:root {
  --navy: #07060e;
  --cream: #f4e8d0;
  --gold: #d4af6a;
  --rose: #e8b4b8;
  --ink: #140f18;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--navy);
  color: var(--cream);
  font-family: "Cormorant Garamond", Georgia, serif;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

#webgl, #fx, #grain, #vignette {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

#webgl { z-index: 1; }
#fx { z-index: 2; pointer-events: none; }
#grain {
  z-index: 3;
  pointer-events: none;
  opacity: 0.09;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='.55'/></svg>");
  mix-blend-mode: overlay;
  animation: grain 0.8s steps(2) infinite;
}
@keyframes grain {
  0% { transform: translate(0,0); }
  25% { transform: translate(-2%, 1%); }
  50% { transform: translate(1%, -2%); }
  75% { transform: translate(-1%, 2%); }
  100% { transform: translate(0,0); }
}
#vignette {
  z-index: 4;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,.55) 100%);
}

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

.boot-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -1;
  mask-image: linear-gradient(to bottom, #000 52%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, #000 52%, transparent 100%);
}
.scene {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 0 28px calc(48px + env(safe-area-inset-bottom));
  text-align: center;
  pointer-events: none;
}

.scene.center { justify-content: center; }

.hidden { display: none !important; }

.date {
  letter-spacing: 0.5em;
  font-size: 13px;
  color: var(--gold);
  margin-bottom: 12px;
  text-indent: 0.5em;
}

h1 {
  font-family: "Great Vibes", cursive;
  font-size: clamp(52px, 16vw, 84px);
  font-weight: 400;
  line-height: 0.95;
  text-shadow: 0 10px 40px rgba(0,0,0,.6);
}

.sub {
  font-style: italic;
  font-size: 20px;
  opacity: 0.82;
  margin-top: 10px;
}

.hint {
  margin-top: 34px;
  font-size: 12px;
  letter-spacing: 0.32em;
  text-transform: lowercase;
  color: var(--gold);
  animation: pulse 2.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 0.95; }
}

.cta {
  pointer-events: auto;
  margin-top: 28px;
  border: 1px solid rgba(212,175,106,.55);
  background: rgba(7,6,14,.35);
  color: var(--cream);
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.34em;
  text-transform: lowercase;
  padding: 14px 28px;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(10px);
}

.cta:active { transform: scale(0.98); }

#tune {
  background: linear-gradient(to top, rgba(7,6,14,.88) 0%, rgba(7,6,14,.25) 42%, transparent 70%);
}
#tune .sub, #tune .hint { text-shadow: 0 2px 16px #000; }
#freq {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.28em;
  color: var(--gold);
  font-size: 18px;
  min-height: 1.2em;
  margin-bottom: 8px;
  text-shadow: 0 2px 18px #000;
}

#tune-bar {
  width: min(78vw, 340px);
  height: 2px;
  background: rgba(244,232,208,.18);
  position: relative;
  margin: 18px auto 8px;
}
#tune-bar i {
  position: absolute;
  top: -5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 16px var(--gold);
  transform: translateX(-50%);
  left: 20%;
}

#hud {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(22px + env(safe-area-inset-bottom));
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.28em;
  color: var(--gold);
  opacity: 0.75;
}
#open-letter {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  left: 14px;
  z-index: 8;
  pointer-events: auto;
  margin: 0;
}

#caption {
  position: absolute;
  left: 18px; right: 18px;
  bottom: calc(70px + env(safe-area-inset-bottom));
  text-align: center;
  pointer-events: none;
  transition: opacity .6s ease, transform .6s ease;
}
#caption .kicker {
  color: var(--gold);
  letter-spacing: 0.32em;
  font-size: 11px;
  margin-bottom: 8px;
}
#caption .line {
  font-size: 22px;
  font-style: italic;
  line-height: 1.35;
  text-shadow: 0 8px 24px #000;
}

#letter {
  position: absolute;
  inset: 0;
  overflow: auto;
  pointer-events: auto;
  touch-action: pan-y;
  padding: 64px 20px 120px;
  background: rgba(7,6,14,.94);
  overflow-x: hidden;
}
.letter-card {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  border: 1px solid rgba(212,175,106,.28);
  background: rgba(20,15,24,.9);
  backdrop-filter: blur(16px);
  border-radius: 22px;
  padding: 28px 18px 32px;
  text-align: left;
}
.letter-card .kicker {
  color: var(--gold);
  letter-spacing: 0.32em;
  font-size: 11px;
  margin-bottom: 18px;
}
.letter-card p {
  font-size: 16.5px;
  line-height: 1.65;
  margin-bottom: 13px;
  font-style: italic;
  overflow-wrap: break-word;
  word-break: break-word;
  max-width: 30ch;
}
.letter-card .sign {
  font-family: "Great Vibes", cursive;
  font-style: normal;
  font-size: 34px;
  margin-top: 10px;
}

#finale {
  justify-content: flex-end;
  background: linear-gradient(to top, rgba(7,6,14,.75), transparent 55%);
}

#sound {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  right: 14px;
  z-index: 8;
  pointer-events: auto;
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: lowercase;
  border: 1px solid rgba(212,175,106,.35);
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(7,6,14,.45);
}

.fade { transition: opacity 1.1s ease, visibility 1.1s ease; }
.fade-fast { transition: opacity .45s ease, visibility .45s ease; }
