/* Luna birthday - design matched to the aya reference, no vendor css */
* { margin:0; padding:0; box-sizing:border-box; }
:root {
  --display:'Syne', 'Arial Black', system-ui, sans-serif;
  --mono:'Share Tech Mono', ui-monospace, Menlo, Consolas, monospace;
}
html, body {
  height:100%; overflow:hidden;
  background:#05000a;
  font-family:Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing:antialiased;
}

.stage { position:fixed; inset:0; display:none; }
.stage.active { display:flex; align-items:center; justify-content:center; }
.hidden { display:none !important; }

#rain { position:fixed; inset:0; width:100%; height:100%; z-index:1; pointer-events:none; }
#dissolve { position:absolute; inset:0; width:100%; height:100%; display:block; }

/* ---- 1. gate ---- */
#intro { flex-direction:column; z-index:5; padding:0 24px; }
.psst {
  font-family:var(--mono);
  font-size:14px; letter-spacing:.32em; text-transform:lowercase;
  color:rgba(255,255,255,.8); margin-bottom:18px;
  text-shadow:0 0 8px #05000a, 0 0 16px #05000a;
  animation:riseIn 1s ease both;
}
.gate { width:min(430px, 88vw); margin-top:38px; animation:riseIn 1.2s ease both; }
.gate input {
  width:100%; padding:15px 20px;
  font-family:var(--mono);
  font-size:17px; text-align:center; color:#fff;
  background:rgba(5,0,10,.86);
  border:1.5px solid rgba(255,105,180,.38);
  border-radius:40px; outline:none;
  transition:border-color .3s ease, box-shadow .3s ease, background .3s ease;
}
.gate input::placeholder { color:rgba(255,255,255,.42); }
.gate input:focus {
  border-color:#ff69b4;
  background:rgba(40,8,30,.92);
  box-shadow:0 0 26px rgba(255,105,180,.4);
}
.gate.shake { animation:shake .4s ease; }
.gate-err {
  min-height:22px; margin-top:14px; text-align:center;
  font-family:var(--mono); font-size:12.5px;
  letter-spacing:.14em; color:#ff7ba8; opacity:0;
  transition:opacity .3s ease;
}
.gate-err.on { opacity:1; }

/* ---- 2. countdown and name ---- */
#count { z-index:4; }

/* ---- shared hint text ---- */
.tap {
  margin-top:34px;
  font-family:var(--mono);
  font-size:12px; letter-spacing:.26em; text-transform:uppercase;
  color:rgba(255,255,255,.8);
  text-shadow:0 0 8px #05000a, 0 0 14px #05000a;
  animation:blink 1.9s step-end infinite;
}

/* ---- 4. book ---- */
#bookStage { z-index:6; flex-direction:column; justify-content:center; }

/* the white card, sized to its text so it never becomes a blank slab */
.card {
  position:fixed; top:4%; left:50%; transform:translateX(-50%);
  width:max-content; max-width:min(88vw, 620px);
  padding:18px 26px;
  border-radius:20px;
  background:linear-gradient(145deg, #ffffff 0%, #fefefe 100%);
  box-shadow:
    0 20px 60px rgba(255,105,180,.28),
    0 10px 30px rgba(0,0,0,.16),
    inset 0 1px 0 rgba(255,255,255,.9);
  opacity:0; pointer-events:none;
  transition:opacity .5s ease;
  overflow-y:auto; z-index:12;
  scrollbar-width:thin;
  scrollbar-color:rgba(255,105,180,.35) transparent;
}
.card.show { opacity:1; pointer-events:auto; }
.card p {
  margin:0; text-align:center;
  font-family:Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-weight:500;
  font-size:clamp(19px, 3vw, 25px);
  line-height:1.7; letter-spacing:.2px;
  color:#1c0b14;
}

.book-wrap {
  perspective:2000px;
  margin-top:120px;
  transition:opacity .8s ease;
}
.book {
  position:relative; width:600px; height:400px;
  transform-style:preserve-3d;
  transform:translateX(-25%);          /* closed book: centre the cover */
  transition:transform .8s ease;
  cursor:pointer; user-select:none;
  -webkit-tap-highlight-color:transparent;
}
.book.opened { transform:none; }
.book::before {
  content:''; position:absolute; inset:-22px;
  background:radial-gradient(circle, rgba(255,255,255,.16) 0%, transparent 70%);
  filter:blur(16px); z-index:-1;
  animation:glowPulse 3s ease-in-out infinite;
}
.page {
  position:absolute; top:0; right:0;
  width:300px; height:400px;
  transform-origin:left center;
  transform-style:preserve-3d;
  transform:translateZ(var(--zu, 0px));
  transition:transform .8s cubic-bezier(.25,.46,.45,.94);
  box-shadow:0 0 0 1px rgba(255,255,255,.8), 0 10px 20px rgba(0,0,0,.3);
  cursor:pointer;
}
.page.flipped { transform:translateZ(var(--zf, 0px)) rotateY(-180deg); }
.page .front, .page .back {
  position:absolute; inset:0; overflow:hidden;
  -webkit-backface-visibility:hidden; backface-visibility:hidden;
  border:2px solid #e2e2e2; background:#fff;
}
.page .front { border-radius:0 8px 8px 0; transform:translateZ(.5px); }
.page .back { border-radius:8px 0 0 8px; transform:rotateY(180deg) translateZ(.5px); }
.page img { width:100%; height:100%; object-fit:cover; display:block; }
.book-hint { margin-top:26px; }

/* ---- 5. heart finale ---- */
#final { z-index:7; flex-direction:column; }
.final-note {
  position:fixed; bottom:6%; left:50%; transform:translateX(-50%);
  width:min(92vw, 720px);
  font-family:var(--display); font-weight:700;
  font-size:clamp(17px, 4.6vw, 26px); color:#fff; text-align:center;
  text-shadow:0 0 24px rgba(255,105,180,.7), 0 2px 6px rgba(0,0,0,.8);
  opacity:0; transition:opacity 1.4s ease; z-index:320;
}
.final-note.show { opacity:1; }

/* the heart tiles, geometry from the reference */
.photo {
  position:fixed; width:120px; height:120px;
  border-radius:20px; object-fit:cover;
  border:5px solid #fff; background:#fff;
  box-shadow:0 0 20px rgba(255,105,180,.8);
  opacity:0; pointer-events:none; z-index:300;
  transform:translate(-50%,-50%) scale(0);
}

.fireworks { position:fixed; top:50%; left:50%;
  width:200px; height:200px; transform:translate(-50%,-50%);
  pointer-events:none; opacity:0;
  transition:opacity .3s ease; z-index:200; }
.firework {
  position:absolute; top:50%; left:50%;
  width:6px; height:20px;
  background:radial-gradient(circle, #fff 0%, transparent 70%);
  border-radius:50% 50% 0 0; transform-origin:bottom center;
  opacity:0; animation:fwBurst 1s ease forwards;
}
.confetti {
  position:fixed; width:9px; height:14px; border-radius:2px;
  pointer-events:none; z-index:250;
  animation:confettiFly 1s ease-out forwards;
}

/* ---- 6. the clip, pops over the heart like the ad it is ---- */
#clip {
  position:fixed; inset:0; z-index:350;
  display:flex; align-items:center; justify-content:center;
  opacity:0; pointer-events:none;
}
#clip.on { opacity:1; pointer-events:auto; }
.clip-frame { position:relative; transform:translateY(-8vh); }
#clip video {
  height:min(70vh, 44vw); width:auto; display:block;
  border:20px solid #ff69b4; border-radius:20px;
  background:#05000a;
  box-shadow:0 0 40px rgba(255,105,180,.9), 0 18px 60px rgba(0,0,0,.55);
  cursor:pointer;
}
#clip.on video { animation:adPop .5s cubic-bezier(.18,1.6,.4,1) both; }
#clipPlay {
  position:absolute; left:50%; top:50%;
  width:min(17vh, 150px); aspect-ratio:1;
  transform:translate(-50%,-50%);
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  border-radius:50%; border:4px solid #fff;
  background:rgba(5,0,10,.55); backdrop-filter:blur(6px);
  color:#fff; font-size:min(6vh, 34px); line-height:1;
  cursor:pointer; z-index:360;
  box-shadow:0 0 30px rgba(255,105,180,.7);
  transition:opacity .3s ease, transform .3s ease;
}
#clipPlay small {
  font-size:min(2vh, 12px); font-family:var(--mono);
  letter-spacing:.18em; margin-top:5px; color:#ff9cc6;
}
#clipPlay.hide {
  opacity:0; pointer-events:none;
  transform:translate(-50%,-50%) scale(.7);
}
@media (prefers-reduced-motion: reduce) {
  #clip.on video { animation:none; }
  #clipPlay { transition:none; }
}

/* ---- keyframes ---- */
@keyframes riseIn { from { opacity:0; transform:translateY(26px); } to { opacity:1; transform:none; } }
@keyframes blink { 50% { opacity:0; } }
@keyframes glowPulse { 0%,100% { opacity:.5; transform:scale(1); } 50% { opacity:.8; transform:scale(1.05); } }
@keyframes shake { 0%,100% { transform:translateX(0); } 20% { transform:translateX(-9px); } 40% { transform:translateX(9px); } 60% { transform:translateX(-6px); } 80% { transform:translateX(6px); } }
@keyframes fwBurst {
  0% { opacity:1; transform:rotate(var(--rot)) translateY(0) scaleY(1); }
  100% { opacity:0; transform:rotate(var(--rot)) translateY(-110px) scaleY(3); }
}
@keyframes confettiFly {
  0% { opacity:1; transform:translate(0,0) rotate(0deg); }
  100% { opacity:0; transform:translate(var(--cx), var(--cy)) rotate(540deg); }
}
@keyframes adPop {
  0% { transform:scale(.15) rotate(-8deg); }
  60% { transform:scale(1.12) rotate(4deg); }
  100% { transform:scale(1) rotate(0deg); }
}

/* ---- small screens ---- */
@media (max-width: 700px) {
  .book-wrap { transform:scale(.62); transform-origin:center top; margin-top:110px; }
  .card { top:3%; padding:14px 18px; }
  .card p { line-height:1.5; }
  .photo { width:74px; height:74px; border-width:3px; border-radius:14px; }
  .psst { font-size:11px; letter-spacing:.3em; }
  .gate input { font-size:17px; padding:13px 16px; }
}
/* the long hint has to fit on one line (placeholders can't wrap) */
@media (max-width: 460px) {
  .gate input::placeholder { font-size:11.5px; letter-spacing:-.2px; }
  .gate input { padding:15px 10px; }
}
@media (max-width: 460px) {
  .book-wrap { transform:scale(.46); margin-top:104px; }
  .photo { width:58px; height:58px; border-width:3px; border-radius:12px; }
}
@media (max-height: 560px) {
  .book-wrap { transform:scale(.5); margin-top:92px; }
}