/* ═══════════════════════════════════════════════════
   11TH MONTHSARY — FLOATING LANTERNS
   Theme: Mystical Night Sky  |  Mobile-First
   Author: Arjan (for Mica, his labs 💕)
═══════════════════════════════════════════════════ */

/* ── CSS Variables ─────────────────────────────── */
:root {
  /* Night Sky */
  --sky-deep:     #0d0015;
  --sky-mid:      #1a0030;
  --sky-top:      #2d0a4e;

  /* Lantern Palette */
  --lantern-pink:  #ff6b9d;
  --lantern-gold:  #ffd700;
  --lantern-glow:  rgba(255, 107, 157, 0.55);
  --lantern-warm:  #ff9ec8;

  /* Text */
  --text-white:   #ffffff;
  --text-cream:   #ffe8f5;
  --text-muted:   rgba(255, 232, 245, 0.65);

  /* Accents */
  --accent-pink:  #ff6b9d;
  --accent-gold:  #ffd700;
  --pink-btn:     linear-gradient(135deg, #ff6b9d 0%, #e0449a 100%);
  --gold-glow:    0 0 20px rgba(255, 215, 0, 0.45), 0 0 40px rgba(255, 107, 157, 0.25);

  /* Easing */
  --ease-bounce:  cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-silk:    cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ── Reset ─────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Georgia', 'Times New Roman', serif;
  background: var(--sky-deep);
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  color: var(--text-white);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ── Screen System ─────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.7s var(--ease-silk);
  z-index: 10;
  overflow-y: auto;
  overflow-x: hidden;
}

.screen.active {
  opacity: 1;
  pointer-events: all;
}

/* ── Starfield Background ──────────────────────── */
.starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: radial-gradient(ellipse at 50% 0%, var(--sky-top) 0%, var(--sky-mid) 45%, var(--sky-deep) 100%);
  overflow: hidden;
}

.star {
  position: absolute;
  border-radius: 50%;
  background: #fff;
  animation: twinkle var(--dur, 3s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

@keyframes twinkle {
  0%, 100% { opacity: var(--min-op, 0.2); transform: scale(1); }
  50%       { opacity: 1; transform: scale(1.4); }
}

/* ── Nebula Blobs ──────────────────────────────── */
.nebula {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 1;
  animation: nebulaDrift 18s ease-in-out infinite alternate;
}

.nebula-1 {
  width: min(420px, 80vw);
  height: min(420px, 80vw);
  background: radial-gradient(circle, rgba(180, 50, 150, 0.18) 0%, transparent 70%);
  top: -10%;
  left: -15%;
  animation-delay: 0s;
}

.nebula-2 {
  width: min(320px, 70vw);
  height: min(320px, 70vw);
  background: radial-gradient(circle, rgba(255, 107, 157, 0.14) 0%, transparent 70%);
  bottom: 10%;
  right: -10%;
  animation-delay: -6s;
}

.nebula-3 {
  width: min(260px, 60vw);
  height: min(260px, 60vw);
  background: radial-gradient(circle, rgba(100, 30, 180, 0.15) 0%, transparent 70%);
  top: 40%;
  left: 35%;
  animation-delay: -12s;
}

@keyframes nebulaDrift {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(20px, 15px) scale(1.06); }
}

/* ══════════════════════════════════════════════════
   SCREEN 1 — SPLASH
══════════════════════════════════════════════════ */
#screen-splash {
  z-index: 10;
  padding: 2rem 1.5rem;
}

.splash-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  max-width: 420px;
  width: 100%;
  text-align: center;
  animation: fadeInUp 1s var(--ease-silk) forwards;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

.lantern-icon {
  font-size: clamp(3.5rem, 15vw, 5rem);
  animation: lanternFloat 4s ease-in-out infinite;
  filter: drop-shadow(0 0 18px rgba(255, 215, 0, 0.7));
}

@keyframes lanternFloat {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%       { transform: translateY(-14px) rotate(3deg); }
}

.splash-title {
  font-size: clamp(1.4rem, 6vw, 2rem);
  color: var(--text-cream);
  line-height: 1.35;
  min-height: 2.8em;
  font-weight: normal;
  letter-spacing: 0.02em;
}

.cursor {
  display: inline-block;
  color: var(--lantern-pink);
  animation: blink 0.9s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.splash-sub {
  font-size: clamp(1rem, 4vw, 1.25rem);
  color: var(--lantern-warm);
  font-style: italic;
}

.splash-from {
  font-size: clamp(0.85rem, 3.5vw, 1rem);
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* ── Glow Button (shared) ──────────────────────── */
.btn-glow {
  display: inline-block;
  padding: 0.85em 2.2em;
  border: none;
  border-radius: 50px;
  background: var(--pink-btn);
  color: #fff;
  font-size: clamp(0.95rem, 4vw, 1.1rem);
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 0 18px rgba(255, 107, 157, 0.5), 0 4px 20px rgba(0, 0, 0, 0.4);
  transition: transform 0.18s var(--ease-bounce), box-shadow 0.18s ease;
  letter-spacing: 0.03em;
  margin-top: 0.5rem;
}

.btn-glow:hover {
  transform: scale(1.06);
  box-shadow: 0 0 28px rgba(255, 107, 157, 0.75), 0 6px 24px rgba(0, 0, 0, 0.4);
}

.btn-glow:active {
  transform: scale(0.96);
}

.btn-glow.hidden {
  display: none;
}

/* ══════════════════════════════════════════════════
   SCREEN 2 — LANTERNS
══════════════════════════════════════════════════ */
#screen-lanterns {
  justify-content: flex-start;
  z-index: 10;
}

.lantern-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 0.9rem 1.2rem;
  display: flex;
  justify-content: center;
  z-index: 20;
  background: linear-gradient(to bottom, rgba(13,0,21,0.75) 60%, transparent);
}

.progress-label {
  font-size: clamp(0.85rem, 3.5vw, 1rem);
  color: var(--lantern-warm);
  letter-spacing: 0.06em;
  text-shadow: 0 0 8px rgba(255, 107, 157, 0.5);
}

.lantern-stage {
  position: fixed;
  inset: 0;
  pointer-events: none; /* children get their own pointer-events */
}

/* ── Individual Floating Lantern ───────────────── */
.lantern {
  position: absolute;
  bottom: -120px;
  font-size: clamp(2.6rem, 10vw, 3.6rem);
  cursor: pointer;
  pointer-events: all;
  filter: drop-shadow(0 0 12px rgba(255, 215, 0, 0.65))
          drop-shadow(0 0 28px rgba(255, 107, 157, 0.45));
  animation: floatLantern var(--dur, 14s) linear forwards;
  animation-delay: var(--spawn-delay, 0s);
  will-change: transform;
  touch-action: manipulation;
  transition: transform 0.25s var(--ease-bounce), filter 0.25s ease;
  z-index: 12;
}

.lantern:hover,
.lantern.touched {
  transform: scale(1.3);
  filter: drop-shadow(0 0 22px rgba(255, 215, 0, 0.9))
          drop-shadow(0 0 44px rgba(255, 107, 157, 0.8));
}

.lantern.held {
  animation-play-state: paused;
  transform: scale(1.35) !important;
  cursor: default;
}

.lantern.collected {
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}

@keyframes floatLantern {
  0% {
    transform: translateY(0) translateX(0) rotate(0deg);
    opacity: 0;
  }
  5% {
    opacity: 1;
  }
  85% {
    opacity: 1;
  }
  100% {
    transform: translateY(calc(-100vh - 140px)) translateX(var(--drift, 30px)) rotate(var(--rot, 8deg));
    opacity: 0;
  }
}

/* ── Lantern Card Overlay ──────────────────────── */
.lantern-card-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 0, 21, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1.5rem;
  animation: overlayIn 0.3s var(--ease-silk) forwards;
}

.lantern-card-overlay.hidden {
  display: none;
}

@keyframes overlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.lantern-card {
  background: linear-gradient(160deg, #2a0040 0%, #1a0030 60%, #0d0015 100%);
  border: 1px solid rgba(255, 107, 157, 0.35);
  border-radius: 24px;
  padding: 2rem 1.6rem 1.6rem;
  max-width: 360px;
  width: 100%;
  text-align: center;
  animation: cardPop 0.4s var(--ease-bounce) forwards;
  box-shadow: 0 0 40px rgba(255, 107, 157, 0.2), 0 20px 60px rgba(0,0,0,0.6);
}

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

.card-lantern-emoji {
  font-size: 2.4rem;
  animation: lanternFloat 3s ease-in-out infinite;
  margin-bottom: 0.3rem;
}

.card-month {
  font-size: clamp(1rem, 4.5vw, 1.25rem);
  color: var(--lantern-gold);
  font-style: italic;
  letter-spacing: 0.04em;
  margin-bottom: 1rem;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

/* ── Card Photo ──────────────────────────────── */
.card-photo-wrap {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  margin: 0 auto 1rem;
  overflow: hidden;
  border: 3px solid var(--lantern-pink);
  box-shadow: 0 0 20px rgba(255, 107, 157, 0.5);
  position: relative;
  background: rgba(255,255,255,0.05);
}

.card-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-photo.hidden,
.card-photo-fallback.hidden {
  display: none;
}

.card-photo-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}

.card-message {
  font-size: clamp(0.88rem, 3.8vw, 1rem);
  color: var(--text-cream);
  line-height: 1.7;
  margin-bottom: 1.2rem;
  font-style: italic;
}

/* ── Timer Bar ───────────────────────────────── */
.card-timer-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 1.2rem;
}

.card-timer-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--lantern-pink), var(--lantern-gold));
  border-radius: 4px;
  transform-origin: left;
  animation: timerDrain 5s linear forwards;
}

@keyframes timerDrain {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

.card-close {
  background: transparent;
  border: 1px solid rgba(255, 107, 157, 0.5);
  border-radius: 30px;
  color: var(--lantern-warm);
  font-size: 0.9rem;
  padding: 0.5em 1.5em;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s ease, transform 0.18s var(--ease-bounce);
}

.card-close:hover {
  background: rgba(255, 107, 157, 0.15);
  transform: scale(1.05);
}

.card-close:active {
  transform: scale(0.95);
}

/* ══════════════════════════════════════════════════
   SCREEN 3 — GIFTS
══════════════════════════════════════════════════ */
#screen-gifts {
  z-index: 10;
  padding: 2rem 1.5rem 3rem;
  overflow-y: auto;
  justify-content: flex-start;
  padding-top: 3.5rem;
}

.gifts-content {
  max-width: 420px;
  width: 100%;
  text-align: center;
  animation: fadeInUp 0.8s var(--ease-silk) forwards;
}

.gifts-title {
  font-size: clamp(1.5rem, 6.5vw, 2rem);
  color: var(--lantern-gold);
  text-shadow: var(--gold-glow);
  font-weight: normal;
  margin-bottom: 0.5rem;
}

.gifts-sub {
  font-size: clamp(0.9rem, 3.8vw, 1rem);
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 2rem;
}

.gift-list {
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
  margin-bottom: 2rem;
}

/* ── Individual Gift Box ─────────────────────── */
.gift-box {
  position: relative;
  cursor: pointer;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(255, 215, 0, 0.2);
  transition: transform 0.2s var(--ease-bounce), box-shadow 0.2s ease;
  touch-action: manipulation;
}

.gift-box:hover:not(.opened) {
  transform: scale(1.03);
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
}

.gift-box:active:not(.opened) {
  transform: scale(0.97);
}

.gift-box.shake {
  animation: giftShake 0.5s ease;
}

@keyframes giftShake {
  0%, 100% { transform: rotate(0deg); }
  20%       { transform: rotate(-5deg) scale(1.05); }
  40%       { transform: rotate(5deg) scale(1.07); }
  60%       { transform: rotate(-4deg) scale(1.06); }
  80%       { transform: rotate(4deg) scale(1.04); }
}

.gift-box-inner {
  position: relative;
  min-height: 90px;
}

.gift-lid {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.1), rgba(255, 107, 157, 0.08));
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.gift-lid .gift-emoji {
  font-size: clamp(2.4rem, 10vw, 3.2rem);
  animation: giftBob 2.5s ease-in-out infinite;
}

@keyframes giftBob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%       { transform: translateY(-8px) rotate(3deg); }
}

.gift-box.opened .gift-lid {
  opacity: 0;
  transform: translateY(-20px) scale(0.8);
  position: absolute;
  pointer-events: none;
}

.gift-reveal {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.6rem 1.4rem;
  background: linear-gradient(135deg, rgba(255, 107, 157, 0.12), rgba(255, 215, 0, 0.06));
  animation: revealPop 0.5s var(--ease-bounce) forwards;
}

.gift-box.opened .gift-reveal {
  display: flex;
}

@keyframes revealPop {
  from { opacity: 0; transform: scale(0.8) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.gift-item-emoji {
  font-size: clamp(2rem, 9vw, 2.8rem);
}

.gift-name {
  font-size: clamp(1rem, 4.5vw, 1.25rem);
  color: var(--lantern-gold);
  font-weight: normal;
  letter-spacing: 0.05em;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

.gift-note {
  font-size: clamp(0.85rem, 3.5vw, 0.95rem);
  color: var(--text-cream);
  font-style: italic;
  line-height: 1.65;
  max-width: 300px;
}

.gift-hints {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-width: 300px;
  text-align: left;
  padding: 0;
}

.gift-hints li {
  font-size: clamp(0.83rem, 3.4vw, 0.93rem);
  color: var(--text-cream);
  font-style: italic;
  line-height: 1.6;
  padding-left: 1.2em;
  position: relative;
}

.gift-hints li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--lantern-pink);
}

.gift-guess-label {
  margin-top: 0.6rem;
  font-size: clamp(0.8rem, 3.2vw, 0.88rem);
  color: var(--lantern-warm);
  letter-spacing: 0.04em;
}

/* ══════════════════════════════════════════════════
   SCREEN 4 — LOVE LETTER + GALLERY
══════════════════════════════════════════════════ */
#screen-letter {
  justify-content: flex-start;
  padding: 2rem 1.5rem 4rem;
  overflow-y: auto;
  z-index: 10;
}

.letter-content {
  max-width: 440px;
  width: 100%;
  animation: fadeInUp 0.8s var(--ease-silk) forwards;
}

.letter-title {
  font-size: clamp(1.4rem, 6vw, 1.9rem);
  color: var(--lantern-gold);
  text-align: center;
  font-weight: normal;
  text-shadow: var(--gold-glow);
  margin-bottom: 1.5rem;
}

.letter-envelope {
  background: linear-gradient(160deg, rgba(42, 0, 64, 0.7), rgba(26, 0, 48, 0.85));
  border: 1px solid rgba(255, 107, 157, 0.25);
  border-radius: 20px;
  padding: 1.8rem 1.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 0 30px rgba(255, 107, 157, 0.08), inset 0 1px 0 rgba(255,255,255,0.04);
}

.letter-text {
  font-size: clamp(0.9rem, 3.8vw, 1rem);
  color: var(--text-cream);
  line-height: 1.9;
  font-style: italic;
  white-space: pre-wrap;
  min-height: 4em;
}

.letter-cursor {
  display: inline-block;
  color: var(--lantern-pink);
  animation: blink 0.9s step-end infinite;
}

/* ── Photo Gallery ───────────────────────────── */
.gallery-title {
  font-size: clamp(1rem, 4.5vw, 1.25rem);
  color: var(--lantern-warm);
  font-weight: normal;
  text-align: center;
  margin-bottom: 1rem;
}

.gallery-track-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  margin: 0 -1.5rem;
  padding: 0.5rem 1.5rem 0.8rem;
  cursor: grab;
}

.gallery-track-wrap:active {
  cursor: grabbing;
}

.gallery-track-wrap::-webkit-scrollbar {
  display: none;
}

.gallery-track {
  display: flex;
  gap: 1.2rem;
  width: max-content;
  align-items: center;
}

.polaroid {
  scroll-snap-align: center;
  background: #fff;
  padding: 8px 8px 32px;
  border-radius: 4px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5), 0 0 20px rgba(255, 107, 157, 0.1);
  transform: rotate(var(--tilt, -2deg));
  transition: transform 0.3s var(--ease-bounce);
  flex-shrink: 0;
  width: 180px;
}

.polaroid:nth-child(even) {
  --tilt: 2deg;
}

.polaroid:hover {
  transform: rotate(0deg) scale(1.06);
  z-index: 2;
}

.polaroid img {
  width: 164px;
  height: 164px;
  object-fit: cover;
  display: block;
  border-radius: 2px;
  background: rgba(255,255,255,0.1);
}

.gallery-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 2rem;
  letter-spacing: 0.06em;
}

.btn-replay {
  display: block;
  margin: 0 auto;
}

/* ══════════════════════════════════════════════════
   AUDIO TOGGLE
══════════════════════════════════════════════════ */
.audio-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 100;
  background: rgba(255, 107, 157, 0.18);
  border: 1px solid rgba(255, 107, 157, 0.35);
  border-radius: 50%;
  width: 42px;
  height: 42px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.2s ease, transform 0.18s var(--ease-bounce);
  touch-action: manipulation;
}

.audio-toggle:hover {
  background: rgba(255, 107, 157, 0.32);
  transform: scale(1.1);
}

.audio-toggle:active {
  transform: scale(0.92);
}

/* ══════════════════════════════════════════════════
   CONFETTI CANVAS
══════════════════════════════════════════════════ */
#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
}

/* ══════════════════════════════════════════════════
   UTILITY
══════════════════════════════════════════════════ */
.hidden {
  display: none !important;
}

/* ══════════════════════════════════════════════════
   RESPONSIVE ADJUSTMENTS
══════════════════════════════════════════════════ */
@media (min-width: 480px) {
  .polaroid {
    width: 210px;
  }
  .polaroid img {
    width: 194px;
    height: 194px;
  }
}

@media (min-width: 768px) {
  .lantern-card {
    max-width: 400px;
  }
  .gifts-content,
  .letter-content {
    max-width: 500px;
  }
}
