/* ============================= SELECT V2 ==============================
   The character IS the screen. Left: a full-height stage where the chosen
   Astralborn stands LARGE (3D turntable when rigged, painted body
   otherwise) over a lit dais. Right: the roster panel - search, filter
   chips, and a compact grid of the collection. On a phone the stage owns
   the top half and the roster the bottom.
   height:100dvh not inset:0 - iOS sizes fixed inset:0 to the LARGE
   viewport and buries the bottom under Safari's toolbar. */
#select-screen { position: fixed; inset: 0; height: 100dvh; z-index: 10;
  display: grid; grid-template-columns: 1fr clamp(340px, 34vw, 430px);
  color: #e8e2f7; font-family: Georgia, serif; overflow: hidden;
  background:
    radial-gradient(ellipse 90% 70% at 32% 38%, #1c1146 0%, rgba(28, 17, 70, 0) 62%),
    radial-gradient(ellipse at 80% 110%, #140b33 0%, rgba(20, 11, 51, 0) 60%),
    #05030f; }
#select-screen.hidden { display: none; }
#rising-lines { position: absolute; inset: 0; width: 100%; height: 100%;
  z-index: 0; pointer-events: none; }

/* ------------------------------ the stage ---------------------------- */
#sel-stage { position: relative; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end; min-width: 0; min-height: 0;
  padding: 18px clamp(12px, 3vw, 40px) calc(18px + env(safe-area-inset-bottom));
  z-index: 1; }
/* the key light behind the character - a quiet aurora, not a spotlight ad */
#stage-halo { position: absolute; left: 50%; top: 44%;
  width: min(62vh, 86%); aspect-ratio: 1; transform: translate(-50%, -50%);
  background:
    radial-gradient(circle at 50% 46%, rgba(138, 108, 255, .26) 0%,
                    rgba(138, 108, 255, .10) 36%, rgba(138, 108, 255, 0) 66%),
    radial-gradient(circle at 50% 52%, rgba(255, 209, 102, .07) 0%,
                    rgba(255, 209, 102, 0) 55%);
  filter: blur(2px); pointer-events: none;
  animation: halo-breathe 6.5s ease-in-out infinite; }
@keyframes halo-breathe { 0%, 100% { opacity: .85; } 50% { opacity: 1.0; } }
/* the dais: a soft elliptical pool of light the character stands in.
   It sits INSIDE #sel-sprite-stage, centred on the stage's bottom edge -
   that edge IS the feet line (both the painted img and the 3D canvas
   frame feet there), so the character stands in the pool at any size */
#stage-floor { position: absolute; left: 50%;
  bottom: calc(clamp(48px, 9vh, 84px) / -2);
  width: min(46vh, 78%); height: clamp(48px, 9vh, 84px);
  transform: translateX(-50%);
  background:
    radial-gradient(ellipse 50% 46% at 50% 50%, rgba(158, 132, 255, .30) 0%,
                    rgba(158, 132, 255, .10) 52%, rgba(158, 132, 255, 0) 72%),
    radial-gradient(ellipse 66% 58% at 50% 50%, rgba(255, 214, 130, .06) 30%,
                    rgba(255, 214, 130, 0) 70%);
  pointer-events: none; }
#stage-floor::after { content: ''; position: absolute; inset: 14% 8%;
  border-radius: 50%; border: 1px solid rgba(178, 156, 255, .22);
  mask-image: linear-gradient(180deg, transparent 30%, #000 65%);
  -webkit-mask-image: linear-gradient(180deg, transparent 30%, #000 65%); }

/* the character itself - the reason the screen exists */
#sel-sprite-stage { position: relative; flex: 1 1 auto; min-height: 0;
  width: 100%; max-width: min(72vh, 100%);
  display: flex; align-items: flex-end; justify-content: center;
  margin-bottom: clamp(96px, 17vh, 156px); }
#sel-sprite { height: 100%; max-height: min(56vh, 560px); width: auto;
  max-width: 100%; object-fit: contain; transform-origin: bottom center;
  animation: breathe 2.6s ease-in-out infinite;
  filter: drop-shadow(0 14px 22px rgba(0, 0, 0, .6)); }
@keyframes breathe {
  0%, 100% { transform: scaleY(1) scaleX(1); }
  50% { transform: scaleY(1.028) scaleX(0.988) translateY(-2px); }
}
/* character swap: a soft rise-in, so browsing feels like presenting */
#sel-sprite.swap-in { animation: swap-in .34s cubic-bezier(0.22, 1, 0.36, 1),
  breathe 2.6s ease-in-out .34s infinite; }
@keyframes swap-in {
  0% { opacity: 0; transform: translateY(14px) scale(.985); filter: brightness(1.6) drop-shadow(0 14px 22px rgba(0,0,0,.6)); }
  100% { opacity: 1; transform: none; }
}

/* the plaque: name large, its facts beneath, traits folded */
#stage-plaque { position: absolute; left: clamp(14px, 3vw, 44px);
  bottom: clamp(88px, 15vh, 132px); max-width: min(340px, 44%);
  text-align: left; z-index: 2; pointer-events: none; }
#stage-plaque > * { pointer-events: auto; }
#sel-name { font-size: clamp(22px, 3.4vw, 38px); line-height: 1.08;
  letter-spacing: 1px;
  background: linear-gradient(180deg, #fff8e9 18%, #ffd166 58%, #c8951f 95%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .75)); }
#sel-name::after { content: ''; display: block; margin-top: 8px;
  width: 130px; height: 1px;
  background: linear-gradient(90deg, #6a5730, rgba(106, 87, 48, 0)); }
#sel-rarity { margin-top: 7px; font-size: clamp(11px, 1.2vw, 13px);
  color: #ffd166; letter-spacing: .6px; }
#sel-sub { margin-top: 4px; font-size: 11.5px; color: #a99ed4; line-height: 1.4; }
#sel-sub em { display: block; font-size: 10.5px; color: #6f639c; font-style: italic; }
#sel-sub:empty { display: none; }
#sel-traits-fold { margin-top: 8px; }
#sel-traits-fold summary { font-size: 11.5px; color: #8f83bd; cursor: pointer;
  letter-spacing: 1.2px; text-transform: uppercase; list-style: none; }
#sel-traits-fold summary::before { content: '❖ '; color: #6a5acd; font-size: 9px; }
#sel-traits-fold summary:hover, #sel-traits-fold[open] summary { color: #cabffa; }
#sel-traits { list-style: none; margin: 8px 0 0; padding: 10px 12px;
  font-size: 12px; color: #a99ed4; max-width: 300px;
  max-height: min(30vh, 240px); overflow-y: auto; scrollbar-width: thin;
  background: rgba(10, 6, 26, .78); border: 1px solid #372b63;
  border-radius: 12px; backdrop-filter: blur(6px); }
#sel-traits li { display: flex; align-items: baseline; gap: 4px;
  overflow-wrap: break-word; padding: 1.5px 0; }
.trait-pct { margin-left: auto; padding-left: 8px; flex: none;
  font-variant-numeric: tabular-nums; font-size: 11px; letter-spacing: .3px; }

/* actions: Play is the point of the page and dresses like it */
#stage-actions { position: relative; z-index: 2; display: flex;
  flex-direction: column; align-items: center; gap: 7px; }
#sel-play { cursor: pointer; font-family: Georgia, serif;
  padding: 15px clamp(44px, 6vw, 76px); border-radius: 16px; position: relative;
  border: 2px solid #cfa54e;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 214, 130, .28), transparent 62%),
    linear-gradient(180deg, rgba(64, 44, 18, .96), rgba(28, 18, 8, .97));
  box-shadow: 0 0 22px rgba(212, 165, 78, .35), 0 6px 20px rgba(0, 0, 0, .55),
              inset 0 1px 0 rgba(255, 230, 170, .35);
  animation: play-breathe 3.2s ease-in-out infinite; }
#play-label { font-size: 18px; letter-spacing: 3px; text-transform: uppercase;
  background: linear-gradient(180deg, #fff8e9 15%, #ffd166 55%, #c8951f 92%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.8)); }
#sel-play::after { content: ''; position: absolute; inset: 4px; border-radius: 12px;
  border: 1px solid rgba(255, 214, 130, .22); pointer-events: none; }
#sel-play:hover { filter: brightness(1.12); }
#sel-play:active { transform: scale(.97); }
@keyframes play-breathe {
  0%, 100% { box-shadow: 0 0 18px rgba(212, 165, 78, .28), 0 6px 20px rgba(0,0,0,.55),
                         inset 0 1px 0 rgba(255, 230, 170, .35); }
  50% { box-shadow: 0 0 34px rgba(255, 200, 110, .55), 0 6px 20px rgba(0,0,0,.55),
                    inset 0 1px 0 rgba(255, 230, 170, .5); }
}
#sel-new { background: none; border: none; padding: 2px 6px; cursor: pointer;
  font-family: Georgia, serif; font-size: 11px; color: #8f83bd;
  letter-spacing: 1px; text-decoration: underline; text-underline-offset: 3px; }
#sel-new:hover { color: #d79b8a; }
#sel-new[hidden] { display: none; }
#free-banner { position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  margin: 0; padding: 5px 16px; color: #7fe39b; font-size: 11px; letter-spacing: 3px;
  text-transform: uppercase; white-space: nowrap;
  background: rgba(12, 26, 16, .6); border: 1px solid rgba(99, 176, 119, .5);
  border-radius: 999px; backdrop-filter: blur(4px); }
#free-banner[hidden] { display: none; }

/* ---------------------------- the roster ------------------------------ */
#sel-panel { position: relative; z-index: 2; display: flex; flex-direction: column;
  min-height: 0; min-width: 0; box-sizing: border-box;
  padding: clamp(12px, 2.4vh, 22px) clamp(12px, 1.6vw, 22px)
           calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(13, 8, 32, .86), rgba(7, 4, 18, .92));
  border-left: 1px solid rgba(75, 61, 122, .55);
  box-shadow: -18px 0 44px rgba(3, 1, 10, .55);
  backdrop-filter: blur(10px); }
#panel-head { display: flex; align-items: center; gap: 12px; flex: none;
  padding: 0 2px 12px; }
#title-emblem { width: 44px; height: 44px; border-radius: 22%; flex: none;
  box-shadow: 0 0 18px rgba(122, 160, 255, .45), 0 0 40px rgba(75, 43, 214, .3); }
.panel-title-wrap { min-width: 0; }
#panel-head h1 { margin: 0; font-size: clamp(17px, 1.7vw, 21px);
  letter-spacing: 6px; text-indent: 2px;
  background: linear-gradient(180deg, #fff8e9 20%, #ffd166 55%, #b8860b 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 12px rgba(255, 209, 102, .3)); }
.tagline { margin: 2px 0 0; color: #8f83bd; font-style: italic;
  font-size: 11px; line-height: 1.3; }

/* search / random / sort on one row */
#roster-tools { flex: none; display: flex; flex-direction: column; gap: 8px;
  padding-bottom: 10px; border-bottom: 1px solid rgba(55, 43, 99, .6); }
#roster-row { display: flex; gap: 7px; align-items: stretch; }
#roster-search { flex: 1; min-width: 0; background: rgba(8, 5, 20, .9);
  color: #e8e2f7; border: 1px solid #372b63; border-radius: 11px;
  padding: 9px 13px; font-family: Georgia, serif; font-size: 14px; }
#roster-search:focus { outline: none; border-color: #8a6cff;
  box-shadow: 0 0 12px rgba(138, 108, 255, .3); }
#roster-search::placeholder { color: #5b5185; font-style: italic; }
#roster-search::-webkit-search-cancel-button { -webkit-appearance: none; }
#sel-random, #sel-sort, #about-mini { flex: none; display: inline-flex; align-items: center;
  justify-content: center; width: 40px; border-radius: 11px; cursor: pointer;
  background: rgba(20, 12, 44, .6); color: #cabffa; border: 1px solid #4b3d7a;
  font-family: Georgia, serif; font-size: 15px;
  transition: border-color .15s ease, color .15s ease, background .15s ease; }
#sel-random:hover, #sel-sort:hover, #about-mini:hover { background: rgba(44, 34, 80, .8);
  border-color: #cfa54e; color: #fff; }
.ico-die { width: 16px; height: 16px; flex: none; }
.ico-die rect { fill: none; stroke: currentColor; stroke-width: 1.8; }
.ico-die circle { fill: currentColor; }

/* filter chips: pills, one active per group, gold when live */
#roster-filters { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.chip { border: 1px solid #372b63; background: rgba(14, 9, 32, .7);
  color: #a99ed4; font-family: Georgia, serif; font-size: 11.5px;
  letter-spacing: .6px; padding: 5px 11px; border-radius: 999px; cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background .15s ease; }
.chip:hover { border-color: #6a5acd; color: #e0d8ff; }
.chip.on { border-color: #cfa54e; color: #ffd98a;
  background: rgba(207, 165, 78, .13);
  box-shadow: 0 0 9px rgba(212, 169, 79, .22); }
.chip-free.on { border-color: #63b077; color: #8fe0a4;
  background: rgba(99, 176, 119, .12);
  box-shadow: 0 0 9px rgba(99, 176, 119, .25); }
/* Honorary: the tribute shelf. Its own colour so it never reads as a rarity
   tier - it sits in the same bar as Legendary and must not be mistaken for
   one. */
.chip-hon.on { border-color: #b98fe0; color: #dcc4ff;
  background: rgba(150, 110, 210, .14);
  box-shadow: 0 0 9px rgba(150, 110, 210, .26); }
.rt-hon .rt-n { color: #dcc4ff; font-size: 9px; letter-spacing: .01em; }
.rt-hon { outline: 1px solid rgba(150, 110, 210, .45); outline-offset: -1px; }
.chip-sep { width: 1px; height: 16px; background: rgba(75, 61, 122, .6);
  margin: 0 3px; }

/* the grid: the whole collection at a glance, thumb-sized */
#roster-grid { flex: 1 1 auto; min-height: 0; overflow-y: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  grid-auto-rows: 100px; gap: 7px; padding: 12px 2px 12px; align-content: start;
  scrollbar-width: thin; scrollbar-color: #372b63 transparent;
  overscroll-behavior: contain; }
.rt { position: relative; border-radius: 11px;
  overflow: hidden; background: #140d2a; border: 1px solid #372b63;
  cursor: pointer; padding: 0;
  transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease,
              opacity .2s ease; }
.rt:hover { border-color: #8a6cff; transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .5); }
.rt img { position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block; user-select: none; -webkit-user-drag: none; }
.rt .rt-n { position: absolute; left: 0; right: 0; bottom: 0;
  padding: 12px 6px 4px; font-family: Georgia, serif;
  font-size: 10.5px; letter-spacing: .4px; color: #cfc6f2; text-align: left;
  background: linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,.78));
  pointer-events: none; }
.rt.sel { border-color: #ffd166;
  box-shadow: 0 0 0 1px #ffd166, 0 0 16px rgba(255, 209, 102, .45); }
/* tile height comes from the TRACK (grid-auto-rows above): a <button> grid
   item refuses to derive its own height from aspect-ratio or padded
   children in Chrome, so the row is simply told how tall it is */
.rt.sel { box-shadow: 0 0 0 1px #ffd166, 0 0 16px rgba(255, 209, 102, .45),
  inset 0 0 14px rgba(255, 209, 102, .18); }
.rt.hide { display: none; }
/* rarity: the tile's FRAME wears the tier colour, the same language the
   old cards spoke - the top-edge hairline read as a rendering glitch
   ("thick colored line inside the grid", Alan) */
.rt[data-tier] { border-color: color-mix(in srgb, var(--tier) 55%, #372b63); }
.rt[data-tier]:hover { border-color: var(--tier); }
.rt[data-tier="Legendary"] { border-color: var(--tier);
  box-shadow: 0 0 8px color-mix(in srgb, var(--tier) 40%, transparent); }
.rt.rt-free { border-color: rgba(99, 176, 119, .75); }
.rt.rt-free .rt-n { color: #8fe0a4; letter-spacing: 1.4px; font-size: 9px;
  text-transform: uppercase; }
.rt.rt-free.sel { border-color: #8fe0a4;
  box-shadow: 0 0 0 1px #8fe0a4, 0 0 16px rgba(126, 196, 140, .5); }
/* saved-run marker: a small gold flame dot, top-right */
/* saved-run marker WEARS THE LEVEL - a bare dot with a tooltip said
   nothing on a phone (Alan: "i cant see what level my characters are") */
.rt .rt-save { position: absolute; top: 4px; right: 4px; z-index: 1;
  border-radius: 999px; padding: 2px 5px;
  background: rgba(20, 12, 44, .88); color: #ffd98a; font-size: 9px;
  line-height: 1; font-weight: 700; letter-spacing: .4px;
  border: 1px solid #cfa54e; box-shadow: 0 0 8px rgba(255, 209, 102, .35);
  pointer-events: none; }
#roster-empty { grid-column: 1 / -1; padding: 28px 8px; text-align: center;
  color: #6f639c; font-size: 12.5px; font-style: italic; }

#panel-foot { flex: none; padding-top: 8px;
  border-top: 1px solid rgba(55, 43, 99, .6); }
#sel-note { color: #6f639c; font-size: 11px; text-align: center;
  display: flex; gap: 10px; align-items: baseline; justify-content: center;
  flex-wrap: wrap; margin: 0; }
#about-btn { background: none; border: none; padding: 0; cursor: pointer;
  font-family: Georgia, serif; font-size: 11px; color: #8f83bd;
  text-decoration: underline; text-underline-offset: 3px; }
#about-btn:hover { color: #c9bdf5; }
#sel-version { position: absolute; bottom: 6px; left: 14px; margin: 0;
  color: #4d4278; font-size: 10px; letter-spacing: 1px; z-index: 2; }
#sel-id-wrap[hidden] { display: none; }

/* --------------------------- phones ----------------------------------- */
@media (max-width: 820px) {
  #select-screen { grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 47dvh) minmax(0, 1fr); }
  #sel-stage { padding: 10px 14px 12px; }
  #sel-sprite-stage { margin-bottom: 64px; }
  #sel-sprite { max-height: 34dvh; }
  #stage-halo { top: 40%; width: min(40dvh, 92%); }
  #stage-floor { bottom: -20px; height: 40px; width: min(34dvh, 84%); }
  #stage-plaque { left: 12px; bottom: 8px; max-width: 60%; }
  /* a 14px summary is not a thumb target - give TRAITS a real tap area */
  #sel-traits-fold summary { padding: 9px 10px 9px 0; font-size: 12px; }
  /* the open traits sheet must beat the roster panel: the stage is a lower
     stacking context (z1 < z2), so position:fixed alone left the sheet
     BURIED under the grid - "nothing happens when I tap it" */
  #sel-stage:has(#sel-traits-fold[open]) { z-index: 40; }
  #sel-name { font-size: 20px; }
  #sel-name::after { margin-top: 5px; width: 90px; }
  #sel-rarity { font-size: 10.5px; margin-top: 4px; }
  #sel-sub { display: none; }             /* the about panel carries it */
  #sel-traits { position: fixed; left: 12px; right: 12px; bottom: 12px;
    max-width: none; max-height: 46dvh; z-index: 30; }
  #stage-actions { position: absolute; right: 12px; bottom: 10px; z-index: 3;
    align-items: flex-end; }
  #sel-play { padding: 12px 28px; }
  #play-label { font-size: 14px; letter-spacing: 2px; }
  #free-banner { top: 8px; font-size: 9.5px; padding: 4px 12px; }
  #sel-panel { border-left: none; border-top: 1px solid rgba(75, 61, 122, .55);
    box-shadow: 0 -14px 34px rgba(3, 1, 10, .5); padding: 10px 12px 8px; }
  #panel-head { display: none; }          /* the stage carries the brand */
  #roster-grid { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    grid-auto-rows: 84px; gap: 6px; padding-top: 9px; }
  #roster-filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  #roster-filters::-webkit-scrollbar { display: none; }
  .chip { flex: none; white-space: nowrap; }
  #sel-version { left: auto; right: 10px; bottom: auto; top: 8px; }
  #panel-foot { display: none; }          /* about lives behind the ? chip */
}

/* very short landscape phones: stage and roster side by side again */
@media (max-width: 940px) and (max-height: 450px) {
  #select-screen { grid-template-columns: 1fr minmax(300px, 44vw);
    grid-template-rows: 1fr; }
  #sel-panel { border-top: none; border-left: 1px solid rgba(75, 61, 122, .55); }
  #sel-sprite { max-height: 62dvh; }
  #sel-sprite-stage { margin-bottom: 48px; }
  #stage-floor { bottom: 40px; }
  #stage-plaque { bottom: 6px; }
  #stage-actions { right: 10px; bottom: 8px; }
}

/* =============== unchanged surfaces below this line =================== */

/* Aura = Sparkles, mirrored from the in-game particles so the trait reads the
   same on the select screen as it does in the world. */
.sel-spark { position: absolute; width: 11px; height: 11px;
  background:
    radial-gradient(circle, rgba(255,252,235,.55) 0%, rgba(255,240,200,.10) 38%,
                    rgba(255,230,170,0) 70%),
    linear-gradient(to right, rgba(255,250,225,0) 0%, rgba(255,255,245,.9) 50%,
                    rgba(255,250,225,0) 100%),
    linear-gradient(to bottom, rgba(255,250,225,0) 0%, rgba(255,255,245,.9) 50%,
                    rgba(255,250,225,0) 100%);
  background-size: 100% 100%, 100% 1.5px, 1.5px 100%;
  background-position: center, center, center;
  background-repeat: no-repeat;
  pointer-events: none; opacity: 0;
  animation: sel-spark-rise var(--dur) ease-in-out var(--delay) infinite; }
@keyframes sel-spark-rise {
  0%   { transform: translate(0, 0) scale(.35) rotate(0deg);        opacity: 0; }
  18%  { opacity: .9; }
  42%  { opacity: .25; }
  64%  { opacity: .85; }
  100% { transform: translate(var(--dx), -86px) scale(.9) rotate(45deg); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .sel-spark { animation: none; opacity: .7; } }

/* Aura = Petals. Falls and tumbles, where .sel-spark rises and twinkles. */
.sel-petal { position: absolute; width: 5px; height: 6px;
  border-radius: 60% 60% 55% 55% / 75% 75% 40% 40%;
  background: linear-gradient(160deg, rgba(255,214,232,.95) 0%,
                              rgba(255,160,198,.95) 60%, rgba(238,120,172,.85) 100%);
  pointer-events: none; opacity: 0;
  animation: sel-petal-fall var(--dur) linear var(--delay) infinite; }
@keyframes sel-petal-fall {
  0%   { transform: translate(0, -14px) rotate(0deg) scale(.85);   opacity: 0; }
  12%  { opacity: .95; }
  50%  { transform: translate(calc(var(--dx) * .6), 42px) rotate(180deg) scale(1); }
  85%  { opacity: .8; }
  100% { transform: translate(var(--dx), 96px) rotate(392deg) scale(.9); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .sel-petal { animation: none; opacity: .75; } }

/* canvas auras (Lightning / Flames / Constellation / Divine Glow) - same
   geometry as the 3D renderer, drawn by select.js */
.sel-fx { position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(ellipse 88% 92% at 50% 52%, #000 58%, transparent 100%);
  mask-image: radial-gradient(ellipse 88% 92% at 50% 52%, #000 58%, transparent 100%); }
@media (prefers-reduced-motion: reduce) { .sel-fx { opacity: .6; } }

/* --- the one explanatory surface on the select screen --- */
#about-panel { position: fixed; inset: 0; z-index: 20; display: flex;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(4, 2, 12, .72); overflow-y: auto; }
#about-panel[hidden] { display: none; }
.about-card { position: relative; max-width: 560px; width: 100%;
  background: linear-gradient(160deg, rgba(18, 10, 40, .98), rgba(8, 5, 22, .98));
  border: 1px solid #4b3d7a; border-radius: 16px; padding: 26px 30px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .6); max-height: 88vh; overflow-y: auto; }
#about-panel h2 { margin: 0 0 14px; font-size: 22px; letter-spacing: 5px;
  text-transform: uppercase; color: #ffd166; text-align: center; }
#about-panel p { margin: 0 0 12px; font-size: 13.5px; line-height: 1.62;
  color: #b7aede; }
#about-panel b { color: #e8e2f7; font-weight: normal; }
#about-panel .about-plan { border-top: 1px solid #322860; padding-top: 12px;
  margin-top: 4px; color: #8f83bd; font-size: 12.5px; }
#about-panel .about-warn { color: #d7b6b6; font-size: 12.5px;
  background: rgba(74, 22, 28, .35); border: 1px solid #6d2f38;
  border-radius: 10px; padding: 10px 13px; margin-bottom: 0; }
#about-panel .about-warn b { color: #ffd9d9; }
#about-close { position: absolute; top: 10px; right: 14px; background: none;
  border: none; color: #8f83bd; font-size: 26px; line-height: 1; cursor: pointer; }
#about-close:hover { color: #e8e2f7; }
#about-panel { text-align: left; }

/* --- step two: who you are, and where --------------------------------- */
#entry { display: flex; flex-direction: column; gap: 12px;
  width: 100%; box-sizing: border-box; }
#entry-modal { position: fixed; inset: 0; z-index: 20; display: flex;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(4, 2, 12, .72); }
#entry-modal[hidden] { display: none; }
.entry-card { position: relative; width: min(390px, 92vw);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  border: 18px solid transparent;
  border-image: url('../assets/ui/panel_frame.png') 100 stretch;
  background: linear-gradient(160deg, rgba(16, 9, 36, .97), rgba(7, 4, 20, .97)) padding-box;
  padding: 14px 16px 14px; box-shadow: 0 10px 40px rgba(0, 0, 0, .6); }
#entry-close { position: absolute; top: 10px; right: 14px; background: none;
  border: none; color: #8f83bd; font-size: 26px; line-height: 1; cursor: pointer; }
#entry-close:hover { color: #e8e2f7; }
#entry-thumb { width: 92px; height: 92px; border-radius: 50%; object-fit: cover;
  border: 2px solid #cfa54e;
  box-shadow: 0 0 18px rgba(212, 169, 79, .45), 0 0 44px rgba(138, 108, 255, .25);
  margin-top: -58px; }
#entry-charname { font-size: 17px; color: #ffd166; letter-spacing: 1px; }
#entry-charname::after { content: ''; display: block; margin: 8px auto 0;
  width: 120px; height: 1px;
  background: linear-gradient(90deg, transparent, #6a5730, transparent); }

#world-list { display: flex; flex-direction: column; gap: 5px; width: 100%;
  max-height: 194px; overflow-y: auto; scrollbar-width: thin; }
.world-row { display: grid; grid-template-columns: 1fr auto; column-gap: 10px;
  row-gap: 3px; align-items: baseline; padding: 7px 11px 8px;
  background: rgba(8, 5, 20, .85); border: 1px solid #372b63; border-radius: 10px;
  cursor: pointer; transition: border-color .15s ease, box-shadow .15s ease; }
.world-row:hover { border-color: #6a5acd; }
.world-row.sel { border-color: #cfa54e;
  box-shadow: 0 0 10px rgba(212, 169, 79, .3), inset 0 0 14px rgba(212, 169, 79, .07); }
.world-row.sel .w-name { color: #ffd166; }
.world-row.full { opacity: .45; cursor: not-allowed; }
.w-name { font-size: 14px; color: #e8e2f7; letter-spacing: .5px; }
.w-pop { font-size: 11px; color: #8f83bd; font-variant-numeric: tabular-nums; }
.w-bar { grid-column: 1 / -1; height: 3px; border-radius: 2px;
  background: rgba(75, 61, 122, .35); overflow: hidden; }
.w-bar i { display: block; height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, #8a6cff, #ffd166); }
#entry-go { margin-top: 4px; width: 100%; padding: 12px 20px; cursor: pointer;
  border-radius: 12px; border: 1.5px solid #cfa54e; font-family: Georgia, serif;
  background: linear-gradient(180deg, rgba(46, 30, 8, .9), rgba(24, 14, 4, .95));
  color: #ffd166; font-size: 15px; letter-spacing: 2px; text-transform: uppercase;
  box-shadow: 0 0 14px rgba(212, 169, 79, .25); }
#entry-go:hover { box-shadow: 0 0 22px rgba(212, 169, 79, .45); }
#entry-go:disabled { opacity: .45; cursor: not-allowed; filter: grayscale(.5); }
#alias-wrap, #world-wrap { display: flex; flex-direction: column; gap: 4px;
  flex: 1 1 0; min-width: 150px; font-family: Georgia, serif; }
#alias-wrap { flex: 1 1 100%; align-items: center; text-align: center;
  margin-bottom: 2px; }
#alias-wrap .entry-label { padding-left: 0; }
#alias-wrap #alias-input { text-align: center; max-width: 320px;
  font-size: 17px; letter-spacing: .5px; }
#world-wrap { flex: 1 1 100%; }
.entry-label { font-size: 9.5px; letter-spacing: 2.5px; text-transform: uppercase;
  color: #8f83bd; padding-left: 2px; }
#alias-input, #world-select {
  background: rgba(8, 5, 20, .92); color: #e8e2f7;
  border: 1px solid #4b3d7a; border-radius: 10px; padding: 9px 12px;
  font-family: Georgia, serif; font-size: 15px; width: 100%;
  box-sizing: border-box; }
#alias-input:focus, #world-select:focus { outline: none; border-color: #8a6cff;
  box-shadow: 0 0 12px rgba(138, 108, 255, .35); }
#alias-input::placeholder { color: #5b5185; font-style: italic; }
#alias-wrap.missing #alias-input { border-color: #cfa54e;
  box-shadow: 0 0 12px rgba(207, 165, 78, .25); }
#alias-wrap.missing .entry-label::after { content: ' — required'; color: #cfa54e; }

@media (max-width: 540px) {
  #entry { gap: 8px; }
  #alias-input, #world-select { padding: 8px 10px; font-size: 14px; }
  .entry-label { font-size: 9px; letter-spacing: 2px; }
}

/* --- device sync ------------------------------------------------------ */
#sync-wrap { width: 100%; font-family: Georgia, serif; margin-top: 2px; }
#sync-wrap summary { font-size: 11px; letter-spacing: 1.5px; color: #8f83bd;
  text-transform: uppercase; cursor: pointer; text-align: center; }
#sync-wrap summary:hover { color: #c9bdf5; }
.sync-note { margin: 8px 0 6px; font-size: 11.5px; line-height: 1.5; color: #8f83bd; }
.sync-row { display: flex; gap: 6px; margin-top: 6px; align-items: stretch; }
#sync-code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; background: rgba(8, 5, 20, .9); border: 1px solid #372b63;
  border-radius: 8px; padding: 7px 9px; font-size: 11px; color: #b7aede;
  font-family: ui-monospace, monospace; }
#sync-input { flex: 1; min-width: 0; background: rgba(8, 5, 20, .9);
  border: 1px solid #372b63; border-radius: 8px; padding: 7px 9px;
  font-size: 11px; color: #e8e2f7; font-family: ui-monospace, monospace; }
#sync-input:focus { outline: none; border-color: #8a6cff; }
.sync-row button { flex: none; padding: 6px 13px; border-radius: 8px;
  border: 1px solid #4b3d7a; background: rgba(22, 14, 44, .9); color: #b7aede;
  font-family: Georgia, serif; font-size: 12px; cursor: pointer; }
.sync-row button:hover { border-color: #8a6cff; color: #e8e2f7; }

/* --- wallet sign-in ---------------------------------------------------- */
#wallet-row { width: 100%; display: flex; flex-direction: column; gap: 4px;
  align-items: center; }
#wallet-btn { width: 100%; padding: 9px 14px; border-radius: 10px; cursor: pointer;
  border: 1px solid #4b3d7a; background: rgba(22, 14, 44, .9); color: #c9bdf5;
  font-family: Georgia, serif; font-size: 13px; letter-spacing: 1px; }
#wallet-btn:hover { border-color: #8a6cff; color: #e8e2f7;
  box-shadow: 0 0 12px rgba(138, 108, 255, .25); }
#wallet-note { font-size: 10.5px; color: #8f83bd; min-height: 13px;
  font-family: Georgia, serif; }
#wallet-note.linked { color: #7fe39b; }
#wallet-list { width: 100%; display: flex; flex-direction: column; gap: 5px; }
#wallet-list[hidden] { display: none; }
#wallet-list button { width: 100%; padding: 8px 12px; border-radius: 9px;
  cursor: pointer; border: 1px solid #372b63; background: rgba(8, 5, 20, .9);
  color: #b7aede; font-family: Georgia, serif; font-size: 12.5px; text-align: left; }
#wallet-list button:hover { border-color: #8a6cff; color: #e8e2f7; }
#wallet-out { background: none; border: none; padding: 0; cursor: pointer;
  font-family: Georgia, serif; font-size: 11px; color: #8f83bd;
  text-decoration: underline; text-underline-offset: 3px; }
#wallet-out:hover { color: #d79b8a; }
#wallet-out[hidden] { display: none; }
.wallet-deep { display: block; padding: 8px 12px; margin: 3px 0; border-radius: 9px;
  background: rgba(138, 108, 255, .14); border: 1px solid #4b3d7a;
  color: #e8e2f7; font-family: Georgia, serif; font-size: 14px;
  text-decoration: none; text-align: center; }
.wallet-deep:hover { background: rgba(138, 108, 255, .26); }

/* alias + re-roll */
.alias-row { display: flex; gap: 6px; align-items: stretch; width: 100%; }
.alias-row #alias-input { flex: 1; min-width: 0; }
#alias-roll { flex: 0 0 auto; padding: 0 10px; cursor: pointer; font-size: 15px;
  background: rgba(138, 108, 255, .16); border: 1px solid #4b3d7a; border-radius: 8px;
  color: #c9c0ec; line-height: 1; }
#alias-roll:hover { background: rgba(138, 108, 255, .32); color: #fff; }

/* --- sort menu --------------------------------------------------------- */
/* display:flex + stretch, NOT inline-block: as a flex item the wrapper
   stretches to the row, but an inline-block wrapper let the button inside
   keep its natural height - the one short button in the row (Alan) */
#sort-wrap { position: relative; display: flex; align-items: stretch; }
#sort-wrap > #sel-sort { height: 100%; }
#sort-menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 40;
  min-width: 210px; padding: 5px; border-radius: 12px;
  max-height: min(60vh, 340px); overflow-y: auto;
  background: rgba(12, 8, 28, .97); border: 1px solid #4b3d7a;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .6); }
#sort-menu.up { top: auto; bottom: calc(100% + 6px);
  box-shadow: 0 -10px 28px rgba(0, 0, 0, .6); }
.sort-item { display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  width: 100%; padding: 7px 10px; border: 0; border-radius: 8px; cursor: pointer;
  background: transparent; color: #e8e2f7; font-family: Georgia, serif;
  font-size: 14px; text-align: left; }
.sort-item small { color: #8f83bd; font-size: 11px; letter-spacing: .2px; }
.sort-item:hover { background: rgba(138, 108, 255, .16); }
.sort-item.on { background: rgba(207, 165, 78, .14); color: #ffd98a; }
.sort-item.on small { color: #c8a56a; }
