@font-face { font-family: 'Jakarta'; src: url('../assets/fonts/PlusJakartaSans-Regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Jakarta'; src: url('../assets/fonts/PlusJakartaSans-Medium.ttf') format('truetype'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Jakarta'; src: url('../assets/fonts/PlusJakartaSans-SemiBold.ttf') format('truetype'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Jakarta'; src: url('../assets/fonts/PlusJakartaSans-Bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Jakarta'; src: url('../assets/fonts/PlusJakartaSans-ExtraBold.ttf') format('truetype'); font-weight: 800; font-display: swap; }

:root {
  --green: #00ae42; --green-d: #008f36; --green-l: #eaf7ea; --ink: #333333;
  --warn: #ffb954; --danger: #eb4862; --purple: #905BF4; --orange: #ff9600; --info: #1E90FF;
  --glass: rgba(18, 18, 18, 0.8);
  --sb: env(safe-area-inset-bottom, 0px); --st: env(safe-area-inset-top, 0px);
  --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #121212; color: #fff;
  font-family: 'Jakarta', system-ui, -apple-system, sans-serif; touch-action: none;
  -webkit-user-select: none; user-select: none; overscroll-behavior: none; -webkit-touch-callout: none; }
#app { position: fixed; inset: 0; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; background: #1aa3c4; }
.hidden { display: none !important; }
button { font-family: inherit; }

/* ---------------- HUD ---------------- */
#hud { position: absolute; inset: 0; pointer-events: none; }
.hud-top { position: absolute; top: calc(8px + var(--st)); left: calc(8px + var(--sl)); right: calc(8px + var(--sr)); display: flex; gap: 8px; align-items: stretch; }
.hud-card { background: var(--glass); border-radius: 14px; padding: 7px 12px; }
.lbl { display: block; color: #a8a8a8; font-weight: 600; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
.hud-cash b, .hud-timer b { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hud-trip { flex: 1; min-width: 0; opacity: .55; transition: opacity .2s, border-color .2s; border: 2px solid transparent; }
.hud-trip.on { opacity: 1; border-color: var(--green); }
.trip-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fare { position: relative; }
.fare b { font-size: 20px; font-weight: 800; color: var(--green); font-variant-numeric: tabular-nums; }
#fare-tick { position: absolute; left: 100%; top: 10px; margin-left: 6px; color: var(--danger); font-style: normal; font-weight: 800; font-size: 14px; opacity: 0; }
#fare-tick.go { animation: tick .9s ease-out; }
@keyframes tick { 0% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(-16px); } }
.arrow-wrap { width: 38px; height: 38px; border-radius: 50%; background: var(--green); display: grid; place-items: center; flex: none; visibility: hidden; }
.hud-trip.on .arrow-wrap { visibility: visible; }
#hud-arrow { width: 0; height: 0; border-left: 9px solid transparent; border-right: 9px solid transparent; border-bottom: 20px solid #fff; transform-origin: 50% 60%; }
#hud-dest { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.hud-timer { text-align: center; min-width: 74px; }
.hud-timer.urgent b { color: var(--danger); }
#hud-strikes { display: block; font-size: 11px; color: var(--danger); letter-spacing: 2px; }
.hud-menu { pointer-events: auto; border: 0; border-radius: 14px; background: var(--glass); color: #fff; font-weight: 800; font-size: 12px; padding: 0 12px; letter-spacing: .05em; cursor: pointer; }
#hud-msg { position: absolute; left: 50%; transform: translateX(-50%); top: calc(84px + var(--st)); max-width: min(92vw, 560px); text-align: center;
  background: rgba(255,255,255,.95); color: var(--ink); font-weight: 700; font-size: 14px; padding: 8px 14px; border-radius: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.25); opacity: 0; transition: opacity .2s; }
#hud-msg.show { opacity: 1; }
#hud-msg.alert { background: var(--danger); color: #fff; }
.hud-bottom { position: absolute; left: calc(8px + var(--sl)); right: calc(8px + var(--sr)); bottom: calc(8px + var(--sb)); display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; }
.gauges { display: flex; gap: 14px; align-items: center; }
.fuel { text-align: center; width: 78px; }
.fuel-gauge { width: 78px; height: 47px; display: block; }
.gtxt { fill: #a8a8a8; font: 800 11px 'Jakarta', sans-serif; }
#fuel-lbl.low { color: var(--danger); animation: blink .6s infinite alternate; }
@keyframes blink { to { opacity: .3; } }
.energy { width: 120px; }
.bar { height: 10px; border-radius: 5px; background: rgba(255,255,255,.15); overflow: hidden; margin-top: 5px; }
.bar i { display: block; height: 100%; width: 100%; background: var(--green); border-radius: 5px; transition: width .2s, background .2s; }
.bar i.mid { background: var(--warn); } .bar i.low { background: var(--danger); }
.radio { display: flex; align-items: center; gap: 8px; pointer-events: auto; font-size: 12px; font-weight: 700; max-width: 50vw; }
.radio button { background: var(--green); color: #fff; border: 0; border-radius: 50%; width: 32px; height: 32px; display: grid; place-items: center; cursor: pointer; flex: none; }
.radio-txt { min-width: 0; }
#radio-name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vol { height: 4px; background: rgba(255,255,255,.2); border-radius: 2px; margin-top: 4px; width: 90px; }
.vol i { display: block; height: 100%; background: var(--green); border-radius: 2px; }

/* ---------------- Dialog ---------------- */
#dialog { position: absolute; left: 0; right: 0; bottom: calc(96px + var(--sb)); display: flex; justify-content: center; padding: 0 12px; pointer-events: auto; }
.dlg-card { display: flex; gap: 12px; align-items: center; background: #fff; color: var(--ink); border-radius: 18px; padding: 12px 16px; max-width: 520px; width: 100%;
  box-shadow: 0 16px 40px rgba(0,0,0,.35); animation: pop .2s ease-out; border-left: 6px solid var(--green); }
@keyframes pop { from { transform: translateY(12px) scale(.97); opacity: 0; } }
.dlg-avatar { width: 52px; height: 52px; border-radius: 50%; flex: none; background: var(--green-l) center/cover no-repeat; display: grid; place-items: center; overflow: hidden; }
.dlg-avatar img { width: 70%; }
.dlg-who { font-size: 11px; font-weight: 800; color: var(--green-d); text-transform: uppercase; letter-spacing: .06em; }
.dlg-text { font-size: 15px; font-weight: 700; line-height: 1.35; }
#dialog.bad .dlg-card { border-left-color: var(--danger); }
#dialog.bad .dlg-who { color: var(--danger); }

/* ---------------- Touch ---------------- */
#touch { position: absolute; inset: 0; pointer-events: none; }
.pad { position: absolute; bottom: calc(84px + var(--sb)); display: flex; gap: 12px; pointer-events: auto; align-items: flex-end; }
.pad-steer { left: calc(14px + var(--sl)); }
.pad-pedals { right: calc(14px + var(--sr)); }
.pad-mid { right: calc(14px + var(--sr)); bottom: calc(196px + var(--sb)) !important; flex-direction: column; align-items: flex-end; gap: 8px; }
.tbtn { width: 74px; height: 74px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); background: rgba(18,18,18,.5); color: #fff;
  font-weight: 800; font-size: 13px; touch-action: none; display: grid; place-items: center; padding: 0; }
.tbtn svg { width: 34px; height: 34px; }
.tbtn.gas { background: rgba(0,174,66,.8); border-color: #3ccf75; width: 82px; height: 100px; border-radius: 24px; }
.tbtn.brake { background: rgba(235,72,98,.7); border-color: #ff7d92; border-radius: 22px; }
.tbtn.horn { width: 58px; height: 40px; border-radius: 20px; font-size: 11px; }
.tbtn.action { width: 110px; height: 52px; border-radius: 26px; background: #fff; color: var(--green-d); border-color: #fff; font-size: 14px; animation: pulse 1s infinite alternate; }
@keyframes pulse { to { box-shadow: 0 0 0 8px rgba(255,255,255,.25); } }
.tbtn.down { transform: scale(.92); filter: brightness(1.25); }

/* ---------------- Screens ---------------- */
.screen { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: calc(16px + var(--st)) 16px calc(16px + var(--sb));
  overflow-y: auto; touch-action: pan-y; -webkit-overflow-scrolling: touch; }
.screen.bg { background: radial-gradient(120% 90% at 50% 20%, rgba(0,190,72,.93), rgba(0,104,40,.97)); }
.screen.dim { background: rgba(10,10,10,.72); }
.screen:empty { display: none; }
.panel { width: 100%; max-width: 440px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; margin: auto; }
.card { background: #fff; color: var(--ink); border-radius: 22px; padding: 22px 20px; text-align: left; align-items: stretch; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.card.dark { background: #1e1e1e; color: #fff; text-align: center; align-items: center; }
.card.wide { max-width: 640px; }
.logo { width: 190px; max-width: 60vw; }
.title { font-size: 54px; font-weight: 800; margin: -8px 0 0; letter-spacing: .24em; padding-left: .24em; line-height: 1; }
.tag { margin: 0; opacity: .9; font-weight: 600; font-size: 14px; }
.hero { width: 230px; max-width: 58vw; filter: drop-shadow(0 18px 18px rgba(0,0,0,.3)); margin: 4px 0 6px; }
h2 { margin: 0 0 4px; font-weight: 800; font-size: 24px; }
.card p { line-height: 1.5; margin: 2px 0; font-size: 14px; }
.sub { color: #6b7280; font-size: 13px; margin: 0; }
.card.dark .sub { color: #a8a8a8; }
.btn { font: 700 16px 'Jakarta', sans-serif; padding: 13px 18px; border-radius: 14px; border: 0; width: 100%; max-width: 320px;
  cursor: pointer; background: rgba(255,255,255,.16); color: #fff; align-self: center; transition: transform .08s; }
.btn.primary { background: #fff; color: var(--green-d); }
.card .btn { background: var(--green-l); color: var(--green-d); max-width: none; }
.card .btn.primary { background: var(--green); color: #fff; }
.card.dark .btn { background: rgba(255,255,255,.1); color: #fff; }
.card.dark .btn.primary { background: var(--green); }
.btn.danger { background: var(--danger) !important; color: #fff !important; }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; cursor: default; }
.row { display: flex; gap: 8px; width: 100%; }
.row .btn { flex: 1; }
.hint { color: rgba(255,255,255,.85); font-size: 12px; margin: 4px 0 0; }
.slots { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.slot { display: flex; align-items: center; gap: 10px; border: 1.5px solid #e4e5e7; border-radius: 14px; padding: 10px 12px; cursor: pointer; background: #fff; text-align: left; font: inherit; color: inherit; width: 100%; }
.slot:hover { border-color: var(--green); }
.slot .num { width: 30px; height: 30px; border-radius: 50%; background: var(--green-l); color: var(--green-d); font-weight: 800; display: grid; place-items: center; flex: none; }
.slot .nm { font-weight: 800; }
.slot .meta { font-size: 12px; color: #6b7280; }
.slot.empty .nm { color: #9d9d9d; font-weight: 600; }
input.name { font: 700 18px 'Jakarta', sans-serif; padding: 12px 14px; border-radius: 12px; border: 2px solid #e4e5e7; width: 100%; outline: none; color: var(--ink); user-select: text; -webkit-user-select: text; }
input.name:focus { border-color: var(--green); }
table.keys { border-collapse: collapse; margin: 6px 0; font-size: 14px; width: 100%; }
table.keys td { padding: 5px 8px; border-bottom: 1px solid #eee; }
table.keys td:first-child { font-weight: 800; color: var(--green-d); white-space: nowrap; width: 96px; }
.opt { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid #eee; font-weight: 700; gap: 10px; }
.toggle { font: 800 13px 'Jakarta', sans-serif; border: 0; border-radius: 20px; padding: 8px 14px; min-width: 76px; cursor: pointer; background: #e4e5e7; color: #6b7280; }
.toggle.on { background: var(--green); color: #fff; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--green-l); color: var(--green-d); font-weight: 800; font-size: 18px; cursor: pointer; }
.stepper b { min-width: 36px; text-align: center; }
.scores { width: 100%; border-collapse: collapse; font-size: 14px; }
.scores td { padding: 7px 6px; border-bottom: 1px solid #eee; }
.scores td:last-child { text-align: right; font-weight: 800; color: var(--green-d); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 10px; }
.tabs button { font: 700 13px 'Jakarta', sans-serif; border: 0; border-radius: 20px; padding: 8px 14px; background: var(--green-l); color: var(--green-d); cursor: pointer; }
.tabs button.on { background: var(--green); color: #fff; }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.item { border: 1.5px solid #e4e5e7; border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; background: #fff; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.item.owned { border-color: var(--green); background: var(--green-l); }
.item h4 { margin: 0; font-size: 14px; font-weight: 800; }
.item .price { font-weight: 800; color: var(--green-d); font-size: 14px; }
.item .stats { font-size: 11px; color: #6b7280; }
.item[disabled] { opacity: .5; cursor: default; }
.swatch { height: 8px; border-radius: 4px; }
.garage-top { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.garage-top canvas { width: 120px; height: 72px; border-radius: 12px; background: var(--green-l); flex: none; }
.garage-top .info { flex: 1; }
.garage-top .bar { background: #e4e5e7; }
.note { font-size: 13px; font-weight: 700; color: var(--danger); min-height: 18px; }
.money-big { font-size: 34px; font-weight: 800; color: var(--green); margin: 4px 0; }

/* ---------------- Responsive ---------------- */
@media (max-width: 640px) {
  .hud-top { flex-wrap: wrap; gap: 6px; }
  .hud-cash, .hud-timer { padding: 5px 10px; }
  .hud-cash b, .hud-timer b { font-size: 15px; }
  .hud-trip { order: 5; flex-basis: 100%; padding: 6px 10px; }
  .fare b { font-size: 17px; }
  .arrow-wrap { width: 34px; height: 34px; }
  .hud-cash { flex: 1; }
  #hud-msg { top: calc(118px + var(--st)); font-size: 13px; }
  .energy { width: 84px; }
  .fuel, .fuel-gauge { width: 64px; } .fuel-gauge { height: 38px; }
  .title { font-size: 44px; }
}
@media (pointer: coarse) {
  .hud-bottom { bottom: calc(132px + var(--sb)); right: calc(150px + var(--sr)); flex-direction: column; align-items: flex-start; }
  #dialog { bottom: calc(270px + var(--sb)); }
  .pad { bottom: calc(18px + var(--sb)); }
  .radio { max-width: 46vw; }
}
@media (pointer: coarse) and (orientation: landscape) {
  .hud-bottom { bottom: calc(8px + var(--sb)); left: 50%; right: auto; transform: translateX(-50%); }
  .hud-bottom .radio { display: none; }
  #dialog { bottom: calc(110px + var(--sb)); padding: 0 200px; }
  .pad { bottom: calc(12px + var(--sb)); }
  .pad-mid { bottom: calc(112px + var(--sb)) !important; flex-direction: row; }
  .tbtn { width: 64px; height: 64px; }
  .tbtn.gas { width: 74px; height: 88px; }
  #hud-msg { top: calc(70px + var(--st)); }
}
