/* BlockDrop — system theme + layout. Follows prefers-color-scheme live. */
:root {
  color-scheme: light dark;
  --banner-h: 0px;
  --bg: #eef2ff;
  --surface: #ffffff;
  --ink: #141736;
  --ink-dim: #5a5f7a;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --line: #d7dcf5;
  --board-bg: #171a33;
  --cell-empty: rgba(255, 255, 255, 0.06);
  --shadow: 0 8px 32px rgba(20, 23, 54, 0.12);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1226;
    --surface: #1b1e38;
    --ink: #eef0ff;
    --ink-dim: #a7abd0;
    --accent: #818cf8;
    --accent-ink: #10122a;
    --line: #2e3358;
    --board-bg: #0a0c1e;
    --cell-empty: rgba(255, 255, 255, 0.05);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  padding-bottom: var(--banner-h);
  -webkit-touch-callout: none; /* no long-press callout anywhere in the game */
}
button { -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
body.bd_banner { padding-bottom: var(--banner-h); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px 4px;
  max-width: 480px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, #4f46e5, #06b6d4);
  color: #fff; font-size: 20px;
}
.icon-btn {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px;
  width: 40px; height: 40px; font-size: 18px; cursor: pointer;
}
.top-actions { display: flex; gap: 8px; }

main { max-width: 480px; margin: 0 auto; padding: 8px 16px 24px; }
.tagline { color: var(--ink-dim); margin: 6px 0 16px; font-size: 15px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-dim); margin: 14px 0 8px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 8px 14px; font-size: 14px; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pool-note { color: var(--ink-dim); font-size: 13px; margin: 8px 0 0; }

.primary-btn, .ghost-btn {
  display: block; width: 100%; border-radius: 12px; font-size: 17px;
  font-weight: 700; padding: 14px; margin-top: 18px; cursor: pointer;
}
.primary-btn { background: var(--accent); color: var(--accent-ink); border: none; }
.ghost-btn { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.ghost-btn.wide { margin-top: 10px; }

.stats { display: flex; gap: 8px; margin-top: 20px; }
.stat {
  flex: 1; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 6px; text-align: center;
}
.stat-num { display: block; font-size: 22px; font-weight: 800; }
.stat-label { font-size: 12px; color: var(--ink-dim); }
.hint { color: var(--ink-dim); font-size: 13px; line-height: 1.5; margin-top: 18px; }

.menu-board { display: flex; flex-direction: column; gap: 4px; align-items: center; padding: 12px 0 4px; }
.mini-row { display: flex; gap: 4px; }
.mini-row .cell { width: 26px; height: 26px; border-radius: 5px; }

/* ---- game view ---- */
.hud { display: flex; gap: 8px; margin: 4px 0 10px; }
.hud-box {
  flex: 1; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 4px; text-align: center;
}
.hud-label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-dim); }
.hud-num { display: block; font-size: 18px; font-weight: 800; }

.play-row { display: flex; gap: 10px; justify-content: center; align-items: flex-start; }
.board {
  display: grid; grid-template-columns: repeat(10, 1fr);
  width: min(300px, 68vw); aspect-ratio: 1 / 2;
  /* Height cap: the whole game view (topbar + HUD + board + controls)
     must fit above the banner with no scrolling, or the Drop button
     ends up under the banner (Michelle 2026-11-12). Fixed chrome
     measures exactly 255px (topbar 56 + gaps 12+10+12 + HUD 57 +
     controls 108) + 90px banner = 345px; 350px leaves a 5px breathing
     room so the board is maximal on every size (the first 380px
     constant left a 35px wasted gap on all sizes). Older engines
     ignore dvh and keep the line above. */
  width: min(300px, 68vw, calc((100dvh - 350px) / 2));
  background: var(--board-bg); border-radius: 10px; padding: 4px; gap: 1px;
  touch-action: none; user-select: none; -webkit-user-select: none;
  box-shadow: var(--shadow);
}
.board .cell { border-radius: 3px; background: var(--cell-empty); }
.side { display: flex; flex-direction: column; gap: 8px; width: 64px; }
.next-box {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 6px; text-align: center;
}
.next-piece {
  display: grid; grid-template-columns: repeat(4, 1fr);
  width: 52px; aspect-ratio: 1; margin: 6px auto 0; gap: 1px;
}
.next-piece .cell { border-radius: 2px; background: transparent; }
.side-btn {
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; height: 44px; font-size: 18px; cursor: pointer;
}

.cell { display: block; }
/* NOTE: .board .cell and .next-piece .cell set a background at (0,2,0)
   specificity, so the colour classes must beat them explicitly. */
.board .cell.c1, .next-piece .cell.c1, .c1 { background: #06b6d4; } /* I — cyan */
.board .cell.c2, .next-piece .cell.c2, .c2 { background: #facc15; } /* O — yellow */
.board .cell.c3, .next-piece .cell.c3, .c3 { background: #a855f7; } /* T — purple */
.board .cell.c4, .next-piece .cell.c4, .c4 { background: #22c55e; } /* S — green */
.board .cell.c5, .next-piece .cell.c5, .c5 { background: #ef4444; } /* Z — red */
.board .cell.c6, .next-piece .cell.c6, .c6 { background: #3b82f6; } /* J — blue */
.board .cell.c7, .next-piece .cell.c7, .c7 { background: #f97316; } /* L — orange */
.cell.ghost { opacity: 0.28; }

.controls {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin-top: 12px;
}
.ctl-btn {
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: 12px; height: 52px; font-size: 20px; cursor: pointer;
  touch-action: manipulation;
}
.ctl-btn.wide { grid-column: span 4; height: 48px; font-size: 16px; font-weight: 700; }
.ctl-btn:active { background: var(--accent); color: var(--accent-ink); }
.level-toast {
  text-align: center; font-weight: 800; color: var(--accent);
  margin: 10px 0 0; font-size: 16px;
}

/* ---- sheets / toast (fixed overlays get their own banner offset) ---- */
.sheet {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(8, 10, 30, 0.55);
  padding-bottom: var(--banner-h);
}
.sheet-card {
  width: 100%; max-width: 480px; background: var(--surface); color: var(--ink);
  border-radius: 20px 20px 0 0; padding: 20px 20px calc(20px + var(--banner-h));
  max-height: calc(88vh - var(--banner-h)); overflow-y: auto;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.25);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; }
.sheet-note { color: var(--ink-dim); font-size: 13px; line-height: 1.5; }
.result-card { text-align: center; }
.result-title { margin: 4px 0 8px; font-size: 24px; }
.result-word { font-size: 20px; font-weight: 800; margin: 4px 0; }
.result-detail, .result-stats { color: var(--ink-dim); margin: 6px 0; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(24px + var(--banner-h)); z-index: 50;
  /* Informational only: must never eat taps. It floats above the
     sheets (z-50 vs z-40) and used to block the pause sheet's Quit
     button when a toast was still up (e2e T16, 2026-11-12). */
  pointer-events: none;
  background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow); max-width: 90vw; text-align: center;
}
