/* Don't Hit the Wall — shared design system */
:root {
  --bg: #f7f2e8;
  --bg2: #efe7d6;
  --card: #fffdf8;
  --ink: #15171c;
  --ink2: #4a4f5c;
  --line: #2357ff;
  --line-ink: #1b45d6;
  --orange: #ff6b1a;
  --orange-ink: #c24400;
  --foil: #c9ced8;
  --good: #11865a;
  --warn: #c98a00;
  --bad: #d1343a;
  --border: #d9cfbc;
  --shadow: 0 2px 0 rgba(21, 23, 28, .9);
  --radius: 14px;
  --display: "Anton", Impact, "Arial Narrow", sans-serif;
  --body: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #121418;
  --bg2: #1b1e25;
  --card: #1f232b;
  --ink: #f2efe8;
  --ink2: #b4b8c3;
  --line: #5c84ff;
  --line-ink: #8eaaff;
  --orange: #ff7a30;
  --orange-ink: #ffa36d;
  --foil: #6b7280;
  --good: #3fcf8e;
  --warn: #f2bb3c;
  --bad: #ff6b70;
  --border: #343944;
  --shadow: 0 2px 0 rgba(0, 0, 0, .8);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.55;
  overflow-x: hidden;
}
img, svg, canvas { max-width: 100%; }
a { color: var(--line-ink); }
a:hover { color: var(--orange-ink); }
h1, h2, h3, .display {
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: .01em;
  line-height: 1.05;
  margin: 0 0 .4em;
}
h1 { font-size: clamp(2.4rem, 9vw, 4.6rem); text-transform: uppercase; }
h2 { font-size: clamp(1.7rem, 5.5vw, 2.6rem); text-transform: uppercase; }
h3 { font-size: 1.35rem; }
p { margin: 0 0 1em; }
.muted { color: var(--ink2); }
.small { font-size: .875rem; }
.center { text-align: center; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: -999px; top: 8px; z-index: 100;
  background: var(--ink); color: var(--bg); padding: 8px 12px; border-radius: 8px;
}
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }

.wrap { width: min(1100px, 100% - 32px); margin-inline: auto; }
.narrow { width: min(760px, 100% - 32px); margin-inline: auto; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 2px solid var(--ink);
}
.site-header .wrap { display: flex; align-items: center; gap: 12px; min-height: 58px; }
.brand {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--display); font-size: 1.25rem; text-transform: uppercase;
  color: var(--ink); text-decoration: none; white-space: nowrap;
}
.brand svg { width: 30px; height: 30px; flex: none; }
.nav { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.nav a {
  color: var(--ink); text-decoration: none; font-weight: 600; font-size: .92rem;
  padding: 7px 10px; border-radius: 999px;
}
.nav a:hover { background: var(--bg2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--ink); color: var(--bg); }
.icon-btn {
  border: 2px solid var(--ink); background: var(--card); color: var(--ink);
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  cursor: pointer; font-size: 1rem; flex: none;
}
.icon-btn svg { width: 18px; height: 18px; }
.menu-btn { display: none; }
@media (max-width: 820px) {
  .menu-btn { display: grid; margin-left: auto; }
  .nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; background: var(--bg);
    border-bottom: 2px solid var(--ink); padding: 8px 16px 14px;
  }
  .nav.open { display: flex; }
  .nav a { padding: 12px 10px; font-size: 1.05rem; }
}

/* ---------- Blue line motif ---------- */
.blue-line {
  height: 6px; background: var(--line); border-radius: 3px;
  position: relative; margin: 0 auto;
}
.blue-line.dash {
  background: repeating-linear-gradient(90deg, var(--line) 0 28px, transparent 28px 40px);
}

/* ---------- Buttons ---------- */
.btn {
  --b: var(--ink); --f: var(--bg);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--body); font-weight: 800; font-size: 1rem; letter-spacing: .01em;
  padding: 12px 20px; border-radius: 999px; border: 2px solid var(--ink);
  background: var(--b); color: var(--f); cursor: pointer; text-decoration: none;
  box-shadow: var(--shadow); transition: transform .08s ease, box-shadow .08s ease;
  min-height: 46px; touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.btn:hover { transform: translateY(-1px); color: var(--f); }
.btn:active { transform: translateY(2px); box-shadow: none; }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn.orange { --b: var(--orange); --f: #15171c; }
.btn.blue { --b: var(--line); --f: #fff; }
.btn.ghost { --b: var(--card); --f: var(--ink); }
.btn.small { padding: 8px 14px; font-size: .9rem; min-height: 38px; }
.btn.big { padding: 16px 28px; font-size: 1.15rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- Cards / chips ---------- */
.card {
  background: var(--card); border: 2px solid var(--ink); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.chip {
  display: inline-block; font-size: .78rem; font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase; padding: 3px 10px; border-radius: 999px;
  background: var(--ink); color: var(--bg);
}
.chip.blue { background: var(--line); color: #fff; }
.chip.orange { background: var(--orange); color: #15171c; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
section { padding: 36px 0; }

/* ---------- Forms ---------- */
label { font-weight: 700; }
input[type="text"], input[type="number"], select, textarea {
  font: inherit; color: var(--ink); background: var(--card);
  border: 2px solid var(--ink); border-radius: 10px; padding: 10px 12px; width: 100%;
}
textarea { resize: vertical; min-height: 70px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button, .opt {
  font: inherit; font-weight: 700; cursor: pointer; color: var(--ink);
  background: var(--card); border: 2px solid var(--ink); border-radius: 12px;
  padding: 10px 12px; text-align: left;
}
.seg button[aria-pressed="true"], .opt[aria-pressed="true"] {
  background: var(--ink); color: var(--bg);
}

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 40px; border-top: 2px solid var(--ink); padding: 28px 0 40px;
  background: var(--bg2); font-size: .92rem;
}
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 14px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 30px);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-weight: 700; opacity: 0; pointer-events: none; transition: .25s ease; z-index: 200;
  max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Hero ---------- */
.hero { padding: 34px 0 16px; position: relative; overflow: hidden; }
.hero .kicker { margin-bottom: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.hero h1 { margin-bottom: .15em; }
.hero h1 .hl { color: var(--line); }
.hero .lede { font-size: clamp(1.05rem, 2.6vw, 1.25rem); max-width: 640px; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 10px 22px; margin: 18px 0 6px; }
.hero-stats div { font-size: .85rem; color: var(--ink2); }
.hero-stats b { display: block; font-family: var(--display); font-size: 1.7rem; color: var(--ink); font-weight: 400; }

/* ---------- Game setup ---------- */
.setup { display: grid; gap: 18px; }
.profiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.profile {
  display: grid; gap: 2px; padding: 12px 14px; border-radius: 12px;
  border: 2px solid var(--ink); background: var(--card); cursor: pointer; text-align: left;
  font: inherit; color: var(--ink);
}
.profile b { font-family: var(--display); font-size: 1.3rem; font-weight: 400; }
.profile span { font-size: .85rem; color: var(--ink2); }
.profile[aria-pressed="true"] { background: var(--line); color: #fff; border-color: var(--ink); }
.profile[aria-pressed="true"] span { color: #e3e9ff; }
.pb { font-size: .78rem !important; font-weight: 700; }

/* ---------- Race ---------- */
.race-shell { position: relative; }
.hud {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 8px;
}
.hud .stat {
  background: var(--card); border: 2px solid var(--ink); border-radius: 10px; padding: 6px 8px;
  min-width: 0;
}
.hud .stat small { display: block; font-size: .68rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--ink2); }
.hud .stat b { font-family: var(--display); font-weight: 400; font-size: 1.35rem; line-height: 1.1; white-space: nowrap; }
.meters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 8px; }
.meter { font-size: .7rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.meter .bar { height: 12px; border: 2px solid var(--ink); border-radius: 8px; overflow: hidden; background: var(--bg2); margin-top: 3px; }
.meter .fill { height: 100%; width: 100%; background: var(--good); transition: width .2s linear, background .3s; }
.meter.low .fill { background: var(--warn); }
.meter.crit .fill { background: var(--bad); }
.meter.crit { animation: pulse 0.8s infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.canvas-box {
  position: relative; border: 2px solid var(--ink); border-radius: var(--radius); overflow: hidden;
  background: #9ec3ff; aspect-ratio: 16 / 9; max-height: 62vh; width: 100%;
}
.canvas-box canvas { display: block; width: 100%; height: 100%; }
@media (max-width: 600px) { .canvas-box { aspect-ratio: 4 / 3; } }
.progress { position: relative; height: 26px; margin: 10px 0 4px; }
.progress .track { position: absolute; left: 0; right: 0; top: 10px; height: 6px; border-radius: 3px; background: var(--border); }
.progress .done { position: absolute; left: 0; top: 10px; height: 6px; border-radius: 3px; background: var(--line); width: 0; }
.progress .me, .progress .ghost {
  position: absolute; top: 3px; width: 20px; height: 20px; border-radius: 50%;
  transform: translateX(-50%); border: 2px solid var(--ink);
}
.progress .me { background: var(--orange); z-index: 2; }
.progress .ghost { background: var(--foil); opacity: .85; }
.progress .tick { position: absolute; top: 18px; font-size: .62rem; font-weight: 800; color: var(--ink2); transform: translateX(-50%); }
.borough-tag {
  position: absolute; left: 10px; top: 10px; background: rgba(21,23,28,.85); color: #fff;
  font-weight: 800; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px;
}
.feed {
  position: absolute; left: 10px; bottom: 10px; right: 10px; display: grid; gap: 4px;
  pointer-events: none;
}
.feed div {
  justify-self: start; background: rgba(255,253,248,.94); color: #15171c; font-size: .82rem; font-weight: 700;
  padding: 4px 10px; border-radius: 8px; border: 2px solid #15171c; animation: feedIn .3s ease;
}
@keyframes feedIn { from { transform: translateY(8px); opacity: 0; } }
.controls { display: grid; gap: 10px; margin-top: 10px; }
.effort { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.effort button {
  font: inherit; font-weight: 800; font-size: .85rem; padding: 10px 2px; border-radius: 10px;
  border: 2px solid var(--ink); background: var(--card); color: var(--ink); cursor: pointer;
  touch-action: manipulation;
}
.effort button small { display: block; font-weight: 600; font-size: .66rem; color: var(--ink2); }
.effort button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.effort button[aria-pressed="true"] small { color: var(--foil); }
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.actions .btn { padding: 10px 4px; font-size: .86rem; min-height: 52px; flex-direction: column; gap: 0; line-height: 1.15; }
.actions .btn small { font-weight: 600; font-size: .68rem; }
.actions .btn.ready { animation: ready .6s ease-in-out infinite alternate; }
@keyframes ready { to { box-shadow: 0 0 0 4px var(--orange); } }
.keys { font-size: .78rem; color: var(--ink2); }
kbd {
  font-family: ui-monospace, monospace; font-size: .75rem; border: 1.5px solid var(--ink2);
  border-bottom-width: 3px; border-radius: 5px; padding: 0 5px;
}

/* sign popup over canvas */
.sign-pop {
  position: absolute; right: 12px; top: 44px; max-width: 58%;
  background: #f4e3c1; color: #15171c; border: 3px solid #15171c; border-radius: 6px;
  padding: 10px 12px; font-family: "Permanent Marker", var(--display); font-size: clamp(.85rem, 2.4vw, 1.2rem);
  line-height: 1.15; transform: rotate(-3deg); cursor: pointer; text-align: center;
  box-shadow: 0 6px 0 rgba(0,0,0,.35); animation: signIn .25s ease;
}
.sign-pop::after { content: "tap to high-five ✋"; display: block; font-family: var(--body); font-size: .68rem; font-weight: 800; margin-top: 6px; color: #7a4a00; }
@keyframes signIn { from { transform: rotate(-3deg) translateY(-20px) scale(.8); opacity: 0; } }

/* event modal */
.modal-back {
  position: fixed; inset: 0; background: rgba(10,12,16,.6); z-index: 90;
  display: grid; place-items: center; padding: 16px;
}
.modal {
  width: min(480px, 100%); background: var(--card); color: var(--ink); border: 3px solid var(--ink);
  border-radius: 18px; padding: 20px; box-shadow: 0 8px 0 rgba(0,0,0,.5); animation: pop .2s ease;
}
.modal .where { font-size: .78rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--orange-ink); }
.modal h3 { font-family: var(--display); font-size: 1.6rem; margin: 4px 0 6px; }
.modal .choices { display: grid; gap: 8px; margin-top: 12px; }
.modal .choices button { text-align: left; }
@keyframes pop { from { transform: scale(.92); opacity: 0; } }

/* ---------- Results ---------- */
.result-head { display: grid; gap: 18px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 860px) { .result-head { grid-template-columns: 1.05fr .95fr; } }
.bigtime { font-family: var(--display); font-size: clamp(3.2rem, 14vw, 5.6rem); line-height: 1; }
.archetype { font-family: var(--display); font-size: 1.6rem; color: var(--line-ink); text-transform: uppercase; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 14px 0; }
.kv div { background: var(--bg2); border-radius: 10px; padding: 8px 10px; }
.kv small { display: block; font-size: .7rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ink2); }
.kv b { font-size: 1.15rem; }
table.splits { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.splits th, table.splits td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; }
table.splits td.num, table.splits th.num { text-align: right; font-variant-numeric: tabular-nums; }
.chart-box { width: 100%; }
.chart-box canvas { width: 100%; height: auto; display: block; }
#card-canvas { width: 100%; height: auto; border-radius: 12px; border: 2px solid var(--ink); display: block; }
.album { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.album .s {
  background: #f4e3c1; color: #15171c; border: 2px solid #15171c; border-radius: 6px; padding: 10px;
  font-family: "Permanent Marker", var(--display); font-size: .95rem; line-height: 1.15; min-height: 80px;
  display: grid; place-items: center; text-align: center;
}
.album .s.locked { background: var(--bg2); color: var(--ink2); font-family: var(--body); font-weight: 700; border-style: dashed; border-color: var(--ink2); }
.album .s:nth-child(3n) { transform: rotate(1.5deg); }
.album .s:nth-child(3n+1) { transform: rotate(-1.5deg); }

/* ---------- Course page ---------- */
.profile-svg { width: 100%; height: auto; display: block; touch-action: pan-y; }
.subway { position: relative; padding-left: 0; list-style: none; margin: 0; }
.subway li { position: relative; padding: 0 0 18px 64px; min-height: 60px; }
.subway li::before {
  content: ""; position: absolute; left: 22px; top: 0; bottom: 0; width: 8px; background: var(--seg, var(--line));
}
.subway li:last-child::before { bottom: auto; height: 20px; }
.subway .stop {
  position: absolute; left: 10px; top: 0; width: 32px; height: 32px; border-radius: 50%;
  background: var(--card); border: 4px solid var(--ink); display: grid; place-items: center;
  font-weight: 900; font-size: .8rem; z-index: 1;
}
.subway li.hi .stop { background: var(--orange); }
.subway h3 { margin: 2px 0 2px; font-size: 1.25rem; }
.subway .meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 6px; }
.subway .meta span { font-size: .72rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--bg2); }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: .85rem; font-weight: 700; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; border: 1.5px solid var(--ink); }

/* ---------- Quiz ---------- */
.q-opts { display: grid; gap: 10px; margin-top: 12px; }
.q-opts button { width: 100%; }
.q-opts button.right { background: var(--good); color: #fff; border-color: var(--ink); }
.q-opts button.wrong { background: var(--bad); color: #fff; }
.qbar { height: 8px; background: var(--bg2); border-radius: 4px; overflow: hidden; margin: 8px 0 16px; }
.qbar div { height: 100%; background: var(--line); width: 0; transition: width .3s; }

/* ---------- Pace page ---------- */
table.pace-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.pace-table th, table.pace-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; }
table.pace-table td:nth-child(n+2), table.pace-table th:nth-child(n+2) { text-align: right; font-variant-numeric: tabular-nums; }
table.pace-table tr.key td { font-weight: 800; background: var(--bg2); }
.table-scroll { overflow-x: auto; }
.live-track { position: relative; height: 54px; margin: 18px 0 8px; }
.live-track .road { position: absolute; left: 0; right: 0; top: 22px; height: 10px; border-radius: 5px; background: linear-gradient(90deg, #8a8f99 0 7.6%, #f0a400 7.6% 50%, #2aa36b 50% 60.6%, #2357ff 60.6% 76.3%, #b34cd6 76.3% 81%, #2357ff 81% 100%); }
.live-track .dot { position: absolute; top: 12px; width: 30px; height: 30px; margin-left: -15px; border-radius: 50%; background: var(--orange); border: 3px solid var(--ink); transition: left .6s ease; }
.live-track .lbl { position: absolute; top: 40px; font-size: .68rem; font-weight: 800; transform: translateX(-50%); color: var(--ink2); white-space: nowrap; }

/* ---------- Signs page ---------- */
.sign-stage canvas { width: 100%; height: auto; display: block; border-radius: 10px; }
.line-list { max-height: 300px; overflow: auto; display: grid; gap: 6px; border: 2px solid var(--ink); border-radius: 12px; padding: 8px; background: var(--card); }
.line-list button { font: inherit; text-align: left; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--ink); cursor: pointer; }
.line-list button:hover, .line-list button[aria-pressed="true"] { border-color: var(--ink); background: var(--bg2); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches button { width: 48px; height: 48px; border-radius: 10px; border: 2px solid var(--ink); cursor: pointer; }
.swatches button[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--orange); }

/* ---------- Misc ---------- */
.prose h2 { margin-top: 1.2em; }
.prose li { margin-bottom: .4em; }
.fact-strip { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.fact-strip div { border-left: 6px solid var(--line); padding: 4px 0 4px 10px; }
.fact-strip b { font-family: var(--display); font-weight: 400; font-size: 1.7rem; display: block; line-height: 1.1; }
.banner-shared { border: 3px dashed var(--orange); }

@media (max-width: 480px) {
  .hud .stat b { font-size: 1.1rem; }
  .hud { gap: 5px; }
  .meters { gap: 5px; }
  .meter { font-size: .6rem; }
  .card { padding: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
