* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --hud-font: 'Oswald', 'Arial Narrow', system-ui, sans-serif;
  --big-font: 'Anton', 'Impact', 'Oswald', sans-serif;
  --gold: #f5c542;
  --pink: #ff3fb4;
  --cyan: #3fd8ff;
  --panel: rgba(8, 9, 12, 0.55);
}
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #0b0b0d; color: #f2f2f2;
  font-family: var(--hud-font);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
/* Readable on any background: dark outline like GTA's HUD text. */
.outline, #clock, .score-value, .score-ico, #stars, .speed-num, #banner, #bigbanner, #radio-name, #drift-meter, #combo, .trick, #wrecked {
  text-shadow: -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 2px 2px 0 #000, 0 3px 10px rgba(0, 0, 0, 0.6);
}

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud button { pointer-events: auto; }

/* Radar + bars (bottom left) */
#radar {
  position: absolute; left: max(18px, env(safe-area-inset-left)); bottom: 18px;
  width: 232px; padding: 4px; background: rgba(0, 0, 0, 0.55); border-radius: 6px;
}
#minimap { display: block; width: 224px; height: 137px; border-radius: 3px; }
.bars { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 3px; margin-top: 4px; }
.bar { height: 7px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.bar i { display: block; height: 100%; width: 100%; transition: width 0.15s linear; }
.bar.hp i { background: linear-gradient(#5fd35a, #2f9a35); }
.bar.air i { background: linear-gradient(#5fb6ff, #2a7fd6); }
.bar.combo i { background: linear-gradient(#ffd34a, #d9a01a); width: 0; }

/* Top-right block */
#topinfo { position: absolute; right: max(22px, env(safe-area-inset-right)); top: 16px; text-align: right; }
#clock { font-size: 22px; font-weight: 600; letter-spacing: 0.04em; }
#score { font-family: var(--big-font); font-size: 40px; line-height: 1.05; letter-spacing: 0.02em; pointer-events: auto; cursor: pointer; }
.score-ico { color: var(--gold); font-size: 30px; margin-right: 6px; vertical-align: 3px; }
#stars { font-size: 22px; letter-spacing: 2px; margin-top: 2px; }
#stars span { color: rgba(255, 255, 255, 0.16); transition: color 0.2s, transform 0.2s; display: inline-block; }
#stars span.on { color: #fff; }
#stars.flash span.on { animation: starflash 0.5s ease-in-out 2; }
@keyframes starflash { 50% { color: var(--gold); transform: scale(1.25); } }
.score-best { font-size: 12px; color: #d6d6d6; letter-spacing: 0.08em; text-shadow: 0 1px 4px #000; }
#market-miles { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; padding: 3px 7px; background: rgba(0,0,0,.55); border: 1px solid rgba(245,197,66,.45); font-size: 11px; letter-spacing: .12em; }
#market-miles span { color: var(--gold); font-weight: 700; }
#market-miles b { color: #fff; font-size: 13px; font-variant-numeric: tabular-nums; }
#toasts { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; margin-top: 10px; }
.toast {
  font-family: var(--big-font); font-size: 20px; letter-spacing: 0.02em; color: #9cff7a;
  text-shadow: -1.5px -1.5px 0 #000, 1.5px -1.5px 0 #000, -1.5px 1.5px 0 #000, 1.5px 1.5px 0 #000;
  animation: toastin 0.25s ease-out; transition: opacity 0.8s, transform 0.8s;
}
.toast small { font-family: var(--hud-font); font-size: 14px; color: #fff; margin-left: 6px; }
.toast.task { color: var(--gold); }
.toast.fade { opacity: 0; transform: translateY(-8px); }
@keyframes toastin { from { opacity: 0; transform: translateX(20px); } }

#drift-meter {
  position: absolute; left: 50%; top: 30%; transform: translateX(-50%);
  font-family: var(--big-font); font-size: 30px; color: #ffb02f; letter-spacing: 0.04em;
}

#telemetry {
  position: absolute; right: 22px; top: 50%; transform: translateY(-50%); text-align: right;
  font: 600 13px/1.6 var(--hud-font); color: #c8c8c8; letter-spacing: 0.08em;
  background: var(--panel); padding: 8px 12px; border-right: 3px solid var(--cyan);
}
#telemetry b { color: #fff; font-weight: 600; margin-left: 8px; }

/* Banners */
#banner {
  position: absolute; left: 50%; top: 20%; transform: translateX(-50%);
  text-align: center; font-family: var(--big-font); font-size: 40px; letter-spacing: 0.04em;
  text-transform: uppercase; opacity: 0; transition: opacity 0.25s; white-space: nowrap;
}
#banner.show { opacity: 1; animation: pop 0.35s ease-out; }
#banner small { display: block; font-family: var(--hud-font); font-size: 17px; letter-spacing: 0.06em; color: #f0f0f0; margin-top: 4px; text-transform: none; }
@keyframes pop { from { transform: translateX(-50%) scale(1.25); opacity: 0; } }
#bigbanner {
  position: absolute; left: 0; right: 0; top: 34%; text-align: center; opacity: 0; transition: opacity 0.4s;
  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.55) 20%, rgba(0, 0, 0, 0.55) 80%, transparent); padding: 14px 0;
}
#bigbanner.show { opacity: 1; }
#bigbanner.show .big-title { animation: slam 0.45s cubic-bezier(.2, 1.4, .5, 1); }
.big-title { font-family: var(--big-font); font-size: 62px; color: var(--gold); letter-spacing: 0.03em; line-height: 1; }
.big-sub { font-size: 20px; letter-spacing: 0.08em; margin-top: 6px; text-transform: uppercase; }
.big-bonus { font-family: var(--big-font); font-size: 26px; color: #9cff7a; margin-top: 4px; }
@keyframes slam { from { transform: scale(2.2); opacity: 0; } }
#radio-name {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%); text-align: center;
  font-family: var(--big-font); font-size: 28px; letter-spacing: 0.06em; opacity: 0; transition: opacity 0.4s;
}
#radio-name small { display: block; font-family: var(--hud-font); font-size: 14px; color: #ddd; letter-spacing: 0.1em; }
#radio-name.show { opacity: 1; }

/* Speedometer (bottom right) */
#speedo { position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: 12px; width: 190px; height: 190px; }
#speedo svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
#arc-bg { fill: none; stroke: rgba(0, 0, 0, 0.5); stroke-width: 12; stroke-linecap: round; }
#arc-fg { fill: none; stroke: #fff; stroke-width: 8; stroke-linecap: round; filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.6)); }
#ticks line { stroke: rgba(255, 255, 255, 0.75); stroke-width: 2; }
#ticks text { fill: #ddd; font: 600 11px var(--hud-font); text-anchor: middle; dominant-baseline: middle; }
.speed-num { position: absolute; left: 0; right: 0; top: 64px; text-align: center; font-family: var(--big-font); font-size: 46px; font-variant-numeric: tabular-nums; }
.speed-unit { position: absolute; left: 0; right: 0; top: 118px; text-align: center; font-size: 12px; letter-spacing: 0.2em; color: #ddd; text-shadow: 0 1px 4px #000; }
.mode-badge {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); padding: 2px 10px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.16em; background: #fff; color: #111; border-radius: 3px;
}
.mode-badge.rocket { background: var(--gold); }
.mode-badge.road { background: #9ad0ff; }
#airtext { position: absolute; right: 2px; bottom: -2px; font-size: 11px; letter-spacing: 0.1em; color: #bfe3ff; text-shadow: 0 1px 3px #000; }
#fps { position: absolute; left: 2px; bottom: -2px; font-size: 10px; color: #888; }

/* Mode switch + camera (bottom right, above the speedometer) */
#quickbar {
  position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: 214px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px; pointer-events: auto;
}
#quickbar .modes { display: flex; background: rgba(0, 0, 0, 0.6); border: 1px solid rgba(255, 255, 255, 0.25); }
#quickbar .mode {
  background: transparent; border: 0; padding: 7px 12px; font-size: 13px; font-weight: 600; letter-spacing: 0.12em; color: #bbb;
}
#quickbar .mode.active { background: #fff; color: #111; }
#quickbar .mode[data-mode="rocket"].active { background: var(--gold); }
.cam-btn {
  display: flex; align-items: center; gap: 6px; background: rgba(0, 0, 0, 0.6); border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 5px 12px; font-size: 13px; font-weight: 600; letter-spacing: 0.12em;
}
.cam-btn svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 2; stroke-linejoin: round; }

.round-btn {
  position: absolute; left: max(18px, env(safe-area-inset-left)); top: 16px; width: 42px; height: 42px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.55); border: 2px solid rgba(255, 255, 255, 0.7); display: flex; align-items: center; justify-content: center;
}
.round-btn svg, .tb svg { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

#hint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  font-size: 13px; letter-spacing: 0.06em; color: #e8e8e8; background: var(--panel);
  padding: 6px 14px; white-space: nowrap; transition: opacity 1s;
}

/* ---------- Pause menu ---------- */
#menu {
  position: fixed; inset: 0; z-index: 5; display: flex; flex-direction: column;
  background: linear-gradient(180deg, rgba(8, 8, 12, 0.92), rgba(18, 8, 26, 0.92));
}
.menu-top { padding: 22px 36px 0; }
.menu-title { font-family: var(--big-font); font-size: 40px; letter-spacing: 0.04em; background: linear-gradient(90deg, #ff9a3c, #ff3fb4 55%, #8a5cff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.menu-tabs { display: flex; gap: 2px; margin-top: 10px; border-bottom: 2px solid rgba(255, 255, 255, 0.15); overflow-x: auto; scrollbar-width: none; }
.menu-tabs::-webkit-scrollbar { display: none; }
.menu-tabs button { background: transparent; border: 0; padding: 10px 22px; font-size: 16px; font-weight: 600; letter-spacing: 0.12em; color: #aaa; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.menu-tabs button.active { color: #fff; border-color: var(--pink); background: rgba(255, 255, 255, 0.06); }
.menu-body { flex: 1; overflow: auto; padding: 18px 36px; }
.menu-body section { display: none; }
.menu-body section.active { display: flex; gap: 22px; flex-wrap: wrap; }
#menu-map { width: min(900px, 100%); height: auto; aspect-ratio: 900 / 580; background: #0c3446; border: 2px solid rgba(255, 255, 255, 0.2); }
.warp-list { display: flex; flex-direction: column; gap: 8px; min-width: 220px; }
.warp-list button, .set-row button {
  background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.18); padding: 10px 14px; text-align: left;
  font-size: 15px; letter-spacing: 0.06em; display: flex; align-items: center; gap: 10px;
}
.warp-list button:hover, .set-row button:hover { background: rgba(255, 63, 180, 0.25); border-color: var(--pink); }
.warp-list .dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
#menu-tasks { width: min(640px, 100%); }
.task { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.08); font-size: 17px; letter-spacing: 0.03em; }
.task .box { width: 22px; height: 22px; border: 2px solid rgba(255, 255, 255, 0.45); display: inline-flex; align-items: center; justify-content: center; font-size: 14px; }
.task.ok { color: #9cff7a; }
.task.ok .box { border-color: #9cff7a; background: rgba(156, 255, 122, 0.15); }
.task .bonus { margin-left: auto; color: var(--gold); font-family: var(--big-font); font-size: 18px; }
.task .prog { color: #aaa; font-size: 13px; }
.tasks-total { margin-top: 14px; color: #ccc; letter-spacing: 0.08em; }
#menu-settings { width: min(640px, 100%); }
.set-row { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.set-row .label { width: 160px; font-size: 15px; letter-spacing: 0.1em; color: #ccc; }
.set-row button { padding: 7px 14px; font-size: 13px; }
.set-row button.active { background: #fff; color: #111; border-color: #fff; }
table.controls { border-collapse: collapse; font-size: 15px; width: min(720px, 100%); }
table.controls td { padding: 8px 14px 8px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
table.controls td:not(:first-child) { color: var(--cyan); letter-spacing: 0.06em; }
.menu-foot { padding: 14px 36px 20px; color: #bbb; letter-spacing: 0.1em; }
.menu-foot span { background: #fff; color: #111; padding: 1px 8px; margin-right: 6px; font-weight: 600; }

/* ---------- Start screen ---------- */
#start {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 60%, rgba(60, 20, 70, 0.55), rgba(5, 5, 8, 0.94));
  padding: 16px;
}
.start-card { max-width: 520px; text-align: center; }
.logo { font-family: var(--big-font); line-height: 0.9; letter-spacing: 0.02em; }
.logo span { display: block; }
.logo span:first-child { font-size: 76px; background: linear-gradient(180deg, #ffe2a8, #ff9a3c 45%, #ff3fb4); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 4px 0 #2a0a2e); }
.logo span:last-child { font-size: 62px; color: #3fd8ff; text-shadow: 0 0 18px rgba(63, 216, 255, 0.6), 0 4px 0 #0a1a2e; font-style: italic; }
.start-card .sub { margin: 18px 0 26px; color: #d0d0d0; line-height: 1.5; font-size: 16px; letter-spacing: 0.02em; }
#btn-play {
  padding: 14px 54px; border: 0; background: linear-gradient(90deg, #ff9a3c, #ff3fb4); color: #fff;
  font-family: var(--big-font); font-size: 24px; letter-spacing: 0.08em; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  clip-path: polygon(6% 0, 100% 0, 94% 100%, 0 100%);
}
#btn-play:disabled { opacity: 0.5; cursor: wait; }
.quality { margin-top: 18px; font-size: 14px; color: #aaa; display: flex; gap: 14px; justify-content: center; letter-spacing: 0.06em; }
.quality label { cursor: pointer; }
.disclaimer { margin-top: 28px; font-size: 12px; color: #777; }
.eyebrow { margin-bottom: 10px; color: #7ce7ff; font-size: 11px; font-weight: 700; letter-spacing: 0.2em; }
/* ---------- Market pulse ---------- */
#market-pulse {
  position: absolute; left: max(72px, calc(env(safe-area-inset-left) + 72px)); top: 16px;
  display: grid; grid-template-columns: auto auto auto; grid-template-areas: "status status status" "symbol price change";
  align-items: baseline; gap: 2px 10px; min-width: 250px; padding: 8px 12px;
  color: #fff; border: 1px solid rgba(255,255,255,.24); border-left: 3px solid var(--cyan);
  background: rgba(4,7,10,.78); backdrop-filter: blur(12px); text-align: left; pointer-events: auto;
}
.market-status { grid-area: status; color: #ffd34a; font-size: 9px; font-weight: 700; letter-spacing: .16em; }
.market-status[data-status="unavailable"] { color: #ff727c; }
.market-symbol { grid-area: symbol; font-size: 13px; font-weight: 700; letter-spacing: .1em; }
.market-price { grid-area: price; font-size: 19px; font-variant-numeric: tabular-nums; }
.market-change { grid-area: change; font-size: 13px; font-style: normal; font-weight: 700; }
.market-change.up { color: #62efa1; }
.market-change.down { color: #ff6571; }
body[data-market-direction="up"] #market-pulse { border-left-color: #62efa1; }
body[data-market-direction="down"] #market-pulse { border-left-color: #ff6571; }

/* ---------- Market dashboard ---------- */
#menu-markets, #menu-garage, #menu-districts { width: min(1120px, 100%); margin: 0 auto; }
.market-head, .garage-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.section-kicker { display: block; color: var(--cyan); font-size: 11px; font-weight: 700; letter-spacing: .2em; margin-bottom: 5px; }
.market-head h2, .garage-hero h2 { font-family: var(--big-font); font-size: clamp(34px, 5vw, 60px); font-weight: 400; letter-spacing: .02em; line-height: 1; }
.market-refresh, #connect-phantom, .cosmetic-card button, .store-grid button {
  padding: 10px 16px; border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.08); color: #fff; font-weight: 700; letter-spacing: .1em;
}
.market-refresh:hover, #connect-phantom:hover, .cosmetic-card button:hover, .store-grid button:hover { border-color: var(--cyan); background: rgba(63,216,255,.15); }
.market-disclosure { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 10px 14px; margin-bottom: 14px; background: rgba(245,197,66,.08); border: 1px solid rgba(245,197,66,.28); color: #d3d3d3; font-size: 12px; }
.market-disclosure b { color: var(--gold); letter-spacing: .12em; }
.quote-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.quote-card { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 10px; min-height: 116px; padding: 14px; border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.055); overflow: hidden; }
.quote-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: #777; }
.quote-card.up::before { background: #62efa1; }
.quote-card.down::before { background: #ff6571; }
.quote-card > div { display: flex; flex-direction: column; }
.quote-card > div strong { font-size: 20px; }
.quote-card > div span, .quote-card small { color: #9298a0; font-size: 10px; letter-spacing: .12em; }
.quote-card > b { font-size: 21px; text-align: right; }
.quote-card > em { align-self: end; color: #bbb; font-size: 15px; font-style: normal; font-weight: 700; }
.quote-card.up > em { color: #62efa1; }
.quote-card.down > em { color: #ff6571; }
.quote-card small { align-self: end; justify-self: end; }
.market-news { margin-top: 22px; }
.market-news a { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid rgba(255,255,255,.1); color: #f2f2f2; text-decoration: none; }
.market-news a:hover b { color: var(--cyan); }
.market-news a span { flex: 0 0 auto; color: #8e959d; }
.empty-state { padding: 18px; color: #9298a0; border: 1px dashed rgba(255,255,255,.18); }
.market-legal { margin-top: 20px; color: #8e959d; font-size: 12px; line-height: 1.45; }

/* ---------- Solana garage ---------- */
.garage-hero { align-items: center; }
.garage-hero p { max-width: 620px; margin-top: 8px; color: #aeb4bc; }
#connect-phantom { border-color: #ab9ff2; background: rgba(171,159,242,.15); white-space: nowrap; }
.garage-message { margin-bottom: 12px; padding: 9px 12px; border: 1px solid rgba(255,101,113,.35); color: #ffadb4; }
.wallet-facts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.wallet-facts span { padding: 8px 12px; border: 1px solid rgba(255,255,255,.14); color: #8e959d; font-size: 10px; letter-spacing: .12em; }
.wallet-facts b { color: #fff; margin-left: 8px; }
.garage-grid, .store-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.cosmetic-card, .garage-empty, .store-grid article, .garage-store-off { display: flex; flex-direction: column; gap: 8px; padding: 14px; border: 1px solid rgba(255,255,255,.15); background: rgba(255,255,255,.05); }
.cosmetic-card span, .garage-empty span, .store-grid span, .garage-store-off span { color: #9298a0; font-size: 12px; line-height: 1.4; }
.paint-swatch { height: 66px; border: 1px solid rgba(255,255,255,.2); background: linear-gradient(135deg, #e6e8eb, #575e68 50%, #eef1f4); }
.cosmetic-card button { margin-top: auto; }
.cosmetic-card button:disabled { opacity: .35; }
.garage-empty { justify-content: center; border-style: dashed; }
.garage-store { margin-top: 24px; }
.garage-store-off { flex-direction: row; justify-content: space-between; }
.store-grid article button { margin-top: auto; }

/* ---------- Tokenized stock districts ---------- */
.district-hero { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 16px; }
.district-hero h2 { font-family: var(--big-font); font-size: clamp(36px, 5vw, 64px); font-weight: 400; line-height: 1; }
.district-hero p { max-width: 700px; margin-top: 8px; color: #aeb4bc; }
.miles-card { flex: 0 0 190px; display: flex; flex-direction: column; padding: 14px; border: 1px solid rgba(245,197,66,.4); background: rgba(245,197,66,.08); }
.miles-card span { color: var(--gold); font-size: 10px; letter-spacing: .16em; }
.miles-card b { font: 400 38px var(--big-font); }
.miles-card small { color: #9a9fa6; }
.district-status { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; padding: 9px 12px; border: 1px solid rgba(171,159,242,.3); background: rgba(171,159,242,.08); font-size: 11px; letter-spacing: .12em; }
.district-status button { padding: 7px 12px; border: 1px solid #ab9ff2; background: rgba(171,159,242,.14); color: #fff; font-weight: 700; letter-spacing: .1em; }
.district-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.district-card { position: relative; padding: 16px; border: 1px solid rgba(255,255,255,.16); border-top: 3px solid var(--district); background: linear-gradient(135deg, color-mix(in srgb, var(--district) 10%, transparent), rgba(255,255,255,.035)); }
.district-card.owned { box-shadow: inset 0 0 30px color-mix(in srgb, var(--district) 10%, transparent); }
.district-card-top { display: flex; justify-content: space-between; gap: 12px; }
.district-card-top > span { color: var(--district); font-weight: 800; letter-spacing: .14em; }
.district-card-top > b { color: #9a9fa6; font-size: 9px; letter-spacing: .13em; }
.district-card.owned .district-card-top > b { color: #62efa1; }
.district-card h3 { margin-top: 18px; font: 400 28px var(--big-font); }
.district-card p { margin: 4px 0 16px; color: #b2b7be; }
.district-token { display: flex; align-items: center; gap: 9px; padding: 8px 10px; background: rgba(0,0,0,.28); }
.district-token > span { font-weight: 800; }
.district-token code { color: #9ba3ad; }
.district-token em { margin-left: auto; color: #8f969e; font-size: 9px; font-style: normal; letter-spacing: .1em; }
.district-actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.district-actions a, .district-actions button { padding: 7px 10px; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.06); color: #fff; text-decoration: none; font: 700 10px var(--hud-font); letter-spacing: .1em; }
.district-actions button { border-color: var(--district); }
.district-actions > span { color: #777f88; font-size: 11px; }
.weekly-rewards { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; margin-top: 18px; padding: 16px; border: 1px solid rgba(255,255,255,.15); background: rgba(255,255,255,.04); }
.weekly-rewards h3 { font: 400 27px var(--big-font); }
.weekly-rewards p { color: #aeb4bc; line-height: 1.5; }
.reward-state { display: flex; flex-direction: column; justify-content: center; padding: 12px; border: 1px solid rgba(255,211,74,.28); background: rgba(255,211,74,.06); }
.reward-state b { color: var(--gold); font-size: 12px; letter-spacing: .12em; }
.reward-state span { margin-top: 6px; color: #9da3aa; font-size: 12px; }

@media (max-width: 760px) {
  #market-pulse { min-width: 0; left: max(62px, calc(env(safe-area-inset-left) + 62px)); padding: 6px 9px; }
  #market-pulse .market-price { font-size: 15px; }
  .quote-grid, .garage-grid, .store-grid { grid-template-columns: 1fr 1fr; }
  .market-head, .garage-hero { align-items: flex-start; flex-direction: column; }
  .district-hero { align-items: flex-start; flex-direction: column; }
  .miles-card { width: 100%; flex-basis: auto; }
}

@media (max-width: 520px) {
  #market-pulse { display: none; }
  .quote-grid, .garage-grid, .store-grid { grid-template-columns: 1fr; }
  .market-news a, .garage-store-off { flex-direction: column; }
  .district-grid, .weekly-rewards { grid-template-columns: 1fr; }
  .district-token { align-items: flex-start; flex-direction: column; }
  .district-token em { margin-left: 0; }
}

/* Shown on the start screen inside X's (or another app's) built-in browser. */
#inapp-hint { margin: 14px auto 0; max-width: 340px; font-size: 13px; line-height: 1.4; color: #ffd27a; letter-spacing: 0.02em; }
#inapp-hint b { color: #fff; }
#inapp-hint .dots { font-family: system-ui, sans-serif; font-weight: 700; padding: 0 2px; }

/* ---------- Tricks, combo, crash ---------- */
#combo {
  position: absolute; left: 50%; top: 29%; transform: translateX(-50%); opacity: 0; transition: opacity 0.2s;
  font-family: var(--big-font); font-size: 34px; letter-spacing: 0.03em; white-space: nowrap;
}
#combo.on { opacity: 1; }
#combo-mult { color: var(--gold); margin-left: 10px; font-size: 28px; }
#trick-feed {
  position: absolute; left: 50%; top: calc(29% + 46px); transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.trick {
  font-family: var(--big-font); font-size: 22px; letter-spacing: 0.04em; white-space: nowrap;
  animation: trickin 0.25s cubic-bezier(.2, 1.4, .5, 1); transition: opacity 0.6s, transform 0.6s;
}
.trick b { color: #9cff7a; font-weight: 400; margin-left: 8px; }
.trick.banked { color: var(--gold); font-size: 26px; }
.trick.lost { color: #ff4a3c; }
.trick.out { opacity: 0; transform: translateY(-10px); }
@keyframes trickin { from { opacity: 0; transform: scale(1.6); } }
#wrecked {
  position: absolute; left: 0; right: 0; top: 40%; text-align: center; opacity: 0; transition: opacity 0.3s;
}
#wrecked.show { opacity: 1; }
#wrecked.show .w-title { animation: slam 0.45s cubic-bezier(.2, 1.4, .5, 1); }
.w-title { font-family: var(--big-font); font-size: 72px; color: #e8261c; letter-spacing: 0.04em; line-height: 1; }
.w-sub { font-size: 18px; letter-spacing: 0.12em; text-transform: uppercase; margin-top: 4px; }
body.wrecked #game { filter: grayscale(0.85) contrast(1.1); transition: filter 0.3s; }
#game { transition: filter 0.6s; }
/* Thruster indicators under the speedometer */
#speedo .thr { position: absolute; left: -62px; bottom: 22px; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
#speedo .thr span {
  font: 600 10px var(--hud-font); letter-spacing: 0.14em; padding: 1px 6px; color: rgba(255, 255, 255, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(0, 0, 0, 0.35);
}
#ind-lift.on { color: #fff; background: #2a7fd6; border-color: #5fb6ff; }
#ind-boost.on { color: #fff; background: #d65a2a; border-color: #ff9a6a; }
/* Start screen key list */
.start-card .keys { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; margin-top: 18px; font-size: 13px; color: #bbb; letter-spacing: 0.04em; }
.start-card .keys b { color: #fff; font-weight: 600; border: 1px solid rgba(255, 255, 255, 0.35); padding: 0 5px; margin-right: 4px; border-radius: 3px; }
body.touch .start-card .keys { display: none; }

.social-x {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 16px; color: #d7d7dd; text-decoration: none;
  font: 600 12px var(--hud-font); letter-spacing: 0.12em; transition: color 0.16s ease;
}
.social-x svg { width: 14px; height: 14px; fill: currentColor; }
.social-x:hover { color: var(--cyan); }
.menu-foot .social-x { margin: 0 0 0 18px; vertical-align: middle; }

/* ---------- Phone layout ----------
   Left thumb: a stick that appears wherever it touches. Right thumb: GAS with an arc of
   BRAKE / DRIFT / LIFT / BOOST around it. Radar top left, a small speedometer at the
   bottom centre, score top right with three small buttons next to it. Sizes follow the
   screen height (--u), so the same layout fits an iPhone SE and a big Android. */
body.touch {
  --u: clamp(44px, 13.5vmin, 62px); /* the short side of the screen, in landscape or portrait */
  touch-action: none; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
body.touch #hint, body.touch #quickbar, body.touch #telemetry, body.touch #speedo .thr,
body.touch #fps, body.touch #airtext { display: none !important; }

#touch { position: fixed; inset: 0; pointer-events: none; }
#stick-zone { position: absolute; left: 0; bottom: 0; width: 46%; height: 74%; pointer-events: auto; touch-action: none; }
#stick {
  position: absolute; left: calc(env(safe-area-inset-left) + 26px); bottom: 22px;
  width: calc(var(--u) * 2); height: calc(var(--u) * 2); border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.03) 45%, rgba(255, 255, 255, 0.1));
  border: 1.5px solid rgba(255, 255, 255, 0.35); opacity: 0.5; transition: opacity 0.2s;
}
#stick.active { opacity: 1; transition: none; }
#knob {
  position: absolute; left: 50%; top: 50%; border-radius: 50%;
  width: calc(var(--u) * 0.86); height: calc(var(--u) * 0.86); margin: calc(var(--u) * -0.43) 0 0 calc(var(--u) * -0.43);
  background: rgba(255, 255, 255, 0.88); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}

.tb {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 0;
  border-radius: 50%; background: rgba(10, 10, 14, 0.36); border: 1.5px solid rgba(255, 255, 255, 0.5); color: #fff;
  font: 600 calc(var(--u) * 0.15) / 1 var(--hud-font); letter-spacing: 0.08em; touch-action: none;
  -webkit-tap-highlight-color: transparent; transition: transform 0.06s, background 0.1s, box-shadow 0.15s;
}
.tb svg { width: calc(var(--u) * 0.34); height: calc(var(--u) * 0.34); fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tb.pressed { background: rgba(255, 255, 255, 0.32); transform: scale(0.93); }

/* Right-thumb cluster: GAS in the corner, the rest on an arc around it. */
#touch-buttons {
  position: absolute; right: calc(env(safe-area-inset-right) + 14px); bottom: 14px;
  width: calc(var(--u) * 2.75); height: calc(var(--u) * 2.75); pointer-events: auto;
}
.tb.act { position: absolute; width: calc(var(--u) * 0.88); height: calc(var(--u) * 0.88); }
.tb.gas {
  right: 0; bottom: 0; width: calc(var(--u) * 1.45); height: calc(var(--u) * 1.45); font-size: calc(var(--u) * 0.2);
  background: rgba(40, 190, 110, 0.3); border-color: rgba(150, 255, 190, 0.85);
}
.tb.gas svg { width: calc(var(--u) * 0.48); height: calc(var(--u) * 0.48); fill: #fff; }
.tb.brake { right: calc(var(--u) * 1.87); bottom: calc(var(--u) * 0.06); background: rgba(220, 50, 50, 0.24); border-color: rgba(255, 140, 140, 0.8); }
.tb.brake svg { fill: #fff; stroke: none; }
.tb.drift { right: calc(var(--u) * 1.7); bottom: calc(var(--u) * 1.04); }
.tb.lift { right: calc(var(--u) * 0.99); bottom: calc(var(--u) * 1.72); background: rgba(60, 150, 255, 0.28); border-color: rgba(140, 200, 255, 0.85); }
.tb.boost { right: calc(var(--u) * 0.01); bottom: calc(var(--u) * 1.86); background: rgba(255, 110, 50, 0.28); border-color: rgba(255, 180, 130, 0.85); }
.tb.lift.firing { box-shadow: 0 0 14px rgba(90, 170, 255, 0.9); background: rgba(60, 150, 255, 0.55); }
.tb.boost.firing { box-shadow: 0 0 14px rgba(255, 130, 60, 0.9); background: rgba(255, 110, 50, 0.55); }

/* Mode, camera, horn: small, next to the score. */
#touch-top {
  position: absolute; top: 10px; right: calc(env(safe-area-inset-right) + 138px);
  display: flex; gap: 8px; pointer-events: auto;
}
.tb.tiny { width: calc(var(--u) * 0.74); height: calc(var(--u) * 0.74); background: rgba(0, 0, 0, 0.4); border-color: rgba(255, 255, 255, 0.4); }
.tb.tiny svg { width: calc(var(--u) * 0.32); height: calc(var(--u) * 0.32); }
#tb-mode-label { font-size: calc(var(--u) * 0.14); letter-spacing: 0.04em; }

/* HUD on phones */
body.touch .round-btn { left: calc(env(safe-area-inset-left) + 12px); top: 10px; width: 36px; height: 36px; border-width: 1.5px; }
body.touch .round-btn svg { width: 18px; height: 18px; }
body.touch #radar { left: calc(env(safe-area-inset-left) + 56px); top: 8px; bottom: auto; width: 146px; padding: 3px; }
body.touch #minimap { width: 140px; height: 86px; }
body.touch .bars { margin-top: 3px; gap: 2px; }
body.touch .bar { height: 5px; }
body.touch #speedo { left: 50%; right: auto; bottom: 2px; transform: translateX(-50%); width: calc(var(--u) * 2.1); height: calc(var(--u) * 2.1); }
body.touch #ticks text { display: none; }
body.touch .speed-num { top: 27%; font-size: calc(var(--u) * 0.6); }
body.touch .speed-unit { top: 61%; font-size: 9px; letter-spacing: 0.16em; }
body.touch .mode-badge { bottom: 4%; font-size: 9px; padding: 1px 6px; }
body.touch #topinfo { top: 8px; right: calc(env(safe-area-inset-right) + 12px); }
body.touch #clock { font-size: 14px; }
body.touch #score { font-size: 26px; }
body.touch .score-ico { font-size: 18px; }
body.touch #stars { font-size: 13px; letter-spacing: 1px; }
body.touch .score-best { font-size: 10px; }
body.touch #toasts { margin-top: 4px; }
body.touch #toasts .toast:nth-child(n + 3) { display: none; }
body.touch .toast { font-size: 15px; }
body.touch .toast small { font-size: 11px; }
body.touch #radio-name { top: 6px; font-size: 18px; }
body.touch #banner { font-size: 24px; top: 19%; }
body.touch #banner small { font-size: 13px; }
body.touch #drift-meter { font-size: 22px; top: 27%; }
body.touch .big-title { font-size: 38px; }
body.touch .big-sub { font-size: 14px; }
body.touch #combo { top: 34%; font-size: 24px; }
body.touch #combo-mult { font-size: 20px; }
body.touch #trick-feed { top: calc(34% + 30px); }
body.touch .trick { font-size: 16px; }
body.touch .trick.banked { font-size: 19px; }
body.touch .w-title { font-size: 46px; }
body.touch .w-sub { font-size: 13px; }

/* Pause menu: a Resume button on phones, the Esc hint on desktops. */
.menu-foot .resume { display: none; }
.menu-foot em { font-style: normal; }
body.touch .menu-foot .resume {
  display: inline-block; padding: 8px 18px; border: 0; background: linear-gradient(90deg, #ff9a3c, #ff3fb4);
  font: 400 16px var(--big-font); letter-spacing: 0.08em; color: #fff;
}
body.touch .menu-foot .esc, body.touch .menu-foot .esc-text { display: none; }

/* Short screens (phones in landscape): compact start screen and menu. */
@media (max-height: 500px) {
  .logo span:first-child { font-size: 46px; }
  .logo span:last-child { font-size: 36px; }
  .start-card .sub { margin: 8px 0 12px; font-size: 13px; line-height: 1.35; }
  #btn-play { padding: 9px 44px; font-size: 20px; }
  .quality { margin-top: 10px; font-size: 12px; }
  .start-card .social-x { margin-top: 10px; }
  .disclaimer { margin-top: 10px; font-size: 10px; }
  .menu-top { padding: 8px 16px 0; display: flex; align-items: flex-end; gap: 18px; }
  .menu-title { font-size: 22px; padding-bottom: 6px; }
  .menu-tabs { margin-top: 0; flex: 1; }
  .menu-tabs button { padding: 7px 12px; font-size: 12px; }
  .menu-body { padding: 10px 16px; }
  .menu-body section.active { flex-wrap: nowrap; gap: 14px; }
  #menu-map { width: auto; height: calc(100vh - 112px); max-width: 64vw; }
  .warp-list { min-width: 0; flex: 1; gap: 5px; }
  .warp-list button { padding: 6px 10px; font-size: 12px; }
  .task { padding: 6px 0; font-size: 13px; }
  .task .bonus { font-size: 14px; }
  .set-row { padding: 5px 0; }
  .set-row .label { width: 120px; font-size: 12px; }
  .set-row button { padding: 5px 10px; font-size: 12px; }
  table.controls { font-size: 12px; }
  table.controls td { padding: 5px 10px 5px 0; }
  .menu-foot { padding: 6px 16px 10px; font-size: 12px; }
}

/* Portrait phones (X's built-in browser does not rotate): controls along the bottom,
   HUD along the top, the speedometer above the buttons on the right. */
@media (orientation: portrait) {
  body.touch #stick-zone { height: 58%; width: 50%; }
  body.touch #stick { bottom: 26px; }
  body.touch #touch-buttons { bottom: 22px; }
  body.touch #speedo {
    left: auto; right: calc(env(safe-area-inset-right) + 10px); transform: none;
    bottom: calc(22px + var(--u) * 2.9); width: calc(var(--u) * 1.7); height: calc(var(--u) * 1.7);
  }
  body.touch #touch-top { top: 100px; right: calc(env(safe-area-inset-right) + 12px); }
  body.touch #toasts { margin-top: 52px; }
  body.touch #radio-name { top: 122px; }
  body.touch #banner { top: 24%; font-size: 22px; white-space: normal; width: 90%; }
  body.touch #combo { top: 36%; }
  body.touch #trick-feed { top: calc(36% + 30px); }
  body.touch #drift-meter { top: 31%; }
  body.touch .big-title { font-size: 32px; }
  .menu-top { padding: 14px 16px 0; }
  .menu-title { font-size: 26px; }
  .menu-tabs button { padding: 8px 10px; font-size: 12px; }
  .menu-body { padding: 12px 16px; }
  .menu-body section.active { flex-direction: column; }
  .warp-list { min-width: 0; }
  .set-row { flex-wrap: wrap; }
  .set-row .label { width: 100%; }
  .menu-foot { padding: 10px 16px 18px; }
}
