/* =========================================================
   Traffic Racer 3D – UI styles
   ========================================================= */
:root {
  --font: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, system-ui, sans-serif;
  --accent: #ffcc00;
  --blue: #1e88ff;
  --panel: rgba(10, 20, 40, .88);
  --line: rgba(120, 170, 255, .35);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #0b1a33; color: #fff; font-family: var(--font); user-select: none; -webkit-user-select: none; touch-action: none; overscroll-behavior: none; }
canvas#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
img { pointer-events: none; -webkit-user-drag: none; }
button { font-family: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- effects overlays ---------- */
.nitro-fx {
  position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity .25s;
  background: radial-gradient(ellipse at 50% 55%, transparent 45%, rgba(60, 170, 255, .28) 75%, rgba(20, 90, 220, .55) 100%);
}
.nitro-fx::after { /* streaky motion-blur style edges */
  content: ''; position: absolute; inset: 0;
  background: repeating-conic-gradient(from 0deg at 50% 52%, rgba(255,255,255,.08) 0deg 1.5deg, transparent 1.5deg 9deg);
  -webkit-mask: radial-gradient(ellipse at 50% 55%, transparent 50%, #000 90%); mask: radial-gradient(ellipse at 50% 55%, transparent 50%, #000 90%);
  animation: streak .25s linear infinite;
}
@keyframes streak { to { transform: scale(1.04); } }
.hit-fx { position: fixed; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, transparent 40%, rgba(255, 30, 30, .55)); transition: opacity .4s; }
.hit-fx.on { opacity: 1; transition: none; }

/* ---------- HUD ---------- */
.hud { position: fixed; inset: 0; pointer-events: none; font-style: italic; }
.hud-tl { position: absolute; left: calc(14px + var(--safe-l)); top: calc(10px + var(--safe-t)); text-shadow: 0 2px 6px rgba(0,0,0,.6); }
.score-label { font-size: 12px; font-weight: 800; letter-spacing: 3px; color: #bcd4ff; }
.score { font-size: 38px; font-weight: 900; line-height: 1; letter-spacing: 1px; }
.combo { display: inline-block; margin-top: 6px; padding: 2px 12px; border-radius: 6px; background: linear-gradient(90deg, #ff8a00, #ff2d55); font-weight: 900; font-size: 20px; transform: skewX(-12deg); box-shadow: 0 3px 10px rgba(255, 60, 60, .5); }
.combo.pop { animation: pop .3s ease; }
@keyframes pop { 50% { transform: skewX(-12deg) scale(1.3); } }
.hud-tc { position: absolute; left: 50%; top: calc(10px + var(--safe-t)); transform: translateX(-50%); display: flex; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 10px; background: rgba(8, 16, 34, .72); border: 1px solid var(--line); font-weight: 800; font-size: 17px; white-space: nowrap; font-style: italic; }
.chip img { width: 20px; height: 20px; }
.chip-k { font-size: 11px; letter-spacing: 2px; color: #8fb4ff; }
.chip.timer { background: rgba(120, 20, 20, .75); }
.chip.timer.low { animation: blink .5s infinite; }
@keyframes blink { 50% { background: rgba(255, 40, 40, .9); } }
.icon-btn { pointer-events: auto; width: 48px; height: 48px; border-radius: 12px; background: rgba(8, 16, 34, .72); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; transition: transform .1s; }
.icon-btn img { width: 24px; height: 24px; }
.icon-btn:active { transform: scale(.92); }
.icon-btn.big { width: 60px; height: 60px; border-radius: 50%; }
.hud-pause { position: absolute; right: calc(14px + var(--safe-r)); top: calc(10px + var(--safe-t)); }
.hud-bl { position: absolute; left: calc(14px + var(--safe-l)); bottom: calc(14px + var(--safe-b)); width: 210px; display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 800; letter-spacing: 2px; color: #bcd4ff; }
.bar { flex: 1; height: 10px; border-radius: 5px; background: rgba(0, 0, 0, .55); border: 1px solid rgba(255,255,255,.2); overflow: hidden; }
.fill { height: 100%; width: 0; border-radius: 5px; transition: width .2s; }
.fill.dmg { background: linear-gradient(90deg, #ffd000, #ff3b30); }
.fill.mis { background: linear-gradient(90deg, #36d1ff, #3bff9e); }
.fill.nos { background: linear-gradient(90deg, #1e8bff, #9ff3ff); transition: width .1s; }
.mission-mini { padding: 6px 10px; border-radius: 10px; background: rgba(8, 16, 34, .72); border: 1px solid var(--line); }
.mm-title { font-size: 13px; font-weight: 800; margin-bottom: 4px; }

.speedo { position: absolute; right: calc(14px + var(--safe-r)); bottom: calc(12px + var(--safe-b)); width: 170px; height: 170px; }
.speedo .dial { position: absolute; inset: 0; width: 100%; height: 100%; }
.needle { position: absolute; left: 50%; top: 50%; width: 4px; height: 44%; margin-left: -2px; transform-origin: 50% 0; background: linear-gradient(#ff3b30, #ff8a00); border-radius: 2px; transform: rotate(60deg); box-shadow: 0 0 8px rgba(255, 60, 40, .7); }
.needle::before { content: ''; position: absolute; left: -5px; top: -7px; width: 14px; height: 14px; border-radius: 50%; background: #1b2740; border: 3px solid #ff3b30; }
.digital { position: absolute; left: 0; right: 0; top: 54%; text-align: center; font-weight: 900; font-size: 34px; line-height: 1; }
.digital small { display: block; font-size: 11px; color: #8fb4ff; letter-spacing: 2px; margin-top: 2px; }
.gear { position: absolute; left: 50%; top: 27%; transform: translateX(-50%); width: 26px; height: 26px; border-radius: 8px; background: rgba(255, 204, 0, .9); color: #111; font-weight: 900; font-size: 18px; display: flex; align-items: center; justify-content: center; font-style: normal; }
.nitro-wrap { position: absolute; left: -10px; right: -10px; bottom: -6px; display: flex; align-items: center; gap: 4px; }
.nitro-wrap img { width: 26px; height: 26px; }
.nitro-bar { height: 12px; }
.speedo.boost .dial { filter: drop-shadow(0 0 12px rgba(80, 180, 255, .9)); }

.popups { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); width: 0; height: 0; }
.popup { position: absolute; left: 0; top: 0; transform: translateX(-50%); white-space: nowrap; font-weight: 900; font-size: 26px; text-shadow: 0 3px 8px rgba(0,0,0,.7); animation: rise 1.2s ease-out forwards; }
.popup.near { color: #4dffb8; }
.popup.over { color: #fff; }
.popup.onc { color: #ffcf33; }
.popup.bad { color: #ff5a4d; }
.popup.coin { color: #ffd34d; font-size: 20px; }
@keyframes rise { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.6); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.1); } 30% { transform: translate(-50%, 0) scale(1); } 100% { opacity: 0; transform: translate(-50%, -60px); } }
.banner { position: absolute; left: 50%; top: 34%; transform: translateX(-50%) skewX(-10deg); padding: 10px 28px; background: linear-gradient(90deg, #ffb300, #ff6d00); color: #fff; font-weight: 900; font-size: 28px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.4); animation: bannerIn .5s cubic-bezier(.3, 1.5, .5, 1); white-space: nowrap; text-align: center; }
.banner small { display: block; font-size: 15px; opacity: .9; }
@keyframes bannerIn { from { transform: translateX(-50%) skewX(-10deg) scale(.4); opacity: 0; } }
.countdown { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); font-size: 120px; font-weight: 900; text-shadow: 0 6px 20px rgba(0,0,0,.6); animation: count .9s ease-out; }
@keyframes count { from { transform: translate(-50%, -50%) scale(2); opacity: 0; } 30% { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

/* ---------- touch controls ---------- */
.controls { position: fixed; left: 0; right: 0; bottom: 0; height: 0; pointer-events: none; }
.ctl { pointer-events: auto; position: relative; width: 84px; height: 84px; border-radius: 50%; background: rgba(10, 20, 40, .5); border: 2px solid rgba(255,255,255,.35); display: flex; align-items: center; justify-content: center; backdrop-filter: blur(3px); transition: transform .06s, background .1s; touch-action: none; }
.ctl img { width: 40px; height: 40px; }
.ctl.down { transform: scale(.92); background: rgba(30, 136, 255, .55); border-color: #9fd0ff; }
.ctl-left { position: absolute; left: calc(16px + var(--safe-l)); bottom: calc(20px + var(--safe-b)); display: flex; gap: 14px; }
.ctl-right { position: absolute; right: calc(200px + var(--safe-r)); bottom: calc(20px + var(--safe-b)); display: flex; gap: 12px; align-items: flex-end; }
.ctl-gas { width: 92px; height: 110px; border-radius: 24px; background: rgba(20, 120, 40, .5); }
.ctl-gas.down { background: rgba(40, 200, 80, .6); }
.ctl-brake { width: 76px; height: 76px; background: rgba(140, 20, 20, .5); }
.ctl-brake.down { background: rgba(230, 50, 50, .65); }
.ctl-nitro { width: 70px; height: 70px; background: rgba(20, 90, 200, .55); margin-bottom: 30px; }
.ctl-nitro.ready { box-shadow: 0 0 18px rgba(80, 180, 255, .9); }
body.touch .hud-bl { bottom: calc(126px + var(--safe-b)); }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: calc(10px + var(--safe-t)) calc(10px + var(--safe-r)) calc(10px + var(--safe-b)) calc(10px + var(--safe-l)); animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; } }
.screen.dim { background: rgba(4, 10, 24, .55); backdrop-filter: blur(4px); z-index: 30; }
.screen.loading { flex-direction: column; background: radial-gradient(ellipse at 50% 30%, #2a7be0, #0b2a5c 70%, #071530); }
.logo { display: flex; align-items: baseline; justify-content: center; flex-wrap: wrap; gap: 0 12px; font-weight: 900; font-style: italic; transform: skewX(-8deg); text-shadow: 0 6px 0 #071a3c, 0 10px 30px rgba(0,0,0,.4); }
.logo span { font-size: min(14vw, 84px); line-height: .95; }
.logo .l2 { color: var(--accent); }
.logo .l3 { font-size: min(8vw, 44px); padding: 2px 10px; border-radius: 8px; background: #ff2d55; text-shadow: none; }
.logo.small span { font-size: min(9vw, 46px); }
.logo.small .l3 { font-size: min(5vw, 26px); }
.road-anim { position: relative; width: min(80vw, 360px); height: 90px; margin: 28px 0 18px; overflow: hidden; border-radius: 12px; background: #3a3f46; box-shadow: inset 0 0 0 4px #20252b; }
.road-anim .lines { position: absolute; left: 0; right: 0; top: 50%; height: 4px; margin-top: -2px; background: repeating-linear-gradient(90deg, #fff 0 30px, transparent 30px 60px); animation: lines .4s linear infinite; }
@keyframes lines { to { background-position: -60px 0; } }
.mini-car { position: absolute; left: 50%; top: 50%; width: 120px; height: 60px; margin: -34px 0 0 -60px; background: url(assets/favicon.svg) center / contain no-repeat; animation: carBob .5s ease-in-out infinite alternate; }
@keyframes carBob { to { transform: translate(6px, 2px); } }
.loadbar { width: min(80vw, 360px); height: 14px; border-radius: 8px; background: rgba(0,0,0,.4); overflow: hidden; border: 1px solid rgba(255,255,255,.2); }
.loadfill { width: 0; height: 100%; background: linear-gradient(90deg, #ffcc00, #ff6d00); transition: width .2s; }
.loadtext { margin-top: 10px; opacity: .85; font-size: 15px; }
.error { margin-top: 16px; max-width: 420px; padding: 14px 18px; border-radius: 12px; background: rgba(180, 20, 20, .85); text-align: center; line-height: 1.4; }

.menu { justify-content: space-between; align-items: stretch; flex-direction: column; background: linear-gradient(90deg, rgba(5,15,35,.75), rgba(5,15,35,0) 55%); }
.menu-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.menu-top .logo { justify-content: flex-start; }
.wallet { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.menu-side { display: flex; flex-direction: column; gap: 12px; width: min(300px, 80vw); }
.menu-car { align-self: center; font-weight: 900; font-style: italic; font-size: 18px; padding: 6px 18px; border-radius: 10px; background: rgba(8, 16, 34, .6); }
.btn { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 10px 20px; border-radius: 12px; font-weight: 900; font-size: 20px; font-style: italic; letter-spacing: .5px; text-transform: uppercase; background: linear-gradient(180deg, #2f8dff, #1559c8); box-shadow: 0 5px 0 #0b3478, 0 8px 18px rgba(0,0,0,.35); transform: skewX(-8deg); transition: transform .1s, filter .15s; }
.btn > * { transform: skewX(8deg); }
.btn img { width: 24px; height: 24px; }
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: skewX(-8deg) translateY(4px); box-shadow: 0 1px 0 #0b3478; }
.btn-play { background: linear-gradient(180deg, #ffd23f, #ff8f00); color: #2b1600; box-shadow: 0 5px 0 #a35200, 0 8px 18px rgba(0,0,0,.35); font-size: 24px; }
.btn-play img { filter: invert(.85); }
.btn-red { background: linear-gradient(180deg, #ff5a4d, #c62828); box-shadow: 0 5px 0 #7a1010, 0 8px 18px rgba(0,0,0,.35); }
.btn.small { min-height: 42px; font-size: 16px; margin-top: 8px; }
.btn:disabled { filter: grayscale(.8) brightness(.7); cursor: default; }

.panel { position: relative; width: min(92vw, 420px); max-height: calc(100vh - 20px); overflow-y: auto; padding: 22px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 20px 50px rgba(0,0,0,.5); display: flex; flex-direction: column; gap: 12px; animation: panel .3s cubic-bezier(.3, 1.4, .5, 1); touch-action: pan-y; }
.panel.wide { width: min(94vw, 640px); }
@keyframes panel { from { transform: scale(.85); opacity: 0; } }
.panel h2 { font-size: 28px; font-weight: 900; font-style: italic; text-align: center; display: flex; align-items: center; justify-content: center; gap: 10px; }
.panel p { text-align: center; opacity: .85; }
.h-icon { width: 28px; height: 28px; }
.close-btn { position: absolute; right: 12px; top: 12px; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.1); padding: 10px; z-index: 2; }
.close-btn img { width: 100%; height: 100%; }
.row { display: flex; gap: 12px; }
.row .btn { flex: 1; }

.panel.wide.modes-panel { width: min(96vw, 760px); }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mode { --acc: #4aa3ff; position: relative; text-align: left; padding: 0; border-radius: 16px; overflow: hidden; background: linear-gradient(180deg, rgba(14,28,58,.95), rgba(8,16,36,.98)); border: 1px solid rgba(255,255,255,.12); display: flex; flex-direction: column; transition: transform .15s, border-color .15s, box-shadow .15s; box-shadow: 0 8px 20px rgba(0,0,0,.35); animation: modeIn .45s cubic-bezier(.3,1.3,.5,1) both; }
.mode:nth-child(2) { animation-delay: .06s; } .mode:nth-child(3) { animation-delay: .12s; } .mode:nth-child(4) { animation-delay: .18s; }
@keyframes modeIn { from { opacity: 0; transform: translateY(16px) scale(.96); } }
.mode:hover, .mode:focus-visible { transform: translateY(-3px); border-color: var(--acc); box-shadow: 0 12px 28px rgba(0,0,0,.45), 0 0 0 1px var(--acc), 0 0 24px color-mix(in srgb, var(--acc) 45%, transparent); }
.mode:active { transform: translateY(0) scale(.98); }
.m-oneway { --acc: #ff9a3c; } .m-twoway { --acc: #ff4fa0; } .m-trial { --acc: #33e0c8; } .m-mission { --acc: #ffc21a; }
.mode-art { position: relative; aspect-ratio: 300 / 132; overflow: hidden; }
.mode-art svg { display: block; width: 100%; height: 100%; }
.mode-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(8,16,36,.95)); pointer-events: none; }
.mode-tag { position: absolute; top: 10px; left: 10px; z-index: 1; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; background: rgba(0,0,0,.55); color: #fff; border: 1px solid rgba(255,255,255,.25); backdrop-filter: blur(4px); }
.mode-tag.hot { background: linear-gradient(90deg, #ff3d7f, #ff8a3c); border-color: transparent; }
.mode-tag.gold { background: linear-gradient(90deg, #ffd23f, #ff8f00); color: #2b1600; border-color: transparent; }
.mode-info { position: relative; padding: 4px 16px 14px; display: flex; flex-direction: column; gap: 5px; margin-top: -14px; z-index: 1; }
.mode-info b { font-size: 19px; font-style: italic; font-weight: 900; text-shadow: 0 2px 6px rgba(0,0,0,.6); }
.mode-info b i { color: var(--acc); }
.mode-info > span { font-size: 13px; opacity: .8; line-height: 1.35; padding-right: 34px; }
.mode-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 3px; }
.mode-meta em { font-style: normal; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; background: rgba(255,255,255,.08); color: color-mix(in srgb, var(--acc) 70%, #fff); }
.mode-go { position: absolute; right: 12px; bottom: 14px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 13px; background: var(--acc); color: #10131c; box-shadow: 0 0 14px color-mix(in srgb, var(--acc) 60%, transparent); transition: transform .15s; }
.mode:hover .mode-go { transform: scale(1.12) translateX(2px); }
/* illustration bits */
.mv-road { fill: url(#mvAsphalt); }
.mv-shoulder { fill: #d9dde3; opacity: .85; }
.mv-lanes line { stroke: #f4f4f4; stroke-width: 1.6; stroke-dasharray: 6 8; animation: mvLane .5s linear infinite; }
@keyframes mvLane { to { stroke-dashoffset: -14; } }
.mv-player { animation: mvBob .6s ease-in-out infinite alternate; }
@keyframes mvBob { to { transform: translateY(1.2px); } }
.mv-head { animation: mvFlick 1.4s ease-in-out infinite alternate; }
@keyframes mvFlick { from { opacity: .55; } to { opacity: 1; } }
.mv-sun { filter: drop-shadow(0 0 10px #ffd38a); }
.mv-hand { transform-origin: 0 0; animation: mvSpin 2s linear infinite; }
@keyframes mvSpin { to { transform: rotate(360deg); } }
.mv-rays { animation: mvRays 14s linear infinite; transform-box: view-box; }
@keyframes mvRays { from { transform: translate(150px, 62px) rotate(0); } to { transform: translate(150px, 62px) rotate(360deg); } }
.mv-coin { animation: mvFloat 1.8s ease-in-out infinite alternate; }
.mv-coin.c2 { animation-delay: -.6s; } .mv-coin.c3 { animation-delay: -1.1s; } .mv-coin.c4 { animation-delay: -.3s; }
@keyframes mvFloat { to { transform: translateY(-5px); } }
.mode:not(:hover) .mv-lanes line { animation-duration: 1.2s; }
@media (prefers-reduced-motion: reduce) { .mode, .mode * { animation: none !important; } }

.garage { justify-content: space-between; align-items: flex-end; pointer-events: none; }
.garage > * { pointer-events: auto; }
.garage-top { position: absolute; left: calc(12px + var(--safe-l)); top: calc(12px + var(--safe-t)); display: flex; gap: 10px; align-items: center; }
.garage-nav { position: absolute; left: calc(12px + var(--safe-l)); right: calc(380px + var(--safe-r)); top: 50%; display: flex; justify-content: space-between; transform: translateY(-50%); pointer-events: none; }
.garage-nav .icon-btn { pointer-events: auto; }
.garage-panel { margin-left: auto; width: min(360px, 94vw); max-height: calc(100vh - 20px); overflow-y: auto; padding: 18px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; touch-action: pan-y; }
.car-name { font-size: 28px; font-weight: 900; font-style: italic; }
.car-price { font-weight: 800; color: var(--accent); display: flex; align-items: center; gap: 6px; }
.car-price img { width: 20px; }
.stats { display: flex; flex-direction: column; gap: 6px; }
.stat { display: grid; grid-template-columns: 90px 1fr 34px; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; }
.stat .bar { height: 8px; }
.stat .fill { background: linear-gradient(90deg, #36d1ff, #ffcc00); }
.swatches { display: flex; gap: 8px; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 3px solid rgba(255,255,255,.3); }
.swatch.on { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }
.upgrades { display: flex; flex-direction: column; gap: 6px; }
.upg { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 10px; background: rgba(255,255,255,.06); font-size: 14px; font-weight: 700; }
.pips { display: flex; gap: 3px; }
.pips i { width: 10px; height: 14px; border-radius: 2px; background: rgba(255,255,255,.18); transform: skewX(-12deg); }
.pips i.on { background: var(--accent); }
.upg button { padding: 6px 10px; border-radius: 8px; background: #1e88ff; font-weight: 800; font-size: 13px; display: flex; align-items: center; gap: 4px; min-width: 76px; justify-content: center; }
.upg button img { width: 14px; }
.upg button:disabled { background: #444c58; opacity: .7; }

.mission-list { display: flex; flex-direction: column; gap: 8px; }
.mission { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.06); border: 1px solid transparent; }
.mission.active { border-color: var(--accent); }
.mission.done { opacity: .6; }
.mission b { font-size: 16px; }
.mission .rew { display: flex; align-items: center; gap: 4px; color: var(--accent); font-weight: 800; font-size: 14px; }
.mission .rew img { width: 16px; }
.mission button { grid-row: span 2; padding: 8px 14px; border-radius: 10px; background: #ff8f00; font-weight: 900; }
.mission button:disabled { background: #2e7d32; }

.set-group { margin-top: 6px; font-size: 12px; letter-spacing: 3px; color: #8fb4ff; font-weight: 800; text-transform: uppercase; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border-radius: 12px; background: rgba(255,255,255,.05); font-weight: 700; font-size: 15px; }
.set-row span { display: flex; align-items: center; gap: 8px; }
.set-row span img { width: 20px; height: 20px; }
.toggle { position: relative; width: 56px; height: 30px; border-radius: 16px; background: #2b3444; flex: none; transition: background .2s; }
.toggle::after { content: ''; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #9aa6c0; transition: transform .2s, background .2s; }
.toggle.on { background: #1e88ff; }
.toggle.on::after { transform: translateX(26px); background: #fff; }
input[type=range] { width: 45%; accent-color: var(--accent); touch-action: pan-x; }
.seg { display: flex; background: #1a2232; border-radius: 10px; padding: 3px; flex-wrap: wrap; }
.seg button { padding: 5px 9px; border-radius: 8px; font-size: 13px; font-weight: 800; color: #9aa6c0; }
.seg button.on { background: var(--accent); color: #111; }

.over-score { text-align: center; }
.over-score .ol { display: block; font-size: 12px; letter-spacing: 3px; color: #8fb4ff; font-weight: 800; }
.over-score b { font-size: 56px; font-style: italic; font-weight: 900; line-height: 1; }
.over-score .new { display: block; color: var(--accent); font-weight: 900; font-style: italic; animation: blink2 .8s infinite; }
@keyframes blink2 { 50% { opacity: .4; } }
.over-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.over-grid div { padding: 10px 6px; border-radius: 12px; background: rgba(255,255,255,.06); text-align: center; }
.over-grid b { display: block; font-size: 20px; font-style: italic; }
.over-grid span { font-size: 11px; letter-spacing: 1px; color: #8fb4ff; font-weight: 700; text-transform: uppercase; }
.earned { display: flex; align-items: center; justify-content: center; gap: 6px; font-weight: 900; font-size: 20px; color: var(--accent); }
.earned img { width: 24px; }

.toast { position: fixed; left: 50%; top: calc(70px + var(--safe-t)); z-index: 60; transform: translate(-50%, -12px); opacity: 0; transition: .3s; padding: 10px 20px; border-radius: 12px; background: rgba(8, 16, 34, .9); border: 1px solid var(--line); font-weight: 800; pointer-events: none; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.rotate-hint { position: fixed; left: 50%; bottom: calc(200px + var(--safe-b)); transform: translateX(-50%); z-index: 15; padding: 8px 14px; border-radius: 10px; background: rgba(8,16,34,.8); font-size: 13px; font-weight: 700; pointer-events: none; text-align: center; width: max-content; max-width: 90vw; }

/* ---------- portrait: keep the road clear ---------- */
@media (orientation: portrait) {
  .score { font-size: 28px; }
  .hud-tc { top: calc(62px + var(--safe-t)); left: 50%; }
  .chip { font-size: 14px; padding: 5px 9px; }
  .speedo { width: 118px; height: 118px; top: calc(100px + var(--safe-t)); right: calc(8px + var(--safe-r)); bottom: auto; }
  .digital { font-size: 24px; }
  .gear { width: 22px; height: 22px; font-size: 13px; top: 22%; }
  .nitro-wrap { bottom: -18px; left: -4px; right: -4px; }
  .nitro-wrap img { width: 18px; height: 18px; }
  .hud-bl { width: 150px; top: calc(100px + var(--safe-t)); bottom: auto; }
  body.touch .hud-bl { bottom: auto; }
  .ctl { width: 70px; height: 70px; }
  .ctl img { width: 32px; height: 32px; }
  .ctl-left { gap: 10px; left: calc(10px + var(--safe-l)); }
  .ctl-right { right: calc(10px + var(--safe-r)); gap: 8px; }
  .ctl-gas { width: 74px; height: 96px; }
  .ctl-brake { width: 62px; height: 62px; }
  .ctl-nitro { width: 58px; height: 58px; margin-bottom: 0; position: absolute; right: 0; bottom: 108px; }
  .modes { grid-template-columns: 1fr; }
  .mode { flex-direction: row; min-height: 96px; }
  .mode-art { width: 38%; height: auto; aspect-ratio: auto; flex: none; }
  .mode-art::after { background: linear-gradient(90deg, transparent 60%, rgba(8,16,36,.95)); }
  .mode-info { margin-top: 0; padding: 10px 12px; justify-content: center; }
  .mode-info b { font-size: 16px; }
  .mode-info > span { font-size: 12px; padding-right: 30px; }
  .mode-tag { font-size: 9px; top: 6px; left: 6px; padding: 3px 7px; }
  .mode-go { width: 28px; height: 28px; right: 10px; bottom: 50%; transform: translateY(50%); }
  .mode:hover .mode-go { transform: translateY(50%) scale(1.1); }
  .garage { align-items: flex-end; }
  .garage-panel { max-height: 56vh; width: 100%; }
  .garage-nav { right: calc(12px + var(--safe-r)); top: 28%; }
  .menu-side { align-self: center; }
  .menu { background: linear-gradient(0deg, rgba(5,15,35,.8), rgba(5,15,35,0) 60%); }
  .menu-top { flex-direction: column; align-items: center; }
  .over-grid { grid-template-columns: repeat(2, 1fr); }
  .popups { top: 30%; }
}
@media (max-height: 460px) {
  .speedo { width: 132px; height: 132px; }
  .digital { font-size: 26px; }
  .ctl { width: 70px; height: 70px; }
  .ctl-gas { width: 80px; height: 92px; }
  .ctl-right { right: calc(160px + var(--safe-r)); }
  .panel { padding: 14px; gap: 8px; }
  .panel h2 { font-size: 22px; }
  .btn { min-height: 44px; font-size: 17px; }
  .menu-side { gap: 8px; }
  .score { font-size: 30px; }
  body.touch .hud-bl { bottom: calc(108px + var(--safe-b)); }
  .over-score b { font-size: 40px; }
}

/* layered dialogs: settings and confirm open above the pause screen */
#scrSettings { z-index: 35; }
#scrConfirm { z-index: 40; }

/* phones held sideways: speedometer moves up so the driving buttons own the bottom corners */
@media (orientation: landscape) and (max-height: 520px) {
  body.touch .speedo { top: calc(66px + var(--safe-t)); bottom: auto; right: calc(10px + var(--safe-r)); width: 116px; height: 116px; }
  body.touch .speedo .digital { font-size: 22px; }
  body.touch .speedo .gear { width: 20px; height: 20px; font-size: 12px; }
  body.touch .nitro-wrap { bottom: -16px; }
  body.touch .ctl-right { right: calc(14px + var(--safe-r)); }
  body.touch .ctl-nitro { margin-bottom: 0; position: absolute; right: 0; bottom: 104px; }
}

/* crash: white impact flash, cracked screen and red vignette */
.crash-fx { position: fixed; inset: 0; pointer-events: none; opacity: 0; z-index: 2; }
.crash-fx::before { content: ''; position: absolute; inset: 0; background: url(assets/ui/crack.svg) center / cover no-repeat; filter: drop-shadow(0 0 2px rgba(0,0,0,.6)); }
.crash-fx::after { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 35%, rgba(120, 0, 0, .55) 100%); }
.crash-fx.on { opacity: 1; animation: crashFlash .6s ease-out; }
@keyframes crashFlash { 0% { opacity: 1; background: rgba(255,255,255,.9); } 25% { background: rgba(255,255,255,.35); } 100% { background: transparent; } }
.banner.crash { background: linear-gradient(90deg, #d50000, #ff3d00); font-size: 44px; padding: 12px 40px; letter-spacing: 2px; }

.chip.bump { animation: chipBump .35s ease; }
@keyframes chipBump { 40% { transform: scale(1.25); background: rgba(255, 190, 40, .45); } }

/* =========================================================
   Loading screen: sunset highway with the hypercar
   ========================================================= */
.screen.loading { padding: 0; overflow: hidden; background: #12081f; display: block; }
.ld-sky { position: absolute; inset: 0; background: linear-gradient(180deg, #1a0b3d 0%, #4b1c6e 28%, #b8366e 46%, #ff7a3d 56%, #ffb347 60%, #2a1238 60.5%, #0d0718 100%); }
.ld-sun { position: absolute; left: 50%; top: 60%; width: min(30vw, 300px); aspect-ratio: 1; transform: translate(-50%, -62%); border-radius: 50%;
  background: linear-gradient(180deg, #ffe58a, #ff8a3d 60%, #ff3d6e);
  -webkit-mask: linear-gradient(180deg, #000 52%, transparent 52% 56%, #000 56% 63%, transparent 63% 67%, #000 67% 73%, transparent 73% 78%, #000 78% 84%, transparent 84% 90%, #000 90%);
  mask: linear-gradient(180deg, #000 52%, transparent 52% 56%, #000 56% 63%, transparent 63% 67%, #000 67% 73%, transparent 73% 78%, #000 78% 84%, transparent 84% 90%, #000 90%);
  box-shadow: 0 0 120px rgba(255, 140, 60, .6); filter: drop-shadow(0 0 40px rgba(255, 120, 60, .7)); }
.ld-skyline { position: absolute; left: 0; right: 0; top: 34%; height: 26.5%; width: 100%; }
.ld-road { position: absolute; left: 0; right: 0; top: 60%; bottom: 0; perspective: 260px; perspective-origin: 50% 0; overflow: hidden; }
.ld-plane { position: absolute; left: 50%; top: 0; width: 520px; height: 2600px; margin-left: -260px; transform-origin: 50% 0; transform: rotateX(80deg);
  background: linear-gradient(90deg, #2a2d33 0 3%, #e9e9e4 3% 4.2%, #3a3e45 4.2% 95.8%, #e9e9e4 95.8% 97%, #2a2d33 97%); }
.ld-lines { position: absolute; inset: 0; background:
  repeating-linear-gradient(180deg, #f4f4ef 0 60px, transparent 60px 160px) 27% 0 / 8px 100% no-repeat,
  repeating-linear-gradient(180deg, #f4f4ef 0 60px, transparent 60px 160px) 50% 0 / 8px 100% no-repeat,
  repeating-linear-gradient(180deg, #f4f4ef 0 60px, transparent 60px 160px) 73% 0 / 8px 100% no-repeat;
  animation: ldRoad .28s linear infinite; }
.ld-studs { position: absolute; inset: 0; background:
  repeating-linear-gradient(180deg, #ffd36b 0 6px, transparent 6px 160px) 26% 80px / 10px 100% no-repeat,
  repeating-linear-gradient(180deg, #ffd36b 0 6px, transparent 6px 160px) 74% 80px / 10px 100% no-repeat;
  animation: ldRoad .28s linear infinite; filter: drop-shadow(0 0 6px #ffb347); }
@keyframes ldRoad { from { background-position-y: 0, 0, 0; } to { background-position-y: 160px, 160px, 160px; } }
.ld-streaks i { position: absolute; top: 50%; left: 50%; width: 2px; height: 30vh; background: linear-gradient(transparent, rgba(255, 255, 255, .7), transparent); transform-origin: 0 0; opacity: 0; animation: ldStreak 1.2s linear infinite; }
.ld-streaks i:nth-child(1) { transform: rotate(60deg) translateY(10vh); animation-delay: 0s; }
.ld-streaks i:nth-child(2) { transform: rotate(-60deg) translateY(10vh); animation-delay: .3s; }
.ld-streaks i:nth-child(3) { transform: rotate(75deg) translateY(10vh); animation-delay: .6s; }
.ld-streaks i:nth-child(4) { transform: rotate(-75deg) translateY(10vh); animation-delay: .9s; }
.ld-streaks i:nth-child(5) { transform: rotate(48deg) translateY(10vh); animation-delay: .15s; }
.ld-streaks i:nth-child(6) { transform: rotate(-48deg) translateY(10vh); animation-delay: .45s; }
.ld-streaks i:nth-child(7) { transform: rotate(85deg) translateY(10vh); animation-delay: .75s; }
.ld-streaks i:nth-child(8) { transform: rotate(-85deg) translateY(10vh); animation-delay: 1.05s; }
@keyframes ldStreak { 0% { opacity: 0; margin-top: 0; } 30% { opacity: .8; } 100% { opacity: 0; margin-top: 0; height: 45vh; } }
.ld-car { position: absolute; left: 50%; bottom: 7%; width: min(56vw, 400px); transform: translateX(-50%); animation: ldCar .9s ease-in-out infinite alternate; }
.ld-car img { position: relative; width: 100%; display: block; filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .6)); }
@keyframes ldCar { from { transform: translate(-51%, 0) rotate(-.6deg); } to { transform: translate(-49%, -3px) rotate(.6deg); } }
.ld-flame { position: absolute; top: 79%; width: 7%; height: 26%; border-radius: 50% 50% 40% 40%; background: radial-gradient(ellipse at 50% 15%, #fff 0 18%, #8fe1ff 30%, #2f7dff 60%, transparent 72%); filter: blur(1px) drop-shadow(0 0 12px #3aa0ff); transform-origin: 50% 0; animation: ldFlame .08s linear infinite alternate; }
.ld-flame.l { left: 41.5%; }
.ld-flame.r { left: 51.5%; }
@keyframes ldFlame { from { transform: scaleY(.85) scaleX(.95); opacity: .85; } to { transform: scaleY(1.15) scaleX(1.05); opacity: 1; } }
.ld-ui { position: absolute; left: 0; right: 0; top: 6%; display: flex; flex-direction: column; align-items: center; padding: 0 16px; }
.ld-logo { position: relative; overflow: hidden; padding: 4px 14px 10px; }
.ld-logo::after { content: ''; position: absolute; top: 0; bottom: 0; left: -40%; width: 16%; background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .45), transparent); transform: skewX(-18deg); mix-blend-mode: overlay; animation: ldShine 2.6s ease-in-out infinite; pointer-events: none; }
@keyframes ldShine { 0%, 55% { left: -40%; } 100% { left: 130%; } }
.ld-logo span { font-size: min(13vw, 88px); }
.ld-logo .l3 { font-size: min(7vw, 46px); }
.ld-sub { margin-top: 4px; font-weight: 800; font-style: italic; letter-spacing: .45em; font-size: min(3vw, 15px); color: #ffd9a8; text-shadow: 0 2px 8px rgba(0, 0, 0, .6); }
.ld-progress { margin-top: 22px; display: flex; align-items: center; gap: 12px; width: min(84vw, 420px); }
.ld-progress .loadbar { flex: 1; height: 16px; border-radius: 10px; background: rgba(10, 4, 20, .6); border: 1px solid rgba(255, 210, 150, .35); box-shadow: inset 0 2px 6px rgba(0, 0, 0, .5); }
.ld-progress .loadfill { border-radius: 10px; background: linear-gradient(90deg, #ffcc00, #ff6d00, #ff2d55); box-shadow: 0 0 14px rgba(255, 120, 40, .8); position: relative; overflow: hidden; }
.ld-progress .loadfill::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(-45deg, rgba(255, 255, 255, .25) 0 8px, transparent 8px 16px); animation: ldStripes .5s linear infinite; }
@keyframes ldStripes { to { background-position: 22px 0; } }
.ld-pct { min-width: 54px; text-align: right; font-weight: 900; font-style: italic; font-size: 22px; color: #fff; text-shadow: 0 2px 8px rgba(0, 0, 0, .6); }
.screen.loading .loadtext { margin-top: 8px; font-weight: 700; color: #fff1e0; text-shadow: 0 1px 2px rgba(0, 0, 0, .9), 0 2px 10px rgba(40, 0, 40, .8); }
.ld-tip { margin-top: 6px; font-size: 14px; color: rgba(255, 255, 255, .85); font-style: italic; text-shadow: 0 1px 2px rgba(0, 0, 0, .9), 0 2px 10px rgba(40, 0, 40, .8); transition: opacity .3s; min-height: 18px; text-align: center; }
@media (max-height: 460px) {
  .ld-ui { top: 3%; }
  .ld-logo span { font-size: min(9vw, 54px); }
  .ld-progress { margin-top: 10px; }
  .ld-car { width: min(34vw, 260px); bottom: 4%; }
  .ld-sun { width: min(22vw, 180px); }
}
@media (orientation: portrait) {
  .ld-sun { width: min(52vw, 260px); }
  .ld-car { width: min(78vw, 380px); bottom: 9%; }
  .ld-ui { top: 9%; }
}

/* ---- realistic loading backdrop: a cinematic render of the actual game ---- */
.ld-photo { position: absolute; inset: -3%; background: #2a1a12 url(assets/ui/loading-bg.jpg) 50% 60% / cover no-repeat;
  animation: ldZoom 14s ease-in-out infinite alternate, ldRumble .12s linear infinite; transform-origin: 30% 65%; }
@keyframes ldZoom { from { scale: 1; } to { scale: 1.09; } }
@keyframes ldRumble { 0% { translate: 0 0; } 25% { translate: .6px -.5px; } 50% { translate: -.5px .4px; } 75% { translate: .4px .6px; } 100% { translate: 0 0; } }
@media (orientation: portrait) { .ld-photo { background-image: url(assets/ui/loading-bg-portrait.jpg); background-position: 50% 70%; transform-origin: 50% 70%; } }
/* the road rushing past: soft streaks over the lower half */
.ld-rush { position: absolute; left: 0; right: 0; top: 55%; bottom: 0; mix-blend-mode: screen; opacity: .35; pointer-events: none;
  background: repeating-linear-gradient(100deg, transparent 0 40px, rgba(255, 220, 180, .25) 40px 42px, transparent 42px 120px);
  -webkit-mask: linear-gradient(transparent, #000 40%); mask: linear-gradient(transparent, #000 40%);
  animation: ldRush .35s linear infinite; }
@keyframes ldRush { to { background-position: 120px 0; } }
/* low sun glare and lens flare */
.ld-flare { position: absolute; left: 77%; top: 36%; width: 0; height: 0; pointer-events: none; mix-blend-mode: screen; }
.ld-flare::before { content: ''; position: absolute; left: -240px; top: -240px; width: 480px; height: 480px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 245, 210, .95) 0 6%, rgba(255, 190, 110, .45) 18%, rgba(255, 140, 60, 0) 60%); animation: ldGlare 3s ease-in-out infinite alternate; }
.ld-flare i { position: absolute; border-radius: 50%; background: radial-gradient(circle, rgba(255, 200, 140, .35), rgba(255, 200, 140, 0) 70%); }
.ld-flare i:nth-child(1) { left: -380px; top: 150px; width: 90px; height: 90px; }
.ld-flare i:nth-child(2) { left: -560px; top: 240px; width: 50px; height: 50px; background: radial-gradient(circle, rgba(140, 200, 255, .35), transparent 70%); }
.ld-flare i:nth-child(3) { left: -700px; top: 310px; width: 140px; height: 140px; }
@keyframes ldGlare { from { transform: scale(.94); opacity: .85; } to { transform: scale(1.06); opacity: 1; } }
@media (orientation: portrait) { .ld-flare { left: 82%; top: 27%; } .ld-flare::before { transform-origin: center; } .ld-flare i { display: none; } }
/* readability: dark sky band behind the logo, vignette around the edges */
.ld-shade { position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(10, 8, 20, .72) 0%, rgba(10, 8, 20, .35) 34%, rgba(10, 8, 20, 0) 52%),
              radial-gradient(ellipse at 50% 60%, transparent 55%, rgba(0, 0, 0, .55) 100%); }
.ld-streaks i { background: linear-gradient(transparent, rgba(255, 240, 220, .6), transparent); }
.screen.loading .ld-sub { color: #ffe6c7; }
@media (max-height: 460px) {
  .panel.wide.modes-panel { padding: 14px 18px; gap: 8px; }
  .modes-panel h2 { font-size: 22px; }
  .modes { gap: 10px; }
  .mode { flex-direction: row; min-height: 84px; }
  .mode-art { width: 36%; height: auto; aspect-ratio: auto; flex: none; }
  .mode-art::after { background: linear-gradient(90deg, transparent 60%, rgba(8,16,36,.95)); }
  .mode-tag { font-size: 9px; top: 6px; left: 6px; padding: 3px 7px; }
  .mode-info { padding: 8px 12px; margin-top: 0; gap: 3px; justify-content: center; }
  .mode-info > span { padding-right: 30px; }
  .mode-info b { font-size: 16px; }
  .mode-info > span { font-size: 12px; }
  .mode-meta { display: none; }
  .mode-go { width: 28px; height: 28px; right: 10px; bottom: 50%; transform: translateY(50%); }
  .mode:hover .mode-go { transform: translateY(50%) scale(1.1); }
}
