/* Pantalla del día: presentación, juego a pantalla completa, apertura y derrota. */

.dia {
  min-height: calc(100dvh - var(--seguro-arriba) - var(--seguro-abajo) - var(--alto-banda));
}

.tarjeta {
  padding: 18px;
  border-radius: var(--radio);
  background: var(--crema);
  color: var(--texto-papel);
  box-shadow: var(--sombra);
}

.tarjeta-antetitulo {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--rojo);
}

.tarjeta-titulo {
  margin-top: 2px;
  font-size: 1.35rem;
  font-weight: 900;
}

.tarjeta-texto {
  margin-top: 8px;
}

.nota-ayuda {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radio-pequeno);
  background: rgba(116, 165, 127, 0.18);
  color: #1f4d39;
  font-weight: 700;
  font-size: 0.95rem;
}

.nota-ayuda-grande {
  background: rgba(116, 165, 127, 0.22);
  color: var(--nieve);
  box-shadow: inset 0 0 0 2px rgba(116, 165, 127, 0.55);
}

.nota-mejor {
  margin-top: 10px;
  font-weight: 700;
  color: var(--madera);
}

.dia-premio > .nota-mejor,
.dia-derrota .nota-mejor {
  color: var(--texto-suave);
  text-align: center;
}

/* ——— Juego a pantalla completa ——— */

.capa-juego {
  position: fixed;
  z-index: 50;
  /* Dentro de la zona segura: con la barra de estado translúcida de iOS no queda bajo la hora. */
  top: var(--seguro-arriba);
  left: var(--seguro-izq);
  width: calc(100vw - var(--seguro-izq) - var(--seguro-der));
  height: calc(100vh - var(--seguro-arriba) - var(--seguro-abajo));
  height: calc(100dvh - var(--seguro-arriba) - var(--seguro-abajo));
  background: var(--noche);
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.lienzo-juego {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* Botones del modo ensayo (solo se crean en ensayo) */
.ensayo-botones {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 2;
}

.boton-ensayo {
  min-width: 96px;
  background: var(--oro);
  color: var(--carbon);
  box-shadow: 0 0 0 3px var(--carbon), var(--sombra);
  touch-action: manipulation;
}

.boton-ensayo-perder {
  background: var(--hielo);
}

body.con-ensayo .capa-juego {
  top: calc(32px + var(--seguro-arriba));
  height: calc(100vh - 32px - var(--seguro-arriba) - var(--seguro-abajo));
  height: calc(100dvh - 32px - var(--seguro-arriba) - var(--seguro-abajo));
}

/* En ensayo, el lienzo deja abajo una franja de 64 px para «Ganar/Perder»:
   así los botones no tapan el juego (en 320×568 tapaban la última fila del memory). */
.capa-juego-ensayo .lienzo-juego {
  height: calc(100% - 64px);
}

.capa-juego-ensayo .ensayo-botones {
  bottom: 8px;
}

/* Móvil girado: el juego encaja 360×640 con bandas y quedaría diminuto. */
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  .capa-juego::after {
    content: "Gira el móvil para jugar";
    position: absolute;
    inset: 0;
    z-index: 3;
    display: grid;
    place-items: center;
    padding: 16px;
    text-align: center;
    font-weight: 800;
    font-size: 1.25rem;
    background: var(--noche);
    color: var(--nieve, var(--crema));
  }
}

/* ——— Apertura de la casilla ——— */

.apertura {
  gap: 24px;
}

.apertura-casilla {
  position: relative;
  width: 180px;
  height: 196px;
  perspective: 700px;
}

.apertura-dentro {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: radial-gradient(circle, var(--oro-claro) 0%, var(--oro) 60%, var(--madera) 100%);
  box-shadow: 0 0 40px 10px rgba(233, 180, 76, 0.6);
}

.apertura-icono {
  width: 96px;
  height: 96px;
  animation: asomar 0.8s 0.9s ease-out both;
}

.apertura-puerta {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  display: grid;
  place-items: center end;
  background: linear-gradient(180deg, var(--noche2), #18284a);
  box-shadow: inset 0 0 0 3px rgba(233, 180, 76, 0.5);
  backface-visibility: hidden;
  animation-duration: 1.1s;
  animation-delay: 0.35s;
  animation-timing-function: cubic-bezier(0.5, 0, 0.3, 1.2);
  animation-fill-mode: both;
}

.apertura-izquierda {
  left: 0;
  border-radius: 22px 0 0 22px;
  transform-origin: left center;
  animation-name: abrir-izquierda;
}

.apertura-izquierda span {
  margin-right: -0.32em;
  font-size: 4rem;
  font-weight: 900;
  color: var(--oro);
}

.apertura-derecha {
  right: 0;
  border-radius: 0 22px 22px 0;
  transform-origin: right center;
  animation-name: abrir-derecha;
  overflow: hidden;
}

.apertura-chispas span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--oro-claro);
  opacity: 0;
  animation: chispa 1s 1s ease-out both;
}

.apertura-chispas span:nth-child(1) { --dx: -110px; --dy: -80px; }
.apertura-chispas span:nth-child(2) { --dx: 110px; --dy: -70px; background: var(--rosa); }
.apertura-chispas span:nth-child(3) { --dx: -120px; --dy: 40px; background: var(--hielo); }
.apertura-chispas span:nth-child(4) { --dx: 120px; --dy: 60px; }
.apertura-chispas span:nth-child(5) { --dx: 0px; --dy: -130px; background: var(--rosa); }
.apertura-chispas span:nth-child(6) { --dx: -60px; --dy: 120px; }
.apertura-chispas span:nth-child(7) { --dx: 70px; --dy: 120px; background: var(--hielo); }
.apertura-chispas span:nth-child(8) { --dx: 0px; --dy: 140px; }

.apertura-texto {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--oro);
  animation: asomar 0.5s 1.2s ease-out both;
}

@keyframes abrir-izquierda {
  from { transform: rotateY(0deg); }
  to { transform: rotateY(-115deg); }
}

@keyframes abrir-derecha {
  from { transform: rotateY(0deg); }
  to { transform: rotateY(115deg); }
}

@keyframes asomar {
  from { opacity: 0; transform: scale(0.5); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes chispa {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.3); }
}

.premio-recien .premio {
  animation: asomar 0.45s ease-out both;
}
