/* Theory Drive — one dark game look, responsive from small phones to desktops.
   Layout: 3D canvas fills the screen; HUD pieces pin to the corners; touch devices
   (html.is-touch) get on-screen controls: steering on the left thumb, pedals on the right. */
:root {
  color-scheme: dark;
  --bg: #0b0e16;
  --ink: #f6f7fb;
  --glass: rgba(12, 16, 26, 0.62);
  --glass-strong: rgba(10, 13, 22, 0.9);
  --line: rgba(255, 255, 255, 0.14);
  --pink: #ff3d7f;
  --yellow: #ffd23f;
  --mint: #3ef0b0;
  --red: #ff4d4d;
  --blue: #4fd8ff;
  --font: "Rubik", "Segoe UI", "Arial Hebrew", Arial, sans-serif;
  /* safe areas (notches, home bars) */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --gut: 16px;
  /* touch control size scales with the short side of the screen */
  --ctl: clamp(54px, 13vmin, 86px);
  --minimap: 150px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; background: var(--bg); color: var(--ink);
  font-family: var(--font); -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
  -webkit-text-size-adjust: 100%;
}
button { font-family: inherit; cursor: pointer; }
button:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; transition: filter 0.35s; touch-action: none; }
body.slowmo #scene { filter: saturate(0.55) contrast(1.06); }
#vignette { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.35s;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.55) 100%); }
body.slowmo #vignette { opacity: 1; }
#flash { position: fixed; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(circle, rgba(255, 30, 50, 0.1), rgba(255, 30, 50, 0.55)); }
body.flash-bad #flash { animation: flash 0.7s ease-out; }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- loading ---------- */
#loading { position: fixed; inset: 0; display: grid; place-content: center; gap: 18px; text-align: center; padding: var(--gut);
  background: radial-gradient(circle at 50% 40%, #1b2236, #07090f); z-index: 50; transition: opacity 0.6s; }
#loading.hide { opacity: 0; pointer-events: none; }
.logo { font-weight: 900; letter-spacing: 0.06em; direction: ltr; font-size: clamp(34px, 9vw, 72px); line-height: 1; }
.logo b { color: var(--pink); }
.load-track { width: min(320px, 70vw); height: 6px; border-radius: 9px; background: rgba(255, 255, 255, 0.1); overflow: hidden; margin: 0 auto; }
#load-bar { height: 100%; background: var(--yellow); transform-origin: right; transform: scaleX(0); transition: transform 0.4s; }
#load-text { margin: 0; opacity: 0.75; }

/* ---------- HUD (desktop defaults) ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.4s; }
#hud.show { opacity: 1; }
.gps { position: absolute; top: calc(14px + var(--sat)); left: 50%; transform: translateX(-50%); max-width: calc(100% - 2 * var(--gut) - 2 * var(--minimap));
  display: flex; align-items: center; gap: 12px; padding: 8px 16px 8px 18px; border-radius: 16px;
  background: linear-gradient(135deg, rgba(22, 120, 80, 0.92), rgba(16, 90, 62, 0.92)); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); }
.gps-text { min-width: 0; }
#gps-icon svg { width: 40px; height: 40px; fill: #fff; transition: transform 0.3s; display: block; }
#gps-icon[data-turn="left"] svg { transform: rotate(-90deg); }
#gps-icon[data-turn="right"] svg { transform: rotate(90deg); }
#gps-dist { font-size: 26px; font-weight: 900; line-height: 1; }
#gps-label { font-size: 14px; opacity: 0.92; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.speed-box { position: absolute; bottom: calc(18px + var(--sab)); left: calc(var(--gut) + var(--sal)); display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 18px; background: var(--glass); backdrop-filter: blur(6px); direction: ltr; }
.limit { width: 46px; height: 46px; border-radius: 50%; background: #fff; border: 6px solid #c8102e; color: #111;
  display: grid; place-content: center; font-weight: 900; font-size: 17px; flex: none; }
.speed-read { text-align: center; min-width: 74px; }
#speed { font-size: 40px; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
#speed.over { color: var(--red); }
.speed-read small { font-size: 12px; opacity: 0.7; }
#gear { font-weight: 900; font-size: 20px; color: var(--mint); width: 26px; text-align: center; }

.right-col { position: absolute; top: calc(14px + var(--sat)); left: calc(var(--gut) + var(--sal)); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.score-box { background: var(--glass); padding: 6px 14px; border-radius: 12px; direction: ltr; }
.score-box small { display: block; font-size: 11px; opacity: 0.7; text-align: left; }
#score { font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; }
#minimap { width: var(--minimap); height: var(--minimap); border-radius: 50%; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4); }

.blinkers { position: absolute; bottom: calc(104px + var(--sab)); left: 50%; transform: translateX(-50%); display: flex; gap: 70px; font-size: 30px; color: rgba(255, 255, 255, 0.12); }
.blinkers .on { color: #29f07a; text-shadow: 0 0 14px #29f07a; }

#coach { position: absolute; top: calc(96px + var(--sat)); right: calc(var(--gut) + var(--sar)); width: min(380px, calc(100% - 2 * var(--gut) - var(--minimap) - 16px));
  padding: 12px 16px; border-radius: 16px; background: var(--glass-strong); border-right: 4px solid var(--yellow); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  opacity: 0; transform: translateX(30px); transition: opacity 0.35s, transform 0.35s; }
#coach.show { opacity: 1; transform: none; }
.coach-head { font-weight: 700; color: var(--yellow); margin-bottom: 6px; }
#coach-rule { font-size: 16px; line-height: 1.45; }
#coach-src { font-size: 11px; opacity: 0.55; margin-top: 6px; }

.buttons { position: absolute; bottom: calc(18px + var(--sab)); right: calc(var(--gut) + var(--sar)); display: flex; gap: 8px; pointer-events: auto; }
.buttons button { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--glass); color: var(--ink); font-size: 18px; display: grid; place-content: center; }
.keys-hint { position: absolute; bottom: calc(24px + var(--sab)); left: 50%; transform: translateX(-50%); font-size: 12px; opacity: 0.55; white-space: nowrap; }

#slowmo-tag { position: fixed; top: calc(92px + var(--sat)); left: 50%; transform: translateX(-50%); background: var(--yellow); color: #111;
  font-weight: 900; padding: 6px 16px; border-radius: 999px; opacity: 0; transition: opacity 0.3s; pointer-events: none; white-space: nowrap; }
body.slowmo #slowmo-tag { opacity: 1; }
#toast { position: fixed; top: 34%; left: 50%; transform: translate(-50%, 0); pointer-events: none; text-align: center;
  font-size: clamp(16px, 3.4vw, 26px); font-weight: 900; padding: 10px 22px; border-radius: 16px; background: var(--glass-strong); opacity: 0;
  width: max-content; max-width: calc(100% - 2 * var(--gut)); }
#toast.good { color: var(--mint); }
#toast.bad { color: var(--red); }
#toast.nav { color: #8fe3ff; font-size: clamp(14px, 2.6vw, 20px); top: auto; bottom: calc(120px + var(--sab)); }
#toast.show { animation: toast 2.4s ease-out; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 10px); } 12% { opacity: 1; transform: translate(-50%, 0); } 80% { opacity: 1; } 100% { opacity: 0; } }

/* next required stop + braking hint */
#stopbar { position: fixed; top: calc(96px + var(--sat)); left: 50%; transform: translate(-50%, -8px); width: min(320px, calc(100% - 2 * var(--gut)));
  padding: 8px 14px 10px; border-radius: 14px; background: var(--glass-strong); opacity: 0; transition: opacity 0.25s, transform 0.25s; pointer-events: none; }
#stopbar.show { opacity: 1; transform: translate(-50%, 0); }
.sb-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 14px; }
#stopbar-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#stopbar-dist { font-size: 22px; font-weight: 900; direction: ltr; white-space: nowrap; }
.sb-track { height: 8px; border-radius: 9px; background: rgba(255, 255, 255, 0.12); margin-top: 6px; overflow: hidden; }
#stopbar-fill { height: 100%; transform-origin: right; background: var(--yellow); transition: transform 0.15s; }
#stopbar.must { border: 2px solid var(--red); }
#stopbar.must #stopbar-fill { background: linear-gradient(90deg, var(--red), var(--yellow)); }
body.slowmo #stopbar { top: calc(140px + var(--sat)); }
#brake-hint { position: fixed; top: calc(168px + var(--sat)); left: 50%; transform: translateX(-50%); padding: 8px 16px; border-radius: 12px; max-width: calc(100% - 2 * var(--gut));
  background: rgba(200, 16, 46, 0.92); font-weight: 900; opacity: 0; transition: opacity 0.2s; pointer-events: none; text-align: center; }
#brake-hint.show { opacity: 1; animation: pulse 0.6s infinite alternate; }
@keyframes pulse { to { transform: translateX(-50%) scale(1.05); } }
#rotate-hint { display: none; }

/* ---------- touch controls ---------- */
#touch { display: none; }
html.is-touch #touch.show { display: block; }
#touch button { pointer-events: auto; border: 0; color: #fff; background: rgba(255, 255, 255, 0.16); backdrop-filter: blur(4px);
  touch-action: none; -webkit-touch-callout: none; display: grid; place-content: center; font-weight: 900; }
#touch button.pressed { background: rgba(255, 255, 255, 0.42); transform: scale(0.96); }
/* steering: left thumb */
.t-left { position: fixed; bottom: calc(18px + var(--sab)); left: calc(var(--gut) + var(--sal)); display: flex; gap: 12px; }
.t-left button { width: var(--ctl); height: var(--ctl); border-radius: 50%; font-size: calc(var(--ctl) * 0.36); }
/* blinkers, horn, reverse: above the steering buttons */
.t-mid { position: fixed; bottom: calc(46px + var(--ctl) + var(--sab)); left: calc(var(--gut) + var(--sal)); display: flex; gap: 8px; }
.t-mid button { width: calc(var(--ctl) * 0.6); height: calc(var(--ctl) * 0.6); border-radius: 50%; font-size: calc(var(--ctl) * 0.24); }
/* pedals: right thumb */
.t-right { position: fixed; bottom: calc(18px + var(--sab)); right: calc(var(--gut) + var(--sar)); display: flex; gap: 12px; align-items: flex-end; }
.pedal { width: calc(var(--ctl) * 0.95); border-radius: 16px; font-size: calc(var(--ctl) * 0.24); }
#touch .pedal.gas { height: calc(var(--ctl) * 1.55); background: rgba(62, 240, 176, 0.32); }
#touch .pedal.brake { height: calc(var(--ctl) * 1.15); background: rgba(255, 77, 77, 0.32); }
#touch .pedal.pressed { background: rgba(255, 255, 255, 0.45); }

/* touch layout: system buttons move to the top corner, speed sits between the thumbs */
html.is-touch .keys-hint { display: none; }
html.is-touch .buttons { top: calc(12px + var(--sat)); bottom: auto; right: calc(var(--gut) + var(--sar)); }
html.is-touch .buttons button { width: 40px; height: 40px; font-size: 16px; }
html.is-touch .score-box { display: none; }
html.is-touch .speed-box { left: 50%; transform: translateX(-50%); bottom: calc(14px + var(--sab)); padding: 6px 12px; gap: 8px; }
html.is-touch .limit { width: 36px; height: 36px; border-width: 5px; font-size: 13px; }
html.is-touch #speed { font-size: 30px; }
html.is-touch .speed-read { min-width: 56px; }
html.is-touch .blinkers { bottom: calc(80px + var(--sab)); gap: 120px; font-size: 24px; }
html.is-touch #toast.nav { bottom: calc(110px + var(--sab)); }
html.is-touch #coach { top: calc(64px + var(--sat)); }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  padding: calc(12px + var(--sat)) calc(var(--gut) + var(--sar)) calc(12px + var(--sab)) calc(var(--gut) + var(--sal));
  background: rgba(6, 8, 14, 0.55); backdrop-filter: blur(4px); z-index: 20; }
.overlay.show { display: flex; animation: pop 0.3s ease-out; }
@keyframes pop { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }
.panel { width: min(580px, 100%); max-height: 100%; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  background: var(--glass-strong); border-radius: 24px; padding: clamp(16px, 4vw, 24px); border: 1px solid rgba(255, 255, 255, 0.1); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  user-select: text; -webkit-user-select: text; }
.panel.small { width: min(340px, 100%); text-align: center; }
.panel h2 { margin: 0 0 8px; }
.menu-panel { text-align: center; }
.logo-he { font-size: clamp(18px, 4vw, 22px); font-weight: 700; color: var(--yellow); margin-top: 6px; }
.tagline { font-size: clamp(15px, 3.6vw, 17px); line-height: 1.5; margin: 14px auto 18px; opacity: 0.9; max-width: 46ch; text-wrap: balance; }
#levels { display: grid; gap: 10px; }
/* levels: quiet rows like route plates; a numbered plate, the text, an arrow */
.level { display: flex; align-items: center; gap: 14px; width: 100%; text-align: right; color: var(--ink); font: inherit; font-size: 18px;
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-height: 48px; cursor: pointer;
  background: rgba(255, 255, 255, 0.04); transition: border-color 0.15s, background 0.15s; }
.level:hover, .level:focus-visible { border-color: var(--yellow); background: rgba(255, 210, 63, 0.06); }
.lv-num { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 8px; background: var(--yellow); color: #14161c;
  font-family: Montserrat, var(--font); font-weight: 600; font-size: 20px; }
.lv-txt { flex: 1; min-width: 0; display: grid; gap: 2px; }
.lv-txt strong { font-weight: 700; }
.level small { font-size: 13px; opacity: 0.7; font-weight: 400; line-height: 1.4; }
.lv-go { flex: none; opacity: 0.45; font-size: 18px; transition: opacity 0.15s, transform 0.15s; }
.level:hover .lv-go { opacity: 1; color: var(--yellow); transform: translateX(-3px); }
.level.suggested { border-color: var(--yellow); }
/* how to drive: a clear, readable box on the menu */
.controls { margin-top: 16px; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04);
  display: grid; gap: 9px; font-size: 16px; text-align: right; }
.ctl-title { font-weight: 800; font-size: 18px; color: var(--yellow); }
.ctl-row { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px; line-height: 1.35; }
.ctl-row > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.ctl-keys { display: flex; gap: 6px; justify-content: flex-start; direction: ltr; }
.ctl-tip { font-size: 14px; opacity: 0.75; text-align: center; }
.controls .touch-help { display: none; }
html.is-touch .controls .key-help { display: none; }
html.is-touch .controls .touch-help { display: grid; }
html.is-touch .controls .ctl-tip.touch-help { display: block; }
.chip { display: inline-grid; place-items: center; min-width: 34px; height: 30px; padding: 0 8px; border-radius: 10px; font-style: normal; font-weight: 700;
  background: rgba(255, 255, 255, 0.16); font-size: 15px; }
.chip.go { background: rgba(62, 240, 176, 0.38); }
.chip.stop { background: rgba(255, 77, 77, 0.4); }
kbd { display: inline-grid; place-items: center; min-width: 34px; height: 30px; padding: 0 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.28); border-bottom-width: 3px; font-family: inherit; font-weight: 700; font-size: 15px; }
.source { font-size: 11px; opacity: 0.55; margin: 14px 0 0; line-height: 1.5; }
.seed { text-align: center; font-size: 13px; opacity: 0.6; margin: 4px 0 10px; }

.setting { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 14px 0 4px; font-size: 15px; }
.setting select { font-family: inherit; font-size: 15px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: #151a26; color: var(--ink); }

#card-verdict { font-size: clamp(20px, 5vw, 26px); font-weight: 900; }
#card-verdict.bad { color: var(--red); }
#card-verdict.tip { color: var(--yellow); }
#card-mode { margin: 6px 0 14px; font-size: 14px; opacity: 0.8; }
#card-question { margin: 0 0 12px; font-size: clamp(17px, 4.2vw, 20px); line-height: 1.4; text-wrap: balance; }
#card-img[hidden] { display: none; }
#card-img { display: block; max-width: 100%; max-height: 180px; margin: 0 auto 12px; border-radius: 12px; background: #fff; }
#card-answers { display: grid; gap: 8px; }
.answer { padding: 12px 14px; border-radius: 12px; font-size: clamp(15px, 3.8vw, 16px); line-height: 1.4; border: 2px solid var(--line); }
.answer.right { border-color: var(--mint); background: rgba(62, 240, 176, 0.18); font-weight: 500; }
.answer.right::before { content: "✓ "; color: var(--mint); font-weight: 900; }
.answer.dim { opacity: 0.45; }
#card-source { font-size: 12px; opacity: 0.6; margin: 14px 0 0; }
.cta, .ghost { width: 100%; border: 0; border-radius: 14px; padding: 14px 18px; font-size: clamp(16px, 4vw, 18px); font-weight: 700; margin-top: 14px; min-height: 48px; }
.cta { background: var(--yellow); color: #14161c; }
.cta:hover { filter: brightness(1.06); }
.ghost { background: transparent; color: var(--ink); border: 2px solid rgba(255, 255, 255, 0.25); margin-top: 10px; }
.link { background: none; border: 0; color: var(--ink); opacity: 0.7; text-decoration: underline; margin-top: 10px; width: 100%; font-size: 14px; min-height: 40px; }

.end-title { font-size: clamp(22px, 5.5vw, 28px); font-weight: 900; text-align: center; }
#end-score { font-size: clamp(40px, 11vw, 56px); font-weight: 900; color: var(--yellow); text-align: center; }
#end-sub { text-align: center; margin: 0 0 12px; }
#end-verdict { text-align: center; font-size: 20px; font-weight: 900; margin: 6px 0; }
#end-verdict.pass, #res-overall.pass { color: var(--mint); }
#end-verdict.fail, #res-overall.fail { color: var(--red); }
#end-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
#end-list li { padding: 8px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.06); display: flex; justify-content: space-between; gap: 8px; align-items: center; }
#end-list li span { min-width: 0; }
#end-list li.ok { border-right: 4px solid var(--mint); }
#end-list li.bad { border-right: 4px solid var(--red); }
#end-list button { border: 0; border-radius: 8px; background: rgba(255, 255, 255, 0.14); color: var(--ink); padding: 6px 12px; flex: none; min-height: 36px; }

/* ---------- theory exam ---------- */
.exam-panel { width: min(760px, 100%); }
.exam-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 16px; flex-wrap: wrap; }
#exam-timer { font-variant-numeric: tabular-nums; font-weight: 900; font-size: 22px; direction: ltr; }
#exam-timer.low { color: var(--red); }
#exam-nav { display: grid; grid-template-columns: repeat(15, 1fr); gap: 4px; margin: 12px 0; }
#exam-nav button { border: 0; border-radius: 6px; padding: 6px 0; font-size: 12px; background: rgba(255, 255, 255, 0.08); color: var(--ink); font-variant-numeric: tabular-nums; min-height: 30px; }
#exam-nav button.answered { background: rgba(79, 216, 255, 0.35); }
#exam-nav button.current { outline: 2px solid var(--yellow); }
#exam-tag { font-size: 12px; opacity: 0.7; margin-bottom: 6px; }
#exam-q { font-size: clamp(17px, 4.4vw, 20px); line-height: 1.45; margin: 0 0 12px; text-wrap: pretty; }
#exam-img[hidden] { display: none; }
.img-src { margin: -6px 0 12px; text-align: center; font-size: 11px; opacity: 0.55; }
#exam-img { display: block; max-width: 100%; max-height: 200px; margin: 0 auto 12px; border-radius: 12px; background: #fff; }
#exam-answers { display: grid; gap: 8px; }
.exam-answer { display: flex; gap: 12px; align-items: center; text-align: right; padding: 12px 14px; border-radius: 12px; font-size: clamp(15px, 3.8vw, 16px); line-height: 1.4;
  border: 2px solid var(--line); background: rgba(255, 255, 255, 0.05); color: var(--ink); min-height: 52px; }
.exam-answer .txt { min-width: 0; }
.exam-answer:hover { border-color: rgba(79, 216, 255, 0.6); }
.exam-answer.picked { border-color: var(--blue); background: rgba(79, 216, 255, 0.18); }
.exam-answer .letter { flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-content: center; background: rgba(255, 255, 255, 0.12); font-weight: 900; }
.exam-answer.picked .letter { background: var(--blue); color: #0b0e16; }
.exam-foot { display: flex; gap: 10px; align-items: center; margin-top: 14px; }
.exam-foot .cta, .exam-foot .ghost { width: auto; flex: 1; margin: 0; }
#exam-left { font-size: 13px; opacity: 0.7; white-space: nowrap; }

/* ---------- final results ---------- */
.res-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0; }
.res-card { border-radius: 16px; padding: 14px; text-align: center; display: grid; gap: 4px; background: rgba(255, 255, 255, 0.06); border: 2px solid transparent; }
.res-card small { opacity: 0.7; }
.res-card b { font-size: clamp(24px, 7vw, 30px); }
.res-card span { font-size: 13px; opacity: 0.8; }
.res-card.pass { border-color: var(--mint); }
.res-card.fail { border-color: var(--red); }
#res-overall { text-align: center; font-size: clamp(20px, 5vw, 24px); font-weight: 900; margin: 10px 0; }
.res-h { margin: 14px 0 8px; font-size: 16px; }
#res-review { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; max-height: 38vh; overflow-y: auto; }
#res-review li { padding: 8px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.06); font-size: 14px; line-height: 1.45; }
#res-review li.ok { border-right: 4px solid var(--mint); opacity: 0.75; }
#res-review li.bad { border-right: 4px solid var(--red); }
#res-review .ra.yours { color: #ff9a9a; }
#res-review .ra.right { color: var(--mint); }
#res-review .rs { font-size: 11px; opacity: 0.5; }

/* ================= responsive ================= */

/* tablets and small laptops */
@media (max-width: 900px) {
  :root { --minimap: 120px; }
  #coach-rule { font-size: 15px; }
}

/* phones in portrait (and narrow windows) */
@media (max-width: 640px) {
  :root { --gut: 12px; --minimap: 96px; }
  .gps { top: calc(10px + var(--sat)); padding: 6px 12px; gap: 8px; max-width: calc(100% - 2 * var(--gut) - var(--minimap) - 8px); left: auto; right: calc(var(--gut) + var(--sar)); transform: none; }
  html.is-touch .gps { right: auto; left: 50%; transform: translateX(-50%); top: calc(60px + var(--sat)); max-width: calc(100% - 2 * var(--gut)); }
  #gps-icon svg { width: 30px; height: 30px; }
  #gps-dist { font-size: 20px; }
  #gps-label { font-size: 12px; }
  #stopbar { top: calc(118px + var(--sat)); }
  #brake-hint { top: calc(184px + var(--sat)); font-size: 14px; }
  #coach { top: auto; bottom: calc(18px + var(--ctl) * 2.6 + var(--sab)); right: var(--gut); left: var(--gut); width: auto; padding: 10px 12px; }
  html:not(.is-touch) #coach { bottom: calc(110px + var(--sab)); }
  #coach-rule { font-size: 14px; }
  .speed-box { padding: 6px 10px; }
  #speed { font-size: 30px; }
  .limit { width: 36px; height: 36px; border-width: 5px; font-size: 13px; }
  .keys-hint { display: none; }
  #exam-nav { grid-template-columns: repeat(10, 1fr); }
  .res-grid { grid-template-columns: 1fr; }
  .exam-foot { flex-wrap: wrap; }
  #exam-left { order: -1; width: 100%; text-align: center; }
}

/* phones held in portrait: ask to rotate (playable either way) */
@media (orientation: portrait) and (max-width: 640px) {
  html.is-touch #rotate-hint {
    display: block; position: fixed; top: calc(12px + var(--sat)); left: calc(var(--gut) + var(--sal)); z-index: 5; pointer-events: none;
    background: var(--glass-strong); padding: 8px 12px; border-radius: 999px; font-size: 12px; white-space: nowrap;
  }
  html.is-touch .right-col { display: none; }
  html.is-touch .blinkers { bottom: calc(18px + var(--ctl) * 1.7 + var(--sab)); }
}

/* phones in landscape: little height, so everything gets compact */
@media (max-height: 520px) {
  :root { --gut: 12px; --minimap: 84px; --ctl: clamp(50px, 15vh, 72px); }
  .gps { top: calc(8px + var(--sat)); padding: 5px 12px; gap: 8px; }
  #gps-icon svg { width: 26px; height: 26px; }
  #gps-dist { font-size: 18px; }
  #gps-label { font-size: 11px; }
  #stopbar { top: calc(62px + var(--sat)); width: min(280px, 46vw); padding: 5px 10px 7px; }
  #stopbar-dist { font-size: 17px; }
  .sb-row { font-size: 12px; }
  #brake-hint { top: calc(116px + var(--sat)); font-size: 13px; padding: 6px 12px; }
  body.slowmo #stopbar { top: calc(96px + var(--sat)); }
  #slowmo-tag { top: calc(62px + var(--sat)); font-size: 13px; padding: 4px 12px; }
  #coach { top: calc(58px + var(--sat)); width: min(300px, 34vw); padding: 8px 12px; }
  .coach-head { font-size: 13px; margin-bottom: 3px; }
  #coach-rule { font-size: 13px; line-height: 1.35; }
  #coach-src { display: none; }
  #toast { top: 30%; font-size: 16px; padding: 8px 16px; }
  .speed-box { padding: 5px 10px; }
  #speed { font-size: 26px; }
  .limit { width: 32px; height: 32px; border-width: 4px; font-size: 12px; }
  .blinkers { bottom: calc(64px + var(--sab)); font-size: 20px; }
  .keys-hint { display: none; }
  /* overlays: use the full height, two columns where it helps */
  .overlay { align-items: stretch; }
  .panel { border-radius: 16px; }
  .menu-panel .logo { font-size: 30px; }
  .tagline { margin: 6px auto 10px; font-size: 14px; }
  #levels { grid-template-columns: repeat(3, 1fr); }
  .level { padding: 8px 10px; gap: 10px; font-size: 16px; }
  .level small { font-size: 11px; }
  .lv-num { width: 30px; height: 30px; font-size: 16px; }
  .controls { margin-top: 8px; padding: 10px 12px; gap: 6px; font-size: 14px; }
  .ctl-row { gap: 8px; }
  kbd, .chip { min-width: 28px; height: 26px; padding: 0 6px; font-size: 13px; }
  .exam-panel { width: min(900px, 100%); }
  #exam-nav { grid-template-columns: repeat(30, 1fr); gap: 2px; margin: 6px 0; }
  #exam-nav button { font-size: 10px; padding: 3px 0; min-height: 24px; }
  #exam-q { font-size: 16px; margin-bottom: 8px; }
  #exam-answers { grid-template-columns: 1fr 1fr; gap: 6px; }
  .exam-answer { padding: 8px 10px; font-size: 14px; min-height: 44px; }
  .exam-foot { margin-top: 8px; }
  .cta, .ghost { padding: 10px 14px; margin-top: 8px; min-height: 44px; }
  #res-review { max-height: none; }
}

/* very narrow phones (e.g. 320–360 px wide) */
@media (max-width: 360px) {
  :root { --ctl: 52px; --minimap: 84px; }
  .t-left, .t-right { gap: 8px; }
}

/* big desktop screens: a bit larger HUD */
@media (min-width: 1600px) and (min-height: 900px) {
  :root { --minimap: 180px; }
  #coach { width: 440px; }
  #coach-rule { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* touch + narrow portrait: stack HUD pieces so nothing overlaps the thumbs */
@media (max-width: 640px) {
  html.is-touch .gps { top: calc(56px + var(--sat)); left: 50%; right: auto; transform: translateX(-50%); max-width: calc(100% - 2 * var(--gut)); }
  html.is-touch #stopbar { top: calc(112px + var(--sat)); }
  html.is-touch #brake-hint { top: calc(170px + var(--sat)); }
  html.is-touch #slowmo-tag { top: calc(112px + var(--sat)); }
  html.is-touch .speed-box { bottom: calc(28px + var(--ctl) * 1.9 + var(--sab)); }
  html.is-touch .blinkers { bottom: calc(36px + var(--ctl) * 1.9 + var(--sab)); gap: 150px; }
  html.is-touch #coach { top: auto; bottom: calc(96px + var(--ctl) * 1.9 + var(--sab)); left: var(--gut); right: var(--gut); width: auto; }
  html.is-touch #toast.nav { bottom: calc(96px + var(--ctl) * 1.9 + var(--sab)); }
}
/* touch + landscape phones */
@media (max-height: 520px) {
  html.is-touch .gps { top: calc(8px + var(--sat)); }
  html.is-touch #coach { top: calc(56px + var(--sat)); right: calc(var(--gut) + var(--sar)); width: min(300px, 34vw); }
  html.is-touch .speed-box { bottom: calc(10px + var(--sab)); }
  html.is-touch .blinkers { bottom: calc(60px + var(--sab)); gap: 130px; }
  html.is-touch #toast.nav { bottom: calc(70px + var(--sab)); }
  html.is-touch .right-col { top: calc(8px + var(--sat)); }
}
@media (max-width: 640px) {
  html.is-touch #toast.nav { top: calc(176px + var(--sat)); bottom: auto; }
  html.is-touch #brake-hint { top: calc(224px + var(--sat)); }
}
@media (max-height: 520px) {
  #exam-img, #card-img { max-height: 26vh; }
}

/* ---------- pricing / paywall ---------- */
.premium-link { margin-top: 12px; width: 100%; border: 1px solid rgba(255, 210, 63, 0.45); background: rgba(255, 210, 63, 0.08); color: var(--yellow);
  border-radius: 14px; padding: 10px 14px; font-size: 15px; font-weight: 700; min-height: 44px; }
.pw-panel { width: min(480px, 100%); text-align: center; }
.pw-status { background: rgba(62, 240, 176, 0.12); border: 1px solid rgba(62, 240, 176, 0.4); color: var(--mint); border-radius: 12px; padding: 8px 12px; font-size: 14px; margin-bottom: 14px; }
.pw-eyebrow { font-size: 12px; letter-spacing: 0.12em; color: var(--yellow); font-weight: 700; }
.pw-title { margin: 6px 0 10px; font-size: clamp(22px, 5.5vw, 28px); text-wrap: balance; }
.pw-price-row { display: flex; align-items: baseline; justify-content: center; gap: 8px; }
#pw-price { font-size: clamp(44px, 12vw, 60px); font-weight: 900; color: var(--yellow); line-height: 1; font-variant-numeric: tabular-nums; }
.pw-price-row small { opacity: 0.7; }
.pw-period { margin: 6px 0 14px; opacity: 0.85; }
.pw-list { list-style: none; padding: 0; margin: 0 auto 14px; display: grid; gap: 8px; text-align: right; max-width: 40ch; }
.pw-list li { padding-right: 26px; position: relative; line-height: 1.45; }
.pw-list li::before { content: "✓"; position: absolute; right: 0; color: var(--mint); font-weight: 900; }
.pw-buy { display: grid; place-content: center; text-decoration: none; }
.pw-buy[aria-disabled="true"] { filter: grayscale(0.6); opacity: 0.75; cursor: default; }
.pw-code { margin-top: 14px; text-align: right; display: grid; gap: 6px; font-size: 14px; }
.pw-code-row { display: flex; gap: 8px; }
.pw-code-row input { flex: 1; min-width: 0; font-family: inherit; font-size: 16px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: #151a26; color: var(--ink); direction: ltr; text-align: center; }
.pw-code-row .ghost { width: auto; margin: 0; padding: 10px 16px; }
.pw-msg { min-height: 1.4em; margin: 10px 0 0; color: var(--yellow); font-size: 14px; }
.pw-note { font-size: 12px; opacity: 0.6; margin: 8px 0 0; }
@media (max-height: 520px) { .pw-list { grid-template-columns: 1fr 1fr; max-width: none; } .pw-title { margin: 2px 0 6px; } }

/* EFRAT credit */
.credit { margin-top: 16px; text-align: center; font-size: 12px; opacity: 0.6; direction: rtl; user-select: text; }
.credit .efrat, .credit .phone { font-family: "Montserrat", "Segoe UI", Arial, sans-serif; font-weight: 400; letter-spacing: 0.22em; direction: ltr; unicode-bidi: isolate; }
.credit .efrat { font-weight: 600; }

.pw-sale { display: inline-block; margin: 2px auto 8px; padding: 5px 12px; border-radius: 999px; background: var(--pink); color: #fff; font-weight: 700; font-size: 14px; }
.pw-regular { font-size: 22px; opacity: 0.55; font-variant-numeric: tabular-nums; }

/* ---------- Shabbat / holiday closed screen ---------- */
.overlay.shabbat { z-index: 80; background: radial-gradient(ellipse at 50% 30%, #2b2140 0%, #120f1d 55%, #07060c 100%); backdrop-filter: none; }
.sh-box { text-align: center; display: grid; gap: 10px; justify-items: center; max-width: 520px; }
.sh-box h1 { font-size: clamp(48px, 12vw, 84px); font-weight: 900; margin: 6px 0 0; color: #ffe7b3; text-shadow: 0 0 40px rgba(255, 190, 90, 0.35); }
.sh-name { font-size: clamp(20px, 5vw, 26px); font-weight: 700; color: var(--yellow); margin: 0; }
.sh-box p { margin: 0; font-size: 18px; line-height: 1.5; opacity: 0.9; }
.sh-until { font-size: 15px !important; opacity: 0.7 !important; font-variant-numeric: tabular-nums; }
.candles { display: flex; gap: 34px; height: 120px; align-items: flex-end; }
.candles span { position: relative; width: 22px; height: 70px; border-radius: 4px; background: linear-gradient(90deg, #f3ead8, #fffaf0 45%, #e2d6be); }
.candles span::before { content: ""; position: absolute; left: 50%; bottom: 100%; width: 2px; height: 8px; background: #3a2f22; transform: translateX(-50%); }
.candles span::after { content: ""; position: absolute; left: 50%; bottom: calc(100% + 6px); width: 16px; height: 30px; transform: translateX(-50%);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: radial-gradient(ellipse at 50% 75%, #fff6c8 0 20%, #ffc247 45%, rgba(255, 120, 30, 0.85) 70%, transparent 72%);
  filter: drop-shadow(0 0 14px rgba(255, 180, 60, 0.9)); animation: flicker 2.4s ease-in-out infinite alternate; transform-origin: 50% 100%; }
.candles span:nth-child(2)::after { animation-delay: -1.1s; }
@keyframes flicker { 0% { transform: translateX(-50%) scale(1, 1) rotate(-2deg); } 50% { transform: translateX(-50%) scale(0.94, 1.06) rotate(2deg); } 100% { transform: translateX(-50%) scale(1.03, 0.96) rotate(-1deg); } }

/* reverse button: pulses when the car is stuck against the curb */
#t-rev.pulse { background: var(--yellow); color: #14161c; animation: revPulse 0.9s ease-in-out infinite; }
@keyframes revPulse { 0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 210, 63, 0.7); } 50% { transform: scale(1.12); box-shadow: 0 0 0 10px rgba(255, 210, 63, 0); } }

/* paywall: buyer details for the SUMIT receipt */
.pw-form { display: grid; gap: 8px; margin-top: 14px; }
.pw-form input { width: 100%; min-height: 46px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); color: var(--ink); padding: 10px 14px; font: inherit; font-size: 16px; }
.pw-form input:focus { outline: 2px solid var(--yellow); outline-offset: 1px; }

/* first screen: the free week and what comes after, said plainly */
.trial-banner { margin: 6px auto 12px; padding: 10px 14px; border-radius: 12px; background: rgba(255, 210, 63, 0.12);
  border: 1px solid rgba(255, 210, 63, 0.55); color: var(--ink); font-size: 15px; line-height: 1.45; text-align: center; }
.trial-banner b { color: var(--yellow); }

/* captions under the small touch buttons, so it's clear what each one does */
#touch .t-left button, #touch .t-mid button { position: relative; }
#touch .t-left button::after, #touch .t-mid button::after { content: attr(data-label); position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  margin-top: 3px; font-size: 11px; font-weight: 700; white-space: nowrap; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9); pointer-events: none; }
#touch .pedal { font-size: calc(var(--ctl) * 0.28); font-weight: 800; }

/* first-drive tutorial: a card under the navigation, and the button to press glows */
.tutorial { position: fixed; top: calc(92px + var(--sat)); left: 50%; transform: translateX(-50%); z-index: 15; width: min(560px, calc(100% - 2 * var(--gut)));
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px;
  background: rgba(10, 13, 22, 0.92); border: 2px solid var(--yellow); box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5); }
.tutorial p { margin: 0; font-size: 18px; line-height: 1.4; }
.tutorial b { color: var(--yellow); }
.tut-step { font-weight: 800; color: #14161c; background: var(--yellow); border-radius: 10px; padding: 4px 9px; font-size: 14px; }
.tut-skip { border: 0; background: rgba(255, 255, 255, 0.12); color: var(--ink); border-radius: 10px; padding: 8px 12px; font: inherit; font-size: 14px; cursor: pointer; }
.tut-pop { animation: tutPop 0.35s ease-out; }
@keyframes tutPop { from { transform: translateX(-50%) scale(0.92); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }
#touch button.tut-glow { box-shadow: 0 0 0 4px var(--yellow), 0 0 26px 6px rgba(255, 210, 63, 0.75); animation: tutGlow 0.9s ease-in-out infinite; }
@keyframes tutGlow { 50% { box-shadow: 0 0 0 6px var(--yellow), 0 0 36px 12px rgba(255, 210, 63, 0.9); } }
@media (max-height: 520px) { .tutorial { top: calc(64px + var(--sat)); padding: 8px 10px; } .tutorial p { font-size: 15px; } }
