:root {
  color-scheme: dark;
  --orange: #ff943e;
  --muted: #aaa298;
  --surface: #191918;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; min-height: 100svh; background: #111110; color: #eee8df; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; }
::selection { background: var(--orange); color: #111110; }
.instrument { width: min(100%, 660px); min-height: 100svh; display: flex; flex-direction: column; margin: auto; padding: 32px 28px max(24px, env(safe-area-inset-bottom)); }
header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
h1 { margin: 0; font-size: 23px; font-weight: 500; letter-spacing: -.03em; }
h1 span { color: var(--orange); margin-left: 4px; }
.gps { font-size: 12px; color: var(--muted); text-align: right; max-width: 260px; }
.gps::before { content: ''; display: inline-block; width: 5px; height: 5px; margin: 0 7px 2px 0; border-radius: 50%; background: currentColor; }
.gps[data-state=active], .gps[data-state=error], .gps[data-state=waiting] { color: var(--orange); }
.dial { flex-shrink: 0; position: relative; width: 100%; margin: 24px auto 16px; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(ellipse at 50% 40%, #20201e, #151514 68%); }
.dial > svg { display: block; width: 100%; overflow: visible; }
.rim { fill: none; stroke: #35332e; stroke-width: 2; }
.inner-rim { fill: none; stroke: #0b0b0a; stroke-width: 5; }
#ticks line { stroke: var(--orange); }
#ticks .major { stroke-width: 2.5; }
#ticks .minor { stroke-width: 1; opacity: .5; }
#ticks text { fill: var(--orange); font-size: 20px; text-anchor: middle; font-weight: 400; font-variant-numeric: tabular-nums; }
#needle { transform: rotate(-130deg); transform-origin: 250px 250px; transition: transform 1s cubic-bezier(.22,1,.36,1); }
.needle { fill: #ffad66; filter: drop-shadow(0 2px 3px #000); }
.hub { fill: #26231e; stroke: #66503b; stroke-width: 1; }
.hub-center { fill: #ff943e; }
.drive-controls { position: relative; text-align: center; margin: 0 0 30px; }
button, select, input { font: inherit; }
button { min-height: 44px; padding: 0 20px; background: transparent; color: var(--orange); border: 1px solid #66503b; border-radius: 4px; font-size: 13px; font-weight: 400; cursor: pointer; }
button:hover { background: #ff943e0d; border-color: var(--orange); }
button:active { background: #ff943e18; }
#start.is-running { border-color: transparent; color: var(--muted); }
#start.is-running:hover { color: var(--orange); background: #ff943e0d; }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 5px; }
.drive-controls p { margin: 12px 0 0; font-size: 12px; color: var(--muted); }
.settings { margin-top: 0; border-top: 1px solid #35312b; padding: 18px 0 0; display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 12px; }
.settings > #start { grid-column: 1; grid-row: 1; }
.settings > label { grid-column: 2; grid-row: 1; min-width: 0; }
.altitude-settings { grid-column: 3; grid-row: 1; display: flex; align-items: center; gap: 8px; }
#altitudeUnit { width: 64px; padding: 0 4px; }
label { display: flex; flex-direction: column; gap: 9px; color: var(--muted); font-size: 12px; }
select { min-height: 40px; border: 1px solid #4d453b; border-radius: 4px; padding: 0 28px 0 10px; background: var(--surface); color: #eee8df; cursor: pointer; font-size: 14px; }
.altitude-toggle { flex-direction: row; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; color: #eee8df; }
input { accent-color: var(--orange); width: 17px; height: 17px; margin: 0; }
.altitude { position: absolute; top: 84%; left: 50%; transform: translateX(-50%); display: flex; align-items: baseline; justify-content: center; gap: 8px; color: var(--orange); white-space: nowrap; }
.altitude output { font-size: clamp(18px, 4.8vw, 26px); font-weight: 400; line-height: 1; font-variant-numeric: tabular-nums; }
.altitude-unit { font-size: 12px; }
[hidden] { display: none !important; }
footer { color: var(--muted); font-size: 12px; line-height: 1.6; margin-top: 20px; text-align: center; }
@media (max-width: 480px) {
  .instrument { padding: 22px 14px max(16px, env(safe-area-inset-bottom)); }
  .dial { margin-top: 28px; margin-bottom: 16px; }
  .settings { grid-template-columns: minmax(44px, 1fr) minmax(58px, 1fr) auto; gap: 6px; }
  #start { padding: 0 4px; font-size: 12px; white-space: nowrap; }
  #speedUnit { width: 100%; padding: 0 4px; }
  .altitude-settings { gap: 4px; }
  .altitude-toggle { gap: 4px; }
  #altitudeUnit { width: 56px; font-size: 12px; }
  #resetSession { min-width: 36px; }
  .drive-controls { margin-bottom: 26px; }
  .gps { max-width: 210px; }
}
@media (prefers-reduced-motion: reduce) { #needle { transition: none; } }

.session { margin-top: auto; padding: 24px 0 18px; display: grid; grid-template-columns: minmax(0, 1fr) 44px; align-items: center; gap: 8px; }
.session dl { display: grid; grid-template-columns: 1fr 1fr; margin: 0; text-align: center; }
.session dl > div { display: flex; align-items: baseline; justify-content: center; gap: 8px; white-space: nowrap; }
.session dt { color: var(--muted); font-size: 12px; }
.session dd { margin: 0; color: var(--orange); font-size: 20px; font-weight: 300; font-variant-numeric: tabular-nums; }
.stat-unit { font-size: 12px; color: var(--muted); }
#resetSession { display: grid; place-items: center; width: 100%; padding: 0; border-color: transparent; color: var(--muted); }
#resetSession:hover { color: var(--orange); }
