/* -------------------------------------------------------------
   ESTILOS DE MINI JUEGO "NUESTRA HISTORIA"
   Elegante, responsivo y adaptado a la estética de la boda.
   ------------------------------------------------------------- */

/* IMPORTACIÓN DE FUENTES */
@import url('https://fonts.googleapis.com/css2?family=Alex+Brush&family=Cormorant+Garamond:ital,wght@0,300;0,400;0,600;0,700;1,400&family=Montserrat:wght@300;400;500;600&display=swap');

:root {
  --color-fuchsia: #d53369;
  --color-orange: #f26419;
  --color-yellow: #f6ae2d;
  --color-lilac: #a044b3;
  --color-green: #7a9a60;
  --color-blue: #4f86c6;

  /* Fondos elegantes */
  --bg-game-main: #fcf8f2; /* Crema/beige */
  --bg-court: #587c47;    /* Verde cancha de tenis */
  --bg-sky-sunset: linear-gradient(to bottom, #2a1b54, #7f3a7a, #d35252, #f8a26c);

  --color-primary: #8a2387;
  --color-primary-light: #b224ef;
  --color-accent-gold: #cba358;
  --color-text-dark: #3c3c3c;
  --color-text-light: #fefefe;
  --color-text-muted: #767676;

  --font-script: 'Alex Brush', cursive;
  --font-serif: 'Cormorant Garamond', serif;
  --font-sans: 'Montserrat', sans-serif;

  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-polaroid: 0 8px 16px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* RESET E HIGIENE */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background-color: #eae3db;
  color: var(--color-text-dark);
  line-height: 1.5;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding: 0;
}

/* WRAPPER MÓVIL CENTRADO (Consistencia total) */
.invitation-wrapper {
  width: 100%;
  max-width: 480px;
  background-color: var(--bg-game-main);
  min-height: 100vh;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.15);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

@media screen and (min-width: 768px) {
  body {
    padding: 30px 0;
  }
  .invitation-wrapper {
    border-radius: 24px;
    min-height: calc(100vh - 60px);
    height: auto;
  }
}

/* CABECERA Y RETORNO */
.game-header {
  padding: 15px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(138, 35, 135, 0.08);
  background-color: #ffffff;
  z-index: 50;
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--color-primary);
  text-decoration: none;
  transition: var(--transition-smooth);
}

.btn-back:hover {
  color: var(--color-primary-light);
  transform: translateX(-3px);
}

.back-icon {
  width: 14px;
  height: 14px;
}

/* BARRA DE PROGRESO DISCRETA */
.game-progress {
  display: flex;
  gap: 8px;
}

.progress-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: #e0e0e0;
  transition: var(--transition-smooth);
  position: relative;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.progress-dot.active {
  background-color: var(--color-yellow); /* Pelota de tenis color */
  box-shadow: 0 0 8px var(--color-yellow);
  transform: scale(1.15);
}

.progress-dot.completed {
  background-color: var(--color-green);
  box-shadow: 0 0 8px var(--color-green);
}

/* CONTENEDOR DE CAPÍTULOS */
.game-canvas {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

.chapter-slide {
  display: none;
  flex-direction: column;
  padding: 20px 20px;
  animation: fadeIn 0.4s ease;
}

.chapter-slide.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.chapter-content {
  text-align: center;
  margin-bottom: 10px;
  z-index: 10;
}

.chapter-tag {
  font-family: var(--font-serif);
  font-size: 0.85rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--color-accent-gold);
  font-weight: 600;
  display: block;
  margin-bottom: 4px;
}

.chapter-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-primary);
  margin-bottom: 6px;
}

.chapter-hint {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-weight: 500;
  letter-spacing: 0.5px;
}

.action-footer {
  margin-top: 0;
  padding-top: 10px;
  text-align: center;
  z-index: 20;
}

.btn-game-next {
  width: 100%;
  max-width: 260px;
  padding: 12px 24px;
  border-radius: 25px;
  border: none;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  color: var(--color-text-light);
  box-shadow: 0 4px 10px rgba(138, 35, 135, 0.15);
  transition: var(--transition-smooth);
}

.btn-game-next:disabled {
  background: #dcdcdc;
  color: #a0a0a0;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-game-next:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(138, 35, 135, 0.25);
}

/* -------------------------------------------------------------
   ELEMENTOS DE CAPÍTULO 1: LA CANCHA DE TENIS
   ------------------------------------------------------------- */
.tennis-court {
  width: 100%;
  height: 260px;
  background-color: var(--bg-court);
  border-radius: 16px;
  border: 4px solid #ffffff;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.2);
  margin: 10px 0;
}

.tennis-court::before {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 20px;
  right: 20px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  pointer-events: none;
}

.court-net {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  background-color: rgba(255, 255, 255, 0.75);
  border-left: 2px dashed #333333;
}

/* Jugadores en Cancha */
.character-player {
  position: absolute;
  width: 60px;
  height: 90px;
  top: 85px;
  z-index: 10;
  transition: transform 0.2s ease;
}

.bride-player {
  left: 30px;
}

.groom-player {
  right: 30px;
  transform: scaleX(-1); /* Voltear para enfrentar */
}

.groom-player img {
  transform: scaleX(1); /* Evitar voltear el interior */
}

.character-player img {
  width: 100%;
  height: 100%;
}

.racket-swing {
  position: absolute;
  width: 25px;
  height: 50px;
  top: 20px;
  transition: transform 0.15s ease;
  pointer-events: none;
}

.bride-player .racket-swing {
  left: 45px;
  transform-origin: bottom left;
}

.groom-player .racket-swing {
  right: 45px;
  transform-origin: bottom right;
}

.racket-swing img {
  width: 100%;
  height: 100%;
}

/* Animación de golpeo de raqueta */
.swing-active .racket-swing {
  transform: rotate(60deg);
}

.groom-player.swing-active .racket-swing {
  transform: rotate(-60deg);
}

/* Pelota de Tenis Interactiva */
.interactive-ball {
  position: absolute;
  width: 48px;
  height: 48px;
  top: 98px;
  left: 28px;
  z-index: 20;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.interactive-ball img {
  width: 24px;
  height: 24px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
  animation: pulse-glow 1.5s infinite alternate;
  pointer-events: none;
}

@keyframes pulse-glow {
  from { filter: drop-shadow(0 0 2px var(--color-yellow)); }
  to { filter: drop-shadow(0 0 8px var(--color-yellow)); }
}

/* -------------------------------------------------------------
   ELEMENTOS DE CAPÍTULO 2: COLLAGE POLAROID
   ------------------------------------------------------------- */
.polaroid-collage-area {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 15px;
  margin: 15px 0;
  perspective: 1000px;
}

.polaroid-game-card {
  width: 110px;
  height: 140px;
  cursor: pointer;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.polaroid-game-card.flipped {
  transform: rotateY(180deg) scale(1.05);
}

/* Posiciones y rotaciones aleatorias sutiles */
.polaroid-game-card:nth-child(1) { transform: rotate(-3deg); }
.polaroid-game-card:nth-child(2) { transform: rotate(4deg); }
.polaroid-game-card:nth-child(3) { transform: rotate(-2deg); }
.polaroid-game-card:nth-child(4) { transform: rotate(3deg); }
.polaroid-game-card:nth-child(5) { transform: rotate(-1deg); }

.polaroid-game-card.flipped:nth-child(1) { transform: rotateY(180deg) rotate(-2deg); }
.polaroid-game-card.flipped:nth-child(2) { transform: rotateY(180deg) rotate(1deg); }
.polaroid-game-card.flipped:nth-child(3) { transform: rotateY(180deg) rotate(-1deg); }
.polaroid-game-card.flipped:nth-child(4) { transform: rotateY(180deg) rotate(2deg); }
.polaroid-game-card.flipped:nth-child(5) { transform: rotateY(180deg) rotate(0deg); }

.polaroid-inner {
  position: absolute;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
}

.polaroid-front, .polaroid-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 4px;
  box-shadow: var(--shadow-polaroid);
  border: 1px solid rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
}

.polaroid-front {
  background: #fca5b7; /* Rojo claro / Rosa suave de marca */
  align-items: center;
  justify-content: center;
}

.polaroid-front .polaroid-q {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  color: #ffffff;
  opacity: 0.6;
}

.polaroid-back {
  background: #ffffff;
  padding: 6px 6px 14px 6px;
  transform: rotateY(180deg);
}

.polaroid-back img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.polaroid-caption {
  font-family: var(--font-serif);
  font-size: 0.62rem;
  font-weight: bold;
  text-align: center;
  color: var(--color-text-dark);
  margin-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Corazón flotante al activar */
.floating-heart {
  position: absolute;
  width: 20px;
  height: 20px;
  pointer-events: none;
  z-index: 100;
  animation: floatUp 1.2s ease-out forwards;
}

@keyframes floatUp {
  0% { transform: translateY(0) scale(0.8) rotate(0deg); opacity: 1; }
  100% { transform: translateY(-80px) scale(1.3) rotate(15deg); opacity: 0; }
}

/* -------------------------------------------------------------
   ELEMENTOS DE CAPÍTULO 3: LIENZO DE LA CONSTELACIÓN
   ------------------------------------------------------------- */
.constellation-canvas {
  width: 100%;
  height: 280px;
  background-color: #0b0f19; /* Cielo nocturno oscuro */
  background-image: radial-gradient(circle at 50% 50%, #161e33 0%, #0b0f19 70%);
  border: 2px solid var(--color-accent-gold);
  border-radius: 16px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 25px rgba(0,0,0,0.8);
  margin: 10px 0;
}

/* SVG para las líneas */
.constellation-lines-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

.constellation-line-draw {
  stroke: rgba(253, 218, 190, 0.7); /* Oro/Beige suave */
  stroke-width: 2.5;
  stroke-linecap: round;
  filter: drop-shadow(0 0 8px rgba(253, 218, 190, 0.9));
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: drawLine 0.8s ease-out forwards;
}

@keyframes drawLine {
  to {
    stroke-dashoffset: 0;
  }
}

/* Iniciales M ♥ B */
.constellation-initials {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  font-family: var(--font-script);
  font-size: 3.8rem;
  color: var(--color-accent-gold);
  text-shadow: 0 0 20px rgba(203, 163, 88, 0.8), 0 0 40px rgba(138, 35, 135, 0.6);
  opacity: 0;
  pointer-events: none;
  z-index: 8;
  transition: opacity 1.5s ease-out, transform 1.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  white-space: nowrap; /* Evita que la B se vaya abajo en pantallas chicas */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.constellation-initials.revealed {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  animation: initialsBeatGlow 2s ease-in-out infinite alternate;
}

@keyframes initialsBeatGlow {
  0% {
    transform: translate(-50%, -50%) scale(1);
    text-shadow: 0 0 20px rgba(203, 163, 88, 0.8), 0 0 40px rgba(138, 35, 135, 0.6);
  }
  100% {
    transform: translate(-50%, -50%) scale(1.05);
    text-shadow: 0 0 30px rgba(253, 218, 190, 0.9), 0 0 50px rgba(138, 35, 135, 0.8);
  }
}

/* Mensaje romántico final */
.constellation-message {
  position: absolute;
  top: 22%; /* Posicionado arriba de las iniciales */
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-serif);
  font-size: 0.9rem;
  font-style: italic;
  font-weight: 500;
  color: #ffffff;
  text-align: center;
  width: 90%;
  opacity: 0;
  transition: opacity 1.5s ease-out;
  z-index: 8;
  text-shadow: 0 0 10px rgba(138, 35, 135, 0.8);
}

.constellation-message.revealed {
  opacity: 0.9;
}

/* Estrellas flotantes */
.constellation-star {
  position: absolute;
  width: 28px;
  height: 28px;
  cursor: pointer;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.constellation-star::before {
  content: "✦";
  font-size: 1.5rem;
  color: rgba(255, 255, 255, 0.8);
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.8));
  animation: starTwinkle 1.8s ease-in-out infinite alternate;
  display: block;
}

.constellation-star:hover {
  transform: scale(1.3);
}

.constellation-star.active::before {
  color: var(--color-accent-gold);
  filter: drop-shadow(0 0 10px var(--color-accent-gold));
  animation: starActiveTwinkle 0.8s ease-in-out infinite alternate;
}

@keyframes starTwinkle {
  0% { transform: scale(0.9); opacity: 0.6; }
  100% { transform: scale(1.15); opacity: 1; }
}

@keyframes starActiveTwinkle {
  0% { transform: scale(1.1); filter: drop-shadow(0 0 8px var(--color-accent-gold)); }
  100% { transform: scale(1.3); filter: drop-shadow(0 0 16px var(--color-accent-gold)); }
}

/* Partículas/Polvo estelar */
.stardust-particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background-color: #ffffff;
  border-radius: 50%;
  pointer-events: none;
  z-index: 7;
  animation: fadeOutParticle 1.5s ease-out forwards;
}

@keyframes fadeOutParticle {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 0.9;
  }
  100% {
    transform: translate(var(--dx), var(--dy)) scale(0.2);
    opacity: 0;
  }
}

/* -------------------------------------------------------------
   ELEMENTOS DE CAPÍTULO 4: LA PREGUNTA
   ------------------------------------------------------------- */
.proposal-scene {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  padding: 5px 0;
  gap: 10px;
}

.proposal-couple {
  width: 100%;
  max-width: 320px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-polaroid);
  border: 3px solid #ffffff;
  aspect-ratio: 4/3;
  margin-bottom: 20px;
}

.proposal-couple img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.proposal-question-box {
  background: white;
  padding: 20px 25px;
  border-radius: 18px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.06);
  border: 1px solid rgba(231, 92, 116, 0.15);
  text-align: center;
  width: 100%;
  max-width: 340px;
}

.question-text {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 15px;
}

/* -------------------------------------------------------------
   ELEMENTOS DE CAPÍTULO 5: LA CELEBRACIÓN
   ------------------------------------------------------------- */
.final-celebration {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-grow: 1;
  padding: 10px 0;
  text-align: center;
  position: relative;
}

.emotion-title {
  font-family: var(--font-script);
  font-size: 3.5rem;
  color: var(--color-fuchsia);
  margin-bottom: 15px;
}

.final-couple-photo {
  width: 100%;
  max-width: 260px;
  aspect-ratio: 1 / 1; /* Hace que se vea cuadrada */
  border-radius: 15px;
  overflow: hidden;
  box-shadow: var(--shadow-polaroid);
  border: 3px solid #ffffff;
  margin-bottom: 20px;
  animation: heartBeat 2s infinite alternate;
}

@keyframes heartBeat {
  from { transform: scale(1); }
  to { transform: scale(1.02); }
}

.final-couple-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.final-message-box {
  background: rgba(255, 255, 255, 0.7);
  border-radius: 16px;
  padding: 20px;
  border: 1px solid rgba(203, 163, 88, 0.2);
  width: 100%;
  max-width: 340px;
  margin-bottom: 20px;
}

.final-lead {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--color-text-dark);
}

.final-couple-names {
  font-family: var(--font-serif);
  font-size: 2.1rem;
  font-weight: bold;
  color: var(--color-primary);
  margin: 10px 0 5px 0;
  letter-spacing: 1px;
}

.final-wedding-date {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--color-accent-gold);
  border-bottom: 1px solid rgba(203, 163, 88, 0.2);
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.final-sub {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 2px;
  color: var(--color-fuchsia);
  text-transform: uppercase;
}

.btn-finish {
  width: 100%;
  max-width: 280px;
}

/* Confeti Animación */
.confetti-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}

.confetti-piece {
  position: absolute;
  width: 8px;
  height: 8px;
  background-color: var(--color-fuchsia);
  opacity: 0.7;
  animation: fallDown 3s linear infinite;
  border-radius: 50%;
}

@keyframes fallDown {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(500px) rotate(360deg); opacity: 0; }
}

/* -------------------------------------------------------------
   SISTEMA DE MÚSICA - BOTÓN FLOTANTE (ESTILO DE LA PORTADA)
   ------------------------------------------------------------- */
.music-player-fab {
  position: fixed;
  bottom: 25px;
  left: 25px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background-color: #ffffff;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 999;
  transition: var(--transition-smooth);
  border: 1px solid rgba(138, 35, 135, 0.15);
}

.music-player-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.music-icon-svg {
  width: 24px;
  height: 24px;
  color: var(--color-primary);
  transition: var(--transition-smooth);
}

.music-playing .music-icon-svg {
  animation: spin 3s linear infinite;
}

.music-waves {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 1px solid rgba(138, 35, 135, 0.3);
  pointer-events: none;
  opacity: 0;
  transform: scale(1);
}

.music-playing .music-waves-1 {
  animation: pulse-wave 2s infinite linear;
}

.music-playing .music-waves-2 {
  animation: pulse-wave 2s infinite linear 1s;
}

@keyframes pulse-wave {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* Botón Descubrirlo Llamativo */
.btn-discover-proposal {
  background: linear-gradient(135deg, var(--color-fuchsia), var(--color-primary));
  color: #ffffff;
  border: 2px solid var(--color-accent-gold);
  border-radius: 30px;
  padding: 12px 30px;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: bold;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 0 15px rgba(138, 35, 135, 0.4), 0 0 5px var(--color-accent-gold);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  animation: pulseButton 1.8s infinite;
  display: inline-block;
  outline: none;
}

.btn-discover-proposal:hover {
  transform: scale(1.06);
  box-shadow: 0 0 25px rgba(138, 35, 135, 0.6), 0 0 10px var(--color-accent-gold);
  background: linear-gradient(135deg, var(--color-primary), var(--color-fuchsia));
}

@keyframes pulseButton {
  0% {
    transform: scale(1);
    box-shadow: 0 0 12px rgba(138, 35, 135, 0.4), 0 0 4px var(--color-accent-gold);
  }
  50% {
    transform: scale(1.04);
    box-shadow: 0 0 20px rgba(138, 35, 135, 0.6), 0 0 10px var(--color-accent-gold);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 12px rgba(138, 35, 135, 0.4), 0 0 4px var(--color-accent-gold);
  }
}
