:root {
  --ink: #3a2430;
  --ink-soft: #6b4a58;
  --rose: #ff6f91;
  --rose-deep: #e84a70;
  --blush: #ffb3c6;
  --petal: #ffd6e0;
  --mint: #7ec8b8;
  --mint-soft: #d8f3ec;
  --cream: #fff7fa;
  --paper: #ffffff;
  --shadow: rgba(58, 36, 48, 0.12);
  --radius: 18px;
  --font-display: "Fredoka", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, sans-serif;
}

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

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--cream);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  text-size-adjust: 100%;
  position: fixed;
  inset: 0;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* —— Music toggle —— */
.music-toggle {
  position: fixed;
  top: max(0.85rem, env(safe-area-inset-top));
  right: max(0.85rem, env(safe-area-inset-right));
  z-index: 20;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.78);
  color: var(--rose-deep);
  backdrop-filter: blur(10px);
  box-shadow: 0 6px 18px var(--shadow);
  transition:
    transform 0.2s ease,
    background 0.2s ease;
}

.music-toggle:active {
  transform: scale(0.94);
}

.music-toggle .icon-on {
  display: none;
}

.music-toggle .icon-off {
  display: block;
}

.music-toggle:not(.is-muted) .icon-on {
  display: block;
}

.music-toggle:not(.is-muted) .icon-off {
  display: none;
}

.music-toggle:not(.is-muted) {
  background: rgba(255, 111, 145, 0.18);
}

.yt-layer {
  position: fixed;
  width: 1px;
  height: 1px;
  left: -9999px;
  top: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 80% at 10% 0%, #ffe0ea 0%, transparent 55%),
    radial-gradient(90% 70% at 95% 15%, #d9f5ef 0%, transparent 50%),
    radial-gradient(70% 60% at 50% 100%, #ffd0dc 0%, transparent 55%),
    linear-gradient(165deg, #fff5f8 0%, #ffe8f0 45%, #eefaf6 100%);
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.55;
  animation: drift 14s ease-in-out infinite;
}

.blob-a {
  width: 280px;
  height: 280px;
  background: var(--blush);
  top: -60px;
  left: -40px;
}

.blob-b {
  width: 320px;
  height: 320px;
  background: var(--mint-soft);
  bottom: 5%;
  right: -80px;
  animation-delay: -4s;
}

.blob-c {
  width: 180px;
  height: 180px;
  background: #ffc4d4;
  top: 40%;
  left: 35%;
  animation-delay: -8s;
  opacity: 0.35;
}

#petals {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

@keyframes drift {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }
  50% {
    transform: translate(24px, -18px) scale(1.06);
  }
}

.stage {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  height: 100dvh;
  height: 100svh;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding:
    max(0.75rem, env(safe-area-inset-top))
    max(0.85rem, env(safe-area-inset-right))
    max(0.85rem, env(safe-area-inset-bottom))
    max(0.85rem, env(safe-area-inset-left));
}

.screen {
  width: min(920px, 100%);
  max-height: 100%;
  opacity: 0;
  transform: translateY(12px) scale(0.985);
  pointer-events: none;
  transition:
    opacity 0.45s ease,
    transform 0.45s ease;
  overflow: hidden;
}

.screen[hidden] {
  display: none;
}

.screen.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* —— Intro —— */
.intro-compose {
  text-align: center;
  max-width: 34rem;
  margin: 0 auto 1.5rem;
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(3.2rem, 12vw, 5.5rem);
  line-height: 0.9;
  letter-spacing: -0.04em;
  color: var(--rose-deep);
  margin: 0 0 0.85rem;
  animation: brandPop 1s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.brand.mini {
  font-size: clamp(1.8rem, 6vw, 2.4rem);
  margin-bottom: 0.4rem;
}

.headline {
  font-family: var(--font-display);
  font-weight: 550;
  font-size: clamp(1.35rem, 4.2vw, 1.85rem);
  line-height: 1.25;
  margin: 0 0 0.65rem;
  color: var(--ink);
}

.support {
  margin: 0 auto 1.35rem;
  max-width: 28rem;
  color: var(--ink-soft);
  font-size: 1.05rem;
  line-height: 1.55;
}

.cta {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 48px;
  padding: 0.9rem 1.55rem;
  border-radius: var(--radius);
  background: var(--rose);
  color: white;
  font-weight: 700;
  font-size: 1rem;
  overflow: hidden;
  transition:
    transform 0.2s ease,
    background 0.2s ease;
  box-shadow: 0 10px 28px rgba(232, 74, 112, 0.28);
}

@media (hover: hover) {
  .cta:hover {
    transform: translateY(-2px) scale(1.02);
    background: var(--rose-deep);
  }

  .cta.ghost:hover {
    background: rgba(255, 255, 255, 0.55);
  }

  .choice.yes:hover {
    transform: translateY(-2px) scale(1.04);
    background: #6bb9a8;
  }

  .letter:hover {
    transform: translateY(-6px) scale(1.03);
  }
}

.cta:active {
  transform: translateY(0) scale(0.98);
}

.cta.ghost {
  background: transparent;
  color: var(--rose-deep);
  box-shadow: none;
  border: 2px solid var(--blush);
}

.cta-shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    110deg,
    transparent 30%,
    rgba(255, 255, 255, 0.35) 45%,
    transparent 60%
  );
  transform: translateX(-120%);
  animation: shine 3.5s ease-in-out infinite;
}

@keyframes shine {
  0%,
  60% {
    transform: translateX(-120%);
  }
  80%,
  100% {
    transform: translateX(120%);
  }
}

@keyframes brandPop {
  from {
    opacity: 0;
    transform: scale(0.7) rotate(-4deg);
  }
  to {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}

/* Letter */
.letter {
  position: relative;
  display: block;
  width: min(220px, 58vw);
  aspect-ratio: 1.35;
  margin: 0.5rem auto 0;
  perspective: 800px;
  animation: letterFloat 3.2s ease-in-out infinite;
  transition: transform 0.25s ease;
}

.letter.opening .letter-flap {
  transform: rotateX(180deg);
}

.letter.opening .letter-seal {
  transform: scale(0);
  opacity: 0;
}

.letter-body {
  position: absolute;
  inset: 18% 0 0;
  background: linear-gradient(180deg, #fff 0%, #fff6f9 100%);
  border-radius: 0 0 14px 14px;
  box-shadow: 0 16px 36px var(--shadow);
  display: grid;
  place-items: center;
}

.letter-flap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 42%;
  background: linear-gradient(180deg, var(--blush) 0%, #ff9eb4 100%);
  clip-path: polygon(0 0, 50% 100%, 100% 0);
  transform-origin: top center;
  transition: transform 0.7s cubic-bezier(0.4, 0.1, 0.2, 1);
  z-index: 2;
}

.letter-heart {
  width: 42px;
  height: 38px;
  position: relative;
  transform: scale(0.9);
  animation: heartbeat 1.4s ease-in-out infinite;
}

.letter-heart::before,
.letter-heart::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 34px;
  background: var(--rose);
  border-radius: 22px 22px 0 0;
  top: 0;
}

.letter-heart::before {
  left: 21px;
  transform: rotate(-45deg);
  transform-origin: 0 100%;
}

.letter-heart::after {
  left: 0;
  transform: rotate(45deg);
  transform-origin: 100% 100%;
}

.letter-seal {
  position: absolute;
  top: 34%;
  left: 50%;
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
  border-radius: 50%;
  background: var(--rose-deep);
  box-shadow: 0 4px 12px rgba(232, 74, 112, 0.35);
  z-index: 3;
  transition:
    transform 0.4s ease,
    opacity 0.4s ease;
}

.letter-seal::after {
  content: "";
  position: absolute;
  inset: 9px;
  background: var(--petal);
  clip-path: polygon(50% 18%, 61% 40%, 85% 43%, 67% 60%, 73% 84%, 50% 72%, 27% 84%, 33% 60%, 15% 43%, 39% 40%);
}

@keyframes letterFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes heartbeat {
  0%,
  100% {
    transform: scale(0.9);
  }
  40% {
    transform: scale(1.05);
  }
}

/* —— Buddy —— */
.buddy {
  width: min(220px, 52vw);
  margin: 0 auto;
  animation: buddyBob 2.8s ease-in-out infinite;
}

.buddy.tiny {
  width: min(150px, 40vw);
  margin-bottom: 0.4rem;
}

.buddy.happy {
  animation: buddyBounce 0.9s ease-in-out infinite;
}

.buddy-svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.buddy-shadow {
  fill: rgba(58, 36, 48, 0.1);
}

.buddy-ear {
  fill: #ff9eb4;
}

.buddy-ear-inner {
  fill: #ffd0dc;
}

.buddy-body {
  fill: #ffb3c6;
}

.buddy-cheek {
  fill: #ff7a9a;
  opacity: 0.45;
}

.buddy-eye {
  fill: var(--ink);
}

.buddy-shine {
  fill: white;
}

.buddy-eye-happy {
  fill: none;
  stroke: var(--ink);
  stroke-width: 5;
  stroke-linecap: round;
}

.buddy-mouth {
  fill: none;
  stroke: var(--ink);
  stroke-width: 4;
  stroke-linecap: round;
}

.buddy-nose {
  fill: var(--rose-deep);
}

.buddy.hopeful .buddy-mouth {
  stroke-width: 4;
}

@keyframes buddyBob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

@keyframes buddyBounce {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-14px) scale(1.04);
  }
}

/* —— Story —— */
.story-layout {
  display: grid;
  gap: 1.5rem;
  align-items: center;
  justify-items: center;
  text-align: center;
}

@media (min-width: 720px) {
  .story-layout {
    grid-template-columns: 0.9fr 1.1fr;
    text-align: left;
    gap: 2.5rem;
  }

  .story-layout .buddy {
    margin: 0;
  }

  .story-copy .cta {
    margin-top: 0.25rem;
  }
}

.story-copy {
  max-width: 28rem;
}

.step-pill {
  display: inline-block;
  margin: 0 0 0.75rem;
  padding: 0.25rem 0.7rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.story-title {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 2rem);
  margin: 0 0 0.65rem;
  line-height: 1.2;
}

.story-text {
  margin: 0 0 1.35rem;
  color: var(--ink-soft);
  font-size: 1.08rem;
  line-height: 1.6;
}

.story-copy .cta {
  width: 100%;
  max-width: 240px;
}

@media (min-width: 720px) {
  .story-copy .cta {
    width: auto;
  }
}

/* —— Forgive —— */
.forgive-compose {
  text-align: center;
  max-width: 36rem;
  margin: 0 auto;
  position: relative;
  min-height: auto;
  width: 100%;
}

.forgive-title {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  margin: 0 0 0.5rem;
}

.forgive-hint {
  margin: 0 0 1.1rem;
  color: var(--ink-soft);
  min-height: 2.6em;
  transition: opacity 0.25s ease;
  padding: 0 0.25rem;
}

.choice-stack,
.choice-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: min(100%, 300px);
  margin: 0 auto;
  min-height: 132px;
  position: relative;
  z-index: 2;
}

.choice {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 54px;
  padding: 0 1rem;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.15;
  transition:
    width 0.28s ease,
    height 0.28s ease,
    font-size 0.28s ease,
    transform 0.28s ease,
    background 0.2s ease,
    box-shadow 0.2s ease,
    opacity 0.28s ease;
}

.choice-label {
  display: block;
  max-width: 100%;
  transition: font-size 0.28s ease;
}

.choice.yes {
  background: var(--mint);
  color: #1f4a42;
  box-shadow: 0 10px 24px rgba(126, 200, 184, 0.4);
  z-index: 5;
  position: relative;
  /* Fixed outer box — text grows inside (cute) */
  width: 100%;
  height: 54px;
  overflow: hidden;
}

.choice.yes .choice-label {
  font-size: calc(0.95rem * var(--yes-text, 1));
  font-weight: 800;
  white-space: nowrap;
}

.choice.no {
  background: #fff5f8;
  color: var(--ink-soft);
  border: 2px solid #f0d4dc;
  position: relative;
  z-index: 3;
  width: calc(100% * var(--no-scale, 1));
  height: calc(54px * var(--no-scale, 1));
  font-size: calc(1rem * var(--no-scale, 1));
  transform-origin: center center;
  white-space: nowrap;
}

.choice.no .choice-label {
  font-size: inherit;
}

.choice.no.vanish {
  animation: noVanish 0.55s ease forwards;
  pointer-events: none;
}

@keyframes noVanish {
  0% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
  55% {
    opacity: 1;
    transform: scale(1.08) rotate(-6deg);
  }
  100% {
    opacity: 0;
    transform: scale(0.15) rotate(14deg);
  }
}

@media (max-width: 719px) {
  .intro-compose {
    margin-bottom: 0.65rem;
  }

  .brand {
    font-size: clamp(2.4rem, 12vw, 3.4rem);
    margin-bottom: 0.45rem;
  }

  .brand.mini {
    font-size: clamp(1.4rem, 6vw, 1.8rem);
  }

  .headline {
    font-size: clamp(1.1rem, 4.8vw, 1.35rem);
    margin-bottom: 0.4rem;
  }

  .support,
  .story-text,
  .celebrate-text,
  .forgive-hint {
    font-size: 0.95rem;
    line-height: 1.45;
  }

  .support {
    margin-bottom: 0.9rem;
  }

  .letter {
    width: min(160px, 46vw);
    margin-top: 0.25rem;
  }

  .buddy {
    width: min(120px, 34vw);
  }

  .buddy.tiny {
    width: min(96px, 28vw);
    margin-bottom: 0.15rem;
  }

  .story-layout {
    gap: 0.75rem;
  }

  .story-title,
  .forgive-title,
  .celebrate-title {
    font-size: clamp(1.25rem, 5vw, 1.55rem);
    margin-bottom: 0.4rem;
  }

  .story-text {
    margin-bottom: 0.9rem;
  }

  .story-copy .cta {
    max-width: none;
    width: 100%;
  }

  .step-pill {
    margin-bottom: 0.4rem;
  }

  .choice-stack,
  .choice-row {
    width: min(100%, 280px);
    min-height: 124px;
    gap: 0.65rem;
  }

  .celebrate-text {
    margin-bottom: 1rem;
  }

  .music-toggle {
    width: 42px;
    height: 42px;
  }

  .cta {
    min-height: 46px;
    padding: 0.75rem 1.25rem;
  }
}

@media (max-height: 700px) {
  .buddy {
    width: min(110px, 28vw);
  }

  .buddy.tiny {
    width: min(84px, 22vw);
  }

  .letter {
    width: min(140px, 40vw);
  }

  .brand {
    font-size: clamp(2.2rem, 10vw, 3rem);
  }
}

@media (max-width: 380px) {
  .choice.yes .choice-label {
    letter-spacing: -0.02em;
  }
}

/* —— Celebrate —— */
#screen-celebrate {
  position: relative;
}

.celebrate-compose {
  text-align: center;
  max-width: 32rem;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

.celebrate-title {
  font-family: var(--font-display);
  font-size: clamp(1.45rem, 4.5vw, 2rem);
  margin: 0 0 0.75rem;
  line-height: 1.25;
}

.celebrate-text {
  margin: 0 0 1.5rem;
  color: var(--ink-soft);
  font-size: 1.08rem;
  line-height: 1.6;
}

#confetti {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* Screen enter helpers */
.fade-swap {
  animation: fadeSwap 0.45s ease both;
}

@keyframes fadeSwap {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    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;
  }
}
