/* —— Sumiyyah — Moonlit storybook garden × Victorian letter —— */
/* Tuned for iPhone 13 Pro Max (428×926) + safe areas */

:root {
  --sky-mid: #8ecce8;
  --parchment: #f7f0e4;
  --parchment-deep: #ebe0c8;
  --ink: #1f160f;
  --ink-soft: #3d2f24;
  --gold: #8f7340;
  --gold-soft: #b8955a;
  --gilt: #b89755;
  --crimson: #b83333;
  --crimson-deep: #6e1a1c;
  --wood-light: #dfc48e;
  --wood-mid: #c2a06a;
  --wood-dark: #7e6036;
  --wood-edge: #4f3a22;
  --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);
  --stage-pad-x: max(1rem, var(--safe-left), var(--safe-right));
  --letter-max: min(22rem, calc(100vw - 2.5rem));
  --font-serif: "Cormorant Garamond", "Palatino Linotype", Palatino, serif;
  --font-script: "Great Vibes", "Segoe Script", cursive;
  --panel-shadow: 0 16px 36px rgba(20, 14, 10, 0.22);
  --panel-border: 1px solid rgba(143, 115, 64, 0.38);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-serif);
  color: var(--ink);
  background: var(--sky-mid);
  overscroll-behavior: none;
  touch-action: manipulation;
}

html[data-period="dawn"] body {
  background: #b8c8e0;
}
html[data-period="day"] body {
  background: #8ecce8;
}
html[data-period="golden"] body {
  background: #e8a878;
}
html[data-period="dusk"] body {
  background: #5a4080;
}
html[data-period="night"] body {
  background: #141c40;
}

.scene {
  position: relative;
  width: 100%;
  height: 100dvh;
  height: 100svh;
  max-height: 100dvh;
  overflow: hidden;
  isolation: isolate;
  display: grid;
  place-items: center;
  padding: var(--safe-top) var(--stage-pad-x) var(--safe-bottom);
}

#world {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  image-rendering: auto;
  pointer-events: none;
}

.scene-dim {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: rgba(20, 14, 10, 0);
  transition:
    background 1.1s ease,
    backdrop-filter 1.1s ease,
    -webkit-backdrop-filter 1.1s ease;
}

.scene.is-open .scene-dim {
  background: rgba(14, 10, 6, 0.42);
  -webkit-backdrop-filter: blur(2.5px);
  backdrop-filter: blur(2.5px);
}

html[data-period="night"] .scene.is-open .scene-dim,
html[data-period="dusk"] .scene.is-open .scene-dim {
  background: rgba(4, 6, 16, 0.5);
}

/* —— Stage / letter —— */
/* Falling rose petals from the letter */
.petal-fall {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  overflow: visible;
}

.fall-petal {
  position: absolute;
  width: 14px;
  height: 12px;
  margin-left: -7px;
  border-radius: 70% 10% 70% 10%;
  background:
    radial-gradient(circle at 30% 30%, #f07070, #d43a3a 55%, #9a2020);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  opacity: 0;
  will-change: transform, opacity;
  animation-name: petal-fall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

.fall-petal::after {
  content: "";
  position: absolute;
  inset: 18% 28%;
  border-radius: inherit;
  background: rgba(255, 200, 200, 0.35);
}

@keyframes petal-fall {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) rotate(0deg) scale(0.7);
  }
  8% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--drift), var(--fall), 0)
      rotate(var(--spin)) scale(0.9);
  }
}

@media (prefers-reduced-motion: reduce) {
  .fall-petal {
    display: none;
  }
}

.stage {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: var(--letter-max);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 2rem);
}

/* Cat kisses the screen at the end of the letter */
.cat-kiss {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  display: grid;
  place-items: center;
  opacity: 0;
  visibility: hidden;
  background: rgba(10, 8, 6, 0);
}

.cat-kiss.is-kissing {
  visibility: visible;
  animation: cat-scene 4.2s ease forwards;
}

.cat-kiss.is-done {
  visibility: hidden;
  opacity: 0;
}

.cat-kiss__glass {
  position: absolute;
  left: 50%;
  top: 42%;
  width: min(78vw, 22rem);
  height: min(78vw, 22rem);
  margin: -39vw 0 0 -39vw;
  max-width: 22rem;
  max-height: 22rem;
  margin-left: -11rem;
  margin-top: -11rem;
  border-radius: 50%;
  background: radial-gradient(
    circle at 50% 45%,
    rgba(255, 255, 255, 0.35),
    rgba(255, 200, 210, 0.12) 40%,
    transparent 62%
  );
  opacity: 0;
}

.cat-kiss.is-kissing .cat-kiss__glass {
  animation: glass-fog 4.2s ease forwards;
}

.cat-kiss__creature {
  position: relative;
  width: min(78vw, 22rem);
  height: min(78vw, 22rem);
  max-width: 22rem;
  max-height: 22rem;
  transform: translateY(70px) scale(0.55);
  opacity: 0;
  filter: drop-shadow(0 16px 28px rgba(0, 0, 0, 0.45));
}

.cat-kiss.is-kissing .cat-kiss__creature {
  animation: cat-lean-in 4.2s cubic-bezier(0.22, 0.9, 0.3, 1) forwards;
}

.cat-kiss__photo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  border-radius: 8px;
  image-rendering: auto;
  -webkit-user-drag: none;
  user-select: none;
}

.cat__kiss-mark {
  position: absolute;
  left: 50%;
  top: 52%;
  width: 72px;
  height: 56px;
  margin-left: -36px;
  margin-top: -8px;
  z-index: 5;
  opacity: 0;
  background:
    radial-gradient(circle at 30% 45%, #e04060 0 38%, transparent 40%),
    radial-gradient(circle at 70% 45%, #e04060 0 38%, transparent 40%),
    radial-gradient(circle at 50% 68%, #c02848 0 42%, transparent 44%);
  filter: drop-shadow(0 2px 0 rgba(120, 20, 40, 0.25));
  pointer-events: none;
}

.cat-kiss.is-kissing .cat__kiss-mark {
  animation: kiss-mark 4.2s ease forwards;
}

.cat-kiss__caption {
  position: absolute;
  bottom: max(14%, calc(var(--safe-bottom) + 3rem));
  margin: 0;
  font-family: var(--font-script);
  font-size: clamp(2.2rem, 10vw, 3.2rem);
  color: #fff0f3;
  opacity: 0;
  text-shadow:
    0 2px 0 rgba(140, 30, 50, 0.45),
    0 8px 24px rgba(0, 0, 0, 0.35);
}

.cat-kiss.is-kissing .cat-kiss__caption {
  animation: mwah-in 4.2s ease forwards;
}

@keyframes cat-scene {
  0% {
    opacity: 0;
    background: rgba(10, 8, 6, 0);
  }
  8% {
    opacity: 1;
    background: rgba(10, 8, 6, 0.45);
  }
  78% {
    opacity: 1;
    background: rgba(10, 8, 6, 0.5);
  }
  100% {
    opacity: 0;
    background: rgba(10, 8, 6, 0);
  }
}

@keyframes cat-lean-in {
  0% {
    opacity: 0;
    transform: translateY(90px) scale(0.45);
  }
  16% {
    opacity: 1;
    transform: translateY(24px) scale(0.85);
  }
  32% {
    transform: translateY(-4px) scale(1.15);
  }
  45% {
    transform: translateY(-18px) scale(1.45);
  }
  55% {
    transform: translateY(-28px) scale(1.75);
  }
  65% {
    transform: translateY(-22px) scale(1.6);
  }
  80% {
    opacity: 1;
    transform: translateY(6px) scale(1.2);
  }
  100% {
    opacity: 0;
    transform: translateY(40px) scale(1);
  }
}

@keyframes kiss-mark {
  0%,
  44% {
    opacity: 0;
    transform: scale(0.4) rotate(-12deg);
  }
  50% {
    opacity: 1;
    transform: scale(1.25) rotate(-6deg);
  }
  62% {
    opacity: 1;
    transform: scale(1.4) rotate(4deg);
  }
  80% {
    opacity: 0.85;
    transform: scale(1.55) rotate(-2deg);
  }
  100% {
    opacity: 0;
    transform: scale(1.7);
  }
}

@keyframes glass-fog {
  0%,
  35% {
    opacity: 0;
    transform: scale(0.8);
  }
  48% {
    opacity: 1;
    transform: scale(1.15);
  }
  75% {
    opacity: 0.7;
  }
  100% {
    opacity: 0;
    transform: scale(1.3);
  }
}

@keyframes mwah-in {
  0%,
  46% {
    opacity: 0;
    transform: translateY(14px) scale(0.9);
  }
  54% {
    opacity: 1;
    transform: translateY(0) scale(1.08);
  }
  70% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-8px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cat-kiss.is-kissing,
  .cat-kiss.is-kissing .cat-kiss__creature,
  .cat-kiss.is-kissing .cat__kiss-mark,
  .cat-kiss.is-kissing .cat-kiss__glass,
  .cat-kiss.is-kissing .cat-kiss__caption {
    animation-duration: 1.6s !important;
  }
}

/* Falling rose petals from the letter */
.petal-fall {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  overflow: visible;
}

.fall-petal {
  position: absolute;
  width: 14px;
  height: 12px;
  margin-left: -7px;
  border-radius: 70% 10% 70% 10%;
  background:
    radial-gradient(circle at 30% 30%, #f07070, #d43a3a 55%, #9a2020);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  opacity: 0;
  will-change: transform, opacity;
  animation-name: petal-fall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

.fall-petal::after {
  content: "";
  position: absolute;
  inset: 18% 28%;
  border-radius: inherit;
  background: rgba(255, 200, 200, 0.35);
}

@keyframes petal-fall {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) rotate(0deg) scale(0.7);
  }
  8% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--drift), var(--fall), 0)
      rotate(var(--spin)) scale(0.9);
  }
}

.scroll-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Soft painted wood roller */
.pixel-roller {
  height: 14px;
  width: 100%;
  margin: 0 auto;
  background:
    linear-gradient(180deg, rgba(255, 248, 230, 0.4), transparent 42%),
    linear-gradient(90deg, #5a4224, #a8844e 20%, #d4b87a 45%, #b89458 65%, #7a5a32 85%, #4a3620);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.28),
    inset 0 -2px 0 rgba(0, 0, 0, 0.2),
    0 4px 10px rgba(0, 0, 0, 0.14);
  border: 1px solid var(--wood-edge);
  border-radius: 999px;
  position: relative;
}

.pixel-roller::before,
.pixel-roller::after {
  content: "";
  position: absolute;
  top: -4px;
  width: 12px;
  height: calc(100% + 8px);
  background: radial-gradient(circle at 40% 35%, #e0c48a, #8a6438 70%, #4a341c);
  border: 1px solid var(--wood-edge);
  border-radius: 999px;
}

.pixel-roller::before {
  left: -6px;
}
.pixel-roller::after {
  right: -6px;
}

/* Sealed scroll */
.scroll-sealed {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  transition: opacity 0.35s ease, transform 0.45s ease;
}

.scroll-sealed.is-gone {
  opacity: 0;
  transform: scale(0.94) translateY(-0.4rem);
  pointer-events: none;
  position: absolute;
  visibility: hidden;
  display: none;
}

.scroll-cylinder {
  position: relative;
  width: min(14rem, 72vw);
  height: 3.6rem;
  display: grid;
  place-items: center;
  animation: scroll-breathe 6.5s ease-in-out infinite;
}

.scroll-tube {
  width: 100%;
  height: 2.4rem;
  border-radius: 2px;
}

.scroll-ribbon {
  position: absolute;
  width: 1.15rem;
  height: 4.1rem;
  background:
    linear-gradient(180deg, #d86868 0%, var(--crimson) 48%, var(--crimson-deep) 100%);
  border: 1px solid #5c1416;
  border-radius: 2px;
  box-shadow:
    0 1px 0 rgba(255, 200, 180, 0.25) inset,
    0 6px 12px rgba(0, 0, 0, 0.18);
  z-index: 1;
  transform-origin: top center;
  transition:
    transform 1.15s cubic-bezier(0.4, 0.1, 0.7, 1),
    opacity 0.85s ease;
}

.scroll-sealed.is-breaking .scroll-ribbon {
  transform: translateY(4.5rem) rotate(12deg);
  opacity: 0;
}

.scroll-seal {
  position: absolute;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, #f09090, var(--crimson) 48%, var(--crimson-deep) 100%);
  border: 1px solid #5c1416;
  box-shadow:
    0 1px 0 rgba(255, 220, 200, 0.35) inset,
    0 6px 14px rgba(0, 0, 0, 0.25);
  z-index: 2;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.seal-heart {
  position: relative;
  z-index: 2;
  color: rgba(255, 230, 200, 0.95);
  font-size: 0.95rem;
  line-height: 1;
  pointer-events: none;
}

.seal-shine {
  position: absolute;
  inset: -40%;
  background: linear-gradient(
    115deg,
    transparent 40%,
    rgba(255, 255, 255, 0.45) 50%,
    transparent 60%
  );
  animation: seal-shine 5.5s ease-in-out infinite;
  z-index: 1;
}

.seal-shard {
  position: absolute;
  inset: 0;
  background: inherit;
  border: 2px solid #6e1818;
  opacity: 0;
  pointer-events: none;
}

.scroll-seal.is-cracked .seal-heart,
.scroll-seal.is-cracked .seal-shine {
  opacity: 0;
}

.scroll-seal.is-cracked {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.scroll-seal.is-cracked .seal-shard {
  opacity: 1;
  animation: shard-fall 1.15s cubic-bezier(0.4, 0.05, 0.7, 1) forwards;
}

.seal-shard--a {
  clip-path: polygon(0 0, 55% 0, 40% 100%, 0 100%);
  background: linear-gradient(135deg, #f07070, var(--crimson));
}
.seal-shard--b {
  clip-path: polygon(55% 0, 100% 0, 100% 55%, 50% 45%);
  background: linear-gradient(135deg, var(--crimson), var(--crimson-deep));
}
.seal-shard--c {
  clip-path: polygon(40% 100%, 50% 45%, 100% 55%, 100% 100%);
  background: linear-gradient(135deg, var(--crimson-deep), #7a1818);
}

.scroll-seal.is-cracked .seal-shard--a {
  --sx: -28px;
  --sy: 42px;
  --rot: -28deg;
}
.scroll-seal.is-cracked .seal-shard--b {
  --sx: 34px;
  --sy: 18px;
  --rot: 36deg;
  animation-delay: 0.04s;
}
.scroll-seal.is-cracked .seal-shard--c {
  --sx: 12px;
  --sy: 54px;
  --rot: 18deg;
  animation-delay: 0.08s;
}

@keyframes shard-fall {
  0% {
    transform: translate(0, 0) rotate(0);
    opacity: 1;
  }
  100% {
    transform: translate(var(--sx), var(--sy)) rotate(var(--rot));
    opacity: 0;
  }
}

@keyframes seal-shine {
  0%,
  100% {
    transform: translateX(-30%);
  }
  50% {
    transform: translateX(30%);
  }
}

@keyframes scroll-breathe {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

.scroll-invite {
  margin: 0;
  font-family: var(--font-script);
  font-size: clamp(1.35rem, 5.2vw, 1.75rem);
  color: var(--ink-soft);
  letter-spacing: 0.02em;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

/* —— Pigeon intro —— */
.intro {
  position: relative;
  z-index: 3;
  width: 100%;
  max-width: var(--letter-max);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  min-height: 16rem;
}

.intro.is-leaving {
  animation: quiz-out 0.45s ease forwards;
  pointer-events: none;
}

.intro-sky {
  position: relative;
  width: 100%;
  height: 7.5rem;
  overflow: visible;
}

.pigeon {
  position: absolute;
  top: 1.2rem;
  left: -4rem;
  width: 52px;
  height: 36px;
  z-index: 2;
  opacity: 0;
  filter: drop-shadow(0 2px 3px rgba(20, 14, 10, 0.22));
}

.intro.is-flying .pigeon {
  opacity: 1;
  animation: pigeon-fly 2.4s linear forwards;
}

.intro.is-flying .pigeon__wing--front,
.intro.is-flying .pigeon__wing--back {
  animation: wing-flap 0.28s steps(2) infinite;
}

.intro.is-dropped .pigeon,
.intro.is-notice .pigeon {
  opacity: 1;
  left: 70%;
  top: 0.4rem;
  animation: pigeon-exit 1.4s ease-in forwards;
}

.pigeon__body {
  position: absolute;
  left: 14px;
  top: 12px;
  width: 22px;
  height: 14px;
  background: #8a90a0;
  box-shadow:
    2px 0 0 #7a8090,
    0 2px 0 #6a7080,
    inset 0 2px 0 #a8b0c0;
}

.pigeon__head {
  position: absolute;
  left: 32px;
  top: 8px;
  width: 12px;
  height: 12px;
  background: #9aa2b2;
  box-shadow: inset 0 2px 0 #c0c8d4;
}

.pigeon__beak {
  position: absolute;
  left: 42px;
  top: 12px;
  width: 8px;
  height: 4px;
  background: #e09040;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}

.pigeon__eye {
  position: absolute;
  left: 36px;
  top: 11px;
  width: 3px;
  height: 3px;
  background: #2a2a38;
  border-radius: 1px;
}

.pigeon__tail {
  position: absolute;
  left: 6px;
  top: 12px;
  width: 10px;
  height: 10px;
  background: #6a7088;
  clip-path: polygon(100% 0, 0 40%, 100% 100%);
}

.pigeon__wing {
  position: absolute;
  left: 16px;
  top: 6px;
  width: 18px;
  height: 10px;
  background: #c8d0dc;
  transform-origin: left center;
}

.pigeon__wing--back {
  background: #7a8498;
  top: 8px;
  z-index: 0;
}

.pigeon__wing--front {
  z-index: 3;
}

.pigeon__letter {
  position: absolute;
  left: 20px;
  top: 24px;
  width: 22px;
  height: 10px;
  z-index: 4;
}

.intro.is-dropped .pigeon__letter,
.intro.is-notice .pigeon__letter {
  opacity: 0;
}

.pigeon__scroll {
  display: block;
  width: 100%;
  height: 8px;
  background: linear-gradient(180deg, #f7eedc, #cbb489);
  border: 1px solid #8a6a3a;
}

.pigeon__ribbon {
  position: absolute;
  left: 9px;
  top: -2px;
  width: 4px;
  height: 12px;
  background: #c02828;
}

.intro-drop {
  position: absolute;
  left: 50%;
  top: 0.8rem;
  width: 7.5rem;
  height: 2.2rem;
  margin-left: -3.75rem;
  opacity: 0;
  z-index: 1;
  display: grid;
  place-items: center;
}

.intro.is-dropped .intro-drop,
.intro.is-notice .intro-drop {
  opacity: 1;
  animation: letter-drop 0.85s cubic-bezier(0.22, 1.2, 0.36, 1) both;
}

.intro-drop__tube {
  width: 100%;
  height: 1.6rem;
  background:
    linear-gradient(180deg, #f7eedc 0%, #e8d9bc 50%, #d9c49a 100%);
  border: 2px solid #8a6a3a;
  border-radius: 2px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.intro-drop__ribbon {
  position: absolute;
  width: 0.7rem;
  height: 2.4rem;
  background: linear-gradient(180deg, #e05050, #8e2428);
  border: 1px solid #6e1818;
}

.intro-drop__seal {
  position: absolute;
  width: 1.35rem;
  height: 1.35rem;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 30%, #e07070, #b83a3a 60%, #8e2428);
  border: 2px solid #6e1818;
  color: rgba(255, 230, 200, 0.95);
  font-size: 0.7rem;
  line-height: 1;
  z-index: 2;
}

.intro-notice {
  width: 100%;
  padding: 1.3rem 1.3rem 1.4rem;
  text-align: center;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 252, 245, 0.7), transparent 55%),
    linear-gradient(165deg, rgba(255, 250, 242, 0.92), var(--parchment) 55%, var(--parchment-deep));
  border: var(--panel-border);
  border-radius: 0.65rem;
  box-shadow: var(--panel-shadow);
  outline: 1px solid rgba(184, 151, 85, 0.22);
  outline-offset: -6px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  position: relative;
}

.intro.is-notice .intro-notice {
  opacity: 1;
  transform: none;
  pointer-events: auto;
  transition:
    opacity 0.55s ease,
    transform 0.55s ease;
}

.intro-story {
  margin: 0 0 0.55rem;
  font-family: var(--font-script);
  font-size: clamp(1.05rem, 4.2vw, 1.28rem);
  line-height: 1.35;
  color: var(--crimson-deep);
  text-wrap: balance;
}

.intro-title {
  margin: 0 0 1rem;
  font-family: var(--font-serif);
  font-size: clamp(1.35rem, 5.5vw, 1.75rem);
  font-weight: 600;
  color: var(--ink);
  line-height: 1.25;
}

.intro-notice .open-btn {
  width: 100%;
  min-height: 52px;
}

@keyframes pigeon-fly {
  0% {
    left: -4rem;
    top: 1.6rem;
    transform: translateY(0);
  }
  45% {
    left: 38%;
    top: 0.9rem;
  }
  55% {
    left: 48%;
    top: 1rem;
  }
  100% {
    left: 70%;
    top: 0.4rem;
    transform: translateY(-4px);
  }
}

@keyframes pigeon-exit {
  0% {
    left: 70%;
    opacity: 1;
  }
  100% {
    left: 120%;
    top: -0.5rem;
    opacity: 0;
  }
}

@keyframes wing-flap {
  0% {
    transform: rotate(-18deg);
  }
  100% {
    transform: rotate(22deg);
  }
}

@keyframes letter-drop {
  0% {
    transform: translateY(-2.2rem) scale(0.85);
    opacity: 0;
  }
  55% {
    opacity: 1;
    transform: translateY(0.2rem) scale(1.02);
  }
  75% {
    transform: translateY(-0.15rem) scale(1);
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .intro.is-flying .pigeon,
  .intro.is-dropped .pigeon,
  .intro.is-notice .pigeon,
  .intro.is-flying .pigeon__wing--front,
  .intro.is-flying .pigeon__wing--back,
  .intro.is-dropped .intro-drop,
  .intro.is-notice .intro-drop {
    animation: none !important;
  }

  .intro.is-notice .pigeon {
    display: none;
  }

  .intro.is-notice .intro-drop {
    opacity: 1;
    transform: none;
  }

  .intro.is-notice .intro-notice {
    transition: none;
  }
}

/* —— Quiz gate —— */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.quiz {
  position: relative;
  z-index: 3;
  width: 100%;
  max-width: var(--letter-max);
  padding: 1.35rem 1.3rem 1.45rem;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 252, 245, 0.7), transparent 55%),
    linear-gradient(165deg, rgba(255, 250, 242, 0.92), var(--parchment) 55%, var(--parchment-deep));
  border: var(--panel-border);
  border-radius: 0.65rem;
  box-shadow: var(--panel-shadow);
  outline: 1px solid rgba(184, 151, 85, 0.22);
  outline-offset: -6px;
  text-align: center;
  animation: quiz-in 0.55s ease both;
}

.quiz.is-leaving {
  animation: quiz-out 0.45s ease forwards;
  pointer-events: none;
}

@keyframes quiz-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes quiz-out {
  to {
    opacity: 0;
    transform: translateY(-8px) scale(0.97);
  }
}

.quiz-eyebrow {
  margin: 0 0 0.35rem;
  font-family: var(--font-script);
  font-size: clamp(1.25rem, 5vw, 1.55rem);
  color: var(--crimson-deep);
}

.quiz-progress {
  margin: 0 0 0.85rem;
  font-size: 0.85rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}

.quiz-question {
  margin: 0 0 1rem;
  font-family: var(--font-serif);
  font-size: clamp(1.15rem, 4.6vw, 1.35rem);
  font-weight: 500;
  line-height: 1.45;
  color: var(--ink);
}

.quiz-form {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
}

.quiz-input {
  appearance: none;
  width: 100%;
  min-height: 48px;
  padding: 0.75rem 0.9rem;
  border: 2px solid rgba(138, 106, 58, 0.45);
  border-radius: 2px;
  background: rgba(255, 252, 245, 0.9);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 1.1rem;
  text-align: center;
}

.quiz-input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(184, 149, 90, 0.2);
}

.quiz-submit {
  width: 100%;
}

.quiz-feedback {
  min-height: 1.4em;
  margin: 0.85rem 0 0;
  font-size: 0.98rem;
  font-style: italic;
  color: var(--ink-soft);
  transition: color 0.2s ease;
}

.quiz-feedback.is-ok {
  color: #3f6a32;
}

.quiz-feedback.is-nope {
  color: var(--crimson-deep);
}

.scroll-wrap[hidden] {
  display: none !important;
}

.open-btn {
  appearance: none;
  border: 1px solid var(--wood-edge);
  background:
    linear-gradient(180deg, #fff8ea 0%, var(--parchment) 48%, var(--parchment-deep) 100%);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 1.12rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.85rem 2.3rem;
  min-height: 48px;
  min-width: 8.5rem;
  border-radius: 0.4rem;
  cursor: pointer;
  box-shadow:
    0 1px 0 rgba(255, 250, 235, 0.55) inset,
    0 8px 18px rgba(40, 28, 16, 0.16);
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease;
  -webkit-user-select: none;
  user-select: none;
}

.open-btn:hover,
.open-btn:focus-visible {
  transform: translateY(-1px);
  box-shadow:
    0 1px 0 rgba(255, 250, 235, 0.65) inset,
    0 12px 22px rgba(40, 28, 16, 0.2);
  outline: none;
}

.open-btn:active {
  transform: translateY(1px);
  box-shadow:
    0 1px 0 rgba(255, 250, 235, 0.4) inset,
    0 4px 10px rgba(40, 28, 16, 0.14);
}

/* Unrolled letter */
.letter {
  width: 100%;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.letter:focus {
  outline: none;
}

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

.scroll-wrap[data-open="true"] .letter {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.letter-reveal {
  display: flex;
  flex-direction: column;
  max-height: 0;
  overflow: hidden;
  transform-origin: top center;
  filter: drop-shadow(0 10px 18px rgba(58, 46, 36, 0.18));
}

.scroll-wrap[data-open="true"] .letter-reveal {
  animation: unroll 2.2s cubic-bezier(0.22, 0.85, 0.28, 1) forwards;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  max-height: min(68dvh, 36rem);
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.scroll-wrap[data-open="true"] .letter-reveal::-webkit-scrollbar {
  display: none;
}

.letter.is-instant .letter-reveal {
  animation: none;
  max-height: min(68dvh, 36rem);
}

.letter-roll-top {
  width: calc(100% + 4px);
  margin-left: -2px;
  z-index: 2;
}

.letter-roll-bottom {
  width: calc(100% + 4px);
  margin-left: -2px;
  margin-top: -2px;
  z-index: 2;
  animation: none;
}

.scroll-wrap[data-open="true"] .letter-roll-bottom {
  animation: roller-settle 2.2s cubic-bezier(0.22, 0.85, 0.28, 1) both;
}

.letter-sheet {
  position: relative;
  margin: 0 0.15rem;
  padding: 1.35rem 1.35rem 1.45rem;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(255, 252, 245, 0.75), transparent 50%),
    linear-gradient(165deg, #faf4e6 0%, var(--parchment) 55%, #e6d4b4 100%);
  border-left: 1px solid rgba(143, 115, 64, 0.35);
  border-right: 1px solid rgba(143, 115, 64, 0.35);
  box-shadow:
    inset 0 0 40px rgba(120, 90, 50, 0.05),
    0 0 0 1px rgba(184, 151, 85, 0.16);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.letter-sheet::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

.filigree {
  display: block;
  width: 70%;
  max-width: 12rem;
  margin: 0 auto 0.7rem;
  color: var(--gilt);
  opacity: 0.75;
}

.filigree--bottom {
  margin: 0.85rem auto 0;
}

/* Letter text — typed letter by letter via JS */
.letter-line {
  margin: 0 0 0.85rem;
  color: var(--ink);
  min-height: 1.2em;
}

.letter-salutation {
  font-family: var(--font-script);
  font-size: clamp(1.75rem, 6.8vw, 2.25rem);
  line-height: 1.25;
  margin-bottom: 1rem;
  color: var(--crimson-deep);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
}

.letter-body {
  font-size: clamp(1.12rem, 4.5vw, 1.28rem);
  line-height: 1.72;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--ink);
}

.letter-closing {
  margin-top: 1.1rem;
  margin-bottom: 0.15rem;
  font-size: clamp(1.05rem, 4vw, 1.15rem);
  font-style: italic;
  color: var(--ink-soft);
}

.letter-signature {
  font-family: var(--font-script);
  font-size: clamp(1.7rem, 6.5vw, 2.2rem);
  margin-bottom: 0.35rem;
  line-height: 1.2;
  color: var(--ink);
}

.letter-rose {
  display: flex;
  justify-content: center;
  margin: 0.35rem 0 0.55rem;
  opacity: 0;
  transform: translateY(6px) scale(0.92);
  transition:
    opacity 0.7s ease,
    transform 0.7s ease;
  pointer-events: none;
}

.letter-rose.is-shown {
  opacity: 0.95;
  transform: none;
}

.letter.is-instant .letter-rose.is-shown {
  transition: none;
}

.letter-rose__svg {
  display: block;
  filter: drop-shadow(0 2px 4px rgba(80, 20, 20, 0.18));
}

@media (prefers-reduced-motion: reduce) {
  .letter-rose.is-shown {
    opacity: 0.95;
    transform: none;
    transition: none;
  }
}

.letter-line.is-typing::after {
  content: "";
  display: inline-block;
  width: 0.55ch;
  height: 1em;
  margin-left: 1px;
  vertical-align: text-bottom;
  background: currentColor;
  opacity: 0.55;
  animation: caret-blink 0.9s steps(1) infinite;
}

@keyframes caret-blink {
  0%,
  49% {
    opacity: 0.55;
  }
  50%,
  100% {
    opacity: 0;
  }
}

@keyframes unroll {
  0% {
    max-height: 0;
    opacity: 0.3;
    transform: scaleY(0.08);
  }
  55% {
    opacity: 1;
  }
  85% {
    transform: scaleY(1.02);
  }
  100% {
    max-height: min(68dvh, 36rem);
    opacity: 1;
    transform: scaleY(1);
  }
}

@keyframes roller-settle {
  0% {
    transform: translateY(-6px);
  }
  70% {
    transform: translateY(2px);
  }
  100% {
    transform: translateY(0);
  }
}

/* —— iPhone 13 Pro Max —— */
@media (max-width: 430px) {
  .stage {
    max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 1.25rem);
  }

  .letter-sheet {
    padding: 1rem 1.1rem 1.15rem;
  }

  .letter-line {
    margin-bottom: 0.7rem;
  }

  .letter-salutation {
    margin-bottom: 0.75rem;
  }

  .letter-closing {
    margin-top: 0.75rem;
  }

  .scroll-wrap[data-open="true"] .letter-reveal,
  .letter.is-instant .letter-reveal {
    max-height: min(62dvh, 34rem);
  }

  @keyframes unroll {
    0% {
      max-height: 0;
      opacity: 0.3;
      transform: scaleY(0.08);
    }
    55% {
      opacity: 1;
    }
    85% {
      transform: scaleY(1.02);
    }
    100% {
      max-height: min(62dvh, 34rem);
      opacity: 1;
      transform: scaleY(1);
    }
  }
}

@media (max-width: 430px) and (min-height: 850px) {
  .letter-body {
    font-size: 1.12rem;
    line-height: 1.58;
  }

  .open-btn {
    min-height: 52px;
    padding: 0.95rem 2.6rem;
  }

  .scroll-wrap[data-open="true"] .letter-reveal,
  .letter.is-instant .letter-reveal {
    max-height: min(64dvh, 36rem);
  }
}

@media (width: 428px) and (min-height: 900px) {
  .scroll-invite {
    font-size: 1.6rem;
  }

  .letter-salutation {
    font-size: 1.95rem;
  }

  .letter-signature {
    font-size: 2rem;
  }

  .letter-sheet {
    padding: 1.05rem 1.2rem 1.35rem;
  }
}

@media (min-width: 768px) {
  :root {
    --letter-max: 26rem;
  }

  .letter-sheet {
    padding: 1.5rem 1.75rem 1.6rem;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .scroll-cylinder,
  .seal-shine {
    animation: none !important;
  }

  .scroll-ribbon,
  .scroll-sealed,
  .seal-shard {
    transition: none !important;
    animation: none !important;
  }

  .scroll-wrap[data-open="true"] .letter-reveal {
    animation: none;
    max-height: min(68dvh, 36rem);
    transform: none;
    opacity: 1;
  }

  .letter-line.is-typing::after {
    animation: none;
    display: none;
  }

  .fall-petal {
    display: none;
  }
}
