/* AUTOπSTA — paleta de marca (idéntica a scripts/managers/Estilo.gd del proyecto Godot) */
:root {
  --indigo: #796dff;
  --ambar: #ff6532;
  --coral: #ff9106;
  --rosa: #ff5c92;
  --verde: #bad432;
  --azul: #2a95ff;
  --sec-rojo: #993c1d;
  --sec-teal: #0f6e56;
  --sec-morado: #534ab7;
  --blanco: #ffffff;
  --gris-claro: #ededed;
  --gris-medio: #9f9f9f;
  --gris-oscuro: #737373;
  --negro: #2b2b2b;
  --correcto: var(--sec-teal);
  --incorrecto: var(--sec-rojo);
  --estrella: #ffd84a;
  --outline-mapa: #1a2845;

  --escala-texto: 1;
}

@font-face {
  font-family: "BubblegumSans";
  src: url("../assets/fonts/BubblegumSans-Regular.ttf") format("truetype");
}
@font-face {
  font-family: "Montserrat";
  src: url("../assets/fonts/Montserrat-Variable.ttf") format("truetype");
  font-weight: 100 900;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: "Montserrat", sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#lienzo {
  position: relative;
  width: 100%;
  max-width: 520px;
  aspect-ratio: 1080 / 1920;
  margin: 0 auto;
  height: 100vh;
  max-height: 100vh;
  /* 100dvh (viewport dinámico) evita que la barra de direcciones del navegador
     móvil tape la parte de abajo de la pantalla — los navegadores que no la
     soportan simplemente ignoran esta línea y se quedan con el 100vh de arriba. */
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
  font-size: calc(16px * var(--escala-texto));
}

@media (min-width: 521px) {
  html, body { background: #111; }
}

.pantalla {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.pantalla.activa { display: flex; }

.fondo-degradado {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.scroll {
  position: relative;
  z-index: 1;
  flex: 1;
  /* Sin min-height:0 un hijo flex no se deja encoger por debajo de su contenido
     en varios navegadores móviles, así que en vez de hacer scroll interno el
     contenido se sale por debajo y queda inalcanzable (recortado por el
     overflow:hidden del padre). Este es el arreglo estándar para ese bug. */
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.scroll::-webkit-scrollbar { width: 6px; }
.scroll::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.25); border-radius: 4px; }

/* ---------- Texto con contraste garantizado (equivalente a Estilo.texto_legible) ---------- */
.titulo-juego {
  font-family: "BubblegumSans", cursive;
  color: var(--blanco);
  -webkit-text-stroke: 3px var(--negro);
  paint-order: stroke fill;
  text-align: center;
  margin: 0;
}
.titulo-llamativo {
  font-family: "BubblegumSans", cursive;
  color: var(--blanco);
  -webkit-text-stroke: 6px var(--ambar);
  paint-order: stroke fill;
  text-align: center;
  margin: 0;
}
.texto-legible {
  color: var(--blanco);
  -webkit-text-stroke: 1px var(--negro);
  paint-order: stroke fill;
}
.texto-oscuro {
  color: #0d0d0d;
}

/* ---------- Botón "arcade": sombra sólida inferior, se hunde al presionar ---------- */
.btn {
  --color: var(--indigo);
  font-family: "Montserrat", sans-serif;
  font-weight: 700;
  font-size: 1.1em;
  color: var(--blanco);
  background: var(--color);
  border: none;
  border-radius: 18px;
  padding: 14px 20px;
  box-shadow: 0 6px 0 color-mix(in srgb, var(--color) 60%, black);
  cursor: pointer;
  transition: transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.08s, filter 0.1s;
  -webkit-text-stroke: 1px rgba(0, 0, 0, 0.5);
  paint-order: stroke fill;
}
.btn:hover { filter: brightness(1.1); transform: translateY(-2px) scale(1.03); }
.btn:active {
  transform: translateY(4px) scale(0.98);
  box-shadow: 0 2px 0 color-mix(in srgb, var(--color) 60%, black);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  filter: grayscale(0.3);
}
.btn.chico { padding: 10px 14px; font-size: 0.95em; border-radius: 14px; }

/* ---------- Tarjetas / chips ---------- */
.tarjeta {
  background: var(--blanco);
  border-radius: 20px;
  padding: 16px 18px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
  border: 2px solid rgba(0, 0, 0, 0.08);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(16, 16, 20, 0.75);
  color: var(--blanco);
  border-radius: 16px;
  padding: 6px 14px;
  font-weight: 700;
  font-size: 0.95em;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.chip.pulso { animation: pulso-racha 0.8s ease-in-out infinite; background: var(--coral); }

@keyframes pulso-racha {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}
@keyframes pulso-chip {
  0% { transform: scale(1); }
  40% { transform: scale(1.3); }
  100% { transform: scale(1); }
}
.chip.rebote { animation: pulso-chip 0.25s cubic-bezier(0.34, 1.56, 0.64, 1); }

/* ---------- Accesibilidad ---------- */
.control-accesibilidad {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 20;
  display: flex;
  gap: 6px;
}
.control-accesibilidad button {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: none;
  background: rgba(20, 20, 30, 0.7);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

/* ---------- Animaciones genéricas ---------- */
@keyframes pop-in {
  0% { transform: scale(0.6); opacity: 0; }
  70% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes sacudir {
  0%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(3deg); }
  40% { transform: rotate(-3deg); }
  60% { transform: rotate(2.5deg); }
  80% { transform: rotate(-2.5deg); }
}
.sacudir { animation: sacudir 0.28s ease-in-out; }

@keyframes flotar {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* ---------- Toast de recompensa ---------- */
#toast-capa {
  position: absolute;
  top: 140px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--coral);
  color: #fff;
  font-weight: 800;
  padding: 10px 18px;
  border-radius: 16px;
  text-align: center;
  white-space: pre-line;
  -webkit-text-stroke: 1px rgba(0, 0, 0, 0.6);
  paint-order: stroke fill;
  animation: pop-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), desvanecer 0.3s ease 1.3s forwards;
}
@keyframes desvanecer {
  to { opacity: 0; transform: translateY(-10px); }
}

/* ---------- Confeti ---------- */
.confeti-pieza {
  position: absolute;
  z-index: 55;
  border-radius: 2px;
  pointer-events: none;
}

/* ---------- Overlays / modales ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.overlay.mostrar { background: rgba(0, 0, 0, 0.65); }
.overlay .tarjeta {
  width: 86%;
  max-height: 80%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transform: scale(0.9);
  opacity: 0;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s;
}
.overlay.mostrar .tarjeta { transform: scale(1); opacity: 1; }

/* ---------- Corazón roto (secuencia de perder vida) ---------- */
#capa-corazon {
  position: absolute;
  inset: 0;
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  background: rgba(64, 5, 5, 0);
  transition: background 0.2s;
}
#capa-corazon.mostrar { display: flex; }
#capa-corazon .corazon-emoji {
  font-size: 90px;
  transition: transform 0.18s, opacity 0.35s;
}
#capa-corazon .texto-corazon {
  color: #fff;
  -webkit-text-stroke: 1.5px #000;
  paint-order: stroke fill;
  font-weight: 800;
  font-size: 1.3em;
  text-align: center;
  padding: 0 30px;
  opacity: 0;
  transition: opacity 0.3s;
}
@keyframes temblor-pantalla {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-6px, 4px); }
  40% { transform: translate(5px, -5px); }
  60% { transform: translate(-4px, -3px); }
  80% { transform: translate(6px, 3px); }
}
.temblando { animation: temblor-pantalla 0.32s linear; }

/* ---------- Anillo de tiempo ---------- */
.anillo-tiempo {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 50px;
  height: 50px;
  z-index: 15;
}
.anillo-tiempo svg { transform: rotate(-90deg); }
.anillo-tiempo circle.fondo { stroke: rgba(0, 0, 0, 0.18); }
.anillo-tiempo circle.progreso {
  stroke: var(--coral);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.2s linear, stroke 0.2s;
}
.anillo-tiempo .numero {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85em;
  color: #111;
}

.pulso-suave { animation: pulso-suave 1.6s ease-in-out infinite; }
@keyframes pulso-suave {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
details summary { list-style: revert; }

/* ---------- Configuración (⚙️): sonido, volumen, notificaciones y tamaño de letra ---------- */
.boton-config {
  width: 42px; height: 42px; border-radius: 12px; border: none; cursor: pointer;
  background: rgba(20, 20, 30, 0.7); color: #fff; font-size: 1.25em; line-height: 1;
  display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
.boton-config:active { transform: scale(0.94); }
.panel-config { gap: 12px !important; overflow-y: auto; padding: 18px 18px 16px !important; }
.config-cabeza { display: flex; align-items: center; justify-content: space-between; }
.config-cabeza h2 { margin: 0; font-size: 1.6em; color: var(--outline-mapa); -webkit-text-stroke: 0; }
.config-cerrar { width: 36px; height: 36px; border-radius: 50%; border: none; background: #eef0f6; font-size: 1.4em; cursor: pointer; color: #333; }
.config-fila { display: flex; flex-direction: column; gap: 8px; }
.config-fila h3 { margin: 0; font-size: 0.8em; letter-spacing: 0.08em; text-transform: uppercase; color: #6b6f86; }
.config-grupo { display: flex; gap: 8px; flex-wrap: wrap; }
.config-opcion {
  flex: 1 1 0; min-width: 0; border: 2px solid #e1e3ee; background: #fff; border-radius: 14px;
  padding: 10px 8px; font: inherit; font-weight: 800; color: #333; cursor: pointer;
}
.config-opcion[aria-pressed="true"] { border-color: var(--indigo); background: #efeeff; color: var(--sec-morado); }
.config-volumen { display: flex; align-items: center; gap: 8px; font-size: 1.1em; }
.config-volumen input { flex: 1; accent-color: var(--indigo); }
.config-volumen input:disabled { opacity: 0.4; }
.config-volumen output { min-width: 3.2em; text-align: right; font-weight: 800; font-size: 0.85em; color: #444; }
.config-paquetes { display: flex; flex-direction: column; gap: 8px; }
.config-paquete { display: flex; gap: 8px; align-items: stretch; }
.config-paquete-elegir { text-align: left; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.config-paquete-elegir small { font-weight: 600; color: #6b6f86; font-size: 0.78em; }
.config-probar { border: none; border-radius: 14px; background: #eef0f6; padding: 0 12px; font: inherit; font-weight: 800; font-size: 0.8em; cursor: pointer; color: #333; white-space: nowrap; }
.config-muestra { margin: 0; color: #444; background: #f6f7fb; border-radius: 10px; padding: 8px 10px; }

/* ---------- Clima y hora del día en el mapa de cada región ---------- */
.clima {
  position: absolute; left: 0; right: 0; pointer-events: none; z-index: 2; overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 24%, #000 76%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 24%, #000 76%, transparent 100%);
}
.clima-icono { position: absolute; top: 40%; font-size: 2.1em; opacity: .85; filter: drop-shadow(0 2px 3px rgba(0,0,0,.35)); }
.clima-soleado { background: radial-gradient(circle at 50% 45%, rgba(255,231,128,.42), rgba(255,231,128,0) 62%); }
.clima-soleado .clima-icono { animation: sol-girar 14s linear infinite; }
.clima-atardecer { background: linear-gradient(180deg, rgba(255,138,64,.42), rgba(236,84,120,.26) 60%, rgba(120,70,160,.2)); }
.clima-noche {
  background:
    radial-gradient(1.6px 1.6px at 12% 30%, #fff 50%, transparent 52%),
    radial-gradient(1.4px 1.4px at 36% 18%, #fff 50%, transparent 52%),
    radial-gradient(1.8px 1.8px at 64% 34%, #fff 50%, transparent 52%),
    radial-gradient(1.3px 1.3px at 82% 22%, #fff 50%, transparent 52%),
    radial-gradient(1.5px 1.5px at 50% 70%, #fff 50%, transparent 52%),
    radial-gradient(1.4px 1.4px at 22% 64%, #fff 50%, transparent 52%),
    rgba(14, 22, 64, .55);
  animation: estrellas-titilar 3.2s ease-in-out infinite; animation-delay: var(--retraso, 0s);
}
.clima-lluvia { background: rgba(46, 66, 98, .3); }
.clima-lluvia::after {
  content: ""; position: absolute; inset: -40px 0 0 0;
  background-image: repeating-linear-gradient(104deg, transparent 0 11px, rgba(214, 232, 255, .6) 11px 12.5px, transparent 12.5px 23px);
  background-size: 100% 46px;
  animation: lluvia-caer .45s linear infinite; animation-delay: var(--retraso, 0s);
}
.clima-nublado { background: rgba(132, 144, 166, .28); }
.clima-niebla { background: linear-gradient(180deg, rgba(245,248,250,0) 0%, rgba(240,244,248,.5) 50%, rgba(245,248,250,0) 100%); }
.clima-nube, .clima-banco { position: absolute; left: -40%; width: 46%; height: 26%; border-radius: 999px; animation: nube-pasar 26s linear infinite; }
.clima-nube { background: radial-gradient(ellipse at 50% 60%, rgba(255,255,255,.9), rgba(235,240,246,.75) 55%, rgba(235,240,246,0) 72%); filter: blur(1px); }
.clima-banco { width: 80%; height: 30%; background: radial-gradient(ellipse, rgba(255,255,255,.8), rgba(255,255,255,0) 70%); filter: blur(4px); animation-duration: 34s; }

/* Efectos sobre el propio pueblo */
.pueblo-lluvia, .pueblo-noche, .pueblo-atardecer { position: absolute; inset: 0; pointer-events: none; border-radius: 14px; }
.pueblo-lluvia {
  background-image: repeating-linear-gradient(104deg, transparent 0 8px, rgba(225,238,255,.75) 8px 9.5px, transparent 9.5px 17px);
  background-size: 100% 36px; animation: lluvia-caer .4s linear infinite;
  -webkit-mask-image: radial-gradient(circle, #000 55%, transparent 72%); mask-image: radial-gradient(circle, #000 55%, transparent 72%);
}
.pueblo-noche {
  background:
    radial-gradient(3px 3px at 34% 52%, #ffd86b 60%, transparent 70%),
    radial-gradient(3px 3px at 52% 46%, #ffe38f 60%, transparent 70%),
    radial-gradient(3px 3px at 66% 58%, #ffd86b 60%, transparent 70%),
    radial-gradient(2.5px 2.5px at 44% 64%, #ffe38f 60%, transparent 70%),
    radial-gradient(circle at 50% 55%, rgba(255,214,120,.28), transparent 60%);
  animation: ventanas 2.6s ease-in-out infinite;
}
.pueblo-atardecer { background: radial-gradient(circle at 50% 70%, rgba(255,150,70,.32), transparent 65%); }
.etiqueta-lugar { max-width: 168px; white-space: normal; text-align: center; line-height: 1.15; font-size: .8em; }

@keyframes lluvia-caer { from { background-position: 0 0; } to { background-position: -10px 46px; } }
@keyframes nube-pasar { from { transform: translateX(0); } to { transform: translateX(330%); } }
@keyframes estrellas-titilar { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.35); } }
@keyframes sol-girar { to { transform: rotate(360deg); } }
@keyframes ventanas { 0%, 100% { opacity: .85; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .clima-lluvia::after, .pueblo-lluvia, .clima-nube, .clima-banco, .clima-noche, .clima-soleado .clima-icono, .pueblo-noche { animation: none; }
}

/* ---------- Minitrailer: la píldora «¡Súbete a la ruta del Saber PRO!» es el botón de entrada ---------- */
.boton-ruta {
  position: absolute; z-index: 6; border: none; padding: 0; cursor: pointer; background: transparent;
  border-radius: 999px; animation: ruta-pulso 1.3s ease-in-out infinite;
}
.boton-ruta:hover, .boton-ruta:focus-visible { outline: none; box-shadow: 0 0 0 4px #fff, 0 0 26px 8px rgba(255, 216, 74, .9); }
@keyframes ruta-pulso {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, .0), 0 0 14px 2px rgba(255, 216, 74, .55); transform: scale(1); }
  50% { box-shadow: 0 0 0 5px rgba(255, 255, 255, .55), 0 0 30px 10px rgba(255, 216, 74, .85); transform: scale(1.03); }
}
@media (prefers-reduced-motion: reduce) { .boton-ruta { animation: none; box-shadow: 0 0 0 4px #fff; } }

/* ---------- Mini-tutoriales de la Nutria (js/tutorial.js) ---------- */
#lienzo.congelado .pantalla.activa, #lienzo.congelado .pantalla.activa * { animation-play-state: paused !important; }
.tuto-capa { position: absolute; inset: 0; z-index: 300; pointer-events: none; transition: opacity .2s; }
.tuto-capa.tuto-saliendo { opacity: 0; }
.tuto-bloqueo { position: absolute; pointer-events: auto; background: transparent; }
.tuto-foco {
  position: absolute; border-radius: 16px; pointer-events: none;
  box-shadow: 0 0 0 4px #ffd84a, 0 0 0 9999px rgba(12, 10, 32, .64);
  transition: left .35s ease, top .35s ease, width .35s ease, height .35s ease;
  animation: tuto-latido 1.4s ease-in-out infinite;
}
.tuto-modo-clic .tuto-foco { box-shadow: 0 0 0 4px #5ec472, 0 0 22px 6px rgba(94, 196, 114, .8), 0 0 0 9999px rgba(12, 10, 32, .6); }
@keyframes tuto-latido { 50% { box-shadow: 0 0 0 7px #ffd84a, 0 0 0 9999px rgba(12, 10, 32, .64); } }
.tuto-guia { position: absolute; left: 10px; right: 10px; display: flex; align-items: flex-end; gap: 6px; pointer-events: none; }
.tuto-guia.tuto-abajo { bottom: 10px; }
.tuto-guia.tuto-arriba { top: 10px; align-items: flex-start; }
.tuto-guia.tuto-espejo { flex-direction: row-reverse; }
.tuto-guia.tuto-espejo .tuto-nutria { transform: scaleX(-1); }
.tuto-nutria { width: 104px; height: 150px; flex: none; filter: drop-shadow(0 6px 8px rgba(0,0,0,.35)); }
.tuto-globo {
  flex: 1; pointer-events: auto; background: #fffdf6; color: #2a1710; border-radius: 18px; padding: 12px 14px 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,.35); border: 3px solid #3b8c7e; font-size: .95em; line-height: 1.35;
}
.tuto-texto { min-height: 3.9em; font-weight: 600; cursor: pointer; }
.tuto-botones { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.tuto-paso { flex: 1; text-align: center; font-size: .75em; color: #7a6a55; font-weight: 700; }
.tuto-saltar, .tuto-ok { font: inherit; font-weight: 800; border: none; border-radius: 999px; cursor: pointer; }
.tuto-saltar { background: transparent; color: #7a6a55; font-size: .78em; padding: 6px 4px; text-decoration: underline; }
.tuto-ok { background: #3b8c7e; color: #fff; padding: 8px 16px; font-size: .9em; box-shadow: 0 3px 0 #2a6a5e; }
.tuto-ok:disabled { opacity: .45; cursor: default; }
.tuto-ok[hidden] { display: none; }
.tuto-cambio .tuto-globo { transform: scale(.96); }
.tuto-globo { transition: transform .2s; }
@media (prefers-reduced-motion: reduce) { .tuto-foco { animation: none; transition: none; } }

/* ---------- Modo demo (demo.autopista.circoap.org) ---------- */
.demo-cinta {
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); z-index: 95;
  background: var(--coral); color: #fff; border-radius: 10px 10px 0 0;
  font-weight: 900; font-size: 8.5px; letter-spacing: 2px; line-height: 1; padding: 3px 12px 2px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); pointer-events: none;
}
.demo-fin-tarjeta { max-width: 400px; max-height: 88vh; overflow: auto; display: flex; flex-direction: column; gap: 10px; line-height: 1.4; }
.demo-fin-titulo { margin: 0; font-size: 1.3em; }
.demo-fin-tarjeta ul { margin: 0; padding-left: 4px; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 0.92em; }
.demo-fin-tarjeta p { margin: 0; font-size: 0.92em; }
.demo-fin-completa { background: rgba(121, 109, 255, 0.12); border-radius: 12px; padding: 10px; }
.demo-fin-botones { display: flex; flex-direction: column; gap: 8px; }
.demo-fin-botones a.btn { text-decoration: none; text-align: center; }
