:root { --bg:#0d0a1c; --panel:#171230; --line:#2e2650; --text:#ece8ff; --dim:#9890c4; --gold:#ffe36b; --good:#6be08a; --bad:#ff6b6b; --acc:#ff9b3d; }
* { box-sizing: border-box; }
body { margin:0; background:var(--bg); color:var(--text); font:15px/1.4 system-ui,-apple-system,Segoe UI,sans-serif; }
header { display:flex; flex-wrap:wrap; gap:10px 24px; align-items:center; justify-content:space-between; padding:12px 16px; border-bottom:1px solid var(--line); }
h1 { margin:0; font-size:20px; letter-spacing:.14em; } h1 small { font-size:11px; letter-spacing:.2em; color:var(--dim); font-weight:400; margin-left:6px; }
.hud { display:flex; gap:8px; flex-wrap:wrap; } .pill { background:var(--panel); border:1px solid var(--line); border-radius:99px; padding:4px 12px; color:var(--dim); } .pill b { color:var(--text); font-variant-numeric:tabular-nums; }
main { display:grid; grid-template-columns:minmax(0,1fr) 300px; gap:16px; padding:16px; max-width:1360px; margin:0 auto; }
@media (max-width:900px) { main { grid-template-columns:1fr; padding:10px; } }
.canvas-wrap { position:relative; border:1px solid var(--line); border-radius:10px; overflow:hidden; background:#000; }
#scroller { overflow-x:auto; overflow-y:hidden; -webkit-overflow-scrolling:touch; overscroll-behavior-x:contain; }
canvas#c { display:block; width:calc(100% * var(--zoom, 1)); height:auto; image-rendering:pixelated; touch-action:manipulation; cursor:crosshair; -webkit-tap-highlight-color:transparent; }
.banner { position:absolute; left:0; right:0; top:18px; margin:auto; width:max-content; max-width:92%; background:rgba(13,10,28,.92); border:1px solid var(--gold); border-radius:10px; padding:10px 16px; text-align:center; }
.banner.held b.res { color:var(--good); } .banner.fell b.res { color:var(--bad); }
.tip { position:absolute; pointer-events:none; background:rgba(13,10,28,.95); border:1px solid var(--line); border-radius:6px; padding:4px 8px; font-size:12px; white-space:nowrap; transform:translate(-50%,-130%); }
.hidden, [hidden] { display:none !important; }
#buildbar, #replaybar { display:flex; flex-wrap:wrap; gap:10px; align-items:center; justify-content:space-between; margin-top:10px; }
#palette { display:flex; gap:6px; flex-wrap:wrap; }
.tool { background:var(--panel); border:2px solid var(--line); color:var(--text); border-radius:8px; padding:6px 10px; cursor:pointer; font:inherit; display:flex; gap:6px; align-items:center; }
.tool canvas { width:20px; height:20px; image-rendering:pixelated; } .tool kbd { color:var(--dim); font-size:11px; }
.tool.sel { border-color:var(--gold); background:#241c4a; }
.left b { font-size:20px; color:var(--gold); }
button { background:var(--panel); color:var(--text); border:1px solid var(--line); border-radius:8px; padding:7px 12px; font:inherit; cursor:pointer; }
button:hover { border-color:var(--dim); } button.primary { background:var(--acc); border-color:var(--acc); color:#1b1000; font-weight:700; }
button.spd.on { border-color:var(--gold); }
#rp-scrub { flex:1; min-width:140px; }
.hint { color:var(--dim); font-size:13px; } .own { color:var(--gold); }
.card { background:var(--panel); border:1px solid var(--line); border-radius:10px; padding:12px 14px; margin-bottom:12px; }
.card h3 { margin:0 0 8px; font-size:13px; letter-spacing:.1em; text-transform:uppercase; color:var(--dim); }
.card label { display:flex; gap:8px; align-items:center; color:var(--dim); } input#name { flex:1; min-width:0; width:100%; background:#0d0a1c; border:1px solid var(--line); color:var(--text); border-radius:6px; padding:5px 8px; font:inherit; }
.verdict { font-size:22px; font-weight:800; letter-spacing:.06em; } .verdict.held { color:var(--good); } .verdict.fell { color:var(--bad); }
.stats { display:grid; grid-template-columns:1fr 1fr; gap:4px 12px; margin:8px 0; } .stats span { color:var(--dim); } .stats b { color:var(--text); }
.saved { background:#241c4a; border-left:3px solid var(--gold); padding:8px 10px; border-radius:4px; margin:8px 0; }
.row { display:flex; gap:8px; flex-wrap:wrap; margin-top:8px; }
.history { display:flex; gap:4px; flex-wrap:wrap; } .history i { width:18px; height:18px; border-radius:4px; display:block; background:var(--line); cursor:pointer; } .history i.h { background:var(--good); } .history i.f { background:var(--bad); }
.mini { font-size:12px; color:var(--dim); margin:6px 0 0; }
dialog { background:var(--panel); color:var(--text); border:1px solid var(--line); border-radius:12px; max-width:min(96vw,760px); }
dialog::backdrop { background:rgba(0,0,0,.7); } dialog canvas { width:100%; border-radius:8px; } textarea { width:100%; margin-top:8px; background:#0d0a1c; color:var(--text); border:1px solid var(--line); border-radius:6px; padding:8px; font:inherit; }
.demo-only { display:none; } body.demo .demo-only { display:inline-block; }
button.linkish { min-height:0 !important; background:none; border:0; padding:0 0 0 6px; color:var(--acc); text-decoration:underline; cursor:pointer; font:inherit; }
#touchbar { display:flex; gap:10px; align-items:center; margin-top:10px; padding:8px; background:var(--panel); border:1px solid var(--gold); border-radius:12px; }
#touchbar .nudge { display:grid; grid-template-columns:repeat(4,48px); gap:6px; }
#touchbar .nudge button { height:48px; padding:0; font-size:18px; }
#tb-msg { flex:1; min-width:0; font-size:14px; color:var(--dim); } #tb-msg.bad { color:var(--bad); } #tb-msg b { color:var(--text); }
#tb-ok { height:48px; padding:0 20px; font-size:16px; } #tb-ok:disabled { opacity:.4; }
#tb-cancel { height:48px; width:48px; padding:0; }
#zoom.on { border-color:var(--gold); }
.hint-touch { display:none; }
@media (pointer:coarse) {
  .hint-touch { display:inline; } .hint-mouse { display:none; } .tool kbd { display:none; }
  button, .tool { min-height:44px; }
  .tool { padding:8px 14px; } .tool canvas { width:24px; height:24px; }
  #rp-scrub { height:32px; } .pill { padding:6px 14px; }
  .history i { width:26px; height:26px; }
  #touchbar { position:sticky; bottom:8px; z-index:5; }
}
@media (max-width:560px) { #touchbar { flex-wrap:wrap; } #tb-msg { flex-basis:100%; order:-1; } }
.midnight { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:flex-start; padding-top:8%; text-align:center; pointer-events:none; background:radial-gradient(ellipse at 50% 40%, rgba(255,60,60,.0), rgba(120,0,0,.35)); }
.midnight #mn-title { font-weight:800; letter-spacing:.2em; font-size:14px; color:var(--gold); text-shadow:0 2px 8px #000; }
.midnight #mn-big { font-weight:900; font-size:clamp(40px,9vw,92px); font-variant-numeric:tabular-nums; text-shadow:0 4px 18px #000; }
.midnight #mn-sub { color:var(--text); text-shadow:0 2px 8px #000; }
.midnight.hot { animation:throb .5s ease-in-out infinite alternate; } .midnight.hot #mn-big { color:var(--bad); }
@keyframes throb { from { background-color:rgba(120,0,0,0); } to { background-color:rgba(160,0,0,.28); } }
.caption { position:absolute; left:0; right:0; top:14px; margin:auto; width:max-content; max-width:92%; padding:8px 16px; border-radius:10px; font-weight:700; background:rgba(13,10,28,.88); border:1px solid var(--line); text-align:center; pointer-events:none; animation:pop .25s ease-out; }
.caption.threat { border-color:#ff9b3d; color:#ffd2a0; } .caption.loss { border-color:var(--bad); color:#ffb0b0; } .caption.win { border-color:var(--good); color:#b8f5c8; }
@keyframes pop { from { transform:translateY(8px) scale(.96); opacity:0; } to { transform:none; opacity:1; } }
.live { color:#fff; background:#d62d3a; border-radius:99px; padding:3px 12px; font-weight:800; letter-spacing:.1em; animation:blink 1.4s ease-in-out infinite; } @keyframes blink { 50% { opacity:.55; } }
#recap { width:min(94vw,560px); } #recap h4 { margin:14px 0 6px; font-size:12px; letter-spacing:.12em; text-transform:uppercase; color:var(--dim); }
.moments, .heroes { margin:0; padding:0; list-style:none; } .moments li { display:flex; gap:10px; padding:4px 0; border-bottom:1px solid var(--line); } .moments time { color:var(--dim); font-variant-numeric:tabular-nums; width:38px; flex:none; }
.moments li.threat b { color:#ffb36b; } .moments li.loss b { color:var(--bad); } .moments li.win b { color:var(--good); } .moments li b { font-weight:600; }
.heroes li { padding:3px 0; } .heroes li.mine { color:var(--gold); }
@media (prefers-reduced-motion: reduce) { .midnight.hot, .live, .caption { animation:none; } }
body.live-on .spoiler { visibility:hidden; } /* no spoilers while the wave airs live */
.verdict.thread { color:#ffb36b; }
.teams { display:grid; gap:6px; } .team-row { display:grid; grid-template-columns:84px 1fr auto; gap:8px; align-items:center; font-size:13px; }
.team-row .nm { font-weight:700; } .team-row .bar { height:10px; border-radius:99px; background:var(--line); overflow:hidden; } .team-row .bar i { display:block; height:100%; border-radius:99px; }
.team-row.mine .nm::after { content:" ★"; color:var(--gold); } .team-row .pts { color:var(--dim); font-variant-numeric:tabular-nums; min-width:34px; text-align:right; }
.team-chips { display:flex; gap:6px; flex-wrap:wrap; margin-bottom:8px; }
.chip { border:2px solid var(--line); border-radius:99px; padding:4px 12px; font-weight:700; cursor:pointer; background:var(--panel); color:var(--text); }
.chip.sel { box-shadow:0 0 0 2px var(--gold); }
#teampick { width:min(94vw,640px); } #teampick h3 { margin:0 0 4px; font-size:20px; }
.tp-cards { display:grid; grid-template-columns:repeat(2,1fr); gap:10px; margin:12px 0; }
.tp-card { text-align:left; padding:12px; border-width:2px; border-radius:12px; min-height:92px; display:grid; gap:2px; }
.tp-card b { font-size:18px; } .tp-card span { color:var(--dim); font-size:13px; } .tp-card em { color:var(--gold); font-style:normal; font-size:12px; font-weight:700; }

button.invite { border-color:var(--acc); color:var(--acc); font-weight:700; border-radius:99px; padding:4px 14px; }
button.invite.done { border-color:var(--good); color:var(--good); }
.guide { margin-top:10px; background:#241c4a; border:1px solid var(--gold); border-radius:12px; padding:12px 14px; animation:pop .25s ease-out; }
.guide h3 { margin:2px 0 6px; font-size:18px; } .guide p { margin:4px 0; } .gd-step { font-size:11px; letter-spacing:.14em; text-transform:uppercase; color:var(--dim); }
.guide .row button.primary { min-height:48px; padding:0 20px; font-size:16px; }
.guide .mini a, button.linkish.dim { color:var(--dim); }
.fc-row { display:flex; flex-wrap:wrap; gap:8px; margin:8px 0; } .fc { display:inline-flex; align-items:center; gap:6px; background:#171230; border:1px solid var(--line); border-radius:99px; padding:2px 12px 2px 4px; } .fc canvas { image-rendering:pixelated; }
button#tour-btn { cursor:pointer; }
.tool { position:relative; } .tool.locked { opacity:.45; cursor:not-allowed; }
.badge { font-style:normal; font-size:10px; font-weight:800; letter-spacing:.06em; color:var(--dim); } .badge.new { color:#1b1000; background:var(--gold); border-radius:99px; padding:1px 6px; }
.tool .badge { position:absolute; top:-7px; right:-4px; } .tool.locked .badge { position:static; }
.new { margin:4px 0; font-size:13px; } .new i { color:var(--dim); } .fc { cursor:pointer; }
.verdict-flash { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; pointer-events:none; font-weight:900; letter-spacing:.14em; font-size:clamp(22px,5.5vw,56px); text-shadow:0 4px 20px #000; animation:vflash 2.6s ease-out both; text-align:center; }
.verdict-flash.win { color:var(--gold); } .verdict-flash.lose { color:var(--bad); }
@keyframes vflash { 0% { opacity:0; transform:scale(.8); } 15% { opacity:1; transform:scale(1.06); } 25% { transform:scale(1); } 80% { opacity:1; } 100% { opacity:0; } }
@media (prefers-reduced-motion: reduce) { .verdict-flash { animation:none; } }
/* invite landing: the whole room in one screen */
#landing { width:min(94vw,520px); padding:18px 20px; } #landing::backdrop { background:rgba(0,0,0,.5); }
#landing h2 { margin:8px 0 10px; font-size:22px; line-height:1.2; }
.ld-from { font-size:15px; } .ld-team { display:inline-block; border:2px solid; border-radius:99px; padding:1px 10px; font-weight:800; font-size:13px; margin-left:4px; }
.ld-facts { list-style:none; margin:0; padding:0; display:grid; gap:8px; } .ld-facts li { display:flex; gap:12px; align-items:center; background:#1d1840; border-radius:10px; padding:8px 12px; } .ld-facts span { font-size:24px; }
.ld-live { margin:12px 0 2px; color:var(--dim); font-size:13px; } .ld-live b { color:var(--text); }
#landing .row button.primary { min-height:52px; flex:1 1 220px; font-size:17px; }
.reveal { display:flex; gap:8px; align-items:center; margin-top:8px; color:var(--text); } .reveal input { width:20px; height:20px; }
/* touch: the palette (10 blocks + Take back) is a finger-sized two-row grid pinned to the bottom, so it never sits below the fold */
@media (pointer:coarse) {
  #buildbar { position:sticky; bottom:0; z-index:6; margin:10px -10px 0; padding:8px 10px calc(8px + env(safe-area-inset-bottom)); background:#0d0a1c; border-top:1px solid var(--line); flex-direction:column; flex-wrap:nowrap; align-items:stretch; }
  #palette { display:grid; grid-template-columns:repeat(auto-fit,minmax(84px,1fr)); gap:6px; }
  .tool { flex-direction:column; justify-content:center; gap:2px; min-height:56px; padding:6px 4px; font-size:12px; text-align:center; }
  .tool canvas { width:28px; height:28px; }
  #buildbar .left { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
  #touchbar { bottom:var(--bb, 150px); }
  body.guiding #buildbar { display:none; } /* the intro card replaces the palette while it is up */
  #scroller { overflow-y:auto; max-height:calc(100dvh - 130px - var(--bb, 230px)); min-height:260px; } /* board + pinned palette fit one 11" iPad screen; pan up for the sky */
  .tool .badge { top:-6px; right:2px; }
}
