[hidden] { display: none !important; }
:root {
  --bg: #EDF0F3;
  --panel: #F8FAFB;
  --ink: #15202B;
  --muted: #5B6877;
  --line: #D3DAE1;
  --sim-bg: #FBFCFD;
  --grid: #E6EBF0;
  --grid-strong: #D2DAE2;
  --wall: #8A97A5;
  --drone: #2353C9;
  --brick: #B7791F;
  --target: #23864F;
  --crash: #C93A33;
  --timeout: #7B8794;
  --focus: #2353C9;
  --sans: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0B1015; --panel: #121A22; --ink: #E4EAF0; --muted: #8C9AAA; --line: #233040;
    --sim-bg: #0E141B; --grid: #18212B; --grid-strong: #243140; --wall: #4E5D6E;
    --drone: #6E98FF; --brick: #E0A84A; --target: #4CC283; --crash: #FF6B61; --timeout: #8C9AAA; --focus: #6E98FF;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0B1015; --panel: #121A22; --ink: #E4EAF0; --muted: #8C9AAA; --line: #233040;
  --sim-bg: #0E141B; --grid: #18212B; --grid-strong: #243140; --wall: #4E5D6E;
  --drone: #6E98FF; --brick: #E0A84A; --target: #4CC283; --crash: #FF6B61; --timeout: #8C9AAA; --focus: #6E98FF;
}
* { box-sizing: border-box; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.5;
  padding-inline: 16px; padding-block: 28px 56px;
}
.wrap { max-width: 1180px; margin: 0 auto; display: grid; gap: 28px; }
header { display: grid; gap: 6px; }
.eyebrow { font-family: var(--mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
h1 { font-size: clamp(28px, 4vw, 40px); line-height: 1.1; margin: 0; font-weight: 700; letter-spacing: -.01em; text-wrap: balance; }
.lede { margin: 0; color: var(--muted); max-width: 68ch; }
.lede strong { color: var(--ink); font-weight: 600; }
h2 { font-size: 19px; margin: 0; font-weight: 600; text-wrap: balance; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* stage */
.stage { display: grid; gap: 12px; }
.canvas-box { position: relative; width: 100%; aspect-ratio: 3 / 2; max-width: 100%; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--sim-bg); }
.canvas-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hud { position: absolute; left: 12px; top: 10px; font-family: var(--mono); font-size: 12px; line-height: 1.55; color: var(--ink); pointer-events: none; font-variant-numeric: tabular-nums; }
.hud .phase { display: inline-block; padding: 1px 8px; border-radius: 99px; font-weight: 500; border: 1px solid currentColor; }
.outcome { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); font-family: var(--mono); font-weight: 500; font-size: clamp(14px, 2.4vw, 20px); padding: 6px 16px; border-radius: 4px; background: var(--panel); border: 1.5px solid currentColor; pointer-events: none; }

.controls { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
button { font: inherit; font-size: 13px; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 5px; padding: 6px 12px; cursor: pointer; }
button:hover { border-color: var(--muted); }
button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button[aria-pressed="true"] { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.seg { display: inline-flex; }
.seg button { border-radius: 0; margin-left: -1px; font-family: var(--mono); font-size: 12px; }
.seg button:first-child { border-radius: 5px 0 0 5px; margin-left: 0; }
.seg button:last-child { border-radius: 0 5px 5px 0; }
.label { font-size: 12px; color: var(--muted); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }


/* panels */
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 18px; display: grid; gap: 14px; align-content: start; }
.readouts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.readouts div { display: grid; gap: 2px; }
.readouts b { font-family: var(--mono); font-weight: 500; font-size: 16px; font-variant-numeric: tabular-nums; }
.readouts span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.plot { width: 100%; height: 92px; display: block; }
.plot-title { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.plot-title i { display: inline-block; width: 12px; height: 2px; margin-right: 5px; vertical-align: 3px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 7px 0; border-bottom: 1px solid var(--line); }
th { font-weight: 500; color: var(--muted); font-size: 12px; }
td.num, th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
td.best { font-weight: 600; }
dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 14px; }
dt { color: var(--muted); }
dd { margin: 0; }
code { font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }
.note { font-size: 13px; color: var(--muted); margin: 0; max-width: 72ch; }
.chart-box { overflow-x: auto; }
#trainChart { width: 100%; min-width: 460px; height: auto; display: block; }
@media (max-width: 560px) {
  .readouts { grid-template-columns: repeat(2, 1fr); }
  .hud { font-size: 10.5px; left: 8px; top: 6px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto; } }

a { color: var(--drone); }
.canvas-box canvas#sim { cursor: crosshair; touch-action: manipulation; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--mono); font-size: 13px; color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); margin: 0; }
.hint b { color: var(--ink); font-weight: 600; }
.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--crash); margin-right: 6px; vertical-align: 1px; }
.speed-group { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
@media (max-width: 560px) {
  table { font-size: 13px; }
  th.num, td.num { white-space: nowrap; }
}
.net { width: 100%; display: block; image-rendering: pixelated; }
