:root {
  /* Chinese/Japanese/Korean text uses the system fonts every OS ships with. */
  --cjk: 'Hiragino Sans', 'Yu Gothic UI', 'Yu Gothic', Meiryo, 'Microsoft YaHei', 'PingFang SC',
    'Malgun Gothic', 'Apple SD Gothic Neo', 'Noto Sans CJK JP', 'Noto Sans JP';
  --pink: #ff4fd8;
  --cyan: #5ce1ff;
  --gold: #ffd23a;
  --green: #3dffa8;
  --red: #ff3b5c;
  --ink: #f4f0ff;
  --panel: rgba(18, 8, 44, 0.82);
  --board: #14b8a6;

  /* Menus: "fable" theme shared with the other Lingoria games — deep plum
     panels framed in warm gold, big pill buttons with a 3D shadow, outlined
     titles. The racing HUD above keeps its own neon palette. */
  --f-plum: #2a1a4e;
  --f-plum-2: #3d2770;
  --f-dark: rgba(18, 9, 38, 0.72);
  --f-line: rgba(255, 214, 140, 0.5);
  --f-line-strong: rgba(255, 214, 140, 0.85);
  --f-text: #fff6e4;
  --f-muted: #cdbfe8;
  --f-gold: #ffcf6b;
  --f-gold-light: #ffe9a8;
  --f-amber: #ff9f43;
  --f-gold-shadow: #b8651a;
  --f-plum-shadow: #170c2c;
  --f-coral: #ff7a59;
  --f-good: #8be28b;
  --f-r: 26px;
  --f-font: Inter, var(--cjk), system-ui, sans-serif;
  --f-title: Orbitron, Inter, var(--cjk), sans-serif;
  --f-t: 0.15s;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b0628;
  color: var(--ink);
  font-family: Inter, system-ui, sans-serif;
}

[hidden] {
  display: none !important;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  pointer-events: none;
}
#hud > * {
  position: absolute;
}

.chip {
  pointer-events: auto;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.35);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 14px;
  font: 600 13px Inter, sans-serif;
  cursor: pointer;
}

.top-left {
  top: 14px;
  left: 16px;
  display: flex;
  gap: 8px;
}

#progress {
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: min(420px, 50vw);
  display: flex;
  align-items: center;
  gap: 10px;
}
#progress .track {
  position: relative;
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.15);
}
#progress-marks .mark {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  border-radius: 50%;
  transform: translateY(-50%);
  border: 2px solid #0b0628;
}
#progress-marks .mark.me {
  width: 16px;
  height: 16px;
  margin-left: -8px;
  z-index: 2;
  box-shadow: 0 0 10px var(--red);
}
#position {
  font: 900 22px Orbitron, sans-serif;
  min-width: 44px;
}

#speedo {
  top: 12px;
  right: 16px;
  text-align: right;
}
.speed-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  justify-content: flex-end;
}
#speed {
  font: 900 56px/1 Orbitron, sans-serif;
  font-style: italic;
  text-shadow: 0 0 18px rgba(92, 225, 255, 0.7);
  font-variant-numeric: tabular-nums;
}
#gear {
  font: 900 18px Orbitron, sans-serif;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid var(--pink);
  border-radius: 6px;
  padding: 2px 7px;
  margin-top: 4px;
}
#gear.bump {
  animation: gearbump 0.35s ease-out;
}
@keyframes gearbump {
  0% {
    transform: scale(1.7);
    background: var(--pink);
  }
}
.unit {
  font-size: 12px;
  opacity: 0.7;
}
#gear-dots {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  margin: 6px 0;
}
#gear-dots i {
  width: 16px;
  height: 5px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.15);
}
#gear-dots i.on {
  background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan);
}
#nitro {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  font: 900 11px Orbitron, sans-serif;
  letter-spacing: 1px;
}
#nitro .bar {
  width: 120px;
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
}
#nitro-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--cyan), #fff);
  transition: width 0.25s;
}
#nitro.full #nitro-fill {
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold);
}
#nitro.active span {
  color: var(--cyan);
  text-shadow: 0 0 8px var(--cyan);
}

#board-wrap {
  top: 13%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}
#billboard {
  min-width: 170px;
  max-width: 86vw;
  padding: 14px 26px 10px;
  background: var(--board);
  border: 4px solid #d8fffb;
  border-radius: 10px;
  box-shadow: 0 0 30px rgba(20, 184, 166, 0.6), inset 0 0 0 2px rgba(0, 0, 0, 0.15);
  text-align: center;
  transition: transform 0.15s;
}
#billboard.golden {
  --board: #c99400;
  border-color: #fff4c2;
  box-shadow: 0 0 45px rgba(255, 210, 58, 0.9);
}
#billboard.pop {
  animation: pop 0.25s ease-out;
}
#billboard.shake {
  animation: shake 0.35s;
  background: #b3243b;
}
@keyframes pop {
  0% {
    transform: scale(0.7);
    opacity: 0.4;
  }
}
@keyframes shake {
  20%,
  60% {
    transform: translateX(-10px);
  }
  40%,
  80% {
    transform: translateX(10px);
  }
}
#prompt {
  font: 700 clamp(40px, 9vw, 84px) / 1.1 Inter, var(--cjk), sans-serif;
  color: #fff;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.2);
  word-break: break-word;
}
#prompt.long {
  font-size: clamp(28px, 6vw, 52px);
}
#ask {
  margin-top: 4px;
  font-size: 13px;
  opacity: 0.85;
}

#rpm {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  white-space: nowrap;
  background: rgba(0, 0, 0, 0.35);
  padding: 5px 10px;
  border-radius: 6px;
}
#rpm .bar {
  position: relative;
  width: 110px;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, rgba(61, 255, 168, 0.25) 0 45%, rgba(255, 255, 255, 0.12) 45% 80%, rgba(255, 59, 92, 0.35) 80%);
  overflow: hidden;
}
#rpm-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--green);
}
#rpm-fill.warn {
  background: var(--gold);
}
#rpm-fill.red {
  background: var(--red);
}
#rpm-perfect {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #fff;
  z-index: 1;
}

#toast {
  margin-top: 12px;
  font: 900 20px Orbitron, sans-serif;
  text-align: center;
  opacity: 0;
  transition: opacity 0.2s;
  text-shadow: 0 0 12px currentColor;
  white-space: nowrap;
}
#toast.show {
  opacity: 1;
}
#toast .answer {
  display: block;
  font: 600 15px Inter, sans-serif;
  color: #fff;
  text-shadow: none;
  margin-top: 4px;
}

#streak {
  left: 16px;
  bottom: 110px;
  font: 900 18px Orbitron, sans-serif;
  color: var(--gold);
  text-shadow: 0 0 10px rgba(255, 210, 58, 0.6);
}

#answer-form {
  bottom: max(22px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: min(360px, 88vw);
  pointer-events: auto;
}
#answer {
  width: 100%;
  padding: 14px 18px;
  font: 800 26px Inter, sans-serif;
  text-align: center;
  color: #fff;
  background: rgba(20, 30, 90, 0.75);
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 12px;
  outline: none;
  box-shadow: 0 0 22px rgba(92, 225, 255, 0.35);
}
#answer:focus {
  border-color: var(--cyan);
}


@media (max-width: 600px) {
  #speed {
    font-size: 38px;
  }
  #progress {
    top: 56px;
    left: 16px;
    transform: none;
    width: calc(100vw - 200px);
  }
  #board-wrap {
    top: 20%;
  }
  #nitro .bar {
    width: 80px;
  }
  #streak {
    bottom: 96px;
  }
}

/* On-screen keyboard open: compact HUD that fits above the keyboard. */
body.kb-open #board-wrap {
  top: 44px;
}
body.kb-open #billboard {
  padding: 6px 16px 4px;
}
body.kb-open #prompt {
  font-size: 34px;
}
body.kb-open #prompt.long {
  font-size: 24px;
}
body.kb-open #rpm {
  margin-top: 4px;
}
body.kb-open #speedo #speed {
  font-size: 26px;
}
body.kb-open #nitro span,
body.kb-open #gear-dots,
body.kb-open .unit,
body.kb-open #progress,
body.kb-open #streak {
  display: none;
}
body.kb-open #answer-form {
  bottom: 8px;
}
body.kb-open #answer {
  padding: 8px 12px;
  font-size: 20px;
}

/* ---------- Countdown, pause, launch extras ---------- */
#countdown {
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  font: 900 min(28vw, 180px) / 1 Orbitron, sans-serif;
  font-style: italic;
  color: #fff;
  text-shadow: 0 0 30px var(--pink), 0 0 60px var(--pink);
  animation: countpop 1s ease-out infinite;
}
@keyframes countpop {
  0% {
    transform: translate(-50%, -50%) scale(1.4);
    opacity: 0.4;
  }
  30% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}
#billboard.waiting,
#billboard.waiting + #rpm {
  visibility: hidden;
}

/* ---------- Gameplay feedback ---------- */
#answer.ok {
  border-color: var(--green);
  box-shadow: 0 0 22px rgba(61, 255, 168, 0.45);
}
#answer.bad {
  border-color: var(--red);
  box-shadow: 0 0 22px rgba(255, 59, 92, 0.55);
  color: #ffc2cc;
}
#hint {
  margin-top: 6px;
  padding: 3px 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
  font: 700 18px Inter, monospace;
  letter-spacing: 2px;
  color: #fff;
}
#remaining {
  top: 44px;
  left: 50%;
  transform: translateX(-50%);
  font: 600 12px Orbitron, sans-serif;
  opacity: 0.75;
}
#remaining.final {
  color: var(--pink);
  opacity: 1;
  font-size: 14px;
  text-shadow: 0 0 10px var(--pink);
}
#feed {
  left: 16px;
  top: 38%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font: 900 16px Orbitron, sans-serif;
  text-shadow: 0 0 10px currentColor;
}
#feed div {
  animation: feedin 0.25s ease-out;
  transition: opacity 0.4s;
}
#feed div.out {
  opacity: 0;
}
@keyframes feedin {
  from {
    transform: translateX(-30px);
    opacity: 0;
  }
}
#slip {
  margin-top: 6px;
  font: 900 12px Orbitron, sans-serif;
  letter-spacing: 1px;
  color: #fff;
  text-shadow: 0 0 8px #fff;
}
@media (max-width: 600px) {
  #remaining {
    top: 80px;
    left: 16px;
    transform: none;
  }
  #feed {
    top: auto;
    bottom: 130px;
    font-size: 13px;
  }
}
body.kb-open #remaining,
body.kb-open #feed {
  display: none;
}

/* New word: the answer is shown so the player copies it. */
#reveal {
  margin-top: 6px;
  padding: 4px 12px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  font: 800 26px Inter, var(--cjk), sans-serif;
  color: #fff;
}
#reveal small {
  display: block;
  font: 700 10px Orbitron, sans-serif;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--gold);
}
#billboard.new-word {
  border-color: var(--gold);
}
body.kb-open #reveal {
  font-size: 20px;
}
/* =====================================================================
   MENUS — "fable" style (see hub/hub.css and the Ballpit menus): the live
   synthwave road stays behind; on top, framed plum panels, gold pill buttons
   with a 3D edge and a soft shine, outlined titles. Everything below is
   presentation only; the race logic never reads these classes.
   ===================================================================== */

/* ---------- Screens (full-viewport layers) ---------- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  gap: 14px;
  padding: 18px 16px;
  overflow: auto;
  color: var(--f-text);
  font-family: var(--f-font);
  background: rgba(10, 4, 22, 0.66);
  animation: fade 0.25s ease-out;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 207, 107, 0.5) transparent;
}
/* Menu over the road: only a vignette so the scene stays alive. */
.screen.clear {
  background: radial-gradient(ellipse at 50% 60%, rgba(20, 8, 44, 0.1) 0%, rgba(12, 5, 28, 0.62) 70%, rgba(8, 3, 20, 0.85) 100%);
}
#settings,
#help {
  z-index: 30;
}
/* The pause lives inside the HUD (which ignores the pointer). */
#hud > #pause {
  position: fixed;
  inset: 0;
  pointer-events: auto;
  gap: 10px;
}
@keyframes fade {
  from { opacity: 0; }
}
@keyframes pop {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}
@keyframes shine {
  0%, 55% { transform: translateX(-130%) skewX(-20deg); }
  100% { transform: translateX(230%) skewX(-20deg); }
}

/* ---------- Panels ---------- */
.panel {
  position: relative;
  padding: 18px 20px;
  border: 3px solid var(--f-line);
  border-radius: var(--f-r);
  background: linear-gradient(160deg, rgba(61, 39, 112, 0.94), rgba(42, 26, 78, 0.96));
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55), inset 0 2px 0 rgba(255, 255, 255, 0.12);
  animation: pop 0.3s ease-out;
}
.panel h3 {
  margin: 0 0 8px;
  font: 700 12px/1.2 var(--f-title);
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--f-gold);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
}
.panel h3 + .choices + h3 {
  margin-top: 14px;
}
.dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 207, 107, 0.5) transparent;
}

/* ---------- Titles ---------- */
.title {
  margin: 0 0 12px;
  font: 900 clamp(26px, 3.4vw, 40px) / 1.1 var(--f-title);
  letter-spacing: 1px;
  text-align: center;
  color: var(--f-gold-light);
  -webkit-text-stroke: 1.5px #5b2a10;
  paint-order: stroke fill;
  text-shadow: 0 4px 0 #8a4a1a, 0 10px 22px rgba(0, 0, 0, 0.55);
}
.logo-wrap {
  text-align: center;
  margin: 2px 0 0;
}
.logo {
  margin: 0;
  font: 900 clamp(42px, 5.6vw, 76px) / 1 var(--f-title);
  letter-spacing: 2px;
  color: var(--f-gold-light);
  -webkit-text-stroke: 2px #5b2a10;
  paint-order: stroke fill;
  text-shadow: 0 7px 0 #a35a1f, 0 16px 30px rgba(0, 0, 0, 0.6);
  animation: bob 3.5s ease-in-out infinite;
}
.logo em {
  font-style: italic;
  color: #ff7ad9;
  text-shadow: 0 7px 0 #7a1f5a, 0 16px 30px rgba(0, 0, 0, 0.6);
}
.tagline {
  margin: 10px 0 0;
  font-size: clamp(14px, 1.4vw, 19px);
  font-weight: 600;
  color: #ffd8a8;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6), 0 0 14px rgba(0, 0, 0, 0.5);
}

/* ---------- Buttons ---------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 26px;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  cursor: pointer;
  font: 800 17px/1.15 var(--f-font);
  color: var(--f-text);
  background: linear-gradient(#4a3578, #36255a);
  border: 2px solid var(--f-line);
  box-shadow: 0 5px 0 var(--f-plum-shadow), 0 12px 20px rgba(0, 0, 0, 0.4), inset 0 2px 0 rgba(255, 255, 255, 0.18);
  transition: transform var(--f-t), box-shadow var(--f-t), filter var(--f-t);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}
.btn .ico {
  font-size: 0.95em;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.35));
}
.btn:hover {
  transform: translateY(-3px);
  filter: brightness(1.08);
  box-shadow: 0 8px 0 var(--f-plum-shadow), 0 16px 24px rgba(0, 0, 0, 0.42), inset 0 2px 0 rgba(255, 255, 255, 0.18);
}
.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--f-plum-shadow), 0 5px 10px rgba(0, 0, 0, 0.4), inset 0 2px 0 rgba(255, 255, 255, 0.12);
}
.btn.primary {
  color: #3a2208;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
  background: linear-gradient(#ffdb85, #ffa94d);
  border-color: transparent;
  box-shadow: 0 6px 0 var(--f-gold-shadow), 0 14px 22px rgba(0, 0, 0, 0.45), inset 0 2px 0 rgba(255, 255, 255, 0.55);
}
.btn.primary:hover {
  box-shadow: 0 9px 0 var(--f-gold-shadow), 0 18px 26px rgba(0, 0, 0, 0.45), inset 0 2px 0 rgba(255, 255, 255, 0.55), 0 0 26px rgba(255, 207, 107, 0.45);
}
.btn.primary:active {
  box-shadow: 0 2px 0 var(--f-gold-shadow), 0 6px 10px rgba(0, 0, 0, 0.4), inset 0 2px 0 rgba(255, 255, 255, 0.4);
}
/* A soft light sweeps across the main button now and then. */
.btn.primary::after {
  content: '';
  position: absolute;
  top: -20%;
  left: 0;
  width: 38%;
  height: 140%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
  animation: shine 3.6s ease-in-out infinite;
  pointer-events: none;
}
.btn.danger {
  color: #fff;
  background: linear-gradient(#ff8f8f, #e04a5a);
  border-color: transparent;
  box-shadow: 0 5px 0 #8f1f2f, 0 12px 20px rgba(0, 0, 0, 0.45), inset 0 2px 0 rgba(255, 255, 255, 0.4);
}
.btn.danger:hover {
  box-shadow: 0 8px 0 #8f1f2f, 0 16px 24px rgba(0, 0, 0, 0.45), inset 0 2px 0 rgba(255, 255, 255, 0.4);
}
.btn.danger:active {
  box-shadow: 0 1px 0 #8f1f2f, 0 5px 10px rgba(0, 0, 0, 0.4), inset 0 2px 0 rgba(255, 255, 255, 0.3);
}
.btn.sm {
  padding: 8px 18px;
  font-size: 14px;
  box-shadow: 0 4px 0 var(--f-plum-shadow), 0 8px 14px rgba(0, 0, 0, 0.35), inset 0 2px 0 rgba(255, 255, 255, 0.18);
}
.btn.big {
  padding: 16px 40px;
  font-size: 22px;
}
.btn.wide {
  width: min(360px, 84vw);
}
.btn:disabled {
  filter: grayscale(1) brightness(0.7);
  cursor: not-allowed;
  transform: none;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin-top: 16px;
}

/* Keyboard / controller focus: always visible. */
.btn:focus-visible,
.choice:focus-visible,
.switch:focus-visible,
.select:focus-visible,
.ui-lang select:focus-visible,
input[type='range']:focus-visible,
.made-by a:focus-visible {
  outline: 4px solid var(--f-gold);
  outline-offset: 3px;
}

/* ---------- Main menu ---------- */
#menu {
  gap: 12px;
  padding-bottom: 40px;
}
.menu-top {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ui-lang {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px 0 12px;
  height: 38px;
  border-radius: 999px;
  background: var(--f-dark);
  border: 2px solid var(--f-line);
  font-size: 15px;
}
.ui-lang select {
  height: 30px;
  font: 700 14px var(--f-font);
  color: var(--f-text);
  background: transparent;
  border: 0;
  border-radius: 999px;
  padding: 0 6px;
  cursor: pointer;
}
.ui-lang option,
.select option {
  color: #111;
  font-weight: 600;
}
.menu-cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  width: min(1200px, 100%);
}
.card-race {
  display: flex;
  flex-direction: column;
}
.card-race .cta {
  margin-top: auto;
  padding-top: 15px;
  padding-bottom: 15px;
  align-self: center;
  font-family: var(--f-title);
  font-weight: 900;
  letter-spacing: 1.5px;
}
.card-race .choices + .cta,
.card-race .paints + .cta {
  margin-top: 16px;
}

/* Choice tiles: languages, levels, cars, paints. */
.choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 8px;
}
.choice {
  padding: 8px 5px 7px;
  border-radius: 16px;
  border: 2px solid rgba(255, 214, 140, 0.22);
  background: linear-gradient(170deg, rgba(20, 10, 36, 0.62), rgba(20, 10, 36, 0.78));
  color: var(--f-text);
  cursor: pointer;
  font: 600 12.5px/1.2 var(--f-font);
  overflow-wrap: anywhere;
  hyphens: auto;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
  transition: transform var(--f-t), border-color var(--f-t), box-shadow var(--f-t), background var(--f-t);
}
.choice:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: rgba(255, 214, 140, 0.6);
}
.choice b {
  display: block;
  font-size: 23px;
  line-height: 1.1;
  margin-bottom: 3px;
  filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.45));
}
.choice small {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  font-weight: 500;
  color: var(--f-muted);
}
.choice.selected {
  border-color: var(--f-gold);
  background: linear-gradient(170deg, rgba(255, 207, 107, 0.26), rgba(255, 159, 67, 0.16));
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35), 0 0 0 3px rgba(255, 207, 107, 0.3), 0 0 20px rgba(255, 207, 107, 0.35);
}
.choice.selected small {
  color: #ffe3b8;
}
.choice:disabled {
  opacity: 0.5;
  cursor: default;
  filter: grayscale(0.6);
}
.levels .choice {
  padding: 9px 8px 8px;
}
.levels .choice b {
  font: 900 13px/1.2 var(--f-title);
  letter-spacing: 0.5px;
  color: var(--f-gold-light);
  margin-bottom: 4px;
}
.levels .choice.selected b {
  color: #fff;
}
.garage {
  grid-template-columns: repeat(6, 1fr);
}
.choice.car {
  padding: 6px 3px 5px;
}
.choice.car small {
  font-size: 10px;
  margin-top: 1px;
}
.car-thumb {
  display: block;
  width: 100%;
  max-width: 96px;
  height: auto;
  margin: 0 auto;
  filter: drop-shadow(0 4px 3px rgba(0, 0, 0, 0.5));
}
.choice.car:disabled .car-thumb {
  filter: grayscale(1) brightness(0.6);
}
.car-thumb.small {
  display: inline-block;
  width: 48px;
  vertical-align: middle;
}
.paints {
  margin-top: 8px;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
}
.choice.paint small {
  white-space: nowrap;
}
.choice.paint {
  min-width: 0;
  padding: 6px 4px 5px;
}
.choice.paint small {
  font-size: 9.5px;
}
.paint-dot {
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid rgba(255, 246, 228, 0.85);
  vertical-align: middle;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5), inset 0 -4px 6px rgba(0, 0, 0, 0.25);
}
.swatch {
  display: inline-block;
  width: 26px;
  height: 14px;
  border-radius: 4px;
  vertical-align: middle;
}

/* Driver level, memory stats, best time. */
.xp {
  float: right;
  color: var(--f-gold-light);
  letter-spacing: 0.5px;
  text-transform: none;
  font: 700 12px var(--f-font);
}
.xp small {
  color: var(--f-muted);
  font-size: 11px;
}
.xp-bar {
  display: inline-block;
  width: 80px;
  height: 9px;
  border-radius: 999px;
  background: rgba(20, 10, 36, 0.8);
  border: 2px solid rgba(255, 214, 140, 0.35);
  vertical-align: middle;
  overflow: hidden;
}
.xp-bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffd36b, #ff8a4a);
  box-shadow: 0 0 8px rgba(255, 207, 107, 0.6);
}
.mem-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin: 10px 0 0;
  font-size: 12.5px;
}
.mem-stats span {
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--f-dark);
  border: 2px solid rgba(255, 214, 140, 0.3);
  font-weight: 600;
}
.mem-stats .due {
  color: var(--f-gold);
  border-color: rgba(255, 207, 107, 0.6);
}
.best {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: var(--f-muted);
}
.best:empty {
  display: none;
}
.made-by {
  margin: 0;
  font-size: 12.5px;
  color: rgba(255, 246, 228, 0.65);
  text-align: center;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}
.made-by a {
  color: var(--f-gold);
  border-radius: 4px;
}
#menu .foot {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 12px;
  pointer-events: none;
}
#menu .foot a {
  pointer-events: auto;
}

/* ---------- Settings ---------- */
.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 4px;
  min-height: 56px;
  border-bottom: 2px dashed rgba(255, 214, 140, 0.2);
}
.setting .lab {
  font-size: 16px;
  font-weight: 600;
}
.setting .ctl {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.pct {
  min-width: 44px;
  text-align: right;
  color: var(--f-gold);
  font-weight: 800;
}
input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: min(210px, 42vw);
  height: 14px;
  border-radius: 999px;
  background: rgba(20, 10, 36, 0.8);
  border: 2px solid rgba(255, 214, 140, 0.4);
  margin: 0;
}
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(#ffdb85, #ffa94d);
  border: 3px solid #fff4d0;
  box-shadow: 0 3px 0 var(--f-gold-shadow);
  cursor: pointer;
}
input[type='range']::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffb84a;
  border: 3px solid #fff4d0;
  cursor: pointer;
}
.switch {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex: none;
  width: 62px;
  height: 34px;
  margin: 0;
  border-radius: 999px;
  background: rgba(20, 10, 36, 0.8);
  border: 2px solid rgba(255, 214, 140, 0.4);
  cursor: pointer;
  transition: background var(--f-t), border-color var(--f-t);
}
.switch::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #cbbde6;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  transition: transform var(--f-t), background var(--f-t);
}
.switch:checked {
  background: linear-gradient(#6fe08a, #34b862);
  border-color: transparent;
}
.switch:checked::after {
  transform: translateX(28px);
  background: #fff;
}
.select {
  font: 700 15px var(--f-font);
  color: var(--f-text);
  background: rgba(20, 10, 36, 0.8);
  border: 2px solid rgba(255, 214, 140, 0.4);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
}
.setting-note {
  margin: 12px 4px 0;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--f-muted);
}

/* ---------- How to play ---------- */
.dialog.help {
  width: min(820px, calc(100vw - 32px));
}
.howto {
  list-style: none;
  counter-reset: step;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.howto li {
  counter-increment: step;
  position: relative;
  padding: 11px 14px 11px 56px;
  border-radius: 18px;
  background: rgba(20, 10, 36, 0.5);
  border: 2px solid rgba(255, 214, 140, 0.26);
  font-size: 14.5px;
  line-height: 1.45;
  color: #f1e6ff;
}
.howto li::before {
  content: counter(step);
  position: absolute;
  left: 13px;
  top: 11px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font: 900 14px var(--f-title);
  color: #3a2208;
  background: linear-gradient(#ffdb85, #ffa94d);
  box-shadow: 0 3px 0 var(--f-gold-shadow);
}
.howto b {
  color: var(--f-gold-light);
}

/* ---------- Results ---------- */
.dialog.results {
  width: min(680px, calc(100vw - 32px));
  text-align: center;
}
.res-extra {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 2px 0 6px;
}
.res-extra span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(255, 207, 107, 0.16);
  border: 2px solid rgba(255, 207, 107, 0.6);
  color: var(--f-gold-light);
  font-size: 13.5px;
  font-weight: 700;
}
#res-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 12px 0;
}
#res-stats div {
  background: rgba(20, 10, 36, 0.55);
  border: 2px solid rgba(255, 214, 140, 0.25);
  border-radius: 18px;
  padding: 9px 8px 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--f-muted);
}
#res-stats b {
  display: block;
  margin-bottom: 2px;
  font: 900 22px var(--f-title);
  color: var(--f-gold-light);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
}
#res-review h3 {
  margin: 8px 0 6px;
  font-size: 13px;
  text-align: center;
}
#res-review h3:empty {
  display: none;
}
#res-review ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}
#res-review li {
  background: rgba(255, 122, 89, 0.18);
  border: 2px solid rgba(255, 122, 89, 0.55);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 14px;
  font-weight: 600;
}
.results .actions {
  margin-top: 14px;
}

/* ---------- Boot error ---------- */
#boot-error {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(460px, calc(100vw - 32px));
  text-align: center;
  color: var(--f-text);
  font-family: var(--f-font);
}
#boot-error h2 {
  margin: 0 0 10px;
  font: 900 26px var(--f-title);
  color: var(--f-gold-light);
}
#boot-error p {
  line-height: 1.5;
}
#boot-error .cta {
  padding: 12px 30px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(#ffdb85, #ffa94d);
  color: #3a2208;
  font: 900 22px var(--f-title);
  box-shadow: 0 6px 0 var(--f-gold-shadow);
  cursor: pointer;
}

/* ---------- Wide screens (desktop / Steam / Steam Deck) ----------
   Two cards side by side: languages left, race setup right. Everything fits
   1280x720 without scrolling; on 1920x1080 it just breathes more. */
@media (min-width: 1000px) and (min-height: 560px) {
  #menu {
    gap: clamp(12px, 1.8vh, 24px);
    padding-top: 16px;
  }
  .menu-cols {
    grid-template-columns: 1.3fr 1fr;
    gap: clamp(14px, 1.6vw, 24px);
    width: min(1220px, calc(100vw - 64px));
    align-items: stretch;
  }
  .panel.card-langs,
  .panel.card-race {
    padding: clamp(16px, 2vh, 24px) clamp(18px, 1.6vw, 26px);
  }
  #natives,
  #targets {
    grid-template-columns: repeat(6, 1fr);
  }
  /* Room enough here: never split a language name in the middle. */
  #natives .choice,
  #targets .choice {
    overflow-wrap: normal;
    hyphens: none;
    padding: 9px 2px 7px;
  }
  .card-race .cta {
    font-size: clamp(20px, 1.6vw, 26px);
    width: 100%;
  }
  .paints {
    grid-template-columns: repeat(4, 1fr);
  }
  .howto {
    grid-template-columns: 1fr 1fr;
  }
}
@media (min-width: 1600px) and (min-height: 900px) {
  .choice {
    font-size: 14px;
    padding: 11px 6px 9px;
  }
  .choice b {
    font-size: 28px;
  }
  .levels .choice b {
    font-size: 15px;
  }
  .choice small {
    font-size: 12.5px;
  }
  .panel h3 {
    font-size: 13.5px;
  }
  .mem-stats,
  .best {
    font-size: 14px;
  }
  .btn.sm {
    font-size: 16px;
    padding: 10px 22px;
  }
  .ui-lang {
    height: 44px;
  }
  .ui-lang select {
    font-size: 16px;
  }
  .setting .lab {
    font-size: 18px;
  }
  .howto li {
    font-size: 16px;
  }
  .paints {
    grid-template-columns: repeat(8, 1fr);
  }
}

/* Phones: one column, bigger touch targets, the top bar flows with the page. */
@media (max-width: 999px) {
  .menu-top {
    position: static;
    width: 100%;
    justify-content: flex-end;
  }
  .btn.sm .ico + span {
    display: none;
  }
  .logo {
    font-size: clamp(34px, 9vw, 52px);
  }
  .choice {
    padding: 9px 3px 7px;
    font-size: 11.5px;
  }
  .choice b {
    font-size: 20px;
  }
  .levels .choice b {
    font-size: 11px;
  }
  .garage {
    grid-template-columns: repeat(3, 1fr);
  }
  .paints {
    grid-template-columns: repeat(4, 1fr);
  }
  #menu .foot {
    position: static;
  }
  #res-stats {
    gap: 6px;
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .screen,
  .panel,
  .logo,
  .btn.primary::after {
    animation: none;
  }
  .btn,
  .choice,
  .switch,
  .switch::after {
    transition: none;
  }
  .btn:hover,
  .choice:hover:not(:disabled) {
    transform: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  #countdown,
  #billboard.pop,
  #billboard.shake,
  #gear.bump {
    animation: none;
  }
}

/* ---------- Combat mode (docs/COMBATE.md) ---------- */
#combat-canvas { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 19; display: block; }
#combat-canvas[hidden], #combat[hidden] { display: none; }
#combat.screen { display: block; padding: 0; overflow: hidden; z-index: 21; pointer-events: none; background: none; }
#combat .cb-top, #combat .cb-form, #combat .cb-overlay { pointer-events: auto; }
.cb-top { position: absolute; top: 10px; left: 14px; right: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cb-clock { font-size: clamp(22px, 3.4vw, 34px); font-weight: 800; color: #fff; text-shadow: 0 2px 0 rgba(20, 20, 50, 0.6); font-variant-numeric: tabular-nums; }
.cb-score { display: flex; gap: 8px; }
.cb-kos { display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 8px; border-radius: 999px; color: #14172b; font-weight: 800; border: 3px solid rgba(255, 255, 255, 0.7); }
.cb-kos.me { border-color: #14172b; box-shadow: 0 0 0 3px #fff; }
.cb-hp { position: absolute; left: 14px; bottom: 150px; width: min(260px, 44vw); height: 20px; border-radius: 999px; background: rgba(20, 22, 40, 0.8); border: 2px solid rgba(255, 255, 255, 0.55); overflow: hidden; }
.cb-hp-fill { height: 100%; width: 100%; background: #4cf08a; transition: width 0.15s linear, background-color 0.2s; }
.cb-hp-fill[data-level='mid'] { background: #ffc83a; }
.cb-hp-fill[data-level='low'] { background: #ff4d5e; }
.cb-hp-text { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #fff; text-shadow: 0 1px 0 #000; }
.cb-queue { position: absolute; left: 14px; bottom: 178px; display: flex; gap: 6px; min-height: 30px; }
.cb-q { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; background: rgba(20, 22, 40, 0.85); font-size: 17px; border: 2px solid #fff; }
.cb-q.stalled { border-color: #ff4d5e; }
.cb-combo { position: absolute; right: 18px; bottom: 154px; font-size: clamp(26px, 4vw, 44px); font-weight: 900; color: #ffe14a; text-shadow: 0 3px 0 rgba(20, 20, 50, 0.7); }
.cb-combo.hot { color: #ff8a3d; animation: cb-pulse 0.5s ease-in-out infinite alternate; }
@keyframes cb-pulse { to { transform: scale(1.18); } }
.cb-toast { position: absolute; top: 22%; left: 50%; transform: translateX(-50%) scale(0.7); font-size: clamp(26px, 5vw, 52px); font-weight: 900; color: #fff; text-shadow: 0 4px 0 rgba(20, 20, 50, 0.7); opacity: 0; transition: opacity 0.12s, transform 0.12s; white-space: nowrap; }
.cb-toast.show { opacity: 1; transform: translateX(-50%) scale(1); }
.cb-toast.perfect { color: #ffe14a; }
.cb-toast.bad { color: #ff7a8a; }
.cb-toast.wait { color: #cbd5ff; }
.cb-hint { position: absolute; top: 56px; left: 50%; transform: translateX(-50%); padding: 6px 14px; border-radius: 999px; background: rgba(20, 22, 40, 0.75); color: #fff; font-size: 14px; animation: cb-fade 7s forwards; max-width: 92vw; text-align: center; }
@keyframes cb-fade { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }
.cb-plates { position: absolute; left: 0; right: 0; bottom: 64px; display: flex; justify-content: center; gap: 12px; padding: 0 12px; }
.cb-plate { flex: 0 1 200px; min-height: 76px; padding: 8px 12px; border-radius: 16px; background: rgba(20, 22, 40, 0.88); border: 3px solid var(--accent, #fff); color: #fff; transition: transform 0.1s, opacity 0.1s, box-shadow 0.1s; }
.cb-plate.act-attack { --accent: #ff7a3d; }
.cb-plate.act-defense { --accent: #4aa3ff; }
.cb-plate.act-dodge { --accent: #b48cff; }
.cb-plate.act-turbo { --accent: #ffd23f; }
.cb-plate.act-repair { --accent: #4fd18b; }
.cb-plate.golden { border-style: dashed; box-shadow: 0 0 14px #ffd23f; }
.cb-plate.typing { transform: translateY(-6px) scale(1.04); box-shadow: 0 0 18px var(--accent); }
.cb-plate.off { opacity: 0.4; }
.cb-plate-head { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--accent); font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; }
.cb-icon { font-size: 18px; }
.cb-bet { margin-left: auto; padding: 1px 7px; border-radius: 999px; background: #ffd23f; color: #14172b; font-size: 11px; }
.cb-word { margin-top: 4px; font-size: clamp(18px, 2.6vw, 26px); font-weight: 800; line-height: 1.15; }
.cb-plate-hint { margin-top: 2px; font-size: 13px; opacity: 0.8; letter-spacing: 0.12em; font-family: ui-monospace, monospace; }
.cb-form { position: absolute; left: 0; right: 0; bottom: 10px; display: flex; justify-content: center; }
.cb-form input { width: min(440px, 88vw); padding: 10px 16px; border-radius: 14px; border: 3px solid #fff; background: rgba(20, 22, 40, 0.92); color: #fff; font-size: 22px; text-align: center; outline: none; }
.cb-form input:focus { border-color: #ffe14a; }
.cb-form.choked input { border-color: #ff4d5e; opacity: 0.6; }
.cb-form.shake { animation: cb-shake 0.25s; }
@keyframes cb-shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.cb-overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(10, 12, 28, 0.72); }
.cb-overlay[hidden] { display: none; }
.cb-box { display: flex; flex-direction: column; align-items: center; gap: 12px; min-width: min(420px, 90vw); padding: 22px 26px; border-radius: 22px; background: linear-gradient(#2b2150, #1a1438); border: 3px solid #ffd23f; color: #fff; }
.cb-box .title.won { color: #ffe14a; }
.cb-table { width: 100%; display: flex; flex-direction: column; gap: 4px; }
.cb-row { display: grid; grid-template-columns: 1.2fr 1fr 1fr 1.2fr; gap: 8px; padding: 6px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.07); text-align: center; align-items: center; }
.cb-row.head { background: none; font-size: 12px; text-transform: uppercase; opacity: 0.7; }
.cb-row.me { background: rgba(255, 210, 63, 0.22); font-weight: 800; }
.cb-name { display: flex; align-items: center; gap: 8px; text-align: left; }
.cb-name i { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
@media (max-width: 640px) {
  .cb-plates { bottom: 62px; gap: 6px; }
  .cb-plate { padding: 6px 8px; min-height: 64px; }
  .cb-hp { bottom: 140px; }
  .cb-queue { bottom: 168px; }
}
@media (prefers-reduced-motion: reduce) {
  .cb-combo.hot, .cb-form.shake, .cb-hint { animation: none; }
  .cb-plate { transition: none; }
}

#start-combat { width: 100%; }
.cb-reward { font-size: 22px; font-weight: 900; color: #ffe14a; }
.cb-unlock { font-size: 14px; color: #fff; font-weight: 700; }

.cb-cat { margin-left: auto; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-size: 13px; }
.cb-bet + .cb-cat { margin-left: 6px; }
.cb-weapon { position: absolute; left: 14px; bottom: 206px; display: flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; background: rgba(20, 22, 40, 0.85); border: 2px solid #fff; color: #fff; }
.cb-weapon[hidden] { display: none; }
.cb-weapon-icon { font-size: 18px; margin-right: 2px; }
.cb-weapon i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: rgba(255, 255, 255, 0.25); }
.cb-weapon i.on { background: #ffe14a; }
.cb-weapon small { color: #ffe14a; letter-spacing: 1px; min-width: 14px; }
.cb-special { position: absolute; left: 14px; bottom: 134px; width: min(260px, 44vw); height: 8px; border-radius: 999px; background: rgba(20, 22, 40, 0.8); border: 1px solid rgba(255, 255, 255, 0.5); overflow: hidden; }
.cb-special-fill { height: 100%; width: 0; background: #b48cff; transition: width 0.15s linear; }
.cb-special.ready .cb-special-fill { background: #ffe14a; animation: cb-pulse 0.4s ease-in-out infinite alternate; }
.cb-boss { position: absolute; left: 50%; bottom: 148px; transform: translateX(-50%); width: min(560px, 90vw); padding: 8px 18px; border-radius: 18px; background: linear-gradient(#3a2a00, #1d1500); border: 3px solid #ffe14a; box-shadow: 0 0 22px #ffe14a; color: #fff; text-align: center; pointer-events: none; }
.cb-boss[hidden] { display: none; }
.cb-boss-head { font-size: 13px; font-weight: 800; color: #ffe14a; text-transform: uppercase; letter-spacing: 0.06em; }
.cb-boss-word { margin-top: 2px; font-size: clamp(18px, 2.4vw, 24px); font-weight: 800; line-height: 1.2; }
.cb-boss.typing { transform: translateX(-50%) scale(1.03); box-shadow: 0 0 32px #fff; }
.cb-boss.off { opacity: 0.45; }
@media (max-width: 640px) { .cb-boss { bottom: 138px; padding: 6px 12px; } .cb-weapon { bottom: 196px; } .cb-special { bottom: 126px; } }

.cb-duel { position: absolute; left: 50%; top: 34%; transform: translate(-50%, -50%); width: min(460px, 88vw); padding: 12px 22px 14px; border-radius: 22px; background: linear-gradient(#4a1d00, #240d00); border: 4px solid #ff9a3d; box-shadow: 0 0 28px #ff9a3d; color: #fff; text-align: center; pointer-events: none; animation: cb-pop 0.25s ease-out; }
.cb-duel[hidden] { display: none; }
.cb-duel-head { font-size: 15px; font-weight: 900; color: #ffb866; letter-spacing: 0.1em; }
.cb-duel-word { margin: 4px 0 8px; font-size: clamp(30px, 5vw, 52px); font-weight: 900; line-height: 1.1; }
.cb-duel-time { height: 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.2); overflow: hidden; }
.cb-duel-bar { height: 100%; width: 100%; background: #ff9a3d; }
.cb-duel.typing { box-shadow: 0 0 40px #fff; }
.cb-duel.off { opacity: 0.55; }
@keyframes cb-pop { from { transform: translate(-50%, -50%) scale(0.6); opacity: 0; } }
#combat.dueling .cb-plates, #combat.dueling .cb-boss { opacity: 0.35; }
@media (prefers-reduced-motion: reduce) { .cb-duel { animation: none; } }

.cb-picker { min-width: min(640px, 92vw); }
.cb-arenas { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; width: 100%; }
.cb-arena { flex: 1 1 170px; display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 16px; background: rgba(255, 255, 255, 0.08); border: 3px solid rgba(255, 255, 255, 0.3); color: #fff; cursor: pointer; font: inherit; }
.cb-arena:hover, .cb-arena:focus-visible { border-color: #ffe14a; transform: translateY(-3px); outline: none; }
.cb-arena.current { border-color: #ffd23f; background: rgba(255, 210, 63, 0.18); }
.cb-arena-strip { display: flex; height: 38px; border-radius: 10px; overflow: hidden; }
.cb-arena-strip i { flex: 1; }
.cb-arena-name { font-weight: 800; font-size: 16px; }

/* ---------- Modo toque (celular, paisagem) ----------
   `html.toque` vem de src/toque.js. O campo de resposta sobe para o alto da tela:
   o teclado virtual ocupa a metade de baixo e a pista/placa continuam visíveis. */
html.toque,
html.toque body {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
html.toque input {
  -webkit-user-select: text;
  user-select: text;
}
html.toque #scene,
html.toque #combat-canvas {
  touch-action: none;
}
html.toque .chip {
  min-width: 48px;
  min-height: 48px;
  display: inline-grid;
  place-items: center;
  font-size: 16px;
}
html.toque .btn,
html.toque .choice,
html.toque .cb-arena {
  min-height: 48px;
}
html.toque select,
html.toque input[type='checkbox'].switch {
  min-height: 44px;
}

/* Corrida: campo no alto, entre os botões e o velocímetro. */
html.toque #answer-form {
  top: max(6px, env(safe-area-inset-top));
  bottom: auto;
  left: 50%;
  width: min(360px, 42vw);
}
html.toque #answer {
  padding: 8px 12px;
  font-size: 22px;
}
html.toque .top-left {
  top: 4px;
  left: max(8px, env(safe-area-inset-left));
}
html.toque #progress {
  top: auto;
  bottom: 10px;
  width: min(420px, 50vw);
}
html.toque #board-wrap {
  top: 64px;
}
html.toque #billboard {
  padding: 6px 16px 4px;
}
html.toque #prompt {
  font-size: 34px;
}
html.toque #prompt.long {
  font-size: 24px;
}
html.toque #rpm {
  margin-top: 4px;
}
html.toque #speedo {
  top: 4px;
  right: max(8px, env(safe-area-inset-right));
}
html.toque #speedo #speed {
  font-size: 28px;
}
html.toque #gear-dots,
html.toque .unit,
html.toque #remaining,
html.toque #streak {
  display: none;
}
html.toque #feed {
  display: none;
}

/* Combate: campo no alto; placas e vida ficam embaixo (acima do teclado, que redimensiona o conteúdo). */
html.toque .cb-form {
  top: 50px;
  bottom: auto;
}
html.toque .cb-form input {
  width: min(360px, 42vw);
  padding: 8px 14px;
  font-size: 20px;
}
html.toque .cb-top {
  top: 4px;
  left: max(8px, env(safe-area-inset-left));
  right: max(8px, env(safe-area-inset-right));
  pointer-events: none;
}
html.toque .cb-top .chip,
html.toque .cb-top button {
  pointer-events: auto;
}
html.toque .cb-hint {
  top: 104px;
}
html.toque .cb-toast {
  top: 110px;
}
html.toque .cb-top .chip {
  min-width: 48px;
  min-height: 48px;
}

/* Menus em paisagem: duas colunas e tudo mais compacto. */
@media (max-height: 520px) and (min-width: 600px) {
  html.toque #menu {
    gap: 8px;
    padding-top: 8px;
  }
  html.toque .logo {
    font-size: 34px;
  }
  html.toque .tagline {
    font-size: 12px;
    margin-top: 2px;
  }
  html.toque .menu-cols {
    grid-template-columns: 1.3fr 1fr;
    width: calc(100vw - 32px);
    gap: 10px;
    align-items: start;
  }
  html.toque .panel {
    padding: 10px 12px;
  }
  html.toque #natives,
  html.toque #targets {
    grid-template-columns: repeat(6, 1fr);
  }
  html.toque .choice {
    padding: 4px 2px;
    font-size: 11px;
  }
  html.toque .choice b {
    font-size: 16px;
  }
  html.toque .garage {
    grid-template-columns: repeat(6, 1fr);
  }
  html.toque .dialog {
    max-height: calc(100vh - 16px);
    overflow: auto;
  }
  html.toque .cb-box {
    padding: 12px 18px;
    gap: 8px;
    max-height: calc(100vh - 12px);
    overflow: auto;
  }
  html.toque .cb-plates {
    bottom: 8px;
  }
  html.toque .cb-hp {
    bottom: 100px;
  }
  html.toque .cb-special {
    bottom: 90px;
  }
  html.toque .cb-queue {
    bottom: 128px;
  }
  html.toque .cb-weapon {
    bottom: 154px;
  }
  html.toque .cb-boss {
    bottom: 104px;
  }
  html.toque .cb-combo {
    bottom: 110px;
  }
}
@media (max-height: 520px) and (min-width: 600px) {
  html.toque #menu {
    overflow-x: hidden;
  }
  html.toque .levels .choice b {
    font-size: 13px;
  }
  html.toque .card-race .cta,
  html.toque #start-combat {
    position: sticky;
    bottom: 6px;
    z-index: 3;
    box-shadow: 0 -10px 14px -6px rgba(11, 6, 40, 0.9);
  }
  html.toque #start-combat {
    bottom: 6px;
  }
  html.toque .card-race .cta {
    bottom: 62px;
  }
}
@media (max-height: 520px) and (min-width: 600px) {
  html.toque .card-race .cta,
  html.toque #start-combat {
    min-height: 48px;
    padding-top: 6px;
    padding-bottom: 6px;
    font-size: 17px;
  }
  html.toque .card-race .cta {
    bottom: 60px;
  }
}

/* Teclado virtual aberto em paisagem (~200px de altura útil): compacta a placa. */
@media (max-height: 260px) {
  html.toque #progress {
    top: 58px;
    bottom: auto;
    left: max(8px, env(safe-area-inset-left));
    transform: none;
    width: 26vw;
  }
  html.toque #board-wrap {
    top: 56px;
  }
  html.toque #billboard {
    padding: 4px 12px 2px;
  }
  html.toque #prompt {
    font-size: 26px;
  }
  html.toque #prompt.long {
    font-size: 18px;
  }
  html.toque #ask,
  html.toque #hint {
    display: none;
  }
  html.toque #reveal {
    margin-top: 2px;
    padding: 2px 8px;
    font-size: 18px;
  }
  html.toque #rpm {
    margin-top: 2px;
  }
  html.toque #toast {
    margin-top: 4px;
  }
  html.toque .cb-plate {
    min-height: 0;
    padding: 4px 8px;
  }
  html.toque .cb-word {
    font-size: 16px;
    margin-top: 0;
  }
  html.toque .cb-plate-hint {
    display: none;
  }
}

/* Duelo e chefe: ficam abaixo do campo (que está no alto), nunca atrás dele. */
@media (max-height: 520px) {
  html.toque .cb-duel {
    top: 100px;
    padding: 6px 18px 8px;
    width: min(420px, 60vw);
  }
  html.toque .cb-duel-word {
    margin: 2px 0 4px;
    font-size: clamp(22px, 5vw, 34px);
  }
}

/* Entrada por voz: botão 🎤 ao lado do campo (só aparece onde há reconhecimento de voz). */
#answer-form,
.cb-form {
  align-items: center;
  gap: 8px;
}
#answer-form:has(.mic:not([hidden])) {
  display: flex;
}
#answer-form #answer {
  flex: 1;
  min-width: 0;
}
.mic {
  flex: none;
  width: 48px;
  height: 48px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
  color: #fff;
  background: rgba(20, 30, 90, 0.75);
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 12px;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
}
.mic[hidden] {
  display: none;
}
.mic.ouvindo {
  background: #e23b50;
  border-color: #fff;
  animation: mic-pulso 0.9s ease-in-out infinite;
}
@keyframes mic-pulso {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(255, 77, 94, 0.8);
  }
  50% {
    box-shadow: 0 0 0 12px rgba(255, 77, 94, 0);
  }
}
html.toque .mic {
  width: 56px;
  height: 56px;
  font-size: 28px;
}
@media (prefers-reduced-motion: reduce) {
  .mic.ouvindo {
    animation: none;
  }
}
/* Aviso curto da voz no combate: menor que os avisos de KO/UFA, não cobre o duelo. */
.cb-toast.voz,
html.toque .cb-toast.voz {
  top: auto;
  bottom: 38%;
  font-size: clamp(16px, 2.6vw, 24px);
  color: #ffe14a;
  text-shadow: 0 2px 0 rgba(20, 20, 50, 0.85);
  background: rgba(20, 22, 40, 0.8);
  padding: 6px 14px;
  border-radius: 12px;
}

/* Estado da voz: "Ouvindo…", "Ouvi: «x»", resultado. Fica logo abaixo do campo. */
.mic-estado {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 6px;
  padding: 4px 12px;
  max-width: 90vw;
  white-space: nowrap;
  font: 800 15px Inter, sans-serif;
  color: #fff;
  background: rgba(20, 22, 40, 0.9);
  border-radius: 10px;
  pointer-events: none;
  opacity: 0;
  z-index: 5;
}
.mic-estado.show { opacity: 1; }
.mic-estado.ouvindo { color: #ff9aa6; }
.mic-estado.ok { color: #6dffb0; }
.mic-estado.erro { color: #ffe14a; }
.cb-form { position: absolute; }

/* Com o estado da voz na tela, a dica do combate sai da frente. */
.cb-form:has(.mic-estado.show) ~ .cb-hint { opacity: 0; }

/* Modo toque (paisagem, pouca altura): o estado fica ao lado do 🎤, sem cobrir a placa. */
html.toque .mic-estado {
  top: 50%;
  left: 100%;
  transform: translateY(-50%);
  margin: 0 0 0 8px;
  width: 190px;
  max-width: 24vw;
  white-space: normal;
  text-align: left;
  font-size: 14px;
  line-height: 1.15;
}

/* Celular baixo (~360px): menu sem título longo, idiomas sem quebrar palavra e Correr/Combate lado a lado numa linha que gruda junta (antes ocupavam 120px e cobriam os cards). */
.cta-row { display: contents; }
@media (max-height: 400px) and (min-width: 600px) {
  html.toque .tagline { display: none; }
  html.toque .logo { font-size: 26px; }
  html.toque .choice { font-size: 9.5px; letter-spacing: 0; overflow-wrap: normal; word-break: normal; hyphens: none; }
  html.toque .cta-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; position: sticky; bottom: 4px; z-index: 3; padding-top: 8px; background: linear-gradient(to bottom, rgba(11, 6, 40, 0), rgba(11, 6, 40, 0.92) 35%); }
  html.toque .cta-row > .btn { position: static; width: 100%; min-height: 44px; font-size: 15px; margin: 0; box-shadow: none; }
}
