:root {
  --bg: #fff7f3;
  --bg-2: #fde8ec;
  --fg: #3b2a2f;
  --muted: #8a6b73;
  --rose: #c43d64;
  --rose-soft: #f3a6b8;
  --gold: #e9a93b;
  --glow: rgba(196, 61, 100, 0.10);
  --flash: rgba(255, 255, 255, 0.95);
  --card: rgba(255, 255, 255, 0.78);
  --card-border: rgba(196, 61, 100, 0.12);
  --shadow: 0 18px 50px -20px rgba(196, 61, 100, 0.35);
  --env: #f6c9d3;
  --env-dark: #e9a7b8;
  --env-flap: #f9d8df;
  --on-rose: #fff;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1216;
    --bg-2: #2a1820;
    --fg: #f6e9ec;
    --muted: #c7a6ae;
    --rose: #f28aa6;
    --rose-soft: #a8506a;
    --gold: #f3c063;
    --glow: rgba(242, 138, 166, 0.13);
    --flash: rgba(255, 214, 226, 0.85);
    --card: rgba(46, 28, 36, 0.78);
    --card-border: rgba(242, 138, 166, 0.16);
    --shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.7);
    --env: #7d3e54;
    --env-dark: #5a2b3c;
    --env-flap: #8f4a62;
    --on-rose: #2a1218;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html {
  scroll-behavior: smooth;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background: var(--bg);
  color: var(--fg);
  font-family: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  font-size: 1.2rem;
  line-height: 1.6;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}
/* iOS Safari ignores background-attachment: fixed, so use a fixed layer instead */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(1200px 800px at 50% -10%, var(--bg-2), var(--bg) 70%);
}
body.locked { overflow: hidden; }

button { touch-action: manipulation; }

.script { font-family: "Dancing Script", "Brush Script MT", cursive; font-weight: 700; }

h2 {
  font-weight: 600;
  font-size: clamp(1.7rem, 5vw, 2.2rem);
  text-align: center;
  margin: 0 0 1.2rem;
  line-height: 1.2;
}

/* ---------- Floating hearts ---------- */
.sky {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.float {
  position: absolute;
  bottom: -40px;
  color: var(--rose);
  animation: rise linear forwards;
}
@keyframes rise {
  0%   { transform: translate(0, 0) rotate(0deg); }
  50%  { transform: translate(18px, -55vh) rotate(12deg); }
  100% { transform: translate(-12px, -115vh) rotate(-8deg); opacity: 0; }
}

/* ---------- Intro / envelope ---------- */
.intro {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 2.4rem;
  overflow: hidden;
  background: radial-gradient(900px 600px at 50% 40%, var(--bg-2), var(--bg));
  padding: calc(16px + var(--safe-top)) calc(16px + var(--safe-right)) calc(16px + var(--safe-bottom)) calc(16px + var(--safe-left));
}
.intro.closing { animation: fadeOut 0.7s ease forwards; }

.stage {
  position: relative;
  display: grid;
  place-items: center;
}
.intro.closing .stage { animation: zoomAway 0.7s ease-in forwards; }

.rays {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 560px;
  height: 560px;
  margin: -280px 0 0 -280px;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, transparent 0deg 9deg, var(--glow) 9deg 18deg);
  -webkit-mask: radial-gradient(circle, #000 18%, transparent 62%);
  mask: radial-gradient(circle, #000 18%, transparent 62%);
  opacity: 0.8;
  animation: spin 40s linear infinite;
  transition: opacity 0.6s ease, scale 0.8s ease;
  pointer-events: none;
}
.opening .rays { scale: 1.5; opacity: 1; animation-duration: 6s; }

.twinkle {
  position: absolute;
  left: 50%;
  top: 50%;
  translate: calc(-50% + var(--x)) calc(-50% + var(--y));
  color: var(--gold);
  font-size: 1.1rem;
  opacity: 0;
  animation: twinkle 2.4s ease-in-out infinite;
  animation-delay: var(--d);
  pointer-events: none;
}
.opening .twinkle { animation: none; opacity: 0; transition: opacity 0.3s; }

.envelope {
  position: relative;
  width: min(240px, 64vw);
  aspect-ratio: 3 / 2;
  border: 0;
  padding: 0;
  background: transparent;
  font: inherit;
  color: inherit;
  cursor: pointer;
  perspective: 800px;
  animation: bob 2.6s ease-in-out infinite;
  filter: drop-shadow(0 18px 24px rgba(140, 45, 75, 0.28));
}
.envelope:focus-visible { outline: 3px solid var(--rose); outline-offset: 8px; border-radius: 12px; }

.env-back, .env-pocket, .env-flap, .env-letter, .env-seal { position: absolute; }
.env-back {
  inset: 0;
  z-index: 0;
  border-radius: 10px;
  background: var(--env-dark);
}
.env-letter {
  left: 7%;
  right: 7%;
  top: 8%;
  height: 84%;
  z-index: 2;
  display: grid;
  place-content: center;
  gap: 0.1rem;
  border-radius: 6px;
  background: #fffdfb;
  color: #c43d64;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}
.env-letter .script { font-size: clamp(1.4rem, 7vw, 1.8rem); line-height: 1; }
.env-letter small { font-size: 0.8rem; font-style: italic; color: #8a6b73; }
.env-pocket {
  inset: 0;
  z-index: 3;
  border-radius: 10px;
  background: var(--env);
  clip-path: polygon(0 0, 50% 55%, 100% 0, 100% 100%, 0 100%);
}
.env-flap {
  top: 0;
  left: 0;
  width: 100%;
  height: 58%;
  z-index: 4;
  background: var(--env-flap);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  backface-visibility: visible;
}
.env-seal {
  left: 50%;
  top: 54%;
  z-index: 5;
  font-size: 2.2rem;
  line-height: 1;
  color: var(--rose);
  text-shadow: 0 2px 6px rgba(140, 45, 75, 0.35);
  transform: translate(-50%, -50%);
  animation: heartbeatCentered 1.6s ease-in-out infinite;
}

.opening .envelope { animation: shake 0.4s ease; }
.opening .env-seal { animation: sealPop 0.4s ease forwards; }
.opening .env-flap { animation: flapOpen 0.6s ease 0.2s forwards; }
.opening .env-letter { animation: letterRise 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) 0.75s forwards; }

.intro-text {
  margin: 0;
  text-align: center;
  font-size: 1.5rem;
  font-style: italic;
  transition: opacity 0.3s ease;
}
.intro-text span {
  display: block;
  font-style: normal;
  font-size: 0.85rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 0.3rem;
  animation: breathe 2s ease-in-out infinite;
}
.opening .intro-text { opacity: 0; }

.flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 42%, var(--flash), transparent 60%);
}
.burst-now .flash { animation: flash 0.8s ease-out; }

/* Particles + rings (used by the envelope and the big heart) */
.particle {
  position: fixed;
  z-index: 44;
  pointer-events: none;
  line-height: 1;
  transform: translate(-50%, -50%);
  animation: fly var(--dur, 1.4s) cubic-bezier(0.15, 0.7, 0.3, 1) forwards;
}
.ring {
  position: fixed;
  z-index: 43;
  width: 60px;
  height: 60px;
  border: 2px solid var(--rose);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.2);
  animation: ring 1s ease-out forwards;
}

/* ---------- Layout ---------- */
main {
  position: relative;
  z-index: 1;
  padding: 0 calc(16px + var(--safe-right)) 3rem calc(16px + var(--safe-left));
}

.hero {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 0.4rem;
  padding-top: var(--safe-top);
}
.hero > * { opacity: 0; }
.revealed .hero > * { animation: fadeUp 1s ease forwards; }
.revealed .hero > :nth-child(2) { animation-delay: 0.25s; }
.revealed .hero > :nth-child(3) { animation-delay: 0.6s; }
.revealed .hero > :nth-child(4) { animation-delay: 1.1s; }

.eyebrow {
  margin: 0;
  font-size: 0.85rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
}
.hero h1 {
  margin: 0;
  font-size: clamp(4.2rem, 17vw, 9.5rem);
  line-height: 1.05;
  color: var(--rose);
}
.sub { margin: 0; font-style: italic; font-size: 1.35rem; color: var(--muted); }
.scroll-hint {
  justify-self: center;
  margin-top: 2rem;
  color: var(--rose);
  text-decoration: none;
  font-size: 1.8rem;
  padding: 8px 16px;
}
.revealed .scroll-hint { animation: fadeUp 1s 1.1s ease forwards, nudge 2s 2.2s ease-in-out infinite; }

.card {
  max-width: 640px;
  margin: 0 auto 2.5rem;
  padding: clamp(22px, 6vw, 46px);
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* Scroll reveal */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.9s ease, transform 0.9s ease; }
.reveal.in { opacity: 1; transform: none; }

/* ---------- Together counter ---------- */
.together { text-align: center; }
.together-label {
  margin: 0;
  font-size: 0.85rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--muted);
}
.together-date { margin: 0.2rem 0 1.4rem; font-size: clamp(2rem, 8vw, 2.8rem); color: var(--rose); line-height: 1.2; }
.timer {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.unit {
  min-width: 0;
  padding: 14px 4px 10px;
  border-radius: 14px;
  background: var(--bg-2);
  border: 1px solid var(--card-border);
}
.num {
  display: block;
  font-size: clamp(1.6rem, 7vw, 2.6rem);
  font-weight: 600;
  line-height: 1.1;
  color: var(--rose);
  font-variant-numeric: tabular-nums;
}
.lbl {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
}
.together-note { margin: 1.2rem 0 0; font-style: italic; }

/* ---------- Photos ---------- */
.us { max-width: 760px; margin: 0 auto 2.5rem; }
.polaroids {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(16px, 4vw, 32px);
  align-items: start;
}
.polaroid {
  margin: 0;
  padding: 12px 12px 0;
  background: #fffdfb;
  border-radius: 6px;
  box-shadow: 0 20px 40px -18px rgba(60, 20, 35, 0.45);
  transition: transform 0.35s ease;
}
.polaroid img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  object-position: center 35%;
  border-radius: 3px;
}
.polaroid figcaption {
  padding: 10px 4px 14px;
  text-align: center;
  font-size: clamp(1.15rem, 3.6vw, 1.5rem);
  color: #8c2d4b;
  line-height: 1.25;
}
.tilt-left { transform: rotate(-3deg); }
.tilt-right { transform: rotate(2.5deg); margin-top: 28px; }

/* ---------- Letter ---------- */
.letter p { margin: 0 0 1.1rem; font-size: 1.3rem; line-height: 1.75; }
.letter .salutation { font-size: 2.3rem; color: var(--rose); margin-bottom: 1rem; line-height: 1.3; }
.letter .emphasis { font-style: italic; font-weight: 600; }
.letter .signoff { font-size: 2rem; color: var(--rose); text-align: right; margin: 1.5rem 0 0; }

/* ---------- Buttons ---------- */
.btn {
  display: block;
  margin: 0 auto;
  min-height: 48px;
  font: inherit;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--on-rose);
  background: var(--rose);
  border: 0;
  border-radius: 999px;
  padding: 0.7em 1.9em;
  cursor: pointer;
  box-shadow: 0 10px 24px -10px var(--rose);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible, .lang-phrase:focus-visible, .big-heart:focus-visible { outline: 3px solid var(--rose); outline-offset: 4px; }

/* ---------- Reasons ---------- */
.reason {
  min-height: 4.8em;
  display: grid;
  place-items: center;
  margin: 0 0 1.2rem;
  text-align: center;
  font-style: italic;
  font-size: 1.5rem;
  line-height: 1.45;
  transition: opacity 0.25s ease;
}
.fade { opacity: 0; }
.count {
  margin: 0.9rem 0 0;
  text-align: center;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  min-height: 1.4em;
}

/* ---------- Languages ---------- */
.languages { text-align: center; }
.lang-phrase {
  display: block;
  width: 100%;
  min-height: 2.6em;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--rose);
  font: inherit;
  font-size: clamp(1.8rem, 7vw, 2.6rem);
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  transition: opacity 0.35s ease;
}
.lang-name {
  margin: 0.2rem 0 1rem;
  font-size: 0.85rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--muted);
  transition: opacity 0.35s ease;
}
.note { margin: 0; font-style: italic; color: var(--muted); }

/* ---------- Facts ---------- */
.facts { max-width: 980px; margin: 0 auto 2.5rem; }
.fact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
  gap: 16px;
}
.fact {
  padding: 22px 22px 18px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  transition: transform 0.25s ease;
}
.fact .emoji { font-size: 2rem; display: block; margin-bottom: 0.4rem; }
.fact p { margin: 0; font-size: 1.15rem; line-height: 1.55; }

/* ---------- Finale ---------- */
.finale { text-align: center; }
.big-heart {
  display: block;
  margin: 0 auto;
  width: 140px;
  height: 140px;
  border: 0;
  padding: 0;
  background: none;
  color: var(--rose);
  font-size: 7rem;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  animation: heartbeat 1.6s ease-in-out infinite;
}
.big-heart.pop { animation: pop 0.35s ease; }
.heart-msg { margin: 0.6rem 0 0; font-size: 1.5rem; font-style: italic; min-height: 1.6em; }

/* ---------- Orbiting hearts & flowers ---------- */
.orbit {
  position: relative;
  width: 120px;
  height: 120px;
  margin: -8px auto 2px;
}
.orbit .core {
  position: absolute;
  left: 50%;
  top: 50%;
  font-size: 2.5rem;
  line-height: 1;
  transform: translate(-50%, -50%);
  animation: heartbeatCentered 1.6s ease-in-out infinite;
}
.orbit .o {
  position: absolute;
  left: 50%;
  top: 50%;
  font-size: 1.15rem;
  line-height: 1;
  animation: orbit 8s linear infinite;
  animation-delay: calc(var(--i) * -1.3333s);
}

/* ---------- Quiz ---------- */
.quiz { text-align: center; }
.quiz-sub { margin: -0.4rem 0 1rem; font-style: italic; color: var(--muted); }
.dots { display: flex; justify-content: center; gap: 8px; margin-bottom: 0.6rem; }
.dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--card-border);
  border: 1px solid var(--rose-soft);
  transition: background 0.3s ease, transform 0.3s ease;
}
.dots span.current { background: var(--rose-soft); transform: scale(1.25); }
.dots span.done { background: var(--rose); border-color: var(--rose); }
.question {
  margin: 0.4rem 0 1rem;
  font-size: clamp(1.4rem, 5.5vw, 1.7rem);
  font-weight: 600;
  line-height: 1.3;
}
.question.in { animation: fadeUp 0.5s ease; }
.options { display: grid; gap: 10px; margin: 0 0 0.8rem; }
.opt {
  min-height: 52px;
  padding: 0.55em 1em;
  font: inherit;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--fg);
  background: var(--bg-2);
  border: 1.5px solid var(--card-border);
  border-radius: 14px;
  cursor: pointer;
  transition: opacity 0.3s ease;
}
.opt.correct {
  background: var(--rose);
  border-color: var(--rose);
  color: var(--on-rose);
  animation: pop 0.5s ease;
  box-shadow: 0 0 0 6px var(--glow), 0 10px 24px -10px var(--rose);
}
.opt.wrong { animation: wobble 0.45s ease; }
.opt:disabled:not(.correct) { opacity: 0.4; cursor: default; }
.feedback { min-height: 1.6em; margin: 0.2rem 0 1rem; font-size: 1.3rem; font-style: italic; }
.feedback.good { color: var(--rose); font-weight: 600; animation: fadeUp 0.5s ease; }
.score {
  margin: 0.4rem 0 0.2rem;
  font-size: clamp(2.6rem, 12vw, 3.4rem);
  color: var(--rose);
  line-height: 1.1;
  animation: pop 0.6s ease;
}

/* ---------- Forever questions ---------- */
.forever { text-align: center; }
.fstage {
  position: relative;
  min-height: 360px;
  display: grid;
  align-content: center;
  gap: 1.2rem;
}
.fq { margin: 0; font-size: clamp(1.6rem, 6.5vw, 2.1rem); font-weight: 600; line-height: 1.3; }
.fq.in { animation: fadeUp 0.6s ease; }
.fbtns { display: flex; justify-content: center; align-items: center; gap: 16px; min-height: 76px; }
.fbtns .btn { margin: 0; }
.btn.yes { transition: transform 0.3s ease, box-shadow 0.2s ease; }
.btn.no {
  color: var(--fg);
  background: var(--bg-2);
  border: 1.5px solid var(--card-border);
  box-shadow: none;
  white-space: nowrap;
}
.btn.no.running { position: absolute; z-index: 2; transition: left 0.22s ease, top 0.22s ease; }
.fanswer { margin: 0; min-height: 1.3em; font-size: clamp(1.9rem, 8vw, 2.6rem); color: var(--rose); line-height: 1.25; }
.fanswer:not(:empty) { animation: pop 0.6s ease; }
.ffinal { display: grid; gap: 0.8rem; justify-items: center; }
.final-note { margin: 0; font-size: 1.3rem; font-style: italic; }

/* ---------- Big effects ---------- */
.rain {
  position: fixed;
  top: -50px;
  z-index: 44;
  pointer-events: none;
  line-height: 1;
  animation: rainFall var(--dur, 3s) linear forwards;
}
.bloom {
  position: fixed;
  bottom: -50px;
  z-index: 44;
  pointer-events: none;
  line-height: 1;
  animation: bloomUp 2.8s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
}
.sun {
  position: fixed;
  left: 50%;
  bottom: -140px;
  z-index: 44;
  pointer-events: none;
  font-size: 110px;
  line-height: 1;
  filter: drop-shadow(0 0 30px rgba(255, 190, 60, 0.9));
  animation: sunRise 2.8s ease-out forwards;
}
.giant {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 42;
  pointer-events: none;
  font-size: 42vmin;
  line-height: 1;
  color: var(--rose);
  transform: translate(-50%, -50%) scale(0);
  animation: giantPop 1.9s ease forwards;
}
.giant.wipe { color: var(--rose-soft); animation: heartWipe 1.5s cubic-bezier(0.6, 0, 0.4, 1) forwards; }

/* ---------- Lock screen ---------- */
.lock {
  position: fixed;
  inset: 0;
  z-index: 12;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: calc(16px + var(--safe-top)) calc(16px + var(--safe-right)) calc(16px + var(--safe-bottom)) calc(16px + var(--safe-left));
}
.lock-sky { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.lock-card {
  position: relative;
  width: min(420px, 100%);
  display: grid;
  justify-items: center;
  gap: 0.8rem;
  text-align: center;
  padding: clamp(22px, 6vw, 40px);
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 26px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeUp 0.8s ease;
}
.lock-card.wrong { animation: wobble 0.45s ease; }
.lock-card.opened { animation: lockOut 0.6s 0.45s ease forwards; }
.lock-card .orbit { margin: -6px auto 0; }
.lock-q { margin: 0; font-size: clamp(1.6rem, 6.5vw, 2rem); line-height: 1.25; }
.lock-input {
  width: 100%;
  font: inherit;
  font-size: 1.35rem; /* >= 16px so iPhone doesn't zoom in */
  text-align: center;
  padding: 0.65em 1em;
  border-radius: 14px;
  border: 1.5px solid var(--rose-soft);
  background: var(--bg);
  color: var(--fg);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.lock-input:focus { border-color: var(--rose); box-shadow: 0 0 0 4px var(--glow); }
.lock-card .btn { width: 100%; }
.lock-msg { margin: 0; min-height: 1.5em; font-style: italic; font-size: 1.15rem; }
.lock-msg.good { color: var(--rose); font-weight: 600; }
.lock.gone { animation: fadeOut 0.5s ease forwards; }

/* Envelope waits hidden until the lock is solved, then drops in */
.intro.waiting .stage, .intro.waiting .intro-text { opacity: 0; pointer-events: none; }
.intro.arrive .stage { animation: dropIn 1s cubic-bezier(0.2, 1.5, 0.4, 1) both; }
.intro.arrive .intro-text { animation: fadeUp 0.8s 0.6s ease both; }

/* Spiral vortex of hearts + screen flash + page shake */
.vortex {
  position: fixed;
  left: 50%;
  top: 45%;
  z-index: 44;
  pointer-events: none;
  line-height: 1;
  animation: vortexIn var(--dur, 1.3s) cubic-bezier(0.55, 0, 0.75, 0.2) var(--delay, 0s) both;
}
.screenflash {
  position: fixed;
  inset: 0;
  z-index: 41;
  pointer-events: none;
  background: radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 0.95), rgba(255, 160, 195, 0.55) 40%, transparent 75%);
  animation: flashOut 0.8s ease-out forwards;
}
main.shake { animation: quake 0.6s ease; }

/* ---------- Fireworks canvas ---------- */
.fxcanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 45;
  pointer-events: none;
}
.intro.quake { animation: quake 0.6s ease; }

/* ---------- Our bond ---------- */
.bond { text-align: center; }
.bondline {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 6px;
  margin: 1.4rem 0 1.4rem;
}
.person { display: grid; justify-items: center; gap: 4px; }
.avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.7rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #ff8fab, #c43d64);
  box-shadow: 0 0 0 5px var(--glow), 0 8px 20px -8px var(--rose);
}
.person:first-child .avatar { animation: leanR 3s ease-in-out infinite; }
.person:last-child .avatar { animation: leanL 3s ease-in-out infinite; }
.pname { font-size: 1.45rem; color: var(--rose); line-height: 1.1; }
.link { position: relative; height: 60px; min-width: 0; }
.link svg { display: block; width: 100%; height: 100%; overflow: visible; }
.ecg-base { fill: none; stroke: var(--card-border); stroke-width: 2; }
.ecg {
  fill: none;
  stroke: var(--rose);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 30 70;
  animation: ecg 1.8s linear infinite;
  filter: drop-shadow(0 0 4px var(--rose));
}
.link-heart {
  position: absolute;
  left: 50%;
  top: -16px;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--rose);
  transform: translate(-50%, -50%);
  animation: heartbeatCentered 1.2s ease-in-out infinite;
}
.bond-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 1.6rem; }
.stat { padding: 12px 8px; border-radius: 14px; background: var(--bg-2); border: 1px solid var(--card-border); }
.stat b { display: block; font-size: 1.9rem; color: var(--rose); line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 0.95rem; color: var(--muted); line-height: 1.3; display: block; }
.meter-title { margin: 0 0 0.5rem; font-size: 0.85rem; letter-spacing: 0.25em; text-transform: uppercase; color: var(--muted); }
.meter {
  height: 18px;
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid var(--card-border);
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff8fab, var(--rose));
}
.meter.over { animation: jitter 0.12s linear infinite; box-shadow: 0 0 18px var(--rose); }
.meter.over .meter-fill, .meter.done .meter-fill {
  background: linear-gradient(90deg, #ff8fab, var(--rose), #ffd166, var(--rose), #ff8fab);
  background-size: 200% 100%;
  animation: shimmer 1s linear infinite;
}
.meter.done { animation: none; box-shadow: 0 0 24px var(--gold); }
.meter-val { margin: 0.5rem 0 0; font-size: 2.6rem; font-weight: 600; color: var(--rose); font-variant-numeric: tabular-nums; line-height: 1.1; }
.meter-val.big { font-size: 3.4rem; animation: pop 0.6s ease; }
.bond-heart {
  display: block;
  margin: 0.4rem auto 0;
  width: 116px;
  height: 116px;
  border: 0;
  padding: 0;
  background: none;
  color: var(--rose);
  font-size: 5.8rem;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  animation: heartbeat 1.6s ease-in-out infinite;
}
.bond-heart.holding { animation: holdPulse 0.28s ease-in-out infinite; text-shadow: 0 0 24px var(--rose); }
.meter-msg { margin: 0.3rem 0 0; font-style: italic; font-size: 1.25rem; min-height: 1.6em; }
.btn.ghost-rose { background: transparent; color: var(--rose); border: 1.5px solid var(--rose); box-shadow: none; }

/* ---------- Cinematic ending ---------- */
.ending {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  text-align: center;
  overflow: hidden;
  padding: calc(24px + var(--safe-top)) calc(20px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(20px + var(--safe-left));
  background: radial-gradient(120% 80% at 50% 100%, #4a1430 0%, #1e0a14 55%, #0d0509 100%);
  color: #fff3f6;
  animation: fadeIn 1.2s ease;
}
.stars { position: absolute; inset: 0; pointer-events: none; }
.stars span {
  position: absolute;
  border-radius: 50%;
  background: #fff;
  opacity: 0.15;
  animation: twinkleStar ease-in-out infinite;
}
.end-line {
  position: relative;
  max-width: 18ch;
  margin: 0;
  font-size: clamp(1.8rem, 7.5vw, 2.5rem);
  font-style: italic;
  line-height: 1.35;
  opacity: 0;
}
.end-line.show { animation: lineInOut 3s ease forwards; }
.end-final { position: relative; display: grid; justify-items: center; gap: 0.5rem; animation: fadeUp 1.2s ease; }
.heart-wrap { filter: drop-shadow(0 0 26px rgba(255, 105, 150, 0.8)); animation: heartbeat 1.8s ease-in-out infinite; }
.heart-photo {
  width: min(250px, 64vw);
  aspect-ratio: 100 / 92;
  -webkit-mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 92'%3E%3Cpath d='M50 90C20 68 0 50 0 28 0 12 12 0 27 0c10 0 18 6 23 14C55 6 63 0 73 0c15 0 27 12 27 28 0 22-20 40-50 62z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 92'%3E%3Cpath d='M50 90C20 68 0 50 0 28 0 12 12 0 27 0c10 0 18 6 23 14C55 6 63 0 73 0c15 0 27 12 27 28 0 22-20 40-50 62z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.heart-photo img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center 28%; }
.end-title { margin: 0.5rem 0 0; font-size: clamp(2.6rem, 12vw, 3.6rem); color: #ff8fab; line-height: 1.1; text-shadow: 0 0 22px rgba(255, 105, 150, 0.65); }
.end-sign { margin: 0; font-size: 1.4rem; font-style: italic; }
.end-sub { margin: 0.2rem 0 1rem; max-width: 22ch; font-size: 1.3rem; font-style: italic; line-height: 1.4; color: #f3c6d3; }
.end-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.end-btns .btn { margin: 0; }
.btn.ghost { background: transparent; color: #fff3f6; border: 1.5px solid rgba(255, 255, 255, 0.45); box-shadow: none; }

footer {
  text-align: center;
  color: var(--muted);
  font-style: italic;
  padding: 1rem 0 calc(2rem + var(--safe-bottom));
}

/* ---------- Hover effects only where a real pointer exists (avoids sticky hover on iPhone) ---------- */
@media (hover: hover) and (pointer: fine) {
  .btn:hover { transform: translateY(-2px); box-shadow: 0 14px 28px -10px var(--rose); }
  .fact:hover { transform: translateY(-4px) rotate(-0.5deg); }
  .polaroid:hover { transform: rotate(0deg) scale(1.03); }
  .envelope:hover { animation-play-state: paused; }
}

/* ---------- Small phones (iPhone 15 = 393px wide) ---------- */
@media (max-width: 560px) {
  .polaroids { grid-template-columns: 1fr; max-width: 330px; margin: 0 auto; }
  .tilt-right { margin-top: 0; }
}
@media (max-width: 430px) {
  body { font-size: 1.15rem; }
  .timer { gap: 6px; }
  .unit { padding: 12px 2px 8px; border-radius: 12px; }
  .lbl { font-size: 0.66rem; letter-spacing: 0.05em; }
  .letter p { font-size: 1.22rem; line-height: 1.7; }
  .reason { font-size: 1.35rem; }
  .eyebrow { letter-spacing: 0.2em; }
  .big-heart { width: 120px; height: 120px; font-size: 6rem; }
}

/* ---------- Keyframes ---------- */
@keyframes fadeOut { to { opacity: 0; visibility: hidden; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(8px); } }
@keyframes breathe { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes twinkle {
  0%, 100% { opacity: 0; scale: 0.4; rotate: 0deg; }
  50% { opacity: 1; scale: 1.15; rotate: 45deg; }
}
@keyframes shake {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-4deg); }
  40% { transform: rotate(4deg); }
  60% { transform: rotate(-3deg); }
  80% { transform: rotate(2deg); }
}
@keyframes sealPop {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  40% { transform: translate(-50%, -50%) scale(1.5); opacity: 1; }
  100% { transform: translate(-50%, -80%) scale(0); opacity: 0; }
}
@keyframes flapOpen {
  0% { transform: rotateX(0deg); z-index: 4; }
  49% { z-index: 4; }
  50% { z-index: 1; }
  100% { transform: rotateX(180deg); z-index: 1; }
}
@keyframes letterRise { to { transform: translateY(-62%); } }
@keyframes zoomAway { to { transform: scale(1.35); opacity: 0; } }
@keyframes flash { 0% { opacity: 0; } 25% { opacity: 1; } 100% { opacity: 0; } }
@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.12); }
  30% { transform: scale(1); }
  45% { transform: scale(1.08); }
}
@keyframes heartbeatCentered {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  15% { transform: translate(-50%, -50%) scale(1.15); }
  30% { transform: translate(-50%, -50%) scale(1); }
  45% { transform: translate(-50%, -50%) scale(1.1); }
}
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes fly {
  0% { transform: translate(-50%, -50%) scale(0.3) rotate(0deg); opacity: 1; }
  55% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1) rotate(var(--rot)); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy) + var(--fall, 90px))) scale(0.8) rotate(calc(var(--rot) * 2)); opacity: 0; }
}
@keyframes ring {
  0% { transform: translate(-50%, -50%) scale(0.2); opacity: 0.8; }
  100% { transform: translate(-50%, -50%) scale(7); opacity: 0; }
}

@keyframes orbit {
  from { transform: translate(-50%, -50%) rotate(0deg) translateX(48px) rotate(0deg); }
  to   { transform: translate(-50%, -50%) rotate(360deg) translateX(48px) rotate(-360deg); }
}
@keyframes wobble {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px) rotate(-2deg); }
  40% { transform: translateX(9px) rotate(2deg); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}
@keyframes rainFall {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 0; }
  10% { opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translate(var(--sway, 0px), 112vh) rotate(var(--spin, 90deg)); opacity: 0; }
}
@keyframes bloomUp {
  0% { transform: translateY(0) scale(0.2) rotate(-25deg); opacity: 0; }
  20% { opacity: 1; }
  60% { transform: translateY(calc(var(--h) * -1)) scale(1.15) rotate(8deg); opacity: 1; }
  100% { transform: translateY(calc(var(--h) * -1 - 40px)) scale(1) rotate(0deg); opacity: 0; }
}
@keyframes sunRise {
  0% { transform: translate(-50%, 0) scale(0.6); opacity: 0; }
  20% { opacity: 1; }
  60% { transform: translate(-50%, -55vh) scale(1.1); opacity: 1; }
  100% { transform: translate(-50%, -62vh) scale(1.2); opacity: 0; }
}
@keyframes giantPop {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
  25% { transform: translate(-50%, -50%) scale(1.15); opacity: 0.95; }
  40% { transform: translate(-50%, -50%) scale(0.95); }
  55% { transform: translate(-50%, -50%) scale(1.08); }
  75% { opacity: 0.9; }
  100% { transform: translate(-50%, -50%) scale(1.6); opacity: 0; }
}
@keyframes heartWipe {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
  50% { transform: translate(-50%, -50%) scale(8); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(10); opacity: 0; }
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes lockOut { to { transform: scale(0.6) rotate(-4deg); opacity: 0; } }
@keyframes dropIn {
  0% { transform: translateY(-60vh) scale(0.4) rotate(-20deg); opacity: 0; }
  60% { transform: translateY(12px) scale(1.12) rotate(4deg); opacity: 1; }
  80% { transform: translateY(-6px) scale(0.97) rotate(-2deg); }
  100% { transform: none; opacity: 1; }
}
@keyframes vortexIn {
  0% { transform: translate(-50%, -50%) rotate(var(--a)) translateX(var(--r)) scale(1.3); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translate(-50%, -50%) rotate(calc(var(--a) + 540deg)) translateX(0) scale(0.2); opacity: 0.9; }
}
@keyframes flashOut { 0% { opacity: 0; } 20% { opacity: 1; } 100% { opacity: 0; } }
@keyframes quake {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-8px, 4px); }
  30% { transform: translate(7px, -5px); }
  45% { transform: translate(-6px, -3px); }
  60% { transform: translate(5px, 4px); }
  80% { transform: translate(-3px, 2px); }
}
@keyframes leanR { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(6px) rotate(4deg); } }
@keyframes leanL { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(-6px) rotate(-4deg); } }
@keyframes ecg { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
@keyframes shimmer { from { background-position: 0% 0; } to { background-position: 200% 0; } }
@keyframes jitter {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-2px, 1px); }
  50% { transform: translate(2px, -1px); }
  75% { transform: translate(-1px, -1px); }
}
@keyframes holdPulse { 0%, 100% { transform: scale(1.05); } 50% { transform: scale(1.18); } }
@keyframes twinkleStar { 0%, 100% { opacity: 0.12; } 50% { opacity: 0.9; } }
@keyframes lineInOut {
  0% { opacity: 0; transform: translateY(14px); filter: blur(6px); }
  22% { opacity: 1; transform: none; filter: blur(0); }
  78% { opacity: 1; transform: none; filter: blur(0); }
  100% { opacity: 0; transform: translateY(-10px); filter: blur(4px); }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
  .hero > *, .reveal { opacity: 1; transform: none; }
  .twinkle { opacity: 0.8; }
}
