/* =========================================================
   RAKSHA BANDHAN INTERACTIVE SURPRISE — STYLESHEET
   Palette: cream #FFF8E8, deep red #A90032, pink/red #D4144C,
            dark bg #0D0D12
   ========================================================= */

:root {
  --cream: #FFF8E8;
  --cream-warm: #FFF2D9;
  --deep-red: #A90032;
  --pink-red: #D4144C;
  --dark-bg: #0D0D12;
  --soft-pink: #FBD8E0;
  --ink: #3A2A1E;
  --gold: #C99A3E;

  --font-hand: 'Caveat', cursive;
  --font-patrick: 'Patrick Hand', cursive;
  --font-body: 'Comic Neue', 'DM Sans', sans-serif;
  --font-serif: 'DM Sans', serif;

  --transition-speed: 550ms;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--dark-bg);
  overflow-x: hidden;
  font-family: var(--font-body);
  color: var(--ink);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

img { max-width: 100%; display: block; }

/* ---------------- Ambient background layer ---------------- */
.ambient-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.floaty {
  position: absolute;
  bottom: -40px;
  font-size: 1.4rem;
  opacity: 0.55;
  animation: floatUp linear forwards;
}
@keyframes floatUp {
  0% { transform: translateY(0) rotate(0deg); opacity: 0; }
  10% { opacity: 0.6; }
  90% { opacity: 0.4; }
  100% { transform: translateY(-110vh) rotate(25deg); opacity: 0; }
}

/* ---------------- Stage / phone frame ---------------- */
.stage {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 12px;
}

.phone-frame {
  position: relative;
  width: 100%;
  max-width: 420px;
  height: min(860px, 92vh);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.card-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 28px;
  overflow: hidden;
  box-shadow: 0 30px 70px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.03);
}

/* ---------------- Screens (stacked, transitioned) ---------------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 14px;
  opacity: 0;
  transform: scale(0.96);
  pointer-events: none;
  transition: opacity var(--transition-speed) ease, transform var(--transition-speed) ease;
  background: var(--dark-bg);
}
.screen.active {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
  position: relative;
}
.screen.leaving {
  opacity: 0;
  transform: scale(1.03);
}

/* ---------------- Gingham border card ---------------- */
.gingham-border {
  width: 100%;
  height: 100%;
  border-radius: 22px;
  padding: 14px;
  background:
    repeating-linear-gradient(45deg, var(--pink-red) 0 6px, var(--cream) 6px 12px),
    repeating-linear-gradient(-45deg, var(--pink-red) 0 6px, transparent 6px 12px);
  background-blend-mode: multiply;
  position: relative;
  box-shadow: inset 0 0 0 2px rgba(169,0,50,0.15);
}
/* simpler, performant gingham using two layered linear-gradients checker */
.gingham-border {
  background-color: var(--pink-red);
  background-image:
    linear-gradient(var(--cream) 50%, transparent 50%),
    linear-gradient(90deg, var(--cream) 50%, transparent 50%);
  background-size: 16px 16px;
}

.card-inner {
  width: 100%;
  height: 100%;
  background: var(--cream);
  background-image:
    radial-gradient(circle at 15% 20%, rgba(169,0,50,0.03), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(212,20,76,0.04), transparent 40%);
  border-radius: 14px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.12), inset 0 0 40px rgba(169,0,50,0.03);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 28px 20px;
  position: relative;
}

.center-content {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
}

/* ---------------- Typography ---------------- */
.handwritten-heading {
  font-family: var(--font-hand);
  color: var(--deep-red);
  font-weight: 700;
  line-height: 1.15;
  margin: 0;
}
.handwritten-heading.big { font-size: clamp(2rem, 9vw, 2.7rem); }
.handwritten-heading.medium { font-size: clamp(1.6rem, 7vw, 2.1rem); }
.handwritten-heading.tight { line-height: 1.05; }

.handwritten-sub {
  font-family: var(--font-patrick);
  color: var(--ink);
  font-size: 1.25rem;
  margin: 0;
}
.handwritten-sub.small { font-size: 1.05rem; }

.body-text {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--ink);
  max-width: 30ch;
  margin: 0;
}
.body-text.small-body { font-size: 0.92rem; }

.script-word {
  font-family: var(--font-hand);
  font-weight: 600;
  color: var(--pink-red);
  font-size: 1.15em;
}

.serif-heading {
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  font-size: clamp(1.5rem, 6.5vw, 1.9rem);
  color: var(--deep-red);
  margin: 6px 0 0;
  letter-spacing: 0.02em;
}
.serif-sub {
  font-family: var(--font-body);
  font-style: italic;
  color: var(--ink);
  font-size: 0.95rem;
  margin: 0;
}
.script-name {
  font-family: var(--font-hand);
  font-size: 2.4rem;
  color: var(--pink-red);
  border-bottom: 2px solid var(--deep-red);
  padding: 0 18px 4px;
  margin: 0;
}

.stamp-heading {
  letter-spacing: 0.05em;
}

/* ---------------- Photo elements ---------------- */
.hero-photo-wrap {
  width: 150px;
  height: 150px;
  border-radius: 16px;
  overflow: hidden;
  border: 4px solid var(--pink-red);
  box-shadow: 0 6px 16px rgba(169,0,50,0.2);
  position: relative;
  background: var(--soft-pink);
  animation: cardPop 600ms ease both;
}
.hero-photo-wrap.round { border-radius: 50%; }
.hero-photo-wrap.small-photo { width: 100px; height: 100px; border-radius: 14px; }
.hero-photo-wrap.center-photo { margin-top: 4px; }
.hero-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.photo-fallback-emoji {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  background: var(--soft-pink);
}
.hero-photo-wrap.img-fallback .hero-photo { display: none; }
.hero-photo-wrap.img-fallback .photo-fallback-emoji { display: flex; }

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

/* ---------------- Buttons ---------------- */
.btn-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 6px;
}
.pill-btn {
  font-family: var(--font-patrick);
  font-size: 1.05rem;
  letter-spacing: 0.03em;
  color: #fff;
  background: var(--pink-red);
  padding: 12px 30px;
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--deep-red), 0 6px 14px rgba(0,0,0,0.18);
  transition: transform 150ms ease, box-shadow 150ms ease;
  position: relative;
}
.pill-btn:hover { transform: translateY(-2px); }
.pill-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--deep-red), 0 3px 8px rgba(0,0,0,0.18);
}
.no-btn { background: #B9B4A8; box-shadow: 0 4px 0 #8f8b80, 0 6px 14px rgba(0,0,0,0.14); }
.try-btn, .continue-btn { background: var(--deep-red); box-shadow: 0 4px 0 #6e0021, 0 6px 14px rgba(0,0,0,0.18); }

/* runaway NO button */
.no-btn.runaway {
  position: fixed;
  z-index: 50;
  transition: left 220ms ease, top 220ms ease;
}

/* ---------------- Screen 2 shake ---------------- */
.shake-heading { animation: shakeIt 650ms ease; }
@keyframes shakeIt {
  0%, 100% { transform: translateX(0) rotate(0); }
  15% { transform: translateX(-6px) rotate(-2deg); }
  30% { transform: translateX(6px) rotate(2deg); }
  45% { transform: translateX(-5px) rotate(-1.5deg); }
  60% { transform: translateX(5px) rotate(1.5deg); }
  75% { transform: translateX(-3px) rotate(-1deg); }
}

/* ---------------- Screen 4: gifts ---------------- */
.gifts-row {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 10px 0;
}
.gift-box {
  width: 78px;
  height: 78px;
  background: linear-gradient(160deg, var(--pink-red), var(--deep-red));
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 14px rgba(169,0,50,0.35);
  animation: giftBob 2.4s ease-in-out infinite;
  transition: transform 200ms ease;
}
.gift-box:nth-child(2) { animation-delay: 0.2s; }
.gift-box:nth-child(3) { animation-delay: 0.4s; }
.gift-box:nth-child(4) { animation-delay: 0.6s; }
.gift-box:hover { transform: scale(1.08); }
.gift-box.opened {
  animation: giftOpen 500ms ease forwards;
  opacity: 0.55;
  pointer-events: none;
}
.gift-emoji { font-size: 2.1rem; }
@keyframes giftBob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-6px) rotate(2deg); }
}
@keyframes giftOpen {
  0% { transform: scale(1); }
  40% { transform: scale(1.25) rotate(-6deg); }
  100% { transform: scale(0.9) rotate(0deg); }
}
.click-hint {
  font-weight: 700;
  color: var(--deep-red);
  letter-spacing: 0.04em;
}
.continue-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.hidden { display: none !important; }

/* ---------------- Screen 5: rakhi theme ---------------- */
.rakhi-theme .card-inner {
  background: linear-gradient(180deg, var(--cream) 70%, var(--cream-warm));
}
.rakhi-icon { font-size: 2.4rem; }

/* ---------------- Screen 6: award ---------------- */
.medal-icon { font-size: 2.6rem; }

/* ---------------- Screen 7: memories / clothesline ---------------- */
.memories-inner { padding-top: 20px; }
.clothesline {
  position: relative;
  width: 100%;
  min-height: 190px;
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  align-content: center;
  padding: 20px 4px 6px;
  border-top: 2px dashed var(--deep-red);
  border-bottom: 2px dashed var(--deep-red);
}
.polaroid {
  width: 78px;
  background: #fff;
  padding: 6px 6px 16px;
  border-radius: 3px;
  box-shadow: 0 5px 10px rgba(0,0,0,0.2);
  cursor: pointer;
  transition: transform 200ms ease;
  position: relative;
}
.polaroid:hover { transform: scale(1.06) rotate(0deg) !important; }
.polaroid-photo {
  width: 100%;
  height: 68px;
  object-fit: cover;
  background: var(--soft-pink);
  border-radius: 2px;
  display: block;
}
.polaroid-photo-fallback {
  width: 100%;
  height: 68px;
  background: var(--soft-pink);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--deep-red);
}
.polaroid-pin {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.9rem;
}
.polaroid-caption {
  font-family: var(--font-hand);
  font-size: 0.8rem;
  text-align: center;
  color: var(--ink);
  margin-top: 4px;
  display: block;
}

/* ---------------- Screen 8: words cloud ---------------- */
.words-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 320px;
}
.floating-word {
  font-family: var(--font-hand);
  font-size: 1.1rem;
  color: var(--pink-red);
  background: var(--soft-pink);
  padding: 5px 14px;
  border-radius: 999px;
  opacity: 0;
  transform: translateY(10px) rotate(-3deg);
  animation: wordIn 500ms ease forwards;
}
@keyframes wordIn {
  to { opacity: 1; transform: translateY(0) rotate(-1deg); }
}
.and-more {
  font-weight: 700;
  color: var(--deep-red);
  opacity: 0;
  animation: wordIn 600ms ease forwards;
}

/* ---------------- Screen 9: final letter ---------------- */
.letter-theme .card-inner {
  background: var(--cream-warm);
}
.letter-inner { padding-top: 30px; gap: 10px; }
.flower-icon { font-size: 2.2rem; }
.letter-heading {
  font-size: 1.2rem;
  margin-bottom: 2px;
}
.letter-text {
  font-size: 0.92rem;
  max-width: 32ch;
}
.letter-text.emphasis {
  font-weight: 700;
  color: var(--deep-red);
}
.final-line {
  font-size: 1.6rem;
  margin: 6px 0 0;
}

/* ---------------- Progress dots ---------------- */
.progress-dots {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}
.progress-dots .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  transition: background 300ms ease, transform 300ms ease;
}
.progress-dots .dot.active {
  background: var(--pink-red);
  transform: scale(1.4);
}

/* ---------------- Music button ---------------- */
.music-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 40;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--pink-red);
  color: #fff;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: transform 200ms ease;
}
.music-btn:hover { transform: scale(1.08); }
.music-btn[aria-pressed="true"] { animation: musicSpin 3s linear infinite; }
@keyframes musicSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ---------------- Modals ---------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13,13,18,0.72);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 250ms ease;
}
.modal-overlay[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: var(--cream);
  border-radius: 18px;
  padding: 28px 22px;
  max-width: 320px;
  width: 100%;
  text-align: center;
  position: relative;
  box-shadow: 0 20px 50px rgba(0,0,0,0.4);
  border: 3px solid var(--pink-red);
  animation: modalPop 350ms ease;
}
@keyframes modalPop {
  from { opacity: 0; transform: scale(0.85) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 1.1rem;
  color: var(--deep-red);
  width: 30px;
  height: 30px;
}
.modal-emoji { font-size: 2.4rem; margin: 0 0 6px; }
.modal-text {
  font-family: var(--font-patrick);
  font-size: 1.15rem;
  color: var(--ink);
  margin: 0;
}
.memory-modal-photo-wrap {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 12px;
  position: relative;
  background: var(--soft-pink);
}
.memory-modal-photo { width: 100%; height: 100%; object-fit: cover; }
.memory-modal-photo-wrap.img-fallback .memory-modal-photo { display: none; }
.memory-modal-photo-wrap .photo-fallback-emoji { font-size: 2.6rem; }
.memory-modal-photo-wrap.img-fallback .photo-fallback-emoji { display: flex; }

/* ---------------- Confetti canvas ---------------- */
#confettiCanvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 55;
}

/* ---------------- Responsive tweaks ---------------- */
@media (max-width: 380px) {
  .hero-photo-wrap { width: 120px; height: 120px; }
  .gift-box { width: 68px; height: 68px; }
  .polaroid { width: 68px; }
}

@media (min-width: 700px) {
  .stage { padding: 40px; }
  .phone-frame { max-width: 400px; }
}
