/* Redline Pursuit */
@font-face { font-family: 'Barlow Condensed'; font-weight: 600; font-display: swap; src: url('fonts/barlow-condensed-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 700; font-display: swap; src: url('fonts/barlow-condensed-latin-700-normal.woff2') format('woff2'); }

:root {
  --accent: #ff6a1a;
  --accent2: #ffb020;
  --red: #ff3b3b;
  --blue: #3a7bff;
  --good: #4ade80;
  --panel: rgba(12, 14, 22, 0.92);
  --line: rgba(255, 255, 255, 0.12);
  --cond: 'Barlow Condensed', 'Arial Narrow', 'Roboto Condensed', sans-serif;
  --ui: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; color: #fff; font-family: var(--ui); user-select: none; -webkit-user-select: none; touch-action: none; overscroll-behavior: none; }
#c { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
.hidden { display: none !important; }
button { font-family: inherit; }

#loading, #nogl { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--cond); font-size: 28px; letter-spacing: .1em; background: #07080d; z-index: 50; text-align: center; padding: 20px; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; font-family: var(--cond); text-shadow: 0 2px 4px rgba(0,0,0,.7); }
#hTopLeft { position: absolute; left: max(16px, env(safe-area-inset-left)); top: 14px; }
.bounty { display: flex; align-items: baseline; gap: 10px; }
.bounty .lbl { font-size: 15px; letter-spacing: .2em; color: var(--accent2); font-weight: 700; }
#hBounty, #hCash { font-size: 34px; font-weight: 700; }
#hPursuitBounty { font-size: 20px; color: #ffd27a; font-weight: 700; }
#hTime { font-size: 15px; opacity: .75; letter-spacing: .08em; margin-top: 2px; }

#hHeat { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; background: rgba(12, 14, 22, 0.88); border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 20px; padding: 4px 14px; box-shadow: 0 4px 14px rgba(0,0,0,0.6); z-index: 2; }
#hStars { font-size: 20px; color: #ff3b3b; line-height: 1; }
#hHeatLevel { font-size: 19px; font-weight: 700; color: #ff3b3b; min-width: 12px; }
#hHeat.chase #hStars, #hHeat.chase #hHeatLevel { color: #ff3b3b; animation: flash .5s steps(2) infinite; }
#hHeat.cool #hStars, #hHeat.cool #hHeatLevel { color: var(--blue); animation: none; }
#hHeat .meter { height: 6px; background: rgba(255,255,255,.18); border-radius: 3px; overflow: hidden; width: 100px; }
#hMeter { height: 100%; width: 0; background: var(--red); transition: width 0.1s linear; }
#hHeat.cool #hMeter { background: var(--blue); }
@keyframes flash { 0% { color: #ff3b3b; } 50% { color: #3a7bff; } }

#hRace { position: absolute; left: 50%; top: 62px; transform: translateX(-50%); text-align: center; }
#hPos { font-size: 46px; font-weight: 700; line-height: 1; color: var(--accent2); }
#hCp, #hRaceTime { font-size: 18px; letter-spacing: .08em; }

#mini { position: absolute; right: max(16px, env(safe-area-inset-right)); top: 14px; width: 200px; height: 200px; border-radius: 50%; box-shadow: 0 4px 18px rgba(0,0,0,.6); opacity: .95; }

#hBottomRight { position: absolute; right: max(22px, env(safe-area-inset-right)); bottom: 18px; width: 230px; }
.spd { text-align: right; line-height: .9; }
#hSpeed { font-size: 76px; font-weight: 700; }
#hUnit { font-size: 18px; margin-left: 6px; letter-spacing: .15em; color: var(--accent2); }
.bar { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.bar span { font-size: 13px; letter-spacing: .15em; width: 64px; opacity: .85; }
.track { flex: 1; height: 10px; background: rgba(255,255,255,.18); border-radius: 5px; overflow: hidden; }
#hHealth { height: 100%; background: linear-gradient(90deg, #36c46b, #7ee08f); width: 100%; transition: width .2s; }
#hHealth.low { background: linear-gradient(90deg, #ff3b3b, #ff7a5a); animation: pulse 0.6s infinite alternate; }
#hNitro { height: 100%; background: linear-gradient(90deg, #2f7bff, #3fe0ff); width: 0; }
#hNitro.on { background: linear-gradient(90deg, #7a5cff, #ff4fd8); }
@keyframes pulse { to { opacity: .5; } }

#popups { position: absolute; left: 50%; top: 30%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pop { font-size: 26px; font-weight: 700; letter-spacing: .05em; color: #fff; animation: popup 2.2s ease-out forwards; white-space: nowrap; }
.pop.big { font-size: 40px; color: var(--accent2); }
.pop.warn { color: #ff7a5a; }
.pop.good { color: var(--good); }
@keyframes popup { 0% { transform: scale(.6); opacity: 0; } 10% { transform: scale(1.1); opacity: 1; } 20% { transform: scale(1); } 80% { opacity: 1; } 100% { transform: translateY(-30px); opacity: 0; } }

#bust { position: absolute; left: 50%; bottom: 22%; transform: translateX(-50%); text-align: center; font-size: 30px; font-weight: 700; letter-spacing: .3em; color: var(--red); width: 260px; }
#bust .track { height: 12px; }
#hBust { height: 100%; background: var(--red); }

#prompt { position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--accent2); border-radius: 10px; padding: 10px 14px; display: flex; gap: 14px; align-items: center; pointer-events: auto; max-width: 92vw; }
#promptText { font-size: 20px; white-space: pre-line; letter-spacing: .03em; }
#promptBtn { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 12px 18px; font-family: var(--cond); font-size: 20px; font-weight: 700; letter-spacing: .08em; cursor: pointer; }

#countdown { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); font-size: 140px; font-weight: 700; color: var(--accent2); }
#countdown.pulse { animation: cd .9s ease-out; }
@keyframes cd { 0% { transform: translate(-50%, -50%) scale(1.8); opacity: 0; } 30% { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

#banner { position: fixed; left: 0; right: 0; top: 36%; text-align: center; pointer-events: none; font-family: var(--cond); background: linear-gradient(90deg, transparent, rgba(0,0,0,.75) 25%, rgba(0,0,0,.75) 75%, transparent); padding: 14px 0; animation: banner .4s ease-out; z-index: 5; }
#bannerTitle { font-size: 64px; font-weight: 700; letter-spacing: .12em; }
#bannerSub { font-size: 22px; opacity: .9; letter-spacing: .04em; }
#banner.red #bannerTitle { color: var(--red); }
#banner.good #bannerTitle { color: var(--good); }
@keyframes banner { from { transform: scaleY(0); } }

/* ---------- touch ---------- */
#touch { position: fixed; inset: 0; pointer-events: none; z-index: 3; }
#touch > * { pointer-events: auto; }
#tSteer { position: absolute; left: 0; bottom: 0; width: 42vw; height: 62vh; }
#tSteer .hint { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); font-family: var(--cond); letter-spacing: .2em; opacity: .35; font-size: 14px; }
#tKnob { position: absolute; width: 70px; height: 70px; border-radius: 50%; border: 3px solid rgba(255,255,255,.55); background: rgba(255,255,255,.08); left: 18vw; top: 35%; opacity: .5; }
#tKnob.on { opacity: 1; background: rgba(255,106,26,.25); border-color: var(--accent); }
.tb { position: absolute; border-radius: 50%; border: 3px solid rgba(255,255,255,.5); background: rgba(0,0,0,.35); color: #fff; font-family: var(--cond); font-weight: 700; font-size: 17px; letter-spacing: .08em; width: 76px; height: 76px; touch-action: none; }
.tb.on { background: rgba(255,106,26,.55); border-color: var(--accent); }
#tGas { right: max(22px, env(safe-area-inset-right)); bottom: 22px; width: 112px; height: 112px; font-size: 22px; }
#tBrake { right: calc(max(22px, env(safe-area-inset-right)) + 124px); bottom: 18px; }
#tDrift { right: calc(max(22px, env(safe-area-inset-right)) + 124px); bottom: 104px; width: 74px; height: 74px; font-size: 16px; border-color: #ffb020; }
.tsmall { position: absolute; top: 8px; background: rgba(0,0,0,.45); color: #fff; border: 2px solid rgba(255,255,255,.4); border-radius: 10px; font-family: var(--cond); font-weight: 700; font-size: 15px; padding: 6px 12px; }
#tPause { left: 50%; transform: translateX(-60px); }
#tCam { left: 50%; transform: translateX(8px); }
body.touching #hBottomRight { right: auto; left: 50%; transform: translateX(-50%); bottom: 10px; width: 200px; }
body.touching #hSpeed { font-size: 44px; }
body.touching .spd { text-align: center; }
body.touching #hHeat { top: 12px; }
body.touching #hRace { top: 62px; }
body.touching #prompt { bottom: auto; top: 110px; }
body.touching #mini { width: 140px; height: 140px; }
body.touching #hCash { font-size: 26px; }

#rotate { display: none; }
@media (orientation: portrait) and (pointer: coarse) {
  #rotate { display: flex; position: fixed; inset: 0; z-index: 100; background: #07080d; flex-direction: column; align-items: center; justify-content: center; font-family: var(--cond); font-size: 30px; letter-spacing: .08em; text-align: center; padding: 20px; }
  #rotate small { font-size: 16px; opacity: .7; margin-top: 8px; }
}
@media (max-height: 430px) {
  #hBounty { font-size: 24px; }
  #hStars { font-size: 26px; }
  #hStatus { font-size: 16px; }
  #mini { width: 130px; height: 130px; }
  #bannerTitle { font-size: 44px; }
  #bannerSub { font-size: 17px; }
  .pop { font-size: 20px; }
  .pop.big { font-size: 30px; }
  #hRace { top: 70px; }
  #hPos { font-size: 32px; }
  #countdown { font-size: 100px; }
  #promptText { font-size: 16px; }
}

/* ---------- menus ---------- */
#menu { position: fixed; inset: 0; z-index: 10; background: rgba(5, 6, 10, .72); display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto; }
#menu.menu-title { background: linear-gradient(90deg, rgba(5,6,10,.85), rgba(5,6,10,.35)); justify-content: flex-start; padding-left: max(6vw, 20px); }
.panel { width: min(720px, 100%); max-height: 88vh; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; padding-bottom: 32px; -webkit-overflow-scrolling: touch; box-sizing: border-box; margin: auto; }
.menu-title .panel { background: transparent; border: 0; width: min(520px, 100%); }

#camFlash {
  position: fixed; inset: 0; pointer-events: none; z-index: 85;
  background: radial-gradient(circle, rgba(255,255,255,0.92) 0%, rgba(210,240,255,0.7) 60%, rgba(255,255,255,0.3) 100%);
  opacity: 0;
  transition: opacity 0.35s cubic-bezier(0.1, 0.9, 0.2, 1);
}
#camFlash.flash {
  opacity: 1;
  transition: none;
}
.logo { font-family: var(--cond); font-weight: 700; font-size: clamp(54px, 10vw, 96px); line-height: .9; letter-spacing: .04em; font-style: italic; color: #fff; }
.logo span { display: block; color: var(--accent); }
.tag { font-size: 17px; opacity: .85; line-height: 1.45; }
.small { font-size: 14px; opacity: .65; }
.warn { color: #ff9a7a; }
h2 { font-family: var(--cond); font-size: 40px; margin: 0 0 12px; letter-spacing: .06em; }
h3 { font-family: var(--cond); font-size: 24px; margin: 18px 0 6px; letter-spacing: .05em; color: var(--accent2); }
.col { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.panel button { background: rgba(255,255,255,.08); color: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 13px 16px; font-family: var(--cond); font-size: 22px; font-weight: 700; letter-spacing: .06em; cursor: pointer; text-align: left; }
.panel button:hover, .panel button.focus { border-color: var(--accent); background: rgba(255,106,26,.18); outline: none; }
.panel button.primary { background: var(--accent); border-color: var(--accent); }
.panel button.primary.focus, .panel button.primary:hover { background: #ff8440; box-shadow: 0 0 0 3px rgba(255,255,255,.6); }
.panel button:disabled { opacity: .45; cursor: default; }
.help p { line-height: 1.5; font-size: 16px; opacity: .92; }
.cars { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.carcard { display: flex; flex-direction: column; gap: 4px; position: relative; }
.carcard .swatch { display: block; height: 8px; border-radius: 4px; margin-bottom: 4px; }
.carcard small { font-family: var(--ui); font-weight: 400; font-size: 13px; letter-spacing: 0; opacity: .8; line-height: 1.35; }
.carcard.current { border-color: var(--good) !important; opacity: 1 !important; }
.carcard em { font-style: normal; color: var(--good); font-size: 15px; }
.stats { display: grid; grid-template-columns: 70px 1fr; gap: 3px 8px; align-items: center; margin-top: 4px; }
.stats i { font-style: normal; font-size: 13px; opacity: .75; letter-spacing: .05em; }
.stat { height: 6px; background: rgba(255,255,255,.12); border-radius: 3px; overflow: hidden; }
.stat div { height: 100%; background: var(--accent); }
.mapwrap { position: relative; }
.mapwrap canvas { width: 100%; height: auto; aspect-ratio: 1; border-radius: 10px; display: block; max-height: 62vh; object-fit: contain; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 14px; opacity: .85; }
.lg { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: -1px; margin-right: 6px; }
.lg.gas { background: #18a558; } .lg.flag { background: repeating-conic-gradient(#fff 0 25%, #111 0 50%) 0 0/6px 6px; border-radius: 2px; }
.lg.car { background: #ffcc33; } .lg.car.got { background: #4ade80; }
.lg.cam { background: #38bdf8; }
.bindrow { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.bindrow code { font-size: 13px; opacity: .8; }
.bindrow button { padding: 8px 12px; font-size: 16px; }
.ctl p { line-height: 1.45; opacity: .9; }
.settings { display: flex; flex-direction: column; gap: 10px; }
.srow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.srow > span { width: 130px; font-family: var(--cond); font-size: 20px; letter-spacing: .05em; opacity: .85; }
.srow button { padding: 9px 12px; font-size: 18px; }
.srow button.on { background: var(--accent); border-color: var(--accent); }
.results { font-family: var(--cond); font-size: 26px; padding-left: 28px; }
.results li.me { color: var(--accent2); }

/* ---------- garage header & upgrades ---------- */
.garage-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; padding: 10px 14px; background: rgba(255,255,255,0.06); border: 1px solid var(--line); border-radius: 10px; }
.garage-bal { font-size: 24px; font-weight: 700; color: var(--good); }
.garage-rep { font-size: 16px; opacity: 0.85; color: var(--accent2); font-weight: 600; letter-spacing: .05em; }
.upg-section { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.upg-section h3 { margin: 0 0 10px 0; display: flex; justify-content: space-between; align-items: baseline; }
.upg-section h3 small { font-size: 15px; color: #fff; opacity: 0.7; font-weight: normal; font-family: var(--ui); }
.upg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.upg-card { background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.upg-card-top { display: flex; justify-content: space-between; align-items: center; }
.upg-card-title { font-size: 17px; font-weight: 700; letter-spacing: .04em; }
.upg-pips { display: flex; gap: 4px; }
.upg-pip { width: 14px; height: 6px; border-radius: 2px; background: rgba(255,255,255,0.2); }
.upg-pip.fill { background: var(--accent); }
.upg-desc { font-family: var(--ui); font-size: 12px; opacity: 0.75; line-height: 1.3; }
.upg-card button { margin-top: 4px; padding: 8px 10px !important; font-size: 15px !important; text-align: center !important; }
.carcard.selected { border-color: var(--accent) !important; box-shadow: 0 0 8px rgba(255, 106, 26, 0.4); }
.car-actions { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
.small-btn { padding: 6px 10px !important; font-size: 14px !important; text-align: center !important; flex: 1; border-radius: 6px !important; }
.drive-btn { background: rgba(255, 255, 255, 0.15) !important; }
.drive-btn:hover { background: var(--good) !important; border-color: var(--good) !important; }
.driving-badge { font-style: normal; color: var(--good); font-size: 13px; font-weight: bold; }
