/* Gold profile character editor (opened from your profile). Prefix: .me-* */

/* ---------- Profile header: room for the "Your character" button ---------- */
/* Phones: two equal buttons plus up to three square ones on one row. */
.pr-actions:has(> .pr-btn--icon + .pr-btn--icon + .pr-btn--icon) {
  grid-template-columns: 1fr 1fr auto auto auto;
}
@media (max-width: 479.98px) {
  /* With two or more square buttons the wide ones drop their icons, and long words may take two lines. */
  .pr-actions:has(> .pr-btn--icon + .pr-btn--icon) > .pr-btn:not(.pr-btn--icon) {
    padding-inline: 8px;
    line-height: 1.12;
    text-align: center;
    white-space: normal;
  }
  .pr-actions:has(> .pr-btn--icon + .pr-btn--icon) > .pr-btn:not(.pr-btn--icon) > .icon {
    display: none;
  }
  .pr-actions:has(> .pr-btn--icon + .pr-btn--icon + .pr-btn--icon) > .pr-btn:not(.pr-btn--icon) {
    font-size: 12.5px;
  }
}

/* ---------- Sheet layout: preview on top, choices scroll, buttons at the bottom ---------- */
.sheet.me-sheet {
  height: calc(100dvh - var(--safe-t) - 24px);
  overflow: hidden;
}
.me-sheet .sheet__body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}
@media (min-width: 768px) {
  .sheet.me-sheet {
    width: min(780px, 100%);
    height: min(860px, calc(100dvh - 48px));
    max-height: min(860px, calc(100dvh - 48px));
  }
}
.me-loading {
  padding: 32px 20px;
}
.me {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
.me__top {
  flex: none;
  padding: 2px 20px 12px;
  border-bottom: 1px solid var(--line);
}
.me__controls {
  flex: 1 1 auto;
  min-height: 0;
  padding: 16px 20px 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.me__foot {
  flex: none;
  display: grid;
  gap: 10px;
  padding: 12px 20px 14px;
  border-top: 1px solid var(--line);
}
.me__buttons {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 10px;
}
@media (min-width: 768px) {
  .me__top {
    padding: 4px 24px 14px;
  }
  .me__controls {
    padding: 18px 24px 8px;
  }
  .me__cols {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0 28px;
    align-items: start;
  }
  .me__foot {
    padding: 14px 24px 18px;
  }
  .me__buttons {
    display: flex;
    justify-content: flex-end;
  }
  .me__buttons .btn {
    min-width: 128px;
  }
}

/* ---------- The preview: a small copy of the profile header ---------- */
.me-stage {
  position: relative;
  isolation: isolate;
  container-type: inline-size;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    radial-gradient(80% 130% at 12% 0%, rgb(207 32 162 / 0.14), transparent 70%),
    radial-gradient(70% 110% at 100% 0%, rgb(114 22 181 / 0.12), transparent 70%), var(--bg);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.me-stage.is-path,
.me-stage.is-spot {
  cursor: crosshair;
}
.me-stage:focus {
  outline: none;
}
.me-stage:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.me-stage .mascot-layer {
  --mascot-h: 52px;
}
.me-stage.is-off .mascot {
  opacity: 0.4;
}

.me-mock {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    'avatar id'
    'avatar stats'
    'actions actions';
  column-gap: 14px;
  align-items: center;
  padding: 18px 14px 14px;
  pointer-events: none;
}
.me-mock__avatar {
  grid-area: avatar;
  align-self: start;
  padding: 2px 0 0 2px;
}
.me-mock .avatar--lg {
  --s: 62px;
  --ring-w: 2.5px;
  --ring-gap: 3px;
}
.me-mock__id {
  grid-area: id;
  min-width: 0;
  align-self: end;
}
.me-mock__name {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  color: var(--text);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.me-mock__text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.me-mock__name .tick {
  width: 16px;
  height: 16px;
}
.me-mock__crown {
  display: grid;
  flex: none;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--gold);
  color: #3b2606;
}
.me-mock__handle {
  margin: 1px 0 0;
  overflow: hidden;
  color: var(--text-2);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.me-mock__stats {
  grid-area: stats;
  align-self: start;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  margin: 7px 0 0;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 550;
  line-height: 1.3;
  white-space: nowrap;
}
.me-mock__num {
  color: var(--text);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.me-mock__actions {
  grid-area: actions;
  display: grid;
  grid-template-columns: 1fr 1fr 30px;
  gap: 6px;
  margin-top: 14px;
}
.me-mock__actions > span {
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
}

/* A wide preview looks like the profile on a computer: big photo on the left, large name. */
@container (min-width: 540px) {
  .me-mock {
    grid-template-columns: 128px minmax(0, 1fr);
    grid-template-areas:
      'avatar id'
      'avatar actions'
      'avatar stats';
    column-gap: 26px;
    align-items: start;
    padding: 22px 22px 22px;
  }
  .me-mock__avatar {
    justify-self: center;
  }
  .me-mock .avatar--lg {
    --s: 104px;
    --ring-w: 3px;
    --ring-gap: 4px;
  }
  .me-mock__name {
    gap: 8px;
    font-family: var(--font-display);
    font-size: 38px;
    font-weight: 400;
    letter-spacing: -0.01em;
    line-height: 1.05;
  }
  .me-mock__name .tick {
    width: 20px;
    height: 20px;
  }
  .me-mock__handle {
    margin-top: 5px;
    font-size: 13px;
  }
  .me-mock__actions {
    display: flex;
    margin-top: 14px;
  }
  .me-mock__actions > span {
    width: 100px;
    height: 28px;
  }
  .me-mock__actions > .is-square {
    width: 28px;
  }
  .me-mock__stats {
    gap: 4px 22px;
    margin-top: 16px;
    font-size: 14px;
  }
  .me-stage .mascot-layer {
    --mascot-h: 58px;
  }
}

/* Path line, numbered points, the tick's spot and the keyboard marker (under the character). */
.me-line,
.me-dots {
  position: absolute;
  z-index: 3;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.me-line {
  overflow: visible;
}
.me-line polyline {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 5 6;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  opacity: 0.9;
}
.me-dot {
  position: absolute;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border-radius: 50%;
  background: var(--brand);
  color: var(--on-brand);
  box-shadow:
    0 0 0 2px var(--bg),
    0 2px 6px rgb(0 0 0 / 0.35);
  font: 800 11px/1 var(--font-ui);
  font-variant-numeric: tabular-nums;
  animation: me-drop 280ms var(--ease-spring) both;
}
.me-spot {
  position: absolute;
  z-index: 3;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border: 2px dashed var(--blue);
  border-radius: 50%;
  background: color-mix(in srgb, var(--blue) 14%, transparent);
  pointer-events: none;
}
.me-stage.is-spot .me-spot {
  animation: me-pulse 1.4s ease-in-out infinite;
}
.me-cursor {
  position: absolute;
  z-index: 5;
  display: none;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--bg);
  pointer-events: none;
}
.me-cursor::before,
.me-cursor::after {
  content: '';
  position: absolute;
  background: var(--accent);
}
.me-cursor::before {
  left: 50%;
  top: 4px;
  bottom: 4px;
  width: 2px;
  margin-left: -1px;
}
.me-cursor::after {
  top: 50%;
  left: 4px;
  right: 4px;
  height: 2px;
  margin-top: -1px;
}
.me-stage:is(.is-path, .is-spot):focus-visible .me-cursor {
  display: block;
}
.me-off {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 700;
}
.me-off[hidden] {
  display: none;
}

.me-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.me-bar__text {
  display: grid;
  flex: 1 1 auto;
  justify-items: start;
  gap: 5px;
  min-width: 0;
}
.me-bar__hint {
  margin: 0;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 550;
  line-height: 1.35;
}
.me-bar__play {
  --btn-h: 40px;
  flex: none;
  padding: 0 14px;
}

/* ---------- Sections ---------- */
.me-sec,
.me-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.me-sec {
  margin-bottom: 26px;
}
.me-sec__title {
  margin: 0 0 10px;
  padding: 0;
  color: var(--text);
  font-size: 15.5px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.me-sec__hint {
  margin: -6px 0 10px;
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.4;
}
.me-field {
  margin-top: 14px;
}
.me-field__label {
  display: block;
  margin: 0 0 8px;
  padding: 0;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 700;
}
.me-field__foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 2px 0;
  color: var(--text-3);
  font-size: 12px;
}
.me-count {
  flex: none;
  font-variant-numeric: tabular-nums;
}
.me-bubble {
  min-height: 46px;
  padding-block: 11px;
}
[data-when][hidden] {
  display: none;
}

/* Every choice is a real radio button, visually hidden; the label shows the state. */
.me-swatch,
.me-pick,
.me-chip,
.me-card {
  position: relative;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.me-swatch:has(input:focus-visible),
.me-pick:has(input:focus-visible),
.me-chip:has(input:focus-visible),
.me-card:has(input:focus-visible),
.me-switch:has(input:focus-visible) .me-switch__track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Colour swatches */
.me-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.me-swatch {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
}
.me-swatch__dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--c);
  box-shadow:
    inset 0 0 0 1px rgb(0 0 0 / 0.16),
    inset 0 -4px 8px rgb(0 0 0 / 0.1);
  transition: transform var(--dur-1) var(--ease);
}
.me-swatch:hover .me-swatch__dot {
  transform: scale(1.07);
}
.me-swatch:has(input:checked) {
  box-shadow: inset 0 0 0 2px var(--accent);
}
.me-swatch:has(input:checked) .me-swatch__dot {
  transform: scale(0.94);
}

/* Picture choices */
.me-picks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 8px;
}
.me-pick {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 3px;
  min-width: 0;
  padding: 6px 2px 7px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 650;
  text-align: center;
  transition:
    background-color var(--dur-2) var(--ease),
    border-color var(--dur-2) var(--ease);
}
.me-pick:hover {
  background: var(--surface-3);
}
.me-pick__art {
  display: block;
  width: 46px;
  height: 55px;
}
.me-picks--head .me-pick__art {
  height: 44px;
}
.me-picks--upper {
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
}
/* Cropped thumbnails: hide the rest of the drawing (it is allowed to spill out elsewhere). */
.me-picks--head .m-svg,
.me-picks--upper .m-svg {
  overflow: hidden;
}
.me-pick__label {
  max-width: 100%;
  overflow: hidden;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.me-pick:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 13%, var(--surface-2));
  color: var(--text);
}

/* Chips */
.me-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.me-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 650;
  white-space: nowrap;
  transition:
    background-color var(--dur-2) var(--ease),
    border-color var(--dur-2) var(--ease),
    color var(--dur-2) var(--ease);
}
.me-chip:hover {
  background: var(--surface-3);
}
.me-chip:has(input:checked) {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}
.me-chip__emoji {
  font-size: 16px;
  line-height: 1;
}

/* Radio cards */
.me-cards {
  display: grid;
  gap: 8px;
}
.me-card {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 10px 14px 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  transition:
    background-color var(--dur-2) var(--ease),
    border-color var(--dur-2) var(--ease);
}
.me-card:hover {
  background: var(--surface-3);
}
.me-card::after {
  content: '';
  justify-self: end;
  width: 18px;
  height: 18px;
  border: 2px solid var(--line-2);
  border-radius: 50%;
  transition: border var(--dur-2) var(--ease);
}
.me-card__icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-2);
}
.me-card__icon .tick {
  color: var(--blue);
}
.me-card__text {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.me-card__text strong {
  font-size: 14px;
  font-weight: 750;
  line-height: 1.25;
}
.me-card__text small {
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.35;
}
.me-card:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface-2));
}
.me-card:has(input:checked)::after {
  border: 5.5px solid var(--accent);
}
.me-card:has(input:checked) .me-card__icon {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent);
}

/* Tick-box cards (what a free character may play with): a square box instead of the round dot */
.me-card--check::after {
  display: none;
}
.me-card__box {
  display: grid;
  justify-self: end;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 2px solid var(--line-2);
  border-radius: 6px;
  color: var(--bg);
  transition:
    background-color var(--dur-2) var(--ease),
    border-color var(--dur-2) var(--ease);
}
.me-card__box .icon {
  opacity: 0;
  transform: scale(0.6);
  transition:
    opacity var(--dur-1) var(--ease),
    transform var(--dur-2) var(--ease-spring);
}
.me-card--check:has(input:checked) .me-card__box {
  border-color: var(--accent);
  background: var(--accent);
}
.me-card--check:has(input:checked) .me-card__box .icon {
  opacity: 1;
  transform: none;
}
.me-card.is-off {
  cursor: not-allowed;
}
.me-card.is-off:hover {
  background: var(--surface-2);
}
.me-card.is-off > :not(.me-card__text),
.me-card.is-off .me-card__text > :not(.me-card__note) {
  opacity: 0.5;
}
.me-card__note {
  color: var(--text-2);
  font-size: 12px;
  font-weight: 700;
}
/* Toy pictures: letters, numbers, a little gold ring and the blue tick */
.me-toy__text {
  font-family: var(--font-display);
  font-size: 15px;
  line-height: 1;
  letter-spacing: -0.02em;
}
.me-toy__ring {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  /* The photo ring's gold, without its palest shade so it also shows on the light card. */
  background: conic-gradient(from 210deg, var(--gold-2), var(--gold-3), var(--gold-2), var(--gold-3), var(--gold-2));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3.5px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3.5px), #000 calc(100% - 3px));
}
.me-toys__none {
  margin: 8px 2px 0;
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.4;
}
.me-toys__none[hidden] {
  display: none;
}
.me-sec .me-toys__safe {
  margin-top: 10px;
}
.me-toys__safe .me-note__icon {
  background: var(--ok-soft);
  color: var(--ok);
}

/* Path and tick-spot tools */
.me-tools {
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px dashed var(--line-2);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface-2) 60%, transparent);
}
.me-tools__text {
  margin: 0;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.4;
}
.me-tools__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.me-tools__row .btn {
  --btn-h: 40px;
}
.me-tools__count {
  margin-right: auto;
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.me-tools [aria-pressed='true'] {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
}

/* On / off switch */
.me-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 24px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}
.me-switch__text {
  display: grid;
  gap: 2px;
}
.me-switch__text strong {
  font-size: 14.5px;
  font-weight: 750;
}
.me-switch__text small {
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
}
.me-switch__track {
  position: relative;
  flex: none;
  width: 48px;
  height: 28px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--surface-3);
  transition: background-color var(--dur-2) var(--ease);
}
.me-switch__track::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.35);
  transition: transform var(--dur-2) var(--ease-spring);
}
.me-switch input:checked + .me-switch__track {
  border-color: transparent;
  background: var(--accent);
}
.me-switch input:checked + .me-switch__track::before {
  transform: translateX(20px);
}

/* Notes (Gold, verification) */
.me-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 16px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.45;
}
.me-note a {
  color: var(--accent);
  font-weight: 700;
}
.me-note__icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
}
.me-note--gold {
  border-color: color-mix(in srgb, var(--gold-2) 30%, transparent);
  background: color-mix(in srgb, var(--gold-2) 9%, var(--surface-2));
}
.me-note--gold .me-note__icon {
  background: var(--gold);
  color: #3b2606;
}
.me-note__icon--tick .tick {
  color: var(--blue);
}
.me-sec .me-note {
  margin-bottom: 0;
}

/* Save messages: an error, or the Gold invitation */
.me-msg {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-m);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.4;
}
.me-msg[hidden] {
  display: none;
}
.me-msg--error {
  border: 1px solid color-mix(in srgb, var(--danger) 22%, transparent);
  background: var(--danger-soft);
  color: var(--danger);
}
.me-msg--gold {
  flex-wrap: wrap;
  border: 1px solid color-mix(in srgb, var(--gold-2) 35%, transparent);
  background: color-mix(in srgb, var(--gold-2) 11%, var(--surface));
  color: var(--text-2);
  font-weight: 500;
}
.me-msg__icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gold);
  color: #3b2606;
}
.me-msg__text {
  flex: 1 1 200px;
  min-width: 0;
}
.me-msg__text strong {
  color: var(--text);
  font-weight: 750;
}
.me-msg--gold .btn {
  flex: none;
  margin-left: auto;
}

@keyframes me-drop {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.6);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes me-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.15);
  }
}
@media (prefers-reduced-motion: reduce) {
  .me-dot,
  .me-stage.is-spot .me-spot {
    animation: none;
  }
}

/* Set free: letters and numbers get lifted overhead, so leave room above the name. */
.me-stage.is-free .me-mock {
  padding-top: 44px;
  transition: padding-top 200ms var(--ease);
}
