/* HOLD THE LINE — shared styles */
:root {
  --red: #e5372b;
  --red-deep: #b8231a;
  --gold: #ffb320;
  --teal: #12968d;
  --sky: #bfe6ff;
  --navy: #13203b;
  --bg: #fff7ea;
  --bg-2: #ffeccc;
  --card: #ffffff;
  --ink: #17213a;
  --ink-soft: #4a5470;
  --line: #e6d7bd;
  --shadow: 0 6px 0 rgba(19, 32, 59, .12), 0 14px 30px rgba(19, 32, 59, .08);
  --radius: 18px;
  --display: "Bowlby One", "Arial Black", Impact, sans-serif;
  --body: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0e1628;
  --bg-2: #16213b;
  --card: #1b2744;
  --ink: #f6efe2;
  --ink-soft: #b9c0d4;
  --line: #2c3a5c;
  --sky: #24406b;
  --shadow: 0 6px 0 rgba(0, 0, 0, .35), 0 14px 30px rgba(0, 0, 0, .3);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  overflow-x: hidden;
}
img, canvas, svg { max-width: 100%; }
a { color: var(--red); }
[data-theme="dark"] a { color: #ff8a7f; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--gold); color: #000; padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- header ---------- */
.site-head {
  position: sticky; top: 0; z-index: 30;
  background: var(--navy);
  color: #fff;
  border-bottom: 4px solid var(--red);
}
.site-head .wrap { display: flex; align-items: center; gap: 12px; padding: 8px 16px; max-width: 1100px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-family: var(--display); font-size: 1.05rem; letter-spacing: .02em; white-space: nowrap; }
.brand img { width: 30px; height: 30px; }
.nav { display: flex; gap: 2px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: #dfe6f5; text-decoration: none; padding: 7px 10px; border-radius: 999px; font-weight: 600; font-size: .9rem; white-space: nowrap; }
.nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav a[aria-current="page"] { background: var(--red); color: #fff; }
.icon-btn { background: rgba(255,255,255,.1); border: 0; color: #fff; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 1rem; flex: none; }
.icon-btn:hover { background: rgba(255,255,255,.2); }
@media (max-width: 640px) {
  .site-head .wrap { flex-wrap: wrap; padding: 6px 10px; gap: 6px; }
  .brand span { font-size: .95rem; }
  .nav { order: 3; width: 100%; margin-left: 0; }
  .nav a { font-size: .82rem; padding: 6px 9px; }
  .head-tools { margin-left: auto; }
}
.head-tools { display: flex; gap: 6px; }

/* ---------- layout ---------- */
main { display: block; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.section { padding: 36px 0; }
h1, h2, h3 { font-family: var(--display); font-weight: 400; line-height: 1.1; letter-spacing: .01em; margin: 0 0 .5em; }
h1 { font-size: clamp(2.1rem, 7vw, 4.2rem); }
h2 { font-size: clamp(1.5rem, 4.5vw, 2.3rem); }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; }
.lede { font-size: 1.12rem; color: var(--ink-soft); max-width: 60ch; }
.kicker { display: inline-block; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; font-size: .78rem; color: var(--red); margin-bottom: 8px; }
[data-theme="dark"] .kicker { color: var(--gold); }

.card { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.grid { display: grid; gap: 14px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 700 1rem var(--body);
  padding: 12px 20px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--red); color: #fff; text-decoration: none;
  box-shadow: 0 4px 0 var(--red-deep);
  transition: transform .08s, box-shadow .08s, filter .15s;
  min-height: 44px;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--red-deep); }
.btn.alt { background: var(--navy); box-shadow: 0 4px 0 #050b18; }
[data-theme="dark"] .btn.alt { background: #33466f; box-shadow: 0 4px 0 #111a2e; }
.btn.gold { background: var(--gold); color: #1b1300; box-shadow: 0 4px 0 #c78400; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); }
.btn.small { padding: 8px 14px; font-size: .9rem; min-height: 38px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- hero ---------- */
.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(180deg, var(--sky) 0%, var(--bg) 100%);
  padding: 34px 0 26px;
}
[data-theme="dark"] .hero { background: linear-gradient(180deg, #1d3258 0%, var(--bg) 100%); }
.hero .wrap { position: relative; z-index: 2; display: grid; gap: 20px; grid-template-columns: 1.2fr .8fr; align-items: center; }
@media (max-width: 760px) { .hero .wrap { grid-template-columns: 1fr; } }
.hero h1 { color: var(--navy); }
[data-theme="dark"] .hero h1 { color: #fff; }
.hero h1 em { font-style: normal; color: var(--red); }
.hero-art { display: flex; justify-content: center; }
.hero-art canvas { width: min(320px, 80vw); height: auto; animation: bob 4s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-12px) rotate(2deg); } }
.stats-strip { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 18px; padding: 0; list-style: none; }
.stats-strip li { background: var(--card); border: 2px solid var(--line); border-radius: 999px; padding: 4px 12px; font-weight: 700; font-size: .88rem; }
.stats-strip b { color: var(--red); }
[data-theme="dark"] .stats-strip b { color: var(--gold); }
.countdown { font-weight: 700; color: var(--ink-soft); font-size: .95rem; }

/* ---------- pickers ---------- */
.picker { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.pick {
  position: relative; text-align: left; cursor: pointer;
  background: var(--card); color: var(--ink);
  border: 3px solid var(--line); border-radius: 16px; padding: 10px;
  font: inherit; display: flex; flex-direction: column; gap: 4px;
  transition: transform .1s, border-color .15s;
}
.pick:hover { transform: translateY(-2px); }
.pick[aria-pressed="true"] { border-color: var(--red); box-shadow: 0 0 0 3px rgba(229,55,43,.2); }
.pick canvas { width: 100%; height: auto; aspect-ratio: 1; background: linear-gradient(180deg, var(--sky), transparent); border-radius: 10px; }
.pick .name { font-weight: 800; }
.pick .meta { font-size: .8rem; color: var(--ink-soft); }
.pick .best { font-size: .78rem; font-weight: 700; color: var(--teal); }
.levels { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.lvl-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.wind-badge { font-size: .75rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--bg-2); white-space: nowrap; }
.wind-badge.hot { background: var(--red); color: #fff; }
.stars { color: var(--gold); letter-spacing: 2px; font-size: 1rem; }
.stars .off { color: var(--line); }

/* ---------- game ---------- */
.game-shell { display: none; }
.game-shell.on { display: block; }
body.playing .site-head, body.playing .hide-play, body.playing footer { display: none; }
body.playing .shared-banner, body.show-results .hero, body.show-results .shared-banner { display: none; }
[hidden] { display: none !important; }
.game-stage { position: relative; max-width: 560px; margin: 0 auto; user-select: none; -webkit-user-select: none; touch-action: none; }
#game { display: block; width: 100%; border-radius: 0 0 16px 16px; background: #555; }
.hud {
  display: grid; grid-template-columns: 1fr auto auto; gap: 6px 10px; align-items: center;
  background: var(--navy); color: #fff; padding: 8px 12px; border-radius: 16px 16px 0 0; font-size: .85rem;
}
.hud .street { font-family: var(--display); font-size: 1rem; line-height: 1.1; }
.hud .next { font-size: .75rem; color: #b8c4e0; }
.hud .score { font-family: var(--display); font-size: 1.3rem; color: var(--gold); text-align: right; }
.hud .bars { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.meter { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: #b8c4e0; }
.meter .track { height: 8px; border-radius: 4px; background: rgba(255,255,255,.15); overflow: hidden; margin-top: 2px; }
.meter .fill { height: 100%; width: 100%; background: var(--teal); transition: width .15s; }
.meter.skin .fill { background: #5ad17a; }
.meter.skin.low .fill { background: var(--red); }
.meter.brace .fill { background: var(--gold); }
.meter.prog .fill { background: #fff; }
.hud .wind { text-align: right; font-weight: 800; }
.hud .wind.warn { color: var(--gold); }
.hud .wind.bad { color: #ff7a6e; }
.pause-btn { background: rgba(255,255,255,.12); border: 0; color: #fff; border-radius: 8px; padding: 4px 8px; cursor: pointer; font-weight: 800; }
.toast {
  position: absolute; left: 50%; top: 96px; transform: translateX(-50%);
  background: rgba(19,32,59,.92); color: #fff; padding: 6px 14px; border-radius: 999px;
  font-weight: 800; font-size: .9rem; pointer-events: none; opacity: 0; transition: opacity .2s; white-space: nowrap; max-width: 92%; overflow: hidden; text-overflow: ellipsis;
}
.toast.on { opacity: 1; }
.toast.bad { background: rgba(200,30,20,.95); }
.toast.good { background: rgba(18,150,141,.95); }
.pad {
  display: grid; grid-template-columns: 1fr 1fr 1.3fr 1fr 1fr; gap: 6px; margin-top: 8px;
}
.pad button {
  font: 800 1.2rem var(--body); min-height: 58px; border-radius: 14px; border: 0;
  background: var(--navy); color: #fff; box-shadow: 0 4px 0 #050b18; touch-action: none; cursor: pointer;
}
[data-theme="dark"] .pad button { background: #2a3a60; box-shadow: 0 4px 0 #0b1222; }
.pad button.on { transform: translateY(3px); box-shadow: 0 1px 0 #050b18; background: var(--red); }
.pad button small { display: block; font-size: .62rem; font-weight: 700; opacity: .8; letter-spacing: .05em; }
.pad .brace-btn { background: var(--gold); color: #1b1300; box-shadow: 0 4px 0 #c78400; }
.keys-hint { text-align: center; font-size: .8rem; color: var(--ink-soft); margin: 8px 0 0; }
.overlay {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(10,16,32,.72); padding: 16px; z-index: 5; border-radius: 16px;
}
.overlay.on { display: flex; }
.overlay .card { max-width: 420px; width: 100%; max-height: 100%; overflow: auto; }
.overlay h2 { font-size: 1.6rem; }
.brief { padding-left: 1.1em; margin: 0 0 1em; }
.brief li { margin-bottom: 6px; }
.count { font-family: var(--display); font-size: 5rem; color: #fff; text-shadow: 0 4px 0 var(--red); }

/* ---------- results ---------- */
.results { display: none; }
.results.on { display: block; }
.result-grid { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 760px) { .result-grid { grid-template-columns: 1fr; } }
#resultCard, #sharedCard { width: 100%; height: auto; border-radius: 14px; box-shadow: var(--shadow); display: block; }
.log { list-style: none; padding: 0; margin: 0 0 1em; }
.log li { padding: 6px 0; border-bottom: 1px dashed var(--line); display: flex; justify-content: space-between; gap: 10px; }
.log li span:last-child { font-weight: 800; text-align: right; }
.shared-banner { background: var(--navy); color: #fff; }
.shared-banner .wrap { padding: 22px 16px; display: grid; gap: 16px; grid-template-columns: minmax(0, 300px) 1fr; align-items: center; }
@media (max-width: 640px) { .shared-banner .wrap { grid-template-columns: 1fr; } }
.shared-banner h2 { color: var(--gold); }

/* ---------- facts ---------- */
.facts { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.fact b { display: block; font-family: var(--display); font-size: 1.7rem; color: var(--red); line-height: 1.1; }
[data-theme="dark"] .fact b { color: var(--gold); }

/* ---------- workshop ---------- */
.ws { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); align-items: start; }
@media (max-width: 760px) { .ws { grid-template-columns: 1fr; } }
.ws-preview { position: sticky; top: 70px; text-align: center; }
@media (max-width: 760px) { .ws-preview { position: static; } }
#wsCanvas { width: 100%; max-width: 380px; height: auto; background: linear-gradient(180deg, var(--sky), var(--bg-2)); border-radius: 16px; }
.opt { margin-bottom: 14px; }
.opt > span { display: block; font-weight: 800; font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: 600 .88rem var(--body); padding: 7px 12px; border-radius: 999px; border: 2px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; min-height: 38px; }
.chip[aria-pressed="true"] { border-color: var(--red); background: var(--red); color: #fff; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.sw { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--card); box-shadow: 0 0 0 2px var(--line); cursor: pointer; padding: 0; }
.sw[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--red); }
.input { font: inherit; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); color: var(--ink); width: 100%; }
.statbars { display: grid; gap: 6px; text-align: left; margin: 12px auto; max-width: 380px; }
.statbar { display: grid; grid-template-columns: 110px 1fr 54px; gap: 8px; align-items: center; font-size: .85rem; font-weight: 700; }
.statbar .t { height: 10px; border-radius: 5px; background: var(--bg-2); overflow: hidden; }
.statbar .f { height: 100%; background: var(--teal); }
.saved { display: flex; flex-wrap: wrap; gap: 8px; }
.saved button { background: var(--card); border: 2px solid var(--line); border-radius: 12px; padding: 4px; cursor: pointer; width: 76px; color: var(--ink); font: 600 .7rem var(--body); }
.saved canvas { width: 100%; height: auto; }

/* ---------- wind lab ---------- */
.lab { display: grid; gap: 18px; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); }
@media (max-width: 760px) { .lab { grid-template-columns: 1fr; } }
#labCanvas { width: 100%; height: auto; border-radius: 16px; background: var(--sky); display: block; }
.range { margin-bottom: 14px; }
.range label { display: flex; justify-content: space-between; font-weight: 800; }
.range input { width: 100%; accent-color: var(--red); }
.verdict { font-family: var(--display); font-size: 1.5rem; padding: 12px 16px; border-radius: 14px; text-align: center; color: #fff; background: var(--teal); }
.verdict.warn { background: #d68a00; }
.verdict.no { background: var(--red); }
.readouts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.readout { background: var(--bg-2); border-radius: 12px; padding: 10px; }
.readout b { display: block; font-family: var(--display); font-size: 1.3rem; }
.readout span { font-size: .8rem; color: var(--ink-soft); }
.note { font-size: .82rem; color: var(--ink-soft); }

/* ---------- history ---------- */
.era-filter { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 22px; border-left: 4px dotted var(--red); }
.timeline li { position: relative; margin: 0 0 16px; }
.timeline li::before { content: ""; position: absolute; left: -33px; top: 18px; width: 18px; height: 18px; border-radius: 50%; background: var(--gold); border: 3px solid var(--bg); }
.timeline li.incident::before { background: var(--red); }
.timeline .yr { font-family: var(--display); font-size: 1.4rem; color: var(--red); }
[data-theme="dark"] .timeline .yr { color: var(--gold); }
.tag { display: inline-block; font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; padding: 2px 8px; border-radius: 999px; background: var(--bg-2); margin-left: 6px; vertical-align: middle; }
.tag.incident { background: var(--red); color: #fff; }
.quiz { max-width: 640px; margin: 0 auto; }
.q-opts { display: grid; gap: 8px; margin: 14px 0; }
.q-opt { text-align: left; font: 600 1rem var(--body); padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.q-opt:hover:not([disabled]) { border-color: var(--navy); }
.q-opt.right { background: #d9f6e2; border-color: #2f9e57; color: #10331d; }
.q-opt.wrong { background: #ffe0dc; border-color: var(--red); color: #4a0d07; }
.q-progress { height: 8px; background: var(--bg-2); border-radius: 4px; overflow: hidden; margin-bottom: 10px; }
.q-progress div { height: 100%; background: var(--red); width: 0; transition: width .3s; }
.q-explain { background: var(--bg-2); padding: 10px 12px; border-radius: 12px; font-size: .95rem; }

/* ---------- footer ---------- */
footer { background: var(--navy); color: #cfd6e8; padding: 26px 0; margin-top: 30px; font-size: .88rem; }
footer a { color: #fff; }
footer .wrap { display: grid; gap: 8px; }

.prose { max-width: 70ch; }
.prose li { margin-bottom: 6px; }
.src-list { word-break: break-word; font-size: .9rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
