/* ───────────── ¡Quizzo! — estilos ───────────── */
:root {
  --night: #0d1b2a;
  --night-2: #1b2a41;
  --night-3: #24395a;
  --ink: #0d1b2a;
  --paper: #ffffff;
  --muted: #9fb3c8;
  --spark: #ffd23f;
  --spark-dark: #d9a800;
  /* Colores de respuesta con contraste AA para su texto (--on): blanco sobre coral y azul (≥4,5:1),
     tinta sobre ámbar y menta (≥7:1). */
  --a0: #d93a48; --a0-d: #a12631;
  --a1: #2a6fc9; --a1-d: #1d5698;
  --a2: #f7a21b; --a2-d: #b8740a;
  --a3: #20bf8e; --a3-d: #138263;
  --good: #20bf8e;
  --bad: #d93a48;
  --field-border: #7b8ca1; /* 3,4:1 sobre blanco (límite de controles, WCAG 1.4.11) */
  --focus-ring: #ffffff; /* sobre fondo oscuro; dentro de tarjetas blancas se redefine */
  --radius: 18px;
  --font-display: 'Lilita One', 'Arial Rounded MT Bold', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--paper);
  background: radial-gradient(1200px 800px at 15% -10%, #2b4c7e 0%, transparent 60%),
              radial-gradient(900px 700px at 110% 110%, #1f6f6a 0%, transparent 55%),
              var(--night);
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }

/* Fondo animado con formas flotantes */
.bg-shapes { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.bg-shapes svg {
  position: absolute; width: 120px; height: 120px; opacity: .07; fill: #fff;
}
.bg-shapes svg:nth-child(1) { left: 6%; top: 12%; }
.bg-shapes svg:nth-child(2) { left: 82%; top: 8%; width: 160px; height: 160px; }
.bg-shapes svg:nth-child(3) { left: 70%; top: 70%; }
.bg-shapes svg:nth-child(4) { left: 12%; top: 75%; width: 90px; height: 90px; }
.bg-shapes svg:nth-child(5) { left: 45%; top: 40%; width: 70px; height: 70px; }
@keyframes float {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33% { transform: translate(30px, -40px) rotate(40deg); }
  66% { transform: translate(-25px, 25px) rotate(-30deg); }
}

#app {
  position: relative; z-index: 1; min-block-size: 100dvh; display: flex; flex-direction: column;
  /* Zonas seguras (notch, esquinas redondeadas) en modo pantalla completa del móvil */
  padding-inline: env(safe-area-inset-left, 0px) env(safe-area-inset-right, 0px);
}

/* ───── Logo ───── */
.logo {
  font-family: var(--font-display);
  font-size: clamp(3rem, 1.5rem + 10vw, 6rem);
  line-height: 1;
  color: var(--spark);
  letter-spacing: 1px;
  text-shadow: 0 6px 0 var(--spark-dark), 0 12px 30px rgba(0,0,0,.35);
  display: inline-flex; align-items: center; gap: .1em;
  transform: rotate(-3deg);
}
.logo svg { width: .8em; height: .8em; fill: var(--spark); filter: drop-shadow(0 4px 0 var(--spark-dark)); animation: zap 2.4s ease-in-out 3; }
.logo.small { font-size: 2.125rem; text-shadow: 0 3px 0 var(--spark-dark); transform: rotate(-2deg); }
@keyframes zap {
  0%, 85%, 100% { transform: rotate(0) scale(1); }
  90% { transform: rotate(-15deg) scale(1.2); }
  95% { transform: rotate(10deg) scale(1.1); }
}

/* ───── Botones ───── */
.btn {
  --c: var(--spark); --cd: var(--spark-dark); --t: var(--ink);
  border: 0; cursor: pointer;
  background: var(--c); color: var(--t);
  font-family: var(--font-display); font-size: 1.25rem; letter-spacing: .5px;
  padding: 14px 26px; border-radius: 14px;
  box-shadow: 0 6px 0 var(--cd);
  transform: translateY(0);
  transition: transform .08s, box-shadow .08s, filter .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--cd); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: grayscale(.4); }
:where(a, button, input, select, textarea, [tabindex]):focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 3px; }
.card, .pin-box, .qr-box, .board-row, .player-bottom, .toast { --focus-ring: var(--a1-d); }
.btn.big { font-size: 1.75rem; padding: 18px 40px; }
.btn.sm { font-size: 1rem; padding: 9px 16px; box-shadow: 0 4px 0 var(--cd); border-radius: 11px; }
.btn.sm:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--cd); }
.btn.white { --c: #fff; --cd: #b9c6d6; --t: var(--ink); }
.btn.dark { --c: var(--night-3); --cd: #111f33; --t: #fff; }
.btn.red { --c: var(--a0); --cd: var(--a0-d); --t: #fff; }
.btn.blue { --c: var(--a1); --cd: var(--a1-d); --t: #fff; }
.btn.green { --c: var(--a3); --cd: var(--a3-d); --t: var(--ink); }
.btn svg { width: 1em; height: 1em; fill: currentColor; }

.icon-btn {
  background: rgba(255,255,255,.12); border: 0; cursor: pointer;
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
}
.icon-btn:hover { background: rgba(255,255,255,.2); }
.icon-btn svg { width: 22px; height: 22px; fill: #fff; }

/* ───── Tarjetas y formularios ───── */
.card {
  background: #fff; color: var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 10px 0 rgba(0,0,0,.18), 0 20px 50px rgba(0,0,0,.25);
  padding: 24px;
}
.field {
  width: 100%; border: 3px solid var(--field-border); border-radius: 12px;
  padding: 14px 16px; font-size: 1.25rem; text-align: center; color: var(--ink);
  background: #fff; transition: border-color .15s;
}
.field:focus { border-color: var(--a1); }
.field.pin { font-family: var(--font-display); font-size: 2rem; letter-spacing: 6px; }

.error-msg {
  background: var(--bad); color: #fff; border-radius: 12px; padding: 10px 14px; margin-top: 12px;
  animation: shake .4s;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.center-stage {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 16px; gap: 26px; text-align: center;
}
.join-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; }
.join-card .btn { width: 100%; }
.footer-link { color: var(--muted); font-size: 0.9375rem; }
.footer-link a { color: #fff; }

/* ───── Barra superior ───── */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; padding-block-start: max(12px, env(safe-area-inset-top, 0px));
  background: rgba(0,0,0,.2); backdrop-filter: blur(6px); flex-wrap: wrap;
}
.topbar .grow { flex: 1; }
.chip {
  background: rgba(255,255,255,.14); border-radius: 999px; padding: 6px 14px;
  font-size: 1rem; white-space: nowrap;
}
.chip.spark { background: var(--spark); color: var(--ink); }

/* ───── Formas de respuesta ───── */
.a0 { --c: var(--a0); --cd: var(--a0-d); --on: #fff; }
.a1 { --c: var(--a1); --cd: var(--a1-d); --on: #fff; }
.a2 { --c: var(--a2); --cd: var(--a2-d); --on: var(--ink); }
.a3 { --c: var(--a3); --cd: var(--a3-d); --on: var(--ink); }

.answers-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: 100%;
}
.answer-tile {
  background: var(--c); box-shadow: 0 7px 0 var(--cd);
  border-radius: 16px; color: var(--on, #fff); border: 0;
  display: flex; align-items: center; gap: 16px;
  padding: 18px 22px; min-height: 90px; text-align: left;
  font-size: clamp(1.125rem, 0.5625rem + 2.4vw, 1.875rem); font-weight: 800;
  text-shadow: 0 2px 0 rgba(0,0,0,.15);
  transition: opacity .3s, transform .3s, filter .3s;
}
.answer-tile .shape { flex: 0 0 auto; width: 1.6em; height: 1.6em; fill: currentColor; filter: drop-shadow(0 3px 0 rgba(0,0,0,.18)); }
.answer-tile .txt { flex: 1; overflow-wrap: anywhere; }
.answer-tile .mark { width: 1.3em; height: 1.3em; fill: currentColor; }
.answer-tile.dim { opacity: .28; filter: grayscale(.6); transform: scale(.97); }

/* Botones de respuesta en el móvil */
.pad-grid { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px; }
.pad-grid.two { grid-template-columns: 1fr; }
.pad-btn {
  background: var(--c); box-shadow: 0 8px 0 var(--cd);
  border: 0; border-radius: 18px; cursor: pointer; color: var(--on, #fff);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 14px; font-size: 1.125rem; font-weight: 800; min-height: 120px;
  transition: transform .08s, box-shadow .08s;
  animation: pop-in .35s cubic-bezier(.3,1.6,.6,1) both;
}
.pad-btn:nth-child(2) { animation-delay: .05s; }
.pad-btn:nth-child(3) { animation-delay: .1s; }
.pad-btn:nth-child(4) { animation-delay: .15s; }
.pad-btn:active { transform: translateY(5px); box-shadow: 0 3px 0 var(--cd); }
.pad-btn svg { width: 64px; height: 64px; fill: currentColor; filter: drop-shadow(0 4px 0 rgba(0,0,0,.18)); }
.pad-btn span { overflow-wrap: anywhere; }

@keyframes pop-in {
  0% { transform: scale(.4); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ───── Pantallas del anfitrión ───── */
.host-wrap { flex: 1; display: flex; flex-direction: column; }
.host-main { container: main / inline-size; flex: 1; display: flex; flex-direction: column; padding: 20px clamp(1rem, 0.5rem + 3vw, 2.5rem) 28px; gap: 20px; }

/* Biblioteca */
.lib-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.lib-head h1 { font-family: var(--font-display); font-weight: 400; font-size: 2.5rem; margin: 0; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 22px; }
.quiz-card { display: flex; flex-direction: column; gap: 10px; padding: 0; overflow: hidden; animation: pop-in .35s both; }
.quiz-card .banner {
  height: 92px; display: flex; align-items: center; justify-content: center; gap: 10px;
  background: linear-gradient(135deg, var(--c), var(--cd));
}
.quiz-card .banner svg { width: 40px; height: 40px; fill: rgba(255,255,255,.85); }
.quiz-card .body { padding: 6px 20px 20px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.quiz-card h2 { font-family: var(--font-display); font-weight: 400; font-size: 1.5rem; margin: 0; }
.quiz-card p { margin: 0; color: #5a6b80; font-weight: 600; }
.quiz-card .meta { color: #5a6b80; font-size: 0.875rem; }
.quiz-card .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 8px; }
.empty { text-align: center; color: var(--muted); padding: 60px 0; font-size: 1.25rem; }

/* Editor */
.editor { max-width: 980px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.editor .card { display: flex; flex-direction: column; gap: 12px; }
.editor label.lbl { font-size: 0.875rem; color: #5a6b80; text-transform: uppercase; letter-spacing: 1px; }
.editor input[type=text], .editor input[type=url], .editor textarea, .editor select {
  width: 100%; border: 3px solid var(--field-border); border-radius: 12px; padding: 11px 14px;
  font-size: 1.125rem; color: var(--ink); background: #fff;
}
.editor input:focus, .editor textarea:focus, .editor select:focus { border-color: var(--a1); }
.editor textarea { resize: vertical; min-height: 60px; }
.editor .title-input { font-family: var(--font-display); font-size: 1.75rem !important; }
.q-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.q-num {
  font-family: var(--font-display); background: var(--night); color: var(--spark);
  border-radius: 10px; padding: 4px 12px; font-size: 1.25rem;
}
.q-head .grow { flex: 1; }
.q-tools { display: flex; gap: 6px; }
.q-tools button {
  border: 0; background: #eef3f8; color: var(--ink); width: 38px; height: 38px; border-radius: 10px;
  cursor: pointer; display: grid; place-items: center;
}
.q-tools button:hover { background: #dde6f0; }
.q-tools button svg { width: 20px; height: 20px; fill: currentColor; }
.q-tools button.del:hover { background: var(--bad); color: #fff; }
.q-settings { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.q-settings > div { display: flex; flex-direction: column; gap: 4px; }
.opt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 10px; background: var(--c); border-radius: 14px; padding: 8px 10px;
  box-shadow: 0 4px 0 var(--cd);
}
.opt { color: var(--on); }
.opt svg.shape { width: 30px; height: 30px; fill: currentColor; flex: 0 0 auto; }
.opt input[type=text] { border: 0 !important; border-radius: 9px !important; font-size: 1.0625rem !important; padding: 9px 11px !important; }
.opt input[type=text]:disabled { background: rgba(255,255,255,.85); }
.correct-toggle {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; border: 3px solid #fff;
  background: transparent; cursor: pointer; display: grid; place-items: center;
}
.correct-toggle { border-color: currentColor; color: inherit; }
.correct-toggle svg { width: 22px; height: 22px; fill: currentColor; opacity: .35; transition: opacity .15s; }
.correct-toggle.on { background: #fff; }
.correct-toggle.on svg { fill: var(--a3-d); opacity: 1; }
.editor-bar {
  position: sticky; bottom: 0; z-index: 5; display: flex; gap: 12px; justify-content: space-between; flex-wrap: wrap;
  padding: 14px 0; background: linear-gradient(transparent, var(--night) 35%);
}
/* Contenedor de avisos (popover="manual" en la capa superior, o fijo si no hay popover) */
.toast-region {
  position: fixed; inset: auto 0 calc(20px + env(safe-area-inset-bottom, 0px)) 0; margin: 0 auto;
  inline-size: min(560px, 100% - 32px); padding: 0; border: 0; background: transparent; overflow: visible;
  display: flex; flex-direction: column; gap: 10px; z-index: 100; pointer-events: none;
}
.toast-region:not([popover]):empty, .toast-region[popover]:not(:popover-open) { display: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; justify-content: space-between;
  background: #fff; color: var(--ink); padding: 12px 18px; border-radius: 18px;
  box-shadow: 0 8px 30px rgba(0,0,0,.35); animation: toast-in .3s cubic-bezier(.3,1.6,.6,1);
}
.toast.bad { background: var(--bad); color: #fff; --focus-ring: #fff; }
.toast-close {
  flex: 0 0 auto; border: 2px solid currentColor; background: transparent; color: inherit; border-radius: 50%;
  inline-size: max(32px, var(--target-size, 24px)); block-size: max(32px, var(--target-size, 24px)); font-size: 1.25rem; line-height: 1; cursor: pointer;
}
@keyframes toast-in { from { transform: translateY(30px); opacity: 0; } }

/* Sala de espera */
.lobby-top { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: stretch; }
.pin-box {
  background: #fff; color: var(--ink); border-radius: var(--radius); padding: 18px 28px;
  display: flex; align-items: center; justify-content: center; gap: 32px; flex-wrap: wrap;
  box-shadow: 0 10px 0 rgba(0,0,0,.18);
}
.pin-box .how { font-size: 1.25rem; color: #5a6b80; }
.pin-box .how b { color: var(--ink); }
.pin-box .pin-label { font-size: 1.125rem; color: #5a6b80; text-transform: uppercase; letter-spacing: 2px; }
.pin-box .pin {
  font-family: var(--font-display); font-size: clamp(3.5rem, 1.75rem + 8vw, 6.5rem); line-height: 1; letter-spacing: 6px;
}
.qr-box { background: #fff; border-radius: var(--radius); padding: 10px; box-shadow: 0 10px 0 rgba(0,0,0,.18); display: grid; place-items: center; }
.qr-box img { width: 190px; height: 190px; display: block; image-rendering: pixelated; }
.lobby-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.lobby-bar .count {
  font-family: var(--font-display); font-size: 1.75rem; display: flex; align-items: center; gap: 10px;
  background: rgba(0,0,0,.25); padding: 8px 18px; border-radius: 14px;
}
.lobby-bar .grow { flex: 1; text-align: center; font-family: var(--font-display); font-size: 1.875rem; }
.players-cloud { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; align-content: flex-start; flex: 1; }
.player-bubble {
  font-family: var(--font-display); font-size: 1.5rem; padding: 10px 20px; border-radius: 14px;
  background: var(--c); box-shadow: 0 5px 0 var(--cd); cursor: pointer; position: relative;
  border: 0; color: var(--on, #fff);
}
.player-bubble.new { animation: bubble-in .5s cubic-bezier(.3,1.8,.5,1) both; }
/* Desconectado: no solo con color/opacidad, también con borde discontinuo */
.player-bubble.off { opacity: .55; outline: 2px dashed currentColor; outline-offset: -5px; }
.player-bubble:not(.static):hover::after {
  content: '✕'; position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(13,27,42,.75); border-radius: 14px; font-size: 1.375rem;
}
@keyframes bubble-in {
  0% { transform: scale(0) rotate(-20deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.waiting-dots { color: var(--muted); font-size: 1.5rem; text-align: center; padding: 40px 0; }
.waiting-dots span { animation: blink 1.4s infinite both; }
.waiting-dots span:nth-child(2) { animation-delay: .2s; }
.waiting-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

/* Pregunta (presentador) */
.q-banner {
  background: #fff; color: var(--ink); border-radius: var(--radius); padding: 22px 28px; text-align: center;
  font-size: clamp(1.5rem, 0.75rem + 3.4vw, 2.875rem); font-weight: 900; line-height: 1.15;
  box-shadow: 0 10px 0 rgba(0,0,0,.18);
  animation: drop-in .45s cubic-bezier(.3,1.5,.6,1) both;
}
@keyframes drop-in { from { transform: translateY(-40px) scale(.95); opacity: 0; } }
.q-middle { flex: 1; display: grid; grid-template-columns: 150px 1fr 150px; align-items: center; gap: 20px; min-height: 180px; }
.q-image { display: flex; justify-content: center; align-items: center; height: 100%; }
.q-image img { max-height: 32dvh; border-radius: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.35); }
.q-image .placeholder svg { width: 160px; height: 160px; fill: rgba(255,255,255,.12); }
.timer { position: relative; width: 130px; height: 130px; justify-self: start; }
.timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 12; }
.timer .track { stroke: rgba(255,255,255,.15); }
.timer .bar { stroke: var(--spark); stroke-linecap: round; transition: stroke .3s; }
.timer.low .bar { stroke: var(--bad); }
.timer .num {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--font-display); font-size: 3rem;
}
.timer.low .num { animation: pulse .5s infinite alternate; color: #ffb3b6; }
@keyframes pulse { to { transform: scale(1.15); } }
.answer-counter { justify-self: end; text-align: center; }
.answer-counter .n { font-family: var(--font-display); font-size: 3.5rem; line-height: 1; }
.answer-counter .l { color: var(--muted); }

/* Cuenta atrás de pregunta */
.countdown-stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; padding: 30px; text-align: center; }
.countdown-stage .qtitle { font-size: clamp(1.875rem, 0.9375rem + 4.5vw, 4rem); font-weight: 900; max-width: 1100px; line-height: 1.15; animation: drop-in .5s both; }
.countdown-bar { width: min(700px, 90%); height: 16px; background: rgba(255,255,255,.15); border-radius: 99px; overflow: hidden; }
.countdown-bar > div { height: 100%; background: var(--spark); border-radius: 99px; transform-origin: left; }
.badge-double {
  font-family: var(--font-display); font-size: 1.75rem; color: var(--ink); background: var(--spark);
  padding: 8px 20px; border-radius: 14px; box-shadow: 0 5px 0 var(--spark-dark);
  animation: wiggle 1s ease-in-out 3;
}
@keyframes wiggle { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg) scale(1.06); } }

/* Revelado (barras) */
.chart { display: flex; justify-content: center; align-items: flex-end; gap: clamp(0.875rem, 0.4375rem + 3vw, 2.5rem); height: 100%; min-height: 200px; }
.chart .col { display: flex; flex-direction: column; align-items: center; gap: 8px; width: clamp(4.375rem, 2.1875rem + 10vw, 8.125rem); height: 100%; justify-content: flex-end; }
.chart .bar {
  width: 100%; background: var(--c); border-radius: 12px 12px 4px 4px; box-shadow: 0 6px 0 var(--cd);
  min-height: 10px; transform-origin: bottom; animation: grow .8s cubic-bezier(.3,1.3,.6,1) both;
}
.chart .col.dim .bar { opacity: .3; }
.chart .lab { display: flex; align-items: center; gap: 6px; font-family: var(--font-display); font-size: 1.75rem; }
.chart .lab svg { width: 28px; height: 28px; fill: #fff; }
@keyframes grow { from { transform: scaleY(0); } }

/* Clasificación */
.board { width: min(900px, 100%); margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.board-row {
  display: grid; grid-template-columns: 54px 1fr auto auto; align-items: center; gap: 16px;
  background: #fff; color: var(--ink); border-radius: 14px; padding: 12px 20px;
  font-size: 1.625rem; font-weight: 900; box-shadow: 0 6px 0 rgba(0,0,0,.2);
  animation: slide-in .5s cubic-bezier(.3,1.3,.6,1) both;
}
.board-row:nth-child(1) { background: var(--spark); }
.board-row .pos { font-family: var(--font-display); font-size: 1.875rem; text-align: center; }
.board-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-row .delta { font-size: 1.125rem; color: var(--a3-d); }
.board-row .move { font-size: 1rem; }
.board-row .move.up { color: var(--a3-d); }
.board-row .move.down { color: var(--a0-d); }
.board-row .score { font-family: var(--font-display); font-size: 1.875rem; min-width: 110px; text-align: right; }
@keyframes slide-in { from { transform: translateX(-60px); opacity: 0; } }
.screen-title { font-family: var(--font-display); font-size: clamp(2.5rem, 1.25rem + 6vw, 4.5rem); text-align: center; margin: 0; text-shadow: 0 5px 0 rgba(0,0,0,.25); }

/* Podio */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: clamp(0.625rem, 0.3125rem + 2vw, 1.5rem); flex: 1; min-height: 340px; }
.podium .slot { display: flex; flex-direction: column; align-items: center; gap: 10px; width: clamp(8.125rem, 4.0625rem + 18vw, 14.375rem); }
.podium .who { font-family: var(--font-display); font-size: clamp(1.375rem, 0.6875rem + 2.6vw, 2.125rem); text-align: center; overflow-wrap: anywhere; animation: fade-up .5s both; }
.podium .pts { color: var(--muted); font-size: 1.25rem; animation: fade-up .5s both; }
.podium .block {
  width: 100%; border-radius: 16px 16px 0 0; display: flex; justify-content: center; padding-top: 14px;
  font-family: var(--font-display); font-size: 4rem; color: rgba(255,255,255,.9);
  transform-origin: bottom; animation: grow 1s cubic-bezier(.3,1.2,.6,1) both;
}
.podium .p1 .block { height: 260px; background: linear-gradient(var(--spark), var(--spark-dark)); color: var(--ink); }
.podium .p2 .block { height: 190px; background: linear-gradient(#c9d6e3, #8ea3b9); color: var(--ink); }
.podium .p3 .block { height: 140px; background: linear-gradient(#e59a5c, #c27a3e); color: var(--ink); }
.podium .p3 .block, .podium .p3 .who, .podium .p3 .pts { animation-delay: .3s; }
.podium .p2 .block, .podium .p2 .who, .podium .p2 .pts { animation-delay: 1.3s; }
.podium .p1 .block, .podium .p1 .who, .podium .p1 .pts { animation-delay: 2.5s; }
.podium .p3 .who, .podium .p3 .pts { animation-delay: 1.1s; }
.podium .p2 .who, .podium .p2 .pts { animation-delay: 2.1s; }
.podium .p1 .who, .podium .p1 .pts { animation-delay: 3.4s; }
.podium .crown { width: 54px; height: 54px; fill: var(--spark); animation: fade-up .5s 3.6s both, wiggle 1s 4.1s 2; }
@keyframes fade-up { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }

.host-actions { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; }
.corner-actions { position: fixed; right: 16px; bottom: 16px; display: flex; gap: 10px; z-index: 20; }

/* ───── Pantallas del jugador ───── */
.player-top {
  display: flex; justify-content: space-between; align-items: center; padding: 10px 14px;
  padding-block-start: max(10px, env(safe-area-inset-top, 0px));
  background: rgba(0,0,0,.25); font-size: 1rem;
}
.player-bottom {
  display: flex; justify-content: space-between; align-items: center; padding: 12px 16px;
  padding-block-end: max(12px, env(safe-area-inset-bottom, 0px));
  background: #fff; color: var(--ink); font-size: 1.125rem;
}
.player-bottom .score { font-family: var(--font-display); background: var(--night); color: #fff; padding: 4px 14px; border-radius: 10px; }
.player-q { padding: 12px 16px 0; text-align: center; font-size: 1.125rem; color: #dbe6f2; }
.big-msg { font-family: var(--font-display); font-size: clamp(2.125rem, 1.0625rem + 9vw, 3.5rem); line-height: 1.05; text-shadow: 0 4px 0 rgba(0,0,0,.2); }
.sub-msg { font-size: 1.25rem; color: #dbe6f2; max-width: 420px; }
.result-screen { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px; text-align: center; }
body.good { background: var(--good); color: var(--ink); }
body.bad { background: var(--bad); }
body.good .sub-msg { color: var(--ink); }
body.bad .sub-msg { color: #fff; }
body.good .big-msg { text-shadow: none; }
body.good, body.bad { --focus-ring: var(--ink); }
.result-icon {
  width: 120px; height: 120px; border-radius: 50%; background: #fff; display: grid; place-items: center;
  animation: bubble-in .6s cubic-bezier(.3,1.8,.5,1) both;
}
.result-icon svg { width: 76px; height: 76px; }
.good .result-icon svg { fill: var(--a3-d); }
.bad .result-icon svg { fill: var(--a0-d); }
.points-pill {
  font-family: var(--font-display); font-size: 2.125rem; background: rgba(0,0,0,.2); padding: 8px 24px; border-radius: 14px;
  animation: pop-in .5s .25s both;
}
.streak { display: inline-flex; align-items: center; gap: 8px; background: var(--spark); color: var(--ink); padding: 6px 16px; border-radius: 999px; font-size: 1.125rem; animation: pop-in .5s .4s both; }
.rank-msg { font-size: 1.375rem; }
.spinner {
  width: 74px; height: 74px; border-radius: 50%; border: 9px solid rgba(255,255,255,.2); border-top-color: var(--spark);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.final-rank { font-family: var(--font-display); font-size: 7.5rem; line-height: 1; color: var(--spark); text-shadow: 0 8px 0 var(--spark-dark); animation: bubble-in .7s cubic-bezier(.3,1.8,.5,1) both; }

/* Confeti */
.confetti-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 50; }

/* ───── Responsivo ───── */
@container main (inline-size < 760px) {
  .lobby-top { grid-template-columns: 1fr; }
  .qr-box { display: none; }
  .q-middle { grid-template-columns: 1fr 1fr; }
  .q-middle .q-image { grid-column: 1 / -1; grid-row: 1; }
  .answers-grid { grid-template-columns: 1fr; }
  .opt-grid { grid-template-columns: 1fr; }
  .q-settings { grid-template-columns: 1fr; }
  .board-row { grid-template-columns: 40px 1fr auto; font-size: 1.25rem; }
  .board-row .move { display: none; }
}
/* Movimiento reducido: sin desplazamientos, escalas ni rotaciones; las entradas se convierten en un
   fundido corto (se conservan los tiempos, que no son movimiento) y se paran los bucles. */
@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .pad-btn, .quiz-card, .toast, .player-bubble.new, .q-banner, .countdown-stage .qtitle, .board-row,
  .podium .block, .podium .who, .podium .pts, .chart .bar, .result-icon, .points-pill, .streak, .final-rank {
    animation-name: fade;
    animation-timing-function: ease-out;
  }
  .podium .crown { animation: fade .5s 3.6s both; }
  .error-msg, .logo svg, .badge-double, .timer.low .num { animation: none; }
  .spinner { animation-duration: 3s; }
  .waiting-dots span { animation: none; opacity: 1; }
  .btn:active, .pad-btn:active { transform: none; }
}

/* ───── Utilidades de maquetación (sustituyen estilos en línea) ───── */
[hidden] { display: none !important; }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.full-row { grid-column: 1 / -1; }
.question-list { display: flex; flex-direction: column; gap: 22px; }
.btn.centered { align-self: center; }
.push-down { margin-top: auto; }
.muted { color: #5a6b80; }
.q-banner.still { animation: none; }
.q-middle.single { grid-template-columns: 1fr; }
.board.compact { gap: 8px; }
.board.compact .board-row { font-size: 1.25rem; padding: 8px 18px; background: #fff; }
.board.compact .pos, .board.compact .score { font-size: 1.375rem; }
.player-bubble.static { cursor: default; }
.streak-mark { margin-left: 8px; }
.nickname { font-size: 1.625rem; padding: 10px 24px; font-family: var(--font-display); }
.sub-msg.faint { font-size: 1rem; opacity: .7; }

/* ───── Esquema de color ─────
   El juego tiene un tema oscuro propio (pensado para proyectar); los controles nativos
   (desplegables, barras de desplazamiento, autocompletado) deben coincidir con cada superficie. */
:root { color-scheme: dark; }
.card, .pin-box, .qr-box, .toast { color-scheme: light; }

/* ───── Modo de colores forzados (alto contraste de Windows) ─────
   Los fondos y sombras desaparecen: los límites de los controles pasan a ser bordes de sistema. */
@media (forced-colors: active) {
  .btn, .icon-btn, .answer-tile, .pad-btn, .player-bubble, .card, .opt, .chip, .toast,
  .board-row, .correct-toggle, .pin-box, .q-banner { border: 2px solid CanvasText; }
  .btn:disabled { border-color: GrayText; color: GrayText; }
  .correct-toggle.on { background: Highlight; }
  .correct-toggle.on svg { fill: HighlightText; }
  .timer .bar { stroke: Highlight; }
  .timer .track { stroke: GrayText; }
  .chart .bar, .countdown-bar > div { background: Highlight; }
  .bg-shapes, .confetti-canvas { display: none; }
}

/* ───── Accesibilidad ───── */
/* Texto solo para lectores de pantalla */
.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important; clip-path: inset(50%) !important; overflow: hidden !important;
  width: 1px !important; height: 1px !important; margin: -1px !important; padding: 0 !important;
  border: 0 !important; white-space: nowrap !important;
}
/* Los encabezados reciben el foco por programa al cambiar de pantalla: sin anillo (no son controles) */
h1[tabindex="-1"]:focus { outline: none; }
h1, h2 { margin: 0; font-weight: inherit; }
.hint { font-size: 0.875rem; color: #5a6b80; text-align: left; }
.join-card .lbl { text-align: left; color: #5a6b80; font-size: 0.9375rem; }
.form-title { font-family: var(--font-display); font-size: 1.5rem; color: var(--ink); text-align: center; }
p { margin: 0; }
.lib-grid { list-style: none; margin: 0; padding: 0; }
.topbar h1.chip { font-size: 1rem; }

/* ───── Texto: equilibrio de titulares, sin huérfanas, sin desbordar en 320 px ───── */
body { overflow-wrap: anywhere; }
h1, h2 { text-wrap: balance; }
p, li { text-wrap: pretty; }

/* ───── Objetivos táctiles (WCAG 2.5.8 / 2.5.5) ───── */
:root { --target-size: 24px; }
@media (pointer: coarse) {
  :root { --target-size: 44px; }
}
:where(button, select, textarea, input:not([type="checkbox"], [type="radio"])) {
  min-block-size: var(--target-size);
  min-inline-size: var(--target-size);
}
.q-tools button, .correct-toggle { inline-size: max(38px, var(--target-size)); block-size: max(38px, var(--target-size)); }
.footer-link a { display: inline-block; padding-block: 8px; }

/* ───── Rendimiento visual ───── */
/* Al cambiar de la fuente de reserva a la web, el texto conserva su tamaño visual (menos CLS) */
body, .logo, .btn, .big-msg, .screen-title { font-size-adjust: from-font; }
/* Listas largas: el navegador no pinta lo que está fuera de pantalla */
.quiz-card { content-visibility: auto; contain-intrinsic-size: auto 260px; }
.question-list > .card { content-visibility: auto; contain-intrinsic-size: auto 420px; }

/* ───── Controles del navegador acordes al tema ───── */
:root { accent-color: var(--spark); scrollbar-color: #5c7391 var(--night); }
