* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

body {
  overflow-x: hidden;
}

/* LANDING PAGE */
.landing {
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background:
    radial-gradient(circle at 15% 20%, #ffe6ec 0%, transparent 40%),
    radial-gradient(circle at 85% 80%, #ffd5de 0%, transparent 35%),
    linear-gradient(135deg, #ffdce5, #ffc2d1 45%, #ffb3c6 100%);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.center-box {
  z-index: 2;
  padding: 34px 26px;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 24px;
  backdrop-filter: blur(8px);
  box-shadow: 0 18px 45px rgba(160, 35, 78, 0.16);
  animation: cardEnter 0.7s ease both;
}

.main-title {
  font-size: clamp(38px, 7vw, 56px);
  margin-bottom: 10px;
  color: #8a1f48;
  animation: riseIn 0.6s 0.12s ease both;
}

.subtitle {
  font-size: clamp(22px, 4vw, 34px);
  margin-bottom: 40px;
  color: #5a1430;
  animation: riseIn 0.6s 0.24s ease both;
}

.button-row {
  position: relative;
  min-height: 64px;
  animation: riseIn 0.6s 0.36s ease both;
}

.btn {
  padding: 14px 30px;
  font-size: 17px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  margin: 10px;
  touch-action: manipulation;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

.primary {
  background: #ff4f78;
  color: white;
  box-shadow: 0 10px 18px rgba(255, 79, 120, 0.28);
}

.primary:hover {
  transform: translateY(-2px) scale(1.03);
}

.primary:active {
  transform: scale(0.98);
}

.ghost {
  background: #50313d;
  color: white;
}

.landing .ghost {
  position: relative;
  z-index: 2;
}

.landing .ghost.escaping {
  position: fixed;
  z-index: 8;
  margin: 0;
}

.tiny-note {
  margin-top: 12px;
  color: #712040;
  font-size: 14px;
  opacity: 0.85;
  animation: riseIn 0.6s 0.52s ease both;
}

.landing-bg-glow {
  position: absolute;
  inset: -20%;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.5), transparent 45%),
    radial-gradient(circle at 75% 65%, rgba(255, 148, 181, 0.36), transparent 42%);
  animation: glowShift 10s ease-in-out infinite alternate;
}

.ambient-hearts {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.float-heart {
  position: absolute;
  bottom: -30px;
  font-size: 18px;
  opacity: 0.65;
  animation: heartFloat linear forwards;
  filter: drop-shadow(0 4px 8px rgba(142, 41, 73, 0.15));
}

/* CONFETTI CANVAS */
#confetti {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 99;
}

.landing #confetti {
  width: 100vw;
  height: 100vh;
}

/* MEMORIES FLIPBOOK */
.memories {
  min-height: 100vh;
  background: linear-gradient(160deg, rgba(48, 13, 29, 0.95), rgba(15, 8, 20, 0.96));
  color: #fef0f5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 14px;
}

.book-shell {
  width: min(960px, 100%);
  text-align: center;
}

.book-title {
  font-size: clamp(30px, 5vw, 48px);
  margin-bottom: 8px;
}

.book-subtitle {
  font-size: clamp(16px, 2.8vw, 22px);
  margin-bottom: 24px;
  opacity: 0.9;
}

.flipbook-wrap {
  perspective: 1800px;
  margin-inline: auto;
  width: min(430px, 92vw);
  height: min(78vh, 680px);
  position: relative;
  padding: 8px;
  border-radius: 24px;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.01));
  box-shadow:
    0 22px 46px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.flipbook-wrap::before {
  content: "";
  position: absolute;
  top: 14px;
  bottom: 14px;
  left: 8px;
  width: 10px;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 175, 201, 0.5), rgba(87, 23, 48, 0.8));
  filter: blur(0.3px);
  z-index: 2;
  pointer-events: none;
}

.flipbook-wrap::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 16px;
  bottom: 16px;
  width: 8px;
  background: repeating-linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.12),
    rgba(255, 255, 255, 0.12) 2px,
    rgba(255, 255, 255, 0.03) 2px,
    rgba(255, 255, 255, 0.03) 6px
  );
  border-radius: 8px;
  opacity: 0.7;
  pointer-events: none;
  z-index: 2;
}

.flipbook {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 18px;
  overflow: hidden;
  touch-action: pan-y;
}

.page {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transition: transform 0.9s cubic-bezier(0.65, 0.05, 0.2, 1), z-index 0.1s linear;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow:
    0 22px 40px rgba(0, 0, 0, 0.35),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.page.dragging {
  transition: none;
  box-shadow:
    0 28px 45px rgba(0, 0, 0, 0.4),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.page-face {
  height: 100%;
  width: 100%;
}

.photo-page {
  background: linear-gradient(155deg, #f9e7ef, #f3d7e1);
  padding: clamp(8px, 1.9vw, 14px);
}

.cover-page {
  background: linear-gradient(145deg, #a61e4d, #8c1742 48%, #5f0f2d);
  position: relative;
}

.cover-page::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 22%, rgba(255, 184, 208, 0.25), transparent 35%),
    radial-gradient(circle at 80% 84%, rgba(0, 0, 0, 0.22), transparent 40%);
}

.cover-inner {
  position: absolute;
  inset: clamp(18px, 4vw, 28px);
  border: 2px solid rgba(255, 219, 232, 0.55);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 10px;
  color: #ffeef4;
  text-shadow: 0 2px 16px rgba(47, 6, 21, 0.45);
}

.cover-kicker {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: clamp(11px, 2.4vw, 13px);
  opacity: 0.9;
}

.cover-title {
  font-size: clamp(36px, 9vw, 56px);
  margin: 0;
}

.cover-byline {
  font-size: clamp(15px, 3vw, 20px);
}

.cover-heart {
  margin-top: 8px;
  font-size: clamp(22px, 4vw, 30px);
  opacity: 0.92;
  animation: pulseHeart 2s ease-in-out infinite;
}

.page-photo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 12px;
  background: #1a0f16;
  box-shadow:
    0 8px 18px rgba(66, 17, 38, 0.22),
    inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.page-overlay {
  height: 100%;
  padding: 34px 28px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.72));
}

.page h2 {
  font-size: clamp(24px, 4vw, 38px);
  margin-bottom: 12px;
}

.page p {
  font-size: clamp(16px, 2.8vw, 23px);
  line-height: 1.35;
}

.page.active {
  z-index: 30;
}

.page.flipped {
  transform: rotateY(-170deg);
  z-index: 1;
}

.last-page .final-front {
  background: linear-gradient(145deg, #ff8fab, #fb6f92 45%, #c9184a);
}

.final-message {
  justify-content: center;
  text-align: center;
}

.book-controls {
  margin-top: 20px;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.control-btn {
  min-width: 124px;
  position: static;
}

.control-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes cardEnter {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

@keyframes glowShift {
  0% { transform: translate3d(-2%, -1%, 0) scale(1); }
  100% { transform: translate3d(2%, 1%, 0) scale(1.04); }
}

@keyframes heartFloat {
  0% {
    transform: translate3d(0, 0, 0) rotate(0deg);
    opacity: 0;
  }
  12% {
    opacity: 0.72;
  }
  100% {
    transform: translate3d(var(--drift-x), -118vh, 0) rotate(var(--spin));
    opacity: 0;
  }
}

@keyframes pulseHeart {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

@media (prefers-reduced-motion: reduce) {
  .center-box,
  .main-title,
  .subtitle,
  .button-row,
  .tiny-note,
  .landing-bg-glow,
  .float-heart {
    animation: none !important;
  }
}

@media (max-width: 680px) {
  .center-box {
    width: min(96vw, 430px);
    padding: 26px 18px;
  }

  .tiny-note {
    font-size: 13px;
  }

  .flipbook-wrap {
    height: 68vh;
  }

  .flipbook-wrap::before,
  .flipbook-wrap::after {
    opacity: 0.5;
  }

  .control-btn {
    min-width: 42vw;
    font-size: 16px;
    padding: 13px 20px;
  }
}
