:root {
  --bg-deep: #090314;
  --bg-mid: #180b2e;
  --bg-plum: #2d104d;
  --gold: #ffe082;
  --gold-glow: #ffd54f;
  --rose: #ff4081;
  --rose-glow: #ff80ab;
  --cream: #fff8e7;
  --violet-soft: #e1bee7;
  --serif: 'Cormorant Garamond', serif;
  --sans: 'Poppins', sans-serif;
  --cursive: 'Sacramento', cursive;
}

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

html, body {
  width: 100%;
  min-height: 100vh;
  background: var(--bg-deep);
  font-family: var(--sans);
  color: var(--cream);
  overflow-x: hidden;
}

#canvas-fx {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 10;
}

.screen {
  display: none;
  min-height: 100vh;
  width: 100%;
  position: relative;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 32px 20px;
  background: radial-gradient(circle at 50% 30%, #3b1363 0%, var(--bg-mid) 50%, var(--bg-deep) 100%);
}

.screen.active { display: flex; }

#screen-matrix {
  padding: 0;
  background: #05020a;
  overflow: hidden;
}

#matrixCanvas {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.overlay-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--rose);
  font-family: var(--sans);
  font-size: clamp(22px, 6vw, 38px);
  font-weight: bold;
  text-shadow: 0 0 10px var(--rose), 0 0 25px var(--rose-glow), 0 0 40px #ffffff;
  opacity: 0;
  transition: opacity 2s ease-in-out;
  z-index: 10;
  pointer-events: none;
  text-align: center;
  white-space: nowrap;
}

.overlay-text.show { opacity: 1; }

.glow-gold {
  color: var(--gold) !important;
  text-shadow: 0 0 10px rgba(255, 224, 130, 0.8), 0 0 25px rgba(255, 213, 79, 0.5);
}

.glow-pink {
  color: var(--rose-glow) !important;
  text-shadow: 0 0 12px rgba(255, 64, 129, 0.8), 0 0 30px rgba(255, 128, 171, 0.6);
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 14px;
}

.title-serif {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(34px, 8vw, 52px);
  text-align: center;
  line-height: 1.15;
}

.subtitle {
  margin-top: 12px;
  text-align: center;
  font-size: 14px;
  color: var(--violet-soft);
}

.stars, .sky {
  position: absolute;
  inset: 0;
  background-image: 
    radial-gradient(2px 2px at 20% 30%, #fff, transparent),
    radial-gradient(2px 2px at 70% 15%, var(--gold), transparent),
    radial-gradient(2px 2px at 40% 70%, var(--rose), transparent);
  background-size: 250px 250px;
  opacity: .8;
  pointer-events: none;
}

.countdown-wrap { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; }
.timer { display: flex; align-items: center; gap: 10px; margin-top: 34px; }
.timebox {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 224, 130, 0.5);
  border-radius: 16px;
  width: 68px;
  padding: 12px 0;
  display: flex; flex-direction: column; align-items: center;
}
.timebox span { font-family: var(--serif); font-size: 30px; font-weight: 600; color: var(--gold); }
.timebox label { margin-top: 4px; font-size: 9px; letter-spacing: 2px; text-transform: uppercase; color: var(--violet-soft); }
.colon { font-size: 22px; color: var(--gold); margin-bottom: 14px; }
.target-label { margin-top: 18px; font-size: 12px; color: var(--violet-soft); }

.btn-gift {
  margin-top: 30px;
  padding: 16px 36px;
  border-radius: 999px;
  border: 1px solid rgba(255, 224, 130, 0.8);
  background: linear-gradient(135deg, rgba(255, 64, 129, 0.4), rgba(255, 224, 130, 0.3));
  color: var(--cream);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(255, 64, 129, 0.4);
  transition: all 0.3s ease;
}
.btn-gift:disabled { opacity: .35; cursor: not-allowed; }

.book-stage { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; }
.book-closed { width: 230px; height: 310px; cursor: pointer; }
.book-cover {
  width: 100%; height: 100%;
  border-radius: 6px 14px 14px 6px;
  background: linear-gradient(135deg, #421e6e, #7b318f);
  border: 1.5px solid rgba(255, 224, 130, 0.7);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
}
.book-cover-title { font-family: var(--serif); font-size: 28px; color: var(--gold); }
.book-cover-hint { font-size: 10px; color: var(--violet-soft); }

.book-open {
  width: min(90vw, 350px); min-height: 330px;
  background: linear-gradient(135deg, #fffbf3, #f2e3cb);
  border-radius: 12px; padding: 30px 24px; display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.book-open.hidden { display: none; }
.page { width: 100%; }
.page-text { font-family: var(--serif); font-size: 20px; color: #2d183d; line-height: 1.6; text-align: center; }
.page-nav { margin-top: 26px; }
#page-indicator { font-size: 12px; color: #7b4f9d; }

#screen-final { overflow: hidden; position: relative; }
.final-content { position: relative; z-index: 5; display: flex; flex-direction: column; align-items: center; text-align: center; }

.photo-frame-wrapper { position: relative; margin-bottom: 18px; }
.photo-frame {
  width: 170px; height: 170px;
  border-radius: 50%; border: 3.5px solid var(--gold);
  overflow: hidden; box-shadow: 0 0 30px rgba(255, 224, 130, 0.8);
}
.photo-frame img { width: 100%; height: 100%; object-fit: cover; }
.badge-star { position: absolute; font-size: 26px; }
.star-1 { top: -5px; right: -5px; }
.star-2 { bottom: 5px; left: -5px; }

.handwritten { font-family: var(--cursive); font-size: 42px; margin-bottom: -12px; }

.pills-container { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 340px; margin-top: 16px; }
.pill {
  background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 224, 130, 0.4);
  padding: 6px 14px; border-radius: 20px; font-size: 12px;
}

#floaters { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.float-item { position: absolute; font-family: var(--cursive); color: rgba(255, 255, 255, 0.85); white-space: nowrap; }

