:root {
  --bg: #1a0f1c;
  --pink: #ffffff;
  --pink-deep: #cfcfd4;
  --pink-glow: #f0f0f4;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background-color: var(--bg);
  overscroll-behavior-y: none;
}

body {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  overscroll-behavior-y: none;
  padding: 6px;
  padding-top: max(6px, env(safe-area-inset-top));
  padding-bottom: max(6px, env(safe-area-inset-bottom));
  padding-left: max(6px, env(safe-area-inset-left));
  padding-right: max(6px, env(safe-area-inset-right));
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(8, 4, 10, 0.6), rgba(8, 4, 10, 0.6)),
    url("assets/fondo.webp");
  background-size: cover, cover;
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

@media (min-width: 900px) {
  body {
    background-attachment: fixed, fixed;
  }
}

/* ---------- Intro: nubes que se juntan y se van, dentro del recuadro ---------- */
#intro-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  overflow: hidden;
  pointer-events: auto;
  border-radius: inherit;
}

.puff {
  position: absolute;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.85) 0%, rgba(238, 241, 245, 0.55) 55%, rgba(217, 223, 230, 0) 100%);
  filter: blur(7px);
  mix-blend-mode: screen;
  will-change: transform, opacity;
}

/* ---------- Contenedor general: cabecera + fila isla/muñeco, todo a la misma anchura ---------- */
.page-shell {
  width: min(96vw, 1800px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 1.6vw, 20px);
}

/* ---------- Recuadro con el logo, arriba del todo (copiado tal cual de lareferenciabby.es) ---------- */
.hero-banner {
  position: relative;
  overflow: hidden;
  width: 100%;
  display: flex;
  background: linear-gradient(160deg, rgba(160, 160, 165, 0.55), rgba(70, 70, 78, 0.55));
  border: none;
  border-radius: 30px;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.9),
    inset 0 0 0 5px rgba(255, 255, 255, 0.95),
    inset 0 0 0 8px rgba(255, 255, 255, 0.35),
    inset 0 0 0 11px rgba(205, 205, 205, 0.9),
    0 0 3px rgba(255, 255, 255, 0.7),
    0 0 22px rgba(255, 255, 255, 0.6),
    0 0 55px rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: box-shadow 0.2s ease;
}
.hero-banner::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.9) 0.6px, transparent 0.8px);
  background-size: 7px 7px;
  opacity: 0.16;
  mix-blend-mode: screen;
  -webkit-mask-image: radial-gradient(closest-side, transparent 68%, black 100%);
  mask-image: radial-gradient(closest-side, transparent 68%, black 100%);
  pointer-events: none;
}
.hero-banner::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle 2.5px at 9% 14%, #fff, transparent 65%),
    radial-gradient(circle 1.6px at 38% 5%, #fff, transparent 65%),
    radial-gradient(circle 2.2px at 93% 11%, #fff, transparent 65%),
    radial-gradient(circle 2px at 97% 58%, #fff, transparent 65%),
    radial-gradient(circle 2.4px at 7% 90%, #fff, transparent 65%),
    radial-gradient(circle 1.8px at 52% 96%, #fff, transparent 65%),
    radial-gradient(circle 2.3px at 91% 92%, #fff, transparent 65%),
    radial-gradient(circle 1.6px at 2% 45%, #fff, transparent 65%);
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.95));
  opacity: 0.9;
}
.hero-banner:hover {
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 1),
    inset 0 0 0 5px rgba(255, 255, 255, 1),
    inset 0 0 0 8px rgba(255, 255, 255, 0.4),
    inset 0 0 0 11px rgba(215, 215, 215, 0.95),
    0 0 4px rgba(255, 255, 255, 0.8),
    0 0 28px rgba(255, 255, 255, 0.75),
    0 0 65px rgba(255, 255, 255, 0.38);
}

.hero-banner img {
  display: block;
  width: 100%;
  height: clamp(160px, 20vw, 280px);
  object-fit: cover;
  object-position: center;
}

/* ---------- Tarjeta "únete a nuestro equipo", entre el logo y el mapa ---------- */
.join-card {
  display: none; /* la muestra JS a la vez que el recuadro del mapa/muñeco */
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  width: 100%;
  padding: clamp(14px, 2.4vw, 20px);
  border-radius: 14px;
  background: rgba(12, 4, 12, 0.78);
  outline: 2px solid rgba(255, 255, 255, 0.9);
  outline-offset: -2px;
  box-shadow:
    inset 0 0 10px rgba(255, 255, 255, 0.16),
    0 0 3px rgba(255, 255, 255, 0.55),
    0 0 10px rgba(255, 255, 255, 0.55),
    0 0 22px rgba(255, 255, 255, 0.3);
  transition: outline-color 0.4s ease, box-shadow 0.4s ease;
}

/* Correo enviado: las líneas del recuadro pasan a verde. */
.join-card.is-success {
  outline-color: rgba(80, 230, 140, 0.9);
  box-shadow:
    inset 0 0 10px rgba(80, 230, 140, 0.18),
    0 0 3px rgba(80, 230, 140, 0.55),
    0 0 10px rgba(80, 230, 140, 0.55),
    0 0 22px rgba(80, 230, 140, 0.3);
}

.join-title {
  margin: 0;
  font-family: 'Anton', sans-serif;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-size: clamp(0.95rem, 2.2vw, 1.2rem);
  color: #ffffff;
}

.join-form[hidden] {
  display: none;
}

.join-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  max-width: 380px;
  justify-content: center;
}

.join-input {
  flex: 1 1 180px;
  min-width: 0;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  background: rgba(8, 4, 10, 0.6);
  color: #fff;
}

.join-input::placeholder {
  color: rgba(255, 255, 255, 0.45);
}

.join-input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.9);
}

.join-submit {
  flex: 0 0 auto;
  font-family: 'Anton', sans-serif;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-size: 0.85rem;
  padding: 10px 20px;
  border-radius: 10px;
  border: none;
  background: #fff;
  color: #000;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.join-submit:hover {
  transform: scale(1.05);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.6);
}

.join-submit:active {
  transform: scale(0.96);
}

.join-success[hidden] {
  display: none;
}

.join-success {
  display: flex;
  justify-content: center;
  width: 100%;
}

.join-whatsapp {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'Anton', sans-serif;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-size: 0.85rem;
  padding: 10px 20px;
  border-radius: 10px;
  border: 1.5px solid rgba(80, 230, 140, 0.8);
  background: rgba(80, 230, 140, 0.12);
  color: #6dff9e;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.join-whatsapp:hover {
  transform: scale(1.05);
  box-shadow: 0 0 12px rgba(80, 230, 140, 0.5);
}

.join-whatsapp:active {
  transform: scale(0.96);
}

/* ---------- Nav inferior: Mapa / Guía ---------- */
.bottom-nav {
  display: flex;
  gap: clamp(10px, 1.6vw, 18px);
  width: 100%;
}

.nav-tab {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: rgba(12, 4, 12, 0.78);
  border-radius: 14px;
  padding: clamp(8px, 1.1vw, 12px);
  color: rgba(230, 230, 230, 0.65);
  outline: 2px solid rgba(255, 255, 255, 0.45);
  outline-offset: -2px;
  cursor: pointer;
  font-family: 'Anton', sans-serif;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-size: clamp(0.7rem, 1vw, 0.85rem);
  transition: background 0.2s ease, color 0.2s ease, outline-color 0.2s ease;
}

.nav-tab svg {
  width: clamp(20px, 2.4vw, 26px);
  height: clamp(20px, 2.4vw, 26px);
}

.nav-tab.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.3);
  outline-color: rgba(255, 255, 255, 0.95);
  box-shadow:
    inset 0 0 10px rgba(255, 255, 255, 0.25),
    0 0 10px rgba(255, 255, 255, 0.55),
    0 0 22px rgba(255, 255, 255, 0.3);
}

/* ---------- Fila con la isla (única tarjeta, centrada) ---------- */
.stage-layout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

/* ---------- Recuadro / tarjeta de isla (estilo lareferenciabby, tonos rosas) ---------- */
.island-card {
  position: relative;
  width: min(84vh, 780px);
  max-width: 100%;
  background-image: linear-gradient(160deg, rgba(255, 255, 255, 0.28), rgba(205, 205, 205, 0.22));
  border-radius: 30px;
  padding: clamp(8px, 1.2vw, 14px);
  overflow: hidden;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.9),
    inset 0 0 0 5px rgba(255, 255, 255, 0.95),
    inset 0 0 0 8px rgba(255, 255, 255, 0.35),
    inset 0 0 0 11px rgba(205, 205, 205, 0.9),
    0 0 3px rgba(255, 255, 255, 0.7),
    0 0 22px rgba(255, 255, 255, 0.6),
    0 0 55px rgba(255, 255, 255, 0.3);
  opacity: 0;
  transform: translateY(10px);
  animation: reveal 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.1s forwards;
}

/* Parpadeo tipo tira de LEDs blancos: mayormente encendido, con apagones breves e irregulares.
   Lo usa .reconstruction-crafting ("CRAFTING MAP…"). */
@keyframes led-flicker {
  0%, 68%, 72%, 78%, 100% {
    color: #fff;
    text-shadow:
      0 0 6px #fff,
      0 0 14px #fff,
      0 0 24px rgba(255, 255, 255, 0.9);
  }
  70%, 76% {
    color: rgba(255, 255, 255, 0.25);
    text-shadow: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .map-brand {
    animation: none;
  }
}

/* ---------- Botón para abrir/cerrar la mascota, abajo a la izquierda del mapa ---------- */
.muneco-toggle {
  position: absolute;
  left: clamp(28px, 4.4vw, 46px);
  bottom: clamp(28px, 4.4vw, 46px);
  z-index: 15;
  width: clamp(42px, 5vw, 54px);
  height: clamp(42px, 5vw, 54px);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(24, 8, 22, 0.85);
  color: #ffffff;
  outline: 2px solid rgba(255, 255, 255, 0.95);
  outline-offset: -2px;
  box-shadow:
    0 0 3px rgba(255, 255, 255, 0.6),
    0 0 12px rgba(255, 255, 255, 0.7),
    0 0 26px rgba(255, 255, 255, 0.4);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.muneco-toggle {
  overflow: hidden;
}

.muneco-toggle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center bottom;
}

.muneco-toggle:hover {
  transform: scale(1.08);
}

.muneco-toggle:active {
  transform: scale(0.94);
}

.muneco-toggle.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

/* ---------- Overlay: aparece encima del mapa al pulsar el botón ---------- */
.muneco-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(10px, 3vw, 30px);
  background: rgba(10, 4, 12, 0.62);
  border-radius: inherit;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.muneco-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* ---------- Tarjeta del muñeco animado (mismo estilo que la isla), dentro del overlay ---------- */
.muneco-card {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  width: min(100%, 640px);
  height: min(100%, 460px);
  gap: clamp(10px, 1.6vw, 20px);
  background-image: linear-gradient(160deg, rgba(255, 255, 255, 0.28), rgba(205, 205, 205, 0.22));
  border-radius: 26px;
  padding: clamp(8px, 1.2vw, 14px);
  overflow: hidden;
  transform: scale(0.94);
  transition: transform 0.25s ease;
}

.muneco-overlay.open .muneco-card {
  transform: scale(1);
}

/* Marco rosa como capa independiente por encima del muñeco, para que quede
   delante de él en vez de detrás. */
.muneco-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 4;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.9),
    inset 0 0 0 5px rgba(255, 255, 255, 0.95),
    inset 0 0 0 8px rgba(255, 255, 255, 0.35),
    inset 0 0 0 11px rgba(205, 205, 205, 0.9),
    0 0 3px rgba(255, 255, 255, 0.7),
    0 0 22px rgba(255, 255, 255, 0.6),
    0 0 55px rgba(255, 255, 255, 0.3);
}

.muneco-close {
  position: absolute;
  top: clamp(10px, 1.4vw, 16px);
  right: clamp(10px, 1.4vw, 16px);
  z-index: 6;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(24, 8, 22, 0.85);
  color: #ffffff;
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: -2px;
  font-size: 0.9rem;
  line-height: 1;
}

/* El muñeco a la izquierda, el bocadillo a su derecha: mismo tamaño, uno al lado del otro. */
#muneco-stage {
  order: 1;
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
}

/* Bocadillo con la historia de la web, al lado del muñeco (estilo neón como el resto de la UI) */
.bocadillo {
  order: 2;
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  background: rgba(24, 8, 22, 0.8);
  color: #ffffff;
  border-radius: 16px;
  padding: clamp(18px, 2.6vw, 32px);
  box-shadow:
    inset 0 0 14px rgba(255, 255, 255, 0.18),
    0 0 3px rgba(255, 255, 255, 0.6),
    0 0 10px rgba(255, 255, 255, 0.65),
    0 0 24px rgba(255, 255, 255, 0.35);
  outline: 2px solid rgba(255, 255, 255, 0.95);
  outline-offset: -2px;
}

.bocadillo::after {
  content: "";
  position: absolute;
  left: -11px;
  top: 30%;
  width: 18px;
  height: 18px;
  background: rgba(24, 8, 22, 0.8);
  border-left: 2px solid rgba(255, 255, 255, 0.95);
  border-bottom: 2px solid rgba(255, 255, 255, 0.95);
  transform: translateY(-50%) rotate(45deg);
  box-shadow: -3px 3px 8px rgba(255, 255, 255, 0.35);
}

.bocadillo-text {
  margin: 0;
  width: 100%;
  font-size: clamp(1.05rem, 2.2vw, 1.4rem);
  line-height: 1.5;
  text-align: left;
}

.bocadillo-dots {
  position: absolute;
  right: 14px;
  bottom: 8px;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 700;
  letter-spacing: 2px;
  font-size: 1rem;
  animation: dots-pulse 1.3s ease-in-out infinite;
}

.bocadillo-dots.hidden {
  display: none;
}

@keyframes dots-pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

#muneco-stage {
  position: relative;
  width: auto;
  border-radius: 18px;
  overflow: hidden;
}

#muneco-stage canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

@media (max-width: 620px) {
  .muneco-card {
    flex-direction: column;
    height: min(100%, 520px);
  }

  /* Como en la referencia: el bocadillo arriba, el muñeco debajo */
  .bocadillo {
    order: 1;
    flex: 0 0 38%;
    min-width: 0;
    width: 100%;
    height: auto;
  }

  #muneco-stage {
    order: 2;
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    height: auto;
  }

  .bocadillo::after {
    left: 40%;
    top: auto;
    bottom: -11px;
    border-left: none;
    border-top: none;
    border-right: 2px solid rgba(255, 255, 255, 0.95);
    border-bottom: 2px solid rgba(255, 255, 255, 0.95);
    transform: translateX(-50%) rotate(45deg);
    box-shadow: 3px 3px 8px rgba(255, 255, 255, 0.35);
  }
}

.island-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.9) 0.6px, rgba(0, 0, 0, 0) 0.8px);
  background-size: 7px 7px;
  background-repeat: repeat;
  mix-blend-mode: screen;
  opacity: 0.16;
  pointer-events: none;
}

/* Escenario del mapa dentro de la tarjeta: siempre cuadrado */
#map-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  overflow: hidden;
  background-image: url("assets/reference-island-bg.webp");
  background-size: 120%;
  background-position: center calc(50% - 1px);
  background-repeat: no-repeat;
}

#map {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: center;
  animation: levitate 3.5s ease-in-out 0.8s infinite;
  filter: brightness(1);
  transition: filter 0.25s ease;
}

#map-stage:hover #map {
  filter: brightness(1.15);
}

/* Línea discontinua y curva que conecta las islas en orden: flota a la vez que el mapa */
#path-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  animation: levitate-path 3.5s ease-in-out 0.8s infinite;
}

.route-path {
  fill: none;
  stroke: rgba(255, 255, 255, 0.85);
  stroke-width: 0.6;
  stroke-linecap: round;
  filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.9));
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: draw-path 2.6s 0.5s cubic-bezier(0.65, 0, 0.35, 1) forwards;
}

/* Una vez trazada, queda fija con el patrón discontinuo, sin más movimiento */
.route-path.drawn {
  animation: none;
  stroke-dasharray: 2.4 1.8;
  stroke-dashoffset: 0;
}

@keyframes draw-path {
  to {
    stroke-dashoffset: 0;
  }
}

/* Capa donde vivirán las islas interactivas, alineada 1:1 con el mapa */
#islands-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#islands-layer > * {
  pointer-events: auto;
}

/* Islas interactivas repartidas sobre el mapa: levitan a la vez que el mapa */
.island {
  position: absolute;
  width: var(--island-size, 16%);
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  animation: levitate-island 3.5s ease-in-out 0.8s infinite;
}

.island-btn {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.25s ease, filter 0.25s ease;
}

.island-btn:focus {
  outline: none;
}

.island-btn:hover {
  transform: scale(1.14);
  filter: drop-shadow(0 8px 20px rgba(255, 255, 255, 0.65)) brightness(1.1);
}

.island-btn:active {
  transform: scale(0.95);
}

.island-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 4px;
  border-radius: 50%;
}

.island-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.35));
}

@keyframes reveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Efecto de levitación suave de la imagen, arranca cuando termina la entrada del recuadro */
@keyframes levitate {
  0%, 100% {
    transform: scale(1.18) translateY(0) rotate(0deg);
  }
  50% {
    transform: scale(1.18) translateY(-11px) rotate(0.5deg);
  }
}

@keyframes levitate-island {
  0%, 100% {
    transform: translate(-50%, -50%) translateY(0) rotate(0deg);
  }
  50% {
    transform: translate(-50%, -50%) translateY(-11px) rotate(0.5deg);
  }
}

@keyframes levitate-path {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-11px) rotate(0.5deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .island-card {
    animation: none;
    opacity: 1;
    transform: none;
  }

  #map {
    animation: none;
    transform: scale(1.18);
  }

  .island {
    animation: none;
    transform: translate(-50%, -50%);
  }

  #path-layer {
    animation: none;
    transform: none;
  }
}

/* ============================================================================
   FASE NARRATIVA: procesado de resultados + reconstrucción del mapa.
   Reutiliza el mismo marco neón, tipografías y paleta que el resto de la web.
   ============================================================================ */

#phase-narrative {
  display: none;
}

/* Panel principal: mismo marco neón rosa que .island-card */
.narrative-panel {
  position: relative;
  width: min(84vh, 780px);
  max-width: 100%;
  background-image: linear-gradient(160deg, rgba(255, 255, 255, 0.28), rgba(205, 205, 205, 0.22));
  border-radius: 30px;
  padding: clamp(18px, 3vw, 32px);
  overflow: hidden;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.9),
    inset 0 0 0 5px rgba(255, 255, 255, 0.95),
    inset 0 0 0 8px rgba(255, 255, 255, 0.35),
    inset 0 0 0 11px rgba(205, 205, 205, 0.9),
    0 0 3px rgba(255, 255, 255, 0.7),
    0 0 22px rgba(255, 255, 255, 0.6),
    0 0 55px rgba(255, 255, 255, 0.3);
  opacity: 0;
  transform: translateY(10px);
  animation: reveal 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.1s forwards;
  display: flex;
  flex-direction: column;
  gap: clamp(16px, 2.6vw, 26px);
}

.narrative-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.9) 0.6px, rgba(0, 0, 0, 0) 0.8px);
  background-size: 7px 7px;
  background-repeat: repeat;
  mix-blend-mode: screen;
  opacity: 0.16;
  pointer-events: none;
}

.narrative-panel.is-processing {
  animation: reveal 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.1s forwards, panel-pulse 2.4s ease-in-out 0.8s infinite;
}

@keyframes panel-pulse {
  0%, 100% {
    box-shadow:
      inset 0 0 0 2px rgba(255, 255, 255, 0.9),
      inset 0 0 0 5px rgba(255, 255, 255, 0.95),
      inset 0 0 0 8px rgba(255, 255, 255, 0.35),
      inset 0 0 0 11px rgba(205, 205, 205, 0.9),
      0 0 3px rgba(255, 255, 255, 0.7),
      0 0 22px rgba(255, 255, 255, 0.6),
      0 0 55px rgba(255, 255, 255, 0.3);
  }
  50% {
    box-shadow:
      inset 0 0 0 2px rgba(255, 255, 255, 1),
      inset 0 0 0 5px rgba(255, 255, 255, 1),
      inset 0 0 0 8px rgba(255, 255, 255, 0.42),
      inset 0 0 0 11px rgba(215, 215, 215, 0.95),
      0 0 4px rgba(255, 255, 255, 0.85),
      0 0 30px rgba(255, 255, 255, 0.8),
      0 0 68px rgba(255, 255, 255, 0.4);
  }
}

/* ---- Resultado de la votación ---- */
.result-section {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 1vw, 10px);
  text-align: center;
  width: 100%;
  padding: clamp(6px, 1vw, 10px) 16px;
}

.result-status {
  margin: 0;
  font-family: 'Anton', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: clamp(0.85rem, 2.2vw, 1.15rem);
  color: #ffffff;
}

.result-progress-track {
  width: min(100%, 460px);
  height: clamp(7px, 1vw, 10px);
  border-radius: 999px;
  background: rgba(24, 8, 22, 0.85);
  outline: 2px solid rgba(255, 255, 255, 0.7);
  outline-offset: -2px;
  overflow: hidden;
}

.result-progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--pink-deep), var(--pink), var(--pink-glow));
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.75);
  transition: width 0.35s ease-out;
}

.result-progress-pct {
  margin: 0;
  font-family: 'Anton', sans-serif;
  letter-spacing: 0.03em;
  font-size: clamp(1.1rem, 3.2vw, 1.6rem);
  color: #fff;
  text-shadow: 0 0 6px #fff, 0 0 16px rgba(255, 255, 255, 0.9);
}

.result-winner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transform: scale(0.92);
  pointer-events: none;
}

.result-winner.is-revealed {
  animation: winner-glitch-in 0.6s ease forwards;
}

.result-winner-label {
  margin: 0;
  font-family: 'Anton', sans-serif;
  letter-spacing: 0.12em;
  font-size: clamp(1rem, 2.6vw, 1.3rem);
  color: rgba(230, 230, 230, 0.85);
}

.result-winner-name {
  margin: 0;
  font-family: 'Anton', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: clamp(1.6rem, 5.4vw, 2.6rem);
  color: #fff;
  text-shadow: 0 0 8px #fff, 0 0 20px rgba(255, 255, 255, 0.9), 0 0 40px rgba(255, 255, 255, 0.5);
}

@keyframes winner-glitch-in {
  0% { opacity: 0; transform: scale(0.9) translate(0, 4px); filter: none; }
  20% { opacity: 1; transform: translate(-3px, 0) scale(1.02); filter: hue-rotate(20deg); }
  35% { transform: translate(3px, 0) scale(0.99); filter: hue-rotate(-15deg); }
  50% { transform: translate(-2px, 0) scale(1.01); filter: none; }
  100% { opacity: 1; transform: translate(0, 0) scale(1); filter: none; }
}

/* ---- Efecto CRT + grano, muy sutiles, por encima de todo el panel ---- */
.crt-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
}

.crt-overlay.crt-active {
  opacity: 1;
  background-image:
    repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.05) 0px,
      rgba(255, 255, 255, 0.05) 1px,
      rgba(0, 0, 0, 0) 1px,
      rgba(0, 0, 0, 0) 3px
    ),
    radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 55%, rgba(5, 2, 6, 0.35) 100%);
}

.crt-overlay.grain-active::after {
  content: "";
  position: absolute;
  inset: -10%;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/></svg>");
  opacity: 0.05;
  mix-blend-mode: overlay;
  animation: grain-flicker 6s steps(1, end) infinite;
}

@keyframes grain-flicker {
  0%, 78%, 84%, 100% { opacity: 0.04; }
  80%, 82% { opacity: 0.11; }
}

/* ---- Reconstrucción del mapa ---- */
.reconstruction-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(6px, 1.2vw, 10px);
  text-align: center;
}

.reconstruction-map-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 4;
  border-radius: 16px;
  overflow: hidden;
}

.reconstruction-map-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.reconstruction-crafting {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Anton', sans-serif;
  letter-spacing: 0.03em;
  font-size: clamp(1.4rem, 4vw, 2.1rem);
  color: #fff;
  text-shadow: 0 0 6px #fff, 0 0 16px rgba(255, 255, 255, 0.9);
  pointer-events: none;
  white-space: nowrap;
  animation: led-flicker 2.6s infinite steps(1, end);
}

/* Monigote pequeño, esquina inferior izquierda del mapa: un compañero
   trabajando de fondo, nunca protagonista ni tapando el mapa. */
.corner-muneco {
  position: absolute;
  left: clamp(8px, 2vw, 14px);
  bottom: clamp(8px, 2vw, 14px);
  z-index: 6;
  width: clamp(56px, 15vw, 84px);
  height: clamp(56px, 15vw, 84px);
  aspect-ratio: 1 / 1;
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  border: none;
  padding: 0;
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  background: rgba(12, 4, 12, 0.6);
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: -2px;
  box-shadow:
    0 0 3px rgba(255, 255, 255, 0.5),
    0 0 10px rgba(255, 255, 255, 0.55),
    0 0 20px rgba(255, 255, 255, 0.3);
}

.corner-muneco:active {
  transform: scale(0.94);
}

/* Botón de sonido: misma esquina que el monigote pero arriba a la izquierda */
.sound-toggle {
  position: absolute;
  left: clamp(8px, 2vw, 14px);
  top: clamp(8px, 2vw, 14px);
  z-index: 6;
  width: clamp(34px, 8vw, 42px);
  height: clamp(34px, 8vw, 42px);
  aspect-ratio: 1 / 1;
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  border: none;
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 4, 12, 0.6);
  color: #fff;
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: -2px;
  box-shadow:
    0 0 3px rgba(255, 255, 255, 0.5),
    0 0 10px rgba(255, 255, 255, 0.55),
    0 0 20px rgba(255, 255, 255, 0.3);
}

.sound-toggle svg {
  width: 100%;
  height: 100%;
}

.sound-toggle:active {
  transform: scale(0.9);
}

/* Silenciado (por defecto): se ve la cruz, no las ondas */
.sound-toggle .sound-toggle-wave {
  opacity: 0;
}
.sound-toggle .sound-toggle-mute {
  opacity: 1;
}

/* Con sonido activado: ondas visibles, cruz oculta */
.sound-toggle.is-on .sound-toggle-wave {
  opacity: 1;
}
.sound-toggle.is-on .sound-toggle-mute {
  opacity: 0;
}

.corner-muneco-stage {
  display: block;
  width: 100%;
  height: 100%;
}

.corner-muneco-stage canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* Bocadillo efímero: aparece al lado derecho del monigote, no encima */
.corner-bocadillo {
  position: absolute;
  left: calc(clamp(8px, 2vw, 14px) + clamp(56px, 15vw, 84px) + clamp(10px, 2vw, 14px));
  right: clamp(8px, 2vw, 14px);
  bottom: clamp(8px, 2vw, 14px);
  z-index: 7;
  max-width: min(60%, 260px);
  background: rgba(24, 8, 22, 0.88);
  color: #ffffff;
  border-radius: 14px;
  padding: 10px 14px;
  outline: 2px solid rgba(255, 255, 255, 0.9);
  outline-offset: -2px;
  box-shadow:
    0 0 3px rgba(255, 255, 255, 0.55),
    0 0 10px rgba(255, 255, 255, 0.55),
    0 0 22px rgba(255, 255, 255, 0.3);
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.corner-bocadillo.is-visible {
  opacity: 1;
  transform: translateX(0);
}

.corner-bocadillo p {
  margin: 0;
  font-size: clamp(0.82rem, 1.9vw, 0.95rem);
  line-height: 1.4;
}

/* ---- Pestaña "Archivo" en la navegación inferior: solo un "?" grande ---- */
.nav-archive-mark {
  font-family: 'Anton', sans-serif;
  font-size: 1.6em;
  line-height: 1;
}

/* ---- Tarjeta del archivo (mismo lenguaje que el overlay del muñeco) ---- */
.archive-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 40px);
  background: rgba(10, 4, 12, 0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.archive-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.archive-card {
  position: relative;
  width: min(100%, 420px);
  background-image: linear-gradient(160deg, rgba(255, 255, 255, 0.28), rgba(205, 205, 205, 0.22));
  border-radius: 22px;
  padding: clamp(28px, 5vw, 40px) clamp(20px, 4vw, 30px);
  text-align: center;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.9),
    inset 0 0 0 5px rgba(255, 255, 255, 0.95),
    inset 0 0 0 8px rgba(255, 255, 255, 0.35),
    inset 0 0 0 11px rgba(205, 205, 205, 0.9),
    0 0 3px rgba(255, 255, 255, 0.7),
    0 0 22px rgba(255, 255, 255, 0.6),
    0 0 55px rgba(255, 255, 255, 0.3);
  transform: scale(0.94);
  transition: transform 0.25s ease;
}

.archive-overlay.open .archive-card {
  transform: scale(1);
}

.archive-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(24, 8, 22, 0.85);
  color: #ffffff;
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: -2px;
  font-size: 0.9rem;
  line-height: 1;
}

.archive-empty {
  margin: 0;
  white-space: pre-line;
  color: #ffffff;
  font-size: clamp(0.9rem, 2vw, 1rem);
  line-height: 1.6;
}

@media (prefers-reduced-motion: reduce) {
  .narrative-panel {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .narrative-panel.is-processing {
    animation: none;
  }

  .result-winner.is-revealed {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .reconstruction-crafting {
    animation: none;
  }

  .crt-overlay.grain-active::after {
    animation: none;
    opacity: 0.05;
  }
}
