@font-face {
  font-family: 'Gelasio';
  src: url('../fuentes/Gelasio.ttf') format('truetype');
  font-display: swap;
}

:root {
  --noche: #1b1838;
  --tinta: #120c1e;
  --papel: #f6efd6;
  --oro: #f2b84b;
  --rojo: #c8324a;
  --magenta: #b3245c;
}

* { box-sizing: border-box; }

html, body { margin: 0; background: var(--tinta); color: var(--papel); font-family: 'Gelasio', Georgia, serif; }

#mundo {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  z-index: 0;
}

#idioma {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10;
  font: bold 14px 'Gelasio', Georgia, serif;
  color: var(--tinta);
  background: var(--oro);
  border: 3px solid var(--tinta);
  box-shadow: 3px 3px 0 var(--tinta);
  padding: 6px 12px;
  cursor: pointer;
}
#idioma:focus-visible { outline: 3px solid var(--papel); outline-offset: 2px; }

main { position: relative; z-index: 1; }

.tramo {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 16px max(16px, 5vw);
  position: relative;
}

/* Globo de texto del Diablito: borde de carta de Lotería */
.globo {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 560px;
  width: 100%;
  padding: 16px 20px 16px 8px;
  background: var(--papel);
  color: var(--tinta);
  border: 4px solid var(--tinta);
  outline: 3px solid var(--rojo);
  outline-offset: -10px;
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.6);
}
/* Solo con la escena 3D lista los globos se esconden y entran en su parada; sin JS o sin 3D se ven siempre */
.con-3d .globo {
  opacity: 0;
  transform: translateY(40px) rotate(-1.5deg);
  transition: opacity 0.35s ease, transform 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.con-3d .parada.activa .globo { opacity: 1; transform: none; }

.diablito {
  width: 150px;
  height: 150px;
  flex: none;
  image-rendering: pixelated;
}

.texto h2 { margin: 0 0 6px; font-size: clamp(20px, 2.4vw, 28px); color: var(--magenta); }
.texto p { margin: 0; font-size: clamp(15px, 1.4vw, 18px); line-height: 1.45; }
.logo {
  margin: 0 0 4px;
  font-size: clamp(30px, 4vw, 48px);
  letter-spacing: 1px;
  color: var(--rojo);
  text-shadow: 2px 2px 0 var(--tinta);
}

.sigue {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  color: var(--oro);
  font-size: 14px;
  letter-spacing: 2px;
  text-transform: uppercase;
  animation: rebote 1.4s ease-in-out infinite;
}
.sigue::after { content: ' ▼'; }
@keyframes rebote { 50% { transform: translate(-50%, 8px); } }

@media (max-width: 767px) {
  .tramo { align-items: flex-end; justify-content: center; padding-bottom: 72px; }
  .globo { padding: 12px 14px 12px 4px; }
  .diablito { width: 104px; height: 104px; }
}

/* Parada 5: el globo y debajo el marco del juego */
#parada-5 { flex-direction: column; justify-content: center; align-items: center; gap: 20px; }
#marco-juego {
  position: relative;
  width: min(940px, 100%);
  padding: 12px 12px 8px;
  background: var(--papel);
  border: 4px solid var(--tinta);
  outline: 3px solid var(--rojo);
  outline-offset: -10px;
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.6);
  transition: opacity 0.4s ease;
}
.con-3d #marco-juego { opacity: 0; }
.con-3d #parada-5.activa #marco-juego, .con-3d #marco-juego.cargado { opacity: 1; }
#marco-juego .numero { position: absolute; top: 14px; left: 20px; z-index: 1; font-weight: bold; color: var(--tinta); }
#marco-juego .pantalla {
  position: relative;
  aspect-ratio: 915 / 412;
  margin-top: 22px;
  background: var(--tinta);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}
#marco-juego .muerte { width: 96px; height: auto; image-rendering: pixelated; }
#marco-juego iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
#jugar {
  font: bold clamp(20px, 3vw, 32px) 'Gelasio', Georgia, serif;
  color: var(--tinta);
  background: var(--oro);
  border: 4px solid var(--papel);
  box-shadow: 4px 4px 0 var(--rojo);
  padding: 10px 28px;
  cursor: pointer;
}
#jugar:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--rojo); }
#jugar:focus-visible, #pantalla-completa:focus-visible { outline: 3px solid var(--rojo); outline-offset: 3px; }
#marco-juego .pie {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 6px 0 2px;
  color: var(--tinta);
  font-weight: bold;
  letter-spacing: 3px;
}
#pantalla-completa {
  font: 13px 'Gelasio', Georgia, serif;
  background: var(--tinta);
  color: var(--papel);
  border: 0;
  padding: 4px 10px;
  cursor: pointer;
  letter-spacing: 0;
}
.gira { display: none; }
@media (max-width: 767px) and (orientation: portrait) {
  .gira { display: block; position: absolute; bottom: 6px; left: 0; right: 0; margin: 0; text-align: center; font-size: 12px; color: var(--oro); }
  #marco-juego .muerte { width: 56px; }
  #parada-5 { justify-content: flex-end; }
}

/* Versión estática: cada tramo con su ilustración de fondo y unas cartas quietas */
.estatico #mundo { display: none; }
.estatico .tramo { overflow: hidden; isolation: isolate; }
.estatico .globo { opacity: 1; transform: none; }
.ilustracion {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
  z-index: -1;
}
.carta-deco {
  position: absolute;
  width: 72px;
  image-rendering: pixelated;
  z-index: -1;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.5);
}

@media (prefers-reduced-motion: reduce) {
  .globo, .sigue { transition: none; animation: none; }
}
