:root {
  --pink: #FFC8DD;
  --lavender: #CDB4DB;
  --peach: #FFD6A5;
  --cream: #FFF8F0;
  --sky-blue: #BDE0FE;
  --rose: #E07A9A;
  --ink: #5b4a57;
  --shadow: rgba(176, 120, 150, 0.28);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--lavender);
  font-family: 'Fredoka', system-ui, sans-serif;
  color: var(--ink);
  touch-action: none;
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.overlay-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.ui-layer > * { pointer-events: auto; }

/* ---------- Loading screen ---------- */
#loading {
  z-index: 100;
  background: linear-gradient(180deg, #CDB4DB 0%, #FFC8DD 55%, #FFD6A5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease;
  pointer-events: auto;
}
.loading-card {
  text-align: center;
  color: var(--ink);
}
.loading-heart {
  font-size: 3rem;
  animation: pulse-heart 1.1s ease-in-out infinite;
}
@keyframes pulse-heart {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}
.loading-text {
  margin-top: 0.5rem;
  font-family: 'Caveat', cursive;
  font-size: 1.4rem;
}
.loading-bar {
  margin: 1rem auto 0;
  width: 160px;
  height: 8px;
  border-radius: 8px;
  background: rgba(255,255,255,0.5);
  overflow: hidden;
}
#loading-fill {
  width: 0%;
  height: 100%;
  background: var(--rose);
  border-radius: 8px;
  transition: width 0.25s ease;
}

/* ---------- Generic cute text ---------- */
.cute-label {
  position: absolute;
  bottom: 9%;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Caveat', cursive;
  font-size: 1.6rem;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0,0,0,0.25);
  text-align: center;
  width: 90%;
  animation: float-label 3s ease-in-out infinite;
}
@keyframes float-label {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, -6px); }
}

.cute-heading {
  position: absolute;
  top: 6%;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 1.3rem;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0,0,0,0.25);
  text-align: center;
  width: 90%;
}
.cute-sub {
  position: absolute;
  top: 13%;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Caveat', cursive;
  font-size: 1.2rem;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.25);
  text-align: center;
  width: 85%;
}
.top-fade { opacity: 0; transition: opacity 1.2s ease; }
.top-fade.visible { opacity: 1; }

.pill-badge {
  position: absolute;
  top: 5%;
  right: 4%;
  background: rgba(255,255,255,0.75);
  color: var(--rose);
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 6px 14px;
  border-radius: 999px;
  box-shadow: 0 4px 14px var(--shadow);
  opacity: 0;
  transition: opacity 0.6s ease;
}
.pill-badge.visible { opacity: 1; }

/* ---------- Buttons ---------- */
.btn {
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 1.05rem;
  border: none;
  border-radius: 999px;
  padding: 14px 30px;
  cursor: pointer;
  box-shadow: 0 6px 18px var(--shadow);
  transition: transform 0.18s cubic-bezier(.34,1.56,.64,1), box-shadow 0.18s ease, background 0.2s ease;
}
.btn:active { transform: scale(0.92); }
.btn-primary {
  background: linear-gradient(180deg, #FFD3E4, var(--pink));
  color: var(--rose);
}
.btn-secondary {
  background: linear-gradient(180deg, #E8DAF2, var(--lavender));
  color: #6b5579;
}
.btn-ghost {
  background: rgba(255,255,255,0.85);
  color: var(--rose);
}
.bottom-fixed {
  position: absolute;
  bottom: 7%;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.6s ease, transform 0.18s cubic-bezier(.34,1.56,.64,1);
  animation: bob-btn 2.6s ease-in-out infinite;
}
.bottom-fixed.visible { opacity: 1; }
@keyframes bob-btn {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-5px); }
}

.icon-btn {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: 14px;
  z-index: 50;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.8);
  box-shadow: 0 4px 12px var(--shadow);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
}

/* ---------- Polaroid card ---------- */
.polaroid {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.85) rotate(-2deg);
  width: min(82vw, 340px);
  background: var(--cream);
  border-radius: 14px;
  padding: 14px 14px 20px;
  box-shadow: 0 14px 34px rgba(90, 50, 70, 0.35);
  z-index: 40;
  pointer-events: auto;
  opacity: 0;
  transition: opacity 0.45s ease, transform 0.45s cubic-bezier(.22,1,.36,1);
}
.polaroid.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1) rotate(-1.5deg);
}
.washi {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%) rotate(-3deg);
  width: 90px;
  height: 22px;
  background: repeating-linear-gradient(45deg, var(--peach), var(--peach) 6px, #ffe3bd 6px, #ffe3bd 12px);
  opacity: 0.9;
  border-radius: 3px;
}
.polaroid-media-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  background: #efe3f3;
}
.polaroid-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.polaroid-unmute {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  top: auto;
}
.polaroid-caption {
  margin-top: 12px;
  font-family: 'Caveat', cursive;
  font-size: 1.35rem;
  color: var(--ink);
  text-align: center;
  line-height: 1.25;
}
.polaroid-close {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 32px;
  height: 32px;
}
.doodle {
  position: absolute;
  font-size: 1rem;
  opacity: 0.8;
  color: var(--rose);
}
.doodle-tl { top: 6px; left: 10px; }
.doodle-br { bottom: 4px; right: 10px; }

/* ---------- Lantern label ---------- */
.lantern-label {
  position: fixed;
  transform: translate(-50%, -100%);
  font-family: 'Patrick Hand', cursive;
  font-size: 1.1rem;
  color: #5a3b2e;
  background: rgba(255, 246, 230, 0.9);
  padding: 8px 14px;
  border-radius: 14px;
  box-shadow: 0 6px 16px rgba(120,70,40,0.25);
  max-width: 220px;
  text-align: center;
  pointer-events: none;
  z-index: 30;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.lantern-label.visible { opacity: 1; }

/* ---------- Letter ---------- */
.letter-paper {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -46%);
  width: min(86vw, 380px);
  max-height: 72vh;
  overflow-y: auto;
  background: var(--cream);
  border: 2px dashed #f0c9d8;
  border-radius: 10px;
  padding: 26px 22px;
  box-shadow: 0 16px 40px rgba(90,50,70,0.3);
  opacity: 0;
  transition: opacity 1s ease, transform 1s cubic-bezier(.22,1,.36,1);
  pointer-events: auto;
}
.letter-paper.visible { opacity: 1; transform: translate(-50%, -50%); }
.letter-doodle {
  position: absolute;
  font-size: 1.3rem;
  opacity: 0.8;
}
.letter-doodle-1 { top: -14px; left: -10px; }
.letter-doodle-2 { bottom: -14px; right: -8px; }
.letter-lines {
  font-family: 'Caveat', cursive;
  font-size: 1.35rem;
  line-height: 1.55;
  color: #574756;
}
.letter-lines .line {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.8s ease, transform 0.8s ease;
  margin-bottom: 0.5em;
}
.letter-lines .line.visible { opacity: 1; transform: translateY(0); }

/* ---------- Finale ---------- */
.finale-question {
  top: 14%;
  font-size: 1.7rem;
}
.finale-buttons {
  position: fixed;
  left: 50%;
  bottom: 16%;
  transform: translateX(-50%);
  display: flex;
  gap: 18px;
  z-index: 20;
  pointer-events: none;
}
.finale-buttons .btn { pointer-events: auto; }
#btn-no { position: relative; }
.finale-message {
  position: absolute;
  bottom: 22%;
  left: 50%;
  transform: translateX(-50%);
  width: 85%;
  text-align: center;
  font-family: 'Caveat', cursive;
  font-size: 1.6rem;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0,0,0,0.3);
  opacity: 0;
  transition: opacity 1s ease;
}
.finale-message.visible { opacity: 1; }
#btn-watch-again {
  position: fixed;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  opacity: 0;
  transition: opacity 0.8s ease;
  font-size: 0.9rem;
  padding: 10px 22px;
}
#btn-watch-again.visible { opacity: 1; }

/* ---------- Misc ---------- */
[hidden] { display: none !important; }

@media (min-width: 700px) {
  .polaroid { width: min(50vw, 360px); }
  .letter-paper { width: min(60vw, 420px); }
}
