:root {
  --bg-cream: #f8ebdd;
  --bg-blush: #eeb8a2;
  --bg-coral: #d4735f;
  --bg-wine: #6d2433;
  --ink: #39161e;
  --paper: #fff8ef;
  --paper-edge: #f0d8bb;
  --paper-line: rgba(95, 37, 51, 0.12);
  --gold: #f3c56f;
  --gold-deep: #d89b36;
  --seal: #b9354f;
  --seal-deep: #7f2037;
  --shadow: 0 28px 60px rgba(80, 26, 35, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  position: relative;
  overflow-x: hidden;
  font-family: "Garamond", "Times New Roman", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.48), transparent 22%),
    radial-gradient(circle at 84% 24%, rgba(255, 232, 186, 0.46), transparent 18%),
    linear-gradient(145deg, var(--bg-cream) 0%, var(--bg-blush) 34%, var(--bg-coral) 68%, var(--bg-wine) 100%);
}

.sky,
.grain,
.spark-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.sky-one {
  background:
    radial-gradient(circle at 12% 78%, rgba(255, 252, 234, 0.18), transparent 22%),
    radial-gradient(circle at 90% 82%, rgba(255, 223, 177, 0.18), transparent 20%);
  filter: blur(8px);
}

.sky-two {
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.08), transparent 30%),
    linear-gradient(300deg, rgba(109, 36, 51, 0.16), transparent 40%);
}

.grain {
  opacity: 0.18;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(57, 22, 30, 0.08) 1px, transparent 1px);
  background-size: 22px 22px;
  mix-blend-mode: soft-light;
}

.stage {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  align-content: center;
  gap: 24px;
  padding: 28px 20px 36px;
}

.intro {
  width: min(100%, 820px);
  margin: 0 auto;
  text-align: center;
}

.kicker {
  margin: 0 0 14px;
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
  font-size: 1.25rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(255, 248, 239, 0.84);
}

h1 {
  margin: 0;
  font-size: clamp(2.4rem, 7vw, 5.2rem);
  line-height: 0.94;
  letter-spacing: -0.05em;
  color: #fff9f1;
  text-wrap: balance;
  text-shadow: 0 10px 30px rgba(77, 20, 32, 0.18);
}

.lede {
  width: min(100%, 42rem);
  margin: 18px auto 0;
  font-size: 1.08rem;
  line-height: 1.7;
  color: rgba(255, 241, 230, 0.92);
}

.letter-stage {
  position: relative;
  width: min(100%, 860px);
  margin: 0 auto;
  padding-top: 18px;
}

.halo {
  position: absolute;
  left: 50%;
  top: 42%;
  width: min(72vw, 520px);
  height: min(72vw, 520px);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 239, 208, 0.42), transparent 64%);
  filter: blur(16px);
  pointer-events: none;
}

.note-shell {
  position: relative;
  width: min(100%, 620px);
  height: 470px;
  margin: 0 auto;
  pointer-events: none;
}

.note-card {
  position: absolute;
  left: 50%;
  bottom: 92px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  width: min(92vw, 500px);
  min-height: 260px;
  padding: 28px 30px 30px;
  border: 1px solid rgba(120, 56, 42, 0.18);
  border-radius: 22px 22px 18px 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.5), transparent 20%),
    repeating-linear-gradient(
      180deg,
      transparent,
      transparent 31px,
      var(--paper-line) 31px,
      var(--paper-line) 32px
    ),
    var(--paper);
  box-shadow:
    0 8px 0 var(--paper-edge),
    0 24px 42px rgba(92, 37, 42, 0.14);
  transform: translateX(-50%) translateY(170px) rotate(1.5deg);
  transform-origin: bottom center;
  opacity: 0;
  transition:
    transform 900ms cubic-bezier(0.21, 0.9, 0.22, 1),
    opacity 420ms ease;
}

.note-card.is-text-mode {
  align-items: center;
  justify-content: flex-start;
  text-align: center;
}

.note-card.is-visual-mode {
  justify-content: center;
}

.note-card::after {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(146, 95, 57, 0.08);
  border-radius: 14px;
}

.note-tag {
  margin: 0;
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
  font-size: 0.76rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(84, 34, 41, 0.56);
}

.note-line {
  margin: 24px 0 0;
  min-height: 124px;
  font-family: "Palatino Linotype", "Book Antiqua", serif;
  font-size: clamp(1.6rem, 4.8vw, 2.55rem);
  line-height: 1.16;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.note-card.is-text-mode .note-line {
  width: 100%;
  margin: 58px 0 0;
  min-height: 0;
  max-width: 82%;
  align-self: center;
  text-wrap: balance;
}

.note-line.is-swapping {
  animation: line-swap 420ms ease;
}

.note-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  min-height: 124px;
  margin-top: 24px;
  opacity: 0;
  transform: translateY(12px) scale(0.96);
}

.note-card.is-visual-mode .note-visual {
  margin-top: 0;
  min-height: 0;
}

.note-visual.is-active {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.kiss-emoji {
  --kiss-tilt: 0deg;
  display: inline-block;
  font-size: clamp(2.2rem, 10vw, 4.2rem);
  line-height: 1;
  opacity: 0;
  transform: translateY(22px) scale(0.45) rotate(var(--kiss-tilt));
}

.note-visual.is-active .kiss-emoji {
  animation:
    kiss-pop 560ms cubic-bezier(0.22, 0.88, 0.3, 1) forwards,
    kiss-bob 1.7s ease-in-out infinite 620ms;
}

.kiss-emoji:nth-child(1) {
  --kiss-tilt: -12deg;
}

.note-visual.is-active .kiss-emoji:nth-child(2) {
  animation-delay: 80ms, 700ms;
}

.kiss-emoji:nth-child(2) {
  --kiss-tilt: 10deg;
}

.note-visual.is-active .kiss-emoji:nth-child(3) {
  animation-delay: 160ms, 780ms;
}

.kiss-emoji:nth-child(3) {
  --kiss-tilt: -4deg;
}

.note-visual.is-active .kiss-emoji:nth-child(4) {
  animation-delay: 240ms, 860ms;
}

.kiss-emoji:nth-child(4) {
  --kiss-tilt: 14deg;
}

.note-visual.is-active .kiss-emoji:nth-child(5) {
  animation-delay: 320ms, 940ms;
}

.kiss-emoji:nth-child(5) {
  --kiss-tilt: -10deg;
}

.note-signoff {
  margin: 12px 0 0;
  font-family: "Lucida Handwriting", "Brush Script MT", cursive;
  font-size: 1.08rem;
  color: rgba(72, 24, 31, 0.74);
}

.envelope {
  position: absolute;
  left: 50%;
  bottom: 0;
  z-index: 2;
  width: min(92vw, 520px);
  aspect-ratio: 1.2 / 0.76;
  transform: translateX(-50%);
  filter: drop-shadow(0 28px 36px rgba(79, 26, 35, 0.16));
  transition: transform 900ms cubic-bezier(0.21, 0.9, 0.22, 1);
}

.envelope-shadow {
  position: absolute;
  left: 11%;
  right: 11%;
  bottom: -20px;
  height: 34px;
  border-radius: 50%;
  background: rgba(99, 37, 50, 0.16);
  filter: blur(10px);
}

.envelope-back,
.envelope-front,
.envelope-flap,
.envelope-letter-slot,
.seal {
  position: absolute;
}

.envelope-back,
.envelope-letter-slot {
  inset: 0;
  border-radius: 24px;
  background: linear-gradient(180deg, #f7ddbd, #e8c69c);
}

.envelope-letter-slot {
  inset: 18px 16px 16px;
  border-radius: 16px;
  background: linear-gradient(180deg, #d8af82, #f0d6b5);
}

.envelope-front {
  left: 0;
  right: 0;
  bottom: 0;
  height: 72%;
  border-radius: 24px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.2), transparent 42%),
    linear-gradient(180deg, #f6e1c4, #e8c29b);
  clip-path: polygon(0 100%, 0 0, 50% 62%, 100% 0, 100% 100%);
}

.envelope-front::before,
.envelope-front::after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 50%;
  height: 100%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 32%);
}

.envelope-front::before {
  left: 0;
  clip-path: polygon(0 100%, 0 0, 100% 62%);
}

.envelope-front::after {
  right: 0;
  clip-path: polygon(100% 100%, 0 62%, 100% 0);
}

.envelope-flap {
  inset: 0;
  z-index: 4;
  transform-origin: top center;
  transition: transform 880ms cubic-bezier(0.22, 0.86, 0.2, 1);
  background: linear-gradient(180deg, #fbebd4, #e5ba8f);
  clip-path: polygon(0 0, 50% 72%, 100% 0);
}

.seal {
  left: 50%;
  top: 42%;
  z-index: 5;
  width: 72px;
  height: 72px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #d85d79, var(--seal) 58%, var(--seal-deep));
  display: grid;
  place-items: center;
  box-shadow:
    inset 0 2px 6px rgba(255, 255, 255, 0.18),
    0 14px 24px rgba(92, 24, 41, 0.22);
  transition:
    transform 300ms ease,
    opacity 220ms ease;
}

.seal-heart {
  position: relative;
  width: 18px;
  height: 18px;
  transform: rotate(45deg);
  background: rgba(255, 245, 246, 0.96);
  border-radius: 2px;
}

.seal-heart::before,
.seal-heart::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: inherit;
}

.seal-heart::before {
  left: -9px;
}

.seal-heart::after {
  top: -9px;
}

.controls {
  position: relative;
  z-index: 6;
  display: grid;
  place-items: center;
  gap: 14px;
  margin-top: 12px;
}

.letter-button {
  width: min(100%, 340px);
  min-width: 230px;
  padding: 16px 28px;
  border: 0;
  border-radius: 999px;
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fffaf2;
  cursor: pointer;
  background: linear-gradient(180deg, var(--gold), var(--gold-deep));
  box-shadow:
    0 18px 24px rgba(104, 52, 18, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.42);
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    filter 160ms ease;
}

.letter-button:hover {
  transform: translateY(-3px);
  filter: saturate(1.05);
  box-shadow:
    0 24px 30px rgba(104, 52, 18, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.46);
}

.letter-button:active {
  transform: translateY(1px);
}

.letter-button:focus-visible {
  outline: 3px solid rgba(255, 248, 239, 0.92);
  outline-offset: 4px;
}

.button-note {
  margin: 0;
  max-width: 26rem;
  text-align: center;
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
  font-size: 0.92rem;
  color: rgba(255, 245, 235, 0.88);
}

body.is-open .note-card {
  opacity: 1;
  transform: translateX(-50%) translateY(-52px) rotate(-1.2deg);
}

body.is-open .envelope {
  transform: translateX(-50%) translateY(22px) scale(0.98);
}

body.is-open .envelope-flap {
  transform: rotateX(180deg);
}

body.is-open .seal {
  transform: translate(-50%, -50%) scale(0.7);
  opacity: 0;
}

.spark-layer {
  z-index: 7;
  overflow: hidden;
}

.rose-particle {
  position: fixed;
  left: 0;
  top: 0;
  pointer-events: none;
  z-index: 8;
  user-select: none;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.15));
  will-change: transform, opacity;
}

.rose-pulse {
  position: fixed;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  pointer-events: none;
  z-index: 7;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background:
    radial-gradient(circle, rgba(255, 252, 245, 0.98) 0 18%, rgba(255, 198, 210, 0.86) 28%, rgba(244, 114, 182, 0.22) 58%, transparent 72%);
  filter: blur(1px);
  animation: rose-pulse 900ms ease-out forwards;
}

.floating-rose {
  position: fixed;
  bottom: -12vh;
  left: 0;
  pointer-events: none;
  z-index: 6;
  opacity: 0;
  user-select: none;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.12));
  animation: rose-float-up var(--float-duration) linear forwards;
  animation-delay: var(--float-delay);
}

@keyframes line-swap {
  0% {
    opacity: 0;
    transform: translateY(16px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes kiss-bob {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  50% {
    transform: translateY(-12px) scale(1.08);
  }
}

@keyframes kiss-pop {
  0% {
    opacity: 0;
    transform: translateY(22px) scale(0.45) rotate(calc(var(--kiss-tilt) - 8deg));
  }

  65% {
    opacity: 1;
    transform: translateY(-6px) scale(1.08) rotate(calc(var(--kiss-tilt) + 4deg));
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(var(--kiss-tilt));
  }
}

@keyframes rose-pulse {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.2);
  }

  20% {
    opacity: 0.95;
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(11);
  }
}

@keyframes rose-float-up {
  0% {
    transform: translate3d(0, 0, 0) rotate(0deg) scale(0.8);
    opacity: 0;
  }

  12% {
    opacity: 0.72;
  }

  88% {
    opacity: 0.72;
  }

  100% {
    transform:
      translate3d(var(--float-drift), calc(-100vh - var(--float-rise)), 0)
      rotate(var(--float-rotate))
      scale(var(--float-scale));
    opacity: 0;
  }
}

@media (max-width: 720px) {
  .stage {
    align-content: start;
    padding-top: 24px;
    gap: 18px;
  }

  .lede {
    font-size: 1rem;
  }

  .note-shell {
    height: 420px;
  }

  .note-card {
    min-height: 232px;
    padding: 24px 22px 24px;
  }

  .note-visual {
    gap: 10px;
  }

  .note-line {
    min-height: 110px;
    margin-top: 18px;
  }

  body.is-open .note-card {
    transform: translateX(-50%) translateY(-34px) rotate(-1deg);
  }
}

@media (max-width: 520px) {
  .stage {
    padding-left: 14px;
    padding-right: 14px;
    padding-bottom: 28px;
  }

  .intro {
    width: min(100%, 24rem);
  }

  .kicker {
    font-size: 1rem;
    letter-spacing: 0.22em;
  }

  .note-shell {
    height: 388px;
  }

  .note-card {
    bottom: 74px;
    min-height: 218px;
    border-radius: 18px 18px 14px 14px;
  }

  .note-visual {
    gap: 8px;
  }

  .note-card.is-text-mode .note-line {
    margin-top: 48px;
    max-width: 90%;
  }

  .note-tag {
    font-size: 0.68rem;
  }

  .note-signoff {
    font-size: 1rem;
  }

  .seal {
    width: 60px;
    height: 60px;
  }

  .button-note {
    font-size: 0.88rem;
  }
}

@media (max-width: 390px) {
  .note-shell {
    height: 372px;
  }

  .note-card {
    bottom: 68px;
    padding: 20px 18px 20px;
  }

  .note-card.is-text-mode .note-line {
    margin-top: 42px;
  }

  .note-line {
    min-height: 98px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .note-card,
  .envelope,
  .envelope-flap,
  .seal,
  .letter-button {
    transition: none;
  }

  .note-line.is-swapping,
  .kiss-emoji,
  .rose-pulse,
  .floating-rose {
    animation: none;
  }
}
