/* NeuroSense v2.3 — ARCADE stylesheet (DESIGN-arcade.md).
   School-computer-lab arcade cabinet: deep indigo CRT, coin-cyan + player-2
   pink phosphor accents, gold reserved for scores and medals.
   Layers: tokens → base → components → views. Class names kept from v2 —
   this is a re-skin, not a rewrite. System fonts + CSS-only effects. */

@layer tokens, base, components, views;

@layer tokens {
  :root {
    /* surfaces */
    --plane: #0B0E1A;
    --surface: #141931;
    --surface-sunken: #0E1226;
    --hairline: #2A3155;

    /* ink */
    --ink: #EAF2FF;
    --ink-2: #A8B3D9;
    --ink-3: #8B96C2;

    /* accents — exactly two neons + one prize color */
    --accent: #2EE6D6;        /* coin cyan */
    --accent-ink: #051217;    /* dark ink ON cyan/gold/neon fills */
    --accent-wash: #10333A;
    --accent-2: #FF5CA8;      /* player-2 pink */
    --gold: #FFC53D;          /* SCORE + medals ONLY */

    /* status */
    --good: #4ADE80;
    --warn: #FFB020;
    --critical: #FF6B6B;
    --rec: #FF4757;
    --good-wash: #10301F;
    --warn-wash: #33260C;
    --crit-wash: #331116;

    /* charts */
    --series-1: #2EE6D6;
    --series-2: #FF5CA8;
    --series-3: #FFC53D;
    --axis: #3A4470;

    --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

    --glow-cyan: 0 0 10px rgba(46, 230, 214, .50), 0 0 28px rgba(46, 230, 214, .18);
    --glow-pink: 0 0 10px rgba(255, 92, 168, .50), 0 0 28px rgba(255, 92, 168, .18);
    --glow-gold: 0 0 12px rgba(255, 197, 61, .55), 0 0 32px rgba(255, 197, 61, .20);
    --text-glow-cyan: 0 0 6px rgba(46, 230, 214, .6), 0 0 18px rgba(46, 230, 214, .25);
    --text-glow-gold: 0 0 8px rgba(255, 197, 61, .6), 0 0 22px rgba(255, 197, 61, .3);

    --radius-card: 6px;
    --radius-ctl: 4px;
    --shadow-card: 0 0 0 1px rgba(46, 230, 214, .06), 0 2px 8px rgba(0, 0, 0, .5);
    --gutter: 24px;
  }
}

@layer base {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; }
  body {
    margin: 0;
    background: var(--plane);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.5;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  h1, h2, h3, p { margin: 0; }
  [hidden] { display: none !important; }
  a { color: var(--accent); }
  button { font: inherit; }
  :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
  .label-caps {
    font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
    color: var(--ink-3); font-weight: 600;
  }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
  }
}

@layer components {
  /* ---- display type + CRT tricks ---- */
  .neon-title {
    font-family: var(--font-ui);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--ink);
    text-shadow: var(--text-glow-cyan);
  }
  .neon-title--gold { text-shadow: var(--text-glow-gold); color: var(--gold); }
  /* Static scanlines — camera stage + score hero ONLY, never over body text.
     No flicker animation, ever (photosensitivity). */
  .crt { position: relative; }
  .crt::after {
    content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 3;
    background: repeating-linear-gradient(
      0deg, rgba(5, 8, 18, .16) 0px, rgba(5, 8, 18, .16) 1px, transparent 1px, transparent 3px);
  }

  /* ---- header ---- */
  .app-header {
    height: 56px; background: var(--surface);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 var(--gutter); gap: 16px;
  }
  .marquee-strip {
    height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
  }
  .wordmark { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
  .wordmark-glyph { flex: none; }
  .wordmark-stack { display: flex; flex-direction: column; line-height: 1.1; }
  .wordmark-text { font-size: 20px; letter-spacing: .06em; }
  .wm-neuro { font-weight: 400; }
  .wm-sense { font-weight: 800; color: var(--accent); text-shadow: var(--text-glow-cyan); }
  .wordmark-sub {
    font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3);
  }
  .header-right { display: flex; align-items: center; gap: 12px; }
  .header-link {
    font-size: 13px; font-weight: 600; text-decoration: none;
    padding: 6px 8px; border-radius: var(--radius-ctl);
    text-transform: uppercase; letter-spacing: .06em;
  }
  .header-link:hover { background: var(--accent-wash); }
  .subject-pill {
    font-size: 13px; background: transparent; color: var(--accent);
    border: 1px solid var(--accent); border-radius: 999px; padding: 4px 12px;
    max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .version-tag { font-size: 12px; color: var(--ink-3); font-family: var(--font-mono); }
  .lang-toggle {
    display: inline-flex; border: 1px solid var(--hairline);
    border-radius: var(--radius-ctl); overflow: hidden;
  }
  .lang-toggle button {
    border: none; background: var(--surface); color: var(--ink-2);
    min-height: 32px; min-width: 44px; padding: 0 10px;
    font-size: 12px; font-weight: 700; cursor: pointer;
  }
  .lang-toggle button + button { border-left: 1px solid var(--hairline); }
  .lang-toggle button[aria-pressed="true"] { background: var(--accent-wash); color: var(--accent); }

  /* ---- layout ---- */
  .view { max-width: 1120px; margin: 0 auto; padding: var(--gutter); outline: none; }
  .view-title { font-size: 24px; }
  .section { margin-top: 32px; }
  .section:first-child { margin-top: 0; }

  /* ---- cards ---- */
  .card {
    background: var(--surface); border: 2px solid var(--hairline);
    border-radius: var(--radius-card); box-shadow: var(--shadow-card);
    padding: 24px;
  }
  .card-title { font-size: 17px; font-weight: 700; letter-spacing: .06em; }

  /* ---- buttons ---- */
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 44px; min-width: 44px; padding: 0 18px;
    border-radius: var(--radius-ctl); border: 2px solid transparent;
    font-size: 15px; font-weight: 700; cursor: pointer; text-decoration: none;
    letter-spacing: .04em;
  }
  .btn--primary { background: var(--accent); color: var(--accent-ink); }
  .btn--primary:hover { box-shadow: var(--glow-cyan); }
  .btn--primary:disabled { background: var(--hairline); color: var(--ink-3); cursor: not-allowed; box-shadow: none; }
  .btn--primary:focus-visible, .btn--start:focus-visible { outline-color: var(--ink); }
  .btn--secondary { background: var(--surface); color: var(--ink); border-color: var(--hairline); }
  .btn--secondary:hover { background: var(--surface-sunken); border-color: var(--accent); }
  .btn--danger { background: var(--surface); color: var(--critical); border-color: var(--critical); }
  .btn--danger:hover { background: var(--crit-wash); }
  .btn--row { height: 32px; font-size: 13px; padding: 0 12px; border-width: 1px; }

  /* ---- forms ---- */
  .field-label { display: block; margin-bottom: 6px; }
  input[type="text"], select {
    font: inherit; color: var(--ink); background: var(--surface-sunken);
    border: 2px solid var(--hairline); border-radius: var(--radius-ctl);
    height: 44px; padding: 0 12px; min-width: 0;
  }
  input[type="text"] { font-family: var(--font-mono); letter-spacing: .04em; }
  input[type="text"]:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
  .hint { font-size: 13px; color: var(--ink-3); margin-top: 6px; }

  /* ---- chips ---- */
  .chip {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 600; letter-spacing: .04em;
    border: 1px solid var(--hairline); border-radius: 999px;
    padding: 3px 10px; color: var(--ink-2); background: var(--surface);
    white-space: nowrap;
  }
  .chip .mono { font-size: 12px; }
  .chip--warn { color: var(--warn); border-color: var(--warn); background: var(--warn-wash); }
  .chip--good { color: var(--good); border-color: var(--good); background: var(--good-wash); }
  .chip--critical { color: var(--critical); border-color: var(--critical); background: var(--crit-wash); }

  /* ---- readout / HUD tiles (signature element) ---- */
  .readout {
    background: var(--surface); border: 1px solid var(--hairline);
    border-radius: 0; /* square corners = HUD tile */
    padding: 14px 16px; min-width: 0;
  }
  .readout-label { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
  .readout-value {
    font-family: var(--font-mono); font-variant-numeric: tabular-nums;
    font-size: 34px; font-weight: 700; line-height: 1.1; color: var(--accent);
    text-shadow: 0 0 6px rgba(46, 230, 214, .35);
    margin-top: 4px; white-space: nowrap;
  }
  .readout-unit { font-family: var(--font-ui); font-size: 13px; color: var(--ink-3); margin-left: 4px; font-weight: 400; }
  .readout-sub { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
  .live-tag { display: block; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin-top: 6px; }
  .watermark { display: inline-block; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; }
  .watermark--prelim { color: var(--warn); }
  .watermark--verified { color: var(--good); }

  /* ---- tables ---- */
  table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
  table.data th {
    text-align: left; font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
    color: var(--ink-3); font-weight: 600; padding: 8px 12px;
    border-bottom: 1px solid var(--hairline);
  }
  table.data td { padding: 0 12px; height: 44px; border-bottom: 1px solid var(--hairline); }
  table.data td.num, table.data th.num { text-align: right; }
  table.data td.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
  table.data tr.rowlink { cursor: pointer; }
  table.data tr.rowlink:hover { background: var(--accent-wash); }
  .empty-row { color: var(--ink-2); }
  .score-cell { color: var(--gold); font-weight: 700; }

  /* ---- state banner = cabinet marquee ---- */
  .state-banner {
    height: 56px; display: flex; align-items: center; justify-content: center; gap: 10px;
    font-size: 15px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700;
    color: var(--ink-3); background: var(--surface-sunken);
    border: 2px solid var(--hairline); border-bottom: none;
  }
  .state-banner[data-state="WAITING"] { background: var(--accent-wash); color: var(--accent); }
  .state-banner[data-state="COUNTDOWN"] { background: var(--accent-wash); color: var(--accent); text-shadow: var(--text-glow-cyan); }
  /* Solid neon fills always take dark ink (white fails contrast on these). */
  .state-banner[data-state="RUNNING"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
  .state-banner[data-state="HAND_LOST"] { background: var(--rec); color: var(--accent-ink); border-color: var(--rec); }
  .state-banner[data-state="DONE"] { background: var(--good); color: var(--accent-ink); border-color: var(--good); }
  .rec-dot {
    width: 8px; height: 8px; border-radius: 999px; background: var(--rec); flex: none;
    box-shadow: 0 0 0 1px rgba(5, 18, 23, .5);
    animation: rec-pulse 1.2s ease-in-out infinite;
  }
  @keyframes rec-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

  /* ---- toasts ---- */
  .toast-region {
    position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
    display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(92vw, 480px);
  }
  .toast {
    background: var(--surface); color: var(--ink); font-size: 13px;
    border: 1px solid var(--hairline);
    border-radius: var(--radius-ctl); padding: 10px 16px; box-shadow: 0 2px 12px rgba(0, 0, 0, .6);
  }
  .toast--error { border-color: var(--critical); color: var(--critical); background: var(--crit-wash); }
  .toast--good { border-color: var(--good); color: var(--good); background: var(--good-wash); }
  .toast--info { border-color: var(--hairline); }

  /* ---- inline status banners (results save state) ---- */
  .inline-banner {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    border: 1px solid var(--hairline); border-radius: var(--radius-ctl);
    background: var(--surface); padding: 12px 16px; font-size: 13px; color: var(--ink-2);
  }
  .inline-banner--error { border-color: var(--critical); color: var(--critical); background: var(--crit-wash); }
  .inline-banner--good { border-color: var(--good); color: var(--good); background: var(--good-wash); }

  /* ---- charts ---- */
  .chart { margin: 0; background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius-card); padding: 16px; position: relative; }
  .chart-title { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 8px; }
  .chart svg { display: block; width: 100%; height: auto; }
  .chart-tooltip {
    position: absolute; pointer-events: none; display: none;
    background: var(--surface-sunken); border: 1px solid var(--accent); border-radius: 4px;
    color: var(--ink);
    box-shadow: var(--shadow-card); padding: 6px 10px; font-size: 12px; white-space: nowrap; z-index: 5;
  }
  .chart-tooltip .mono { font-size: 12px; }
  .chart-empty {
    height: 220px; display: flex; align-items: center; justify-content: center;
    background: var(--surface-sunken); border-radius: 4px;
    color: var(--ink-2); font-size: 13px; text-align: center; padding: 0 24px;
  }
  details.chart-data { margin-top: 8px; font-size: 13px; }
  details.chart-data summary { cursor: pointer; color: var(--accent); font-weight: 600; padding: 4px 0; }
  details.chart-data .scroll { overflow-x: auto; max-height: 260px; overflow-y: auto; }

  /* ---- shared footer: attribution + disclaimer ---- */
  .app-footer { margin-top: 32px; }
  .credit-line {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; color: var(--ink-2); font-weight: 600;
  }
  .pixel-heart { flex: none; }
  .disclaimer {
    margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--hairline);
    font-size: 12px; color: var(--ink-3);
  }

  .sr-only {
    position: absolute; width: 1px; height: 1px; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
}

@layer views {
  /* ---- home: insert-coin hero ---- */
  .arcade-hero {
    text-align: center; padding: 40px 16px 32px;
    background: var(--surface-sunken);
    border: 2px solid var(--hairline); border-radius: var(--radius-card);
    overflow: hidden;
  }
  .arcade-hero .neon-title { font-size: 32px; }
  .press-start {
    margin-top: 14px;
    font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
    color: var(--gold);
    animation: blink 1.2s steps(1) infinite;
  }
  @keyframes blink { 50% { opacity: .25; } }

  .subject-row { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
  .subject-row .grow { flex: 1 1 240px; display: flex; flex-direction: column; }

  .launcher-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; margin-top: 16px; }
  .launcher-card { display: flex; flex-direction: column; gap: 10px; }
  .launcher-desc { color: var(--ink-2); font-size: 15px; }
  .launcher-chips { display: flex; gap: 8px; flex-wrap: wrap; }
  .game-card { border-top: 3px solid var(--card-accent, var(--accent)); }
  .game-card:hover { box-shadow: var(--shadow-card), var(--glow-cyan); }
  .game-card .card-title { text-transform: uppercase; letter-spacing: .1em; }
  .game-art { color: var(--card-accent, var(--accent)); line-height: 0; }
  .btn--start {
    align-self: stretch; margin-top: auto; height: 48px;
    text-transform: uppercase; letter-spacing: .08em;
  }

  /* ---- test screen: game HUD ---- */
  .test-head { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
  .test-layout { display: grid; grid-template-columns: 62fr 38fr; gap: 24px; align-items: start; }
  .stage { user-select: none; -webkit-user-select: none; }
  .stage-well {
    position: relative; background: var(--surface-sunken);
    border: 2px solid var(--hairline); overflow: hidden;
    aspect-ratio: 4 / 3;
    box-shadow: inset 0 0 48px rgba(0, 0, 0, .45);
  }
  /* z-order: video/canvas < scanlines (3) < instruction (4) < countdown/GO (5) < cover (6) */
  .stage-well video, .stage-well canvas {
    position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
  }
  .mirror { transform: scaleX(-1); }
  .countdown-num {
    position: absolute; inset: 0; z-index: 5;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-mono); font-size: clamp(72px, 24vw, 120px); font-weight: 700;
    pointer-events: none;
  }
  .countdown-num[data-beat="3"] { color: var(--accent); text-shadow: var(--text-glow-cyan); }
  .countdown-num[data-beat="2"] { color: var(--accent-2); text-shadow: 0 0 6px rgba(255, 92, 168, .6), 0 0 18px rgba(255, 92, 168, .25); }
  .countdown-num[data-beat="1"], .countdown-num[data-beat="go"] { color: var(--gold); text-shadow: var(--text-glow-gold); }
  .cd-pop { animation: cd-pop .2s ease-out; }
  @keyframes cd-pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: scale(1); } }
  .instruction-line {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 4;
    padding: 10px 16px; font-size: 13px; color: var(--ink);
    background: rgba(11, 14, 26, .72); text-align: center;
  }
  .ring-holder { position: absolute; top: 12px; right: 12px; width: 88px; height: 88px; z-index: 4; }
  .stage-cover {
    position: absolute; inset: 0; z-index: 6;
    display: flex; align-items: center; justify-content: center;
    background: var(--surface-sunken); padding: 24px;
  }
  .stage-cover .cover-card { max-width: 420px; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; }
  .stage-cover h2 { font-size: 17px; text-transform: uppercase; letter-spacing: .08em; }
  .stage-cover p { color: var(--ink-2); font-size: 14px; }
  .stage-hint { margin-top: 8px; font-size: 13px; color: var(--warn); min-height: 20px; font-weight: 600; }
  .stage-actions { margin-top: 12px; display: flex; justify-content: flex-start; }

  /* ---- QUICK DRAW cue overlay + round pips ---- */
  .go-cue {
    position: absolute; inset: 0; z-index: 5;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 8px; text-align: center; padding: 16px; pointer-events: none;
  }
  .go-cue[data-phase="wait"] { background: rgba(11, 14, 26, .55); }
  .go-cue[data-phase="go"] { background: var(--accent); }
  .go-cue[data-phase="hit"], .go-cue[data-phase="miss"] { background: var(--surface); }
  .go-cue[data-phase="toosoon"] { background: var(--accent-2); }
  .cue-main {
    font-size: 24px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
    color: var(--ink);
  }
  .go-cue[data-phase="toosoon"] .cue-main { color: var(--accent-ink); }
  .cue-sub { font-size: 15px; color: var(--ink-2); }
  .go-cue[data-phase="toosoon"] .cue-sub { color: var(--accent-ink); }
  .cue-go {
    font-family: var(--font-mono); font-weight: 800; color: var(--accent-ink);
    font-size: clamp(64px, 18vh, 160px); line-height: 1;
  }
  .cue-rt { font-size: clamp(40px, 12vw, 64px); font-weight: 700; color: var(--gold); text-shadow: var(--text-glow-gold); }
  .rt-rounds {
    position: absolute; top: 12px; left: 0; right: 0; z-index: 4;
    display: flex; justify-content: center; gap: 10px; pointer-events: none;
  }
  .round-pip {
    width: 12px; height: 12px; border-radius: 999px;
    border: 2px solid var(--axis); background: transparent;
  }
  .round-pip[data-state="current"] { border-color: var(--accent); animation: blink 1.2s steps(1) infinite; }
  .round-pip[data-state="hit"] { border-color: var(--accent); background: var(--accent); }
  .round-pip[data-state="miss"] { border-color: var(--axis); background: var(--axis); }
  .rt-list { background: var(--surface); border: 1px solid var(--hairline); padding: 14px 16px; }
  .rt-row {
    display: flex; justify-content: space-between; font-size: 14px;
    padding: 4px 0; border-bottom: 1px solid var(--surface-sunken); color: var(--ink);
  }
  .rt-row:last-of-type { border-bottom: none; }

  .rail { display: flex; flex-direction: column; gap: 12px; }
  .rail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .rail-foot { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
  .spark-panel { background: var(--surface); border: 1px solid var(--hairline); padding: 14px 16px; }
  .spark-panel svg { display: block; width: 100%; height: 32px; margin-top: 8px; }

  @media (max-width: 860px), (orientation: portrait) {
    .test-layout { grid-template-columns: 1fr; }
  }

  /* ---- results: score reveal ---- */
  .results-head { display: flex; flex-direction: column; gap: 8px; }
  .results-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; color: var(--ink-2); font-size: 13px; }
  .score-hero {
    margin-top: 24px; padding: 32px 24px; text-align: center;
    background: var(--surface); border: 2px solid var(--hairline);
    border-radius: var(--radius-card); box-shadow: var(--shadow-card);
    overflow: hidden;
  }
  .score-label { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
  .score-value {
    font-family: var(--font-mono); font-variant-numeric: tabular-nums;
    font-size: clamp(48px, 12vw, 64px); font-weight: 700; line-height: 1.1;
    color: var(--gold); text-shadow: var(--text-glow-gold);
  }
  .score-value--pending { color: var(--ink-3); text-shadow: none; }
  .score-max { font-size: 17px; color: var(--ink-3); margin-left: 6px; font-family: var(--font-mono); }
  .score-sub { margin-top: 8px; font-size: 13px; color: var(--ink-2); }
  .score-rank { margin-top: 6px; font-size: 13px; font-weight: 700; color: var(--accent); }
  .verdict-row {
    display: flex; align-items: center; justify-content: center; gap: 16px;
    margin-bottom: 20px; text-align: left;
  }
  .rank-badge {
    flex: none; width: 64px; height: 64px;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-mono); font-size: 40px; font-weight: 800;
    border: 2px solid var(--hairline); border-radius: var(--radius-card);
    background: var(--surface-sunken); color: var(--ink-2);
  }
  .rank-badge[data-band="S"] { color: var(--gold); border-color: var(--gold); box-shadow: var(--glow-gold); }
  .rank-badge[data-band="A"] { color: var(--accent); border-color: var(--accent); box-shadow: var(--glow-cyan); }
  .rank-badge[data-band="B"] { color: var(--good); border-color: var(--good); }
  .rank-badge[data-band="C"] { color: var(--ink-2); border-color: var(--hairline); }
  .rank-badge[data-band="X"] { color: var(--critical); border-color: var(--critical); }
  .verdict-copy { min-width: 0; }
  .verdict-title { font-size: 20px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
  .verdict-text { font-size: 14px; color: var(--ink-2); margin-top: 2px; }

  .metric-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-top: 16px; }
  .metric-grid .readout-value { color: var(--ink); text-shadow: none; }
  .charts-col { display: flex; flex-direction: column; gap: 24px; margin-top: 24px; }
  .results-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
  .quality-panel { margin-top: 24px; }
  .quality-panel .chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

  /* ---- history + leaderboard ---- */
  .filter-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
  .seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--hairline); border-radius: var(--radius-ctl); overflow: hidden; }
  .seg button {
    border: none; background: var(--surface); color: var(--ink-2);
    height: 44px; padding: 0 14px; font-size: 13px; font-weight: 600; cursor: pointer;
  }
  .seg button + button { border-left: 1px solid var(--hairline); }
  .seg button[aria-pressed="true"] { background: var(--accent-wash); color: var(--accent); }
  .table-scroll { overflow-x: auto; }

  .lb-sub { margin-top: 4px; }
  .rank-cell { white-space: nowrap; }
  .medal { margin-right: 4px; }
  tr.rank-1 td:first-child { border-left: 3px solid #FFC53D; }
  tr.rank-2 td:first-child { border-left: 3px solid #C7D0E8; }
  tr.rank-3 td:first-child { border-left: 3px solid #D89A5B; }
  tr.row-me { background: var(--accent-wash); }

  @media (max-width: 720px) {
    .view { padding: 16px; }
    .app-header { padding: 0 16px; }
    .arcade-hero .neon-title { font-size: 28px; }
  }
  @media (max-width: 400px) {
    .metric-grid { grid-template-columns: 1fr 1fr; }
    .readout-value { font-size: 26px; }
  }
}

/* Real NeuroSense logo mark in the header (replaces the pixel-coin glyph). */
img.wordmark-glyph { height: 34px; width: auto; display: block; filter: drop-shadow(0 0 6px rgba(42,214,255,.35)); }

/* ================= ADDENDUM v2.4 — polish wave ================= */

@layer components {
  /* ---- header sound toggle ---- */
  .snd-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 36px; min-height: 32px; padding: 0 6px;
    background: var(--surface); color: var(--ink-2); cursor: pointer;
    border: 1px solid var(--hairline); border-radius: var(--radius-ctl);
  }
  .snd-toggle[aria-pressed="true"] { color: var(--accent); background: var(--accent-wash); }
  .snd-toggle[aria-pressed="true"] .snd-slash { display: none; }
  .snd-toggle[aria-pressed="false"] .snd-waves { display: none; }

  /* ---- record banner + best chip (results hero) ---- */
  .record-banner {
    display: inline-block; margin-bottom: 16px; padding: 8px 20px;
    font-size: 17px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
    color: var(--gold); border: 2px solid var(--gold); border-radius: var(--radius-ctl);
    background: var(--warn-wash); text-shadow: var(--text-glow-gold); box-shadow: var(--glow-gold);
    animation: record-pop .4s ease-out;
  }
  @keyframes record-pop { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: scale(1); } }
  .score-best {
    display: inline-block; margin-top: 10px; padding: 3px 12px;
    font-family: var(--font-mono); font-variant-numeric: tabular-nums;
    font-size: 13px; font-weight: 700; letter-spacing: .06em;
    color: var(--ink-2); border: 1px solid var(--hairline); border-radius: 999px;
  }

  /* ---- confetti (JS-generated <i> pieces, no assets) ---- */
  .confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 4; }
  .confetti i {
    position: absolute; top: -16px; left: var(--x);
    width: var(--w); height: calc(var(--w) * 1.6);
    background: var(--c); opacity: 0;
    transform: rotate(var(--r));
    animation: confetti-fall var(--d) linear var(--delay) forwards;
  }
  @keyframes confetti-fall {
    0% { opacity: 1; transform: translateY(0) rotate(var(--r)); }
    100% { opacity: 0; transform: translateY(min(60vh, 420px)) rotate(calc(var(--r) + 540deg)); }
  }
}

@layer views {
  /* ---- home card ⓘ ---- */
  .game-art-row { display: flex; align-items: flex-start; justify-content: space-between; }
  .info-btn {
    min-width: 32px; min-height: 32px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 16px; line-height: 1; cursor: pointer;
    color: var(--ink-2); background: transparent;
    border: 1px solid var(--hairline); border-radius: 999px;
  }
  .info-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-wash); }

  /* ---- how-to-play overlay ---- */
  .howto-backdrop {
    position: fixed; inset: 0; z-index: 40;
    display: flex; align-items: center; justify-content: center;
    background: rgba(5, 8, 18, .78); padding: 16px;
  }
  .howto-card {
    position: relative; width: min(92vw, 460px); max-height: 90vh; overflow-y: auto;
    background: var(--surface); border: 2px solid var(--hairline);
    border-radius: var(--radius-card); box-shadow: var(--shadow-card);
    padding: 24px; display: flex; flex-direction: column; gap: 12px;
  }
  .howto-close {
    position: absolute; top: 10px; right: 10px;
    min-width: 36px; min-height: 36px; cursor: pointer;
    background: transparent; color: var(--ink-2);
    border: 1px solid var(--hairline); border-radius: var(--radius-ctl);
  }
  .howto-close:hover { color: var(--ink); border-color: var(--accent); }
  .howto-kicker { margin: 0; }
  .howto-name { font-size: 22px; }
  .howto-line { color: var(--ink-2); font-size: 14px; }
  .howto-line--2 { color: var(--ink-3); font-size: 13px; }
  .howto-dontshow {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; color: var(--ink-2); cursor: pointer;
  }
  .howto-dontshow input { width: 18px; height: 18px; accent-color: var(--accent); }
  .howto-start { align-self: stretch; height: 48px; text-transform: uppercase; letter-spacing: .08em; }

  /* CSS-art motion demos (divs only; global reduced-motion rule freezes them) */
  .howto-demo {
    position: relative; height: 110px; overflow: hidden;
    background: var(--surface-sunken); border: 1px solid var(--hairline);
    border-radius: var(--radius-ctl);
  }
  .hd-dot { position: absolute; top: 50%; width: 26px; height: 26px; border-radius: 999px; margin-top: -13px; }
  .hd-thumb { left: 26%; background: var(--accent); animation: hd-pinch-l 1s ease-in-out infinite; }
  .hd-finger { right: 26%; background: var(--accent-2); animation: hd-pinch-r 1s ease-in-out infinite; }
  @keyframes hd-pinch-l { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(34px); } }
  @keyframes hd-pinch-r { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(-34px); } }
  .hd-palm {
    position: absolute; left: 50%; top: 50%; width: 44px; height: 58px;
    margin: -29px 0 0 -22px; border-radius: 10px 10px 6px 6px;
    background: var(--accent); border: 2px solid rgba(5, 18, 23, .4);
  }
  .hd-steady { animation: hd-shiver 2.4s ease-in-out infinite; }
  @keyframes hd-shiver { 0%, 100% { transform: translate(0, 0); } 30% { transform: translate(1px, -1px); } 65% { transform: translate(-1px, 1px); } }
  .hd-ring {
    position: absolute; left: 50%; top: 50%; width: 82px; height: 82px;
    margin: -41px 0 0 -41px; border-radius: 999px;
    border: 2px dashed var(--good); animation: hd-ring-pulse 2.4s ease-in-out infinite;
  }
  @keyframes hd-ring-pulse { 0%, 100% { opacity: .35; } 50% { opacity: .9; } }
  .hd-fist {
    position: absolute; left: 50%; top: 50%; width: 62px; height: 62px;
    margin: -31px 0 0 -31px; border-radius: 999px;
    background: var(--accent-2); animation: hd-openclose 1.1s ease-in-out infinite;
  }
  @keyframes hd-openclose { 0%, 100% { transform: scale(1); border-radius: 34%; } 50% { transform: scale(.55); border-radius: 999px; } }
  .hd-screen {
    position: absolute; inset: 12px; border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    background: var(--plane); animation: hd-flash-bg 2.6s steps(1) infinite;
  }
  .hd-go {
    font-family: var(--font-mono); font-weight: 800; font-size: 34px; letter-spacing: .1em;
    color: var(--accent-ink); opacity: 0; animation: hd-flash-txt 2.6s steps(1) infinite;
  }
  @keyframes hd-flash-bg { 0%, 64% { background: var(--plane); } 65%, 90% { background: var(--gold); } 91%, 100% { background: var(--plane); } }
  @keyframes hd-flash-txt { 0%, 64% { opacity: 0; } 65%, 90% { opacity: 1; } 91%, 100% { opacity: 0; } }
  .hd-flip { animation: hd-flip 1.2s ease-in-out infinite alternate; }
  @keyframes hd-flip {
    0% { transform: perspective(220px) rotateY(0deg); background: var(--accent); }
    49.9% { background: var(--accent); }
    50% { transform: perspective(220px) rotateY(90deg); background: var(--accent-2); }
    100% { transform: perspective(220px) rotateY(180deg); background: var(--accent-2); }
  }
  .hd-target {
    position: absolute; left: 50%; top: 50%; width: 30px; height: 30px;
    margin: -15px 0 0 -15px; border-radius: 999px;
    border: 3px solid var(--gold); animation: hd-orbit 3s linear infinite;
  }
  .hd-chaser {
    position: absolute; left: 50%; top: 50%; width: 14px; height: 14px;
    margin: -7px 0 0 -7px; border-radius: 999px;
    background: var(--accent); animation: hd-orbit 3s linear infinite; animation-delay: -2.88s;
  }
  @keyframes hd-orbit {
    0% { transform: translate(-70px, 0); }
    25% { transform: translate(0, -26px); }
    50% { transform: translate(70px, 0); }
    75% { transform: translate(0, 26px); }
    100% { transform: translate(-70px, 0); }
  }

  /* ---- science page ---- */
  .sci-sub { margin-top: 12px; color: var(--ink-2); font-size: 15px; max-width: 640px; margin-left: auto; margin-right: auto; }
  .sci-games-title { font-size: 20px; }
  .sci-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px; margin-top: 16px;
  }
  .sci-game { border-top: 3px solid var(--card-accent, var(--accent)); }
  .sci-game .card-title { text-transform: uppercase; letter-spacing: .1em; }
  .sci-label { margin-top: 14px; }
  .sci-body { color: var(--ink-2); font-size: 14px; margin-top: 8px; }
  .sci-formula {
    margin-top: 8px; padding: 10px 12px; font-size: 13px; color: var(--accent);
    background: var(--surface-sunken); border: 1px solid var(--hairline);
    border-radius: var(--radius-ctl); overflow-x: auto;
  }
}
