:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #f2f7ed;
  background: #132323;
  --ink: #f2f7ed;
  --muted: #c4d4cc;
  --accent: #cced9e;
  --panel: #132827;
  --line: #62786f;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
main { position: relative; min-height: 100svh; }
#scene { position: fixed; inset: 0; background: linear-gradient(#afc7c5 0 48%, #849476 48%); }
#scene canvas { display: block; width: 100%; height: 100%; touch-action: none; }
header {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 18px max(16px, env(safe-area-inset-left));
  background: linear-gradient(#102323ed, #10232300); z-index: 1; pointer-events: none;
}
header button { pointer-events: auto; }
.header-actions { display: flex; gap: 6px; }
.header-actions button { font-size: .78rem; }
main:is([data-phase="driving"], [data-phase="held"]) .page-header { display: none; }
h1, h2, p { margin: 0; }
.brand { color: var(--accent); font-size: .75rem; font-weight: 700; }
h1 { font-size: clamp(.95rem, 3.7vw, 1.28rem); line-height: 1.15; margin-top: 3px; }
h2 { font-size: clamp(1.42rem, 5vw, 1.9rem); letter-spacing: -.028em; }
button {
  border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: #203c39;
  font: inherit; font-weight: 650; font-size: .9rem; padding: 9px 13px; min-height: 44px;
  cursor: pointer; touch-action: manipulation;
}
button:focus-visible, a:focus-visible, input:focus-visible, [tabindex]:focus-visible { outline: 3px solid #e3fdc1; outline-offset: 3px; }
button[aria-pressed="true"] { color: #152921; border-color: var(--accent); background: var(--accent); }
button:disabled { opacity: .55; cursor: default; }
.panel {
  position: relative; width: min(430px, calc(100% - 28px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  margin: max(16px, 13vh) auto max(14px, env(safe-area-inset-bottom));
  padding: clamp(15px, 4vw, 24px); border: 1px solid #729189; border-radius: 17px;
  background: #132827f7; box-shadow: 0 16px 40px #12241d50; display: grid; gap: 10px;
}
.approach { color: var(--accent); font-size: .83rem; font-weight: 750; }
.status { color: var(--muted); font-size: .94rem; line-height: 1.35; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.traffic-options { display: grid; grid-template-columns: .9fr minmax(0, 1.3fr) 1.05fr; gap: 5px 8px; }
.traffic-options label { display: grid; gap: 3px; min-width: 0; font-size: .77rem; color: var(--muted); }
.traffic-options select { min-width: 0; width: 100%; min-height: 38px; background: #203c39; color: var(--ink);
  border: 1px solid var(--line); border-radius: 7px; font: inherit; font-size: .79rem; padding: 4px; }
.traffic-options p { grid-column: 1 / -1; }
.actions, .options { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions .primary { color: #152921; background: var(--accent); border-color: var(--accent); flex: 1; }
.action-symbol { display: none; }
.panel.compact .menu-action { display: grid; place-items: center; min-width: 44px; padding: 4px; }
.panel.compact .action-name { display: none; }
.panel.compact .action-symbol { display: inline-flex; gap: 2px; align-items: center; font-size: 1.26rem; line-height: 1; }
.action-symbol small { font-size: .62rem; }
.copy-symbol { position: relative; width: 18px; height: 19px; }
.copy-symbol::before, .copy-symbol::after {
  content: ''; position: absolute; width: 10px; height: 12px; border: 1.5px solid; border-radius: 2px;
}
.copy-symbol::before { top: 0; left: 0; opacity: .65; }
.copy-symbol::after { top: 4px; left: 4px; background: #203c39; }
.options p, .share, .rotate-tip, .credit, .screen-help { font-size: .77rem; color: var(--muted); }
.credit { justify-self: start; }
.credit a { color: inherit; }
.panel-links { display: flex; gap: 8px 14px; flex-wrap: wrap; align-items: baseline; font-size: .8rem; }
.panel-links > a, .junction-link { color: var(--accent); }
.picker { width: min(460px, calc(100% - 28px)); }
.route-links { display: grid; gap: 8px; }
.route-links a { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 13px 12px; min-height: 52px; border: 1px solid var(--line); border-radius: 9px;
  background: #203c39; color: var(--ink); text-decoration: none; font-weight: 650; }
.route-links small { white-space: nowrap; color: var(--accent); }
.junction-link { display: flex; justify-content: space-between; padding: 8px 0; font-size: .88rem; }
#share-url { width: 100%; min-height: 36px; padding: 5px; }
.drive { position: absolute; inset: 0; pointer-events: none; }
.drive button { pointer-events: auto; background: #132827ed; }
.drive-top { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0 10px;
  padding: env(safe-area-inset-top) max(6px, env(safe-area-inset-right)) 0 max(6px, env(safe-area-inset-left));
  background: #102323eb; color: white; }
.drive-bar { display: flex; gap: 3px; }
.mirror-view { position: absolute; z-index: 1; top: calc(100% + 7px); left: 50%; translate: -50% 0;
  width: clamp(168px, 34vw, 270px); height: clamp(70px, 23svh, 95px);
  border: 2px solid #759189; border-radius: 7px; box-shadow: 0 5px 14px #060e1070; }
.mirror-picture { position: absolute; inset: 0; }
.mirror-view span { position: absolute; right: 4px; bottom: 4px; padding: 2px 5px; border-radius: 3px;
  color: var(--ink); background: #102323e8; font-size: .64rem; }
.exercise-result { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 10px; align-items: baseline; }
.exercise-score { font-size: 1.32rem; font-weight: 800; color: var(--accent); white-space: nowrap; }
#exercise-missed { grid-column: 1 / -1; }
#exercise-missed-title { font-size: .75rem; color: var(--muted); margin: 0 0 2px; }
#exercise-misses { list-style: none; margin: 0; padding: 0 6px 0 0; font-size: .8rem;
  max-block-size: min(23svh, 8rem); overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
#exercise-misses li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 6px;
  padding: 3px 0; border-top: 1px solid #34504a; }
#exercise-misses span { color: var(--muted); }
.exercise-tip { color: var(--muted); font-size: .82rem; line-height: 1.3; }
.exercise-tip strong { color: var(--ink); margin-right: 4px; }
#report-detail { grid-column: 1 / -1; color: var(--muted); font-size: .78rem; }
.drive-bar button { font-size: .86rem; min-width: 44px; padding: 3px 6px; border-color: transparent; background: transparent; }
.drive-bar button:active { background: #2c4641; }
.drive-bar #playback-rate[aria-pressed="true"] { background: var(--accent); color: #152921; }
.caption { min-width: 0; padding-block: 4px; font-size: clamp(.78rem, 2.2vw, .92rem); line-height: 1.2; }
.coach-cue { position: absolute; top: calc(100% + 5px); left: max(7px, env(safe-area-inset-left)); padding: 4px 7px;
  border-radius: 5px; background: #102323ed; color: var(--accent); font-size: .75rem; }
.drive button.drive-voice { grid-column: 3; grid-row: 1; justify-self: end; min-width: 44px; padding: 4px;
  background: transparent; border-color: transparent; font-size: 1rem; }
.drive button.drive-voice[aria-pressed="true"] { color: var(--muted); background: #29413b; }
#route-progress { grid-column: 1 / -1; display: block; width: 100%; height: 2px; border: none;
  accent-color: var(--accent); appearance: none; }
#route-progress::-webkit-progress-bar { background: #34504a; }
#route-progress::-webkit-progress-value { background: var(--accent); }
#route-progress::-moz-progress-bar { background: var(--accent); }
.drive-controls {
  position: absolute; inset-inline: max(13px, env(safe-area-inset-left)) max(13px, env(safe-area-inset-right));
  bottom: max(10px, calc(env(safe-area-inset-bottom) + 5px)); display: flex; gap: 5px; align-items: end; justify-content: space-between;
}
.steering-console { display: grid; grid-template-columns: auto auto auto; gap: 4px; align-items: end; }
.steering-console button { touch-action: none; user-select: none; }
.steering-console #mirrors { grid-column: 2; grid-row: 1; justify-self: center; padding-inline: 9px; }
.steering-console button[aria-pressed="true"] { background: var(--accent); color: #152921; }
.steering-console button[id^="indicate-"] { grid-row: 2; width: 44px; min-height: 53px; padding: 0; font-size: 1.2rem; }
.steering-console button[id^="indicate-"][aria-pressed="true"] { background: #715226; color: #ffdf8f; }
.steering-console button[id^="indicate-"].indicator-lit { background: #ffda86; color: #362705; }
#indicate-left { grid-column: 1; }
#indicate-right { grid-column: 3; }
.thumb, .guided-steering { grid-column: 2; grid-row: 2; display: grid; place-items: center; width: 126px; min-height: 53px; }
.thumb { overflow: clip; }
#thumb-knob { background: #c7dfa9; color: #152921; padding: 5px 8px; border-radius: 6px; }
.guided-steering { border-radius: 9px; background: #132827ed; border: 1px solid var(--line); color: var(--muted); font-size: .8rem; }
.pedal-console { display: flex; gap: 6px; margin-left: auto; align-items: end; }
.drive-speed { display: grid; place-items: center; min-width: 55px; padding: 5px 6px; border-radius: 8px;
  background: #132827ed; border: 1px solid var(--line); color: var(--muted); font-size: .68rem; line-height: 1; }
#drive-speed { font-size: 1.38rem; font-weight: 750; color: var(--ink); font-variant-numeric: tabular-nums; }
.pedal { display: grid; grid-template-columns: 1fr 20px; grid-template-rows: 1fr 1fr; align-items: center; gap: 4px;
  width: 111px; height: 106px; padding: 5px 7px; border: 1px solid var(--line); border-radius: 10px;
  background: linear-gradient(#31553def, #142a27f5 48%, #63362ff2); color: var(--ink); font-weight: 700; font-size: .72rem;
  pointer-events: auto; touch-action: none; user-select: none; cursor: ns-resize; }
.pedal-accelerate { grid-row: 1; white-space: nowrap; }
.pedal-brake { grid-row: 2; white-space: nowrap; }
.pedal-track { grid-column: 2; grid-row: 1 / 3; justify-self: center; align-self: stretch;
  position: relative; width: 6px; margin-block: 7px; border-radius: 5px; background: #0c1d1be8; }
.pedal-knob { position: absolute; top: var(--pedal-position, 50%); left: 50%; translate: -50% -50%;
  width: 17px; height: 13px; border-radius: 4px; background: var(--ink); }
.overhead { position: absolute; bottom: max(21px, env(safe-area-inset-bottom)); left: 50%; translate: -50% 0; display: grid; text-align: center; gap: 7px; background: var(--panel); border-radius: 10px; padding: 10px; width: max-content; }
.overhead p { font-size: .8rem; }
@media (orientation: landscape) {
  .rotate-tip { display: none; }
  .panel { width: min(370px, calc(100% - 28px)); margin: 6px auto max(10px, env(safe-area-inset-bottom)); padding: 12px 14px; gap: 8px; }
  #panel { margin-inline: max(12px, env(safe-area-inset-left)) auto; }
  #panel.compact { width: min(322px, calc(100% - 28px)); padding: 9px 11px; gap: 7px; }
  #panel.compact .approach { display: none; }
  #panel.compact .actions { gap: 5px; }
  #panel.compact .status { font-size: .8rem; }
  main[data-scored-drive][data-phase="finished"] .page-header { display: none; }
  main[data-scored-drive][data-phase="finished"] #panel { width: min(414px, calc(100% - 28px)); margin-top: max(8px, env(safe-area-inset-top)); }
  #exercise-misses { max-block-size: min(20svh, 8rem); }
  .page-header { padding-bottom: 7px; }
  h2 { font-size: 1.25rem; }
}
@media (orientation: portrait) and (max-width: 480px) {
  .drive-top { grid-template-columns: minmax(0, 1fr) auto; }
  .drive button.drive-voice { grid-column: 2; }
  .caption { grid-row: 2; grid-column: 1 / -1; padding: 2px 7px 6px; }
  .drive-bar { flex-wrap: wrap; }
}
@media (max-width: 420px) {
  .drive-controls { inset-inline: max(7px, env(safe-area-inset-left)) max(7px, env(safe-area-inset-right)); }
  .thumb, .guided-steering { width: 68px; padding-inline: 3px; }
  .pedal-console { gap: 4px; }
  .drive-speed { min-width: 42px; padding-inline: 4px; }
  .pedal { width: 90px; grid-template-columns: 1fr 15px; padding-inline: 4px; font-size: .64rem; }
}
