:root {
  --pink: #ff006e;
  --orange: #fb5607;
  --yellow: #ffbe0b;
  --purple: #8338ec;
  --blue: #3a86ff;
  --ink: #1a1a2e;
  --cream: #fff5e1;
  --soft-pink: #ffd6e0;
  --white: #fff;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: #0a0a14;
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
}

.frame {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  background: var(--ink);
}

/* Desktop phone frame */
@media (min-width: 500px) {
  .frame {
    background:
      radial-gradient(circle at 30% 20%, rgba(255,0,110,0.18), transparent 50%),
      radial-gradient(circle at 70% 80%, rgba(131,56,236,0.18), transparent 50%),
      #0a0a14;
  }
  .stage {
    width: 420px;
    height: min(880px, 95vh);
    border-radius: 36px;
    box-shadow: 0 30px 80px rgba(0,0,0,0.5), 0 0 0 8px #000, 0 0 0 10px #1a1a1a;
  }
}

/* === Progress bars === */
.progress {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  left: 12px;
  right: 12px;
  display: flex;
  gap: 4px;
  z-index: 20;
}
.bar {
  flex: 1;
  height: 3px;
  background: rgba(255,255,255,0.25);
  border-radius: 2px;
}
.bar.done, .bar.active { background: rgba(255,255,255,0.95); }

/* === Chapters === */
.chapter {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px 40px;
  opacity: 0;
  transition: opacity 300ms ease;
  text-align: center;
}
.chapter.active {
  display: flex;
  opacity: 1;
}

.chapter[data-bg="ch1"] { background: linear-gradient(135deg, var(--pink) 0%, var(--orange) 100%); }
.chapter[data-bg="ch2"] { background: linear-gradient(135deg, var(--yellow) 0%, var(--pink) 100%); }
.chapter[data-bg="ch3"] { background: linear-gradient(180deg, var(--ink) 0%, #2d1b3d 100%); }
.chapter[data-bg="ch4"] { background: linear-gradient(135deg, var(--purple) 0%, var(--pink) 100%); }
.chapter[data-bg="ch5"] { background: linear-gradient(135deg, var(--cream) 0%, var(--soft-pink) 100%); justify-content: flex-start; padding-top: 80px; }
.chapter[data-bg="ch6"] { background: linear-gradient(180deg, var(--pink) 0%, var(--purple) 50%, var(--blue) 100%); justify-content: flex-start; padding-top: 90px; }

/* === Tap zones === */
.tap-zones {
  position: absolute;
  inset: 0;
  display: flex;
  z-index: 5;
}
.tap-back { width: 35%; height: 100%; }
.tap-fwd { width: 65%; height: 100%; }

button { z-index: 10; position: relative; }

/* === Floating emojis === */
.floaters {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}
.floater {
  position: absolute;
  left: var(--x);
  top: var(--y);
  font-size: var(--s, 26px);
  animation: float-bob 3.5s ease-in-out infinite;
  animation-delay: var(--d, 0s);
  opacity: 0.9;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.15));
}
@keyframes float-bob {
  0%, 100% { transform: translateY(0) rotate(-4deg) scale(1); }
  50% { transform: translateY(-14px) rotate(5deg) scale(1.08); }
}

/* === Chapter 1 heart === */
.ch1-heart {
  font-size: 50px;
  margin-top: 14px;
  opacity: 0;
  transform: scale(0);
  z-index: 2;
}
.chapter[data-bg="ch1"].active .ch1-heart {
  animation: pop-in 500ms cubic-bezier(0.34, 1.56, 0.64, 1) 420ms forwards, heartbeat 1.6s ease-in-out 1s infinite;
}
@keyframes pop-in {
  to { opacity: 1; transform: scale(1); }
}
@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  20% { transform: scale(1.18); }
  40% { transform: scale(1); }
  60% { transform: scale(1.12); }
  80% { transform: scale(1); }
}

/* === Chapter 1: name === */
.ch1-name {
  font-family: 'Anton', Impact, sans-serif;
  color: white;
  font-size: clamp(64px, 18vw, 110px);
  letter-spacing: -2px;
  display: flex;
  gap: 2px;
  line-height: 1;
}
.ch1-name span {
  display: inline-block;
  opacity: 0;
  transform: translateY(40px);
}
.chapter[data-bg="ch1"].active .ch1-name span {
  animation: spring-in 600ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.chapter[data-bg="ch1"].active .ch1-name span:nth-child(1) { animation-delay: 0ms; }
.chapter[data-bg="ch1"].active .ch1-name span:nth-child(2) { animation-delay: 60ms; }
.chapter[data-bg="ch1"].active .ch1-name span:nth-child(3) { animation-delay: 120ms; }
.chapter[data-bg="ch1"].active .ch1-name span:nth-child(4) { animation-delay: 180ms; }
.chapter[data-bg="ch1"].active .ch1-name span:nth-child(5) { animation-delay: 240ms; }
.chapter[data-bg="ch1"].active .ch1-name span:nth-child(6) { animation-delay: 300ms; }

@keyframes spring-in { to { opacity: 1; transform: translateY(0); } }

.ch1-sub {
  margin-top: 24px;
  color: rgba(255,255,255,0.85);
  font-size: 11px;
  letter-spacing: 3px;
  font-weight: 700;
  opacity: 0;
  animation: fade-in 400ms ease 500ms forwards;
}

@keyframes fade-in { to { opacity: 1; } }

/* === Chapter 2: hook === */
.ch2-text {
  color: white;
  font-family: 'Anton', Impact, sans-serif;
  letter-spacing: -1px;
  line-height: 1.05;
}
.ch2-text > div {
  opacity: 0;
  transform: translateY(20px);
}
.chapter[data-bg="ch2"].active .ch2-text > div {
  animation: rise-in 500ms ease forwards;
}
.chapter[data-bg="ch2"].active .ch2-text > div:nth-child(1) {
  animation-delay: 0ms;
  font-size: clamp(36px, 11vw, 70px);
}
.chapter[data-bg="ch2"].active .ch2-text > div:nth-child(2) {
  animation-delay: 200ms;
  font-size: clamp(48px, 14vw, 92px);
  color: white;
}
.chapter[data-bg="ch2"].active .ch2-emoji {
  animation-delay: 500ms;
  font-size: 56px;
  margin-top: 20px;
  font-family: 'Inter', sans-serif;
}

@keyframes rise-in { to { opacity: 1; transform: translateY(0); } }

/* === Chapter 3: confession === */
.ch3-text {
  color: white;
  font-family: Georgia, serif;
  font-size: clamp(20px, 5.5vw, 26px);
  line-height: 1.55;
  max-width: 340px;
  text-align: left;
}
.ch3-text p {
  opacity: 0;
  transform: translateY(10px);
}
.chapter[data-bg="ch3"].active .ch3-text p {
  animation: rise-in 600ms ease forwards;
}
.chapter[data-bg="ch3"].active .ch3-text p:nth-child(1) { animation-delay: 200ms; }
.chapter[data-bg="ch3"].active .ch3-text p:nth-child(2) {
  animation-delay: 1100ms;
  margin-top: 14px;
  color: rgba(255,255,255,0.85);
}
.chapter[data-bg="ch3"].active .ch3-text p:nth-child(3) {
  animation-delay: 2200ms;
  margin-top: 32px;
  color: var(--pink);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  font-style: italic;
}

/* === Chapter 4: compliment kinetic === */
.ch4-line {
  color: white;
  font-family: 'Anton', Impact, sans-serif;
  position: absolute;
  letter-spacing: -1px;
  opacity: 0;
  line-height: 1;
  z-index: 2;
}
.ch4-l1 { top: 22%; left: 8%; font-size: clamp(36px, 11vw, 64px); transform: rotate(-4deg) translateX(-40px); }
.ch4-l2 { top: 36%; right: 6%; font-size: clamp(48px, 14vw, 80px); color: var(--yellow); transform: rotate(3deg) translateX(40px); }
.ch4-l3 { top: 54%; left: 12%; font-size: clamp(32px, 10vw, 56px); transform: rotate(-2deg) translateX(-40px); }
.ch4-l4 { top: 68%; right: 8%; font-size: clamp(44px, 13vw, 76px); transform: rotate(4deg) translateX(40px); }

.chapter[data-bg="ch4"].active .ch4-l1 { animation: slide-in-l1 600ms cubic-bezier(0.22, 1, 0.36, 1) 0ms forwards; }
.chapter[data-bg="ch4"].active .ch4-l2 { animation: slide-in-l2 600ms cubic-bezier(0.22, 1, 0.36, 1) 200ms forwards; }
.chapter[data-bg="ch4"].active .ch4-l3 { animation: slide-in-l3 600ms cubic-bezier(0.22, 1, 0.36, 1) 400ms forwards; }
.chapter[data-bg="ch4"].active .ch4-l4 { animation: slide-in-l4 600ms cubic-bezier(0.22, 1, 0.36, 1) 600ms forwards; }

@keyframes slide-in-l1 { to { opacity: 1; transform: rotate(-4deg) translateX(0); } }
@keyframes slide-in-l2 { to { opacity: 1; transform: rotate(3deg) translateX(0); } }
@keyframes slide-in-l3 { to { opacity: 1; transform: rotate(-2deg) translateX(0); } }
@keyframes slide-in-l4 { to { opacity: 1; transform: rotate(4deg) translateX(0); } }

/* === Chapter 5: playful runaway === */
.ch5-top { margin-top: 20px; }
.ch5-emoji { font-size: 80px; line-height: 1; }
.ch5-q {
  font-family: 'Inter', sans-serif;
  font-size: 24px;
  font-weight: 900;
  color: #d4537a;
  margin-top: 12px;
}
.ch5-buttons {
  position: relative;
  flex: 1;
  width: 100%;
  margin-top: 30px;
}
.btn-yes, .btn-no {
  position: absolute;
  border: none;
  border-radius: 30px;
  padding: 16px 32px;
  font-family: 'Inter', sans-serif;
  font-weight: 900;
  font-size: 18px;
  color: white;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  -webkit-tap-highlight-color: transparent;
}
.btn-yes {
  background: #22c55e;
  bottom: 30px;
  left: 24px;
}
.btn-no {
  background: #ef4444;
  top: 20px;
  right: 24px;
  transform: rotate(-8deg);
  transition: top 220ms ease, left 220ms ease, right 220ms ease, transform 220ms ease, background-color 300ms ease;
}
.btn-no.surrendered {
  background: #94a3b8;
  font-size: 13px;
  padding: 12px 22px;
}

/* === Chapter 6: finale === */
.ch6-top {
  color: white;
  margin-top: 20px;
}
.ch6-emoji { font-size: 50px; line-height: 1; }
.ch6-text {
  font-size: 18px;
  font-weight: 800;
  margin-top: 12px;
}

.ch6-btn-wrap {
  position: absolute;
  bottom: 32%;
  left: 50%;
  transform: translateX(-50%);
}
.ch6-btn {
  background: white;
  color: var(--pink);
  border: none;
  border-radius: 36px;
  padding: 20px 38px;
  font-family: 'Inter', sans-serif;
  font-weight: 900;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  animation: pulse 2s ease-in-out infinite;
  -webkit-tap-highlight-color: transparent;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}
.ch6-btn.clicked {
  animation: none;
  transform: scale(0.95);
  opacity: 0.4;
  pointer-events: none;
}

.ch6-final {
  position: absolute;
  bottom: 14%;
  left: 0;
  right: 0;
  text-align: center;
  color: white;
  font-size: 18px;
  font-weight: 700;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 700ms ease, transform 700ms ease;
}
.ch6-final.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .ch1-name span, .ch2-text > div, .ch3-text p, .ch4-line, .ch1-heart {
    opacity: 1 !important;
    transform: none !important;
  }
  .floater { animation: none !important; }
  .ch4-l1 { transform: rotate(-4deg) !important; }
  .ch4-l2 { transform: rotate(3deg) !important; }
  .ch4-l3 { transform: rotate(-2deg) !important; }
  .ch4-l4 { transform: rotate(4deg) !important; }
}
