/* The game's stylesheet (hand-owned; em-ui adds its own rules from rust/crates/ui/src/own.css). Asset paths are
   ../assets/ (the dev server serves the checkout's assets there). */
  /* ---------- type (assets/fonts, SIL OFL — CREDITS.md there) ----------
     EM Rune is the carved display face: Metamorphous for Latin, Kurale for
     Cyrillic (Metamorphous has none), split by unicode-range under ONE family
     so a Ukrainian heading never falls to Georgia mid-word. Both halves carry
     identical descriptors — a face with a different weight range is matched
     separately and its range silently never loads. Runic caps are unreadable
     at stat sizes, so every number, stat and sentence is EM Text (Vollkorn). */
  @font-face { font-family: 'EM Rune'; src: url('../assets/fonts/metamorphous-latin.8a972389af.woff2') format('woff2');
    font-display: swap; unicode-range: U+0020-007E, U+00A0-017F, U+0192, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2190-2193, U+2212; }
  @font-face { font-family: 'EM Rune'; src: url('../assets/fonts/kurale-cyrillic.fd18f6c547.woff2') format('woff2');
    font-display: swap; unicode-range: U+0400-045F, U+0490-0491, U+2116; }
  @font-face { font-family: 'EM Text'; src: url('../assets/fonts/vollkorn-vf.071ab4999c.woff2') format('woff2');
    font-display: swap; font-weight: 400 900; font-style: normal; }
  @font-face { font-family: 'EM Text'; src: url('../assets/fonts/vollkorn-italic-vf.0564e9a1fa.woff2') format('woff2');
    font-display: swap; font-weight: 400 900; font-style: italic; }

  /* ---------- the palette: every colour the chrome wears is one of these ----------
     Near-black ground, white text and light, two accents: WITCHLIGHT green (where
     you are: section names, active tabs, selection, focus) and BLOOD red (what you
     commit to and what hurts: calls to action, danger, life). Rarity colours are
     not here: em-ui publishes the RARITY table's as --r-<rarity> at mount. */
  :root {
    /* THE VISIBLE HEIGHT: em-ui sets --vvh from the visual viewport (windows.rs fit_view: a phone's URL bar, toolbars
       and keyboard shrink it; 100vh is the LARGEST viewport and runs under them). Every window is capped by
       --win-fit and scrolls inside it under its header. */
    --vvh: 100dvh;
    /* THE SAFE AREA, read here once (every edge in the chrome is var(--safe-*), never env() itself). --env-* are the
       insets as the device reports them; the bottom one is measured from the SCREEN's bottom. iOS 26 lays a home-screen
       app installed under the translucent status bar (index.html now asks for a solid one; an old install keeps its
       own) under the bar but a status bar short of the screen, and paints nothing below it (Valy 11-16's shots: a
       layer sized to the screen is cut there): em-ui sets --app-short to that shortfall (windows.rs fit_view), and
       the home indicator's inset is spent on the strip the page never reaches. A page laid out below the bar (its top
       inset 0) ends at the screen's foot and keeps the whole inset. Never size a layer past the viewport. */
    --env-t: env(safe-area-inset-top, 0px);
    --env-r: env(safe-area-inset-right, 0px);
    --env-b: env(safe-area-inset-bottom, 0px);
    --env-l: env(safe-area-inset-left, 0px);
    --safe-t: var(--env-t);
    --safe-r: var(--env-r);
    --safe-b: max(0px, var(--env-b) - min(var(--app-short, 0px), var(--env-t)));
    --safe-l: var(--env-l);
    --win-fit: calc(var(--vvh) - 16px - var(--safe-t) - var(--safe-b));
    --font-rune: 'EM Rune', Georgia, 'Palatino Linotype', serif;
    --font-text: 'EM Text', Georgia, 'Palatino Linotype', serif;

    --bg: #040607;
    --well: #070a0b;        /* sunken: slots, cells */
    --well-2: #0a0e0f;      /* inputs */
    --raise: #0f1415;
    --raise-2: #161d1e;
    --raise-3: #1f2829;
    --glass-rgb: 7, 10, 11; /* translucent panels over the world */
    --light-rgb: 255, 255, 255;

    --line-faint: #141b1c;
    --line: #1f2a29;
    --line-strong: #2f3e3b;
    --line-hot: #58c48f;

    --text-hi: #ffffff;
    --text: #e3e9e6;
    --text-2: #b3bfbb;      /* secondary copy: 9:1 on the panel head, 10:1 below */
    --text-3: #8d9995;      /* meta labels: 5.8:1 */
    --text-4: #7d8985;      /* hints, never below 10px: 4.7:1 */

    --witch: #6fd6a0;
    --witch-rgb: 111, 214, 160;
    --mint-rgb: 244, 212, 122;
    --mint-hi: #fff1c2;
    --mint-mid: #e2bb5c;
    --witch-hi: #c4f7db;
    --witch-hi-rgb: 196, 247, 219;
    --witch-mid: #4fb283;
    --witch-lo: #2d7a56;
    --witch-deep: #1b4a35;
    --witch-ink: #03140b;
    --witch-wash: #0c2218;

    --blood: #d83a33;
    --blood-rgb: 216, 58, 51;
    --blood-hi: #ff6b61;
    --blood-soft: #ef7f74;
    --blood-pale: #ffb4ab;
    --blood-deep: #8e1f1b;
    --blood-lo: #5c0f0c;
    --blood-line: #7c2a25;
    --cta-bg: linear-gradient(180deg, #a3241f, #5a0f0c);
    --cta-bg-hot: linear-gradient(180deg, #c22e27, #6e1410);

    --warn: #e8bd57;

    --hp-top: #e2463d;
    --mana-top: #5b84e0; --mana-lo: #19306e;
    --stam-top: #5cc48a; --stam-lo: #1d5236;

    --good: #8fe0a8;
    --souls: #8fd8e0;
    --frost: #7fb8ff;
    --frost-rgb: 127, 184, 255;
    --ally: #9fdcc8;
    --party: #62c08a; --party-line: #2d6b4b; --party-bg: #0f2a1d;
    --cmp-up: #86a6ec;
    --cmp-dn: #ec6262;
    --arcane: #a574dc; --arcane-rgb: 165, 116, 220; --arcane-hi: #d2adff; --arcane-lo: #6a3d8f; --arcane-line: #5f4a80;
    --way-line: #2c4450; --way-text: #cfe6f2; --way-hot: #5aa0c8; --way-name: #8fd6f0; --way-sub: #8a9ba6;
    --way-rgb: 30, 48, 60;

    /* canvas chrome: the plate a world label sits on, foe/ally slivers */
    --plate: rgba(4, 7, 8, 0.78);
    --plate-hot: rgba(12, 34, 24, 0.95);
    --foe-hp: #c0302a;
    --ally-hp: #3fae72;

    /* the frame every window wears: a dark rim, a white hairline of light on
       its top edge, and a breath of witchlight around it */
    --frame-shadow: 0 0 0 1px rgba(0, 0, 0, 0.8), 0 16px 48px rgba(0, 0, 0, 0.85), 0 0 40px rgba(var(--witch-rgb), 0.045),
      inset 0 1px 0 rgba(var(--light-rgb), 0.08), inset 0 0 40px rgba(0, 0, 0, 0.35);
    --panel-bg: radial-gradient(130% 110px at 50% 0, rgba(var(--light-rgb), 0.055), transparent),
      radial-gradient(90% 160px at 50% 0, rgba(var(--witch-rgb), 0.05), transparent),
      linear-gradient(180deg, rgba(15, 21, 22, 0.97), rgba(6, 9, 10, 0.97) 150px), rgba(var(--glass-rgb), 0.97);
    --btn-bg: linear-gradient(180deg, #19201f, #0b0f10);
    --btn-bg-hot: linear-gradient(180deg, #1c2b26, #0e1614);
    --veil: rgba(2, 4, 5, 0.66);
  }
  /* NO TEXT IS SELECTED AND NO CALLOUT RISES under a finger anywhere in the game (WebKit reads only its own
     prefixed names); what takes typing (a name, a chat line, a field) is selectable again */
  * { margin: 0; padding: 0; box-sizing: border-box; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  input, textarea, [contenteditable="true"] { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
  html, body { width: 100%; height: 100%; overflow: hidden; background: var(--bg); }
  /* line-height pinned: the faces' own metrics run taller and would grow panels */
  body { font-family: var(--font-text); color: var(--text); line-height: 1.14; font-variant-numeric: lining-nums; -webkit-font-smoothing: antialiased; }
  /* the carved face: headings, names, buttons — never stats. One weight only,
     so the browser must not fake a bold or an italic out of it. */
  #title h1, .btn, #gamelist-label, .am-row, .set-sec, .set-tab,
  .panel h2, .inv-sec, .tt-name, .tt-cmp-head, .zb-title, #bossname, #glossary .gl-sec,
  #deathscreen h2, .lb-ribbon, .lb-num, .trade-col-head, .wp-name, .pm-head b, .ask-text b,
  #hud-name, .shop-title {
    font-family: var(--font-rune); font-weight: normal; font-style: normal; font-synthesis: none;
  }
  input, textarea, select, button { font-family: inherit; line-height: inherit; }
  /* the canvas box IS the layout viewport; the client sizes the backing store from this
     box, never innerWidth/innerHeight (the visual viewport drifts with the URL
     bar on a phone). No z-index: the 3D canvas (z-index:1) paints over it. */
  canvas#game { display: block; position: fixed; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
  .hidden { display: none !important; }
  /* no iOS callout on a long press (it is the combat lock gesture), no
     rubber-band. 100dvh, never 100vh: vh clips behind an expanded URL bar. */
  html, body { height: 100dvh; overscroll-behavior: none; }
  canvas { -webkit-touch-callout: none; }
  /* NO PAGE ZOOM, ANYWHERE: a resting finger on a HUD cell plus a steering thumb
     reads as a pinch, iOS ignores user-scalable=no, and once WebKit owns a pinch
     no JS guard can cancel it. So pan-y everywhere (lists still scroll; neither
     pinch nor double-tap is a pan) and none on controls, the canvas and #thumbs.
     Never use manipulation here: it keeps pinch-zoom. */
  html, body { touch-action: pan-y; }
  button, .btn, .hud-btn, .belt-slot, .skill-slot, .slot, .linkish,
  .panel { touch-action: pan-y; }
  /* inside a window its controls and pieces fill the list: a swipe on any of them must scroll it (a
     piece's own touch handlers tell a swipe from a drag) */
  .panel button, .panel .btn, .panel .slot, .panel .linkish { touch-action: pan-y; }
  .mono { font-family: 'Menlo', 'Consolas', monospace; font-size: 0.85em; }

  /* ---------- the title ---------- */
  /* The title stands on a painted plate (a real <picture>, the LCP image,
     preloaded in the head). Wordmark and line at the top edge, the verbs on the
     left rail low where the thumb is, identity top right, build info in the foot. */
  #title {
    position: fixed; inset: 0; z-index: 50; overflow: hidden; text-align: left;
    background: var(--bg);   /* under the plate while it decodes; never a flash of white */
  }
  #t-plate { position: absolute; inset: 0; z-index: 0; }
  #t-plate img, .lv-plate img {
    display: block; width: 100%; height: 100%; object-fit: cover;
    /* the ruin sits at ~72 % across and its fire at ~60 % down: hold that band
       when a window is wider or shorter than the plate's own 16:9 */
    object-position: 62% 48%;
  }
  /* the portrait plate is already cut around the gatehouse — centre it */
  @media (max-aspect-ratio: 1/1) { #t-plate img, .lv-plate img { object-position: 50% 50%; } }
  /* the scrim: as thin as the contrast ratios allow — dark under the rail,
     nearly gone across the ruin, closed under the foot row so its links keep 4.5:1 */
  #title::before {
    content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none;
    background:
      linear-gradient(90deg, rgba(var(--glass-rgb), 0.72) 0%, rgba(var(--glass-rgb), 0.62) 24%,
        rgba(var(--glass-rgb), 0.26) 42%, rgba(var(--glass-rgb), 0.12) 72%, rgba(var(--glass-rgb), 0.5) 100%),
      linear-gradient(0deg, rgba(var(--glass-rgb), 0.86) 0%, rgba(var(--glass-rgb), 0.3) 24%, transparent 46%),
      linear-gradient(180deg, rgba(var(--glass-rgb), 0.66) 0%, transparent 20%),
      radial-gradient(ellipse 58% 70% at 16% 62%, rgba(var(--witch-rgb), 0.07), transparent 72%),
      radial-gradient(ellipse 96% 86% at 52% 44%, transparent 34%, rgba(var(--glass-rgb), 0.58) 100%),
      linear-gradient(rgba(var(--glass-rgb), 0.16), rgba(var(--glass-rgb), 0.16));
  }
  #t-rail, #t-foot, #t-seed, #seed-back { z-index: 2; }
  /* the brand shares the rail's left margin and the identity circle's line; the
     wordmark must fit left of the circle at every width (its size below does that) */
  #t-brand {
    position: absolute; z-index: 57; left: clamp(18px, 5vw, 84px);
    top: calc(clamp(16px, 3.5vh, 40px) + var(--safe-t));
    max-width: calc(100% - 2 * clamp(18px, 5vw, 84px));
  }
  /* the rail: left column from mid-screen down — the verbs, then the slot list
     filling the column to the foot row's line */
  #t-rail {
    position: absolute; left: clamp(18px, 5vw, 84px); top: 46%; bottom: calc(46px + var(--safe-b));
    display: flex; flex-direction: column; gap: 9px; width: min(440px, calc(100vw - 36px));
  }
  #t-rail .btn { margin: 0; width: 100%; text-align: center; }
  #t-verbs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  /* two equal doors side by side (a phone stacks them); a label never spills */
  #t-verbs .btn { padding-left: 10px; padding-right: 10px; letter-spacing: 1.5px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* a door that is not open yet: greyed, deaf to the pointer, and no hover
     answer at all — the gauntlet cursor would promise a click */
  .btn:disabled, .btn:disabled:hover, .btn:disabled:active {
    background: var(--btn-bg); border-color: var(--line); color: var(--text-4);
    box-shadow: none; text-shadow: none; opacity: 0.62; cursor: inherit;
  }
  /* the seed step is a state of the title (body.t-seed), not a layer: the plate
     stays, rail/brand/corners give way to a back arrow and a prefilled seed field */
  #t-seed, #seed-back { display: none; }
  body.t-seed #t-seed { display: flex; }
  body.t-seed #seed-back { display: flex; }
  body.t-seed #t-rail, body.t-seed #t-brand, body.t-seed #t-foot, body.t-seed #acctwrap { display: none; }
  #t-seed {
    position: absolute; left: clamp(18px, 5vw, 84px); top: 46%;
    flex-direction: column; gap: 9px; width: min(440px, calc(100vw - 36px));
  }
  #seed-label { font-family: var(--font-rune); font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-2);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9); }
  #seed-row { display: flex; gap: 9px; }
  /* 16px, not the field's usual 13: iOS zooms the page into any smaller input */
  #seed-row #ow-seed { flex: 1; width: auto; min-width: 0; font-size: 16px; letter-spacing: 0.06em;
    -webkit-user-select: text; user-select: text; }
  #seed-row .btn { margin: 0; flex: 0 0 auto; }
  /* the back arrow the hall and the seed share: top left, clear of a
     fingertip, over the safe area a notch leaves */
  .back-arrow {
    position: absolute; left: calc(10px + var(--safe-l)); top: calc(10px + var(--safe-t));
    width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
    background: none; border: 0; padding: 0; cursor: pointer; color: var(--text-2);
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.95)); transition: color 0.2s, transform 0.2s;
  }
  .back-arrow svg { width: 30px; height: 30px; }
  .back-arrow:hover { color: var(--text-hi); transform: translateX(-2px); }
  #title h1 {
    /* letter-spacing in em, paid back on the right. The widest wordmark is
       8.94 em, so the /9 arm fits it left of the identity circle; the vh arm
       keeps it off the rail on a sideways phone. */
    font-size: clamp(22px, min(8.4vw, 11vh, (100vw - clamp(18px, 5vw, 84px) - 90px) / 9), 70px);
    letter-spacing: 0.17em; margin-right: -0.17em;
    font-weight: normal; line-height: 1.05; white-space: nowrap;
    /* white carved into witchlight, a slow band of light passing over it */
    background: linear-gradient(105deg, transparent 38%, rgba(var(--light-rgb), 0.95) 50%, transparent 62%) 160% 0 / 250% 100% no-repeat,
      linear-gradient(180deg, var(--text-hi) 28%, var(--witch-hi) 62%, var(--witch) 100%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
    filter: drop-shadow(0 2px 0 #000) drop-shadow(0 0 26px rgba(var(--witch-rgb), 0.32));
    animation: title-shimmer 9s ease-in-out infinite;
  }
  @keyframes title-shimmer { 0%, 55% { background-position: 160% 0, 0 0; } 85%, 100% { background-position: -60% 0, 0 0; } }
  @media (prefers-reduced-motion: reduce) { #title h1 { animation: none; } }
  #title .sub {
    /* text-2: the line sits on bright painted sky; --text-3 fails contrast
       there */
    display: block; margin-top: 7px; font-size: 14px; font-style: italic; color: var(--text-2); letter-spacing: 0.14em;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  }
  /* a line that opens a story (the world's lore; a wanderer's in the hall: her name, or a new character's line): a
     door by its underline alone, with a hit area past the glyphs for a thumb */
  #title .sub, #cs-name, #cs-bline.linkish {
    position: relative; background: none; border: 0; padding: 0; text-align: inherit;
    text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px;
    text-decoration-color: color-mix(in srgb, currentColor 55%, transparent);
  }
  #title .sub::after, #cs-name::after, #cs-bline.linkish::after { content: ''; position: absolute; inset: -10px -8px; }
  #title .sub:hover, #cs-name:hover, #cs-bline.linkish:hover { color: var(--text-hi); text-decoration-color: currentColor; }
  #title .sub:focus-visible, #cs-name:focus-visible, #cs-bline.linkish:focus-visible { outline: 1px solid var(--witch); outline-offset: 4px; }
  .btn {
    display: inline-block; margin: 5px 8px; padding: 11px 34px; font-size: 16px;
    background: var(--btn-bg); color: var(--text-hi);
    border: 1px solid var(--line-strong); border-radius: 2px; cursor: pointer; letter-spacing: 2px;
    box-shadow: inset 0 1px 0 rgba(var(--light-rgb), 0.08), inset 0 -1px 0 rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.45);
    text-shadow: 0 1px 1px #000;
    transition: border-color 0.15s, color 0.15s, box-shadow 0.15s;
  }
  .btn:hover { background: var(--btn-bg-hot); border-color: var(--line-hot); color: var(--text-hi);
    box-shadow: inset 0 1px 0 rgba(var(--witch-rgb), 0.22), inset 0 -1px 0 rgba(0, 0, 0, 0.5), 0 0 16px rgba(var(--witch-rgb), 0.2); }
  .btn:active { background: var(--btn-bg); box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6); }
  .btn:focus-visible { outline: 1px solid var(--witch); outline-offset: 2px; }
  /* the call to action: the one thing on a screen you commit to wears blood */
  .btn.primary { background: var(--cta-bg); border-color: var(--blood); color: var(--text-hi);
    box-shadow: inset 0 1px 0 rgba(var(--light-rgb), 0.18), inset 0 -1px 0 rgba(0, 0, 0, 0.45), 0 0 18px rgba(var(--blood-rgb), 0.22); }
  .btn.primary:hover { background: var(--cta-bg-hot); border-color: var(--blood-soft);
    box-shadow: inset 0 1px 0 rgba(var(--light-rgb), 0.24), inset 0 -1px 0 rgba(0, 0, 0, 0.45), 0 0 24px rgba(var(--blood-rgb), 0.4); }
  .btn.danger { color: var(--blood-soft); }
  .btn.danger:hover { border-color: var(--blood); color: var(--blood-pale); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.5), 0 0 14px rgba(var(--blood-rgb), 0.25); }
  /* the foot: small print (the offline chip) in the far
     corner, opposite the rail. The top right belongs to the identity circle and the fullscreen switch. */
  #t-foot {
    position: absolute; z-index: 57; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
    justify-content: flex-end; text-align: right;
    right: clamp(18px, 5vw, 84px); bottom: calc(14px + var(--safe-b));
  }
  #creditspanel { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, 92vw); max-height: min(86dvh, var(--win-fit)); overflow-y: auto; text-align: left; z-index: 102; }
  #creditspanel p { font-size: 12.5px; color: var(--text-2); line-height: 1.75; margin: 12px 0 0; }
  #creditspanel a { color: var(--witch); text-decoration: none; border-bottom: 1px solid var(--witch-deep); }
  #creditspanel a:hover { color: var(--text-hi); }
  #creditspanel .cr-lic { color: var(--text-4); }
  /* the lore window: only the text scrolls, so the close never scrolls away */
  #lorepanel {
    left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, 94vw); max-height: min(86dvh, var(--win-fit));
    display: flex; flex-direction: column; overflow: hidden; text-align: left; z-index: 101;
  }
  #lorepanel > h2 { flex: 0 0 auto; }
  #lore-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 2px 8px 2px 2px; }
  #lore-body:focus { outline: none; }
  #lore-body p { font-size: 14.5px; line-height: 1.7; color: var(--text-2); margin: 0 0 13px; }
  #lore-body p:last-child { margin-bottom: 0; }
  .btn.small { padding: 8px 20px; font-size: 13px; }
  .linkish {
    background: none; border: none; color: var(--text-3); font-size: 11.5px;
    cursor: pointer; text-decoration: underline; text-underline-offset: 3px; letter-spacing: 1px;
  }
  .linkish:hover { color: var(--text-hi); }
  #acct-status { min-height: 16px; font-size: 12px; color: var(--blood-soft); font-style: italic; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9); }
  /* offline is a state, not an error: a quiet amber chip in the foot row,
     never written into #acct-status */
  #offlinechip {
    display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--warn);
    background: rgba(var(--glass-rgb), 0.82); border: 1px solid var(--line); border-radius: 4px; padding: 5px 9px;
  }
  #offlinechip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); flex: 0 0 auto; }
  #ow-seed {
    width: 100%; padding: 10px 12px; font-size: 13px;
    background: var(--well-2); border: 1px solid var(--line-strong); border-radius: 2px; color: var(--text);
  }
  #ow-seed:focus { outline: none; border-color: var(--line-hot); box-shadow: 0 0 10px rgba(var(--witch-rgb), 0.18); }
  /* the three game slots: a framed box filling what the column has left,
     scrolling inside itself. Empty slot = dashed New game; taken = a badge
     (portrait, name, meta, when) with Play and a small delete. */
  #gamelist {
    display: flex; flex-direction: column; gap: 7px; width: 100%;
    flex: 0 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
    padding: 8px 10px 10px; background: rgba(var(--glass-rgb), 0.55);
    border: 1px solid var(--line); border-radius: 2px;
  }
  #gamelist-label { display: flex; justify-content: space-between; align-items: baseline;
    font-size: 10px; letter-spacing: 0.18em; color: var(--text-3); margin: 4px 2px 1px; }
  #gamelist-label .s-count { letter-spacing: 0.08em; color: var(--text-4); }
  #gamelist .s-note { font-size: 12px; color: var(--text-2); margin: 0 2px 2px; line-height: 1.45; }
  .gslot { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 72px; padding: 9px 10px;
    border-radius: 2px; text-align: left; font: inherit; color: var(--text); }
  .gslot.s-empty {
    justify-content: center; gap: 10px; background: rgba(var(--glass-rgb), 0.28);
    border: 1px dashed var(--line-strong); color: var(--text-3); cursor: pointer;
    font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase; transition: border-color 0.15s, color 0.15s, background 0.15s;
  }
  .gslot.s-empty .s-plus { font-size: 20px; line-height: 1; color: var(--text-4); transition: color 0.15s; }
  .gslot.s-empty:hover:not(:disabled) { border-color: var(--line-hot); color: var(--text-hi); background: rgba(var(--witch-rgb), 0.06); }
  .gslot.s-empty:hover:not(:disabled) .s-plus { color: var(--witch); }
  .gslot.s-empty:focus-visible { outline: 1px solid var(--witch); outline-offset: 2px; }
  .gslot.s-empty:disabled { opacity: 0.5; cursor: default; }
  #gamelist[data-mode="signedout"] .gslot.s-empty { opacity: 0.72; }
  .gslot.s-game { background: rgba(var(--glass-rgb), 0.66); border: 1px solid var(--line-strong); }
  .gslot .s-face {
    flex: 0 0 auto; width: 54px; height: 54px; border-radius: 50%; overflow: hidden;
    border: 1px solid var(--line-strong); background: var(--well-2);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.6);
  }
  .gslot .s-face img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .gslot .s-face span { font-family: var(--font-rune); font-size: 22px; color: var(--text-3); }
  .gslot .s-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
  .gslot .s-name { color: var(--text-hi); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .gslot .s-meta { color: var(--text-2); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .gslot .s-when { color: var(--text-4); font-size: 10.5px; }
  #t-rail .gslot .s-play { flex: 0 0 auto; width: auto; margin: 0; padding: 9px 20px; font-size: 13px; letter-spacing: 1.5px; }
  .gslot .s-del {
    flex: 0 0 auto; width: 32px; height: 32px; margin-left: -4px; display: flex; align-items: center; justify-content: center;
    background: none; border: 0; padding: 0; color: var(--text-4); cursor: pointer; border-radius: 2px;
  }
  .gslot .s-del svg { width: 14px; height: 14px; }
  .gslot .s-del:hover { color: var(--blood-hi); background: rgba(var(--blood-rgb), 0.1); }
  .gslot .s-del:focus-visible { outline: 1px solid var(--blood-soft); }
  /* the pickers' field (design/SELECT.md): no plate, no braziers; a near-black ground with one low ember light where
     the painting stands and a faint floor, so the painting is the only picture on the screen */
  #charselect, #foeselect {
    --sel-field: radial-gradient(ellipse 34% 46% at var(--sel-x, 36%) 62%, rgba(var(--mint-rgb), 0.075), transparent 72%),
      radial-gradient(ellipse 46% 9% at var(--sel-x, 36%) 92%, rgba(var(--witch-rgb), 0.07), transparent 70%),
      linear-gradient(180deg, #06090a 0%, var(--bg) 55%, #020303 100%);
    background: var(--sel-field);
  }
  /* the muster hall: a grid whose boxes never overlap (measure/harness checks/selscreen): the painting (stage), the
     headline (build), the spell, the numbers, the bars, the belt of faces, Choose. Desktop: painting left, the column
     right; a phone stands them in one column, the belt right over Choose; a short landscape keeps two columns, small. */
  #charselect, #foeselect {
    position: fixed; inset: 0; z-index: 58; overflow: hidden; touch-action: pan-y;
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 470px);
    grid-template-rows: minmax(0, 1fr) repeat(6, auto) minmax(0, 1fr) auto;
    column-gap: clamp(24px, 4vw, 80px); row-gap: 12px;
    padding: calc(28px + var(--safe-t)) clamp(20px, 6vw, 120px) calc(22px + var(--safe-b));
  }
  #charselect { grid-template-areas: "stage ." "stage head" "stage spell" "stage snums" "stage dnums" "stage bars" "stage choose" "stage ." "strip ."; }
  #cs-back, #fo-back { z-index: 3; }
  #cs-stage, #fo-stage { grid-area: stage; position: relative; min-height: 0; pointer-events: none; }
  #cs-shot, #fo-shot, .sel-out, .sel-peek {
    position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; object-position: 50% 100%;
    pointer-events: auto; filter: drop-shadow(0 18px 28px rgba(0, 0, 0, 0.6)); transition: transform 0.25s ease;
    user-select: none; -webkit-user-drag: none;
  }
  #cs-shot:not([src]), #fo-shot:not([src]) { visibility: hidden; }
  #cs-build { grid-area: head; display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
  #cs-btext { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
  #cs-bname {
    font-family: var(--font-rune); font-size: clamp(28px, 2.8vw, 44px); line-height: 1.05; letter-spacing: 0.12em; color: var(--text-hi);
    text-transform: uppercase; overflow-wrap: anywhere; text-shadow: 0 0 28px rgba(var(--light-rgb), 0.16), 0 2px 6px rgba(0, 0, 0, 0.9);
  }
  #cs-name { font-family: var(--font-rune); font-size: 14px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--text-3); }
  #cs-bline { font-style: italic; font-size: 15px; line-height: 1.45; color: var(--text-2); letter-spacing: 0.02em; }
  #cs-bspell {
    grid-area: spell; display: flex; align-items: center; gap: 12px; min-width: 0; padding: 10px 14px;
    background: rgba(var(--glass-rgb), 0.62); border: 1px solid var(--line); border-left: 2px solid var(--line-strong);
  }
  #cs-bglyph { display: flex; flex: 0 0 auto; color: var(--witch-hi); }
  #cs-bglyph svg { width: 30px; height: 30px; fill: currentColor; filter: drop-shadow(0 0 7px rgba(var(--witch-rgb), 0.5)); }
  #cs-sptext { min-width: 0; }
  #cs-bspname { font-family: var(--font-rune); font-size: 20px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--witch-hi); }
  #cs-spline { margin-top: 3px; font-size: 13px; line-height: 1.4; font-style: italic; color: var(--text-2); }
  #cs-spnums { grid-area: snums; }
  #cs-derived { grid-area: dnums; }
  .cs-nums { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; min-width: 0; }
  .cs-num { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; background: var(--well-2); border: 1px solid var(--line); min-width: 0; }
  .cs-num b { font-size: 16px; font-weight: 600; color: var(--text-hi); white-space: nowrap; }
  .cs-num span { font-size: 9.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #cs-bars { grid-area: bars; }
  #cs-bars, .cs-bars { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px 18px; }
  .cs-bar { display: grid; grid-template-columns: minmax(0, 6.2em) minmax(0, 1fr) 2.2em; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text-2); }
  .cs-bar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cs-bar i { position: relative; height: 5px; background: var(--well); border: 1px solid var(--line); }
  .cs-bar i::after {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--v) * 100%);
    background: linear-gradient(90deg, var(--witch-lo), var(--witch)); transition: width 0.3s ease;
  }
  .cs-bar b { text-align: right; font-weight: 600; color: var(--text-hi); }
  #cs-choose { grid-area: choose; margin: 0; width: 100%; padding: 13px 34px; font-size: 17px; letter-spacing: 0.25em; text-transform: uppercase; }
  /* the belt: one face per wanderer; hers lit, the rest dimmed; a band (windows.rs bind_bands): it pans under a finger
     with the browser's own momentum, snaps to a face, scrolls itself and never the page */
  #cs-strip, #fo-strip { grid-area: strip; }
  .cs-strip { display: flex; align-items: center; justify-content: center; gap: 10px; min-width: 0; }
  .cs-faces { display: flex; gap: 8px; min-width: 0; padding: 6px 4px; scroll-snap-type: x mandatory; scroll-behavior: smooth; }
  .cs-face {
    position: relative; flex: 0 0 auto; width: 58px; height: 58px; padding: 0; overflow: hidden; cursor: pointer; scroll-snap-align: center;
    background: var(--raise); border: 1px solid var(--line-strong); opacity: 0.55; filter: saturate(0.45);
    transition: opacity 0.2s, filter 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.2s;
  }
  .cs-face img { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
  .cs-face img:not([src]) { visibility: hidden; }
  .cs-face:hover { opacity: 0.85; filter: none; }
  .cs-face.on { opacity: 1; filter: none; border-color: var(--witch); box-shadow: 0 0 0 1px var(--witch), 0 0 18px rgba(var(--witch-rgb), 0.35); transform: translateY(-3px); }
  .cs-face:focus-visible { outline: 1px solid var(--witch); outline-offset: 2px; }
  /* the foes are painted darker than the wanderers: their resting portraits dim less, so the belt still reads */
  #fo-faces .cs-face:not(.on) { opacity: 0.72; filter: saturate(0.6); }
  #fo-faces .cs-face:not(.on):hover { opacity: 0.9; filter: none; }
  /* a boss's portrait carries a blood-red sill */
  .cs-face.boss { box-shadow: inset 0 -3px 0 var(--blood-hi); }
  .cs-face.boss.on { box-shadow: inset 0 -3px 0 var(--blood-hi), 0 0 0 1px var(--witch), 0 0 18px rgba(var(--witch-rgb), 0.35); }
  #charselect.cs-one #cs-strip, #foeselect.fo-one #fo-strip { display: none; }
  .cs-arrow, .sel-book {
    flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; padding: 0;
    background: rgba(var(--glass-rgb), 0.55); border: 1px solid var(--line-strong); color: var(--text-2); cursor: pointer;
    transition: color 0.2s, border-color 0.2s, box-shadow 0.2s;
  }
  .cs-arrow svg { width: 22px; height: 22px; }
  .sel-book svg { width: 20px; height: 20px; fill: currentColor; }
  .sel-book { color: var(--witch-hi); border-color: var(--line-hot); }
  .cs-arrow:hover, .sel-book:hover { color: var(--witch-hi); border-color: var(--line-hot); box-shadow: 0 0 20px rgba(var(--witch-rgb), 0.3); }
  /* A BAND: a native sideways scroller (windows.rs bind_bands); pan-x on it and on everything in it (a button is pan-y
     by the rule above), so a finger's sideways pan scrolls it and never lands as a tap */
  .band { overflow-x: auto; overflow-y: hidden; overscroll-behavior: contain; scrollbar-width: none; touch-action: pan-x; }
  .band::-webkit-scrollbar { display: none; }
  /* .panel .band * outranks `.panel .slot { pan-y }`: a bag cell under a finger must slide its row (Valy 11-15) */
  .band *, .panel .band * { touch-action: pan-x; }
  .band.dragging { scroll-snap-type: none; scroll-behavior: auto; cursor: grabbing; }
  .band.more-r { -webkit-mask-image: linear-gradient(90deg, #000 84%, transparent); mask-image: linear-gradient(90deg, #000 84%, transparent); }
  .band.more-l { -webkit-mask-image: linear-gradient(90deg, transparent, #000 16%); mask-image: linear-gradient(90deg, transparent, #000 16%); }
  .band.more-l.more-r { -webkit-mask-image: linear-gradient(90deg, transparent, #000 16%, #000 84%, transparent); mask-image: linear-gradient(90deg, transparent, #000 16%, #000 84%, transparent); }
  /* THE BOOK (shots.rs): the pickers' detail sheet; a dialog on a wide screen, a bottom sheet on a phone */
  .sel-sheet { position: fixed; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(0, 0, 0, 0.6); }
  .ss-panel {
    display: flex; flex-direction: column; width: min(600px, 100%); max-height: min(86%, 900px); min-height: 0;
    background: rgba(var(--glass-rgb), 0.97); border: 1px solid var(--line-strong); box-shadow: 0 18px 60px rgba(0, 0, 0, 0.7);
    animation: ss-in 0.22s ease both;
  }
  @keyframes ss-in { from { opacity: 0; transform: translateY(18px); } }
  .ss-head { display: flex; align-items: center; gap: 10px; padding: 12px 10px 10px 18px; border-bottom: 1px solid var(--line); }
  .ss-title { flex: 1; min-width: 0; font-family: var(--font-rune); font-size: 20px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-hi); }
  .ss-x { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; background: none; border: 0; color: var(--text-2); cursor: pointer; padding: 0; }
  .ss-x svg { width: 22px; height: 22px; fill: currentColor; }
  .ss-x:hover { color: var(--text-hi); }
  .ss-body { overflow-y: auto; overscroll-behavior: contain; padding: 6px 18px calc(18px + var(--safe-b)); display: flex; flex-direction: column; gap: 14px; }
  .ss-sec h3 { margin: 8px 0 8px; font-size: 10.5px; letter-spacing: 0.28em; text-transform: uppercase; color: var(--witch-hi); font-weight: 600; }
  .ss-card { padding: 10px 12px; background: var(--well-2); border: 1px solid var(--line); }
  .ss-tags { font-style: italic; font-size: 13px; color: var(--witch-hi); }
  .ss-nums { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .ss-move { padding: 8px 10px; margin-bottom: 6px; border: 1px solid var(--line); border-left: 2px solid var(--line-strong); background: var(--well-2); }
  .ss-move b { font-size: 12.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-hi); }
  .ss-move p { margin: 3px 0 4px; font-size: 13px; line-height: 1.4; color: var(--text); }
  .ss-move span { font-size: 12px; line-height: 1.5; color: var(--text-2); }
  .ss-sec ul { margin: 0; padding: 0 0 0 18px; display: flex; flex-direction: column; gap: 5px; font-size: 13px; line-height: 1.4; color: var(--text); }
  .ss-sec ul.ss-drops, .ss-sec ul.ss-rows { list-style: none; padding: 0; gap: 3px; }
  .ss-drops li, .ss-rows li { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border-bottom: 1px solid var(--line-faint); }
  .ss-drops i { font-size: 11px; color: var(--text-3); }
  .ss-drops b, .ss-rows b { font-weight: 600; color: var(--text-hi); }
  .ss-rows { margin-top: 12px !important; }
  .ss-lore { margin: 0; font-size: 12.5px; font-style: italic; line-height: 1.5; color: var(--text-3); }
  /* the loading ring (#loadveil, the sheet's figure): iron band, twelve runes, an
     ember lighting each in turn. Never takes a pointer; hidden when the stage's
     ready hook fires; delayed a beat so a warm hall never flashes it. */
  .ld-ring {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    display: flex; flex-direction: column; align-items: center; gap: 14px;
    pointer-events: none; animation: ld-in 0.5s ease 0.25s both; transition: opacity 0.5s ease;
  }
  .ld-ring.ld-done { opacity: 0; animation: none; }
  .ld-ring svg { width: 112px; height: 112px; overflow: visible; filter: drop-shadow(0 0 8px rgba(var(--witch-rgb), 0.35)); }
  /* a pool of smoke behind it, so it reads over any stretch of the painting */
  .ld-ring::before {
    content: ''; position: absolute; z-index: -1; left: 50%; top: -14px; width: 140px; height: 140px; margin-left: -70px;
    border-radius: 50%; background: radial-gradient(closest-side, rgba(var(--glass-rgb), 0.78) 55%, rgba(var(--glass-rgb), 0.35) 80%, transparent);
  }
  .ld-iron { fill: none; stroke: var(--line-strong); stroke-width: 4; }
  .ld-inner { fill: none; stroke: var(--line-strong); stroke-width: 1; }
  .ld-rune { fill: none; stroke: var(--witch-hi); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
    opacity: 0.16; animation: ld-rune 3.2s linear infinite; }
  .ld-ember { transform-origin: 60px 60px; animation: ld-turn 3.2s linear infinite; }
  .ld-arc { fill: none; stroke: var(--witch); stroke-linecap: round; }
  .ld-spark { fill: var(--witch); }
  .ld-halo { fill: var(--witch); opacity: 0.25; }
  .ld-head { fill: var(--witch-hi); transform-origin: 60px 14px; animation: ld-gutter 0.45s ease-in-out infinite alternate; }
  /* the load screen (the shell's, the page's first state): the title's plate with the
     ring, over the game until the renderer reports the world ready, or until the boot
     finds nothing to load. Never takes a pointer, so the first click lands. */
  #loadveil { position: fixed; inset: 0; z-index: 57; background: var(--bg); pointer-events: none; transition: opacity 0.5s ease; }
  #loadveil.ld-done { opacity: 0; }
  #loadveil .lv-plate { position: absolute; inset: 0; }
  #loadveil::after {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background: radial-gradient(ellipse 96% 86% at 50% 48%, rgba(var(--glass-rgb), 0.12) 30%, rgba(var(--glass-rgb), 0.62) 100%),
      linear-gradient(rgba(var(--glass-rgb), 0.22), rgba(var(--glass-rgb), 0.22));
  }
  #loadveil .ld-ring { z-index: 1; }
  /* the load screen is a screen state (body.loading, em-ui's apply_screen): the corner's chrome that stands over
     the pickers (59) goes while it is up, whatever screen the wheel was raised over (Valy 10-17: the fullscreen
     switch and the frame meter stood over the wheel between the roster's Fight and play, and through a join) */
  body.loading #fsbtn, body.loading #statsmeter { display: none; }
  /* no WebGL, no moor: said plainly over everything, with a way to try again */
  #nowebgl { position: fixed; inset: 0; z-index: 99; display: grid; place-items: center; padding: 16px; background: var(--bg); }
  #nowebgl .nw-box { max-width: 420px; text-align: center; color: var(--text-2); line-height: 1.5; }
  #nowebgl .nw-head { color: var(--text-hi); font-size: 18px; margin-bottom: 8px; }
  #nowebgl .btn { margin-top: 16px; }
  @keyframes ld-in { from { opacity: 0; } }
  @keyframes ld-turn { to { transform: rotate(360deg); } }
  /* a rune catches as the ember reaches it, then smoulders back down */
  @keyframes ld-rune { 0% { opacity: 1; } 45%, 100% { opacity: 0.16; } }
  @keyframes ld-gutter { from { opacity: 0.7; transform: scale(0.8); } to { opacity: 1; transform: scale(1.18); } }
  @keyframes ld-breathe { from { opacity: 0.16; } to { opacity: 0.75; } }
  @media (prefers-reduced-motion: reduce) {
    .ld-ember, .ld-head { animation: none; }
    .ld-rune { animation: ld-breathe 1.8s ease-in-out infinite alternate; animation-delay: 0s !important; }
  }
  /* a phone upright (design/SELECT.md "Phone"): nothing in the top band (the status bar and the haze iOS lays under
     it: the back arrow and the FPS readout only); the headline and the book, then SHE as tall as fits, then the spell
     and the numbers, the belt right over Choose in the thumb's reach. The bars live in the book (a new character, who
     has no spell, keeps them). */
  @media (max-width: 700px) and (orientation: portrait) {
    #charselect {
      grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); grid-template-rows: auto minmax(0, 1fr) repeat(5, auto);
      grid-template-areas: "head head" "stage stage" "spell spell" "snums dnums" "bars bars" "strip strip" "choose choose";
      row-gap: 0; column-gap: 6px;
      padding: calc(52px + var(--safe-t)) calc(14px + var(--safe-r)) calc(10px + var(--safe-b)) calc(14px + var(--safe-l));
      --sel-x: 50%;
    }
    #charselect:not(.cs-demo) { grid-template-areas: "head head" "stage stage" "spell spell" "dnums dnums" "bars bars" "strip strip" "choose choose"; }
    #cs-back { top: calc(4px + var(--safe-t)); left: calc(2px + var(--safe-l)); }
    #cs-build { gap: 8px; align-items: center; margin-bottom: 6px; }
    #cs-btext { gap: 2px; }
    #cs-bname { font-size: 22px; letter-spacing: 0.08em; }
    #cs-name { font-size: 11px; }
    #cs-bline { font-size: 12.5px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
    #cs-stage { margin-bottom: 8px; }
    #cs-bspell { padding: 6px 10px; gap: 9px; margin-bottom: 6px; }
    #cs-bglyph svg { width: 24px; height: 24px; }
    #cs-bspname { font-size: 15px; }
    #cs-spline { font-size: 11.5px; margin-top: 1px; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
    #charselect.cs-demo #cs-bars { display: none; }
    #cs-bars { margin-top: 8px; gap: 5px 12px; }
    .cs-bar { font-size: 10.5px; gap: 6px; }
    .cs-nums { gap: 4px; }
    .cs-num { padding: 4px 2px; }
    .cs-num b { font-size: 14px; }
    .cs-num span { font-size: 8.5px; letter-spacing: 0.08em; }
    #cs-spnums .cs-grade { display: none; }
    .cs-strip { gap: 6px; margin-top: 8px; }
    .cs-strip .cs-arrow { width: 34px; height: 34px; }
    .cs-faces { padding: 5px 2px; gap: 6px; }
    .cs-face { width: 48px; height: 48px; }
    #cs-choose { padding: 11px 24px; font-size: 15px; margin-top: 8px; }
    .sel-sheet { align-items: flex-end; padding: calc(56px + var(--safe-t)) 0 0; }
    .ss-panel { width: 100%; max-height: 100%; border-radius: 14px 14px 0 0; border-bottom: 0; }
    .ss-body { padding-left: 14px; padding-right: 14px; }
  }
  /* a short landscape (a phone on its side): two columns kept, everything small; the bars live in the book */
  @media (max-height: 620px) and (orientation: landscape) {
    #charselect {
      grid-template-columns: minmax(0, 1fr) minmax(280px, 46vw); grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
      grid-template-areas: "stage head" "stage spell" "stage snums" "stage dnums" "stage ." "strip choose"; row-gap: 6px; column-gap: 16px;
      padding: calc(8px + var(--safe-t)) calc(12px + var(--safe-r)) calc(8px + var(--safe-b)) calc(52px + var(--safe-l));
    }
    #charselect:not(.cs-demo) { grid-template-areas: "stage head" "stage dnums" "stage bars" "stage ." "stage ." "strip choose"; }
    #charselect.cs-demo #cs-bars { display: none; }
    #cs-back { top: calc(4px + var(--safe-t)); }
    #cs-btext { gap: 2px; }
    #cs-bname { font-size: 20px; }
    #cs-name { font-size: 10.5px; }
    #cs-bline { font-size: 11.5px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
    #cs-bspell { padding: 6px 9px; gap: 8px; }
    #cs-bspname { font-size: 14px; }
    #cs-bglyph svg { width: 20px; height: 20px; }
    #cs-spline { font-size: 11px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
    .cs-nums { gap: 4px; }
    .cs-num { padding: 3px 2px; }
    .cs-num b { font-size: 13px; }
    .cs-bar { font-size: 10px; }
    #cs-choose { padding: 8px 20px; font-size: 14px; align-self: end; }
    .cs-strip .cs-arrow { width: 32px; height: 32px; }
    .cs-faces { padding: 3px 2px; gap: 5px; }
    .cs-face { width: 38px; height: 38px; }
    .cs-face.on { transform: none; }
    .sel-book { width: 34px; height: 34px; }
    .sel-sheet { padding: 8px; }
    .ss-panel { max-height: 100%; }
  }
  @media (prefers-reduced-motion: reduce) {
    .cs-arrow, #cs-shot, #fo-shot, .cs-face, .cs-bar i::after, .ss-panel { transition: none; animation: none; }
    .cs-faces { scroll-behavior: auto; }
  }
  /* THE TAPE (shots.rs): a step rolls the stills through the stage's window, the leaving one a copy (.sel-out), the
     one a finger pulls in behind the dragged one a .sel-peek; on a phone the window reaches the screen's sides */
  #cs-stage, #fo-stage { clip-path: inset(-100vh 0); }
  .sel-out, .sel-peek { pointer-events: none; }
  @media (max-width: 700px) and (orientation: portrait) {
    #cs-stage, #fo-stage { clip-path: inset(-100vh calc(-14px - var(--safe-r)) -100vh calc(-14px - var(--safe-l))); }
  }
  /* THE PROVING ROSTER (design/SELECT.md "The roster"): the hall's grid for the foe, box for box: the painting (stage),
     the headline (its name, its tags as the epithet, the book), when to strike, its moves as glyphs, its numbers, the
     belt of portraits right over Fight. Desktop: painting left, the column right; a phone stands them in one column. */
  #foeselect { grid-template-areas: "stage ." "stage head" "stage strike" "stage moves" "stage nums" "stage more" "stage choose" "stage ." "strip ."; }
  #fo-head { grid-area: head; display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
  #fo-htext { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
  #fo-name {
    font-family: var(--font-rune); font-size: clamp(28px, 2.8vw, 44px); line-height: 1.05; letter-spacing: 0.12em; color: var(--text-hi);
    text-transform: uppercase; overflow-wrap: anywhere; text-shadow: 0 0 28px rgba(var(--light-rgb), 0.16), 0 2px 6px rgba(0, 0, 0, 0.9);
  }
  #foeselect.fo-boss #fo-name { text-shadow: 0 0 30px rgba(var(--blood-rgb), 0.35), 0 2px 6px rgba(0, 0, 0, 0.9); }
  #fo-flags { font-style: italic; font-size: 15px; line-height: 1.45; letter-spacing: 0.02em; color: var(--witch-hi); }
  #fo-strike {
    grid-area: strike; display: flex; align-items: center; gap: 12px; min-width: 0; padding: 10px 14px;
    background: rgba(var(--glass-rgb), 0.62); border: 1px solid var(--line); border-left: 2px solid var(--line-strong);
  }
  #fo-sglyph { display: flex; flex: 0 0 auto; color: var(--witch-hi); }
  #fo-sglyph svg { width: 28px; height: 28px; fill: currentColor; filter: drop-shadow(0 0 7px rgba(var(--witch-rgb), 0.5)); }
  #fo-stext { min-width: 0; }
  #fo-shead { font-size: 10.5px; letter-spacing: 0.28em; text-transform: uppercase; color: var(--witch-hi); font-weight: 600; }
  #fo-sline { margin-top: 4px; font-size: 14px; line-height: 1.4; color: var(--text); }
  #fo-moves { grid-area: moves; display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
  .fo-move {
    display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 7px; min-width: 0;
    background: var(--well-2); border: 1px solid var(--line); color: var(--witch-hi); cursor: help;
  }
  .fo-move svg { width: 17px; height: 17px; flex: 0 0 auto; fill: currentColor; }
  .fo-move b { font-size: 10.5px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-2); white-space: nowrap; }
  #fo-stats { grid-area: nums; }
  #fo-more { grid-area: more; }
  #fo-choose { grid-area: choose; margin: 0; width: 100%; padding: 13px 34px; font-size: 17px; letter-spacing: 0.25em; text-transform: uppercase; }
  /* upright (a phone): the headline under the haze, the foe as tall as fits, when to strike in one line, the four
     numbers, the belt right over Fight; its moves, armour, speed and opening live in the book */
  @media (max-width: 700px) and (orientation: portrait) {
    #foeselect {
      grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) repeat(4, auto);
      grid-template-areas: "head" "stage" "strike" "nums" "strip" "choose";
      row-gap: 0; column-gap: 0;
      padding: calc(52px + var(--safe-t)) calc(14px + var(--safe-r)) calc(10px + var(--safe-b)) calc(14px + var(--safe-l));
      --sel-x: 50%;
    }
    #fo-back { top: calc(4px + var(--safe-t)); left: calc(2px + var(--safe-l)); }
    #fo-head { gap: 8px; align-items: center; margin-bottom: 6px; }
    #fo-htext { gap: 3px; }
    #fo-name { font-size: 22px; letter-spacing: 0.08em; }
    #fo-flags { font-size: 12.5px; line-height: 1.35; }
    #fo-stage { margin-bottom: 8px; }
    #fo-strike { padding: 6px 10px; gap: 9px; margin-bottom: 6px; }
    #fo-sglyph svg { width: 22px; height: 22px; }
    #fo-shead { font-size: 9px; letter-spacing: 0.22em; }
    #fo-sline { font-size: 12px; margin-top: 1px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
    #fo-moves, #fo-more { display: none; }
    #fo-choose { padding: 11px 24px; font-size: 15px; margin-top: 8px; }
  }
  /* a short landscape (a phone on its side): two columns kept, everything small, the moves and the second numbers too */
  @media (max-height: 620px) and (orientation: landscape) {
    #foeselect {
      grid-template-columns: minmax(0, 1fr) minmax(280px, 46vw); grid-template-rows: auto auto auto auto auto minmax(0, 1fr) auto;
      grid-template-areas: "stage head" "stage strike" "stage moves" "stage nums" "stage more" "stage ." "strip choose"; row-gap: 6px; column-gap: 16px;
      padding: calc(8px + var(--safe-t)) calc(12px + var(--safe-r)) calc(8px + var(--safe-b)) calc(52px + var(--safe-l));
    }
    #fo-back { top: calc(4px + var(--safe-t)); }
    #fo-htext { gap: 2px; }
    #fo-name { font-size: 20px; }
    #fo-flags { font-size: 11.5px; line-height: 1.3; }
    #fo-strike { padding: 6px 9px; gap: 8px; }
    #fo-sglyph svg { width: 20px; height: 20px; }
    #fo-shead { font-size: 9px; }
    #fo-sline { font-size: 11.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
    #fo-moves { gap: 4px; }
    .fo-move { padding: 3px 7px 3px 5px; gap: 4px; }
    .fo-move svg { width: 13px; height: 13px; }
    .fo-move b { font-size: 9px; letter-spacing: 0.1em; }
    #fo-choose { padding: 8px 20px; font-size: 14px; align-self: end; }
  }
  #loginwarn { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(400px, 92vw); text-align: center; z-index: 60; }
  #loginwarn p { font-size: 13px; color: var(--text-2); line-height: 1.7; margin: 12px 0 16px; }
  .menu-stack { display: flex; flex-direction: column; align-items: center; gap: 6px; }


  /* ---------- HUD ---------- */
  #hud {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    display: flex; align-items: flex-end; justify-content: center; gap: 14px;
    padding: 0 20px calc(10px + var(--safe-b)); pointer-events: none;
  }
  #hud > * { pointer-events: auto; }
  /* vitals: life / mana / stamina bars, top left after the account icon. Each
     bar's length is its capacity (ui.refreshHud), hence align-items:flex-start.
     No pointer events: the corner of the world stays clickable. */
  #vitals {
    position: fixed; top: calc(14px + var(--safe-t)); left: 88px; z-index: 21;
    display: flex; flex-direction: column; gap: 3px; align-items: flex-start;
    width: auto; max-width: calc(100vw - 82px); pointer-events: none;
  }
  .vbar {
    position: relative; height: 15px; background: var(--well-2); width: 340px; max-width: 100%;
    border: 1px solid var(--line-strong); border-radius: 2px; overflow: hidden;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.6), 0 2px 10px rgba(0,0,0,0.6), inset 0 0 10px rgba(0,0,0,0.85);
    transition: width 0.25s ease;   /* levelling up visibly lengthens the bar */
  }
  .vfill { position: absolute; left: 0; top: 0; bottom: 0; width: 0%; transition: width 0.12s linear;
    box-shadow: inset 0 1px 0 rgba(var(--light-rgb), 0.22), inset 0 -2px 3px rgba(0, 0, 0, 0.35); }
  .vfill.hp { background: linear-gradient(var(--hp-top), var(--blood-lo)); box-shadow: inset 0 1px 0 rgba(var(--light-rgb), 0.28), inset 0 -2px 3px rgba(0, 0, 0, 0.35), 0 0 8px rgba(var(--blood-rgb), 0.35); }
  .vfill.mana { background: linear-gradient(var(--mana-top), var(--mana-lo)); }
  .vfill.stam { background: linear-gradient(var(--stam-top), var(--stam-lo)); }
  .vlabel, .vnum {
    position: absolute; top: 0; bottom: 0; display: flex; align-items: center;
    text-shadow: 0 1px 2px #000; pointer-events: none;
  }
  .vlabel { left: 7px; font-size: 8.5px; letter-spacing: 2px; color: rgba(var(--light-rgb), 0.78); }
  .vnum { right: 7px; font-size: 10.5px; font-weight: 600; color: var(--text-hi); font-variant-numeric: lining-nums tabular-nums; }
  #hud-mid { display: flex; flex-direction: column; align-items: center; gap: 6px; }
  #hud-bar {
    display: flex; align-items: center; gap: 8px; padding: 8px 14px;
    background: var(--panel-bg); border: 1px solid var(--line-strong); border-radius: 3px;
    box-shadow: var(--frame-shadow);
  }
  /* a desktop has no bar: the flasks and the spell stand apart in the bottom-right corner, the emotes and the
     chat in the bottom-left */
  body:not(.touch) #hud-bar { position: fixed; right: 16px; bottom: 16px; gap: 10px; padding: 0; background: none; border: none; box-shadow: none; }
  body:not(.touch) #hud-bar > .belt-slot, body:not(.touch) #hud-bar > .skill-slot {
    width: 52px; height: 52px; font-size: 23px; border-radius: 6px; background: rgba(var(--glass-rgb), 0.82); }
  body:not(.touch) #hud-bar > #emote-btn { position: fixed; left: 16px; bottom: 16px; border-radius: 50%; }
  body:not(.touch) #chatwrap { left: 80px; bottom: 22px; }
  .belt-slot, .skill-slot, .hud-btn { box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(var(--light-rgb), 0.04); }
  .belt-slot:hover, .skill-slot:hover, .hud-btn:hover { box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.6), 0 0 10px rgba(var(--witch-rgb), 0.22); }
  .belt-slot {
    position: relative; width: 42px; height: 42px; border: 1px solid var(--line-strong); border-radius: 2px;
    background: var(--well); display: flex; align-items: center; justify-content: center; font-size: 20px;
    cursor: pointer;
  }
  .belt-slot:hover { border-color: var(--line-hot); }
  .belt-slot.empty { opacity: 0.35; }
  .belt-count { position: absolute; bottom: 1px; right: 3px; font-size: 11px; font-weight: 600; color: var(--text-hi); text-shadow: 0 1px 2px #000; }
  .skill-slot {
    position: relative; width: 42px; height: 42px; border: 1px solid var(--line-strong); border-radius: 2px;
    background: var(--well); display: flex; align-items: center; justify-content: center; font-size: 19px;
    cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .skill-slot:hover { border-color: var(--line-hot); }
  .skill-slot:active { background: var(--raise-2); }
  .skill-key { position: absolute; bottom: 1px; right: 3px; font-size: 9px; color: var(--text-3); }
  body.touch .skill-key { display: none; }   /* no keyboard to name, wherever the cell rides */
  /* THE EMOTE PIE: a hub on the masks cell and the gestures round it; the slice the slide
     points at lights. A click-through sheet: the press that opened it owns the input */
  #emote-pie { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
  /* the veil: a blur under the ring that fades out to its rim, so what stands under it (the chat button a rung above
     the masks on a phone) goes soft instead of showing an outline half under a gesture; the hub (--hub, the masks
     cell) is left out of it */
  #emote-pie .pie-veil { position: fixed; border-radius: 50%;
    background: radial-gradient(closest-side, rgba(var(--glass-rgb), 0.55), rgba(var(--glass-rgb), 0.35) 60%, transparent);
    -webkit-backdrop-filter: blur(7px); backdrop-filter: blur(7px);
    -webkit-mask-image: radial-gradient(closest-side, transparent var(--hub), #000 calc(var(--hub) + 6%), #000 62%, transparent);
    mask-image: radial-gradient(closest-side, transparent var(--hub), #000 calc(var(--hub) + 6%), #000 62%, transparent); }
  #emote-pie .pie-hub { position: fixed; border-radius: 50%; border: 1px solid var(--witch-mid);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.8), 0 0 18px rgba(var(--witch-rgb), 0.25), inset 0 0 12px rgba(var(--witch-rgb), 0.15); }
  .emote-opt {
    position: fixed; width: 52px; height: 52px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 24px;
    background: rgba(var(--glass-rgb), .94); border: 1px solid var(--line-strong);
    box-shadow: 0 2px 10px rgba(0, 0, 0, .55); transition: transform .08s, border-color .08s, box-shadow .08s;
  }
  .emote-opt.hot { border-color: var(--witch-hi); background: var(--raise-2); transform: scale(1.14);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.8), 0 0 16px rgba(var(--witch-rgb), 0.45); }
  body.touch .emote-opt { width: 62px; height: 62px; font-size: 30px; }
  /* the identity circle: top right on the title, top left in game, one size
     everywhere, its menu hanging under it. The name lives inside the menu. */
  #acctwrap {
    position: fixed; z-index: 55;   /* above the title overlay (50) */
    top: calc(14px + var(--safe-t)); right: calc(14px + var(--safe-r));
  }
  /* the name heads the menu, one line, cut with an ellipsis: `width: 0` +
     `min-width: 100%` keeps a long name from widening the menu (the rows set
     its width) while the line still takes all of it */
  #acctname {
    display: none; width: 0; min-width: 100%; padding: 13px 20px 7px;
    color: var(--text-hi); font-size: 14px; letter-spacing: 1px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  #am-namesep { display: none; margin: 4px 12px 6px;
    background: linear-gradient(90deg, transparent, var(--line-strong) 16%, var(--line-strong) 84%, transparent); }
  /* in game the identity LINE under the bars carries the name already */
  body:not(.ingame) #acctmenu.am-named #acctname, body:not(.ingame) #acctmenu.am-named #am-namesep { display: block; }
  #acctbtn {
    position: relative; width: 62px; height: 62px; border-radius: 50%; flex: 0 0 auto;
    touch-action: none;  /* a tap target, never a zoom of any kind */
    background: rgba(var(--glass-rgb), .94); border: 1px solid var(--line-strong); box-shadow: 0 2px 10px rgba(0, 0, 0, .55);
    display: flex; align-items: center; justify-content: center; font-size: 22px; cursor: pointer;
    overflow: hidden; user-select: none; -webkit-tap-highlight-color: transparent;
  }
  body.touch #acctbtn { width: 56px; height: 56px; }
  /* a menu's button owns its press: a slide down it aims at a row (app.rs anchor_menu), never pans */
  #acctbtn, .lp-btn { touch-action: none; }
  #acctbtn:hover { border-color: var(--witch); box-shadow: 0 2px 10px rgba(0, 0, 0, .55), 0 0 14px rgba(var(--witch-rgb), 0.3); }
  /* overflow stays visible for the level ring; the picture clips itself */
  body.ingame #acctbtn { overflow: visible; }
  #acctbtn img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
  #acct-glyph svg { width: 30px; height: 30px; display: block; color: var(--text); }
  .am-sep { height: 1px; margin: 6px 10px; background: linear-gradient(90deg, transparent, var(--line), transparent); }
  .am-row.am-exit { letter-spacing: 0.09em; }
  .set-sec { font-size: 10.5px; letter-spacing: 0.2em; color: var(--witch); margin: 16px 0 4px; }
  /* a .pop-menu with a short fixed set of rows: no list cap, only the screen
     bounds it */
  #acctmenu { min-width: 244px; max-height: none; padding: 4px 0; }
  /* read at a glance mid-fight: big rows, no hairlines, one rule above the exit */
  .am-row {
    display: flex; align-items: center; gap: 9px; width: 100%;   /* full width, so rows align to the menu's edge */
    padding: 14px 20px; text-align: left; background: none; border: none;
    color: var(--text); font-size: 15px; letter-spacing: 1.2px; cursor: pointer;
  }
  .am-row:hover, .am-row:focus-visible, .am-row.hot { background: linear-gradient(90deg, rgba(var(--witch-rgb), 0.12), transparent 80%); color: var(--text-hi); box-shadow: inset 2px 0 0 var(--witch); outline: none; }
  .am-row.danger { color: var(--blood-soft); }
  .am-row.danger:hover { color: var(--blood-hi); background: linear-gradient(90deg, rgba(var(--blood-rgb), 0.12), transparent 80%); box-shadow: inset 2px 0 0 var(--blood); }
  /* in game the circle is the game menu: top left, vitals after it. Rows swap
     with the state (.am-game in play, .am-title on the title). */
  body.ingame #acctwrap { right: auto; left: 14px; }
  /* on the desktop title the circle stands left of fullscreen, which keeps the corner (touch has no fullscreen) */
  body:not(.touch):not(.ingame):not(:has(#fsbtn.hidden)) #acctwrap { right: calc(86px + var(--safe-r)); }   /* 14 + the 62px switch + 10 */
  /* fullscreen: the circle's twin, always in the corner. Over the hall (58),
     under the dialogs (60). Hidden on touch: iOS has no page fullscreen. */
  #fsbtn {
    position: fixed; z-index: 59; padding: 0;
    top: calc(14px + var(--safe-t)); right: calc(14px + var(--safe-r));
    width: 62px; height: 62px; border-radius: 50%;
    background: rgba(var(--glass-rgb), .94); border: 1px solid var(--line-strong); box-shadow: 0 2px 10px rgba(0, 0, 0, .55);
    display: flex; align-items: center; justify-content: center; color: var(--text);
    user-select: none; -webkit-tap-highlight-color: transparent;
  }
  #fsbtn:hover { border-color: var(--witch); box-shadow: 0 2px 10px rgba(0, 0, 0, .55), 0 0 14px rgba(var(--witch-rgb), 0.3); }
  #fsbtn svg { width: 30px; height: 30px; display: block; }
  /* in play it sits under the windows (.panel 30): a tall bag reaches the corner and its close X must win */
  body.ingame #fsbtn { z-index: 29; }
  body.touch #fsbtn, #fsbtn.hidden { display: none; }
  body.ingame .am-title { display: none; }
  body:not(.ingame) .am-game { display: none; }
  body:not(.signed) .am-signed { display: none; }
  /* settings: wide, left-aligned, tabbed */
  #settingspanel { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(640px, 94vw); max-height: min(88dvh, var(--win-fit)); overflow-y: auto; text-align: left; z-index: 60; }
  /* identity row: avatar · name over email · account actions. minmax(0, 1fr)
     gives a long name the panel's width instead of the avatar's. */
  #set-head { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px; align-items: center;
    margin: 6px 0 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line-faint); }
  #set-who { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
  #set-who #set-name {
    background: none; border: 1px solid transparent; border-radius: 3px; color: var(--text-hi);
    font-size: 21px; letter-spacing: 1px; padding: 3px 6px; width: 100%;
    text-overflow: ellipsis;   /* a name longer than the row still ends legibly */
  }
  #set-who #set-name:hover { border-color: var(--line); }
  #set-who #set-name:focus { border-color: var(--line-hot); outline: none; background: rgba(0, 0, 0, 0.3); }
  #set-who #set-email { font-size: 12px; color: var(--text-4); padding-left: 7px; }
  /* THE SECTIONS scale as a list: wide, a sidebar beside the open section; on a phone, a list of rows
     that opens one section full width (.drill) with a way back to the list */
  .set-tab {
    background: none; border: none; color: var(--text-3); text-align: left; cursor: pointer;
    font-size: 12.5px; letter-spacing: 1.5px;
  }
  .set-tab:hover { color: var(--text); }
  .set-tab.on { color: var(--text-hi); text-shadow: 0 0 12px rgba(var(--witch-rgb), 0.45); }
  .set-page { padding: 0 2px 4px; }
  #set-back { display: none; }
  @media (min-width: 641px) {
    #set-body { display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: 18px; align-items: start; }
    #set-tabs { display: flex; flex-direction: column; gap: 2px;
      border-right: 1px solid var(--line); padding-right: 10px; }
    .set-tab { padding: 9px 12px; border-left: 2px solid transparent; }
    .set-tab.on { border-left-color: var(--witch); }
  }
  @media (max-width: 640px) {
    #settingspanel:not(.drill) .set-page, #settingspanel.drill #set-tabs, #settingspanel.drill #set-head { display: none; }
    #set-tabs { display: flex; flex-direction: column; }
    .set-tab { display: flex; justify-content: space-between; align-items: center; min-height: 48px;
      padding: 0 6px; font-size: 14px; color: var(--text-2); border-bottom: 1px solid var(--line-faint); }
    .set-tab:last-child { border-bottom: none; }
    .set-tab::after { content: '\203A'; font-size: 20px; color: var(--text-4); }
    .set-tab.on { text-shadow: none; }
    #settingspanel.drill #set-back { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px;
      background: none; border: none; border-bottom: 1px solid var(--line); margin-bottom: 4px; padding: 0 6px;
      color: var(--text-hi); font-size: 14px; letter-spacing: 1.5px; cursor: pointer; text-align: left; }
    #set-back::before { content: '\2039'; font-size: 22px; color: var(--text-3); }
  }
  /* no account, nothing to change about one — not the name, not the picture */
  #set-head.anon #set-name { pointer-events: none; opacity: 0.75; }
  #set-head.anon #set-avatar-wrap { pointer-events: none; }
  #set-head.anon #set-picover { display: none; }
  /* styled stand-in for confirm(): a centred panel over a backdrop that swallows every click */
  #confirmwrap { position: fixed; inset: 0; z-index: 110; background: var(--veil); }   /* over every modal */
  #confirmbox { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(380px, 92vw); text-align: center; z-index: 71; }
  #confirm-msg { color: var(--text-2); font-size: 13.5px; line-height: 1.6; margin: 12px 6px 16px; }
  #confirmbox .btn { font-size: 14px; padding: 9px 26px; }
  #confirmbox .btn:focus { outline: 1px solid var(--line-hot); outline-offset: 2px; }
  /* the avatar opens its own picture menu; a camera overlay shows on hover */
  #set-avatar-wrap {
    position: relative; width: 64px; height: 64px; padding: 0; margin: 0; border-radius: 50%; overflow: hidden; cursor: pointer;
    border: 2px solid var(--line-strong); background: var(--well-2); display: flex; align-items: center; justify-content: center; font-size: 52px;
  }
  #set-avatar-wrap:hover { border-color: var(--line-hot); }
  #set-avatar-wrap:focus-visible { outline: 1px solid var(--witch); outline-offset: 2px; }
  #set-avatar-wrap img { width: 100%; height: 100%; object-fit: cover; }
  /* the camera, half-transparent over whatever is there — on hover, on keyboard
     focus, and while the menu it opens is up */
  #set-picover {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, 0.5); opacity: 0; transition: opacity .12s; pointer-events: none;
  }
  #set-picover svg { width: 26px; height: 26px; display: block; color: var(--text-hi); }
  #set-avatar-wrap:hover #set-picover, #set-avatar-wrap:focus-visible #set-picover,
  #set-pic.on #set-picover { opacity: 1; }
  /* a thumb has no hover: the camera rides a band along the foot of the circle
     instead, always there, so the tap is discoverable without one */
  body.touch #set-picover { opacity: 1; inset: auto 0 0 0; height: 40%; align-items: flex-start; }
  body.touch #set-picover svg { width: 15px; height: 15px; margin-top: 2px; }
  /* every settings row: the name on the left, the control on the right */
  .set-row { margin: 0; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 14px;
    padding: 9px 6px; border-bottom: 1px solid var(--line-faint); }
  /* the last SHOWN row draws no rule: rows hidden after it — by .hidden, or by the screen and account
     state (.am-title, .am-game, .am-signed above) — don't count */
  body.ingame.signed .set-row:not(:has(~ .set-row:not(.hidden, .am-title))),
  body.ingame:not(.signed) .set-row:not(:has(~ .set-row:not(.hidden, .am-title, .am-signed))),
  body:not(.ingame).signed .set-row:not(:has(~ .set-row:not(.hidden, .am-game))),
  body:not(.ingame):not(.signed) .set-row:not(:has(~ .set-row:not(.hidden, .am-game, .am-signed))) { border-bottom: none; }
  .set-row > span:last-child { display: flex; align-items: center; gap: 8px; }
  /* a row that opens something (Account's NFTs: the ledger): the whole row is the button, its value ends in the
     phone list's chevron */
  /* every control ends on the row's own edge: a button's margin would step it in from the language picker */
  .set-row .btn { margin: 0; }
  /* a row's hint line: what the chosen thing is FOR, under the row, carrying
     the row's own rule so the pair reads as one row */
  .set-hint { font-size: 11.5px; line-height: 1.5; color: var(--text-3); text-align: left; padding: 0 6px 9px; margin-top: -3px;
    border-bottom: 1px solid var(--line-faint); }
  .set-row:has(+ .set-hint:not(.hidden)), .set-row:has(+ .set-hint.hidden + .set-row.hidden:last-child),
  .set-hint:has(+ .set-row.hidden:last-child), .set-hint:last-child { border-bottom: none; }
  #set-vol, #set-vol-music { accent-color: var(--witch); width: 120px; }
  .set-label { font-size: 13px; letter-spacing: 0.6px; color: var(--text-2); text-align: left; }
  /* the account's email, read-only — one panel serves desktop and phone, so
     long addresses wrap instead of pushing the 92vw panel wide */
  #set-email { font-size: 12.5px; color: var(--text); overflow-wrap: anywhere; min-width: 0; text-align: left; }
  #set-status { min-height: 16px; font-size: 12px; font-style: italic; color: var(--good); }
  /* level-up celebration: heraldic banner drop — rays of light wheel behind a
     shield carrying the new level big, under a forked cloth ribbon. Built by
     em-ui; pointer-events none; self-dismisses. */
  #lvlbanner { position: fixed; left: 50%; top: 22%; z-index: 45; pointer-events: none; transform: translateX(-50%); text-align: center; }
  #lvlbanner .lb-wrap { position: relative; animation: lb-drop .55s cubic-bezier(.2, 1.5, .4, 1) both; }
  #lvlbanner.out .lb-wrap { animation: lb-out .45s ease-in both; }
  @keyframes lb-drop { from { transform: translateY(-110px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
  @keyframes lb-out { to { transform: translateY(-40px); opacity: 0; } }
  .lb-rays { position: absolute; left: 50%; top: 96px; width: 380px; height: 380px; margin: -190px 0 0 -190px; border-radius: 50%;
    background: repeating-conic-gradient(rgba(var(--witch-hi-rgb), .16) 0deg 11deg, rgba(var(--witch-hi-rgb), 0) 11deg 30deg);
    -webkit-mask-image: radial-gradient(circle, #000 0%, transparent 66%); mask-image: radial-gradient(circle, #000 0%, transparent 66%);
    animation: lb-spin 10s linear infinite; }
  @keyframes lb-spin { to { transform: rotate(360deg); } }
  .lb-ribbon { position: relative; display: inline-block; padding: 5px 36px; font-size: 14px; letter-spacing: 5px; color: var(--text-hi);
    background: var(--cta-bg); text-shadow: 0 1px 1px #000;
    clip-path: polygon(0 0, 100% 0, 93% 50%, 100% 100%, 0 100%, 7% 50%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .5); }
  .lb-shield { display: block; width: 124px; margin: 6px auto 0; filter: drop-shadow(0 8px 16px rgba(0, 0, 0, .65)) drop-shadow(0 0 18px rgba(var(--witch-rgb), .35)); }
  .lb-num { font-size: 46px; fill: var(--text-hi); }
  .hud-btn {
    width: 42px; height: 42px; border: 1px solid var(--line-strong); border-radius: 2px; background: var(--well);
    color: var(--text-2); font-size: 15px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
  }
  .hud-btn:hover { border-color: var(--line-hot); color: var(--text-hi); }
  .belt-slot:focus-visible, .skill-slot:focus-visible, .hud-btn:focus-visible { outline: 1px solid var(--witch); outline-offset: 1px; }
  .hud-btn svg { width: 24px; height: 24px; display: block; }
  /* controls wear the action glyphs; belt cells show the item instead.
     The drop shadow is needed where touch rings sit straight on the world. */
  .skill-slot svg, .hud-btn svg { pointer-events: none; color: var(--text-hi);
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.85)); }
  .skill-slot svg { width: 26px; height: 26px; display: block; }
  .emote-opt svg { width: 26px; height: 26px; color: var(--text-hi); }
  body.touch .emote-opt svg { width: 32px; height: 32px; }
  #set-glyph svg { width: 34px; height: 34px; display: block; color: var(--text-3); }
  .am-row > svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 9px; }
  .btn svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 6px; }
  .belt-slot img { width: 32px; height: 32px; display: block; pointer-events: none; image-rendering: auto; }
  /* THE BAG: the doll, the two shelves and the bar stay put; the pieces lie in a BAND a few cells tall that
     scrolls sideways like the shelves (a sideways swipe scrolls, a pull up toward the doll lifts the piece).
     A band fades at an edge with more beyond it (.more-l / .more-r) */
  #invpanel { display: flex; flex-direction: column; overflow: hidden; }
  #invpanel > * { flex: none; }
  .inv-row { display: flex; gap: 4px; padding: 2px 1px; }
  .inv-row > * { flex: none; }
  #inv-grid.inv-row { display: grid; grid-auto-flow: column; grid-template-rows: repeat(4, 40px); grid-auto-columns: 40px; }
  #inv-elements.inv-row { display: grid; grid-auto-flow: column; grid-template-rows: 40px; grid-auto-columns: 40px; }
  /* THE ARMED CELLS (the first spell, the two bottles on the belt): one frame, the panel's own line with
     the witchlight bracketed at its four corners */
  .armed { border-color: var(--witch-mid) !important; opacity: 1 !important;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(0, 0, 0, 0.8), 0 0 10px rgba(var(--witch-rgb), 0.22) !important; }
  .armed::before { content: ''; position: absolute; inset: 2px; pointer-events: none;
    background:
      linear-gradient(var(--witch-hi), var(--witch-hi)) top left / 7px 1px, linear-gradient(var(--witch-hi), var(--witch-hi)) top left / 1px 7px,
      linear-gradient(var(--witch-hi), var(--witch-hi)) top right / 7px 1px, linear-gradient(var(--witch-hi), var(--witch-hi)) top right / 1px 7px,
      linear-gradient(var(--witch-hi), var(--witch-hi)) bottom left / 7px 1px, linear-gradient(var(--witch-hi), var(--witch-hi)) bottom left / 1px 7px,
      linear-gradient(var(--witch-hi), var(--witch-hi)) bottom right / 7px 1px, linear-gradient(var(--witch-hi), var(--witch-hi)) bottom right / 1px 7px;
    background-repeat: no-repeat; filter: drop-shadow(0 0 2px rgba(var(--witch-rgb), 0.8)); }
  /* a count or a cost stays clear of the brackets */
  .armed .spell-cost, .armed .pot-n { right: 6px; bottom: 3px; }
  body.touch #thumbs .belt-slot img { width: 34px; height: 34px; }
  body.touch #thumbs .skill-slot svg { width: 40px; height: 40px; }
  body.touch #thumbs #skill-strike svg { width: 50px; height: 50px; }
  /* the identity line under the bars: name · souls, the name ellipsis-capped */
  #hud-id {
    display: flex; align-items: baseline; gap: 9px; margin-top: 3px;
    font-size: 12px; letter-spacing: 1px; color: var(--text);
    text-shadow: 0 1px 2px #000; pointer-events: none; white-space: nowrap;
  }
  /* what runs on her, after the souls (Dark Souls' row): the giver's art or the effect's glyph in its colour, a harm
     ringed red, the seconds left under it and stacks over it */
  #hud-fx { display: inline-flex; gap: 6px; margin-left: 4px; align-self: center; }
  #hud-fx .fxchip {
    position: relative; width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--fx); background: rgba(var(--glass-rgb), 0.82); box-shadow: 0 0 6px var(--fx); color: var(--fx); pointer-events: auto;
  }
  #hud-fx .fxchip.bad { border-color: #c0392b; box-shadow: 0 0 6px rgba(192, 57, 43, 0.8); }
  #hud-fx .fxchip img { width: 17px; height: 17px; }
  #hud-fx .fxchip svg { width: 13px; height: 13px; }
  #hud-fx .fxchip b, #hud-fx .fxchip i {
    position: absolute; left: 50%; transform: translateX(-50%); font-size: 9.5px; font-weight: 600; font-style: normal;
    color: var(--text-hi); letter-spacing: 0; text-shadow: 0 1px 2px #000; white-space: nowrap; line-height: 1;
  }
  #hud-fx .fxchip b { bottom: -11px; }
  #hud-fx .fxchip i { top: -9px; left: auto; right: -7px; transform: none; }

  #hud-name { max-width: 9em; overflow: hidden; text-overflow: ellipsis; }
  #hud-souls-wrap { font-size: 12px; color: var(--souls); }
  /* the level ring: xp progress outside the identity circle. 289 = 2π·46;
     rotate(90deg) starts the dash at 6 o'clock, under the level badge. */
  #lvlring { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); transform: rotate(90deg); pointer-events: none; display: none; }
  #lvlring circle { fill: none; stroke-width: 7; }
  #lvlring .lr-bg { stroke: rgba(var(--glass-rgb), 0.78); }
  #lvlring-fill { stroke: var(--witch); stroke-linecap: round; stroke-dasharray: 289; stroke-dashoffset: 289; transition: stroke-dashoffset 0.3s;
    filter: drop-shadow(0 0 3px rgba(var(--witch-rgb), 0.7)); }
  body.ingame #lvlring { display: block; }
  /* the level badge on the portrait's chin; both ends of the ring tuck behind it */
  #hud-level {
    position: absolute; left: 50%; bottom: -10px; transform: translateX(-50%);
    width: 19px; height: 19px; border-radius: 50%; z-index: 2;
    display: none; align-items: center; justify-content: center;
    background: radial-gradient(circle at 35% 30%, var(--witch-hi), var(--witch) 55%, var(--witch-lo));
    border: 1px solid var(--witch-deep); box-shadow: 0 1px 4px rgba(0, 0, 0, .6), 0 0 8px rgba(var(--witch-rgb), .5);
    color: var(--witch-ink); font-size: 10px; font-weight: 700; line-height: 1;

    pointer-events: none; user-select: none;
  }
  body.ingame #hud-level { display: flex; }


  /* ---------- zone banner ---------- */
  #zonebanner {
    position: fixed; top: 14%; left: 0; right: 0; z-index: 25; text-align: center;
    pointer-events: none; opacity: 0;
  }
  #zonebanner.show { animation: zb 3.4s ease forwards; }
  @keyframes zb { 0% {opacity:0; transform:translateY(8px);} 12% {opacity:1; transform:none;} 78% {opacity:1;} 100% {opacity:0;} }
  .zb-title { font-size: 34px; letter-spacing: 8px; color: var(--text-hi); text-shadow: 0 0 26px rgba(var(--witch-rgb), 0.4), 0 0 60px rgba(var(--light-rgb), 0.12), 0 2px 2px #000; }
  .zb-sub { font-size: 13px; font-style: italic; color: var(--text-2); letter-spacing: 3px; margin-top: 4px; }

  /* ---------- boss bar ---------- */
  #bossbar {
    position: fixed; top: 26px; left: 50%; transform: translateX(-50%); z-index: 25;
    width: min(520px, 70vw); text-align: center; pointer-events: none;
  }
  #bossname { font-size: 15px; letter-spacing: 3px; color: var(--arcane-hi); text-shadow: 0 1px 3px #000; }
  #bosstrack { margin-top: 5px; height: 10px; background: rgba(var(--glass-rgb), 0.85); border: 1px solid var(--arcane-line); border-radius: 2px; overflow: hidden; }
  #bossfill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--arcane-lo), var(--arcane)); transition: width 0.15s; }
  /* the TAB focus lock wears the lock's own red, not the boss purple */
  #bossbar.focus #bossname { color: var(--blood-pale); }
  #bossbar.focus #bosstrack { border-color: var(--blood-line); }
  #bossbar.focus #bossfill { background: linear-gradient(90deg, var(--blood-deep), var(--blood-soft)); }

  /* over a fight with a wanderer the bar is her menu's way in */
  #bossbar.peer { pointer-events: auto; cursor: pointer; }
  /* whoever has her locked, by name, quietly under the bar; a press takes them back */
  #lockedby {
    position: fixed; top: 62px; left: 50%; transform: translateX(-50%); z-index: 25;
    padding: 2px 10px; font-size: 11px; letter-spacing: 1px; color: var(--blood-pale);
    background: rgba(var(--glass-rgb), 0.7); border: 1px solid var(--blood-line); border-radius: 2px; cursor: pointer;
  }
  #lockedby::before { content: '\25C8\00A0'; opacity: 0.8; }
  #lockedby.hidden, body:not(.ingame) #lockedby { display: none; }

  /* THE INTERACT PROMPT (design/INTERACT.md): one line, the soulslike's context prompt. A desktop shows it low in the
     middle, over her feet's side of the screen, its key first; a touch screen makes it a button over the thumb cluster
     (no cell moves). The thing it names wears the outline in the world. */
  #interact {
    position: fixed; left: 50%; bottom: 21%; transform: translateX(-50%); z-index: 22;
    display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; max-width: min(360px, 80vw);
    font-size: 14px; color: var(--text-hi); white-space: nowrap;
    background: rgba(var(--glass-rgb), 0.78); border: 1px solid var(--line-strong); border-radius: 3px; cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  }
  #interact kbd { display: inline-block; min-width: 22px; padding: 2px 6px; text-align: center; font: inherit; font-size: 12px;
    border: 1px solid var(--line-strong); border-radius: 3px; background: var(--well); color: var(--text-hi); }
  #interact b { font-weight: normal; color: var(--witch-hi); letter-spacing: 0.04em; }
  #interact span { overflow: hidden; text-overflow: ellipsis; }
  #interact.hidden, body:not(.ingame) #interact { display: none; }
  body.touch #interact {
    left: auto; transform: none; right: calc(12px + var(--safe-r)); bottom: calc(256px + var(--safe-b));
    min-height: 48px; padding: 8px 16px; font-size: 15px; border-radius: 24px; touch-action: manipulation;
    -webkit-tap-highlight-color: transparent; max-width: calc(100vw - 100px);
  }
  body.touch #interact kbd { display: none; }
  body.touch #interact:active { background: var(--line); border-color: var(--line-hot); }
  @media (max-height: 520px) {
    body.touch #interact { bottom: calc(196px + var(--safe-b)); }
  }
  body.touch.tablet #interact { bottom: calc(var(--tsq) + var(--tq) + 2 * var(--tg)); }

  /* ---------- the controls glossary (a settings tab) ---------- */
  #glossary .gl-sec { font-size: 11px; letter-spacing: 0.18em; color: var(--witch); margin: 14px 0 6px; }
  #glossary .gl-sec:first-child { margin-top: 2px; }
  #glossary .gl-row { display: grid; grid-template-columns: 116px 1fr; gap: 10px; padding: 3px 0; align-items: baseline; }
  #glossary .gl-key { color: var(--text-hi); font-size: 12px; text-align: right; letter-spacing: 0.04em; }
  #glossary .gl-key b { display: inline-block; padding: 1px 6px; border: 1px solid var(--line-strong); border-radius: 3px; background: var(--well); box-shadow: inset 0 1px 0 rgba(var(--light-rgb), 0.06); font-weight: normal; }
  #glossary .gl-what { color: var(--text-2); font-size: 12px; line-height: 1.5; }

  /* ---------- the language picker ---------- */
  /* a drawn flag, never an emoji one (Windows renders no flag glyphs). The picker
     lives only as a row in Settings > General. */
  .langpick .lp-btn {
    display: flex; align-items: center; gap: 6px; cursor: pointer;
    background: rgba(var(--glass-rgb), 0.82); border: 1px solid var(--line-strong); border-radius: 4px;
    padding: 5px 7px; line-height: 0;
  }
  .langpick .lp-btn:hover { border-color: var(--line-hot); box-shadow: 0 0 10px rgba(var(--witch-rgb), 0.2); }
  .lp-flag { width: 24px; height: 16px; display: block; border-radius: 2px; overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.45); }
  .lp-flag svg { width: 100%; height: 100%; display: block; }
  .langpick .lp-caret { width: 0; height: 0; border: 4px solid transparent; border-top-color: var(--text-3); margin-top: 2px; }
  /* the anchored popover for every menu hung off a button (language, picture,
     account); scrollable so lists can grow. em-ui puts it in the top
     layer and sets top/left/max-height; inset and color undo popover UA defaults. */
  .pop-menu {
    position: fixed; inset: auto; color: inherit; min-width: 168px; max-width: calc(100vw - 16px);
    max-height: 232px; overflow-y: auto; overscroll-behavior: contain;
    background: var(--panel-bg); border: 1px solid var(--line-strong); border-radius: 4px;
    box-shadow: var(--frame-shadow); padding: 4px;
  }
  /* a finger that lands on a row still scrolls the list: the controls' `none`
     would pin it, and `pan-y` lets no zoom in either */
  .pop-menu button { touch-action: pan-y; }
  .pop-row {
    display: flex; align-items: center; width: 100%; cursor: pointer;
    background: none; border: 0; border-radius: 3px; padding: 7px 8px;
    font-size: 13px; color: var(--text-2); text-align: left;
  }
  .pop-row .lp-flag { margin-right: 11px; flex: 0 0 auto; }
  .pop-row:hover, .pop-row:focus-visible, .pop-row.hot { background: var(--raise-2); color: var(--text-hi); outline: none; }
  .pop-row.on { color: var(--witch); box-shadow: inset 2px 0 0 var(--witch); }
  .pop-row.danger { color: var(--blood-soft); }
  .pop-row.danger:hover { color: var(--blood-hi); background: rgba(var(--blood-rgb), 0.12); }
  body.touch .pop-row { padding: 11px 9px; font-size: 14px; }
  body.touch .lp-flag { width: 28px; height: 19px; }
  body.touch .pop-menu { max-height: calc(var(--vvh) * 0.46); }

  /* ---------- panels ---------- */
  .panel {
    position: fixed; z-index: 30; background: var(--panel-bg);
    border: 1px solid var(--line-strong); border-radius: 3px; box-shadow: var(--frame-shadow);
    padding: 14px;
    /* never taller than what is on screen (--win-fit): it scrolls inside, under its header */
    max-height: var(--win-fit); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  }
  .panel h2 {
    font-size: 15px; font-weight: normal; letter-spacing: 3px; color: var(--text-hi);
    text-shadow: 0 1px 0 #000, 0 0 16px rgba(var(--witch-rgb), 0.35);
    /* the h2 is the drag handle: the negative margin, paid
       back as padding, makes the grab start at the window's own edge. It is the window's HEADER: it holds the
       close and stays put while the window scrolls under it, on the window's own top background (sticky
       counts from the padding: -14px is the window's edge) */
    position: sticky; top: -14px; z-index: 3; background: var(--panel-bg); border-radius: 3px 3px 0 0;
    margin: -14px -14px 10px; padding: 14px 40px 8px 14px;   /* the right is the close button's */
    cursor: move; touch-action: none;   /* a finger on the bar moves the window, never scrolls it */
  }
  .panel.win-drag, .panel.win-drag h2 { cursor: grabbing; }
  .panel.win-drag { box-shadow: var(--frame-shadow), 0 0 0 1px var(--witch-deep), 0 0 32px rgba(var(--witch-rgb), 0.14); }
  .panel h2::after {
    content: ''; position: absolute; left: 14px; right: 14px; bottom: 0; height: 1px;
    background: linear-gradient(90deg, var(--witch-mid), var(--line) 45%, transparent);
    box-shadow: 0 0 6px rgba(var(--witch-rgb), 0.25);
  }
  /* a small X with a finger-sized target */
  .panel-close {
    position: absolute; top: 0; right: 0; width: 40px; height: 38px; padding: 0;
    display: flex; align-items: center; justify-content: center;
    background: none; border: none; color: var(--text-3); font-size: 16px; cursor: pointer;
  }
  body.touch .panel-close { width: 52px; height: 48px; }
  body.touch .panel h2 { padding-right: 52px; }
  .panel-close:hover, .panel-close:focus-visible { color: var(--witch-hi); outline: none; }
  .panel-close svg { width: 15px; height: 15px; display: block; }
  .mint-badge svg { width: 10px; height: 10px; display: block; }
  .tt-minted svg { width: 12px; height: 12px; vertical-align: -1px; }
  .tt-minted a, .ledger-row a { color: var(--cmp-up); }
  #ledger-title > svg, #set-title > svg, #adminv-title > svg { width: 15px; height: 15px; vertical-align: -2px; margin-right: 6px; }
  .p-leave svg { width: 12px; height: 12px; vertical-align: -2px; }
  /* the height cap keeps the bag clear of the corner chrome; it scrolls inside */
  #invpanel { right: 16px; top: 50%; transform: translateY(-50%); width: 336px; max-height: min(calc(var(--vvh) - 110px), var(--win-fit)); }
  /* the character sheet: two tabs, the stats table (it opens on it) or her full-height figure alone */
  #charpanel { left: 16px; top: 50%; transform: translateY(-50%); width: min(380px, calc(100vw - 32px)); }
  #char-tabs { display: flex; gap: 4px; margin: -2px 0 12px; border-bottom: 1px solid var(--line); }
  .char-tab { flex: 1; background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
    padding: 8px 6px; color: var(--text-3); cursor: pointer; font-size: 12.5px; letter-spacing: 1.5px; text-transform: uppercase; }
  .char-tab:hover { color: var(--text); }
  .char-tab.on { color: var(--text-hi); border-bottom-color: var(--witch); text-shadow: 0 0 12px rgba(var(--witch-rgb), 0.45); }
  #charpanel:not([data-tab="character"]) #char-figure, #charpanel[data-tab="character"] #char-stats { display: none; }
  /* a live 3D stage, unframed (the client's doll stage); a drag turns her */
  #char-figure { position: relative; height: min(470px, calc(var(--vvh) - 200px)); touch-action: none; cursor: grab; }
  #char-figure:active { cursor: grabbing; }
  #char-figure canvas.doll-stage { position: absolute; inset: 0; width: 100%; height: 100%; }
  #char-wait svg { width: 72px; height: 72px; }

  /* the doll is a body, three rows: the belt's eatables in the top-left corner beside the top and the weapon hand;
     the ring, the bottom and the gloves; the legs and the shoes side by side (Valy 10-31: the spell cell gone, the
     book is the account menu's Spells). Head, bra and panties have no area: em-ui hides a cell no base can fill (so
     [hidden] must beat the flex below), and once one can be filled it flows into the free cell, then a row of its own. */
  #paperdoll { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 12px;
    grid-template-areas: 'belt top weapon' 'ring bottom gloves' '. legs shoes'; }
  #eq-chest { grid-area: top; } #eq-weapon { grid-area: weapon; }
  #eq-trinket { grid-area: ring; } #eq-legs { grid-area: bottom; } #eq-gloves { grid-area: gloves; }
  #eq-hose { grid-area: legs; } #eq-boots { grid-area: shoes; }
  .slot[hidden] { display: none; }
  /* the belt: its cells the eatables she drinks from the HUD, side by side in one doll cell */
  #doll-belt { grid-area: belt; display: flex; gap: 6px; }
  #doll-belt .slot.belt-cell { flex: 1; width: auto; height: 52px; }
  #paperdoll .slot.eq, #doll-belt .slot.belt-cell { min-width: 0; }
  .belt-cell img, .pot-stack img { width: 30px; height: 30px; pointer-events: none; }
  .belt-cell .pot-n, .pot-stack .pot-n { position: absolute; bottom: 1px; right: 3px; font-size: 10px; font-weight: 600; color: var(--text-hi); text-shadow: 0 1px 2px #000; }
  .slot.belt-cell.target { border-color: var(--witch); animation: eqpulse 1.1s ease-in-out infinite; }
  .slot.belt-cell.drop-hover { background: rgba(var(--witch-rgb), 0.2); }
  .slot {
    position: relative; width: 48px; height: 48px; background: var(--well);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.7);
    border: 1px solid var(--line); border-radius: 2px;
    display: flex; align-items: center; justify-content: center;
    font-size: 9px; color: var(--text-4); letter-spacing: 1px; cursor: default;
  }
  .slot.eq { width: 100%; height: 52px; }
  .slot.filled { cursor: pointer; }
  .slot.filled:hover { border-color: var(--line-hot); background: var(--raise); box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.6), 0 0 10px rgba(var(--witch-rgb), 0.2); }
  /* rarity rims come from the RARITY table itself (--r-*, published by em-ui), dimmed
     into the frame so the colour reads without shouting over the picture */
  .slot.r-magic { border-color: color-mix(in srgb, var(--r-magic) 55%, var(--well)); box-shadow: inset 0 0 10px color-mix(in srgb, var(--r-magic) 16%, transparent); }
  .slot.r-rare { border-color: color-mix(in srgb, var(--r-rare) 58%, var(--well)); box-shadow: inset 0 0 10px color-mix(in srgb, var(--r-rare) 16%, transparent); }
  .slot.r-legendary { border-color: color-mix(in srgb, var(--r-legendary) 65%, var(--well)); box-shadow: inset 0 0 12px color-mix(in srgb, var(--r-legendary) 24%, transparent); }
  /* selection is an outline, declared after the rarity rules: a border-color
     at their specificity would lose to them */
  .slot.selected {
    outline: 2px solid var(--witch-hi); outline-offset: 1px;
    box-shadow: 0 0 12px rgba(var(--witch-rgb), 0.55), inset 0 0 8px rgba(var(--witch-hi-rgb), 0.12);
  }
  #inv-grid .slot { width: 40px; height: 40px; }
  #inv-grid .slot canvas { width: 30px; height: 30px; }
  .mint-badge {
    position: absolute; top: -1px; right: 1px; font-size: 10px; color: var(--blood-hi);
    text-shadow: 0 0 6px rgba(var(--blood-rgb), 0.8);
  }
  #inv-meta { display: flex; justify-content: space-between; margin-top: 8px; font-size: 11px; color: var(--text-3); }
  .spell-cost { position: absolute; right: 3px; bottom: 1px; font-family: var(--font-text); font-size: 9.5px; letter-spacing: 0; color: var(--mana-top); }
  #inv-elements .slot { width: 40px; height: 40px; }
  /* what a row asks (met, short) and what it grows with */
  .tt-req, .tt-scale { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
  .tt-req-ok { color: var(--text-2); }
  .tt-req-no { color: var(--blood-hi); }
  .tt-scale b { color: var(--witch-hi); font-weight: 600; }
  /* THE SPELL BOOK: a star chart grown out of one heart in every direction (grimoire.rs: a radial tidy tree), bigger
     than its window: a drag pans it, the wheel or a pinch zooms it. Under it the row of her parchments.
     LEAN AND STILL: nothing here animates at rest, blurs or casts a shadow (a drag's drop cells pulse while it lasts); the plane is a layer of its own only while a
     gesture moves it (.moving), so a pan never repaints the sky under it. The palette is the windows': iron discs,
     bone for what she knows, the witch's green for what she can learn, ash for the rest, one ember for the armed. */
  /* it opens from the account menu's Spells, where the bag stands, in front of it */
  #spellpanel { right: 16px; top: 50%; transform: translateY(-50%); width: min(760px, calc(100vw - 12px)); max-height: min(calc(var(--vvh) - 40px), var(--win-fit)); overflow: hidden; }
  #spellpanel h2 { margin-bottom: 0; }
  /* the sky and the shelf fill the window under its header, edge to edge: the shelf a row of the bag's cells under
     the sky (a finger lifts a piece by pulling it up, a sideways swipe scrolls the row) */
  #spell-body { display: flex; flex-direction: column; margin: 0 -14px -14px; height: clamp(260px, calc(var(--vvh) - 130px), 560px); }
  body.touch #spell-body { height: clamp(280px, calc(var(--vvh) - 172px - var(--safe-t) - var(--safe-b)), 820px); }
  /* a finger on the sky pans the chart, never the page */
  #spell-sky {
    position: relative; flex: 1; min-width: 0; min-height: 0; overflow: hidden; contain: strict;
    touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab;
    background: radial-gradient(120% 100% at 50% 50%, #0a0f10, #050708 75%);
  }
  #spellpanel.win-drag #spell-sky, #spell-sky:active { cursor: grabbing; }
  #spell-sky * { touch-action: none; }
  #spell-dock { flex: none; align-items: center; min-height: 40px; padding: 8px 10px; border-top: 1px solid var(--line); background: var(--well); }
  #spell-dock .slot { width: 40px; height: 40px; touch-action: pan-x; }
  #spell-dock .slot canvas { width: 30px; height: 30px; }
  /* none carried: one muted line where they are found */
  #spell-dock .sb-none { flex: 1; padding: 2px 4px; font-size: 11px; line-height: 1.4; color: var(--text-4); }
  #spell-plane { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-origin: 0 0; }
  #spell-plane.moving { will-change: transform; }
  .sb-lines { position: absolute; left: 0; top: 0; overflow: visible; }
  .sb-lines line { stroke-linecap: round; vector-effect: non-scaling-stroke; }
  .sb-stars circle { fill: #b9c4c0; opacity: 0.16; }
  .sb-stars circle.b { opacity: 0.38; }
  /* the tree's rings: guides, barely there */
  .sb-ring { fill: none; stroke: #8d9995; stroke-width: 1; stroke-dasharray: 1 7; opacity: 0.16; vector-effect: non-scaling-stroke; }
  /* the branches: thin ash, dotted toward what she does not know, solid along what she does */
  .sb-link, .sb-trunk { stroke: #5d6865; stroke-width: 1.2; stroke-dasharray: 1 5; }
  .sb-link.lit, .sb-trunk.lit { stroke: #a39e8f; stroke-width: 1.4; stroke-dasharray: none; opacity: 0.8; }
  .sb-link.planned { opacity: 0.45; }
  /* THE HEART: her grimoire, a plain disc a ring inside a ring */
  .sb-heart {
    position: absolute; left: 0; top: 0; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; pointer-events: none; color: #b8b09c;
    background: #0d1213; border: 1px solid #4b5654; outline: 1px solid #263130; outline-offset: 4px;
  }
  .sb-heart svg { width: 30px; height: 30px; }
  /* a school: a small disc on the first ring, its colour only a tint on its rim and glyph; its name small, low */
  .sb-school { position: absolute; width: 140px; margin: -24px 0 0 -70px; display: flex; flex-direction: column; align-items: center; pointer-events: none; }
  .sb-sigil {
    width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    background: #0b1011; border: 1px solid color-mix(in srgb, var(--c) 24%, #2f3e3b);
    color: color-mix(in srgb, var(--c) 22%, #7d8985);
  }
  .sb-sigil svg { width: 24px; height: 24px; }
  .sb-sname { margin-top: 5px; font-family: var(--font-rune); font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: color-mix(in srgb, var(--c) 18%, var(--text-4)); text-shadow: 0 1px 0 #000; }
  /* a spell: an iron disc on a thin rim, its glyph in the colour of its state */
  .sb-node { position: absolute; width: 56px; height: 56px; margin: -28px 0 0 -28px; cursor: pointer; outline: none; border-radius: 50%; }
  .sb-medal {
    width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    background: #0b1011; border: 1.5px solid #2a3433; color: #5a6562;
  }
  .sb-medal svg { width: 26px; height: 26px; }
  /* known: bone */
  .sb-node.known .sb-medal { border-color: #7d786b; color: #d6cfbd; background: #101516; }
  /* armed: the one ember on the chart, the brightest thing in it (Valy 10-31: "more highlighted"): a lit rim, a
     double ring, an ember halo (a still gradient, no blur) and its word under it */
  .sb-node.known.on { z-index: 2; }
  .sb-node.known.on::before {
    content: ''; position: absolute; left: 50%; top: 50%; width: 124px; height: 124px; margin: -62px 0 0 -62px; border-radius: 50%; pointer-events: none;
    background: radial-gradient(closest-side, rgba(255, 176, 84, 0.42), rgba(255, 150, 60, 0.14) 62%, transparent);
  }
  .sb-node.known.on .sb-medal {
    position: relative; border: 2.5px solid #ffbf66; color: #ffe0a8;
    background: radial-gradient(circle at 50% 38%, #5a3510, #1c1209 78%);
    outline: 2px solid rgba(255, 191, 102, 0.85); outline-offset: 3px;
  }
  .sb-armed {
    position: absolute; left: 50%; top: 100%; transform: translate(-50%, 9px); pointer-events: none; white-space: nowrap;
    padding: 1px 7px; border-radius: 2px; background: #ffbf66; color: #1c1209;
    font-size: 9.5px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase;
  }
  /* ready to learn (its parchment in the bag): the witch's green, faint */
  .sb-node.can .sb-medal { border-color: var(--witch-lo); color: color-mix(in srgb, var(--witch) 75%, #5a6562); }
  /* within reach, sealed: ash, the sealed darker */
  .sb-node.open .sb-medal { color: #66716e; }
  .sb-node.locked .sb-medal { border-color: #1f2827; color: #3f4947; }
  /* planned (not yet in the moor): ash on a dotted rim */
  .sb-node.planned .sb-medal { border: 1.5px dotted #3a4442; color: #434d4b; background: #090d0e; }
  .sb-node:hover .sb-medal, .sb-node:focus-visible .sb-medal { border-color: #8d9995; }
  .sb-node.known.on:hover .sb-medal { border-color: #ffd08a; }
  .sb-node:focus-visible .sb-medal { outline: 1px solid var(--witch-hi); outline-offset: 3px; }
  /* a piece lifted: each star that takes it is a drop cell in the bag's own language (.slot.eq.target: the witch's
     rim and its pulse, only while the drag lasts), filled under the pointer (drop-hover) */
  .sb-node.target .sb-medal { border: 1.5px solid var(--witch); color: var(--witch-hi); animation: eqpulse 1.1s ease-in-out infinite; }
  .sb-node.drop-hover .sb-medal { background: rgba(var(--witch-rgb), 0.2); }
  .tt-state { font-size: 11.5px; color: var(--witch-hi); margin-top: 4px; }
  /* THE MENTOR: her stats; + and − place points unsaved (shown "+n" on the stat), Save spends them */
  /* a talk opens it beside her, where a trader's shop stands (it had no anchor: it opened in the top-left corner) */
  #mentorpanel { right: 16px; top: 50%; transform: translateY(-50%); width: min(320px, calc(100vw - 12px)); max-height: min(calc(var(--vvh) - 110px), var(--win-fit)); }
  .mt-row { align-items: center; gap: 8px; }
  .mt-row b { margin-left: auto; }
  .mt-row .btn { padding: 2px 9px; min-width: 28px; }
  .mt-row .mt-up { color: var(--cmp-up); }
  .mt-save { display: flex; justify-content: flex-end; margin-top: 8px; }
  /* shut like every other disabled button (.btn.primary would keep its blood) */
  #mentor-save:disabled { background: var(--btn-bg); border-color: var(--line); color: var(--text-4); box-shadow: none; }
  .tt-armed { font-size: 9px; letter-spacing: 1.5px; color: var(--witch); vertical-align: 2px; margin-left: 4px; }
  .tt-line { font-style: italic; color: var(--text-3); }
  #inv-poise.burdened { color: var(--blood-hi); }
  /* the bag's shelves */
  .inv-sec {
    display: flex; justify-content: space-between; align-items: baseline;
    margin: 10px 0 5px; padding-bottom: 3px; border-bottom: 1px solid var(--line-faint);
    font-size: 10px; letter-spacing: 2px; color: var(--witch);
  }
  /* the shelf's name is carved; the hint beside it is a sentence */
  .inv-sec > span { font-family: var(--font-text); font-size: 10.5px; letter-spacing: 0.5px; color: var(--text-3); }
  /* an empty shelf is hidden: [hidden] must beat the flex above */
  .inv-sec[hidden] { display: none; }
  .inv-empty { font-size: 10.5px; color: var(--text-4); padding: 1px 0 3px; }

  .cs-row { display: flex; justify-content: space-between; font-size: 12.5px; padding: 3px 2px; color: var(--text-2); }
  .cs-row b { color: var(--text-hi); font-weight: normal; }
  .cs-row.trophy span { color: var(--witch-hi); }
  .cs-sep { height: 1px; background: linear-gradient(90deg, transparent, var(--line-strong), transparent); margin: 6px 0; }

  /* ---------- tooltip ---------- */
  /* the item card rides above the window stack; em-ui re-pins it when the stack is re-dealt */
  #tooltip {
    position: fixed; z-index: 70; max-width: 260px; pointer-events: none;
    background: var(--panel-bg);
    border: 1px solid var(--line-strong); border-radius: 2px;
    padding: 10px 12px; box-shadow: var(--frame-shadow); line-height: 1.35;
  }
  /* the CARD variant (touch): same box, but it takes taps — ✕ to close, the
     item's actions right inside it */
  #tooltip.card { pointer-events: auto; padding-right: 26px; }
  #tooltip .tt-x { position: absolute; top: 5px; right: 5px; padding: 4px; color: var(--text-3); cursor: pointer; }
  body.touch #tooltip .tt-x { top: 0; right: 0; padding: 14px; }
  #tooltip .tt-x svg { width: 12px; height: 12px; display: block; }
  /* wrap: a worn piece's card carries three buttons, too wide for a phone row */
  #tooltip .tt-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
  /* select a bag item and its HOME CELL glows — that cell is the equip button.
     While a pinned item rides the finger, the same glow shows the drop target. */
  .slot.eq.target {
    border-color: var(--witch);
    animation: eqpulse 1.1s ease-in-out infinite;
  }
  .slot.eq.drop-hover { background: rgba(var(--witch-rgb), 0.2); }
  /* a cell a garment holds from another cell (a dress's legs): the same piece,
     ghosted behind a dashed rim. Hovering any of its cells outlines all (kin). */
  .slot.eq.held { border-style: dashed; }
  .slot.eq.held canvas { opacity: 0.38; filter: saturate(0.5); }
  .slot.eq.kin { outline: 1px solid rgba(var(--witch-rgb), 0.55); outline-offset: 1px; }
  @keyframes eqpulse {
    0%, 100% { box-shadow: 0 0 6px rgba(var(--witch-rgb), 0.35), inset 0 0 6px rgba(var(--witch-rgb), 0.18); }
    50% { box-shadow: 0 0 16px rgba(var(--witch-rgb), 0.75), inset 0 0 10px rgba(var(--witch-rgb), 0.35); }
  }
  .slot.lift { opacity: 0.35; }
  /* a worn piece dragged off the doll lights the bag as one target cell */
  #inv-grid.target { outline: 1px solid var(--witch); outline-offset: 2px; border-radius: 3px; animation: eqpulse 1.1s ease-in-out infinite; }
  #inv-grid.drop-hover { background: rgba(var(--witch-rgb), 0.12); }
  #drag-ghost { position: fixed; z-index: 90; pointer-events: none; transform: scale(1.2); filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.75)); }
  /* the ghost is sized by em-ui to the icon in the cell it left; its face (a canvas, a bottle's picture) fills it */
  #drag-ghost > * { display: block; width: 100%; height: 100%; object-fit: contain; }
  /* over the world, out of the window: let go and it falls at her feet */
  #drag-ghost.drop-out { transform: scale(1.05) rotate(-8deg); opacity: 0.85;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.8)) drop-shadow(0 0 10px rgba(216, 58, 51, 0.6)); }
  .tt-name { font-size: 15px; margin-bottom: 2px; text-shadow: 0 1px 0 #000; }
  .tt-base { font-size: 11px; color: var(--text-3); margin-bottom: 6px; padding-bottom: 5px; border-bottom: 1px solid var(--line-faint); letter-spacing: 0.3px; }
  .tt-imp { font-size: 12.5px; font-weight: 600; color: var(--text-hi); margin-bottom: 4px; }
  /* affixes read neutral: blue/red belong to the vs-worn comparison alone */
  .tt-affix { font-size: 12.5px; color: var(--text); padding: 1px 0; }
  .tt-cmp-head { font-size: 10.5px; letter-spacing: 1px; color: var(--text-3); margin-top: 6px; border-top: 1px solid var(--line-faint); padding-top: 5px; }
  .tt-cmp-up { font-size: 12.5px; color: var(--cmp-up); padding: 1px 0; }
  .tt-cmp-dn { font-size: 12.5px; color: var(--cmp-dn); padding: 1px 0; }
  .tt-minted { font-size: 11px; color: var(--blood-soft); margin-top: 6px; }
  .tt-minted.tt-token, .tt-minted.tt-token a { color: var(--mint-hi); }
  .tt-minted.tt-minting { color: var(--text-3); }
  #tooltip:has(.tt-token) { border-color: var(--mint-mid); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.85), 0 0 14px rgba(var(--mint-rgb), 0.4); }
  .tt-hint { font-size: 10.5px; color: var(--text-4); font-style: italic; margin-top: 6px; }

  .spin {
    display: inline-block; width: 10px; height: 10px; border: 2px solid var(--witch-deep); border-top-color: var(--witch-hi);
    border-radius: 50%; animation: spin 0.8s linear infinite; margin-right: 6px; vertical-align: -1px;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  /* ---------- waypoints ---------- */
  #wppanel { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(430px, 92vw); }
  /* the totem she stands at is hers to name: its title is a tap away from a field */
  #wp-title.wp-namable { cursor: text; border-bottom: 1px dashed transparent; }
  #wp-title.wp-namable:hover { border-bottom-color: var(--line-strong); }
  #wp-name { font: inherit; letter-spacing: inherit; text-transform: uppercase; color: var(--text-hi); width: 15em; max-width: 70%;
    background: var(--well); border: 1px solid var(--line-hot); border-radius: 2px; padding: 1px 6px; }
  #wp-name:focus { outline: none; }
  #wp-body { max-height: calc(var(--vvh) * 0.56); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  /* the admin inventory: every base as icon · name · a drop button, one scroll */
  #adminvpanel { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(430px, 92vw); }
  #ai-body { max-height: calc(var(--vvh) * 0.62); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .ai-row { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 2px; border-bottom: 1px solid var(--line-faint); }
  .ai-row:last-child { border-bottom: none; }
  .ai-row canvas { flex: 0 0 auto; image-rendering: auto; }
  .ai-name { flex: 1; font-size: 12.5px; color: var(--text); line-height: 1.25; }
  .ai-name small { display: block; font-size: 10px; color: var(--text-4); letter-spacing: 0.5px; }
  .ai-drop { font-size: 10.5px; padding: 3px 10px; }
  .wp-row { padding: 7px 10px; margin: 5px 0; background: rgba(var(--way-rgb), 0.5); border: 1px solid var(--way-line);
    border-radius: 4px; color: var(--way-text); cursor: pointer; }
  .wp-row:hover { background: rgba(var(--way-rgb), 0.85); border-color: var(--way-hot); }
  .wp-name { font-size: 14px; color: var(--way-name); }
  .wp-sub { font-size: 10.5px; color: var(--way-sub); font-style: italic; margin-top: 2px; }

  /* ---------- tags (design/TAGS.md): the paint-a-tag window and a painted tag's card; --tag is the row's paint ---------- */
  #tagpanel { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(430px, 92vw); }
  #tag-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px;
    max-height: calc(var(--vvh) * 0.62); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .tag-opt { display: flex; align-items: center; gap: 9px; padding: 7px 9px; background: var(--well); color: var(--text);
    border: 1px solid var(--line-strong); border-radius: 4px; font: inherit; font-size: 12.5px; text-align: left; cursor: pointer; }
  .tag-opt:hover { border-color: var(--tag); box-shadow: 0 0 10px color-mix(in srgb, var(--tag) 35%, transparent); }
  .tag-opt svg { flex: 0 0 auto; width: 26px; height: 26px; color: var(--tag); filter: drop-shadow(0 0 4px color-mix(in srgb, var(--tag) 55%, transparent)); }
  body.touch .tag-opt { min-height: 48px; font-size: 13.5px; }
  #tagcard { left: 50%; top: calc(var(--hud-h, 70px) + 16px); transform: translateX(-50%); width: min(340px, 92vw); }
  #tagcard h2 { display: flex; align-items: center; gap: 10px; }
  #tagc-glyph svg { width: 30px; height: 30px; color: var(--tag); filter: drop-shadow(0 0 5px color-mix(in srgb, var(--tag) 60%, transparent)); }
  #tagc-say { flex: 1; color: var(--text-hi); text-transform: none; letter-spacing: 0.3px; }
  #tagc-by { font-size: 12px; color: var(--text-3); margin: 6px 0 0; }
  #tagc-by b { color: var(--text-hi); font-weight: 600; }
  #tagcard .set-row { margin-top: 8px; }
  body:not(.touch) #hud-bar > #btn-tag { position: fixed; left: 16px; bottom: 80px; width: 52px; height: 52px; border-radius: 50%;
    background: rgba(var(--glass-rgb), 0.82); }
  #btn-tag svg { width: 24px; height: 24px; }
  /* the brush is the chat button's twin on a phone, one step right of the emotes on their rung (Valy 11-16: "make the
     paint pattern the same as the chat box pattern, but located to the right from the gestures wheel") */
  body.touch #btn-tag {
    position: fixed; z-index: 21;
    left: calc(10px + 58px + 12px + var(--safe-l));
    bottom: calc(var(--rail0, 14px) + var(--safe-b));
    width: 58px; height: 58px; border-radius: 50%; border-width: 2px;
    background: rgba(var(--glass-rgb), 0.82); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
    transition: opacity 0.12s;
  }
  body.touch #btn-tag svg { width: 26px; height: 26px; }
  body.touch:not(.ingame) #btn-tag { display: none; }
  body.touch.pie-open #btn-tag { opacity: 0; pointer-events: none; }
  @media (max-height: 520px) {
    body.touch #btn-tag { left: calc(10px + 52px + 10px + var(--safe-l)); bottom: calc(var(--rail0) + var(--safe-b)); width: 52px; height: 52px; }
  }
  body.touch.tablet #btn-tag { left: calc(var(--tm) + var(--safe-l) + 2 * (var(--tq) + var(--tg))); bottom: var(--tbt); width: var(--tq); height: var(--tq); }

  /* ---------- ledger ---------- */
  /* the wallet shrine's window, placed like the traders' shop (right of centre, the shrine stays in view) */
  #ledgerpanel { right: 16px; top: 50%; transform: translateY(-50%); width: min(430px, 94vw); }
  /* the modal veil: settings dims the game and takes every click behind it */
  #modalveil { position: fixed; inset: 0; z-index: 100; background: var(--veil); }
  #settingspanel { z-index: 101; }
  .ledger-row { display: flex; align-items: center; gap: 10px; font-size: 12.5px; padding: 6px 2px; border-bottom: 1px solid var(--line-faint); }
  .ledger-row .slot { flex: 0 0 auto; width: 40px; height: 40px; cursor: default; }
  .ledger-row .slot canvas { width: 30px; height: 30px; }
  .ledger-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
  .ledger-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ledger-st { font-size: 11px; color: var(--text-3); }
  .ledger-deposit { flex: 0 0 auto; }
  .ledger-row[data-st="minted"] { background: linear-gradient(90deg, rgba(var(--mint-rgb), 0.11), transparent 72%); }
  .ledger-row[data-st="minted"] .ledger-st, .ledger-row[data-st="minted"] a { color: var(--mint-hi); }
  /* A MINTED PIECE, a real token (Valy 11-03: "a highlight ... to denote that they are very different"): the armed
     frame's language in gold, so it reads as one design family: four corner brackets over a lit rim, a glowing
     perimeter and a gold cell. Told apart by shape as well as colour (redundant coding, WCAG 1.4.1): rare's rim is a
     yellow too, so the brackets and the chain carry it. Still: nothing here animates, and a shut window paints nothing */
  .slot.filled.minted { border-color: var(--mint-mid);
    background: linear-gradient(160deg, rgba(var(--mint-rgb), 0.3), rgba(122, 86, 20, 0.34) 55%, rgba(58, 38, 8, 0.46));
    box-shadow: inset 0 0 8px rgba(var(--mint-rgb), 0.32), 0 0 0 1px rgba(0, 0, 0, 0.85), 0 0 9px rgba(var(--mint-rgb), 0.6); }
  .slot.filled.minted:hover { border-color: var(--mint-hi); box-shadow: inset 0 0 10px rgba(var(--mint-rgb), 0.45), 0 0 0 1px rgba(0, 0, 0, 0.85), 0 0 13px rgba(var(--mint-rgb), 0.8); }
  .slot.minted::before { content: ''; position: absolute; inset: 2px; pointer-events: none;
    background:
      linear-gradient(var(--mint-hi), var(--mint-hi)) top left / 8px 1px, linear-gradient(var(--mint-hi), var(--mint-hi)) top left / 1px 8px,
      linear-gradient(var(--mint-hi), var(--mint-hi)) top right / 8px 1px, linear-gradient(var(--mint-hi), var(--mint-hi)) top right / 1px 8px,
      linear-gradient(var(--mint-hi), var(--mint-hi)) bottom left / 8px 1px, linear-gradient(var(--mint-hi), var(--mint-hi)) bottom left / 1px 8px,
      linear-gradient(var(--mint-hi), var(--mint-hi)) bottom right / 8px 1px, linear-gradient(var(--mint-hi), var(--mint-hi)) bottom right / 1px 8px;
    background-repeat: no-repeat; }
  /* a mint on its way is hers already but no token yet: the quiet form, a dashed rim and a dim glyph, no frame */
  .slot.filled.minting { border-style: dashed; border-color: rgba(var(--mint-rgb), 0.5); }
  /* the chain, in its cell's corner on a dark seat of its own, over the bracket */
  .slot-chain { position: absolute; top: 3px; right: 3px; width: 13px; height: 13px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    background: rgba(14, 10, 3, 0.82); color: var(--mint-hi); pointer-events: none; }
  .slot-chain svg { width: 9px; height: 9px; display: block; }
  .minting .slot-chain { color: var(--text-3); }
  .ledger-empty { font-size: 12.5px; color: var(--text-3); line-height: 1.7; padding: 8px 0; }

  /* ---------- death ---------- */
  #deathscreen {
    position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    background: radial-gradient(ellipse at center, rgba(var(--blood-rgb), 0.22), rgba(var(--glass-rgb), 0.9) 60%, var(--bg));
  }
  #deathscreen h2 {
    font-size: 42px; font-weight: normal; letter-spacing: 10px; color: var(--blood-hi);
    text-shadow: 0 2px 8px #000, 0 0 30px rgba(var(--blood-rgb), 0.6); margin-bottom: 18px; text-align: center; padding: 0 12px;
    /* pay back letter-spacing's trailing gap so the line centres */
    margin-right: -10px;
  }

  /* ---------- toasts ---------- */
  #toasts {
    position: fixed; left: 50%; bottom: 130px; transform: translateX(-50%); z-index: 35; width: max-content; max-width: 92vw; text-align: center;
    display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none;
  }
  /* off game, toasts stand over the title (50) and the account circle (55);
     in game they stay under the windows */
  body:not(.ingame) #toasts { z-index: 56; }
  /* Settings open: its own answers (a wallet linked, a phone with no wallet) stand over it, not behind it */
  body:has(#settingspanel:not(.hidden)) #toasts { z-index: 103; }
  .toast {
    font-size: 13.5px; padding: 5px 16px; background: linear-gradient(90deg, rgba(var(--glass-rgb), 0.3), rgba(var(--glass-rgb), 0.9) 18%, rgba(var(--glass-rgb), 0.9) 82%, rgba(var(--glass-rgb), 0.3));
    border-top: 1px solid; border-bottom: 1px solid; text-shadow: 0 1px 2px #000;
    border-image: linear-gradient(90deg, transparent, var(--line-strong) 20%, var(--line-strong) 80%, transparent) 1;
    transition: opacity 0.6s;
  }
  .toast.fade { opacity: 0; }
  /* one line over every screen (the veil is 57): a newer build is live, until the page reloads; or, in play, the link is bad */
  #updnote {
    position: fixed; left: 50%; top: calc(14px + var(--safe-t)); transform: translateX(-50%); z-index: 60;
    font-size: 13.5px; padding: 5px 16px; pointer-events: none; white-space: nowrap; color: var(--text); text-shadow: 0 1px 2px #000;
    background: linear-gradient(90deg, rgba(var(--glass-rgb), 0.3), rgba(var(--glass-rgb), 0.9) 18%, rgba(var(--glass-rgb), 0.9) 82%, rgba(var(--glass-rgb), 0.3));
    border-top: 1px solid; border-bottom: 1px solid;
    border-image: linear-gradient(90deg, transparent, var(--line-strong) 20%, var(--line-strong) 80%, transparent) 1;
  }
  /* touch: the top is the vitals' and the account menu's; the notice stands over the thumb cluster, wrapping */
  body.touch #updnote { top: auto; bottom: calc(250px + var(--safe-b)); white-space: normal; width: max-content; max-width: 86vw; text-align: center; }

  /* ---------- chat (online) ---------- */
  #chatwrap {
    position: fixed; left: 14px; bottom: 130px; z-index: 22; width: min(340px, 60vw);
    display: flex; flex-direction: column; gap: 6px; pointer-events: none;
  }
  #chatlog { display: flex; flex-direction: column; gap: 2px; }
  .chat-line {
    font-size: 12.5px; color: var(--text); text-shadow: 0 1px 2px #000;
    background: rgba(var(--glass-rgb), 0.55); border-radius: 2px; padding: 2px 8px;
    max-width: 100%; overflow-wrap: break-word; transition: opacity 1s;
  }
  .chat-line b { color: var(--ally); font-weight: normal; }
  .chat-line.me b { color: var(--witch); }
  .chat-line.fade { opacity: 0; }
  #chatinput {
    pointer-events: auto; width: 100%; padding: 7px 10px; font-size: 13px;
    background: rgba(var(--glass-rgb), 0.95); border: 1px solid var(--line-strong); border-radius: 2px; color: var(--text);
  }
  #chatinput:focus { outline: none; border-color: var(--line-hot); box-shadow: 0 0 10px rgba(var(--witch-rgb), 0.18); }

  /* the chat button: a hud-bar cell on desktop; on touch, em-ui reparents it
     to the left rail, one rung above the emotes */
  #btn-chat svg { width: 20px; height: 20px; }
  body.touch #btn-chat {
    position: fixed; z-index: 21;
    left: calc(10px + var(--safe-l));
    bottom: calc(var(--rail0, 14px) + 1 * var(--rung, 70px) + var(--safe-b));
    width: 58px; height: 58px; border-radius: 50%; border-width: 2px;
    background: rgba(var(--glass-rgb), 0.82); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
  }
  body.touch #btn-chat svg { width: 26px; height: 26px; }
  body.touch:not(.ingame) #btn-chat { display: none; }
  /* the emote pie's upper gesture lands just off the chat button on a phone: the button steps aside while it is open */
  body.touch #btn-chat { transition: opacity 0.12s; }
  body.touch.pie-open #btn-chat { opacity: 0; pointer-events: none; }
  /* the chat line rides one rung above the chat button, whatever the safe area lifts the rail by (Valy 10-24: "say
     something form on mobile must show above the message button not on top of it") */
  body.touch:not(.tablet) #chatwrap { bottom: calc(var(--rail0) + 2 * var(--rung) + var(--safe-b)); }

  /* ---------- speech bubbles: a chat line rides its speaker ---------- */
  /* placement is PER-DEVICE (ui.updateBubbles): clamped to this viewport,
     flipped below when the head is off-top, stacked when speakers crowd */
  #bubbles { position: fixed; inset: 0; z-index: 23; pointer-events: none; }
  .bubble {
    position: absolute; max-width: min(240px, 56vw); padding: 5px 10px;
    font-size: 12.5px; line-height: 1.35; color: var(--text-hi); overflow-wrap: break-word;
    background: rgba(var(--glass-rgb), 0.92); border: 1px solid var(--line-strong); border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5); text-shadow: 0 1px 2px #000;
    transition: opacity 0.5s;
  }
  .bubble::after {
    content: ''; position: absolute; left: 50%; bottom: -6px; margin-left: -6px;
    border: 6px solid transparent; border-bottom: none; border-top: 6px solid rgba(var(--glass-rgb), 0.92);
  }
  .bubble.below::after { bottom: auto; top: -6px; border-top: none; border-bottom: 6px solid rgba(var(--glass-rgb), 0.92); }
  .bubble.fade { opacity: 0; }
  /* the slot list under a thumb: every control clears a fingertip */
  body.touch .gslot .s-del { width: 44px; height: 44px; margin-left: -8px; }
  body.touch #t-rail .gslot .s-play { padding-top: 12px; padding-bottom: 12px; }

  /* ---------- small screens ---------- */
  @media (max-width: 640px) {
    #hud { gap: 8px; padding: 0 8px calc(8px + var(--safe-b)); }
    #hud-bar { flex-wrap: wrap; justify-content: center; max-width: calc(100vw - 24px); gap: 5px; padding: 5px 8px; }
    .belt-slot, .skill-slot, .hud-btn { width: 32px; height: 32px; font-size: 15px; }
    .skill-slot svg { width: 22px; height: 22px; }
    .hud-btn svg { width: 20px; height: 20px; }
    .skill-key { font-size: 8px; }
    #zonebanner .zb-title { font-size: 24px; letter-spacing: 5px; }
    #invpanel { right: 50%; transform: translate(50%, -50%); width: min(336px, calc(100vw - 12px)); }
    #spellpanel { right: 50%; transform: translate(50%, -50%); }
    #charpanel { left: 50%; transform: translate(-50%, -50%); width: min(320px, calc(100vw - 12px)); }
    #char-figure { height: min(calc(var(--vvh) * 0.52), 420px); }
    /* the full-size line is ~2x a phone's width */
    #deathscreen h2 { font-size: 24px; letter-spacing: 4px; margin-right: -4px; margin-bottom: 14px; }
    /* phone width: a smaller avatar beside the name */
    #set-head { gap: 12px; }
    #set-avatar-wrap { width: 56px; height: 56px; }
    #set-glyph svg { width: 30px; height: 30px; }
    #set-who #set-name { font-size: 19px; }
    /* portrait: the rail is full width, sits on the foot row and grows up as
       tall as its three slots need; the two verbs share a line */
    #t-rail, #t-seed { left: 18px; right: 18px; top: 52%; width: auto; }
    #t-rail { top: auto; max-height: calc(100% - 150px - var(--safe-t)); bottom: calc(52px + var(--safe-b)); }
    #t-verbs .btn { font-size: 14px; letter-spacing: 1px; padding-left: 6px; padding-right: 6px; }
    /* full-width rail: the scrim stacks bottom-up and clears by 55% height,
       leaving the plate the upper half */
    #title::before { background:
      linear-gradient(0deg, rgba(var(--glass-rgb), 0.9) 0%, rgba(var(--glass-rgb), 0.7) 34%, rgba(var(--glass-rgb), 0.2) 55%, transparent 74%),
      /* deeper at the top: the portrait plate's sky sits right under the wordmark */
      linear-gradient(180deg, rgba(var(--glass-rgb), 0.85) 0%, rgba(var(--glass-rgb), 0.55) 14%, rgba(var(--glass-rgb), 0.28) 24%, transparent 34%),
      radial-gradient(ellipse 90% 40% at 50% 78%, rgba(var(--witch-rgb), 0.08), transparent 72%); }
  }
  /* short viewport: brand hard against the top, the rail under it down to the
     foot row, both tightened */
  @media (max-height: 560px) {
    #t-rail, #t-seed { top: calc(84px + var(--safe-t)); gap: 7px; width: min(360px, 46vw); }
    #t-rail { bottom: calc(40px + var(--safe-b)); }   /* clears the foot row */
    #t-rail .btn { padding-top: 9px; padding-bottom: 9px; }
    #t-rail .btn.primary { padding-top: 12px; padding-bottom: 12px; }
    .gslot { min-height: 58px; padding-top: 6px; padding-bottom: 6px; }
    .gslot .s-face { width: 44px; height: 44px; }
    #t-brand { top: calc(10px + var(--safe-t)); }
    #title h1 { font-size: clamp(28px, 5vw, 44px); }
    #title .sub { margin-top: 4px; font-size: 12.5px; }
    #t-foot { bottom: calc(10px + var(--safe-b)); }
  }

  /* ---------- party (co-op) ---------- */
  #partyroster { position: fixed; top: 96px; left: 14px; z-index: 20; display: flex; flex-direction: column; gap: 4px; }
  .party-row { display: flex; align-items: center; gap: 7px; background: rgba(var(--glass-rgb), 0.82); border: 1px solid var(--line); border-radius: 4px; padding: 4px 9px 4px 7px; font-size: 12px; color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,0.5); min-width: 130px; }
  .party-row .p-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--party); flex: 0 0 auto; }
  .party-row.leader .p-dot { background: var(--witch-hi); box-shadow: 0 0 6px var(--witch); }
  .party-row .p-name { font-weight: 600; color: var(--text-hi); }
  .party-row .p-info { display: flex; flex-direction: column; gap: 3px; min-width: 74px; }
  .party-row .p-hpbar { height: 3px; background: rgba(0,0,0,0.55); border-radius: 2px; overflow: hidden; }
  .party-row .p-hpfill { height: 100%; width: 100%; background: var(--party); transition: width 0.2s linear; }
  .party-row .p-lvl { color: var(--text-3); margin-left: auto; font-size: 11px; }
  .party-row .p-leave { margin-left: 6px; color: var(--text-4); cursor: pointer; }
  .party-row .p-leave:hover { color: var(--blood-hi); }
  /* ---------- trade ---------- */
  #tradepanel { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(470px, 94vw); }
  /* the traders' shop sits right of centre so the stall stays in view */
  #shoppanel { right: 16px; top: 50%; transform: translateY(-50%); width: min(420px, 94vw); }
  .shop-title { color: var(--text-3); font-size: 12px; letter-spacing: 1px; margin-left: 8px; }
  .shop-greet { font-style: italic; color: var(--text-2); font-size: 12px; margin: -2px 0 8px; line-height: 1.5; }
  .shop-souls { font-size: 13px; color: var(--souls); margin-bottom: 6px; }
  /* the wares and her bag are BANDS like the bag's pieces: a few rows tall, scrolling sideways, so a full stall
     or a full bag never stretches the window down the screen */
  .shop-grid { display: grid; grid-auto-flow: column; grid-template-rows: repeat(2, auto); grid-auto-columns: 54px; gap: 6px; padding: 2px 1px; }
  #shop-bag.shop-grid { grid-template-rows: repeat(3, auto); }
  .shop-grid:has(> .shop-empty) { display: block; }
  .shop-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
  .shop-cell .slot { width: 100%; height: 42px; cursor: pointer; touch-action: pan-x; }
  .shop-cell .slot canvas, .shop-cell .slot img { width: 30px; height: 30px; }
  .shop-cell .slot.filled:hover { border-color: var(--line-hot); background: var(--raise); }
  .shop-price { font-size: 10.5px; color: var(--souls); white-space: nowrap; }
  .shop-cell.sold { opacity: 0.32; cursor: default; }
  .shop-cell.nobuy { opacity: 0.55; }
  .shop-cell.nobuy .shop-price { color: var(--text-4); }
  .shop-cell.sel .slot { outline: 2px solid var(--witch-hi); outline-offset: 1px; box-shadow: 0 0 12px rgba(var(--witch-rgb), 0.55); }
  .shop-empty { font-size: 11px; color: var(--text-4); font-style: italic; padding: 4px 0 6px; }
  .shop-foot { margin-top: 10px; font-size: 10.5px; color: var(--text-4); }
  .tt-buy, .tt-sell { margin-top: 6px; }
  /* how many of a stacked ware: - [n] + above the Buy */
  .tt-qty { display: flex; align-items: stretch; gap: 0; margin-top: 10px; width: max-content; border: 1px solid var(--line-strong); border-radius: 3px; overflow: hidden; }
  .tt-qty .qty-step { width: 30px; border: 0; background: var(--panel-bg); color: var(--text-2); font: inherit; font-size: 16px; line-height: 1; cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; }
  .tt-qty .qty-step:hover { color: var(--text); background: rgba(255,255,255,.06); }
  .tt-qty .qty-step:active { background: rgba(255,255,255,.12); }
  .tt-qty input { width: 44px; border: 0; border-inline: 1px solid var(--line-strong); background: rgba(0,0,0,.35); color: var(--text); font: inherit; font-size: 14px; text-align: center; padding: 5px 0; }
  .tt-qty input:focus { outline: none; background: rgba(0,0,0,.5); }
  #npc-hint {
    position: fixed; z-index: 26; pointer-events: none; font-size: 12px; color: var(--text-hi);
    background: rgba(var(--glass-rgb), 0.88); border: 1px solid var(--line-strong); border-radius: 3px; padding: 3px 8px; white-space: nowrap;
  }
  #npc-hint b { color: var(--souls); font-weight: normal; }
  .trade-cols { display: flex; gap: 10px; margin: 2px 0 10px; }
  .trade-col { flex: 1; min-width: 0; background: var(--well); border: 1px solid var(--line); border-radius: 3px; padding: 8px; box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.5); }
  .trade-col.ready { border-color: var(--party-line); box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.5), 0 0 10px color-mix(in srgb, var(--party) 18%, transparent); }
  .trade-col-head { display: flex; flex-direction: column; gap: 2px; font-size: 11px; letter-spacing: 1px; color: var(--text-2); margin-bottom: 7px; }
  .trade-col-head span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .trade-ready { font-family: var(--font-text); font-size: 10px; letter-spacing: 0.5px; color: var(--text-4); }
  .trade-col.ready .trade-ready { color: var(--good); }
  .trade-grid { display: flex; flex-wrap: wrap; gap: 4px; min-height: 48px; align-content: flex-start; }
  .trade-bag { max-height: 108px; overflow-y: auto; }
  .trade-bag:empty, .trade-pots:empty { display: none; }
  .trade-pots { min-height: 0; margin-top: 4px; }
  .trade-empty { font-size: 11px; color: var(--text-4); font-style: italic; padding: 5px 2px; align-self: center; }
  .trade-col-souls { margin-top: 7px; font-size: 12px; color: var(--souls); }
  .trade-inv { margin: 0 0 10px; }
  .trade-inv-label { font-size: 11px; color: var(--text-3); margin-bottom: 5px; }
  .trade-foot { display: flex; align-items: center; gap: 12px; }
  .trade-souls { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--souls); }
  .trade-souls input { width: 76px; background: var(--raise); border: 1px solid var(--line); color: var(--text-hi); border-radius: 3px; padding: 4px 6px; font-size: 13px; font-variant-numeric: lining-nums; user-select: text; }
  .trade-souls-max { font-size: 11px; color: var(--text-3); }
  .trade-ready-btn { margin-left: auto; padding: 8px 18px; font-size: 13px; }
  .trade-ready-btn.on { border-color: var(--party-line); background: var(--party-bg); color: var(--good); }
  /* a wallet's piece in her trade bag: it does not move here, moving it is a MetaMask operation (Valy 11-03) */
  .slot.filled.trade-locked { cursor: not-allowed; opacity: 0.55; filter: grayscale(0.8); box-shadow: none; }
  .slot.filled.trade-locked:hover { border-color: var(--line); background: none; box-shadow: none; }
  .trade-minted-note { margin-top: 6px; font-size: 10.5px; color: var(--mint-hi); line-height: 1.35; }
  .trade-note { margin-top: 8px; font-size: 10.5px; color: var(--text-4); line-height: 1.35; }
  #inspectpanel { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(330px, 92vw); }
  .insp-who { font-size: 13px; color: var(--text-2); margin-bottom: 8px; }
  .insp-who b { color: var(--text-hi); font-weight: normal; }
  .panel h2 > svg { width: 15px; height: 15px; vertical-align: -2px; margin-right: 6px; }

  /* ---------- another wanderer: the menu at her, the ask cards ---------- */
  #peermenu { position: fixed; z-index: 45; min-width: 190px; max-width: calc(100vw - 16px);
    background: var(--panel-bg); border: 1px solid var(--line-strong); border-radius: 4px; box-shadow: var(--frame-shadow); padding: 4px; }
  .pm-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 7px 8px 6px; margin-bottom: 3px;
    border-bottom: 1px solid var(--line); font-size: 11px; color: var(--text-3); }
  .pm-head b { font-size: 14px; letter-spacing: 1px; color: var(--text-hi); font-weight: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .pm-row { gap: 9px; font-size: 13.5px; color: var(--text); }
  .pm-row svg { width: 16px; height: 16px; flex: 0 0 auto; color: var(--witch); }
  .pm-row.danger svg { color: var(--blood-soft); }
  .pm-row small { margin-left: auto; padding-left: 10px; font-size: 10.5px; color: var(--text-4); white-space: nowrap; }
  .pm-row:disabled { cursor: default; color: var(--text-4); }
  .pm-row:disabled svg { color: var(--text-4); }
  .pm-row:disabled:hover { background: none; color: var(--text-4); }
  body.touch .pm-row { padding: 12px 10px; font-size: 15px; }
  #asks { position: fixed; top: calc(64px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 44;
    display: flex; flex-direction: column; gap: 6px; width: min(380px, calc(100vw - 16px)); }
  .ask-card { position: relative; display: flex; align-items: center; gap: 10px; padding: 10px 12px 12px; overflow: hidden;
    background: var(--panel-bg); border: 1px solid var(--line-strong); border-radius: 4px; box-shadow: var(--frame-shadow); }
  .ask-ic svg { width: 20px; height: 20px; display: block; color: var(--witch); }
  .ask-text { flex: 1; min-width: 0; font-size: 13px; color: var(--text); line-height: 1.3; }
  .ask-text b { color: var(--text-hi); font-weight: normal; letter-spacing: 0.5px; }
  .ask-btns { display: flex; gap: 6px; flex: 0 0 auto; }
  .ask-btns .btn { padding: 6px 12px; font-size: 12px; }
  .ask-btns .ask-yes { border-color: var(--party-line); background: var(--party-bg); color: var(--good); }
  .ask-bar { position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; background: var(--witch); transform-origin: left;
    animation: ask-drain linear forwards; }
  .ask-card.mine .ask-bar { background: var(--text-4); }
  @keyframes ask-drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }
  body.touch #asks { top: calc(var(--hud-h, 92px) + 8px + var(--safe-t)); }
  body.touch .ask-btns .btn { padding: 10px 14px; font-size: 13px; }

  /* vignette: above the world canvases (z 1-2), below the HUD (z 20), never eats a click */
  body::after {
    content: ''; position: fixed; inset: 0; z-index: 15; pointer-events: none;
    background: radial-gradient(ellipse at 50% 47%, rgba(0, 0, 0, 0) 38%, rgba(var(--glass-rgb), 0.64) 100%);
  }

  /* ---------- phone controls (body.touch, set by the client on a touch device) ---------- */

  /* on touch the HUD moves to the top: the bottom corners belong to the thumbs */
  body.touch #hud {
    top: 0; bottom: auto; align-items: flex-start; gap: 8px;
    /* clears the fixed account + vitals cluster at the top left */
    padding: calc(92px + var(--safe-t)) 8px 0;
  }
  body.touch #hud-mid { gap: 4px; }

  body.touch .vbar { height: 13px; }
  /* on touch the bar's controls live elsewhere; it is only DOM housing and paints no frame */
  body.touch #hud-bar { gap: 6px; padding: 0; max-width: calc(100vw - 16px); background: none; border: none; box-shadow: none; }
  body.touch #vitals { left: 82px; }
  /* on touch every loose window has one placement: under the top-left cluster,
     centred by left:50% + translateX(-50%) (set both, or a window drifts off-edge) */
  body.touch #invpanel, body.touch #charpanel, body.touch #shoppanel, body.touch #tradepanel, body.touch #inspectpanel,
  body.touch #spellpanel, body.touch #mentorpanel, body.touch #wppanel, body.touch #ledgerpanel, body.touch #adminvpanel {
    top: calc(96px + var(--safe-t)); bottom: auto;
    left: 50%; right: auto; transform: translateX(-50%);
    max-width: calc(100vw - 12px - var(--safe-l) - var(--safe-r));
    max-height: calc(var(--vvh) - 108px - var(--safe-t) - var(--safe-b));
  }
  body.touch .hud-btn { width: 44px; height: 44px; }
  /* the left rail holds only standing-still verbs (emotes, chat) —
     the only reason it may sit under the steering thumb. One named pitch, so the
     landscape block re-spaces the whole rail in a line. */
  body.touch { --rail0: 14px; --rung: 70px; }
  /* no bag button on touch: the game menu under the avatar carries Inventory */
  body.touch #btn-inv { display: none !important; }

  /* play controls exist only in play */
  body:not(.ingame) #thumbs { display: none !important; }
  /* the cluster is not a box: the wrapper covers the screen and passes
     everything through; only the cells and #thumbpad take a finger. The pad is
     clipped to the cluster's hull and hands its finger to the
     nearest cell, so a near-miss is a press and open ground stays ground. */
  body.touch #thumbs {
    position: fixed; inset: 0; z-index: 21; pointer-events: none;
    -webkit-tap-highlight-color: transparent;
  }
  body.touch #thumbs > * {
    position: fixed; pointer-events: auto; touch-action: none;
    border-radius: 50%; border-width: 2px;
    background: rgba(var(--glass-rgb), 0.82); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
  }
  body.touch #thumbs > #thumbpad { inset: 0; border: 0; border-radius: 0; background: none; box-shadow: none; }
  /* a quarter-arc about the right thumb's pivot: the light hit in the corner,
     the roll straight up from it, flasks on the outer band. Every cell within a
     27-41mm thumb reach and none under 44pt. */
  body.touch #skill-strike { right: calc(12px + var(--safe-r)); bottom: calc(12px + var(--safe-b)); width: 76px; height: 76px; font-size: 32px; }
  body.touch #skill-heavy  { right: calc(98px + var(--safe-r)); bottom: calc(26px + var(--safe-b)); width: 64px; height: 64px; font-size: 27px; }
  body.touch #skill-dash   { right: calc(18px + var(--safe-r)); bottom: calc(100px + var(--safe-b)); width: 68px; height: 68px; font-size: 29px; }
  body.touch #skill-cast   { right: calc(90px + var(--safe-r)); bottom: calc(106px + var(--safe-b)); width: 64px; height: 64px; font-size: 27px; }
  body.touch #pot-hp       { right: calc(20px + var(--safe-r)); bottom: calc(186px + var(--safe-b)); width: 56px; height: 56px; font-size: 23px; }
  body.touch #pot-mana     { right: calc(100px + var(--safe-r)); bottom: calc(178px + var(--safe-b)); width: 56px; height: 56px; font-size: 23px; }

  /* emotes sit on the left rail. Still a #thumbs child (the tap guard keys off
     that ancestry), so this must come after the wrapper rule above. */
  body.touch #emote-btn {
    right: auto; left: calc(10px + var(--safe-l));
    bottom: calc(var(--rail0) + var(--safe-b));
    width: 58px; height: 58px; font-size: 26px;
  }

  /* landscape must come after the portrait cells: same specificity, so order decides */
  @media (max-height: 520px) {
    /* landscape: a shallower top strip, a flatter arc, a tighter rail; the
       middle of the screen stays clear */
    body.touch #hud { padding-top: calc(56px + var(--safe-t)); }
    /* her figure fits a ~390px-tall screen under the bar and the tabs */
    body.touch #char-figure { height: max(150px, calc(var(--vvh) - 230px - var(--safe-t) - var(--safe-b))); }
    body.touch .vbar { height: 11px; }
    body.touch { --rail0: 14px; --rung: 62px; }
    body.touch #emote-btn, body.touch #btn-chat { width: 52px; height: 52px; }
    body.touch #skill-strike { right: calc(14px + var(--safe-r)); bottom: calc(14px + var(--safe-b)); width: 76px; height: 76px; }
    body.touch #skill-heavy  { right: calc(100px + var(--safe-r)); bottom: calc(24px + var(--safe-b)); }
    body.touch #skill-dash   { right: calc(20px + var(--safe-r)); bottom: calc(102px + var(--safe-b)); }
    body.touch #skill-cast   { right: calc(180px + var(--safe-r)); bottom: calc(40px + var(--safe-b)); }
    body.touch #pot-hp       { right: calc(96px + var(--safe-r)); bottom: calc(108px + var(--safe-b)); }
    body.touch #pot-mana     { right: calc(176px + var(--safe-r)); bottom: calc(130px + var(--safe-b)); }
    body.touch #toasts { bottom: calc(190px + var(--safe-b)); }
    /* a short screen lays the bag out in two columns: the doll on the left, the shelves and the scrolling
       pieces on the right */
    #inv-grid.inv-row { grid-template-rows: repeat(2, 40px); }
    #invpanel { display: grid; width: min(720px, calc(100vw - 12px)) !important; grid-template-columns: 220px minmax(0, 1fr) minmax(0, 1fr); column-gap: 12px;
      grid-template-rows: auto auto minmax(0, 1fr) auto;
      grid-template-areas: 'head head head' 'doll items items' 'doll items items' 'doll items items'; }
    #invpanel > h2 { grid-area: head; }
    #paperdoll { grid-area: doll; align-self: start; margin-bottom: 0; }
    #paperdoll .slot.eq, #doll-belt .slot.belt-cell { height: 44px; }
    #inv-items { grid-area: items; margin-top: 2px; }
  }
  body.touch #thumbs > .down { background: var(--line); border-color: var(--line-hot); }
  /* A TABLET: the desktop's corners with the touch cluster. One unit u sizes it all (thumb-reach
     guidance: the attack ~18 mm, a perfect fourth (1.333) down to dash and heavy, a major third down to the
     squares; gaps >= 8 px, margins clear of the safe area). Bottom right: the attack in the corner, heavy
     and dash beside it in a row, the flasks and the spell each over a circle; bottom left: the emotes and
     the chat field. */
  body.touch.tablet {
    --u: clamp(6.5px, 0.95vmin, 10px);
    --tm: calc(3 * var(--u)); --ta: calc(12 * var(--u)); --tb: calc(9 * var(--u));
    --tq: calc(7.25 * var(--u)); --tg: calc(1.5 * var(--u));
    --tr: calc(var(--tm) + var(--safe-r)); --tbt: calc(var(--tm) + var(--safe-b));
    --tsq: calc(var(--tbt) + var(--ta) + var(--tg));
  }
  body.touch.tablet #skill-strike { right: var(--tr); bottom: var(--tbt); width: var(--ta); height: var(--ta); }
  body.touch.tablet #skill-heavy { right: calc(var(--tr) + var(--ta) + var(--tg)); bottom: calc(var(--tbt) + (var(--ta) - var(--tb)) / 2); width: var(--tb); height: var(--tb); }
  body.touch.tablet #skill-dash { right: calc(var(--tr) + var(--ta) + 2 * var(--tg) + var(--tb)); bottom: calc(var(--tbt) + (var(--ta) - var(--tb)) / 2); width: var(--tb); height: var(--tb); }
  body.touch.tablet #skill-cast { right: calc(var(--tr) + (var(--ta) - var(--tq)) / 2); }
  body.touch.tablet #pot-mana { right: calc(var(--tr) + var(--ta) + var(--tg) + (var(--tb) - var(--tq)) / 2); }
  body.touch.tablet #pot-hp { right: calc(var(--tr) + var(--ta) + 2 * var(--tg) + var(--tb) + (var(--tb) - var(--tq)) / 2); }
  body.touch.tablet #skill-cast, body.touch.tablet #pot-mana, body.touch.tablet #pot-hp {
    bottom: var(--tsq); width: var(--tq); height: var(--tq); border-radius: calc(1.75 * var(--u)); }
  body.touch.tablet #thumbs > .skill-slot svg { width: 56%; height: 56%; }
  body.touch.tablet #thumbs .belt-slot img { width: 66%; height: 66%; }
  body.touch.tablet #emote-btn { left: calc(var(--tm) + var(--safe-l)); bottom: var(--tbt); width: var(--tq); height: var(--tq); }
  body.touch.tablet #chatwrap { left: calc(var(--tm) + var(--safe-l) + var(--tq) + var(--tg)); bottom: calc(var(--tbt) + (var(--tq) - 6 * var(--u)) / 2); width: min(calc(30 * var(--u)), 40vw); }
  body.touch.tablet #chatinput { height: calc(6 * var(--u)); }
  body.touch.tablet #toasts { bottom: calc(var(--tsq) + var(--tq) + var(--tg)); }


  /* a skill cell dims when its cost (stamina, mana) is not there */
  .skill-slot.nores { opacity: 0.42; }
  /* THE RECHARGE (hud.rs spell_recharge, off em-sim's cooldown): the cast cell goes transparent and the part of
     the cooldown still to run is a dark sector that sweeps off clockwise from twelve (--cd: 1 just cast, 0 ready) */
  #skill-cast.recharge { opacity: 0.5; }
  #skill-cast.recharge::after { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
    background: conic-gradient(transparent calc((1 - var(--cd, 0)) * 360deg), rgba(0, 0, 0, 0.8) 0); }

  /* on touch: roster and boss bar clear the measured top bar (--hud-h,
     ui.measureHud); toasts lift above the thumb cluster */
  body.touch #partyroster { top: calc(var(--hud-h, 92px) + 6px); left: 8px; }
  body.touch #bossbar { top: calc(var(--hud-h, 92px) + 10px); }
  body.touch #lockedby { top: calc(var(--hud-h, 92px) + 46px); padding: 6px 14px; font-size: 13px; }
  body.touch #toasts { bottom: calc(260px + var(--safe-b)); }
  body.touch #zonebanner { top: 24%; }

  /* steer stick — spawns under the thumb wherever the drag starts */
  #joy { position: fixed; left: 0; top: 0; z-index: 19; pointer-events: none; }
  #joy-ring {
    position: absolute; left: 0; top: 0; width: 116px; height: 116px;
    transform: translate(-50%, -50%); border-radius: 50%;
    border: 2px solid rgba(var(--witch-rgb), 0.45);
    background: radial-gradient(circle, rgba(var(--glass-rgb), 0.5), rgba(var(--glass-rgb), 0.12));
  }
  #joy-knob {
    position: absolute; left: 0; top: 0; width: 48px; height: 48px;
    transform: translate(-50%, -50%); border-radius: 50%;
    border: 2px solid rgba(var(--light-rgb), 0.7); background: rgba(var(--witch-rgb), 0.28);
  }

  /* free-aim ring. Centred here as a fallback; showAim() pins it to the hero's
     real projected position, which the 3D camera frames below screen centre. */
  #aimring {
    position: fixed; left: 50%; top: 50%; z-index: 18; pointer-events: none;
    width: 168px; height: 168px; margin: -84px 0 0 -84px; border-radius: 50%;
    border: 2px dashed rgba(var(--witch-rgb), 0.4);
  }
  #aim-arrow {
    position: absolute; left: 50%; top: 50%; width: 0; height: 0;
    margin: -84px 0 0 -9px; transform-origin: 50% 84px;
    border-left: 9px solid transparent; border-right: 9px solid transparent;
    border-bottom: 26px solid rgba(var(--witch-hi-rgb), 0.9);

  }
  /* ---------- dark fantasy pointers ---------- */
  /* inline SVG cursors: a blade by default, a gauntlet where the UA hand would
     be, a fist while an item is lifted (body.em-drag), a reticle over the world.
     Each keeps a keyword fallback. A data: URI cannot read a custom property, so
     these spell the palette's values (--text a shade brighter, --bg, --witch, --blood). */
  body {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Cpath d='M3 1 L3 22.5 L8.5 17.5 L12 26 L16.2 24.2 L12.7 15.8 L20 15 Z' fill='%23eef3f1' stroke='%23040607' stroke-width='1.6' stroke-linejoin='round'/%3E%3Cpath d='M5.5 5 L5.5 16.5' stroke='%236fd6a0' stroke-width='1'/%3E%3C/svg%3E") 3 1, auto;
  }
  button, .btn, .hud-btn, .belt-slot, .skill-slot, .slot.filled, .slot.eq,
  .linkish, .gslot.s-empty, .cs-arrow, .am-row, .wp-row, .emote-opt, #acctbtn,
  .tt-x, .p-leave, select {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Cpath d='M11 3 q0-2 2.5-2 q2.5 0 2.5 2 l0 9 l4.5 0.5 q4.5 0.5 4.5 5 l0 3 q0 6 -6.5 6 l-5 0 q-4 0 -5.5 -3.5 l-3.5 -7 q-1 -2.2 1.2 -3 q1.8 -0.6 3 1.2 l2.3 3.3 z' fill='%23eef3f1' stroke='%23040607' stroke-width='1.5' stroke-linejoin='round'/%3E%3Cpath d='M8.5 22.5 l12 0' stroke='%236fd6a0' stroke-width='2'/%3E%3C/svg%3E") 13 1, pointer;
  }
  canvas#game {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cg fill='%23eef3f1' stroke='%23040607' stroke-width='1.2' stroke-linejoin='round'%3E%3Cpath d='M16 2 l2 7 -2 2.4 -2 -2.4 z'/%3E%3Cpath d='M30 16 l-7 2 -2.4 -2 2.4 -2 z'/%3E%3Cpath d='M16 30 l-2 -7 2 -2.4 2 2.4 z'/%3E%3Cpath d='M2 16 l7 -2 2.4 2 -2.4 2 z'/%3E%3C/g%3E%3Ccircle cx='16' cy='16' r='1.8' fill='%23d83a33' stroke='%23040607' stroke-width='0.8'/%3E%3C/svg%3E") 16 16, crosshair;
  }
  body.em-drag, body.em-drag * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Cpath d='M5 13 q0-4 4-4 l10 0 q4 0 4 4 l0 5 q0 6 -6 6 l-6 0 q-6 0 -6 -6 z' fill='%23eef3f1' stroke='%23040607' stroke-width='1.5' stroke-linejoin='round'/%3E%3Cpath d='M10 9.5 l0 3.5 M14 9.5 l0 3.5 M18 9.5 l0 3.5' stroke='%23040607' stroke-width='1.2' fill='none'/%3E%3Cpath d='M6.5 23 l15 0' stroke='%236fd6a0' stroke-width='2'/%3E%3C/svg%3E") 14 12, grabbing !important;
  }
