:root {
  --ink: #151517;
  --ink2: #1d1c1a;
  --cream: #eee3cd;
  --cream-dim: rgba(238, 227, 205, 0.68);
  --amber: #eaa14b;
  --amber-hot: #f3b45e;
  --red: #cc4329;
  --teal: #5e8c7e;
  --dial: clamp(88px, min(30vw, 20vh), 166px);
  --wheel: clamp(146px, 42vw, 270px);
  --pedal: clamp(58px, 18.5vw, 118px);
  --smallbtn: clamp(44px, 13vw, 82px);
  --cam: clamp(32px, 8vw, 58px);
  --pad: max(10px, env(safe-area-inset-left));
  --padt: max(10px, env(safe-area-inset-top));
  --padb: max(10px, env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #151412;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  font-family: 'Barlow', 'Helvetica Neue', Arial, sans-serif;
}

#app { position: fixed; inset: 0; }
#app.garage-open #title, #app.online-open #title { opacity: 0; pointer-events: none; }

#scene {
  position: absolute;
  filter: saturate(1.1) contrast(1.04) sepia(0.035);
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #1a1713;
}

#vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    radial-gradient(ellipse at 50% 44%, rgba(0,0,0,0) 46%, rgba(12,9,7,0.32) 100%),
    linear-gradient(to bottom, rgba(10,8,7,0.18), rgba(0,0,0,0) 14%, rgba(0,0,0,0) 82%, rgba(10,8,7,0.24));
}

#grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  opacity: 0.055;
  background-image: url("assets/ui_grain.png");
  background-size: 180px 180px;
  mix-blend-mode: overlay;
}

/* ---------------- HUD ---------------- */
#hud {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  color: var(--cream);
  font-family: 'Barlow', sans-serif;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 500ms ease;
}
#app.playing #hud { opacity: 1; }

.hud-left {
  position: absolute;
  left: var(--pad);
  top: var(--padt);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
}

#speedBlock { display: flex; align-items: center; gap: 7px; }

#dial {
  position: relative;
  width: var(--dial);
  height: var(--dial);
  flex: none;
}

#dialFace { display: block; width: 100%; height: 100%; }

#needle {
  position: absolute;
  left: 50%;
  bottom: 50%;
  width: calc(var(--dial) * 0.018);
  height: calc(var(--dial) * 0.345);
  margin-left: calc(var(--dial) * -0.009);
  background: linear-gradient(to top, #d9562e, #f6bd67 70%, #f6c778);
  border-radius: 2px;
  transform-origin: 50% 100%;
  transform: rotate(-135deg);
  will-change: transform;
}

#hub {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--dial) * 0.165);
  height: calc(var(--dial) * 0.165);
  margin-left: calc(var(--dial) * -0.0825);
  margin-top: calc(var(--dial) * -0.0825);
  border-radius: 50%;
  background: #e7dcc4;
  border: 1px solid rgba(38, 34, 28, 0.18);
}

#digital {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-top: calc(var(--dial) * 0.12);
}

#spd {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 100;
  font-size: calc(var(--dial) * 0.35);
  line-height: 0.82;
  letter-spacing: -0.06em;
  color: #f2e7d2;
  font-variant-numeric: tabular-nums;
}

.unit {
  font-family: 'Barlow', sans-serif;
  font-size: calc(var(--dial) * 0.085);
  letter-spacing: 0.16em;
  color: var(--cream-dim);
  margin-top: 3px;
}

#heatBlock {
  width: calc(var(--dial) * 1.32);
  position: relative;
}
#heatImg { display: block; width: 100%; opacity: 0.86; }
#heatBlock .micro { display: flex; justify-content: space-between; margin-top: -3px; }

#bestBlock {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--cream);
  font-size: 12px;
  line-height: 1;
}
#bestBlock .micro { color: var(--cream-dim); }

.micro {
  font-family: 'Barlow', sans-serif;
  font-weight: 600;
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--cream-dim);
}

.hud-right {
  position: absolute;
  right: var(--pad);
  top: var(--padt);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

#battery {
  position: relative;
  height: clamp(82px, 15vh, 140px);
  aspect-ratio: 130 / 372;
}
#battFrame { display: block; width: 100%; height: 100%; }
#cells { position: absolute; inset: 0; }
.cell {
  position: absolute;
  left: 14%;
  right: 14%;
  height: 12.8%;
  border-radius: 5px;
  background: linear-gradient(180deg, #f3e8d1, #d9c29a);
  opacity: 0.96;
  transition: opacity 140ms linear;
}
.cell.off { opacity: 0; }
.battlabel {
  position: absolute;
  right: 0;
  bottom: -13px;
  letter-spacing: 0.18em;
}

#map {
  position: relative;
  width: calc(var(--dial) * 0.82);
  aspect-ratio: 290 / 307;
  margin-top: 12px;
}
#mapFrame { display: block; width: 100%; height: 100%; }
#mapInner {
  position: absolute;
  inset: 7.5%;
  background: #191817;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 3px;
  overflow: hidden;
}
#mapCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0.94;
}
#mapInner span {
  position: relative;
  z-index: 2;
  font-size: 7px;
  letter-spacing: 0.2em;
  color: rgba(238, 227, 205, 0.62);
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}
#raceLine {
  display: flex;
  justify-content: center;
  gap: 9px;
  width: calc(var(--dial) * 0.82);
  margin-top: 3px;
  padding: 2px 5px;
  background: rgba(18, 16, 13, 0.52);
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--cream);
  text-transform: uppercase;
}
#raceLine #posVal { color: var(--amber); font-weight: 700; }

#driftFlash {
  position: absolute;
  left: 50%;
  top: 29vh;
  transform: translateX(-50%) skewX(-7deg);
  display: flex;
  align-items: baseline;
  gap: 8px;
  opacity: 0;
  transition: opacity 220ms ease;
  pointer-events: none;
  white-space: nowrap;
  padding: 2px 14px 4px;
  background: rgba(20, 17, 14, 0.58);
}
#driftFlash.live { opacity: 0.68; }
#driftFlash.hit { opacity: 1; }
#driftFlash .dword {
  font-family: 'Big Shoulders', Impact, sans-serif;
  font-weight: 800;
  font-size: clamp(13px, 2.3vh, 24px);
  letter-spacing: 0.06em;
  color: var(--cream);
  -webkit-text-stroke: 1px rgba(20, 17, 14, 0.55);
}
#dscore {
  font-family: 'Big Shoulders', Impact, sans-serif;
  font-weight: 800;
  font-style: italic;
  font-size: clamp(34px, 7vh, 68px);
  line-height: 0.78;
  letter-spacing: -0.02em;
  color: var(--amber-hot);
  -webkit-text-stroke: 1px rgba(20, 17, 14, 0.5);
  font-variant-numeric: tabular-nums;
}
#dmult {
  font-family: 'Big Shoulders', Impact, sans-serif;
  font-weight: 800;
  font-size: clamp(15px, 3vh, 30px);
  color: var(--amber);
  -webkit-text-stroke: 1px rgba(20, 17, 14, 0.45);
}
#driftFlash.hit #dscore { animation: punch 320ms cubic-bezier(.2,1.7,.4,1); }
@keyframes punch {
  0% { transform: scale(0.72); }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

#boostLamp {
  position: absolute;
  left: 50%;
  bottom: calc(var(--padb) + var(--cam) + 30px);
  width: clamp(30px, 6vh, 54px);
  transform: translateX(-50%);
  opacity: 0.22;
  transition: opacity 160ms linear;
}
#boostLamp img { display: block; width: 100%; }
#boostLamp.ready { opacity: 1; }
#boostLamp.spent { opacity: 0.1; }

@media (hover: none), (max-width: 760px) {
  #legend { display: none; }
}
#legend {
  position: absolute;
  left: 50%;
  top: max(7px, env(safe-area-inset-top));
  transform: translateX(-50%);
  width: max-content;
  max-width: 94vw;
  font-size: clamp(7px, 0.9vh, 10px);
  font-weight: 600;
  letter-spacing: 0.13em;
  color: rgba(238, 227, 205, 0.58);
  text-align: center;
  white-space: nowrap;
}
#legend i {
  display: inline-block;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(238, 227, 205, 0.4);
  margin: 0 6px 2px;
}

#camToast {
  position: absolute;
  left: 50%;
  top: 38vh;
  transform: translateX(-50%);
  font-family: 'Big Shoulders', sans-serif;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.12em;
  color: var(--cream);
  opacity: 0;
  transition: opacity 200ms ease;
}
#camToast.show { opacity: 0.85; }

/* ---------------- touch controls ---------------- */
#touch {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  opacity: 0;
  transition: opacity 400ms ease;
}
#app.playing #touch { opacity: 1; }

#wheelPad {
  position: absolute;
  left: var(--pad);
  bottom: var(--padb);
  width: var(--wheel);
  height: var(--wheel);
  pointer-events: none;
  touch-action: none;
  cursor: pointer;
}
#app.playing #wheelPad { pointer-events: auto; }
#wheelLabel {
  position: absolute;
  left: var(--pad);
  bottom: calc(var(--padb) + var(--wheel) + 5px);
  pointer-events: none;
  font-family: 'Barlow', sans-serif;
  font-weight: 600;
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(238, 227, 205, 0.6);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}
#wheel {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  transform-origin: 50% 50%;
  will-change: transform;
  filter: drop-shadow(0 2px 0 rgba(10, 8, 6, 0.18));
}

#pedalPad {
  position: absolute;
  right: var(--pad);
  bottom: var(--padb);
  display: flex;
  align-items: flex-end;
  gap: 6px;
  pointer-events: none;
}
.smallrow {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}
.pedalRow { display: flex; align-items: flex-end; gap: 6px; }

.tbtn {
  pointer-events: none;
  touch-action: none;
  border: 0;
  background: none;
  padding: 0;
  margin: 0;
  display: block;
  cursor: pointer;
  opacity: 0.94;
  transition: transform 80ms linear, opacity 120ms linear;
}
#app.playing .tbtn { pointer-events: auto; }
.tbtn img { display: block; width: 100%; height: auto; pointer-events: none; }
.tbtn.pressed { transform: scale(0.965); }
.tbtn.small { width: var(--smallbtn); }
.tbtn.pedal.throttle { width: var(--pedal); }
.tbtn.pedal.brake { width: calc(var(--pedal) * 0.79); opacity: 0.9; }
.tbtn.cam {
  position: absolute;
  left: 50%;
  bottom: var(--padb);
  transform: translateX(-50%);
  width: var(--cam);
  opacity: 0.9;
}
.tbtn.cam.pressed { transform: translateX(-50%) scale(0.94); }

#app.playing #resetBtn { pointer-events: auto; }
#resetBtn {
  position: absolute;
  left: 50%;
  bottom: calc(var(--padb) + var(--cam) + 8px);
  transform: translateX(-50%);
  pointer-events: none;
  border: 0;
  border-bottom: 1px solid rgba(238, 227, 205, 0.55);
  background: none;
  padding: 2px 3px;
  color: rgba(238, 227, 205, 0.72);
  font-family: 'Barlow', sans-serif;
  font-weight: 600;
  font-size: 9px;
  letter-spacing: 0.18em;
  cursor: pointer;
}

/* ---------------- title ---------------- */
#title {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 clamp(22px, 7vw, 96px);
  pointer-events: none;
}
#title::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, rgba(238, 222, 196, 0.4), rgba(238, 222, 196, 0.1) 46%, rgba(238, 222, 196, 0) 72%);
  pointer-events: none;
}
.title-wrap {
  position: relative;
  max-width: min(760px, 88vw);
  transform: translateY(-8vh);
  pointer-events: auto;
}
.title-kicker {
  margin: 0 0 4px;
  font-family: 'Big Shoulders', Impact, sans-serif;
  font-weight: 800;
  font-size: clamp(13px, 1.8vw, 22px);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--amber);
}
#title h1 {
  margin: 0;
  font-family: 'Big Shoulders', Impact, 'Arial Narrow', sans-serif;
  font-weight: 800;
  font-size: clamp(52px, 12.5vw, 138px);
  line-height: 0.78;
  letter-spacing: -0.035em;
  color: #141310;
  text-transform: uppercase;
  text-wrap: balance;
}
.title-rule {
  width: clamp(52px, 9vw, 120px);
  height: 3px;
  background: var(--amber);
  margin: 22px 0 12px;
}
.title-step {
  margin: 0 0 30px;
  font-family: 'Barlow', sans-serif;
  font-weight: 600;
  font-size: clamp(11px, 1.25vw, 15px);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(22, 20, 16, 0.86);
}
.title-step span { color: var(--amber); padding: 0 2px; }
.title-actions { display: flex; align-items: baseline; gap: clamp(22px, 4vw, 46px); }

#driveBtn, #ctrlBtn, #grgBtn {
  border: 0;
  background: none;
  padding: 0 0 5px;
  cursor: pointer;
  font-family: 'Big Shoulders', Impact, sans-serif;
  font-weight: 800;
  text-transform: uppercase;
  color: #141310;
  line-height: 1;
}
#driveBtn {
  font-size: clamp(30px, 4.6vw, 52px);
  letter-spacing: 0.02em;
  border-bottom: 4px solid var(--amber);
}
#ctrlBtn, #grgBtn {
  font-size: clamp(15px, 1.9vw, 22px);
  letter-spacing: 0.12em;
  border-bottom: 1px solid rgba(20, 19, 16, 0.55);
  color: rgba(20, 19, 16, 0.78);
}
#driveBtn:hover, #ctrlBtn:hover { color: #000; }
#driveBtn:active, #ctrlBtn:active { transform: translateY(1px); }

#loadingLine {
  margin-top: 24px;
  font-family: 'Barlow', sans-serif;
  font-weight: 600;
  font-size: 9px;
  letter-spacing: 0.22em;
  color: rgba(22, 20, 16, 0.62);
}

#ctrlPanel {
  display: none;
  margin-top: 26px;
  padding: 18px 20px 16px;
  background: #161513;
  border-top: 2px solid var(--amber);
  color: var(--cream);
  max-width: 760px;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
}
#ctrlPanel.open { display: grid; }
.ctrl-col b {
  display: block;
  font-family: 'Big Shoulders', sans-serif;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.08em;
  color: var(--amber);
  margin-bottom: 5px;
}
.ctrl-col p {
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
  letter-spacing: 0.01em;
  color: rgba(238, 227, 205, 0.8);
  text-transform: none;
}

#title.gone {
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity 620ms ease, transform 620ms ease;
  pointer-events: none;
}
#title.gone .title-wrap { transform: translateY(-10vh); transition: transform 620ms cubic-bezier(.4,0,.2,1); }

#fade {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: #171512;
  opacity: 1;
  pointer-events: none;
  transition: opacity 900ms ease;
}
#fade.out { opacity: 0; }

/* ---------------- responsive ---------------- */
@media (orientation: portrait) {
  .title-wrap { transform: translateY(-14vh); }
}

@media (orientation: landscape) {
  :root {
    --pedal: clamp(56px, 9vw, 96px);
    --wheel: clamp(128px, 24vw, 250px);
    --smallbtn: clamp(40px, 7vw, 68px);
    --cam: clamp(30px, 4.5vw, 48px);
  }
  #driftFlash { top: 15vh; }
  #legend { font-size: 9px; }
}

@media (max-width: 380px) {
  #camBtn { left: calc(50% - 36px); width: 28px; }
  #wheelPad { width: 42vw; height: 42vw; }
  .tbtn.small { width: 42px; }
  .tbtn.pedal.brake { width: 44px; }
  .tbtn.pedal.throttle { width: 56px; }
  #legend { display: none; }
}

@media (min-width: 500px) and (orientation: landscape) {
  #camBtn { left: calc(50% - 30px); }
}

@media (max-height: 500px) and (max-width: 760px) {
  #ctrlPanel {
    position: fixed;
    left: 10px; right: 10px; bottom: 10px; top: auto;
    max-height: 62vh; overflow-y: auto;
    touch-action: pan-y;
    z-index: 6;
  }
}

@media (max-width: 520px) {
  #ctrlPanel { grid-template-columns: 1fr 1fr; gap: 12px; padding: 14px 16px 12px; }
  .ctrl-col:last-child { grid-column: 1 / -1; }
  .ctrl-col p { font-size: 10px; }
}

@media (max-width: 400px) {
  #spd { font-size: calc(var(--dial) * 0.32); }
  #legend { font-size: 6.5px; letter-spacing: 0.08em; }
  #legend i { margin: 0 3px 2px; }
  #camBtn { left: calc(50% - 24px); }
  #resetBtn { bottom: calc(var(--padb) + var(--cam) + 6px); font-size: 8px; }
  .hud-left { gap: 5px; }
  #heatBlock { width: calc(var(--dial) * 1.18); }
}

@media (max-height: 460px) {
  #dial { width: clamp(78px, 18vh, 120px); height: auto; aspect-ratio: 1; }
  #driftFlash { top: 13vh; }
  #boostLamp { bottom: calc(var(--padb) + 6px); left: calc(50% + 84px); }
  #resetBtn { display: none; }
  #legend { display: none; }
  .hud-left { gap: 4px; }
  #bestBlock { display: none; }
}

@media (min-width: 900px) and (orientation: landscape) {
  .title-wrap { transform: translateY(-2vh); }
}

/* ---------------- pursuit, hull, wallet ---------------- */
#heatBlock { position: relative; }
#heatFrame { position: relative; }
#heatPips {
  position: absolute;
  left: 4.6%;
  right: 2.6%;
  top: 19%;
  bottom: 19%;
  display: flex;
  gap: 2.7%;
  pointer-events: none;
}
#heatPips i {
  flex: 1;
  background: rgba(255, 112, 58, 0.1);
  transform: skewX(-16deg);
  border-radius: 1px;
  transition: background 160ms linear, box-shadow 160ms linear;
}
#heatPips i.on {
  background: rgba(255, 95, 42, 0.95);
  box-shadow: 0 0 7px rgba(255, 90, 40, 0.85);
}

#hullBlock {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--cream);
}
#hullBar { display: flex; gap: 2px; }
#hullBar i {
  width: 11px;
  height: 5px;
  background: rgba(238, 227, 205, 0.18);
  border-radius: 1px;
}
#hullBar i.on { background: #d9cba9; }
#hullBar i.low { background: #d2502d; }
#hullVal { color: var(--cream-dim); }

#wallet {
  display: flex;
  gap: 9px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.04em;
  color: var(--cream-dim);
  white-space: nowrap;
}
#cashVal { color: var(--amber-hot); font-weight: 700; }

#pursuitBanner {
  position: absolute;
  left: 50%;
  top: max(30px, calc(env(safe-area-inset-top) + 26px));
  transform: translateX(-50%) skewX(-7deg);
  font-family: 'Big Shoulders', Impact, sans-serif;
  font-weight: 800;
  font-size: clamp(20px, 4.2vh, 40px);
  letter-spacing: 0.14em;
  color: var(--amber-hot);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
  opacity: 0;
  transition: opacity 240ms ease;
  pointer-events: none;
  white-space: nowrap;
}
#pursuitBanner.show { opacity: 1; }
#pursuitBanner.hot { color: #ff5236; }
#pursuitBanner.cool { color: #9ed27b; }

#garageBtn {
  pointer-events: auto;
  border: 0;
  border-bottom: 1px solid rgba(238, 227, 205, 0.45);
  background: none;
  padding: 1px 2px;
  color: rgba(238, 227, 205, 0.78);
  font-family: 'Barlow', sans-serif;
  font-weight: 600;
  font-size: 9px;
  letter-spacing: 0.16em;
  cursor: pointer;
}

/* ---------------- garage ---------------- */
#garage {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: none;
  background: rgba(11, 10, 9, 0.97);
  color: var(--cream);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
#garage.open { display: block; }
.garage-panel {
  max-width: 1120px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) clamp(14px, 4vw, 44px) 40px;
}
.garage-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid rgba(238, 227, 205, 0.18);
  padding-bottom: 10px;
}
.garage-title h2 {
  margin: 2px 0 0;
  font-family: 'Big Shoulders', Impact, sans-serif;
  font-weight: 800;
  font-size: clamp(34px, 6vw, 64px);
  line-height: 0.86;
  letter-spacing: -0.02em;
}
.garage-wallet {
  display: flex;
  gap: 14px;
  align-items: baseline;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.04em;
}
#gCash { color: var(--amber); font-weight: 700; }
#garageClose {
  border: 1px solid rgba(238, 227, 205, 0.4);
  background: transparent;
  color: var(--cream);
  font-family: 'Big Shoulders', Impact, sans-serif;
  font-weight: 800;
  letter-spacing: 0.12em;
  padding: 8px 14px;
  font-size: 14px;
}
.garage-body { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); gap: 26px; padding-top: 18px; }
#gCarList { display: grid; gap: 8px; }
.gCar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid rgba(238,227,205,0.16); background: rgba(238,227,205,0.04);
  padding: 10px 12px; cursor: pointer; text-align: left;
  font-family: 'Barlow', sans-serif; color: var(--cream);
}
.gCar:hover { border-color: rgba(238,227,205,0.4); }
.gCar.sel { border-color: var(--amber); background: rgba(234,161,75,0.12); }
.gCar b { font-family: 'Big Shoulders', Impact, sans-serif; font-size: 20px; font-weight: 800; letter-spacing: 0.04em; }
.gCar span { font-family: 'JetBrains Mono', monospace; font-size: 9px; color: var(--cream-dim); }
.garage-controls { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.g-section b {
  display: block; font-family: 'Barlow', sans-serif; font-weight: 600; font-size: 10px;
  letter-spacing: 0.18em; color: var(--amber); margin-bottom: 8px; text-transform: uppercase;
}
#gPaintList { display: flex; gap: 8px; flex-wrap: wrap; }
.gPaint {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid rgba(238,227,205,0.35);
  cursor: pointer; padding: 0;
}
.gPaint.sel { border-color: #fff; box-shadow: 0 0 0 2px var(--amber); }
.gUpgradeRow {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border-top: 1px solid rgba(238,227,205,0.12); padding: 9px 0;
}
.gUpgradeRow .gUpName { font-family: 'Barlow', sans-serif; font-size: 12px; letter-spacing: 0.04em; }
.gUpgradeRow .gUpLv { font-family: 'JetBrains Mono', monospace; font-size: 9px; color: var(--cream-dim); margin-left: 6px; }
.gUpgradeRow button {
  border: 1px solid rgba(238,227,205,0.35); background: transparent; color: var(--cream);
  font-family: 'Barlow', sans-serif; font-weight: 600; font-size: 10px; letter-spacing: 0.08em;
  padding: 6px 9px; cursor: pointer; white-space: nowrap;
}
.gUpgradeRow button:disabled { opacity: 0.35; cursor: default; }
.gUpgradeRow button:not(:disabled):hover { border-color: var(--amber); color: var(--amber); }
.g-actions { display: flex; gap: 10px; margin-top: 4px; }
.g-actions button {
  flex: 1; border: 0; padding: 12px 10px; cursor: pointer;
  font-family: 'Big Shoulders', Impact, sans-serif; font-weight: 800; font-size: 18px;
  letter-spacing: 0.08em; text-transform: uppercase;
  background: rgba(238,227,205,0.1); color: var(--cream);
}
#gDrive { background: var(--amber); color: #161310; }
#gRepair { border: 1px solid rgba(238,227,205,0.28); }
#gRepair:disabled { opacity: 0.35; cursor: default; }
.garage-preview { position: relative; min-width: 0; }
#garageCar {
  width: 100%; max-height: 44vh; object-fit: contain; display: block;
  filter: hue-rotate(0deg) saturate(1.12);
  transition: filter 220ms ease;
}
.garage-carinfo { padding: 8px 0 0; }
.garage-carinfo h3 {
  margin: 0; font-family: 'Big Shoulders', Impact, sans-serif; font-weight: 800;
  font-size: clamp(28px, 4vw, 44px); line-height: 0.9; letter-spacing: 0.02em;
}
.garage-carinfo p { margin: 6px 0 10px; color: rgba(238,227,205,0.66); font-size: 12px; line-height: 1.45; max-width: 46ch; }
.g-stat { display: flex; align-items: center; gap: 8px; font-family: 'JetBrains Mono', monospace; font-size: 9px; color: var(--cream-dim); margin: 4px 0; }
.g-stat > span { width: 48px; letter-spacing: 0.08em; }
.g-bar { flex: 1; height: 5px; background: rgba(238,227,205,0.14); }
.g-bar i { display: block; height: 100%; background: var(--amber); }
.g-stat b { font-size: 10px; color: var(--cream); min-width: 26px; text-align: right; }

@media (max-width: 760px) {
  .garage-body { display: block; }
  #garageCar { max-height: 26vh; }
  .garage-wallet { font-size: 10px; gap: 8px; }
  .garage-head { align-items: flex-start; }
  .garage-preview { margin-bottom: 14px; }
}
@media (max-height: 540px) {
  #garageCar { max-height: 30vh; }
  .garage-head { position: sticky; top: 0; background: rgba(11,10,9,0.96); z-index: 2; }
}

/* ---------------- Crown City Online ---------------- */
.title-online {
  display: inline-block;
  margin-top: 18px;
  border: 0;
  border-bottom: 1px solid rgba(20, 19, 16, 0.4);
  background: none;
  padding: 0 0 3px;
  cursor: pointer;
  font-family: 'Barlow', sans-serif;
  font-weight: 600;
  font-size: clamp(10px, 1.2vw, 14px);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(20, 19, 16, 0.72);
}
.title-online:hover { color: #000; }

#onlineHud {
  display: none;
  font-family: 'Barlow', sans-serif;
  font-weight: 600;
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--amber);
  text-transform: uppercase;
  background: rgba(18, 16, 13, 0.52);
  padding: 2px 5px;
  width: calc(var(--dial) * 0.82);
  text-align: center;
}
#app.online #raceLine { display: none; }
#app.online #onlineHud { display: block; }
#app.online #garageBtn { display: none; }

#online {
  position: absolute;
  inset: 0;
  z-index: 27;
  display: none;
  background: rgba(10, 9, 8, 0.94);
  color: var(--cream);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
#online.open { display: flex; align-items: center; justify-content: center; }
.online-panel {
  width: min(560px, 92vw);
  border-top: 3px solid var(--amber);
  background: #151311;
  padding: clamp(18px, 4vw, 34px);
  margin: 16px;
}
.online-panel h2 {
  margin: 4px 0 10px;
  font-family: 'Big Shoulders', Impact, sans-serif;
  font-weight: 800;
  font-size: clamp(40px, 9vw, 76px);
  line-height: 0.84;
  letter-spacing: -0.02em;
}
.online-panel p { margin: 0 0 12px; color: rgba(238,227,205,0.72); font-size: 13px; line-height: 1.5; }
#onlinePeople { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--cream); margin: 8px 0; min-height: 16px; }
#onlineLink {
  font-family: 'JetBrains Mono', monospace; font-size: 9px; color: var(--amber);
  word-break: break-all; margin: 8px 0 14px; min-height: 12px; user-select: text;
}
.online-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.online-actions button, #onlineBack {
  border: 1px solid rgba(238,227,205,0.3);
  background: transparent;
  color: var(--cream);
  font-family: 'Big Shoulders', Impact, sans-serif;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 10px 14px;
  cursor: pointer;
}
#onlineQuick { background: var(--amber); color: #161310; border-color: var(--amber); }
.online-actions button:hover { border-color: var(--amber); color: var(--amber); }
#onlineQuick:hover { color: #000; }
#onlineBack { font-family: 'Barlow', sans-serif; font-weight: 600; font-size: 10px; letter-spacing: 0.16em; border: 0; border-bottom: 1px solid rgba(238,227,205,0.35); padding: 2px 0 3px; }
#onlineBack:hover { color: var(--amber); }
