/* ==========================================================================
   Brain Drift - all UI styling (menus, modals, HUD, keypads, parent area)
   The game world itself is drawn on <canvas> in game.js.
   ========================================================================== */

:root {
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  --ink: #1f1d3d;
  --ink-soft: #4c4a6e;
  --paper: #ffffff;
  --paper-2: #f4f2ff;
  --line: #d9d5f5;
  --primary: #5a4fdc;
  --primary-dark: #4038b3;
  --secondary: #ff8c42;
  --secondary-dark: #d96a20;
  --good: #1f9d63;
  --good-soft: #dff7ea;
  --warn: #b7791f;
  --warn-soft: #fff4d6;
  --bad: #c2410c;
  --bad-soft: #ffe6dc;
  --gold: #ffc93c;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(40, 30, 110, 0.18);
  --tap: 52px; /* minimum tap target */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, #7cc6fe 0%, #b8c8ff 55%, #f2c4f5 100%);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0 0 0.4em; line-height: 1.15; }
p { line-height: 1.45; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- Screens */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.screen.active { display: block; }
#screen-game { padding: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }

.screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 1100px;
  margin: 0 auto 16px;
}
.screen-header h2 { flex: 1; margin: 0; font-size: 1.8rem; color: var(--paper); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.15); }

.panel {
  background: var(--paper);
  border-radius: 26px;
  box-shadow: var(--shadow);
  padding: 24px;
  max-width: 640px;
  margin: 24px auto;
}

/* ---------------------------------------------------------------- Buttons */
.btn {
  min-height: var(--tap);
  padding: 10px 22px;
  border: none;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 800;
  font-size: 1.05rem;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--line);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s;
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:focus-visible, .icon-btn:focus-visible, .key:focus-visible { outline: 4px solid var(--gold); outline-offset: 2px; }
.btn.primary { background: var(--primary); color: #fff; box-shadow: 0 4px 0 var(--primary-dark); }
.btn.primary:active:not(:disabled) { box-shadow: 0 1px 0 var(--primary-dark); }
.btn.secondary { background: var(--secondary); color: #fff; box-shadow: 0 4px 0 var(--secondary-dark); }
.btn.secondary:active:not(:disabled) { box-shadow: 0 1px 0 var(--secondary-dark); }
.btn.good { background: var(--good); color: #fff; box-shadow: 0 4px 0 #157049; }
.btn.danger { background: var(--bad); color: #fff; box-shadow: 0 4px 0 #8f2f08; }
.btn.ghost { background: transparent; box-shadow: none; border: 2px solid var(--line); }
.btn.small { min-height: 44px; padding: 6px 14px; font-size: 0.95rem; }
.btn.big { font-size: 1.3rem; padding: 14px 30px; }
.btn.huge { font-size: 1.8rem; padding: 18px 48px; min-height: 72px; }

.icon-btn {
  width: var(--tap);
  height: var(--tap);
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.85);
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
  touch-action: manipulation;
}

.button-row { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 16px; }

.back-btn { background: rgba(255, 255, 255, 0.9); }

/* ----------------------------------------------------------- Pills/badges */
.coin-pill, .best-pill, .hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 800;
  font-size: 1.15rem;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.08);
}
.coin-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6c4 0 15%, #ffd23f 16% 60%, #e8a400 61%);
  box-shadow: inset 0 0 0 2px #d99100;
  vertical-align: -0.12em;
  flex: none;
}
.badges { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; min-height: 40px; }
.badge {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 700;
}
.new-badge {
  background: var(--gold);
  color: var(--ink);
  font-size: 0.8rem;
  border-radius: 999px;
  padding: 3px 10px;
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }

/* ------------------------------------------------------------ Title screen */
.title-wrap {
  position: relative;
  max-width: 620px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  padding: 20px 0;
}
.parent-gear { position: absolute; top: 0; right: 0; }
.logo {
  font-size: clamp(3rem, 12vw, 5.5rem);
  color: #fff;
  letter-spacing: 1px;
  text-shadow: 0 5px 0 var(--primary), 0 10px 18px rgba(40, 30, 110, 0.3);
  margin: 0;
}
.logo span { color: var(--gold); }
.tagline { margin: 0; font-size: 1.2rem; font-weight: 700; color: var(--ink-soft); }
.title-car { width: min(280px, 70vw); height: min(200px, 50vw); }
.title-message {
  margin: 0;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 14px;
  padding: 10px 16px;
  font-weight: 700;
}
.title-message:empty { display: none; }
.title-stats { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.title-buttons { display: flex; flex-direction: column; gap: 14px; align-items: center; margin-top: 8px; }

/* -------------------------------------------------------------------- HUD */
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  pointer-events: none;
}
.hud-left { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.hud-pause { pointer-events: auto; }
.hud-powerups { display: flex; gap: 8px; }
.power {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 800;
  color: #fff;
}
.power.shield { background: #1aa3d9; }
.power.turbo { background: linear-gradient(90deg, #ff5d8f, #ff9f1c); }
.hud-hint {
  position: absolute;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.9);
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 800;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 0.6s;
}
.hud-hint.hide { opacity: 0; }

/* ------------------------------------------------------------- Countdown */
.countdown {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  pointer-events: none;
}
.countdown-number {
  font-size: clamp(5rem, 25vw, 10rem);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 6px 0 var(--primary), 0 12px 30px rgba(0, 0, 0, 0.25);
}
.countdown-number.pop { animation: pop 0.6s ease-out; }
@keyframes pop { 0% { transform: scale(0.4); opacity: 0; } 40% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); } }

/* ---------------------------------------------------------------- Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(30, 24, 80, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow-y: auto;
  animation: fade-in 0.15s ease-out;
}
@keyframes fade-in { from { opacity: 0; } }
.modal {
  position: relative;
  background: var(--paper);
  border-radius: 26px;
  box-shadow: var(--shadow);
  padding: 22px;
  width: 100%;
  max-width: 560px;
  max-height: calc(100% - 8px);
  overflow-y: auto;
  animation: rise 0.2s ease-out;
}
@keyframes rise { from { transform: translateY(20px) scale(0.97); opacity: 0; } }
.modal.dialog { max-width: 440px; text-align: center; }
.modal.wide { max-width: 760px; }
.dialog-message { font-size: 1.1rem; white-space: pre-line; }

.toast-root, #toast-root { position: fixed; left: 0; right: 0; bottom: 24px; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 80; pointer-events: none; }
.toast {
  background: var(--ink);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 700;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: none; }

.confetti-layer { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 70; }

/* --------------------------------------------------------------- Progress */
.progress {
  position: relative;
  height: 26px;
  background: var(--paper-2);
  border-radius: 999px;
  overflow: hidden;
  border: 2px solid var(--line);
}
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--gold), #ff9f1c); border-radius: 999px; transition: width 0.5s ease; }
.progress-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 0.85rem; font-weight: 800; }

/* ----------------------------------------------------------------- Toggle */
.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 700; min-height: var(--tap); }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle-track { width: 54px; height: 30px; border-radius: 999px; background: #c8c4e0; position: relative; transition: background 0.2s; flex: none; }
.toggle-thumb { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); }
.toggle input:checked + .toggle-track { background: var(--good); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(24px); }
.toggle input:focus-visible + .toggle-track { outline: 3px solid var(--gold); }

/* --------------------------------------------------------------- Game over */
.gameover { text-align: center; }
.gameover h2 { font-size: 2.2rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin: 16px 0; }
.stat { background: var(--paper-2); border-radius: var(--radius); padding: 12px; }
.stat-label { font-size: 0.9rem; font-weight: 700; color: var(--ink-soft); }
.stat-value { font-size: 1.8rem; font-weight: 900; }
.new-best { color: var(--good); font-weight: 900; animation: pulse 1s ease-in-out infinite; display: inline-block; }
.goal { margin: 16px 0; text-align: left; }
.goal p { margin: 0 0 6px; font-weight: 700; }
.answered-list { margin: 0; padding: 0; list-style: none; font-weight: 700; }

/* ---------------------------------------------------------------- Chooser */
.chooser h2, .quiz h2 { text-align: center; }
.choice-grid { display: grid; gap: 12px; }
.choice-card {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 14px;
  align-items: center;
  text-align: left;
  min-height: 88px;
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 3px solid var(--line);
  background: var(--paper);
  cursor: pointer;
  box-shadow: 0 5px 0 var(--line);
  touch-action: manipulation;
}
.choice-card:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 var(--line); }
.choice-card .choice-icon { grid-row: span 2; font-size: 2.6rem; }
.choice-card .choice-name { font-size: 1.35rem; font-weight: 900; }
.choice-card .choice-reward { font-weight: 800; color: var(--good); }
.choice-card.spelling { border-color: #9bd3ff; }
.choice-card.math { border-color: #ffd27a; }
.choice-card.wordProblem { border-color: #c9a7ff; }
.choice-card:disabled { filter: grayscale(1); opacity: 0.5; cursor: not-allowed; }
.choice-card .choice-note { grid-column: 2; font-weight: 700; color: var(--ink-soft); }

/* ------------------------------------------------------------------- Quiz */
.modal.quiz { max-width: 680px; padding: 18px; }
.quiz-header {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--paper-2);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 900;
  font-size: 1.1rem;
  margin-bottom: 12px;
  text-align: center;
}
.quiz-header .reward { color: var(--good); }
.quiz-prompt {
  text-align: center;
  font-size: clamp(1.8rem, 7vw, 3rem);
  font-weight: 900;
  margin: 8px 0;
  word-break: break-word;
}
.quiz-prompt.text { font-size: clamp(1.15rem, 3.8vw, 1.5rem); font-weight: 700; text-align: left; line-height: 1.5; background: var(--paper-2); padding: 14px 16px; border-radius: var(--radius); }
.quiz-listen { text-align: center; font-size: 1.25rem; font-weight: 800; color: var(--ink-soft); margin: 4px 0 8px; }
.speak-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 8px 0; }
.answer-row { display: flex; justify-content: center; align-items: center; gap: 10px; margin: 12px 0; }
.answer-box {
  min-width: 200px;
  max-width: 100%;
  min-height: 64px;
  padding: 8px 18px;
  border: 4px solid var(--primary);
  border-radius: var(--radius);
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  word-break: break-all;
}
.answer-box::after { content: ""; width: 3px; height: 1.1em; background: var(--primary); margin-left: 3px; animation: blink 1s steps(1) infinite; }
.answer-box.empty::before { content: attr(data-placeholder); color: #b3afd6; font-weight: 700; letter-spacing: 0; font-size: 1.2rem; }
@keyframes blink { 50% { opacity: 0; } }
.answer-unit { font-size: 1.5rem; font-weight: 800; }

.keypad { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; user-select: none; -webkit-user-select: none; }
.key-row { display: flex; justify-content: center; gap: 6px; }
.key {
  flex: 1 1 0;
  max-width: 64px;
  min-width: 0;
  min-height: var(--tap);
  border: none;
  border-radius: 12px;
  background: var(--paper-2);
  font-size: 1.35rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--line);
  touch-action: manipulation;
  padding: 0;
}
.key:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); background: #e6e2ff; }
.key.wide { max-width: 140px; flex-grow: 2; font-size: 1.05rem; }
.key.done { background: var(--good); color: #fff; box-shadow: 0 3px 0 #157049; max-width: 180px; flex-grow: 3; }
.keypad.numbers .key { max-width: 96px; min-height: 58px; font-size: 1.6rem; }
.keypad.numbers .key.done { max-width: 210px; }

.quiz-result { text-align: center; }
.result-title { font-size: 2.2rem; font-weight: 900; margin: 6px 0; }
.result-title.correct { color: var(--good); }
.result-title.wrong { color: var(--primary); }
.result-answer { font-size: clamp(2rem, 8vw, 3.2rem); font-weight: 900; margin: 6px 0; word-break: break-word; }
.letter-diff { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.letter-diff span { display: inline-block; min-width: 0.8em; padding: 0 4px; border-radius: 8px; }
.letter-diff span.bad { background: var(--warn-soft); color: var(--bad); box-shadow: inset 0 -4px 0 var(--gold); }
.your-answer { font-size: 1.15rem; font-weight: 700; color: var(--ink-soft); }
.reward-line { font-size: 1.25rem; font-weight: 900; color: var(--good); }
.continue-btn { position: relative; overflow: hidden; }
.continue-btn .fill { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(255, 255, 255, 0.3); }

/* ----------------------------------------------------------------- Garage */
.garage-grid {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
}
.car-card {
  position: relative;
  background: var(--paper);
  border: 4px solid transparent;
  border-radius: 22px;
  padding: 10px 12px 14px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
  touch-action: manipulation;
}
.car-card.selected { border-color: var(--good); }
.car-card.affordable { border-color: var(--gold); }
.car-canvas { width: 100%; height: 120px; display: block; }
.car-name { font-weight: 900; font-size: 1.15rem; }
.car-status { font-weight: 800; color: var(--ink-soft); }
.car-status.driving { color: var(--good); }
.lock-badge { position: absolute; top: 8px; right: 10px; font-size: 1.4rem; }
.perk { font-size: 0.85rem; font-weight: 700; color: var(--primary); }

.purchase { text-align: center; }
.purchase .car-canvas { height: 170px; }
.purchase .price { font-size: 1.4rem; font-weight: 900; }
.purchase .button-row { flex-direction: column; align-items: stretch; }
.purchase .note { color: var(--ink-soft); font-weight: 700; }

/* ------------------------------------------------------------ Parent area */
.parent { max-width: 980px; margin: 0 auto; }
.parent-header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.parent-header h2 { flex: 1; margin: 0; color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.15); }
.parent-card { background: var(--paper); border-radius: 22px; box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.parent-card h3 { margin-top: 0; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tab {
  min-height: 46px;
  padding: 8px 18px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
  font-weight: 800;
  cursor: pointer;
}
.tab.active { background: var(--paper); box-shadow: 0 3px 0 var(--line); }
.subtabs .tab { background: var(--paper-2); }
.subtabs .tab.active { background: var(--primary); color: #fff; box-shadow: none; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-weight: 700; }
.field-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.field-row .field { flex: 1 1 140px; }
.hint { font-size: 0.9rem; color: var(--ink-soft); font-weight: 600; margin: 0 0 8px; }
input[type="text"], input[type="number"], input[type="password"], select, textarea {
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  min-height: 46px;
  font-size: 1rem;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
textarea.big { min-height: 220px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; line-height: 1.5; }
input[type="range"] { width: 100%; min-height: 40px; accent-color: var(--primary); }

.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .editor-grid { grid-template-columns: 1fr; } }
.preview-list { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; border: 2px solid var(--line); border-radius: 12px; }
.preview-list:empty::before { content: "Nothing yet - type in the box to see a preview."; display: block; padding: 12px; color: var(--ink-soft); }
.preview-row { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--paper-2); flex-wrap: wrap; }
.preview-row:last-child { border-bottom: none; }
.preview-main { flex: 1; min-width: 120px; font-weight: 700; word-break: break-word; }
.preview-sub { display: block; font-weight: 500; color: var(--ink-soft); font-size: 0.9rem; }
.flag { font-size: 0.8rem; font-weight: 800; border-radius: 999px; padding: 2px 10px; }
.flag.error { background: var(--bad-soft); color: var(--bad); }
.flag.warn { background: var(--warn-soft); color: var(--warn); }
.flag.ok { background: var(--good-soft); color: var(--good); }
.editor-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.editor-footer { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 12px; }
.generator { background: var(--paper-2); border-radius: 16px; padding: 14px; margin-top: 12px; }
.generator h4 { margin: 0 0 8px; }
.generator .field-row .field { flex: 1 1 90px; }

.wp-card { border: 2px solid var(--line); border-radius: 16px; padding: 12px; margin-bottom: 12px; }
.wp-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.wp-card-head strong { flex: 1; }
.wp-card textarea { min-height: 90px; resize: vertical; }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }

.report-summary { font-size: 1.15rem; font-weight: 800; margin: 0 0 8px; }
.report-list { list-style: none; margin: 0 0 16px; padding: 0; }
.report-item { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--paper-2); }
.report-item .status { font-size: 1.2rem; }
.report-item .stats { font-weight: 700; color: var(--ink-soft); text-align: right; font-size: 0.95rem; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-weight: 700; font-size: 0.9rem; color: var(--ink-soft); }
.hardest { background: var(--warn-soft); border-radius: 14px; padding: 10px 14px; font-weight: 700; }

/* --------------------------------------------------------------------- PIN */
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 12px 0; }
.pin-dot { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--primary); }
.pin-dot.filled { background: var(--primary); }
.pin-error { color: var(--bad); font-weight: 800; min-height: 1.4em; text-align: center; margin: 0; }
.shake { animation: shake 0.35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

.noscript { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; background: #fff; margin: 0; }

/* ------------------------------------------------------------- Small screens */
@media (max-width: 480px) {
  .panel, .modal { padding: 16px; }
  .garage-grid { gap: 10px; }
  .car-card { padding: 8px 8px 10px; border-radius: 18px; }
  .car-canvas { height: 90px; }
  .car-name { font-size: 1rem; }
  .btn.huge { font-size: 1.5rem; padding: 14px 36px; }
  .key { font-size: 1.15rem; border-radius: 10px; }
  .key-row { gap: 4px; }
  .answer-box { font-size: 1.6rem; min-width: 160px; }
  .hud-pill { font-size: 1rem; padding: 6px 12px; }
}
@media (max-height: 560px) {
  .title-car { height: 120px; }
  .logo { font-size: 2.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ------------------------------------------------------- Late additions */
.price-tag { display: inline-flex; align-items: center; gap: 5px; }
.editor-status { font-weight: 800; color: var(--ink-soft); }
.pin h2 { text-align: center; }
.pin .hint { text-align: center; }
.pin .keypad .key { max-width: 88px; }
.btn.stack { flex-direction: column; gap: 2px; line-height: 1.2; }
.btn-sub { display: inline-flex; align-items: center; gap: 4px; font-size: 0.85em; opacity: 0.95; }
.garage-owned { font-size: 0.6em; background: rgba(255, 255, 255, 0.85); color: var(--ink); border-radius: 999px; padding: 3px 10px; vertical-align: middle; text-shadow: none; }
.last-tag { margin-left: 8px; font-size: 0.7rem; vertical-align: middle; background: var(--paper-2); color: var(--ink-soft); border-radius: 999px; padding: 2px 8px; }
.choice-card.mix { border-color: #8bd346; }

/* Zone banner: slides in when the car reaches a new zone */
.zone-banner {
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translate(-50%, -20px);
  opacity: 0;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 999px;
  padding: 12px 26px;
  font-weight: 900;
  font-size: clamp(1.2rem, 4.5vw, 1.8rem);
  box-shadow: var(--shadow);
  white-space: nowrap;
  transition: opacity 0.4s, transform 0.4s;
}
.zone-banner.show { opacity: 1; transform: translate(-50%, 0); }
.zone-banner small { display: block; text-align: center; font-size: 0.55em; color: var(--ink-soft); letter-spacing: 1px; text-transform: uppercase; }
