:root {
  --bg: #fff5f8;
  --bg-2: #ffe9f2;
  --ink: #3a2230;
  --ink-soft: #7a5c6b;
  --accent: #ff69b4;
  --accent-2: #ffd700;
  --accent-3: #e8a0bf;
  --card-bg: #ffffff;
  --card-border: #ffc4dd;
  --shadow: 0 18px 50px rgba(255, 105, 180, 0.25);
  --font-title: 'Fredoka', 'Segoe UI', sans-serif;
  --font-body: 'Quicksand', system-ui, sans-serif;
  --radius: 22px;
  --title-size: clamp(3rem, 12vw, 7rem);
}

#app {
  position: relative;
  z-index: 1;
  overflow-x: hidden;
}

.particles-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 40;
}

.section {
  position: relative;
  padding: 6rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.section-title {
  font-family: var(--font-title);
  font-size: clamp(1.7rem, 4.5vw, 2.6rem);
  margin: 0 0 0.5rem;
  text-align: center;
  color: var(--ink);
}

.section-sub {
  margin: 0 0 2.5rem;
  color: var(--ink-soft);
  text-align: center;
}

/* ===== HERO ===== */
.hero {
  min-height: 100svh;
  justify-content: center;
  text-align: center;
  padding-top: 4rem;
  padding-bottom: 4rem;
}

.hero-content {
  position: relative;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}

.greeting-line {
  font-family: var(--font-body);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  font-size: clamp(0.95rem, 2.6vw, 1.15rem);
  margin: 0 0 1.2rem;
  min-height: 1.5em;
}

.hero-title {
  font-family: var(--font-title);
  font-weight: 700;
  line-height: 0.98;
  margin: 0;
  color: var(--ink);
  text-shadow: 0 6px 24px rgba(0, 0, 0, 0.06);
}

.hero-title .title-line {
  display: block;
}

.hero-title .title-line-1,
.hero-title .title-line-2 {
  font-size: var(--title-size);
  letter-spacing: 0.01em;
}

.hero-title .title-line-3 {
  font-size: calc(var(--title-size) * 1.15);
  color: var(--accent);
  margin-top: 0.05em;
}

.hero-subtitle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.8rem;
}

.decorative-line {
  height: 2px;
  width: clamp(40px, 12vw, 90px);
  background: linear-gradient(90deg, transparent, var(--accent-3), transparent);
}

.date-text {
  font-family: var(--font-body);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: clamp(0.7rem, 2.2vw, 0.85rem);
  color: var(--ink-soft);
}

.age-badge {
  display: inline-block;
  margin-top: 1.6rem;
  padding: 0.5rem 1.4rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-title);
  font-size: clamp(0.9rem, 3vw, 1.2rem);
  box-shadow: var(--shadow);
}

.scroll-hint {
  margin-top: 3.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink-soft);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  animation: floaty 2.4s ease-in-out infinite;
}

.scroll-arrow {
  width: 14px;
  height: 14px;
  border-right: 2px solid var(--ink-soft);
  border-bottom: 2px solid var(--ink-soft);
  transform: rotate(45deg);
}

@keyframes floaty {
  0%, 100% { transform: translateY(0); opacity: 0.85; }
  50% { transform: translateY(8px); opacity: 1; }
}

.sparkle {
  position: absolute;
  color: var(--accent-2);
  font-size: 1.4rem;
  animation: twinkle 2.6s ease-in-out infinite;
  pointer-events: none;
}

.sparkle.s1 { top: 8%; left: 6%; animation-delay: 0s; }
.sparkle.s2 { top: 20%; right: 8%; animation-delay: 0.5s; }
.sparkle.s3 { bottom: 18%; left: 12%; animation-delay: 1s; }
.sparkle.s4 { bottom: 10%; right: 14%; animation-delay: 1.4s; }
.sparkle.s5 { top: 45%; left: 2%; animation-delay: 0.8s; }

@keyframes twinkle {
  0%, 100% { transform: scale(0.7); opacity: 0.4; }
  50% { transform: scale(1.2); opacity: 1; }
}

/* ===== COUNTDOWN ===== */
.countdown-section {
  background: var(--bg-2);
}

.countdown-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(0.6rem, 2vw, 1.4rem);
  width: min(680px, 100%);
}

.countdown-cell {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: clamp(0.9rem, 3vw, 1.6rem) 0.4rem;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

.countdown-num {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: clamp(1.8rem, 7vw, 3.2rem);
  line-height: 1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.countdown-label {
  margin-top: 0.5rem;
  font-size: clamp(0.62rem, 2vw, 0.78rem);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.countdown-today {
  font-family: var(--font-title);
  font-size: clamp(1.4rem, 5vw, 2.2rem);
  color: var(--accent);
  text-align: center;
}

/* ===== CARD ===== */
.card-instruction {
  color: var(--ink-soft);
  margin-bottom: 2.2rem;
  font-weight: 600;
}

.greeting-card-scene {
  perspective: 1800px;
  width: min(420px, 92vw);
  height: min(560px, 130vw);
  cursor: pointer;
}

.greeting-card {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.9s cubic-bezier(0.4, 0.2, 0.2, 1);
}

.greeting-card.flipped {
  transform: rotateY(180deg);
}

.greeting-card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.greeting-card-front {
  background: linear-gradient(160deg, var(--card-bg), var(--bg-2));
  border: 2px solid var(--card-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  padding: 2rem;
  text-align: center;
}

.greeting-card-back {
  transform: rotateY(180deg);
  background: var(--card-bg);
  border: 2px solid var(--card-border);
  padding: 1.6rem;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.card-border-inner {
  position: absolute;
  inset: 10px;
  border: 1.5px dashed var(--card-border);
  border-radius: calc(var(--radius) - 8px);
  pointer-events: none;
}

.cover-cake svg {
  width: clamp(120px, 34vw, 170px);
  height: auto;
}

.cover-seal {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--font-title);
  font-size: 1.8rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.cover-text {
  font-family: var(--font-title);
  font-size: 1.5rem;
  margin: 0;
  color: var(--ink);
}

.cover-hint {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 0;
}

.back-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0.6rem;
}

.back-title {
  font-family: var(--font-title);
  text-align: center;
  color: var(--accent);
  margin: 0.4rem 0 1rem;
  font-size: 1.5rem;
}

.back-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 0 0.3rem;
}

.back-msg {
  margin: 0;
  line-height: 1.65;
  font-size: 0.98rem;
  color: var(--ink);
}

.back-msg.main {
  font-weight: 600;
}

.back-msg.highlight {
  font-family: var(--font-title);
  color: var(--accent);
  font-size: 1.15rem;
  text-align: center;
}

.back-msg.signature {
  text-align: right;
  color: var(--ink-soft);
  font-style: italic;
}

.back-hearts {
  text-align: center;
  color: var(--accent);
  letter-spacing: 0.4em;
  margin-top: 0.8rem;
}

.download-btn {
  margin-top: 2.4rem;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1.8rem;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.download-btn:hover {
  transform: translateY(-2px);
}

.download-btn:disabled {
  opacity: 0.7;
  cursor: default;
}

/* ===== GALLERY ===== */
.gallery-section {
  background: var(--bg-2);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  width: min(960px, 100%);
}

.gallery-item {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--card-bg);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.08);
  transition: transform 0.25s ease;
}

.gallery-item:nth-child(3n) {
  transform: rotate(-1.2deg);
}

.gallery-item:nth-child(4n) {
  transform: rotate(1.2deg);
}

.gallery-item:hover {
  transform: scale(1.03) rotate(0);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.7rem 0.8rem;
  font-size: 0.8rem;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
}

/* ===== MUSIC ===== */
.music-btn {
  position: fixed;
  top: 1.1rem;
  right: 1.1rem;
  z-index: 50;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease;
}

.music-btn:hover {
  transform: scale(1.08);
}

.music-btn.muted {
  background: var(--ink-soft);
}

.music-btn svg {
  width: 22px;
  height: 22px;
}

.music-btn .music-icon.off {
  display: none;
}

.music-btn.muted .music-icon.on {
  display: none;
}

.music-btn.muted .music-icon.off {
  display: block;
}

.music-btn.playing {
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: var(--shadow); }
  50% { box-shadow: 0 0 0 10px rgba(255, 105, 180, 0.15), var(--shadow); }
}

/* ===== FOOTER ===== */
.footer {
  padding: 3rem 1.5rem 4rem;
  text-align: center;
  color: var(--ink-soft);
}

.footer-hearts {
  color: var(--accent);
  letter-spacing: 0.5em;
  margin-bottom: 0.6rem;
}

.footer-year {
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  opacity: 0.7;
}

/* ===== UTIL ANIMATIONS ===== */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.reveal.visible {
  opacity: 1;
  transform: none;
}

.hearts-rain {
  position: fixed;
  top: -40px;
  z-index: 60;
  pointer-events: none;
  animation: heartFall linear forwards;
}

@keyframes heartFall {
  to {
    transform: translateY(110vh) rotate(40deg);
    opacity: 0;
  }
}

/* ===== STATES ===== */
.state-screen {
  min-height: 100svh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 2rem;
}

.state-screen h1 {
  font-family: var(--font-title);
  color: var(--accent);
}

@media (max-width: 560px) {
  .countdown-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .section {
    padding: 4rem 1.1rem;
  }
}
