:root {
  --void: #05060c;
  --ink: #0a0c14;
  --navy: #141c30;
  --ice: #d5e0f0;
  --moon: #eef3f8;
  --silver: #9aadc4;
  --mauve: #8a6574;
  --rose: #c4a0b0;
  --pumpkin: #c45c28;
  --amber: #d4783a;
  --burgundy: #3a1824;
  --pine: #0c1c1a;
  --frost: #7f98b8;
  --line: rgba(197, 212, 232, 0.22);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--void);
  color: var(--ice);
  overflow: hidden;
  font-family: "Outfit", system-ui, sans-serif;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

canvas#scene,
canvas#snow {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

canvas#snow {
  z-index: 2;
  pointer-events: none;
}

#vignette {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 40%, transparent 40%, rgba(2, 3, 8, 0.55) 100%),
    linear-gradient(180deg, rgba(5, 6, 12, 0.35) 0%, transparent 18%, transparent 78%, rgba(5, 6, 12, 0.55) 100%);
}

#grain {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0.07;
  mix-blend-mode: screen;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.9'/%3E%3C/svg%3E");
}

#start-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  background:
    radial-gradient(circle at 50% 42%, #1a2438 0%, #0a0e18 42%, #05060c 100%);
  cursor: pointer;
  transition: opacity 1.1s ease;
}

#start-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.start-mark {
  width: min(58vw, 250px);
  height: min(56vw, 236px);
  filter: drop-shadow(0 0 28px rgba(186, 206, 232, 0.4));
  animation: moonFloat 4.2s ease-in-out infinite;
}

.start-date {
  margin: 6px 0 0;
  font-size: 0.68rem;
  letter-spacing: 0.46em;
  text-transform: uppercase;
  color: var(--frost);
}

.start-name {
  margin: 2px 0 0;
  font-family: "Great Vibes", cursive;
  font-weight: 400;
  font-size: clamp(3.4rem, 12vw, 6.2rem);
  line-height: 1.05;
  color: var(--moon);
  text-shadow:
    0 0 28px rgba(196, 160, 176, 0.45),
    0 0 48px rgba(170, 196, 230, 0.28);
  animation: nameShimmer 4.8s ease-in-out infinite;
}

.start-sub {
  margin: 4px 0 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.15rem, 3.4vw, 1.55rem);
  color: var(--ice);
  opacity: 0.88;
}

.start-from {
  margin: 10px 0 0;
  font-size: 0.7rem;
  letter-spacing: 0.38em;
  text-transform: uppercase;
  color: var(--amber);
}

@keyframes nameShimmer {
  0%, 100% { filter: brightness(1); transform: scale(1); }
  50% { filter: brightness(1.12); transform: scale(1.025); }
}

@keyframes moonFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

#top-title {
  position: fixed;
  top: 22px;
  left: 0;
  width: 100%;
  z-index: 10;
  text-align: center;
  pointer-events: none;
}

#top-title .kicker {
  margin: 0 0 2px;
  font-size: 0.7rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--frost);
}

#top-title h1 {
  margin: 0;
  font-family: "Great Vibes", cursive;
  font-weight: 400;
  font-size: clamp(2.4rem, 7vw, 4rem);
  color: var(--moon);
  text-shadow:
    0 0 22px rgba(196, 160, 176, 0.4),
    0 0 28px rgba(170, 196, 230, 0.3);
}

#top-title .flourish {
  margin: 2px 0 0;
  font-size: 0.7rem;
  letter-spacing: 0.45em;
  color: var(--amber);
  opacity: 0.85;
}

#couple {
  position: fixed;
  left: 50%;
  bottom: -2px;
  z-index: 8;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
  transform: translateX(-50%) translateY(18px);
  opacity: 0;
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.55));
}

#couple.visible {
  animation: coupleIn 1.35s ease forwards;
}

#couple::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: 78%;
  height: 22px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.5), transparent 72%);
  z-index: -1;
}

#couple .person {
  width: auto;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

#couple .luis {
  height: min(28vh, 240px);
  margin-right: -18px;
  animation: coupleIdle 3.8s ease-in-out infinite;
}

#couple .luisa {
  height: min(30vh, 258px);
  margin-left: -10px;
  z-index: 1;
  animation: coupleIdle 4.1s ease-in-out infinite 0.35s;
}

#couple .couple-heart {
  position: absolute;
  left: 50%;
  bottom: 46%;
  margin: 0;
  font-size: 0.95rem;
  color: var(--rose);
  text-shadow: 0 0 14px rgba(196, 160, 176, 0.85);
  transform: translateX(-50%);
  animation: heartPulse 2.4s ease-in-out infinite;
}

@keyframes coupleIn {
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes coupleIdle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes heartPulse {
  0%, 100% { opacity: 0.72; transform: translateX(-50%) scale(1); }
  50% { opacity: 1; transform: translateX(-50%) scale(1.18); }
}

#from-line {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(min(30vh, 258px) + 10px);
  z-index: 10;
  text-align: center;
  pointer-events: none;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  color: var(--silver);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
}

#phrases {
  position: fixed;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}

.phrase {
  position: absolute;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-size: clamp(0.95rem, 2.4vw, 1.25rem);
  color: var(--ice);
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.85);
  opacity: 0;
  white-space: nowrap;
  animation: phraseLift 7.5s ease-in-out forwards;
}

@keyframes phraseLift {
  0% { opacity: 0; transform: translateY(12px); }
  18% { opacity: 0.92; }
  70% { opacity: 0.78; }
  100% { opacity: 0; transform: translateY(-28px); }
}

#letter-btn,
#mute-btn {
  position: fixed;
  z-index: 12;
  border: 1px solid var(--line);
  background: rgba(12, 16, 28, 0.72);
  color: var(--ice);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
  transition: transform 0.25s ease, border-color 0.25s ease;
}

#letter-btn:hover,
#mute-btn:hover { transform: scale(1.06); border-color: rgba(213, 224, 240, 0.45); }

#letter-btn {
  right: 22px;
  bottom: 22px;
  width: 58px;
  height: 58px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: btnGlow 2.4s ease-in-out infinite;
}

#letter-btn svg {
  width: 34px;
  height: 34px;
  display: block;
}

#mute-btn {
  left: 22px;
  bottom: 22px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  font-size: 1.05rem;
}

#mute-btn.muted { opacity: 0.45; }

@keyframes btnGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(160, 184, 220, 0.15); }
  50% { box-shadow: 0 0 22px 2px rgba(160, 184, 220, 0.28); }
}

#letter-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(4, 6, 12, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

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

#letter-card {
  position: relative;
  width: min(640px, 100%);
  max-height: 82vh;
  overflow-y: auto;
  padding: 42px 40px 28px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 88% 0%, rgba(120, 70, 92, 0.32), transparent 42%),
    linear-gradient(180deg, rgba(18, 24, 40, 0.96), rgba(8, 10, 18, 0.98));
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px rgba(196, 160, 176, 0.08);
  transform: translateY(16px);
  transition: transform 0.45s ease;
}

#letter-card::before {
  content: "❀";
  position: absolute;
  top: 16px;
  left: 18px;
  font-size: 0.85rem;
  color: var(--rose);
  opacity: 0.55;
}

#letter-overlay.visible #letter-card { transform: translateY(0); }

.letter-seal {
  margin: 0 0 8px;
  text-align: center;
  font-size: 1.5rem;
  color: var(--silver);
}

#letter-card h2 {
  margin: 0 0 6px;
  text-align: center;
  font-family: "Great Vibes", cursive;
  font-size: clamp(2.6rem, 6vw, 3.4rem);
  font-weight: 400;
  color: var(--moon);
}

.letter-date {
  margin: 0 0 4px;
  text-align: center;
  font-size: 0.68rem;
  letter-spacing: 0.36em;
  text-transform: uppercase;
  color: var(--frost);
}

.letter-rule {
  width: 72px;
  height: 1px;
  margin: 0 auto 22px;
  background: linear-gradient(90deg, transparent, var(--rose), transparent);
}

#letter-body p {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.18rem;
  line-height: 1.65;
  color: var(--ice);
  margin: 0 0 1.05em;
  opacity: 0;
  transform: translateY(8px);
}

#letter-overlay.visible #letter-body p {
  animation: letterIn 0.7s ease forwards;
}
#letter-overlay.visible #letter-body p:nth-child(1) { animation-delay: 0.12s; }
#letter-overlay.visible #letter-body p:nth-child(2) { animation-delay: 0.28s; }
#letter-overlay.visible #letter-body p:nth-child(3) { animation-delay: 0.44s; }
#letter-overlay.visible #letter-body p:nth-child(4) { animation-delay: 0.6s; }
#letter-overlay.visible #letter-body p:nth-child(5) { animation-delay: 0.76s; }

@keyframes letterIn {
  to { opacity: 1; transform: translateY(0); }
}

#letter-sign {
  margin: 18px 0 0;
  text-align: right;
  font-family: "Great Vibes", cursive;
  font-size: 1.8rem;
  color: var(--silver);
}

.letter-bouquet {
  margin: 6px auto 0;
  width: min(248px, 78%);
  display: block;
  opacity: 0;
  transform: translateY(10px) scale(0.94);
}

.letter-bouquet svg {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.4));
}

#letter-overlay.visible .letter-bouquet {
  animation: bouquetIn 0.9s ease forwards;
  animation-delay: 0.92s;
}

@keyframes bouquetIn {
  to { opacity: 1; transform: translateY(0) scale(1); }
}

#letter-close {
  position: absolute;
  top: 14px;
  right: 16px;
  border: 0;
  background: transparent;
  color: var(--silver);
  font-size: 1.15rem;
  cursor: pointer;
}

#letter-close:hover { color: var(--moon); }

[hidden] { display: none !important; }

@media (max-width: 560px) {
  #letter-card { padding: 32px 22px 22px; border-radius: 18px; }
  #letter-body p { font-size: 1.05rem; }
  #letter-btn { right: 14px; bottom: 16px; width: 52px; height: 52px; }
  #mute-btn { left: 14px; bottom: 16px; }
  #from-line { bottom: calc(26vh + 8px); font-size: 0.85rem; }
  #top-title { top: 14px; }
  .phrase { white-space: normal; max-width: 78vw; text-align: center; }
  #couple .luis { height: 24vh; margin-right: -14px; }
  #couple .luisa { height: 26vh; margin-left: -8px; }
  .letter-bouquet { width: min(196px, 78%); }
}

@media (max-height: 640px) {
  #couple .luis { height: 22vh; }
  #couple .luisa { height: 24vh; }
  #from-line { bottom: calc(24vh + 6px); }
}
