/* Prototipo A · Zoom continuo · Dirección "Documental nocturno" */

:root {
  /* Curva de la interfaz: lo que entra frena al llegar (nada en línea recta ni con la curva por defecto). */
  --salir: cubic-bezier(.16, 1, .3, 1);
  --fondo: #05060b;
  --velo: 5, 6, 11; /* el velo de detrás del texto: el fondo oscuro con un tinte de la escala (main.js → teñirVelo) */
  --texto: #f4f0e8;
  --tenue: rgba(244, 240, 232, 0.66);
  --muy-tenue: rgba(244, 240, 232, 0.38);
  --ambar: #ffb347;
  --ambar-suave: rgba(255, 179, 71, 0.16);
  --rojo: #ff5a5f;
  --linea: rgba(255, 255, 255, 0.14);
  --panel: rgba(9, 11, 20, 0.72);
  --titular: system-ui, sans-serif;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --titular-peso: 500;
  --titular-escala: .86;
  --centro-x: 62%;
  --centro-y: 50%;
  --col-izq: min(560px, 40vw);
  --margen: clamp(24px, 4.4vw, 72px);
  --nivel: #ffffff;
  color-scheme: dark;
}

html, body { height: 100%; background: var(--fondo); color: var(--texto); font-family: var(--sans); overflow: hidden; }

/* Rejilla de tres filas: HUD, zona de paneles y pie (lectura + escalera).
   Cada cosa tiene su sitio reservado: nada se pisa aunque la ventana sea estrecha, baja o con zoom. */
.app {
  /* Pegada al área visible: con el teclado de iOS, la vista baja (--desplazamiento) y la app la sigue. */
  position: fixed; inset: 0; top: var(--desplazamiento, 0px); bottom: auto;
  height: var(--alto-visible, 100dvh);
  overflow: hidden;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr);
}

#lienzo { position: absolute; inset: 0; width: 100%; height: 100%; }

/* Velo para que el texto de la izquierda se lea sobre la escena */
.app::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 1;
  /* Ligado al ancho de la columna (no a %): el texto nunca queda sobre la escena sin velo. */
  background: linear-gradient(90deg, rgba(var(--velo), 0.92) 0, rgba(var(--velo), 0.8) calc(var(--margen) + var(--col-izq) * .7), rgba(var(--velo), 0.55) calc(var(--margen) + var(--col-izq) + 24px), rgba(var(--velo), 0) calc(var(--margen) + var(--col-izq) + 180px));
  transition: opacity .6s; transition-timing-function: var(--salir);
}
.app.sin-velo::before { opacity: 0; }

/* ---------- HUD ---------- */
.hud {
  position: relative; grid-row: 1; z-index: 10;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
  padding: 18px var(--margen);
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.marca { display: flex; flex-direction: column; text-decoration: none; color: inherit; line-height: 1.1; justify-self: start; }
.marca-nombre { font-family: var(--titular); font-size: 26px; letter-spacing: .01em; }
.marca-reto { font-size: 12px; color: var(--tenue); letter-spacing: .08em; text-transform: uppercase; margin-top: 2px; }
.progreso { display: flex; gap: 10px; list-style: none; margin: 0; padding: 0; }
.progreso li {
  width: 12px; height: 12px; border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, .35);
  transition: background .4s, border-color .4s, transform .4s; transition-timing-function: var(--salir);
}
.progreso li.actual { border-color: var(--ambar); box-shadow: 0 0 0 4px var(--ambar-suave); transform: scale(1.15); }
.progreso li.hecha { background: var(--c); border-color: var(--c); box-shadow: 0 0 12px var(--c); }
.progreso li.vacia { background: #2a2d36; border-color: #4a4e5a; }
.hud-der { justify-self: end; display: flex; align-items: center; gap: 14px; }
.marcador { font-family: var(--mono); font-size: 22px; font-weight: 700; display: flex; align-items: baseline; gap: 4px; }
.marcador small { font-size: 12px; color: var(--muy-tenue); font-weight: 500; }
.btn-icono {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--linea);
  background: rgba(255, 255, 255, .04); display: grid; place-items: center;
  transition: background .2s, border-color .2s, transform .12s; transition-timing-function: var(--salir);
}
.btn-icono:hover { background: rgba(255, 255, 255, .1); }
.btn-icono:active { transform: scale(.92); }
.btn-icono svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.btn-icono .altavoz { fill: currentColor; stroke: none; }
.btn-icono[data-activo="1"] .tachado { display: none; }
.btn-icono[data-activo="0"] .ondas { display: none; }
.btn-icono[data-activo="1"] { border-color: var(--ambar); color: var(--ambar); }

:focus-visible { outline: 2px solid var(--ambar); outline-offset: 3px; }

/* ---------- Lectura de escala ---------- */
.pie {
  position: relative; grid-row: 3; z-index: 4; pointer-events: none;
  display: flex; align-items: flex-end; gap: 16px 28px;
  padding: 12px var(--margen) 26px;
}
.lectura {
  flex: none; min-width: 9.5em; text-align: left;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .8);
  transition: opacity .4s; transition-timing-function: var(--salir);
}
.en-final .lectura { opacity: 0; }
.lectura-pot { font-family: var(--mono); font-weight: 700; font-size: clamp(30px, 3.2vw, 48px); color: var(--ambar); letter-spacing: -.02em; line-height: 1; }
.lectura-med { font-family: var(--mono); font-size: 15px; color: var(--texto); margin-top: 6px; }
.lectura-lugar { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--tenue); margin-top: 4px; }

/* ---------- Mira, leyendas y escalera de niveles ---------- */
.mira {
  position: absolute; z-index: 3; left: var(--centro-x); top: var(--centro-y);
  width: 0; height: 0; pointer-events: none; opacity: 0;
}
.mira i {
  position: absolute; left: 50%; top: 50%; border-radius: 50%;
  border: 1.5px solid var(--ambar); transform: translate(-50%, -50%);
}
.mira i:first-child { width: 120px; height: 120px; border-style: dashed; }
.mira i:last-child { width: 30px; height: 30px; }
.mira.fijando { animation: fijar .5s cubic-bezier(.2, .9, .3, 1) both; }
.mira.fijando i:first-child { animation: girar .5s linear both; }
@keyframes fijar { 0% { opacity: 0; transform: scale(2.4); } 60% { opacity: 1; } 100% { opacity: 0; transform: scale(.4); } }
@keyframes girar { to { transform: translate(-50%, -50%) rotate(140deg); } }

.leyendas {
  position: absolute; z-index: 4; left: var(--centro-x); top: calc(var(--centro-y) + 120px);
  transform: translateX(-50%); width: min(420px, 80vw);
  display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none;
}
.leyenda {
  font-family: var(--mono); font-size: 13px; padding: 6px 12px; border-radius: 999px;
  background: rgba(5, 6, 11, .66); border: 1px solid rgba(255, 255, 255, .12); white-space: nowrap;
  animation: leyenda 1.6s var(--salir) both;
}
.leyenda b { color: var(--ambar); font-weight: 500; }
.leyenda.parada { border-color: color-mix(in srgb, var(--c) 60%, transparent); font-size: 15px; }
.leyenda.parada b { color: var(--c); font-family: var(--titular); font-weight: 600; }
@keyframes leyenda { 0% { opacity: 0; transform: translateY(10px) scale(.96); } 12% { opacity: 1; transform: none; } 70% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }
/* Datillo: un dato curioso del sitio, corto (≤ 90 caracteres), mientras la cámara viaja o frena. */
.datillo {
  max-width: min(400px, 80vw); padding: 8px 14px 9px; border-radius: 12px; text-align: center;
  background: rgba(5, 6, 11, .74); border: 1px solid rgba(255, 214, 170, .2);
  font-family: var(--sans); font-size: 14.5px; line-height: 1.35; color: rgba(255, 244, 232, .94);
  animation: datillo var(--dura, 2.6s) var(--salir) both;
}
.datillo b { display: block; margin-bottom: 2px; font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .05em; color: var(--ambar); }
@keyframes datillo { 0% { opacity: 0; transform: translateY(8px); } 9% { opacity: 1; transform: none; } 82% { opacity: 1; } 100% { opacity: 0; } }

.escalera {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-wrap: wrap; justify-content: center; align-content: flex-end; gap: 8px;
  list-style: none; margin: 0; padding: 0;
  opacity: 0; transition: opacity .3s; transition-timing-function: var(--salir);
}
.escalera.visible { opacity: 1; }
/* Si no caben en una fila, dos filas de tres (nunca una píldora suelta). */
@media (max-width: 1240px) and (min-width: 761px) {
  .escalera { display: grid; grid-template-columns: repeat(3, max-content); justify-content: center; }
}
.escalera li {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600; letter-spacing: .02em;
  padding: 8px 15px 8px 11px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .2);
  color: var(--tenue); background: rgba(5, 6, 11, .7); white-space: nowrap;
  transition: color .18s, background-color .18s, border-color .18s, box-shadow .18s, transform .18s; transition-timing-function: var(--salir);
}
.escalera li .ico, .portada-niveles li .ico { width: 20px; height: 20px; flex: none; }
.ico { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.escalera li.encendida { color: #0a0b10; background: var(--c); border-color: var(--c); box-shadow: 0 0 18px var(--c); transform: translateY(-3px); }
.escalera li.ultima { animation: latido .5s ease-out; }
@keyframes latido { 0% { transform: translateY(-3px) scale(1.25); } 100% { transform: translateY(-3px) scale(1); } }

/* ---------- Paneles de la izquierda ---------- */
.portada, .pregunta, .revelacion {
  position: relative; z-index: 6; grid-row: 2; grid-column: 1;
  align-self: center; justify-self: start; margin-left: var(--margen);
  width: var(--col-izq); max-height: 100%;
}

.portada-kicker { font-family: var(--mono); font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--ambar); margin: 0 0 18px; }
.portada-titulo { font-family: var(--titular); font-weight: var(--titular-peso); font-size: calc(clamp(64px, 8.4vw, 128px) * var(--titular-escala)); line-height: .9; margin: 0; letter-spacing: -.02em; }
.portada-lema { font-family: var(--titular); font-size: clamp(24px, 2.4vw, 34px); line-height: 1.15; margin: 18px 0 28px; color: var(--texto); }
.portada-lema em { color: var(--ambar); }
.portada-reglas { margin: 0 0 32px; padding: 0; list-style: none; display: grid; gap: 12px; font-size: 16px; line-height: 1.45; color: var(--tenue); }
.portada-reglas li { padding-left: 26px; position: relative; }
.portada-reglas li::before { content: ""; position: absolute; left: 2px; top: .55em; width: 9px; height: 9px; border: 1.5px solid var(--ambar); transform: rotate(45deg); }
.portada-reglas b { color: var(--texto); font-weight: 600; }
.portada-reglas em { font-family: var(--titular); font-size: 1.15em; color: #ff8ee6; }
/* Menú: dos botones grandes, uno por dirección; el botón empieza la partida. */
.direcciones { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dir {
  --dir-c: var(--ambar);
  display: flex; align-items: flex-start; gap: 12px; text-align: left; min-height: 64px;
  padding: 14px 16px 14px 14px; border-radius: 20px; border: 1px solid var(--linea); color: var(--texto);
  background: rgba(9, 11, 20, .62); cursor: pointer;
  transition: transform .15s, border-color .2s, background .2s, box-shadow .2s; transition-timing-function: var(--salir);
}
/* Al abrir el menú ninguna parece elegida: se ilumina la que señalas (ratón o Tab). */
.direcciones:focus { outline: none; }
.dir:hover, .dir:focus-visible { transform: translateY(-2px); outline: none; border-color: var(--dir-c); background: color-mix(in srgb, var(--dir-c) 14%, rgba(9, 11, 20, .8)); box-shadow: 0 12px 40px color-mix(in srgb, var(--dir-c) 22%, transparent); }
.dir:active { transform: translateY(1px) scale(.98); }
.dir-ico { width: 30px; height: 30px; flex: none; margin-top: 2px; fill: none; stroke: var(--dir-c); stroke-width: 1.6; stroke-linecap: round; }
.dir-texto { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.dir-nombre { font-family: var(--titular); font-weight: 600; font-size: 21px; line-height: 1.1; color: var(--dir-c); }
.dir-meta { font-size: 13.5px; color: var(--tenue); line-height: 1.3; }
.dir-record { font-size: 12px; color: var(--muy-tenue); line-height: 1.35; margin-top: 3px; }
.dir-record sup.exp { margin-right: 0; }

/* «Próximamente» (T25): la dirección cerrada se queda a la vista, de noche y con su color, pero quieta: unas
   estrellas que titilan, las órbitas del icono que giran despacio y un brillo que cruza la etiqueta de vez en cuando.
   No se eleva al pasar el ratón (no es un botón que lleve a ningún sitio); al tocarla, destella. */
.dir.proximamente {
  position: relative; isolation: isolate; overflow: hidden; cursor: default;
  border-color: color-mix(in srgb, var(--dir-c) 24%, transparent);
  background:
    radial-gradient(120% 90% at 0% 0%, color-mix(in srgb, var(--dir-c) 12%, transparent), transparent 60%),
    rgba(6, 8, 16, .74);
}
.dir.proximamente::before, .dir.proximamente::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(1.2px 1.2px at 78% 22%, #fff 60%, transparent),
    radial-gradient(1px 1px at 91% 64%, #dfeeff 60%, transparent),
    radial-gradient(1.4px 1.4px at 63% 80%, #cfe6ff 60%, transparent),
    radial-gradient(1px 1px at 47% 14%, #fff 60%, transparent),
    radial-gradient(1px 1px at 97% 38%, #cfe6ff 60%, transparent);
  opacity: .5; animation: titila 3.6s ease-in-out infinite alternate;
}
.dir.proximamente::after {
  background:
    radial-gradient(1px 1px at 70% 50%, #fff 60%, transparent),
    radial-gradient(1.3px 1.3px at 86% 12%, #dfeeff 60%, transparent),
    radial-gradient(1px 1px at 56% 62%, #cfe6ff 60%, transparent),
    radial-gradient(1.1px 1.1px at 94% 88%, #fff 60%, transparent);
  animation-duration: 5.2s; animation-delay: -2s;
}
@keyframes titila { from { opacity: .15; } to { opacity: .7; } }
.dir.proximamente .dir-nombre { opacity: .88; }
.dir.proximamente .dir-ico circle { transform-origin: 12px 12px; }
.dir.proximamente .dir-ico circle:nth-child(2) { animation: orbita 26s linear infinite; }
.dir.proximamente .dir-ico circle:nth-child(3) { animation: orbita 44s linear infinite reverse; }
@keyframes orbita { to { transform: rotate(1turn); } }
.dir-pronto {
  align-self: flex-start; margin-top: 7px; padding: 3px 9px 3px 10px; border-radius: 999px;
  font-family: var(--mono); font-size: 10.5px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; line-height: 1.3;
  color: var(--dir-c); border: 1px solid color-mix(in srgb, var(--dir-c) 42%, transparent);
  background:
    linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, .28) 50%, transparent 62%) no-repeat,
    color-mix(in srgb, var(--dir-c) 9%, transparent);
  background-size: 300% 100%, auto;
  background-position: 120% 0, 0 0;
  animation: pronto-barrido 6s var(--salir) 2.4s infinite;
}
@keyframes pronto-barrido { 0% { background-position: 120% 0, 0 0; } 30%, 100% { background-position: -20% 0, 0 0; } }
.dir.proximamente:hover, .dir.proximamente:focus-visible {
  transform: none; box-shadow: none;
  border-color: color-mix(in srgb, var(--dir-c) 46%, transparent);
  background:
    radial-gradient(120% 90% at 0% 0%, color-mix(in srgb, var(--dir-c) 18%, transparent), transparent 62%),
    rgba(6, 8, 16, .78);
}
.dir.proximamente:hover::before, .dir.proximamente:hover::after { animation-duration: 1.6s; }
.dir.proximamente:active { transform: none; }
.dir.proximamente.llamada { animation: llamada .9s var(--salir); }
.dir.proximamente.llamada .dir-pronto { animation: pronto-destello .9s var(--salir); }
@keyframes llamada {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--dir-c) 0%, transparent); }
  25% { box-shadow: 0 0 0 1px color-mix(in srgb, var(--dir-c) 70%, transparent), 0 0 36px color-mix(in srgb, var(--dir-c) 30%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--dir-c) 0%, transparent); }
}
@keyframes pronto-destello {
  0% { background-position: 120% 0, 0 0; color: var(--dir-c); }
  35% { color: #fff; }
  100% { background-position: -20% 0, 0 0; color: var(--dir-c); }
}
/* Lo de hacia fuera en «¿Cómo se juega?», solo con ?obras=1; y la portada avisa de que está en obras. */
.app:not(.obras) .solo-obras { display: none; }
.app.obras .portada-kicker::after { content: " · obras"; color: #7fc4ff; }
/* En pantallas bajas o estrechas, el botón se compacta y el récord no dice «ayer». */
@media (max-width: 1099px), (max-height: 760px) { .dir-ayer { display: none; } }
@media (max-width: 1099px) and (min-width: 761px) {
  .dir { padding: 12px; gap: 8px; }
  .dir-ico { width: 22px; height: 22px; }
  .dir-nombre { font-size: 19px; }
}
.portada-nota { font-size: 13px; color: var(--muy-tenue); margin: 18px 0 0; }
/* Siempre dos filas de tres (nunca una píldora suelta). */
.portada-niveles { display: grid; grid-template-columns: repeat(3, max-content); gap: 6px; list-style: none; margin: 8px 0 0; padding: 0; }
.portada-niveles li { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; letter-spacing: .02em; padding: 6px 12px 6px 9px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--c) 55%, transparent); color: var(--c); background: rgba(5, 6, 11, .55); }
.portada-niveles small { font-family: var(--mono); font-size: 11.5px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--tenue); }
/* Con la columna estrecha (menos de 520 px) no caben los aumentos: solo nombre e icono. */
@media (max-width: 1299px) and (min-width: 761px) { .portada-niveles small { display: none; } }
/* La nota del teclado, solo si sobra alto. */
@media (max-height: 940px) and (min-width: 761px) { .portada-nota:last-child { display: none; } }

.btn-principal {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px; padding: 0 28px; border-radius: 999px; border: 0;
  background: var(--ambar); color: #1a1006; font-weight: 700; font-size: 17px; letter-spacing: .01em;
  box-shadow: 0 10px 40px rgba(255, 179, 71, .28), inset 0 -2px 0 rgba(0, 0, 0, .15);
  transition: transform .15s, box-shadow .2s, background .2s; transition-timing-function: var(--salir);
}
.btn-principal:hover { transform: translateY(-2px); box-shadow: 0 16px 50px rgba(255, 179, 71, .38); }
.btn-principal:active { transform: translateY(1px) scale(.98); }
.btn-secundario {
  min-height: 48px; padding: 0 20px; border-radius: 999px; border: 1px solid var(--linea);
  background: rgba(255, 255, 255, .05); font-weight: 600; font-size: 15px;
  transition: background .2s, border-color .2s, transform .12s; transition-timing-function: var(--salir);
}
.btn-secundario:hover { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .3); }
.btn-secundario:active { transform: scale(.97); }
/* Sin reto no se juega: aviso centrado con «Reintentar». */
.aviso-carga {
  position: fixed; inset: 0; z-index: 20; margin: auto; height: fit-content; width: min(500px, calc(100% - 32px));
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  padding: 28px 24px 18px; border-radius: 22px; border: 1px solid var(--linea); background: rgba(9, 11, 20, .92);
}
.aviso-carga p { margin: 0; color: var(--tenue); }
.aviso-carga .aviso-titulo { font-family: var(--titular); font-size: 22px; font-weight: 600; color: var(--texto); line-height: 1.2; }
.aviso-carga .btn-principal { margin-top: 10px; }
.btn-texto { background: none; border: 0; color: var(--muy-tenue); text-decoration: underline; text-underline-offset: 4px; padding: 12px 0; font-size: 14px; transition: color .2s, transform .12s; transition-timing-function: var(--salir); }
.btn-texto:hover { color: var(--tenue); }
.btn-texto:active, .pasar:active { transform: translateY(1px); }

/* Entradas y salidas de paneles */
.entra { animation: entra .55s cubic-bezier(.2, .9, .25, 1) both; }
.sale { animation: sale .32s ease-in both; }
@keyframes entra { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: none; } }
@keyframes sale { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateX(-18px); } }

/* ---------- Pregunta ---------- */
.pregunta-num { font-family: var(--mono); font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--ambar); margin: 0 0 14px; }
.pregunta-texto { font-family: var(--titular); font-weight: var(--titular-peso); font-size: calc(clamp(40px, 4.2vw, 62px) * var(--titular-escala)); line-height: 1.02; margin: 0; letter-spacing: -.01em; text-wrap: balance; }
.pregunta-texto .p { display: inline-block; opacity: 0; transform: translateY(14px); animation: palabra .5s cubic-bezier(.2, .9, .3, 1) forwards; }
@keyframes palabra { to { opacity: 1; transform: none; } }
.pregunta-aclaracion { color: var(--tenue); font-size: 15px; margin: 14px 0 26px; min-height: 1.2em; }

.respuesta {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 8px 8px 8px; border-radius: 22px;
  background: rgba(14, 16, 27, .84); border: 1px solid rgba(255, 255, 255, .16);
  /* Sin backdrop-filter: desenfocar el lienzo, que cambia en cada fotograma, costaba tirones. */
  transition: border-color .2s, box-shadow .2s, opacity .3s; transition-timing-function: var(--salir);
}
.respuesta:focus-within { border-color: var(--ambar); box-shadow: 0 0 0 4px var(--ambar-suave); }
.respuesta.bloqueado { opacity: 1; }
.respuesta.confirmando { border-color: #7fd8ff; box-shadow: 0 0 0 4px rgba(127, 216, 255, .16); }
.campo {
  flex: 1; min-width: 0; height: 56px; border: 0; background: transparent; outline: none;
  font-size: 24px; font-weight: 500; letter-spacing: .01em; color: var(--texto); padding: 0 4px;
}
.campo::placeholder { color: var(--muy-tenue); font-weight: 400; }
.campo:read-only { cursor: default; }
.enviar {
  width: 52px; height: 52px; flex: none; border-radius: 16px; border: 0;
  background: var(--ambar); color: #1a1006; display: grid; place-items: center;
}
.enviar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.bloqueado .enviar { background: rgba(255, 255, 255, .12); color: var(--muy-tenue); }

.reloj { position: relative; width: 52px; height: 52px; flex: none; }
.reloj svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.reloj circle { fill: none; stroke-width: 3.5; }
.reloj-fondo { stroke: rgba(255, 255, 255, .12); }
.reloj-arco { stroke: var(--ambar); stroke-linecap: round; stroke-dasharray: 119.4; stroke-dashoffset: 0; transition: stroke .3s; transition-timing-function: var(--salir); }
.reloj-num { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--mono); font-weight: 700; font-size: 17px; }
/* Cuenta previa: número grande, sin anillo, y el campo apagado. Distinta del reloj de 25 s. */
.reloj.previa svg { opacity: 0; }
.reloj.previa .reloj-num { font-size: 40px; color: var(--ambar); text-shadow: 0 0 22px rgba(255, 179, 71, .55); }
.reloj svg { transition: opacity .25s var(--salir); }
.bloqueado .campo { opacity: .45; }
@keyframes pulso-num { 0% { transform: scale(1.35); opacity: .2; } 30% { transform: scale(1); opacity: 1; } }
.reloj.urgente .reloj-arco { stroke: var(--rojo); }
.reloj.urgente .reloj-num { color: var(--rojo); animation: pulso-num 1s ease-out infinite; }

.mensaje { min-height: 1.4em; margin: 14px 4px 0; font-size: 15px; color: var(--tenue); }
.mensaje[data-tipo="error"] { color: #ffb4a6; }
.mensaje[data-tipo="sugerencia"] { color: #a9e6ff; }
.sugerencias { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.sugerencia {
  min-height: 40px; padding: 0 16px; border-radius: 999px; font-weight: 600; font-size: 15px;
  border: 1px solid rgba(127, 216, 255, .45); background: rgba(127, 216, 255, .1); color: #d9f4ff;
}
.sugerencia.principal { background: #7fd8ff; color: #04131c; border-color: #7fd8ff; }
.sugerencia.principal::before { content: "✓ "; }
.pasar { margin-top: 18px; background: none; border: 0; padding: 6px 0; color: var(--muy-tenue); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; transition: color .2s, transform .12s; transition-timing-function: var(--salir); }
.pasar:hover { color: var(--tenue); }

.aviso-urgente {
  position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0;
  box-shadow: inset 0 0 140px rgba(255, 60, 70, .55);
  transition: opacity .4s; transition-timing-function: var(--salir);
}
.urgente .aviso-urgente { opacity: 1; animation: urgente 1s ease-in-out infinite; }
@keyframes urgente { 50% { opacity: .45; } }

/* Respuesta que viaja al centro */
.vuela {
  position: absolute; z-index: 8; font-family: var(--titular); font-size: 30px; white-space: nowrap;
  color: var(--texto); text-shadow: 0 0 20px rgba(255, 179, 71, .8); pointer-events: none;
  transform: translate(-50%, -50%); will-change: transform, opacity;
}

/* ---------- Revelación ---------- */
.tarjeta {
  position: relative; padding: 32px 34px 30px; border-radius: 28px;
  background: linear-gradient(180deg, rgba(14, 16, 28, .94), rgba(8, 9, 16, .96));
  border: 1px solid color-mix(in srgb, var(--nivel) 45%, transparent);
  isolation: isolate;
}
/* La sombra grande va en su propia capa: así no se repinta cuando cambian los puntos o el borde de la gema. */
.tarjeta::after {
  content: ""; position: absolute; inset: -1px; z-index: -1; border-radius: inherit; pointer-events: none;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55), 0 0 60px color-mix(in srgb, var(--nivel) 22%, transparent);
  will-change: transform;
}
.tarjeta-tuya { margin: 0; font-family: var(--mono); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muy-tenue); }
.tarjeta-respuesta { font-family: var(--titular); font-weight: var(--titular-peso); font-size: calc(clamp(34px, 3.4vw, 48px) * var(--titular-escala)); line-height: 1.05; margin: 6px 0 14px; }
.tarjeta-nivel {
  display: inline-block; margin: 0; font-weight: 700; font-size: 15px; letter-spacing: .16em; text-transform: uppercase;
  color: #0a0b10; background: var(--nivel); padding: 8px 14px; border-radius: 999px;
  box-shadow: 0 0 30px color-mix(in srgb, var(--nivel) 60%, transparent);
}
.tarjeta-frase { margin: 12px 0 0; color: var(--tenue); font-size: 16px; }
.tarjeta-puntos { display: flex; align-items: baseline; gap: 10px; margin: 18px 0 6px; }
.tarjeta-puntos span { font-family: var(--mono); font-weight: 700; font-size: 56px; line-height: 1; color: var(--nivel); }
.tarjeta-puntos small { color: var(--muy-tenue); font-size: 14px; }
.tarjeta-donde { margin: 0 0 6px; font-size: 15px; color: var(--tenue); }
.tarjeta-donde b { font-family: var(--mono); color: var(--ambar); font-weight: 500; }
.tarjeta-dato {
  margin: 16px 0 22px; padding: 14px 16px; border-radius: 14px; font-size: 16px; line-height: 1.45;
  background: rgba(255, 255, 255, .05); border-left: 3px solid var(--nivel);
}
.tarjeta-dato:empty { display: none; }
.tarjeta .btn-principal { width: 100%; margin-top: 4px; }
.revelacion.entra .tarjeta > * { animation: aparece .5s cubic-bezier(.2, .9, .3, 1) both; }
.revelacion.entra .tarjeta > :nth-child(2) { animation-delay: .05s; }
.revelacion.entra .tarjeta > :nth-child(3) { animation-delay: .18s; }
.revelacion.entra .tarjeta > :nth-child(4) { animation-delay: .28s; }
.revelacion.entra .tarjeta > :nth-child(5) { animation-delay: .34s; }
.revelacion.entra .tarjeta > :nth-child(6) { animation-delay: .5s; }
.revelacion.entra .tarjeta > :nth-child(7) { animation-delay: .62s; }
.revelacion.entra .tarjeta > :nth-child(8) { animation-delay: .75s; }
@keyframes aparece { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- Portada: entra por partes (el título letra a letra, luego el lema, los botones y «¿Cómo se juega?»).
   Un clic o una tecla la completan (main.js quita .intro); sin movimiento, base.css deja las animaciones en nada. */
.portada-titulo span { display: inline-block; }
.portada.intro .portada-kicker { animation: aparece .5s var(--salir) both; }
.portada.intro .portada-titulo span { animation: letra-portada .7s var(--salir) calc(.12s + var(--i) * .075s) both; }
.portada.intro .portada-lema { animation: aparece .6s var(--salir) .62s both; }
.portada.intro .direcciones { animation: aparece .6s var(--salir) .82s both; }
.portada.intro .portada-como { animation: aparece .6s var(--salir) 1.02s both; }
@keyframes letra-portada { from { opacity: 0; transform: translateY(.32em) rotate(calc(var(--g, 0) * 1deg)) scale(.9); } to { opacity: 1; transform: none; } }

/* ---------- Portada: «¿Cómo se juega?», plegado ---------- */
.portada-como { margin-top: 16px; }
/* Cerrado, lo de dentro no ocupa nada (Chrome le deja caja, y los detectores de solapes lo veían). */
.portada-como:not([open]) > :not(summary) { display: none; }
.portada-como summary { display: inline-flex; align-items: center; gap: 8px; color: var(--tenue); font-size: 15px; padding: 6px 0; transition: color .2s; transition-timing-function: var(--salir); }
.portada-como summary:hover { color: var(--texto); }
.portada-como summary::before { content: "▸"; color: var(--ambar); transition: transform .25s; transition-timing-function: var(--salir); }
.portada-como[open] summary::before { transform: rotate(90deg); }
.portada-como[open] .portada-reglas { margin-top: 12px; }
/* Con las reglas abiertas, la portada crece: la lectura de abajo se aparta y, si no cabe, la portada hace scroll. */
.app:has(.portada-como[open]) .lectura { opacity: 0; }
.portada:has(.portada-como[open]) { overflow-y: auto; overscroll-behavior: contain; }
/* Revisión visual 1: si el panel no cabe, su borde de abajo se funde mientras quede texto debajo (§1.2);
   en un móvil bajo, con las reglas abiertas, el escritorio se queda detrás del texto, apagado (§1.1). */
.portada.desborda { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 48px), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - 48px), transparent); }
#lienzo { transition: opacity .5s var(--salir); }
.portada-tapada #lienzo { opacity: .35; }
@media (min-width: 761px) { /* abierta, más junta: a 1440×900 cabe entera */
  .portada:has(.portada-como[open]) .portada-lema { margin-bottom: 18px; }
  .portada:has(.portada-como[open]) .portada-como { margin-top: 10px; }
  .portada:has(.portada-como[open]) .portada-reglas { margin-bottom: 12px; }
  .portada:has(.portada-como[open]) .portada-nota { margin-top: 10px; }
}

/* ---------- El portal de la gema: deja ver la frontera un momento (la única ventana del juego) ---------- */
/* Todo se pinta en su lienzo (main.js → pintarPortal): la lente, la frontera, el borde vivo y las chispas. */
.portal { position: absolute; z-index: 5; width: var(--caja); height: var(--caja); transform: translate(-50%, -50%); pointer-events: none; }
.portal canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.portal-nombre {
  position: absolute; left: 50%; top: calc(50% + var(--lado) / 2 + 14px); transform: translateX(-50%); white-space: nowrap; margin: 0;
  font-family: var(--mono); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: #ffc6f1;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .9);
  opacity: 0; transition: opacity .4s var(--salir) .25s;
}
.portal.abierto .portal-nombre { opacity: 1; }
.portal.cerrando .portal-nombre { opacity: 0; transition: opacity .2s; }

/* ---------- Final: lo que te quedó por ver ---------- */
.final-falta { margin: 8px 0 0; font-size: 15px; color: var(--ambar); }
.final-falta:empty { display: none; }
.revelacion.entra .tarjeta-nivel { animation: sello .55s cubic-bezier(.2, 1.6, .4, 1) .18s both !important; }
@keyframes sello { 0% { opacity: 0; transform: scale(2.4) rotate(-6deg); } 100% { opacity: 1; transform: none; } }

/* Gema: borde tornasolado y brillo */
.tarjeta.gema {
  border: 2px solid transparent;
  background:
    linear-gradient(180deg, rgba(18, 12, 30, .97), rgba(9, 8, 18, .97)) padding-box,
    conic-gradient(from var(--giro, 0deg), #ff4fd8, #7fd8ff, #ffe27a, #b18cff, #ff4fd8) border-box;
  animation: tornasol 3s linear infinite;
}
.tarjeta.gema::after { box-shadow: 0 30px 80px rgba(0, 0, 0, .55), 0 0 90px rgba(255, 79, 216, .35); }
.tarjeta.gema .tarjeta-nivel { background: linear-gradient(90deg, #ff4fd8, #b18cff, #7fd8ff, #ff4fd8); background-size: 200% 100%; animation: brillo-nivel 2s linear infinite; }
@property --giro { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@keyframes tornasol { to { --giro: 360deg; } }
@keyframes brillo-nivel { to { background-position: -200% 0; } }
.tarjeta.nada { --nivel: #6b7080; }

/* ---------- Final ---------- */
.final { position: absolute; inset: 0; z-index: 7; }
.final-panel {
  position: absolute; top: 76px; bottom: 0; left: 0; width: min(640px, 50vw);
  padding: 20px var(--margen) 60px; overflow-y: auto; overscroll-behavior: contain;
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 22px);
  mask-image: linear-gradient(180deg, transparent 0, #000 22px);
  background: linear-gradient(90deg, rgba(5, 6, 11, .95) 70%, rgba(5, 6, 11, .6) 100%);
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .2) transparent;
}
.final-etq { margin: 0; font-family: var(--mono); font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--muy-tenue); }
.final-pot { font-family: var(--mono); font-weight: 700; font-size: clamp(56px, 6vw, 88px); color: var(--ambar); margin: 6px 0 0; line-height: 1; letter-spacing: -.03em; }
.final-lugar { font-family: var(--titular); font-size: clamp(30px, 3vw, 42px); margin: 8px 0 6px; line-height: 1.1; }
.final-dato { color: var(--tenue); font-size: 16px; line-height: 1.5; margin: 0 0 20px; }
.final-total { font-size: 18px; color: var(--tenue); }
.final-total strong { font-family: var(--mono); font-size: 34px; color: var(--texto); }
.final-total span { display: block; font-size: 14px; color: var(--muy-tenue); margin-top: 2px; }
.final-acciones { margin: 18px 0 8px; display: flex; gap: 10px; flex-wrap: wrap; }
.final-sub { font-family: var(--titular); font-weight: var(--titular-peso); font-size: 28px; margin: 38px 0 12px; }
.final-ayuda { margin: -6px 0 14px; color: var(--muy-tenue); font-size: 14px; }
.final-bajada svg { width: 100%; height: auto; display: block; }
.compartir-texto {
  font-family: var(--mono), "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji"; font-size: 15px; line-height: 1.6; margin: 0 0 14px; padding: 16px 18px;
  border-radius: 16px; background: rgba(255, 255, 255, .05); border: 1px solid var(--linea); white-space: pre-wrap;
}
.final-botones { display: flex; gap: 10px; flex-wrap: wrap; }
.final-proximo { color: var(--tenue); font-size: 15px; margin: 18px 0 0; }
.final-proximo b { font-family: var(--mono); color: var(--texto); }
.estadisticas { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 28px; }
.estadistica { text-align: center; padding: 12px 6px; border-radius: 14px; background: rgba(255, 255, 255, .04); border: 1px solid var(--linea); }
.estadistica strong { display: block; font-family: var(--mono); font-size: 24px; }
.estadistica span { font-size: 12px; color: var(--muy-tenue); text-transform: uppercase; letter-spacing: .08em; }

/* Resumen de rondas (comun/final.js) */
.resumen-rondas { list-style: none; margin: 0 0 24px; padding: 0; display: grid; gap: 8px; }
.rr details { border-radius: 16px; border: 1px solid var(--linea); background: rgba(255, 255, 255, .03); overflow: hidden; }
.rr details[open] { background: rgba(255, 255, 255, .05); }
.rr summary { display: grid; grid-template-columns: 30px 1fr auto 18px; gap: 12px; align-items: center; padding: 12px 14px; }
.rr summary:hover { background: rgba(255, 255, 255, .04); }
.rr-num { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-family: var(--mono); font-size: 13px; font-weight: 700; color: #0a0b10; background: var(--color-nivel); }
.rr-cuerpo { min-width: 0; display: flex; flex-direction: column; }
.rr-preg { font-size: 12px; color: var(--muy-tenue); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rr-resp { font-family: var(--titular); font-size: 21px; line-height: 1.15; }
.rr-lado { display: flex; flex-direction: column; align-items: flex-end; }
.rr-nivel { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--color-nivel); font-weight: 700; }
.rr-pts { font-family: var(--mono); font-size: 15px; }
.rr-flecha::before { content: "▾"; color: var(--muy-tenue); transition: transform .2s; transition-timing-function: var(--salir); display: inline-block; }
.rr details[open] .rr-flecha::before { transform: rotate(180deg); }
.rr-todas { padding: 4px 14px 14px; max-height: 360px; overflow-y: auto; }
.rr-titulo { font-size: 12px; color: var(--muy-tenue); margin: 4px 0 10px; }
.rr-lista { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.rr-item { padding: 7px 10px; border-radius: 10px; position: relative; }
.rr-item.elegida { background: color-mix(in srgb, var(--color-nivel) 18%, transparent); outline: 1px solid var(--color-nivel); }
.rr-item-cab { display: grid; grid-template-columns: 22px 1fr auto 34px; gap: 8px; align-items: baseline; }
.rr-item-nombre { font-weight: 600; }
.rr-item-nivel { font-size: 11px; color: var(--color-nivel); text-transform: uppercase; letter-spacing: .06em; }
.rr-item-pts { font-family: var(--mono); font-size: 13px; text-align: right; color: var(--tenue); }
.rr-item-dato { margin: 3px 0 0 30px; font-size: 13.5px; color: var(--tenue); line-height: 1.4; }
.rr-item-tuya { position: absolute; right: 48px; top: 8px; font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--color-nivel); }

/* ---------- Móvil ---------- */
@media (max-width: 760px) {
  :root { --centro-x: 50%; --centro-y: 36%; --margen: 16px; }
  .app::before { background: linear-gradient(0deg, rgba(var(--velo), .95) 0%, rgba(var(--velo), .75) 34%, rgba(var(--velo), 0) 58%); }
  .hud { grid-template-columns: auto 1fr auto; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; gap: 10px; }
  .marca-nombre { font-size: 20px; }
  .marca-reto { font-size: 9.5px; margin-top: 0; } /* «Partida libre» bajo el nombre, como en el ordenador */
  .progreso { justify-self: center; gap: 6px; }
  .progreso li { width: 9px; height: 9px; }
  .marcador { font-size: 18px; }
  .btn-icono { width: 38px; height: 38px; }
  /* position: static: así la lectura se coloca respecto a la app (bajo la cabecera) y no respecto al pie, que está abajo del todo. */
  .pie { padding: 0; position: static; }
  .teclado-abierto .lectura { display: none; }
  .lectura { position: absolute; right: auto; left: 16px; bottom: auto; top: calc(62px + env(safe-area-inset-top)); text-align: left; min-width: 0; }
  .lectura-pot { font-size: 24px; }
  .lectura-med { font-size: 12px; margin-top: 2px; }
  .lectura-lugar { font-size: 10px; }
  .leyendas { top: calc(var(--centro-y) + 70px); }
  .leyenda { font-size: 11.5px; }
  .datillo { font-size: 12.5px; padding: 6px 10px 7px; }
  .escalera { display: none; }

  /* justify-self: stretch: con el «start» del escritorio, un panel absoluto toma el ancho de su contenido y se sale. */
  .portada, .pregunta, .revelacion {
    position: absolute; left: 16px; right: 16px; width: auto; top: auto; margin: 0; max-height: none; justify-self: stretch;
    bottom: calc(16px + env(safe-area-inset-bottom));
  }
  .teclado-abierto .pregunta { bottom: 10px; }
  .portada { max-height: calc(100% - 74px - env(safe-area-inset-top)); } /* abierta, no se mete bajo la cabecera */
  .entra { animation-name: entra-m; }
  .sale { animation-name: sale-m; }
  @keyframes entra-m { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
  @keyframes sale-m { from { opacity: 1; } to { opacity: 0; transform: translateY(16px); } }
  .portada-titulo { font-size: 64px; }
  .portada-lema { font-size: 23px; margin: 10px 0 16px; }
  .portada-reglas { font-size: 14.5px; gap: 8px; margin-bottom: 20px; }
  .portada-nota, .portada-niveles { display: none; }
  .direcciones { gap: 8px; }
  .dir { padding: 12px; gap: 8px; border-radius: 16px; }
  .dir-ico { width: 24px; height: 24px; }
  .dir-nombre { font-size: 18px; }
  .dir-meta { font-size: 12.5px; }
  .pregunta-num { font-size: 11px; margin-bottom: 8px; }
  .pregunta-texto { font-size: 30px; }
  .pregunta-aclaracion { font-size: 13.5px; margin: 8px 0 14px; }
  .teclado-abierto .pregunta-aclaracion { display: none; }
  /* Con el teclado abierto en pantallas bajas (iPhone SE), la pregunta se compacta para no pisar la cabecera. */
  .teclado-abierto .pregunta-num { margin-bottom: 4px; }
  .teclado-abierto .pregunta-texto { font-size: 24px; margin-bottom: 12px; } /* que la 2.ª línea no roce el campo */
  .teclado-abierto .pasar { margin-top: 2px; }
  .respuesta { gap: 8px; padding: 6px; border-radius: 18px; }
  .reloj { width: 44px; height: 44px; }
  .campo { height: 48px; font-size: 20px; }
  .enviar { width: 46px; height: 46px; border-radius: 13px; }
  .mensaje { font-size: 14px; margin-top: 8px; }
  .pasar { margin-top: 6px; }
  .tarjeta { padding: 22px 20px 18px; border-radius: 22px; }
  .tarjeta-respuesta { font-size: 32px; margin-bottom: 10px; }
  .tarjeta-puntos { margin: 12px 0 4px; }
  .tarjeta-puntos span { font-size: 42px; }
  .tarjeta-dato { margin: 12px 0 14px; font-size: 14.5px; }
  .final-panel { width: 100%; top: calc(58px + env(safe-area-inset-top)); padding: 16px 16px 40px; background: rgba(5, 6, 11, .93); }
  .rr summary { grid-template-columns: 28px 1fr auto 14px; gap: 10px; padding: 10px; }
  .rr-resp { font-size: 18px; }
  .estadisticas { gap: 6px; }
}

/* Va antes que el de 760 px: si no, le pisa los márgenes compactos. */
@media (max-height: 860px) and (min-width: 761px) {
  .portada-titulo { font-size: calc(clamp(64px, 11vh, 110px) * var(--titular-escala)); }
  .portada-lema { margin: 14px 0 20px; }
  .portada-reglas { gap: 9px; margin-bottom: 24px; }
  /* La portada usa también la fila del pie: la lectura vuelve al empezar. */
  .app:has(#portada:not([hidden])) .pie { display: none; }
}

@media (max-height: 760px) and (min-width: 761px) {
  .portada-titulo { font-size: calc(clamp(60px, 10.5vh, 84px) * var(--titular-escala)); }
  .portada-lema { margin: 12px 0 18px; }
  .portada-reglas { gap: 8px; font-size: 15px; margin-bottom: 22px; }
  .portada-nota { margin-top: 12px; }
  .portada-kicker { margin-bottom: 10px; }
  .pregunta-texto { font-size: calc(44px * var(--titular-escala)); }
  .tarjeta { padding: 24px 28px 22px; }
  /* En pantallas bajas, la portada usa también la fila del pie y la tarjeta no lleva lectura. */
  .app:has(#revelacion:not([hidden])) .lectura { opacity: 0; }
}

@media (max-height: 640px) and (min-width: 761px) {
  .portada-kicker { display: none; }
  .portada-titulo { font-size: calc(68px * var(--titular-escala)); }
  .portada-lema { font-size: 24px; margin: 8px 0 14px; }
  .portada-reglas { font-size: 14px; gap: 6px; margin-bottom: 18px; }
  .dir { padding: 10px 12px; }
  .dir-meta { display: none; }
  .pregunta-aclaracion { margin: 10px 0 18px; }
  .tarjeta { padding: 20px 24px 18px; }
  .tarjeta-respuesta { margin-bottom: 10px; }
  .tarjeta-dato { margin: 10px 0 12px; }
  .pie { padding-bottom: 16px; }
}

.entra-final { animation: entra-final .7s cubic-bezier(.2, .9, .25, 1) both; }
@keyframes entra-final { from { opacity: 0; transform: translateX(-30px); } to { opacity: 1; transform: none; } }

/* ---------- Tipografía (fuentes.js, ?fuente=N) ---------- */
/* Cifras de ancho fijo aunque la fuente de cifras cambie. */
.lectura, .marcador, .reloj-num, .tarjeta-puntos, .final-pot, .final-total, .estadistica strong { font-variant-numeric: tabular-nums; }
.portada-titulo, .pregunta-texto, .tarjeta-respuesta { letter-spacing: -.03em; }
[data-fuente="2"] { --titular-peso: 600; --titular-escala: .9; }
[data-fuente="2"] .portada-titulo, [data-fuente="2"] .pregunta-texto, [data-fuente="2"] .tarjeta-respuesta { letter-spacing: -.01em; }
[data-fuente="3"] { --titular-peso: 600; --titular-escala: .66; }
[data-fuente="3"] .portada-titulo, [data-fuente="3"] .pregunta-texto, [data-fuente="3"] .tarjeta-respuesta { letter-spacing: .01em; line-height: 1.12; }

/* Exponentes: <sup> propio, misma fuente, altura fija (sin mover la línea). */
sup.exp { font-size: .58em; line-height: 0; vertical-align: 0; position: relative; top: -.78em; margin: 0 -.18em 0 .04em; letter-spacing: 0; }

/* Botón que confirma "¡Copiado!" */
.btn-principal.hecho { background: #5ee08f; border-color: #5ee08f; color: #07120b; }

/* ---------- Momento «HÁPAX» (gema) ----------
   Capa a pantalla completa sobre todo. Solo transform, opacity y background-position:
   el lienzo sigue a su ritmo debajo (partículas y temblor de cámara van en motor.js). */
.hapax {
  position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; overflow: hidden;
  background: radial-gradient(ellipse at 50% 50%, rgba(5, 6, 11, .62) 0%, rgba(5, 6, 11, .35) 55%, rgba(5, 6, 11, .1) 100%);
  cursor: pointer; animation: hapax-velo .25s ease-out both;
}
.hapax.precarga { opacity: .003; pointer-events: none; }
/* Durante el viaje la capa ya está montada (casi transparente y en su estado final): el navegador la pinta antes de que haga falta. */
.hapax.precarga, .hapax.precarga * { animation: none !important; }
.hapax.fuera { opacity: 0; transition: opacity .38s var(--salir); }
.hapax.fuera.rapido { transition-duration: .18s; }
@keyframes hapax-velo { from { opacity: 0; } to { opacity: 1; } }
.hapax-destello {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 50% 50%, #fff 0%, rgba(255, 230, 250, .95) 22%, rgba(255, 79, 216, .45) 48%, rgba(127, 216, 255, 0) 75%);
  animation: hapax-destello .75s ease-out both;
}
@keyframes hapax-destello { 0% { opacity: 1; } 100% { opacity: 0; } }
.hapax-onda {
  position: absolute; left: 50%; top: 50%; width: 40vmax; height: 40vmax; margin: -20vmax 0 0 -20vmax;
  border-radius: 50%; pointer-events: none; opacity: 0;
  border: 4px solid rgba(255, 255, 255, .9);
  animation: hapax-onda 1.1s cubic-bezier(.15, .7, .3, 1) both;
}
.hapax-onda:nth-of-type(3) { animation-delay: .14s; border-color: rgba(255, 140, 230, .8); }
.hapax-onda:nth-of-type(4) { animation-delay: .3s; border-color: rgba(127, 216, 255, .7); border-width: 2px; }
@keyframes hapax-onda { 0% { opacity: 1; transform: scale(.05); } 70% { opacity: .5; } 100% { opacity: 0; transform: scale(3); } }
.hapax-centro { position: relative; text-align: center; padding: 0 16px; animation: hapax-temblor .5s linear .05s both; }
@keyframes hapax-temblor {
  0%, 100% { transform: none; } 10% { transform: translate(-9px, 5px) rotate(-.6deg); } 20% { transform: translate(8px, -7px) rotate(.5deg); }
  30% { transform: translate(-7px, -4px); } 40% { transform: translate(6px, 6px) rotate(-.3deg); } 55% { transform: translate(-4px, 2px); }
  70% { transform: translate(3px, -2px); } 85% { transform: translate(-1px, 1px); }
}
.hapax-titulo {
  position: relative; margin: 0; display: flex; justify-content: center; gap: .02em;
  font-family: var(--titular); font-weight: 700; line-height: .95; letter-spacing: .02em;
  font-size: min(21vw, 36vh, 340px);
}
/* Aura detrás de las letras: degradado radial, sin filtros (un blur sobre letras tan grandes costaba un tirón). */
.hapax-titulo::before {
  content: ""; position: absolute; inset: -30% -8%; z-index: -1; opacity: 0; will-change: opacity;
  background: radial-gradient(ellipse at 50% 50%, rgba(255, 79, 216, .5) 0%, rgba(177, 140, 255, .28) 38%, rgba(127, 216, 255, 0) 68%);
  animation: hapax-halo .7s ease-out .2s both;
}
@keyframes hapax-halo { to { opacity: 1; } }
.hapax-titulo span {
  display: inline-block; color: var(--c);
  animation: hapax-letra .62s cubic-bezier(.2, 1.5, .35, 1) calc(.08s + var(--i) * .075s) both;
}
/* Iridiscencia: cada letra con un color fijo de la paleta y el tono girando sobre el conjunto.
   Un degradado recortado al texto o un color animado obligaban a repintar letras enormes (tirones);
   hue-rotate sobre contenido fijo lo hace la GPU. */
.hapax-titulo span:nth-child(1) { --c: #ff8ee6; }
.hapax-titulo span:nth-child(2) { --c: #c7a8ff; }
.hapax-titulo span:nth-child(3) { --c: #8fe0ff; }
.hapax-titulo span:nth-child(4) { --c: #a8ffd9; }
.hapax-titulo span:nth-child(5) { --c: #fff3a6; }
.hapax-titulo { animation: hapax-iris 2.2s linear infinite; }
@keyframes hapax-letra { 0% { opacity: 0; transform: translateY(.18em) scale(2.4) rotate(calc(var(--g) * 1deg)); } 60% { opacity: 1; } 100% { opacity: 1; transform: none; } }
@keyframes hapax-iris { from { filter: hue-rotate(0deg); } to { filter: hue-rotate(360deg); } }
.hapax-def {
  margin: .6em auto 0; max-width: 34em; min-height: 1.5em;
  font-family: var(--mono); font-size: clamp(16px, 1.7vw, 24px); color: #fff; letter-spacing: .01em;
  text-shadow: 0 2px 14px rgba(0, 0, 0, .9);
}
.hapax-def b { color: #ff8ee6; font-weight: 700; }
.hapax-def::after { content: "▍"; color: #ff8ee6; animation: hapax-cursor .6s steps(1) infinite; }
.hapax-def.hecha::after { content: none; }
@keyframes hapax-cursor { 50% { opacity: 0; } }
.hapax-tuya {
  margin: .8em 0 0; font-family: var(--titular); font-size: clamp(20px, 2.2vw, 30px); color: var(--texto);
  text-shadow: 0 2px 14px rgba(0, 0, 0, .9); opacity: 0; transform: translateY(8px); transition: opacity .4s, transform .4s; transition-timing-function: var(--salir);
}
.hapax-tuya.visible { opacity: 1; transform: none; }
.hapax-tuya em { font-style: normal; color: #ff8ee6; }
.hapax-saltar {
  margin: 2.4em 0 0; text-align: center;
  font-family: var(--mono); font-size: 12px; letter-spacing: .06em; color: var(--muy-tenue);
  animation: hapax-velo .4s var(--salir) 1s both;
}
.leyendas { transition: opacity .25s var(--salir); }
.app:has(#hapax:not([hidden]):not(.precarga)) .leyendas { opacity: 0; }

/* Hacia fuera, el mismo momento con tono de espacio profundo: azules fríos, estrellas y oro de estrella. */
.hapax.tono-fuera { background: radial-gradient(ellipse at 50% 50%, rgba(4, 8, 24, .7) 0%, rgba(4, 8, 24, .45) 55%, rgba(4, 8, 24, .15) 100%); }
.hapax.tono-fuera .hapax-destello { background: radial-gradient(circle at 50% 50%, #fff 0%, rgba(220, 235, 255, .95) 20%, rgba(80, 140, 255, .45) 48%, rgba(120, 90, 255, 0) 75%); }
.hapax.tono-fuera .hapax-onda { border-color: rgba(200, 225, 255, .9); }
.hapax.tono-fuera .hapax-onda:nth-of-type(3) { border-color: rgba(120, 180, 255, .8); }
.hapax.tono-fuera .hapax-onda:nth-of-type(4) { border-color: rgba(170, 140, 255, .7); }
.hapax.tono-fuera .hapax-titulo::before { background: radial-gradient(ellipse at 50% 50%, rgba(90, 150, 255, .5) 0%, rgba(140, 110, 255, .28) 38%, rgba(127, 216, 255, 0) 68%); }
.hapax.tono-fuera .hapax-titulo span:nth-child(1) { --c: #8fc8ff; }
.hapax.tono-fuera .hapax-titulo span:nth-child(2) { --c: #b8a8ff; }
.hapax.tono-fuera .hapax-titulo span:nth-child(3) { --c: #e8f2ff; }
.hapax.tono-fuera .hapax-titulo span:nth-child(4) { --c: #7fe8ff; }
.hapax.tono-fuera .hapax-titulo span:nth-child(5) { --c: #ffd98a; }
/* El tono gira poco: de azul a violeta, sin pasar por el rosa de hacia dentro. */
.hapax.tono-fuera .hapax-titulo { animation-name: hapax-iris-fuera; }
@keyframes hapax-iris-fuera { 0%, 100% { filter: hue-rotate(-25deg); } 50% { filter: hue-rotate(35deg); } }
.hapax.tono-fuera .hapax-def b, .hapax.tono-fuera .hapax-def::after, .hapax.tono-fuera .hapax-tuya em { color: #8fc8ff; }

@media (max-width: 760px) {
  .hapax-titulo { font-size: 25vw; }
  .hapax-def { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .hapax-destello, .hapax-onda { display: none; }
  .hapax-centro { animation: none; }
  .hapax-titulo span { animation: hapax-velo .4s ease both; }
  .hapax-titulo { animation: none; }
  .hapax-def::after { content: none; }
}

/* Explorar el descenso: al acabar «Repetir el viaje», la rueda o el arrastre mueven la cámara. */
.final.explorando { touch-action: none; }
.final.explorando .final-panel { touch-action: pan-y; }
.explorador {
  position: absolute; left: var(--centro-x); bottom: 28px; transform: translateX(-50%);
  width: min(440px, 42vw); padding: 14px 18px; border-radius: 18px; text-align: center; pointer-events: none;
  background: rgba(9, 11, 20, .86); border: 1px solid var(--linea);
  animation: explorador .5s var(--salir) both;
}
@keyframes explorador { from { opacity: 0; } to { opacity: 1; } }
.explorador p { margin: 0; }
.explorador-lugar { font-family: var(--titular); font-weight: var(--titular-peso); font-size: 22px; }
.explorador-dato { font-size: 14px; line-height: 1.4; color: var(--tenue); margin-top: 6px !important; }
.explorador-ayuda { font-family: var(--mono); font-size: 11px; letter-spacing: .03em; color: var(--muy-tenue); margin-top: 10px !important; }
/* En móvil el panel final ocupa la pantalla y no queda lienzo que explorar: de momento, solo escritorio. */
@media (max-width: 760px) { .explorador { display: none; } }

/* ---------- T27: enlaces, «ya jugado» y archivo ---------- */
.portada-pie { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.portada-pie .portada-como { flex: 1; min-width: 0; }
.portada-enlaces, .final-enlaces { display: flex; gap: 18px; margin: 10px 0 0; font-size: 14px; }
.portada-pie .portada-enlaces { margin: 16px 0 0; flex: none; }
.portada-pie .portada-enlaces a { padding: 6px 0; display: inline-block; line-height: 1.6; }
.portada-enlaces a, .final-enlaces a { color: var(--muy-tenue); text-underline-offset: 4px; padding: 6px 0; }
.portada-enlaces a:hover, .final-enlaces a:hover { color: var(--tenue); }
.portada-enlaces a[hidden] { display: none; }
.final-enlaces { margin-top: 4px; }
.final-ya { margin: 0 0 14px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--linea); background: rgba(255, 179, 71, .08); color: var(--texto); font-size: 15px; }
.archivo {
  position: fixed; inset: 0; z-index: 20; overflow-y: auto; overscroll-behavior: contain;
  padding: max(28px, env(safe-area-inset-top)) 16px 40px; background: rgba(5, 6, 11, .96);
}
.archivo > * { max-width: 560px; margin-left: auto; margin-right: auto; }
.archivo-titulo { font-family: var(--titular); font-size: 34px; font-weight: 600; margin: 8px auto 6px; }
.archivo-ayuda { color: var(--tenue); margin: 0 auto 18px; }
.archivo-lista { list-style: none; padding: 0; display: grid; gap: 6px; }
.archivo-dia { display: grid; grid-template-columns: 5.5em 1fr auto; gap: 10px; align-items: baseline; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--linea); color: var(--texto); text-decoration: none; background: rgba(255, 255, 255, .03); }
.archivo-dia:hover, .archivo-dia:focus-visible { border-color: rgba(255, 179, 71, .6); outline: none; }
.archivo-num { font-family: var(--mono); color: var(--ambar); }
.archivo-fecha::first-letter { text-transform: uppercase; }
.archivo-marca { font-size: 12px; color: var(--muy-tenue); }
.archivo-form { display: grid; gap: 10px; max-width: 360px; margin: 30vh auto 0; }
.archivo-form label { color: var(--tenue); }
.archivo-campo { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--linea); background: rgba(255, 255, 255, .05); color: var(--texto); font-size: 16px; }
.portada.intro .portada-enlaces { animation: aparece .6s var(--salir) 1.02s both; }

/* Cabecera legible en el móvil: encima de la franja clara del fondo (el techo de la habitación), «RETO N.º» y el
   nombre quedaban a 1,9–2,2:1. Un degradado oscuro detrás, sin tapar lo que hay debajo (T27, revisión visual). */
@media (max-width: 760px) {
  .hud::before {
    content: ""; position: absolute; left: 0; right: 0; top: 0; z-index: -1; pointer-events: none;
    height: calc(84px + env(safe-area-inset-top));
    background: linear-gradient(to bottom, rgba(5, 6, 11, .92) 0%, rgba(5, 6, 11, .82) 55%, rgba(5, 6, 11, 0) 100%);
  }
}
