/* Destello · Pregunta. Responde. Brilla. */
:root {
  --noche: #14213D;
  --coral: #FF5A36;
  --menta: #2EC4B6;
  --sol: #FFC300;
  --cielo: #3A6EA5;
  --crema: #FFF8EE;

  --fondo: var(--crema);
  --superficie: #FFFFFF;
  --superficie-2: #F6EEE2;
  --texto: var(--noche);
  --texto-suave: #4F5B73;
  --borde: #E6DccD;
  --sombra: 0 1px 2px rgba(20, 33, 61, .06), 0 8px 24px rgba(20, 33, 61, .08);
  --acento: var(--coral);
  --acento-texto: #FFFFFF;
  --bien: #1F9E6E;
  --mal: #D7263D;

  --op-a: var(--coral);
  --op-b: var(--menta);
  --op-c: var(--sol);
  --op-d: var(--cielo);
  --op-texto-a: #FFFFFF;
  --op-texto-b: #0B2B28;
  --op-texto-c: #2B2100;
  --op-texto-d: #FFFFFF;

  --radio: 18px;
  --radio-sm: 12px;
  --fuente: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) {
    --fondo: #0E1628;
    --superficie: #18233D;
    --superficie-2: #1F2C4A;
    --texto: #F4EFE6;
    --texto-suave: #AEB7C9;
    --borde: #2C3A5C;
    --sombra: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
    --cielo: #5B8FD0;
    color-scheme: dark;
  }
}
:root[data-tema="oscuro"] {
  --fondo: #0E1628;
  --superficie: #18233D;
  --superficie-2: #1F2C4A;
  --texto: #F4EFE6;
  --texto-suave: #AEB7C9;
  --borde: #2C3A5C;
  --sombra: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  --cielo: #5B8FD0;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  overflow-x: hidden;
  background: var(--fondo);
  color: var(--texto);
  font-family: var(--fuente);
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
h1, h2, h3 { line-height: 1.12; letter-spacing: -0.02em; margin: 0 0 .4em; font-weight: 800; }
p { margin: 0 0 .8em; }
[hidden] { display: none !important; }
.oculto-accesible { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Cabecera ---------- */
.cabecera {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px clamp(16px, 4vw, 40px);
  max-width: 1200px; margin: 0 auto;
}
.marca { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 900; font-size: 1.35rem; letter-spacing: -0.03em; }
.marca svg { width: 30px; height: 30px; flex: none; }
.cabecera nav { display: flex; gap: 6px; align-items: center; }

/* ---------- Botones ---------- */
.boton {
  appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 999px; text-decoration: none;
  background: var(--acento); color: var(--acento-texto);
  box-shadow: 0 3px 0 rgba(0, 0, 0, .18);
  transition: transform .08s ease, filter .15s ease, box-shadow .08s ease;
  min-height: 46px;
}
.boton:hover { filter: brightness(1.06); }
.boton:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, .18); }
.boton:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.boton.secundario { background: var(--superficie); color: var(--texto); box-shadow: inset 0 0 0 2px var(--borde); }
.boton.fantasma { background: transparent; color: var(--texto); box-shadow: none; padding: 10px 14px; }
.boton.fantasma:hover { background: var(--superficie-2); }
.boton.menta { background: var(--menta); color: #0B2B28; }
.boton.grande { font-size: 1.15rem; padding: 16px 28px; min-height: 58px; }
.boton.peque { padding: 8px 14px; min-height: 36px; font-size: .9rem; }
.boton.ia { background: linear-gradient(135deg, var(--coral), #FF8A3D 55%, var(--sol)); color: #2B1100; }
.icono-boton { appearance: none; border: 0; background: transparent; color: var(--texto-suave); cursor: pointer; padding: 8px; border-radius: 10px; font: inherit; line-height: 1; }
.icono-boton:hover { background: var(--superficie-2); color: var(--texto); }
:focus-visible { outline: 3px solid var(--sol); outline-offset: 2px; }

/* ---------- Tarjetas y formularios ---------- */
.contenedor { max-width: 1200px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px) 64px; }
.tarjeta { background: var(--superficie); border-radius: var(--radio); box-shadow: var(--sombra); padding: clamp(18px, 3vw, 28px); }
label { font-weight: 700; font-size: .95rem; display: block; margin-bottom: 6px; }
input[type=text], input[type=url], input[type=password], input[type=number], textarea, select {
  width: 100%; font: inherit; color: var(--texto); background: var(--superficie);
  border: 2px solid var(--borde); border-radius: var(--radio-sm); padding: 12px 14px;
  transition: border-color .15s ease;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--menta); }
.campo { margin-bottom: 16px; }
.ayuda { color: var(--texto-suave); font-size: .9rem; }
.fila { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.separar { justify-content: space-between; }

/* ---------- Avisos ---------- */
.avisos { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(92vw, 460px); }
.aviso { background: var(--noche); color: #fff; padding: 12px 16px; border-radius: 14px; box-shadow: var(--sombra); font-weight: 700; animation: subir .25s ease; }
.aviso.error { background: var(--mal); }
.aviso.ok { background: var(--bien); }
@keyframes subir { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Portada ---------- */
.portada { display: grid; gap: 28px; grid-template-columns: 1.1fr .9fr; align-items: start; padding-top: clamp(12px, 4vw, 40px); }
.portada > *, .editor > *, .sala > * { min-width: 0; }
.portada h1 { font-size: clamp(2.2rem, 6vw, 4.2rem); overflow-wrap: break-word; }
.portada .lema { font-size: clamp(1.1rem, 2.2vw, 1.4rem); color: var(--texto-suave); margin-bottom: 24px; }
.destaca { color: var(--coral); }
.entrar-pin { display: grid; gap: 12px; }
.entrar-pin input { font-size: 1.6rem; text-align: center; letter-spacing: .2em; font-weight: 800; }
.lista-quizzes { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.lista-quizzes li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-radius: var(--radio-sm); background: var(--superficie-2); }
.lista-quizzes .nombre { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lista-quizzes .acciones { display: flex; gap: 4px; flex: none; }
.ventajas { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-top: 36px; }
.ventaja { background: var(--superficie); border-radius: var(--radio); padding: 18px; box-shadow: var(--sombra); }
.ventaja b { display: block; font-size: 1.05rem; margin-bottom: 4px; }
.ventaja span { color: var(--texto-suave); font-size: .95rem; }

/* ---------- Editor ---------- */
.editor { display: grid; grid-template-columns: 300px 1fr; gap: 24px; align-items: start; }
.panel-lateral { position: sticky; top: 16px; display: grid; gap: 14px; }
.barra-ia { display: grid; gap: 8px; }
.estado-guardado { font-size: .9rem; color: var(--texto-suave); font-weight: 700; }
.pregunta-editor { margin-bottom: 18px; }
.pregunta-editor .cabeza { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.pregunta-editor .numero { font-weight: 900; color: var(--coral); }
.opciones-editor { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.opcion-editor { display: flex; align-items: center; gap: 8px; border-radius: var(--radio-sm); padding: 6px 6px 6px 10px; border: 2px solid transparent; background: var(--superficie-2); }
.opcion-editor.es-correcta { border-color: var(--bien); }
.opcion-editor .letra { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-weight: 900; flex: none; }
.opcion-editor input[type=text] { border: 0; background: transparent; padding: 8px 4px; }
.opcion-editor input[type=radio] { width: 22px; height: 22px; accent-color: var(--bien); flex: none; }
.imagen-pregunta { position: relative; width: fit-content; }
.imagen-pregunta img { max-height: 160px; border-radius: var(--radio-sm); }
.vacio { text-align: center; padding: 40px 20px; color: var(--texto-suave); }

/* Letras y colores de respuesta */
.op-0 { background: var(--op-a); color: var(--op-texto-a); }
.op-1 { background: var(--op-b); color: var(--op-texto-b); }
.op-2 { background: var(--op-c); color: var(--op-texto-c); }
.op-3 { background: var(--op-d); color: var(--op-texto-d); }

/* ---------- Ventana modal ---------- */
dialog { border: 0; border-radius: var(--radio); padding: 0; background: var(--superficie); color: var(--texto); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); width: min(94vw, 560px); }
dialog::backdrop { background: rgba(14, 22, 40, .55); }
.modal { padding: 24px; }
.pestanas { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.pestanas button { appearance: none; border: 2px solid var(--borde); background: var(--superficie); color: var(--texto); border-radius: 999px; padding: 6px 14px; font: inherit; font-weight: 700; cursor: pointer; }
.pestanas button[aria-selected=true] { background: var(--noche); color: #fff; border-color: var(--noche); }
:root[data-tema="oscuro"] .pestanas button[aria-selected=true] { background: var(--menta); color: #0B2B28; border-color: var(--menta); }
.cargando { display: inline-block; width: 18px; height: 18px; border: 3px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: girar .8s linear infinite; vertical-align: -3px; }
@keyframes girar { to { transform: rotate(360deg); } }

/* ---------- Pantalla del presentador ---------- */
.escenario { min-height: 100vh; display: flex; flex-direction: column; }
.escenario .contenido { flex: 1; display: flex; flex-direction: column; padding: 0 clamp(16px, 4vw, 48px) 28px; max-width: 1400px; width: 100%; margin: 0 auto; }
.sala { display: grid; grid-template-columns: auto 1fr; gap: clamp(20px, 4vw, 48px); align-items: center; margin-top: 8px; }
.sala .qr { background: #fff; border-radius: var(--radio); padding: 14px; width: clamp(180px, 22vw, 280px); box-shadow: var(--sombra); }
.sala .instrucciones { font-size: clamp(1.1rem, 2vw, 1.5rem); color: var(--texto-suave); margin-bottom: 4px; }
.sala .url { font-weight: 800; font-size: clamp(1.1rem, 2.2vw, 1.6rem); word-break: break-all; }
.pin-gigante { font-size: clamp(3.4rem, 10vw, 7.5rem); font-weight: 900; letter-spacing: .06em; line-height: 1; margin: 8px 0 4px; }
.jugadores { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--superficie); padding: 8px 8px 8px 16px; border-radius: 999px; box-shadow: var(--sombra); font-weight: 800; animation: aparecer .3s ease; }
.chip.desconectado { opacity: .5; }
.chip button { appearance: none; border: 0; background: var(--superficie-2); color: var(--texto-suave); width: 26px; height: 26px; border-radius: 50%; cursor: pointer; font-weight: 900; }
.chip button:hover { background: var(--mal); color: #fff; }
@keyframes aparecer { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
.pie-sala { margin-top: auto; padding-top: 24px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.contador-jugadores { font-size: 1.4rem; font-weight: 900; }

.pregunta-grande { text-align: center; font-size: clamp(1.6rem, 3.6vw, 3rem); margin: 8px auto 18px; max-width: 1100px; }
.zona-media { display: grid; grid-template-columns: 120px 1fr 120px; align-items: center; gap: 16px; flex: 1; min-height: 120px; }
.zona-media .imagen { display: flex; justify-content: center; }
.zona-media .imagen img { max-height: 34vh; border-radius: var(--radio); box-shadow: var(--sombra); }
.reloj { width: 110px; height: 110px; position: relative; }
.reloj svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.reloj .numero { position: absolute; inset: 0; display: grid; place-items: center; font-size: 2.4rem; font-weight: 900; }
.recuento { text-align: center; }
.recuento b { display: block; font-size: 2.6rem; font-weight: 900; line-height: 1; }
.rejilla-opciones { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
.opcion-grande { border-radius: var(--radio); padding: clamp(14px, 2.2vw, 24px); font-size: clamp(1.1rem, 2.2vw, 1.8rem); font-weight: 800; display: flex; align-items: center; gap: 16px; min-height: 84px; transition: opacity .3s ease, transform .3s ease; }
.opcion-grande .letra { width: 1.9em; height: 1.9em; border-radius: 12px; background: rgba(255, 255, 255, .28); display: grid; place-items: center; font-weight: 900; flex: none; }
.opcion-grande.apagada { opacity: .28; }
.opcion-grande.correcta { transform: scale(1.02); box-shadow: 0 0 0 5px var(--superficie), 0 0 0 9px var(--bien); }
.barras { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(60px, 140px)); gap: 18px; justify-content: center; align-items: end; height: 30vh; margin: 8px 0 4px; }
.barra { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; font-weight: 900; font-size: 1.4rem; }
.barra .columna { width: 100%; border-radius: 12px 12px 4px 4px; min-height: 8px; transition: height .7s cubic-bezier(.2, .9, .3, 1.2); }
.explicacion { background: var(--superficie); border-left: 6px solid var(--menta); border-radius: var(--radio-sm); padding: 14px 18px; margin: 14px auto 0; max-width: 1000px; font-size: clamp(1rem, 1.8vw, 1.3rem); box-shadow: var(--sombra); }
.barra-inferior { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 18px; flex-wrap: wrap; }
.progreso { font-weight: 800; color: var(--texto-suave); }

.ranking { list-style: none; padding: 0; margin: 12px auto; width: min(100%, 760px); display: grid; gap: 10px; }
.ranking li { display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 12px; background: var(--superficie); border-radius: var(--radio-sm); padding: 12px 18px; font-size: clamp(1.1rem, 2vw, 1.5rem); font-weight: 800; box-shadow: var(--sombra); animation: aparecer .35s ease both; }
.ranking .pos { font-weight: 900; color: var(--coral); font-size: 1.3em; }
.ranking .sube { color: var(--bien); font-size: .75em; margin-left: 8px; }

.podio { display: flex; justify-content: center; align-items: flex-end; gap: clamp(10px, 2vw, 22px); margin: 20px 0 10px; min-height: 42vh; }
.peldano { width: clamp(110px, 18vw, 220px); display: flex; flex-direction: column; align-items: center; gap: 10px; animation: crecer .8s cubic-bezier(.2, .9, .3, 1.2) both; }
.peldano .nombre { font-size: clamp(1.1rem, 2.2vw, 1.8rem); font-weight: 900; text-align: center; word-break: break-word; }
.peldano .puntos { color: var(--texto-suave); font-weight: 800; }
.peldano .bloque { width: 100%; border-radius: 16px 16px 6px 6px; display: grid; place-items: start center; padding-top: 12px; font-size: clamp(2rem, 4vw, 3.4rem); font-weight: 900; color: #fff; }
.peldano.p1 .bloque { height: 30vh; background: var(--sol); color: #2B2100; }
.peldano.p2 .bloque { height: 21vh; background: var(--menta); color: #0B2B28; }
.peldano.p3 .bloque { height: 15vh; background: var(--coral); }
.peldano.p1 { animation-delay: .9s; }
.peldano.p2 { animation-delay: .45s; }
@keyframes crecer { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Móvil del jugador ---------- */
.movil { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.movil .barra-jugador { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; font-weight: 800; background: var(--superficie); box-shadow: var(--sombra); }
.movil .zona { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 20px 16px; max-width: 560px; width: 100%; margin: 0 auto; }
.movil .centro { text-align: center; }
.movil h1 { font-size: clamp(1.8rem, 7vw, 2.4rem); }
.botones-respuesta { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; flex: 1; max-height: 70vh; }
.botones-respuesta.dos { grid-template-columns: 1fr; }
.boton-respuesta { appearance: none; border: 0; border-radius: var(--radio); font: inherit; font-weight: 800; font-size: 1.05rem; padding: 14px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 110px; box-shadow: 0 5px 0 rgba(0, 0, 0, .2); transition: transform .08s ease; }
.boton-respuesta:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, .2); }
.boton-respuesta .letra { font-size: 2rem; font-weight: 900; line-height: 1; }
.boton-respuesta .texto { font-size: .95rem; line-height: 1.25; }
.pregunta-movil { font-weight: 800; font-size: 1.1rem; text-align: center; margin-bottom: 14px; }
.tiempo-movil { height: 8px; background: var(--superficie-2); border-radius: 99px; overflow: hidden; margin-bottom: 14px; }
.tiempo-movil div { height: 100%; background: var(--menta); border-radius: 99px; transform-origin: left; }
.gran-icono { font-size: 4.5rem; line-height: 1; margin-bottom: 10px; }
.resultado-bien { color: var(--bien); }
.resultado-mal { color: var(--mal); }
.ganados { font-size: 2.2rem; font-weight: 900; }
.reconectando { position: fixed; top: 0; left: 0; right: 0; background: var(--sol); color: #2B2100; text-align: center; padding: 8px; font-weight: 800; z-index: 40; }
.chispas { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 30; }
.chispas i { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 3px; animation: caer linear forwards; }
@keyframes caer { to { transform: translateY(110vh) rotate(720deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media (max-width: 860px) {
  .portada { grid-template-columns: 1fr; }
  .editor { grid-template-columns: 1fr; }
  .panel-lateral { position: static; }
  .sala { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .zona-media { grid-template-columns: 80px 1fr 80px; }
  .reloj { width: 76px; height: 76px; }
  .reloj .numero { font-size: 1.6rem; }
  .recuento b { font-size: 1.8rem; }
}
@media (max-width: 560px) {
  .opciones-editor { grid-template-columns: 1fr; }
  .rejilla-opciones { grid-template-columns: 1fr; }
  .cabecera .ocultar-movil { display: none; }
  .lista-quizzes li { flex-wrap: wrap; }
  .lista-quizzes .nombre { width: 100%; }
  .portada .fila .boton { flex: 1 1 100%; }
}
