@font-face { font-family: 'Inter Display'; src: url('/static/fonts/inter-display-800.woff') format('woff'); font-weight: 800; font-display: swap; }
@font-face { font-family: 'Inter Display'; src: url('/static/fonts/inter-display-600.woff') format('woff'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/static/fonts/inter-400.woff') format('woff'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/static/fonts/inter-600.woff') format('woff'); font-weight: 600; font-display: swap; }

:root {
  --hall: #0d1b26; --hall-2: #16303f; --ink: #f4f1e8; --muted: #9fb2bf; --line: rgba(244, 241, 232, 0.16);
  --blue: #3b82f6; --orange: #f08a3c; --go: #f4f1e8; --go-ink: #0d1b26; --danger: #ff8a80;
  --display: 'Inter Display', system-ui, sans-serif; --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--hall); color: var(--ink); font: 400 16px/1.45 var(--sans); overscroll-behavior: none; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.stage { position: fixed; inset: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- sheets (menu, lobby, results) ---------- */
.sheet { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; background: linear-gradient(180deg, rgba(13, 27, 38, 0.55), rgba(13, 27, 38, 0.82)); overflow-y: auto; z-index: 5; }
.sheet-card { width: min(460px, 100%); background: rgba(16, 33, 45, 0.92); border: 1px solid var(--line); border-radius: 22px; padding: 26px 26px 24px; backdrop-filter: blur(8px); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35); }
.sheet-card.wide { width: min(640px, 100%); }
.eyebrow { margin: 0 0 2px; color: var(--muted); font-weight: 600; font-size: 0.92rem; }
h1 { font: 800 clamp(2.8rem, 9vw, 4.2rem)/0.95 var(--display); letter-spacing: -0.045em; margin: 0 0 8px; }
h2 { font: 800 1.9rem/1.05 var(--display); letter-spacing: -0.03em; margin: 0 0 16px; }
h3 { font: 600 1rem var(--sans); margin: 0 0 10px; }
.lede { color: var(--muted); margin: 0 0 18px; }
.muted { color: var(--muted); font-size: 0.92rem; }
.err { color: var(--danger); font-weight: 600; margin: 12px 0 0; }
.field { display: grid; gap: 6px; margin-bottom: 16px; font-weight: 600; font-size: 0.92rem; }
.field input { min-height: 46px; padding: 8px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: rgba(0, 0, 0, 0.25); font-size: 1.02rem; }
.field input:focus { outline: none; border-color: var(--ink); }
#code { text-transform: uppercase; letter-spacing: 0.3em; font: 800 1.4rem var(--display); }
.choices { display: grid; gap: 10px; }
.big { display: grid; gap: 2px; text-align: left; padding: 14px 18px; border-radius: 16px; border: 1.5px solid var(--line); background: rgba(255, 255, 255, 0.04); cursor: pointer; }
.big strong { font: 600 1.12rem var(--sans); }
.big span { color: var(--muted); font-size: 0.92rem; }
.big:hover, .big:focus-visible { border-color: var(--ink); background: rgba(255, 255, 255, 0.08); outline: none; }
.big:first-child { background: var(--go); color: var(--go-ink); border-color: var(--go); }
.big:first-child span { color: #3d4f5c; }
.back { background: none; border: 0; color: var(--muted); font-weight: 600; padding: 6px 0; margin: -6px 0 8px; cursor: pointer; min-height: 40px; }
.back:hover { color: var(--ink); }
.go { min-height: 48px; padding: 0 26px; border-radius: 999px; border: 1.5px solid var(--go); background: var(--go); color: var(--go-ink); font-weight: 600; cursor: pointer; }
.go:hover { filter: brightness(0.92); }
.go.quiet { background: transparent; color: var(--ink); border-color: var(--line); }
.go[disabled] { opacity: 0.45; cursor: not-allowed; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.chip { min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: rgba(13, 27, 38, 0.6); font-size: 0.86rem; font-weight: 600; cursor: pointer; }
.chip:hover { border-color: var(--ink); }
.seg { border: 0; padding: 0; margin: 0 0 16px; }
.seg legend { font-weight: 600; font-size: 0.92rem; margin-bottom: 6px; padding: 0; }
.seg label { display: inline-block; margin: 0 6px 6px 0; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--line); font-weight: 600; font-size: 0.94rem; }
.seg input:checked + span { background: var(--ink); color: var(--hall); border-color: var(--ink); }
.seg input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.split > * { min-width: 0; }
.keys2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.keys2 p { margin: 0; color: var(--muted); font-size: 0.94rem; line-height: 2; }
.blue { color: var(--blue); } .orange { color: var(--orange); }
kbd { display: inline-block; min-width: 26px; padding: 1px 7px; border-radius: 6px; border: 1px solid var(--line); border-bottom-width: 2.5px; font: 600 0.86rem var(--sans); text-align: center; color: var(--ink); }
.keys { border-collapse: collapse; margin-bottom: 16px; }
.keys th { text-align: left; padding: 4px 18px 4px 0; color: var(--muted); font-weight: 600; }
.shots { padding-left: 18px; margin: 0 0 12px; }
.shots li { margin-bottom: 4px; }

/* lobby */
.code { font: 800 1em var(--display); letter-spacing: 0.12em; color: var(--ink); background: rgba(255, 255, 255, 0.08); padding: 0 10px; border-radius: 10px; }
.share { display: flex; gap: 8px; margin: -4px 0 18px; }
.share input { flex: 1; min-width: 0; min-height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.25); color: var(--muted); font-size: 0.9rem; }
.seats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.team-col { border-radius: 16px; padding: 12px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); display: grid; gap: 8px; align-content: start; }
.team-col h3 { margin: 0 0 2px; }
.seat { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 46px; padding: 6px 8px 6px 12px; border-radius: 12px; background: rgba(0, 0, 0, 0.22); }
.seat .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat .who.empty { color: var(--muted); font-weight: 400; }
.seat .tag { font-size: 0.78rem; color: var(--muted); margin-left: 6px; }
.host { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 8px; }

/* ---------- playing ---------- */
.hud { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.board { position: absolute; top: max(12px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 14px; background: rgba(8, 17, 24, 0.78); border: 1px solid var(--line); border-radius: 16px; padding: 6px 16px; white-space: nowrap; }
.team { display: inline-flex; align-items: center; gap: 10px; }
.team b { font-weight: 600; font-size: 0.9rem; max-width: 22vw; overflow: hidden; text-overflow: ellipsis; }
.team i { font: 800 2rem/1 var(--display); font-style: normal; font-variant-numeric: tabular-nums; min-width: 1.3em; text-align: center; }
.team.a i { color: var(--blue); } .team.b i { color: var(--orange); }
.team.serving b::after { content: ' ●'; color: var(--ink); font-size: 0.7em; vertical-align: middle; }
.to { color: var(--muted); font-size: 0.78rem; }
.hud-tools { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; display: flex; gap: 6px; pointer-events: auto; }
.call { position: absolute; top: 26%; left: 0; right: 0; text-align: center; font: 800 clamp(2rem, 7vw, 4rem)/1 var(--display); letter-spacing: -0.03em; margin: 0; opacity: 0; transform: translateY(8px); transition: opacity 0.18s, transform 0.18s; text-shadow: 0 4px 30px rgba(0, 0, 0, 0.5); }
.call.show { opacity: 1; transform: none; }
.prompt { position: absolute; top: calc(max(12px, env(safe-area-inset-top)) + 64px); left: 50%; transform: translateX(-50%); text-align: center; margin: 0; color: var(--ink); font-weight: 600; font-size: 0.95rem; background: rgba(8, 17, 24, 0.6); padding: 6px 14px; border-radius: 999px; white-space: nowrap; }
.prompt:empty { display: none; }
.toast { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--hall); padding: 10px 16px; border-radius: 12px; font-weight: 600; z-index: 9; max-width: calc(100% - 32px); text-align: center; margin: 0; }

/* touch pad */
.pad { position: absolute; left: 0; right: 0; bottom: max(14px, env(safe-area-inset-bottom)); display: flex; justify-content: space-between; padding: 0 14px; z-index: 4; pointer-events: none; }
.pad > div { display: flex; gap: 12px; pointer-events: auto; }
.pad button { width: 74px; height: 74px; border-radius: 50%; border: 1.5px solid rgba(244, 241, 232, 0.35); background: rgba(8, 17, 24, 0.45); font-weight: 600; font-size: 1.05rem; touch-action: none; }
.pad button.on { background: rgba(244, 241, 232, 0.28); }
.pad button.hit { width: 86px; height: 86px; background: rgba(240, 138, 60, 0.35); border-color: var(--orange); }

@media (max-width: 560px) {
  .split, .keys2, .seats { grid-template-columns: 1fr; }
  .sheet-card { padding: 22px 18px 20px; border-radius: 18px; }
  .hud-tools .chip { padding: 0 10px; }
  #help-btn { display: none; }
  .board { gap: 8px; padding: 4px 10px; top: max(56px, env(safe-area-inset-top)); }
  .prompt { top: 112px; font-size: 0.85rem; white-space: normal; width: max-content; max-width: calc(100% - 24px); }
  .team i { font-size: 1.6rem; }
}
@media (prefers-reduced-motion: reduce) { .call { transition: none; } }
