:root {
  --dawn: #f7e8d6;
  --ivory: #fff9ee;
  --forest: #3f5a45;
  --forest-deep: #2f4433;
  --sage: #8fa98a;
  --blush: #e8b4b8;
  --coral: #d97a5f;
  --butter: #f2cc8f;
  --ink: #3a322c;
  --gold: #c9a227;
  --font-display: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --font-body: "Lora", Georgia, "Times New Roman", serif;
  --font-script: "Caveat", "Segoe Script", cursive;
}

* {
  box-sizing: border-box;
}

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

body {
  overflow: hidden;
  background: var(--dawn);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font: inherit;
  color: inherit;
}

button:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 4px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
  opacity: 0.06;
  background-image: radial-gradient(rgba(58, 50, 44, 0.7) 0.5px, transparent 0.6px);
  background-size: 4px 4px;
}

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

.petal {
  position: absolute;
  top: -6vh;
  width: 11px;
  height: 16px;
  border-radius: 60% 0 60% 0;
  opacity: 0.55;
  animation: petal-fall linear infinite;
  will-change: transform;
}

.petal--burst {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 75;
  pointer-events: none;
  opacity: 0.9;
  animation: none;
}

@keyframes petal-fall {
  from {
    transform: translate3d(0, -10vh, 0) rotate(0deg);
  }
  to {
    transform: translate3d(var(--drift, 40px), 112vh, 0) rotate(620deg);
  }
}

/* ---------- scenes ---------- */

.scene {
  position: fixed;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.9s ease, visibility 0.9s ease;
}

.gate-scene {
  z-index: 3;
  display: grid;
  place-items: center;
}

.garden-scene {
  z-index: 2;
  overflow: hidden;
}

body[data-scene="gate"] .gate-scene,
body[data-scene="garden"] .garden-scene,
body[data-scene="finale"] .garden-scene {
  opacity: 1;
  visibility: visible;
}

.gate-scene.is-leaving {
  opacity: 0;
  visibility: hidden;
}

.gate-bg,
.garden-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.garden-art {
  transform: scale(1.045);
  transition: transform 2.2s cubic-bezier(0.22, 1, 0.36, 1);
}

body[data-scene="garden"] .garden-art,
body[data-scene="finale"] .garden-art {
  transform: scale(1);
}

/* ---------- gate ---------- */

.gate-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: max(4vh, 24px) 20px max(3vh, 18px);
  text-align: center;
  transition: transform 1.3s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.8s ease;
}

.gate-scene.is-leaving .gate-content {
  transform: scale(1.1);
  opacity: 0;
}

.gate-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.7rem, 7vw, 5rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.01em;
  color: var(--forest-deep);
  text-shadow: 0 2px 20px rgba(255, 249, 238, 0.65);
}

.gate-sub {
  margin: 0.12em 0 0.55em;
  font-family: var(--font-script);
  font-size: clamp(1.9rem, 4.2vw, 2.9rem);
  font-weight: 600;
  color: #8a5a3b;
  text-shadow: 0 2px 14px rgba(255, 249, 238, 0.55);
}

.gate-frame {
  position: relative;
  width: min(78vw, 380px);
  aspect-ratio: 0.82;
  padding: clamp(10px, 1.8vw, 18px);
  border-radius: 50% 50% 0 0 / 36% 36% 0 0;
  background: linear-gradient(145deg, #d9cbb5, #b9a58a 55%, #cbb99f);
  box-shadow:
    0 30px 60px rgba(58, 50, 44, 0.28),
    inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.gate-frame::after {
  content: "";
  position: absolute;
  inset: 6px;
  z-index: 6;
  border: 1px solid rgba(58, 50, 44, 0.18);
  border-radius: inherit;
  pointer-events: none;
}

.gate {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  overflow: hidden;
  border-radius: 50% 50% 0 0 / 36% 36% 0 0;
  background: var(--forest-deep);
  cursor: pointer;
  perspective: 1100px;
  -webkit-tap-highlight-color: transparent;
}

.gate__glow {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: radial-gradient(circle at 50% 58%, #fff6d8 0%, rgba(255, 246, 216, 0.75) 38%, rgba(255, 246, 216, 0) 70%);
  opacity: 0.3;
  transform: scale(1);
  transition: opacity 1.2s ease, transform 1.5s ease;
}

.gate.is-open .gate__glow {
  opacity: 1;
  transform: scale(1.7);
}

.gate__door {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  width: 50.4%;
  background:
    repeating-linear-gradient(90deg, rgba(58, 50, 44, 0.2) 0 1px, transparent 1px 34px),
    linear-gradient(180deg, #9a6544, #7c4e34 58%, #6b422c);
  transition: transform 1.4s cubic-bezier(0.22, 1, 0.36, 1);
  backface-visibility: hidden;
  will-change: transform;
}

.gate__door::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.2), transparent 18%, transparent 82%, rgba(0, 0, 0, 0.2));
  pointer-events: none;
}

.gate__door--left {
  left: 0;
  transform-origin: left center;
  border-right: 2px solid rgba(58, 50, 44, 0.35);
}

.gate__door--right {
  right: 0;
  transform-origin: right center;
}

.gate.is-open .gate__door--left {
  transform: rotateY(105deg);
}

.gate.is-open .gate__door--right {
  transform: rotateY(-105deg);
}

.gate__brace {
  position: absolute;
  left: 0;
  right: 0;
  height: clamp(10px, 2.6%, 16px);
  background: linear-gradient(#6b422c, #8a5a3b);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.15), 0 3px 6px rgba(0, 0, 0, 0.2);
}

.gate__brace--top {
  top: 18%;
}

.gate__brace--bottom {
  bottom: 16%;
}

.gate__hinge {
  position: absolute;
  width: 27%;
  height: clamp(7px, 1.6%, 10px);
  border-radius: 2px;
  background: linear-gradient(#3a322c, #5a4a3a);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.35);
}

.gate__hinge::before,
.gate__hinge::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #c9b79c;
  transform: translateY(-50%);
}

.gate__hinge::before {
  left: 14%;
}

.gate__hinge::after {
  right: 14%;
}

.gate__door--left .gate__hinge {
  left: 0;
}

.gate__door--right .gate__hinge {
  right: 0;
}

.gate__hinge--1 {
  top: 24%;
}

.gate__hinge--2 {
  bottom: 22%;
}

.gate__handle {
  position: absolute;
  left: 9%;
  top: 51%;
  width: clamp(24px, 6vw, 36px);
  aspect-ratio: 1;
  border: 4px solid #3a322c;
  border-radius: 50%;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.35);
  transform: translateY(-50%);
}

.gate__handle::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c9b79c;
  transform: translate(-50%, -50%);
}

.gate-roses {
  position: absolute;
  inset: -4%;
  z-index: 5;
  width: 108%;
  height: 108%;
  pointer-events: none;
  filter: drop-shadow(0 4px 5px rgba(58, 50, 44, 0.18));
}

.hint {
  margin: 0;
  font-family: var(--font-body);
  font-size: clamp(0.72rem, 1.4vw, 0.84rem);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: #5a4a3a;
  opacity: 0.72;
}

.gate-hint {
  margin-top: clamp(10px, 1.8vh, 18px);
  color: var(--ivory);
  text-shadow: 0 1px 8px rgba(47, 68, 51, 0.55);
  animation: hint-pulse 2.6s ease-in-out infinite;
}

@keyframes hint-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.92; }
}

/* ---------- garden copy ---------- */

.garden-copy {
  position: absolute;
  top: 13%;
  left: 50%;
  width: min(88vw, 760px);
  margin: 0;
  transform: translateX(-50%);
  text-align: center;
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  color: var(--forest);
  text-shadow: 0 2px 16px rgba(255, 249, 238, 0.8);
  opacity: 0;
  transition: opacity 1s ease;
  pointer-events: none;
}

.garden-grown .garden-copy {
  opacity: 1;
  transition-delay: 1.7s;
}

.envelope-visible .garden-copy {
  opacity: 0;
  transition-delay: 0s;
}

/* ---------- flowers ---------- */

.tulip {
  opacity: 0;
  transform: translateY(28px) scale(0.72);
  transform-box: fill-box;
  transform-origin: bottom center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.garden-grown .tulip {
  animation: tulip-rise 0.95s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: var(--delay, 0ms);
}

@keyframes tulip-rise {
  from {
    opacity: 0;
    transform: translateY(28px) scale(0.72);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.tulip-sway {
  transform-box: fill-box;
  transform-origin: bottom center;
}

.garden-grown .tulip-sway {
  animation: tulip-sway 7s ease-in-out infinite alternate;
  animation-delay: var(--sway-delay, 0ms);
}

@keyframes tulip-sway {
  from { transform: rotate(-1.2deg); }
  to { transform: rotate(1.2deg); }
}

.tulip .bloom {
  transform-box: fill-box;
  transform-origin: center bottom;
  transition: transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tulip .petal {
  transform-box: fill-box;
  transform-origin: center bottom;
  transition: transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tulip.is-bloomed .bloom {
  transform: scale(1.13) rotate(2deg);
}

.tulip.is-bloomed .petal--l {
  transform: rotate(-14deg) translate(-2px, -1px);
}

.tulip.is-bloomed .petal--r {
  transform: rotate(14deg) translate(2px, -1px);
}

.tulip.is-bloomed .petal--c {
  transform: scale(1.06);
}

.tulip:focus-visible {
  outline: none;
}

.tulip:focus-visible .bloom {
  filter: drop-shadow(0 0 7px #fff6d8);
}

.b-stem {
  stroke-dasharray: 290;
  stroke-dashoffset: 290;
}

.garden-grown .b-stem {
  animation: draw-stem 1.15s ease forwards;
  animation-delay: var(--d, 0ms);
}

@keyframes draw-stem {
  to { stroke-dashoffset: 0; }
}

.b-flower,
.b-greenery,
.b-wrap,
.b-ribbon {
  opacity: 0;
}

.garden-grown .b-flower {
  animation: flower-pop 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  animation-delay: var(--d, 0ms);
}

.garden-grown .b-greenery {
  animation: soft-in 0.9s ease forwards;
  animation-delay: var(--d, 0ms);
}

.garden-grown .b-wrap {
  animation: soft-in 0.8s ease forwards;
  animation-delay: 80ms;
}

.garden-grown .b-ribbon {
  animation: ribbon-in 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  animation-delay: var(--d, 0ms);
}

.b-flower {
  transform-box: fill-box;
  transform-origin: center;
}

.b-ribbon {
  transform-box: fill-box;
  transform-origin: center;
}

@keyframes flower-pop {
  from { opacity: 0; transform: scale(0); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes soft-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes ribbon-in {
  from { opacity: 0; transform: scale(0.4) rotate(-8deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

/* ---------- envelope ---------- */

.envelope-area {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1.4vh, 16px);
  padding: max(6vh, 24px) 18px max(4vh, 18px);
  text-align: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.8s ease, visibility 0.8s ease;
}

.envelope-visible .envelope-area {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

body[data-scene="finale"] .envelope-area {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.envelope-copy h2 {
  margin: 0 0 0.08em;
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 4.2vw, 3.1rem);
  font-weight: 500;
  line-height: 1.05;
  color: var(--forest-deep);
  text-shadow: 0 2px 18px rgba(255, 249, 238, 0.8);
}

.envelope-copy p {
  margin: 0;
  font-size: clamp(0.98rem, 2vw, 1.15rem);
  color: #5a4a3a;
  text-shadow: 0 1px 10px rgba(255, 249, 238, 0.7);
}

.envelope-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(92vw, 760px);
  height: clamp(300px, 46vh, 430px);
}

.envelope-float {
  position: relative;
  z-index: 2;
  opacity: 0;
  transform: translateY(-56vh) rotate(-4deg);
  transition: transform 3.8s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.7s ease;
  will-change: transform;
}

.envelope-visible .envelope-float {
  opacity: 1;
  transform: translateY(0) rotate(0deg);
}

.envelope-landed .envelope-float {
  animation: envelope-hover 4.5s ease-in-out infinite alternate;
}

.envelope-open .envelope-float {
  animation: none;
  transform: translateY(30%) scale(0.9);
  transition: transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes envelope-hover {
  from { transform: translateY(0) rotate(-0.4deg); }
  to { transform: translateY(-6px) rotate(0.4deg); }
}

.envelope {
  position: relative;
  display: block;
  width: clamp(230px, 28vw, 310px);
  aspect-ratio: 1.5;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  filter: drop-shadow(0 24px 28px rgba(58, 50, 44, 0.28));
  transform-style: preserve-3d;
  -webkit-tap-highlight-color: transparent;
}

.envelope:disabled {
  opacity: 1;
  cursor: default;
}

.envelope:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 10px;
  border-radius: 8px;
}

.env-back,
.env-front,
.env-flap {
  position: absolute;
  inset: 0;
  border-radius: 6px;
}

.env-back {
  background: linear-gradient(160deg, #fff9ee, #f1e2cc);
  box-shadow: inset 0 0 0 1px rgba(58, 50, 44, 0.18);
}

.env-note {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 10%;
  z-index: 1;
  height: 70%;
  border-radius: 4px;
  background: #fffdf7;
  box-shadow: 0 4px 12px rgba(58, 50, 44, 0.12);
  transition: transform 0.8s 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.env-front {
  z-index: 2;
  background: linear-gradient(160deg, #f4e3ca, #e6cfae);
  clip-path: polygon(0 0, 50% 44%, 100% 0, 100% 100%, 0 100%);
  box-shadow: inset 0 0 0 1px rgba(58, 50, 44, 0.1);
}

.env-front::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(33deg, transparent 49.55%, rgba(58, 50, 44, 0.14) 49.8%, rgba(58, 50, 44, 0.14) 50.2%, transparent 50.45%),
    linear-gradient(-33deg, transparent 49.55%, rgba(58, 50, 44, 0.14) 49.8%, rgba(58, 50, 44, 0.14) 50.2%, transparent 50.45%);
  clip-path: inherit;
}

.env-flap {
  z-index: 3;
  height: 58%;
  background: linear-gradient(180deg, #f6e7cf, #dfc39c);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  filter: drop-shadow(0 2px 2px rgba(58, 50, 44, 0.2));
  transform-origin: top center;
  backface-visibility: hidden;
  transition: transform 1s cubic-bezier(0.22, 1, 0.36, 1), z-index 0s 1s;
}

.env-seal {
  position: absolute;
  left: 50%;
  top: 44%;
  z-index: 4;
  display: grid;
  place-items: center;
  width: clamp(46px, 6vw, 60px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #e6c65a, #b8891f 70%);
  color: #6b4a12;
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 2vw, 1.6rem);
  font-weight: 600;
  box-shadow:
    0 4px 10px rgba(58, 50, 44, 0.25),
    inset 0 2px 3px rgba(255, 255, 255, 0.4);
  transform: translate(-50%, -50%);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.envelope.is-open .env-flap {
  z-index: 1;
  transform: rotateX(180deg);
}

.envelope.is-open .env-seal {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.6);
}

.envelope.is-open .env-note {
  transform: translateY(-38%);
}

/* ---------- letter cards ---------- */

.letter-cards {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}

.letter-card {
  --fan: clamp(72px, 12vw, 130px);
  position: absolute;
  left: 50%;
  top: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: clamp(138px, 18vw, 210px);
  aspect-ratio: 0.72;
  padding: 18px 14px;
  border: 0;
  border-radius: 4px;
  background: linear-gradient(160deg, #fffaf0, #f4e5d0);
  box-shadow: 0 18px 30px rgba(58, 50, 44, 0.22);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.2) rotate(0deg);
  transition:
    transform 0.95s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.45s ease,
    box-shadow 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

.letter-card--ralph {
  background: linear-gradient(160deg, #fff9ee, #f7e3d8);
}

.envelope-open .letter-card {
  opacity: 1;
  pointer-events: auto;
}

.envelope-open .letter-card--pau {
  transform: translate(calc(-50% - var(--fan)), -50%) rotate(-7deg);
}

.envelope-open .letter-card--ralph {
  transform: translate(calc(-50% + var(--fan)), -50%) rotate(7deg);
}

.letter-card:hover {
  box-shadow: 0 24px 38px rgba(58, 50, 44, 0.3);
}

.letter-card:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 4px;
}

.card-tape {
  position: absolute;
  top: -9px;
  left: 50%;
  width: 56px;
  height: 17px;
  background: rgba(217, 122, 95, 0.35);
  transform: translateX(-50%) rotate(-2deg);
}

.letter-card--ralph .card-tape {
  background: rgba(143, 169, 138, 0.45);
  transform: translateX(-50%) rotate(2deg);
}

.card-flower {
  width: 42px;
  height: 64px;
  margin-bottom: 6px;
}

.card-label {
  font-size: 0.66rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #8a6a52;
}

.card-name {
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 2.6vw, 2rem);
  line-height: 1;
  color: var(--ink);
}

.card-cta {
  margin-top: 4px;
  padding-bottom: 2px;
  border-bottom: 1px solid rgba(138, 90, 59, 0.4);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: #8a5a3b;
}

.letter-card.is-read::after {
  content: "Read";
  position: absolute;
  left: 10px;
  top: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(63, 90, 69, 0.12);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--forest);
}

.envelope-hint {
  opacity: 0;
  text-shadow: 0 1px 8px rgba(255, 249, 238, 0.95), 0 0 3px rgba(255, 249, 238, 0.9);
  transition: opacity 0.6s ease;
}

.envelope-landed .envelope-hint {
  opacity: 0.72;
  transition-delay: 0.3s;
}

.envelope-open .envelope-hint {
  opacity: 0;
}

.continue-btn {
  margin-top: 4px;
  padding: 12px 24px;
  border: 1px solid rgba(58, 50, 44, 0.32);
  border-radius: 999px;
  background: rgba(255, 249, 238, 0.72);
  color: var(--ink);
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.25s ease, transform 0.25s ease;
}

.continue-btn:hover {
  background: var(--ivory);
  transform: translateY(-1px);
}

/* ---------- finale ---------- */

.finale-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: max(15vh, 90px) 24px 24px;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  background: radial-gradient(circle at 50% 46%, rgba(255, 240, 205, 0.6), rgba(255, 249, 238, 0) 66%);
  transition: opacity 2.4s ease, visibility 1.2s ease;
}

body[data-scene="finale"] .finale-overlay {
  opacity: 1;
  visibility: visible;
}

.finale-overlay h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 7vw, 5.2rem);
  font-weight: 500;
  line-height: 1.02;
  color: var(--forest-deep);
  text-shadow: 0 3px 22px rgba(255, 249, 238, 0.85);
}

.finale-overlay p {
  margin: 0.2em 0 1.1em;
  font-family: var(--font-script);
  font-size: clamp(1.7rem, 4vw, 2.7rem);
  font-weight: 600;
  color: #8a5a3b;
  text-shadow: 0 2px 14px rgba(255, 249, 238, 0.75);
}

body[data-scene="finale"] .finale-overlay h2 {
  animation: fade-up 2s 0.8s both;
}

body[data-scene="finale"] .finale-overlay p {
  animation: fade-up 2s 2.6s both;
}

body[data-scene="finale"] .finale-overlay .replay-btn {
  animation: fade-up 1.5s 6s both;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.replay-btn {
  padding: 12px 26px;
  border: 1px solid rgba(58, 50, 44, 0.35);
  border-radius: 999px;
  background: rgba(255, 249, 238, 0.76);
  color: var(--ink);
  font-size: 0.95rem;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 0.25s ease, transform 0.25s ease;
}

.replay-btn:hover {
  background: var(--ivory);
  transform: translateY(-1px);
}

/* ---------- letter view ---------- */

.letter-view {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: max(4vh, 16px) 16px;
}

.letter-view[hidden] {
  display: none;
}

.letter-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(47, 68, 51, 0.62);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.letter-view.is-open .letter-backdrop {
  opacity: 1;
}

.letter-paper {
  position: relative;
  width: min(680px, 94vw);
  max-height: min(86dvh, 820px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(30px, 5vw, 56px);
  border-radius: 6px;
  background:
    repeating-linear-gradient(0deg, rgba(58, 50, 44, 0.025) 0 1px, transparent 1px 30px),
    linear-gradient(160deg, #fffdf7, #f8ecd9);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.35),
    inset 0 0 0 1px rgba(58, 50, 44, 0.08);
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.35s ease;
}

.letter-view.is-open .letter-paper {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.letter-flower {
  position: absolute;
  right: 28px;
  bottom: 24px;
  width: 72px;
  height: 116px;
  opacity: 0.32;
  pointer-events: none;
}

.letter-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(58, 50, 44, 0.18);
  border-radius: 50%;
  background: rgba(255, 249, 238, 0.82);
  color: var(--ink);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease;
}

.letter-close:hover {
  background: var(--ivory);
}

.letter-eyebrow {
  margin: 0 0 0.1em;
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #8a6a52;
}

.letter-name {
  margin: 0 0 0.6em;
  font-family: var(--font-script);
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  font-weight: 600;
  line-height: 1;
  color: #8a5a3b;
}

.letter-body {
  font-size: clamp(1.05rem, 2.4vw, 1.18rem);
  line-height: 1.85;
  color: var(--ink);
}

.letter-body p {
  margin: 0 0 1.05em;
}

.letter-body p:last-child {
  margin-bottom: 0;
}

.letter-body p:first-child {
  margin-bottom: 0.8em;
  font-family: var(--font-display);
  font-size: 1.5em;
  line-height: 1.2;
  color: var(--forest-deep);
}

.letter-body .signature {
  margin-top: 1.3em;
  font-family: var(--font-script);
  font-size: 1.65rem;
  line-height: 1.2;
  color: #8a5a3b;
}

.letter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 2em;
  padding-top: 1.2em;
  border-top: 1px solid rgba(58, 50, 44, 0.12);
}

.btn {
  padding: 12px 20px;
  border: 0;
  border-radius: 999px;
  font-size: 0.94rem;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.btn--primary {
  background: var(--forest);
  color: var(--ivory);
}

.btn--primary:hover {
  background: var(--forest-deep);
  transform: translateY(-1px);
}

.btn--ghost {
  border: 1px solid rgba(58, 50, 44, 0.2);
  background: transparent;
  color: #5a4a3a;
}

.btn--ghost:hover {
  background: rgba(255, 249, 238, 0.7);
}

.noscript {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--dawn);
  font-size: 1.1rem;
  text-align: center;
}

/* ---------- responsive ---------- */

@media (max-width: 560px) {
  .gate-frame {
    width: min(86vw, 350px);
  }

  .gate-content {
    padding-top: max(3vh, 18px);
  }

  .envelope-stage {
    height: clamp(300px, 43vh, 380px);
  }

  .letter-card {
    width: clamp(136px, 40vw, 160px);
    padding: 14px 10px;
  }

  .card-flower {
    width: 34px;
    height: 52px;
  }

  .letter-paper {
    max-height: 88dvh;
    padding: 30px 22px;
  }

  .letter-actions {
    flex-direction: column;
  }

  .letter-actions .btn {
    width: 100%;
  }
}

@media (max-height: 720px) and (min-width: 561px) {
  .gate-frame {
    width: min(52vh, 360px);
  }

  .gate-header h1 {
    font-size: clamp(2.2rem, 5vw, 3.6rem);
  }

  .gate-sub {
    font-size: clamp(1.5rem, 3vw, 2.1rem);
  }

  .envelope-stage {
    height: 300px;
  }
}

.letter-view.is-open .letter-body p {
  animation: fade-up 1s calc(0.6s + var(--i) * 0.7s) both;
}

body[data-scene="finale"] .finale-overlay .finale-sign {
  margin-top: 0.4em;
  font-size: clamp(1.5rem, 3.4vw, 2.2rem);
  line-height: 1.25;
  animation: fade-up 2s 4.4s both;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .petal-layer {
    display: none;
  }

  .garden-grown .tulip-sway,
  .envelope-landed .envelope-float {
    animation: none;
  }
}

/* ---------- performance ---------- */
.garden-art { will-change: transform; }
.reading .petal { animation-play-state: paused; }
.lite .grain { display: none; }
.lite .tulip-sway { animation: none; }
.lite .tulip, .lite .tulip * { filter: none; }

/* hide letter scrollbar, keep scrolling */
.letter-paper { scrollbar-width: none; -ms-overflow-style: none; }
.letter-paper::-webkit-scrollbar { display: none; }

/* undraggable */
html, body, svg, button, span { -webkit-user-drag: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.letter-body { user-select: text; -webkit-user-select: text; }
