@font-face { font-family: 'Anton'; src: url(fonts/Anton-Regular.ttf); font-display: swap; }
@font-face { font-family: 'Barlow Condensed'; src: url(fonts/BarlowCondensed-SemiBold.ttf); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Barlow Condensed'; src: url(fonts/BarlowCondensed-ExtraBold.ttf); font-weight: 800; font-display: swap; }
@font-face { font-family: 'Mono'; src: url(fonts/JetBrainsMono.ttf); font-display: swap; }

:root {
  --bg: #05070f; --ink: #eef3ff; --dim: #8d98b8; --gold: #ffc93c; --gold2: #ff9d1c; --cyan: #3ff0ff;
  --red: #ff3b3b; --green: #2bff88; --panel: rgba(8, 12, 26, 0.82); --line: rgba(120, 160, 255, 0.22);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink);
  font-family: 'Barlow Condensed', system-ui, sans-serif; font-weight: 600; user-select: none; -webkit-user-select: none; touch-action: none; }
canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#map { display: none; }
body.map #map { display: block; }
button { font: inherit; color: inherit; cursor: pointer; }
.num { font-family: 'Mono', monospace; font-weight: 700; letter-spacing: -0.02em; }

.screen { position: fixed; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 16px; z-index: 5; }
.screen.show { display: flex; }

.btn { border: 0; border-radius: 6px; padding: 12px 26px; font-weight: 800; font-size: 22px; letter-spacing: 0.04em; text-transform: uppercase; transition: transform 0.08s, filter 0.2s; }
.btn:active { transform: scale(0.96); }
.btn.gold { background: linear-gradient(180deg, #ffe07a, var(--gold) 45%, var(--gold2)); color: #2a1500; box-shadow: 0 0 30px rgba(255, 180, 40, 0.45), inset 0 -3px 0 rgba(0,0,0,0.2); }
.btn.red { background: linear-gradient(180deg, #ff6464, #e3152c); color: #fff; box-shadow: 0 0 22px rgba(255, 40, 60, 0.4), inset 0 -3px 0 rgba(0,0,0,0.25); }
.btn.ghost { background: rgba(255,255,255,0.08); border: 1px solid var(--line); }

/* title */
#title { background: radial-gradient(ellipse at 50% 40%, rgba(255,120,30,0.28), transparent 60%), radial-gradient(ellipse at 50% 100%, rgba(60,80,255,0.25), transparent 60%), rgba(3,5,12,0.72); }
.kicker { font-family: 'Mono', monospace; font-size: 12px; color: var(--cyan); letter-spacing: 0.12em; opacity: 0.85; }
h1 { margin: 6px 0 0; line-height: 0.86; font-family: 'Anton', sans-serif; font-weight: 400; }
h1 .t1 { display: block; font-size: clamp(64px, 17vw, 150px); background: linear-gradient(180deg, #fff5c8, var(--gold) 45%, #e0700a); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 24px rgba(255,160,30,0.5)); }
h1 .t2 { display: block; font-size: clamp(34px, 9vw, 78px); color: #ff3b3b; letter-spacing: 0.14em; text-shadow: 0 0 20px rgba(255,40,40,0.6); }
.sub { margin: 10px 0 18px; font-size: 18px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--dim); }
.how { list-style: none; counter-reset: s; padding: 0; margin: 0 0 12px; max-width: 460px; text-align: left; font-size: 18px; }
.how li { counter-increment: s; padding: 6px 0 6px 40px; position: relative; border-top: 1px solid var(--line); }
.how li::before { content: counter(s); position: absolute; left: 6px; top: 6px; font-family: 'Anton'; color: var(--gold); font-size: 20px; }
.how b { color: var(--gold); font-weight: 800; }
.goal { color: var(--cyan); margin: 4px 0 18px; font-size: 16px; }
.credit { margin-top: 16px; font-size: 13px; color: var(--dim); letter-spacing: 0.08em; }

/* map */
#cards { margin-top: auto; }
#mapui { justify-content: flex-start; pointer-events: none; padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); }
#mapui > * { pointer-events: auto; }
.maphead { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.tag { background: var(--panel); border: 1px solid var(--line); padding: 4px 12px; border-radius: 4px; font-family: 'Mono', monospace; font-size: 13px; letter-spacing: 0.06em; }
#mapAlive { color: var(--red); }
#mapMsg { font-family: 'Anton'; font-size: clamp(26px, 6vw, 44px); letter-spacing: 0.03em; text-shadow: 0 0 20px rgba(0,0,0,0.9); margin-top: 8px; pointer-events: none; }
#mapMsg small { display: block; font-family: 'Barlow Condensed'; font-size: 17px; color: var(--gold); letter-spacing: 0.1em; }
#board { position: absolute; right: 12px; top: 56px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font-size: 14px; text-align: left; min-width: 190px; }
#board h4 { margin: 0 0 4px; font-size: 12px; color: var(--dim); letter-spacing: 0.12em; }
#board div { display: flex; justify-content: space-between; gap: 12px; }
#board .me { color: var(--gold); }
#cards { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; width: 100%; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; min-width: 150px; flex: 1 1 150px; max-width: 240px; text-align: left; transition: border-color 0.15s, transform 0.15s; }
.card:hover, .card.hot { border-color: var(--gold); transform: translateY(-3px); }
.card h3 { margin: 0; font-family: 'Anton'; font-weight: 400; font-size: 26px; letter-spacing: 0.02em; }
.card .tagline { color: var(--gold); font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; min-height: 16px; }
.card .row { display: flex; justify-content: space-between; font-size: 15px; color: var(--dim); }
.card .row b { color: var(--ink); }
.dots { color: var(--red); letter-spacing: 2px; }
.dots i { font-style: normal; color: rgba(255,255,255,0.18); }

/* city hud */
#hud, #drivehud { position: fixed; inset: 0; pointer-events: none; display: none; z-index: 4; }
body.city #hud, body.drive #drivehud { display: block; }
#hudTop { position: absolute; top: 0; left: 0; right: 0; display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; padding: max(8px, env(safe-area-inset-top)) 10px 0; }
.hcity { font-size: 15px; letter-spacing: 0.08em; }
#hCity { font-weight: 800; }
.zonebar { height: 6px; background: rgba(255,255,255,0.1); border-radius: 3px; overflow: hidden; margin: 4px 0 2px; max-width: 200px; }
.zonebar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--cyan), var(--gold) 60%, var(--red)); transform-origin: left; }
#hZoneT { font-family: 'Mono'; font-size: 12px; color: var(--dim); }
#hZoneT.hot { color: var(--red); animation: blink 0.5s steps(2) infinite; }
.hcash { text-align: center; }
#hCash { font-family: 'Mono'; font-weight: 700; font-size: clamp(22px, 5.4vw, 34px); color: var(--gold); text-shadow: 0 0 18px rgba(255,180,40,0.5); white-space: nowrap; }
#hInc { font-family: 'Mono'; font-size: 12px; color: #9dffc4; }
.hrank { text-align: right; }
#hRank { font-family: 'Anton'; font-size: 26px; line-height: 1; }
#hRank.out { color: var(--red); }
#hRank.in { color: var(--green); }
#hCut { font-size: 12px; color: var(--dim); letter-spacing: 0.04em; }
.meters { position: absolute; top: calc(max(8px, env(safe-area-inset-top)) + 64px); left: 0; right: 0; display: flex; justify-content: center; gap: 14px; font-size: 11px; letter-spacing: 0.12em; color: var(--dim); }
.meters b { display: inline-block; width: 70px; height: 6px; background: rgba(255,255,255,0.1); border-radius: 3px; vertical-align: middle; overflow: hidden; margin-left: 4px; }
.meters i { display: block; height: 100%; width: 0; background: var(--gold); transition: width 0.3s; }
#mCrime { background: var(--red); }
#toast { position: absolute; top: 108px; left: 50%; transform: translateX(-50%); max-width: min(92vw, 520px); text-align: center; background: rgba(8,12,26,0.9); border: 1px solid var(--gold); color: var(--ink); padding: 8px 14px; border-radius: 6px; font-size: 17px; opacity: 0; transition: opacity 0.25s; }
#toast.show { opacity: 1; }
#toast.red { border-color: var(--red); }
#toast b { color: var(--gold); }
#hudBottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 8px max(8px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
#hudBottom > * { pointer-events: auto; }
#sell { font-size: 18px; padding: 8px 20px; display: flex; flex-direction: column; align-items: center; line-height: 1.05; }
#sell small { font-family: 'Mono'; font-size: 12px; font-weight: 700; opacity: 0.9; letter-spacing: 0; text-transform: none; }
#sell.pulse { animation: pulse 0.7s ease-in-out infinite alternate; }
#palette { display: flex; gap: 6px; overflow-x: auto; max-width: 100%; padding: 2px; scrollbar-width: none; }
.pb { flex: 0 0 auto; width: 104px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 7px 5px; text-align: left; position: relative; }
.pb.sel { border-color: var(--cyan); box-shadow: 0 0 14px rgba(63,240,255,0.35); }
.pb.no { opacity: 0.45; }
.pb .sw { width: 14px; height: 14px; border-radius: 3px; display: inline-block; vertical-align: -2px; margin-right: 4px; }
.pb .nm { font-weight: 800; font-size: 15px; white-space: nowrap; }
.pb .co { font-family: 'Mono'; font-size: 11px; color: var(--gold); }
.pb .in { font-family: 'Mono'; font-size: 10px; color: #9dffc4; }
.pb .key { position: absolute; right: 6px; top: 4px; font-family: 'Mono'; font-size: 10px; color: var(--dim); }
#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 3; opacity: 0; background: radial-gradient(ellipse at center, transparent 45%, rgba(255,20,30,0.55)); transition: opacity 0.4s; }

/* popups */
#pops { position: fixed; inset: 0; pointer-events: none; z-index: 6; overflow: hidden; }
.pop { position: absolute; transform: translate(-50%, -50%); font-family: 'Mono'; font-weight: 700; font-size: 15px; white-space: nowrap; text-shadow: 0 1px 3px #000, 0 0 10px rgba(0,0,0,0.8); animation: rise 1.1s ease-out forwards; }
.pop.gold { color: var(--gold); font-size: 17px; }
.pop.red { color: var(--red); font-size: 18px; }
.pop.green { color: #7dffb0; font-size: 13px; }
.pop.big { font-family: 'Anton'; font-size: 30px; font-weight: 400; animation-duration: 1.6s; }
.pop.info { color: var(--ink); font-family: 'Barlow Condensed'; font-size: 15px; background: rgba(8,12,26,0.85); padding: 3px 8px; border-radius: 4px; border: 1px solid var(--line); animation-duration: 2s; }

/* drive */
#dTop { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 0; right: 0; text-align: center; }
#dDest { font-family: 'Anton'; font-size: clamp(26px, 6vw, 40px); letter-spacing: 0.04em; text-shadow: 0 0 16px #000; }
#dCash { font-family: 'Mono'; font-size: 18px; color: var(--gold); }
#dHint { position: absolute; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 18px); left: 0; right: 0; text-align: center; color: var(--dim); font-size: 15px; }
.dbar { position: absolute; bottom: max(10px, env(safe-area-inset-bottom)); left: 20%; right: 20%; height: 4px; background: rgba(255,255,255,0.12); border-radius: 2px; overflow: hidden; }
.dbar i { display: block; height: 100%; width: 0; background: var(--gold); }

/* modal + end */
#modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(2,4,10,0.6); z-index: 8; padding: 16px; }
#modal.show { display: flex; }
.box { background: linear-gradient(180deg, #111a33, #0a0f1f); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; max-width: 420px; width: 100%; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.6); }
.box h2 { margin: 0 0 6px; font-family: 'Anton'; font-weight: 400; font-size: 34px; letter-spacing: 0.02em; }
.box .big { font-family: 'Mono'; font-weight: 700; font-size: 30px; color: var(--gold); margin: 6px 0; }
.box p { margin: 6px 0; color: var(--dim); font-size: 17px; }
.box .row { display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding: 5px 0; font-size: 17px; }
.box .row b { font-family: 'Mono'; }
.box .btns { display: flex; gap: 10px; justify-content: center; margin-top: 14px; }
.box .ok { color: var(--green); }
.box .bad { color: var(--red); }
#end { background: rgba(3,5,12,0.8); }
#end .box { max-width: 460px; }
#end h2 { font-size: 48px; line-height: 1; }
#end h2.win { color: var(--gold); text-shadow: 0 0 30px rgba(255,170,30,0.6); }
#end h2.lose { color: var(--red); }

#mute { position: fixed; right: max(10px, env(safe-area-inset-right)); top: max(10px, env(safe-area-inset-top)); z-index: 9; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--ink); display: grid; place-items: center; padding: 0; }
#mute #muteX { display: none; }
#mute.off #muteX { display: inline; }
#mute.off #muteWave { display: none; }
body.city #mute { top: calc(max(8px, env(safe-area-inset-top)) + 84px); }
body.map #mute { top: auto; bottom: calc(max(10px, env(safe-area-inset-bottom)) + 150px); }
@media (min-width: 641px) { body.map #mute { top: max(10px, env(safe-area-inset-top)); bottom: auto; right: 220px; } }
@media (max-width: 420px) {
  #palette { gap: 4px; }
  #palette .pb { width: 68px; padding: 4px 5px; }
  #palette .pb .nm { font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
  #palette .pb .sw { display: none; }
  #palette .pb .co { font-size: 10px; }
  #palette .pb .in { font-size: 9px; }
  #toast { font-size: 14px; top: 96px; }
  #sell { font-size: 16px; }
}

@keyframes rise { 0% { opacity: 0; margin-top: 6px; } 12% { opacity: 1; } 100% { opacity: 0; margin-top: -46px; } }
@keyframes pulse { from { transform: scale(1); box-shadow: 0 0 16px rgba(255,40,60,0.4); } to { transform: scale(1.06); box-shadow: 0 0 34px rgba(255,40,60,0.9); } }
@keyframes blink { 50% { opacity: 0.35; } }

@media (max-width: 640px) {
  #board { display: none; }
  .pb { width: 88px; padding: 5px 6px 4px; }
  .pb .nm { font-size: 13px; }
  .pb .key { display: none; }
  .card { min-width: 0; padding: 8px 10px; flex-basis: 100%; max-width: none; display: grid; grid-template-columns: 1fr auto; column-gap: 12px; }
  .card h3 { font-size: 22px; }
  #hRank { font-size: 21px; }
  .hcity { font-size: 13px; }
  .how { font-size: 16px; }
}
