:root {
  --page: #12161b; --panel: #1b2129; --panel2: #232b35; --line: #2f3946; --ink: #eef1f4; --muted: #9aa5b1;
  --sun: #f2c230; --go: #3cc27a; --warn: #f2a030; --bad: #e5533d; --blue: #2f6db5;
  --display: "Russo One", "Arial Black", system-ui, sans-serif;
  --body: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px);
  --tg-top: var(--tg-content-safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--page); color: var(--ink); font: 14px/1.4 var(--body); }
body { overscroll-behavior: none; user-select: none; -webkit-user-select: none; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--sun); outline-offset: 2px; }
#app { position: fixed; inset: 0; overflow: hidden; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; padding: calc(10px + var(--st) + var(--tg-top)) 10px 0; display: flex; flex-direction: column; gap: 8px; }
.hud-top { display: flex; gap: 8px; align-items: stretch; }
.spacer { flex: 1; }
.chip { background: rgba(14, 18, 23, .8); border: 1px solid rgba(255, 255, 255, .09); border-radius: 12px; padding: 6px 10px; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.chip small { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.chip b { font-family: var(--display); font-weight: 400; font-size: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chip.money b { color: var(--sun); }
.icon-btn { pointer-events: auto; min-width: 42px; height: 42px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .15); background: rgba(14, 18, 23, .8); font-weight: 800; font-size: 15px; }
.mission { display: flex; align-items: center; gap: 10px; }
.mission .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--sun); flex: 0 0 auto; box-shadow: 0 0 0 4px rgba(242, 194, 48, .25); }
.mission.drop .dot { background: var(--go); box-shadow: 0 0 0 4px rgba(60, 194, 122, .25); }
.mtxt { flex: 1; min-width: 0; font-size: 12px; line-height: 1.3; }
.mtxt strong { display: block; font-size: 13px; }
.mtxt span { color: #c9d1da; }
.mdist { font-family: var(--display); font-size: 16px; font-variant-numeric: tabular-nums; }
.hold { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .12); overflow: hidden; margin-top: 4px; }
.hold i { display: block; height: 100%; width: 0; background: var(--go); }
.racehud { display: flex; align-items: center; gap: 12px; }
.racehud b { font-size: 22px; }
.rdelta { font-family: var(--display); font-size: 16px; min-width: 70px; }
.rdelta.ahead { color: var(--go); } .rdelta.behind { color: var(--bad); }
.rprog { flex: 1; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.rprog i { display: block; height: 100%; width: 0; background: var(--sun); }
.dmg { align-self: flex-end; display: flex; align-items: center; gap: 6px; background: rgba(14, 18, 23, .7); border-radius: 10px; padding: 4px 8px; }
.dmg small { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.dmg .bar { width: 64px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.dmg .bar i { display: block; height: 100%; background: var(--go); }
#feed { position: absolute; left: 0; right: 0; top: 40%; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pop { font-family: var(--display); font-size: 18px; text-shadow: 0 2px 0 rgba(0, 0, 0, .6), 0 0 12px rgba(0, 0, 0, .5); animation: pop 1.6s ease-out forwards; white-space: nowrap; }
.pop.good { color: var(--go); } .pop.bad { color: var(--bad); } .pop.warn { color: var(--warn); } .pop.gold { color: var(--sun); }
@keyframes pop { 0% { opacity: 0; transform: translateY(10px) scale(.9); } 12% { opacity: 1; transform: translateY(0) scale(1.05); } 70% { opacity: 1; } 100% { opacity: 0; transform: translateY(-26px); } }
.hint { position: absolute; left: 16px; right: 16px; top: calc(205px + var(--st) + var(--tg-top)); text-align: center; background: rgba(14, 18, 23, .85); border: 1px solid rgba(242, 194, 48, .5); border-radius: 12px; padding: 8px 12px; font-size: 13px; }

/* ---------- boshqaruv ---------- */
#controls { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; padding: 12px 12px calc(14px + var(--sb)); gap: 10px; pointer-events: none; }
#controls .grp { display: flex; gap: 10px; }
.ctrl { pointer-events: auto; width: 72px; height: 72px; border-radius: 18px; border: 1px solid rgba(255, 255, 255, .2); background: rgba(14, 18, 23, .55); font-weight: 800; font-size: 14px; touch-action: none; }
.ctrl.arrow { font-size: 24px; }
.ctrl.gas { background: rgba(60, 194, 122, .38); width: 84px; }
.ctrl.brake { background: rgba(229, 83, 61, .34); }
.ctrl.on { transform: scale(.94); filter: brightness(1.45); }

/* ---------- toast, countdown ---------- */
.toast { position: absolute; left: 50%; top: calc(150px + var(--st) + var(--tg-top)); transform: translateX(-50%); display: flex; align-items: center; gap: 12px; background: rgba(14, 18, 23, .94); border: 1px solid rgba(60, 194, 122, .55); border-radius: 14px; padding: 8px 8px 8px 14px; white-space: nowrap; z-index: 5; }
.toast b { display: block; font-family: var(--display); font-weight: 400; color: var(--go); font-size: 18px; }
.toast small { display: block; color: var(--muted); font-size: 11px; }
.toast button { font-weight: 800; font-size: 12px; border: 0; border-radius: 10px; padding: 10px 12px; background: var(--sun); color: #1a1405; }
.toast button[disabled] { background: #2a323d; color: var(--muted); }
#countdown { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--display); font-size: 110px; color: var(--sun); text-shadow: 0 6px 0 rgba(0, 0, 0, .5); pointer-events: none; z-index: 6; }

/* ---------- ekranlar ---------- */
.screen { position: absolute; inset: 0; z-index: 10; }
.menu { display: flex; flex-direction: column; background: linear-gradient(to bottom, rgba(18, 22, 27, .2) 0%, rgba(18, 22, 27, .15) 30%, rgba(18, 22, 27, .92) 55%, var(--page) 70%); padding: calc(14px + var(--st) + var(--tg-top)) 16px calc(14px + var(--sb)); overflow-y: auto; touch-action: pan-y; }
.menu-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
h1 { font-family: var(--display); font-weight: 400; font-size: 32px; margin: 0; line-height: 1; text-shadow: 0 3px 0 rgba(0, 0, 0, .45); }
h1 span { color: var(--sun); }
.menu-body { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 34vh; }
.group-banner { margin-top: 10px; align-self: flex-start; background: rgba(47, 109, 181, .85); border-radius: 10px; padding: 6px 10px; font-size: 12px; font-weight: 700; }
.big { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; border-radius: 16px; padding: 14px 16px; border: 1px solid var(--line); background: var(--panel); text-align: left; }
.big .t { font-family: var(--display); font-size: 19px; }
.big .s { font-size: 12px; color: var(--muted); }
.big.primary { background: var(--sun); color: #1a1405; border-color: transparent; }
.big.primary .s { color: #5a4708; }
.big.race { background: linear-gradient(90deg, #2b1f3f, #3b2440); border-color: #5a3a63; }
.big:active { transform: scale(.985); }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mid { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 6px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); font-size: 20px; }
.mid span { font-size: 13px; font-weight: 800; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; }
.card h3 { margin: 0 0 8px; font-family: var(--display); font-weight: 400; font-size: 15px; }
.daily ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.daily li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-size: 13px; }
.daily li .pb { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: #2a323d; overflow: hidden; }
.daily li .pb i { display: block; height: 100%; background: var(--sun); }
.daily li.done { color: var(--muted); }
.daily li.done .pb i { background: var(--go); }
.daily li em { font-style: normal; color: var(--sun); font-weight: 800; font-size: 12px; }
.menu-foot { display: flex; justify-content: space-between; align-items: center; }
.pill { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: 12px; }
.ver { color: var(--muted); font-size: 10.5px; line-height: 1.3; text-align: right; flex: 1; min-width: 0; }
.muted { color: var(--muted); } .small { font-size: 12px; }

.sheet, .page { display: flex; flex-direction: column; padding: calc(10px + var(--st) + var(--tg-top)) 0 0; }
.page { background: var(--page); }
.sheet { pointer-events: none; }
.sheet > * { pointer-events: auto; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 0 12px 10px; }
.sheet-head h2 { font-family: var(--display); font-weight: 400; font-size: 20px; margin: 0; flex: 1; }
.sheet .sheet-head { background: linear-gradient(to bottom, rgba(18, 22, 27, .8), transparent); padding-bottom: 14px; }
.car-pick { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: linear-gradient(to bottom, transparent, rgba(18, 22, 27, .95) 40%); }
.car-name { flex: 1; text-align: center; }
.car-name b { display: block; font-family: var(--display); font-weight: 400; font-size: 22px; }
.car-name small { color: var(--muted); }
.tabs { display: flex; gap: 6px; padding: 0 12px 8px; background: rgba(18, 22, 27, .95); }
.tabs button { flex: 1; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 8px 4px; font-weight: 800; font-size: 12px; }
.tabs button.on { background: var(--sun); color: #1a1405; border-color: transparent; }
.tabs button[disabled] { opacity: .4; }
.sheet-body { background: var(--page); height: 38vh; overflow-y: auto; padding: 8px 12px calc(16px + var(--sb)); touch-action: pan-y; }
.page-body { flex: 1; overflow-y: auto; padding: 4px 12px calc(16px + var(--sb)); touch-action: pan-y; display: flex; flex-direction: column; gap: 10px; }
.stats { display: grid; grid-template-columns: auto 1fr auto; gap: 6px 10px; align-items: center; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.stats .bar { height: 6px; border-radius: 3px; background: #2a323d; overflow: hidden; }
.stats .bar i { display: block; height: 100%; background: var(--sun); }
.stats b { color: var(--ink); font-variant-numeric: tabular-nums; }
.act { width: 100%; border: 0; border-radius: 12px; padding: 12px; font-weight: 800; background: var(--go); color: #06210f; }
.act.gold { background: var(--sun); color: #1a1405; }
.act[disabled] { background: #2a323d; color: var(--muted); }
.up-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.up-row .lv { display: flex; gap: 4px; }
.up-row .lv i { width: 18px; height: 6px; border-radius: 3px; background: #2a323d; }
.up-row .lv i.on { background: var(--sun); }
.up-row small { color: var(--muted); }
.up-row button { grid-row: 1 / 3; grid-column: 2; border: 0; border-radius: 10px; padding: 10px 12px; font-weight: 800; background: var(--go); color: #06210f; font-size: 12px; }
.up-row button[disabled] { background: #2a323d; color: var(--muted); }
.opt-h { margin: 12px 0 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; display: flex; justify-content: space-between; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.sw { width: 40px; height: 40px; border-radius: 12px; border: 2px solid transparent; position: relative; }
.sw.on { border-color: var(--sun); }
.sw.lock::after { content: "⭐"; position: absolute; right: -6px; top: -8px; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 8px 10px; font-weight: 700; font-size: 12px; }
.opt.on { border-color: var(--sun); color: var(--sun); }
.opt.lock { opacity: .75; }
.board { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.board li { display: grid; grid-template-columns: 34px 1fr auto; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.board li.me { border-color: var(--sun); }
.board .rk { font-family: var(--display); color: var(--muted); }
.board .nm { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .nm small { display: block; color: var(--muted); font-weight: 500; }
.board .tm { font-family: var(--display); font-variant-numeric: tabular-nums; }
.me-row { color: var(--muted); font-size: 13px; text-align: center; }
.shop-item { display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 12px; margin-bottom: 10px; }
.shop-item .ic { font-size: 30px; text-align: center; }
.shop-item b { display: block; font-size: 15px; }
.shop-item p { margin: 2px 0 8px; color: var(--muted); font-size: 12px; }
.center { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; background: rgba(10, 13, 17, .86); }
.center h2 { font-family: var(--display); font-weight: 400; font-size: 34px; margin: 0; }
.center .big { max-width: 340px; align-items: center; }
.result-time { font-family: var(--display); font-size: 48px; color: var(--sun); }
.result-lines { text-align: center; color: #c9d1da; line-height: 1.7; }
.result-lines b { color: var(--ink); }
#loading { position: absolute; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: var(--page); }
#loading p { color: var(--muted); margin: 0; }

/* ---------- v0.2: marshrutka HUD, signal, yo'l chizig'i ---------- */
.pax { align-self: flex-end; display: flex; align-items: baseline; gap: 6px; }
.pax b { font-size: 16px; }
.routebar { position: relative; height: 6px; margin: 2px 4px 0; border-radius: 3px; background: rgba(14, 18, 23, .55); }
.routebar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: rgba(242, 194, 48, .55); }
.routebar b { position: absolute; top: -4px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--sun); border: 2px solid #12161b; }
.routebar .stop { position: absolute; top: -2px; width: 4px; height: 10px; margin-left: -2px; border-radius: 2px; background: #e8edf2; opacity: .75; }
.routebar .stop.dest { background: var(--go); opacity: 1; height: 12px; top: -3px; }
.routebar .stop em { position: absolute; top: 11px; left: 50%; transform: translateX(-50%); font-style: normal; font-size: 9px; color: #dfe6ec; white-space: nowrap; text-shadow: 0 1px 2px #000; }
.ctrl.horn { position: absolute; right: 18px; bottom: calc(104px + var(--sb)); width: 56px; height: 56px; border-radius: 50%; font-size: 22px; background: rgba(242, 194, 48, .22); }
.ctrl.horn.on { transform: scale(.92); }
.loadbar { width: 180px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.loadbar i { display: block; height: 100%; width: 0; background: var(--sun); transition: width .2s; }
.menu-foot { flex-wrap: wrap; }
@media (max-width: 360px) { .ctrl { width: 64px; height: 64px; } .ctrl.gas { width: 74px; } .ctrl.horn { width: 48px; height: 48px; } }
