* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0e1116; font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif; color: #eef2f6; user-select: none; -webkit-user-select: none; }
#view { position: fixed; inset: 0; }
#view canvas { display: block; }

.panel, #exPanel, #scorePanel, #dash, #speedo { background: rgba(14, 18, 24, 0.78); border: 1px solid rgba(255,255,255,0.08); border-radius: 12px; backdrop-filter: blur(6px); }

#hud { position: fixed; inset: 0; pointer-events: none; }
#exPanel { position: absolute; top: 12px; left: 12px; width: min(380px, calc(100vw - 24px)); padding: 10px 14px; }
#exPanel .row { display: flex; justify-content: space-between; font-size: 12px; letter-spacing: .08em; color: #8fa3b8; font-weight: 700; }
#mode { color: #ffd23f; }
#exName { font-size: 18px; font-weight: 700; margin: 4px 0; }
#exHint { font-size: 13px; line-height: 1.4; color: #c9d4df; }

#scorePanel { position: absolute; top: 12px; right: 12px; width: 250px; padding: 10px 12px; }
#scoreBox { display: flex; align-items: baseline; gap: 6px; }
#scoreBox b { font-size: 30px; color: #6be07a; }
#scoreBox.bad b { color: #ff5a4f; }
#scoreBox small { color: #8fa3b8; }
#timer { float: right; margin-top: -32px; font-size: 18px; font-variant-numeric: tabular-nums; }
#timer.bad { color: #ff5a4f; }
#exList { list-style: none; padding: 0; margin: 8px 0 0; font-size: 12px; }
#exList li { display: flex; gap: 6px; padding: 2px 0; color: #7d8b99; }
#exList li span { width: 18px; text-align: right; font-weight: 700; }
#exList li.cur { color: #ffd23f; font-weight: 700; }
#exList li.ok { color: #6be07a; }
#exList li.pen { color: #ffb14a; }
#exList li b { margin-left: auto; color: #ff5a4f; }

#toasts { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; width: min(520px, calc(100vw - 24px)); }
.toast { padding: 8px 14px; border-radius: 10px; font-size: 14px; font-weight: 600; background: rgba(30, 90, 160, 0.92); transition: opacity .4s, transform .4s; text-align: center; }
.toast.pen { background: rgba(200, 110, 20, 0.95); }
.toast.fail { background: rgba(190, 25, 30, 0.96); font-size: 16px; }
.toast.urgent { background: rgba(190, 25, 30, 0.96); font-size: 20px; }
.toast.hide { opacity: 0; transform: translateY(-8px); }

#alarm { position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%); font-size: 42px; font-weight: 900; color: #fff; background: #d0141c; padding: 10px 28px; border-radius: 14px; display: none; animation: blink .5s steps(2) infinite; }
#alarm.show { display: block; }
@keyframes blink { 50% { opacity: .25; } }

#minimap { position: absolute; left: 12px; bottom: 12px; border-radius: 10px; border: 2px solid rgba(255,255,255,0.25); opacity: .95; }
#minimap.hidden { display: none; }

#dash { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); padding: 8px 12px; display: flex; gap: 14px; align-items: center; }
#ind { display: flex; gap: 8px; }
.ico { font-size: 12px; font-weight: 800; padding: 4px 7px; border-radius: 6px; background: #1e252e; color: #4a5562; min-width: 30px; text-align: center; }
.ico.on { background: #1f5e2b; color: #9dffad; }
.ico.red.on { background: #7a1418; color: #ffb3b0; }
.ico.arrow { font-size: 16px; padding: 1px 7px; }
.ico.arrow.on { background: #1f5e2b; color: #4dff6a; }
#iBelt:not(.on) { background: #5a1c1c; color: #ff8a80; }
#gears { display: flex; gap: 4px; }
#gears span { width: 26px; text-align: center; font-weight: 800; color: #4a5562; padding: 3px 0; border-radius: 5px; }
#gears span.on { color: #fff; background: #2b6cb0; }

#speedo { position: absolute; right: 12px; bottom: 12px; width: 130px; height: 130px; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#speed { font-size: 36px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
#speedo small { color: #8fa3b8; font-size: 11px; }
#speedNeedle { position: absolute; width: 3px; height: 52px; background: #ff5a4f; left: calc(50% - 1.5px); top: 13px; transform-origin: 50% 52px; border-radius: 2px; opacity: .8; }

/* modallar */
.modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(5, 8, 12, 0.55); padding: 16px; z-index: 10; }
.modal.show { display: flex; }
.card { background: #141a22; border: 1px solid rgba(255,255,255,0.1); border-radius: 16px; padding: 22px; width: min(420px, 100%); max-height: calc(100vh - 32px); overflow: auto; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.card.wide { width: min(760px, 100%); }
h1 { margin: 0; font-size: 26px; }
h2 { margin: 10px 0 0; font-size: 17px; color: #ffd23f; }
.sub { margin: 0; color: #9fb0c2; font-size: 14px; }
.note { color: #8fa3b8; font-size: 12.5px; line-height: 1.45; margin: 0; }
button { font: inherit; font-weight: 700; border: 0; border-radius: 10px; padding: 11px 14px; background: #263140; color: #eef2f6; cursor: pointer; }
button:hover { background: #2f3d50; }
button.primary { background: #2b6cb0; }
button.primary:hover { background: #3479c4; }
.practice { display: flex; gap: 8px; }
.practice select { flex: 1; min-width: 0; font: inherit; background: #0f141a; color: #eef2f6; border: 1px solid #2f3d50; border-radius: 10px; padding: 8px; }
.opts { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 13px; color: #c9d4df; }
.opts input[type=color] { width: 34px; height: 22px; border: 0; padding: 0; background: none; vertical-align: middle; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
td, th { padding: 5px 8px; border-bottom: 1px solid rgba(255,255,255,0.07); text-align: left; }
.pen td:last-child, .pen th:last-child { text-align: right; font-weight: 800; color: #ffb14a; }
.keys td:nth-child(odd) { color: #ffd23f; font-weight: 700; white-space: nowrap; }
.rules-ex { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.5; color: #c9d4df; }
#result.passed h1 { color: #6be07a; }
#result:not(.passed) h1 { color: #ff5a4f; }
a.switch { display: block; text-align: center; font-weight: 700; border-radius: 10px; padding: 11px 14px; background: #3a2a52; color: #eef2f6; text-decoration: none; }
a.switch:hover { background: #4a3768; }
.slowT { font-size: 22px; font-weight: 800; color: #ffd23f; font-variant-numeric: tabular-nums; }
code { background: #0f141a; padding: 1px 5px; border-radius: 4px; }

/* sensorli boshqaruv */
#touch { display: none; }
body.touch #touch { display: block; }
#touch button { pointer-events: auto; background: rgba(30, 40, 52, 0.75); border: 1px solid rgba(255,255,255,0.15); touch-action: none; }
#touch button.on { background: rgba(43, 108, 176, 0.9); }
#touch .tl { position: fixed; left: 12px; bottom: 170px; display: flex; gap: 10px; }
#touch .tl button { width: 74px; height: 74px; font-size: 26px; }
#touch .tr { position: fixed; right: 12px; bottom: 160px; display: flex; gap: 10px; }
#touch .tr button { width: 80px; height: 100px; }
#touch .gas { background: rgba(31, 94, 43, 0.85) !important; }
#touch .brake { background: rgba(122, 20, 24, 0.85) !important; }
#touch .tm { position: fixed; left: 50%; transform: translateX(-50%); bottom: 70px; display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; width: min(520px, calc(100vw - 24px)); }
#touch .tm button { padding: 7px 9px; font-size: 12px; }
body.touch #minimap { width: 150px; height: 81px; left: auto; right: 12px; bottom: auto; top: 96px; }
body.touch #scorePanel #exList { display: none; }
body.touch #scorePanel { width: 150px; }
body.touch #toasts { top: auto; bottom: 330px; }
body.touch #dash { left: 12px; transform: none; bottom: 12px; padding: 6px 8px; gap: 8px; max-width: calc(100vw - 24px); }
body.touch .ico { min-width: 0; padding: 3px 5px; font-size: 11px; }
body.touch #gears span { width: 20px; }
body.touch #speedo { width: 78px; height: 78px; bottom: auto; top: 186px; }
body.touch #speed { font-size: 26px; }
body.touch #speedNeedle { display: none; }
body.touch #exHint { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
body.touch #touch .tm { bottom: 56px; }
body.touch #touch .tl, body.touch #touch .tr { bottom: 150px; }

@media (max-width: 720px) {
  #scorePanel { width: 150px; }
  #exList { display: none; }
  #exPanel { width: calc(100vw - 186px); }
  #exHint { font-size: 12px; }
  #speedo { width: 100px; height: 100px; }
  #speedNeedle { display: none; }
}
body.touch #timer { font-size: 14px; float: none; margin-top: 2px; text-align: right; }

/* gameuzb.uz: mualliflar (CC BY) va portalga qaytish */
.credits { margin-top: 10px; font-size: 11.5px; color: #7f93a8; }
a.switch.portal { margin-top: 8px; background: #1d8cf0; color: #fff; }
a.switch.portal:hover { background: #3a9df5; }
