* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  font-family: 'Cormorant Garamond', Georgia, serif;
  background: #f5f0e8;
  color: #2a1f3d;
  overflow-x: hidden;
  cursor: auto;
}
@media (pointer: coarse) {
  #glow { display: none; }
}

body::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(139,92,246,0.10), transparent 30%),
    radial-gradient(circle at 20% 30%, rgba(139,92,246,0.06) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(139,92,246,0.05) 0%, transparent 40%);
  pointer-events: none;
  z-index: 1;
}

#glow {
  position: fixed;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(139,92,246,0.45);
  box-shadow: 0 0 30px 8px rgba(139,92,246,0.30);
  pointer-events: none;
  z-index: 999999;
  transform: translate(-50%, -50%);
  transition: width 0.3s, height 0.3s;
  left: 50%; top: 50%;
  mix-blend-mode: multiply;
}
#glow.big { width: 60px; height: 60px; background: rgba(139,92,246,0.20); }

#particles {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 2;
  opacity: 0.55;
}

#trail {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 999998;
}

/* LOCK */
#lock {
  position: fixed; inset: 0;
  background: #f5f0e8;
  display: flex; align-items: center; justify-content: center;
  z-index: 10000; padding: 24px;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}
#lock.unlocked { opacity: 0; visibility: hidden; pointer-events: none; }
.lock-inner { text-align: center; max-width: 400px; width: 100%; }
.lock-label {
  font-family: 'Caveat', cursive; font-size: 1.4rem;
  color: #8b5cf6; letter-spacing: 2px; margin-bottom: 8px;
}
.lock-title {
  font-family: 'Cormorant Garamond', serif; font-weight: 600;
  font-size: clamp(3rem, 12vw, 5rem); line-height: 1;
  letter-spacing: -0.02em;
}
.lock-title em { color: #8b5cf6; font-style: italic; }
.lock-hint {
  font-family: 'Caveat', cursive; font-size: 1.2rem;
  color: #8a7f9a; margin: 20px 0 30px;
}
#lockForm { display: flex; gap: 10px; justify-content: center; }
#lockInput {
  font-family: 'Cormorant Garamond', serif; font-size: 1.6rem;
  text-align: center; letter-spacing: 0.5em;
  padding: 14px 14px 14px 24px; width: 160px;
  border: 1.5px solid rgba(139,92,246,0.4);
  background: rgba(255,255,255,0.6);
  border-radius: 40px; outline: none;
  transition: border-color 0.3s;
}
#lockInput:focus { border-color: #8b5cf6; }
#lockForm button {
  font-family: 'Caveat', cursive; font-size: 1.4rem;
  padding: 14px 28px; background: #8b5cf6; color: #fff;
  border: none; border-radius: 40px;
  cursor: pointer;
  transition: background 0.3s, transform 0.2s;
}
#lockForm button:hover { background: #7c3aed; transform: translateY(-2px); }
.lock-error {
  color: #d946a6; font-family: 'Caveat', cursive;
  font-size: 1.1rem; margin-top: 16px; min-height: 1.2em;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}
.shake { animation: shake 0.4s; }

/* ENVELOPE */
#envelope {
  position: fixed; inset: 0;
  background: #f5f0e8;
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}
#envelope.done { opacity: 0; visibility: hidden; pointer-events: none; }
.env-wrap { text-align: center; }
.env {
  width: 240px; height: 160px;
  position: relative; margin: 0 auto;
  transition: transform 0.3s;
  cursor: pointer;
}
.env:hover { transform: scale(1.05); }
.env-body {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, #e8dff5, #d8c9ef);
  border-radius: 6px;
  box-shadow: 0 20px 50px rgba(42,31,61,0.25);
}
.env-flap {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 90px;
  background: linear-gradient(180deg, #c9b6e9, #b39ddb);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top;
  transition: transform 0.6s ease;
  border-radius: 6px 6px 0 0;
  z-index: 2;
}
.env.open .env-flap { transform: rotateX(180deg); }
.env-heart {
  position: absolute;
  top: 55%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem; color: #8b5cf6;
  z-index: 3;
  transition: transform 0.5s ease;
}
.env.open .env-heart {
  transform: translate(-50%, -220%) scale(1.6);
  opacity: 0;
}
.env-text {
  font-family: 'Caveat', cursive; font-size: 1.4rem;
  color: #8a7f9a; margin-top: 30px;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* SECTIONS */
section {
  min-height: 100vh;
  padding: 80px 24px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  position: relative;
  z-index: 3;
}
.fade {
  opacity: 0; transform: translateY(40px);
  transition: opacity 1s ease, transform 1s ease;
}
.fade.in { opacity: 1; transform: translateY(0); }

/* WELCOME BACK */
.welcome-back {
  position: fixed;
  top: 20px; left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.95);
  border: 1px solid rgba(139,92,246,0.3);
  border-radius: 40px;
  padding: 12px 24px;
  font-family: 'Caveat', cursive;
  font-size: 1.2rem;
  color: #8b5cf6;
  z-index: 1000;
  box-shadow: 0 8px 30px rgba(42,31,61,0.12);
  animation: slideDown 0.6s ease, fadeOutDelay 6s ease forwards;
  max-width: 90vw;
  text-align: center;
}
@keyframes slideDown {
  from { opacity: 0; transform: translate(-50%, -20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes fadeOutDelay {
  0%, 80% { opacity: 1; }
  100% { opacity: 0; }
}

/* HERO */
.hero { text-align: center; }
.hero .label {
  font-family: 'Caveat', cursive; font-size: 1.6rem;
  color: #8b5cf6; letter-spacing: 1px; margin-bottom: 10px;
}
.hero h1 {
  font-family: 'Cormorant Garamond', serif; font-weight: 600;
  font-size: clamp(4rem, 14vw, 10rem);
  line-height: 0.9; letter-spacing: -0.02em;
}
.hero h1 em { color: #8b5cf6; font-style: italic; }
.hero .sub {
  font-family: 'Caveat', cursive; font-size: 1.8rem;
  color: #6b5b7d; margin-top: 20px; transform: rotate(-2deg);
}
.polaroid-hero {
  margin-top: 50px; display: inline-block;
  background: #fff; padding: 14px 14px 50px 14px;
  box-shadow: 0 10px 40px rgba(42,31,61,0.15);
  transform: rotate(-3deg);
  transition: transform 0.4s;
}
.polaroid-hero:hover { transform: rotate(0deg) scale(1.02); }
.polaroid-hero img { width: min(280px, 70vw); display: block; }
.polaroid-hero .cap {
  font-family: 'Caveat', cursive; font-size: 1.3rem;
  margin-top: 10px;
}
.scroll-hint {
  font-family: 'Caveat', cursive; font-size: 1.2rem;
  color: #8a7f9a; margin-top: 60px;
  animation: bob 2s infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(8px); }
}

/* COUNTER */
.counter-section { text-align: center; }
.counter-num {
  font-family: 'Cormorant Garamond', serif; font-weight: 600;
  font-size: clamp(6rem, 20vw, 14rem);
  line-height: 1; color: #8b5cf6; letter-spacing: -0.04em;
}
.counter-label {
  font-family: 'Caveat', cursive; font-size: 1.8rem;
  color: #6b5b7d; margin-top: 10px;
}
.live-grid {
  display: flex; gap: 24px; justify-content: center;
  margin-top: 30px;
}
.live-cell { display: flex; flex-direction: column; align-items: center; }
.live-cell span {
  font-family: 'Cormorant Garamond', serif; font-weight: 600;
  font-size: 2rem; color: #8b5cf6;
  font-variant-numeric: tabular-nums;
}
.live-cell small {
  font-family: 'Caveat', cursive; font-size: 1rem;
  color: #8a7f9a; margin-top: 2px; letter-spacing: 1px;
}
.counter-sub {
  font-style: italic; font-size: 1.1rem;
  color: #8a7f9a; margin-top: 30px;
}

/* BIRTHDAY */
.bday-section { text-align: center; }
.bday-card {
  background: #fff;
  padding: 50px 60px;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(42,31,61,0.12);
  border: 1px solid rgba(139,92,246,0.15);
  position: relative;
  overflow: hidden;
}
.bday-card::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(circle, rgba(139,92,246,0.08) 0%, transparent 60%);
  animation: rotate 20s linear infinite;
  pointer-events: none;
}
@keyframes rotate { to { transform: rotate(360deg); } }
.bday-label {
  font-family: 'Caveat', cursive; font-size: 1.4rem;
  color: #8a7f9a; letter-spacing: 2px;
  position: relative;
}
.bday-days {
  font-family: 'Cormorant Garamond', serif; font-weight: 600;
  font-size: clamp(4rem, 12vw, 7rem);
  line-height: 1; color: #8b5cf6;
  letter-spacing: -0.04em;
  margin: 10px 0;
  position: relative;
}
.bday-sub {
  font-family: 'Caveat', cursive; font-size: 1.6rem;
  color: #6b5b7d;
  position: relative;
}
.bday-note {
  font-style: italic; font-size: 1rem;
  color: #8a7f9a; margin-top: 20px;
  position: relative;
}

/* SCRAPBOOK */
.scrapbook-title, .reasons-title, .reply-title, .voice-title, .surprise-title {
  font-family: 'Caveat', cursive; font-size: 3rem;
  margin-bottom: 60px; text-align: center;
}
.reply-title, .voice-title { margin-bottom: 10px; }
.scatter {
  width: 100%; max-width: 1000px;
  display: flex; flex-wrap: wrap;
  justify-content: center; gap: 50px 40px;
}
.polaroid {
  background: #fff; padding: 12px 12px 55px 12px;
  box-shadow: 0 8px 30px rgba(42,31,61,0.18);
  position: relative; width: 240px;
  transition: transform 0.4s ease;
}
.polaroid img {
  width: 100%; height: 240px;
  object-fit: cover; display: block;
  filter: saturate(0.92) contrast(1.02);
}
.polaroid .cap {
  font-family: 'Caveat', cursive; font-size: 1.2rem;
  margin-top: 12px; text-align: center; line-height: 1.2;
}
.polaroid:hover {
  transform: rotate(0deg) scale(1.05) !important;
  z-index: 10;
}
.polaroid::before {
  content: ''; position: absolute;
  width: 70px; height: 22px;
  background: rgba(180,160,200,0.45);
  top: -11px; left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.p1 { transform: rotate(-5deg); }
.p2 { transform: rotate(4deg); }
.p3 { transform: rotate(-3deg); }
.p4 { transform: rotate(6deg); }
.p6 { transform: rotate(3deg); }
.p7 { transform: rotate(-6deg); }
.p8 { transform: rotate(5deg); }

/* REASONS */
.reasons-list { max-width: 620px; width: 100%; }
.reason {
  display: flex; align-items: flex-start; gap: 18px;
  padding: 22px 0;
  border-bottom: 1px dashed rgba(139,92,246,0.3);
}
.reason-num {
  font-family: 'Caveat', cursive; font-size: 1.8rem;
  color: #8b5cf6; min-width: 40px;
}
.reason-text {
  font-size: 1.25rem; line-height: 1.5; font-style: italic;
}

/* LETTER */
.letter-section { text-align: center; }
.letter {
  max-width: 580px;
  font-family: 'Caveat', cursive; font-size: 1.6rem;
  line-height: 1.6; text-align: left;
  white-space: pre-wrap; min-height: 200px;
}
.letter .cursor {
  display: inline-block; width: 3px; height: 1.3em;
  background: #8b5cf6; vertical-align: middle;
  animation: blink 1s infinite; margin-left: 2px;
}
@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* SURPRISES */
.surprise-section { text-align: center; }
.surprise-card {
  max-width: 620px; width: 100%;
  background: #fff;
  border-radius: 24px;
  padding: 60px 40px;
  box-shadow: 0 20px 60px rgba(42,31,61,0.12);
  border: 1px solid rgba(139,92,246,0.15);
  position: relative;
  overflow: hidden;
  display: flex; flex-direction: column;
  align-items: center; gap: 32px;
}
.surprise-card::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(circle, rgba(139,92,246,0.07) 0%, transparent 60%);
  animation: rotate 25s linear infinite;
  pointer-events: none;
}
.surprise-msg {
  font-family: 'Caveat', cursive;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  line-height: 1.4;
  color: #2a1f3d;
  position: relative;
  z-index: 1;
  min-height: 3em;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.4s ease, transform 0.4s ease;
  padding: 0 10px;
  text-align: center;
}
.surprise-msg.out {
  opacity: 0;
  transform: translateY(-10px);
}
.surprise-msg.in {
  opacity: 0;
  transform: translateY(10px);
}
.surprise-btn {
  font-family: 'Caveat', cursive; font-size: 1.4rem;
  padding: 14px 40px;
  background: #8b5cf6; color: #fff;
  border: none; border-radius: 40px;
  cursor: pointer;
  position: relative; z-index: 1;
  transition: background 0.3s, transform 0.2s;
}
.surprise-btn:hover {
  background: #7c3aed;
  transform: translateY(-2px);
}
.surprise-btn:active { transform: translateY(0); }
.surprise-count {
  font-family: 'Caveat', cursive;
  font-size: 1.1rem;
  color: #8a7f9a;
  margin-top: 24px;
  font-style: italic;
  letter-spacing: 0.5px;
}

/* VOICE NOTE */
.voice-section { text-align: center; }
.voice-sub {
  font-family: 'Caveat', cursive; font-size: 1.4rem;
  color: #8a7f9a; margin-bottom: 40px;
}
.voice-box {
  max-width: 500px; width: 100%;
  background: rgba(255,255,255,0.7);
  border: 1.5px solid rgba(139,92,246,0.25);
  border-radius: 20px;
  padding: 30px;
  display: flex; flex-direction: column;
  align-items: center; gap: 16px;
}
.rec-btn {
  font-family: 'Caveat', cursive; font-size: 1.5rem;
  padding: 14px 34px;
  background: #8b5cf6; color: #fff;
  border: none; border-radius: 40px;
  cursor: pointer;
  transition: background 0.3s, transform 0.2s;
}
.rec-btn:hover { background: #7c3aed; transform: translateY(-2px); }
.rec-btn.recording {
  background: #d946a6;
  animation: recPulse 1s infinite;
}
@keyframes recPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217,70,166,0.5); }
  50% { box-shadow: 0 0 0 12px rgba(217,70,166,0); }
}
.rec-timer {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.6rem;
  color: #8b5cf6;
  font-variant-numeric: tabular-nums;
}
.rec-preview {
  display: flex; flex-direction: column;
  align-items: center; gap: 14px;
  width: 100%;
}
.rec-preview audio { width: 100%; max-width: 380px; }
.rec-actions { display: flex; gap: 10px; }
.rec-send {
  font-family: 'Caveat', cursive; font-size: 1.3rem;
  padding: 10px 26px;
  background: #8b5cf6; color: #fff;
  border: none; border-radius: 30px;
  cursor: pointer;
  transition: background 0.3s;
}
.rec-send:hover { background: #7c3aed; }
.rec-send:disabled { background: #b39ddb; cursor: not-allowed; }
.rec-redo {
  font-family: 'Caveat', cursive; font-size: 1.3rem;
  padding: 10px 26px;
  background: transparent;
  border: 1.5px solid #8b5cf6;
  color: #8b5cf6;
  border-radius: 30px;
  cursor: pointer;
}
.rec-status {
  font-family: 'Caveat', cursive;
  font-size: 1.2rem;
  color: #8b5cf6;
  min-height: 1.2em;
}

/* REPLY */
.reply-section { text-align: center; }
.reply-sub {
  font-family: 'Caveat', cursive; font-size: 1.4rem;
  color: #8a7f9a; margin-bottom: 40px;
}
.reply-form {
  max-width: 500px; width: 100%;
  display: flex; flex-direction: column; gap: 14px;
}
.reply-form textarea,
.reply-form input {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.15rem;
  padding: 16px 20px;
  border: 1.5px solid rgba(139,92,246,0.35);
  background: rgba(255,255,255,0.7);
  border-radius: 14px;
  color: #2a1f3d;
  outline: none;
  resize: vertical;
  transition: border-color 0.3s, background 0.3s;
}
.reply-form textarea:focus,
.reply-form input:focus {
  border-color: #8b5cf6;
  background: #fff;
}
.reply-form button {
  font-family: 'Caveat', cursive; font-size: 1.5rem;
  padding: 16px 34px;
  background: #8b5cf6; color: #fff;
  border: none; border-radius: 40px;
  cursor: pointer;
  transition: background 0.3s, transform 0.2s;
}
.reply-form button:hover { background: #7c3aed; transform: translateY(-2px); }
.reply-form button:disabled {
  background: #b39ddb; transform: none; cursor: not-allowed;
}
.reply-status {
  font-family: 'Caveat', cursive;
  font-size: 1.3rem; color: #8b5cf6;
  margin-top: 22px; min-height: 1.5em;
}

/* FINAL */
.final { text-align: center; }
.final h2 {
  font-family: 'Caveat', cursive;
  font-size: clamp(3rem, 10vw, 6rem); line-height: 1.1;
}
.final h2 em { color: #8b5cf6; font-style: italic; }
.final-btn {
  margin-top: 40px;
  font-family: 'Caveat', cursive; font-size: 1.4rem;
  padding: 14px 34px; background: transparent;
  border: 1.5px solid #8b5cf6; color: #8b5cf6;
  border-radius: 40px;
  cursor: pointer;
  transition: all 0.3s;
}
.final-btn:hover {
  background: #8b5cf6; color: #fff;
  transform: translateY(-2px);
}
.date-stamp {
  font-style: italic; font-size: 1.1rem;
  color: #8a7f9a; margin-top: 40px;
  letter-spacing: 2px;
}

/* CONFETTI */
#confetti {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 9000;
  display: none;
}

@media (max-width: 600px) {
  .polaroid { width: 200px; }
  .polaroid img { height: 200px; }
  .scatter { gap: 40px 20px; }
  .letter { font-size: 1.35rem; }
  .live-cell span { font-size: 1.5rem; }
  .bday-card { padding: 40px 30px; }
  .voice-box { padding: 24px 18px; }
  .surprise-card { padding: 40px 24px; }
}