@import url('https://fonts.googleapis.com/css2?family=Dancing+Script:wght@600;700&family=Poppins:wght@300;400;600&display=swap');

* { box-sizing: border-box; }
body { margin: 0; overflow: hidden; font-family: 'Poppins', sans-serif; color: white; background-color: #1a000a; display: flex; justify-content: center; align-items: center; height: 100vh; width: 100vw; }
.bg-gradient { position: absolute; top: -50%; left: -50%; width: 200%; height: 200%; background: radial-gradient(circle, #4d0026 0%, #0a0004 70%); animation: pulseBg 12s infinite alternate ease-in-out; z-index: 0; }
@keyframes pulseBg { 0% { transform: scale(1); } 100% { transform: scale(1.1); } }
#hearts-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
.heart { position: absolute; top: -10%; animation: fall linear infinite; opacity: 0.7; filter: drop-shadow(0 0 8px rgba(255, 105, 180, 0.8)); }
@keyframes fall { 0% { transform: translateY(0) rotate(0deg) scale(0.8); } 50% { transform: translateY(55vh) rotate(180deg) scale(1.2); } 100% { transform: translateY(110vh) rotate(360deg) scale(0.8); } }

.screen { display: none; z-index: 10; flex-direction: column; align-items: center; justify-content: center; background: rgba(255, 255, 255, 0.03); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid rgba(255, 255, 255, 0.08); box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4); padding: 40px; border-radius: 25px; text-align: center; width: 90%; max-width: 500px; }
.screen.active { display: flex; }
.transparent-screen { background: transparent; backdrop-filter: none; box-shadow: none; border: none; padding: 10px; }
.fade-in { animation: fadeInUI 1s ease-in-out; }
@keyframes fadeInUI { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.glow-text { font-family: 'Dancing Script', cursive; font-size: 3.5rem; color: #ffe6f0; text-shadow: 0 0 12px rgba(255, 51, 133, 0.8), 0 0 25px rgba(255, 51, 133, 0.5); margin-bottom: 5px; line-height: 1.2; }
#timer { font-size: 3rem; font-weight: 600; letter-spacing: 2px; margin: 15px 0; text-shadow: 0 0 15px rgba(255, 255, 255, 0.6); transition: all 0.3s ease; }

.pulse-fast { font-size: 8rem !important; color: #ff3385 !important; animation: heartbeat 1s infinite; }
@keyframes heartbeat { 0% { transform: scale(1); } 50% { transform: scale(1.2); text-shadow: 0 0 40px #ff3385; } 100% { transform: scale(1); } }

.pin-container { display: flex; flex-direction: column; align-items: center; gap: 15px; width: 100%; }
input[type="password"], input[type="text"] { padding: 15px; font-size: 1.5rem; border-radius: 15px; border: 2px solid rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.05); color: white; text-align: center; outline: none; transition: 0.3s; width: 100%; max-width: 250px; }
input[type="password"] { letter-spacing: 8px; }
input[type="password"]:focus, input[type="text"]:focus { border-color: #ff66a3; background: rgba(255, 255, 255, 0.15); box-shadow: 0 0 15px rgba(255, 102, 163, 0.4); }

.btn-glow { padding: 12px 35px; font-size: 1.1rem; font-weight: 600; font-family: 'Poppins', sans-serif; background: rgba(255, 51, 133, 0.15); color: #ffb3d1; border: 1px solid rgba(255, 51, 133, 0.5); border-radius: 50px; cursor: pointer; transition: all 0.4s ease; box-shadow: 0 0 15px rgba(255, 51, 133, 0.2), inset 0 0 10px rgba(255, 51, 133, 0.1); backdrop-filter: blur(5px); text-transform: uppercase; letter-spacing: 1.5px; }
.btn-glow:hover { background: rgba(255, 51, 133, 0.8); color: #ffffff; transform: translateY(-3px) scale(1.02); box-shadow: 0 0 25px rgba(255, 51, 133, 0.7), inset 0 0 15px rgba(255, 255, 255, 0.3); border: 1px solid rgba(255, 105, 180, 0.8); }
.sound-btn { position: absolute; top: 20px; right: 20px; font-size: 0.8rem; padding: 8px 15px; z-index: 100; border-radius: 12px; }

/* SUPER REALISTIC 3D BOOK */
.book-wrapper { perspective: 2500px; margin-bottom: 25px; width: 100%; display: flex; justify-content: center; }
.book-container { position: relative; width: 450px; height: 600px; max-width: 95vw; max-height: 85vh; transform-style: preserve-3d; }
.book-page {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: #fdfbf7; 
    border-radius: 4px 18px 18px 4px; box-shadow: inset 4px 0 15px rgba(0,0,0,0.08), 8px 10px 25px rgba(0,0,0,0.5);
    border: 1px solid #d3c4b1; transform-origin: left center; transform-style: preserve-3d;
    transition: transform 1.4s cubic-bezier(0.645, 0.045, 0.355, 1), box-shadow 1.4s ease; /* Realistic physics curve */
    padding: 30px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #4a3b32; overflow: hidden;
}
/* Shading shadow that moves dynamically as page turns */
.book-page::after {
    content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(to right, rgba(0,0,0,0.18) 0%, rgba(0,0,0,0) 12%, rgba(255,255,255,0.4) 50%, rgba(0,0,0,0.08) 100%);
    pointer-events: none; transition: opacity 1.4s, background 1.4s;
}
/* Flips the page over to the left, slightly lifts it up on the Z axis */
.book-page.flipped { transform: rotateY(-140deg) translateZ(10px); box-shadow: inset -4px 0 15px rgba(0,0,0,0.1), -8px 10px 20px rgba(0,0,0,0.3); pointer-events: none; }
.book-page.flipped::after { opacity: 0.9; background: linear-gradient(to left, rgba(0,0,0,0.3) 0%, rgba(0,0,0,0.05) 100%); }

.polaroid { background: white; padding: 12px 12px 40px 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); margin-bottom: 25px; transform: rotate(-2deg); border: 1px solid #eaeaea; width: 100%; max-width: 340px; }
.polaroid img { width: 100%; height: 250px; object-fit: cover; border-radius: 2px; }
.page-text { font-size: 1.3rem; text-align: center; line-height: 1.5; font-weight: 600; padding: 0 10px; }
.letter-title { font-family: 'Dancing Script', cursive; font-size: 2.8rem; color: #ff3385; margin-bottom: 20px; margin-top: 0; }
.letter-text { font-family: 'Dancing Script', cursive; font-size: 1.5rem; line-height: 1.6; text-align: left; color: #333; overflow-y: auto; max-height: 420px; padding-right: 10px; }
.book-controls { display: flex; gap: 15px; justify-content: center; }

@media (max-width: 768px) { .glow-text { font-size: 2.8rem; } #timer { font-size: 2.2rem; } .screen { padding: 30px 20px; } }
@media (max-width: 480px) { .glow-text { font-size: 2.2rem; } #timer { font-size: 1.8rem; } .book-container { height: 480px; width: 340px;} .polaroid img { height: 180px; } .page-text { font-size: 1.1rem; } .letter-title { font-size: 2.2rem; } .letter-text { font-size: 1.2rem; } .btn-glow { padding: 10px 25px; font-size: 1rem; } }