:root {
  color: #f6f3e8;
  color-scheme: dark;
  background: #202820;
  font: 15px/1.45 'Avenir Next', Avenir, 'Segoe UI', sans-serif;
  --glass: rgba(26, 33, 26, .93);
  --line: rgba(229, 235, 211, .18);
  --muted: #c4cdba;
  --accent: #f3cf75;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}
* { box-sizing: border-box; }
html, body, #app { width: 100%; height: 100%; margin: 0; overflow: hidden; }
button, input, select { font: inherit; }
button { color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
[hidden] { display: none !important; }
#viewport, #viewport canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.site-header {
  position: absolute; inset: 0 0 auto; display: flex; align-items: center; gap: 14px;
  padding: calc(16px + var(--safe-top)) max(20px, var(--safe-right)) 16px max(20px, var(--safe-left));
  pointer-events: none; z-index: 3;
}
.site-header h1 {
  font-size: 15px; line-height: 1; margin: 0; letter-spacing: -.01em; font-weight: 600;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .55);
}
.site-header p { display: none; }
.site-header .location-mark { display: none; }
.location-mark {
  display: grid; align-content: center; justify-content: center; gap: 4px; width: 42px; height: 42px;
  border: 1px solid rgba(250, 231, 178, .55); border-radius: 11px; background: #e6c36a;
  transform: rotate(-9deg); box-shadow: 0 3px 12px #1924164d;
}
.location-mark span { display: block; width: 19px; height: 2px; border-radius: 2px; background: #273425; transform: rotate(-22deg); }
.location-mark span:nth-child(2) { width: 13px; }
.header-actions {
  pointer-events: auto; margin-left: auto; display: flex; align-items: center; gap: 8px;
}
.header-button {
  pointer-events: auto; padding: 5px 11px; background: rgba(26, 33, 26, .55);
  border: 1px solid var(--line); border-radius: 999px; font-size: 12px; font-weight: 600;
  backdrop-filter: blur(6px);
}
.header-button:hover, .control-preferences[open] summary, .drive-actions button:hover, .quiet-button:hover, .close-button:hover, .preset-chip:hover, .picker-zoom button:hover { background: #495746; }
#profiler-toggle[aria-pressed='true'] { color: var(--accent); border-color: var(--accent); background: var(--glass); }
.profiler {
  position: absolute; top: calc(56px + var(--safe-top)); left: max(20px, var(--safe-left)); z-index: 2;
  width: min(258px, calc(100% - 40px)); max-height: calc(100dvh - 165px - var(--safe-bottom));
  padding: 10px 12px; overflow: auto; border: 1px solid var(--line); border-radius: 11px;
  background: var(--glass); color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums;
}
.profiler header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.profiler h2 { margin: 0; color: #f6f3e8; font-size: 13px; }
.profiler-fps { margin: 0 0 7px; }
.profiler-fps strong { color: var(--accent); font-size: 26px; line-height: 1.15; }
.profiler-stats { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 9px; margin: 0; }
.profiler-stats dt { overflow-wrap: anywhere; }
.profiler-stats dd { margin: 0; color: #f6f3e8; text-align: right; }
.control-preferences { position: relative; }
.control-preferences summary { display: grid; place-items: center; cursor: pointer; }
.control-preferences summary::-webkit-details-marker { display: none; }
.control-preferences-panel {
  position: absolute; right: 0; top: calc(100% + 7px); display: flex; align-items: center; gap: 12px;
  padding: 10px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--glass); box-shadow: 0 8px 24px #15241350; white-space: nowrap;
}
.control-preferences-panel label { font-size: 13px; color: var(--muted); }
.control-preferences-panel select {
  min-height: 36px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 5px; background: #313b30;
}
.start-picker {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center;
  padding: max(24px, var(--safe-top)) max(24px, var(--safe-right)) max(24px, var(--safe-bottom)) max(24px, var(--safe-left));
  background: radial-gradient(120% 90% at 50% 40%, rgba(22, 30, 22, .78), rgba(10, 14, 10, .92)); backdrop-filter: blur(10px);
}
.picker-card {
  width: min(1040px, 100%); height: 100%; min-height: 0; max-height: 760px;
  display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; gap: 14px; padding: 20px 22px;
  background: linear-gradient(180deg, rgba(33, 42, 32, .96), rgba(24, 31, 24, .96));
  border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .05);
}
.picker-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.picker-header h2 { margin: 0; font-size: 26px; letter-spacing: -.035em; line-height: 1.1; }
.picker-header p { margin: 5px 0 0; font-size: 13px; color: var(--muted); }
.picker-header .close-button { flex-shrink: 0; width: 36px; height: 36px; border-radius: 999px; font-size: 20px; }
.picker-presets {
  display: flex; gap: 8px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
  margin: 0 -22px; padding: 2px 22px; scroll-padding-inline: 22px;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 22px, #000 calc(100% - 36px), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 22px, #000 calc(100% - 36px), transparent);
}
.picker-presets::-webkit-scrollbar { display: none; }
.preset-chip {
  flex: none; padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; white-space: nowrap;
  background: rgba(46, 56, 44, .8); font-size: 13px; font-weight: 600; color: #e5e9d8;
  transition: background .15s, border-color .15s, color .15s;
}
.preset-chip[aria-pressed='true'] { background: rgba(243, 207, 117, .16); border-color: var(--accent); color: var(--accent); }
.picker-map-wrap {
  position: relative; min-height: 0; overflow: hidden;
  border: 1px solid var(--line); border-radius: 14px; background: #111611;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .35);
}
#picker-canvas { width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; }
#picker-canvas:active { cursor: grabbing; }
.picker-zoom {
  position: absolute; top: 12px; right: 12px; display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  background: rgba(26, 33, 26, .88); backdrop-filter: blur(8px); box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
}
.picker-zoom button {
  display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 0; background: transparent;
}
.picker-zoom button + button { border-top: 1px solid var(--line); }
.picker-zoom svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.picker-hint {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); margin: 0; padding: 5px 11px;
  border-radius: 999px; background: rgba(17, 22, 17, .72); color: var(--muted); font-size: 11px;
  white-space: nowrap; pointer-events: none; backdrop-filter: blur(6px);
}
.picker-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.picker-status { display: grid; gap: 2px; min-width: 0; margin: 0; }
.picker-status strong { font-size: 15px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-status span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-status[data-state='error'] strong { color: #f49c78; }
.primary-button {
  flex: none; padding: 12px 26px; border: 1px solid rgba(250, 231, 178, .6); border-radius: 12px;
  background: linear-gradient(180deg, #f1d07c, #dfb95c); color: #1e281d; font-size: 15px; font-weight: 700;
  box-shadow: 0 6px 18px rgba(230, 195, 106, .22);
}
.primary-button:hover { background: #f3cf75; }
.nav-map {
  position: absolute; top: calc(56px + var(--safe-top)); right: max(20px, var(--safe-right)); width: 220px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--glass);
  box-shadow: 0 8px 24px #15241330; pointer-events: none;
}
#minimap { width: 100%; height: 154px; display: block; border-radius: inherit; }
.map-toggle {
  position: absolute; top: 6px; left: 6px; width: 24px; height: 24px; padding: 0;
  border: 1px solid var(--line); border-radius: 6px; background: rgba(26, 33, 26, .7);
  font-size: 13px; line-height: 1; pointer-events: auto;
}
.map-toggle:hover, .map-toggle[aria-pressed='true'] { color: var(--accent); background: #495746; }
.map-north { position: absolute; top: 8px; right: 9px; color: var(--accent); font-size: 10px; font-weight: 700; }
.map-attribution {
  position: absolute; right: 5px; bottom: 4px; display: flex; align-items: center; gap: 8px;
  padding: 2px 6px; border-radius: 5px; background: var(--glass); color: var(--muted); font-size: 11px;
}
.map-attribution a, .map-attribution summary { color: inherit; pointer-events: auto; }
.map-attribution summary { cursor: pointer; }
.map-attribution summary:hover { color: var(--accent); }
.provenance {
  position: absolute; top: calc(100% + 9px); right: -5px; z-index: 1;
  width: min(280px, calc(100vw - 40px)); margin: 0; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--glass); pointer-events: auto;
}
.announcement {
  position: absolute; left: 50%; top: calc(56px + var(--safe-top)); transform: translateX(-50%); max-width: calc(100% - 32px);
  padding: 8px 13px; border: 1px solid var(--line); border-radius: 7px; color: var(--accent);
  background: var(--glass); font-size: 13px; text-align: center; pointer-events: none;
}
.driving-hud {
  position: absolute; left: max(20px, var(--safe-left)); bottom: calc(18px + var(--safe-bottom)); pointer-events: none;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .6);
}
.driving-hud .support, .driving-hud .drive-actions { display: none; }
.street { margin-bottom: 4px; max-width: min(320px, 60vw); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 600; color: #f2e9d3; }
.speedometer { display: flex; align-items: baseline; gap: 5px; white-space: nowrap; }
#speed { font-size: 34px; font-weight: 700; line-height: 1; letter-spacing: -.06em; font-variant-numeric: tabular-nums; }
.speed-unit, .support { font-size: 11px; color: var(--muted); }
.support { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.support-light { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.support-light[data-contact='all'] { background: #b5dd95; box-shadow: 0 0 7px #a8d57980; }
.support-light[data-contact='none'] { background: #f49c78; }
.drive-actions { grid-column: 1 / 3; display: flex; justify-content: space-between; gap: 9px; padding-top: 8px; margin-top: 9px; border-top: 1px solid var(--line); }
.drive-actions button, .quiet-button, .close-button { background: transparent; border: 1px solid var(--line); border-radius: 5px; }
.drive-actions button { padding: 4px 8px; font-size: 11px; }
kbd { display: inline-grid; place-items: center; border: 1px solid rgba(235, 241, 221, .24); padding: 1px 4px; border-radius: 3px; min-width: 18px; font-size: 10px; color: #f2e9d3; }
.keyboard-hint {
  position: absolute; left: 50%; bottom: 27px; transform: translateX(-50%); display: flex; align-items: center;
  bottom: 18px; gap: 4px; padding: 5px 8px; background: rgba(26, 33, 26, .55); border-radius: 999px;
  color: #e9eddf; font-size: 11px; white-space: nowrap; pointer-events: none;
}
/* The hint fades a few seconds after driving starts, i.e. once the location picker closes. */
.start-picker[hidden] ~ .keyboard-hint { animation: hint-fade 1s ease 8s forwards; }
@keyframes hint-fade { to { opacity: 0; visibility: hidden; } }
.keyboard-hint span { margin: 0 5px 0 2px; }
.tools {
  position: absolute; top: calc(56px + var(--safe-top)); right: max(20px, var(--safe-right)); z-index: 2; width: min(343px, calc(100vw - 54px)); max-height: calc(100dvh - 121px - var(--safe-bottom));
  overflow: auto; border: 1px solid var(--line); border-radius: 11px; background: var(--glass); box-shadow: 0 20px 65px #14221370;
}
.tools-header { display: flex; justify-content: space-between; padding: 16px 17px 12px; }
.tools-header h2 { margin: 0; font-size: 21px; letter-spacing: -.04em; }
.tools-header p { font-size: 11px; color: var(--muted); margin: 3px 0 0; }
.close-button { width: 27px; height: 27px; font-size: 19px; line-height: 1; }
.tabs { display: flex; gap: 5px; padding: 0 17px; border-bottom: 1px solid var(--line); }
.tabs button { background: transparent; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 7px 11px; font-size: 12px; }
.tabs button[aria-pressed='true'] { color: var(--accent); border-color: var(--accent); }
.tools-content { padding: 13px 17px 16px; }
.control { display: grid; grid-template-columns: 1fr auto; column-gap: 8px; margin-bottom: 9px; }
.control label, .control output { font-size: 12px; }
.control output { color: var(--accent); font-variant-numeric: tabular-nums; }
.control input { width: 100%; grid-column: span 2; margin: 4px 0 0; accent-color: var(--accent); }
.quiet-button { padding: 5px 9px; color: var(--muted); font-size: 12px; }
.stats { margin: 0; font-size: 11px; font-variant-numeric: tabular-nums; }
.stats div { display: flex; justify-content: space-between; gap: 6px; padding: 3px 0; border-bottom: 1px solid var(--line); }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; text-align: right; }
.overlays { border: 0; padding: 0; margin: 13px 0 0; }
.overlays legend { font-weight: 700; font-size: 12px; padding: 0 0 4px; }
.overlays > div { display: grid; grid-template-columns: 1fr 1fr; }
.overlays label { font-size: 11px; color: var(--muted); display: flex; gap: 5px; align-items: center; }
.overlays input { accent-color: var(--accent); }
.touch-controls {
  display: flex; position: absolute; bottom: calc(12px + var(--safe-bottom));
  left: max(12px, var(--safe-left)); right: max(12px, var(--safe-right));
  justify-content: space-between; gap: 12px; pointer-events: none;
}
.start-picker:not([hidden]) ~ .touch-controls { display: none; }
.touch-steering, .touch-pedals { display: flex; gap: 6px; }
.touch-controls button {
  pointer-events: auto; touch-action: none; user-select: none; -webkit-touch-callout: none;
  min-width: clamp(44px, 13vw, 58px); height: 48px; padding: 0 6px;
  border: 1px solid rgba(229, 235, 211, .36); border-radius: 9px;
  background: var(--glass); font-size: 12px; font-weight: 700;
}
.touch-steering button { font-size: 22px; line-height: 1; }
.touch-controls button[data-key='ArrowUp'] { color: var(--accent); }
.touch-controls button[data-held] { background: #53623f; border-color: var(--accent); }
[data-touch-driving] .keyboard-hint { display: none; }
[data-touch-driving] .driving-hud { bottom: calc(70px + var(--safe-bottom)); }
[data-touch-driving] .drive-actions {
  display: flex; justify-content: flex-start; pointer-events: auto; border: 0; padding: 0; margin-top: 6px;
}
[data-touch-driving] .drive-actions button { min-height: 44px; background: var(--glass); }
[data-touch-driving] .drive-actions button:hover { background: #495746; }
[data-touch-driving] .drive-actions kbd { display: none; }
@media (max-width: 830px) { .keyboard-hint { display: none; } }
@media (max-width: 580px) {
  .site-header { padding: calc(12px + var(--safe-top)) max(12px, var(--safe-right)) 12px max(12px, var(--safe-left)); gap: 9px; }
  .site-header > div:has(h1) { min-width: 0; }
  .site-header h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav-map { top: calc(48px + var(--safe-top)); right: max(12px, var(--safe-right)); width: 150px; }
  .profiler { top: calc(48px + var(--safe-top)); left: max(12px, var(--safe-left)); }
  #profiler-toggle { padding-inline: 8px; }
  #minimap { height: 105px; }
  .driving-hud { left: max(12px, var(--safe-left)); bottom: calc(13px + var(--safe-bottom)); }
  #speed { font-size: 28px; }
  .tools { width: min(343px, calc(100vw - 24px)); top: calc(48px + var(--safe-top)); right: max(12px, var(--safe-right)); max-height: calc(100dvh - 120px - var(--safe-bottom)); }
  .announcement { top: auto; bottom: calc(64px + var(--safe-bottom)); }
  [data-touch-driving] .announcement { bottom: calc(163px + var(--safe-bottom)); }
}
@media (any-pointer: coarse) {
  .keyboard-hint { display: none; }
  .header-button { display: inline-grid; place-items: center; min-height: 36px; }
  .nav-map, .tools, .profiler { top: calc(64px + var(--safe-top)); }
  .control-preferences-panel select { min-height: 44px; }
  .profiler .close-button { min-width: 36px; min-height: 36px; }
}
@media (max-width: 440px) {
  .profiler { width: min(258px, calc(100% - 178px - var(--safe-left) - var(--safe-right))); }
  .profiler-stats { gap: 3px 6px; }
}
@media (any-pointer: coarse) {
  .picker-zoom button { width: 44px; height: 44px; }
  .preset-chip { min-height: 40px; }
}
/* Phones: the picker becomes a full-screen sheet with the map edge to edge. */
@media (max-width: 640px) {
  .start-picker { padding: 0; background: #151b15; backdrop-filter: none; }
  .picker-card {
    width: 100%; max-height: none; gap: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none;
    grid-template-rows: auto auto minmax(0, 1fr) auto; background: #182018;
  }
  .picker-header { padding: calc(12px + var(--safe-top)) max(16px, var(--safe-right)) 8px max(16px, var(--safe-left)); align-items: center; }
  .picker-header h2 { font-size: 21px; }
  .picker-header p { margin-top: 2px; font-size: 12px; }
  .picker-presets { margin: 0; padding: 2px max(16px, var(--safe-left)) 12px; scroll-padding-inline: 16px; }
  .picker-map-wrap { border: 0; border-radius: 0; border-block: 1px solid var(--line); }
  .picker-zoom { top: 10px; right: max(10px, var(--safe-right)); }
  .picker-hint { top: 10px; bottom: auto; left: max(10px, var(--safe-left)); transform: none; }
  .picker-footer {
    flex-direction: column; align-items: stretch; gap: 10px;
    padding: 12px max(16px, var(--safe-right)) calc(14px + var(--safe-bottom)) max(16px, var(--safe-left));
  }
  .picker-footer .primary-button { width: 100%; min-height: 50px; }
}
@media (max-height: 500px) and (min-width: 641px) {
  .start-picker {
    padding: max(10px, var(--safe-top)) max(12px, var(--safe-right)) max(10px, var(--safe-bottom)) max(12px, var(--safe-left));
  }
  .picker-card { gap: 8px; padding: 12px 14px; }
  .picker-presets { margin: 0 -14px; padding: 2px 14px; }
  .picker-header h2 { font-size: 20px; }
}
/* Landscape phones: map on the left, controls stacked on the right. */
@media (max-height: 500px) and (orientation: landscape) and (max-width: 1000px) {
  .start-picker { padding: 0; background: #151b15; }
  .picker-card {
    width: 100%; max-height: none; border: 0; border-radius: 0; box-shadow: none; gap: 10px 14px;
    padding: max(10px, var(--safe-top)) max(12px, var(--safe-right)) max(10px, var(--safe-bottom)) max(12px, var(--safe-left));
    grid-template-columns: minmax(0, 1fr) minmax(220px, 34%); grid-template-rows: auto minmax(0, 1fr) auto;
  }
  .picker-map-wrap { grid-column: 1; grid-row: 1 / 4; }
  .picker-header, .picker-presets, .picker-footer { grid-column: 2; }
  .picker-presets { flex-wrap: wrap; align-content: flex-start; overflow-y: auto; margin: 0; padding: 0; -webkit-mask-image: none; mask-image: none; }
  .picker-footer { flex-direction: column; align-items: stretch; gap: 8px; }
  .picker-hint { display: none; }
}
