/* === Game area — Nintendo 2001 chrome ===
 * Loaded after /assets/site.css by game-area pages (/games/, /game/,
 * /games/riichi/, /games/yesno/, and the 401 page in server.js /
 * middleware.js). Overrides the Notion tokens on these pages and adds
 * the beveled-plate, carbon-nav, halftone-textured chrome of the 2001
 * Nintendo.com design language.
 *
 * Readability on iPhone is preserved by collapsing the dual nav into a
 * single carbon bar, stacking all panels vertically, and keeping every
 * button ≥44px tall with a 16px+ input font (no iOS zoom). */

/* ---------- tokens ---------- */

:root {
  /* Carbon / chrome / surface — the chassis the page is built from */
  --paper: #7A8ABA;            /* periwinkle canvas body */
  --ink: #21242E;               /* carbon navy (text on light) */
  --ink-soft: #3D4F97;          /* chrome indigo (secondary text / chrome labels) */
  --surface: #FFFFFF;
  --line: #C8CCDC;              /* bevel seam, light enough to show on periwinkle */

  --carbon: #21242E;            /* command slab */
  --carbon-deep: #16181F;
  --canvas-soft: #9FBEE7;       /* pale sky — subnav / inset panels */
  --periwinkle: #8BA1D4;        /* raised mid panel */
  --platinum: #DEDEDE;          /* list-row / inset surface */
  --lavender: #ACACE7;          /* hero field */
  --chrome: #3D4F97;            /* bevel border / shadow line */
  --muted-indigo: #60619C;      /* inactive tab / recessed chrome */
  --on-primary: #FFFFFF;

  /* Brand & signal — rationed warmth, used only for wayfinding */
  --primary: #E60012;           /* Nintendo Red — brand only */
  --signal: #F68D1F;            /* Signal Orange — forward / Submit */
  --amber: #ECAB37;             /* Amber — utility chips, badges */
  --gold: #E48600;              /* Nav Gold — top nav words */

  --plum: var(--signal);        /* alias used by legacy selectors */
  --mint: var(--amber);
  --honey: var(--amber);
  --honey-ink: #B2770F;

  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Noto Serif SC", "Source Han Serif SC", serif;
  --sans: Arial, "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", sans-serif;

  --radius-xs: 2px;
  --radius-s: 4px;
  --radius-m: 6px;
  --radius-l: 10px;
  --radius-pill: 9999px;

  /* Beveled plate shadow vocabulary — physical bevel, not blurred drop-shadow.
     Every region reads as a stamped injection-molded plastic plate. */
  --bevel-inset: inset 0 1px 0 rgba(255, 255, 255, 0.55),
                 inset 0 -1px 0 rgba(61, 79, 151, 0.5);
  --bevel-shadow: 0 1px 2px rgba(33, 36, 46, 0.25);

  --shadow-card: var(--bevel-inset), var(--bevel-shadow);
  --shadow-card-hover: inset 0 1px 0 rgba(255, 255, 255, 0.65),
                       inset 0 -1px 0 rgba(61, 79, 151, 0.55),
                       0 4px 10px rgba(33, 36, 46, 0.30);

  /* Shared button chrome. .btn uses signal (Submit / forward);
     .btn-secondary uses amber (utility / continue). */
  --btn-primary-bg: var(--signal);
  --btn-primary-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55),
                        inset 0 -2px 0 rgba(0, 0, 0, 0.20),
                        0 2px 4px rgba(33, 36, 46, 0.30);
  --btn-secondary-bg: var(--amber);
  --btn-secondary-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55),
                          inset 0 -2px 0 rgba(0, 0, 0, 0.18),
                          0 2px 4px rgba(33, 36, 46, 0.25);
  --ghost-line: var(--chrome);
  --ghost-text: var(--ink-soft);

  --ease-pop: cubic-bezier(0.22, 0.9, 0.3, 1);
}

/* ---------- base ---------- */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font: 13px/1.4 var(--sans);
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* Skip link. Same skip semantics, retinted for the chrome. */
.skip {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 1000;
  padding: 8px 14px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--chrome);
  border-radius: var(--radius-xs);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  text-decoration: none;
}
.skip:focus-visible {
  left: 12px;
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

a { color: var(--gold); }
a:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ---------- 401 page (server.js / middleware.js) ---------- */

.wrap {
  min-height: calc(100vh - 88px);
  min-height: calc(100dvh - 88px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.wrap .card {
  background: var(--surface);
  border: 1px solid var(--chrome);
  border-radius: var(--radius-m);
  padding: 24px 20px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-card);
}

.wrap .card h1 {
  font-family: "Arial Black", Arial, sans-serif;
  font-size: 22px;
  font-weight: 900;
  margin: 0 0 6px;
  color: var(--ink);
  letter-spacing: 0;
  text-transform: uppercase;
}

.wrap .card p {
  color: var(--ink-soft);
  margin: 0 0 16px;
  font-size: 13px;
}

/* ---------- top nav bar — carbon slab with halftone-dot texture ----------
   The original 2001 chrome: near-black bar with a faint dot-matrix
   speaker-grille pattern, nav words in nav-gold uppercase Arial, and
   a white logo-pill at the left. On mobile the dual bars collapse to
   a single carbon bar. */

.n-nav {
  background-color: var(--carbon);
  /* Halftone-dot matrix — a 6px grid of 1px near-white dots over carbon. */
  background-image: radial-gradient(circle at 1px 1px,
                       rgba(255, 255, 255, 0.08) 1px,
                       transparent 1.4px);
  background-size: 6px 6px;
  color: var(--gold);
  border-bottom: 2px solid var(--carbon-deep);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  min-height: 44px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  -webkit-tap-highlight-color: transparent;
  /* The nav sits above the game overlay stack (which uses z-index:100)
     so users can navigate away even while a menu is showing. */
  position: relative;
  z-index: 110;
}

.n-subnav {
  position: relative;
  z-index: 110;
}

.n-logo {
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--chrome);
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  font-family: "Arial Black", Arial, sans-serif;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0;
  text-decoration: none;
  flex: 0 0 auto;
}
.n-logo:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.n-link {
  color: var(--gold);
  text-decoration: none;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  min-height: 32px;
  display: inline-flex;
  align-items: center;
}
.n-link:hover { color: var(--surface); border-color: var(--muted-indigo); }
.n-link[aria-current="page"] {
  color: var(--carbon);
  background: var(--amber);
  border-color: var(--carbon-deep);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5),
              inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}

.n-title {
  color: var(--surface);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.n-tag {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  background: var(--amber);
  color: var(--carbon);
  padding: 4px 8px;
  border: 1px solid var(--carbon-deep);
  border-radius: var(--radius-xs);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.n-back {
  margin-left: auto;
  color: var(--canvas-soft);
  text-decoration: none;
  padding: 8px 10px;
  border: 1px solid var(--muted-indigo);
  border-radius: var(--radius-xs);
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.n-back:hover { color: var(--surface); border-color: var(--gold); }
.n-back:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* On narrow phones the tag drops; the back link is the primary escape. */
@media (max-width: 540px) {
  .n-tag { display: none; }
}

/* Subnav strip — pale-sky utility row (Parents · Customer Service · etc.).
   On phones it collapses to a single horizontal scroll row. */

.n-subnav {
  background: var(--canvas-soft);
  border-bottom: 1px solid var(--chrome);
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  position: relative;
  z-index: 110;
}
.n-subnav a {
  color: var(--ink);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}
.n-subnav a:hover { background: var(--periwinkle); color: var(--ink); }
.n-subnav a[aria-current="page"] {
  background: var(--ink);
  color: var(--canvas-soft);
}

@media (max-width: 540px) {
  .n-subnav { padding: 4px 8px; }
}

/* ---------- hero plate (games selection) ----------
   Beveled lavender field with outlined display wordmark + signal CTA. */

.n-hero {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.10) 0%, rgba(0, 0, 0, 0.08) 100%),
    var(--lavender);
  border: 1px solid var(--chrome);
  border-radius: var(--radius-m);
  padding: 22px 18px;
  margin: 18px 12px;
  display: grid;
  gap: 14px;
  box-shadow: var(--shadow-card);
  position: relative;
}

.n-hero-title {
  margin: 0;
  font-family: "Arial Black", Arial, sans-serif;
  font-weight: 900;
  font-size: clamp(28px, 8vw, 40px);
  line-height: 1;
  letter-spacing: 0;
  color: var(--surface);
  text-transform: uppercase;
  -webkit-text-stroke: 1px var(--ink);
  text-shadow:
    2px 2px 0 var(--ink),
    3px 3px 0 rgba(0, 0, 0, 0.4);
}

.n-hero-tagline {
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0;
}

.n-hero .n-btn { justify-self: start; }

/* ---------- entry list (games selection) ---------- */

.n-entries {
  display: grid;
  gap: 10px;
  padding: 0 12px 18px;
  margin: 0;
  list-style: none;
}

.n-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--chrome);
  border-radius: var(--radius-s);
  padding: 14px 16px;
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow-card);
  -webkit-tap-highlight-color: transparent;
  min-height: 60px;
}
.n-entry:hover {
  background: var(--platinum);
  border-color: var(--carbon);
  box-shadow: var(--shadow-card-hover);
}
.n-entry:active { transform: translateY(1px); }

.n-entry-text {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  gap: 2px;
}
.n-entry-title {
  font-family: "Arial Black", Arial, sans-serif;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.2;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0;
}
.n-entry-desc {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.3;
}

.n-entry-arrow {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--signal);
  color: var(--on-primary);
  border: 1px solid var(--carbon-deep);
  border-radius: var(--radius-pill);
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

/* ---------- footer bar (carbon slab) ---------- */

.n-footer {
  background: var(--carbon);
  background-image: radial-gradient(circle at 1px 1px,
                       rgba(255, 255, 255, 0.06) 1px,
                       transparent 1.4px);
  background-size: 6px 6px;
  color: var(--canvas-soft);
  padding: 18px 16px;
  border-top: 2px solid var(--carbon-deep);
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0;
  text-align: center;
}

/* ---------- main shared button system ----------
   Marketing CTAs are pill; on this chrome they're a solid signal-orange
   beveled plate. .btn-secondary is amber (utility / secondary action).
   .btn-ghost is a quiet transparent utility with chrome border. */

.btn, .btn-secondary, .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 12px 22px;
  border: 1px solid var(--carbon-deep);
  border-radius: var(--radius-xs);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  line-height: 1;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: filter .12s ease, transform .12s var(--ease-pop);
}

.btn {
  background: var(--btn-primary-bg);
  color: var(--on-primary);
  box-shadow: var(--btn-primary-shadow);
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(0.97); }

.btn-secondary {
  background: var(--btn-secondary-bg);
  color: var(--carbon);
  box-shadow: var(--btn-secondary-shadow);
}
.btn-secondary:hover { filter: brightness(1.05); }
.btn-secondary:active { transform: scale(0.97); }

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--chrome);
  box-shadow: none;
  font-size: 11px;
  min-height: 36px;
  padding: 8px 14px;
}
.btn-ghost:hover { color: var(--ink); border-color: var(--carbon); }
.btn-ghost:active { transform: scale(0.97); }

/* ---------- mini pages (/games/, /games/riichi/, /games/yesno/) ---------- */

.mini {
  max-width: 760px;
  margin: 0 auto;
  padding: 18px 14px 32px;
}

.mini-head {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--chrome);
  border-radius: var(--radius-s);
  padding: 10px 14px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-card);
}

.mini-head a {
  color: var(--ink);
  text-decoration: none;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 6px 8px;
  border: 1px solid var(--chrome);
  border-radius: var(--radius-xs);
  white-space: nowrap;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
}
.mini-head a:hover { background: var(--platinum); border-color: var(--carbon); }

.mini h1 {
  font-family: "Arial Black", Arial, sans-serif;
  font-size: clamp(22px, 6vw, 28px);
  font-weight: 900;
  line-height: 1;
  color: var(--ink);
  margin: 0;
  letter-spacing: 0;
  text-transform: uppercase;
  flex: 1;
  min-width: 0;
}

.mini .lead {
  color: var(--ink-soft);
  font-size: 13px;
  margin: 4px 0 14px;
}

.mini-card {
  background: var(--surface);
  border: 1px solid var(--chrome);
  border-radius: var(--radius-m);
  padding: 18px 16px;
  box-shadow: var(--shadow-card);
}

.mini-meta {
  color: var(--ink-soft);
  font-size: 12px;
  margin-bottom: 10px;
}

.mini-prompt {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 12px;
  white-space: pre-line;
  color: var(--ink);
}

.mini h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 22px;
  line-height: 1.2;
  margin: 0 0 10px;
  color: var(--ink);
}

.tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin: 12px 0 18px;
}
.tile {
  width: clamp(27px, 7vw, 42px);
  height: clamp(38px, 9.8vw, 59px);
  flex: none;
}

.choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.choice {
  min-height: 56px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--chrome);
  border-radius: var(--radius-s);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-card);
  -webkit-tap-highlight-color: transparent;
}
.choice:hover { background: var(--platinum); }
.choice[aria-pressed="true"] {
  border-color: var(--carbon);
  background: var(--canvas-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45),
              0 0 0 2px var(--signal);
}
.choice:disabled { opacity: .6; cursor: default; }

.mini button:disabled { cursor: default; opacity: .55; }

.mini-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.mini-note {
  min-height: 1.4em;
  margin: 12px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  white-space: pre-wrap;
}
.mini-note.good { color: #1F6B45; font-weight: 700; }
.mini-note.bad { color: #B8324A; font-weight: 700; }

.mini-source {
  font-size: 11px;
  color: var(--ink-soft);
  margin-top: 18px;
}
.mini-source a { overflow-wrap: anywhere; color: var(--gold); }

.mini-input {
  width: 100%;
  min-height: 44px;
  font: inherit;
  font-size: 16px;       /* iOS-safe: prevents auto-zoom */
  padding: 10px 12px;
  border: 1px solid var(--chrome);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--ink);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08);
}
.mini-input:focus {
  outline: none;
  border-color: var(--carbon);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08),
              0 0 0 2px var(--gold);
}

.mini-form {
  display: flex;
  gap: 8px;
  margin: 10px 0 16px;
}
.mini-form .mini-input { min-width: 0; }
.mini-form button {
  flex: none;
  padding: 10px 16px;
  font-size: 13px;
}

.history {
  list-style: none;
  padding: 0;
  margin: 14px 0;
  background: var(--platinum);
  border: 1px solid var(--chrome);
  border-radius: var(--radius-s);
}
.history li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink);
}
.history li:last-child { border-bottom: none; }
.history li span {
  flex: none;
  font-weight: 700;
  color: var(--ink-soft);
}

@media (max-width: 540px) {
  .choices { grid-template-columns: 1fr 1fr; }
  .mini-form { align-items: stretch; }
}

/* ---------- /game/ (消消乐) — HUD, items, overlays, footer buttons ---------- */

body:has(#canvas-wrap) {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 0;
  padding-top: env(safe-area-inset-top);
  padding-bottom: 0;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

/* The nav + page footer span the full width; #main is a vertical flex
   column that centers its children horizontally and stretches to fill
   the available height so the canvas-wrap can flex-1. */
body:has(#canvas-wrap) > .n-nav,
body:has(#canvas-wrap) > .n-footer { align-self: stretch; }
body:has(#canvas-wrap) > #main {
  flex: 1 1 auto;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 0;
}

#header,
#ol-header {
  width: calc(100% - 24px);
  max-width: 420px;
  padding: 12px 14px;
  margin-top: 12px;
  background: var(--surface);
  border: 1px solid var(--chrome);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-card);
}
#ol-header { display: none; margin-top: 12px; padding: 10px 12px; }
#header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.stat { text-align: center; flex: 1 1 0; min-width: 0; }
.stat-label {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-soft);
  letter-spacing: 0;
  text-transform: uppercase;
  white-space: nowrap;
}
.stat-value {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 900;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  letter-spacing: -0.06em;
  white-space: nowrap;
}
#score-val { color: var(--honey-ink); }
#moves-val { color: #1F6B45; }
#level-val { color: var(--ink); }

#progress-wrap {
  width: calc(100% - 24px);
  max-width: 420px;
  padding: 0;
  margin: 8px 0 0;
}
#progress-bar {
  height: 6px;
  background: rgba(33, 36, 46, 0.18);
  border: 1px solid var(--chrome);
  border-radius: 3px;
  overflow: hidden;
}
#progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #1F6B45, var(--honey-ink));
  transition: width .3s;
}

#canvas-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
  width: calc(100% - 24px);
  max-width: 420px;
  margin: 0 12px;
}
/* Canvas chrome is preserved as the surrounding bevel. Don't touch the
   actual rendering. */
canvas {
  display: block;
  border-radius: var(--radius-l);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

#combo-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: "Arial Black", Arial, sans-serif;
  font-size: 32px;
  font-weight: 900;
  color: var(--honey-ink);
  -webkit-text-stroke: 1px var(--carbon);
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
  z-index: 10;
}

#items-bar {
  width: calc(100% - 24px);
  max-width: 420px;
  padding: 0;
  margin: 4px auto 0;
  display: flex;
  justify-content: center;
  gap: 8px;
}
.item-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--amber);
  color: var(--carbon);
  border: 1px solid var(--carbon-deep);
  border-radius: var(--radius-pill);
  padding: 9px 14px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  cursor: pointer;
  min-height: 44px;
  line-height: 1.1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5),
              inset 0 -2px 0 rgba(0, 0, 0, 0.18),
              0 2px 4px rgba(33, 36, 46, 0.25);
  transition: transform .12s var(--ease-pop), background .12s, border-color .12s, box-shadow .12s;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.item-btn:active { transform: scale(0.96); background: var(--gold); }
.item-btn.active-item {
  background: var(--signal);
  color: var(--on-primary);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5),
              inset 0 -2px 0 rgba(0, 0, 0, 0.20),
              0 0 0 3px rgba(246, 141, 31, 0.25);
}
.item-btn .item-icon { font-size: 16px; }
.item-btn .item-count {
  background: var(--carbon);
  color: var(--amber);
  border-radius: var(--radius-pill);
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.item-btn.empty { opacity: .45; cursor: default; }
.item-btn:disabled { opacity: .45; cursor: default; }

/* Footer utility buttons (sound / pause / hint). */
#footer {
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
  justify-content: center;
}
#footer button {
  background: var(--signal);
  color: var(--on-primary);
  border: 1px solid var(--carbon-deep);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
  min-height: 44px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5),
              inset 0 -2px 0 rgba(0, 0, 0, 0.20),
              0 2px 4px rgba(33, 36, 46, 0.25);
  transition: filter .12s ease, transform .12s var(--ease-pop);
}
#footer button:hover { filter: brightness(1.06); }
#footer button:active { transform: scale(0.96); }
#footer button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.btn:focus-visible, .btn-ghost:focus-visible, .item-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ---------- overlays (menu, map, level clear, over, pause, online) ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(122, 138, 186, 0.78);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 16px;
}
.overlay.active { opacity: 1; pointer-events: auto; }

.overlay h1 {
  font-family: var(--sans);
  font-size: 40px;
  margin: 0 0 8px;
  line-height: 1;
}
.overlay h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 26px;
  margin: 0 0 6px;
  color: var(--ink);
  letter-spacing: .02em;
}
.overlay p {
  font-size: 14px;
  color: var(--ink-soft);
  margin: 0 0 18px;
  text-align: center;
}
.overlay .sub {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0 0 14px;
  text-align: center;
}

.stars-display {
  font-size: 28px;
  margin: 0 0 10px;
  letter-spacing: 4px;
  text-align: center;
}
.reward-text {
  font-size: 13px;
  color: #1F6B45;
  margin: 0 0 12px;
  text-align: center;
  font-weight: 700;
}

/* ---------- map overlay (level select) ---------- */

#map-overlay { overflow: hidden; }
#map-container {
  width: 100%;
  max-width: 420px;
  height: 70vh;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 18px 0;
  scrollbar-width: none;
}
#map-container::-webkit-scrollbar { display: none; }
#map-title {
  font-family: "Arial Black", Arial, sans-serif;
  font-weight: 900;
  font-size: 22px;
  margin: 0 0 8px;
  text-align: center;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--ink);
}
#map-stats {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0 0 14px;
  text-align: center;
  font-weight: 700;
}
#map-nodes {
  position: relative;
  width: 100%;
  min-height: 100px;
}
.map-node {
  position: absolute;
  left: 50%;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s, background .12s, color .12s, border-color .12s;
  font-weight: 900;
  font-size: 18px;
  border: 3px solid var(--chrome);
  background: var(--surface);
  color: var(--ink);
  padding: 0;
  font-family: "Arial Black", Arial, sans-serif;
  line-height: 1.1;
  transform: translate(-50%, 0);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55),
              inset 0 -2px 0 rgba(61, 79, 151, 0.4),
              0 2px 4px rgba(33, 36, 46, 0.25);
}
.map-node:active { transform: translate(-50%, 0) scale(0.92); }
.map-node:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
.map-node.unlocked {
  background: var(--amber);
  color: var(--carbon);
  border-color: var(--carbon-deep);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5),
              inset 0 -2px 0 rgba(0, 0, 0, 0.2),
              0 4px 14px rgba(236, 171, 55, 0.4);
}
.map-node.current {
  background: var(--signal);
  color: var(--on-primary);
  border-color: var(--carbon-deep);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5),
              inset 0 -2px 0 rgba(0, 0, 0, 0.2),
              0 0 0 3px rgba(246, 141, 31, 0.25),
              0 4px 18px rgba(246, 141, 31, 0.45);
  animation: pulse 1.5s infinite;
}
.map-node.locked {
  background: var(--surface);
  border-color: var(--muted-indigo);
  color: rgba(61, 79, 151, 0.55);
  cursor: default;
}
.map-node:disabled { cursor: default; opacity: 1; }
.map-node .node-stars {
  font-size: 9px;
  margin-top: 2px;
  letter-spacing: 1px;
  font-family: var(--sans);
}
.map-line {
  position: absolute;
  left: 50%;
  width: 2px;
  background: var(--muted-indigo);
  transform: translateX(-50%);
}
.map-line.active { background: var(--amber); }
#map-back {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 2;
  margin-top: 0;
  padding: 8px 14px;
  font-size: 12px;
  min-height: 44px;
}

/* ---------- online play HUD ---------- */

.ol-scores {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.ol-p {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  padding: 8px 6px;
  border-radius: var(--radius-s);
  background: var(--platinum);
  border: 1px solid var(--chrome);
  transition: background .3s, box-shadow .3s, color .3s;
}
.ol-p .ol-name { font-size: 11px; color: var(--ink-soft); font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; }
.ol-p .ol-pts {
  font-size: 24px;
  font-weight: 900;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.ol-p .ol-left { font-size: 11px; margin-top: 4px; color: var(--ink-soft); }
.ol-vs {
  font-family: "Arial Black", Arial, sans-serif;
  font-size: 14px;
  font-weight: 900;
  color: rgba(33, 36, 46, 0.35);
}
.ol-scores.turn-0 .ol-p:first-child {
  background: var(--canvas-soft);
  box-shadow: 0 0 0 2px #1F6B45;
}
.ol-scores.turn-0 .ol-p:first-child .ol-pts,
.ol-scores.turn-0 .ol-p:first-child .ol-left { color: #1F6B45; }
.ol-scores.turn-1 .ol-p:last-child {
  background: rgba(220, 38, 38, 0.10);
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.25);
}
.ol-scores.turn-1 .ol-p:last-child .ol-pts,
.ol-scores.turn-1 .ol-p:last-child .ol-left { color: #B8324A; }
.ol-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
}
.ol-round, .ol-steps-left {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--chrome);
  padding: 6px 10px;
  border-radius: var(--radius-pill);
}
.ol-status {
  font-size: 11px;
  text-align: center;
  margin-top: 6px;
  color: #1F6B45;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.room-code-display {
  font-family: "Arial Black", Arial, sans-serif;
  font-size: 36px;
  font-weight: 900;
  letter-spacing: 10px;
  color: var(--carbon);
  margin: 12px 0;
  -webkit-text-stroke: 1px var(--chrome);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.10);
}
.room-input {
  background: var(--surface);
  border: 2px solid var(--chrome);
  border-radius: var(--radius-s);
  color: var(--ink);
  font-family: "Arial Black", Arial, sans-serif;
  font-size: 26px;
  font-weight: 900;
  text-align: center;
  letter-spacing: 8px;
  padding: 10px 16px;
  width: 200px;
  outline: none;
  caret-color: var(--signal);
}
.room-input:focus {
  border-color: var(--carbon);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.10), 0 0 0 3px rgba(246, 141, 31, 0.35);
}
.room-input::placeholder {
  color: rgba(33, 36, 46, 0.30);
  letter-spacing: 4px;
  font-size: 16px;
  font-weight: 700;
}
.room-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  width: 200px;
  color: var(--ink-soft);
}
.room-divider::before, .room-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--chrome);
}
.room-divider span { font-size: 12px; color: var(--ink-soft); font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; }

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(33, 36, 46, 0.15);
  border-top-color: var(--carbon);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 12px auto 8px;
}

/* cap-note + spinner-inline used by yesno page */
.cap-note {
  margin: -8px 0 12px;
  font-size: 12px;
  color: var(--ink-soft);
  min-height: 1.2em;
}
.cap-note.warn { color: #B8324A; font-weight: 700; }
.spinner-inline {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(33, 36, 46, 0.18);
  border-top-color: var(--signal);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}
.btn .spinner {
  display: none;
  width: 14px; height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin-right: 6px;
  vertical-align: -2px;
}
.btn.pending .spinner { display: inline-block; }
.btn.pending { cursor: default; }
.btn:disabled, .btn-secondary:disabled { cursor: default; }

@keyframes popIn {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1 }
  50% { transform: translate(-50%, -50%) scale(1.3); opacity: 1 }
  100% { transform: translate(-50%, -50%) scale(1) translateY(-40px); opacity: 0 }
}
@keyframes pulse {
  0%, 100% { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5),
                       inset 0 -2px 0 rgba(0, 0, 0, 0.2),
                       0 0 0 3px rgba(246, 141, 31, 0.25),
                       0 4px 18px rgba(246, 141, 31, 0.45) }
  50% { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5),
                 inset 0 -2px 0 rgba(0, 0, 0, 0.2),
                 0 0 0 3px rgba(246, 141, 31, 0.45),
                 0 4px 26px rgba(246, 141, 31, 0.70) }
}
@keyframes spin { to { transform: rotate(360deg) } }

@media (prefers-reduced-motion: reduce) {
  .map-node.current, .spinner, .spinner-inline, .btn .spinner { animation: none; }
}

@media (prefers-color-scheme: dark) {
  /* Carbon chrome already reads correctly on dark; no inversion needed. */
}

/* ===== Game-area stage UI (issue #11 R2 sync) =====================
 * Shared chrome for /game/, /games/riichi/, /games/yesno/. Reuses
 * the Nintendo 2001 tokens above (--carbon / --amber / --gold /
 * --surface / --chrome). These rules add:
 *   - stage-head / stage-kicker / brand / stage-count / stage-dots
 *     (uniform header for L1 / L2 / L3)
 *   - dossier-card / dossier-title / dossier-rule (the unified
 *     question panel shared by all three games)
 *   - mahjong tile / hand / discard / choice UI for L2
 *   - L3 dossier rules / q-history / reveal animation
 * ================================================================= */

.stage-head {
  text-align: center;
  margin: 22px auto 14px;
  max-width: 480px;
  padding: 0 18px;
}
.stage-kicker {
  margin: 0;
  color: var(--amber);
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 4px;
  text-transform: uppercase;
}
.stage-head .brand {
  margin: 4px 0 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 32px;
  letter-spacing: 2px;
  text-align: center;
}
.stage-count {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 2px;
}
.stage-count strong {
  color: var(--signal);
  font-weight: 700;
}
.stage-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 18px;
  margin: 8px auto 0;
}
.stage-dot {
  width: 9px;
  height: 9px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--platinum);
  cursor: pointer;
  appearance: none;
}
.stage-dot.is-complete { background: var(--amber); }
.stage-dot.is-failed {
  background: transparent;
  box-shadow: inset 0 0 0 2px var(--ink-soft);
}
.stage-dot.is-current {
  width: 11px;
  height: 11px;
  background: var(--signal);
}
.stage-dot:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.dossier-card {
  border: 1px solid var(--chrome);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  padding: 18px 18px 20px;
  margin: 0 auto;
  max-width: 480px;
}
.dossier-title {
  margin: 0;
  color: var(--amber);
  text-align: center;
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.dossier-rule {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0 18px;
  color: var(--gold);
}
.dossier-rule::before,
.dossier-rule::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.frame {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 14px 18px calc(24px + env(safe-area-inset-bottom));
}

.q-card .dossier-rule { margin: 12px 0 18px; }
.q-card .dossier-title { color: var(--amber); margin: 0; }
.q-prompt {
  font-size: 14px;
  line-height: 1.55;
  margin: 4px 0 12px;
  white-space: pre-wrap;
  color: var(--ink);
}

/* ---------- mahjong tiles (vendored CC0 SVG, 30x40 display size) ---------- */
.q-situation {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
  align-items: start;
  font-size: 12px;
  margin-bottom: 10px;
}
.q-situation .badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--platinum);
  color: var(--ink);
  font-weight: 600;
  letter-spacing: 0.5px;
  font-size: 11px;
  line-height: 1;
}
.q-situation .badge.dealer {
  background: var(--amber);
  color: var(--carbon);
}
.q-situation .badge.self {
  background: var(--signal);
  color: var(--carbon);
}
.q-situation .row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.q-situation .row .pair {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}
.q-situation .mini {
  color: var(--ink-soft);
  font-size: 11px;
  letter-spacing: 1px;
}
.q-scores {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  margin: 8px 0 10px;
  padding: 8px 10px;
  background: var(--platinum);
  border-radius: 8px;
  font-size: 12px;
}
.q-scores .seat {
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--ink);
}
.q-scores .pts {
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}
.q-scores .row.self {
  background: rgba(246, 141, 31, 0.10);
  border-radius: 6px;
  padding: 2px 6px;
  margin: 0 -6px;
}
.q-scores .row.self .seat { color: var(--signal); }
.q-scores .row.self .pts { color: var(--signal); font-weight: 700; }
.q-dora {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 12px;
}
.q-dora .label {
  letter-spacing: 1px;
  color: var(--ink-soft);
}
.q-dora .tile {
  width: 32px;
  height: 43px;
}

.q-hand {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 8px 6px;
  background: var(--platinum);
  border-radius: 10px;
  margin-top: 8px;
  align-items: flex-end;
}
.q-hand .tile {
  width: 28px;
  height: 37px;
  border-radius: 3px;
  object-fit: contain;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.10);
}
.q-hand .tile.draw {
  margin-left: 10px;
  position: relative;
}
.q-hand .tile.draw::after {
  content: "";
  position: absolute;
  left: -7px;
  top: 6px;
  bottom: 6px;
  border-left: 1px dashed var(--ink-soft);
  opacity: 0.5;
}
.q-melds {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  font-size: 12px;
}
.q-meld {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  background: rgba(236, 171, 55, 0.18);
  border-radius: 8px;
  padding: 4px 6px;
  font-size: 11px;
  color: var(--ink-soft);
}
.q-meld .row {
  display: flex;
  gap: 2px;
}
.q-meld .tile {
  width: 20px;
  height: 26px;
  object-fit: contain;
  background: #fff;
  border-radius: 2px;
}
.q-meld .row .tile.called {
  outline: 2px solid var(--signal);
  outline-offset: 0;
}
.q-meld .kind {
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 1px;
}

.q-rivers {
  display: grid;
  gap: 6px;
  margin: 10px 0;
}
/* The situation block is a 2-column grid — the rivers span both. */
.q-situation .q-rivers,
.q-situation .q-omelds {
  grid-column: 1 / -1;
}
.q-river {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 6px;
  align-items: center;
  background: var(--platinum);
  border-radius: 8px;
  padding: 6px 8px;
}
.q-river.self {
  background: rgba(246, 141, 31, 0.10);
}
.q-river .who {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--ink);
}
.q-river.self .who { color: var(--signal); }
.q-river .tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  min-width: 0;
  margin: 0;
}
.q-river .discard {
  width: 20px;
  height: 27px;
  object-fit: contain;
  border-radius: 2px;
  background: #fff;
}
.q-river .discard.riichi-declare {
  outline: 2px solid var(--signal);
  outline-offset: 1px;
}
.q-river .riichi {
  position: relative;
  display: inline-block;
  line-height: 0;
}
.q-river .riichi .flag {
  position: absolute;
  top: -5px;
  right: -4px;
  background: var(--signal);
  color: var(--carbon);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  padding: 2px 3px;
  border-radius: 4px;
}
.q-river .empty {
  color: var(--ink-soft);
  font-size: 11px;
}
/* Other players' melds (副露) — shown under the rivers when present. */
.q-omelds {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin: 6px 0 10px;
}
.q-omeld {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.q-omeld .who {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--ink);
}
.q-omeld .q-meld {
  margin: 0;
}

.q-choices {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin-top: 14px;
}
.q-choices button {
  position: relative;
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--chrome);
  border-radius: 10px;
  padding: 8px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  min-height: 56px;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: var(--sans);
  color: var(--ink);
}
.q-choices button:hover {
  border-color: var(--amber);
}
.q-choices button.is-picked {
  border-color: var(--signal);
  box-shadow: 0 0 0 3px rgba(246, 141, 31, 0.22);
}
.q-choices button.is-correct {
  border-color: #1f6b45;
  background: #dff5ec;
  box-shadow: 0 0 0 3px rgba(31, 107, 69, 0.25);
}
.q-choices button.is-wrong {
  border-color: var(--signal);
  background: rgba(246, 141, 31, 0.18);
  box-shadow: 0 0 0 3px rgba(246, 141, 31, 0.32);
}
.q-choices button[disabled] {
  cursor: default;
  opacity: 0.85;
}
.q-choices .tile {
  width: 24px;
  height: 32px;
  object-fit: contain;
}
.q-choices .choice-label {
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 0;
}
.q-choices .choice-label--action {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.02em;
}
.q-call-offer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 4px;
  font-size: 12px;
  color: var(--ink-soft);
}
.q-call-offer .label {
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.04em;
}

.q-result {
  display: none;
  margin: 8px 0;
  padding: 6px 16px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  border-radius: 999px;
  box-shadow: var(--shadow-card);
}
.q-result:not([hidden]) {
  display: inline-block;
}
.q-result.success {
  color: #1f6b45;
  background: #dff5ec;
}
.q-result.error {
  color: #b83232;
  background: rgba(246, 141, 31, 0.18);
}

.q-answer {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.q-answer .answer-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  margin-bottom: 6px;
}
.q-answer .answer-head .tile {
  width: 26px;
  height: 34px;
  object-fit: contain;
}
.q-answer .explanation {
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  color: var(--ink-soft);
  background: rgba(31, 107, 69, 0.10);
  border-left: 3px solid #1f6b45;
  padding: 10px 12px;
  border-radius: 4px;
  margin-top: 8px;
}
.q-answer .credit {
  margin-top: 10px;
  font-size: 11px;
  color: var(--ink-soft);
  text-align: right;
}
.q-answer .credit a {
  color: var(--ink);
  border-bottom: 1px dotted;
}

.q-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 20px;
}

/* ---------- L3 dossier / question screen ---------- */
.char-grid {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 10px auto 0;
}
.char-tile {
  width: 12px;
  height: 12px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--platinum);
}
.char-tile.is-complete {
  background: var(--amber);
}
.char-tile.is-current {
  background: var(--signal);
  width: 14px;
  height: 14px;
}
.solved-strip {
  min-height: 18px;
  margin: 6px 0 0;
  color: var(--ink-soft);
  text-align: center;
  font-size: 12px;
  letter-spacing: 1px;
}
.solved-strip:empty {
  display: none;
}

.q-card.l3 {
  margin: 18px auto 0;
  max-width: 480px;
}
.mystery-mark {
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  margin: 18px auto 10px;
  border: 5px double var(--amber);
  border-radius: 50%;
  background: var(--signal);
  color: var(--carbon);
  font-family: var(--serif);
  font-size: 60px;
  line-height: 1;
}
.q-card.revealed .mystery-mark {
  width: auto;
  max-width: 100%;
  min-height: 96px;
  padding: 16px;
  border-radius: 60px;
  font-size: 22px;
  background: var(--amber);
  animation: reveal 0.5s ease-out;
}
@keyframes reveal {
  from { transform: scale(0.9); opacity: 0.65; }
  to { transform: scale(1); opacity: 1; }
}
.attempt-count {
  margin: 0;
  text-align: center;
  font-size: 14px;
  color: var(--ink-soft);
}
.attempt-count strong {
  color: var(--signal);
  font-size: 18px;
  font-weight: 700;
}
.qa-history {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 240px;
  margin: 12px 0 16px;
  padding: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
}
.qa-history li {
  display: flex;
  flex-direction: column;
  gap: 6px;
  list-style: none;
  min-width: 0;
}
.qa-history .question {
  align-self: flex-start;
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 14px 14px 14px 4px;
  background: var(--platinum);
  color: var(--ink);
  overflow-wrap: anywhere;
}
.qa-history .ans {
  align-self: flex-end;
  padding: 7px 14px;
  border-radius: 14px 14px 4px 14px;
  background: var(--amber);
  color: var(--carbon);
  font-weight: 700;
}
.ask-form,
.guess-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.ask-form[hidden],
.guess-row[hidden] {
  display: none;
}
.ask-form input,
.guess-row input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--chrome);
  border-radius: 999px;
  background: var(--surface);
  padding: 11px 14px;
  font-size: 16px;
  outline: none;
  color: var(--ink);
  font-family: var(--sans);
}
.ask-form input:focus,
.guess-row input:focus {
  border-color: var(--signal);
  box-shadow: 0 0 0 3px rgba(246, 141, 31, 0.20);
}
.ask-form .btn,
.guess-row .btn {
  width: auto;
  flex: none;
  padding: 11px 17px;
  box-shadow: none;
}
.guess-toggle {
  display: block;
  margin: 16px auto 0;
  padding: 8px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  color: var(--ink-soft);
  font-size: 13px;
  cursor: pointer;
  font-family: var(--sans);
}
.guess-toggle:hover,
.guess-toggle:focus-visible {
  color: var(--ink);
}
.retry-row {
  margin: 18px auto 22px;
  text-align: center;
}
.card-actions {
  margin-top: 14px;
  text-align: center;
}
@media (max-width: 380px) {
  .stage-head { padding: 0 14px; }
  .q-hand .tile { width: 26px; height: 34px; }
  .q-meld .tile { width: 18px; height: 24px; }
  .q-river .discard { width: 18px; height: 24px; }
  .q-river .riichi .flag { top: -6px; right: -5px; font-size: 8px; }
  .q-choices { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .q-card.revealed .mystery-mark { animation: none; }
}

/* ===== L1 card-scoped overlays (start / subclear / clear / over) ===== */
/* The L1 page nests each overlay inside #stage so the canvas dims
 * behind a single backdrop. They take precedence over the global
 * .overlay (fixed full-screen) for these IDs only. */
#stage { position: relative; overflow: hidden; }
#stage .overlay {
  position: absolute;
  inset: 0;
  background: rgba(122, 138, 186, 0.86);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  z-index: 50;
  border-radius: 14px;
}
#stage .overlay.active { display: flex; }
#stage .overlay h2 {
  font-family: "Arial Black", Arial, sans-serif;
  font-weight: 900;
  font-size: 22px;
  line-height: 1.1;
  margin: 0 0 8px;
  color: var(--ink);
  text-transform: uppercase;
}
#stage .overlay .overlay-emblem {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  margin: 0 auto 14px;
  border: 5px double var(--chrome);
  border-radius: 50%;
  background: var(--amber);
  color: var(--carbon);
  font-family: var(--serif);
  font-size: 44px;
  line-height: 1;
}
#stage .overlay .score-line {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 14px;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin: 0;
}

/* ---------- yesno nine-grid category entry ---------- */
.yesno-cat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 8px 0 18px;
  list-style: none;
  padding: 0;
}
.yesno-cat-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-height: 88px;
  padding: 12px 12px 10px;
  background: var(--surface);
  border: 1px solid var(--chrome);
  border-radius: var(--radius-s);
  box-shadow: var(--shadow-card);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  font: inherit;
  text-align: left;
}
.yesno-cat-card:hover {
  background: var(--platinum);
  border-color: var(--carbon);
  box-shadow: var(--shadow-card-hover);
}
.yesno-cat-card:active { transform: translateY(1px); }
.yesno-cat-card.is-cleared {
  border-color: var(--amber);
}
.yesno-cat-card.is-failed {
  opacity: 0.72;
}
.yesno-cat-name {
  font-family: "Arial Black", Arial, sans-serif;
  font-size: 15px;
  font-weight: 900;
  line-height: 1.25;
  color: var(--ink);
}
.yesno-cat-meta {
  font-size: 11px;
  color: var(--ink-soft);
  line-height: 1.3;
}
.yesno-cat-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--carbon);
  background: var(--amber);
  padding: 2px 6px;
  border-radius: 2px;
}
.yesno-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0 0 8px;
  text-decoration: none;
}
@media (max-width: 420px) {
  .yesno-cat-name { font-size: 13px; }
  .yesno-cat-card { min-height: 78px; padding: 10px; }
}
