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

:root {
  --pink-50: #fff5f7;
  --pink-100: #ffe4ec;
  --pink-200: #ffc9da;
  --pink-300: #ff9fbe;
  --pink-400: #ff7aa8;
  --pink-500: #f25d8f;
  --rose-text: #8c3a56;
  --rose-deep: #6e2a42;
  --cream: #fffaf4;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Mali', 'Itim', sans-serif;
  color: var(--rose-text);
  background: linear-gradient(160deg, var(--pink-50) 0%, var(--pink-100) 45%, var(--pink-200) 100%);
}

.hidden { display: none !important; }

/* ============ floating hearts bg ============ */
#hearts-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.float-heart {
  position: absolute;
  bottom: -8vh;
  font-size: 18px;
  opacity: 0;
  animation: floatUp linear forwards;
}
@keyframes floatUp {
  0%   { transform: translateY(0) rotate(0deg); opacity: 0; }
  10%  { opacity: .5; }
  90%  { opacity: .3; }
  100% { transform: translateY(-110vh) rotate(30deg); opacity: 0; }
}

/* ============ scenes ============ */
.scene {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  padding-top: calc(24px + env(safe-area-inset-top));
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 1;
  min-height: 100dvh;
}
.scene.active {
  display: flex;
  animation: sceneIn .7s ease both;
}
@keyframes sceneIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.scene.leaving {
  animation: sceneOut .4s ease both;
}
@keyframes sceneOut {
  from { opacity: 1; }
  to   { opacity: 0; transform: translateY(-12px); }
}
.scene-inner {
  width: 100%;
  max-width: 420px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.scene-title {
  font-size: 1.45rem;
  font-weight: 600;
  color: var(--rose-deep);
}
.scene-hint { font-size: .95rem; opacity: .75; }

/* ============ buttons ============ */
.btn {
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  border: none;
  border-radius: 999px;
  padding: 14px 30px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.96); }
.btn-primary {
  background: linear-gradient(135deg, var(--pink-400), var(--pink-500));
  color: #fff;
  box-shadow: 0 6px 18px rgba(242, 93, 143, .35);
}

#mute-btn {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  right: 14px;
  z-index: 50;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, .8);
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(140, 58, 86, .15);
}

/* ============ scene 1: landing ============ */
.gift-box {
  font-size: 5rem;
  animation: bounce 1.6s ease-in-out infinite;
  cursor: pointer;
}
@keyframes bounce {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%      { transform: translateY(-14px) rotate(3deg); }
}
.landing-title {
  font-size: 1.7rem;
  font-weight: 600;
  color: var(--rose-deep);
}
.dots { animation: blink 1.4s steps(4) infinite; }
@keyframes blink { 50% { opacity: .2; } }
.landing-sub { font-size: 1rem; opacity: .8; }

/* ============ scene 2: cake ============ */
.cake-wrap {
  position: relative;
  width: 240px;
  height: 230px;
  margin: 8px auto;
}
.cake {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
}
.candles {
  display: flex;
  justify-content: center;
  gap: 34px;
  margin-bottom: -2px;
}
.candle {
  position: relative;
  width: 12px;
  height: 44px;
  background: repeating-linear-gradient(45deg, #fff 0 6px, var(--pink-300) 6px 12px);
  border-radius: 4px;
}
.flame {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 20px;
  background: radial-gradient(circle at 50% 70%, #ffd76e 0%, #ffae34 60%, #ff7a00 100%);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  animation: flicker .35s ease-in-out infinite alternate;
  box-shadow: 0 0 18px 6px rgba(255, 190, 80, .55);
}
@keyframes flicker {
  from { transform: translateX(-50%) scale(1) rotate(-3deg); }
  to   { transform: translateX(-50%) scale(1.12) rotate(3deg); }
}
.flame.out {
  animation: blowOut .5s ease forwards;
}
@keyframes blowOut {
  0%   { opacity: 1; transform: translateX(-50%) scale(1); }
  60%  { opacity: .6; transform: translateX(-30%) scale(.6) rotate(20deg); }
  100% { opacity: 0; transform: translateX(0) scale(.1) rotate(40deg); }
}
.cake-layer {
  margin: 0 auto;
  border-radius: 10px;
}
.layer-top {
  width: 150px;
  height: 44px;
  background: linear-gradient(var(--pink-300), var(--pink-400));
  border-radius: 12px 12px 6px 6px;
  position: relative;
}
.layer-top::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 18px;
  background:
    radial-gradient(circle at 12px 100%, var(--cream) 11px, transparent 12px),
    radial-gradient(circle at 40px 100%, var(--cream) 13px, transparent 14px),
    radial-gradient(circle at 70px 100%, var(--cream) 11px, transparent 12px),
    radial-gradient(circle at 100px 100%, var(--cream) 13px, transparent 14px),
    radial-gradient(circle at 130px 100%, var(--cream) 11px, transparent 12px),
    linear-gradient(var(--cream), var(--cream));
  border-radius: 12px 12px 0 0;
}
.layer-mid {
  width: 185px;
  height: 48px;
  background: linear-gradient(#fff0e0, #ffdfc0);
  margin-top: -4px;
}
.layer-bottom {
  width: 220px;
  height: 54px;
  background: linear-gradient(var(--pink-400), var(--pink-500));
  margin-top: -4px;
}
.cake-plate {
  width: 240px;
  height: 14px;
  background: #fff;
  border-radius: 999px;
  margin: -2px auto 0;
  box-shadow: 0 4px 12px rgba(140, 58, 86, .2);
}
.mic-hint { font-size: .85rem; opacity: .7; }

/* ============ scene 3: confetti / hbd ============ */
#confetti-canvas {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
#scene-confetti .scene-inner { position: relative; z-index: 3; }
.hbd-pre { font-size: 1.15rem; opacity: .85; }
.hbd-title {
  font-family: 'Itim', 'Mali', sans-serif;
  font-size: 3.2rem;
  line-height: 1.1;
  background: linear-gradient(135deg, var(--pink-500), #c44e9b);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}
.hbd-name {
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--rose-deep);
}
.hbd-emoji { font-size: 1.6rem; letter-spacing: 6px; }

/* ============ scene 4: gallery ============ */
.gallery-inner { gap: 14px; }
.carousel {
  width: 100%;
  overflow: hidden;
  border-radius: 18px;
  touch-action: pan-y;
}
.carousel-track {
  display: flex;
  transition: transform .35s ease;
}
.photo-card {
  flex: 0 0 100%;
  padding: 12px 12px 14px;
}
.photo-frame {
  background: #fff;
  border-radius: 14px;
  padding: 10px 10px 12px;
  box-shadow: 0 8px 24px rgba(140, 58, 86, .18);
}
.photo-card { display: flex; align-items: center; }
.photo-frame { width: 100%; }
.photo-frame img {
  width: 100%;
  height: auto;
  max-height: 48dvh;
  object-fit: contain;
  border-radius: 8px;
  background: var(--pink-50);
  display: block;
}
.photo-caption {
  margin-top: 10px;
  font-size: .95rem;
  color: var(--rose-text);
}
.carousel-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.nav-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: #fff;
  color: var(--pink-500);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(140, 58, 86, .15);
}
.carousel-dots { display: flex; gap: 7px; }
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pink-200);
  transition: all .25s ease;
}
.dot.active { background: var(--pink-500); transform: scale(1.3); }

/* ============ scene 5: letter ============ */
.envelope {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.envelope-body {
  font-size: 6rem;
  animation: bounce 1.8s ease-in-out infinite;
}
.envelope-hint { font-size: .95rem; opacity: .75; }
.letter-paper {
  background: var(--cream);
  border-radius: 16px;
  padding: 26px 22px;
  width: 100%;
  box-shadow: 0 10px 30px rgba(140, 58, 86, .18);
  text-align: left;
  animation: paperIn .8s ease both;
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-height: 68dvh;
  overflow-y: auto;
}
@keyframes paperIn {
  from { opacity: 0; transform: translateY(30px) scale(.92); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.letter-text {
  font-size: 1rem;
  line-height: 1.9;
  white-space: pre-line;
}
.letter-paper .btn { align-self: center; }

/* ============ scene 6: reply ============ */
.reply-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.hp { display: none; }
#reply-message {
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.7;
  width: 100%;
  border: 2px solid var(--pink-200);
  border-radius: 16px;
  padding: 16px;
  background: var(--cream);
  color: var(--rose-deep);
  resize: none;
  outline: none;
}
#reply-message:focus { border-color: var(--pink-400); }
.reply-error { color: #c0392b; font-size: .9rem; }
.btn[disabled] { opacity: .6; }

.reply-done {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  animation: sceneIn .6s ease both;
}
.reply-done h3 { font-size: 1.6rem; color: var(--rose-deep); }
.reply-done-sub { opacity: .8; }
.fly-heart {
  font-size: 4rem;
  animation: flyAway 1.6s ease forwards;
}
@keyframes flyAway {
  0%   { transform: translateY(0) scale(1); opacity: 1; }
  70%  { transform: translateY(-60px) scale(1.15); opacity: 1; }
  100% { transform: translateY(-120px) scale(.6); opacity: 0; }
}

/* ============ small screens ============ */
@media (max-height: 700px) {
  .hbd-title { font-size: 2.6rem; }
  .photo-frame img { height: 40dvh; }
  .cake-wrap { transform: scale(.85); margin: -10px auto; }
}
