:root {
  --bg: #0f1724; --panel: #172235; --panel2: #1f2d45; --line: rgba(255,255,255,0.1);
  --text: #f3f5f8; --dim: #9fb0c6; --gold: #ffcf3f; --red: #ff5a5f; --green: #3fd17a; --blue: #4d9bff;
  --r: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; touch-action: none; user-select: none; -webkit-user-select: none; }
canvas#cv { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud button { pointer-events: auto; }
#bug { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  display: flex; align-items: stretch; border-radius: 12px; overflow: hidden; box-shadow: 0 6px 20px rgba(0,0,0,0.35); font-weight: 800; }
#bug .tm { display: flex; align-items: center; gap: 10px; padding: 7px 12px; min-width: 92px; justify-content: space-between; }
#bug .tm .ab { font-size: 14px; letter-spacing: 0.04em; }
#bug .tm .sc { font-size: 22px; font-variant-numeric: tabular-nums; }
#bug .tm.poss .ab::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); margin-right: 6px; vertical-align: 2px; }
#bug .mid { background: #0b111b; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4px 12px; min-width: 70px; font-size: 13px; }
#bug .mid span:last-child { font-size: 17px; font-variant-numeric: tabular-nums; }
#sit { position: absolute; top: calc(max(10px, env(safe-area-inset-top)) + 54px); left: 50%; transform: translateX(-50%);
  background: rgba(11,17,27,0.82); padding: 5px 12px; border-radius: 999px; font-weight: 700; font-size: 13px; white-space: nowrap; }
#pauseBtn { position: absolute; top: max(10px, env(safe-area-inset-top)); right: 12px; width: 42px; height: 42px; border-radius: 12px;
  background: rgba(11,17,27,0.8); font-weight: 900; }
#toast { position: absolute; top: 34%; left: 50%; transform: translate(-50%, -50%); background: rgba(11,17,27,0.88);
  padding: 14px 22px; border-radius: 16px; font-weight: 900; font-size: clamp(20px, 5vw, 34px); text-align: center; max-width: 90vw;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4); }
#toast.big { color: var(--gold); font-size: clamp(30px, 8vw, 56px); }
#pads { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); display: grid;
  grid-template-columns: repeat(2, auto); gap: 12px; align-items: end; justify-items: center; }
.pad { width: 74px; height: 74px; border-radius: 50%; background: rgba(255,255,255,0.16); border: 2px solid rgba(255,255,255,0.4);
  font-weight: 900; font-size: 13px; letter-spacing: 0.04em; backdrop-filter: blur(4px); }
.pad.big { width: 96px; height: 96px; font-size: 18px; background: var(--gold); color: #1b1300; border-color: #fff3c4; grid-column: span 2; }
.pad.on { background: rgba(255,207,63,0.5); }
#turbo { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: calc(max(18px, env(safe-area-inset-bottom)) + 182px); width: 160px; height: 8px;
  border-radius: 99px; background: rgba(0,0,0,0.4); overflow: hidden; }
#turbo i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ff9f1c, var(--gold)); }
#stick { position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.35); background: rgba(255,255,255,0.08); }
#stick i { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(255,255,255,0.55); }
#hint { position: absolute; left: 14px; bottom: max(16px, env(safe-area-inset-bottom)); font-size: 12px; color: rgba(255,255,255,0.8);
  background: rgba(11,17,27,0.6); padding: 6px 10px; border-radius: 10px; max-width: 46vw; }
@media (pointer: coarse) { #hint .kb { display: none; } }
@media (pointer: fine) { #hint .tp { display: none; } }

/* ---------- Screens ---------- */
#screen { position: fixed; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
#screen:empty { display: none; }
#screen.dim { background: rgba(8,12,20,0.55); }
#screen.solid { background: radial-gradient(1200px 600px at 50% -10%, #1d3150 0%, var(--bg) 60%); }
.wrap { max-width: 980px; margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) 16px 40px; }
h1, h2, h3 { margin: 0; }
.title { text-align: center; padding-top: 6vh; }
.title h1 { font-size: clamp(40px, 10vw, 86px); line-height: 0.92; font-weight: 900; letter-spacing: -0.02em; }
.title h1 span { color: var(--gold); }
.title p { color: var(--dim); font-size: 17px; margin: 14px auto 26px; max-width: 520px; }
.helmrow { display: flex; justify-content: center; gap: 4px; flex-wrap: wrap; margin: 24px auto; max-width: 720px; }
.helmrow img { width: 56px; height: 56px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 22px; border-radius: 12px; background: var(--panel2);
  font-weight: 800; font-size: 16px; min-height: 48px; }
a.btn { text-decoration: none; color: inherit; }
.btn.gold { background: var(--gold); color: #1b1300; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.small { padding: 9px 14px; min-height: 38px; font-size: 14px; }
.btn:disabled { opacity: 0.4; cursor: default; }
.stack { display: flex; flex-direction: column; gap: 10px; max-width: 320px; margin: 0 auto; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.between { justify-content: space-between; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.muted { color: var(--dim); }
.kicker { font-size: 12px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); }

.teams { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 14px 0 18px; }
.team { background: var(--panel); border: 2px solid transparent; border-radius: var(--r); padding: 10px; text-align: center; }
.team img { width: 76px; height: 76px; }
.team b { display: block; font-size: 15px; }
.team small { color: var(--dim); }
.team.sel { border-color: var(--gold); background: var(--panel2); }
.opts { display: grid; gap: 12px; margin-bottom: 18px; }
.seg { display: flex; background: var(--panel); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; padding: 10px 6px; border-radius: 9px; background: transparent; font-weight: 700; font-size: 14px; color: var(--dim); }
.seg button.on { background: var(--panel2); color: var(--text); }

.hubtop { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.hubtop img { width: 64px; height: 64px; }
.hubtop h2 { font-size: 24px; }
.next { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; text-align: center; margin: 8px 0 14px; }
.next img { width: 84px; height: 84px; }
.next b { display: block; }
.next .vs { font-weight: 900; color: var(--dim); }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 18px 0 10px; padding-bottom: 4px; }
.tabs button { padding: 9px 14px; border-radius: 999px; background: var(--panel); font-weight: 700; font-size: 14px; color: var(--dim); white-space: nowrap; }
.tabs button.on { background: var(--text); color: var(--bg); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--dim); font-weight: 700; font-size: 12px; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tr.me td { background: rgba(255,207,63,0.08); }
.tinyhelm { width: 26px; height: 26px; vertical-align: middle; margin-right: 6px; }
.scroll { overflow-x: auto; }
.plus { width: 32px; height: 32px; border-radius: 8px; background: var(--gold); color: #1b1300; font-weight: 900; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; background: var(--panel2); font-size: 12px; font-weight: 800; }
.badge.w { background: rgba(63,209,122,0.2); color: var(--green); }
.badge.l { background: rgba(255,90,95,0.18); color: var(--red); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }

/* Play call */
.call { position: fixed; left: 0; right: 0; bottom: 0; max-height: 72vh; overflow-y: auto; background: rgba(12,18,29,0.96);
  border-top-left-radius: 20px; border-top-right-radius: 20px; padding: 14px 14px max(14px, env(safe-area-inset-bottom)); box-shadow: 0 -10px 40px rgba(0,0,0,0.5); touch-action: pan-y; }
.call .head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.call h3 { font-size: 18px; }
.plays { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; }
.play { background: var(--panel); border-radius: 12px; padding: 8px; text-align: left; border: 2px solid transparent; }
.play:hover { border-color: rgba(255,255,255,0.25); }
.play svg { width: 100%; height: auto; display: block; background: #3f8a49; border-radius: 8px; }
.play b { display: block; font-size: 14px; margin-top: 6px; }
.play small { color: var(--dim); font-size: 12px; }
.play.kick { background: #2a2140; }
.kickmeter { position: fixed; left: 50%; bottom: 22%; transform: translateX(-50%); width: min(420px, 86vw); background: rgba(12,18,29,0.94); border-radius: 18px; padding: 16px; text-align: center; }
.meter { position: relative; height: 26px; border-radius: 99px; margin: 12px 0; background: linear-gradient(90deg, #ff5a5f 0%, #ffcf3f 30%, #3fd17a 45%, #3fd17a 55%, #ffcf3f 70%, #ff5a5f 100%); }
.meter i { position: absolute; top: -6px; width: 6px; height: 38px; margin-left: -3px; background: #fff; border-radius: 3px; box-shadow: 0 0 8px rgba(0,0,0,0.6); }
.final { max-width: 560px; margin: 8vh auto 0; }
.final .score { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; text-align: center; gap: 10px; margin: 14px 0; }
.final .score img { width: 84px; height: 84px; }
.final .score .n { font-size: 46px; font-weight: 900; }
.howto li { margin: 6px 0; }
