:root {
  --pink-50: #fff7fa;
  --pink-100: #ffe8f1;
  --pink-200: #ffd0e3;
  --pink-300: #f7a8c4;
  --pink-400: #e87a9f;
  --pink-500: #d45a84;
  --ink: #5a3544;
  --ink-soft: #8a5a6c;
  --paper: #fffafb;
  --paper-shadow: rgba(90, 53, 68, 0.2);
  --tape: rgba(255, 214, 229, 0.85);
  --frame-empty: #f3d5e2;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

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

body {
  font-family: "Patrick Hand", cursive;
  color: var(--ink);
  background: var(--pink-100);
  -webkit-tap-highlight-color: transparent;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 20% 10%, rgba(255, 182, 208, 0.55), transparent 55%),
    radial-gradient(ellipse 70% 45% at 90% 80%, rgba(232, 122, 159, 0.28), transparent 50%),
    linear-gradient(165deg, var(--pink-50), var(--pink-100) 45%, #f8d4e4);
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cpath d='M60 8c8 18 22 28 40 32-18 4-32 14-40 32-8-18-22-28-40-32 18-4 32-14 40-32z' fill='%23e87a9f' fill-opacity='0.12'/%3E%3C/svg%3E");
  background-size: 96px 96px;
}

.stage {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem 0.75rem calc(1.25rem + var(--safe-bottom));
  gap: 0.85rem;
  overflow-x: clip;
}

.hint {
  margin: 0;
  font-size: 0.95rem;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
  opacity: 0.85;
  animation: hint-pulse 2.4s ease-in-out infinite;
}

@keyframes hint-pulse {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

.book-shell {
  width: min(100%, 440px);
  height: min(72dvh, 660px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.book {
  width: 100%;
  height: 100%;
}

/* StPageFlip injects wrappers — keep our pages full-bleed paper */
.page {
  background: transparent !important;
}

.stf__parent {
  margin: 0 auto;
}

.stf__block {
  box-shadow: 0 18px 40px rgba(90, 53, 68, 0.18);
}

.paper {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 4px 12px 12px 4px;
  background:
    linear-gradient(90deg, rgba(90, 53, 68, 0.07), transparent 12px),
    linear-gradient(135deg, rgba(255, 255, 255, 0.55), transparent 40%),
    var(--paper);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.8) inset,
    0 0 0 1px rgba(232, 122, 159, 0.18);
  padding: 1.15rem 1rem 1.25rem;
}

.paper::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1.5px dashed rgba(232, 122, 159, 0.35);
  border-radius: 6px;
  pointer-events: none;
  z-index: 1;
}

.paper::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.05),
    transparent 16%,
    transparent 84%,
    rgba(255, 255, 255, 0.18)
  );
  z-index: 0;
}

.lily-blend {
  filter:
    drop-shadow(0 0 1px rgba(90, 53, 68, 0.35))
    drop-shadow(2px 3px 5px rgba(90, 53, 68, 0.22));
}

.sticker {
  position: absolute;
  pointer-events: none;
  user-select: none;
  z-index: 2;
}

.sticker-lily {
  width: 42%;
  top: -4%;
  right: -8%;
  transform: rotate(12deg);
  animation: floaty 5s ease-in-out infinite;
  z-index: 4;
}

.sticker-bubub {
  width: 36%;
  bottom: 5%;
  left: -2%;
  transform: rotate(-8deg);
  filter: drop-shadow(2px 4px 6px rgba(90, 53, 68, 0.2));
}

.sticker-adek {
  width: 26%;
  bottom: 7%;
  right: 2%;
  transform: rotate(7deg);
  filter: drop-shadow(2px 4px 6px rgba(90, 53, 68, 0.18));
}

.sticker-lily-sm {
  width: 30%;
  top: -5%;
  right: -6%;
  transform: rotate(8deg);
  z-index: 4;
}

.sticker-julian {
  width: 20%;
  bottom: 2%;
  right: -1%;
  transform: rotate(6deg);
  filter: drop-shadow(2px 4px 6px rgba(90, 53, 68, 0.2));
  z-index: 1;
  opacity: 0.92;
}

.sticker-adek-note {
  width: 20%;
  bottom: 2%;
  left: -1%;
  transform: rotate(-8deg);
  filter: drop-shadow(2px 4px 6px rgba(90, 53, 68, 0.18));
  z-index: 1;
  opacity: 0.92;
}

.sticker-lily-corner {
  width: 28%;
  top: -4%;
  left: -6%;
  transform: rotate(-18deg);
  z-index: 4;
}

.sticker-closing-lily {
  width: 34%;
  top: -5%;
  left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  z-index: 4;
}

.sticker-closing-bubub {
  width: 24%;
  bottom: 3%;
  left: -1%;
  transform: rotate(-10deg);
}

.sticker-closing-adek {
  width: 20%;
  bottom: 5%;
  right: 28%;
  transform: rotate(5deg);
}

.sticker-closing-julian {
  width: 22%;
  bottom: 3%;
  right: -1%;
  transform: rotate(8deg);
}

@keyframes floaty {
  0%,
  100% {
    transform: rotate(12deg) translateY(0);
  }
  50% {
    transform: rotate(14deg) translateY(-6px);
  }
}

.tape {
  position: absolute;
  width: 64px;
  height: 18px;
  background: var(--tape);
  box-shadow: 0 1px 2px rgba(90, 53, 68, 0.12);
  z-index: 5;
}

.tape-tl {
  top: 18px;
  left: 22px;
  transform: rotate(-18deg);
}

.tape-br {
  bottom: 28px;
  right: 28px;
  transform: rotate(12deg);
}

.cover-copy {
  position: relative;
  z-index: 3;
  margin-top: 16%;
  text-align: center;
  padding: 0 0.5rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  font-family: "Caveat", cursive;
  font-size: 1.35rem;
  color: var(--pink-500);
  letter-spacing: 0.18em;
}

.cover-copy h1,
.page-title,
.closing-copy h2 {
  font-family: "Caveat", cursive;
  font-weight: 700;
  line-height: 1.05;
  margin: 0;
}

.cover-copy h1 {
  font-size: clamp(2.3rem, 10vw, 3.3rem);
  color: var(--pink-500);
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.6);
}

.sub {
  margin: 0.75rem auto 0;
  max-width: 16ch;
  font-size: 1.15rem;
  color: var(--ink-soft);
  line-height: 1.35;
}

.page-title {
  position: relative;
  z-index: 3;
  font-size: clamp(1.85rem, 7.5vw, 2.35rem);
  color: var(--pink-500);
  text-align: center;
  margin-top: 0.35rem;
}

.page-note {
  position: relative;
  z-index: 3;
  margin: 0.25rem 0 0.85rem;
  text-align: center;
  color: var(--ink-soft);
  font-size: 1rem;
}

.paper-memories .page-title {
  margin-bottom: 0.55rem;
}

.memory-grid {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem 0.5rem;
  padding: 0 0.1rem 0.2rem;
  align-content: start;
}

.polaroid {
  margin: 0;
  background: #fff;
  padding: 0.3rem 0.3rem 0.45rem;
  box-shadow: 2px 3px 10px rgba(90, 53, 68, 0.14);
  transform: rotate(-2deg);
}

.polaroid:nth-child(2) {
  transform: rotate(2.5deg);
}

.polaroid:nth-child(3) {
  transform: rotate(1.5deg);
}

.polaroid:nth-child(4) {
  transform: rotate(-3deg);
}

.polaroid .frame {
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: var(--frame-empty);
  border: 1px solid rgba(232, 122, 159, 0.25);
}

.polaroid .frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.polaroid.is-broken .frame {
  background:
    repeating-linear-gradient(
      -45deg,
      var(--frame-empty),
      var(--frame-empty) 6px,
      #f9e4ee 6px,
      #f9e4ee 12px
    );
}

.polaroid.is-broken .frame img {
  display: none;
}

.polaroid figcaption {
  font-size: 0.9rem;
  text-align: center;
  padding: 0.35rem 0.15rem 0.45rem;
  color: var(--ink-soft);
}

.note-card {
  position: relative;
  z-index: 3;
  margin: 0.35rem 0.1rem 0;
  max-height: calc(100% - 4.8rem);
  overflow-y: auto;
  padding: 0.8rem 0.85rem 0.95rem;
  background: rgba(255, 255, 255, 0.78);
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(232, 122, 159, 0.2);
  -webkit-overflow-scrolling: touch;
}

.note-card p {
  margin: 0;
  font-size: clamp(0.95rem, 3.4vw, 1.1rem);
  line-height: 1.45;
}

.note-signoff {
  margin-top: 0.85rem !important;
  font-family: "Caveat", cursive;
  font-size: 1.3rem !important;
  color: var(--pink-500);
  text-align: right;
}

.paper-closing {
  display: flex;
  align-items: center;
  justify-content: center;
}

.closing-copy {
  position: relative;
  z-index: 3;
  text-align: center;
  padding: 0 1rem 3.2rem;
  max-width: 22ch;
}

.closing-heart {
  margin: 0 0 0.25rem;
  font-size: 1.8rem;
  color: var(--pink-400);
  animation: heart-beat 1.6s ease-in-out infinite;
}

@keyframes heart-beat {
  0%,
  100% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.12);
  }
  60% {
    transform: scale(1);
  }
}

.closing-copy h2 {
  font-size: clamp(2rem, 8.5vw, 2.55rem);
  color: var(--pink-500);
  margin-bottom: 0.65rem;
}

.closing-text {
  margin: 0;
  font-size: clamp(1.1rem, 4.2vw, 1.3rem);
  line-height: 1.4;
  color: var(--ink);
}

.closing-extra {
  margin: 0.85rem 0 0;
  font-family: "Caveat", cursive;
  font-size: clamp(1.25rem, 5vw, 1.55rem);
  color: var(--pink-500);
  line-height: 1.25;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  width: min(100%, 440px);
}

.nav-btn {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: var(--pink-300);
  color: #fff;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(232, 122, 159, 0.35);
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.nav-btn:hover:not(:disabled) {
  background: var(--pink-400);
  transform: scale(1.05);
}

.nav-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
  box-shadow: none;
}

.dots {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  padding: 0;
  background: rgba(232, 122, 159, 0.35);
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.dot.is-active {
  background: var(--pink-500);
  transform: scale(1.25);
}

@media (min-width: 720px) {
  .book-shell {
    width: min(100%, 460px);
  }

  .hint {
    font-size: 1.05rem;
  }
}

.stage.is-locked {
  visibility: hidden;
  pointer-events: none;
}

/* —— Gift gate —— */
.gift-gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem 1rem calc(1.25rem + var(--safe-bottom));
  background:
    radial-gradient(ellipse 80% 50% at 50% 20%, rgba(255, 182, 208, 0.55), transparent 55%),
    linear-gradient(165deg, var(--pink-50), var(--pink-100) 50%, #f8d4e4);
  transition: opacity 0.55s ease, visibility 0.55s ease;
}

.gift-gate.is-leaving {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.gift-gate.is-hidden {
  display: none;
}

.gift-gate__inner {
  width: min(100%, 360px);
  text-align: center;
}

.gift-gate__eyebrow {
  margin: 0;
  font-family: "Caveat", cursive;
  font-size: 1.25rem;
  color: var(--pink-500);
  letter-spacing: 0.12em;
}

.gift-gate__title {
  margin: 0.15rem 0 0.35rem;
  font-family: "Caveat", cursive;
  font-size: clamp(2rem, 9vw, 2.6rem);
  color: var(--pink-500);
  line-height: 1.05;
}

.gift-gate__hint {
  margin: 0 0 1.35rem;
  color: var(--ink-soft);
  font-size: 1.05rem;
}

.gift {
  position: relative;
  width: min(78vw, 260px);
  margin: 0 auto;
  perspective: 900px;
}

.gift.is-shake {
  animation: gift-shake 0.45s ease;
}

.gift.is-open .gift__lid {
  transform: translateY(-72%) rotateX(28deg) rotateZ(-8deg);
  opacity: 0.95;
}

.gift.is-open .gift__bow {
  transform: translate(-50%, -120%) scale(1.08);
}

@keyframes gift-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-8px) rotate(-2deg);
  }
  40% {
    transform: translateX(8px) rotate(2deg);
  }
  60% {
    transform: translateX(-6px);
  }
  80% {
    transform: translateX(6px);
  }
}

.gift__box {
  position: relative;
  height: 168px;
  border-radius: 10px 10px 14px 14px;
  background:
    linear-gradient(180deg, #ffc4d8 0%, var(--pink-300) 45%, #e87a9f 100%);
  box-shadow:
    0 16px 28px rgba(90, 53, 68, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
  overflow: visible;
}

.gift__ribbon-v {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 28px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, #fff0f6, #ffe0ec 40%, #ffd0e3);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.gift__ribbon-h {
  position: absolute;
  left: 0;
  right: 0;
  top: 42%;
  height: 28px;
  transform: translateY(-50%);
  background: linear-gradient(180deg, #fff0f6, #ffe0ec 40%, #ffd0e3);
}

.gift__lid {
  position: absolute;
  left: -6%;
  right: -6%;
  top: -18px;
  height: 52px;
  z-index: 3;
  transform-origin: center top;
  transition: transform 1s cubic-bezier(0.22, 0.8, 0.3, 1), opacity 0.9s ease;
}

.gift__lid-face {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background:
    linear-gradient(180deg, #ffd6e5, #f7a8c4 70%, #e87a9f);
  box-shadow:
    0 8px 16px rgba(90, 53, 68, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.gift__lid-face::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 28px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, #fff0f6, #ffe0ec 40%, #ffd0e3);
}

.gift__bow {
  position: absolute;
  left: 50%;
  top: -6px;
  z-index: 4;
  width: 70px;
  height: 40px;
  transform: translate(-50%, -55%);
  transition: transform 1s cubic-bezier(0.22, 0.8, 0.3, 1);
}

.gift__bow-loop {
  position: absolute;
  top: 4px;
  width: 34px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff7fa, #ffb6ce 55%, #e87a9f);
  box-shadow: 0 3px 6px rgba(90, 53, 68, 0.15);
}

.gift__bow-loop--l {
  left: 0;
  transform: rotate(-28deg);
}

.gift__bow-loop--r {
  right: 0;
  transform: rotate(28deg);
}

.gift__bow-knot {
  position: absolute;
  left: 50%;
  top: 12px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  transform: translateX(-50%);
  background: radial-gradient(circle at 30% 30%, #fff, #f7a8c4 60%, #d45a84);
}

.gift__label {
  position: absolute;
  left: 50%;
  top: 58%;
  z-index: 5;
  width: min(86%, 200px);
  transform: translate(-50%, -50%) rotate(-2deg);
  padding: 0.65rem 0.7rem 0.75rem;
  background: #fffafb;
  border-radius: 6px;
  box-shadow:
    0 4px 12px rgba(90, 53, 68, 0.16),
    0 0 0 1px rgba(232, 122, 159, 0.2);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.gift__label-text {
  font-family: "Caveat", cursive;
  font-size: 1.05rem;
  color: var(--pink-500);
  text-align: left;
}

.gift__input {
  width: 100%;
  border: 1.5px dashed rgba(232, 122, 159, 0.45);
  border-radius: 4px;
  padding: 0.45rem 0.5rem;
  font-family: "Patrick Hand", cursive;
  font-size: 1.05rem;
  color: var(--ink);
  background: #fff;
  outline: none;
}

.gift__input:focus {
  border-color: var(--pink-400);
  box-shadow: 0 0 0 3px rgba(247, 168, 196, 0.35);
}

.gift__open-btn {
  margin-top: 0.15rem;
  border: none;
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  background: var(--pink-400);
  color: #fff;
  font-family: "Patrick Hand", cursive;
  font-size: 1.05rem;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(232, 122, 159, 0.35);
}

.gift__open-btn:active {
  transform: scale(0.97);
}

.gift__error {
  margin: 0;
  font-size: 0.92rem;
  color: #c44569;
}

@media (prefers-reduced-motion: reduce) {
  .hint,
  .sticker-lily,
  .closing-heart,
  .gift.is-shake,
  .gift__lid,
  .gift__bow {
    animation: none !important;
    transition: none !important;
  }
}
