/* Neon Chase — UI styles. Canvas world is LTR; menus follow the language direction. */
:root {
  --teal: #2ee6c8;
  --teal-2: #7fffea;
  --pink: #ff3d9a;
  --gold: #ffe566;
  --red: #ff4a5c;
  --ink: #e8f2ff;
  --muted: #9ab0c8;
  --panel: rgba(8, 14, 30, .92);
  --line: rgba(0, 230, 200, .3);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
/* Gameplay surfaces swallow gestures; menu panels must still scroll on phones */
#game, #laneBtns, #laneBtns button { touch-action: none; }
.panel, .sheet { touch-action: pan-y; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #0a1830; font-family: Heebo, sans-serif; color: #fff; }
html[lang="ar"] body { font-family: Tajawal, Heebo, sans-serif; }
html[lang="ru"] body { font-family: Heebo, Roboto, "Segoe UI", system-ui, sans-serif; }
html[lang="ja"] body { font-family: Heebo, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Noto Sans CJK JP", "Yu Gothic UI", Meiryo, sans-serif; }
html[lang="ko"] body { font-family: Heebo, "Apple SD Gothic Neo", "Noto Sans KR", "Noto Sans CJK KR", "Malgun Gothic", sans-serif; }
html[lang="hi"] body { font-family: Heebo, "Noto Sans Devanagari", "Kohinoor Devanagari", "Nirmala UI", sans-serif; }
button { font-family: inherit; color: inherit; }

/* HUD + controls only exist during a run */
body:not(.in-run) #hud, body:not(.in-run) #laneBtns { opacity: 0; visibility: hidden; pointer-events: none; }
#hud, #laneBtns { transition: opacity .2s; }
body:has(#over:not(.hidden)) #laneBtns, body:has(#pause:not(.hidden)) #laneBtns, body:has(#levelDone:not(.hidden)) #laneBtns { opacity: 0; visibility: hidden; pointer-events: none; }
/* Numbers / "+50" / "×4" must read left-to-right even in Hebrew/Arabic */
#scoreBig, #streakChip, #floatFx, #combo, #coinN, #wanted, .score-hero, .grid b, .wallet b { direction: ltr; unicode-bidi: isolate; }

.cico {
  display: inline-block; width: 1em; height: 1em; border-radius: 50%; vertical-align: -0.15em;
  background: radial-gradient(circle at 35% 30%, #fff6b0 0 18%, #ffd23a 40%, #d99400 100%);
  box-shadow: inset 0 0 0 2px rgba(150,90,0,.55), 0 0 6px rgba(255,200,0,.5);
}

#game { display: block; width: 100%; height: 100%; direction: ltr; }
#vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background:
    radial-gradient(ellipse at 50% 35%, transparent 55%, rgba(0,10,30,.18) 100%),
    linear-gradient(180deg, rgba(40,80,140,.08) 0%, transparent 25%, transparent 80%, rgba(0,0,20,.15) 100%);
  transition: box-shadow .2s;
}
#vignette.danger { box-shadow: inset 0 0 80px rgba(255,20,40,.45), inset 0 0 160px rgba(255,0,40,.2); }
#speedLines {
  position: absolute; inset: 0; pointer-events: none; z-index: 1; opacity: 0;
  background:
    repeating-linear-gradient(90deg, transparent 0, transparent 46%, rgba(0,255,220,.1) 49%, transparent 52%, transparent 100%),
    repeating-linear-gradient(0deg, transparent 0, transparent 8px, rgba(255,255,255,.03) 9px, transparent 10px);
  background-size: 36px 100%, 100% 20px;
  transition: opacity .12s; mix-blend-mode: screen;
}
#speedLines.on { opacity: 1; animation: speedRush .07s linear infinite; }
@keyframes speedRush { to { background-position: 36px 0, 0 20px; } }
#hitFlash {
  position: absolute; inset: 0; pointer-events: none; z-index: 2; opacity: 0;
  background:
    radial-gradient(circle at 50% 50%, rgba(255,255,220,.7), transparent 22%),
    radial-gradient(circle at 50% 58%, rgba(255,60,10,.7), transparent 48%),
    rgba(40,0,0,.25);
  transition: opacity .04s;
}
#hitFlash.on { opacity: 1; }
#lightning { position: absolute; inset: 0; pointer-events: none; z-index: 2; background: #dfe9ff; opacity: 0; }
#lightning.on { animation: bolt .5s ease-out; }
@keyframes bolt { 0% { opacity: .55; } 12% { opacity: .05; } 22% { opacity: .4; } 100% { opacity: 0; } }

#ui { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
html[dir="rtl"] #ui { direction: rtl; }
html[dir="ltr"] #ui { direction: ltr; }
#ui button, #ui a, #ui .hit { pointer-events: auto; }
#ui .hidden, .btn.hidden { display: none !important; }

/* —— HUD —— */
.hud-top {
  position: absolute; top: max(8px, var(--safe-t)); left: 12px; right: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 5;
}
.hud-top::before {
  content: ''; position: fixed; top: 0; left: 0; right: 0; height: calc(200px + var(--safe-t)); z-index: -1; pointer-events: none;
  background: linear-gradient(180deg, rgba(3,6,20,.62) 0%, rgba(3,6,20,.34) 55%, transparent 100%);
}
#scoreBig {
  font-family: Orbitron, sans-serif; font-weight: 900; font-size: clamp(22px, 7vw, 34px); letter-spacing: 1px;
  text-shadow: 0 0 24px rgba(0,255,220,.5), 0 4px 12px rgba(0,0,0,.8); line-height: 1;
}
#wanted {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
  background: rgba(0,0,0,.45); border: 1px solid rgba(255,229,102,.35);
  font-size: 14px; letter-spacing: 1px; color: var(--gold); text-shadow: 0 0 10px rgba(255,200,0,.6);
}
#wanted b { font-family: Orbitron, sans-serif; font-size: 12px; color: #fff; }
#wanted.pulse { animation: wantedPulse .9s ease-out; }
@keyframes wantedPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255,60,80,.9); }
  30% { transform: scale(1.35); box-shadow: 0 0 0 10px rgba(255,60,80,0); background: rgba(160,0,30,.7); }
  100% { transform: scale(1); }
}
#escapeMeter {
  position: relative; width: min(220px, 60vw); height: 16px; border-radius: 999px; overflow: hidden;
  background: rgba(0,0,0,.5); border: 1px solid rgba(125,255,200,.5); opacity: 0; transition: opacity .2s;
  direction: ltr;
}
#escapeMeter.on { opacity: 1; }
#escapeMeter i { position: absolute; inset: 0 auto 0 0; width: 0%; background: linear-gradient(90deg, #2ee6a0, #7dffc8); }
#escapeMeter span {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 900; letter-spacing: 1.5px; color: #fff; text-shadow: 0 1px 3px #000, 0 0 6px #000;
}
#spotted {
  position: absolute; top: 46%; left: 50%; transform: translateX(-50%); z-index: 6;
  padding: 6px 14px; border-radius: 999px; font-weight: 900; font-size: 14px;
  background: rgba(255,255,255,.9); color: #102; box-shadow: 0 0 24px rgba(220,235,255,.8);
  opacity: 0; transition: opacity .15s; pointer-events: none;
}
#spotted.on { opacity: 1; animation: blink .5s steps(2) infinite; }
@keyframes blink { 50% { opacity: .55; } }
.hud-row { display: flex; width: 100%; justify-content: space-between; align-items: flex-start; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 14px;
  background: linear-gradient(180deg, rgba(8,24,40,.85), rgba(4,12,24,.9));
  border: 1px solid rgba(0,220,200,.28); font-weight: 800; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.08); backdrop-filter: blur(10px);
}
.chip.streak { padding: 2px 10px; font-size: 12px; color: var(--gold); border-color: rgba(255,200,80,.45); font-family: Orbitron, sans-serif; }
.bars { display: flex; gap: 12px; width: min(420px, 100%); }
.stage-wrap, .threat-wrap { flex: 1 1 0; min-width: 0; }
.stage-label span, .threat-label span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score-col { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.hud-end { display: flex; gap: 8px; align-items: center; }
.stage-label, .threat-label {
  display: flex; justify-content: space-between; font-size: 11px; font-weight: 700;
  margin-bottom: 4px; text-shadow: 0 2px 6px #000; color: #a8e6ff;
}
.threat-label { color: #ffb0b8; }
.stage-bar, .threat-bar { border-radius: 999px; overflow: hidden; direction: ltr; background: rgba(0,0,0,.45); }
.stage-bar { height: 8px; border: 1px solid rgba(80,200,255,.35); }
.threat-bar { height: 12px; border: 1px solid rgba(255,80,80,.35); box-shadow: inset 0 2px 4px rgba(0,0,0,.5); }
.stage-bar > i, .threat-bar > i { display: block; height: 100%; width: 0%; transition: width .12s linear, background .2s; }
.stage-bar > i { background: linear-gradient(90deg, #2ee6c8, #44aaff); }
.threat-bar > i { background: #2bb88a; box-shadow: 0 0 12px rgba(255,60,60,.35); }
.pause-btn {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 14px; border: 1px solid rgba(0,220,200,.3);
  background: linear-gradient(180deg, rgba(8,24,40,.85), rgba(4,12,24,.9)); color: #fff; cursor: pointer;
  box-shadow: 0 8px 24px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.08);
}
.pause-btn svg { width: 18px; height: 18px; }

#toast {
  position: absolute; top: 30%; left: 12px; right: 12px; text-align: center;
  font-family: Orbitron, Heebo, sans-serif; font-weight: 800; font-size: clamp(17px, 5vw, 26px); opacity: 0;
  text-shadow: 0 0 20px rgba(255,60,60,.7), 0 4px 8px #000;
  transition: opacity .2s, transform .2s; transform: translateY(10px); pointer-events: none; color: #ff6b7a;
}
html[lang="ar"] #toast, html[lang="he"] #toast { font-family: Heebo, Tajawal, sans-serif; font-weight: 900; }
#toast.show { opacity: 1; transform: translateY(0); }
#toast.good { color: #7dffc8; text-shadow: 0 0 20px rgba(0,255,180,.6), 0 4px 8px #000; }
#toast.gold { color: var(--gold); text-shadow: 0 0 20px rgba(255,200,0,.6), 0 4px 8px #000; }
#combo {
  position: absolute; top: 38%; left: 0; right: 0; text-align: center;
  font-family: Orbitron, sans-serif; font-weight: 900; font-size: clamp(26px, 8vw, 44px); color: var(--gold);
  text-shadow: 0 0 28px rgba(255,200,0,.7), 0 4px 0 rgba(0,0,0,.4);
  opacity: 0; transform: scale(.75); transition: opacity .12s, transform .12s; pointer-events: none; letter-spacing: 2px;
}
#combo.show { opacity: 1; transform: scale(1); }
#floatFx { position: absolute; inset: 0; pointer-events: none; z-index: 6; overflow: hidden; }
#floatFx .pop {
  position: absolute; font-family: Orbitron, Heebo, sans-serif; font-weight: 900; font-size: clamp(16px, 4.5vw, 24px);
  animation: floatPop .75s ease-out forwards; text-shadow: 0 2px 8px #000, 0 0 16px currentColor; white-space: nowrap;
}
#floatFx .pop.gold { color: var(--gold); }
#floatFx .pop.good { color: #7dffc8; }
#floatFx .pop.nitro { color: #ffb84d; }
#floatFx .pop.big { font-size: clamp(22px, 6vw, 34px); }
@keyframes floatPop {
  0% { opacity: 1; transform: translate(-50%, 0) scale(.7); }
  40% { opacity: 1; transform: translate(-50%, -28px) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -70px) scale(.95); }
}

/* level-up banner */
#banner {
  position: absolute; top: 22%; left: 50%; transform: translate(-50%, 0); z-index: 6; text-align: center;
  padding: 12px 26px; border-radius: 16px; pointer-events: none; opacity: 0; white-space: nowrap;
  background: linear-gradient(90deg, rgba(0,0,0,0), rgba(5,10,30,.8) 20%, rgba(5,10,30,.8) 80%, rgba(0,0,0,0));
}
#banner b { display: block; font-family: Orbitron, Heebo, sans-serif; font-size: clamp(20px, 6vw, 30px); color: #fff; text-shadow: 0 0 18px var(--teal); }
#banner span { display: block; font-weight: 800; font-size: 14px; color: var(--gold); margin-top: 2px; }
#banner.show { animation: banner 2.6s ease-out forwards; }
@keyframes banner {
  0% { opacity: 0; transform: translate(-50%, -12px) scale(.9); }
  10% { opacity: 1; transform: translate(-50%, 0) scale(1.03); }
  80% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -8px); }
}

/* tutorial coach */
#coach {
  position: absolute; left: 50%; bottom: calc(110px + var(--safe-b)); transform: translateX(-50%); z-index: 7;
  display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-radius: 18px;
  background: rgba(5,12,28,.88); border: 1px solid rgba(46,230,200,.55); box-shadow: 0 0 30px rgba(46,230,200,.25);
  font-weight: 800; font-size: 16px; max-width: 92vw; opacity: 0; transition: opacity .25s; pointer-events: none;
}
#coach.on { opacity: 1; }
.coach-ico { font-size: 28px; animation: nudge 1s ease-in-out infinite; direction: ltr; }
@keyframes nudge { 50% { transform: translateX(var(--nudge, 0)); } }

/* —— Lane controls (physical LTR placement) —— */
#laneBtns { position: absolute; inset: 0; pointer-events: none; z-index: 3; direction: ltr; }
#laneBtns button {
  pointer-events: auto; position: absolute; width: 56px; height: 56px; border-radius: 16px;
  border: 1.5px solid rgba(0,255,220,.28); background: rgba(6,16,28,.42);
  color: rgba(127,255,234,.85); font-size: 22px; font-weight: 900; cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,.25); font-family: Orbitron, sans-serif;
  bottom: max(12px, var(--safe-b)); opacity: 0.55; transition: opacity .15s, background .15s, transform .1s;
}
#laneBtns button:active { transform: scale(.9); opacity: 1; background: rgba(0,70,80,.75); }
#btnLeft { left: max(14px, env(safe-area-inset-left)) !important; }
#btnRight { right: max(14px, env(safe-area-inset-right)) !important; }
#laneBtns #btnNitro {
  left: 50%; transform: translateX(-50%); width: 64px; height: 64px; font-size: 26px; color: #ffb84d;
  border-color: rgba(255,160,40,.4); background: rgba(40,22,4,.45); bottom: max(14px, calc(var(--safe-b) + 2px));
}
#laneBtns #btnNitro:active { transform: translateX(-50%) scale(.9); opacity: 1; }
#laneBtns #btnNitro.cd {
  opacity: .45; color: rgba(255,184,77,.5);
  background: conic-gradient(rgba(255,160,40,.35) calc(var(--cd, 0) * 1turn), transparent 0) border-box, rgba(40,22,4,.45);
}
#laneBtns #btnNitro.ready { opacity: .9; box-shadow: 0 0 16px rgba(255,160,40,.45); }
#laneBtns #btnNitro.coach { opacity: 1; animation: ring 1s ease-in-out infinite; }
@keyframes ring { 50% { box-shadow: 0 0 0 10px rgba(255,160,40,.25), 0 0 30px rgba(255,160,40,.8); } }

#pwrIcons { display: flex; gap: 8px; justify-content: center; pointer-events: none; }
.pwr {
  display: none; align-items: center; gap: 4px; padding: 3px 10px 3px 6px; border-radius: 999px;
  font-size: 12px; font-weight: 800; background: rgba(0,0,0,.5); border: 1px solid currentColor; box-shadow: 0 0 12px currentColor;
}
.pwr.on { display: inline-flex; animation: popIn .2s ease-out; }
.pwr .pico { display: block; width: 18px; height: 18px; line-height: 18px; font-size: 15px; text-align: center; }
.pwr.magnet .pico::before { content: '\1F9F2'; }
.pwr.shield .pico::before { content: '\1F6E1\FE0F'; }
.pwr.nitro .pico::before { content: '\26A1'; }
.pwr.magnet { color: #7ec8ff; }
.pwr.shield { color: #7dffc8; }
.pwr.nitro { color: #ffb84d; }

#mirror {
  position: relative; width: min(200px, 54vw); height: 84px; flex-shrink: 0; border-radius: 16px;
  border: 3px solid rgba(210,225,255,.85); background: #02060f;
  box-shadow: 0 12px 32px rgba(0,0,0,.6), inset 0 0 0 1px rgba(255,255,255,.12), inset 0 0 28px rgba(0,0,0,.5);
  overflow: hidden; pointer-events: none; z-index: 4; opacity: 0; transition: opacity .2s, border-color .15s, box-shadow .15s;
}
#mirror.on { opacity: 1; }
#mirror .m-label {
  position: absolute; top: 5px; left: 0; right: 0; text-align: center; font-size: 9px; font-weight: 800;
  letter-spacing: 1.5px; color: rgba(230,240,255,.85); font-family: Orbitron, sans-serif; z-index: 2; text-shadow: 0 1px 4px #000;
}
#mirror canvas { display: block; width: 100%; height: 100%; transform: scaleX(-1); }
#mirror .m-flash { position: absolute; inset: 0; z-index: 1; mix-blend-mode: screen; opacity: 0; transition: opacity .05s; }
#mirror.flash-r .m-flash { opacity: 1; background: radial-gradient(circle at 32% 42%, rgba(255,30,70,.55), transparent 58%); }
#mirror.flash-b .m-flash { opacity: 1; background: radial-gradient(circle at 68% 42%, rgba(50,140,255,.55), transparent 58%); }
#mirror.danger { border-color: rgba(255,70,90,.95); box-shadow: 0 12px 32px rgba(0,0,0,.6), 0 0 22px rgba(255,40,60,.45); }

/* —— Main menu (full screen, transparent: the 3D garage shot is the background) —— */
.screen {
  position: absolute; inset: 0; z-index: 8; display: flex; flex-direction: column; justify-content: space-between;
  padding: calc(14px + var(--safe-t)) 16px calc(18px + var(--safe-b)); pointer-events: none;
  background: linear-gradient(180deg, rgba(5,8,25,.65) 0%, transparent 26%, transparent 52%, rgba(5,8,25,.88) 82%);
}
.screen > * { pointer-events: auto; }
.screen.hidden { display: none; }
.menu-top { display: flex; justify-content: space-between; align-items: center; }
.wallet {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  background: rgba(0,0,0,.5); border: 1px solid rgba(255,200,80,.4); font-weight: 900; font-size: 17px; color: var(--gold);
}
.wallet.small { font-size: 14px; padding: 6px 12px; }
.icon-btn {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; border: 1px solid var(--line);
  background: rgba(0,0,0,.45); font-size: 20px; cursor: pointer; color: var(--teal-2); transition: transform .1s, background .15s;
}
.icon-btn:active { transform: scale(.92); background: rgba(0,90,80,.5); }
.icon-btn svg { width: 22px; height: 22px; }
.logo { text-align: center; margin-top: -4vh; pointer-events: none; }
.logo-kicker { font-family: Orbitron, sans-serif; font-size: 12px; letter-spacing: 6px; color: var(--teal-2); opacity: .85; }
.logo h1 {
  font-family: Orbitron, sans-serif; font-weight: 900; font-size: clamp(44px, 15vw, 76px); line-height: .95; letter-spacing: 2px;
  background: linear-gradient(180deg, #fff 10%, #7fffea 50%, #ff4fd8 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 18px rgba(46,230,200,.45)) drop-shadow(0 6px 0 rgba(0,0,0,.35));
  direction: ltr;
}
.menu-bottom { width: min(420px, 100%); margin: 0 auto; text-align: center; }
.menu-best { font-size: 13px; color: var(--muted); margin-bottom: 8px; font-weight: 700; }
.menu-best b { color: #fff; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 12px 6px 11px;
  border-radius: 18px; border: 1px solid var(--line); font-weight: 800; font-size: 14px; line-height: 1.15; cursor: pointer;
  background: linear-gradient(180deg, rgba(14,28,56,.82), rgba(6,12,28,.88));
  box-shadow: 0 10px 26px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.07);
  transition: transform .1s, border-color .15s;
}
.tile:active { transform: scale(.96); border-color: rgba(46,230,200,.7); }
.t-ico {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px;
  color: var(--tc, var(--teal-2)); background: color-mix(in srgb, var(--tc, #2ee6c8) 14%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tc, #2ee6c8) 35%, transparent), 0 0 18px color-mix(in srgb, var(--tc, #2ee6c8) 22%, transparent);
}
.t-ico svg { width: 24px; height: 24px; filter: drop-shadow(0 0 4px currentColor); }
#btnDaily { --tc: #ffd84a; }
#btnGarage { --tc: #4fe8ff; }
#btnMissions { --tc: #ff5fb4; }
.badge {
  position: absolute; top: -6px; inset-inline-end: -4px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: var(--red); color: #fff; font-style: normal; font-size: 12px; font-weight: 900; line-height: 22px;
  box-shadow: 0 0 12px rgba(255,60,80,.7);
}
.dot { position: absolute; top: 6px; inset-inline-end: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 10px var(--gold); }
.link-btn { background: none; border: none; color: var(--muted); font-weight: 700; font-size: 14px; margin-top: 12px; text-decoration: underline; cursor: pointer; }
.link-btn.danger { color: #ff8a96; }

/* —— Bottom sheets (garage / missions): the car stays visible above —— */
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 9; pointer-events: auto;
  max-height: 64dvh; overflow-y: auto; overscroll-behavior: contain;
  padding: 14px 16px calc(16px + var(--safe-b)); border-radius: 24px 24px 0 0;
  background: linear-gradient(180deg, #0c1530, #060a1a); border-top: 1px solid var(--line);
  box-shadow: 0 -20px 50px rgba(0,0,0,.5); animation: sheetUp .28s cubic-bezier(.2,.8,.2,1);
}
.sheet.hidden { display: none; }
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.sheet-head h2 { font-size: 20px; font-weight: 900; flex: 1; text-align: center; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; padding: 4px; border-radius: 14px; background: rgba(255,255,255,.05); }
.tab { flex: 1; padding: 10px; border: none; border-radius: 10px; background: transparent; font-weight: 800; font-size: 15px; color: var(--muted); cursor: pointer; }
.tab.on { background: rgba(46,230,200,.18); color: var(--teal-2); }
.car-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.arrow { width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line); background: rgba(0,0,0,.4); font-size: 28px; line-height: 1; cursor: pointer; }
html[dir="rtl"] .arrow { transform: scaleX(-1); }
.car-name { text-align: center; }
.car-name b { display: block; font-family: Orbitron, Heebo, sans-serif; font-size: 22px; letter-spacing: 1px; }
.car-name .tag {
  display: inline-block; margin-top: 4px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 800;
  color: var(--muted); background: rgba(255,255,255,.07);
}
.car-name .tag.on { color: var(--teal-2); background: rgba(46,230,200,.14); }
.car-dots { display: flex; justify-content: center; gap: 5px; margin-top: 7px; direction: ltr; }
html[dir="rtl"] .car-dots { direction: rtl; }
.car-dots i { width: 6px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.22); transition: width .2s, background .2s; }
.car-dots i.lock { background: rgba(255,255,255,.1); }
.car-dots i.on { width: 18px; background: var(--teal); box-shadow: 0 0 8px rgba(46,230,200,.6); }
.car-desc { text-align: center; font-size: 13px; font-weight: 700; color: #b9cce0; margin: 0 0 10px; min-height: 1.4em; }
.stats { display: grid; gap: 7px; margin: 6px 0 12px; }
.stat-row { display: grid; grid-template-columns: 80px 1fr; align-items: center; gap: 10px; font-size: 13px; font-weight: 700; color: var(--muted); }
.pips { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; direction: ltr; }
.pips i { height: 8px; border-radius: 4px; background: rgba(255,255,255,.1); }
.pips i.on { background: linear-gradient(90deg, var(--teal), #44aaff); box-shadow: 0 0 8px rgba(46,230,200,.5); }
.paints { display: flex; justify-content: center; gap: 12px; margin-bottom: 10px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255,255,255,.25); cursor: pointer; }
.swatch.on { border-color: #fff; box-shadow: 0 0 14px rgba(255,255,255,.6); }
.btn .cico { margin-inline-start: 4px; }
.btn.locked { background: rgba(255,255,255,.08); color: var(--muted); box-shadow: none; }
.up-row { display: grid; grid-template-columns: 36px 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,.06); }
.up-ico { font-size: 26px; text-align: center; }
.up-txt b { display: block; font-size: 15px; }
.up-txt small { display: block; font-size: 12px; color: var(--muted); margin: 2px 0 6px; }
.btn.mini { width: auto; margin: 0; padding: 9px 12px; font-size: 14px; white-space: nowrap; }

.mission {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center;
  padding: 12px; margin-bottom: 10px; border-radius: 16px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08);
}
.mission.done { border-color: rgba(255,229,102,.6); background: rgba(255,229,102,.08); }
.mission p { font-weight: 800; font-size: 15px; }
.mission .reward { font-weight: 900; color: var(--gold); white-space: nowrap; }
.mbar { grid-column: 1 / -1; height: 8px; border-radius: 999px; background: rgba(0,0,0,.4); overflow: hidden; direction: ltr; }
.mbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--gold)); }
.mprog { font-size: 12px; color: var(--muted); font-weight: 700; }
.sub.small { font-size: 12px; color: var(--muted); text-align: center; margin-top: 4px; }

/* —— Modal overlays —— */
/* level complete */
.ld-badge {
  display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 10px; border-radius: 50%;
  color: #041410; background: linear-gradient(180deg, #7fffea, #2ee6c8);
  box-shadow: 0 0 0 6px rgba(46,230,200,.18), 0 0 36px rgba(46,230,200,.55); animation: badgePop .5s cubic-bezier(.2,1.6,.4,1);
}
.ld-badge svg { width: 34px; height: 34px; }
@keyframes badgePop { from { transform: scale(.3); opacity: 0; } }
.ld-grid { margin-top: 12px; }
.ld-gift {
  display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; margin-bottom: 10px; border-radius: 14px;
  background: rgba(255,229,102,.1); border: 1px solid rgba(255,229,102,.45); animation: popIn .4s .3s backwards;
}
.ld-gift b { color: var(--gold); font-size: 16px; }
.ld-gift span { color: var(--muted); font-size: 12px; font-weight: 700; }
.ld-next { color: #cfe6ff; font-weight: 800; font-size: 14px; margin: 4px 0 2px; }
.overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 20%, rgba(60,200,220,.22), transparent 50%), rgba(6,10,26,.74);
  backdrop-filter: blur(4px); z-index: 10; pointer-events: auto;
}
.overlay.hidden { display: none; }
.overlay:not(.hidden) { animation: fadeIn .2s ease-out; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: translateY(18px) scale(.94); } to { opacity: 1; transform: none; } }
.panel {
  width: min(400px, 92vw); padding: 24px 22px 20px; border-radius: 22px;
  max-height: calc(100dvh - 28px - var(--safe-t) - var(--safe-b)); overflow-y: auto; overscroll-behavior: contain;
  background: linear-gradient(155deg, rgba(0,70,70,.45), var(--panel) 50%);
  border: 1px solid rgba(0,230,200,.35); box-shadow: 0 28px 60px rgba(0,0,0,.55), 0 0 40px rgba(0,200,180,.08);
  text-align: center; animation: popIn .3s cubic-bezier(.2,.8,.2,1);
}
.panel h1 {
  font-family: Orbitron, Heebo, sans-serif; font-weight: 900; font-size: clamp(30px, 9vw, 40px);
  background: linear-gradient(180deg, #fff, #7fffea); -webkit-background-clip: text; background-clip: text; color: transparent;
  margin-bottom: 6px; letter-spacing: 1px;
}
.panel h1.h-sm { font-size: 24px; }
.panel h1.bust { background: linear-gradient(180deg, #fff, #ff5060); -webkit-background-clip: text; background-clip: text; }
.panel .sub { color: var(--muted); font-size: 14px; margin-bottom: 16px; line-height: 1.5; }
.panel .stat { font-size: 15px; margin: 8px 0 14px; color: #cde; }
.panel .stat b { color: var(--gold); }
.kicker { font-family: Orbitron, sans-serif; font-size: 12px; letter-spacing: 3px; color: var(--teal-2); margin-bottom: 4px; }
.newbest {
  display: inline-block; padding: 4px 12px; border-radius: 999px; font-weight: 900; font-size: 13px;
  background: linear-gradient(90deg, #ffd23a, #ff8a00); color: #2a1400; margin-bottom: 4px; animation: popIn .4s;
}
.score-hero { font-family: Orbitron, sans-serif; font-weight: 900; font-size: 38px; color: #fff; text-shadow: 0 0 20px rgba(46,230,200,.5); margin: 4px 0 12px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.grid > div {
  padding: 9px 4px 8px; border-radius: 14px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.06);
  animation: popIn .35s cubic-bezier(.2,.8,.2,1) backwards;
}
.grid > div:nth-child(2) { animation-delay: .05s; }
.grid > div:nth-child(3) { animation-delay: .1s; }
.grid > div:nth-child(4) { animation-delay: .15s; }
.grid > div:nth-child(5) { animation-delay: .2s; }
.grid > div:nth-child(6) { animation-delay: .25s; }
#btnRevive:not(.hidden) { animation: revivePulse 1.6s ease-in-out infinite; }
@keyframes revivePulse { 50% { box-shadow: 0 8px 24px rgba(255,140,0,.35), 0 0 0 5px rgba(255,170,60,.18); } }
.grid b { display: block; font-size: 17px; font-weight: 900; color: var(--gold); }
.grid span { font-size: 11px; color: var(--muted); font-weight: 700; }
#overMissions .mdone {
  display: flex; justify-content: space-between; gap: 8px; padding: 8px 12px; margin-bottom: 6px; border-radius: 12px;
  background: rgba(255,229,102,.1); border: 1px solid rgba(255,229,102,.4); font-size: 13px; font-weight: 800; color: var(--gold);
}
.btn {
  display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; margin: 8px 0; padding: 14px 18px;
  border: none; border-radius: 14px; font-weight: 800; font-size: 17px; cursor: pointer; transition: transform .1s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .6; }
.btn.primary {
  background: linear-gradient(180deg, #3ff0d2, #0a9a80); color: #041410;
  box-shadow: 0 8px 24px rgba(0,200,160,.35), inset 0 1px 0 rgba(255,255,255,.45);
}
.btn.primary:disabled { opacity: 1; background: rgba(46,230,200,.16); color: var(--teal-2); box-shadow: none; }
.btn.big { padding: 18px; font-size: 22px; font-family: Orbitron, Heebo, sans-serif; letter-spacing: 2px; border-radius: 18px; }
.btn.secondary { background: rgba(255,255,255,.08); color: #fff; border: 1px solid rgba(255,255,255,.2); }
.btn.revive { background: linear-gradient(180deg, #ffb84d, #e07010); color: #1a0c00; box-shadow: 0 8px 24px rgba(255,140,0,.35); }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
.set-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 2px; border-bottom: 1px solid rgba(255,255,255,.07); font-weight: 800; }
.set-row.col { flex-direction: column; align-items: stretch; gap: 10px; }
.toggle {
  position: relative; width: 52px; height: 30px; border-radius: 999px; border: none; background: rgba(255,255,255,.15); cursor: pointer;
  transition: background .2s;
}
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle.on { background: var(--teal); }
.toggle.on::after { transform: translateX(22px); }
html[dir="rtl"] .toggle::after { left: auto; right: 3px; }
html[dir="rtl"] .toggle.on::after { transform: translateX(-22px); }
.set-links { display: flex; flex-direction: column; align-items: center; gap: 2px; margin: 10px 0 6px; }
.set-links a { color: var(--teal-2); font-weight: 700; font-size: 14px; margin-top: 10px; }
.version { font-size: 11px; color: rgba(255,255,255,.35); margin-top: 6px; direction: ltr; }
.lang-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.lang-btn {
  min-width: 0; padding: 9px 6px; border-radius: 12px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.06); color: #cde; font-weight: 800; font-size: 14px;
}
.lang-btn.on { border-color: rgba(46,230,200,.7); background: rgba(0,120,100,.35); color: var(--teal-2); }
.howto { text-align: start; font-size: 14px; line-height: 1.6; color: #cde; margin: 12px 0 16px; padding-inline-start: 18px; }
.howto li { margin: 6px 0; }
.days { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.day {
  padding: 10px 4px; border-radius: 12px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08);
  font-size: 12px; font-weight: 800; color: var(--muted);
}
.day b { display: block; font-size: 15px; color: #fff; margin-top: 4px; }
.day.got { opacity: .45; }
.day.today { border-color: var(--gold); background: rgba(255,229,102,.12); color: var(--gold); box-shadow: 0 0 16px rgba(255,229,102,.3); }
.day.big { grid-column: span 2; }

#adGate { position: absolute; inset: 0; z-index: 20; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,.82); }
#adGate.on { display: flex; }
#adGate .ad-box { width: min(340px, 90vw); padding: 22px; border-radius: 18px; text-align: center; background: #121820; border: 1px solid rgba(255,255,255,.15); }
#adGate .ad-box h2 { font-size: 18px; margin-bottom: 8px; }
#adGate .ad-box p { color: var(--muted); font-size: 13px; }

@media (max-height: 560px) {
  #mirror { transform: scale(0.78); transform-origin: top center; margin-bottom: -18px; }
  .hud-top { gap: 3px; }
  .logo h1 { font-size: 40px; }
  .tiles .t-ico { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  #speedLines.on { animation: none; }
  .grid > div, #btnRevive:not(.hidden), .overlay:not(.hidden), .ld-badge, .ld-gift { animation: none; }
  .coach-ico, #spotted.on { animation: none; }
}
