/* Emergent Racing — shared look. Light/dark via tokens; Barlow for text, Barlow Condensed for numbers. */
:root {
  --bg: #e7ebe4; --panel: #f6f7f3; --ink: #1c2124; --muted: #59636a; --line: #c8cfc5;
  --grass: #b4c3a8; --runoff: #d6cfbb; --asphalt: #41464b; --asphalt-edge: #f2f2ee;
  --kerb: #d7263d; --kerb2: #f4f4f0; --tower: #1c2124; --tower-ink: #f4f5f1; --tower-muted: #9aa49d;
  --lead: #f0b400; --focus: #2b6cb0; --water: #cfe3ea; --deep: #9fc3d1; --sand: #e9dcc0;
  --f0: #d7263d; --f1: #2b6cb0; --f2: #e0a800; --f3: #0f9d8a; --f4: #7b4fc9;
  --ok: #2e8b57; --bad: #c0392b;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141916; --panel: #1c221e; --ink: #e5e9e3; --muted: #9aa39b; --line: #2f3832;
    --grass: #23301f; --runoff: #3b382f; --asphalt: #50565c; --asphalt-edge: #d9dad5;
    --kerb: #e0405a; --kerb2: #dcdcd6; --tower: #0d110f; --tower-ink: #eef0ec; --tower-muted: #8d978f;
    --lead: #f5c22e; --focus: #7fb0ea; --water: #14303a; --deep: #0e2129; --sand: #4a4130;
    --f0: #ef4b60; --f1: #5b9be0; --f2: #f2c230; --f3: #2fbfa8; --f4: #a07ce6;
    --ok: #5dc38a; --bad: #e8685a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141916; --panel: #1c221e; --ink: #e5e9e3; --muted: #9aa39b; --line: #2f3832;
  --grass: #23301f; --runoff: #3b382f; --asphalt: #50565c; --asphalt-edge: #d9dad5;
  --kerb: #e0405a; --kerb2: #dcdcd6; --tower: #0d110f; --tower-ink: #eef0ec; --tower-muted: #8d978f;
  --lead: #f5c22e; --focus: #7fb0ea; --water: #14303a; --deep: #0e2129; --sand: #4a4130;
  --f0: #ef4b60; --f1: #5b9be0; --f2: #f2c230; --f3: #2fbfa8; --f4: #a07ce6;
  --ok: #5dc38a; --bad: #e8685a;
  color-scheme: dark;
}
:root { box-sizing: border-box; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
*, *::before, *::after { box-sizing: inherit; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: "Barlow", "Helvetica Neue", Arial, sans-serif; font-size: 16px; line-height: 1.5; }
.wrap { max-width: 1360px; margin: 0 auto; padding: 14px clamp(12px, 3vw, 32px) 40px; }
.cond { font-family: "Barlow Condensed", "Arial Narrow", sans-serif; }
nav.er { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; font-size: 14px; color: var(--muted); margin-bottom: 10px; }
nav.er a { color: inherit; text-decoration: none; padding: 2px 0; border-bottom: 1px solid transparent; }
nav.er a:hover { border-bottom-color: var(--muted); }
nav.er a[aria-current="page"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }
nav.er .home { font-weight: 700; color: var(--ink); margin-right: 6px; }
header.er { display: grid; grid-template-columns: 1fr auto; gap: 8px 24px; align-items: end; margin-bottom: 14px; }
h1 { font-family: "Barlow Condensed", "Arial Narrow", sans-serif; font-weight: 700; font-size: clamp(30px, 4.4vw, 52px); line-height: 1; letter-spacing: -0.01em; margin: 0; }
.lede { grid-column: 1 / -1; margin: 6px 0 0; max-width: 72ch; color: var(--muted); }
.lede a { color: inherit; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.stage { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.bar.bottom { border-bottom: 0; border-top: 1px solid var(--line); }
.clock { font-family: "Barlow Condensed", "Arial Narrow", sans-serif; font-weight: 600; font-size: 22px; line-height: 1; font-variant-numeric: tabular-nums; }
.clock small { font-size: 15px; color: var(--muted); font-weight: 500; margin-left: 4px; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; align-items: center; }
button, .btn { font: 600 15px/1 "Barlow", "Helvetica Neue", Arial, sans-serif; color: var(--ink); background: transparent; border: 1px solid var(--line); border-radius: 4px; padding: 8px 12px; cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .btn:hover { border-color: var(--muted); }
button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button[aria-pressed="true"], .btn.primary { background: var(--ink); color: var(--panel); border-color: var(--ink); }
button:disabled { opacity: .45; cursor: default; }
.seg { display: inline-flex; }
.seg button { border-radius: 0; margin-left: -1px; }
.seg button:first-child { border-radius: 4px 0 0 4px; margin-left: 0; }
.seg button:last-child { border-radius: 0 4px 4px 0; }
canvas.main { display: block; width: 100%; height: auto; touch-action: none; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 10px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 18px; height: 8px; border-radius: 2px; display: inline-block; background: var(--f0); }
aside { display: grid; gap: 18px; }
.tower { background: var(--tower); color: var(--tower-ink); border-radius: 6px; overflow: hidden; }
.tower-head { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 12px 8px; font-family: "Barlow Condensed", "Arial Narrow", sans-serif; }
.tower-head b { font-size: 24px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.tower-head span { color: var(--tower-muted); font-size: 15px; }
.tower ol { list-style: none; margin: 0; padding: 0 0 6px; }
.tower li { display: grid; grid-template-columns: 26px 5px 1fr auto; gap: 8px; align-items: center; padding: 3px 12px; font-family: "Barlow Condensed", "Arial Narrow", sans-serif; font-size: 17px; line-height: 1.25; font-variant-numeric: tabular-nums; }
.tower li .pos { text-align: right; font-weight: 700; }
.tower li .chip { height: 16px; border-radius: 1px; }
.tower li .chip.child { opacity: .55; }
.tower li .who { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tower li .who em { font-style: normal; color: var(--tower-muted); margin-left: 6px; font-size: 15px; }
.tower li .gap { text-align: right; }
.tower li.out { color: var(--tower-muted); }
.tower li.lead .pos { color: var(--lead); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px 14px; }
.card h2 { font-family: "Barlow Condensed", "Arial Narrow", sans-serif; font-weight: 600; font-size: 20px; line-height: 1.2; margin: 0 0 8px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 10px; margin: 0; }
.stats div { min-width: 0; }
.stats dt { font-size: 13px; color: var(--muted); }
.stats dd { margin: 0; font-family: "Barlow Condensed", "Arial Narrow", sans-serif; font-weight: 600; font-size: 24px; line-height: 1.1; font-variant-numeric: tabular-nums; }
canvas.small { display: block; width: 100%; height: auto; }
.note { font-size: 14px; color: var(--muted); margin: 8px 0 0; }
.toast { min-height: 1.5em; margin: 0; padding: 0 14px 10px; font-weight: 600; }
.gauges { display: grid; grid-template-columns: 44px 1fr 44px; gap: 6px 8px; align-items: center; font-size: 14px; margin-top: 8px; }
.gauge { position: relative; height: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 2px; }
.gauge i { position: absolute; top: 0; bottom: 0; background: var(--ink); }
.gauge::after { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--muted); }
.gauges output { text-align: right; font-variant-numeric: tabular-nums; }
.sliders { display: grid; grid-template-columns: 110px 1fr 44px; gap: 8px 10px; align-items: center; font-size: 14px; }
.sliders input[type=range] { width: 100%; accent-color: var(--ink); }
.sliders output { text-align: right; font-variant-numeric: tabular-nums; font-family: "Barlow Condensed", sans-serif; font-size: 17px; }
input[type=text] { font: 15px "Barlow", sans-serif; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 7px 9px; }
textarea { font: 15px/1.4 "Barlow", sans-serif; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 7px 9px; width: 100%; min-height: 64px; resize: vertical; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.pill.ok { color: var(--ok); border-color: var(--ok); }
.pill.bad { color: var(--bad); border-color: var(--bad); }
/* feedback widget */
.fb { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px 14px; margin-top: 18px; }
.fb h2 { font-family: "Barlow Condensed", "Arial Narrow", sans-serif; font-weight: 600; font-size: 20px; margin: 0 0 6px; }
.fb .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.fb .votes button { font-size: 18px; padding: 6px 12px; }
.fb .count { color: var(--muted); font-size: 14px; }
.fb .status { font-size: 14px; color: var(--muted); min-height: 1.4em; margin-top: 6px; }
.fb ul.notes { list-style: none; padding: 0; margin: 10px 0 0; font-size: 14px; color: var(--muted); display: grid; gap: 4px; }
.fb ul.notes li b { color: var(--ink); font-weight: 600; }
.share-out { font: 14px/1.5 ui-monospace, Menlo, Consolas, monospace; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px; white-space: pre-wrap; margin: 8px 0 0; }
.keys { display: inline-grid; grid-template-columns: repeat(3, 28px); gap: 2px; vertical-align: middle; }
.keys b { display: block; height: 24px; border: 1px solid var(--line); border-radius: 3px; font: 600 12px/22px "Barlow", sans-serif; text-align: center; }
.touch { display: none; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); }
.touch button { flex: 1; font-size: 20px; padding: 14px 0; }
@media (pointer: coarse) { .touch { display: flex; } }
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  aside { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
  header.er { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
