/* ─────────────────────────────────────────────
   Palette + Type
   ───────────────────────────────────────────── */
:root {
  --cream:    #ece9ef;
  --peach:    #e3d4e0;
  --blush:    #e0b9d0;
  --rose:     #d997b9;
  --coral:    #b8649a;
  --lavender: #8a5ea6;
  --plum:     #5a3a7a;
  --night:    #2d1c40;
  --deep:     #110a1c;

  --gold:       #e879b0;
  --gold-soft:  #f5a8cf;
  --ink:        #1a1322;
  --ink-soft:   #5b4868;

  --serif:  'Cormorant Garamond', 'Times New Roman', serif;
  --hand:   'Caveat', cursive;
  --script: 'Pinyon Script', cursive;
  --mono:   'JetBrains Mono', ui-monospace, monospace;
}

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

html, body { margin: 0; padding: 0; }
body {
  font-family: var(--serif);
  color: var(--ink);
  line-height: 1.5;
  overflow-x: hidden;
  background:
    linear-gradient(180deg,
      var(--cream)    0%,
      var(--peach)    9%,
      var(--blush)   20%,
      var(--rose)    32%,
      var(--coral)   44%,
      var(--lavender) 56%,
      var(--plum)    68%,
      var(--night)   82%,
      var(--deep)   100%);
}

::selection { background: var(--gold); color: var(--deep); }

/* ─────────────────────────────────────────────
   Clouds
   ───────────────────────────────────────────── */
.clouds {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: var(--cloud-op, 0.9);
  transition: opacity 0.5s linear;
}

.cloud {
  position: absolute;
  pointer-events: none;
}

.cloud-body {
  position: relative;
  background: rgba(255, 250, 255, 0.52);
  border-radius: 60px;
  filter: blur(1.5px);
}

.cloud-body::before,
.cloud-body::after {
  content: '';
  position: absolute;
  background: rgba(255, 250, 255, 0.52);
  border-radius: 50%;
}

/* Cloud sizes */
.cloud-1 .cloud-body              { width: 170px; height: 46px; }
.cloud-1 .cloud-body::before      { width: 80px;  height: 68px; top: -38px; left: 22px; }
.cloud-1 .cloud-body::after       { width: 58px;  height: 52px; top: -28px; right: 24px; }

.cloud-2 .cloud-body              { width: 115px; height: 32px; }
.cloud-2 .cloud-body::before      { width: 56px;  height: 50px; top: -28px; left: 16px; }
.cloud-2 .cloud-body::after       { width: 42px;  height: 38px; top: -20px; right: 16px; }

.cloud-3 .cloud-body              { width: 82px;  height: 24px; }
.cloud-3 .cloud-body::before      { width: 40px;  height: 36px; top: -20px; left: 12px; }
.cloud-3 .cloud-body::after       { width: 30px;  height: 28px; top: -14px; right: 12px; }

.cloud-4 .cloud-body              { width: 140px; height: 38px; }
.cloud-4 .cloud-body::before      { width: 66px;  height: 58px; top: -32px; left: 18px; }
.cloud-4 .cloud-body::after       { width: 48px;  height: 44px; top: -24px; right: 20px; }

/* Cloud positions & drift speeds */
.cloud-1 { top: 9vh;  animation: cloud-drift 85s linear infinite; }
.cloud-2 { top: 20vh; animation: cloud-drift 58s linear infinite 20s; }
.cloud-3 { top: 6vh;  animation: cloud-drift 44s linear infinite 36s; }
.cloud-4 { top: 15vh; animation: cloud-drift 70s linear infinite 10s; }

@keyframes cloud-drift {
  from { transform: translateX(-360px); }
  to   { transform: translateX(calc(100vw + 360px)); }
}

/* Single subtle background heart */
.bg-hearts {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.bh {
  position: absolute;
  pointer-events: none;
  animation: bh-breathe 18s ease-in-out infinite;
}

.bh-a {
  width: 42vmin;
  height: 42vmin;
  bottom: 18vh;
  right: 5vw;
  animation-delay: 0s;
}

@keyframes bh-breathe {
  0%, 100% { transform: scale(1);    opacity: 1; }
  50%       { transform: scale(1.06); opacity: 0.45; }
}

/* ─────────────────────────────────────────────
   Layered atmosphere
   ───────────────────────────────────────────── */
.sky {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.sun {
  position: absolute;
  width: 520px; height: 520px;
  border-radius: 50%;
  left: 50%;
  top: 12vh;
  transform: translateX(-50%) translateY(var(--sun-y, 0));
  background: radial-gradient(circle at center,
      rgba(255, 220, 235, 0.85) 0%,
      rgba(245, 180, 215, 0.45) 28%,
      rgba(220, 150, 200, 0.18) 50%,
      rgba(220, 150, 200, 0) 70%);
  filter: blur(2px);
  opacity: var(--sun-op, 1);
  transition: opacity 0.4s linear;
}
.moon {
  position: absolute;
  right: 12vw;
  top: 14vh;
  width: 110px; height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f5e8ff, #c8b3e0 60%, #8a72b0 100%);
  box-shadow:
    0 0 60px rgba(220, 200, 240, 0.5),
    0 0 140px rgba(200, 170, 230, 0.28);
  opacity: var(--moon-op, 0);
  transform: translateY(var(--moon-y, 30px));
  transition: opacity 0.6s linear, transform 0.6s linear;
}
.stars {
  position: absolute; inset: 0;
  opacity: var(--stars-op, 0);
  transition: opacity 0.6s linear;
}
.stars span {
  position: absolute;
  width: 2px; height: 2px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 6px #fff, 0 0 14px rgba(255,240,210,0.6);
  animation: twinkle var(--d, 3s) ease-in-out infinite alternate;
}
@keyframes twinkle {
  0%   { opacity: 0.2; transform: scale(0.8); }
  100% { opacity: 1;   transform: scale(1.2); }
}

/* Petals/hearts container */
.petals {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}
.petal {
  position: absolute;
  top: -40px;
  will-change: transform, opacity;
  animation: drift linear forwards;
  opacity: 0;
}
@keyframes drift {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg);    opacity: 0; }
  8%   { opacity: var(--peak, 0.85); }
  100% { transform: translate3d(var(--dx, 80px), 110vh, 0) rotate(var(--dr, 360deg)); opacity: 0; }
}

/* ─────────────────────────────────────────────
   Layout
   ───────────────────────────────────────────── */
.page { position: relative; z-index: 2; }

.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8vh 6vw 4vh;
  position: relative;
}
.prelude {
  font-family: var(--script);
  font-size: clamp(2.4rem, 5vw, 4.4rem);
  color: var(--coral);
  margin: 0 0 0.4rem;
  letter-spacing: 0.01em;
  line-height: 1;
}
.hero h1 {
  font-family: var(--serif);
  font-weight: 300;
  font-style: italic;
  font-size: clamp(2.6rem, 5.6vw, 5rem);
  line-height: 1.08;
  margin: 0.4rem 0 1.6rem;
  color: var(--ink);
  text-wrap: balance;
  max-width: 18ch;
}
.hero h1 em {
  font-style: italic;
  color: var(--coral);
}
.hero .signoff {
  font-family: var(--hand);
  font-size: clamp(1.4rem, 2.2vw, 2rem);
  color: var(--ink-soft);
  margin: 0.4rem 0 4rem;
}
.hero .scroll-hint {
  position: absolute;
  bottom: 4vh;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--hand);
  font-size: 1.3rem;
  color: var(--ink-soft);
  letter-spacing: 0.06em;
  opacity: 0.75;
  animation: bob 2.4s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translate(-50%, 0); }
  50%      { transform: translate(-50%, 8px); }
}
.hero .heart-hint {
  position: absolute;
  bottom: 11vh;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--hand);
  font-size: 1.1rem;
  color: var(--ink-soft);
  opacity: 0.6;
  white-space: nowrap;
  pointer-events: none;
}

/* ─────────────────────────────────────────────
   Chapters
   ───────────────────────────────────────────── */
.chapter {
  min-height: 100vh;
  padding: 14vh 8vw;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
}
.chapter-num {
  font-family: var(--script);
  font-size: clamp(2.4rem, 4vw, 3.6rem);
  color: var(--gold);
  line-height: 1;
  margin: 0 0 0.4rem;
  opacity: 0.8;
}
.chapter h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-style: italic;
  font-size: clamp(2rem, 4.4vw, 4rem);
  line-height: 1.1;
  margin: 0 0 1.6rem;
  text-wrap: balance;
  max-width: 22ch;
}
.chapter p {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.15rem, 1.6vw, 1.5rem);
  line-height: 1.6;
  max-width: 38ch;
  margin: 0.6rem 0;
  text-wrap: pretty;
}
.chapter .reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 1s ease, transform 1s cubic-bezier(.2,.7,.2,1);
}
.chapter.in-view .reveal { opacity: 1; transform: none; }
.chapter .reveal:nth-child(2) { transition-delay: 0.12s; }
.chapter .reveal:nth-child(3) { transition-delay: 0.24s; }
.chapter .reveal:nth-child(4) { transition-delay: 0.36s; }
.chapter .reveal:nth-child(5) { transition-delay: 0.48s; }
.chapter .reveal:nth-child(6) { transition-delay: 0.6s; }

/* Layout variants */
.lay-left  { align-items: flex-start; text-align: left; }
.lay-right { align-items: flex-end;   text-align: right; }
.lay-right p, .lay-right h2 { margin-left: auto; }
.lay-center{ align-items: center;     text-align: center; }
.lay-center h2, .lay-center p { margin-left: auto; margin-right: auto; }

/* Chapter 2  drifting bubbles */
.bubbles {
  margin-top: 2rem;
  display: flex; flex-wrap: wrap; gap: 0.6rem 0.8rem;
  max-width: 46ch;
}
.bubble {
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.7);
  color: var(--ink);
  font-family: var(--hand);
  font-size: 1.2rem;
  padding: 0.4rem 0.95rem;
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 6px 20px rgba(120, 60, 90, 0.08);
  transform: rotate(var(--rot, -1deg));
}
.bubble.right { border-radius: 18px 18px 4px 18px; }

/* Chapter 3  sleepcall */
.chapter-3 {
  background: linear-gradient(180deg,
    transparent 0%,
    rgba(40, 30, 60, 0.18) 40%,
    rgba(40, 30, 60, 0.32) 100%);
}
.chapter-3 h2, .chapter-3 p { color: #2d1f3a; }
.crescent {
  position: absolute;
  right: 8vw; top: 18vh;
  width: 140px; height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 32%, #f5e8ff, #c8b3e0 60%, #8a72b0 100%);
  box-shadow: 14px 14px 0 0 rgba(60, 40, 80, 0.0);
}
.crescent::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 70% 50%,
    rgba(40, 30, 60, 0) 0%,
    rgba(40, 30, 60, 0) 38%,
    rgba(40, 30, 60, 0.92) 42%,
    rgba(40, 30, 60, 0.96) 100%);
  transform: translateX(28%);
}

/* Chapter 4  downfall */
.chapter-4 h2 {
  font-style: italic;
  transform: rotate(-1.2deg);
}
.chapter-4 .crack {
  width: 220px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--ink-soft), transparent);
  margin: 1.4rem 0;
  position: relative;
}
.chapter-4 .crack::before {
  content: '';
  position: absolute; left: 50%; top: -3px;
  width: 7px; height: 7px;
  background: var(--coral);
  border-radius: 50%;
  transform: translateX(-50%);
  box-shadow: 0 0 18px rgba(232, 155, 156, 0.7);
}

/* Chapter 5  matching */
.matching {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1.5rem;
  align-items: center;
  max-width: 720px;
  margin-top: 2rem;
}
.profile-card {
  background: rgba(255,255,255,0.5);
  border: 1px solid rgba(255,255,255,0.8);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  box-shadow: 0 10px 30px rgba(120, 60, 90, 0.08);
  text-align: center;
  color: inherit;
  text-decoration: none;
  display: block;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
}
a.profile-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 36px rgba(120, 60, 90, 0.16);
}
.profile-card .pfp.has-avatar {
  background-size: cover;
  background-position: center;
  color: transparent;
  text-shadow: none;
}
.profile-card .pfp {
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, var(--rose), var(--coral));
  margin: 0 auto 0.5rem;
  display: grid; place-items: center;
  color: #fff;
  font-family: var(--serif);
  font-size: 1.4rem;
  font-style: italic;
}
.profile-card .pfp.jp { background: linear-gradient(135deg, var(--lavender), var(--plum)); }
.profile-card .name { font-family: var(--hand); font-size: 1.3rem; }
.profile-card .status {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-soft);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 0.25rem;
}
.matching .between {
  font-family: var(--script);
  font-size: 2.4rem;
  color: var(--coral);
}

/* Chapter 6  flowers */
.flowers {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.flower {
  position: absolute;
  font-size: 28px;
  opacity: 0.55;
  animation: sway 7s ease-in-out infinite alternate;
}
@keyframes sway {
  0%   { transform: rotate(-6deg); }
  100% { transform: rotate(6deg);  }
}
.chapter-6 .note {
  margin-top: 1rem;
  font-family: var(--hand);
  font-size: 1.4rem;
  color: var(--ink-soft);
  background: rgba(255,255,255,0.5);
  padding: 0.6rem 1rem;
  border-radius: 14px;
  display: inline-block;
  transform: rotate(-1.5deg);
  border: 1px dashed rgba(120, 60, 90, 0.25);
}

/* Chapter 7  neun Tage */
.chapter-7 {
  text-align: center;
  align-items: center;
}
.chapter-7 h2, .chapter-7 p { margin-left: auto; margin-right: auto; }
.nine-dots {
  display: flex;
  gap: 14px;
  margin: 2rem 0 1.5rem;
  justify-content: center;
}
.nine-dots span {
  width: 10px; height: 10px;
  background: rgba(255,255,255,0.45);
  border-radius: 50%;
  animation: pulse-dot 2.4s ease-in-out infinite;
}
.nine-dots span:nth-child(1){ animation-delay: 0.0s; }
.nine-dots span:nth-child(2){ animation-delay: 0.15s; }
.nine-dots span:nth-child(3){ animation-delay: 0.3s; }
.nine-dots span:nth-child(4){ animation-delay: 0.45s; }
.nine-dots span:nth-child(5){ animation-delay: 0.6s; }
.nine-dots span:nth-child(6){ animation-delay: 0.75s; }
.nine-dots span:nth-child(7){ animation-delay: 0.9s; }
.nine-dots span:nth-child(8){ animation-delay: 1.05s; }
.nine-dots span:nth-child(9){ animation-delay: 1.2s; }
@keyframes pulse-dot {
  0%, 100% { opacity: 0.25; transform: scale(0.85); }
  50%      { opacity: 0.95; transform: scale(1.2); }
}

/* Chapter 8  final, stars overhead */
.chapter-8 h2, .chapter-8 p { color: #fff8ee; }
.chapter-8 .chapter-num { color: var(--gold-soft); }
.chapter-8 h2 em { color: var(--gold-soft); font-style: italic; }

/* ─────────────────────────────────────────────
   Hidden hearts in chapters
   ───────────────────────────────────────────── */
.hh {
  --size: 22px;
  display: inline-grid;
  place-items: center;
  width: var(--size); height: var(--size);
  margin: 0 0.15em;
  border: 0; padding: 0;
  background: transparent;
  cursor: pointer;
  position: relative;
  color: var(--coral);
  vertical-align: -3px;
  transition: transform 0.25s ease, filter 0.3s ease;
  font-family: var(--serif);
  line-height: 1;
}
.hh::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 200, 200, 0.6), transparent 70%);
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}
.hh:hover { transform: scale(1.25) rotate(-6deg); }
.hh:hover::before { opacity: 1; }
.hh svg { width: 100%; height: 100%; display: block; transition: transform 0.4s ease; }
.hh .letter {
  position: absolute;
  inset: 0;
  display: grid; place-items: center;
  font-family: var(--mono);
  font-weight: 600;
  font-size: calc(var(--size) * 0.48);
  color: #fff;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(.3,1.4,.4,1);
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(120, 60, 90, 0.4);
}
.hh.found {
  color: var(--gold);
  transform: scale(1.18);
}
.hh.found .letter { opacity: 1; transform: scale(1); }
.hh.found svg {
  filter: drop-shadow(0 0 12px rgba(212, 169, 106, 0.8));
}
.hh.popping { animation: hh-pop 0.6s ease; }
@keyframes hh-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.5); }
  70%  { transform: scale(0.95); }
  100% { transform: scale(1.18); }
}

/* Letter tray */
.tray {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 50;
  background: rgba(255, 250, 244, 0.78);
  backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid rgba(255,255,255,0.7);
  border-radius: 12px;
  padding: 0.45rem 0.65rem 0.4rem;
  box-shadow: 0 10px 28px rgba(80, 40, 60, 0.16);
  transform: translateY(140%);
  transition: transform 0.6s cubic-bezier(.2,.8,.2,1);
}
.tray.visible { transform: none; }
.tray .label {
  font-family: var(--hand);
  font-size: 0.78rem;
  color: var(--ink-soft);
  letter-spacing: 0.03em;
  margin-bottom: 0.25rem;
  text-align: center;
  line-height: 1;
}
.tray .slots {
  display: flex; gap: 4px;
}
.tray .slot {
  width: 20px; height: 26px;
  display: grid; place-items: center;
  border-bottom: 2px solid var(--gold);
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gold);
  background: rgba(255,255,255,0.4);
  border-radius: 3px 3px 0 0;
  transition: background 0.3s ease, color 0.3s ease;
}
.tray .slot.filled {
  background: var(--gold);
  color: #fff;
  animation: slot-pop 0.5s cubic-bezier(.2,1.4,.4,1);
}
@keyframes slot-pop {
  0%   { transform: scale(0.7); }
  60%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* ─────────────────────────────────────────────
   Reveal section + gift
   ───────────────────────────────────────────── */
.reveal-section {
  min-height: 100vh;
  padding: 12vh 6vw 16vh;
  text-align: center;
  color: #fff8ee;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.reveal-section h2 {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(2rem, 4.4vw, 3.6rem);
  margin: 0 0 1rem;
  text-wrap: balance;
}
.reveal-section h2 em { color: var(--gold-soft); }
.reveal-section .lead {
  max-width: 38ch;
  font-size: clamp(1.05rem, 1.4vw, 1.3rem);
  color: rgba(255, 248, 238, 0.85);
  margin: 0 auto 2.5rem;
  text-wrap: pretty;
}

.code-form {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(212, 169, 106, 0.4);
  border-radius: 999px;
  padding: 0.4rem 0.5rem 0.4rem 1.4rem;
  box-shadow: 0 16px 48px rgba(0,0,0,0.25), inset 0 0 0 1px rgba(255,255,255,0.04);
  backdrop-filter: blur(10px);
}
#code-input {
  background: transparent;
  border: 0;
  outline: 0;
  color: #fff8ee;
  font-family: var(--mono);
  font-size: 1.1rem;
  letter-spacing: 0.4em;
  width: 220px;
  padding: 0.4rem 0;
  text-transform: uppercase;
}
#code-input::placeholder {
  color: rgba(255, 248, 238, 0.4);
  letter-spacing: 0.18em;
  text-transform: none;
  font-family: var(--serif);
  font-style: italic;
}
#submit-code {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  border: 0;
  color: #fff;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1rem;
  padding: 0.55rem 1.4rem;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 8px 18px rgba(232, 121, 176, 0.35);
}
#submit-code:hover { transform: translateY(-2px); box-shadow: 0 12px 22px rgba(232, 121, 176, 0.45); }
#submit-code:active { transform: translateY(0); }

.code-msg {
  margin-top: 1rem;
  font-family: var(--hand);
  font-size: 1.2rem;
  min-height: 1.6em;
  color: rgba(255, 248, 238, 0.85);
  transition: color 0.3s ease;
}
.code-msg.error { color: #ffb6b8; animation: shake 0.5s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-6px); }
  75%      { transform: translateX(6px); }
}

/* Gift box */
.gift-stage {
  margin-top: 4rem;
  width: 280px; height: 280px;
  perspective: 800px;
  position: relative;
  opacity: 0;
  transform: translateY(30px) scale(0.92);
  transition: opacity 1s ease, transform 1s ease;
}
.gift-stage.show {
  opacity: 1;
  transform: none;
}
.gift-stage svg { width: 100%; height: 100%; overflow: visible; }

.gift-lid       { transform-origin: 50% 60%; transition: transform 1.3s cubic-bezier(.4, -0.3, .4, 1.4); }
.gift-ribbon-v  { transform-origin: 50% 50%; transition: transform 1s ease; }
.gift-ribbon-h  { transform-origin: 50% 50%; transition: transform 1s ease; }
.gift-bow       { transform-origin: 50% 50%; transition: transform 1.1s cubic-bezier(.5,1.6,.5,1), opacity 0.8s ease; }

.gift-stage.unwrapping .gift-bow      { transform: translateY(-200px) rotate(45deg) scale(0.4); opacity: 0; }
.gift-stage.unwrapping .gift-ribbon-v { transform: scaleY(0); }
.gift-stage.unwrapping .gift-ribbon-h { transform: scaleX(0); }
.gift-stage.unwrapping .gift-lid      { transform: translateY(-160px) rotate(-14deg); }

.key-card {
  position: absolute;
  left: 50%;
  bottom: -110px;
  transform: translate(-50%, 60px) scale(0.85);
  width: 380px;
  background: linear-gradient(180deg, #f6eef5, #d8c5e0);
  border: 1px solid rgba(232, 121, 176, 0.4);
  border-radius: 12px;
  padding: 1.2rem 1.4rem 1.4rem;
  box-shadow:
    0 24px 60px rgba(0,0,0,0.45),
    0 0 0 1px rgba(255,255,255,0.4) inset,
    0 0 80px rgba(232, 121, 176, 0.35);
  opacity: 0;
  transition: opacity 0.6s ease 0.9s, transform 0.8s cubic-bezier(.2,.9,.2,1) 0.9s;
  text-align: center;
}
.gift-stage.unwrapping .key-card {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}
.key-card .kc-label {
  font-family: var(--hand);
  font-size: 1.1rem;
  color: var(--ink-soft);
  margin-bottom: 0.3rem;
}
#kc-keys .kc-key + .kc-key {
  margin-top: 0.5rem;
}
.key-card .kc-key {
  font-family: var(--mono);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.18em;
  background: rgba(232, 121, 176, 0.12);
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  border: 1px dashed rgba(232, 121, 176, 0.6);
  word-break: break-all;
}
.key-card .kc-foot {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1rem;
  color: var(--ink-soft);
  margin-top: 0.7rem;
}

/* Confetti pieces (golden sparkles) */
.sparkles {
  position: absolute; inset: -40px;
  pointer-events: none;
}
.sparkles span {
  position: absolute;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--gold-soft);
  box-shadow: 0 0 8px var(--gold);
  opacity: 0;
}
.gift-stage.unwrapping .sparkles span {
  animation: sparkle 1.6s ease-out forwards;
}
@keyframes sparkle {
  0%   { transform: translate(0,0) scale(0); opacity: 1; }
  100% { transform: translate(var(--sx, 80px), var(--sy, -120px)) scale(1.3); opacity: 0; }
}

/* ─────────────────────────────────────────────
   Footer
   ───────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 4vh 6vw 6vh;
  color: rgba(255, 248, 238, 0.6);
  font-family: var(--script);
  font-size: 1.6rem;
  position: relative;
  z-index: 2;
}

/* Reduce motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Preview-mode badge */
.preview-badge {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 100;
  background: rgba(212, 169, 106, 0.92);
  color: var(--deep);
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  box-shadow: 0 8px 22px rgba(0,0,0,0.18);
  backdrop-filter: blur(8px);
}

/* Mobile */
@media (max-width: 720px) {
  .chapter { padding: 10vh 7vw; }
  .matching { grid-template-columns: 1fr; }
  .matching .between { transform: rotate(90deg); justify-self: center; }
  .crescent { width: 90px; height: 90px; right: 6vw; top: 8vh; }
  .key-card { width: calc(100vw - 4rem); }
  #code-input { width: 160px; }
}
