:root {
  --yellow: #ffcc00;
  --orange: #ff6a00;
  --red: #e2231a;
  --ink: #141018;
  --paper: #fff8e6;
  --panel: rgba(20, 16, 24, 0.82);
  --display: 'Bangers', Impact, 'Arial Black', sans-serif;
  --text: 'Nunito', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #111;
  color: var(--paper);
  font-family: var(--text);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; }

#loading {
  position: fixed; inset: 0; display: grid; place-items: center; text-align: center;
  background: #1a1420; font: 32px var(--display); letter-spacing: 2px; z-index: 50; padding: 16px;
}

/* ---------- Pantallas ---------- */
.screen {
  position: fixed; inset: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 16px;
}
.screen.dim { background: rgba(10, 6, 16, 0.62); backdrop-filter: blur(3px); }
.screen h2 {
  font: 54px var(--display); letter-spacing: 3px; margin: 0; color: var(--yellow);
  text-shadow: 3px 3px 0 var(--ink), -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 0 6px 18px rgba(0,0,0,.6);
}

#screen-title { background: radial-gradient(ellipse at center, rgba(0,0,0,0) 30%, rgba(0,0,0,.55) 100%); }

.logo { text-align: center; line-height: 0.85; transform: rotate(-3deg); margin-bottom: 10px; }
.logo-top {
  font: 64px var(--display); color: #fff; letter-spacing: 12px;
  text-shadow: 4px 4px 0 var(--red), 7px 7px 0 var(--ink);
}
.logo-main {
  font: clamp(64px, 13vw, 150px) var(--display); letter-spacing: 4px;
  background: linear-gradient(180deg, #fff3a0 0%, var(--yellow) 40%, var(--orange) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: 3px var(--ink);
  filter: drop-shadow(6px 6px 0 var(--ink)) drop-shadow(0 10px 20px rgba(0,0,0,.5));
}
.logo-sub {
  display: inline-block; margin-top: 12px; padding: 6px 18px;
  font: 30px var(--display); letter-spacing: 3px; color: var(--ink);
  background: repeating-linear-gradient(-45deg, var(--yellow) 0 18px, #f5b800 18px 36px);
  border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink);
}

.big-btn {
  font: 40px var(--display); letter-spacing: 3px; color: var(--ink);
  background: linear-gradient(180deg, #ffe45c, var(--yellow) 45%, var(--orange));
  border: 4px solid var(--ink); border-radius: 16px; padding: 10px 38px;
  box-shadow: 0 7px 0 var(--ink), 0 12px 24px rgba(0,0,0,.45);
  transition: transform .08s ease, box-shadow .08s ease;
}
.big-btn:hover { transform: translateY(-2px) scale(1.03); }
.big-btn:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--ink); }
#btn-play { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }

.small-btn {
  font: 24px var(--display); letter-spacing: 2px; color: var(--paper);
  background: #2c2533; border: 3px solid var(--ink); border-radius: 12px; padding: 8px 22px;
  box-shadow: 0 5px 0 var(--ink);
}
.small-btn:hover { background: #3c3346; }
.small-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }

.controls {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 16px; max-width: 760px;
  background: var(--panel); padding: 12px 18px; border-radius: 14px; font-size: 15px;
}
kbd {
  display: inline-block; min-width: 24px; padding: 1px 6px; margin-right: 3px; text-align: center;
  background: #fff; color: var(--ink); border-radius: 5px; border-bottom: 3px solid #999; font: 800 13px var(--text);
}
.obstacles-list { font-size: 14px; opacity: .85; text-align: center; max-width: 700px; text-shadow: 0 1px 3px #000; }

.corner-btns { position: absolute; right: 16px; top: 16px; display: flex; gap: 8px; }
.round {
  width: 46px; height: 46px; border-radius: 50%; border: 3px solid var(--ink); background: var(--yellow); color: var(--ink);
  display: grid; place-items: center; padding: 8px; box-shadow: 0 4px 0 var(--ink);
}
.round svg { width: 100%; height: 100%; }
.round.off { background: #777; position: relative; }
.round.off::after { content: ''; position: absolute; width: 4px; height: 44px; background: var(--red); transform: rotate(45deg); border-radius: 2px; }

/* ---------- Selección ---------- */
#screen-select { justify-content: space-between; padding: 18px 16px 22px; }
#screen-select h2 { font-size: 46px; }
.arrow {
  position: absolute; top: 40%; width: 74px; height: 74px; border-radius: 50%;
  font-size: 34px; color: var(--ink); background: var(--yellow); border: 4px solid var(--ink);
  box-shadow: 0 6px 0 var(--ink); display: grid; place-items: center;
}
.arrow.left { left: 4vw; }
.arrow.right { right: 4vw; }
.arrow:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.panel {
  width: min(620px, 100%); background: var(--panel); border: 3px solid rgba(255,255,255,.08);
  border-radius: 18px; padding: 14px 20px 16px; display: flex; flex-direction: column; gap: 8px;
  box-shadow: 0 14px 40px rgba(0,0,0,.45);
}
#truck-dots { display: flex; gap: 8px; justify-content: center; }
#truck-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #000; opacity: .45; }
#truck-dots i.on { opacity: 1; transform: scale(1.3); }
#truck-name {
  font: 50px var(--display); letter-spacing: 3px; text-align: center; line-height: 1;
  text-shadow: 3px 3px 0 var(--ink), -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink);
}
#truck-desc { text-align: center; font-size: 16px; min-height: 22px; }
#truck-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 22px; }
.stat { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 900; font-size: 15px; }
.bar { display: flex; gap: 4px; }
.bar i { width: 22px; height: 12px; border-radius: 3px; background: #3a3342; transform: skewX(-15deg); }
.bar i.on { background: linear-gradient(90deg, var(--yellow), var(--orange)); }
.opts { display: flex; flex-wrap: wrap; gap: 10px 22px; justify-content: center; margin-top: 4px; }
.opt { display: flex; align-items: center; gap: 6px; font-weight: 900; }
.opt span { margin-right: 4px; }
.opt button {
  font: 900 15px var(--text); padding: 5px 12px; border-radius: 9px; border: 2px solid #000; background: #3a3342; color: var(--paper);
}
.opt button.sel { background: var(--yellow); color: var(--ink); }
#truck-record { text-align: center; font-size: 14px; color: var(--yellow); min-height: 18px; }
.row { display: flex; gap: 14px; justify-content: center; align-items: center; flex-wrap: wrap; }

/* ---------- HUD (uno por jugador) ---------- */
.hud { position: fixed; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; z-index: 10; font-family: var(--display); letter-spacing: 1px; overflow: hidden; }
.hud .h-pos {
  position: absolute; left: 18px; top: 10px; line-height: 1; color: #fff;
  font-size: 84px; text-shadow: 4px 4px 0 var(--ink), -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink);
}
.hud .pos-suf { font: 900 40px var(--text); vertical-align: top; color: var(--yellow); margin-left: 2px; }
.hud .pos-total { font-size: 34px; opacity: .85; }
.hud .h-lap {
  position: absolute; left: 22px; top: 100px; font-size: 30px; color: var(--yellow);
  text-shadow: 2px 2px 0 var(--ink), -1px -1px 0 var(--ink);
}
.hud .h-lap b { color: #fff; font-weight: normal; }
.hud .ranking {
  position: absolute; left: 16px; top: 146px; margin: 0; padding: 0; list-style: none;
  font: 800 14px var(--text); letter-spacing: 0;
}
.hud .ranking li {
  display: flex; align-items: center; gap: 6px; padding: 3px 10px 3px 6px; margin-bottom: 3px;
  background: rgba(0,0,0,.45); border-radius: 8px; width: 160px;
}
.hud .ranking li.me { background: rgba(255, 204, 0, .9); color: var(--ink); }
.hud .ranking li.other { background: rgba(60, 160, 255, .75); }
.hud .ranking li.done::after { content: ''; margin-left: auto; width: 14px; height: 10px; background: conic-gradient(#000 25%, #fff 0 50%, #000 0 75%, #fff 0) 0 0 / 7px 5px; border: 1px solid #000; }
.hud .ranking i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #000; flex: none; }
.hud .h-time {
  position: absolute; right: 18px; top: 14px; text-align: right; font-size: 38px; color: #fff;
  text-shadow: 3px 3px 0 var(--ink), -1px -1px 0 var(--ink);
}
.hud .time-best { font: 800 15px var(--text); color: var(--yellow); }
.hud .h-item {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%);
  width: 96px; height: 96px; border-radius: 18px; background: rgba(0,0,0,.55);
  border: 4px solid rgba(255,255,255,.75); display: grid; place-items: center;
}
.hud .h-item.ready { border-color: var(--yellow); animation: itemGlow 0.8s ease-in-out infinite; }
.hud .h-item.rolling { border-color: #ff4fd8; }
@keyframes itemGlow { 50% { box-shadow: 0 0 22px var(--yellow); } }
.hud .item-slot { width: 72px; height: 72px; }
.hud .item-slot svg { width: 100%; height: 100%; }
.hud .item-name {
  position: absolute; top: 100px; white-space: nowrap; font-size: 20px; color: #fff;
  text-shadow: 2px 2px 0 var(--ink);
}
.hud .keyhint { position: absolute; bottom: -46px; font: 800 11px var(--text); opacity: 0; white-space: nowrap; text-shadow: 0 1px 2px #000; }
.hud .h-item.ready .keyhint { opacity: .9; }
.hud .minimap {
  position: absolute; right: 14px; bottom: 120px; width: 190px; height: 190px;
  background: rgba(10, 30, 10, .45); border-radius: 50%; border: 3px solid rgba(255,255,255,.35);
}
.hud .h-speed {
  position: absolute; right: 22px; bottom: 22px; text-align: right; color: #fff;
  font-size: 64px; line-height: 1; text-shadow: 3px 3px 0 var(--ink), -1px -1px 0 var(--ink);
}
.hud .h-speed small { font-size: 22px; margin-left: 4px; color: var(--yellow); }
.hud .boost-bar { width: 170px; height: 12px; margin-top: 6px; margin-left: auto; background: rgba(0,0,0,.5); border-radius: 6px; overflow: hidden; border: 2px solid var(--ink); }
.hud .boost-fill { height: 100%; width: 0; background: linear-gradient(90deg, #39c6ff, #a26bff); }
.hud .h-msg {
  position: absolute; left: 50%; top: 26%; transform: translate(-50%, -50%) scale(.6); opacity: 0;
  font-size: 54px; color: #fff; white-space: nowrap; transition: transform .15s ease, opacity .15s ease;
  text-shadow: 3px 3px 0 var(--ink), -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink);
}
.hud .h-msg.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.hud .h-msg.warn { color: var(--yellow); font-size: 64px; }
.hud .h-msg.gold { color: #ffc81e; font-size: 64px; top: 16%; }
.hud .h-big.top { top: 16%; }
.hud .h-big.small.top { font-size: 80px; }
.hud .h-big {
  position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); opacity: 0;
  font-size: 200px; color: var(--yellow); white-space: nowrap;
  text-shadow: 6px 6px 0 var(--ink), -3px -3px 0 var(--ink), 3px -3px 0 var(--ink), -3px 3px 0 var(--ink);
}
.hud .h-big.show { animation: bigPop .9s ease-out forwards; }
.hud .h-big.small { font-size: 96px; }
.hud .h-big.go { color: #3dff6e; }
@keyframes bigPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(2.2); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(.9); }
}
.hud .h-big.small.show { animation-duration: 1.6s; }
.hud .h-hint {
  position: absolute; left: 50%; bottom: 16%; transform: translateX(-50%); opacity: 0;
  font-size: 34px; color: #ff4040; text-shadow: 2px 2px 0 var(--ink); white-space: nowrap; transition: opacity .2s;
}
.hud .h-hint.show { opacity: 1; animation: blink .6s step-end infinite; }
@keyframes blink { 50% { opacity: .35; } }
.hud .h-tag {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  font-size: 26px; padding: 2px 14px; border-radius: 10px; border: 3px solid var(--ink);
  background: var(--yellow); color: var(--ink);
}
.hud .h-tag.p2 { background: #3ca0ff; }
.hud.div-top { border-top: 4px solid var(--ink); }
.hud.div-left { border-left: 4px solid var(--ink); }

/* HUD compacto: pantalla partida o móvil */
.hud.compact .h-pos { font-size: 56px; }
.hud.compact .pos-suf { font-size: 28px; }
.hud.compact .pos-total { font-size: 24px; }
.hud.compact .h-lap { top: 66px; font-size: 22px; left: 18px; }
.hud.compact .ranking { display: none; }
.hud.compact .h-time { font-size: 26px; }
.hud.compact .h-item { width: 70px; height: 70px; top: 10px; }
.hud.compact .item-slot { width: 50px; height: 50px; }
.hud.compact .item-name { top: 72px; font-size: 16px; }
.hud.compact .minimap { width: 120px; height: 120px; right: 10px; bottom: auto; top: 60px; }
.hud.compact .h-speed { font-size: 40px; bottom: 14px; right: 14px; }
.hud.compact .h-speed small { font-size: 16px; }
.hud.compact .boost-bar { width: 110px; }
.hud.compact .h-msg { font-size: 34px; }
.hud.compact .h-msg.warn, .hud.compact .h-msg.gold { font-size: 40px; }
.hud.compact .h-big { font-size: 120px; }
.hud.compact .h-big.small { font-size: 54px; }
.hud.compact .h-big.small.top { font-size: 44px; }
.hud.compact .h-hint { font-size: 22px; bottom: 30%; }
.hud.compact .h-tag { font-size: 20px; bottom: 8px; }

#btn-pause {
  position: fixed; left: 14px; bottom: 14px; z-index: 12; width: 44px; height: 44px; border-radius: 50%;
  border: 3px solid var(--ink); background: rgba(255,255,255,.85); font: 900 16px var(--text); color: var(--ink);
}

/* ---------- Resultados ---------- */
#res-table { border-collapse: separate; border-spacing: 0 5px; font: 800 20px var(--text); min-width: min(440px, 100%); }
#res-table td { padding: 7px 14px; background: rgba(0,0,0,.5); }
#res-table td:first-child { border-radius: 10px 0 0 10px; font: 26px var(--display); color: var(--yellow); }
#res-table td:last-child { border-radius: 0 10px 10px 0; text-align: right; font-variant-numeric: tabular-nums; }
#res-table tr.me td { background: rgba(255, 204, 0, .92); color: var(--ink); }
#res-table tr.me2 td { background: rgba(60, 160, 255, .92); color: #fff; }
#res-table .tag { font: 18px var(--display); letter-spacing: 1px; margin-left: 8px; padding: 0 6px; border-radius: 6px; background: var(--ink); color: #fff; }
#res-table i { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #000; margin-right: 8px; vertical-align: -1px; }
#res-extra { font-weight: 900; color: var(--yellow); text-align: center; }

/* ---------- Controles táctiles ---------- */
#touch { position: fixed; inset: auto 0 0 0; z-index: 11; display: flex; justify-content: space-between; padding: 0 16px 18px; pointer-events: none; }
#touch button {
  pointer-events: auto; width: 84px; height: 84px; border-radius: 50%; border: 3px solid rgba(255,255,255,.7);
  background: rgba(0,0,0,.35); color: #fff; font-size: 30px; touch-action: none;
}
#touch button.on { background: rgba(255, 204, 0, .7); color: var(--ink); }
#touch .tleft, #touch .tright { display: flex; gap: 14px; align-items: flex-end; }
#touch .tgas { width: 100px; height: 100px; background: rgba(40, 200, 80, .45); }
#touch .titem { margin-bottom: 70px; background: rgba(255, 79, 216, .45); }

/* ---------- Pantallas pequeñas ---------- */
@media (max-width: 720px) {
  .logo-top { font-size: 40px; }
  .logo-sub { font-size: 20px; }
  .big-btn { font-size: 30px; padding: 8px 26px; }
  .controls { font-size: 12px; }
  .obstacles-list { display: none; }
  #screen-select h2 { font-size: 32px; }
  .arrow { width: 54px; height: 54px; font-size: 24px; top: 30%; }
  #truck-name { font-size: 36px; }
  #truck-desc { font-size: 14px; }
  #truck-stats { grid-template-columns: 1fr; }
  .panel { padding: 10px 14px 12px; gap: 6px; }
  #btn-pause { left: auto; bottom: 130px; right: 16px; }
  #touch button { width: 70px; height: 70px; }
  #touch .tgas { width: 86px; height: 86px; }
}

/* Selección en pantallas anchas: camión a la izquierda, panel a la derecha */
@media (min-width: 900px) {
  #screen-select .panel {
    position: absolute; right: 3vw; top: 50%; transform: translateY(-50%);
    width: min(470px, 42vw);
  }
  #screen-select h2 { position: absolute; top: 22px; left: 0; width: calc(100% - min(470px, 42vw) - 3vw); text-align: center; }
  #screen-select #truck-stats { grid-template-columns: 1fr; }
  .arrow.right { right: calc(min(470px, 42vw) + 6vw); }
  .arrow { top: 46%; }
}
.bar i { background: #4d4458; }

/* ---------- Modo de juego y dos jugadores ---------- */
.mode-row { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.mode-row .big-btn.sel { outline: 5px solid #fff; outline-offset: 3px; }
#btn-play2 { background: linear-gradient(180deg, #9fd4ff, #3ca0ff 45%, #1f63c9); }
#btn-play, #btn-play2 { animation: none; }
.mode-row .big-btn.sel { animation: pulse 1.4s ease-in-out infinite; }
#select-who {
  align-self: center; font: 26px var(--display); letter-spacing: 2px; padding: 2px 16px; border-radius: 10px;
  border: 3px solid var(--ink); background: var(--yellow); color: var(--ink);
}
#select-who.p2 { background: #3ca0ff; }
#select-keys { text-align: center; font-size: 13px; opacity: .85; }
#truck-dots i.taken { opacity: .15; }
.opt-screen2 .note { font-size: 12px; font-weight: 700; opacity: .8; }

/* Ventana del jugador 2 */
body.screen2 #screen2-wait {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  text-align: center; padding: 20px; background: #1a1420; z-index: 30; font-size: 18px;
}
body.screen2 #screen2-wait h2 { font: 54px var(--display); color: #3ca0ff; margin: 0; text-shadow: 3px 3px 0 var(--ink); }
#screen2-wait { display: none; }

#fps { position: fixed; left: 50%; bottom: 6px; transform: translateX(-50%); z-index: 50; padding: 2px 10px; border-radius: 8px;
  background: rgba(0,0,0,.6); color: #9f9; font: 13px/1.4 monospace; pointer-events: none; white-space: pre; text-align: center; }

.opt-circuit { flex-wrap: wrap; }
.circuit-opts { display: inline-flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.circuit-desc { margin: 2px 0 8px; font-size: 13px; opacity: .85; text-align: center; min-height: 1.2em; }

/* ---------- Foco de mando y teclado (se ve a varios metros de la tele) ---------- */
@keyframes focusGlow { 50% { box-shadow: 0 0 0 4px var(--ink), 0 0 30px 12px rgba(255, 204, 0, .8); } }
body.nav-on button.focus {
  outline: 5px solid #fff; outline-offset: 4px;
  box-shadow: 0 0 0 4px var(--ink), 0 0 18px 6px rgba(255, 204, 0, .55);
  animation: focusGlow 1s ease-in-out infinite;
  transform: scale(1.08);
}
body.nav-on .small-btn.focus { background: var(--yellow); color: var(--ink); }
body.nav-on .opt.focus {
  outline: 4px solid var(--yellow); outline-offset: 5px; border-radius: 10px;
  background: rgba(255, 204, 0, .16); box-shadow: 0 0 22px 4px rgba(255, 204, 0, .35);
}
body.nav-on .opt.focus > span:first-child { color: var(--yellow); }
body.nav-on .opt.focus > span:first-child::before { content: '◀ '; }
body.nav-on .opt.focus > span:first-child::after { content: ' ▶'; }
body.nav-on #truck-name.focus { text-decoration: underline 5px var(--yellow); text-underline-offset: 8px; }
.round.on { background: #fff; }

/* Controles del mando en la portada */
.pad-controls { align-items: center; }
.pad-controls > b { font: 18px var(--display); letter-spacing: 2px; color: var(--yellow); }
kbd.pad-a, kbd.pad-b, kbd.pad-x, kbd.pad-y { min-width: 22px; border-radius: 50%; color: #fff; border-bottom-color: rgba(0,0,0,.45); }
kbd.pad-a { background: #2fa84f; }
kbd.pad-b { background: #d7261e; }
kbd.pad-x { background: #2b6fd6; }
kbd.pad-y { background: #e8b400; color: var(--ink); }

/* ---------- Selección: que el panel quepa entero (también con dos jugadores) ---------- */
.panel { touch-action: pan-y; scrollbar-width: none; }
.panel::-webkit-scrollbar { display: none; }
#screen-select .panel { flex: 0 1 auto; min-height: 0; overflow-y: auto; }
#screen-select .panel > * { flex-shrink: 0; }
.opt-cup button { min-width: 0; }
.cup-route { color: var(--yellow); opacity: 1; font-weight: 900; }
@media (min-width: 900px) {
  #screen-select .panel { max-height: calc(100% - 20px); padding: 12px 18px 14px; gap: 6px; }
  #screen-select #truck-stats { grid-template-columns: 1fr 1fr; gap: 4px 16px; }
  #screen-select .stat { font-size: 14px; }
  #screen-select .bar i { width: 16px; height: 11px; }
  #truck-name { font-size: 44px; }
  #screen-select .opts { gap: 7px 18px; margin-top: 2px; }
  #screen-select .opt button { padding: 4px 10px; font-size: 14px; }
  #screen-select .circuit-desc { margin: 0; }
  #screen-select .row .big-btn { font-size: 34px; padding: 6px 30px; }
  #screen-select .row .small-btn { font-size: 22px; padding: 6px 18px; }
}
@media (min-width: 900px) and (max-height: 760px) {
  #screen-select .panel { padding: 8px 16px 10px; gap: 4px; }
  #truck-name { font-size: 36px; }
  #truck-desc { font-size: 14px; min-height: 0; }
  #select-who { font-size: 20px; padding: 0 12px; }
  #truck-dots i { width: 11px; height: 11px; }
  #screen-select .opts { gap: 5px 16px; }
  #screen-select .opt button { padding: 3px 9px; }
  .opt-screen2 .note { font-size: 11px; line-height: 1.25; }
  #select-keys { font-size: 12px; }
  #truck-record { font-size: 13px; min-height: 0; }
  #screen-select .circuit-desc { font-size: 12px; }
  #screen-select .row .big-btn { font-size: 30px; padding: 4px 26px; }
}
/* móvil apaisado: panel a la derecha, como en las pantallas anchas */
@media (max-width: 899px) and (min-width: 600px) and (max-height: 500px) and (orientation: landscape) {
  #screen-select { padding: 8px; }
  #screen-select h2 { position: absolute; top: 8px; left: 0; width: 55%; text-align: center; font-size: 30px; }
  #screen-select .panel { position: absolute; right: 8px; top: 8px; bottom: 8px; width: 45%; max-height: none; padding: 8px 12px; gap: 4px; }
  .arrow { top: 45%; width: 48px; height: 48px; font-size: 22px; }
  .arrow.left { left: 2vw; }
  .arrow.right { right: calc(45% + 24px); }
  #truck-name { font-size: 28px; }
  #select-who { font-size: 18px; padding: 0 10px; }
  #truck-dots i { width: 10px; height: 10px; }
  .opt-circuit { flex-wrap: nowrap; }
  .circuit-opts { flex-wrap: wrap; justify-content: flex-start; }
  #truck-desc, #truck-record, #select-keys, .circuit-desc { font-size: 12px; min-height: 0; }
  #truck-stats { grid-template-columns: 1fr; gap: 2px; }
  .stat { font-size: 12px; }
  .bar i { width: 14px; height: 9px; }
  .opts { gap: 5px 10px; }
  .opt { font-size: 13px; }
  .opt button { padding: 3px 8px; font-size: 13px; }
  #screen-select .row .big-btn { font-size: 24px; padding: 4px 18px; }
  #screen-select .row .small-btn { font-size: 18px; padding: 4px 12px; }
}

/* ---------- Campeonato ---------- */
.cup-badge {
  font: 28px var(--display); letter-spacing: 2px; color: var(--ink); padding: 3px 18px; border-radius: 10px;
  background: repeating-linear-gradient(-45deg, var(--yellow) 0 16px, #f5b800 16px 32px);
  border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); text-align: center;
}
.res-tables { display: flex; gap: 24px; align-items: flex-start; justify-content: center; }
#screen-results.cup #res-table { min-width: 0; }
@media (max-width: 720px) and (orientation: portrait) { .res-tables { flex-wrap: wrap; } }
.res-tables h3, .podium-panel h3 { font: 26px var(--display); letter-spacing: 2px; color: var(--yellow); margin: 0 0 2px; text-align: center; text-shadow: 2px 2px 0 var(--ink); }
#res-table td.pts { color: #3dff6e; font: 22px var(--display); letter-spacing: 1px; }
#res-table tr.me td.pts { color: #0a6a22; }
.cup-table { border-collapse: separate; border-spacing: 0 5px; font: 800 20px var(--text); min-width: min(300px, 100%); }
.cup-table td { padding: 7px 14px; background: rgba(0,0,0,.5); }
.cup-table td:first-child { border-radius: 10px 0 0 10px; font: 26px var(--display); color: var(--yellow); }
.cup-table td:last-child { border-radius: 0 10px 10px 0; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cup-table td small { font-size: 13px; opacity: .8; }
.cup-table tr.me td { background: rgba(255, 204, 0, .92); color: var(--ink); }
.cup-table tr.me2 td { background: rgba(60, 160, 255, .92); color: #fff; }
.cup-table .tag { font: 18px var(--display); letter-spacing: 1px; margin-left: 8px; padding: 0 6px; border-radius: 6px; background: var(--ink); color: #fff; }
.cup-table i { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #000; margin-right: 8px; vertical-align: -1px; }
#screen-results.cup { gap: 10px; }
#screen-results.cup h2 { font-size: 46px; }
#screen-results.cup #res-table td { padding: 5px 12px; }
#screen-results.cup .cup-table td { padding: 5px 12px; }
@media (max-height: 560px) {
  #screen-results.cup { gap: 5px; padding: 6px; }
  #screen-results.cup .row + .row { margin-top: 6px; }
  #screen-results.cup h2 { font-size: 28px; }
  .cup-badge { font-size: 18px; padding: 1px 12px; }
  .res-tables { gap: 12px; }
  .res-tables h3 { display: none; }
  #screen-results.cup #res-table, #screen-results.cup .cup-table { font-size: 13px; border-spacing: 0 2px; }
  #screen-results.cup #res-table td, #screen-results.cup .cup-table td { padding: 2px 8px; }
  #screen-results.cup #res-table td:first-child, #screen-results.cup .cup-table td:first-child { font-size: 16px; }
  #screen-results.cup #res-extra { font-size: 12px; }
  #screen-results.cup .big-btn { font-size: 20px; padding: 2px 16px; border-width: 3px; box-shadow: 0 4px 0 var(--ink); }
  #screen-results.cup .small-btn { font-size: 15px; padding: 1px 12px; }
  #screen-results.cup .row { gap: 8px; }
  #screen-results.cup #res-table td, #screen-results.cup .cup-table td { padding: 1px 8px; }
  #screen-results.cup .cup-table td:first-child, #screen-results.cup #res-table td:first-child { font-size: 14px; }
  #screen-results.cup td.pts { font-size: 15px; }
}

#screen-cupnext { background: radial-gradient(ellipse at center, #3a2050 0%, #1a1420 70%); z-index: 40; }
#screen-cupnext h2 { font-size: 64px; text-align: center; }
.cupnext-wait { font: 900 18px var(--text); opacity: .8; margin: 0; }

#cup-banner {
  position: fixed; left: 50%; top: 72%; transform: translateX(-50%); z-index: 15; pointer-events: none; white-space: nowrap;
  font: 36px var(--display); letter-spacing: 2px; color: var(--ink); padding: 4px 22px; border-radius: 12px;
  background: repeating-linear-gradient(-45deg, var(--yellow) 0 18px, #f5b800 18px 36px);
  border: 4px solid var(--ink); box-shadow: 4px 4px 0 var(--ink);
}
body.two #cup-banner { top: 50%; transform: translate(-50%, -50%); }
@media (max-width: 720px), (max-height: 500px) { #cup-banner { font-size: 22px; padding: 2px 14px; } }

#screen-podium { justify-content: flex-start; overflow: hidden; }
.podium-head { position: absolute; top: 18px; left: 0; width: calc(100% - min(440px, 40vw) - 3vw); text-align: center; z-index: 1; }
#podium-title { font-size: 64px; }
#screen-podium.ai #podium-title { font-size: 52px; color: #fff; }
#podium-sub { font: 900 20px var(--text); text-shadow: 0 2px 4px #000; margin-top: 4px; }
.podium-panel { position: absolute; right: 3vw; top: 50%; transform: translateY(-50%); width: min(440px, 40vw); max-height: calc(100% - 20px); overflow-y: auto; z-index: 1; }
.podium-panel .cup-table { width: 100%; font-size: 17px; border-spacing: 0 4px; }
.podium-panel .cup-table td { padding: 5px 10px; }
#podium-record { text-align: center; font-size: 14px; color: var(--yellow); font-weight: 900; }
.podium-panel .big-btn { font-size: 30px; padding: 6px 22px; }
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 2px; animation: confettiFall linear infinite; }
.confetti i:nth-child(3n) { width: 8px; height: 8px; border-radius: 50%; }
@keyframes confettiFall {
  0% { transform: translate3d(0, -20px, 0) rotate(0deg); }
  50% { transform: translate3d(30px, 50vh, 0) rotate(360deg); }
  100% { transform: translate3d(-20px, 105vh, 0) rotate(720deg); }
}
@media (max-width: 899px) and (orientation: portrait) {
  .podium-head { width: 100%; }
  .podium-panel { top: auto; bottom: 10px; transform: none; left: 10px; right: 10px; width: auto; max-height: 52%; }
}
@media (max-height: 560px) {
  #podium-title { font-size: 34px; }
  #screen-podium.ai #podium-title { font-size: 30px; }
  #podium-sub { font-size: 14px; }
  .podium-head { top: 8px; }
  .podium-panel { padding: 8px 12px; gap: 4px; }
  .podium-panel h3 { font-size: 18px; }
  .podium-panel .cup-table { font-size: 13px; border-spacing: 0 2px; }
  .podium-panel .cup-table td { padding: 2px 8px; }
  .podium-panel .cup-table td:first-child { font-size: 16px; }
  .podium-panel .big-btn { font-size: 20px; padding: 4px 14px; }
  .podium-panel .small-btn { font-size: 16px; padding: 3px 12px; }
}

/* ---------- Truco de la salida (portada) ---------- */
.start-tip { font: 18px var(--display); letter-spacing: 1px; color: var(--yellow); text-align: center; text-shadow: 0 2px 0 var(--ink), 0 0 6px #000; }
@media (max-width: 720px) { .start-tip { font-size: 15px; } }
