/* Tic-Tac-Turf — jumbotron look. Dark only. */
:root {
  --bg: #07080B;
  --panel: #101218;
  --panel-2: #181B24;
  --line: #262A36;
  --text: #F2F3F5;
  --muted: #9AA0AE;
  --amber: #FFB300;
  --green: #2E7D32;
  --red: #C62828;
  --p1: #888888;
  --p2: #444444;
  --p1-text: #FFFFFF;
  --p2-text: #FFFFFF;
  --head: "Barlow Condensed", "Arial Narrow", Impact, system-ui, sans-serif;
  --body: system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --tween: 220ms;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--body); overflow: hidden; overscroll-behavior: none; }
body { position: fixed; inset: 0; -webkit-user-select: none; user-select: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }

#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; z-index: 0; }

/* Screens: a centered column over the canvas. UI widgets have pointer events; gaps let taps reach the canvas. */
.screen { position: fixed; inset: 0; z-index: 2; pointer-events: none; }
.col { position: absolute; left: 50%; transform: translateX(-50%); top: 0; bottom: 0; width: 100%; max-width: 520px;
  display: flex; flex-direction: column; padding: calc(var(--sat) + 12px) calc(var(--sar) + 16px) calc(var(--sab) + 16px) calc(var(--sal) + 16px); }
.col > * { pointer-events: auto; }
.col > .spacer, .col > .preview-gap { pointer-events: none; }
.spacer { flex: 1; }
.col.center { justify-content: center; align-items: center; }

h1, h2, h3, h4 { font-family: var(--head); text-transform: uppercase; letter-spacing: 0.04em; margin: 0; font-weight: 800; }
h2 { font-size: 26px; }
h3 { font-size: 24px; color: var(--amber); }
.led { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--amber); text-shadow: 0 0 10px rgba(255,179,0,0.55); font-weight: 700; }

/* Buttons */
.btn { min-height: 56px; padding: 0 22px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line);
  font-family: var(--head); font-size: 20px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text);
  transition: transform 120ms, background var(--tween), opacity var(--tween); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; }
.btn-big { width: 100%; min-height: 64px; font-size: 26px; background: var(--amber); color: #1a1200; border-color: transparent; box-shadow: 0 0 24px rgba(255,179,0,0.35); }
.btn-big:disabled { box-shadow: none; background: #3a3320; color: #8d8060; opacity: 1; }
.row { display: flex; gap: 12px; width: 100%; }
.row .btn { flex: 1; }
.btn-back { min-width: 56px; min-height: 56px; font-size: 40px; line-height: 1; color: var(--muted); }
.gear { position: absolute; top: calc(var(--sat) + 8px); right: calc(var(--sar) + 8px); min-width: 56px; min-height: 56px; font-size: 30px; color: var(--muted); z-index: 3; }
.help-chip { min-width: 56px; min-height: 56px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line); font-family: var(--head); font-size: 24px; font-weight: 800; color: var(--muted); }

/* Title */
.title-col { align-items: center; text-align: center; }
.title-block { margin-top: 12vh; }
.game-title { font-size: clamp(44px, 13vw, 72px); line-height: 0.95; color: var(--amber); text-shadow: 0 0 18px rgba(255,179,0,0.5), 0 4px 0 #6b4a00; letter-spacing: 0.02em; }
.tagline { margin: 12px 0 0; color: var(--muted); font-size: 16px; font-style: italic; }
.disclaimer { margin: 14px 0 0; font-size: 11px; line-height: 1.4; color: var(--muted); text-align: center; }

/* Pick screens */
.pick .col { padding-bottom: calc(var(--sab) + 8px); }
.pick-header { display: flex; align-items: center; gap: 4px; min-height: 56px; }
.pick-header h2 { flex: 1; font-size: 22px; }
.preview-gap { height: 24vh; min-height: 120px; flex: 0 0 auto; }
.tile-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 4px 2px 12px; }
.division { margin-bottom: 14px; }
.division-label { font-family: var(--head); font-size: 13px; letter-spacing: 0.16em; color: var(--muted); margin: 0 0 6px 2px; }
.tile-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.tile { position: relative; display: flex; align-items: center; min-height: 60px; padding: 8px 10px 8px 0; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); text-align: left; overflow: hidden;
  transition: border-color var(--tween), box-shadow var(--tween), transform 120ms; }
.tile:active { transform: scale(0.98); }
.tile .bar { width: 8px; align-self: stretch; border-radius: 10px 0 0 10px; margin-right: 10px; flex: 0 0 auto; }
.tile .names { flex: 1; min-width: 0; line-height: 1.1; }
.tile .l1 { display: block; font-size: 12px; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .l2 { display: block; font-family: var(--head); font-size: 19px; font-weight: 700; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .l2:empty { display: none; }
.names-city .tile .l1 { font-family: var(--head); font-size: 17px; font-weight: 700; color: var(--text); white-space: normal; line-height: 1.05; overflow-wrap: anywhere; }
.chip { display: inline-block; font-family: var(--head); font-weight: 800; font-size: 13px; letter-spacing: 0.08em; padding: 3px 7px; border-radius: 6px; background: var(--panel-2); border: 1px solid rgba(255,255,255,0.15); }
.tile.selected { border-color: var(--amber); box-shadow: 0 0 0 2px var(--amber), 0 0 18px rgba(255,179,0,0.35); }
.tile:disabled { opacity: 0.32; }
.tile .rival-tag { position: absolute; right: 6px; bottom: 3px; font-size: 9px; letter-spacing: 0.1em; color: var(--amber); font-family: var(--head); }
.pick-footer { padding-top: 8px; display: flex; flex-direction: column; gap: 8px; }

/* Segmented control */
.seg { display: flex; width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg-btn { flex: 1; min-height: 52px; border-radius: 9px; font-family: var(--head); font-size: 16px; font-weight: 700; letter-spacing: 0.08em; color: var(--muted); }
.seg-btn.on { background: var(--amber); color: #1a1200; }
.record-line { margin: 0; text-align: center; font-family: var(--mono); font-size: 13px; color: var(--muted); min-height: 16px; }
.collision-note { margin: 0; text-align: center; font-size: 12px; color: var(--amber); }

/* Toss */
.toss-title { text-align: center; margin-top: 8px; color: var(--amber); }

/* Drive */
.scoreboard { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 14px; background: rgba(16,18,24,0.92); border: 1px solid var(--line); box-shadow: inset 0 0 0 1px #000, 0 6px 20px rgba(0,0,0,0.5); }
.sb-side { display: flex; align-items: center; gap: 8px; }
.sb-side.right { justify-content: flex-end; }
.sb-side .score { font-size: 34px; line-height: 1; }
.sb-mid .quarter { font-size: 22px; padding: 4px 10px; border: 1px solid #3a2f00; border-radius: 6px; background: #0b0900; }
.abbr-chip { font-size: 15px; padding: 5px 9px; }
#sb-p1-abbr { background: var(--p1); color: var(--p1-text); }
#sb-p2-abbr { background: var(--p2); color: var(--p2-text); }
.sb-side.turn .abbr-chip { box-shadow: 0 0 0 2px var(--amber); }
.flag-icon { color: #3a3f4c; transition: color var(--tween), filter var(--tween); }
.flag-icon.lit { color: var(--amber); filter: drop-shadow(0 0 6px rgba(255,179,0,0.7)); }
.turn-banner { margin-top: 8px; text-align: center; font-family: var(--head); font-size: 20px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text); text-shadow: 0 2px 6px #000; }
.drive-bottom { display: flex; align-items: center; gap: 12px; }

/* BLITZ pill */
.blitz-pill { flex: 1; min-height: 64px; border-radius: 999px; font-family: var(--head); font-size: 28px; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase;
  background: var(--panel-2); color: var(--muted); border: 2px solid var(--line); transition: box-shadow var(--tween), background var(--tween), color var(--tween), transform 120ms; }
.blitz-pill:active { transform: scale(0.97); }
.blitz-pill.ready { background: var(--p1); color: var(--p1-text); border-color: transparent; box-shadow: 0 0 22px var(--p1), 0 0 4px #fff inset; }
.blitz-pill.target { background: var(--amber); color: #1a1200; border-color: transparent; box-shadow: 0 0 26px var(--amber); animation: pulse 0.9s ease-in-out infinite; }
.blitz-pill.spent { background: #15171d; color: #4a4f5c; border-color: #1f222b; text-decoration: line-through; }
.blitz-pill.disabled { opacity: 0.45; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.03); } }

/* Banner and toast */
.banner { position: fixed; left: 50%; top: 32%; transform: translate(-50%, -50%) scale(1); z-index: 6; pointer-events: none;
  font-family: var(--head); font-size: clamp(30px, 9vw, 54px); font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text);
  padding: 8px 22px; border-radius: 12px; background: rgba(7,8,11,0.75); border: 1px solid var(--line); text-shadow: 0 0 12px rgba(255,255,255,0.3); white-space: nowrap;
  animation: bannerIn 260ms cubic-bezier(.2,1.4,.4,1); }
.banner .p1 { color: var(--p1-ink, var(--p1)); } .banner .p2 { color: var(--p2-ink, var(--p2)); }
@keyframes bannerIn { from { transform: translate(-50%,-50%) scale(0.6); opacity: 0; } to { transform: translate(-50%,-50%) scale(1); opacity: 1; } }
.toast { position: fixed; left: 50%; bottom: calc(var(--sab) + 100px); transform: translateX(-50%); z-index: 6; pointer-events: none; font-size: 14px; padding: 8px 14px; border-radius: 8px; background: rgba(24,27,36,0.95); border: 1px solid var(--line); color: var(--text); }

/* Cards (result / final) */
.card { width: 100%; padding: 22px 18px calc(18px); border-radius: 18px; background: rgba(16,18,24,0.96); border: 1px solid var(--line); box-shadow: 0 10px 40px rgba(0,0,0,0.6); text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center;
  animation: cardIn 300ms cubic-bezier(.2,1.2,.4,1); }
@keyframes cardIn { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.card-quarter { font-size: 16px; letter-spacing: 0.2em; }
.card-title { font-size: clamp(30px, 9vw, 44px); line-height: 1; }
.card-title .p1 { color: var(--p1-ink, var(--p1)); } .card-title .p2 { color: var(--p2-ink, var(--p2)); }
.card-sub { margin: 0; color: var(--muted); font-size: 15px; }
.card-score { font-family: var(--mono); font-size: 40px; font-weight: 700; color: var(--amber); text-shadow: 0 0 12px rgba(255,179,0,0.5); display: flex; gap: 14px; align-items: center; justify-content: center; }
.card-score .chip { font-size: 14px; }
.card-score .c1 { background: var(--p1); color: var(--p1-text); } .card-score .c2 { background: var(--p2); color: var(--p2-text); }

/* Overlays / sheets */
.overlay { position: fixed; inset: 0; z-index: 8; background: rgba(7,8,11,0.82); display: flex; align-items: flex-end; justify-content: center; padding: calc(var(--sat) + 8px) 0 0; animation: fadeIn 180ms; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.sheet { width: 100%; max-width: 520px; max-height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--panel); border: 1px solid var(--line); border-radius: 20px 20px 0 0;
  padding: 18px 18px calc(var(--sab) + 18px); display: flex; flex-direction: column; gap: 14px; animation: sheetUp 260ms cubic-bezier(.2,1,.3,1); }
.sheet h3 { text-align: center; }
.sheet .btn { width: 100%; }
@keyframes sheetUp { from { transform: translateY(60px); } to { transform: none; } }
.setting-row { display: flex; align-items: center; justify-content: space-between; min-height: 56px; font-family: var(--head); font-size: 18px; letter-spacing: 0.1em; }
.setting-row.col-row { flex-direction: column; align-items: stretch; gap: 8px; }
.toggle { position: relative; width: 64px; height: 36px; border-radius: 18px; background: #2a2e3a; transition: background var(--tween); }
.toggle .knob { position: absolute; top: 3px; left: 3px; width: 30px; height: 30px; border-radius: 50%; background: #fff; transition: transform var(--tween); }
.toggle[aria-checked="true"] { background: var(--green); }
.toggle[aria-checked="true"] .knob { transform: translateX(28px); }
.howto-cards { display: flex; flex-direction: column; gap: 10px; }
.howto-card { display: grid; grid-template-columns: 64px 1fr; grid-template-rows: auto auto; gap: 2px 12px; align-items: center; padding: 10px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.howto-card .picto { grid-row: 1 / span 2; width: 64px; height: 64px; }
.howto-card h4 { font-size: 18px; color: var(--amber); }
.howto-card p { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.35; }
.half-stats { display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px 12px; font-family: var(--mono); font-size: 15px; text-align: center; }
.half-stats .lbl { color: var(--muted); font-family: var(--head); letter-spacing: 0.1em; font-size: 13px; }

/* Kick meter */
#overlay-kick { align-items: center; background: rgba(7,8,11,0.55); cursor: pointer; }
#overlay-howto, #overlay-kick { z-index: 9; } /* transient overlays paint above the settings sheet */
.overlay, .sheet, .card { touch-action: manipulation; } /* no iOS double-tap zoom */
.kick-card { width: min(92vw, 480px); padding: 20px 16px; border-radius: 18px; background: rgba(16,18,24,0.96); border: 1px solid var(--line); text-align: center; }
.kick-card h3 { margin-bottom: 14px; }
.kick-bar { position: relative; height: 44px; border-radius: 10px; overflow: hidden; display: flex; border: 2px solid #000; box-shadow: 0 0 0 1px var(--line); }
.kick-bar .band { height: 100%; transition: filter 120ms; }
.kick-bar .wide { flex: 0 0 29%; background: var(--red); }
.kick-bar .doink { flex: 0 0 7%; background: var(--amber); }
.kick-bar .good { flex: 0 0 28%; background: #43A047; }
.kick-bar .band.flash { filter: brightness(1.8); animation: bandFlash 150ms 3; }
@keyframes bandFlash { 50% { filter: brightness(0.6); } }
.needle { position: absolute; top: -4px; bottom: -4px; left: 0; width: 4px; margin-left: -2px; background: #fff; box-shadow: 0 0 8px #fff, 0 0 2px #000; }
.kick-hint { margin: 12px 0 0; font-family: var(--head); letter-spacing: 0.1em; color: var(--muted); font-size: 15px; }
.kick-result { color: var(--amber); font-size: 22px; }

/* Wide screens: keep the UI in a centered column over the canvas. */
@media (min-width: 900px) {
  .col { max-width: 520px; }
  .banner { font-size: 54px; }
}
@media (max-height: 640px) {
  .preview-gap { height: 18vh; min-height: 90px; }
  .title-block { margin-top: 6vh; }
}

@media (prefers-reduced-motion: reduce) {
  :root { --tween: 60ms; }
  .banner, .card, .sheet, .overlay { animation: none; }
  .blitz-pill.target { animation: none; }
  .kick-bar .band.flash { animation: none; }
}
