/* El nivel: fondo parallax, mundo escalado, zonas, carteles, objetos y muñeco (unidades de diseño = px dentro de #mundo) */

/* ── Fondo ─────────────────────────────────────────────── */
.escena {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.cielo {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, var(--cielo-arriba, #A9DCF5), var(--cielo-abajo, #E8F6FD));
}

.capa {
  position: absolute;
  left: 0;
  bottom: 0;
  height: calc(var(--escala) * 900px);
  width: calc(100vw + var(--escala) * 900px * var(--proporcion));
  background-repeat: repeat-x;
  background-position: left bottom;
  background-size: auto 100%;
  will-change: transform;
}

.capa-montana { background-image: url("../img/fondo/montana.svg"); }
.capa-colinas { background-image: url("../img/fondo/colinas.svg"); }
.capa-aldea { background-image: url("../img/fondo/aldea.svg"); }
.capa-arboles { background-image: url("../img/fondo/arboles.svg"); }
.capa-frente { background-image: url("../img/fondo/primer-plano.svg"); }

/* Las capas de la noche existen desde la carga (.noche-activa la pone fondo.js al crear el fondo, durante la
   intro); sin el juego (modo CV o sin JS) no se crean. */
.escena:not(.noche-activa) .capa-luces,
.escena:not(.noche-activa) .estrellas { visibility: hidden; }

/* Anochecer: cada capa se tiñe con su propia silueta como máscara (solo cambia la opacidad, --noche va de 0 a 1).
   Las URL van escritas en cada regla: dentro de una variable CSS obligan a volver a rasterizar en cada fotograma.
   will-change: opacity deja cada tinte en su propia capa: al cambiar la noche solo se recompone, sin repintar
   la máscara (repintarla en cada paso era el tirón al final del nivel). */
.noche-activa .capa-montana::after, .noche-activa .capa-colinas::after, .noche-activa .capa-aldea::after,
.noche-activa .capa-arboles::after, .noche-activa .capa-frente::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #161D45;
  -webkit-mask-position: left bottom;
  mask-position: left bottom;
  -webkit-mask-size: auto 100%;
  mask-size: auto 100%;
  -webkit-mask-repeat: repeat-x;
  mask-repeat: repeat-x;
  opacity: calc(var(--noche, 0) * var(--oscurece));
  will-change: opacity;
}

.capa-montana::after { -webkit-mask-image: url("../img/fondo/montana.svg"); mask-image: url("../img/fondo/montana.svg"); --oscurece: 0.62; }
.capa-colinas::after { -webkit-mask-image: url("../img/fondo/colinas.svg"); mask-image: url("../img/fondo/colinas.svg"); --oscurece: 0.6; }
.capa-aldea::after { -webkit-mask-image: url("../img/fondo/aldea.svg"); mask-image: url("../img/fondo/aldea.svg"); --oscurece: 0.55; }
.capa-arboles::after { -webkit-mask-image: url("../img/fondo/arboles.svg"); mask-image: url("../img/fondo/arboles.svg"); --oscurece: 0.58; }
.capa-frente::after { -webkit-mask-image: url("../img/fondo/primer-plano.svg"); mask-image: url("../img/fondo/primer-plano.svg"); --oscurece: 0.6; }

/* Ventanas y farolillos de la aldea: se encienden al anochecer */
.capa-luces {
  background-image: url("../img/fondo/aldea-luces.svg");
  opacity: var(--noche, 0);
  will-change: transform, opacity;
}

.estrellas {
  position: absolute;
  inset: 0 0 35% 0;
  background:
    radial-gradient(1.5px 1.5px at 12% 18%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 27% 8%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 41% 26%, #FFF4D6 50%, transparent 51%),
    radial-gradient(1px 1px at 55% 12%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 68% 30%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 79% 6%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 90% 20%, #FFF4D6 50%, transparent 51%),
    radial-gradient(1px 1px at 6% 40%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 34% 44%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 62% 48%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 85% 42%, #fff 50%, transparent 51%);
  background-size: 640px 100%;
  opacity: calc((var(--noche, 0) - 0.4) * 1.6);
  will-change: opacity;
}

/* Hojas: una capa detrás del mundo (dentro de .escena) y otra delante, en el primer plano */
.hojas {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hoja {
  position: absolute;
  left: -16px;
  top: -16px;
  width: 32px;
  height: 32px;
  will-change: transform;
}

.hojas-fondo .hoja { opacity: 0.85; }
.hoja-0 { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M16 2Q28 14 16 26Q4 14 16 2z' fill='%235E9E3F'/%3E%3Cpath d='M16 5V30' stroke='%23000' stroke-opacity='.22' stroke-width='1.4'/%3E%3C/svg%3E"); }
.hoja-1 { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M16 2Q28 14 16 26Q4 14 16 2z' fill='%2373B353'/%3E%3Cpath d='M16 5V30' stroke='%23000' stroke-opacity='.22' stroke-width='1.4'/%3E%3C/svg%3E"); }
.hoja-2 { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M16 2Q28 14 16 26Q4 14 16 2z' fill='%238CC06E'/%3E%3Cpath d='M16 5V30' stroke='%23000' stroke-opacity='.22' stroke-width='1.4'/%3E%3C/svg%3E"); }
.hoja-3 { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M16 2Q28 14 16 26Q4 14 16 2z' fill='%23B9C25A'/%3E%3Cpath d='M16 5V30' stroke='%23000' stroke-opacity='.22' stroke-width='1.4'/%3E%3C/svg%3E"); }
.hoja-4 { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M16 2Q28 14 16 26Q4 14 16 2z' fill='%23E2A23A'/%3E%3Cpath d='M16 5V30' stroke='%23000' stroke-opacity='.22' stroke-width='1.4'/%3E%3C/svg%3E"); }

/* Primer plano: matas desenfocadas delante del muñeco, más rápidas que el mundo */
.primer-plano {
  position: fixed;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}

/* ── Mundo ─────────────────────────────────────────────── */
.mundo {
  position: fixed;
  left: 0;
  top: var(--mundo-y);
  z-index: 1;
  width: 18500px;
  height: 900px;
  transform-origin: 0 0;
  transform: scale(var(--escala));
  will-change: transform;
}

.suelo {
  position: absolute;
  left: 0;
  top: 780px;
  width: 100%;
  height: 120px;
  background:
    linear-gradient(var(--naranja) 0 18px, var(--naranja-oscuro) 18px 24px, transparent 24px),
    repeating-linear-gradient(90deg, transparent 0 78px, #8E400D 78px 80px),
    repeating-linear-gradient(#B4520F 0 32px, #8E400D 32px 34px);
}

.suelo::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -12px;
  height: 12px;
  background: radial-gradient(circle at 50% 100%, var(--naranja) 0 10px, transparent 10.5px) 0 0 / 40px 12px repeat-x;
}

/* ── Posicionamiento por variables (--x, --y, --w, --h) ── */
.zona, .app {
  position: absolute;
  top: 0;
  left: calc(var(--x) * 1px);
  width: calc(var(--ancho) * 1px);
  height: 900px;
}

.zona > :not(.app), .app > *, .torres > li {
  position: absolute;
  left: calc(var(--x, 0) * 1px);
  top: calc(var(--y, 0) * 1px);
  width: calc(var(--w) * 1px);
}

/* ── Carteles: placas crema con studs y postes de madera ── */
.cartel {
  padding: 22px 26px 24px;
  border-radius: 16px;
  background: var(--crema);
  color: var(--texto);
  font-size: 19px;
  line-height: 1.55;
  box-shadow: 0 6px 0 var(--crema-sombra), 0 18px 30px rgb(29 40 64 / 0.16);
  user-select: text;
  -webkit-user-select: text;
}

.cartel::before {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  top: -11px;
  height: 12px;
  background: radial-gradient(circle at 50% 100%, var(--crema) 0 9px, transparent 9.5px) 0 0 / 34px 12px repeat-x;
}

/* Postes: sin z-index en .cartel para que queden detrás de la placa */
.cartel::after {
  content: "";
  position: absolute;
  z-index: -1;
  top: 40px;
  left: 42px;
  right: 42px;
  height: calc((780 - var(--y) - 40) * 1px);
  background: linear-gradient(90deg,
    var(--madera) 0 16px, transparent 16px calc(100% - 16px), var(--madera) calc(100% - 16px));
}

.cartel h2 { font-size: 30px; margin-bottom: 10px; }
.cartel h3 { font-size: 23px; margin-bottom: 6px; }
.cartel p + p, .cartel p + ul, .cartel ul + p { margin-top: 8px; }

.etiqueta {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--naranja-claro);
  color: #9A4307;
  font-size: 16px;
  font-weight: 600;
}

.nota { color: var(--texto-suave); font-size: 16px; }

.lista { padding-left: 1.1em; }
.lista li + li { margin-top: 6px; }
.lista li::marker { color: var(--naranja); }

/* ── Inicio: el nombre en letras saltables ── */
.titulo {
  font-size: 0;
  text-transform: uppercase;
}

.titulo-linea {
  display: block;
  white-space: nowrap;
  font-family: var(--fuente-titulos);
  font-weight: 600;
}

.titulo-linea-1 { font-size: 118px; color: var(--marino); }
.titulo-linea-2 { font-size: 86px; color: var(--naranja); margin-top: 18px; }

.letra {
  display: inline-block;
  line-height: 0.74;
  text-shadow: 0 6px 0 rgb(0 0 0 / 0.16);
}

.letra.pisada { animation: pisada 0.18s ease-out; }

@keyframes pisada { 50% { transform: translateY(6px); } }

.titular {
  font-family: var(--fuente-titulos);
  font-weight: 600;
  font-size: 34px;
  line-height: 1.2;
  color: var(--marino);
}

.subtitular { margin-top: 6px; font-size: 21px; color: var(--texto-suave); }

.pista { font-size: 17px; font-weight: 600; color: var(--marino); }
.pista-truco { margin-top: 8px; font-size: 15px; font-weight: 400; color: var(--texto-suave); }

/* ── Perfil ── */
.foto { text-align: center; }

.foto img {
  width: 320px;
  height: 320px;
  margin: 0 auto 12px;
  border-radius: 50%;
  object-fit: cover;
  border: 8px solid #fff;
  box-shadow: 0 8px 18px rgb(29 40 64 / 0.2);
}

.foto figcaption {
  font-family: var(--fuente-titulos);
  font-weight: 500;
  font-size: 20px;
  color: var(--marino);
}

/* ── Piezas de juego ── */
.escalon {
  height: 40px;
  border-radius: 6px;
  background: var(--naranja);
  box-shadow: inset 0 -8px 0 var(--naranja-oscuro), 0 6px 14px rgb(0 0 0 / 0.15);
}

.escalon::before {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  top: -10px;
  height: 10px;
  background: radial-gradient(circle at 50% 100%, var(--naranja) 0 8px, transparent 8.5px) 0 0 / 28px 10px repeat-x;
}

.pieza {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 42%, #FFE08A 0 9px, #F5B731 10px 15px, #D18A12 16px);
  box-shadow: 0 3px 0 #A86E0C;
  animation: flotar 2.4s ease-in-out infinite;
}

.pieza.recogida { animation: recoger-ya 0.12s ease-out forwards; pointer-events: none; }

/* La pieza que vuela al contador sale de main.js; aquí solo desaparece la del nivel */
@keyframes recoger-ya { to { transform: scale(1.3); opacity: 0; } }

@keyframes flotar { 50% { transform: translateY(-6px); } }
@keyframes recoger { to { transform: translateY(-60px) scale(1.4); opacity: 0; } }

.bandera { width: 84px; height: 260px; }

.bandera::before {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 10px;
  height: 100%;
  border-radius: 5px;
  background: var(--madera);
}

.bandera::after {
  content: "";
  position: absolute;
  left: 10px;
  top: 8px;
  width: 70px;
  height: 46px;
  background: var(--naranja);
  clip-path: polygon(0 0, 100% 0, 78% 50%, 100% 100%, 0 100%);
  /* Se iza con transform (lo mueve la GPU); animar top repintaba el mundo en cada fotograma */
  transform: translateY(188px);
  transition: transform 0.9s cubic-bezier(0.3, 1.4, 0.6, 1);
}

.bandera.izada::after { transform: none; }

.bandera.meta { height: 580px; }

.bandera.meta::before { width: 14px; background: linear-gradient(90deg, #A97A4E, var(--madera) 60%); }

.bandera.meta::after {
  left: 14px;
  transform: translateY(504px);
  width: 104px;
  height: 66px;
  background:
    radial-gradient(circle at 36% 50%, #fff 0 7px, transparent 7.5px),
    radial-gradient(circle at 58% 50%, #fff 0 7px, transparent 7.5px),
    var(--marino);
}

.bandera.meta.izada::after { transform: none; }

/* ── Proyectos: fichas, bloques sorpresa y capturas ── */
.ficha-cabecera { display: flex; gap: 16px; align-items: center; }

.ficha-icono {
  width: 72px;
  height: 72px;
  flex: none;
  border-radius: 18px;
  box-shadow: 0 3px 8px rgb(0 0 0 / 0.2);
}

.ficha h3 { font-size: 30px; margin: 0; }
.ficha-frase { font-size: 18px; color: var(--texto-suave); line-height: 1.4; }
.ficha-puntos { margin-top: 14px; padding-left: 1.1em; }
.ficha-puntos li + li { margin-top: 6px; }
.ficha-puntos li::marker { color: var(--naranja); }
.ficha-tec { margin-top: 12px; font-size: 15px; font-weight: 600; color: var(--texto-suave); }

.boton-tienda {
  display: inline-block;
  margin-top: 14px;
  padding: 10px 18px;
  border-radius: 12px;
  background: var(--marino);
  color: #fff;
  font-weight: 600;
  font-size: 17px;
  text-decoration: none;
  box-shadow: 0 4px 0 #0E1424;
}

.boton-tienda:hover { background: #2A3858; }
.boton-tienda.proximamente { background: #6B7285; box-shadow: 0 4px 0 #4C5262; }

.sorpresa {
  width: 96px;
  height: 96px;
  padding: 0;
  border: 0;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: #FFD25E;
  box-shadow: inset 0 -8px 0 #E0A82E, 0 6px 0 #B9861F, 0 14px 22px rgb(0 0 0 / 0.18);
  cursor: pointer;
}

.sorpresa img { width: 70px; height: 70px; border-radius: 16px; }
.sorpresa[aria-expanded="true"] { background: #FFE7A6; box-shadow: inset 0 -8px 0 #E8C36A, 0 6px 0 #C49A3A; }
.sorpresa.golpeado { animation: golpe 0.25s ease-out; }

@keyframes golpe { 50% { transform: translateY(-16px); } }

.capturas {
  display: flex;
  gap: 14px;
  padding: 14px;
  border-radius: 20px;
  background: rgb(29 40 64 / 0.92);
  box-shadow: 0 18px 30px rgb(0 0 0 / 0.25);
  animation: aparecer 0.35s cubic-bezier(0.2, 1.3, 0.5, 1);
}

.capturas img {
  width: 128px;
  height: 277px;
  border-radius: 14px;
  object-fit: cover;
  background: #2B3550;
}

@keyframes aparecer { from { transform: translateY(30px) scale(0.9); opacity: 0; } }

/* ── Habilidades: torres de ladrillos ── */
.rotulo { text-align: center; }

.rotulo h2 {
  font-size: 46px;
  color: var(--marino);
  text-shadow: 0 3px 0 #fff, 0 -2px 0 #fff, 2px 0 0 #fff, -2px 0 0 #fff;
}

.rotulo p {
  margin-top: 6px;
  font-size: 20px;
  font-weight: 600;
  color: var(--marino);
  text-shadow: 0 2px 0 rgb(255 255 255 / 0.9);
}

.torres { height: 900px; margin: 0; padding: 0; list-style: none; }

.torre {
  height: calc(var(--h) * 1px);
  padding: 16px 10px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  color: var(--marino);
  border-radius: 10px 10px 0 0;
  background:
    linear-gradient(90deg, transparent calc(100% - 12px), rgb(0 0 0 / 0.1) calc(100% - 12px)),
    repeating-linear-gradient(var(--naranja) 0 58px, var(--naranja-oscuro) 58px 60px);
}

.torre::before {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  top: -10px;
  height: 10px;
  background: radial-gradient(circle at 50% 100%, var(--naranja) 0 9px, transparent 9.5px) 0 0 / 30px 10px repeat-x;
}

.torre-nombre {
  font-family: var(--fuente-titulos);
  font-weight: 600;
  font-size: 17px;
  line-height: 1.2;
  text-shadow: 0 1px 0 rgb(255 255 255 / 0.35);
}

.torre-detalle { font-size: 13px; line-height: 1.35; }

.torre-nivel {
  margin-top: auto;
  font-size: 15px;
  letter-spacing: 2px;
  color: rgb(29 40 64 / 0.4);
}

.torre-nivel .lleno { color: var(--marino); }

/* ── Decorados de las apps ── */
.robot { height: auto; transform-origin: 50% 100%; }
.robot.saluda { animation: robot 0.9s ease-in-out infinite; }

@keyframes robot {
  25% { transform: rotate(-8deg); }
  75% { transform: rotate(8deg); }
}

.forja { height: 90px; }

.forja-forma {
  position: absolute;
  inset: 0;
  background: linear-gradient(#25B9E8 0 8px, #2E3340 8px);
  clip-path: polygon(0 0, 100% 0, 100% 22%, 78% 30%, 70% 62%, 86% 100%, 14% 100%, 30% 62%, 22% 30%, 0 22%);
}

.chispas {
  position: absolute;
  left: 50%;
  top: -6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #FFC24A;
  box-shadow: -42px -18px #FFC24A, 36px -28px #FF8A3D, -18px -46px #FFD86B, 24px -52px #FFC24A, 54px -10px #FF8A3D, -60px -4px #FFD86B;
  opacity: 0;
}

.forja.clang .chispas { animation: chispas 0.5s ease-out; }

@keyframes chispas {
  0% { opacity: 1; transform: scale(0.4); }
  100% { opacity: 0; transform: translateY(-30px) scale(1.3); }
}

.burbuja {
  height: 58px;
  border-radius: 22px;
  background: #fff;
  border: 3px solid #6F4BE3;
  box-shadow: 0 6px 0 #D9D0FA;
}

.burbuja::before {
  content: "• • •";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #6F4BE3;
  font-size: 22px;
  letter-spacing: 2px;
}

.burbuja::after {
  content: "";
  position: absolute;
  left: 24px;
  bottom: -17px;
  border: 8px solid transparent;
  border-top-color: #6F4BE3;
}

.cama-elastica {
  height: 160px;
  background: url("../img/apps/una-neurona/neurona.webp") center bottom / contain no-repeat;
  transform-origin: 50% 100%;
}

.cama-elastica.rebota { animation: rebote 0.35s ease-out; }

@keyframes rebote {
  30% { transform: scale(1.15, 0.7); }
  60% { transform: scale(0.92, 1.12); }
}

/* ── Charlas, idiomas y meta ── */
.escenario {
  height: 90px;
  border-radius: 6px 6px 0 0;
  border-top: 10px solid var(--madera-oscura);
  background: repeating-linear-gradient(90deg, #A86B3C 0 58px, var(--madera) 58px 60px);
  box-shadow: 0 -4px 12px rgb(0 0 0 / 0.12);
}

.atril {
  height: 90px;
  background: linear-gradient(#5A3A1F 0 14px, var(--madera) 14px);
  clip-path: polygon(0 0, 100% 0, 80% 18%, 70% 100%, 30% 100%, 20% 18%);
}

.coche {
  height: 90px;
  background:
    radial-gradient(circle at 22% 78%, #2A2D3A 0 10px, #1D2030 11px 17px, transparent 18px),
    radial-gradient(circle at 78% 78%, #2A2D3A 0 10px, #1D2030 11px 17px, transparent 18px);
}

.coche::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 22px;
  height: 48px;
  border-radius: 12px 12px 6px 6px;
  background: #D93B30;
  box-shadow: inset 0 -8px 0 #A82A22;
  z-index: -1;
}

.coche::after {
  content: "";
  position: absolute;
  left: 50px;
  right: 50px;
  top: 0;
  height: 22px;
  border-radius: 10px 10px 0 0;
  background: linear-gradient(90deg, #BFE6FA 0 45%, #D93B30 45% 55%, #BFE6FA 55%);
  box-shadow: 0 0 0 4px #D93B30;
}

.bandera-mini {
  display: inline-block;
  width: 26px;
  height: 18px;
  margin-right: 10px;
  border-radius: 3px;
  vertical-align: -3px;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.12);
}

.bandera-mini.es { background: linear-gradient(#C60B1E 0 25%, #FFC400 25% 75%, #C60B1E 75%); }
.bandera-mini.va { background: linear-gradient(90deg, #0039A6 0 22%, transparent 22%), repeating-linear-gradient(#FFD100 0 2px, #DA121A 2px 4px); }
.bandera-mini.en {
  background:
    linear-gradient(transparent 40%, #C8102E 40% 60%, transparent 60%),
    linear-gradient(90deg, transparent 43%, #C8102E 43% 57%, transparent 57%),
    linear-gradient(transparent 32%, #fff 32% 68%, transparent 68%),
    linear-gradient(90deg, transparent 37%, #fff 37% 63%, transparent 63%),
    #012169;
}

.idiomas { padding-left: 0; list-style: none; }

.puesto { height: 710px; pointer-events: none; }

.puesto::before {
  content: "";
  position: absolute;
  left: -30px;
  right: -30px;
  top: 0;
  height: 96px;
  border-radius: 18px 18px 6px 6px;
  background:
    radial-gradient(circle at 50% 0, #A83A26 0 14px, transparent 14.5px) 0 76px / 40px 20px repeat-x,
    repeating-linear-gradient(90deg, #C8462F 0 40px, #A83A26 40px 44px);
  box-shadow: 0 10px 0 #7E2A1B;
}

.puesto::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  top: 96px;
  bottom: 0;
  background: linear-gradient(90deg,
    var(--madera) 0 22px, transparent 22px calc(100% - 22px), var(--madera) calc(100% - 22px));
}

.noren {
  position: absolute;
  left: 50%;
  top: -58px;
  z-index: 1;
  transform: translateX(-50%);
  padding: 6px 24px;
  border: 4px solid var(--madera-oscura);
  border-radius: 10px;
  background: var(--madera);
  color: var(--crema);
  font: 600 30px var(--fuente-titulos);
  letter-spacing: 6px;
  white-space: nowrap;
}

.contacto-enlaces {
  margin-top: 12px;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 18px;
  font-weight: 600;
}

.contacto-enlaces a { text-decoration: none; overflow-wrap: anywhere; }

.contacto-pdf { margin-top: 12px; }

.boton-pdf {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 12px;
  background: var(--marino);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 4px 0 #0E1424;
}

.boton-pdf::before { content: "⬇ "; }
.boton-pdf:hover { background: #2A3858; }
.contacto-enlaces a:hover { text-decoration: underline; }

.formulario { margin-top: 16px; display: grid; gap: 12px; }
.formulario-fila { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.formulario label {
  display: grid;
  gap: 4px;
  font-size: 15px;
  font-weight: 600;
  color: var(--texto-suave);
}

.formulario input, .formulario textarea {
  padding: 10px 12px;
  border: 2px solid var(--crema-sombra);
  border-radius: 10px;
  background: #fff;
  color: var(--texto);
  font: inherit;
  font-size: 17px;
  font-weight: 400;
  resize: vertical;
  user-select: text;
}

.formulario input:focus, .formulario textarea:focus { border-color: var(--naranja); outline: none; }

.boton-enviar {
  justify-self: start;
  padding: 12px 22px;
  border: 0;
  border-radius: 12px;
  background: var(--naranja);
  color: var(--marino);
  font: 600 18px var(--fuente-titulos);
  cursor: pointer;
  box-shadow: 0 4px 0 var(--naranja-oscuro);
}

.boton-enviar:disabled { opacity: 0.6; cursor: progress; }
.form-exito { color: #2E7D32; font-weight: 600; }

/* ── Muñeco, premios, estela y clones ── */
/* .muneco dibuja un fotograma de la hoja; el jugador es un contenedor con el sprite y sus premios encima */
.muneco {
  position: absolute;
  left: 0;
  top: 0;
  width: 160px;
  height: 160px;
  background-image: url("../img/personaje/muneco.webp");
  background-repeat: no-repeat;
  background-size: calc(var(--columnas, 8) * 160px) calc(var(--filas, 6) * 160px);
  pointer-events: none;
}

.jugador {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 10;
  width: 160px;
  height: 160px;
  /* Gira sobre los pies (frenazo, risa); colgado del ratón, sobre la cabeza */
  transform-origin: 50% 96%;
  cursor: grab;
  touch-action: none;
  visibility: hidden;
  --cabeza: 10px;
  --vaiven: 0deg;
}

.jugador.listo { visibility: visible; }
.jugador.agarrado { cursor: grabbing; transform-origin: 50% 14%; }
.jugador.humo { animation: humo 0.45s ease-out; }
.jugador.premiado .jugador-sprite { animation: premiado 0.6s ease-out; }

@keyframes humo { from { opacity: 0; filter: blur(6px); } }
@keyframes premiado { 40% { filter: brightness(1.8) drop-shadow(0 0 12px #FFD36B); } }

.jugador > span { position: absolute; pointer-events: none; display: none; }
.jugador > .jugador-sprite { display: block; }

/* Bandana de la Hoja (12 piezas): cinta azul en la frente con placa metálica y dos colas por detrás */
.con-bandana > .premio-bandana {
  display: block;
  left: 55px;
  top: calc(var(--cabeza) + 15px);
  width: 51px;
  height: 9px;
  border-radius: 4px;
  background: #24314F;
  box-shadow: inset 0 -2px 0 rgb(0 0 0 / 0.25);
}

.bandana-placa {
  position: absolute;
  left: 50%;
  top: -3px;
  width: 24px;
  height: 14px;
  margin-left: -12px;
  border-radius: 3px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 14'%3E%3Cpath d='M12 3.2a3.8 3.8 0 1 0 3.8 3.8c0-1.4-1-2.4-2.3-2.4a1.6 1.6 0 1 0 1.5 1.7M15.8 7l3.2-3.6' fill='none' stroke='%2353606F' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E") center / 100% 100%,
    linear-gradient(#EEF2F6, #A9B4C2);
  box-shadow: 0 1px 0 rgb(0 0 0 / 0.3);
}

.premio-bandana::before, .premio-bandana::after {
  content: "";
  position: absolute;
  top: 2px;
  width: 18px;
  height: 6px;
  border-radius: 3px;
  background: #24314F;
  transform-origin: 100% 50%;
  display: none;
}

/* De perfil la placa va delante (a la derecha en la hoja) y las colas ondean detrás */
.jugador[data-vista="perfil"] .bandana-placa { left: 82%; }
.jugador[data-vista="perfil"] .premio-bandana::before,
.jugador[data-vista="perfil"] .premio-bandana::after { display: block; left: -15px; }
.jugador[data-vista="perfil"] .premio-bandana::before { transform: rotate(calc(-10deg - var(--vaiven) * 0.5)); }
.jugador[data-vista="perfil"] .premio-bandana::after { transform: rotate(calc(18deg - var(--vaiven) * 0.3)); }

/* Capa de Hokage (24 piezas): detrás del cuerpo, blanca con llamas rojas; se echa hacia atrás al correr */
.con-capa > .premio-capa {
  display: block;
  left: 36px;
  top: calc(var(--cabeza) + 48px);
  width: 88px;
  height: calc(102px - var(--cabeza));
  transform-origin: 50% 0;
  transform: rotate(var(--vaiven));
  clip-path: polygon(22% 0, 78% 0, 100% 100%, 0 100%);
  background:
    linear-gradient(transparent 78%, #D8402B 78%),
    linear-gradient(90deg, #E9E4DA, #FFFFFF 30% 70%, #E9E4DA);
  -webkit-mask: radial-gradient(9px 14px at 9px 100%, transparent 98%, #000) 0 0 / 18px 100%;
  mask: radial-gradient(9px 14px at 9px 100%, transparent 98%, #000) 0 0 / 18px 100%;
}

.jugador[data-vista="perfil"] > .premio-capa { left: 24px; }

/* Aura de chakra (36 piezas): resplandor naranja que late y contorno brillante */
.con-aura > .premio-aura {
  display: block;
  left: 10px;
  top: 0;
  width: 140px;
  height: 160px;
  border-radius: 50% 50% 40% 40%;
  background: radial-gradient(closest-side, rgb(255 190 80 / 0.55), rgb(244 123 32 / 0.3) 60%, transparent);
  animation: chakra 1.1s ease-in-out infinite alternate;
}

.con-aura > .jugador-sprite { filter: drop-shadow(0 0 3px #FFE08A) drop-shadow(0 0 8px rgb(244 123 32 / 0.8)); }

@keyframes chakra {
  from { transform: scale(0.92); opacity: 0.7; }
  to { transform: scale(1.06); opacity: 1; }
}

/* Imágenes residuales al lanzar al muñeco */
.estela {
  z-index: 9;
  transform-origin: 50% 96%;
  animation: estela 0.32s ease-out forwards;
}

@keyframes estela {
  from { opacity: 0.45; }
  to { opacity: 0; }
}

/* Bocadillo: sigue la cabeza del muñeco; el globo cuelga hacia arriba desde ese punto */
.bocadillo {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 12;
  width: 0;
  height: 0;
  pointer-events: none;
}

.bocadillo-globo {
  position: absolute;
  left: 0;
  bottom: 14px;
  width: max-content;
  max-width: 360px;
  padding: 12px 18px;
  border-radius: 18px;
  background: #fff;
  color: var(--marino);
  font: 600 19px/1.35 var(--fuente-titulos);
  text-align: center;
  transform: translateX(-50%);
  box-shadow: 0 4px 0 var(--crema-sombra), 0 12px 24px rgb(29 40 64 / 0.22);
}

.bocadillo-globo::after {
  content: "";
  position: absolute;
  left: calc(50% + var(--cola, 0px));
  bottom: -12px;
  margin-left: -10px;
  border: 10px solid transparent;
  border-bottom: 0;
  border-top: 13px solid #fff;
}

.bocadillo-globo.aparece { animation: globo 0.32s cubic-bezier(0.2, 1.4, 0.5, 1); }

@keyframes globo { from { opacity: 0; scale: 0.6; translate: 0 14px; } }

/* Ayuda contextual: teclas junto al muñeco si nadie se mueve */
.ayuda {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 12;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgb(29 40 64 / 0.88);
  color: #fff;
  font: 600 18px var(--fuente-titulos);
  white-space: nowrap;
  pointer-events: none;
  animation: ayuda 1.2s ease-in-out infinite;
}

.ayuda kbd {
  display: inline-block;
  min-width: 34px;
  padding: 2px 10px;
  border-radius: 8px;
  background: #fff;
  color: var(--marino);
  font: inherit;
  text-align: center;
  box-shadow: 0 3px 0 var(--crema-sombra);
}

@keyframes ayuda { 50% { translate: 8px 0; } }

/* Pieza secreta: morada y brillante, muy arriba sobre la cama elástica de Una Neurona */
.pieza-secreta {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 42%, #F3D9FF 0 9px, #B26BEA 10px 16px, #7B3FC0 17px);
  box-shadow: 0 3px 0 #5A2D91, 0 0 18px 4px rgb(178 107 234 / 0.6);
  animation: flotar 1.8s ease-in-out infinite;
}

.pieza-secreta.recogida { animation: recoger 0.6s ease-out forwards; }

/* Modo Kyūbi (código Konami): aura de fuego naranja y roja */
.modo-kyubi > .premio-aura {
  display: block;
  left: -6px;
  top: -14px;
  width: 172px;
  height: 180px;
  border-radius: 50% 50% 42% 42%;
  background:
    radial-gradient(closest-side, rgb(255 120 40 / 0.65), rgb(214 40 20 / 0.45) 55%, transparent),
    conic-gradient(from 200deg at 50% 70%, transparent, rgb(255 90 20 / 0.35), transparent 30%, rgb(255 150 40 / 0.3), transparent 60%);
  animation: chakra 0.45s ease-in-out infinite alternate;
}

.modo-kyubi > .jugador-sprite { filter: drop-shadow(0 0 4px #FF8A3D) drop-shadow(0 0 12px rgb(214 40 20 / 0.9)); }

/* Tuberías de las apps: verdes, con studs de LEGO en el borde; la de entrada lleva un botón con la flecha */
.tuberia {
  z-index: 11;
  height: calc((780 - var(--y)) * 1px);
  --verde: #3FA34D;
  --verde-luz: #7BD389;
  --verde-sombra: #1F6B2C;
}

.tuberia::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 34px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 100%, var(--verde) 0 7px, transparent 7.5px) 4px -12px / 24px 12px repeat-x,
    linear-gradient(90deg, var(--verde-sombra), var(--verde) 18%, var(--verde-luz) 32%, var(--verde) 50%, var(--verde-sombra));
  box-shadow: inset 0 -5px 0 rgb(0 0 0 / 0.18), 0 4px 0 rgb(0 0 0 / 0.15);
}

.tuberia::after {
  content: "";
  position: absolute;
  inset: 30px 9px 0;
  z-index: -1;
  background: linear-gradient(90deg, var(--verde-sombra), var(--verde) 18%, var(--verde-luz) 32%, var(--verde) 50%, var(--verde-sombra));
}

.tuberia-boton {
  position: absolute;
  inset: 34px 9px 0;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
}

.tuberia-boton::before {
  content: "▼";
  font-size: 30px;
  line-height: 1;
  text-shadow: 0 2px 0 rgb(0 0 0 / 0.3);
  animation: flecha-tuberia 1s ease-in-out infinite;
}

.tuberia-boton > span {
  position: absolute;
  bottom: calc(100% + 54px);
  left: 50%;
  translate: -50% 0;
  padding: 6px 12px;
  border-radius: 10px;
  background: var(--marino);
  color: #fff;
  font: 600 16px var(--fuente-titulos);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}

.tuberia-boton:hover > span,
.tuberia-boton:focus-visible > span { opacity: 1; }

@keyframes flecha-tuberia { 50% { translate: 0 6px; } }

.tuberia-salida::after { inset: 30px 7px 0; }
.tuberia-salida::before { inset: 0 -4px auto; }

.jugador.en-tuberia { visibility: hidden; }

/* Partículas: polvo, chispas del yunque y piezas de LEGO de los bloques sorpresa */
.particulas {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 11;
  pointer-events: none;
}

.particula {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform, opacity;
}

.particula-polvo {
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, rgb(255 246 230 / 0.95), rgb(222 200 165 / 0.75));
}

.particula-chispa {
  width: 7px;
  height: 7px;
  margin: -3.5px 0 0 -3.5px;
  border-radius: 50%;
  background: #FFD86B;
  box-shadow: 0 0 8px 2px rgb(255 160 60 / 0.8);
}

.particula-lego {
  width: 18px;
  height: 12px;
  margin: -6px 0 0 -9px;
  border-radius: 2px;
  background: var(--color, var(--naranja));
  box-shadow: inset 0 -3px 0 rgb(0 0 0 / 0.22);
}

.particula-lego::before {
  content: "";
  position: absolute;
  left: 4px;
  top: -4px;
  width: 10px;
  height: 5px;
  border-radius: 2px 2px 0 0;
  background: inherit;
  box-shadow: inset 0 -1px 0 rgb(0 0 0 / 0.15);
}

/* «+1» al recoger una pieza */
.mas-uno {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 12;
  font: 600 28px var(--fuente-titulos);
  color: #F5B731;
  -webkit-text-stroke: 5px #fff;
  paint-order: stroke fill;
  pointer-events: none;
  animation: mas-uno 0.8s ease-out forwards;
}

@keyframes mas-uno {
  0% { translate: 0 0; scale: 0.6; opacity: 0; }
  20% { scale: 1.15; opacity: 1; }
  100% { translate: 0 -70px; scale: 1; opacity: 0; }
}

/* Luciérnagas del contacto: aparecen de noche */
.luciernaga {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #FFF3A0;
  box-shadow: 0 0 10px 4px rgb(255 228 92 / 0.65);
  opacity: calc(var(--noche, 0) * 0.95);
  animation: luciernaga 5s ease-in-out var(--retraso, 0s) infinite alternate;
  pointer-events: none;
}

@keyframes luciernaga {
  0% { translate: 0 0; scale: 1; }
  30% { translate: 26px -18px; scale: 0.5; }
  65% { translate: -14px -40px; scale: 1.1; }
  100% { translate: 18px -12px; scale: 0.7; }
}

.clon {
  z-index: 9;
  animation: clon 1.3s ease-in var(--retraso, 0s) both;
}

@keyframes clon {
  0% { transform: translateX(0); opacity: 0; }
  15% { opacity: 0.6; }
  100% { transform: translateX(var(--destino, 400px)); opacity: 0; }
}

.depurar-caja {
  position: absolute;
  z-index: 15;
  border-top: 3px solid #E0218A;
  background: rgb(224 33 138 / 0.12);
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .pieza, .robot.saluda, .capturas, .clon, .letra.pisada, .sorpresa.golpeado, .cama-elastica.rebota,
  .forja.clang .chispas, .jugador.humo, .con-aura > .premio-aura, .luciernaga, .bocadillo-globo.aparece,
  .jugador.premiado .jugador-sprite, .pieza-secreta, .modo-kyubi > .premio-aura, .tuberia-boton::before { animation: none; }
  .bandera::after { transition: none; }
}
