/* ==========================================================
   Carta Digital — Para Evelin (10 Meses)
   Revisión 01: Basílica con cruz única, explanada con perspectiva,
   personajes naturales, sobre interactivo y carta editorial.
   ========================================================== */

:root {
  --bg-night-1: #0f0a1c;
  --bg-night-2: #1e1333;
  --bg-night-3: #381e48;
  --bg-sunset: #833e60;
  --bg-glow: #e88d75;

  --gold-warm: #ffd166;
  --gold-matte: #ecd399;
  --gold-glow: rgba(255, 209, 102, 0.45);
  --pink-blush: #f4b8c5;
  --pink-deep: #c82352;
  --pink-glow: rgba(244, 114, 142, 0.4);

  --paper-ivory: #fcf8f2;
  --paper-border-gold: rgba(212, 163, 115, 0.45);
  --paper-border-pink: rgba(200, 92, 122, 0.28);
  --ink-primary: #2c1f1a;
  --ink-body: #3c2d26;
  --ink-muted: #7d6356;
  --ink-accent: #a33852;

  --font-serif: "Georgia", "Cambria", "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-night-1);
  font-family: var(--font-sans);
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 500px;
  margin: 0 auto;
  overflow: hidden;
  background: linear-gradient(180deg, var(--bg-night-1) 0%, var(--bg-night-2) 35%, var(--bg-night-3) 65%, var(--bg-sunset) 88%, var(--bg-glow) 100%);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.85);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Audio nativo HTML5 en background */
#bg-audio {
  display: none;
}

/* ==========================================================
   Canvas de Partículas Ambientales (Pétalos de rosa y polvo dorado)
   ========================================================== */
#ambient-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 15;
}

/* ==========================================================
   Pantalla de Inicio / Tap inicial
   ========================================================== */
.overlay-screen {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at center, rgba(32, 19, 48, 0.95) 0%, rgba(13, 8, 22, 0.98) 100%);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease;
}

.overlay-screen.active {
  opacity: 1;
  pointer-events: auto;
}

.start-card {
  text-align: center;
  padding: 34px 26px;
  max-width: 86%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 209, 102, 0.28);
  border-radius: 28px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55), 0 0 35px rgba(244, 184, 197, 0.15);
  animation: floatStartCard 4s ease-in-out infinite alternate;
}

@keyframes floatStartCard {
  0% { transform: translateY(0); }
  100% { transform: translateY(-7px); }
}

.start-icon {
  font-size: 3rem;
  margin-bottom: 10px;
  animation: pulseIcon 2s ease-in-out infinite;
}

@keyframes pulseIcon {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.14); }
}

.start-title {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 12px rgba(244, 184, 197, 0.4);
  margin-bottom: 16px;
}

.start-subtitle {
  font-size: 0.92rem;
  color: rgba(255, 240, 245, 0.85);
  line-height: 1.45;
  margin-bottom: 16px;
}

.music-status-badge {
  display: inline-block;
  font-size: 0.82rem;
  color: var(--gold-warm);
  background: rgba(255, 209, 102, 0.12);
  border: 1px solid rgba(255, 209, 102, 0.25);
  padding: 4px 14px;
  border-radius: 20px;
  margin-bottom: 22px;
}

.start-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.btn-glow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 28px;
  background: linear-gradient(135deg, #f48fb1 0%, #c82352 100%);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(200, 35, 82, 0.45);
  transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.25s ease;
  min-width: 230px;
}

.btn-glow:hover:not(:disabled), .btn-glow:focus-visible:not(:disabled) {
  transform: scale(1.04);
  box-shadow: 0 10px 30px rgba(200, 35, 82, 0.65);
  outline: 3px solid var(--gold-warm);
  outline-offset: 3px;
}

.btn-glow:disabled {
  opacity: 0.58;
  cursor: not-allowed;
  background: linear-gradient(135deg, #6c4b5e 0%, #3e2837 100%);
  box-shadow: none;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.75);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 22px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 209, 102, 0.35);
  color: var(--gold-warm);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.25s ease;
}

.btn-secondary:hover, .btn-secondary:focus-visible {
  background: rgba(255, 209, 102, 0.18);
  color: #fff;
  transform: translateY(-2px);
  outline: 2px solid var(--gold-warm);
  outline-offset: 2px;
}

.start-hint {
  margin-top: 18px;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.52);
  font-style: italic;
}

/* ==========================================================
   Botón Flotante de Música y Feedback Accesible
   ========================================================== */
.music-toggle {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  font-size: 1.15rem;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  z-index: 40;
  transition: transform 0.2s, background 0.2s, opacity 0.5s;
}

.music-toggle:focus-visible {
  outline: 3px solid var(--gold-warm);
  outline-offset: 3px;
}

.music-toggle.hidden {
  opacity: 0;
  pointer-events: none;
}

.music-toggle.playing .music-note {
  animation: bounceNote 1.4s ease-in-out infinite;
}

@keyframes bounceNote {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-3px) rotate(12deg); }
}

.music-feedback {
  position: absolute;
  top: 70px;
  right: 16px;
  background: rgba(20, 14, 28, 0.88);
  border: 1px solid rgba(255, 209, 102, 0.35);
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 0.8rem;
  color: var(--gold-warm);
  max-width: 240px;
  text-align: right;
  z-index: 40;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  transition: opacity 0.4s ease;
}

.music-feedback.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ==========================================================
   Escena del Mundo: Basílica y Cielo
   ========================================================== */
.scene-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  transition: filter 1.2s ease, opacity 1s ease;
}

.scene-stage.dimmed {
  filter: blur(3px) brightness(0.65);
}

/* Cielo y Luna */
.night-sky {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 55%;
  pointer-events: none;
}

.moon {
  position: absolute;
  top: 32px;
  right: 44px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  box-shadow: 8px 6px 0 0 #fff3cc;
  filter: drop-shadow(0 0 14px rgba(255, 243, 204, 0.75));
  animation: moonGlow 6s ease-in-out infinite alternate;
}

@keyframes moonGlow {
  0% { filter: drop-shadow(0 0 8px rgba(255, 243, 204, 0.5)); }
  100% { filter: drop-shadow(0 0 18px rgba(255, 243, 204, 0.95)); }
}

/* Basílica */
.basilica-container {
  position: absolute;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%);
  width: 130%;
  max-width: 650px;
  pointer-events: none;
  z-index: 2;
}

.basilica-svg {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 12px 32px rgba(0, 0, 0, 0.45));
}

/* Explanada / Calle con Adoquinado Gris Bonito */
.ground-plaza {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 135px;
  background: #121418;
  border-top: 2px solid #4a515c;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.55);
  z-index: 3;
  overflow: hidden;
}

.ground-cobblestones-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.ground-glow-center {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 320px;
  height: 70px;
  background: radial-gradient(ellipse at top, rgba(255, 222, 140, 0.38) 0%, rgba(255, 195, 100, 0.12) 45%, transparent 75%);
  pointer-events: none;
}

/* ==========================================================
   Pareja: Hombre y Mujer
   ========================================================== */
.couple-stage {
  position: absolute;
  bottom: 45px;
  left: 50%;
  transform: translateX(-50%);
  width: 280px;
  height: 160px;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  z-index: 5;
}

.character {
  position: absolute;
  bottom: 0;
  width: 88px;
  height: 140px;
  transition: transform 1.8s cubic-bezier(0.25, 1, 0.5, 1);
}

.character-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.char-man {
  left: 10px;
  transform: translateX(0);
}

.char-woman {
  right: 10px;
  transform: translateX(0);
}

.char-man.walking {
  animation: manWalkCycle 0.5s ease-in-out infinite alternate;
}

.char-woman.walking {
  animation: womanWalkCycle 0.5s ease-in-out infinite alternate;
}

@keyframes manWalkCycle {
  0% { transform: translateY(0); }
  100% { transform: translateY(-4px); }
}

@keyframes womanWalkCycle {
  0% { transform: translateY(0); }
  100% { transform: translateY(-4px); }
}

.char-man.at-center {
  transform: translateX(38px);
}

.char-woman.at-center {
  transform: translateX(-38px);
}

.char-man.kissing {
  transform: translateX(47px) rotate(4deg);
}

.char-woman.kissing {
  transform: translateX(-47px) rotate(-4deg);
}

.blush-man, .blush-woman {
  opacity: 0;
  transition: opacity 0.8s ease;
}

.kissing .blush-man, .kissing .blush-woman {
  opacity: 1;
}

/* Chispitas del Beso */
.kiss-sparks {
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

.kiss-sparks.active {
  opacity: 1;
}

.spark {
  display: inline-block;
  font-size: 1.4rem;
  animation: sparkFloat 1.2s ease-in-out infinite alternate;
}

.spark.s1 { animation-delay: 0s; }
.spark.s2 { animation-delay: 0.3s; font-size: 1.8rem; }
.spark.s3 { animation-delay: 0.6s; }

@keyframes sparkFloat {
  0% { transform: translateY(0) scale(0.9); }
  100% { transform: translateY(-10px) scale(1.2); }
}

/* ==========================================================
   Fase 2 y 3: Corazón Luminoso y Sobre Interactivo
   ========================================================== */
.envelope-stage {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 20;
  transition: opacity 0.8s ease;
}

.envelope-stage.hidden {
  display: none;
}

/* Corazón Mágico */
.morph-heart {
  position: absolute;
  top: 55%;
  left: 50%;
  width: 60px;
  height: 60px;
  transform: translate(-50%, -50%) scale(0.2);
  opacity: 0;
  pointer-events: none;
  transition: transform 1.6s cubic-bezier(0.34, 1.56, 0.64, 1), top 1.6s ease, opacity 0.8s ease;
}

.morph-heart.emerged {
  opacity: 1;
  top: 42%;
  transform: translate(-50%, -50%) scale(1.6);
  animation: heartbeat 1.1s ease-in-out infinite;
}

@keyframes heartbeat {
  0%, 100% { transform: translate(-50%, -50%) scale(1.5); }
  30% { transform: translate(-50%, -50%) scale(1.75); }
  60% { transform: translate(-50%, -50%) scale(1.58); }
}

.heart-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 25px rgba(255, 64, 129, 0.85));
}

.morph-heart.vanish {
  opacity: 0;
  transform: translate(-50%, -50%) scale(2.4);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

/* ==========================================================
   Fase 3: Sobre Interactivo y Hermético (Sin fugas de carta)
   ========================================================== */
.envelope-box-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.envelope-box-container.visible {
  opacity: 1;
  transform: scale(1);
}

.envelope-box-container.opening .envelope-btn {
  animation: envelopeSlightPop 0.4s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes envelopeSlightPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.025) translateY(-5px); }
  100% { transform: scale(1) translateY(0); }
}

.envelope-box-container.opening-away {
  opacity: 0;
  transform: scale(0.85) translateY(25px);
  filter: blur(4px);
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.2, 0.9, 0.3, 1), filter 0.6s ease;
  pointer-events: none;
}

.envelope-box-container.hidden {
  display: none;
}

/* Botón Interactivo del Sobre */
.envelope-btn {
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  perspective: 1200px;
  width: 284px;
  height: 180px;
  border-radius: 14px;
  transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1), filter 0.3s ease;
}

.envelope-btn:focus-visible {
  outline: 3px solid var(--gold-warm);
  outline-offset: 6px;
  border-radius: 14px;
}

.envelope-btn:hover {
  transform: translateY(-4px) scale(1.02);
  filter: brightness(1.03);
}

/* Chasis Principal del Sobre: contenedor de capas estricto */
.envelope-shell {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 14px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.65), 0 0 32px rgba(255, 209, 102, 0.22);
  overflow: visible;
}

/* ==========================================================
   CAPA 1: FONDO DEL SOBRE (Pared trasera + Solapa abierta)
   ========================================================== */
.envelope-back {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  background: #e8d5be;
  border: 1px solid rgba(175, 115, 80, 0.35);
  z-index: 1;
  overflow: visible;
}

.envelope-lining {
  position: absolute;
  inset: 0;
  border-radius: 13px;
  opacity: 0.35;
  background-color: #faece7;
  background-image: radial-gradient(circle at 50% 50%, #c93b62 0 1.2px, transparent 1.6px);
  background-size: 18px 18px;
}

/* Solapa trasera abierta: emerge hacia arriba detrás de la carta */
.envelope-open-flap {
  position: absolute;
  left: 0;
  bottom: 100%;
  width: 284px;
  height: 110px;
  pointer-events: none;
  transform-origin: bottom center;
  transform: scaleY(0);
  opacity: 0;
  transition: transform 0.48s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.2s ease;
  z-index: 1;
}

.open-flap-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
  filter: drop-shadow(0 -3px 6px rgba(45, 15, 25, 0.16));
}

.envelope-box-container.opening .envelope-open-flap {
  transform: scaleY(1);
  opacity: 1;
}

/* ==========================================================
   CAPA 2: CARTA PLEGADA (Ubicada entre el fondo y el bolsillo)
   ========================================================== */
.letter-folded {
  position: absolute;
  top: 32px;
  left: 24px;
  right: 24px;
  height: 140px;
  z-index: 2;
  transform: translateY(0);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.85s cubic-bezier(0.2, 0.9, 0.32, 1), opacity 0.25s ease;
}

.envelope-box-container.opening .letter-folded {
  opacity: 1;
}

/* La carta emerge deslizándose hacia arriba:
   - Su parte superior se muestra sobre la solapa abierta de fondo (z-index 1).
   - Su base permanece cubierta por el bolsillo frontal (z-index 3). */
.letter-folded.slide-up {
  opacity: 1;
  z-index: 2;
  transform: translateY(-68px);
}

.folded-paper-inner {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #fffdfa 0%, #f7ecd9 100%);
  border: 1px solid #d8b898;
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(25, 12, 18, 0.2);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  padding-top: 14px;
  gap: 5px;
}

.folded-tag {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  font-style: italic;
  color: #a33852;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.folded-heart {
  font-size: 1.3rem;
  color: #c82352;
}

/* ==========================================================
   CAPA 3: BOLSILLO FRONTAL (Cubre la base de la carta)
   ========================================================== */
.envelope-pocket {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  z-index: 3;
  pointer-events: none;
  overflow: hidden;
}

.pocket-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.envelope-address {
  position: absolute;
  bottom: 24px;
  left: 0;
  width: 100%;
  text-align: center;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.15rem;
  font-weight: 600;
  color: #8e2b49;
  letter-spacing: 0.03em;
  z-index: 4;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.6);
}

.envelope-address-line {
  position: absolute;
  bottom: 18px;
  left: 28%;
  width: 44%;
  height: 1px;
  background: rgba(142, 43, 73, 0.35);
  z-index: 4;
}

/* ==========================================================
   CAPA 4: SOLAPA FRONTAL CERRADA (Se abre en 3D y se desvanece)
   ========================================================== */
.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 284px;
  height: 105px;
  transform-origin: top center;
  transition: transform 0.48s cubic-bezier(0.25, 0.9, 0.3, 1), opacity 0.16s ease 0.3s;
  z-index: 4;
  pointer-events: none;
}

.closed-flap-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.envelope-flap.open {
  transform: rotateX(180deg);
  opacity: 0;
}

/* ==========================================================
   CAPA 5: SELLO DE LACRE RUBÍ 3D
   ========================================================== */
.envelope-seal {
  position: absolute;
  top: 94px;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #ff8fa7 0%, #d42a54 35%, #9b1338 75%, #63051c 100%);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.45), inset 2px 2px 3px rgba(255, 200, 215, 0.65), inset -2px -2px 3px rgba(50, 0, 15, 0.7);
  border: 1px solid rgba(255, 190, 210, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.3, 1), opacity 0.35s ease;
}

.envelope-seal::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px dashed rgba(255, 220, 230, 0.38);
  border-radius: 50%;
}

.seal-inner-heart {
  color: #fff0f3;
  font-size: 1.25rem;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(60, 5, 20, 0.7);
  transform: translateY(-1px);
}

.envelope-seal.broken {
  opacity: 0;
  transform: translate(-50%, -50%) scale(1.3) rotate(15deg);
  filter: blur(1.5px);
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.3, 1), opacity 0.3s ease, filter 0.3s ease;
}

/* Partículas de Lacre al Romperse */
.seal-burst-wrapper {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
}

.seal-burst-particle {
  position: absolute;
  top: 0;
  left: 0;
  font-size: 0.95rem;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0);
}

.envelope-seal.broken .seal-burst-particle {
  animation: sealParticleExplode 0.7s cubic-bezier(0.12, 0.8, 0.32, 1) forwards;
}

.envelope-seal.broken .seal-burst-particle.b1 { --tx: -34px; --ty: -32px; --rot: -45deg; color: #ff8fa7; animation-delay: 0ms; }
.envelope-seal.broken .seal-burst-particle.b2 { --tx: 0px;   --ty: -44px; --rot: 20deg;  color: #ffd166; animation-delay: 20ms; }
.envelope-seal.broken .seal-burst-particle.b3 { --tx: 36px;  --ty: -30px; --rot: 55deg;  color: #ff6b8b; animation-delay: 10ms; }
.envelope-seal.broken .seal-burst-particle.b4 { --tx: 44px;  --ty: 6px;   --rot: -25deg; color: #ffe699; animation-delay: 30ms; }
.envelope-seal.broken .seal-burst-particle.b5 { --tx: 32px;  --ty: 36px;  --rot: 40deg;  color: #d42a54; animation-delay: 15ms; }
.envelope-seal.broken .seal-burst-particle.b6 { --tx: -4px;  --ty: 42px;  --rot: -15deg; color: #ffd166; animation-delay: 25ms; }
.envelope-seal.broken .seal-burst-particle.b7 { --tx: -36px; --ty: 32px;  --rot: 30deg;  color: #ff8fa7; animation-delay: 10ms; }
.envelope-seal.broken .seal-burst-particle.b8 { --tx: -42px; --ty: 4px;   --rot: -60deg; color: #ffe699; animation-delay: 20ms; }

@keyframes sealParticleExplode {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.3) rotate(0deg);
  }
  25% {
    opacity: 1;
    transform: translate(calc(-50% + var(--tx) * 0.5), calc(-50% + var(--ty) * 0.5)) scale(1.3) rotate(calc(var(--rot) * 0.5));
  }
  75% {
    opacity: 0.85;
    transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(1) rotate(var(--rot));
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--tx) * 1.25), calc(-50% + var(--ty) * 1.25)) scale(0.6) rotate(calc(var(--rot) * 1.4));
  }
}

.envelope-sparkle {
  position: absolute;
  right: -13px;
  top: -18px;
  z-index: 9;
  color: #ffe7a2;
  font-size: 1.2rem;
  opacity: 0.6;
  animation: envelopeTwinkle 2.2s ease-in-out infinite alternate;
}

@keyframes envelopeTwinkle {
  from { transform: scale(0.75) rotate(0deg); opacity: 0.35; }
  to { transform: scale(1.15) rotate(18deg); opacity: 1; }
}

/* Indicación para tocar el sobre */
.envelope-prompt {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  background: rgba(30, 20, 42, 0.88);
  border: 1px solid rgba(255, 209, 102, 0.35);
  border-radius: 30px;
  font-size: 0.92rem;
  color: var(--gold-warm);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  animation: promptGlow 2.2s ease-in-out infinite alternate;
  transition: opacity 0.4s ease;
}

.envelope-prompt.hidden {
  opacity: 0;
  pointer-events: none;
}

@keyframes promptGlow {
  0% { transform: translateY(0); box-shadow: 0 4px 14px rgba(255, 209, 102, 0.15); }
  100% { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(255, 209, 102, 0.4); }
}

.prompt-icon {
  font-size: 1.1rem;
}

/* ==========================================================
   Fase 4: Modal de la Carta Desplegada Completa
   ========================================================== */
.letter-modal {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at 50% 45%, rgba(18, 10, 28, 0.82) 0%, rgba(8, 4, 14, 0.94) 100%);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 30;
  padding: 16px 12px;
  opacity: 0;
  pointer-events: none;
  perspective: 1200px;
  transition: opacity 0.5s ease;
}

.letter-modal.visible {
  opacity: 1;
  pointer-events: auto;
}

.letter-modal.hidden {
  display: none;
}

.letter-paper-wrapper {
  width: 100%;
  max-width: 450px;
  max-height: 86vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  border-radius: 18px;
  box-shadow: 0 25px 65px rgba(0, 0, 0, 0.75), 0 0 40px rgba(244, 184, 197, 0.25);
  transform-origin: center bottom;
}

/* Barra de desplazamiento estética en tonos oro rosa */
.letter-paper-wrapper::-webkit-scrollbar {
  width: 6px;
}
.letter-paper-wrapper::-webkit-scrollbar-track {
  background: rgba(230, 215, 200, 0.25);
  border-radius: 10px;
}
.letter-paper-wrapper::-webkit-scrollbar-thumb {
  background: rgba(184, 75, 105, 0.45);
  border-radius: 10px;
}
.letter-paper-wrapper::-webkit-scrollbar-thumb:hover {
  background: rgba(184, 75, 105, 0.75);
}

/* Animación de desplegado de la carta */
.letter-modal.visible .letter-paper-wrapper {
  animation: letterUnfoldScale 0.72s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes letterUnfoldScale {
  0% {
    transform: scale(0.68) translateY(60px) rotateX(14deg);
    opacity: 0;
    filter: blur(3px);
  }
  65% {
    transform: scale(1.015) translateY(-5px) rotateX(-1deg);
    opacity: 1;
    filter: blur(0);
  }
  100% {
    transform: scale(1) translateY(0) rotateX(0deg);
    opacity: 1;
    filter: blur(0);
  }
}

/* Papel Editorial Marfil Pergamino Cálido */
.letter-paper {
  position: relative;
  background: radial-gradient(ellipse at 50% 10%, #fffefc 0%, #faf3e6 55%, #f3e6cf 100%);
  padding: 34px 24px 28px;
  color: var(--ink-body);
  font-family: var(--font-serif);
  line-height: 1.76;
  border: 1px solid rgba(212, 175, 55, 0.55);
  border-radius: 18px;
  box-shadow: inset 0 0 45px rgba(210, 175, 135, 0.16);
  user-select: text;
  -webkit-user-select: text;
}

/* Borde interior doble perfectamente redondeado */
.letter-paper::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(196, 75, 105, 0.22);
  border-radius: 12px;
  pointer-events: none;
}

/* Esquinas ornamentales victorianas en filigrana */
.paper-corner {
  position: absolute;
  font-size: 1.15rem;
  color: #c48b62;
  opacity: 0.65;
  pointer-events: none;
  line-height: 1;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
}

.paper-corner.top-left {
  top: 13px;
  left: 14px;
}

.paper-corner.top-right {
  top: 13px;
  right: 14px;
  transform: scaleX(-1);
}

.paper-corner.bottom-left {
  bottom: 13px;
  left: 14px;
  transform: scaleY(-1);
}

.paper-corner.bottom-right {
  bottom: 13px;
  right: 14px;
  transform: scale(-1);
}

/* Encabezado Editorial, Sello Postal y Matasellos */
.letter-header {
  position: relative;
  margin-bottom: 22px;
  border-bottom: 1px solid rgba(140, 95, 80, 0.18);
  padding-bottom: 14px;
  padding-right: 90px;
  min-height: 70px;
}

.letter-stamp-container {
  position: absolute;
  top: -10px;
  right: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

/* Matasellos circular histórico */
.letter-postmark {
  display: flex;
  align-items: center;
  gap: 4px;
  transform: rotate(-12deg);
  opacity: 0.72;
}

.postmark-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px dashed rgba(163, 56, 82, 0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.41rem;
  font-family: var(--font-serif);
  line-height: 1.15;
  font-weight: 700;
  color: #922b49;
  letter-spacing: 0.2px;
  background: rgba(255, 245, 240, 0.35);
}

.pm-center {
  font-size: 0.46rem;
  color: #b8325a;
}

.postmark-waves {
  display: flex;
  flex-direction: column;
  gap: 3.5px;
}

.postmark-waves span {
  display: block;
  width: 18px;
  height: 1.5px;
  background: repeating-linear-gradient(90deg, rgba(163, 56, 82, 0.48) 0 3px, transparent 3px 5px);
}

/* Estampilla postal conmemorativa */
.letter-stamp {
  position: relative;
  width: 52px;
  height: 62px;
  background: linear-gradient(140deg, #fffcf7 0%, #faecd9 100%);
  border: 2px dashed rgba(190, 125, 75, 0.65);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(60, 30, 20, 0.16), inset 0 0 6px rgba(210, 160, 100, 0.2);
  transform: rotate(3.5deg);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 3px;
}

.stamp-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.stamp-icon {
  font-size: 1.35rem;
  filter: drop-shadow(0 2px 3px rgba(180, 50, 70, 0.25));
  line-height: 1;
}

.stamp-text-badge {
  font-size: 0.52rem;
  font-weight: 800;
  letter-spacing: 0.6px;
  color: #8e1c3a;
  background: rgba(230, 180, 190, 0.38);
  padding: 2px 4px;
  border-radius: 3px;
  margin-top: 3px;
  font-family: var(--font-sans);
  line-height: 1;
  text-transform: uppercase;
}

.letter-date {
  display: block;
  font-size: 0.94rem;
  color: var(--ink-muted);
  font-style: italic;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}

.letter-recipient {
  font-size: 1.85rem;
  font-weight: 700;
  color: #8e1c3a;
  letter-spacing: 0.02em;
  font-style: italic;
  text-shadow: 0 1px 2px rgba(142, 28, 58, 0.12);
}

.letter-recipient:focus {
  outline: none;
}

/* Cuerpo de la Carta (Tipografía editorial legible y sin huecos forzados) */
.letter-body {
  position: relative;
}

.letter-para {
  font-size: 1.02rem;
  margin-bottom: 16px;
  text-align: left;
  color: var(--ink-body);
  line-height: 1.76;
  text-wrap: pretty;
  opacity: 0;
  transform: translateY(10px);
}

/* Animación escalonada rápida y fluida de los párrafos al desplegarse */
.letter-modal.visible .letter-para {
  animation: letterItemFadeIn 0.55s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.letter-modal.visible .letter-para.p1 { animation-delay: 0.15s; }
.letter-modal.visible .letter-para.p2 { animation-delay: 0.28s; }
.letter-modal.visible .letter-para.p3 { animation-delay: 0.40s; }
.letter-modal.visible .letter-para.p4 { animation-delay: 0.52s; }

@keyframes letterItemFadeIn {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Letra capitular ornamental en el primer párrafo */
.letter-para.p1::first-letter {
  float: left;
  font-size: 2.9rem;
  line-height: 0.85;
  margin: 3px 6px 0 0;
  font-family: var(--font-serif);
  font-weight: 700;
  color: #8e1c3a;
  text-shadow: 1px 1px 0 rgba(212, 175, 55, 0.42);
}

/* Párrafo destacado en rosa sin recuadro */
.letter-highlight-wrapper {
  margin: 20px 0 16px;
  padding: 4px 0;
  background: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  text-align: center;
  opacity: 0;
  transform: translateY(8px);
}

.letter-modal.visible .letter-highlight-wrapper {
  animation: letterItemFadeIn 0.55s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  animation-delay: 0.64s;
}

.highlight-flourish {
  font-size: 0.88rem;
  color: #e04f7a;
  letter-spacing: 3px;
  margin: 4px 0;
}

.letter-highlight {
  font-weight: 600;
  color: #d82b60 !important;
  font-style: italic;
  text-align: center !important;
  padding: 4px 0 !important;
  font-size: 1.14rem !important;
  line-height: 1.65;
  margin: 0 !important;
  text-shadow: 0 1px 2px rgba(216, 43, 96, 0.12);
}

/* Despedida, Firma y Sello de Lacre */
.letter-footer {
  margin-top: 24px;
  text-align: right;
  border-top: 1px dashed rgba(140, 95, 80, 0.18);
  padding-top: 16px;
  opacity: 0;
  transform: translateY(10px);
}

.letter-modal.visible .letter-footer {
  animation: letterItemFadeIn 0.55s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  animation-delay: 0.76s;
}

.letter-closing {
  font-size: 1.35rem;
  font-weight: 700;
  color: #8e1c3a;
  font-style: italic;
  margin-bottom: 8px;
}

.letter-signature-block {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}

.letter-signature {
  font-size: 1.85rem;
  font-style: italic;
  font-weight: 700;
  color: #2c1a1f;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 2px rgba(44, 26, 31, 0.15);
}

/* Mini sello de lacre en relieve */
.mini-wax-seal {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 32%, #ff9ebb 0%, #db3b63 35%, #a21a3f 75%, #6a0b25 100%);
  box-shadow: inset 1.5px 1.5px 2px rgba(255, 210, 220, 0.6), 0 3px 8px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 210, 220, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(-8deg);
  position: relative;
  cursor: default;
}

.mini-wax-seal::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px dashed rgba(255, 220, 225, 0.35);
  border-radius: 50%;
}

.wax-text {
  font-size: 0.72rem;
  font-weight: 900;
  color: #ffe4e8;
  text-shadow: 0 1px 1px rgba(70, 8, 25, 0.8), 0 -0.5px 0.5px rgba(255, 255, 255, 0.35);
  font-family: var(--font-serif);
  letter-spacing: -0.5px;
  z-index: 1;
}

/* Botón de Repetición */
.letter-actions {
  margin-top: 26px;
  text-align: center;
  opacity: 0;
  transform: translateY(10px);
}

.letter-modal.visible .letter-actions {
  animation: letterItemFadeIn 0.55s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  animation-delay: 0.9s;
}

.btn-replay {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(184, 59, 94, 0.08) 0%, rgba(212, 163, 115, 0.12) 100%);
  border: 1px solid rgba(184, 59, 94, 0.38);
  color: var(--ink-accent);
  padding: 10px 22px;
  border-radius: 30px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(184, 59, 94, 0.12);
  transition: all 0.28s ease;
}

.btn-replay:hover, .btn-replay:focus-visible {
  background: linear-gradient(135deg, #a33852 0%, #8e2042 100%);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(163, 56, 82, 0.38);
  outline: 3px solid var(--gold-warm);
  outline-offset: 3px;
}

.replay-icon {
  font-size: 1.15rem;
}

/* ==========================================================
   Accesibilidad: prefers-reduced-motion
   ========================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .character {
    transition: none !important;
  }
  .char-man.at-center, .char-man.kissing {
    transform: translateX(47px) !important;
  }
  .char-woman.at-center, .char-woman.kissing {
    transform: translateX(-47px) !important;
  }
  .envelope-prompt {
    animation: none !important;
  }
}

/* ==========================================================
   Media Queries para Pantallas Pequeñas (≤ 380px)
   ========================================================== */
@media (max-width: 380px) {
  .start-title {
    font-size: 1.8rem;
  }
  .start-card {
    padding: 26px 18px;
  }
  .letter-paper {
    padding: 24px 18px 20px;
  }
  .letter-body p {
    font-size: 0.96rem;
    line-height: 1.65;
  }
  .couple-stage {
    width: 250px;
    height: 145px;
  }
  .character {
    width: 76px;
    height: 125px;
  }
}
