:root {
  color-scheme: dark;
  --bg: #0c0d0b;
  --panel: #151612;
  --line: rgba(243, 241, 234, 0.1);
  --text: #f3f1ea;
  --muted: #9b978c;
  --amber: #f0b429;
  --play: 0%;
  font-family: "URW Gothic", "Noto Sans", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

body, button, input, select { font: inherit; }
button, select { color: var(--text); }

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.top, .panel, footer {
  width: min(1120px, calc(100% - 32px));
  margin-left: auto;
  margin-right: auto;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding: 22px 0 14px;
}

.kicker {
  margin: 0 0 4px;
  color: var(--amber);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 560;
  letter-spacing: -0.03em;
}

.when, footer, .keys, .status { color: var(--muted); }
.when { margin: 4px 0 0; font-size: 14px; }

.units {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.units button {
  background: transparent;
  border: 0;
  padding: 8px 14px;
  cursor: pointer;
}

.units button[aria-pressed="true"] {
  background: var(--amber);
  color: #1c1606;
  font-weight: 700;
}

.frame {
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
}

video {
  display: block;
  width: 100%;
  background: #000;
  object-fit: contain;
}

video[hidden] { display: none; }

.frame video { max-height: 42vh; }

.transport {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0 8px;
  flex-wrap: wrap;
}

button {
  background: #23251f;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}

button:hover { border-color: rgba(243, 241, 234, 0.28); }

button.primary {
  background: var(--amber);
  color: #1c1606;
  border-color: transparent;
  font-weight: 700;
  min-width: 76px;
}

.rate {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

select {
  background: #0c0d0b;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 8px;
}

.clocks {
  margin: 0 0 0 auto;
  display: flex;
  gap: 12px;
  font-variant-numeric: tabular-nums;
}

.clocks strong { font-weight: 600; }
.dim { color: var(--muted); }

.scrub {
  position: relative;
  height: 12px;
  border-radius: 99px;
  background: #23251f;
  cursor: pointer;
  touch-action: none;
  overflow: hidden;
}

.progress {
  height: 100%;
  width: var(--play);
  background: var(--amber);
}

.keys {
  margin: 10px 0 0;
  font-size: 12px;
  letter-spacing: 0.04em;
}

kbd {
  display: inline-block;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  margin-right: 2px;
  color: var(--text);
}

.status { min-height: 1.2em; }

.group { margin: 28px 0 6px; }

.group h2 {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--amber);
}

.row { margin: 0 0 16px; }

.row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
}

.row-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.value {
  margin: 0;
  font-size: 34px;
  line-height: 1;
  font-weight: 560;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--amber);
}

.value .unit {
  font-size: 14px;
  letter-spacing: 0;
  color: var(--muted);
  margin-left: 6px;
  font-weight: 500;
}

.trace {
  position: relative;
  height: 72px;
  margin-top: 6px;
  background: #10110e;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  touch-action: none;
}

.trace canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.head {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--play);
  width: 2px;
  transform: translateX(-1px);
  background: var(--text);
  pointer-events: none;
}

.tabs {
  display: flex;
  gap: 4px;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  border-bottom: 1px solid var(--line);
}

.tabs button {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 10px 14px 8px;
  color: var(--muted);
}

.tabs button[aria-selected="true"] {
  color: var(--amber);
  border-bottom-color: var(--amber);
  font-weight: 700;
}

.panel[hidden] { display: none; }

.lap-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.lap-feed {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}

.lap-slot video { max-height: 24vh; }

.lap-feed figcaption {
  margin: 0;
  padding: 5px 8px 6px;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--panel);
}

.lap-feed.is-current { border-color: var(--amber); }
.lap-feed.is-current figcaption { color: var(--amber); font-weight: 700; }

.video-park {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 4px;
  height: 4px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.video-park video {
  width: 4px;
  height: 4px;
  max-height: none;
}

.map-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.laps { display: flex; flex-wrap: wrap; gap: 8px; }

.laps button {
  font-variant-numeric: tabular-nums;
  font-size: 14px;
}

.laps button[aria-pressed="true"] {
  background: var(--amber);
  color: #1c1606;
  border-color: transparent;
  font-weight: 700;
}

.scale {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.scale-bar {
  width: 148px;
  height: 10px;
  border-radius: 99px;
  background: linear-gradient(90deg, #d63030, #f4d64a, #2aa846);
}

.map-note, .map-credit { color: var(--muted); }
.map-note { margin: 8px 0 0; font-size: 13px; }

.map-frame {
  position: relative;
  width: 100%;
  margin-top: 10px;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.lap-compare {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  max-width: calc(100% - 74px);
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(12, 13, 11, 0.86);
  pointer-events: none;
  font-size: 12px;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}

.lap-compare table { border-collapse: collapse; }

.lap-compare th,
.lap-compare td {
  padding: 2px 6px;
  text-align: right;
  font-weight: 560;
  white-space: nowrap;
}

.lap-compare thead th {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.lap-compare tbody th {
  text-align: left;
  color: var(--text);
  padding-left: 2px;
}

.lap-compare td.brake,
.lap-compare td.accel {
  background: linear-gradient(90deg, var(--ink) var(--p, 0%), transparent var(--p, 0%));
}

.lap-compare td.brake { --ink: rgba(214, 48, 48, 0.72); }
.lap-compare td.accel { --ink: rgba(42, 168, 64, 0.62); }

.lap-compare tr.is-current th { color: var(--amber); font-weight: 800; }

.map-zoom {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.map-zoom button {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 10px;
  background: rgba(12, 13, 11, 0.86);
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}

.map-zoom button:disabled {
  opacity: 0.38;
  cursor: default;
}

#zoomFit { font-size: 13px; letter-spacing: 0.02em; }

.map-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.map-credit { margin: 8px 0 0; font-size: 11px; }

footer {
  padding: 8px 0 32px;
  font-size: 13px;
}

footer p { margin: 4px 0; }

@media (max-width: 680px) {
  .lap-compare { font-size: 11px; padding: 4px 5px; top: 8px; left: 8px; }
  .lap-compare th, .lap-compare td { padding: 2px 3px; }
  .value { font-size: 28px; }
  .clocks { margin-left: 0; }
  .frame video { max-height: 32vh; }
  .lap-slot video { max-height: 16vh; }
  .lap-grid { gap: 6px; }
}
