/* ============================================================================
   HALO · Decision Engine — Design System
   Aesthetic: "Obsidian Aurora" — space-black glass, aurora mesh, neon energy.

   ARCHITECTURE
   ------------
   The whole stylesheet lives inside explicit cascade layers, declared once here.
   Later layers beat earlier ones regardless of selector specificity, which is
   why this file needs no `!important` arms race and no "must be last" rules:

     reset      normalise + the [hidden] contract
     tokens     :root design tokens — the only place raw values are invented
     base       document, atmosphere, typography defaults, focus
     components shared UI used by EVERY mode (page-head, action, surface, …)
     modes      per-mode geometry; each mode owns its own media queries
     a11y       reduced-motion + forced-colors, last word on motion
     hidden     the [hidden] contract, final word on visibility

   Theme variables (--accent, --accent2, --bg, --mesh-*) are injected at runtime
   by app.js from config.js. Everything else derives from them, so a theme swap
   re-skins every surface without a single extra rule.

   RULES OF THE ROAD
   -----------------
   1. New colour/size/duration values go in `tokens`, never inline in a rule.
   2. A pattern used by two or more modes belongs in `components`, not `modes`.
   3. Responsive rules live next to the thing they modify — never in a global
      "mobile override" block at the bottom of the file.
   ========================================================================== */

@layer reset, tokens, base, components, modes, a11y, hidden;

/* ============================================================================
   RESET
   ========================================================================== */
@layer reset {
  *,
  *::before,
  *::after { box-sizing: border-box; }

  body, h1, h2, h3, h4, p, ol, ul, figure { margin: 0; }
  ol, ul { padding: 0; list-style: none; }

  button, input, textarea, select {
    font: inherit;
    color: inherit;
  }
  button { cursor: pointer; background: none; border: 0; }

  img, svg, canvas { display: block; max-width: 100%; }
}

/* ============================================================================
   TOKENS
   The single source of truth. Nothing below invents a raw value.
   ========================================================================== */
@layer tokens {
  :root {
    /* ── Theme channel — overwritten live by app.js ─────────────────────── */
    --accent: #00f5d4;
    --accent2: #7b2ff7;
    --bg: #06070d;
    --mesh-1: #0a1f3c;
    --mesh-2: #1a0b3d;
    --mesh-3: #04221f;
    --seg-text: #06070d;

    /* ── Surfaces — all derived from --bg so themes stay coherent ──────── */
    --surface-0: color-mix(in srgb, var(--bg) 88%, #000 12%);
    --surface-1: color-mix(in srgb, var(--bg) 76%, #fff 5%);
    --surface-2: color-mix(in srgb, var(--bg) 66%, #fff 8%);
    --glass: rgba(255, 255, 255, 0.045);
    --glass-2: rgba(255, 255, 255, 0.07);
    --well: rgba(0, 0, 0, 0.28);
    --well-deep: rgba(0, 0, 0, 0.42);

    /* ── Strokes ───────────────────────────────────────────────────────── */
    --stroke: rgba(255, 255, 255, 0.09);
    --stroke-bright: rgba(255, 255, 255, 0.16);
    --stroke-accent: color-mix(in srgb, var(--accent) 26%, var(--stroke));

    /* ── Ink ───────────────────────────────────────────────────────────── */
    /* Dark-theme ink can be warmed or cooled per theme (`ink` in config.js →
       --theme-ink); the dimmer steps derive from it so the whole text scale
       shifts together. Light themes set all three outright below. */
    --ink: var(--theme-ink, #f4f6fb);
    --ink-dim: color-mix(in srgb, var(--ink) 72%, var(--bg));
    --ink-faint: color-mix(in srgb, var(--ink) 55%, var(--bg));

    /* ── Semantic states — shared by Oracle, Blackjack, Mines, Dice ────── */
    --ok: #00f5a0;
    --ok-soft: rgba(0, 245, 160, 0.16);
    --warn: #ffd75a;
    --warn-soft: rgba(255, 215, 90, 0.16);
    --bad: #ff5d73;
    --bad-soft: rgba(255, 93, 115, 0.16);
    --gold: #ffd700;
    --silver: #cfd6df;
    --bronze: #d9925b;

    /* ── Type — "Precision Instrument" ───────────────────────────────────
       Three voices, each with one job. Zodiak is a high-contrast serif and
       carries every title; Switzer is the neutral-but-warm workhorse; Martian
       Mono is reserved for NUMBERS AND STATUS — timers, chip counts, dice
       totals, percentages. Never set body copy in mono: it is the instrument
       voice, and it stops meaning anything if everything wears it. */
    --font-display: "Zodiak", "Iowan Old Style", Georgia, serif;
    --font-body: "Switzer", ui-sans-serif, system-ui, sans-serif;
    --font-mono: "Martian Mono", ui-monospace, "SF Mono", monospace;

    /* Body ladder. Nudged up from the old ramp — the smallest sizes were
       under-reading on tablets held at arm's length, and unreadable in a car. */
    --t-2xs: 0.72rem;
    --t-xs: 0.8rem;
    --t-sm: 0.88rem;
    --t-md: 0.98rem;
    --t-lg: 1.1rem;

    /* Display ladder — fluid, one ramp for every mode title */
    --d-sm: clamp(1.3rem, 2.2vw, 1.7rem);
    --d-md: clamp(1.8rem, 3.4vw, 2.6rem);
    --d-lg: clamp(2.2rem, 5vw, 3.6rem);
    --d-xl: clamp(2.8rem, 7vw, 5rem);

    /* Tracking. Zodiak has real contrast, so display sits tighter than the old
       grotesk did; mono caps need air to read as instrumentation. */
    --track-caps: 0.26em;
    --track-display: -0.015em;
    --track-mono: 0.06em;

    /* Line heights — display is set tight so multi-line titles hold together */
    --lh-display: 0.94;
    --lh-body: 1.55;

    /* Mono numerals must not jitter as values count up. */
    --num: tabular-nums;

    /* ── Space ─────────────────────────────────────────────────────────── */
    --s-1: 4px;
    --s-2: 8px;
    --s-3: 12px;
    --s-4: 16px;
    --s-5: 22px;
    --s-6: 30px;
    --s-7: 42px;
    --s-8: 58px;

    /* Fluid gutters */
    --gutter: clamp(14px, 3.2vw, 34px);
    --section-y: clamp(16px, 3vh, 40px);

    /* ── Radii ─────────────────────────────────────────────────────────── */
    /* --round is theme character: 0.6 machined … 1.25 soft (set by applyTheme). */
    --r-xs: calc(8px * var(--round, 1));
    --r-sm: calc(12px * var(--round, 1));
    --r-md: calc(16px * var(--round, 1));
    --r-lg: calc(24px * var(--round, 1));
    --r-xl: calc(32px * var(--round, 1));
    --r-2xl: calc(40px * var(--round, 1));
    --r-full: 999px;

    /* ── Elevation ─────────────────────────────────────────────────────── */
    --e-1: 0 2px 10px -4px rgba(0, 0, 0, 0.5);
    --e-2: 0 14px 34px -18px rgba(0, 0, 0, 0.75);
    --e-3: 0 30px 80px -20px rgba(0, 0, 0, 0.8);
    --inset-top: inset 0 1px 0 rgba(255, 255, 255, 0.09);
    /* Glow strength is theme character: applyTheme() writes the three alphas
       (neon tubes glow, paper barely does). Defaults are the house level. */
    --glow: 0 0 0 1px color-mix(in srgb, var(--accent) var(--glow-a1, 30%), transparent),
            0 0 40px -6px color-mix(in srgb, var(--accent) var(--glow-a2, 55%), transparent);
    --glow-soft: 0 0 34px -14px color-mix(in srgb, var(--accent) var(--glow-a3, 70%), transparent);

    /* ── Motion ────────────────────────────────────────────────────────── */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --t-fast: 0.18s;
    --t-base: 0.26s;
    --t-slow: 0.5s;
    --t-exit: 0.22s;     /* overlays leave faster than they arrive */

    /* Hover physics — one recipe, used everywhere */
    --hover-lift: translateY(-2px);
    --press: scale(0.97);

    /* ── Layout ────────────────────────────────────────────────────────── */
    --topbar-h: 74px;
    --bottom-nav-h: 0px;
    --shell-max: 1720px;
    --tap: 44px;            /* minimum touch target */
    --mode-count: 7;        /* Spin + Claw + Marble + Blackjack + Coin + Dice + Oracle */

    /* ── Focus — one visible ring for the entire app ───────────────────── */
    --focus-ring: 0 0 0 2px var(--surface-0), 0 0 0 4px var(--accent);

    /* ── Z ladder — declared once so layers can never collide again ────── */
    --z-atmos: -1;
    --z-stage: 1;
    --z-raised: 5;
    --z-topbar: 40;
    --z-nav: 60;
    --z-drawer: 70;
    --z-modal: 80;
    --z-toast: 95;
  }

  /* ── Light themes ──────────────────────────────────────────────────────
     Everything in this file derives from --bg and the ink scale, so a light
     theme is not a second stylesheet — it is this block. app.js toggles
     .theme-light from the theme's `light` flag; --bg/--accent still arrive
     inline from the theme itself, which is why they are absent here. */
  :root.theme-light {
    --surface-0: color-mix(in srgb, var(--bg) 94%, #000 6%);
    --surface-1: color-mix(in srgb, var(--bg) 86%, #fff 14%);
    --surface-2: color-mix(in srgb, var(--bg) 70%, #fff 30%);
    --glass: rgba(255, 255, 255, 0.55);
    --glass-2: rgba(255, 255, 255, 0.75);
    --well: rgba(0, 0, 0, 0.055);
    --well-deep: rgba(0, 0, 0, 0.1);

    --stroke: rgba(23, 30, 38, 0.14);
    --stroke-bright: rgba(23, 30, 38, 0.26);

    --ink: #131a21;
    --ink-dim: #47535f;
    --ink-faint: #6d7885;

    /* Shadows on paper are short and soft, never the deep wells dark mode uses. */
    --e-1: 0 1px 3px -1px rgba(20, 26, 33, 0.16);
    --e-2: 0 10px 26px -14px rgba(20, 26, 33, 0.28);
    --e-3: 0 24px 60px -22px rgba(20, 26, 33, 0.32);
    --inset-top: inset 0 1px 0 rgba(255, 255, 255, 0.7);
    --glow-soft: 0 0 26px -14px color-mix(in srgb, var(--accent) 55%, transparent);
  }

  /* The shell retunes itself at each step; components below inherit the change
     rather than each being overridden individually.
     ≤900px is where the mode rail gives way to the one-row header with the
     game switcher, so the header shrinks there — not at the phone breakpoint. */
  @media (max-width: 900px) {
    :root {
      --topbar-h: 64px;
      --bottom-nav-h: 0px;
      --gutter: clamp(12px, 2.4vw, 22px);
    }
  }
  @media (max-width: 720px) {
    :root {
      --topbar-h: 60px;
      --gutter: 16px;
      --section-y: 10px;
    }
  }

  /* ── Device profile: in-car and kiosk ──────────────────────────────────
     A Tesla's browser is a 15-17" touchscreen at roughly 1900x1200, sat an
     arm's length away and frequently in direct sunlight. It reports a COARSE
     pointer at a DESKTOP width — a combination neither a phone nor a laptop
     produces — so this is a genuine feature test, not UA sniffing. Large
     kiosks and big tablets in landscape get the same treatment, which is
     correct: they share the ergonomics.

     Everything grows: targets past the 44px phone minimum, the whole type
     ramp, and stroke/ink contrast to survive glare. */
  @media (pointer: coarse) and (min-width: 1200px) {
    :root {
      --tap: 60px;
      --t-2xs: 0.84rem;
      --t-xs: 0.92rem;
      --t-sm: 1.02rem;
      --t-md: 1.14rem;
      --t-lg: 1.28rem;
      --gutter: clamp(28px, 3vw, 56px);
      --topbar-h: 92px;
      --stroke: rgba(255, 255, 255, 0.15);
      --stroke-bright: rgba(255, 255, 255, 0.26);
      --ink-dim: #ccd2e0;
      --ink-faint: #9ba2b6;
      /* Sunlight kills subtle elevation, so lean on contrast instead. */
      --e-2: 0 16px 38px -16px rgba(0, 0, 0, 0.9);
      --e-3: 0 34px 90px -18px rgba(0, 0, 0, 0.95);
    }
  }

  /* Any touch device: a :hover that never fires must not be the only way to
     discover an affordance, so the resting state carries more of the weight. */
  @media (hover: none) {
    :root {
      --hover-lift: none;
      --stroke: rgba(255, 255, 255, 0.13);
    }
  }
}

/* ============================================================================
   BASE
   ========================================================================== */
@layer base {
  html {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
  }

  body {
    width: 100%;
    max-width: 100%;
    min-height: 100svh;
    padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
    font-family: var(--font-body);
    font-size: var(--t-md);
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    transition: background var(--t-slow) var(--ease-out);
  }

  ::selection { background: var(--accent); color: var(--seg-text); }

  /* One focus ring for the whole app. Pointer users never see it; keyboard
     users always do — the old stylesheet had no consistent ring at all. */
  :focus { outline: none; }
  :focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--r-xs);
  }

  /* Scrollbars inside panels: present but unobtrusive. */
  * { scrollbar-width: thin; scrollbar-color: var(--stroke-bright) transparent; }
  *::-webkit-scrollbar { width: 8px; height: 8px; }
  *::-webkit-scrollbar-thumb {
    background: var(--stroke-bright);
    border-radius: var(--r-full);
  }
  *::-webkit-scrollbar-track { background: transparent; }

  /* ── Atmospheric background ───────────────────────────────────────────
     A static mesh of soft radial gradients in the theme's mesh colours.
     It replaced three 60vw blobs under blur(90px) + mix-blend-mode, drifting
     forever, plus an animated noise layer and nine floating bubbles. That
     stack forced a full-viewport repaint and blend every frame on every
     screen: measured on a throttled phone, 16fps idle versus 58fps without
     it. A radial gradient already *is* a soft blob, so the look survives
     at zero per-frame cost. Nothing in here may animate. */
  .atmos {
    position: fixed;
    inset: 0;
    z-index: var(--z-atmos);
    overflow: hidden;
    pointer-events: none;
    background:
      radial-gradient(60vmax 50vmax at 8% 4%, color-mix(in srgb, var(--mesh-1) 75%, transparent), transparent 70%),
      radial-gradient(55vmax 50vmax at 96% 96%, color-mix(in srgb, var(--mesh-2) 75%, transparent), transparent 70%),
      radial-gradient(45vmax 40vmax at 55% 55%, color-mix(in srgb, var(--mesh-3) 55%, transparent), transparent 70%);
  }
  /* On paper the mesh tints rather than glows. */
  :root.theme-light .atmos { opacity: 0.55; }
  :root.theme-light .grid-overlay { opacity: 0.5; }

  .grid-overlay {
    position: absolute;
    inset: 0;
    background-image:
      linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
    background-size: 64px 64px;
    mask-image: radial-gradient(ellipse 80% 70% at 50% 40%, #000 30%, transparent 75%);
  }

  /* Film grain, rasterised once (a 120px tile) and never animated. */
  .grain {
    position: absolute;
    inset: 0;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  }

  /* Shared entrance used by panes, history rows and mode sections. */
  @keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
  }
  @keyframes spinDot { to { transform: rotate(360deg); } }

  /* ── View transitions between modes (setMode in app.js) ───────────────
     The old view dissolves quickly; the new one rises in. The header has its
     own transition name so it stays perfectly still across the change. */
  .topbar { view-transition-name: topbar; }
  ::view-transition-group(topbar) { animation: none; }
  ::view-transition-old(root) { animation: vtOut var(--t-exit) var(--ease-out) both; }
  ::view-transition-new(root) { animation: vtIn 0.38s var(--ease-out) both; }
  @keyframes vtOut { to { opacity: 0; } }
  @keyframes vtIn { from { opacity: 0; transform: translateY(12px); } }

}
/* ============================================================================
   COMPONENTS
   Everything in this layer is used by two or more modes. If you find yourself
   writing a second bespoke "flip button" or "section header", extend one of
   these instead — that is the whole point of the layer.
   ========================================================================== */
@layer components {

  /* ══════════════════════════════════════════════════════════════════════
     SECTION SHELL
     Every mode section is a `.mode-section`. Width and rhythm come from here
     so no mode has to reinvent its own page padding.
     ══════════════════════════════════════════════════════════════════════ */
  /* A game is an app screen, not a document: it fills the viewport below the
     header, the playfield takes the slack, and the action dock sits at the
     bottom of what is visible — where a thumb already is. */
  .mode-section {
    display: flex;
    flex-direction: column;
    width: min(100% - (var(--gutter) * 2), var(--mode-max, 880px));
    min-height: calc(100svh - var(--topbar-h) - var(--bottom-nav-h));
    margin-inline: auto;
    padding-block: var(--section-y) calc(var(--section-y) + env(safe-area-inset-bottom, 0px));
    animation: fadeUp 0.4s var(--ease-out);
  }
  .mode-section > .mode-stack { flex: 1; }
  /* Where view transitions exist they own the entrance; this fadeUp is the
     fallback for browsers without them. */
  @supports (view-transition-name: none) {
    .mode-section { animation: none; }
  }

  /* Vertical rhythm for the stack of blocks inside a mode. */
  .mode-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(14px, 2.4vh, 28px);
    width: 100%;
  }

  /* ══════════════════════════════════════════════════════════════════════
     PAGE HEAD — one header for Coin, Dice, Oracle, Marble, Mines, Blackjack
     ══════════════════════════════════════════════════════════════════════ */
  .page-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--s-2);
    text-align: center;
  }

  /* Kicker is a status pill — the same object as the home hero's, so every
     mode opens with the same "instrument online" signature. */
  .page-head__kicker {
    display: inline-flex;
    width: fit-content;
    align-items: center;
    gap: 9px;
    padding: 6px 12px;
    border: 1px solid var(--stroke);
    border-radius: var(--r-full);
    background: var(--glass);
    font-family: var(--font-mono);
    font-size: var(--t-2xs);
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-dim);
  }
  .page-head__kicker::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent);
  }

  /* Editorial title: sentence case in Zodiak, the final word set as an
     italic gradient — the same voice as the home page headlines. */
  .page-head__title {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: var(--d-lg);
    line-height: var(--lh-display);
    letter-spacing: -0.03em;
    text-wrap: balance;
    color: var(--ink);
  }
  .page-head__title em {
    font-style: italic;
    font-weight: 400;
    padding-right: 0.06em;
    background: linear-gradient(100deg, var(--accent), color-mix(in srgb, var(--accent2) 70%, var(--accent)));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }

  .page-head__sub {
    max-width: 54ch;
    font-size: var(--t-sm);
    line-height: 1.5;
    color: var(--ink-dim);
    text-wrap: balance;
  }

  /* Title + live stat on one row (Marble, Mines, Blackjack). */
  .page-head--split {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--s-4);
    width: 100%;
    text-align: left;
  }
  .page-head--split .page-head__group {
    display: flex;
    flex-direction: column;
    gap: var(--s-1);
    min-width: 0;
  }

  @media (max-width: 720px) {
    .page-head--split { align-items: center; }
    .page-head__sub { display: none; }
    .page-head--split .page-head__kicker { display: none; }
  }

  /* Short landscape viewports — tablets turned sideways, small laptops. Height
     is the scarce resource there, and the page header is the cheapest thing to
     trim so the playfield below it keeps its size. Applies to every mode at
     once because they all share this component. */
  @media (min-width: 901px) and (max-height: 800px) {
    .page-head__title { font-size: var(--d-md); }
    .page-head__sub { display: none; }
  }

  /* ══════════════════════════════════════════════════════════════════════
     SURFACE — the one glass card
     ══════════════════════════════════════════════════════════════════════ */
  .surface {
    position: relative;
    border: 1px solid var(--stroke);
    border-radius: var(--r-lg);
    background: linear-gradient(180deg, var(--glass-2), var(--glass));
    box-shadow: var(--inset-top), var(--e-2);
  }
  .surface--accent { border-color: var(--stroke-accent); }
  .surface--pad { padding: clamp(14px, 2.2vw, 24px); }
  .surface--well {
    background: var(--well);
    box-shadow: inset 0 10px 28px rgba(0, 0, 0, 0.3);
  }
  /* Aurora wash — used by the hero surfaces (Marble arena, Mines shell). */
  .surface--aurora {
    background:
      radial-gradient(circle at 20% 8%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 38%),
      radial-gradient(circle at 84% 22%, color-mix(in srgb, var(--accent2) 18%, transparent), transparent 42%),
      linear-gradient(180deg, var(--glass-2), var(--glass));
    box-shadow: var(--inset-top), var(--e-3), var(--glow-soft);
  }

  /* ══════════════════════════════════════════════════════════════════════
     ACTION — the one primary button
     Replaces .coin-flip-btn / .dice-roll-btn / .ball8-ask-btn / .marble-launch
     / .btn--spin / .bj-btn--deal / .mode-clear-btn.
     ══════════════════════════════════════════════════════════════════════ */
  .action {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    min-height: var(--tap);
    padding: 14px 30px;
    border: 1px solid transparent;
    border-radius: var(--r-full);
    overflow: hidden;
    font-family: var(--font-body);
    font-weight: 650;
    font-size: var(--t-md);
    letter-spacing: 0.005em;
    white-space: nowrap;
    color: var(--ink);
    transition:
      transform var(--t-base) var(--ease-spring),
      box-shadow var(--t-base) var(--ease-out),
      border-color var(--t-base) var(--ease-out),
      filter var(--t-base) var(--ease-out);
  }
  /* Every mono surface is an instrument readout: tabular figures so counting
     values never jitter, and a touch more tracking so it reads as machined. */
  .readout, .stat, .stat__val, .field--mono, [class*="__count"], [class*="timer"] {
    font-variant-numeric: var(--num);
    letter-spacing: var(--track-mono);
  }

  .action:hover:not(:disabled) { transform: var(--hover-lift); }
  .action:active:not(:disabled) { transform: var(--press); }
  .action:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

  /* Primary — one solid accent fill. Gradients and a shine sweep on every
     button made the most important control on each screen read as decoration;
     a calm, solid surface reads as *the* thing to press. */
  .action--primary {
    color: var(--seg-text);
    background: var(--accent);
    box-shadow:
      0 14px 34px -16px color-mix(in srgb, var(--accent) 75%, transparent),
      inset 0 1px 0 rgba(255, 255, 255, 0.28),
      inset 0 -2px 0 rgba(0, 0, 0, 0.14);
  }
  .action--primary:hover:not(:disabled) { filter: brightness(1.07); }

  .action--ghost {
    color: var(--ink);
    background: var(--glass);
    border-color: var(--stroke);
  }
  .action--ghost:hover:not(:disabled) { border-color: var(--stroke-bright); background: var(--glass-2); }

  /* Danger — clear / reset / eliminate. Quiet until hovered: these are the
     least important actions on a screen and must never out-shout the primary. */
  .action--danger {
    color: color-mix(in srgb, var(--bad) 78%, var(--ink));
    background: transparent;
    border-color: var(--stroke);
  }
  .action--danger:hover:not(:disabled) {
    border-color: color-mix(in srgb, var(--bad) 55%, transparent);
    background: var(--bad-soft);
  }

  .action--sm { min-height: 40px; padding: 8px 18px; font-size: var(--t-sm); }
  .action--lg { min-height: 56px; padding: 0 40px; font-size: 1.06rem; }
  .action--block { width: 100%; }

  /* Action dock — the bottom of every simple game: one primary action at
     full thumb width, the quiet reset under it. */
  .mode-dock {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--s-2);
    width: min(100%, 440px);
    margin-top: auto;
    padding-top: var(--s-3);
  }

  /* Every mode gets one obvious reset. Centred, quiet, always reachable. */
  .mode-clear-row {
    display: flex;
    justify-content: center;
    width: 100%;
  }

  @media (max-width: 720px) {
    .action--lg { padding: 0 24px; font-size: 1.02rem; }
    /* Free-standing large actions cap at a comfortable width; block actions
       (the docks) are meant to span their column. */
    .action--lg:not(.action--block) { width: min(100%, 340px); }
    .action { min-height: 48px; }
  }

  /* ══════════════════════════════════════════════════════════════════════
     BTN — compact utility button (topbar, modal, panel actions)
     ══════════════════════════════════════════════════════════════════════ */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    min-height: 40px;
    padding: 10px 18px;
    border: 1px solid var(--stroke);
    border-radius: var(--r-sm);
    background: var(--glass);
    color: var(--ink);
    font-weight: 700;
    font-size: var(--t-sm);
    transition: transform var(--t-fast) var(--ease-out),
                border-color var(--t-fast), background var(--t-fast), filter var(--t-fast);
  }
  .btn:hover:not(:disabled) { transform: var(--hover-lift); border-color: var(--stroke-bright); }
  .btn:active:not(:disabled) { transform: var(--press); }
  .btn:disabled { opacity: 0.45; cursor: not-allowed; }
  .btn--solid {
    background: var(--accent);
    color: var(--seg-text);
    border-color: transparent;
  }
  .btn--solid:hover:not(:disabled) { filter: brightness(1.08); }

  .icon-btn {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: var(--tap);
    height: var(--tap);
    border: 1px solid var(--stroke);
    border-radius: var(--r-sm);
    background: var(--glass);
    color: var(--ink-dim);
    transition: transform var(--t-fast) var(--ease-out), color var(--t-fast), border-color var(--t-fast);
  }
  .icon-btn:hover { color: var(--ink); border-color: var(--stroke-bright); transform: var(--hover-lift); }
  .ico { width: 18px; height: 18px; fill: currentColor; }
  .icon-btn[data-on="false"] .snd-wave { opacity: 0.2; }
  .dot-accent {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 12px var(--accent);
  }

  /* ══════════════════════════════════════════════════════════════════════
     CHIP — pill toggle / tag (presets, entry tools, dice types, history)
     ══════════════════════════════════════════════════════════════════════ */
  .chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    min-height: 36px;
    padding: 7px 14px;
    border: 1px solid var(--stroke);
    border-radius: var(--r-full);
    background: var(--glass);
    color: var(--ink-dim);
    font-weight: 600;
    font-size: var(--t-xs);
    transition: transform var(--t-fast) var(--ease-out),
                border-color var(--t-fast), color var(--t-fast), background var(--t-fast);
  }
  .chip:hover { color: var(--ink); border-color: var(--stroke-bright); transform: var(--hover-lift); }
  .chip.is-active {
    color: var(--accent);
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    box-shadow: 0 0 18px -6px color-mix(in srgb, var(--accent) 55%, transparent);
  }
  /* Mixed from --ink so it reads on paper themes as well as dark ones. */
  .chip--danger {
    color: color-mix(in srgb, var(--bad) 70%, var(--ink));
    border-color: color-mix(in srgb, var(--bad) 42%, transparent);
    background: color-mix(in srgb, var(--bad) 10%, transparent);
  }
  .chip--danger:hover { color: var(--ink); border-color: color-mix(in srgb, var(--bad) 72%, transparent); }
  .chip--ok   { color: var(--ok);   border-color: color-mix(in srgb, var(--ok) 34%, transparent);   background: var(--ok-soft); }
  .chip--warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 34%, transparent); background: var(--warn-soft); }
  .chip--bad  { color: var(--bad);  border-color: color-mix(in srgb, var(--bad) 34%, transparent);  background: var(--bad-soft); }

  @media (max-width: 720px) {
    .chip { min-height: var(--tap); padding-inline: 12px; }
  }

  /* ══════════════════════════════════════════════════════════════════════
     STAT — label + value readout (Coin tally, Mines counts, BJ bank, Marble)
     ══════════════════════════════════════════════════════════════════════ */
  .stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 0;
  }
  .stat__label {
    font-family: var(--font-mono);
    font-size: var(--t-2xs);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--ink-faint);
    white-space: nowrap;
  }
  .stat__val {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: var(--d-sm);
    line-height: 1;
    color: var(--ink);
  }
  .stat--accent .stat__val { color: var(--accent); }
  .stat--gold .stat__val { color: var(--gold); }
  .stat--pill {
    padding: 9px 14px;
    border: 1px solid var(--stroke);
    border-radius: var(--r-full);
    background: var(--well);
  }
  .stat--pill .stat__val { font-size: var(--t-md); }
  .stat--boxed {
    padding: 12px 18px;
    border: 1px solid var(--stroke-accent);
    border-radius: var(--r-md);
    background: var(--well);
  }

  /* ══════════════════════════════════════════════════════════════════════
     READOUT — the wide result strip (Marble champion, Dice total, Mines status)
     ══════════════════════════════════════════════════════════════════════ */
  .readout {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-4);
    width: 100%;
    min-height: 66px;
    padding: 12px 18px;
    border: 1px solid var(--stroke);
    border-radius: var(--r-md);
    background: linear-gradient(90deg, var(--glass-2), var(--glass)), var(--well);
    text-align: left;
  }
  .readout--center { flex-direction: column; justify-content: center; gap: var(--s-1); text-align: center; }
  .readout__label {
    font-family: var(--font-mono);
    font-size: var(--t-2xs);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--ink-faint);
    white-space: nowrap;
  }
  .readout__val,
  .readout b {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: var(--d-sm);
    line-height: 1.1;
    color: var(--ink);
    text-align: right;
    text-wrap: balance;
    min-width: 0;
  }

  /* ══════════════════════════════════════════════════════════════════════
     FIELD — inputs and textareas
     16px minimum font size everywhere so iOS Safari never zooms on focus.
     ══════════════════════════════════════════════════════════════════════ */
  .field {
    width: 100%;
    min-width: 0;
    min-height: var(--tap);
    padding: 0 14px;
    border: 1px solid var(--stroke);
    border-radius: var(--r-sm);
    background: var(--well);
    color: var(--ink);
    font-size: max(16px, var(--t-md));
    outline: none;
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
  }
  .field::placeholder { color: var(--ink-faint); }
  .field:focus-visible,
  .field:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
  }
  .field--area {
    min-height: 180px;
    padding: 14px;
    font-family: var(--font-mono);
    font-size: max(16px, var(--t-sm));
    line-height: 1.7;
    resize: vertical;
  }
  .field--mono { font-family: var(--font-mono); font-weight: 700; }

  /* Input + adjacent submit button. */
  .field-row { display: flex; gap: var(--s-2); width: 100%; }
  .field-row .action,
  .field-row .btn { flex: 0 0 auto; }

  .field-note {
    margin: 0;
    font-size: var(--t-xs);
    line-height: 1.5;
    color: var(--ink-faint);
  }
  .field-note code {
    padding: 1px 5px;
    border-radius: 5px;
    background: var(--glass-2);
    font-family: var(--font-mono);
    color: var(--accent);
  }

  .field-label {
    display: block;
    font-family: var(--font-mono);
    font-size: var(--t-2xs);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--ink-faint);
  }

  /* ══════════════════════════════════════════════════════════════════════
     SEG — segmented control (engine switch, panel tabs, dice count, nav)
     ══════════════════════════════════════════════════════════════════════ */
  .seg {
    display: flex;
    gap: var(--s-1);
    padding: var(--s-1);
    border: 1px solid var(--stroke);
    border-radius: var(--r-full);
    background: var(--well);
  }
  .seg__item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    min-height: 36px;
    padding: 8px 18px;
    border-radius: var(--r-full);
    color: var(--ink-dim);
    font-weight: 600;
    font-size: var(--t-sm);
    white-space: nowrap;
    transition: background var(--t-base) var(--ease-out), color var(--t-base) var(--ease-out);
  }
  .seg__item:hover { color: var(--ink); }
  .seg__item.is-active {
    background: var(--accent);
    color: var(--seg-text);
    box-shadow: 0 6px 22px -8px color-mix(in srgb, var(--accent) 70%, transparent);
  }
  .seg--square { border-radius: var(--r-sm); }
  .seg--square .seg__item { border-radius: var(--r-xs); }

  /* ══════════════════════════════════════════════════════════════════════
     TOPBAR
     ══════════════════════════════════════════════════════════════════════ */
  .topbar {
    position: sticky;
    top: 0;
    z-index: var(--z-topbar);
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: clamp(16px, 2.4vw, 36px);
    min-height: var(--topbar-h);
    padding-inline: clamp(18px, 3vw, 48px);
    border-bottom: 1px solid var(--stroke);
  }
  /* The blur lives on a pseudo-element, not on .topbar itself. `backdrop-filter`
     on an element makes it the containing block for any `position: fixed`
     descendant — which would pin the mobile bottom nav to the header instead of
     the viewport. Keeping the filter on ::before avoids that entirely. */
  .topbar::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(180deg, color-mix(in srgb, var(--bg) 94%, transparent), color-mix(in srgb, var(--bg) 72%, transparent));
    backdrop-filter: blur(28px) saturate(1.3);
    -webkit-backdrop-filter: blur(28px) saturate(1.3);
  }

  .brand {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    min-width: 0;
    text-decoration: none;
    color: var(--ink);
  }
  .brand__mark svg {
    display: block;
    filter:
      drop-shadow(0 0 10px color-mix(in srgb, var(--accent) 48%, transparent))
      drop-shadow(0 10px 24px rgba(0, 0, 0, 0.42));
  }
  .bm-aura {
    fill: color-mix(in srgb, var(--accent) 14%, transparent);
    stroke: color-mix(in srgb, var(--accent2) 26%, transparent);
    stroke-width: 1;
  }
  .bm-ring { fill: none; stroke: url(#brandHaloStroke); stroke-width: 3.3; opacity: 0.94; }
  .bm-sweep {
    fill: none;
    stroke: #fff;
    stroke-width: 4.2;
    stroke-linecap: round;
    opacity: 0.5;
    transform-origin: 24px 24px;
    animation: spinDot 3.8s linear infinite;
  }
  .bm-prism {
    fill: url(#brandCoreGlow);
    opacity: 0.9;
    transform-origin: 24px 24px;
    animation: logoPrismPulse 3.6s var(--ease-out) infinite;
  }
  .bm-core { fill: #06110f; stroke: color-mix(in srgb, var(--accent) 48%, transparent); stroke-width: 1.4; }
  .bm-dot { fill: var(--warn); transform-origin: 24px 24px; animation: spinDot 5s linear infinite; }
  @keyframes logoPrismPulse {
    0%, 100% { transform: scale(0.95); opacity: 0.72; }
    45% { transform: scale(1.05); opacity: 1; }
  }

  .brand__type { display: flex; flex-direction: column; line-height: 1; min-width: 0; }
  .brand__name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.4rem;
    letter-spacing: 0.04em;
  }
  .brand__sub {
    margin-top: 3px;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--ink-faint);
  }

  .topbar__actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--s-2);
  }

  /* Below 1200px the header's job is the mode rail, so the secondary
     affordances yield their width first. Share and Fullscreen are desktop
     conveniences — touch platforms have a native share sheet and their own
     fullscreen gesture — so they are the right things to drop. */
  @media (max-width: 1199px) {
    #btnShare,
    #btnFullscreen { display: none; }
    .brand__sub { display: none; }
    .brand__name { font-size: 1.25rem; }
    .topbar__actions .btn { padding-inline: var(--s-3); }
  }
  @media (max-width: 720px) {
    .brand__name { font-size: 1.2rem; }
  }

  /* ══════════════════════════════════════════════════════════════════════
     MODE NAV — the app's primary navigation, 7 modes
     Desktop: a centred pill rail in the topbar.
     Mobile:  a labelled, horizontally scrollable second header row.
     ══════════════════════════════════════════════════════════════════════ */
  .mode-nav {
    display: flex;
    justify-content: center;
    gap: 2px;
    padding: 4px;
    border: 1px solid var(--stroke);
    border-radius: var(--r-full);
    background: color-mix(in srgb, var(--well) 86%, transparent);
    min-width: 0;
  }

  .mode-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 40px;
    padding: 8px clamp(10px, 1vw, 16px);
    border-radius: var(--r-full);
    color: var(--ink-dim);
    font-weight: 700;
    font-size: var(--t-sm);
    white-space: nowrap;
    letter-spacing: 0.01em;
    transition: background var(--t-base) var(--ease-out), color var(--t-base) var(--ease-out), transform var(--t-base) var(--ease-spring);
  }
  .mode-tab:hover { color: var(--ink); transform: translateY(-1px); }
  .mode-tab[aria-selected="true"],
  .mode-tab.is-active {
    background: color-mix(in srgb, var(--accent) 14%, var(--glass-2));
    color: color-mix(in srgb, var(--accent) 78%, white);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 24%, transparent), 0 8px 24px -14px var(--accent);
  }
  .mode-ico { font-size: 1.05rem; line-height: 1; }
  /* Game icons are inline SVG sized by the surrounding font-size, so every
     container keeps controlling them with one property. */
  .ico-game { display: block; width: 1em; height: 1em; flex: none; }

  /* A mode label is never hidden. Seven abstract glyphs (◎ ◆ ◌ ♠ ⬤ ⚄ ◉) are
     indistinguishable without one, so when space runs out the *rail* gives way
     — first by tightening, then by moving to the bottom of the screen — never
     the words. `overflow-x` is the backstop that stops the rail from ever
     spilling over the topbar actions. */
  .mode-nav {
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }
  .mode-nav::-webkit-scrollbar { display: none; }

  @media (max-width: 1199px) {
    .mode-tab { gap: 5px; padding-inline: 10px; font-size: var(--t-xs); }
    .mode-ico { font-size: 0.95rem; }
  }

  /* ---------- Game switcher (≤900px) ----------
     Seven pills cannot share a phone's width without clipping, and a clipped
     pill reads as broken. On touch layouts the header becomes one row — brand,
     the current game, settings — and the switcher opens the game sheet, where
     every game keeps its name and tagline at full size. */
  .mode-switch {
    display: none;
    align-items: center;
    gap: 8px;
    justify-self: center;
    min-width: 0;
    max-width: 100%;
    min-height: var(--tap);
    padding: 6px 12px 6px 6px;
    border: 1px solid var(--stroke);
    border-radius: var(--r-full);
    background: var(--glass);
    color: var(--ink);
    font-weight: 600;
    font-size: var(--t-md);
    transition: border-color var(--t-fast), background var(--t-fast);
  }
  .mode-switch:hover { border-color: var(--stroke-bright); }
  .mode-switch[aria-expanded="true"] { border-color: var(--accent); }
  .mode-switch__ico {
    display: grid;
    place-items: center;
    flex: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--cab-accent, var(--accent)) 16%, transparent);
    color: color-mix(in srgb, var(--cab-accent, var(--accent)) 85%, white);
    font-size: 1rem;
    line-height: 1;
  }
  .mode-switch__name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .mode-switch__chev { flex: none; width: 18px; height: 18px; color: var(--ink-faint); }

  @media (max-width: 900px) {
    .topbar {
      grid-template-columns: auto minmax(0, 1fr) auto;
      gap: 10px;
      padding: 0 var(--gutter);
    }
    .mode-nav { display: none; }
    .mode-switch { display: inline-flex; }
  }

  .mode-sheet { display: flex; flex-direction: column; gap: 6px; }
  .mode-sheet__item {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 64px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: var(--r-md);
    color: var(--ink);
    text-align: left;
    transition: background var(--t-fast), border-color var(--t-fast);
  }
  .mode-sheet__item:hover { background: var(--glass); }
  .mode-sheet__item.is-active {
    border-color: color-mix(in srgb, var(--cab-accent) 45%, transparent);
    background: color-mix(in srgb, var(--cab-accent) 9%, transparent);
  }
  .mode-sheet__ico {
    display: grid;
    place-items: center;
    flex: none;
    width: 44px;
    height: 44px;
    border-radius: var(--r-sm);
    border: 1px solid color-mix(in srgb, var(--cab-accent) 40%, transparent);
    background: color-mix(in srgb, var(--cab-accent) 12%, var(--well));
    color: color-mix(in srgb, var(--cab-accent) 85%, white);
    font-size: 1.2rem;
  }
  .mode-sheet__copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  .mode-sheet__copy b { font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; }
  .mode-sheet__copy span { font-size: var(--t-sm); color: var(--ink-dim); }

  /* ══════════════════════════════════════════════════════════════════════
     ENGINE SWITCH — Wheel ↔ Hypercharge.
     This is a Spin-mode control, so it lives on the stage next to the wheel
     rather than in global chrome (where it was dead weight in six of seven
     modes and had to be hidden by a list of :not() selectors).
     ══════════════════════════════════════════════════════════════════════ */
  .engine-switch {
    display: flex;
    gap: var(--s-1);
    padding: var(--s-1);
    border: 1px solid var(--stroke);
    border-radius: var(--r-full);
    background: var(--well);
  }
  .eng-tab {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    min-height: 36px;
    padding: 8px 18px;
    border-radius: var(--r-full);
    color: var(--ink-dim);
    font-weight: 600;
    font-size: var(--t-sm);
    white-space: nowrap;
    transition: background var(--t-base) var(--ease-out), color var(--t-base) var(--ease-out);
  }
  .eng-tab:hover { color: var(--ink); }
  .eng-tab.is-active {
    background: var(--accent);
    color: var(--seg-text);
    box-shadow: 0 6px 22px -8px color-mix(in srgb, var(--accent) 70%, transparent);
  }
  .eng-ico { font-size: 1rem; }
  /* Claw has no wheel/strip choice — hide the switcher while it is active. */
  [data-engine="claw"] .engine-switch { display: none; }

  /* ══════════════════════════════════════════════════════════════════════
     CONTROL PANEL (Spin / Claw)
     ══════════════════════════════════════════════════════════════════════ */
  .panel {
    width: 100%;
    padding: var(--s-2);
    border: 1px solid var(--stroke);
    border-radius: var(--r-lg);
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--e-3);
    overflow: hidden;
  }
  .panel__tabs {
    display: flex;
    gap: var(--s-1);
    padding: 6px;
    border-radius: var(--r-md);
    background: rgba(0, 0, 0, 0.2);
    overflow-x: auto;
    scrollbar-width: none;
  }
  .panel__tabs::-webkit-scrollbar { display: none; }
  .ptab {
    flex: 1;
    min-width: max-content;
    min-height: 40px;
    padding: 10px 14px;
    border-radius: var(--r-xs);
    color: var(--ink-dim);
    font-weight: 600;
    font-size: var(--t-sm);
    transition: background var(--t-base) var(--ease-out), color var(--t-base) var(--ease-out);
  }
  .ptab:hover { color: var(--ink); }
  .ptab.is-active {
    background: var(--glass-2);
    color: var(--ink);
    box-shadow: inset 0 0 0 1px var(--stroke-bright);
  }
  .ptab-pane {
    display: none;
    padding: 18px 16px 20px;
    animation: fadeUp 0.4s var(--ease-out);
  }
  .ptab-pane.is-active { display: block; }

  /* Stacked form blocks inside the panel. */
  .setting { padding: 14px 0; border-bottom: 1px solid var(--stroke); }
  .setting:last-child { border-bottom: 0; }
  .setting__label {
    display: block;
    margin-bottom: var(--s-2);
    font-family: var(--font-mono);
    font-size: var(--t-2xs);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--ink-faint);
  }
  .setting__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    min-height: var(--tap);
    font-weight: 600;
    font-size: var(--t-md);
    cursor: pointer;
  }
  .setting__hint { margin-top: 6px; font-size: var(--t-xs); color: var(--ink-faint); }
  .setting__val { font-family: var(--font-mono); font-size: var(--t-xs); color: var(--accent); float: right; }

  .switch {
    position: relative;
    flex: 0 0 auto;
    width: 48px;
    height: 28px;
    appearance: none;
    border-radius: var(--r-full);
    background: rgba(255, 255, 255, 0.12);
    cursor: pointer;
    transition: background var(--t-base);
  }
  .switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    transition: transform var(--t-base) var(--ease-spring);
  }
  .switch:checked { background: var(--accent); }
  .switch:checked::after { transform: translateX(20px); }

  .range {
    width: 100%;
    height: 6px;
    margin-top: var(--s-3);
    appearance: none;
    border-radius: var(--r-full);
    background: rgba(255, 255, 255, 0.12);
    outline: none;
  }
  .range::-webkit-slider-thumb {
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 12px var(--accent);
    cursor: pointer;
  }
  .range::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
  }

  .number-field {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--s-3);
    min-height: 56px;
    padding: 8px 10px 8px 14px;
    border: 1px solid var(--stroke);
    border-radius: var(--r-sm);
    background: var(--well);
  }
  .number-field input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--ink);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: max(16px, 1.3rem);
    line-height: 1;
  }
  .number-field input:focus { color: var(--accent); }
  .number-field__unit {
    padding: 6px 10px;
    border: 1px solid var(--stroke);
    border-radius: var(--r-full);
    background: var(--glass);
    font-family: var(--font-mono);
    font-size: var(--t-2xs);
    color: var(--ink-faint);
    white-space: nowrap;
  }

  .toolbar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
    gap: var(--s-2);
  }
  /* Four entry tools, always one row — a lone wrapped "Clear" read as broken. */
  .entries-toolbar { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: var(--s-3); }
  .entries-toolbar .chip { justify-content: center; padding-inline: 6px; white-space: nowrap; }
  .preset-row { display: flex; flex-wrap: wrap; gap: 7px; }

  /* Results / history */
  .results-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    margin-bottom: var(--s-3);
  }
  .results-head h3 { font-family: var(--font-display); font-size: var(--t-lg); }
  .history-list {
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    max-height: 300px;
    margin-bottom: var(--s-4);
    overflow-y: auto;
  }
  .history-list li {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: 11px 14px;
    border: 1px solid var(--stroke);
    border-radius: var(--r-sm);
    background: var(--glass);
    font-weight: 600;
    font-size: var(--t-sm);
    animation: fadeUp 0.4s var(--ease-out);
  }
  .history-list .h-idx { font-family: var(--font-mono); font-size: var(--t-2xs); color: var(--ink-faint); }
  .history-list .h-dot { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; }
  .history-list .h-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .history-list .h-time { margin-left: auto; font-family: var(--font-mono); font-size: var(--t-2xs); color: var(--ink-faint); }
  .history-empty { justify-content: center; color: var(--ink-faint); font-weight: 400; }

  .tally__label {
    font-family: var(--font-mono);
    font-size: var(--t-2xs);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--ink-faint);
  }
  .tally__bars { display: flex; flex-direction: column; gap: var(--s-2); margin-top: var(--s-3); }
  .tally-row {
    display: grid;
    grid-template-columns: minmax(0, 90px) 1fr 28px;
    align-items: center;
    gap: var(--s-3);
    font-size: var(--t-sm);
  }
  .tally-row .t-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tally-row .t-track { height: 8px; border-radius: var(--r-full); background: rgba(0, 0, 0, 0.3); overflow: hidden; }
  .tally-row .t-fill { height: 100%; border-radius: var(--r-full); transition: width 0.6s var(--ease-out); }
  .tally-row .t-count { font-family: var(--font-mono); font-size: var(--t-2xs); color: var(--ink-dim); text-align: right; }

  .saved-wheels { display: flex; flex-wrap: wrap; gap: 7px; }
  .saved-wheels .saved-item { display: inline-flex; align-items: center; gap: var(--s-2); }
  .saved-item .sw-del { color: var(--ink-faint); }

  /* ══════════════════════════════════════════════════════════════════════
     THEME DRAWER
     ══════════════════════════════════════════════════════════════════════ */
  .drawer {
    position: fixed;
    inset: 0;
    z-index: var(--z-drawer);
    visibility: hidden;
  }
  .drawer[aria-hidden="true"] { pointer-events: none; }
  .drawer[aria-hidden="false"] { visibility: visible; }
  .drawer__scrim {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.62);
    backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity var(--t-slow);
  }
  .drawer[aria-hidden="false"] .drawer__scrim { opacity: 1; }
  .drawer__panel {
    position: absolute;
    inset: 0 0 0 auto;
    width: min(460px, 100vw);
    padding: var(--s-5);
    padding-bottom: calc(var(--s-5) + env(safe-area-inset-bottom, 0px));
    border-left: 1px solid var(--stroke);
    background: color-mix(in srgb, var(--bg) 80%, #000);
    box-shadow: var(--e-3);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateX(100%);
    transition: transform var(--t-slow) var(--ease-out);
  }
  .drawer[aria-hidden="false"] .drawer__panel { transform: none; }
  /* Phones: every drawer is a bottom sheet — reachable by thumb, and it
     reads as "on top of" the game rather than replacing it. */
  @media (max-width: 720px) {
    .drawer__panel {
      inset: auto 0 0 0;
      width: 100%;
      max-height: 88svh;
      padding: var(--s-4) var(--s-4) calc(var(--s-5) + env(safe-area-inset-bottom, 0px));
      border-left: 0;
      border-top: 1px solid var(--stroke-bright);
      border-radius: var(--r-xl) var(--r-xl) 0 0;
      transform: translateY(100%);
    }
    .drawer__panel::before {
      content: "";
      display: block;
      width: 40px;
      height: 4px;
      margin: 0 auto var(--s-3);
      border-radius: 2px;
      background: var(--stroke-bright);
    }
    .drawer__head { margin-bottom: var(--s-3); }
  }
  .drawer__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--s-5);
  }
  .drawer__head h2 { font-family: var(--font-display); font-size: 1.4rem; }

  /* Theme gallery: collections of cards, each a tiny scene painted in that
     theme's own page colour, wheel, ink and accent (--tc-* set inline by
     app.js), so a theme is judged by how it looks, not by a swatch strip. */
  .theme-gallery { display: flex; flex-direction: column; gap: var(--s-6); }
  .theme-group__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--s-3);
    margin-bottom: var(--s-3);
  }
  .theme-group__head h3 { font-family: var(--font-display); font-weight: 700; font-size: var(--t-lg); }
  .theme-group__head span {
    font-family: var(--font-mono);
    font-size: var(--t-2xs);
    letter-spacing: var(--track-mono);
    color: var(--ink-faint);
    text-align: right;
  }
  .theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
  .theme-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 8px 12px;
    border: 1px solid var(--stroke);
    border-radius: var(--r-md);
    background: var(--glass);
    text-align: left;
    transition: transform var(--t-base) var(--ease-out), border-color var(--t-base), box-shadow var(--t-base);
  }
  .theme-card:hover { transform: translateY(-3px); border-color: var(--stroke-bright); }
  .theme-card.is-active { border-color: var(--accent); box-shadow: var(--glow); }
  /* An active check so the current theme is identifiable without relying on
     the glow alone (which is easy to miss and invisible in forced colours). */
  .theme-card.is-active::after {
    content: "✓";
    position: absolute;
    top: 14px;
    left: 14px;
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--seg-text);
    font-size: 0.7rem;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  }
  .theme-card__scene {
    position: relative;
    display: block;
    aspect-ratio: 16 / 10;
    margin-bottom: 8px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: calc(12px * var(--tc-round, 1));
    overflow: hidden;
    background:
      radial-gradient(circle at 18% 12%, var(--tc-mesh1), transparent 62%),
      radial-gradient(circle at 88% 92%, var(--tc-mesh2), transparent 60%),
      var(--tc-bg);
  }
  .theme-card--light .theme-card__scene { border-color: rgba(20, 26, 33, 0.12); }
  .theme-card__wheel {
    position: absolute;
    top: 50%;
    right: -14%;
    width: 64%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: var(--tc-wheel);
    box-shadow:
      0 0 0 3px var(--tc-bg),
      0 0 0 4px var(--tc-accent),
      0 10px 28px -8px var(--tc-accent);
    translate: 0 -50%;
    transition: rotate 0.9s var(--ease-out);
  }
  .theme-card__wheel::after {
    content: "";
    position: absolute;
    inset: 37%;
    border-radius: 50%;
    background: var(--tc-bg);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--tc-accent) 60%, transparent);
  }
  .theme-card:hover .theme-card__wheel,
  .theme-card.is-active .theme-card__wheel { rotate: 60deg; }
  /* A sketch of the UI in the theme's ink and accent: title, line, button. */
  .theme-card__ui {
    position: absolute;
    top: 26%;
    left: 9%;
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 42%;
  }
  .theme-card__ui i { display: block; height: 6px; border-radius: 3px; background: var(--tc-ink); }
  .theme-card__ui i + i { width: 66%; height: 4px; opacity: 0.45; }
  .theme-card__ui b {
    display: block;
    width: 72%;
    height: 13px;
    margin-top: 7px;
    border-radius: calc(7px * var(--tc-round, 1));
    background: var(--tc-accent);
    box-shadow: 0 4px 14px -4px var(--tc-accent);
  }
  .theme-card__name {
    padding-inline: 4px;
    font-family: var(--font-display);
    font-weight: 650;
    font-size: var(--t-md);
    color: var(--ink);
  }
  .theme-card__tag {
    padding-inline: 4px;
    font-size: var(--t-2xs);
    line-height: 1.35;
    color: var(--ink-faint);
  }

  /* ══════════════════════════════════════════════════════════════════════
     WINNER MODAL
     ══════════════════════════════════════════════════════════════════════ */
  .winner {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: grid;
    place-items: center;
    padding: var(--gutter);
    /* Visibility flips only after the exit transition has played (delay =
       exit duration), so closing animates instead of cutting to nothing.
       While hidden or closing it takes no input: a tap on "Dismiss" can never
       fall through to the Spin button underneath. */
    visibility: hidden;
    pointer-events: none;
    transition: visibility 0s linear var(--t-exit);
  }
  .winner[aria-hidden="false"] {
    visibility: visible;
    pointer-events: auto;
    transition-delay: 0s;
  }
  .winner::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(4, 5, 10, 0.8);
    opacity: 0;
    transition: opacity var(--t-exit) var(--ease-out);
  }
  /* Backdrop blur re-rasterises the whole page every frame of the fade; a
     phone GPU feels that. Desktop gets the blur, phones a deeper scrim. */
  @media (min-width: 721px) {
    .winner::before { backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
  }
  @media (max-width: 720px) {
    .winner::before { background: rgba(4, 5, 10, 0.86); }
  }
  .winner[aria-hidden="false"]::before { opacity: 1; transition-duration: var(--t-slow); }
  .confetti-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
  .winner__card {
    position: relative;
    z-index: 2;
    width: min(92vw, 560px);
    padding: clamp(28px, 5vw, 44px) clamp(20px, 5vw, 44px) clamp(18px, 3vw, 28px);
    border: 1px solid var(--stroke-bright);
    border-radius: var(--r-2xl);
    background:
      radial-gradient(120% 70% at 50% 0%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 60%),
      color-mix(in srgb, var(--bg) 82%, #000);
    box-shadow: var(--e-3), 0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent);
    text-align: center;
    opacity: 0;
    transform: scale(0.96) translateY(10px);
    /* Exit: quick and quiet. Entry (below): springy and a touch slower. */
    transition: opacity var(--t-exit) var(--ease-out), transform var(--t-exit) var(--ease-out);
  }
  .winner[aria-hidden="false"] .winner__card {
    opacity: 1;
    transform: none;
    transition: opacity var(--t-slow) var(--ease-out), transform 0.55s var(--ease-spring);
  }
  .winner__eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border: 1px solid var(--stroke);
    border-radius: var(--r-full);
    font-family: var(--font-mono);
    font-size: var(--t-2xs);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-dim);
  }
  .winner__swatch {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.14);
  }
  /* The name is the payoff: solid ink at display size, readable at a glance
     from across a room. Long names step down (data-len, set in app.js). */
  .winner__name {
    margin: var(--s-4) 0 var(--s-5);
    font-family: var(--font-display);
    font-weight: 800;
    font-size: var(--d-xl);
    line-height: 1.02;
    letter-spacing: -0.025em;
    text-wrap: balance;
    overflow-wrap: anywhere;
    color: var(--ink);
    animation: none;
  }
  .winner[aria-hidden="false"] .winner__name { animation: winnerName 0.7s 0.08s var(--ease-spring) both; }
  @keyframes winnerName {
    from { opacity: 0; transform: translateY(12px) scale(0.94); }
    to { opacity: 1; transform: none; }
  }
  .winner__name[data-len="m"] { font-size: var(--d-lg); }
  .winner__name[data-len="l"] { font-size: var(--d-md); }
  .winner__name[data-len="xl"] { font-size: var(--d-sm); line-height: 1.2; }
  .winner__actions { display: flex; flex-direction: column; gap: var(--s-2); }
  .winner__secondary { display: flex; gap: var(--s-2); }
  .winner__secondary > * { flex: 1; }
  .winner__close {
    min-height: var(--tap);
    margin-top: var(--s-2);
    padding-inline: var(--s-4);
    color: var(--ink-faint);
    font-size: var(--t-sm);
  }
  .winner__close:hover { color: var(--ink-dim); }

  /* ══════════════════════════════════════════════════════════════════════
     TOASTS — above the bottom nav, always
     ══════════════════════════════════════════════════════════════════════ */
  .toast-stack {
    position: fixed;
    left: 50%;
    bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px) + var(--s-5));
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--s-3);
    transform: translateX(-50%);
    pointer-events: none;
  }
  .toast {
    padding: 12px 20px;
    border: 1px solid var(--stroke-bright);
    border-radius: var(--r-full);
    /* Surface-derived, so it reads as a lifted card on paper themes too
       (a black mix turned it muddy grey on light backgrounds). */
    background: color-mix(in srgb, var(--surface-1) 92%, transparent);
    box-shadow: var(--e-3);
    backdrop-filter: blur(12px);
    color: var(--ink);
    font-size: var(--t-sm);
    font-weight: 600;
    animation: toastIn 0.4s var(--ease-spring);
  }
  .toast b { color: var(--accent); }
  @keyframes toastIn {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: none; }
  }

  /* ══════════════════════════════════════════════════════════════════════
     WELCOME INTRO — first-paint splash, faded out once by app.js
     ══════════════════════════════════════════════════════════════════════ */
  /* Boot veil — see the inline script in <head>. */
  #modeMain { transition: opacity 0.3s var(--ease-out); }
  .is-booting #modeMain { opacity: 0; }

  .boot-error {
    position: fixed;
    left: 50%;
    bottom: calc(var(--s-5) + env(safe-area-inset-bottom));
    z-index: var(--z-toast);
    translate: -50% 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--s-2) var(--s-4);
    width: min(92vw, 460px);
    padding: var(--s-4) var(--s-5);
    border: 1px solid var(--stroke-bright);
    border-radius: var(--r-lg);
    background: var(--surface-1);
    box-shadow: var(--e-3);
    color: var(--ink-dim);
    font-size: var(--t-sm);
  }
  .boot-error b { color: var(--ink); }


  /* ══════════════════════════════════════════════════════════════════════
     HOME
     A landing page, not a dashboard: a hero that *demonstrates* the product
     (a live halo wheel painted from the active theme's palette), then the
     instrument index, how it works, a live theme picker and a closing CTA.
     Every ambient animation here is CSS on transform/opacity only and the
     whole section is display:none outside the lobby, so it costs nothing
     while a game is running.
     ══════════════════════════════════════════════════════════════════════ */
  .lobby-section {
    --home-max: 1320px;
    width: min(var(--home-max), calc(100% - 2 * var(--gutter)));
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: clamp(64px, 11vh, 140px);
    padding-bottom: var(--s-6);
    animation: lobbyArrive 0.8s var(--ease-out) both;
  }
  @keyframes lobbyArrive {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: none; }
  }
  /* Anchor jumps (#instruments) must clear the sticky header. */
  .lobby-section [id] { scroll-margin-top: calc(var(--topbar-h) + var(--s-5)); }

  /* Mode switches move focus to the view container for keyboard users —
     these aren't interactive, so no focus ring. The global ring is a
     box-shadow, so that has to go too: without this, every game rendered
     inside a full-page accent outline that looked like a debug border. */
  .stage-wrap:focus,
  .stage-wrap:focus-visible,
  section[tabindex="-1"]:focus,
  section[tabindex="-1"]:focus-visible { outline: none; box-shadow: none; }

  .hero__status i,
  .oracle-status i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 12px var(--accent);
    animation: statusPulse 2.2s ease-in-out infinite;
  }
  @keyframes statusPulse { 50% { opacity: 0.4; transform: scale(0.72); } }

  /* Shared italic-accent treatment for every home headline's second half. */
  .hero__title em,
  .home-block__title em,
  .home-cta__title em {
    font-style: italic;
    font-weight: 400;
    background: linear-gradient(100deg, var(--accent), color-mix(in srgb, var(--accent2) 70%, var(--accent)));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }

  /* ---------- Hero ---------- */
  .hero {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    align-items: center;
    gap: clamp(24px, 4vw, 72px);
    min-height: calc(100svh - var(--topbar-h) - var(--bottom-nav-h));
    padding-block: clamp(24px, 5vh, 64px) clamp(56px, 9vh, 96px);
  }
  .hero__copy { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: flex-start; }
  .hero__status {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border: 1px solid var(--stroke);
    border-radius: var(--r-full);
    background: var(--glass);
    font-family: var(--font-mono);
    font-size: var(--t-2xs);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-dim);
    animation: heroRise 0.9s var(--ease-out) 0.05s both;
  }
  .hero__title {
    margin-top: clamp(18px, 3vh, 30px);
    font-family: var(--font-display);
    font-size: clamp(3.4rem, 8.6vw, 8.4rem);
    font-weight: 800;
    line-height: 0.88;
    letter-spacing: -0.035em;
  }
  .hero__line { display: block; animation: heroRise 1s var(--ease-out) 0.12s both; }
  .hero__line--accent { animation-delay: 0.22s; padding-bottom: 0.08em; }
  .hero__sub {
    max-width: 46ch;
    margin-top: clamp(18px, 3vh, 28px);
    font-size: clamp(var(--t-md), 1.3vw, 1.22rem);
    line-height: 1.65;
    color: var(--ink-dim);
    animation: heroRise 1s var(--ease-out) 0.32s both;
  }
  .hero__sub em { font-style: normal; color: var(--ink); }
  .hero__ctas {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s-3) var(--s-4);
    margin-top: clamp(24px, 4vh, 38px);
    animation: heroRise 1s var(--ease-out) 0.42s both;
  }
  .hero__cta { padding-inline: 34px 28px; letter-spacing: 0.14em; }
  .hero__cta .ico { width: 20px; height: 20px; transition: transform var(--t-base) var(--ease-spring); }
  .hero__cta:hover .ico { transform: translateX(4px); }
  .hero__cta-2 { min-height: var(--tap); padding-inline: 22px; border-radius: var(--r-full); text-decoration: none; }
  .hero__stats {
    display: flex;
    gap: clamp(22px, 3.4vw, 48px);
    margin-top: clamp(28px, 5vh, 52px);
    padding-top: var(--s-5);
    border-top: 1px solid var(--stroke);
    animation: heroRise 1s var(--ease-out) 0.52s both;
  }
  .hero__stat { display: flex; flex-direction: column-reverse; gap: 6px; }
  .hero__stat dt {
    font-family: var(--font-mono);
    font-size: var(--t-2xs);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-faint);
  }
  .hero__stat dd {
    font-family: var(--font-mono);
    font-size: clamp(1.4rem, 2.2vw, 2rem);
    font-weight: 600;
    font-variant-numeric: var(--num);
    color: var(--ink);
  }
  @keyframes heroRise {
    from { opacity: 0; transform: translateY(22px); }
    to { opacity: 1; transform: none; }
  }

  /* ---------- Hero visual: halo wheel + orbiting instruments ---------- */
  .hero__visual {
    position: relative;
    display: grid;
    place-items: center;
    aspect-ratio: 1;
    width: min(100%, 620px);
    justify-self: center;
    /* Orbit glyphs are placed in cqw of this box, so they track its size. */
    container-type: inline-size;
    animation: heroWheelIn 1.4s var(--ease-out) 0.15s both;
  }
  @keyframes heroWheelIn {
    from { opacity: 0; transform: scale(0.86) rotate(-24deg); }
    to { opacity: 1; transform: none; }
  }
  .hero__visual::before {
    content: "";
    position: absolute;
    inset: 4%;
    border-radius: 50%;
    background: radial-gradient(circle, color-mix(in srgb, var(--accent) 24%, transparent), transparent 68%);
    z-index: -1;
  }
  .hero-orbit { position: absolute; inset: 0; }
  .hero-orbit__ring {
    position: absolute;
    border-radius: 50%;
    border: 1px solid var(--stroke);
  }
  .hero-orbit__ring--1 { inset: 4%; border-style: dashed; opacity: 0.7; animation: spinDot 120s linear infinite; }
  .hero-orbit__ring--2 { inset: 10%; border-color: color-mix(in srgb, var(--accent) 22%, transparent); }
  .hero-orbit__ring--3 {
    inset: 14%;
    border: 0;
    background: conic-gradient(from 0deg, transparent 0 72%, color-mix(in srgb, var(--accent) 55%, transparent) 92%, transparent);
    -webkit-mask: radial-gradient(circle, transparent calc(70% - 2px), #000 70%);
    mask: radial-gradient(circle, transparent calc(70% - 2px), #000 70%);
    animation: spinDot 6s linear infinite;
  }
  /* Glyphs ride the outer ring; each counter-rotates so it stays upright. */
  .hero-orbit__track { position: absolute; inset: 0; animation: spinDot 60s linear infinite; }
  .hero-orbit__glyph {
    --angle: calc(360deg / var(--n) * var(--i));
    position: absolute;
    top: 50%;
    left: 50%;
    width: clamp(36px, 4.4vw, 50px);
    aspect-ratio: 1;
    margin: calc(clamp(36px, 4.4vw, 50px) / -2);
    transform: rotate(var(--angle)) translateY(-46cqw);
  }
  .hero-orbit__glyph > span {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 1px solid color-mix(in srgb, var(--g-accent) 45%, transparent);
    background: color-mix(in srgb, var(--surface-0) 82%, var(--g-accent) 18%);
    box-shadow: 0 0 22px -4px color-mix(in srgb, var(--g-accent) 60%, transparent);
    color: color-mix(in srgb, var(--g-accent) 80%, white);
    font-size: clamp(0.95rem, 1.3vw, 1.2rem);
    transform: rotate(calc(-1 * var(--angle)));
    animation: heroGlyphUpright 60s linear infinite;
  }
  .hero-orbit__glyph > span { transition: scale var(--t-slow) var(--ease-spring), box-shadow var(--t-slow), background var(--t-slow); }
  .hero-orbit__glyph.is-picked > span {
    scale: 1.32;
    background: color-mix(in srgb, var(--surface-0) 55%, var(--g-accent) 45%);
    box-shadow: 0 0 0 2px var(--g-accent), 0 0 36px -2px var(--g-accent);
    color: var(--ink);
  }
  @keyframes heroGlyphUpright {
    from { rotate: 0deg; }
    to { rotate: -360deg; }
  }

  .hero-wheel {
    position: relative;
    width: 72%;
    aspect-ratio: 1;
    display: grid;
    place-items: center;
  }
  .hero-wheel__disc {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    /* --hero-games is one palette slice per game, set by applyTheme(). */
    background: var(--hero-games, conic-gradient(var(--accent), var(--accent2), var(--accent)));
    box-shadow:
      0 0 0 6px color-mix(in srgb, var(--surface-0) 90%, transparent),
      0 0 0 7px color-mix(in srgb, var(--accent) 50%, transparent),
      0 40px 90px -30px color-mix(in srgb, var(--accent) 60%, transparent),
      var(--e-3);
    animation: spinDot 38s linear infinite;
  }
  /* Once spun, app.js owns the angle (inline transform); the idle drift stops. */
  .hero-wheel.is-live .hero-wheel__disc { animation: none; }
  /* Hairline segment dividers + a gloss pass make a flat gradient read as an object. */
  .hero-wheel__ticks {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: repeating-conic-gradient(from 0deg, rgba(0, 0, 0, 0.32) 0 0.6deg, transparent 0.6deg var(--slice, 30deg));
  }
  /* One game icon per slice, riding the disc and pointing outward. Sized in
     cqw of .hero__visual so it scales with the wheel. */
  .hero-wheel__slots { position: absolute; inset: 0; }
  .hero-wheel__slot { position: absolute; inset: 0; transform: rotate(var(--a)); }
  .hero-wheel__slot > span {
    position: absolute;
    top: 9%;
    left: 50%;
    display: grid;
    place-items: center;
    translate: -50% 0;
    color: var(--hero-games-ink, var(--seg-text));
    font-size: 6.2cqw;
    opacity: 0.86;
  }
  .hero-wheel__sheen {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background:
      radial-gradient(circle at 50% 50%, transparent 30%, rgba(0, 0, 0, 0.32) 72%),
      linear-gradient(150deg, rgba(255, 255, 255, 0.34), transparent 46%);
    mix-blend-mode: soft-light;
  }
  .hero-wheel__pointer {
    position: absolute;
    top: -5%;
    left: 50%;
    z-index: 2;
    width: 9%;
    aspect-ratio: 0.8;
    translate: -50% 0;
    background: linear-gradient(180deg, var(--ink), color-mix(in srgb, var(--ink) 70%, var(--accent)));
    clip-path: polygon(0 0, 100% 0, 50% 100%);
    filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.5));
  }
  .hero-wheel__hub {
    position: relative;
    z-index: 1;
    width: 30%;
    aspect-ratio: 1;
    border-radius: 50%;
    border: 1px solid var(--stroke-bright);
    background:
      radial-gradient(circle at 35% 28%, color-mix(in srgb, var(--surface-2) 70%, #fff 10%), var(--surface-0) 72%);
    box-shadow:
      0 0 0 6px color-mix(in srgb, var(--surface-0) 70%, transparent),
      0 18px 40px -10px rgba(0, 0, 0, 0.7),
      var(--inset-top);
    color: var(--ink);
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: clamp(0.8rem, 1.3vw, 1.05rem);
    letter-spacing: 0.22em;
    cursor: pointer;
    transition: transform var(--t-base) var(--ease-spring), box-shadow var(--t-base);
  }
  .hero-wheel__hub span { padding-left: 0.22em; }
  .hero-wheel__hub:hover { transform: scale(1.06); box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 40%, transparent), var(--glow); }
  .hero-wheel__hub:active { transform: scale(0.96); }
  .hero-wheel__hub:focus-visible { outline: none; box-shadow: var(--focus-ring), var(--glow); }

  /* The pick: what the game wheel chose, and the way in. */
  .hero-pick {
    position: absolute;
    left: 50%;
    bottom: -6%;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: min(94%, 360px);
    padding: 12px 14px 14px;
    border: 1px solid color-mix(in srgb, var(--g-accent, var(--accent)) 50%, var(--stroke));
    border-radius: var(--r-lg);
    background: color-mix(in srgb, var(--surface-0) 86%, transparent);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--e-3), 0 0 50px -18px var(--g-accent, var(--accent));
    text-align: center;
    translate: -50% 0;
    animation: heroPickIn 0.5s var(--ease-spring) both;
  }
  @keyframes heroPickIn {
    from { opacity: 0; transform: translateY(14px) scale(0.94); }
    to { opacity: 1; transform: none; }
  }
  .hero-pick__kicker {
    font-family: var(--font-mono);
    font-size: var(--t-2xs);
    letter-spacing: var(--track-caps);
    text-transform: uppercase;
    color: var(--ink-faint);
  }
  .hero-pick__game { display: inline-flex; align-items: center; gap: 10px; }
  .hero-pick__glyph {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--surface-0) 60%, var(--g-accent, var(--accent)) 40%);
    color: var(--ink);
    font-size: 1.05rem;
  }
  .hero-pick__name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: var(--d-sm);
    line-height: 1.05;
    color: var(--ink);
  }
  .hero-pick__tag { font-size: var(--t-sm); color: var(--ink-dim); }
  .hero-pick__actions { display: flex; gap: var(--s-2); width: 100%; margin-top: 6px; }
  /* While a pick is showing, the floating readouts step aside for it. */
  .hero__readout { transition: opacity var(--t-base); }
  .hero__visual:has(.hero-pick:not([hidden])) .hero__readout { opacity: 0; }
  /* Phones: a compact card that covers the orbit below the wheel, not the
     slice that just won (that one sits under the pointer at the top). */
  @media (max-width: 720px) {
    .hero-pick { bottom: -10%; }
    .hero__visual:has(.hero-pick:not([hidden])) { margin-bottom: var(--s-6); }
    .hero-pick__tag { display: none; }
    .hero-pick__name { font-size: var(--t-lg); }
    .hero-pick__glyph { width: 28px; height: 28px; font-size: 0.9rem; }
  }
  .hero-pick__play { flex: 1 1 auto; min-height: 46px; padding: 10px 18px; }
  .hero-pick__again { flex: 0 0 auto; min-height: 46px; padding: 10px 16px; font-size: var(--t-sm); }

  .hero__readout {
    position: absolute;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 10px 14px;
    border: 1px solid var(--stroke);
    border-radius: var(--r-sm);
    background: color-mix(in srgb, var(--surface-0) 78%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: var(--e-2);
    font-family: var(--font-mono);
    font-size: 0.66rem;
    letter-spacing: 0.06em;
    color: var(--ink-dim);
    white-space: nowrap;
  }
  .hero__readout b { font-weight: 600; font-size: 0.6rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); }
  .hero__readout--a { left: -2%; bottom: 14%; animation: heroFloat 7s ease-in-out infinite; }
  .hero__readout--b { right: -2%; top: 12%; animation: heroFloat 8s ease-in-out -3s infinite; }
  @keyframes heroFloat { 50% { transform: translateY(-10px); } }

  .hero__scroll {
    position: absolute;
    left: 50%;
    bottom: clamp(8px, 2vh, 20px);
    translate: -50% 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--ink-faint);
  }
  .hero__scroll i {
    width: 1px;
    height: 34px;
    background: linear-gradient(180deg, var(--accent), transparent);
    animation: heroScroll 2s var(--ease-out) infinite;
    transform-origin: top;
  }
  @keyframes heroScroll {
    0% { transform: scaleY(0); opacity: 1; }
    70% { transform: scaleY(1); opacity: 1; }
    100% { transform: scaleY(1); opacity: 0; }
  }

  /* ---------- Ticker ---------- */
  .ticker {
    margin-top: calc(-1 * clamp(40px, 8vh, 110px));
    width: 100vw;
    margin-inline: calc(50% - 50vw);
    overflow: hidden;
    border-block: 1px solid var(--stroke);
    background: color-mix(in srgb, var(--surface-0) 55%, transparent);
    -webkit-mask: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
    mask: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
  }
  .ticker__track {
    display: flex;
    align-items: center;
    gap: clamp(22px, 3vw, 44px);
    width: max-content;
    padding-block: 18px;
    font-family: var(--font-display);
    font-size: clamp(1.1rem, 1.8vw, 1.6rem);
    font-style: italic;
    white-space: nowrap;
    color: var(--ink-dim);
    animation: tickerRun 38s linear infinite;
  }
  .ticker__track b { font-style: normal; font-size: 0.8em; color: var(--accent); }
  @keyframes tickerRun { to { transform: translateX(-50%); } }

  /* ---------- Section frame ---------- */
  .home-block { display: flex; flex-direction: column; gap: clamp(24px, 4vh, 44px); }
  .home-block__head {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
    align-items: end;
    gap: var(--s-3) clamp(24px, 5vw, 80px);
  }
  .home-block__index {
    grid-column: 1 / -1;
    font-family: var(--font-mono);
    font-size: var(--t-2xs);
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--accent);
  }
  .home-block__title {
    font-family: var(--font-display);
    font-size: clamp(2.1rem, 4.6vw, 4rem);
    font-weight: 700;
    line-height: 0.98;
    letter-spacing: -0.03em;
    text-wrap: balance;
  }
  .home-block__sub { max-width: 44ch; color: var(--ink-dim); font-size: var(--t-md); line-height: var(--lh-body); }

  /* ---------- Instrument grid ----------
     Desktop bento: Spin is the 2×2 hero card, four regular cards flank it,
     and the last two run wide so the grid closes without holes. */
  .lobby-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: minmax(220px, auto);
    gap: clamp(12px, 1.2vw, 18px);
  }
  .lobby-grid > .cab--spin { grid-column: span 2; grid-row: span 2; }
  .lobby-grid > .cab:nth-child(n + 6) { grid-column: span 2; }

  .cab {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--s-4);
    min-width: 0;
    padding: clamp(18px, 1.6vw, 26px);
    text-align: left;
    background:
      radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--cab-accent) 16%, transparent), transparent 55%),
      linear-gradient(180deg, var(--glass-2), color-mix(in srgb, var(--surface-0) 82%, transparent));
    border: 1px solid var(--stroke);
    border-radius: var(--r-xl);
    box-shadow: var(--inset-top);
    overflow: hidden;
    color: var(--ink);
    cursor: pointer;
    isolation: isolate;
    transition: transform 0.42s var(--ease-spring), border-color 0.3s, box-shadow 0.3s;
  }
  /* Cursor-tracked spotlight; --mx/--my are written by buildLobby() on pointermove. */
  .cab::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    opacity: 0;
    background: radial-gradient(360px circle at var(--mx, 50%) var(--my, 30%), color-mix(in srgb, var(--cab-accent) 20%, transparent), transparent 60%);
    transition: opacity var(--t-slow) var(--ease-out);
  }
  .cab:hover,
  .cab:focus-visible {
    transform: translateY(-6px);
    border-color: color-mix(in srgb, var(--cab-accent) 55%, transparent);
    box-shadow:
      0 0 0 1px color-mix(in srgb, var(--cab-accent) 28%, transparent),
      0 30px 70px -28px color-mix(in srgb, var(--cab-accent) 60%, transparent);
  }
  .cab:hover::after, .cab:focus-visible::after { opacity: 1; }
  .cab:focus-visible { outline: 2px solid var(--cab-accent); outline-offset: 3px; }

  .cab__top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); }
  .cab__glyph {
    display: grid;
    place-items: center;
    flex: none;
    width: 56px;
    height: 56px;
    border-radius: var(--r-md);
    border: 1px solid color-mix(in srgb, var(--cab-accent) 40%, transparent);
    background: color-mix(in srgb, var(--cab-accent) 12%, var(--well));
    color: color-mix(in srgb, var(--cab-accent) 82%, white);
    font-size: 1.6rem;
    line-height: 1;
    box-shadow: 0 0 30px -8px color-mix(in srgb, var(--cab-accent) 70%, transparent);
    transition: transform 0.5s var(--ease-spring);
  }
  .cab:hover .cab__glyph { transform: rotate(-8deg) scale(1.08); }
  .cab__meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    font-family: var(--font-mono);
    font-size: var(--t-2xs);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-faint);
  }
  .cab__meta b { font-weight: 600; color: var(--cab-accent); }
  .cab__copy { display: flex; flex-direction: column; gap: 6px; margin-top: auto; }
  .cab__title {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 2vw, 2rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1;
  }
  .cab__tag { font-size: var(--t-sm); line-height: 1.5; color: var(--ink-dim); }
  .cab__cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: var(--s-4);
    border-top: 1px solid var(--stroke);
    font-family: var(--font-mono);
    font-size: var(--t-2xs);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-faint);
    transition: color var(--t-base), border-color var(--t-base);
  }
  .cab__cta b {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid color-mix(in srgb, var(--cab-accent) 40%, transparent);
    font-size: 0.95rem;
    color: var(--cab-accent);
    transition: transform var(--t-base) var(--ease-spring), background var(--t-base), color var(--t-base);
  }
  .cab:hover .cab__cta, .cab:focus-visible .cab__cta { color: var(--ink); border-color: color-mix(in srgb, var(--cab-accent) 35%, transparent); }
  .cab:hover .cab__cta b { transform: rotate(-45deg); background: var(--cab-accent); color: var(--surface-0); }

  /* Featured Spin card carries a miniature of the real wheel. */
  .cab__wheel { display: none; }
  .cab--spin .cab__wheel {
    display: block;
    position: absolute;
    right: -18%;
    top: 50%;
    z-index: -1;
    width: 62%;
    aspect-ratio: 1;
    translate: 0 -54%;
    border-radius: 50%;
    background: var(--hero-wheel, conic-gradient(var(--accent), var(--accent2), var(--accent)));
    opacity: 0.2;
    -webkit-mask: radial-gradient(circle, transparent 17%, #000 18%);
    mask: radial-gradient(circle, transparent 17%, #000 18%);
    transition: opacity var(--t-slow), transform 1.2s var(--ease-out);
  }
  .cab--spin:hover .cab__wheel { opacity: 0.38; transform: rotate(120deg); }
  .cab--spin .cab__title { font-size: clamp(2.4rem, 4.4vw, 4rem); }
  .cab--spin .cab__tag { max-width: 30ch; font-size: var(--t-md); }
  .cab--spin .cab__glyph { width: 68px; height: 68px; font-size: 2rem; }

  /* ---------- How it works ---------- */
  .steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(12px, 1.2vw, 18px);
    counter-reset: none;
  }
  .step {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    padding: clamp(20px, 2vw, 30px);
    overflow: hidden;
  }
  .step::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), transparent 70%);
  }
  .step__num {
    font-family: var(--font-mono);
    font-size: clamp(2rem, 3vw, 2.6rem);
    font-weight: 600;
    line-height: 1;
    color: transparent;
    -webkit-text-stroke: 1px color-mix(in srgb, var(--accent) 70%, var(--ink));
  }
  .step__title { margin-top: var(--s-4); font-family: var(--font-display); font-size: var(--d-sm); font-weight: 700; letter-spacing: -0.01em; }
  .step__body { color: var(--ink-dim); font-size: var(--t-sm); line-height: var(--lh-body); }
  .step__body em { font-style: normal; color: var(--ink); }
  .step__body code {
    padding: 1px 6px;
    border-radius: 6px;
    background: var(--well);
    font-family: var(--font-mono);
    font-size: 0.85em;
    color: var(--accent);
  }

  /* ---------- Live theme picker ---------- */
  .home-themes {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    align-items: center;
    gap: clamp(24px, 4vw, 64px);
    padding: clamp(24px, 3.6vw, 52px);
    border-radius: var(--r-2xl);
  }
  .home-themes__copy { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-4); }
  .home-themes__copy .btn { margin-top: var(--s-2); }
  .home-themes__grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: var(--s-2);
  }
  .home-theme {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
    min-height: var(--tap);
    padding: 7px;
    border: 1px solid var(--stroke);
    border-radius: var(--r-sm);
    background: var(--glass);
    color: var(--ink-dim);
    font-size: var(--t-2xs);
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: transform var(--t-fast) var(--ease-out), border-color var(--t-fast), color var(--t-fast);
  }
  .home-theme:hover { transform: var(--hover-lift); border-color: var(--stroke-bright); color: var(--ink); }
  .home-theme.is-active { border-color: var(--accent); color: var(--ink); box-shadow: var(--glow-soft); }
  .home-theme__name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .home-theme__dot {
    width: 100%;
    aspect-ratio: 1.5;
    border-radius: 6px;
    background: var(--sw);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  }

  /* ---------- Closing CTA ---------- */
  .home-cta {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(22px, 4vh, 36px);
    padding: clamp(56px, 10vh, 120px) var(--gutter);
    text-align: center;
    overflow: hidden;
    border: 1px solid var(--stroke);
    border-radius: var(--r-2xl);
    background: linear-gradient(180deg, var(--glass), transparent);
    isolation: isolate;
  }
  .home-cta__halo {
    position: absolute;
    left: 50%;
    top: 100%;
    z-index: -1;
    width: min(900px, 140%);
    aspect-ratio: 1;
    translate: -50% -50%;
    border-radius: 50%;
    background: var(--hero-wheel, conic-gradient(var(--accent), var(--accent2), var(--accent)));
    opacity: 0.18;
    -webkit-mask: radial-gradient(circle, transparent 54%, #000 55%, #000 68%, transparent 69%);
    mask: radial-gradient(circle, transparent 54%, #000 55%, #000 68%, transparent 69%);
    animation: spinDot 50s linear infinite;
  }
  .home-cta__title {
    max-width: 16ch;
    font-family: var(--font-display);
    font-size: clamp(2.2rem, 5.4vw, 4.8rem);
    font-weight: 700;
    line-height: 0.98;
    letter-spacing: -0.03em;
    text-wrap: balance;
  }

  /* ---------- Footer ---------- */
  .home-foot {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--s-5) var(--s-7);
    margin-top: calc(-1 * clamp(24px, 5vh, 70px));
    padding-top: var(--s-6);
    border-top: 1px solid var(--stroke);
  }
  .home-foot__brand { display: grid; grid-template-columns: auto 1fr; align-items: baseline; gap: 6px 10px; }
  .home-foot__brand b { font-family: var(--font-display); font-size: 1.5rem; letter-spacing: -0.01em; }
  .home-foot__brand span { font-family: var(--font-mono); font-size: var(--t-2xs); letter-spacing: 0.3em; text-transform: uppercase; color: var(--ink-faint); }
  .home-foot__brand p { grid-column: 1 / -1; max-width: 36ch; color: var(--ink-dim); font-size: var(--t-sm); }
  .home-foot__links { display: flex; flex-wrap: wrap; align-content: flex-start; justify-content: flex-end; gap: 4px; }
  .home-foot__links button {
    min-height: var(--tap);
    padding: 0 14px;
    border-radius: var(--r-full);
    color: var(--ink-dim);
    font-size: var(--t-sm);
    font-weight: 500;
    transition: color var(--t-fast), background var(--t-fast);
  }
  .home-foot__links button:hover { color: var(--ink); background: var(--glass); }
  .noscript-note {
    margin: var(--s-4) auto;
    max-width: 60ch;
    padding: var(--s-4) var(--s-5);
    border: 1px solid var(--stroke-accent);
    border-radius: var(--r-md);
    background: var(--glass);
    color: var(--ink);
    text-align: center;
  }
  .home-foot__fine {
    grid-column: 1 / -1;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-faint);
  }

  /* ---------- Responsive ---------- */
  @media (max-width: 1199px) {
    .lobby-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .lobby-grid > .cab--spin { grid-column: 1 / -1; grid-row: auto; min-height: 280px; }
    .lobby-grid > .cab:nth-child(n + 6) { grid-column: auto; }
    .cab--spin .cab__wheel { width: 52%; right: -8%; }
    .home-themes { grid-template-columns: 1fr; }
    .home-themes__grid { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  }
  @media (max-width: 900px) {
    .hero {
      grid-template-columns: 1fr;
      min-height: 0;
      padding-top: var(--s-5);
      text-align: left;
    }
    .hero__visual { order: -1; width: min(78vw, 440px); }
    .hero__scroll { display: none; }
    .ticker { margin-top: 0; }
    .home-block__head { grid-template-columns: 1fr; }
    .lobby-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(200px, auto); }
    .lobby-grid > .cab--spin { grid-column: 1 / -1; }
    .steps { grid-template-columns: 1fr; }
    .home-themes__grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .home-foot { grid-template-columns: 1fr; }
    .home-foot__links { justify-content: flex-start; margin-left: -14px; }
  }
  @media (max-width: 720px) {
    .lobby-section { gap: 56px; }
    .hero { gap: var(--s-5); padding-bottom: var(--s-4); }
    .hero__visual { width: min(84vw, 360px); }
    .hero__readout { display: none; }
    .hero__title { font-size: clamp(3rem, 15vw, 4.4rem); }
    .hero__ctas { width: 100%; }
    .hero__cta { flex: 1 1 100%; }
    .hero__cta-2 { flex: 1 1 100%; }
    .hero__stats { width: 100%; justify-content: space-between; }
    .lobby-grid { grid-template-columns: 1fr; grid-auto-rows: auto; gap: 10px; }
    .cab { flex-direction: row; flex-wrap: wrap; align-items: center; gap: var(--s-3) var(--s-4); padding: 16px; border-radius: var(--r-lg); }
    .cab__top { display: contents; }
    .cab__glyph { width: 48px; height: 48px; font-size: 1.3rem; }
    .cab__meta { order: 3; flex-basis: 100%; flex-direction: row; justify-content: space-between; align-items: center; display: none; }
    .cab__copy { flex: 1; min-width: 0; margin-top: 0; gap: 3px; }
    .cab__title { font-size: 1.3rem; }
    .cab__tag { font-size: var(--t-xs); }
    .cab__cta { padding: 0; border: 0; }
    .cab__cta span { display: none; }
    .cab--spin { flex-direction: column; align-items: flex-start; min-height: 0; padding: 20px; }
    .lobby-grid > .cab--spin { min-height: 0; }
    .cab--spin .cab__top { display: flex; width: 100%; }
    .cab--spin .cab__meta { display: flex; order: 0; flex-basis: auto; flex-direction: column; align-items: flex-end; }
    .cab--spin .cab__copy { margin-top: var(--s-6); }
    .cab--spin .cab__title { font-size: 2.6rem; }
    .cab--spin .cab__cta { width: 100%; padding-top: var(--s-3); border-top: 1px solid var(--stroke); }
    .cab--spin .cab__cta span { display: inline; }
    .cab--spin .cab__wheel { width: 70%; right: -26%; }
    .home-themes { padding: 20px; border-radius: var(--r-xl); }
    .home-themes__grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
    .home-cta { border-radius: var(--r-xl); }
    .home-foot { margin-top: 0; }
  }

  /* Short desktop windows: let the hero breathe less so the cards peek in. */
  @media (min-width: 901px) and (max-height: 800px) {
    .hero__title { font-size: clamp(3rem, 7vw, 6.4rem); }
    .hero__visual { width: min(100%, 520px); }
  }

  @media (prefers-reduced-motion: reduce) {
    .hero__status i, .oracle-status i { animation: none; }
    .hero__line, .hero__sub, .hero__ctas, .hero__stats, .hero__status, .hero__visual,
    .hero-orbit__track, .hero-orbit__glyph > span, .hero-orbit__ring, .hero-wheel__disc,
    .hero__readout, .hero__scroll i, .ticker__track, .home-cta__halo, .hero-pick { animation: none; }
    .cab:hover { transform: none; }
  }

  /* ══════════════════════════════════════════════════════════════════════
     MOBILE HINT TOGGLE + CUSTOMIZE DRAWER
     On phones the control panel stacks below the stage (see the .stage-wrap
     override below), but the drawer gives one-tap access to theme/engine/
     settings without scrolling past it.
     ══════════════════════════════════════════════════════════════════════ */
  .hint--mobile { display: none; }
  .mobile-customize-btn { display: none; }
  @media (max-width: 720px) {
    .hint--desktop { display: none; }
    .hint--mobile { display: inline; }
    .mobile-customize-btn { display: grid; }
    #btnSound, #btnTheme { display: none; }
  }

  .mobile-drawer-body {
    padding: 12px 20px 28px;
    display: flex; flex-direction: column; gap: 24px;
  }
  .mobile-drawer-section__title {
    font-family: var(--font-mono); font-size: 0.68rem;
    letter-spacing: 0.22em; text-transform: uppercase;
    color: var(--ink-faint); margin: 0 0 12px;
  }
  .mobile-drawer-engines {
    display: flex; gap: 6px; padding: 4px;
    background: var(--glass); border: 1px solid var(--stroke); border-radius: 999px;
  }
  .mobile-drawer-engines .eng-tab {
    flex: 1; justify-content: center;
    display: flex; align-items: center; gap: 8px;
    padding: 10px 14px; border: 0; border-radius: 999px;
    background: transparent; color: var(--ink-dim);
    font-weight: 600; font-size: 0.88rem;
    transition: all 0.3s var(--ease-out);
  }
  .mobile-drawer-engines .eng-tab .eng-ico { font-size: 1rem; }
  .mobile-drawer-engines .eng-tab.is-active {
    background: var(--accent); color: var(--seg-text);
    box-shadow: 0 6px 22px -6px color-mix(in srgb, var(--accent) 70%, transparent);
  }
  .mobile-drawer-controls {
    display: flex; gap: 10px;
  }
  .theme-gallery--compact { gap: var(--s-5); }
  .theme-gallery--compact .theme-grid {
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 8px;
  }
  .theme-gallery--compact .theme-card__tag { display: none; }
  .theme-gallery--compact .theme-card__name { font-size: var(--t-sm); }
  [data-engine="claw"] .mobile-drawer-engines { display: none; }

  /* ══════════════════════════════════════════════════════════════════════
     IMMERSIVE (THEATER) VIEW — data-immersive on <html>
     Only the game on screen: topbar, mode nav, and the settings panel
     vanish. Zeroing the layout vars lets every height calc() in the app
     adapt for free.
     ══════════════════════════════════════════════════════════════════════ */
  html[data-immersive] {
    --topbar-h: 0px;
    --bottom-nav-h: 0px;
  }
  html[data-immersive] .topbar,
  html[data-immersive] .mode-nav,
  html[data-immersive] .panel { display: none !important; }
  html[data-immersive] body { padding-bottom: 0 !important; }

  /* Stage games: collapse the two-column grid and center the machine. */
  html[data-immersive] .stage-wrap {
    grid-template-columns: 1fr !important;
    max-width: none;
    min-height: 100svh;
    align-items: center;
    padding: clamp(12px, 2vh, 28px) clamp(12px, 2vw, 28px);
    gap: 0;
  }
  html[data-immersive] .stage {
    min-height: 92svh;
    justify-content: center;
  }
  /* Let the wheel grow into the freed space (pointer offset tracks width/2). */
  html[data-immersive] .wheel-frame { --wheel-size: min(88vw, 80vh, 880px); }
  html[data-immersive] .wheel-pointer {
    right: calc(50% - min(44vw, 40vh, 440px) - 6px);
  }

  /* Section games: give back the topbar strip and center what remains. */
  html[data-immersive] .mode-section,
  html[data-immersive] .bj-section,
  html[data-immersive] .marble-section {
    padding-top: clamp(16px, 3vh, 36px);
  }

  /* Floating exit button — under the winner modal, above all chrome. */
  .immersive-exit {
    position: fixed;
    top: max(14px, env(safe-area-inset-top, 0px));
    right: max(14px, env(safe-area-inset-right, 0px));
    z-index: var(--z-modal);
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: 1rem;
    line-height: 1;
    color: var(--ink);
    background: color-mix(in srgb, var(--bg) 72%, transparent);
    border: 1px solid var(--stroke-bright);
    backdrop-filter: blur(14px) saturate(1.4);
    -webkit-backdrop-filter: blur(14px) saturate(1.4);
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s, transform 0.25s var(--ease-spring);
  }
  .immersive-exit:hover,
  .immersive-exit:focus-visible {
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 60%, transparent);
    transform: scale(1.08);
  }
  .immersive-exit:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
  }
  @media (prefers-reduced-motion: reduce) {
    .immersive-exit:hover { transform: none; }
  }
}
/* ============================================================================
   MODES · SPIN (Wheel + Hypercharge + Claw)
   The "command deck": playfield left, controls right, no page scroll on
   desktop. Each mode owns its own breakpoints — there is no global mobile
   override block anywhere in this file.
   ========================================================================== */
@layer modes {

  /* ══════════════════════════════════════════════════════════════════════
     STAGE SHELL
     ══════════════════════════════════════════════════════════════════════ */
  .stage-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(350px, 25vw, 440px);
    gap: clamp(18px, 2.6vw, 48px);
    align-items: center;
    width: 100%;
    max-width: var(--shell-max);
    height: calc(100svh - var(--topbar-h));
    margin-inline: auto;
    padding: clamp(10px, 1.6vh, 20px) var(--gutter);
    overflow: hidden;
  }

  /* Stack the control panel below the stage on phones — the two-column
     shell grid only makes sense once there's room for both side by side. */
  @media (max-width: 720px) {
    .stage-wrap {
      grid-template-columns: 1fr;
      height: auto;
      min-height: calc(100svh - var(--topbar-h) - var(--bottom-nav-h));
      padding-bottom: calc(var(--s-5) + var(--bottom-nav-h));
    }
    .panel { width: 100%; }
  }

  .stage {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: clamp(10px, 1.8vh, 22px);
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .stage__halo {
    position: absolute;
    top: 46%;
    left: 50%;
    width: min(78vh, 680px);
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    /* Already soft as a gradient; a blur filter here was re-rasterised on
       every frame of the charge pulse. */
    background: radial-gradient(circle, color-mix(in srgb, var(--accent) 20%, transparent), transparent 66%);
    opacity: 0.7;
    pointer-events: none;
    z-index: 0;
    transition: background 0.6s var(--ease-out);
  }
  .stage.is-stage-spinning .stage__halo { animation: haloCharge 1.1s ease-in-out infinite alternate; }
  .stage.is-stage-winner .stage__halo { animation: haloWinner 1.25s var(--ease-out); }
  @keyframes haloCharge {
    from { opacity: 0.55; transform: translate(-50%, -50%) scale(0.94); }
    to { opacity: 0.95; transform: translate(-50%, -50%) scale(1.08); }
  }
  @keyframes haloWinner {
    0% { opacity: 0.7; transform: translate(-50%, -50%) scale(0.8); }
    38% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    100% { opacity: 0.68; transform: translate(-50%, -50%) scale(1); }
  }

  .engine {
    position: relative;
    z-index: var(--z-stage);
    display: flex;
    justify-content: center;
    width: 100%;
    min-height: 0;
  }

  .stage__footline {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--s-4);
    z-index: 2;
  }
  .counter-pill {
    padding: 6px 14px;
    border: 1px solid var(--stroke);
    border-radius: var(--r-full);
    background: var(--glass);
    font-family: var(--font-mono);
    font-size: var(--t-xs);
    color: var(--ink-dim);
  }
  .counter-pill b { color: var(--accent); }
  .hint { font-size: var(--t-xs); color: var(--ink-faint); text-align: center; }
  .hint kbd {
    padding: 1px 7px;
    border: 1px solid var(--stroke);
    border-radius: 6px;
    background: var(--glass-2);
    font-family: var(--font-mono);
    color: var(--ink-dim);
  }

  /* The engine switch sits on the stage, above the wheel. */
  .stage__engines { z-index: 2; }

  /* ══════════════════════════════════════════════════════════════════════
     WHEEL ENGINE
     ══════════════════════════════════════════════════════════════════════ */
  .engine--wheel { flex-direction: column; align-items: center; }

  /* One size drives the wheel and everything hung off it (pointer, halo).
     Phones get a wheel that nearly fills the width — it is the product. */
  .wheel-frame {
    --wheel-size: min(56vw, calc(100svh - 290px), 620px);
    position: relative;
    width: var(--wheel-size);
    aspect-ratio: 1;
  }
  @media (max-width: 720px) {
    .wheel-frame { --wheel-size: min(88vw, calc(100svh - 300px), 440px); }
  }
  .wheel-frame::before,
  .wheel-frame::after {
    content: "";
    position: absolute;
    inset: -18px;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--t-base) var(--ease-out);
  }
  /* Spin glow: a soft ring shaped by a radial mask, not filter: blur() — a
     blurred layer that rotates every frame was re-rasterised every frame. */
  .wheel-frame::before {
    z-index: -1;
    background: conic-gradient(from 0deg, transparent, var(--accent), transparent, var(--accent2), transparent);
    -webkit-mask: radial-gradient(circle, transparent 58%, #000 66%, #000 70%, transparent 78%);
    mask: radial-gradient(circle, transparent 58%, #000 66%, #000 70%, transparent 78%);
    will-change: transform, opacity;
  }
  .wheel-frame::after {
    inset: -9px;
    border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
    box-shadow: inset 0 0 28px color-mix(in srgb, var(--accent) 18%, transparent);
  }
  .is-stage-spinning .wheel-frame::before { opacity: 0.62; animation: spinDot 1.4s linear infinite; }
  .is-stage-spinning .wheel-frame::after { opacity: 1; animation: wheelScan 0.85s ease-in-out infinite alternate; }
  .is-stage-winner .wheel-frame::before { opacity: 0.9; animation: wheelBloom 1.1s var(--ease-out); }
  @keyframes wheelScan { from { transform: scale(0.98); } to { transform: scale(1.04); } }
  @keyframes wheelBloom {
    0% { transform: scale(0.88); opacity: 0; }
    40% { transform: scale(1.1); opacity: 0.9; }
    100% { transform: scale(1.02); opacity: 0; }
  }

  /* The wheel's drop shadow lives on the frame as a static box-shadow. As a
     CSS filter on the canvas it was recomputed for every frame of a spin. */
  .wheel-frame { border-radius: 50%; box-shadow: 0 30px 60px -10px rgba(0, 0, 0, 0.55); }
  /* The disc spins as a compositor layer (wheel.js sets its transform each
     frame); the rings canvas stays still above it. */
  #wheelCanvas {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    will-change: transform;
  }
  .wheel-rings {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    pointer-events: none;
  }

  /* The pointer hangs off the right edge of the wheel; it is positioned from
     the wheel's own radius so it tracks every responsive size change. */
  .wheel-pointer {
    position: absolute;
    top: 50%;
    right: -6px; /* the frame is exactly the wheel, so its edge is the rim */
    z-index: var(--z-raised);
    width: clamp(34px, 5vw, 52px);
    transform: translateY(-50%);
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
  }
  .wheel-pointer svg { width: 100%; fill: var(--ink); }

  .wheel-hub {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 6;
    display: grid;
    place-items: center;
    width: clamp(74px, 12vw, 104px);
    aspect-ratio: 1;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--bg) 40%, #fff 12%), var(--bg) 70%);
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--bg) 70%, #000), 0 14px 30px rgba(0, 0, 0, 0.55), var(--glow);
    color: var(--ink);
    transition: transform var(--t-base) var(--ease-spring);
  }
  .wheel-hub:hover { transform: translate(-50%, -50%) scale(1.06); }
  .wheel-hub:active { transform: translate(-50%, -50%) scale(0.95); }
  .hub-ring {
    position: absolute;
    inset: 8px;
    border: 2px dashed color-mix(in srgb, var(--accent) 60%, transparent);
    border-radius: 50%;
    animation: spinDot 14s linear infinite;
  }
  .hub-label {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(0.8rem, 1.6vw, 1rem);
    letter-spacing: 0.12em;
  }
  .is-spinning .hub-label { opacity: 0.4; }

  /* ══════════════════════════════════════════════════════════════════════
     HYPERCHARGE STRIP ENGINE
     ══════════════════════════════════════════════════════════════════════ */
  .engine--strip {
    position: relative;
    flex-direction: column;
    align-items: center;
    gap: 0;
    width: 100%;
    --strip-w: min(70vw, 780px);
    --strip-h: clamp(360px, calc(100svh - 300px), 620px);
  }
  .engine--strip::before,
  .engine--strip::after {
    content: "";
    position: absolute;
    top: 50%;
    z-index: 12;
    width: 2px;
    height: var(--strip-h);
    transform: translateY(-50%);
    pointer-events: none;
    background: linear-gradient(180deg, transparent 0%, var(--accent) 28%, var(--accent2) 72%, transparent 100%);
    transition: background 0.6s var(--ease-out);
  }
  .engine--strip::before {
    left: calc(50% - (var(--strip-w) / 2) - 22px);
    box-shadow: 0 0 20px 3px color-mix(in srgb, var(--accent) 65%, transparent);
  }
  .engine--strip::after {
    right: calc(50% - (var(--strip-w) / 2) - 22px);
    box-shadow: 0 0 20px 3px color-mix(in srgb, var(--accent2) 65%, transparent);
  }

  .strip-viewport {
    position: relative;
    z-index: 1;
    width: var(--strip-w);
    height: var(--strip-h);
    border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--stroke-bright));
    border-radius: var(--r-xl);
    overflow: hidden;
    background:
      linear-gradient(90deg, rgba(255, 255, 255, 0.055), transparent 18%, transparent 82%, rgba(255, 255, 255, 0.055)),
      rgba(0, 0, 0, 0.48);
    box-shadow:
      inset 0 0 100px rgba(0, 0, 0, 0.7),
      inset 0 0 0 1px rgba(255, 255, 255, 0.04),
      0 48px 100px -24px rgba(0, 0, 0, 0.72);
    -webkit-mask-image: linear-gradient(180deg, transparent 0%, rgba(0,0,0,.38) 5%, rgba(0,0,0,.82) 13%, #000 22%, #000 78%, rgba(0,0,0,.82) 87%, rgba(0,0,0,.38) 95%, transparent 100%);
    mask-image: linear-gradient(180deg, transparent 0%, rgba(0,0,0,.38) 5%, rgba(0,0,0,.82) 13%, #000 22%, #000 78%, rgba(0,0,0,.82) 87%, rgba(0,0,0,.38) 95%, transparent 100%);
  }
  .strip-viewport::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 6;
    pointer-events: none;
    background:
      linear-gradient(180deg, transparent, rgba(255,255,255,0.08) 46%, rgba(255,255,255,0.12) 50%, rgba(255,255,255,0.08) 54%, transparent),
      radial-gradient(ellipse 85% 16% at 50% 50%, rgba(255, 255, 255, 0.12) 0%, transparent 72%);
  }
  .strip-viewport::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 7;
    opacity: 0;
    pointer-events: none;
    background:
      repeating-linear-gradient(180deg, transparent 0 18px,
        color-mix(in srgb, var(--accent) 22%, transparent) 18px 19px, transparent 19px 42px),
      radial-gradient(ellipse 42% 100% at 50% 50%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 72%);
  }
  .strip-viewport.is-strip-spinning::before { opacity: 1; animation: stripScan 0.34s linear infinite; }
  .strip-viewport.is-strip-locked { animation: stripLock 0.72s var(--ease-spring); }
  @keyframes stripScan { from { transform: translateY(0); } to { transform: translateY(42px); } }
  @keyframes stripLock {
    0% { filter: saturate(1); }
    42% { filter: saturate(1.6) brightness(1.18); }
    100% { filter: saturate(1) brightness(1); }
  }

  .strip-track { display: flex; flex-direction: column; width: 100%; will-change: transform; }

  .strip-cell {
    position: relative;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 100%;
    min-height: clamp(104px, calc(var(--strip-h) * 0.22), 152px);
    padding: 20px clamp(22px, 5vw, 54px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.36);
    overflow: hidden;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.6rem, 4.2vw, 4rem);
    text-align: center;
    color: var(--seg-text);
    background-image: linear-gradient(180deg, rgba(255,255,255,0.14) 0%, transparent 32%, transparent 68%, rgba(0,0,0,0.18) 100%);
    transform: translateZ(0);
    transition: filter var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out);
  }
  .strip-cell::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    z-index: 3;
    height: 1px;
    pointer-events: none;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25) 30%, rgba(255,255,255,0.25) 70%, transparent);
  }
  .strip-cell span {
    position: relative;
    z-index: 2;
    line-height: 0.95;
    overflow-wrap: anywhere;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  }
  .is-strip-spinning .strip-cell span {
    animation: cellFlicker 0.48s ease-in-out infinite alternate;
    animation-delay: calc(var(--cell-i, 0) * -38ms);
  }
  @keyframes cellFlicker {
    from { opacity: 0.72; transform: translateY(1px); }
    to { opacity: 1; transform: translateY(-1px); }
  }
  .strip-cell--winner {
    transform: scale(1.03);
    filter: saturate(1.35) brightness(1.12);
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.5);
  }
  .strip-cell--winner::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 4;
    pointer-events: none;
    background: rgba(255, 255, 255, 0.22);
    animation: cellWinFlash 1s var(--ease-out) forwards;
  }
  @keyframes cellWinFlash {
    0% { opacity: 1; }
    40% { opacity: 0.6; }
    100% { opacity: 0; }
  }

  .strip-marker {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 10;
    width: var(--strip-w);
    height: 3px;
    transform: translate(-50%, -50%);
    pointer-events: none;
    background: var(--accent);
    box-shadow:
      0 0 5px 1px var(--accent),
      0 0 20px 4px color-mix(in srgb, var(--accent) 60%, transparent),
      0 0 60px 10px color-mix(in srgb, var(--accent) 24%, transparent);
    transition: background var(--t-slow), box-shadow var(--t-slow);
  }
  .strip-marker::before,
  .strip-marker::after {
    content: "";
    position: absolute;
    top: 50%;
    border-top: 11px solid transparent;
    border-bottom: 11px solid transparent;
    transform: translateY(-50%);
  }
  .strip-marker::before {
    left: -2px;
    border-left: 15px solid var(--accent);
    filter: drop-shadow(-3px 0 8px color-mix(in srgb, var(--accent) 90%, transparent));
  }
  .strip-marker::after {
    right: -2px;
    border-right: 15px solid var(--accent);
    filter: drop-shadow(3px 0 8px color-mix(in srgb, var(--accent) 90%, transparent));
  }

  .strip-glow {
    width: var(--strip-w);
    height: 44px;
    margin-top: -18px;
    pointer-events: none;
    background: radial-gradient(ellipse 65% 100% at 50% 0%,
      color-mix(in srgb, var(--accent) 40%, transparent),
      color-mix(in srgb, var(--accent2) 18%, transparent) 52%,
      transparent 76%);
    transition: background 0.6s var(--ease-out);
  }

  /* ══════════════════════════════════════════════════════════════════════
     CLAW MACHINE ENGINE — prize cabinet name picker
     ══════════════════════════════════════════════════════════════════════ */
  .engine--claw { align-items: center; }
  .claw-cabinet {
    display: flex; flex-direction: column; align-items: stretch;
    width: min(80vw, 640px);
    gap: 12px;
  }
  .claw-marquee {
    position: relative; overflow: hidden;
    display: flex; justify-content: center; gap: 14px;
    font-family: var(--font-display); font-weight: 700; letter-spacing: 0.34em;
    font-size: clamp(0.9rem, 1.8vw, 1.15rem);
    padding: 13px 0;
    border-radius: var(--r-md);
    border: 1px solid color-mix(in srgb, var(--accent) 34%, var(--stroke));
    background:
      linear-gradient(180deg, color-mix(in srgb, var(--accent) 10%, transparent), transparent 55%),
      linear-gradient(180deg, var(--glass-2), rgba(0,0,0,0.25));
    box-shadow: 0 0 30px -12px color-mix(in srgb, var(--accent) 60%, transparent), inset 0 1px 0 rgba(255,255,255,0.08);
  }
  .claw-marquee span:first-child { color: var(--ink); }
  .claw-marquee span:last-child {
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    -webkit-background-clip: text; background-clip: text; color: transparent;
  }
  /* Arcade chase lights running along the marquee edges */
  .claw-marquee::before,
  .claw-marquee::after {
    content: ""; position: absolute; left: 12px; right: 12px; height: 5px;
    background-image: radial-gradient(circle 2px at 5px 2.5px, var(--accent) 55%, transparent 60%);
    background-size: 24px 5px; background-repeat: repeat-x;
    filter: drop-shadow(0 0 4px var(--accent));
    animation: clawChase 0.9s steps(2, end) infinite;
  }
  .claw-marquee::before { top: 4px; }
  .claw-marquee::after { bottom: 4px; animation-delay: 0.45s; }
  @keyframes clawChase { to { background-position-x: 24px; } }
  .claw-glass {
    position: relative;
    height: clamp(400px, 54vh, 540px);
    border-radius: var(--r-lg);
    border: 1px solid color-mix(in srgb, var(--accent) 22%, rgba(255,255,255,0.1));
    background:
      linear-gradient(90deg, rgba(255,255,255,0.05), transparent 16%, transparent 84%, rgba(255,255,255,0.05)),
      rgba(0, 0, 0, 0.46);
    box-shadow:
      inset 0 0 90px rgba(0, 0, 0, 0.65),
      inset 0 0 0 1px rgba(255,255,255,0.04),
      0 44px 90px -24px rgba(0, 0, 0, 0.72),
      0 0 44px -14px color-mix(in srgb, var(--accent) 45%, transparent);
    overflow: hidden;
  }
  .claw-shine {
    position: absolute; inset: 0; z-index: 8; pointer-events: none;
    background:
      linear-gradient(112deg, transparent 8%, rgba(255,255,255,0.06) 14%, transparent 26%),
      linear-gradient(112deg, transparent 58%, rgba(255,255,255,0.04) 66%, transparent 74%);
  }
  /* Chromed corner pillars frame the glass like a real cabinet */
  .claw-glass::before,
  .claw-glass::after {
    content: ""; position: absolute; top: 0; bottom: 0; width: 13px; z-index: 7; pointer-events: none;
  }
  .claw-glass::before {
    left: 0; border-radius: var(--r-lg) 0 0 var(--r-lg);
    background: linear-gradient(90deg, rgba(255,255,255,0.14), rgba(255,255,255,0.03) 70%, transparent);
    border-right: 1px solid rgba(255,255,255,0.07);
  }
  .claw-glass::after {
    right: 0; border-radius: 0 var(--r-lg) var(--r-lg) 0;
    background: linear-gradient(-90deg, rgba(255,255,255,0.14), rgba(255,255,255,0.03) 70%, transparent);
    border-left: 1px solid rgba(255,255,255,0.07);
  }
  .claw-rail {
    position: absolute; top: 12px; left: 14px; right: 14px; height: 5px; z-index: 3;
    border-radius: 999px;
    background: linear-gradient(90deg,
      color-mix(in srgb, var(--accent) 60%, transparent),
      color-mix(in srgb, var(--accent2) 60%, transparent));
    box-shadow: 0 0 14px -2px color-mix(in srgb, var(--accent) 60%, transparent);
  }
  /* The rig sits BEHIND the capsule pile (pit z 4) so the claw visibly reaches
     into the balls rather than hovering in front of them. */
  .claw-rig { position: absolute; top: 14px; left: 0; z-index: 2; will-change: transform; }
  .claw-trolley {
    position: absolute; left: -17px; top: -6px; width: 34px; height: 15px;
    border-radius: 6px;
    background: linear-gradient(180deg, #dfe6f2, #8a93a8 60%, #565e72);
    box-shadow: 0 3px 8px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.7);
  }
  .claw-cable {
    position: absolute; left: -1.5px; top: 8px; width: 3px; height: 0;
    background: linear-gradient(180deg, #9aa3b8, #6a7288);
    box-shadow: 0 0 4px rgba(0,0,0,0.5);
  }
  .claw-head { position: absolute; left: -27px; top: 8px; width: 54px; will-change: transform; }
  .claw-svg { display: block; width: 54px; height: 43px; overflow: visible; }
  .claw-hub {
    fill: #cfd6e4;
    stroke: #565e72; stroke-width: 2;
  }
  .claw-arm path {
    stroke: color-mix(in srgb, var(--accent) 35%, #cfd6e4);
    stroke-width: 6;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.5));
  }
  .claw-arm {
    transform-origin: 40px 14px;
    transition: transform 0.22s var(--ease-out);
  }
  .claw-head.is-open .claw-arm--l { transform: rotate(-26deg); }
  .claw-head.is-open .claw-arm--r { transform: rotate(26deg); }
  .claw-head.is-open .claw-arm--m { transform: rotate(6deg); }
  .claw-ball--held {
    position: absolute; left: 50%; top: 26px;
    transform: translateX(-50%);
    z-index: -1;
  }
  .claw-pit { position: absolute; left: 13px; right: 100px; bottom: 8px; height: 50%; z-index: 4; pointer-events: none; }
  /* Gacha-style capsules: colored dome on a pearl base, glossy specular */
  .claw-ball {
    position: absolute; border-radius: 50%;
    background:
      radial-gradient(circle at 30% 22%, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0.3) 13%, transparent 32%),
      linear-gradient(180deg,
        color-mix(in srgb, var(--ball) 78%, #ffffff) 0%,
        var(--ball) 44%,
        color-mix(in srgb, var(--ball) 80%, #000000) 48.5%,
        #f2f4fa 51.5%,
        #c6cddc 76%,
        #96a0b6 100%);
    box-shadow:
      inset 0 -5px 10px rgba(0,0,0,0.28),
      inset 0 2px 5px rgba(255,255,255,0.3),
      0 7px 14px -5px rgba(0,0,0,0.65);
  }
  .claw-ball::after {
    /* capsule seam */
    content: ""; position: absolute; left: 5%; right: 5%; top: 47.5%; height: 4.5%;
    border-radius: 999px; background: rgba(0,0,0,0.3);
  }
  /* Prize chute — lit sign, drop hole, chasing arrows. The pulled capsule falls
     behind this face (chute z 5 > rig z 2), so it reads as swallowed. */
  .claw-chute {
    position: absolute; right: 12px; bottom: 8px; width: 82px; height: 62%; z-index: 5;
    border-radius: 16px;
    border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--stroke));
    background:
      linear-gradient(180deg, color-mix(in srgb, var(--accent) 16%, rgba(8,9,15,0.92)), rgba(0,0,0,0.86) 45%),
      rgba(0,0,0,0.85);
    box-shadow:
      inset 0 0 26px rgba(0,0,0,0.85),
      inset 0 1px 0 rgba(255,255,255,0.1),
      0 0 30px -10px color-mix(in srgb, var(--accent) 60%, transparent);
  }
  .claw-chute__sign {
    position: absolute; left: 50%; top: 9px; transform: translateX(-50%);
    padding: 4px 9px; border-radius: 8px; white-space: nowrap;
    font-family: var(--font-display); font-weight: 700; font-size: 0.6rem; letter-spacing: 0.22em;
    color: var(--seg-text);
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    box-shadow: 0 0 16px -2px var(--accent), inset 0 1px 0 rgba(255,255,255,0.5);
    animation: clawSignPulse 1.8s ease-in-out infinite;
  }
  @keyframes clawSignPulse {
    0%, 100% { box-shadow: 0 0 16px -2px var(--accent), inset 0 1px 0 rgba(255,255,255,0.5); }
    50% { box-shadow: 0 0 26px 1px var(--accent), inset 0 1px 0 rgba(255,255,255,0.5); }
  }
  .claw-chute__hole {
    position: absolute; left: 50%; top: 40px; transform: translateX(-50%);
    width: 58px; height: 26px; border-radius: 50%;
    background: radial-gradient(ellipse at 50% 42%, #000 52%, rgba(0,0,0,0.55) 66%, transparent 72%);
    box-shadow:
      inset 0 6px 10px rgba(0,0,0,0.95),
      0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent),
      0 0 16px -4px var(--accent);
  }
  .claw-chute__arrows {
    position: absolute; left: 50%; top: 84px; transform: translateX(-50%);
    display: flex; flex-direction: column; gap: 8px;
  }
  .claw-chute__arrows i {
    width: 15px; height: 15px;
    border-right: 3px solid var(--accent);
    border-bottom: 3px solid var(--accent);
    border-radius: 2px;
    transform: rotate(45deg);
    opacity: 0.2;
    filter: drop-shadow(0 0 5px var(--accent));
    animation: clawArrow 1.1s ease-in-out infinite;
  }
  .claw-chute__arrows i:nth-child(2) { animation-delay: 0.18s; }
  .claw-chute__arrows i:nth-child(3) { animation-delay: 0.36s; }
  @keyframes clawArrow { 0%, 70%, 100% { opacity: 0.18; } 35% { opacity: 1; } }
  .claw-chute__star {
    position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
    font-size: 1.05rem; color: var(--accent2);
    text-shadow: 0 0 12px var(--accent2);
    animation: clawStarTwinkle 2.4s ease-in-out infinite;
  }
  @keyframes clawStarTwinkle {
    0%, 100% { opacity: 0.5; transform: translateX(-50%) scale(1) rotate(0deg); }
    50% { opacity: 1; transform: translateX(-50%) scale(1.25) rotate(22deg); }
  }
  /* Base deck: glowing trim + coin slot under the glass */
  .claw-deck {
    display: flex; align-items: center; gap: 16px;
    padding: 11px 18px;
    border-radius: var(--r-md);
    border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--stroke));
    background: linear-gradient(180deg, var(--glass-2), rgba(0,0,0,0.4));
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.07), 0 14px 30px -18px rgba(0,0,0,0.8);
  }
  .claw-deck__light {
    flex: 1; height: 3px; border-radius: 999px;
    background: linear-gradient(90deg, transparent, var(--accent), var(--accent2), transparent);
    box-shadow: 0 0 12px -2px var(--accent);
    opacity: 0.85;
  }
  .claw-deck__slot {
    position: relative; width: 40px; height: 13px; border-radius: 4px;
    background: linear-gradient(180deg, #262b38, #0c0e15);
    border: 1px solid var(--stroke-bright);
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.9);
  }
  .claw-deck__slot::after {
    content: ""; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: 22px; height: 3px; border-radius: 2px; background: #000;
    box-shadow: 0 0 5px color-mix(in srgb, var(--accent) 60%, transparent);
  }
  /* Reveal capsule — lands centre-stage, shakes, cracks open */
  .claw-prize {
    position: absolute; left: 50%; top: 42%; z-index: 9;
    width: clamp(130px, 30%, 170px); aspect-ratio: 1;
    transform: translate(-50%, -50%) scale(0.4);
    opacity: 0;
    filter: drop-shadow(0 18px 40px rgba(0,0,0,0.6));
  }
  .claw-prize.is-landed {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    transition: transform 0.4s var(--ease-spring), opacity 0.25s var(--ease-out);
    /* Escalating shake — starts as a wobble, ends violent, peaks at the pop */
    animation: clawShakeBuild var(--shake-ms, 750ms) ease-in 0.35s forwards;
  }
  @keyframes clawShakeBuild {
    0%   { transform: translate(-50%, -50%) rotate(0deg) scale(1); }
    14%  { transform: translate(-50.6%, -50%) rotate(-2deg) scale(1); }
    28%  { transform: translate(-49.4%, -50.2%) rotate(2deg) scale(1.01); }
    42%  { transform: translate(-51%, -49.6%) rotate(-4deg) scale(1.02); }
    56%  { transform: translate(-49%, -50.6%) rotate(5deg) scale(1.03); }
    68%  { transform: translate(-51.6%, -49.2%) rotate(-7deg) scale(1.05); }
    78%  { transform: translate(-48.4%, -50.8%) rotate(8deg) scale(1.07); }
    86%  { transform: translate(-52%, -49%) rotate(-10deg) scale(1.09); }
    93%  { transform: translate(-48%, -51%) rotate(10deg) scale(1.11); }
    100% { transform: translate(-50%, -50%) rotate(0deg) scale(1.13); }
  }
  /* Light burst behind the capsule the moment it cracks */
  .claw-prize::before {
    content: ""; position: absolute; inset: -35%; border-radius: 50%; z-index: -1;
    background: radial-gradient(circle, color-mix(in srgb, var(--accent) 55%, transparent) 0%, color-mix(in srgb, var(--accent2) 30%, transparent) 35%, transparent 68%);
    opacity: 0; transform: scale(0.4);
  }
  .claw-prize.is-cracked::before { animation: clawBurst 0.8s var(--ease-out) forwards; }
  @keyframes clawBurst {
    0% { opacity: 0; transform: scale(0.4); }
    30% { opacity: 1; }
    100% { opacity: 0; transform: scale(1.7); }
  }
  .claw-prize__half {
    position: absolute; left: 0; width: 100%; height: 50%;
  }
  .claw-prize__half--top {
    top: 0; border-radius: 999px 999px 0 0;
    background:
      radial-gradient(circle at 32% 40%, rgba(255,255,255,0.85) 0%, rgba(255,255,255,0.2) 22%, transparent 46%),
      linear-gradient(180deg, color-mix(in srgb, var(--ball) 75%, #fff), var(--ball));
    box-shadow: inset 0 -3px 0 rgba(0,0,0,0.25);
  }
  .claw-prize__half--bottom {
    bottom: 0; border-radius: 0 0 999px 999px;
    background: linear-gradient(180deg, #e9edf5, #b9c1d2 70%, #8a93a8);
    box-shadow: inset 0 3px 0 rgba(255,255,255,0.5);
  }
  /* The pop: both halves blast apart and vanish */
  .claw-prize.is-cracked .claw-prize__half--top {
    animation: clawPopTop 0.65s var(--ease-out) forwards;
  }
  .claw-prize.is-cracked .claw-prize__half--bottom {
    animation: clawPopBottom 0.65s var(--ease-out) forwards;
  }
  @keyframes clawPopTop {
    0% { transform: none; opacity: 1; }
    100% { transform: translate(-85px, -150px) rotate(-75deg) scale(0.9); opacity: 0; }
  }
  @keyframes clawPopBottom {
    0% { transform: none; opacity: 1; }
    100% { transform: translate(75px, 140px) rotate(60deg) scale(0.9); opacity: 0; }
  }
  /* Spark shrapnel flying out of the burst */
  .claw-prize__sparks { position: absolute; inset: 0; pointer-events: none; }
  .claw-prize__sparks i {
    position: absolute; left: 50%; top: 50%;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 12px var(--accent);
    opacity: 0;
  }
  .claw-prize__sparks i:nth-child(2n) { background: var(--accent2); box-shadow: 0 0 12px var(--accent2); }
  .claw-prize__sparks i:nth-child(3n) { background: #fff; box-shadow: 0 0 12px #fff; width: 5px; height: 5px; }
  .claw-prize__sparks i:nth-child(1) { --sx: -110px; --sy: -70px; }
  .claw-prize__sparks i:nth-child(2) { --sx: 115px; --sy: -55px; }
  .claw-prize__sparks i:nth-child(3) { --sx: -95px; --sy: 65px; }
  .claw-prize__sparks i:nth-child(4) { --sx: 100px; --sy: 80px; }
  .claw-prize__sparks i:nth-child(5) { --sx: -35px; --sy: -125px; }
  .claw-prize__sparks i:nth-child(6) { --sx: 45px; --sy: -115px; }
  .claw-prize__sparks i:nth-child(7) { --sx: -55px; --sy: 115px; }
  .claw-prize__sparks i:nth-child(8) { --sx: 60px; --sy: 105px; }
  .claw-prize.is-cracked .claw-prize__sparks i {
    animation: clawSpark 0.7s ease-out forwards;
  }
  .claw-prize.is-cracked .claw-prize__sparks i:nth-child(2n) { animation-duration: 0.85s; }
  @keyframes clawSpark {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(calc(-50% + var(--sx)), calc(-50% + var(--sy))) scale(0.3); }
  }
  /* The winning name springs out of the explosion */
  .claw-prize__name {
    position: absolute; inset: 8%;
    display: flex; align-items: center; justify-content: center; text-align: center;
    font-family: var(--font-display); font-weight: 700;
    font-size: clamp(1.15rem, 2.8vw, 1.65rem); line-height: 1.15;
    color: var(--ink); overflow-wrap: anywhere;
    opacity: 0; transform: scale(0);
    text-shadow: 0 0 20px color-mix(in srgb, var(--accent) 80%, transparent), 0 2px 12px rgba(0,0,0,0.85);
  }
  .claw-prize__name[data-len="m"] { font-size: clamp(1rem, 2.3vw, 1.35rem); }
  .claw-prize__name[data-len="l"] { font-size: clamp(0.85rem, 1.9vw, 1.1rem); }
  .claw-prize__name[data-len="xl"] { font-size: clamp(0.72rem, 1.5vw, 0.92rem); }
  .claw-prize.is-cracked .claw-prize__name {
    animation: clawNamePop 0.55s 0.12s var(--ease-spring) forwards;
  }
  @keyframes clawNamePop {
    0% { opacity: 0; transform: scale(0) rotate(-6deg); }
    65% { opacity: 1; transform: scale(1.22) rotate(2deg); }
    100% { opacity: 1; transform: scale(1) rotate(0deg); }
  }
  /* Status is a sentence ("Winner: Ana"), so it reads in the body face —
     mono stays reserved for numbers. Names wrap rather than overflow. */
  .claw-status {
    max-width: 100%;
    text-align: center;
    font-size: var(--t-sm);
    font-weight: 500;
    color: var(--ink-dim);
    overflow-wrap: anywhere;
  }
  /* Fit the cabinet plus controls on one desktop screen (mirrors the strip pass) */
  @media (min-width: 1100px) {
    [data-engine="claw"] .stage { justify-content: flex-start; gap: clamp(10px, 1.4vh, 16px); }
    [data-engine="claw"] .claw-glass { height: clamp(360px, calc(100svh - 360px), 540px); }
  }
}
/* ============================================================================
   MODES · COIN, DICE, ORACLE
   Each of these is a single showpiece object plus a readout plus one action.
   They share `.page-head`, `.surface`, `.action`, `.stat` and `.readout`; only
   the showpiece itself is bespoke.
   ========================================================================== */
@layer modes {

  /* ══════════════════════════════════════════════════════════════════════
     COIN FLIP
     ══════════════════════════════════════════════════════════════════════ */
  .coin-section { --mode-max: 640px; }

  .coin-tally {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--s-4);
    width: 100%;
    max-width: 440px;
  }
  .coin-tally .stat { align-items: center; }
  .coin-ratio-bar {
    height: 8px;
    border-radius: var(--r-full);
    background: color-mix(in srgb, var(--accent2) 55%, var(--well-deep));
    overflow: hidden;
  }
  .coin-ratio-fill {
    width: 50%;
    height: 100%;
    border-radius: var(--r-full);
    background: var(--accent);
    transition: width 0.6s var(--ease-out);
  }
  /* Tails is the accent2 side of the bar, so its stat matches. */
  .coin-tally .stat--tails .stat__val { color: var(--accent2); }

  /* The coin and its verdict own the free space between tally and dock. */
  .coin-stage-wrap {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--s-3);
    width: 100%;
    min-height: 0;
  }
  .coin-float {
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 1000px;
  }
  .coin-float--flipping { animation: coinArc 1.85s cubic-bezier(0.17, 0.67, 0.12, 1) forwards; }
  @keyframes coinArc {
    0% { transform: translateY(0) scale(1); }
    28% { transform: translateY(-64px) scale(1.08); }
    55% { transform: translateY(-18px) scale(1.02); }
    75% { transform: translateY(-6px); }
    100% { transform: translateY(0) scale(1); }
  }

  .coin {
    position: relative;
    width: clamp(190px, min(58vw, 34svh), 280px);
    aspect-ratio: 1;
    border-radius: 50%;
    transform-style: preserve-3d;
    transform: rotateY(0deg);
    cursor: pointer;
  }
  /* Struck metal: a lit dome, a recessed field inside a raised rim, and a
     reeded edge — tinted by the theme so every palette gets its own coin. */
  .coin__face {
    --metal: var(--accent);
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    border-radius: 50%;
    color: color-mix(in srgb, var(--metal) 30%, #000);
    background:
      radial-gradient(circle at 34% 26%, rgba(255, 255, 255, 0.55), transparent 34%),
      radial-gradient(circle, transparent 66%, rgba(0, 0, 0, 0.22) 67%, transparent 69%),
      conic-gradient(from 210deg,
        color-mix(in srgb, var(--metal) 70%, #fff), color-mix(in srgb, var(--metal) 72%, #000),
        color-mix(in srgb, var(--metal) 82%, #fff), color-mix(in srgb, var(--metal) 66%, #000),
        color-mix(in srgb, var(--metal) 70%, #fff));
    box-shadow:
      inset 0 0 0 5px color-mix(in srgb, var(--metal) 60%, #000),
      inset 0 0 0 7px rgba(255, 255, 255, 0.28),
      inset 0 -10px 24px rgba(0, 0, 0, 0.28),
      0 30px 60px -24px rgba(0, 0, 0, 0.85),
      0 0 70px -18px color-mix(in srgb, var(--metal) 70%, transparent);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
  }
  .coin__face::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: repeating-conic-gradient(rgba(0, 0, 0, 0.16) 0 1.2deg, transparent 1.2deg 3deg);
    -webkit-mask: radial-gradient(circle, transparent 93%, #000 94%);
    mask: radial-gradient(circle, transparent 93%, #000 94%);
  }
  .coin__face--tails { --metal: var(--accent2); transform: rotateY(180deg); }
  .coin__symbol {
    width: 30%;
    height: auto;
    filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.35));
    pointer-events: none;
  }
  .coin__label {
    max-width: 78%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    border-bottom: 1px dashed transparent;
    outline: none;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(1.1rem, 5vw, 1.6rem);
    letter-spacing: -0.01em;
    text-align: center;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
    transition: border-color var(--t-fast);
  }
  .coin__label[contenteditable]:hover,
  .coin__label:focus { border-color: currentColor; }

  .coin-shadow-el {
    width: clamp(130px, 40vw, 200px);
    height: 18px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    filter: blur(12px);
    transition: opacity var(--t-base);
  }

  .coin-result-area {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 3.2rem;
  }
  .coin-result-text {
    max-width: 100%;
    overflow-wrap: anywhere;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: var(--d-lg);
    letter-spacing: -0.02em;
    opacity: 0;
    transform: translateY(10px) scale(0.92);
    transition: opacity var(--t-slow) var(--ease-out), transform var(--t-slow) var(--ease-spring);
  }
  .coin-result-text--show { opacity: 1; transform: none; }
  .coin-result-text--heads { color: var(--accent); }
  .coin-result-text--tails { color: var(--accent2); }

  .coin-history-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    min-height: 14px;
  }
  .coin-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    animation: dotPop 0.35s var(--ease-spring);
  }
  @keyframes dotPop {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
  }
  .coin-dot--heads { background: var(--accent); }
  .coin-dot--tails { background: var(--accent2); }

  @media (max-width: 720px) {
    /* The labels are editable on desktop only — on touch, tapping the coin
       must flip it, never drop a caret into a contenteditable span. */
    .coin__label { pointer-events: none; -webkit-user-select: none; user-select: none; }
  }

  /* ══════════════════════════════════════════════════════════════════════
     DICE
     ══════════════════════════════════════════════════════════════════════ */
  .dice-section { --mode-max: 940px; }

  .dice-config {
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    width: 100%;
    max-width: 760px;
  }
  .dice-config-row {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    align-items: center;
    gap: var(--s-3);
  }
  /* Tray and total own the space between the pickers and the dock. */
  .dice-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--s-4);
    width: 100%;
    min-height: 0;
  }
  .dice-type-pills,
  .dice-count-btns { display: flex; flex-wrap: wrap; gap: var(--s-2); }

  /* Type pills are `.chip`s with a second line, so they keep the shared
     hover / active / focus behaviour for free. */
  .dice-type-pill {
    flex-direction: column;
    gap: 3px;
    min-width: 72px;
    min-height: 54px;
    padding: 8px 14px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: var(--t-md);
    line-height: 1.05;
  }
  .dice-type-pill small {
    font-family: var(--font-mono);
    font-size: 0.55rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-faint);
  }
  .dice-type-pill.is-active small { color: color-mix(in srgb, var(--accent) 82%, #fff 18%); }

  .dice-count-btn {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border: 1px solid var(--stroke);
    border-radius: var(--r-sm);
    background: var(--glass);
    color: var(--ink-dim);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: var(--t-lg);
    transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast), transform var(--t-fast) var(--ease-out);
  }
  .dice-count-btn:hover { border-color: var(--stroke-bright); color: var(--ink); transform: var(--hover-lift); }
  .dice-count-btn.is-active {
    border-color: var(--accent2);
    background: color-mix(in srgb, var(--accent2) 18%, transparent);
    color: var(--accent2);
  }

  .dice-tray {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--s-5);
    width: min(100%, 760px);
    min-height: clamp(140px, 22vh, 240px);
    padding: clamp(16px, 3vw, 32px);
    /* A felt-lined well, not another bordered card. */
    border-radius: var(--r-2xl);
    background:
      radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%),
      radial-gradient(ellipse at 50% 120%, color-mix(in srgb, var(--accent2) 16%, transparent), transparent 60%),
      var(--well);
    box-shadow: inset 0 12px 40px rgba(0, 0, 0, 0.35), inset 0 0 0 1px var(--stroke);
    perspective: 900px;
  }
  .dice-tray::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 16px;
    width: min(78%, 520px);
    height: 24px;
    transform: translateX(-50%);
    border-radius: 50%;
    background: radial-gradient(ellipse, rgba(0, 0, 0, 0.5), transparent 72%);
    filter: blur(12px);
    pointer-events: none;
  }

  .die {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: clamp(84px, 13vw, 118px);
    aspect-ratio: 1;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--r-md);
    transform: translateY(var(--lift, 0)) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) rotateZ(var(--rz, 0deg));
    transform-style: preserve-3d;
    background:
      radial-gradient(circle at 30% 20%, rgba(255,255,255,0.26), transparent 42%),
      linear-gradient(145deg, color-mix(in srgb, var(--accent) 54%, #0a0a16), color-mix(in srgb, var(--accent2) 44%, #05050d));
    box-shadow:
      inset 0 -8px 24px rgba(0,0,0,0.38),
      inset 0 1px 0 rgba(255,255,255,0.22),
      0 20px 38px -18px rgba(0,0,0,0.92),
      0 0 24px -14px color-mix(in srgb, var(--accent) 72%, transparent);
  }
  .die::before {
    content: "";
    position: absolute;
    inset: 8px;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.13), transparent 48%);
    pointer-events: none;
  }
  .die--rolling { animation: diceTumble 0.42s cubic-bezier(0.2, 0.8, 0.2, 1) infinite; }
  @keyframes diceTumble {
    0% { transform: translateY(6px) rotateX(0deg) rotateY(0deg) rotateZ(0deg) scale(0.95); }
    45% { transform: translateY(var(--lift, -14px)) rotateX(var(--rx, 28deg)) rotateY(var(--ry, -28deg)) rotateZ(var(--rz, 16deg)) scale(1.08); }
    100% { transform: translateY(4px) rotateX(calc(var(--rx, 28deg) * -0.5)) rotateY(calc(var(--ry, -28deg) * -0.4)) rotateZ(calc(var(--rz, 16deg) * -0.6)) scale(0.98); }
  }
  .die--settling { animation: diceLand 0.5s var(--ease-spring); }
  @keyframes diceLand {
    0% { transform: translateY(-22px) rotateX(34deg) rotateY(-28deg) rotateZ(var(--rz, 0deg)) scale(1.12); filter: brightness(1.24); }
    58% { transform: translateY(4px) rotateX(-8deg) rotateY(6deg) rotateZ(var(--rz, 0deg)) scale(0.94); }
    100% { transform: translateY(0) rotateX(0deg) rotateY(0deg) rotateZ(var(--rz, 0deg)) scale(1); filter: brightness(1); }
  }

  .die__body {
    position: relative;
    z-index: 2;
    display: grid;
    place-items: center;
    min-width: 58%;
    min-height: 58%;
  }
  .die__val {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(1.9rem, 4.4vw, 3rem);
    line-height: 1;
    color: var(--ink);
    text-shadow: 0 3px 16px rgba(0, 0, 0, 0.48);
  }
  .die--idle .die__val { color: color-mix(in srgb, var(--ink) 45%, transparent); text-shadow: none; }
  .die__label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.34);
  }

  /* D6 renders classic pips; the numeric value stays in the DOM for screen
     readers but is visually replaced by the pip grid. */
  .die__pips {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 5px;
    width: 58px;
    aspect-ratio: 1;
  }
  .die__pips + .die__val { position: absolute; opacity: 0; }
  .die__pips i {
    align-self: center;
    justify-self: center;
    width: 10px;
    aspect-ratio: 1;
    border-radius: 50%;
    background: var(--ink);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
  }
  .die__pips--1 i:nth-child(1) { grid-area: 2 / 2; }
  .die__pips--2 i:nth-child(1) { grid-area: 1 / 1; }
  .die__pips--2 i:nth-child(2) { grid-area: 3 / 3; }
  .die__pips--3 i:nth-child(1) { grid-area: 1 / 1; }
  .die__pips--3 i:nth-child(2) { grid-area: 2 / 2; }
  .die__pips--3 i:nth-child(3) { grid-area: 3 / 3; }
  .die__pips--4 i:nth-child(1) { grid-area: 1 / 1; }
  .die__pips--4 i:nth-child(2) { grid-area: 1 / 3; }
  .die__pips--4 i:nth-child(3) { grid-area: 3 / 1; }
  .die__pips--4 i:nth-child(4) { grid-area: 3 / 3; }
  .die__pips--5 i:nth-child(1) { grid-area: 1 / 1; }
  .die__pips--5 i:nth-child(2) { grid-area: 1 / 3; }
  .die__pips--5 i:nth-child(3) { grid-area: 2 / 2; }
  .die__pips--5 i:nth-child(4) { grid-area: 3 / 1; }
  .die__pips--5 i:nth-child(5) { grid-area: 3 / 3; }
  .die__pips--6 i:nth-child(1) { grid-area: 1 / 1; }
  .die__pips--6 i:nth-child(2) { grid-area: 1 / 3; }
  .die__pips--6 i:nth-child(3) { grid-area: 2 / 1; }
  .die__pips--6 i:nth-child(4) { grid-area: 2 / 3; }
  .die__pips--6 i:nth-child(5) { grid-area: 3 / 1; }
  .die__pips--6 i:nth-child(6) { grid-area: 3 / 3; }

  .dice-total {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: var(--d-lg);
    line-height: 1;
    letter-spacing: -0.02em;
    font-variant-numeric: var(--num);
    color: var(--ink);
    transition: color var(--t-base);
  }
  .dice-total--max {
    color: var(--gold);
    text-shadow: 0 0 24px color-mix(in srgb, var(--gold) 55%, transparent);
    animation: maxGlow 0.6s var(--ease-spring);
  }
  @keyframes maxGlow {
    from { transform: scale(0.8); opacity: 0.5; }
    to { transform: scale(1); opacity: 1; }
  }
  .dice-total--rolling {
    color: color-mix(in srgb, var(--accent) 84%, #fff 16%);
    animation: diceResultPulse 0.7s ease-in-out infinite alternate;
  }
  @keyframes diceResultPulse {
    from { opacity: 0.64; transform: translateY(2px); }
    to { opacity: 1; transform: translateY(0); }
  }
  .dice-readout { min-height: 0; padding: 0; background: none; border: 0; box-shadow: none; }
  .dice-breakdown {
    max-width: 40ch;
    font-family: var(--font-mono);
    font-size: var(--t-xs);
    line-height: 1.4;
    letter-spacing: 0.06em;
    color: var(--ink-faint);
    text-align: center;
  }

  @media (max-width: 720px) {
    .dice-config-row { grid-template-columns: 1fr; gap: 6px; }
    .dice-config { gap: var(--s-3); }
    /* Both control rows are exactly six options, so a six-column grid keeps
       each on a single line — wrapping them was what pushed Roll below the
       fold on a 360px phone. */
    .dice-type-pills,
    .dice-count-btns {
      display: grid;
      grid-template-columns: repeat(6, minmax(0, 1fr));
      gap: 6px;
    }
    .dice-type-pill {
      min-width: 0;
      min-height: var(--tap);
      padding: 6px 2px;
      font-size: var(--t-sm);
    }
    .dice-type-pill small { display: none; }
    .dice-count-btn { width: auto; height: var(--tap); }
    .dice-tray { min-height: 128px; padding: var(--s-3); gap: var(--s-3); }
    .die { width: clamp(64px, 24vw, 96px); }
    .die__pips { width: 38px; gap: 4px; }
    .die__pips i { width: 7px; }
  }

  /* Short laptops (1366×768, 1280×720): Roll must stay above the fold, so the
     kicker goes and the tray sizes to its dice rather than to the viewport. */
  @media (min-width: 901px) and (max-height: 800px) {
    .dice-section .mode-stack { gap: var(--s-3); }
    .dice-section .page-head__kicker { display: none; }
    .dice-config { gap: var(--s-2); }
    .dice-tray { min-height: 0; padding: var(--s-3) var(--s-4); }
  }

  /* ══════════════════════════════════════════════════════════════════════
     ORACLE (Magic 8)
     One implementation, not three. Division of labour:
       · the sphere shows a one-word SIGNAL (YES / NO / WAIT)
       · the card below carries the full answer at display size
     That split is what makes it readable; nothing here needs !important.
     ══════════════════════════════════════════════════════════════════════ */
  .ball8-section { --mode-max: 1180px; }
  .oracle-shell { display: flex; flex-direction: column; gap: clamp(18px, 3vh, 30px); }
  .oracle-head {
    align-items: flex-end;
    padding-bottom: var(--s-5);
    border-bottom: 1px solid var(--stroke);
  }
  .oracle-head .page-head__title { font-size: clamp(2.4rem, 6vw, 5.4rem); }
  .oracle-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--stroke);
    border-radius: var(--r-full);
    background: var(--glass);
    font-family: var(--font-mono);
    font-size: var(--t-2xs);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-dim);
  }
  .oracle-console {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
    min-height: 560px;
    border: 1px solid var(--stroke);
    border-radius: var(--r-2xl);
    overflow: hidden;
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 6%, transparent), var(--glass));
    box-shadow: var(--e-3), var(--inset-top);
  }

  .ball8-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 520px;
    overflow: hidden;
    border-right: 1px solid var(--stroke);
    background:
      radial-gradient(circle at 50% 48%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 34%),
      linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
    background-size: auto, 42px 42px, 42px 42px;
  }
  .oracle-orbit {
    position: absolute;
    aspect-ratio: 1;
    border-radius: 50%;
    border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
    pointer-events: none;
  }
  .oracle-orbit::before,
  .oracle-orbit::after {
    content: "";
    position: absolute;
    width: 7px;
    aspect-ratio: 1;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 14px var(--accent);
  }
  .oracle-orbit::before { top: -4px; left: 50%; }
  .oracle-orbit::after { bottom: 14%; right: 6%; }
  .oracle-orbit--outer { width: min(78%, 460px); animation: spinDot 26s linear infinite; }
  .oracle-orbit--inner { width: min(61%, 360px); border-style: dashed; animation: spinDot 18s linear infinite reverse; opacity: 0.66; }

  .oracle-reading {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(28px, 4vw, 54px);
    background: linear-gradient(180deg, color-mix(in srgb, var(--surface-1) 62%, transparent), color-mix(in srgb, var(--surface-0) 72%, transparent));
  }
  .oracle-step {
    margin-bottom: var(--s-4);
    font-family: var(--font-mono);
    font-size: var(--t-2xs);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--accent);
  }
  .ball8-input {
    min-height: 112px;
    padding: 18px;
    border-radius: var(--r-md);
    font-family: var(--font-display);
    font-size: clamp(1.2rem, 2.1vw, 1.55rem);
    line-height: 1.35;
    resize: none;
  }
  .oracle-ask { width: 100%; margin-top: var(--s-3); }
  .oracle-divider {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    margin: var(--s-6) 0 var(--s-4);
    font-family: var(--font-mono);
    font-size: 0.58rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-faint);
  }
  .oracle-divider::before, .oracle-divider::after { content: ""; flex: 1; height: 1px; background: var(--stroke); }

  .oracle-memory {
    padding: var(--s-4) var(--s-5);
    border: 1px solid var(--stroke);
    border-radius: var(--r-lg);
    background: var(--glass);
  }
  .oracle-memory__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-4);
    font-family: var(--font-mono);
    font-size: var(--t-xs);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-dim);
  }

  .ball8-orb {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: clamp(240px, 28vw, 320px);
    aspect-ratio: 1;
    border-radius: 50%;
    cursor: pointer;
    user-select: none;
    background:
      radial-gradient(circle at 36% 30%, rgba(120,60,220,0.3) 0%, transparent 45%),
      radial-gradient(circle at 32% 26%, rgba(255,255,255,0.12) 0%, transparent 16%),
      radial-gradient(ellipse at 60% 75%, rgba(0,180,255,0.08), transparent 55%),
      radial-gradient(ellipse at 50% 50%, #1a0842 0%, #06060e 70%);
    box-shadow:
      0 30px 80px -15px rgba(0, 0, 0, 0.95),
      0 0 0 1px rgba(255, 255, 255, 0.07),
      inset 0 -8px 30px rgba(0, 0, 0, 0.6),
      0 0 60px -15px color-mix(in srgb, var(--orb-tint, var(--accent)) 55%, transparent);
    transition: box-shadow var(--t-slow) var(--ease-out), transform var(--t-base) var(--ease-spring);
  }
  .ball8-orb:hover { transform: scale(1.03); }
  .ball8-orb:active { transform: scale(0.97); }
  .ball8-orb.is-shaking { animation: orbShake 0.6s var(--ease-out); }
  @keyframes orbShake {
    0%, 100% { transform: none; }
    15% { transform: translate(10px, -8px) rotate(-5deg); }
    30% { transform: translate(-8px, 6px) rotate(4deg); }
    45% { transform: translate(7px, -5px) rotate(-3deg); }
    60% { transform: translate(-5px, 4px) rotate(2deg); }
    75% { transform: translate(3px, -2px) rotate(-1deg); }
  }
  /* One tint variable drives the orb glow, the triangle and the card, so the
     three never disagree about what the answer's mood is. */
  .ball8-orb.ball8--positive { --orb-tint: var(--ok); }
  .ball8-orb.ball8--negative { --orb-tint: var(--bad); }
  .ball8-orb.ball8--neutral  { --orb-tint: var(--warn); }

  .ball8-eight {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(5rem, 14vw, 8rem);
    line-height: 1;
    color: rgba(255, 255, 255, 0.04);
    pointer-events: none;
    user-select: none;
  }

  .ball8-window {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 58%;
    aspect-ratio: 1;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    background:
      radial-gradient(circle at 50% 48%, rgba(0,0,0,0.18), transparent 42%),
      radial-gradient(ellipse at 50% 62%, rgba(10, 6, 34, 0.98), #020207 78%);
    box-shadow:
      inset 0 5px 22px rgba(0, 0, 0, 0.9),
      0 0 0 3px rgba(0, 0, 0, 0.62),
      0 0 0 1px color-mix(in srgb, var(--orb-tint, var(--accent)) 44%, transparent),
      0 0 32px -12px color-mix(in srgb, var(--orb-tint, var(--accent)) 70%, transparent);
  }

  .ball8-tri {
    display: grid;
    place-items: center;
    width: 82%;
    aspect-ratio: 1;
    border: 1px solid rgba(255, 255, 255, 0.16);
    clip-path: polygon(50% 4%, 98% 91%, 2% 91%);
    background: rgba(5, 10, 24, 0.92);
    filter: drop-shadow(0 0 18px rgba(0, 0, 0, 0.8));
    transition: background var(--t-slow) var(--ease-out);
  }
  .ball8-tri.ball8--positive { background: rgba(0, 72, 45, 0.94);  border-color: color-mix(in srgb, var(--ok) 52%, transparent); }
  .ball8-tri.ball8--negative { background: rgba(88, 12, 29, 0.95);  border-color: color-mix(in srgb, var(--bad) 58%, transparent); }
  .ball8-tri.ball8--neutral  { background: rgba(86, 63, 8, 0.95);   border-color: color-mix(in srgb, var(--warn) 56%, transparent); }

  /* The signal word sits low in the triangle where the glass is widest. */
  .ball8-ans {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(0.9rem, 2.2vw, 1.28rem);
    line-height: 1;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    white-space: nowrap;
    color: #fff;
    text-shadow: 0 2px 9px rgba(0, 0, 0, 0.9), 0 0 16px currentColor;
    transform: translateY(34%);
  }
  .ball8-tri.ball8--positive .ball8-ans { color: var(--ok); }
  .ball8-tri.ball8--negative .ball8-ans { color: #ffb3c0; }
  .ball8-tri.ball8--neutral  .ball8-ans { color: var(--warn); }
  @keyframes answerReveal {
    0% { opacity: 0; transform: scale(0.5) translateY(12px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
  }

  .ball8-shine {
    position: absolute;
    top: 8%;
    left: 16%;
    width: 30%;
    height: 22%;
    border-radius: 50%;
    background: radial-gradient(ellipse, rgba(255, 255, 255, 0.14) 0%, transparent 70%);
    pointer-events: none;
  }

  /* The answer card — the actual reading surface. */
  .ball8-answer-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    width: 100%;
    max-width: none;
    padding: 22px 28px 24px;
    border: 2px solid var(--stroke);
    border-radius: var(--r-lg);
    background:
      linear-gradient(180deg, rgba(255,255,255,0.105), rgba(255,255,255,0.035)),
      radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 58%),
      color-mix(in srgb, var(--surface-0) 94%, #000 6%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--e-2);
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(1.65rem, 3vw, 2.7rem);
    line-height: 1.08;
    letter-spacing: -0.022em;
    text-align: center;
    text-wrap: balance;
    color: var(--ink);
    opacity: 0;
    transform: scale(0.92) translateY(14px);
    pointer-events: none;
    transition:
      opacity 0.48s var(--ease-out),
      transform 0.48s var(--ease-spring),
      color 0.38s, border-color 0.42s, box-shadow 0.48s;
  }
  .ball8-answer-display.is-visible { opacity: 1; transform: none; }

  .ball8-answer-display--idle,
  .ball8-answer-display--thinking {
    gap: 0;
    padding: 18px 24px;
    font-size: clamp(1.05rem, 2.3vw, 1.45rem);
    font-weight: 500;
    letter-spacing: 0;
    color: var(--ink-faint);
    box-shadow: none;
  }
  .ball8-answer-display--thinking {
    font-weight: 600;
    color: var(--ink-dim);
    animation: oracleThink 1.1s ease-in-out infinite;
  }
  @keyframes oracleThink {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 1; }
  }

  .ball8-answer-display--positive {
    color: var(--ok);
    border-color: color-mix(in srgb, var(--ok) 45%, transparent);
    box-shadow: 0 0 44px color-mix(in srgb, var(--ok) 15%, transparent), var(--e-2);
  }
  .ball8-answer-display--negative {
    color: #ffb3c0;
    border-color: color-mix(in srgb, var(--bad) 45%, transparent);
    box-shadow: 0 0 44px color-mix(in srgb, var(--bad) 15%, transparent), var(--e-2);
  }
  .ball8-answer-display--neutral {
    color: var(--warn);
    border-color: color-mix(in srgb, var(--warn) 45%, transparent);
    box-shadow: 0 0 44px color-mix(in srgb, var(--warn) 13%, transparent), var(--e-2);
  }

  .ball8-answer-display--positive.is-visible::before { content: "✦"; }
  .ball8-answer-display--negative.is-visible::before { content: "✕"; }
  .ball8-answer-display--neutral.is-visible::before  { content: "◌"; }
  .ball8-answer-display--positive.is-visible::before,
  .ball8-answer-display--negative.is-visible::before,
  .ball8-answer-display--neutral.is-visible::before {
    display: block;
    font-size: clamp(1.6rem, 6vw, 2.4rem);
    line-height: 1;
    filter: drop-shadow(0 0 14px currentColor);
    animation: oracleIconPop 0.62s var(--ease-spring) 0.18s both;
  }
  @keyframes oracleIconPop {
    0% { transform: scale(0.1) rotate(-28deg); opacity: 0; }
    60% { transform: scale(1.25) rotate(6deg); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
  }

  .ball8-history {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: var(--s-2);
    width: 100%;
    max-width: none;
    min-height: 40px;
  }
  .ball8-hist-card {
    display: flex;
    flex: 1 1 180px;
    flex-direction: column;
    gap: 4px;
    max-width: 280px;
    padding: 12px 14px;
    border: 1px solid var(--stroke);
    border-radius: var(--r-sm);
    background: var(--glass);
    color: var(--ink-dim);
    text-align: left;
    animation: fadeUp 0.3s var(--ease-out);
  }
  .ball8-hist-card span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--t-xs);
    color: var(--ink-faint);
  }
  .ball8-hist-card b { font-family: var(--font-display); font-size: var(--t-sm); }
  .ball8-hist-card--positive { color: var(--ok);   border-color: color-mix(in srgb, var(--ok) 34%, transparent);  background: var(--ok-soft); }
  .ball8-hist-card--negative { color: #ff9aaa;     border-color: color-mix(in srgb, var(--bad) 34%, transparent); background: rgba(80, 8, 24, 0.62); }
  .ball8-hist-card--neutral  { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 32%, transparent); background: var(--warn-soft); }

  /* Touch layouts: one column in the order a person actually uses it —
     sphere, then the answer right under it (where the eye already is), then
     the question and the Ask button at thumb height. The reading column
     dissolves (display: contents) so its parts can be ordered around the orb. */
  @media (max-width: 900px) {
    .oracle-console {
      display: flex;
      flex-direction: column;
      gap: var(--s-3);
      min-height: 0;
      border: 0;
      background: none;
      box-shadow: none;
      overflow: visible;
    }
    .oracle-reading { display: contents; }
    .ball8-stage {
      order: 1;
      min-height: 0;
      padding: var(--s-2) 0;
      border: 0;
      background: radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 60%);
      overflow: visible;
    }
    .ball8-answer-display { order: 2; }
    .oracle-divider { display: none; }
    .oracle-step { order: 3; margin: var(--s-2) 0 0; }
    .ball8-input { order: 4; }
    .oracle-ask { order: 5; margin-top: 0; }
  }

  @media (max-width: 720px) {
    .oracle-head { align-items: flex-start; padding-bottom: var(--s-3); }
    .oracle-status { display: none; }
    .ball8-orb { width: clamp(180px, 50vw, 230px); }
    .oracle-orbit--outer { width: min(72vw, 290px); }
    .oracle-orbit--inner { width: min(60vw, 240px); }
    .ball8-input { min-height: 76px; font-size: 1.1rem; }
    .ball8-ans { font-size: clamp(0.8rem, 4.4vw, 1.1rem); }
    .ball8-answer-display { padding: 16px 18px 18px; border-radius: var(--r-md); }
    /* Only a real answer gets display size; the idle/thinking line stays quiet. */
    .ball8-answer-display:not(.ball8-answer-display--idle):not(.ball8-answer-display--thinking) {
      font-size: clamp(1.4rem, 7.5vw, 2.1rem);
    }
    .oracle-memory { padding: 14px; }
    .oracle-memory__head { align-items: flex-start; font-size: 0.62rem; }
    .ball8-hist-card { padding: 6px 12px; }
  }
}
/* ============================================================================
   MODES · MARBLE RACE and BLACKJACK
   The two "arena" modes: a wide playfield with its own controls, rather than
   a single centred showpiece.
   ========================================================================== */
@layer modes {

  /* ══════════════════════════════════════════════════════════════════════
     MARBLE RACE
     One big stage (the camera follows the race down a tall course) beside a
     side panel: live status, standings, and the roster. On desktop the
     section is exactly one screen tall: the stage takes the slack and the
     side panel scrolls on its own. Below 981px it becomes a column: the
     stage and Start first, the standings and roster under them.
     ══════════════════════════════════════════════════════════════════════ */
  .marble-section {
    --mode-max: 1320px;
    --mr-row: 46px;
    --mr-chip: rgba(8, 10, 20, 0.74);
  }
  .marble-head { margin-bottom: clamp(12px, 2vh, 22px); }
  .marble-stats { display: flex; flex: 0 0 auto; gap: var(--s-2); }
  .marble-stats .stat { min-width: 86px; }

  .marble-layout {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(300px, 27vw, 372px);
    gap: clamp(14px, 1.8vw, 24px);
    min-height: 0;
  }
  .marble-main {
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    min-width: 0;
    min-height: 0;
  }

  /* marble.js sizes its canvas from this box, so it must always have one. */
  .marble-stage {
    position: relative;
    flex: 1;
    min-height: 360px;
    border: 1px solid var(--stroke-accent);
    border-radius: var(--r-xl);
    overflow: hidden;
    background:
      radial-gradient(120% 55% at 50% 0%, color-mix(in srgb, var(--accent) 13%, transparent), transparent 62%),
      radial-gradient(90% 50% at 50% 112%, color-mix(in srgb, var(--accent2) 15%, transparent), transparent 62%),
      var(--surface-0);
    box-shadow: var(--inset-top), var(--e-3);
    outline: none;
  }
  .mr-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }

  /* Idle hint, pinned to the stage floor. */
  .mr-hint {
    position: absolute;
    left: 50%;
    bottom: var(--s-4);
    translate: -50% 0;
    padding: 8px 14px;
    border: 1px solid var(--stroke);
    border-radius: var(--r-full);
    background: var(--mr-chip);
    font-family: var(--font-mono);
    font-size: var(--t-2xs);
    letter-spacing: var(--track-mono);
    color: rgba(255, 255, 255, 0.82);
    white-space: nowrap;
    pointer-events: none;
    transition: opacity var(--t-base) var(--ease-out);
  }
  .marble-stage:not([data-phase="idle"]) .mr-hint { opacity: 0; }

  /* Countdown: one beat per number, re-triggered by toggling .is-beat. */
  .mr-count {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(4rem, 14vw, 9rem);
    line-height: 1;
    color: var(--accent);
    text-shadow: 0 0 40px color-mix(in srgb, var(--accent) 60%, transparent);
    pointer-events: none;
  }
  .mr-count.is-beat { animation: mrBeat 0.7s var(--ease-out) both; }
  @keyframes mrBeat {
    0% { opacity: 0; transform: scale(1.5); }
    25% { opacity: 1; transform: scale(1); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: scale(0.92); }
  }

  /* Phone-only top-three strip (the board sits below the fold there). */
  .mr-leaders {
    position: absolute;
    top: var(--s-3);
    left: var(--s-3);
    right: 30px;
    display: none;
    gap: 6px;
    pointer-events: none;
  }
  .mr-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    max-width: 34%;
    padding: 3px 10px 3px 3px;
    border-radius: var(--r-full);
    background: var(--mr-chip);
    color: #fff;
    font-size: var(--t-2xs);
    font-weight: 600;
  }
  .mr-chip b {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: hsl(var(--hue) 82% 60%);
    color: #06070d;
    font-family: var(--font-mono);
    font-size: 0.68rem;
  }
  .mr-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* The champion moment. Full name, never truncated: it wraps instead. */
  .mr-banner {
    position: absolute;
    top: var(--s-4);
    left: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    width: max-content;
    max-width: calc(100% - 64px);
    padding: 10px 22px 12px;
    border: 1px solid color-mix(in srgb, var(--gold) 55%, transparent);
    border-radius: var(--r-lg);
    background: var(--mr-chip);
    box-shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.8), 0 0 40px -12px color-mix(in srgb, var(--gold) 60%, transparent);
    text-align: center;
    pointer-events: none;
    translate: -50% 0;
    animation: mrBanner 0.6s var(--ease-spring) both;
  }
  @keyframes mrBanner {
    from { opacity: 0; transform: translateY(-14px) scale(0.92); }
    to { opacity: 1; transform: none; }
  }
  .mr-banner__kicker {
    font-family: var(--font-mono);
    font-size: var(--t-2xs);
    letter-spacing: var(--track-caps);
    text-transform: uppercase;
    color: var(--gold);
  }
  .mr-banner__name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: var(--d-sm);
    line-height: 1.1;
    color: #fff;
    overflow-wrap: anywhere;
    text-wrap: balance;
  }
  .mr-banner[data-len="long"] .mr-banner__name { font-size: var(--t-lg); }

  /* ── Side panel ─────────────────────────────────────────────────────── */
  .marble-side {
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }
  .marble-result { min-height: 60px; }
  .marble-result b { overflow-wrap: anywhere; }
  .marble-panel {
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    padding: var(--s-4);
    border-radius: var(--r-lg);
  }
  .marble-panel__title {
    font-family: var(--font-mono);
    font-size: var(--t-2xs);
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--ink-faint);
  }

  /* Standings. Live rows sit absolutely and move by transform only, so a
     reorder animates without layout; the final results flow normally so a
     long name can wrap. */
  .marble-board {
    position: relative;
    height: calc(var(--rows, 1) * var(--mr-row));
    margin: 0;
    padding: 0;
    list-style: none;
  }
  .mr-row {
    position: absolute;
    inset: 0 0 auto;
    display: grid;
    grid-template-columns: 22px 10px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    height: calc(var(--mr-row) - 4px);
    padding: 0 12px;
    border: 1px solid transparent;
    border-radius: var(--r-xs);
    background: var(--glass);
    transform: translateY(calc(var(--i) * var(--mr-row)));
    transition: transform 0.45s var(--ease-out), background var(--t-base), border-color var(--t-base);
  }
  .mr-row__pos {
    font-family: var(--font-mono);
    font-size: var(--t-2xs);
    font-variant-numeric: var(--num);
    color: var(--ink-faint);
  }
  .mr-row__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: hsl(var(--hue) 82% 60%);
    box-shadow: 0 0 10px hsl(var(--hue) 82% 60% / 0.6);
  }
  .mr-row__name {
    overflow: hidden;
    font-size: var(--t-sm);
    font-weight: 600;
    color: var(--ink);
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mr-row__meta {
    font-family: var(--font-mono);
    font-size: var(--t-2xs);
    font-variant-numeric: var(--num);
    color: var(--ink-faint);
  }
  .mr-row.is-home .mr-row__meta { color: var(--ok); }
  .mr-row.is-idle .mr-row__meta { color: var(--ink-faint); }
  .mr-empty { font-size: var(--t-sm); color: var(--ink-faint); }

  .marble-board.is-final {
    display: flex;
    flex-direction: column;
    gap: 4px;
    height: auto;
  }
  .is-final .mr-row {
    position: relative;
    height: auto;
    min-height: calc(var(--mr-row) - 4px);
    padding-block: 8px;
    transform: none;
    animation: mrRowIn 0.4s var(--ease-out) both;
    animation-delay: calc(var(--i) * 45ms);
  }
  .is-final .mr-row__name { white-space: normal; overflow-wrap: anywhere; }
  .mr-row.is-podium .mr-row__pos { color: var(--ink); }
  .mr-row.is-champ {
    border-color: color-mix(in srgb, var(--gold) 50%, transparent);
    background: color-mix(in srgb, var(--gold) 12%, transparent);
  }
  .mr-row.is-champ .mr-row__pos,
  .mr-row.is-champ .mr-row__meta { color: var(--gold); }
  .mr-row.is-champ .mr-row__name { font-size: var(--t-md); font-weight: 700; }
  @keyframes mrRowIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
  }

  .marble-list { min-height: 140px; }
  .marble-actions { display: flex; justify-content: space-between; gap: var(--s-2); }

  .marble-panel__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); }
  .marble-panel__count {
    font-family: var(--font-mono);
    font-size: var(--t-2xs);
    font-variant-numeric: var(--num);
    letter-spacing: var(--track-mono);
    color: var(--ink-faint);
  }
  /* Adding and text editing step aside while a race is on. */
  .marble-section[data-phase="countdown"] .marble-add,
  .marble-section[data-phase="racing"] .marble-add,
  .marble-section[data-phase="countdown"] .marble-text,
  .marble-section[data-phase="racing"] .marble-text { display: none; }

  .marble-text summary {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    min-height: var(--tap);
    font-size: var(--t-sm);
    color: var(--ink-dim);
    cursor: pointer;
    list-style: none;
  }
  .marble-text summary::-webkit-details-marker { display: none; }
  .marble-text summary::before {
    content: "";
    width: 7px;
    height: 7px;
    border-right: 1.6px solid currentColor;
    border-bottom: 1.6px solid currentColor;
    rotate: -45deg;
    transition: rotate var(--t-base) var(--ease-out);
  }
  .marble-text[open] summary::before { rotate: 45deg; }
  .marble-text summary:hover { color: var(--ink); }
  .marble-text[open] { display: flex; flex-direction: column; gap: var(--s-2); }

  /* Remove control on idle rows: the full row height, so it is a real target. */
  .mr-row__x {
    display: grid;
    place-items: center;
    width: 40px;
    height: calc(var(--mr-row) - 4px);
    margin-right: -12px;
    border-radius: var(--r-xs);
    color: var(--ink-faint);
    transition: color var(--t-fast), background var(--t-fast);
  }
  .mr-row__x svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
  .mr-row__x:hover { color: var(--bad); background: var(--bad-soft); }

  /* Podium: gold, silver, bronze on the final board. */
  .mr-row[data-place="2"] { border-color: color-mix(in srgb, var(--silver) 40%, transparent); }
  .mr-row[data-place="2"] .mr-row__pos { color: var(--silver); }
  .mr-row[data-place="3"] { border-color: color-mix(in srgb, var(--bronze) 40%, transparent); }
  .mr-row[data-place="3"] .mr-row__pos { color: var(--bronze); }

  /* "New course": top-right of the stage. */
  .mr-reroll {
    position: absolute;
    top: var(--s-3);
    right: 28px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid var(--stroke-bright);
    border-radius: var(--r-full);
    background: var(--mr-chip);
    color: #fff;
    font-size: var(--t-xs);
    font-weight: 600;
    transition: transform var(--t-fast) var(--ease-out), border-color var(--t-fast);
  }
  .mr-reroll svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .mr-reroll:hover { transform: var(--hover-lift); border-color: var(--accent); }
  .mr-reroll:active { transform: var(--press); }
  /* Idle only: after a race, "Race again" already deals a fresh course, and
     the champion banner owns the top of the stage. */
  .marble-stage:not([data-phase="idle"]) .mr-reroll { display: none; }

  /* Desktop: exactly one screen. The stage absorbs the height. */
  @media (min-width: 981px) {
    .marble-section { height: max(620px, calc(100svh - var(--topbar-h) - var(--bottom-nav-h))); }
  }

  @media (max-width: 980px) {
    .marble-layout { grid-template-columns: 1fr; }
    .marble-stage { flex: none; height: clamp(380px, 62svh, 680px); }
    .marble-side { overflow: visible; }
    .mr-leaders { display: flex; }
    .marble-stage[data-phase="done"] .mr-leaders,
    .marble-stage[data-phase="idle"] .mr-leaders { display: none; }
  }

  @media (max-width: 720px) {
    .marble-head { margin-bottom: var(--s-3); }
    .marble-stats .stat { min-width: 0; padding: 7px 12px; }
    /* Head, stage and Start all fit the first screen of a phone. */
    .marble-stage {
      height: clamp(340px, calc(100svh - var(--topbar-h) - var(--bottom-nav-h) - 200px), 640px);
      border-radius: var(--r-lg);
    }
    .marble-panel { padding: var(--s-3); }
  }

  /* ══════════════════════════════════════════════════════════════════════
     BLACKJACK
     ══════════════════════════════════════════════════════════════════════ */
  /* A card table is furniture, not a document: it fits the viewport and never
     scrolls, at every width. The two card zones flex to absorb whatever height
     is left over, which keeps the bet controls reachable without scrolling —
     the single formula below works at all sizes because --bottom-nav-h is 0
     above 900px, where the nav lives in the header instead. */
  .bj-section {
    --mode-max: 1180px;
    display: flex;
    flex-direction: column;
    height: calc(100svh - var(--topbar-h) - var(--bottom-nav-h));
    min-height: 540px;
    padding-block: var(--section-y);
  }

  .bj-table {
    position: relative;
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    width: 100%;
    border: 1px solid var(--stroke);
    border-radius: var(--r-2xl);
    overflow: hidden;
    background: radial-gradient(ellipse 110% 70% at 50% 35%, #0f3018, #061209);
    box-shadow: var(--e-3), var(--inset-top), 0 0 0 5px rgba(0, 0, 0, 0.3);
  }
  .bj-table::before {
    content: "";
    position: absolute;
    inset: 8px;
    z-index: 0;
    border: 2px solid rgba(255, 255, 255, 0.035);
    border-radius: calc(var(--r-2xl) - 5px);
    pointer-events: none;
  }

  .bj-table__header {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    display: grid;
    grid-template-columns: minmax(92px, 1fr) minmax(260px, auto) minmax(92px, 1fr);
    align-items: center;
    gap: var(--s-4);
    padding: var(--s-4) var(--s-6) var(--s-3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  }
  .bj-table__header > :last-child { justify-self: end; }
  .bj-table__header .page-head { gap: var(--s-1); }
  .bj-table__header .page-head__title { font-size: var(--d-md); }

  .bj-free-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 10px;
    border: 1px solid color-mix(in srgb, var(--accent) 34%, transparent);
    border-radius: var(--r-full);
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    box-shadow: 0 0 22px -10px var(--accent);
    font-family: var(--font-mono);
    font-size: 0.58rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--accent);
  }

  .bj-balance-pop { animation: balancePop 0.34s var(--ease-spring); }
  @keyframes balancePop {
    50% { transform: scale(1.12); text-shadow: 0 0 18px color-mix(in srgb, var(--gold) 45%, transparent); }
  }

  .bj-zone {
    position: relative;
    z-index: 1;
    flex: 1;
    min-height: 0;
    padding: clamp(12px, 2.2vw, 24px) clamp(16px, 3.2vw, 32px);
  }
  /* The player's hand carries more chrome (bet, total, active ring) than the
     dealer's row, so it gets the larger share of the felt. */
  .bj-zone--player { flex-grow: 1.35; }
  @media (min-width: 901px) and (max-height: 800px) {
    .bj-zone { padding-block: var(--s-2); }
    .bj-zone__label { margin-bottom: var(--s-1); }
    .bj-free-pill { display: none; }
  }
  .bj-zone__label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-3);
    margin-bottom: var(--s-3);
    font-family: var(--font-mono);
    font-size: var(--t-2xs);
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.38);
  }
  .bj-cards-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--s-3);
    min-height: 108px;
  }
  /* Empty seats show where the cards will land — two ghost card slots —
     so a fresh table reads as "ready", not as missing content. */
  .bj-empty-state {
    --slot-w: clamp(46px, min(7vw, 7.4svh), 76px);
    position: relative;
    display: block;
    padding-top: calc(var(--slot-w) * 1.43 + var(--s-3));
    color: rgba(255, 255, 255, 0.42);
    font-size: var(--t-sm);
    text-align: center;
  }
  .bj-empty-state::before,
  .bj-empty-state::after {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: var(--slot-w);
    height: calc(var(--slot-w) * 1.43);
    border: 1.5px dashed rgba(255, 255, 255, 0.16);
    border-radius: clamp(6px, 1vw, 10px);
    background: rgba(255, 255, 255, 0.02);
  }
  .bj-empty-state::before { transform: translateX(calc(-100% - 5px)); }
  .bj-empty-state::after { transform: translateX(5px); }

  .bj-felt-center {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    display: grid;
    grid-template-columns: minmax(120px, 1fr) auto minmax(120px, 1fr);
    align-items: center;
    gap: var(--s-4);
    padding: var(--s-3) clamp(16px, 3vw, 32px);
    border-block: 1px solid rgba(255, 255, 255, 0.04);
    background: rgba(0, 0, 0, 0.14);
  }
  /* Label over amount, chips to the side: the rail stays one row tall so the
     fixed-height table always has room for both hands. */
  .bj-bet-display {
    display: grid;
    grid-template-columns: auto auto;
    grid-template-areas: "label chips" "amt chips";
    align-items: center;
    column-gap: var(--s-4);
    row-gap: 2px;
    padding-inline: var(--s-4);
  }
  .bj-bet-display .stat__label { grid-area: label; }
  .bj-bet-amt {
    grid-area: amt;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--accent);
    text-shadow: 0 0 20px color-mix(in srgb, var(--accent) 60%, transparent);
  }
  .bj-chip-stack {
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    grid-area: chips;
    width: 92px;
    min-height: 48px;
  }
  .bj-chip-stack__empty { display: none; }
  /* No chips yet: the stack gives its column back so the bet sits centred. */
  .bj-chip-stack:has(.bj-chip-stack__empty) { display: none; }
  .bj-bet-display:has(.bj-chip-stack__empty) { grid-template-columns: auto; grid-template-areas: "label" "amt"; justify-items: center; }
  .bj-real-chip {
    --chip: #ef4444;
    position: absolute;
    bottom: calc(var(--chip-i) * 2px);
    left: calc(50% + var(--chip-x) * 14px);
    display: grid;
    place-items: center;
    width: 42px;
    aspect-ratio: 1;
    border: 4px solid var(--chip);
    border-radius: 50%;
    transform: translateX(-50%) rotate(calc(var(--chip-i) * 9deg));
    background:
      radial-gradient(circle at 50% 50%, rgba(255,255,255,0.16) 0 22%, transparent 23%),
      repeating-conic-gradient(from 6deg, rgba(255,255,255,0.92) 0 9deg, transparent 9deg 32deg),
      radial-gradient(circle at 34% 24%, rgba(255,255,255,0.28), transparent 42%),
      var(--chip);
    box-shadow: 0 6px 10px rgba(0,0,0,0.34), inset 0 0 0 2px rgba(0,0,0,0.18), inset 0 0 0 8px rgba(255,255,255,0.12);
    animation: chipDrop 0.35s var(--ease-spring) both;
    animation-delay: calc(var(--chip-i) * 22ms);
  }
  .bj-real-chip b {
    position: relative;
    z-index: 1;
    font-family: var(--font-display);
    font-size: 0.56rem;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  }
  @keyframes chipDrop {
    from { opacity: 0; transform: translate(-50%, -20px) rotate(-18deg) scale(0.75); }
    to { opacity: 1; transform: translateX(-50%) rotate(calc(var(--chip-i) * 9deg)) scale(1); }
  }

  /* Status (left) and strategy tip (right) are quiet pills on the rail —
     context, never competing with the bet in the middle. */
  .bj-status-orb,
  .bj-advice {
    justify-self: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 120px;
    padding: 8px 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--r-md);
    background: rgba(0, 0, 0, 0.22);
  }
  .bj-status-orb span,
  .bj-advice b {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: var(--t-sm);
    text-align: center;
    color: var(--ink);
  }
  .bj-advice .bj-label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
  }
  .bj-status-orb { color: var(--accent); box-shadow: inset 0 0 22px color-mix(in srgb, var(--accent) 9%, transparent); }
  .bj-advice b { color: var(--gold); }

  .bj-player-hands {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: center;
    gap: var(--s-5);
    min-height: 148px;
  }
  .bj-hand {
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    padding: var(--s-3);
    border: 2px solid transparent;
    border-radius: var(--r-md);
    transition: border-color var(--t-base), box-shadow var(--t-base);
  }
  .bj-hand--active {
    border-color: var(--accent);
    box-shadow:
      0 0 0 1px color-mix(in srgb, var(--accent) 50%, transparent),
      0 8px 28px -8px color-mix(in srgb, var(--accent) 45%, transparent);
    animation: handFocus 1.3s ease-in-out infinite alternate;
  }
  @keyframes handFocus {
    from { transform: translateY(0); }
    to { transform: translateY(-3px); }
  }
  .bj-hand--settled { opacity: 0.88; }
  .bj-hand__cards { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-2); }
  .bj-hand__info { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
  .bj-hand__bet {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: var(--t-xs);
    color: rgba(255, 255, 255, 0.42);
  }

  .bj-card {
    /* Bounded by height as well as width: the table is a fixed-height screen,
       and on short laptops width-only sizing pushed the hand under the
       controls. */
    --card-w: clamp(46px, min(8.5vw, 8.2svh), 84px);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: var(--card-w);
    height: calc(var(--card-w) * 1.43);
    border-radius: clamp(6px, 1vw, 10px);
    transform-style: preserve-3d;
    transform-origin: 50% 120%;
  }
  .bj-card--new { animation: bjDeal 0.72s var(--ease-out) both; animation-delay: var(--dd, 0s); }
  @keyframes bjDeal {
    from { transform: translate(118px, -96px) rotate(14deg) scale(0.72); opacity: 0; }
    48% { transform: translate(18px, -12px) rotate(4deg) scale(1.03); opacity: 1; }
    78% { transform: translate(-5px, 9px) rotate(-2deg) scale(1.05); }
    to { transform: none; opacity: 1; }
  }
  .bj-card--red,
  .bj-card--black {
    background: #f5f0e8;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 2px 3px 14px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.85);
  }
  .bj-card--red { color: #c0392b; }
  .bj-card--black { color: #1a1a2e; }
  .bj-card__tl,
  .bj-card__br {
    position: absolute;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(9px, 1.5vw, 14px);
    line-height: 1.2;
    text-align: center;
  }
  .bj-card__tl { top: 5px; left: 6px; }
  .bj-card__br { right: 6px; bottom: 5px; transform: rotate(180deg); }
  .bj-card__center { font-size: clamp(20px, 3.5vw, 34px); line-height: 1; pointer-events: none; }
  .bj-card--back {
    background: linear-gradient(145deg, #120738, #060d2e);
    border: 1px solid var(--stroke);
    box-shadow: 2px 3px 14px rgba(0, 0, 0, 0.5);
  }
  .bj-card__back-inner {
    position: absolute;
    inset: 5px;
    border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
    border-radius: 6px;
    background-image:
      repeating-linear-gradient(45deg, transparent, transparent 7px,
        color-mix(in srgb, var(--accent) 11%, transparent) 7px, color-mix(in srgb, var(--accent) 11%, transparent) 8px),
      repeating-linear-gradient(-45deg, transparent, transparent 7px,
        color-mix(in srgb, var(--accent2) 9%, transparent) 7px, color-mix(in srgb, var(--accent2) 9%, transparent) 8px);
  }

  .bj-score-badge:empty { display: none; }
  .bj-score-badge {
    min-width: 28px;
    padding: 3px 9px;
    border: 1px solid var(--stroke);
    border-radius: var(--r-full);
    background: var(--glass-2);
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: var(--t-xs);
    text-align: center;
    color: var(--ink-dim);
  }
  .bj-score--bust { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 38%, transparent); color: var(--bad); }
  .bj-score--21 { background: var(--warn-soft); border-color: color-mix(in srgb, var(--gold) 32%, transparent); color: var(--gold); }

  .bj-badge {
    padding: 4px 11px;
    border-radius: var(--r-full);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: var(--t-xs);
    letter-spacing: 0.1em;
    animation: badgePop 0.42s var(--ease-spring);
  }
  @keyframes badgePop {
    from { transform: scale(0.4); opacity: 0; }
    to { transform: none; opacity: 1; }
  }
  .bj-badge--win { background: var(--ok-soft); border: 1px solid color-mix(in srgb, var(--ok) 38%, transparent); color: var(--ok); }
  .bj-badge--bj {
    background: var(--warn-soft);
    border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
    color: var(--gold);
    box-shadow: 0 0 18px color-mix(in srgb, var(--gold) 28%, transparent);
    animation-duration: 0.6s;
  }
  .bj-badge--push { background: var(--glass-2); border: 1px solid var(--stroke-bright); color: var(--ink-dim); }
  .bj-badge--bust,
  .bj-badge--loss { background: var(--bad-soft); border: 1px solid color-mix(in srgb, var(--bad) 32%, transparent); color: var(--bad); }

  .bj-controls-bar {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    padding: var(--s-5) var(--s-6) var(--s-6);
    padding-bottom: calc(var(--s-6) + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.22);
  }
  .bj-bet-panel { display: flex; flex-direction: column; gap: var(--s-3); }
  .bj-quick-bets { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--s-3); }
  .bj-qbet {
    min-height: 56px;
    padding: 14px 8px;
    border: 2px solid var(--stroke-bright);
    border-radius: var(--r-md);
    background: var(--glass-2);
    color: var(--ink);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: var(--t-lg);
    letter-spacing: 0.05em;
    transition: transform var(--t-fast) var(--ease-out), border-color var(--t-fast), background var(--t-fast), color var(--t-fast);
  }
  .bj-qbet:hover {
    transform: var(--hover-lift);
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    color: var(--accent);
  }
  .bj-qbet:active { transform: var(--press); }
  .bj-qbet--max { border-color: color-mix(in srgb, var(--accent2) 60%, transparent); color: var(--accent2); }
  .bj-qbet--max:hover { border-color: var(--accent2); background: color-mix(in srgb, var(--accent2) 12%, transparent); color: var(--accent2); }
  .bj-qbet--active {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    color: var(--accent);
    box-shadow: 0 0 20px -6px color-mix(in srgb, var(--accent) 60%, transparent);
    transform: var(--hover-lift);
  }
  .bj-bet-secondary { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }

  .bj-action-panel { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: var(--s-3); }
  .bj-result-panel { display: flex; }

  /* The action buttons are `.action`s tinted by role. */
  .bj-btn--action { flex-direction: column; gap: 5px; min-height: 68px; border-radius: var(--r-md); letter-spacing: 0.08em; }
  .bj-btn--action kbd {
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--glass-2);
    font-family: var(--font-mono);
    font-size: 0.6em;
    color: var(--ink-faint);
  }
  .bj-btn--hit { border-color: color-mix(in srgb, var(--accent) 55%, transparent); color: var(--accent); }
  .bj-btn--hit:hover:not(:disabled) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
  .bj-btn--stand { border-color: color-mix(in srgb, var(--bad) 50%, transparent); color: var(--bad); }
  .bj-btn--stand:hover:not(:disabled) { border-color: var(--bad); background: var(--bad-soft); }
  .bj-btn--double:hover:not(:disabled) { border-color: var(--accent2); background: color-mix(in srgb, var(--accent2) 10%, transparent); color: var(--accent2); }
  .bj-btn--split { border-color: var(--accent2); color: var(--accent2); }
  .bj-btn--split:hover:not(:disabled) { background: color-mix(in srgb, var(--accent2) 10%, transparent); }

  /* Whole-table feedback flash on deal / win / loss / push. */
  .bj-table.is-bj-dealing::after,
  .bj-table.is-bj-win::after,
  .bj-table.is-bj-loss::after,
  .bj-table.is-bj-push::after,
  .bj-table.is-bj-ready::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    animation: tablePulse 0.85s var(--ease-out) forwards;
  }
  .bj-table.is-bj-dealing::after,
  .bj-table.is-bj-ready::after {
    background: radial-gradient(ellipse 55% 40% at 50% 56%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 72%);
  }
  .bj-table.is-bj-win::after  { background: radial-gradient(ellipse 62% 48% at 50% 56%, color-mix(in srgb, var(--ok) 28%, transparent), transparent 72%); }
  .bj-table.is-bj-loss::after { background: radial-gradient(ellipse 62% 48% at 50% 56%, color-mix(in srgb, var(--bad) 24%, transparent), transparent 72%); }
  .bj-table.is-bj-push::after { background: radial-gradient(ellipse 62% 48% at 50% 56%, rgba(255, 255, 255, 0.16), transparent 72%); }
  @keyframes tablePulse {
    0% { opacity: 0; transform: scale(0.96); }
    35% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.04); }
  }

  /* Below 900px the table stops being a page you scroll and becomes a fixed
     playfield: it fills the space between the topbar and the bottom nav, the
     felt absorbs the slack, and the controls bar is pinned in thumb reach.
     This starts at the bottom-nav breakpoint, not the phone one — on a portrait
     tablet the scrolling version stranded the Deal button below the fold. */
  @media (max-width: 900px) {
    /* Edge to edge: on touch sizes the felt uses every pixel it can get. */
    .bj-section { width: 100%; min-height: 0; padding: 0; animation: none; }
    .bj-table { border: 0; border-radius: 0; box-shadow: none; }
    .bj-table::before { display: none; }

    .bj-table__header {
      grid-template-columns: 1fr auto 1fr;
      gap: var(--s-3);
      padding: var(--s-2) var(--s-4);
    }
    .bj-table__header .page-head__title { font-size: var(--d-sm); }
    .bj-table__header .page-head__sub { display: none; }

    .bj-zone { padding: var(--s-2) var(--s-4); }
    .bj-zone__label { margin-bottom: var(--s-1); }
    .bj-cards-row,
    .bj-player-hands { min-height: 0; gap: var(--s-2); flex-wrap: nowrap; }

    .bj-felt-center {
      grid-template-columns: 1fr auto 1fr;
      gap: var(--s-3);
      padding: var(--s-2) var(--s-4);
    }
    .bj-bet-display { padding-inline: var(--s-3); }
    .bj-chip-stack { width: 84px; min-height: 40px; }
    .bj-status-orb,
    .bj-advice { min-width: 0; width: auto; padding: 7px 12px; }

    .bj-controls-bar {
      padding: var(--s-3) var(--s-4) calc(var(--s-3) + env(safe-area-inset-bottom, 0px));
    }
  }

  /* Phones additionally tighten every fixed dimension. */
  @media (max-width: 720px) {
    .bj-table__header,
    .bj-zone,
    .bj-felt-center { padding-inline: var(--s-3); }
    .bj-free-pill { display: none; }
    .bj-chip-stack { width: 72px; min-height: 36px; }
    .bj-status-orb,
    .bj-advice { min-width: 0; max-width: 34vw; padding: 6px 10px; }
    .bj-felt-center { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
    .bj-controls-bar { padding: var(--s-3) var(--s-3) calc(var(--s-3) + env(safe-area-inset-bottom, 0px)); }
    .bj-quick-bets { gap: var(--s-2); }
    .bj-qbet { min-height: 48px; padding: 12px 4px; font-size: var(--t-md); }
    .bj-btn--action { min-height: 58px; }
    .bj-btn--action kbd { display: none; }
    .bj-card { --card-w: clamp(42px, 12.5vw, 60px); }
  }
}
/* ============================================================================
   A11Y
   Motion and contrast accommodations get the last word on presentation, which
   is why this layer sits after `modes`.
   ========================================================================== */
@layer a11y {

  /* Visually hidden but available to screen readers. */
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }

  /* Skip link — the first tab stop on the page. */
  .skip-link {
    position: fixed;
    top: var(--s-2);
    left: var(--s-2);
    z-index: calc(var(--z-toast) + 1);
    padding: 10px 18px;
    border-radius: var(--r-sm);
    background: var(--accent);
    color: var(--seg-text);
    font-weight: 700;
    transform: translateY(-160%);
    transition: transform var(--t-base) var(--ease-out);
  }
  .skip-link:focus-visible { transform: none; box-shadow: var(--focus-ring); }

  @media (prefers-reduced-motion: reduce) {
    /* Kill ambient/decorative motion outright; keep state changes instant
       rather than animated so nothing appears frozen mid-transition. */
    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
      scroll-behavior: auto !important;
    }
    .bm-dot,
    .bm-sweep,
    .bm-prism,
    .hub-ring { animation: none !important; }

    /* Elements that animate *into* view must not be left invisible. */
    .mr-banner,
    .is-final .mr-row,
    .ball8-answer-display.is-visible,
    .winner[aria-hidden="false"] .winner__card {
      opacity: 1 !important;
      transform: none !important;
    }
  }

  @media (forced-colors: active) {
    .surface,
    .panel,
    .chip,
    .action,
    .btn,
    .mode-tab,
    .theme-card { border: 1px solid CanvasText; }
    .mode-tab[aria-selected="true"],
    .chip.is-active,
    .seg__item.is-active { forced-color-adjust: none; background: Highlight; color: HighlightText; }
    .atmos { display: none; }
  }
}

/* ============================================================================
   HIDDEN
   The last layer in the cascade, so `hidden` always wins over any author
   `display` rule regardless of specificity. This replaces the three separate
   copies of this rule the previous stylesheet needed, including the one
   commented "must be ABSOLUTELY last in the file".
   ========================================================================== */
@layer hidden {
  [hidden] { display: none; }
}
