:root {
  color-scheme: dark;
  --ink: #10131b;
  --panel: #171c26;
  --line: #2d3544;
  --text: #f4f6fa;
  --muted: #a9b4c6;
  --gold: #ffd052;
  --gold-dark: #1f1707;
  --teal: #58dfc7;
  --radius: 14px;
  font-family: Inter,Geist,"Segoe UI",sans-serif;
  background: var(--ink);
  color: var(--text)
}

*,*::before,*::after {
  box-sizing: border-box
}

[hidden] {
  display: none!important
}

body {
  margin: 0;
  min-width: 310px
}

button,input,select {
  font: inherit
}

button,a,input,select,summary {
  -webkit-tap-highlight-color: transparent
}

button {
  cursor: pointer
}

button:disabled {
  cursor: default;
  opacity: .46
}

button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible,summary:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px
}

a {
  color: inherit;
  text-decoration: none
}

.topbar {
  height: 70px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 clamp(18px,4vw,64px);
  border-bottom: 1px solid var(--line);
  gap: 20px
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 950;
  letter-spacing: .035em;
  white-space: nowrap;
  font-style: italic;
  font-size: clamp(15px,2.1vw,21px)
}

.brand strong {
  color: var(--gold)
}

.brand-mark {
  color: var(--gold);
  font-size: 24px;
  line-height: .43;
  letter-spacing: -.12em;
  transform: skew(-10deg);
  padding: 3px 4px 3px 0
}

.brand-mark::first-line {
  color: var(--text)
}

nav {
  display: flex;
  align-items: stretch;
  gap: 8px;
  height: 100%
}

nav button {
  border: 0;
  background: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 0 18px;
  font-size: .95rem;
  font-weight: 660
}

nav button:hover {
  color: var(--text);
  background: #202633
}

nav button[aria-current] {
  color: var(--gold);
  border-bottom-color: var(--gold)
}

.guest {
  display: flex;
  gap: 7px;
  align-items: center;
  color: var(--muted);
  font-size: .9rem
}

.guest span,.location-dot {
  width: 8px;
  height: 8px;
  background: var(--teal);
  border-radius: 50%;
  box-shadow: 0 0 10px #58dfc760
}

main {
  max-width: 1700px;
  margin-inline: auto;
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(300px,345px);
  gap: 20px;
  padding: 22px clamp(16px,3vw,42px)
}

.stage {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  align-self: start;
  background: #171e28
}

.map-frame {
  height: clamp(530px,calc(100dvh - 155px),850px);
  position: relative;
  overflow: hidden;
  background: #202938
}

.map-frame canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none
}

.map-frame.editing canvas {
  cursor: crosshair
}

.map-caption,.hud,.map-message {
  position: absolute;
  top: 18px;
  border: 1px solid #58647777;
  border-radius: 10px;
  background: #101622e8;
  box-shadow: 0 7px 24px #080c14aa
}

.map-caption {
  left: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  pointer-events: none
}

.map-caption strong,.map-caption small {
  display: block
}

.map-caption strong {
  font-size: 1rem
}

.map-caption small {
  font-size: .8rem;
  color: var(--muted);
  margin-top: 2px
}

.hud {
  right: 18px;
  display: flex;
  gap: 17px;
  padding: 10px 14px;
  font-variant-numeric: tabular-nums;
  pointer-events: none
}

.hud small,.hud strong {
  display: block
}

.hud small {
  color: var(--muted);
  font-size: .66rem;
  letter-spacing: .075em
}

.hud strong {
  font-size: 1.1rem;
  white-space: nowrap;
  margin-top: 3px
}

.hud div:first-child strong {
  color: var(--gold)
}

.map-message {
  inset: auto auto 38px 18px;
  color: var(--text);
  font-size: .88rem;
  padding: 9px 12px;
  max-width: calc(100% - 36px);
  pointer-events: none
}

.attribution {
  position: absolute;
  right: 0;
  bottom: 0;
  padding: 3px 7px;
  background: #111721dc;
  font-size: .73rem;
  color: #e0e9f6;
  border-top-left-radius: 6px
}

.attribution:hover {
  text-decoration: underline
}

.stage-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 42px;
  padding: 8px 15px;
  color: #c0cadc;
  font-size: .86rem
}

.stage-footer span:first-child {
  display: flex;
  align-items: center;
  gap: 8px
}

.stage-footer i {
  width: 14px;
  height: 3px;
  border-radius: 2px;
  background: var(--gold)
}

.rail {
  min-width: 0;
  align-self: start
}

.panel,.share-box,.notice {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 19px
}

.eyebrow {
  color: var(--gold);
  letter-spacing: .105em;
  text-transform: uppercase;
  font-weight: 730;
  font-size: .76rem;
  margin: 0 0 7px
}

.panel h1 {
  font-size: clamp(27px,3vw,42px);
  font-weight: 820;
  line-height: 1.01;
  letter-spacing: -.05em;
  margin: 0 0 16px;
  overflow-wrap: anywhere
}

.panel h2 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 8px
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px
}

.stats div {
  background: #11151f;
  border: 1px solid #303848;
  border-radius: 8px;
  padding: 9px 10px
}

.stats span,.stats strong {
  display: block
}

.stats span {
  color: var(--muted);
  font-size: .83rem
}

.stats strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-size: 1.11rem;
  margin-top: 3px
}

.stats div:nth-child(2) strong {
  color: var(--gold)
}

.primary,.secondary {
  min-height: 43px;
  padding: 9px 12px;
  border-radius: 8px;
  display: block;
  width: 100%;
  font-weight: 730;
  text-align: center;
  margin-top: 8px
}

.primary {
  background: var(--gold);
  color: var(--gold-dark);
  border: 1px solid var(--gold)
}

.primary:hover:not(:disabled) {
  background: #ffe086;
  border-color: #ffe086
}

.secondary {
  background: #1c2330;
  color: var(--text);
  border: 1px solid #3a4455
}

.secondary:hover:not(:disabled) {
  background: #283447;
  border-color: #67758d
}

.car-count {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  font-size: .91rem;
  color: #e2e7ef
}

.car-count>div {
  display: flex;
  gap: 8px;
  align-items: center
}

.car-count button {
  height: 31px;
  min-width: 36px;
  border: 1px solid #3a4455;
  background: #222a37;
  color: var(--text);
  border-radius: 6px
}

.car-count button:hover:not(:disabled) {
  background: #39485f
}

.car-count output {
  width: 14px;
  text-align: center;
  color: var(--gold);
  font-weight: 740
}

.keyboard-hint {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 5px;
  margin: 13px 0;
  color: var(--muted);
  font-size: .75rem
}

.keyboard-hint span {
  white-space: nowrap
}

kbd {
  font: inherit;
  display: inline-grid;
  place-items: center;
  border: 1px solid #3b4659;
  border-radius: 4px;
  background: #141926;
  padding: 1px 4px;
  color: #e6ecf7;
  margin-right: 2px
}

.roster,.leaderboard {
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid var(--line)
}

ol {
  list-style: none;
  margin: 0;
  padding: 0
}

.roster li,.leaderboard li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .85rem;
  padding: 5px 0
}

.roster li span:last-child,.leaderboard li strong {
  margin-left: auto;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: .8rem
}

.roster li strong,.leaderboard li>span:nth-child(2) {
  overflow-wrap: anywhere;
  min-width: 0
}

.driver-swatch {
  display: inline-grid;
  place-items: center;
  color: #10131b;
  min-width: 21px;
  height: 19px;
  border-radius: 4px;
  font-weight: 820;
  font-size: .72rem
}

.leaderboard p,.muted {
  color: var(--muted);
  font-size: .91rem;
  line-height: 1.48;
  margin: 0 0 10px
}

.leaderboard p {
  font-size: .84rem;
  margin-bottom: 0
}

.ranking-position {
  font-variant-numeric: tabular-nums;
  color: var(--gold);
  min-width: 17px
}

.result {
  margin-top: 12px
}

.result>strong,.result>span {
  display: block
}

.result>strong {
  font-size: 2rem;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  margin: 2px 0 6px
}

.result #result-detail {
  font-size: .86rem;
  color: var(--muted);
  margin-bottom: 8px
}

label {
  display: block;
  color: #e2e8f2;
  font-size: .9rem;
  margin: 12px 0 5px
}

input,select {
  width: 100%;
  min-height: 42px;
  background: #101620;
  color: var(--text);
  border: 1px solid #3b4557;
  padding: 8px 10px;
  border-radius: 8px
}

input::placeholder {
  color: #8d99ae
}

.pins {
  margin: 8px 0;
  max-height: 185px;
  overflow: auto
}

.pins li {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid #2e3745;
  padding: 7px 0;
  font-size: .85rem
}

.pins li b {
  min-width: 24px;
  color: var(--gold)
}

.editor-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px
}

.editor-note {
  margin: 9px 0 0
}

.street-select {
  margin-top: 12px;
  font-size: .88rem;
  color: var(--muted)
}

.street-select summary {
  cursor: pointer;
  margin-bottom: 6px
}

.compact {
  min-height: 35px
}

.track-list {
  display: grid;
  gap: 7px;
  margin-bottom: 12px
}

.track-card {
  display: block;
  text-align: left;
  border: 1px solid #3a4455;
  border-radius: 8px;
  background: #1c2330;
  color: var(--text);
  padding: 9px 10px
}

.track-card:hover {
  background: #2a3445
}

.track-card strong,.track-card small {
  display: block;
  overflow-wrap: anywhere
}

.track-card small {
  margin-top: 3px;
  color: var(--muted)
}

.share-box,.notice {
  margin-top: 10px;
  padding: 13px
}

.share-box label {
  margin-top: 0
}

.share-box p,.notice {
  font-size: .9rem;
  color: var(--muted)
}

.share-box p {
  margin: 8px 0 0
}

.notice {
  color: #ffd999
}

.touch {
  position: absolute;
  bottom: 25px;
  left: 12px;
  right: 12px;
  display: none;
  justify-content: space-between;
  pointer-events: none
}

.touch>div {
  display: flex;
  gap: 7px
}

.touch button {
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  background: #172231e8;
  border: 1px solid #75839b;
  color: #fff;
  border-radius: 10px;
  min-height: 52px;
  min-width: 49px;
  font-weight: 740;
  padding: 5px 9px
}

.touch button[data-control="left"],.touch button[data-control="right"] {
  font-size: 1.9rem
}

.touch .gas {
  background: var(--gold);
  color: var(--gold-dark);
  min-width: 59px;
  border-color: var(--gold)
}

.touch button.pressed {
  filter: brightness(1.45);
  transform: translateY(2px)
}

@media(max-width:850px) {
  main {
    grid-template-columns: minmax(0,1fr) minmax(240px,280px);
    gap: 12px;
    padding: 14px 13px
  }
  .panel {
    padding: 14px
  }
  .topbar {
    padding-inline: 15px
  }
  .map-frame {
    height: clamp(490px,calc(100dvh - 145px),740px)
  }
  nav button {
    padding-inline: 10px
  }
  .hud {
    gap: 10px
  }
}

@media(max-width:670px) {
  .topbar {
    height: 56px;
    padding-inline: 11px;
    gap: 8px
  }
  .brand {
    gap: 6px;
    font-size: 14px
  }
  .brand-mark {
    font-size: 18px
  }
  nav {
    gap: 0
  }
  nav button {
    font-size: .85rem;
    padding-inline: 8px
  }
  .guest {
    display: none
  }
  main {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 8px
  }
  .stage,.rail {
    width: 100%
  }
  .map-frame {
    height: clamp(320px,52dvh,520px)
  }
  .map-caption {
    top: 8px;
    left: 8px;
    padding: 6px 8px;
    gap: 6px
  }
  .map-caption strong {
    font-size: .86rem
  }
  .map-caption small {
    font-size: .72rem
  }
  .hud {
    top: 8px;
    right: 8px;
    padding: 6px 7px;
    gap: 8px
  }
  .hud strong {
    font-size: .86rem
  }
  .hud small {
    font-size: .57rem
  }
  .map-message {
    left: 8px;
    bottom: 22px;
    padding: 5px 7px
  }
  .stage-footer {
    min-height: 33px;
    padding: 6px 9px
  }
  .stage-footer,.attribution {
    font-size: .74rem
  }
  .panel h1 {
    margin-bottom: 11px
  }
  .stats {
    margin-bottom: 8px
  }
  .touch {
    display: flex
  }
  .keyboard-hint {
    display: none
  }
  .panel .primary,.panel .secondary {
    min-height: 44px
  }
}

@media(pointer:coarse) {
  .touch {
    display: flex
  }
  .keyboard-hint {
    display: none
  }
}

.result-ad {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 13px;
  padding: 9px 12px;
  background: #302b20;
  border: 1px solid #665431;
  border-radius: 8px;
  color: #f8ce64
}

.result-ad strong {
  letter-spacing: .14em;
  font-style: italic
}

.result-ad span {
  font-size: .78rem;
  color: #e0cda4
}

@media (max-width: 670px), (pointer: coarse) {
  .map-frame:has(.touch:not([hidden])) .map-message {
    bottom: 87px;
  }
}

.globe-stage {
  position: relative;
  height: clamp(438px, calc(100dvh - 135px), 860px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101622;
}

#globe { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#globe:active { cursor: grabbing; }
.world-panel { align-self: start; }
.world-panel h1 { margin-bottom: 13px; }
.city-list { display: flex; gap: 6px; flex-wrap: wrap; margin: 13px 0; }
.city-list .secondary { width: auto; margin: 0; font-size: .83rem; padding-inline: 8px; }
.coordinates { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.coordinates label { margin: 0 0 8px; min-width: 0; }
.coordinates input { margin-top: 5px; min-width: 0; }
#world-note { margin: 8px 0 0; }
#relief-profile { display: block; width: 100%; height: 42px; margin-top: 6px; background: #14202a; border-radius: 6px; }

.map-tools {
  position: absolute;
  right: 14px;
  top: 15px;
  display: flex;
  gap: 5px;
}
.globe-tools { top: auto; bottom: 16px; }
.map-tools button {
  min-width: 39px;
  height: 39px;
  border: 1px solid #667483;
  border-radius: 8px;
  background: #141e2cee;
  color: var(--text);
  font-size: 1.22rem;
}
.map-tools button:hover, .mini-map:hover { background: #27364a; }
.mini-map {
  position: absolute;
  right: 13px;
  bottom: 29px;
  width: 122px;
  padding: 5px;
  border: 1px solid #6a7787;
  border-radius: 9px;
  color: var(--text);
  background: #101925e8;
  font-size: .77rem;
}
.mini-map canvas { display: block; width: 100%; height: auto; }
.mini-map[aria-pressed=true] { border-color: var(--gold); }
.attribution { display: flex; flex-wrap: wrap; column-gap: 7px; justify-content: flex-end; }
.attribution:hover { text-decoration: none; }
.attribution a:hover { text-decoration: underline; }
.pins li { padding: 4px 0; }
.pin-choice, .pin-remove { border: 1px solid transparent; border-radius: 5px; color: var(--text); background: transparent; }
.pin-choice { flex: 1; min-width: 0; display: flex; align-items: center; text-align: left; padding: 5px; }
.pin-choice span { overflow-wrap: anywhere; }
.pin-choice[aria-pressed=true] { border-color: #536a7e; background: #273344; }
.pin-remove { min-width: 31px; height: 31px; color: var(--muted); font-size: 1.12rem; }
.pin-remove:hover { color: var(--text); background: #443649; }

@media (max-width: 670px) {
  .globe-stage, .world-panel { width: 100%; }
  .globe-stage { height: clamp(340px, 51dvh, 515px); }
  .map-tools { right: 8px; top: 8px; }
  .globe-tools { top: auto; }
  .map-tools button { min-width: 36px; height: 36px; }
  .mini-map { bottom: 86px; right: 8px; width: 89px; font-size: .68rem; }
  .map-frame:has(.touch:not([hidden])) .map-message { max-width: calc(100% - 117px); }
  .touch>div { gap: 4px; }
  .touch button { min-width: 42px; padding: 4px 6px; }
  .touch .gas { min-width: 50px; }
}
@media (max-width: 380px) {
  .brand { font-size: 12px; }
  .brand-mark { display: none; }
  nav button { padding-inline: 6px; font-size: .78rem; }
}
