:root {
  --linen: #f3e6d4;
  --paper: #fff8ee;
  --ink: #3a2c24;
  --ink-soft: #6a5348;
  --rose: #c48472;
  --rose-deep: #a45c4c;
  --blush: #e8cfc4;
  --envelope: #d9b4a6;
  --envelope-deep: #c49a8c;
  --seal: #9b3d3d;
  --sage: #7a8b6a;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
}

body {
  background: var(--linen);
  color: var(--ink);
  font-family: "Source Serif 4", Georgia, serif;
  overflow-x: hidden;
}

.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 8;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ── envelope stage ── */
.stage {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px 64px;
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.stage.away {
  opacity: 0;
  transform: translateY(-24px);
  pointer-events: none;
  position: absolute;
  inset: 0;
}

.from-line {
  font-family: Nunito, sans-serif;
  font-size: 11px;
  letter-spacing: 0.38em;
  text-transform: uppercase;
  color: var(--rose-deep);
  margin-bottom: 36px;
}

.envelope {
  position: relative;
  width: min(340px, 86vw);
  height: 220px;
  border: 0;
  background: transparent;
  cursor: pointer;
  transform: rotate(-2.5deg);
  transform-style: preserve-3d;
  perspective: 800px;
  transition: transform 0.4s ease;
}

.envelope:hover,
.envelope:focus-visible {
  transform: rotate(0deg) translateY(-6px);
}

.envelope-shadow {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -18px;
  height: 28px;
  background: rgba(80, 50, 40, 0.18);
  filter: blur(16px);
  border-radius: 50%;
}

.envelope-pocket,
.envelope-front,
.envelope-flap {
  position: absolute;
  inset: 0;
}

.envelope-pocket {
  background: var(--envelope-deep);
  clip-path: polygon(0 38%, 50% 72%, 100% 38%, 100% 100%, 0 100%);
  z-index: 2;
}

.envelope-front {
  background: var(--envelope);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: 12px;
  z-index: 3;
  box-shadow: 0 18px 40px rgba(90, 40, 30, 0.12);
}

.envelope-front::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 42%, var(--envelope-deep) 42.2%, var(--envelope-deep) 100%);
  clip-path: polygon(0 42%, 50% 78%, 100% 42%, 100% 100%, 0 100%);
}

.to-script {
  position: relative;
  z-index: 1;
  font-family: "Great Vibes", cursive;
  font-size: 64px;
  color: #5c332c;
  line-height: 1;
}

.to-date {
  position: relative;
  z-index: 1;
  font-family: Nunito, sans-serif;
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: #7a4e44;
  margin-top: 4px;
}

.envelope-flap {
  background: #e3c4b8;
  clip-path: polygon(0 0, 50% 54%, 100% 0);
  transform-origin: top center;
  z-index: 4;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  backface-visibility: hidden;
}

.envelope.opening .envelope-flap {
  transform: rotateX(180deg);
}

.seal {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 5;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #c45c5c, var(--seal));
  color: #f8e4d8;
  font-family: Fraunces, serif;
  font-size: 16px;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 0 #7a2c2c;
}

.hint {
  margin-top: 40px;
  font-family: Nunito, sans-serif;
  font-size: 12px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ── opened card ── */
.card {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 22px 96px;
  animation: rise 1s ease both;
}

.card[hidden] { display: none; }

@keyframes rise {
  from { opacity: 0; transform: translateY(28px); }
  to { opacity: 1; transform: none; }
}

.hero {
  text-align: center;
  padding: 48px 12px 24px;
}

.hero-kicker,
.nana-kicker {
  font-family: Nunito, sans-serif;
  font-size: 11px;
  letter-spacing: 0.36em;
  text-transform: uppercase;
  color: var(--rose-deep);
  margin-bottom: 12px;
}

.hero-thirty {
  font-family: Fraunces, serif;
  font-weight: 300;
  font-style: italic;
  font-size: clamp(72px, 22vw, 148px);
  line-height: 0.8;
  color: var(--rose-deep);
}

.hero-name {
  font-family: "Great Vibes", cursive;
  font-size: clamp(64px, 18vw, 120px);
  font-weight: 400;
  color: var(--ink);
  margin-top: -8px;
}

.hero-wish {
  margin-top: 8px;
  font-family: Fraunces, serif;
  font-style: italic;
  font-weight: 300;
  font-size: 22px;
  color: var(--ink-soft);
}

.letter {
  background: var(--paper);
  margin: 40px 0 72px;
  padding: clamp(28px, 6vw, 56px);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.8) inset,
    0 24px 50px rgba(90, 40, 20, 0.08);
  border: 1px solid rgba(180, 130, 110, 0.18);
}

.letter p {
  font-size: 1.15rem;
  line-height: 1.85;
  margin-bottom: 1.15em;
}

.letter p:first-child {
  font-family: "Great Vibes", cursive;
  font-size: 2.2rem;
  margin-bottom: 0.4em;
}

.letter-close {
  font-family: Fraunces, serif;
  font-style: italic;
  font-size: 1.35rem !important;
  color: var(--rose-deep);
  margin-top: 1.6em;
  margin-bottom: 0 !important;
}

/* ── nana ── */
.nana {
  text-align: center;
}

.nana h2 {
  font-family: Fraunces, serif;
  font-weight: 300;
  font-size: clamp(28px, 6vw, 44px);
  line-height: 1.2;
  margin: 8px 0 18px;
}

.nana-lede {
  max-width: 38em;
  margin: 0 auto 36px;
  color: var(--ink-soft);
  line-height: 1.7;
  font-size: 1.05rem;
}

.player {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 460px;
  margin: 0 auto 48px;
  padding: 16px 18px;
  background: var(--paper);
  border: 1px solid rgba(180, 130, 110, 0.22);
  text-align: left;
}

.player[hidden],
.player-missing[hidden] { display: none; }

.play {
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: var(--rose-deep);
  color: #fff8ee;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

.play.playing {
  background: var(--sage);
}

.player-title {
  font-family: Fraunces, serif;
  font-size: 1.05rem;
}

.player-sub {
  font-family: Nunito, sans-serif;
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 2px;
}

.bars {
  margin-left: auto;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 22px;
}

.bars span {
  width: 3px;
  background: var(--blush);
  height: 40%;
  animation: none;
}

.player.playing .bars span {
  animation: bounce 1s ease-in-out infinite;
}
.player.playing .bars span:nth-child(2) { animation-delay: 0.1s; height: 70%; }
.player.playing .bars span:nth-child(3) { animation-delay: 0.2s; height: 100%; }
.player.playing .bars span:nth-child(4) { animation-delay: 0.15s; height: 55%; }
.player.playing .bars span:nth-child(5) { animation-delay: 0.05s; height: 80%; }

@keyframes bounce {
  0%, 100% { transform: scaleY(0.45); }
  50% { transform: scaleY(1); }
}

.player-missing {
  font-family: Nunito, sans-serif;
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 36px;
}

.polaroids {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 22px;
  padding: 8px 0 24px;
}

.polaroid {
  background: #fff;
  padding: 10px 10px 36px;
  width: min(220px, 44vw);
  box-shadow: 0 14px 30px rgba(80, 40, 20, 0.12);
  transform: rotate(var(--tilt, -2deg));
}

.polaroid:nth-child(even) { --tilt: 2.4deg; }
.polaroid:nth-child(3n) { --tilt: -1.2deg; }

.polaroid img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #efe4d8;
}

.close {
  text-align: center;
  padding: 80px 12px 20px;
}

.close-script {
  font-family: "Great Vibes", cursive;
  font-size: clamp(36px, 8vw, 56px);
}

.close-date {
  font-family: Nunito, sans-serif;
  font-size: 11px;
  letter-spacing: 0.4em;
  color: var(--rose-deep);
  margin-top: 10px;
}

@media (max-width: 520px) {
  .letter p { font-size: 1.05rem; }
  .polaroid { width: 46vw; padding-bottom: 28px; }
}
