* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body {
  width: 100%; height: 100%; overflow: hidden; background: #1b2430; color: #f4f1e8;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* O'yin: uzoq bosishda matn tanlanmasin, kontekst menyu chiqmasin */
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none;
}
canvas#gl, canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
canvas#game { pointer-events: none; }
.hidden { display: none !important; }

/* Mashina ustida ko'tarilib yo'qoladigan yozuvlar (+12 000 so'm) */
#floats { position: fixed; left: 0; right: 0; top: 30%; pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.float {
  font-weight: 800; font-size: 19px; text-shadow: 0 2px 6px rgba(0, 0, 0, .75), 0 0 2px #000;
  animation: floatUp 2.1s ease-out forwards; white-space: nowrap; max-width: 94vw; overflow: hidden; text-overflow: ellipsis;
}
@keyframes floatUp { from { opacity: 0; transform: translateY(14px); } 12% { opacity: 1; } 70% { opacity: 1; } to { opacity: 0; transform: translateY(-34px); } }

/* ── HUD ── */
#hud { position: fixed; inset: 0; pointer-events: none; }
.topbar {
  position: absolute; top: max(8px, env(safe-area-inset-top)); left: 8px; right: 8px;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.pill {
  background: rgba(20, 26, 36, .82); border-radius: 999px; padding: 7px 13px;
  font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 6px;
  font-variant-numeric: tabular-nums;
}
.pill.timer.low { color: #ff6b5b; }
.pill.fuel .bar { width: 74px; height: 9px; background: #3a4352; border-radius: 9px; overflow: hidden; }
.pill.fuel .bar i { display: block; height: 100%; width: 100%; background: #58c26b; border-radius: 9px; }
.pill.fuel.low .bar i { background: #ff6b5b; }
.iconbtn {
  pointer-events: auto; margin-left: auto; width: 42px; height: 42px; border: 0; border-radius: 50%;
  background: rgba(20, 26, 36, .82); color: #fff; font-size: 18px; cursor: pointer;
}
#paxlist {
  position: absolute; top: calc(max(8px, env(safe-area-inset-top)) + 52px); left: 8px;
  display: flex; flex-direction: column; gap: 5px; max-width: 62vw;
}
.pax {
  background: rgba(20, 26, 36, .82); border-radius: 12px; padding: 6px 10px; font-size: 13.5px;
  display: flex; align-items: center; gap: 7px; border-left: 4px solid #ffc83d;
}
.pax .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pax .pt { flex: none; width: 46px; height: 6px; background: #3a4352; border-radius: 6px; overflow: hidden; }
.pax .pt i { display: block; height: 100%; background: #58c26b; }
.pax.angry { border-left-color: #ff6b5b; }
.pax.angry .pt i { background: #ff6b5b; }
#mini {
  position: absolute; right: 8px; top: calc(max(8px, env(safe-area-inset-top)) + 52px);
  width: 112px; height: 112px; border-radius: 12px; background: rgba(20, 26, 36, .82);
}
.hint {
  position: absolute; left: 50%; bottom: 150px; transform: translateX(-50%);
  background: rgba(20, 26, 36, .88); padding: 9px 16px; border-radius: 999px;
  font-weight: 600; font-size: 14.5px; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis;
}

/* ── barmoq bilan boshqarish ── */
#touch { position: fixed; inset: 0; pointer-events: none; }
.pad { position: absolute; bottom: max(18px, env(safe-area-inset-bottom)); display: flex; gap: 12px; }
.pad.left { left: 16px; }
.pad.right { right: 16px; }
.tbtn {
  pointer-events: auto; width: 74px; height: 74px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .35);
  background: rgba(20, 26, 36, .55); color: #fff; font-size: 26px; cursor: pointer;
}
.tbtn.on { background: rgba(255, 200, 61, .75); color: #1b2430; }
.tbtn.gas { border-color: rgba(88, 194, 107, .8); }
.tbtn.brake { border-color: rgba(255, 107, 91, .8); }

/* ── oynalar ── */
.screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(13, 18, 26, .72); padding: 14px; overflow-y: auto;
}
.card {
  width: min(380px, 100%); background: #232e3d; border-radius: 20px; padding: 22px 20px;
  display: flex; flex-direction: column; gap: 11px; text-align: center; margin: auto;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
}
.card.wide { width: min(560px, 100%); text-align: left; }
.card { touch-action: pan-y; }   /* ro'yxatlarni barmoq bilan aylantirish uchun */

/* Garaj: mashina ko'rinib turishi uchun oyna ekranni to'liq yopmaydi —
   tik ekranda pastdan, yotiq ekranda o'ng tomondan chiqadi */
.screen.sheet { background: none; align-items: flex-end; padding: 0; overflow: hidden; pointer-events: none; }
.screen.sheet .card {
  pointer-events: auto; width: 100%; max-height: 62%; overflow-y: auto; margin: 0;
  border-radius: 22px 22px 0 0; padding: 16px 16px max(16px, env(safe-area-inset-bottom));
  background: rgba(35, 46, 61, .96);
}
@media (min-aspect-ratio: 1/1) {
  .screen.sheet { align-items: stretch; justify-content: flex-end; }
  .screen.sheet .card { width: min(430px, 46%); max-height: none; height: 100%; border-radius: 22px 0 0 22px; }
}
.screen.sheet h1 { font-size: 24px; }
.screen.sheet .stats { justify-content: flex-start; gap: 8px; margin: 0; }
.screen.sheet .pill { background: #1b2430; }
.btn.big { font-size: 20px; padding: 15px; letter-spacing: 1px; position: sticky; top: 0; z-index: 2; box-shadow: 0 6px 16px rgba(0, 0, 0, .35); }
.row.tight { gap: 6px; }
.rules { text-align: left; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 14.5px; line-height: 1.4; }
.resgrid b.minus { color: #ff6b5b; }
#rules { z-index: 5; }
.row.tight .btn.small { flex: none; }
h1 { font-size: 34px; color: #ffc83d; letter-spacing: .5px; }
h2 { font-size: 23px; }
h3 { font-size: 15px; color: #9fb0c5; margin-top: 4px; }
.sub, .help { color: #9fb0c5; font-size: 14px; line-height: 1.45; }
.stats { display: flex; justify-content: center; gap: 22px; font-size: 17px; margin: 4px 0; }
.btn {
  border: 0; border-radius: 14px; padding: 13px 16px; font: inherit; font-weight: 700; font-size: 16px;
  background: #33435a; color: #f4f1e8; cursor: pointer;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: #ffc83d; color: #1b2430; }
.btn.gold { background: #58c26b; color: #10240f; }
.btn.small { padding: 9px 12px; font-size: 14px; flex: 1; }
a.btn { text-decoration: none; text-align: center; }
.btn:disabled { opacity: .45; }
.row { display: flex; gap: 10px; }
.head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }

.carlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 9px; }
.car {
  background: #1b2430; border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 5px;
  border: 2px solid transparent;
}
.car.sel { border-color: #ffc83d; }
.car canvas { width: 100%; height: 54px; }
.car .nm { font-weight: 700; }
.car .st { color: #9fb0c5; font-size: 12px; line-height: 1.4; }
.car .btn { padding: 8px; font-size: 13.5px; }
.upglist { display: flex; flex-direction: column; gap: 7px; }
.upg {
  background: #1b2430; border-radius: 12px; padding: 9px 11px; display: flex; align-items: center; gap: 10px;
}
.upg .info { flex: 1; min-width: 0; }
.upg .nm { font-weight: 600; font-size: 14.5px; }
.upg .lv { color: #9fb0c5; font-size: 12px; }
.upg .btn { padding: 8px 12px; font-size: 13.5px; white-space: nowrap; }

.resgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 4px 0; }
.resgrid div { background: #1b2430; border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 3px; }
.resgrid span { color: #9fb0c5; font-size: 12.5px; }
.resgrid b { font-size: 19px; font-variant-numeric: tabular-nums; }

.toast {
  position: fixed; left: 50%; top: 22%; transform: translateX(-50%); z-index: 9;
  background: rgba(20, 26, 36, .92); padding: 11px 18px; border-radius: 14px; font-weight: 700;
  pointer-events: none; text-align: center; max-width: 90vw;
}

@media (max-height: 430px) {
  .card { padding: 14px 16px; gap: 8px; }
  h1 { font-size: 26px; }
  .tbtn { width: 62px; height: 62px; }
  #mini { width: 86px; height: 86px; }
}
