:root {
  --bg-deep: #05060b;
  --bg-mid: #0b1020;
  --bg-light: #1d2542;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-strong: rgba(255, 255, 255, 0.12);
  --surface-elevated: rgba(255, 255, 255, 0.16);
  --stroke: rgba(255, 255, 255, 0.18);
  --stroke-soft: rgba(255, 255, 255, 0.12);
  --text: #f7f9ff;
  --muted: #bdc6e8;
  --accent: #9bb8ff;
  --accent-soft: #d5e0ff;
  --pearl: #ffffff;
  --blush: #ffdde8;
  --gold: #ffe3ad;
  --radius-xl: 34px;
  --radius-lg: 24px;
  --radius-md: 16px;
  --shadow-xl: 0 36px 90px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.34);
  --shadow-sm: 0 10px 20px rgba(0, 0, 0, 0.2);
  --font-display: "Playfair Display", "Georgia", serif;
  --font-body: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-body);
  color: var(--text);
  line-height: 1.65;
  overflow-x: hidden;
  position: relative;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background:
    radial-gradient(1200px 680px at 8% -8%, rgba(127, 162, 255, 0.24), transparent 60%),
    radial-gradient(980px 620px at 88% 12%, rgba(244, 170, 202, 0.18), transparent 64%),
    radial-gradient(760px 520px at 50% 110%, rgba(110, 136, 245, 0.12), transparent 72%),
    linear-gradient(158deg, var(--bg-deep) 0%, var(--bg-mid) 42%, #080b15 100%);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: -12vh -10vw;
  pointer-events: none;
  z-index: -6;
}

body::before {
  background:
    radial-gradient(42vw 42vw at 15% 24%, rgba(146, 179, 255, 0.14), transparent 68%),
    radial-gradient(36vw 36vw at 78% 34%, rgba(254, 189, 218, 0.12), transparent 70%);
  filter: blur(20px);
  animation: atmosphere-shift 24s ease-in-out infinite alternate;
}

body::after {
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.34) 0.6px, transparent 0.7px);
  background-size: 4px 4px;
  opacity: 0.06;
  mix-blend-mode: soft-light;
}

@keyframes atmosphere-shift {
  0% {
    transform: translate3d(-1.8vw, -1vh, 0) scale(1);
  }
  100% {
    transform: translate3d(1.8vw, 1vh, 0) scale(1.03);
  }
}

body.no-scroll {
  overflow: hidden;
}

body.mobile-stable::before {
  animation: none;
  filter: blur(12px);
}

body.mobile-stable #confetti-canvas,
body.mobile-stable .noise-layer,
body.mobile-stable #cursor-glow {
  display: none;
}

body.mobile-stable #floating-hearts {
  opacity: 0.2;
}

body.mobile-stable #ambient-sparkles {
  opacity: 0.24;
}

body.mobile-stable .hero-stage,
body.mobile-stable .panel,
body.mobile-stable footer,
body.mobile-stable .letter-book,
body.mobile-stable .gift-view,
body.mobile-stable .finale-card {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

body.mobile-stable .letter-backdrop {
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

#entry-curtain {
  position: fixed;
  inset: 0;
  z-index: 120;
  pointer-events: none;
  background:
    radial-gradient(420px 240px at 50% 38%, rgba(255, 240, 214, 0.2), transparent 76%),
    rgba(2, 4, 10, 0.78);
  opacity: 0;
}

body.is-entering #entry-curtain {
  opacity: 1;
}

body.is-entering.is-ready #entry-curtain {
  opacity: 0;
  transition: opacity 880ms ease;
}

#intro-flock {
  position: fixed;
  inset: 0;
  z-index: 121;
  pointer-events: none;
  overflow: hidden;
  opacity: 0;
}

body.is-entering #intro-flock {
  opacity: 1;
}

body.is-entering.is-ready #intro-flock {
  opacity: 0;
  transition: opacity 760ms ease 380ms;
}

.intro-bird {
  position: absolute;
  left: -20vw;
  top: 0;
  width: 58px;
  height: 26px;
  opacity: 0;
  transform: translate3d(-18vw, var(--bird-y, 40vh), 0) scale(var(--bird-scale, 1)) rotate(var(--bird-rot, 0deg));
  filter: drop-shadow(0 2px 9px rgba(188, 208, 255, 0.42));
  animation: intro-bird-fly var(--bird-duration, 1900ms) cubic-bezier(0.21, 0.82, 0.3, 1) var(--bird-delay, 0ms) forwards;
}

.intro-bird .wing {
  position: absolute;
  top: 6px;
  width: 24px;
  height: 13px;
  border: 2.6px solid rgba(245, 251, 255, 0.95);
  border-bottom: none;
  border-radius: 100% 100% 0 0;
}

.intro-bird .wing.left {
  left: 4px;
  transform-origin: right bottom;
  animation: wing-left-flap var(--wing-speed, 250ms) ease-in-out infinite alternate;
}

.intro-bird .wing.right {
  right: 4px;
  transform-origin: left bottom;
  animation: wing-right-flap var(--wing-speed, 250ms) ease-in-out infinite alternate;
}

.intro-bird .tail {
  position: absolute;
  left: 16px;
  top: 12px;
  width: 8px;
  height: 6px;
  clip-path: polygon(0 50%, 100% 0, 82% 100%);
  background: rgba(239, 247, 255, 0.85);
}

.intro-bird .core {
  position: absolute;
  left: 22px;
  top: 10px;
  width: 14px;
  height: 7px;
  border-radius: 999px;
  background: rgba(246, 252, 255, 0.94);
}

.intro-bird .core::after {
  content: "";
  position: absolute;
  right: -5px;
  top: 1px;
  width: 6px;
  height: 5px;
  clip-path: polygon(0 50%, 100% 0, 100% 100%);
  background: rgba(255, 223, 179, 0.94);
}

@keyframes intro-bird-fly {
  0% {
    opacity: 0;
    transform: translate3d(-18vw, var(--bird-y, 40vh), 0) scale(var(--bird-scale, 1)) rotate(var(--bird-rot, 0deg));
  }
  14% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(118vw, var(--bird-y-end, 30vh), 0) scale(var(--bird-scale, 1)) rotate(calc(var(--bird-rot, 0deg) + 6deg));
  }
}

@keyframes wing-left-flap {
  0% {
    transform: rotate(30deg) scaleY(1);
  }
  100% {
    transform: rotate(-2deg) scaleY(0.84);
  }
}

@keyframes wing-right-flap {
  0% {
    transform: rotate(-30deg) scaleY(1);
  }
  100% {
    transform: rotate(2deg) scaleY(0.84);
  }
}

#scroll-progress {
  position: fixed;
  inset: 0 auto auto 0;
  height: 3px;
  width: 0;
  z-index: 125;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.9), var(--accent), #ffd6e7);
  box-shadow: 0 0 18px rgba(189, 211, 255, 0.62);
  transition: width 120ms linear;
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
}

.noise-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -4;
  opacity: 0.06;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.6) 0.6px, transparent 0.65px);
  background-size: 5px 5px;
  mix-blend-mode: overlay;
}

#ambient-sparkles,
#floating-hearts {
  position: fixed;
  inset: 0;
  pointer-events: none;
  transition: opacity 280ms ease;
}

#ambient-sparkles {
  z-index: -3;
}

.sparkle-dot {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(218, 234, 255, 0.84);
  box-shadow: 0 0 14px rgba(201, 223, 255, 0.78);
  animation: sparkle-twinkle linear infinite;
}

@keyframes sparkle-twinkle {
  0% {
    opacity: 0.2;
    transform: scale(0.62);
  }
  50% {
    opacity: 1;
    transform: scale(1.28);
  }
  100% {
    opacity: 0.2;
    transform: scale(0.62);
  }
}

#floating-hearts {
  z-index: -2;
}

.heart {
  position: absolute;
  bottom: -42px;
  color: rgba(218, 229, 255, 0.28);
  font-size: 14px;
  text-shadow: 0 0 12px rgba(196, 214, 255, 0.36);
  animation: float-heart linear infinite;
}

.heart.is-star {
  color: rgba(249, 227, 255, 0.32);
}

.heart.is-heart {
  color: rgba(245, 206, 226, 0.2);
}

@keyframes float-heart {
  0% {
    transform: translate3d(0, 0, 0) scale(0.84);
    opacity: 0;
  }
  14% {
    opacity: 0.36;
  }
  100% {
    transform: translate3d(8px, -108vh, 0) scale(1.08);
    opacity: 0;
  }
}

#cursor-glow {
  position: fixed;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  pointer-events: none;
  z-index: -1;
  background: radial-gradient(circle, rgba(176, 202, 255, 0.18), rgba(201, 171, 255, 0.05), transparent 68%);
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 220ms ease;
}

body.no-scroll #ambient-sparkles,
body.no-scroll #floating-hearts {
  opacity: 0.32;
}

.shell {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding:
    max(30px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(30px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
  transform-origin: center top;
  will-change: transform, opacity, filter;
}

body.is-entering {
  overflow: hidden;
}

body.is-entering .shell {
  opacity: 0;
  filter: blur(12px) saturate(0.78);
  transform: perspective(1700px) translate3d(0, 110px, -560px) rotateX(18deg) rotateY(-8deg) scale(0.77);
}

body.is-entering.is-ready .shell {
  opacity: 1;
  filter: blur(0) saturate(1);
  transform: perspective(1700px) translate3d(0, 0, 0) rotateX(0) rotateY(0) scale(1);
  transition:
    transform 1300ms cubic-bezier(0.13, 0.83, 0.2, 1),
    opacity 860ms ease,
    filter 980ms ease;
}

.hero-stage,
.panel,
footer {
  position: relative;
  border-radius: var(--radius-xl);
  border: 1px solid var(--stroke-soft);
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.03)),
    linear-gradient(20deg, rgba(157, 185, 255, 0.08), rgba(255, 205, 226, 0.04));
  box-shadow:
    var(--shadow-lg),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(24px) saturate(1.08);
}

.panel,
footer {
  overflow: hidden;
}

.panel::before,
footer::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(227, 236, 255, 0.74), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.hero-stage {
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  gap: 20px;
  padding: 34px;
  overflow: hidden;
  isolation: isolate;
}

.hero-stage::before,
.hero-stage::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.hero-stage::before {
  width: 620px;
  height: 620px;
  left: -180px;
  top: -250px;
  background: radial-gradient(circle, rgba(164, 191, 255, 0.2), transparent 68%);
  filter: blur(18px);
  animation: drift-glow 12s ease-in-out infinite alternate;
}

.hero-stage::after {
  width: 520px;
  height: 520px;
  right: -160px;
  bottom: -230px;
  background: radial-gradient(circle, rgba(255, 189, 215, 0.16), transparent 68%);
  filter: blur(18px);
  animation: drift-glow 14s ease-in-out infinite alternate-reverse;
}

@keyframes drift-glow {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  100% {
    transform: translate3d(20px, -16px, 0) scale(1.06);
  }
}

.hero-stage > * {
  position: relative;
  z-index: 1;
}

.hero-copy {
  display: grid;
  align-content: start;
  gap: 10px;
}

.eyebrow {
  display: inline-block;
  width: fit-content;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.06);
  color: #e9efff;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.66rem;
  font-weight: 700;
  padding: 8px 13px;
  margin-bottom: 8px;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  line-height: 1.1;
}

h1 {
  font-size: clamp(2.4rem, 5.3vw, 4.1rem);
  letter-spacing: -0.018em;
  margin-bottom: 8px;
}

h1 span {
  background: linear-gradient(100deg, var(--pearl) 0%, #e9ddff 44%, #ffdce8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 8px 24px rgba(159, 186, 255, 0.24);
}

.subtitle {
  max-width: 56ch;
  color: #e5ebff;
  font-size: clamp(1rem, 1.6vw, 1.15rem);
  line-height: 1.72;
  text-wrap: pretty;
}

.birth-line {
  margin-top: 11px;
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: #dbe5ff;
  padding: 10px 14px;
  font-size: 0.92rem;
}

.countdown {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(4, minmax(82px, 124px));
  gap: 11px;
}

.time-card {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.05));
  box-shadow: var(--shadow-sm);
  text-align: center;
  padding: 14px 8px;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.time-card.is-tick {
  animation: tick-pop 360ms ease;
}

@keyframes tick-pop {
  42% {
    transform: translateY(-4px) scale(1.03);
    border-color: rgba(190, 214, 255, 0.75);
    box-shadow: 0 16px 28px rgba(146, 180, 255, 0.26);
  }
}

.time-card p {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 800;
  color: #f4f8ff;
}

.time-card span {
  display: block;
  margin-top: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #cfd9fb;
}

.hero-actions {
  margin-top: 18px;
  display: flex;
  justify-content: center;
  width: 100%;
}

.btn {
  border: 1px solid transparent;
  border-radius: 999px;
  min-height: 46px;
  padding: 13px 22px;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  touch-action: manipulation;
  transition: transform 220ms ease, box-shadow 220ms ease, border-color 220ms ease, background-color 220ms ease;
}

.btn:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px rgba(9, 12, 24, 0.88),
    0 0 0 4px rgba(198, 216, 255, 0.62);
}

.btn:hover {
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(0) scale(0.992);
}

.btn:disabled,
.btn.is-locked {
  cursor: not-allowed;
  opacity: 0.68;
  filter: saturate(0.58);
  transform: none !important;
  box-shadow:
    0 8px 20px rgba(98, 111, 145, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.btn-primary {
  color: #101320;
  border-color: rgba(255, 255, 255, 0.56);
  background: linear-gradient(106deg, #f9fbff 0%, #dce8ff 42%, #ffdceb 100%);
  box-shadow:
    0 12px 30px rgba(176, 201, 255, 0.36),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.btn-surprise {
  border-color: rgba(255, 255, 255, 0.46);
  background: linear-gradient(98deg, #f8fbff 0%, #d5e5ff 42%, #ffdcea 100%);
  box-shadow:
    0 16px 34px rgba(158, 188, 255, 0.42),
    0 0 0 1px rgba(255, 255, 255, 0.46) inset;
  animation: surprise-glow 2.7s ease-in-out infinite;
}

@keyframes surprise-glow {
  50% {
    box-shadow:
      0 18px 36px rgba(148, 179, 255, 0.5),
      0 0 0 1px rgba(255, 255, 255, 0.58) inset,
      0 0 22px rgba(209, 188, 255, 0.4);
  }
}

.btn-ghost {
  color: #eaf0ff;
  border-color: rgba(255, 255, 255, 0.24);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.btn-ripple {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0);
  background: rgba(255, 255, 255, 0.5);
  animation: ripple-wave 620ms ease-out forwards;
}

@keyframes ripple-wave {
  to {
    transform: translate(-50%, -50%) scale(16);
    opacity: 0;
  }
}

.hint {
  margin-top: 10px;
  font-size: 0.86rem;
  color: var(--muted);
}

.hint.is-empty {
  display: none;
}

.btn.is-disabled-link {
  opacity: 0.5;
  pointer-events: none;
  filter: grayscale(0.3);
}

code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.hero-visual {
  display: grid;
  align-content: center;
  justify-items: center;
}

.portrait-orb {
  width: min(390px, 100%);
  aspect-ratio: 1;
  border-radius: 50%;
  position: relative;
  overflow: hidden;
  border: 5px solid rgba(255, 255, 255, 0.26);
  box-shadow: var(--shadow-xl);
  animation: orb-float 7s ease-in-out infinite;
}

@keyframes orb-float {
  50% {
    transform: translateY(-5px);
  }
}

.portrait-orb::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 34%);
  pointer-events: none;
}

.portrait-orb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.portrait-orb .photo-missing {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 22px;
  font-size: 0.86rem;
  color: #eef4ff;
  background: rgba(255, 255, 255, 0.11);
}

.portrait-orb.is-missing img {
  display: none;
}

.portrait-orb.is-missing .photo-missing {
  display: flex;
}

.badge {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(9, 11, 20, 0.66);
  color: #edf3ff;
  padding: 8px 14px;
  font-size: 0.82rem;
  letter-spacing: 0.05em;
}

.float-balloon {
  display: none;
}

.orbit-hearts {
  display: none;
}

main {
  margin-top: 22px;
  display: grid;
  gap: 20px;
}

.panel {
  padding: 30px 24px;
}

.panel h2 {
  font-size: clamp(1.6rem, 3.8vw, 2.4rem);
  margin-bottom: 14px;
  letter-spacing: -0.012em;
}

.section-copy {
  color: var(--muted);
  margin-bottom: 14px;
  text-wrap: pretty;
}

.wish p {
  margin-bottom: 14px;
  color: #e9efff;
  line-height: 1.8;
  text-wrap: pretty;
  transition: opacity 220ms ease;
  max-width: 58ch;
}

.spark-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

@media (min-width: 1080px) {
  main {
    grid-template-columns: minmax(320px, 0.84fr) minmax(0, 1.16fr);
    align-items: stretch;
  }

  .wish {
    display: grid;
    align-content: space-between;
    gap: 16px;
  }

  .wish .btn {
    justify-self: start;
  }

  .spark {
    display: grid;
    align-content: start;
    gap: 10px;
  }
}

.spark-card {
  perspective: 1200px;
  min-height: 188px;
}

.spark-card-inner {
  position: relative;
  width: 100%;
  min-height: 188px;
  transform-style: preserve-3d;
  transition: transform 520ms ease;
  cursor: pointer;
  animation: note-float 6.5s ease-in-out infinite;
}

@media (hover: hover) and (pointer: fine) {
  .spark-card:hover .spark-card-inner {
    transform: translateY(-4px);
  }

  .spark-card.is-flipped:hover .spark-card-inner {
    transform: rotateY(180deg) translateY(-4px);
  }
}

.spark-card.is-flipped .spark-card-inner {
  transform: rotateY(180deg);
  animation: none;
}

@keyframes note-float {
  50% {
    transform: translateY(-4px);
  }
}

.spark-face {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-md);
  backface-visibility: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow:
    var(--shadow-sm),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  padding: 18px;
  display: grid;
  align-content: center;
  text-align: center;
}

.spark-face.front {
  background:
    radial-gradient(250px 140px at 50% 0, rgba(162, 194, 255, 0.2), transparent 66%),
    rgba(255, 255, 255, 0.06);
}

.spark-face.back {
  transform: rotateY(180deg);
  background:
    radial-gradient(250px 140px at 50% 100%, rgba(255, 205, 224, 0.2), transparent 64%),
    rgba(255, 255, 255, 0.09);
}

.spark-face h3 {
  font-size: 1.24rem;
  margin-bottom: 8px;
}

.spark-face p {
  color: #e8efff;
}

footer {
  margin-top: 22px;
  padding: 20px 16px;
  text-align: center;
  color: #d6e0ff;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
}

.letter-modal,
.overlay-view,
.finale-overlay {
  position: fixed;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 260ms ease;
}

.letter-modal,
.overlay-view {
  z-index: 110;
}

.finale-overlay {
  z-index: 115;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 6, 13, 0.82);
}

.letter-modal.is-visible,
.overlay-view.is-visible,
.finale-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.letter-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 16, 0.9);
  backdrop-filter: blur(18px);
}

.letter-book {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.94);
  width: min(940px, 94%);
  max-height: min(90vh, 800px);
  border-radius: 26px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.03));
  box-shadow: var(--shadow-xl);
  box-shadow:
    var(--shadow-xl),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(24px);
  padding: 20px;
  overflow: auto;
  overscroll-behavior: contain;
  opacity: 0;
  transition: transform 340ms ease, opacity 340ms ease;
}

.letter-modal.is-visible .letter-book {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.icon-btn {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.05));
  color: #eef4ff;
  font-size: 1.22rem;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: transform 180ms ease, border-color 180ms ease, background-color 180ms ease;
}

.icon-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.42);
}

.book-stage {
  margin-top: 22px;
  min-height: min(430px, 58vh);
  perspective: 1400px;
  display: grid;
}

.book-cover,
.book-paper {
  grid-area: 1 / 1;
  border-radius: 22px;
  min-height: min(430px, 58vh);
}

.book-cover {
  width: 52%;
  display: grid;
  place-content: center;
  gap: 12px;
  padding: 22px;
  text-align: center;
  color: #fff6fb;
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 24px 38px rgba(0, 0, 0, 0.33);
  background:
    radial-gradient(140px 120px at 24% 20%, rgba(255, 255, 255, 0.28), transparent 62%),
    linear-gradient(150deg, #ff8fa8 0%, #ff6f8b 46%, #e25f88 100%);
  transform-origin: left center;
  transform: rotateY(0deg);
  transition: transform 900ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 360ms ease;
  user-select: none;
  cursor: pointer;
  z-index: 3;
}

.book-cover p {
  font-size: 0.98rem;
}

.book-cover h3 {
  font-size: clamp(1.9rem, 4vw, 2.9rem);
}

.book-paper {
  margin-left: auto;
  width: 70%;
  padding: 24px 22px;
  border: 1px solid rgba(137, 103, 107, 0.26);
  background: linear-gradient(180deg, rgba(255, 250, 246, 0.98), rgba(255, 244, 237, 0.98));
  color: #5f3d3f;
  box-shadow: 0 22px 30px rgba(0, 0, 0, 0.2);
  overflow: auto;
  transform: translateX(30px) scale(0.985);
  opacity: 0;
  pointer-events: none;
  transition: transform 820ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 580ms ease;
}

.book-paper h3 {
  font-size: clamp(1.8rem, 2.4vw, 2.2rem);
}

.letter-content {
  margin-top: 12px;
  display: grid;
  gap: 12px;
  font-size: 1rem;
  line-height: 1.76;
  color: #654446;
}

.signature {
  margin-top: 14px;
  color: #a06462;
  font-style: italic;
}

.letter-footer {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

.letter-footer-actions {
  width: min(300px, 100%);
  margin-left: auto;
  display: grid;
  gap: 8px;
}

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

#open-gallery.hidden {
  display: none;
}

#open-gallery.hidden.show {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.hidden {
  opacity: 0;
  pointer-events: none;
}

.hidden.show {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 280ms ease;
}

.letter-modal.is-visible:not(.is-open) .book-cover {
  animation: cover-idle 1900ms ease-in-out infinite;
}

@keyframes cover-idle {
  50% {
    transform: translateY(-2px) rotateY(-2deg);
  }
}

.letter-modal.is-open .book-cover {
  animation: cover-open 900ms cubic-bezier(0.2, 0.85, 0.2, 1) forwards;
  cursor: default;
}

@keyframes cover-open {
  0% {
    transform: rotateY(0deg);
  }
  72% {
    transform: rotateY(-176deg);
  }
  100% {
    transform: rotateY(-166deg);
  }
}

.letter-modal.is-open .book-paper {
  transform: translateX(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.overlay-view {
  background:
    radial-gradient(720px 360px at 52% 0%, rgba(167, 193, 255, 0.14), transparent 72%),
    rgba(4, 7, 15, 0.96);
  padding:
    max(24px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.overlay-head {
  width: min(920px, 100%);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 6;
  padding: 8px 0;
  background: linear-gradient(180deg, rgba(4, 7, 15, 0.96), rgba(4, 7, 15, 0.72));
  backdrop-filter: blur(8px);
}

.overlay-head h2 {
  font-size: clamp(2rem, 4vw, 3.2rem);
}

.gift-view {
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 16px;
}

.gift-view .overlay-head {
  width: min(900px, 100%);
}

.gift-view video {
  width: min(900px, 100%);
  max-height: 62vh;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow-lg);
}

.finale-card {
  width: min(640px, 100%);
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background:
    radial-gradient(500px 260px at 0 0, rgba(170, 198, 255, 0.2), transparent 62%),
    radial-gradient(380px 240px at 100% 100%, rgba(255, 198, 221, 0.2), transparent 64%),
    rgba(16, 20, 36, 0.92);
  text-align: center;
  box-shadow: var(--shadow-xl);
  padding: 36px 24px;
}

.finale-card h2 {
  font-size: clamp(2rem, 4.8vw, 3.2rem);
  margin-bottom: 12px;
}

.finale-card p {
  color: #e5edff;
  line-height: 1.74;
  margin-bottom: 15px;
}

.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 560ms ease, transform 560ms ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .hero-stage {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 24px;
  }

  .hero-visual {
    order: -1;
  }

  .hero-copy {
    justify-items: center;
    text-align: center;
  }

  .portrait-orb {
    width: min(320px, 100%);
  }
}

@media (max-width: 700px) {
  .shell {
    padding:
      max(14px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      max(20px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
  }

  .hero-stage,
  .panel {
    border-radius: 22px;
    padding: 20px 16px;
  }

  .portrait-orb {
    width: min(256px, 78vw);
  }

  .orbit-hearts {
    display: none;
  }

  .hero-actions {
    width: 100%;
  }

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

  .birth-line {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .hint {
    width: 100%;
    text-align: center;
  }

  .countdown {
    grid-template-columns: repeat(2, minmax(96px, 1fr));
  }

  .book-stage {
    min-height: 392px;
    margin-top: 8px;
  }

  .letter-book {
    width: min(920px, calc(100% - 8px));
    max-height: 92vh;
    border-radius: 22px;
    padding: 10px 8px;
  }

  .letter-modal.is-open .letter-book {
    width: min(920px, calc(100% - 2px));
    max-height: 94vh;
    border-radius: 20px;
    padding: 2px;
  }

  .book-cover {
    width: 100%;
    min-height: 158px;
    transform-origin: top center;
  }

  .book-paper {
    width: 100%;
    min-height: 302px;
    margin-top: 86px;
    padding: 16px 12px;
  }

  .letter-modal.is-open .book-stage {
    margin-top: 0;
    min-height: 0;
  }

  .letter-modal.is-open .book-paper {
    margin-top: 0 !important;
    min-height: clamp(280px, 54vh, 560px);
    max-height: calc(94vh - 92px);
    border-radius: 18px;
  }

  .letter-modal.is-open .book-cover {
    display: none;
  }

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

  .overlay-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .overlay-head h2 {
    font-size: clamp(1.7rem, 7.6vw, 2.3rem);
  }

  .gift-view video {
    max-height: 50vh;
  }
}

@media (max-width: 420px) {
  h1 {
    font-size: clamp(1.95rem, 10vw, 2.46rem);
  }

  .subtitle {
    font-size: 0.96rem;
  }

  .eyebrow {
    font-size: 0.62rem;
    letter-spacing: 0.12em;
  }

  .portrait-orb {
    width: min(228px, 78vw);
  }

  .float-balloon {
    width: 36px;
    height: 48px;
  }

  .float-balloon::after {
    height: 28px;
    top: 45px;
  }

  .book-paper h3 {
    font-size: 1.56rem;
  }
}

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

  body.is-entering .shell,
  body.is-entering.is-ready .shell,
  body.is-entering #entry-curtain,
  body.is-entering.is-ready #entry-curtain,
  body.is-entering #intro-flock,
  body.is-entering.is-ready #intro-flock {
    opacity: 1 !important;
    filter: none !important;
    transform: none !important;
    transition: none !important;
  }
}
