/* Brickline — brand v0 palette (dark only, by decision). Every colour explicit: works on any host ground. */
:root {
  --bg: #0d1620; --panel: #14202e; --primary: #4a76a8; --primary-press: #3d6390; --accent: #9db9dc;
  --gold: #d09a5a; --text: #f2f6fa; --muted: #8fa1b5; --green: #7fb069; --red: #c96a6a; --line: #2b3f55;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
}
html, body { margin: 0; padding: 0; height: 100%; background: var(--bg); }
body {
  position: fixed; inset: 0; overflow: hidden; color: var(--text); font-family: var(--font); font-size: 14px;
  -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
  overscroll-behavior: none; -webkit-font-smoothing: antialiased; -webkit-touch-callout: none;
}
* { box-sizing: border-box; }
#stage { position: absolute; inset: 0; }
canvas { position: absolute; display: block; touch-action: none; background: var(--panel); }

/* ---- overlays: positioned by JS to the canvas box; bottom block = thumb reach ---- */
.overlay {
  position: absolute; display: none; flex-direction: column; background: rgba(13, 22, 32, 0.82);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.overlay.show { display: flex; }
.overlay.sheet { background: rgba(13, 22, 32, 0.96); }
.ov-scroll { flex: 1 1 auto; overflow-y: auto; padding: calc(28px + var(--sat)) 22px 8px; text-align: center; }
.ov-scroll.centered { display: flex; flex-direction: column; justify-content: center; }
.ov-bottom { flex: 0 0 auto; padding: 8px 22px calc(16px + var(--sab)); text-align: center; }

.brand { margin-top: 6vh; }
.wordmark { font-size: 36px; font-weight: 800; letter-spacing: 3px; line-height: 1; }
.wordmark .accent { color: var(--accent); }
.tagline, .kicker { margin-top: 8px; font-size: 11px; letter-spacing: 2px; color: var(--muted); text-transform: uppercase; font-weight: 700; }
.cup { margin-top: 26px; }
.cup-date { margin-top: 6px; font-size: 20px; font-weight: 700; }
.cup-sub { margin: 6px auto 0; max-width: 30ch; font-size: 13px; line-height: 1.5; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.chip { padding: 6px 12px; border-radius: 14px; background: rgba(157, 185, 220, 0.12); color: var(--text); font-size: 12px; font-weight: 600; }
.chip.gold { color: var(--gold); background: rgba(208, 154, 90, 0.14); }
.challenge { margin: 14px auto 0; max-width: 30ch; padding: 10px 14px; border-radius: 12px; border: 1px dashed var(--line); font-size: 13px; line-height: 1.45; }
.challenge b { color: var(--gold); }
.howto { margin: 0 auto 14px; max-width: 34ch; font-size: 13px; line-height: 1.5; color: var(--muted); }
.foot { margin: 12px 0 0; font-size: 11px; color: var(--muted); letter-spacing: 0.3px; line-height: 1.5; }

.title { font-size: 26px; font-weight: 800; letter-spacing: 3px; }
.title.small { font-size: 16px; letter-spacing: 2.5px; color: var(--muted); margin-bottom: 8px; }
.sub { margin: 12px auto 0; max-width: 32ch; font-size: 14px; line-height: 1.5; color: var(--muted); }
.sub.small { font-size: 12px; margin-top: 14px; }
.bigscore { margin-top: 6px; font-size: 60px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.05; letter-spacing: -1px; }
.newbest { min-height: 20px; margin-top: 4px; color: var(--green); font-weight: 800; font-size: 13px; letter-spacing: 2px; }
.newbest.test { color: var(--muted); letter-spacing: 1px; font-weight: 600; }
.statgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px auto 0; max-width: 320px; }
.statgrid div { padding: 8px 4px; border-radius: 10px; background: rgba(255, 255, 255, 0.05); }
.statgrid b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.statgrid span { display: block; margin-top: 2px; font-size: 10px; letter-spacing: 1.2px; color: var(--muted); text-transform: uppercase; }
.vsline { margin: 14px 0 0; font-size: 14px; font-weight: 600; min-height: 18px; }
.vsline.win { color: var(--green); } .vsline.lose { color: var(--red); }
.streak { margin-top: 10px; font-size: 14px; color: var(--gold); font-weight: 700; }

/* ---- controls: every hit target ≥ 60 px tall ---- */
button { font: inherit; border: none; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; color: inherit; background: none; padding: 0; }
button:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.btn {
  display: block; width: min(86%, 320px); height: 60px; margin: 10px auto 0; border-radius: 30px;
  background: var(--primary); color: #fff; font-size: 16px; font-weight: 800; letter-spacing: 1.5px;
}
.btn:active { background: var(--primary-press); }
.btn.secondary { background: transparent; border: 2px solid var(--line); color: #cfd9e4; }
.btn.secondary:active { background: rgba(255, 255, 255, 0.06); }
.minirow { margin-top: 10px; display: flex; gap: 6px; justify-content: center; }
.mini { min-height: 48px; padding: 0 14px; border-radius: 24px; color: var(--muted); font-size: 13px; font-weight: 600; }
.mini:active { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.mini.wide { display: block; margin: 8px auto 0; }
.mini.danger { color: var(--red); margin-top: 18px; }
.rows { margin: 10px auto 0; max-width: 360px; text-align: left; }
.row {
  display: flex; width: 100%; min-height: 60px; padding: 8px 6px; align-items: center; justify-content: space-between; gap: 12px;
  border-bottom: 1px solid var(--line); font-size: 15px; text-align: left;
}
.row:last-child { border-bottom: none; }
.row small { display: block; margin-top: 3px; font-size: 11px; color: var(--muted); line-height: 1.35; }
.row b { flex: 0 0 auto; min-width: 64px; padding: 6px 12px; border-radius: 14px; text-align: center; background: rgba(157, 185, 220, 0.14); color: var(--accent); font-size: 13px; }
.row b.off { background: rgba(255, 255, 255, 0.05); color: var(--muted); }
.history { margin: 14px auto 0; padding: 0; max-width: 360px; list-style: none; text-align: left; }
.history li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line); font-size: 13px; font-variant-numeric: tabular-nums; }
.history li span { color: var(--muted); }
.history li b { color: var(--text); }
.history li.best b { color: var(--gold); }

#pauseBtn {
  position: absolute; display: none; width: 64px; height: 60px; border-radius: 30px; align-items: center; justify-content: center;
  color: #dfe7ef; font-size: 13px; font-weight: 800; letter-spacing: 1px;
}
#pauseBtn span { display: inline-block; padding: 10px 17px; border-radius: 19px; background: rgba(255, 255, 255, 0.12); }
#pauseBtn.show { display: flex; }
#pauseBtn:active span { background: rgba(255, 255, 255, 0.22); }

#toast {
  position: absolute; left: 50%; bottom: 24%; transform: translateX(-50%); max-width: 86%;
  background: #24486b; color: #eaf2fa; font-size: 13px; padding: 9px 16px; border-radius: 16px;
  opacity: 0; transition: opacity .25s; pointer-events: none; text-align: center; line-height: 1.4;
}
#safeProbe { position: absolute; left: -9999px; top: 0; width: 1px; height: 1px; visibility: hidden; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
#debug { position: absolute; left: 6px; top: 6px; font: 10px/1.4 Menlo, monospace; color: #7fb069; pointer-events: none; white-space: pre; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- left-hand mode mirrors everything that has a side ---- */
.hand-left .minirow, .hand-left .chips { flex-direction: row-reverse; }
.hand-left .row { flex-direction: row-reverse; text-align: right; }
.hand-left .history li { flex-direction: row-reverse; }

#rotate {
  position: fixed; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center;
  background: var(--bg); color: var(--muted); font-size: 16px; line-height: 1.6; text-align: center; padding: 20px;
}
@media (orientation: landscape) and (pointer: coarse) and (max-height: 500px) { #rotate { display: flex; } }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
