/* FAILSAFE. Mobile first: nearly every student plays on a phone.
 *
 * The play screen is a fixed game layout, not a scrolling page: header, map,
 * build menu. The map fills whatever is left and has its own camera.
 *
 * Every colour is a token. `body.storm` (the attack) re-points the chrome
 * tokens to a night palette. On the map: red is where people get hurt, orange
 * on a road is rogue traffic, purple is who the fake alert reaches, green is
 * something that held, blue is what you are placing or looking at.
 */
@font-face { font-family: 'Outfit'; font-style: normal; font-weight: 300 700; font-display: swap; src: url('fonts/outfit.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 400 700; font-display: swap; src: url('fonts/jetbrainsmono.woff2') format('woff2'); }

:root {
  --paper: #f3eee4; --card: #fffdf8; --ink: #16202f; --mute: #566072; --faint: #8b93a1;
  --line: #d3cab6; --line2: #e7e0d1;
  --brand: #2346d8; --low: #23894f; --mid: #c98708; --high: #d23c28; --mid-ink: #7d5300; --hazard: #f5b81c;
  --veh: #d9482b; --pow: #3b4252; --alr: #7a3fd0;
  --sky: #dfeaf2;
  --font: 'Outfit', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
}
body.storm {
  --paper: #0b101c; --card: #151d31; --ink: #eef2fb; --mute: #a7b2c8; --faint: #7f8ba5;
  --line: #36435f; --line2: #28334e; --mid-ink: #f2c45c; --sky: #0f1728;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 16px/1.45 var(--font); min-height: 100dvh; transition: background-color .7s, color .7s; }
h1, h2, h3, h4, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:focus-visible, input:focus-visible, tr:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.ic { width: 1em; height: 1em; flex: none; }
small { font-size: .8em; }
strong { font-weight: 600; }
[hidden] { display: none !important; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45em; padding: .6em 1em; border-radius: 10px;
  border: 1.5px solid var(--line); background: var(--card); font-weight: 600; line-height: 1.1; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn.go { background: var(--high); border-color: var(--high); color: #fff; }
.btn.big { padding: .9em 1.5em; font-size: 1.06rem; border-radius: 12px; }
.btn.ghost { background: transparent; }
.eyebrow { display: inline-flex; align-items: center; gap: .4em; font-size: .78rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }
.hint-text { color: var(--mute); font-size: .9rem; }
.card { background: var(--card); border: 1px solid var(--line2); border-radius: 14px; padding: 14px 16px; }
.card h3 { font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); margin-bottom: 8px; }
.t-ic { flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-size: 1.25rem; color: #fff; background: var(--ink); }
.t-ic.k-veh { background: var(--veh); } .t-ic.k-pow { background: var(--pow); color: var(--hazard); } .t-ic.k-alr { background: var(--alr); }

/* ------------------------------------------------------------------ title */
.home { max-width: 660px; margin: 0 auto; padding: 26px 16px 48px; }
.stripe { width: 104px; height: 12px; border-radius: 3px; margin-bottom: 14px;
  background: repeating-linear-gradient(135deg, var(--ink) 0 9px, var(--hazard) 9px 18px); }
.hero h1 { font-size: clamp(46px, 14vw, 88px); font-weight: 700; letter-spacing: .03em; line-height: .95; }
.tag { margin-top: 10px; font-size: clamp(1.05rem, 3.6vw, 1.3rem); color: var(--mute); }
.preview { margin: 12px -10px 8px; pointer-events: none; }
.preview .iso { height: auto; }
.threats { display: grid; gap: 8px; }
.threats li { display: flex; gap: 12px; align-items: flex-start; background: var(--card); border: 1px solid var(--line2); border-radius: 12px; padding: 11px 12px; }
.threats li > span:last-child { font-size: .95rem; color: var(--mute); }
.threats li b { display: block; font-weight: 600; color: var(--ink); font-size: 1.02rem; }
.deal { margin-top: 14px; font-size: 1.04rem; }
.namebox { display: grid; gap: 5px; margin-top: 16px; }
.namebox span { font-size: .78rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }
.namebox input { padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); font-size: 1.1rem; font-weight: 500; width: 100%; }
.namebox input.need { border-color: var(--high); }
.home .btn.big { width: 100%; margin-top: 12px; }
.home .resume { width: 100%; margin-top: 12px; border-color: var(--brand); color: var(--brand); }
.mini-board { margin-top: 18px; }
.mini-board .btn { margin-top: 10px; width: 100%; }
.foot { margin-top: 16px; color: var(--mute); font-size: .92rem; text-align: center; }

/* ------------------------------------------------------------------ frame */
body.playing { overflow: hidden; }
.play { height: 100dvh; display: flex; flex-direction: column; }
.hud { flex: none; background: var(--paper); border-bottom: 1px solid var(--line2); padding: 7px 8px 0; transition: background-color .7s; }
.hud-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; min-height: 38px; }
.brand { border: 0; background: none; padding: 0; font-weight: 700; letter-spacing: .08em; font-size: .95rem; }
.timer { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 99px; background: var(--ink); color: var(--paper); font: 700 .95rem var(--mono); }
.timer.amber { background: var(--mid); color: #16202f; } .timer.red { background: var(--high); color: #fff; }
.storm .timer { background: #eef2fb; color: #0b101c; }
.bar { margin-left: auto; display: flex; gap: 6px; }
.bar .btn { padding: 8px 12px; }
.bar .btn.go, .bar .btn.primary { padding: 8px 18px; }
.bar em { font: 600 .74rem var(--mono); font-style: normal; color: var(--mute); }
.bar em.new { background: var(--hazard); color: #16202f; border-radius: 8px; padding: 1px 6px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.stat { background: var(--card); border: 1px solid var(--line2); border-radius: 10px; padding: 5px 8px 6px; min-width: 0; }
.stat span { display: block; font-size: .64rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat b { display: inline-block; font: 700 1.15rem/1.15 var(--mono); }
.stat.grave { background: #16202f; border-color: #16202f; }
.stat.grave span { color: #a7b2c8; } .stat.grave b { color: #ff6b57; }
.storm .stat b { font-size: 1.5rem; }
.stat.bump b { animation: bump .4s; }
@keyframes bump { 40% { transform: scale(1.2); } }
.layer { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px 5px 9px; border-radius: 99px; border: 1.5px solid var(--line); background: var(--card); font-size: .84rem; font-weight: 500; white-space: nowrap; }
.layer.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.board-area { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.mapwrap { flex: 1; min-height: 0; position: relative; }
.mapbox { position: absolute; inset: 0; overflow: hidden; background: var(--sky); touch-action: none; cursor: grab; transition: background-color .7s; }
.mapbox:active { cursor: grabbing; }
.mapbox.shake { animation: shake .5s; }
@keyframes shake { 20% { transform: translate(-6px, 3px); } 40% { transform: translate(6px, -4px); } 60% { transform: translate(-4px, -2px); } 80% { transform: translate(3px, 3px); } }
.iso { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-select: none; }
.zoom { position: absolute; top: 8px; right: 8px; display: grid; gap: 5px; }
.zoom button { width: 40px; height: 40px; border-radius: 11px; border: 1.5px solid var(--line); background: var(--card); display: grid; place-items: center; font-size: 1.2rem; box-shadow: 0 3px 10px rgba(22, 32, 47, .14); }
.hint { position: absolute; left: 8px; right: 8px; bottom: 8px; display: flex; gap: 9px; align-items: center; padding: 8px 11px; border-radius: 12px;
  background: color-mix(in srgb, var(--card) 94%, transparent); border: 1.5px solid var(--line); font-size: .88rem; line-height: 1.3; box-shadow: 0 4px 14px rgba(22, 32, 47, .14); }
.hint > .ic { font-size: 1.15rem; color: var(--brand); }
.hint span { flex: 1; min-width: 0; }
.hint.placing { border-color: var(--brand); border-width: 2px; }
.hint .btn { padding: 7px 12px; }

/* ------------------------------------------------------------- the menu */
.dock { flex: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; padding: 7px 8px calc(7px + env(safe-area-inset-bottom)); background: var(--paper); border-top: 1px solid var(--line2); }
.tool { display: grid; grid-template-columns: auto 1fr; column-gap: 7px; align-items: center; text-align: left; padding: 6px 7px; border-radius: 11px; border: 1.5px solid var(--line); background: var(--card); min-width: 0; }
.tool-ic { grid-row: 1 / 3; width: 32px; height: 32px; border-radius: 9px; background: var(--line2); display: grid; place-items: center; font-size: 1.15rem; }
.tool b { font-weight: 600; font-size: .86rem; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool .t-full { display: none; }
.tool-cost { font: 700 .76rem var(--mono); color: var(--mute); }
.tool small { display: none; }
.tool.on { border-color: var(--brand); background: var(--brand); color: #fff; }
.tool.on .tool-ic { background: rgba(255, 255, 255, .22); }
.tool.on .tool-cost { color: #dfe6ff; }
.tool.poor { opacity: .45; }

/* ------------------------------------------------------------------- map */
.iso [data-i] { cursor: pointer; }
.gnd { stroke: rgba(22, 32, 47, .1); stroke-width: 1; }
.lane { stroke: #fff; stroke-width: 2; stroke-dasharray: 7 9; opacity: .55; }
.l-ground .lane, .l-over, .l-rings, .l-fx, .l-pops { pointer-events: none; }
.hl { fill: none; stroke: none; }
.hl.d1 { fill: rgba(210, 60, 40, .13); } .hl.d2 { fill: rgba(210, 60, 40, .26); }
.hl.d3 { fill: rgba(210, 60, 40, .4); } .hl.d4 { fill: rgba(190, 30, 20, .56); stroke: #8f1408; stroke-width: 2; }
.hl.t1 { fill: rgba(255, 130, 30, .2); } .hl.t2 { fill: rgba(255, 115, 20, .4); } .hl.t3 { fill: rgba(245, 90, 10, .6); }
.hl.a1 { fill: rgba(122, 63, 208, .2); } .hl.a2 { fill: rgba(122, 63, 208, .42); }
.hl.glow { fill: rgba(35, 70, 216, .34); stroke: #2346d8; stroke-width: 2; }
.hl.valid { fill: rgba(40, 200, 120, .5); stroke: #0f7a45; stroke-width: 3; animation: valid 1.1s ease-in-out infinite; }
@keyframes valid { 50% { fill: rgba(40, 200, 120, .22); } }
.hl.sel { fill: rgba(35, 70, 216, .22); stroke: #2346d8; stroke-width: 5; stroke-linejoin: round; }
.range { fill: rgba(122, 63, 208, .045); stroke: var(--alr); stroke-width: 2.5; stroke-dasharray: 9 9; opacity: .75; }

.bdg .ring { fill: #16202f; stroke: #fff; stroke-width: 2.5; }
.bdg.r-low .ring { fill: var(--low); } .bdg.r-mid .ring { fill: var(--mid); } .bdg.r-high .ring { fill: var(--high); }
.bdg .disc { fill: #fff; }
.bdg .bi { color: #16202f; }
.bdg .num rect { fill: var(--low); stroke: #fff; stroke-width: 2; }
.bdg.r-mid .num rect { fill: var(--mid); } .bdg.r-high .num rect { fill: var(--high); }
.bdg .num text { fill: #fff; font: 700 16px var(--mono); }
.bdg.quiet .num, .bdg.control .num { display: none; }
.bdg.launch .disc { fill: #16202f; } .bdg.launch .bi { color: #fff; }
.bdg.launch.quiet .ring { fill: var(--high); }
.bdg.launch.quiet.held .ring { fill: var(--low); }
.bdg.control .ring { fill: var(--high); stroke: rgba(210, 60, 40, .45); animation: beacon 1.6s ease-out infinite; }
@keyframes beacon { from { stroke-width: 0; } to { stroke-width: 30px; stroke: rgba(210, 60, 40, 0); } }
.chip circle { fill: var(--brand); stroke: #fff; stroke-width: 2.5; }
.chip svg { color: #fff; }
.chip.up circle { fill: var(--low); }
.chip.flash circle { fill: var(--hazard); animation: pop .5s; }
.chip.flash svg { color: #16202f; }

/* ------------------------------------------------------------- the panel */
.sheet-empty { display: flex; gap: 10px; align-items: center; color: var(--mute); padding: 14px 16px; border: 1.5px dashed var(--line); border-radius: 14px; }
.sheet-head { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; margin-bottom: 10px; }
.sheet-head h3 { font-size: 1.25rem; line-height: 1.15; }
.sheet-head p { color: var(--mute); font-size: .86rem; }
.sheet-ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 1.6rem; background: var(--ink); color: var(--paper); }
.x { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--line2); display: grid; place-items: center; font-size: 1.05rem; }
.dbar { display: block; height: 7px; border-radius: 4px; background: var(--line2); overflow: hidden; }
.dbar i { display: block; height: 100%; background: var(--high); border-radius: 4px; }
.parts { display: grid; gap: 5px; }
.parts li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 10px; background: color-mix(in srgb, var(--high) 8%, var(--card)); font-size: .9rem; color: var(--mute); }
.parts li .ic { color: var(--high); font-size: 1.15rem; margin-top: .1em; }
.parts b { display: block; color: var(--ink); font-weight: 600; }
.sheet .body { font-size: .96rem; }
.notes { margin-top: 8px; display: grid; gap: 4px; font-size: .9rem; color: var(--mute); }
.notes li { padding-left: 14px; position: relative; }
.notes li::before { content: ''; position: absolute; left: 2px; top: .62em; width: 5px; height: 5px; border-radius: 50%; background: var(--faint); }
.notes.warn li { color: var(--ink); } .notes.warn li::before { background: var(--high); }
.sheet h4 { font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); margin: 14px 0 6px; }
.opt { display: grid; grid-template-columns: auto 1fr auto; gap: 11px; align-items: start; width: 100%; text-align: left; padding: 10px 11px; margin-bottom: 6px;
  background: var(--card); border: 1.5px solid var(--line); border-radius: 12px; }
.opt:not(:disabled):hover { border-color: var(--ink); }
.opt:disabled { cursor: default; color: var(--mute); }
.opt.owned { border-color: var(--low); background: color-mix(in srgb, var(--low) 8%, var(--card)); }
.opt-ic { width: 36px; height: 36px; border-radius: 10px; background: var(--line2); display: grid; place-items: center; font-size: 1.25rem; }
.opt.owned .opt-ic { background: var(--low); color: #fff; }
.opt-main { display: grid; gap: 2px; min-width: 0; }
.opt-main b { font-weight: 600; line-height: 1.2; font-size: 1.02rem; }
.opt-main > span { font-size: .86rem; color: var(--mute); }
.opt-main .short { color: var(--high); font-weight: 600; }
.price { font: 700 .95rem var(--mono); padding: 4px 9px; border-radius: 8px; background: var(--ink); color: var(--paper); white-space: nowrap; text-align: center; }
.price.done { background: var(--low); color: #fff; display: grid; justify-items: center; font-family: var(--font); font-size: .84rem; }
.price.done small { font: 700 .72rem var(--mono); opacity: .95; }
.opt:disabled .price { background: var(--line2); color: var(--mute); }

/* ----------------------------------------------------------- modal, toast */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(9, 13, 24, .66); display: grid; place-items: center; padding: 14px; animation: fade .18s; }
.modal-card { width: min(100%, 560px); max-height: 92dvh; overflow: auto; background: var(--card); color: var(--ink); border-radius: 18px; padding: 22px 20px 20px; box-shadow: 0 24px 60px rgba(0, 0, 0, .4); animation: rise .22s; }
.modal h2 { font-size: 1.55rem; line-height: 1.15; margin: 6px 0 10px; }
.brief p + p { margin-top: 9px; }
.steps { display: grid; gap: 9px; margin: 14px 0; }
.steps li { display: flex; gap: 11px; align-items: flex-start; font-size: .96rem; }
.brief .btn.big, .fact-card .btn, .facts-list > .btn { width: 100%; margin-top: 16px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.fact-card p { font-size: 1.06rem; }
.fact-card .src { margin-top: 10px; font-size: .8rem; color: var(--faint); }
.fact-card .eyebrow .ic, .facts-list .eyebrow .ic { color: var(--mid-ink); }
.factlist { display: grid; gap: 5px; margin-top: 10px; }
.fact-row { display: flex; gap: 9px; align-items: center; width: 100%; text-align: left; padding: 9px 11px; border-radius: 10px; border: 1.5px solid var(--line2); background: var(--card); font-weight: 500; }
.fact-row .ic { color: var(--mid-ink); }
.locked { display: flex; gap: 9px; align-items: center; padding: 9px 11px; border-radius: 10px; border: 1.5px dashed var(--line); color: var(--faint); font-size: .92rem; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }

.toasts { position: fixed; top: 6px; left: 8px; right: 8px; z-index: 70; display: grid; justify-items: center; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; width: min(100%, 440px); min-height: 40px; text-align: left; padding: 4px 6px 4px 10px; border: 0; border-radius: 11px;
  background: #16202f; color: #f3eee4; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); animation: drop .25s; }
.toast.out { opacity: 0; transform: translateY(-8px); transition: .25s; }
.toast > .ic { font-size: 1.15rem; color: var(--hazard); }
.toast span { display: grid; flex: 1; min-width: 0; }
.toast small { display: none; }
.toast b { font-weight: 600; }
.toast.fact b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast em { font-style: normal; font-weight: 600; font-size: .86rem; padding: 4px 10px; border-radius: 8px; background: var(--hazard); color: #16202f; }
.toast.warn { background: var(--high); color: #fff; padding: 8px 12px; }
@keyframes drop { from { transform: translateY(-12px); opacity: 0; } }

/* ------------------------------------------------------------ the attack */
.live .hint, .live .side, .live .zoom { display: none; }
.live .l-rings:not(.on) .range { display: none; }
.live .mapbox { cursor: default; }
.storm .l-ground { filter: brightness(.48) saturate(.75); }
.storm .l-objs { filter: brightness(.74) saturate(.85); }
.live .bdg.target:not(.struck) { opacity: .35; }
.bdg.struck { animation: pop .5s ease-out; }
@keyframes pop { 0% { opacity: .2; } 40% { opacity: 1; filter: brightness(2.2); } 100% { filter: none; } }
.live .bdg.control .ring, .frozen .bdg.control .ring { animation: none; stroke: #fff; }
.hl.struck { animation: pop .5s ease-out; }
.tile.dark { filter: brightness(.3) saturate(.35); transition: filter .5s; }
.tile.lit .win { fill: #ffe7a0; }
.l-rings.on .range { fill: none; opacity: 1; stroke: #c9a2ff; stroke-dasharray: none; stroke-width: 5; transform-box: fill-box; transform-origin: center; animation: ring 1.8s ease-out infinite; }
@keyframes ring { from { transform: scale(.05); opacity: 1; } to { transform: scale(1); opacity: 0; } }
.arc { fill: none; stroke: #ff5340; stroke-width: 5; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; filter: drop-shadow(0 0 6px #ff5340); animation: arc 1s ease-out forwards; }
@keyframes arc { to { stroke-dashoffset: 0; } }
.walker { fill: #c9a2ff; stroke: #fff; stroke-width: 1.5; transition: transform 2.8s ease-in-out, fill .3s; }
.walker.down { fill: #ff3b28; }
.walker.near { transition-duration: 1.2s, .3s; }
.car { transition: transform .42s linear; }
.car.ram { transition: transform .85s ease-in; }
.pop { fill: #fff; font: 700 24px var(--mono); paint-order: stroke; stroke: #16202f; stroke-width: 6px; stroke-linejoin: round; animation: rise-off 2.4s ease-out forwards; }
.pop.bad { fill: #ff7a66; }
.pop.good { fill: #7dffb0; font-size: 18px; }
.tool { position: relative; }
/* Placing something that only works inside a mast's circle: the circles get loud. */
.iso.ranges .range { fill: rgba(122, 63, 208, .13); stroke-width: 5; opacity: 1; }
.iso.many .hl.valid { animation: none; fill: rgba(40, 200, 120, .4); }
/* What a thing did, under its name in the report. */
.worth .did { display: block; font-style: normal; font-size: .82rem; line-height: 1.3; color: var(--mute); margin-top: 2px; }
/* The towns that came before, and the way to them. */
.kept { margin: 10px 2px 0; }
.kept a, .link { color: var(--brand); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.link { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; cursor: pointer; }
.boardpage .tabs.towns { margin-bottom: 0; }
.boardpage .tabs.towns .layer.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.hint b { font-weight: 600; }
.pop.big { font-size: 64px; stroke-width: 10px; animation-duration: 3.4s; }
@keyframes rise-off { 0% { transform: translateY(8px); opacity: 0; } 15% { opacity: 1; } 70% { opacity: 1; } 100% { transform: translateY(-46px); opacity: 0; } }
.caption { position: absolute; left: 8px; right: 8px; top: 8px; display: none; gap: 10px; align-items: flex-start; padding: 11px 13px; border-radius: 14px; background: rgba(11, 16, 28, .9); color: #eef2fb; border-left: 5px solid #7f8ba5; font-size: 1.02rem; line-height: 1.3; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); }
.caption.show { display: flex; animation: drop .3s; }
.caption b { font: 700 .95rem var(--mono); color: var(--hazard); padding-top: .1em; }
.caption.bad { border-left-color: #ff5340; } .caption.good { border-left-color: #3fc27d; }
.tally { position: absolute; left: 8px; right: 8px; bottom: 8px; padding: 16px; border-radius: 18px; background: rgba(11, 16, 28, .95); color: #eef2fb; box-shadow: 0 12px 40px rgba(0, 0, 0, .5); animation: rise .4s; }
.tally .eyebrow { color: var(--hazard); }
.tally-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.tally-nums div { background: #1c2740; border-radius: 12px; padding: 9px 11px; }
.tally-nums b { display: block; font: 700 1.6rem var(--mono); }
.tally-nums .grave b { color: #ff6b57; }
.tally-nums span { font-size: .78rem; color: #a7b2c8; }
.tally-score { display: grid; grid-template-columns: auto 1fr; align-items: baseline; column-gap: 12px; margin-bottom: 12px; }
.tally-score span { font-size: .78rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #a7b2c8; }
.tally-score b { font: 700 2.4rem var(--mono); color: var(--hazard); }
.tally-score small { grid-column: 1 / -1; color: #a7b2c8; min-height: 1.3em; }
.tally .btn { width: 100%; background: #eef2fb; border-color: #eef2fb; color: #0b101c; }
.frozen [data-i] { cursor: default; }
.daycard { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 24px; background: #070a13; color: #eef2fb; text-align: center; animation: fade .5s; transition: opacity .4s; }
.daycard.out { opacity: 0; }
.daycard span { display: block; font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; color: var(--hazard); }
.daycard b { display: block; font: 700 clamp(1.7rem, 7vw, 3rem) var(--mono); margin: 12px 0; }
.daycard p { font-size: clamp(1.05rem, 4vw, 1.4rem); max-width: 22em; color: #c3ccdf; }

/* ---------------------------------------------------------------- report */
.report { max-width: 1100px; margin: 0 auto; padding: 22px 14px 64px; }
.verdict { padding: 22px 18px; border-radius: 18px; background: #16202f; color: #f3eee4; border-top: 8px solid var(--high); }
.verdict.pass { border-top-color: var(--mid); }
.verdict .eyebrow { color: #a7b2c8; }
.verdict h1 { font-size: clamp(1.9rem, 8.4vw, 3.2rem); line-height: 1.05; margin: 8px 0; letter-spacing: .01em; }
.verdict p { color: #c3ccdf; margin-top: 6px; max-width: 36em; font-size: 1.08rem; }
.scoreline { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.scoreline b { font: 700 2.3rem var(--mono); color: var(--hazard); }
.scoreline span { color: #a7b2c8; }
.tiles4 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.big4 { background: var(--card); border: 1px solid var(--line2); border-radius: 14px; padding: 11px 13px; }
.big4 span { display: block; font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--mute); }
.big4 b { font: 700 1.7rem/1.2 var(--mono); }
.big4 small { display: block; color: var(--mute); }
.big4.bad b { color: var(--high); } .big4.good b { color: var(--low); }
.rep-grid { display: grid; gap: 10px; }
.rep-map { background: var(--card); border: 1px solid var(--line2); border-radius: 14px; padding: 14px; overflow: hidden; }
.rep-map h3 { font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); margin-bottom: 6px; }
.rep-map .iso { height: auto; }
.rep-map .hint-text { margin-top: 4px; }
.rep-body { display: grid; gap: 10px; align-content: start; }
.lines { display: grid; gap: 6px; }
.lines li { padding: 8px 11px; border-left: 4px solid var(--faint); border-radius: 8px; background: color-mix(in srgb, var(--ink) 5%, var(--card)); font-size: .93rem; }
.lines .l-high { border-color: var(--high); } .lines .l-mid { border-color: var(--mid); } .lines .l-low { border-color: var(--low); }
.sites, .worth, .board { width: 100%; border-collapse: collapse; font-size: .9rem; }
.sites { margin-top: 12px; }
.sites td, .worth td, .board td { padding: 6px 0; border-top: 1px solid var(--line2); }
.sites td:first-child { font-weight: 600; white-space: nowrap; padding-right: 12px; }
.sites td:first-child::before { content: ''; display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; background: var(--high); }
.sites tr.held td:first-child::before { background: var(--low); }
.sites td:last-child { color: var(--mute); }
.worth th, .board th { text-align: right; font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; color: var(--mute); font-weight: 600; padding-bottom: 4px; }
.worth th:first-child, .board th:nth-child(-n+2) { text-align: left; }
.worth td:first-child { display: flex; gap: 9px; align-items: flex-start; }
.worth td:first-child .ic { font-size: 1.1rem; margin-top: .15em; color: var(--mute); }
.worth td:first-child b { font-weight: 600; }
.worth td:first-child small { display: block; color: var(--mute); }
.worth td:not(:first-child) { text-align: right; font: 700 .95rem var(--mono); white-space: nowrap; padding-left: 10px; }
.worth tr.good td:nth-child(2) { color: var(--low); }
.worth tr.none td { color: var(--faint); }
.worth + .hint-text { margin-top: 10px; }
.worth.score .total td { border-top: 2px solid var(--ink); font-weight: 700; }
.learn ul { display: grid; gap: 8px; font-size: 1.04rem; font-weight: 500; }
.learn li { padding-left: 14px; border-left: 4px solid var(--hazard); }
.again { display: grid; gap: 8px; margin-top: 16px; }
.share { margin-top: 12px; }

/* ----------------------------------------------------------- leaderboard */
.board td { font-family: var(--mono); text-align: right; padding: 8px 0 8px 10px; }
.board td:nth-child(2) { font-family: var(--font); font-weight: 600; text-align: left; overflow: hidden; text-overflow: ellipsis; max-width: 9em; white-space: nowrap; }
.board td:first-child { text-align: left; color: var(--mute); padding-left: 0; }
.board td:nth-child(3) { font-weight: 700; }
.board tbody tr { cursor: pointer; }
.board tbody tr:hover td { background: color-mix(in srgb, var(--brand) 7%, transparent); }
.board tr.hidden-row td { opacity: .45; }
.board small { color: var(--high); font-family: var(--font); font-weight: 500; }
.board .btn { padding: 4px 9px; font-size: .8rem; }
.board.full td:nth-child(n+5), .board.full th:nth-child(n+5) { display: none; }
.boardpage .tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.boardpage .gap { flex: 1; }
.boardpage .card + .again { margin-top: 14px; }
.board + .hint-text { margin-top: 10px; }

/* --------------------------------------------------------------- narrow */
@media (max-width: 899px) {
  .sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; max-height: 58dvh; overflow: auto; overscroll-behavior: contain;
    background: var(--card); border-radius: 18px 18px 0 0; box-shadow: 0 -10px 34px rgba(13, 19, 33, .3);
    padding: 14px 14px calc(14px + env(safe-area-inset-bottom)); transform: translateY(105%); transition: transform .22s ease; }
  body.sheet-open .sheet { transform: none; }
  .sheet-empty { display: none; }
  .layer span { display: none; }
  .layer.on span, .tabs .layer span { display: inline; }
}

/* ----------------------------------------------------------------- wide */
@media (min-width: 720px) {
  .tiles4 { grid-template-columns: repeat(4, 1fr); }
  .again { grid-template-columns: repeat(3, auto); justify-content: start; }
  .board.full td:nth-child(n+5), .board.full th:nth-child(n+5) { display: table-cell; }
  .board td:nth-child(2) { max-width: 16em; }
}
@media (min-width: 900px) {
  .hud { padding: 10px 18px 0; }
  .brand { font-size: 1.15rem; }
  .timer { font-size: 1.05rem; padding: 5px 13px; }
  .stats { max-width: 640px; }
  .stat { padding: 7px 12px 8px; }
  .stat span { font-size: .7rem; } .stat b { font-size: 1.4rem; }
  .storm .stat b { font-size: 1.9rem; }
  .board-area { flex-direction: row; }
  .side { flex: none; width: 430px; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; border-left: 1px solid var(--line2); background: var(--paper); }
  .dock { grid-template-columns: 1fr 1fr; padding: 0; border: 0; gap: 8px; }
  .tool { grid-template-columns: auto 1fr auto; padding: 10px; align-items: start; row-gap: 3px; }
  .tool-ic { grid-row: 1 / 2; width: 36px; height: 36px; }
  .tool b { font-size: .95rem; white-space: normal; align-self: center; }
  .tool .t-full { display: inline; } .tool .t-tag { display: none; }
  .tool-cost { font-size: .86rem; align-self: center; }
  .tool small { display: block; grid-column: 1 / -1; font-size: .8rem; color: var(--mute); line-height: 1.3; }
  .tool.on small { color: #dfe6ff; }
  .sheet { background: var(--card); border: 1px solid var(--line2); border-radius: 14px; padding: 16px; }
  .sheet:has(.sheet-empty) { background: none; border: 0; padding: 0; }
  .x { display: none; }
  .hint { left: 14px; right: auto; bottom: 14px; max-width: 560px; font-size: .95rem; }
  .zoom { top: 14px; right: 14px; }
  .caption { left: 50%; right: auto; transform: translateX(-50%); top: 16px; width: min(760px, 90%); font-size: 1.25rem; padding: 14px 18px; }
  .caption.show { animation: fade .3s; }
  .tally { left: 50%; right: auto; bottom: 24px; transform: translateX(-50%); width: 520px; animation: fade .4s; }
  .toasts { top: 10px; left: auto; right: 450px; width: 420px; }
  .rep-grid { grid-template-columns: minmax(0, 560px) 1fr; align-items: start; }
  .rep-map { position: sticky; top: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01s !important; animation-iteration-count: 1 !important; transition-duration: .01s !important; }
}
