:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  color: #e6f0f5;
  background: #101c25;
  --muted: #a9bdc9;
  --surface: #172833;
  --border: #304550;
  --cyan: #59e3c2;
  --red: #ff9a86;
  --replay: #fbd168;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
header, main { max-width: 1680px; margin: auto; padding-inline: clamp(14px, 3vw, 46px); }
header { min-height: 99px; display: flex; justify-content: space-between; align-items: center; gap: 18px; }
h1 { margin: 2px 0 0; font-size: clamp(1.6rem, 3vw, 2.5rem); letter-spacing: -.045em; }
.eyebrow { color: var(--cyan); font-size: .69rem; letter-spacing: .14em; font-weight: 750; margin: 0; }
.connection { display: grid; justify-items: end; gap: 6px; color: var(--muted); font-size: .8rem; text-align: right; }
#live { font-weight: 700; color: var(--replay); }
#live.good { color: var(--cyan); }
#live::before { content: '●'; padding-right: .45em; }
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.stats > div, aside section { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.stats > div { display: grid; gap: 2px; padding: 10px clamp(9px, 2vw, 24px); }
.stats span, label, dt, aside p { color: var(--muted); font-size: .81rem; }
.stats strong { font-size: clamp(1.3rem, 3.5vw, 2.1rem); line-height: 1.12; font-variant-numeric: tabular-nums; }
.stats > div:last-child strong { color: var(--red); }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(285px, 327px); gap: 14px; padding-bottom: 20px; }
.map-panel { position: relative; min-width: 0; border: 1px solid var(--border); overflow: hidden; border-radius: 12px; }
#map { height: max(540px, calc(100dvh - 208px)); background: #cfddd9; }
.legend { position: absolute; z-index: 500; left: 12px; bottom: 23px; padding: 8px; border-radius: 6px; background: #14242e; color: white; font-size: .72rem; display: flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; border-radius: 50%; background: var(--cyan); width: 8px; height: 8px; margin-left: 4px; }
.legend i:nth-of-type(2) { background: var(--red); }
.legend i:nth-of-type(3) { background: var(--replay); }
aside { display: grid; align-content: start; gap: 12px; min-width: 0; }
aside section { padding: 15px; }
h2 { font-size: .99rem; margin: 0 0 12px; }
aside p { line-height: 1.45; margin: 10px 0 0; }
label { display: block; margin-bottom: 5px; }
input:not([type=range]), button { font: inherit; font-size: .83rem; border-radius: 6px; min-height: 36px; }
input:not([type=range]) { width: 100%; min-width: 0; border: 1px solid #49616d; color: inherit; background: #111e27; padding: 6px 9px; }
button { border: 1px solid transparent; background: var(--cyan); color: #14252c; padding: 6px 11px; font-weight: 700; cursor: pointer; white-space: nowrap; }
button.secondary { background: transparent; border-color: #49616d; color: inherit; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--replay); outline-offset: 2px; }
.form-row { display: flex; gap: 8px; }
#replay-form .form-row { margin-top: 8px; }
dl { display: grid; grid-template-columns: auto 1fr; gap: 5px 10px; margin: 12px 0 0; }
dd { margin: 0; text-align: right; overflow-wrap: anywhere; font-size: .81rem; }
#incident-list { margin: 0; padding: 0; list-style: none; max-height: 180px; overflow: auto; }
#incident-list button { white-space: normal; text-align: left; width: 100%; color: var(--red); background: #101c25; margin-top: 6px; }
#sample { width: 100%; accent-color: var(--replay); }
.car { background: transparent; border: 0; }
.car span { display: block; width: 13px; height: 17px; border: 1.5px solid #0a2230; border-radius: 4px 4px 5px 5px; background: var(--cyan); box-shadow: 0 1px 3px #192a34; transform: rotate(var(--heading)); }
.car span::before { content: ''; display: block; background: #194554; border-radius: 2px; margin: 3px 2px; height: 4px; }
.car.selected span { outline: 2px solid white; background: #5ebcfa; }
@media (max-width: 740px) {
  header { min-height: 81px; }
  .stats { gap: 4px; }
  .stats span { font-size: .64rem; }
  .layout { grid-template-columns: 1fr; }
  #map { height: 56dvh; min-height: 330px; }
}
