:root {
  color-scheme: dark;
  --bg: #171813;
  --panel: #202119;
  --line: #3b3b2f;
  --text: #fcf0d9;
  --muted: #c0b7a0;
  --gold: #f6ba52;
  --sage: #a4c9a3;
  --dark: #261c0e;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-width: 300px;
  background: radial-gradient(ellipse at 29% 7%, #2e261b, transparent 65%), var(--bg);
  color: var(--text);
  font: 15px/1.45 Arial, sans-serif;
}
a { color: inherit; text-decoration: none; }
button, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; opacity: .49; }
button:focus-visible, a:focus-visible, select:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
h1, h2, p { margin: 0; }
.shell { width: min(1370px, calc(100% - 72px)); margin-inline: auto; }
.topbar { background: #161711; border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; justify-content: space-between; align-items: center; min-height: 62px; gap: 10px; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 900; letter-spacing: .17em; white-space: nowrap; }
.brand i { width: 26px; height: 22px; background: var(--gold); clip-path: polygon(0 74%,35% 20%,47% 39%,62% 17%,100% 74%,81% 74%,62% 45%,47% 68%,36% 50%,19% 74%); }
nav { display: flex; align-items: center; gap: 21px; color: var(--muted); font-size: 13px; }
nav a:hover, nav a.current { color: var(--gold); }
nav a span { margin-left: 3px; }

.masthead { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-block: 30px 19px; }
.eyebrow { color: var(--gold); display: flex; align-items: center; gap: 9px; font-size: 10px; font-weight: 800; letter-spacing: .16em; }
.eyebrow::before { content: ""; width: 7px; height: 7px; background: currentColor; flex: none; transform: rotate(45deg); }
h1 { margin: 5px 0 7px; font-size: clamp(43px, 6.6vw, 97px); line-height: .94; letter-spacing: -.072em; font-weight: 900; }
.intro { color: var(--muted); }
.outline-button { border: 1px solid #685432; border-radius: 6px; background: #2b2417; padding: 9px 12px; font-size: 13px; color: var(--text); white-space: nowrap; }
.outline-button:not(:disabled):hover { border-color: var(--gold); }
.outline-button span { color: var(--gold); margin-right: 4px; font-weight: 800; }

.layout { display: grid; gap: 17px; grid-template-columns: minmax(0, 1fr) 289px; padding-bottom: 34px; }
.drive-area { min-width: 0; }
.stage {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  width: 100%;
  min-height: 420px;
  aspect-ratio: 1.75;
  border: 1px solid #6d5338;
  border-radius: 10px;
  background: #815537;
}
#terrain-view, .stage-cover, .overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
#terrain-view { display: block; }
.stage-cover {
  pointer-events: none;
  background: linear-gradient(90deg, #271911d9 0%, #27191171 47%, transparent 85%),
    url("./assets/desert-rally.jpg") center / cover;
}
[data-graphics="ready"] .stage-cover { background: linear-gradient(90deg, #261a13eb 0%, #261a1382 40%, transparent 78%); }
[data-graphics="ready"]:not([data-phase="parked"]) .stage-cover { opacity: 0; }
.drive-hud, .stage-actions { position: absolute; z-index: 2; top: 13px; display: flex; gap: 5px; }
.drive-hud { left: 13px; }
.stage-actions { right: 13px; }
.hud-cell, .icon-button, .speed, .boost { border: 1px solid #f0d2a44d; border-radius: 6px; background: #231c13e8; }
.hud-cell { min-width: 65px; padding: 5px 9px 4px; }
.hud-cell span { color: #e0c8a8; display: block; font-size: 9px; font-weight: 800; letter-spacing: .12em; }
.hud-cell strong { font-size: 19px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.hud-cell small { font-size: 12px; font-weight: 400; }
.icon-button { width: 39px; height: 39px; display: grid; place-items: center; line-height: 1; font-size: 23px; }
.icon-button:not(:disabled):hover { border-color: var(--gold); color: var(--gold); }
.map-symbol { font-weight: 800; }
.pause-icon { width: 11px; height: 13px; border-inline: 3px solid currentColor; }
[data-phase="paused"] .pause-icon { border: 0; background: currentColor; clip-path: polygon(0 0, 100% 50%, 0 100%); }
.expand-icon {
  width: 16px; height: 16px; border: 2px solid currentColor;
  clip-path: polygon(0 0,100% 0,100% 100%,0 100%,0 66%,33% 66%,33% 100%,66% 100%,66% 66%,100% 66%,100% 33%,66% 33%,66% 0,33% 0,33% 33%,0 33%);
}
#expand[aria-pressed="true"] { color: var(--gold); }
.overlay { z-index: 1; display: flex; align-items: center; padding-inline: 6%; }
[data-phase="paused"] .overlay { background: #22170bb8; }
.overlay h2 { margin-block: 7px 10px; font-size: clamp(35px, 5.1vw, 76px); line-height: .94; letter-spacing: -.06em; font-weight: 900; }
.overlay-content > p:not(.eyebrow) { max-width: 28ch; margin-bottom: 17px; font-size: 14px; color: #fff0d8; }
.graphics-status { margin: 9px 0 0 !important; }
.primary-button { min-height: 44px; padding: 0 14px; border: 1px solid #ffd58d; border-radius: 6px; background: var(--gold); color: var(--dark); font-weight: 800; }
.primary-button:not(:disabled):hover { background: #ffd385; }
.primary-button span { margin-left: 10px; }

.notice {
  position: absolute; z-index: 2; top: 66px; left: 50%; transform: translateX(-50%);
  display: grid; gap: 1px; width: max-content; max-width: calc(100% - 28px);
  border: 1px solid #c39d5c91; border-radius: 6px; padding: 7px 12px;
  background: #24190de8; color: #f4dec1; text-align: center; font-size: 13px;
}
.notice strong { color: var(--gold); }
.telemetry { position: absolute; z-index: 2; inset: auto 12px 12px; display: flex; align-items: end; justify-content: space-between; pointer-events: none; }
.speed { min-width: 84px; display: flex; align-items: baseline; gap: 5px; padding: 3px 8px; color: #f6e0bb; font-size: 11px; }
.speed strong { font-size: 26px; line-height: 1.3; color: var(--text); font-variant-numeric: tabular-nums; }
.reverse { color: var(--gold); font-weight: 800; }
.boost { width: 125px; padding: 6px 8px; }
.boost > span { display: flex; align-items: center; gap: 5px; font-size: 9px; font-weight: 800; }
.boost b { font-size: 14px; line-height: 1; color: var(--gold); }
.boost strong { margin-left: auto; font-variant-numeric: tabular-nums; }
.boost-track { height: 4px; margin-top: 4px; overflow: hidden; border-radius: 4px; background: #58442f; }
.boost-track i { display: block; height: 100%; background: var(--gold); transform-origin: left; }

.drive-tools { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-top: 7px; }
.keyboard-help { display: flex; gap: 13px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.keyboard-help > span { white-space: nowrap; }
kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding-inline: 4px; margin-right: 2px; border: 1px solid #61543b; border-radius: 4px; background: #28251a; color: var(--text); font: 700 10px Arial,sans-serif; }
.quiet-button { background: transparent; border: 0; padding: 3px 5px; white-space: nowrap; color: var(--muted); font-size: 12px; }
.quiet-button:hover { color: var(--gold); }

.sidebar { min-width: 0; display: grid; align-content: start; gap: 10px; }
.panel { padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.panel h2 { font-size: 16px; line-height: 1.25; }
.vehicle-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-top: 10px; }
.vehicle {
  min-width: 0; min-height: 70px; display: grid; justify-items: start; text-align: left;
  padding: 6px 8px; border: 1px solid #494234; border-radius: 5px; background: #26241b;
}
.vehicle:hover { border-color: #c39450; }
.vehicle[aria-pressed="true"] { background: #362c1c; border-color: #ba8944; }
.vehicle strong, .vehicle small { display: block; }
.vehicle strong { font-size: 13px; }
.vehicle small { color: var(--muted); font-size: 10px; line-height: 1.22; }
.vehicle-symbol { position: relative; width: 32px; height: 21px; color: #cda15b; }
.vehicle-symbol::before, .vehicle-symbol::after { position: absolute; content: ""; }
.vehicle-symbol::before { inset: 1px 0 4px; background: currentColor; clip-path: polygon(0 50%,18% 12%,65% 9%,80% 52%,100% 61%,100% 100%,0 100%); }
.atv-symbol::before { clip-path: polygon(0 54%,18% 35%,44% 62%,63% 50%,68% 15%,86% 23%,100% 81%,73% 100%,12% 100%); }
.vehicle-symbol::after { width: 9px; height: 9px; inset: auto auto 1px 4px; border: 2px solid currentColor; border-radius: 100%; background: #29231a; box-shadow: 13px 0 #29231a, 14px 0 #cda15b; }
.journal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.found-count { color: var(--gold); font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.journal p { margin-top: 6px; color: var(--muted); font-size: 12px; }
.discovery-list { display: grid; gap: 0; margin: 8px 0 0; padding: 0; list-style: none; }
.discovery-list li { min-width: 0; border-top: 1px solid var(--line); }
.discovery-list button { width: 100%; padding: 7px 2px; display: flex; align-items: center; gap: 9px; text-align: left; border: 0; background: transparent; color: var(--muted); font-size: 12px; }
.discovery-list button:hover { color: var(--text); }
.discovery-list button[aria-pressed="true"] { color: var(--gold); }
.discovery-list b { flex: 0 0 16px; width: 16px; color: #9d8963; text-align: center; font-size: 10px; }
.discovery-list .seen b { color: var(--sage); }
.discovery-list .seen button:not([aria-pressed="true"]) { color: var(--text); }

.map-dialog {
  width: min(480px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 14px;
  border: 1px solid #6f5d3d;
  border-radius: 10px;
  background: #222017;
  color: var(--text);
}
.map-dialog::backdrop { background: #0f0e0bd5; }
.map-head { display: flex; align-items: start; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.map-head h2 { font-size: 19px; }
.map-head p { color: var(--muted); font-size: 12px; }
#map { display: block; width: min(100%, calc(100dvh - 190px)); height: auto; margin: 0 auto; border: 1px solid #735a3e; border-radius: 5px; cursor: crosshair; }
.map-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-block: 8px; color: var(--muted); font-size: 11px; }
.map-legend .you::before { content: "▲"; color: #bfe4b2; margin-right: 3px; }
.map-legend .camp-legend::before { content: "◆"; color: var(--gold); margin-right: 3px; }
.map-foot { display: flex; align-items: center; gap: 7px; font-size: 12px; }
.map-foot select { flex: 1; min-width: 0; padding: 5px; border: 1px solid #665232; border-radius: 5px; background: #2d271b; }

.touch { display: none; }
body.is-expanded { overflow: hidden; }
.drive-area.is-expanded { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; background: #171712; padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
.is-expanded > .stage { flex: 1; min-height: 0; aspect-ratio: auto; }

@media (max-width: 990px) {
  .shell { width: calc(100% - 36px); }
  .layout { grid-template-columns: minmax(0, 1fr) 235px; gap: 12px; }
  .stage { min-height: 385px; }
}
@media (max-width: 730px) {
  .shell { width: calc(100% - 24px); }
  .topbar-inner { min-height: 49px; }
  .brand { font-size: 11px; gap: 5px; }
  .brand i { width: 20px; }
  nav { gap: 9px; font-size: 11px; }
  .masthead { align-items: start; margin-block: 17px 13px; }
  h1 { font-size: clamp(39px, 9.8vw, 64px); }
  .intro { font-size: 12px; }
  .main-map { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .stage { min-height: 335px; aspect-ratio: 1.4; }
  .overlay { padding-inline: 14px; }
  .overlay h2 { font-size: 37px; }
  .overlay-content > p:not(.eyebrow) { font-size: 12px; max-width: 24ch; margin-bottom: 11px; }
  .drive-hud, .stage-actions { top: 8px; }
  .drive-hud { left: 8px; }
  .stage-actions { right: 8px; }
  .hud-cell { min-width: 47px; padding-inline: 6px; }
  .hud-cell strong { font-size: 16px; }
  .icon-button { width: 34px; height: 35px; }
  .telemetry { inset: auto 8px 8px; }
  .boost { width: 105px; }
  .speed { min-width: 70px; }
  .speed strong { font-size: 23px; }
}
@media (max-width: 730px), (pointer: coarse) {
  .drive-area:has([data-phase="driving"]) .touch { display: flex; justify-content: space-between; gap: 9px; padding-top: 6px; }
  .touch > div { display: flex; gap: 5px; }
  .touch button { display: grid; place-items: center; width: clamp(41px, 12vw, 61px); height: 46px; touch-action: none; user-select: none; border: 1px solid #6b5637; border-radius: 6px; background: #30271a; font-size: 23px; font-weight: 800; }
  .touch .gas { color: var(--gold); border-color: #b88237; }
  .touch .is-held { background: var(--gold); color: #271b0e; }
}
@media (pointer: coarse) { .keyboard-help { display: none; } .drive-tools { justify-content: end; } }
@media (max-width: 730px) { .keyboard-help { display: none; } .drive-tools { justify-content: end; } }
@media (max-height: 480px) and (orientation: landscape) {
  .is-expanded .touch button { height: 32px; }
  .is-expanded .drive-tools { padding-top: 3px; }
  #map { min-width: 132px; }
}
.waypoint {
  position: absolute; z-index: 2; top: 17px; left: 50%; transform: translateX(-50%);
  max-width: min(45%, 285px); padding: 4px 9px; border: 1px solid #b99853;
  border-radius: 5px; background: #241b10ed; color: #ffe1a5; font-size: 12px;
  text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 730px) {
  .waypoint { top: 55px; max-width: calc(100% - 24px); }
  .stage:has(.waypoint:not([hidden])) .notice { top: 86px; }
}

.field-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin-left: auto; }
.vehicle-action { padding: 5px 10px; font-weight: 700; }
.vehicle-action:focus-visible { outline-offset: 2px; }
.travel-status {
  margin-left: auto; border: 1px solid #d9e1b461; border-radius: 6px;
  padding: 5px 8px; background: #1b231de8; color: #e0f1d9; font-size: 12px; font-weight: 700;
}
[data-travel="swim"] .travel-status { border-color: #a4e2df91; background: #133a42de; color: #dbf7f3; }
[data-travel="swim"] .hud-cell { border-color: #a4e2df61; background: #11333ade; }
[data-travel="swim"] .hud-cell span { color: #bde1da; }
[data-travel]:not([data-travel="car"]) .boost,
[data-travel]:not([data-travel="car"]) .car-control,
[data-travel]:not([data-travel="car"]) .car-help,
[data-travel="car"] .person-control,
[data-travel="car"] .person-help,
[data-travel]:not([data-travel="swim"]) .depth-help,
.touch > .depth-controls { display: none; }
[data-travel]:not([data-travel="car"]) #terrain-view { touch-action: none; cursor: grab; }
[data-travel]:not([data-travel="car"]) #terrain-view:active { cursor: grabbing; }
@media (max-width: 730px), (pointer: coarse) {
  [data-travel="swim"] .touch { flex-wrap: wrap; }
  [data-travel="swim"] .touch > .depth-controls { display: flex; flex-basis: 100%; justify-content: flex-end; }
  .touch .depth-controls button { width: auto; min-width: 86px; height: 35px; padding-inline: 8px; border-color: #63918b; color: #d9f9ed; font-size: 12px; }
}
