:root {
  --ink: #4a2030;
  --rose: #9f1d45;
  --rose-deep: #7c1636;
  --muted: #8d5a6b;
  --cream: #fffdfb;
  --line: rgba(159, 29, 69, 0.16);
  --shadow: 0 18px 40px rgba(120, 28, 56, 0.12);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  font-family: Nunito, "Segoe UI", sans-serif;
  background:
    radial-gradient(900px 420px at 50% -8%, #fff 0%, transparent 60%),
    linear-gradient(180deg, #fff6f8 0%, #f7d5e0 100%);
}

body.card-page {
  min-height: 100vh;
  background: linear-gradient(180deg, #fff6f8 0%, #f4c9d4 100%);
}

body.qr-only {
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

body.qr-only canvas {
  width: min(100%, 460px);
  height: auto;
  display: block;
  cursor: pointer;
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.sky {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.floater {
  position: absolute;
  top: 110%;
  color: #e25b86;
  opacity: 0.35;
  animation: float-up linear infinite;
}

.love-intro {
  position: fixed;
  inset: 0;
  z-index: 30;
  overflow: hidden;
  pointer-events: auto;
  background: linear-gradient(180deg, #fff6f8 0%, #f4c9d4 100%);
}

.love-intro.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.7s ease, visibility 0.7s ease;
}

.love-hint {
  position: absolute;
  left: 50%;
  bottom: 16%;
  z-index: 2;
  width: min(18rem, calc(100% - 2.5rem));
  margin: 0;
  transform: translateX(-50%);
  text-align: center;
  color: var(--rose);
  font-family: Nunito, "Segoe UI", sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
}

.love-intro.needs-tap .love-hint {
  opacity: 1;
}

.love-burst {
  position: absolute;
  bottom: 0;
  width: 1em;
  height: 1em;
  color: #c22555;
  animation-name: love-fly;
  animation-timing-function: linear;
  animation-fill-mode: both;
}

.love-burst svg {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 8px 12px rgba(180, 30, 70, 0.22));
}

.gate,
main,
.card-shell {
  position: relative;
  z-index: 1;
}

.gate {
  min-height: 100vh;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  padding: 2.5rem 1.25rem 3rem;
  gap: 0.4rem;
}

.gate-kicker,
.eyebrow,
.section-kicker {
  margin: 0;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
}

.gate-title {
  margin: 0 0 1.2rem;
  font-family: "Great Vibes", cursive;
  font-size: clamp(3.4rem, 14vw, 5.5rem);
  line-height: 0.9;
  color: var(--rose);
  font-weight: 400;
}

.heart-button {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  display: grid;
  justify-items: center;
  gap: 0.8rem;
  padding: 0;
}

.heart-button:focus-visible,
.shot:focus-visible,
.song-toggle:focus-visible,
.lightbox-btn:focus-visible {
  outline: 3px solid var(--rose);
  outline-offset: 4px;
}

.heart-beat {
  display: grid;
  place-items: center;
  animation: beat 1.35s ease-in-out infinite;
}

.heart-svg {
  width: 148px;
  height: 148px;
  display: block;
  filter: drop-shadow(0 16px 22px rgba(180, 30, 70, 0.28));
}

.heart-label,
.gate-from {
  font-weight: 700;
}

.gate-from {
  margin: 1.4rem 0 0;
  color: var(--muted);
}

.gate { display: none; }
main { display: none; }
html.is-open main { display: block; }

html.just-opened main {
  animation: rise 0.7s ease;
}

.wrap {
  width: min(920px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 3.2rem 0 4rem;
}

.hero { text-align: center; }

.hero h1 {
  margin: 0.35rem 0 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 600;
  font-size: clamp(2.5rem, 8vw, 4.6rem);
  line-height: 0.95;
}

.age {
  margin: 0.2rem 0 0.8rem;
  color: var(--rose);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-weight: 600;
}

.name {
  margin: 0;
  color: var(--rose);
  font-family: "Great Vibes", cursive;
  font-size: clamp(2.5rem, 10vw, 4.6rem);
  font-weight: 400;
  line-height: 0.95;
}

.name span { display: block; }

.hero-note {
  max-width: 34rem;
  margin: 1rem auto 0;
  color: var(--muted);
  line-height: 1.6;
}

.letter {
  margin-top: 2.4rem;
}

.gallery { margin-top: 2.8rem; }

.gallery-head {
  text-align: center;
  margin-bottom: 1.6rem;
}

.gallery-head h2,
.letter h2 {
  margin: 0.2rem 0 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 600;
}

.memory {
  display: grid;
  justify-items: center;
  gap: 0.85rem;
  margin: 0 auto 3.2rem;
  max-width: 520px;
}

.memory:nth-child(even) .polaroid { transform: rotate(-1.4deg); }
.memory:nth-child(odd) .polaroid { transform: rotate(1.2deg); }

.polaroid {
  width: 100%;
  margin: 0;
  background: #fff;
  padding: 0.7rem 0.7rem 1.2rem;
  border-radius: 4px;
  box-shadow: var(--shadow);
}

.shot {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: #f3d5de;
  cursor: pointer;
}

.shot img {
  display: block;
  width: 100%;
  height: min(62vh, 520px);
  object-fit: cover;
}

.memory-note {
  margin: 0;
  text-align: center;
  color: var(--rose);
  font-family: "Great Vibes", cursive;
  font-size: clamp(1.7rem, 5vw, 2.4rem);
  line-height: 1.25;
  max-width: 20em;
  opacity: 0;
  transform: translateY(18px);
}

.reveal {
  opacity: 0;
  transform: translateY(36px);
}

.reveal.is-in {
  opacity: 1;
  transform: none;
  transition: opacity 0.85s ease, transform 0.85s ease;
}

.memory.is-in .memory-note {
  opacity: 1;
  transform: none;
  transition: opacity 0.9s ease 0.22s, transform 0.9s ease 0.22s;
}

.letter {
  background: var(--cream);
  border-radius: 22px;
  padding: 1.5rem 1.25rem 1.4rem;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.letter::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 7px;
  background: linear-gradient(90deg, #9f1d45, #f0a0b6, #9f1d45);
}

.letter p {
  line-height: 1.7;
  margin: 0.85rem 0 0;
}

.sign {
  margin-top: 1.3rem !important;
  font-family: "Great Vibes", cursive;
  font-size: 2.4rem;
  line-height: 1;
  color: var(--rose);
}

.tagline {
  margin-top: 0.15rem !important;
  color: var(--muted);
  font-weight: 700;
}

.closing {
  margin: 3.4rem auto 0;
  max-width: 580px;
  text-align: center;
}

.closing-card {
  margin-bottom: 0;
}

.closing-card .polaroid {
  transform: none;
}

.closing-card .shot img {
  height: min(56vh, 500px);
  object-position: center 38%;
}

.closing-verse {
  margin: 0.2rem auto 0;
  max-width: 22em;
  opacity: 0;
  transform: translateY(18px);
}

.closing-verse p {
  margin: 0.15rem 0 0;
  color: var(--rose);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-size: clamp(1.2rem, 3.4vw, 1.65rem);
  line-height: 1.5;
}

.memory.is-in .closing-verse {
  opacity: 1;
  transform: none;
  transition: opacity 1s ease 0.28s, transform 1s ease 0.28s;
}

.footer-note {
  margin: 2rem 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
}

.lightbox {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  border: 0;
  padding: 0;
  background: rgba(32, 8, 16, 0.94);
  color: #fff;
}

.lightbox::backdrop { background: rgba(32, 8, 16, 0.94); }

.lightbox-img {
  position: absolute;
  inset: 4.5rem 4.5rem;
  width: calc(100% - 9rem);
  height: calc(100% - 9rem);
  margin: auto;
  object-fit: contain;
}

.lightbox-btn {
  position: absolute;
  z-index: 1;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255, 253, 251, 0.92);
  color: var(--rose-deep);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.song-toggle {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 32;
  min-height: 48px;
  padding: 0.65rem 1rem 0.65rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 251, 0.96);
  color: var(--rose);
  box-shadow: var(--shadow);
  cursor: pointer;
  font-family: Nunito, "Segoe UI", sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  animation: song-pulse 1.7s ease-in-out infinite;
}

.song-label { line-height: 1; }
.song-icon-pause { display: none; font-size: 0.7rem; letter-spacing: 0.08em; }
.song-icon-play { font-size: 1.2rem; line-height: 1; }

.song-toggle.is-playing {
  animation: none;
}

.song-toggle.is-playing .song-icon-play { display: none; }
.song-toggle.is-playing .song-icon-pause { display: block; }

.lightbox-close { top: 1rem; right: 1rem; }
.lightbox-prev { top: 50%; left: 0.6rem; transform: translateY(-50%); }
.lightbox-next { top: 50%; right: 0.6rem; transform: translateY(-50%); }

.card-shell {
  width: min(460px, calc(100% - 1.5rem));
  margin: 0 auto;
  padding: 1.4rem 0 2.5rem;
  text-align: center;
}

.back {
  text-align: left;
  margin: 0 0 0.6rem;
}

.back a {
  color: var(--rose-deep);
  font-weight: 700;
  text-decoration: none;
}

.card-shell h1 {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 2.4rem;
  font-weight: 600;
}

.card-shell canvas {
  width: 100%;
  height: auto;
  margin-top: 0.8rem;
  border-radius: 18px;
  box-shadow: var(--shadow);
}

@keyframes beat {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.07); }
}

@keyframes float-up {
  from { transform: translateY(0) rotate(0deg); }
  to { transform: translateY(-115vh) rotate(18deg); }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

@keyframes song-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes love-fly {
  0% {
    transform: translate3d(0, 0, 0) scale(0.86) rotate(-10deg);
    opacity: 1;
  }
  82% { opacity: 1; }
  100% {
    transform: translate3d(var(--drift, 0px), calc(-100vh - 40px), 0) scale(1.12) rotate(14deg);
    opacity: 0;
  }
}

@media (min-width: 800px) {
  .memory { max-width: 580px; }
  .letter { padding: 2rem 2.2rem 1.7rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .floater,
  .heart-beat,
  .love-burst,
  html.just-opened main { animation: none; }
  .song-toggle { animation: none; }
  .love-intro { display: none; }
  .reveal,
  .memory-note,
  .closing-verse {
    opacity: 1;
    transform: none;
    transition: none;
  }
}
