/* Paleta "pista de juguete" acordada en el concept art: azul cobalto de fondo,
   naranja de pista y amarillo turbo de acento. Sin Google Fonts (la CSP del
   sitio no las permite): se imita el look pedido (Lilita One + Figtree) con
   pilas de fuentes del sistema. */
:root {
  --blue: #0f3ab5;
  --blue-2: #061a5c;
  --track: #ff6b00;
  --gold: #ffd600;
  --paper: #ffffff;
  --ink: #e4e7ee;
  --muted: #c9ced8;
  --avance: #1b7f35;
  --arranque: #ffb800;
  --ataque: #d62b2b;
  --remedio: #1c6fc7;
  --proteccion: #6b46d9;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: ui-rounded, "Arial Rounded MT Bold", "Baloo 2", Impact, var(--font);
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(170deg, var(--blue), var(--blue-2) 60%);
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100dvh;
}

/* La franja a cuadros de arriba, como en el concept art. */
.strip { height: 10px; background: repeating-linear-gradient(90deg, #ffffff 0 12px, transparent 12px 24px) center/100% 3px no-repeat, var(--track); }

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px calc(14px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 100vh;
  min-height: 100dvh;
}
#app > .strip:first-child { margin: 0 -16px 4px; }

#app.game {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  padding-top: calc(0px + env(safe-area-inset-top));
}
#app.game > * { flex-shrink: 0; }

h1, h2, h3, p { margin: 0; }
h1 { font-family: var(--font-display); font-weight: 800; font-size: 40px; line-height: 1; letter-spacing: 0.4px; color: var(--gold); text-shadow: 0 3px 0 var(--track); text-align: center; }
h2 { font-size: 22px; font-weight: 800; text-align: center; color: var(--paper); }
.sub { font-size: 14px; color: var(--ink); font-weight: 700; text-align: center; }

button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.btn {
  border: 2px solid #ffffff;
  background: transparent;
  border-radius: 14px;
  padding: 0 14px;
  min-height: 48px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.3px;
  color: #ffffff;
}
.btn.primary { background: var(--gold); border-color: var(--gold); color: #0b1440; box-shadow: 0 4px 0 #b38f00; }
.btn.quiet { background: transparent; border-color: transparent; color: var(--muted); font-family: var(--font); font-size: 14px; font-weight: 700; }
.btn.warn { border-color: #ff8a5c; color: #ff8a5c; }
.btn:disabled { opacity: 0.4; box-shadow: none; }
.btn.full { width: 100%; }
.btn.big { min-height: 62px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: 19px; }
.btn.big small { font-family: var(--font); font-size: 13px; font-weight: 700; letter-spacing: 0; color: inherit; }

.panel { background: rgba(255, 255, 255, 0.08); border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.panel h3 { font-size: 13px; font-weight: 800; color: var(--gold); }
.spacer { flex: 1; }
.center { align-items: center; text-align: center; }

.topbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px; }
.pill { font-size: 12px; font-weight: 800; color: #ffffff; background: rgba(255, 255, 255, 0.12); padding: 5px 12px; border-radius: 999px; }
.pill.warn { color: #4a1400; background: #ff8a5c; }
.pill-btn { border: 2px solid rgba(255, 255, 255, 0.28); min-height: 32px; color: #ffffff; }

.code-input {
  width: 100%;
  text-align: center;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  font: 800 26px var(--font-display);
  color: var(--gold);
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid #ffffff;
  border-radius: 14px;
  padding: 14px 8px 14px 16px;
}

.alias-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.alias-btn {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.24);
  border-radius: 14px; padding: 10px 12px; min-height: 52px; text-align: left; font-weight: 800; font-size: 14px;
  color: #ffffff;
}
.alias-btn:disabled { opacity: 0.4; }

.dot { position: relative; width: 32px; height: 32px; border-radius: 50%; background: var(--c); flex-shrink: 0; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #0b1440; }
.dot.big { width: 44px; height: 44px; font-size: 18px; }
.dot.away { outline: 2px dashed rgba(255, 255, 255, 0.7); outline-offset: 2px; }
.dot.away::before { content: ""; position: absolute; inset: 0; border-radius: 50%; background: rgba(6, 26, 92, 0.55); }
.dot.bot { border-radius: 9px; color: #0b1440; }
.dot.bot .gear { width: 70%; height: 70%; margin: 0; }
.gear { width: 1em; height: 1em; }
.badge-off { position: absolute; right: -6px; bottom: -6px; width: 16px; height: 16px; border-radius: 50%; background: #ff8a5c; border: 2px solid var(--blue-2); display: grid; place-items: center; }
.badge-off svg { width: 10px; height: 10px; }

/* ---------- Sala de espera: asientos y "libre" ---------- */
.seats { display: flex; flex-direction: column; gap: 6px; }
.seat { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 6px 10px; border-radius: 14px; background: rgba(255, 255, 255, 0.1); }
.seat.free { background: transparent; border: 2px dashed rgba(255, 255, 255, 0.32); }
.seat .snm { flex: 1; font-size: 15px; font-weight: 800; color: #ffffff; }
.seat .snm.muted { color: var(--muted); font-weight: 700; }
.seat .tag { margin-left: 6px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.18); color: #ffffff; }
.seat .btn { min-height: 40px; padding: 0 12px; font-size: 13px; }
.big-code { font-family: var(--font-display); font-size: 44px; letter-spacing: 0.16em; font-weight: 800; color: var(--gold); padding-left: 0.16em; }

/* ---------- Partida: pista de cada jugador ---------- */
/* Con hasta 6 jugadores esta lista puede no caber entera en un celular chico:
   a diferencia de las demás secciones (que no se achican, ver "#app.game > *"
   arriba), esta sí se encoge y, si aun así no entra, se desliza dentro de su
   propio espacio — la pantalla del juego nunca hace scroll completo. */
.lanes { display: flex; flex-direction: column; gap: 5px; flex-shrink: 1; min-height: 0; max-height: 42dvh; overflow-y: auto; overscroll-behavior: contain; }
.lane { width: 100%; display: flex; align-items: center; gap: 8px; min-height: var(--lane-h, 56px); padding: 6px 10px; background: rgba(6, 26, 92, 0.55); color: #ffffff; border: 2px solid rgba(255, 255, 255, 0.22); border-radius: 14px; text-align: left; }
.lane.you { box-shadow: 0 0 0 3px var(--gold); }
.lane.aim { box-shadow: 0 0 0 3px var(--ataque), 0 0 16px rgba(214, 43, 43, 0.55); }
.lane.off { opacity: 0.5; }
.lane:disabled { cursor: default; }
.lane-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.lane-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.lane-nm { font-size: 13px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill.ok { background: #d3f9d8; color: #14602a; }
.pill.bad { background: #ffe0e0; color: #a61e1e; }
.pill.lim { background: #fff0c9; color: #7a4b00; }
.pill.esc { background: #e9e2ff; color: #45259e; }
.pill.tap { background: var(--ataque); color: #ffffff; }
.rail { position: relative; height: 12px; margin-right: 8px; border-radius: 4px; background: repeating-linear-gradient(90deg, #ffffff 0 9px, transparent 9px 18px) center/100% 2px no-repeat, var(--track); }
.rail .fill { position: absolute; left: 0; top: 0; bottom: 0; width: var(--w, 0%); border-radius: 4px; background: rgba(6, 26, 92, 0.42); }
.rail .car { position: absolute; top: 50%; left: var(--w, 0%); transform: translate(-50%, -60%); line-height: 0; width: 40px; }
.rail .car svg { width: 100%; height: auto; display: block; }
.rail .fin { position: absolute; right: -7px; top: 50%; width: 11px; height: 11px; transform: translateY(-50%); border-radius: 2px; background: conic-gradient(#0b1440 25%, #ffffff 0 50%, #0b1440 0 75%, #ffffff 0) 0 0 / 6px 6px; }
.lane-side { width: 60px; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.km { font-family: var(--font-display); font-size: 16px; }
.km small { font-family: var(--font); font-size: 10px; font-weight: 700; }
.prots { display: flex; gap: 2px; min-height: 12px; }
.prots svg { width: 12px; height: 12px; }

/* ---------- Última jugada ---------- */
.lastmove { display: flex; flex-direction: column; gap: 2px; text-align: left; background: rgba(255, 255, 255, 0.1); border: 0; border-radius: 14px; padding: 8px 12px; min-height: 44px; color: #ffffff; }
.lm-label { font-size: 10px; font-weight: 800; color: var(--gold); text-transform: uppercase; letter-spacing: 0.04em; }
.lm-text { font-size: 13px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.who { color: var(--c); font-weight: 800; }

.status { text-align: center; font-weight: 800; font-size: 15px; color: var(--gold); min-height: 22px; }
.status.warn { color: #ffb58f; }
.status.urgent { color: #ff8a5c; }

/* ---------- Mano y ficha inferior ---------- */
.hand-zone { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.hand { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; align-content: start; }
.hcard { min-height: 80px; padding: 0; border: 0; border-radius: 12px; background: var(--paper); color: #0b1440; display: flex; flex-direction: column; overflow: hidden; text-align: left; box-shadow: 0 6px 12px -8px rgba(0, 0, 0, 0.6); }
.hcard.up { box-shadow: 0 0 0 3px var(--gold), 0 10px 14px -8px rgba(0, 0, 0, 0.6); }
.hcard:disabled { opacity: 0.55; }
/* En tu turno, pero esta carta no se puede jugar ahora (solo descartar):
   se ve pálida en vez de apagada, para no confundirla con "no es tu turno". */
.hcard.dim { filter: saturate(0.3) brightness(1.12); }
.hcard .hb { display: flex; justify-content: space-between; align-items: baseline; padding: 3px 8px; font-size: 10.5px; font-weight: 700; background: var(--k); color: var(--kt); }
.hcard .hb b { font-family: var(--font-display); font-weight: 800; font-size: 13px; }
.hcard .hm { flex: 1; display: flex; align-items: center; gap: 6px; padding: 2px 6px 6px 8px; }
.hcard .hm svg { flex-shrink: 0; width: 26px; height: 26px; }
.hcard .hn { font-weight: 800; font-size: 12px; line-height: 1.15; }

.dock { padding: 10px 12px; border-radius: 14px; background: rgba(255, 255, 255, 0.1); color: #ffffff; display: flex; flex-direction: column; gap: 8px; }
.dock p { margin: 0; font-size: 14px; line-height: 1.3; }
.dock .hint { font-weight: 800; color: var(--gold); }
.dock-btns { display: grid; grid-template-columns: 1fr 1.5fr; gap: 8px; }

.hint { font-size: 12px; color: var(--muted); text-align: center; font-weight: 700; }

/* ---------- Ventanas modales (mismo patrón que Jardín Encantado) ---------- */
.modal-backdrop { position: fixed; inset: 0; height: 100vh; height: 100dvh; background: rgba(6, 14, 40, 0.75); display: grid; place-items: center; padding: 16px; z-index: 5; }
.modal { width: min(440px, 100%); max-height: 92vh; max-height: 92dvh; overflow: auto; background: linear-gradient(170deg, var(--blue), var(--blue-2)); border: 2px solid rgba(255, 255, 255, 0.2); border-radius: 22px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.choices { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Historial ---------- */
.log-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 60vh; max-height: 60dvh; overflow-y: auto; overscroll-behavior: contain; }
.log-item { display: flex; align-items: center; gap: 10px; background: rgba(255, 255, 255, 0.08); border-radius: 14px; padding: 8px 10px; }
.log-item.latest { box-shadow: 0 0 0 2px var(--gold); }
.log-item .dot { width: 28px; height: 28px; font-size: 12px; }
.log-text { flex: 1; font-size: 13px; font-weight: 600; line-height: 1.35; color: #ffffff; }

/* ---------- Fin de carrera ---------- */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 8px; margin-top: 4px; }
.pcol { flex: 1; max-width: 116px; display: flex; flex-direction: column; align-items: center; gap: 4px; color: #ffffff; }
.pcol b { font-size: 12px; text-align: center; line-height: 1.15; }
.pbar { width: 100%; height: var(--h, 60px); display: grid; place-items: center; border-radius: 10px 10px 0 0; background: var(--pc, #3a4150); }
.pbar i { font-family: var(--font-display); font-style: normal; font-size: 28px; color: var(--pi, #ffffff); }
.finrow { display: flex; align-items: center; gap: 10px; padding: 5px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.1); color: #ffffff; }
.finrow.win { background: var(--gold); color: #0b1440; }
.finpos { font-family: var(--font-display); font-size: 16px; width: 18px; text-align: center; }
.finnm { flex: 1; font-size: 14px; font-weight: 800; }
.finkm { font-family: var(--font-display); font-size: 15px; }

/* ---------- Reglas (pantalla completa, como Jardín Encantado) ---------- */
.back { align-self: flex-start; }
.rules p { font-size: 14px; font-weight: 600; line-height: 1.45; color: var(--ink); }
.info-list { display: flex; flex-direction: column; gap: 10px; }
.info-row { display: flex; gap: 12px; align-items: flex-start; background: rgba(255, 255, 255, 0.08); border-left: 5px solid var(--c); border-radius: 14px; padding: 10px 12px; }
.info-icon { width: 36px; height: 36px; flex-shrink: 0; color: var(--c); }
.info-icon svg { width: 100%; height: 100%; }
.info-text p { margin: 2px 0 0; font-size: 13px; font-weight: 600; line-height: 1.35; color: var(--ink); }
.info-text b { color: #ffffff; }

.gap-16 { height: 16px; }
.gap-40 { height: 40px; }
.link { align-self: center; color: var(--muted); font-size: 13px; font-weight: 700; text-decoration: underline; padding: 8px; }
.link:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

#toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #ff8a5c; color: #3a1400; font-weight: 800; padding: 12px 18px; border-radius: 14px; max-width: 90vw; z-index: 10; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); }
#toast[hidden] { display: none; }

@media (max-height: 720px) {
  #app { gap: 8px; }
  .hcard .hb, .pill { font-size: 10px; }
}
