/* El Belén de Pipo · estilos */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Baloo 2", system-ui, sans-serif;
  color: #2a2350;
  background: #1b1f6b;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button { font-family: inherit; color: inherit; cursor: pointer; }
img { -webkit-user-drag: none; }
#fondo { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }
.pant {
  position: fixed; inset: 0; z-index: 1;
  display: flex; flex-direction: column; align-items: center;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}
.pant[hidden], .velo[hidden], [hidden] { display: none !important; }

/* Botones redondos */
.btn-redondo {
  width: 54px; height: 54px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 26px; line-height: 1; text-decoration: none; color: #4b2f9e; font-weight: 800;
  background: #fff; border: 0; box-shadow: 0 5px 0 rgba(42,35,80,.25), 0 8px 18px rgba(0,0,0,.18);
  transition: transform .12s;
}
.btn-redondo:active { transform: translateY(3px) scale(.96); box-shadow: 0 2px 0 rgba(42,35,80,.25); }
.btn-redondo.grande { width: 84px; height: 84px; font-size: 40px; background: linear-gradient(#5fe07a, #2fb257); color: #fff; }
#iAtras { font-size: 40px; padding-bottom: 6px; }

/* ---------- Portada ---------- */
.esquina { position: absolute; top: max(10px, env(safe-area-inset-top)); display: flex; gap: 8px; z-index: 3; }
.esquina.izq { left: max(10px, env(safe-area-inset-left)); }
.esquina.der { right: max(10px, env(safe-area-inset-right)); }
#pInicio { justify-content: space-evenly; gap: 6px; }
.logo { margin: 0; line-height: 0; }
.logo img { width: min(74vw, 430px, 42dvh); height: auto; filter: drop-shadow(0 6px 10px rgba(0,0,0,.35)); animation: flota 4s ease-in-out infinite; }
.inicio-centro { display: flex; align-items: center; justify-content: center; gap: clamp(8px, 3vw, 30px); }
.heroe-zona .pipo { width: clamp(110px, 30vw, 190px); max-height: 24dvh; object-fit: contain; cursor: pointer; }
.mi-belen {
  position: relative; display: flex; flex-direction: column; align-items: center;
  width: clamp(130px, 36vw, 210px); padding: 10px 10px 12px; border: 0; border-radius: 26px;
  background: linear-gradient(#fff8e0, #ffe39a); box-shadow: 0 7px 0 #d99a1a, 0 12px 24px rgba(0,0,0,.3);
  animation: late 2.6s ease-in-out infinite;
}
.mi-belen img { width: 70%; max-height: 13dvh; object-fit: contain; }
.mi-belen .t { font-family: "Lilita One", sans-serif; font-size: clamp(22px, 6vw, 30px); color: #b0461c; line-height: 1.05; }
.mi-belen .cuenta { font-weight: 800; font-size: 16px; color: #7a4b16; }
.mi-belen:active { transform: translateY(4px); box-shadow: 0 3px 0 #d99a1a; }
.juegos {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: clamp(8px, 1.6vw, 16px);
  width: min(100%, 820px);
}
.juego-btn {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding: 8px 6px 6px; border: 0; border-radius: 24px; background: #fff;
  box-shadow: 0 6px 0 var(--sh), 0 10px 18px rgba(0,0,0,.25);
  animation: entra .5s cubic-bezier(.3,1.5,.5,1) both; animation-delay: calc(var(--i) * 70ms);
}
.juego-btn .art { width: 82%; aspect-ratio: 1; object-fit: contain; }
.juego-btn .nombre { font-family: "Lilita One", sans-serif; font-size: clamp(14px, 2.2vw, 19px); line-height: 1.05; text-align: center; color: #3a2b7a; min-height: 2.1em; display: flex; align-items: center; }
.juego-btn .estrellas { font-size: 12px; min-height: 16px; letter-spacing: -2px; }
.juego-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--sh); }
@media (max-width: 640px) {
  .juegos { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .juego-btn { grid-column: span 2; }
  .juego-btn:nth-child(4) { grid-column: 2 / span 2; }
  .juego-btn .art { width: 70%; }
}

/* ---------- Partida ---------- */
.barra { width: 100%; max-width: 900px; display: flex; align-items: center; justify-content: space-between; gap: 10px; position: relative; z-index: 3; }
.progreso { display: flex; gap: 4px; padding: 6px 12px; border-radius: 999px; background: rgba(255,255,255,.85); box-shadow: 0 4px 10px rgba(0,0,0,.15); }
.progreso span { font-size: 26px; line-height: 1; color: #d9d3f0; transition: transform .3s; }
.progreso span.si { color: #ffc21a; text-shadow: 0 0 8px rgba(255,200,40,.8); }
.progreso span.ahora { color: #b9adf0; animation: late 1.2s infinite; }
.progreso span.brilla { animation: pop .5s; }
.titulo-juego, .titulo-belen { margin: 4px 0 0; font-family: "Lilita One", sans-serif; font-weight: 400; color: #fff; font-size: clamp(20px, 5vw, 28px); text-shadow: 0 3px 0 rgba(42,35,80,.6); text-align: center; }
.titulo-belen { margin: 0; }
.chip { font-weight: 800; font-size: 18px; padding: 6px 14px; border-radius: 999px; background: #fff8e0; color: #7a4b16; box-shadow: 0 4px 10px rgba(0,0,0,.2); }
.leyenda { max-width: 600px; margin: 4px 12px 0; padding: 6px 14px; border-radius: 16px; background: rgba(255,255,255,.92); font-weight: 700; font-size: 18px; text-align: center; z-index: 3; }
.area { position: relative; flex: 1; width: 100%; max-width: 980px; min-height: 0; }
.ronda { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(12px, 3dvh, 28px); padding: 6px 4px 92px; animation: entra .45s cubic-bezier(.3,1.4,.5,1) both; }
.ronda.sale { animation: sale .4s ease-in forwards; pointer-events: none; }
.pipo-dock { position: absolute; left: max(6px, env(safe-area-inset-left)); bottom: max(4px, env(safe-area-inset-bottom)); z-index: 4; }
.pipo-dock .pipo { width: clamp(78px, 18vw, 120px); cursor: pointer; display: block; }
.pipo { transform-origin: 50% 100%; }
.pipo.salta { animation: salta .6s ease-out; }
.pipo.tiembla { animation: tiembla .5s; }

/* Figuras genéricas */
.fig { display: block; pointer-events: auto; }
.movil { width: clamp(120px, 30vw, 190px); touch-action: none; cursor: grab; filter: drop-shadow(0 8px 8px rgba(0,0,0,.3)); position: relative; z-index: 5; animation: ofrece 1.8s ease-in-out infinite; }
.arrastrando { animation: none !important; z-index: 50 !important; cursor: grabbing; }
.bandeja { display: flex; justify-content: center; align-items: flex-end; }
.acierto { animation: pop .55s cubic-bezier(.3,1.6,.5,1); }
.tiembla { animation: tiembla .5s; }
.pista { animation: pista 1s ease-in-out infinite !important; }

/* 1. ¿Dónde está? */
.tarjetas { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(10px, 2.5vw, 24px); max-width: 900px; }
.tarjeta { width: clamp(120px, 26vw, 200px); aspect-ratio: 1; padding: 6px; border: 0; border-radius: 28px; background: rgba(255,255,255,.95); box-shadow: 0 6px 0 rgba(42,35,80,.25), 0 10px 20px rgba(0,0,0,.2); }
.tarjetas.n4 .tarjeta { width: clamp(118px, 40vw, 190px); }
@media (min-width: 700px) { .tarjetas.n4 .tarjeta { width: clamp(120px, 19vw, 190px); } }
.tarjeta .fig { width: 100%; height: 100%; object-fit: contain; }
.tarjeta:active { transform: scale(.96); }

/* 2. Sombras */
.sombras { display: flex; gap: clamp(8px, 2.5vw, 24px); justify-content: center; }
.sombra { width: clamp(100px, 27vw, 180px); aspect-ratio: 1; border: 4px dashed rgba(255,255,255,.75); border-radius: 26px; background: rgba(255,255,255,.35); padding: 4px; }
.sombra img { width: 100%; height: 100%; object-fit: contain; }
.sombra.llena { border-style: solid; border-color: #ffd23f; background: rgba(255,255,255,.85); }

/* 3. Ovejas */
.prado { position: relative; width: min(94vw, 600px); aspect-ratio: 16 / 10; max-height: 46dvh; border-radius: 30px; background: radial-gradient(ellipse at 50% 30%, #bff08a, #7fc95a); box-shadow: inset 0 -10px 0 rgba(0,0,0,.08), 0 8px 18px rgba(0,0,0,.2); }
.prado.bajo { aspect-ratio: 16 / 7; }
.oveja-campo { position: absolute; width: 20%; cursor: pointer; transition: transform .15s; }
.oveja-campo.girada { transform: scaleX(-1); }
.oveja-campo[data-n] { filter: drop-shadow(0 0 6px #fff) brightness(1.05); }
.numero { position: absolute; transform: translate(-50%, -30%); width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-family: "Lilita One", sans-serif; font-size: 22px; color: #fff; background: #ff6b3d; box-shadow: 0 3px 0 #c2441f; animation: pop .4s; pointer-events: none; }
.numeros { display: flex; gap: clamp(10px, 3vw, 24px); }
.num-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: clamp(84px, 22vw, 120px); padding: 6px 10px 10px; border: 0; border-radius: 24px; background: #fff; box-shadow: 0 6px 0 #6fae47, 0 10px 18px rgba(0,0,0,.2); }
.num-btn b { font-family: "Lilita One", sans-serif; font-weight: 400; font-size: clamp(40px, 11vw, 60px); line-height: 1; color: #3a2b7a; }
.puntos { display: grid; grid-template-columns: repeat(5, 10px); gap: 3px; justify-content: center; }
.puntos i { width: 10px; height: 10px; border-radius: 50%; background: #ff6b3d; }
.corral { position: relative; width: min(80vw, 420px); }
.redil { width: 100%; display: block; }
.dentro-redil { position: absolute; left: 12%; right: 12%; top: 22%; bottom: 14%; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; }
.hueco { width: 22%; aspect-ratio: 1; display: block; }
.oveja-redil { width: 100%; animation: pop .4s; }

/* 4. Luces */
.guirnalda { position: relative; display: flex; align-items: flex-start; justify-content: center; gap: clamp(2px, 1vw, 12px); padding: 14px 10px 0; width: min(96vw, 820px); }
.guirnalda .cable { position: absolute; left: 2%; right: 2%; top: 4px; height: 40px; border-top: 5px solid #2c7a3a; border-radius: 50% 50% 0 0 / 30px 30px 0 0; transform: scaleY(-1); }
.bombilla { width: clamp(38px, 11vw, 82px); }
.guirnalda .bombilla:nth-child(odd) { margin-top: 10px; }
.guirnalda .bombilla.espera { filter: grayscale(1) brightness(.85); opacity: .6; }
.guirnalda .bombilla { transition: filter .2s, opacity .2s; }
.guirnalda .bombilla.falta { animation: late 1.1s infinite; }
.interroga { position: absolute; right: clamp(8px, 4vw, 40px); top: 54%; font-family: "Lilita One", sans-serif; font-size: clamp(30px, 8vw, 50px); color: #fff; text-shadow: 0 3px 0 #2a2350; pointer-events: none; }
.guirnalda.fiesta .bombilla { animation: parpadea .5s steps(2) 4; }
.opciones-luz { display: flex; gap: clamp(12px, 4vw, 30px); }
.luz-btn { width: clamp(90px, 24vw, 130px); aspect-ratio: 1; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 6px 0 #c9a76a, 0 10px 18px rgba(0,0,0,.2); display: grid; place-items: center; }
.luz-btn .bombilla { width: 52%; }

/* 5. Coloca y Mi belén */
.escena-marco { position: relative; width: min(94vw, calc(100dvh - 330px), 620px); aspect-ratio: 1; border-radius: 26px; overflow: hidden; box-shadow: 0 0 0 5px #fff8e0, 0 0 0 9px #c98a50, 0 12px 30px rgba(0,0,0,.4); flex: none; }
.escena-marco.grande { width: min(96vw, calc(100dvh - 100px), 900px); }
.escena { position: absolute; inset: 0; width: 100%; height: 100%; }
.en-escena { position: absolute; height: auto; }
.en-escena.cae, .en-escena.nueva { animation: cae .7s cubic-bezier(.3,1.5,.5,1) both; }
.en-escena.nueva { animation-delay: .35s; }
.en-escena.toca { animation: pop .5s; }
.hueco-fig { opacity: .22; cursor: pointer; }
.zona { position: absolute; width: 14%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; border: 4px dashed #fff; background: radial-gradient(circle, rgba(255,240,150,.55), rgba(255,240,150,.08)); box-shadow: 0 0 18px rgba(255,240,150,.7); animation: zona 1.6s ease-in-out infinite; padding: 0; }
.zona.pista { animation: zona .8s ease-in-out infinite !important; border-color: #ffd23f; box-shadow: 0 0 0 6px #ffd23f, 0 0 26px #ffd23f; }
.belen-zona { flex: 1; display: grid; place-items: center; width: 100%; min-height: 0; }
.escena-marco.completo .en-escena[src] { cursor: pointer; }
.escena-marco.completo::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle at 47% 20%, rgba(255,240,150,.35), transparent 40%); animation: late 2.4s infinite; }
#pBelen .pipo-dock .pipo { width: clamp(70px, 14vw, 110px); }

/* ---------- Premio ---------- */
.velo { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(20,18,70,.72); }
.premio { position: relative; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.rayos { position: absolute; left: 50%; top: 40%; width: 520px; height: 520px; margin: -260px 0 0 -260px; background: repeating-conic-gradient(rgba(255,240,150,.35) 0 12deg, transparent 12deg 30deg); border-radius: 50%; animation: gira 12s linear infinite; mask-image: radial-gradient(circle, #000 30%, transparent 70%); -webkit-mask-image: radial-gradient(circle, #000 30%, transparent 70%); pointer-events: none; }
.premio-fig { position: relative; width: min(64vw, 300px); filter: drop-shadow(0 10px 20px rgba(0,0,0,.4)); animation: cae .8s cubic-bezier(.3,1.5,.5,1) both; }
.premio-estrella { position: relative; font-size: 160px; animation: cae .8s cubic-bezier(.3,1.5,.5,1) both; }
.acciones { position: relative; display: flex; align-items: center; gap: 16px; }
.btn-belen { border: 0; border-radius: 999px; padding: 12px 24px; font-family: "Lilita One", sans-serif; font-size: 24px; color: #fff; background: linear-gradient(#ffb84a, #f08a12); box-shadow: 0 6px 0 #b8600a, 0 10px 18px rgba(0,0,0,.3); animation: late 1.6s infinite; }

/* ---------- Animaciones ---------- */
@keyframes flota { 50% { transform: translateY(-6px) rotate(-1deg); } }
@keyframes late { 50% { transform: scale(1.06); } }
@keyframes entra { from { opacity: 0; transform: scale(.6) translateY(20px); } }
@keyframes sale { to { opacity: 0; transform: translateX(-40px) scale(.9); } }
@keyframes pop { 40% { transform: scale(1.18); } 70% { transform: scale(.95); } }
@keyframes tiembla { 20%, 60% { transform: translateX(-8px) rotate(-3deg); } 40%, 80% { transform: translateX(8px) rotate(3deg); } }
@keyframes pista { 50% { transform: scale(1.08); box-shadow: 0 0 0 6px #ffd23f, 0 0 26px #ffd23f; } }
@keyframes salta { 40% { transform: translateY(-18px) scale(1.05, .95); } 70% { transform: translateY(0) scale(.95, 1.05); } }
@keyframes ofrece { 50% { transform: translateY(-8px) rotate(2deg); } }
@keyframes cae { from { opacity: 0; transform: translateY(-60px) scale(.6); } }
@keyframes zona { 50% { transform: translate(-50%, -50%) scale(1.1); } }
@keyframes parpadea { 50% { filter: brightness(1.6) drop-shadow(0 0 10px #fff); } }
@keyframes gira { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; } }

/* Ordenador: aprovechar el alto */
@media (min-width: 900px) and (min-height: 600px) {
  .tarjeta { width: clamp(150px, 24dvh, 220px); }
  .tarjetas.n4 .tarjeta { width: clamp(140px, 22dvh, 210px); }
  .sombra { width: clamp(120px, 22dvh, 200px); }
  .movil { width: clamp(140px, 24dvh, 210px); }
  .escena-marco { width: min(94vw, calc(100dvh - 330px), 640px); }
}
/* Móvil en horizontal (poco alto): todo en fila y sin título */
@media (max-height: 520px) and (min-aspect-ratio: 4/3) {
  .titulo-juego { display: none; }
  .ronda { flex-direction: row; padding: 4px 8px 4px 96px; gap: 18px; }
  .ronda-luces { flex-direction: column; gap: 10px; }
  .tarjeta { width: min(30dvh + 40px, 22vw); }
  .tarjetas.n4 .tarjeta { width: min(36dvh, 18vw); }
  .sombras { flex-direction: row; }
  .sombra { width: min(34dvh, 18vw); }
  .movil { width: min(40dvh, 22vw); }
  .prado { width: auto; height: 66dvh; max-height: none; }
  .numeros { flex-direction: column; gap: 8px; }
  .num-btn { min-width: 74px; padding: 2px 8px 6px; }
  .num-btn b { font-size: 32px; }
  .corral { width: min(48vw, 70dvh); }
  .prado.bajo { height: 50dvh; }
  .escena-marco { width: calc(100dvh - 90px); }
  .escena-marco.grande { width: calc(100dvh - 84px); }
  .luz-btn { width: min(24dvh, 110px); }
  .pipo-dock .pipo { width: 74px; }
  #pInicio { flex-direction: row; flex-wrap: wrap; align-content: center; justify-content: center; gap: 4px 20px; }
  .logo img { width: min(36vw, 46dvh); }
  .heroe-zona .pipo { width: 22dvh; }
  .mi-belen { width: 30dvh; padding: 6px; }
  .mi-belen img { max-height: 11dvh; }
  .juegos { width: min(100%, 720px); }
  .juego-btn .art { width: 58%; }
}
