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

body {
    font-family: 'Outfit', sans-serif;
    min-height: 100vh;
    background: #0f0c29; /* fallback */
    background: linear-gradient(to bottom, #240b36, #c31432);
    overflow: hidden; /* Prevent scrolling, handle in absolute layers */
    display: flex;
    justify-content: center;
    align-items: center;
    color: #333;
}

/* Starry background effect */
.stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}
.star {
    position: absolute;
    background: white;
    border-radius: 50%;
    animation: twinkle infinite ease-in-out;
}
@keyframes twinkle {
    0%, 100% { opacity: 0.2; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* --- Envelope Intro --- */
.envelope-wrapper {
    position: absolute;
    z-index: 10;
    cursor: pointer;
    transition: transform 0.5s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.envelope-wrapper:hover {
    transform: scale(1.05) translateY(-5px);
}

.envelope-wrapper.open {
    pointer-events: none;
    animation: fadeOutEnvelope 1.5s forwards 1s;
}

@keyframes fadeOutEnvelope {
    to { opacity: 0; transform: scale(0.8) translateY(100px); visibility: hidden; }
}

.glow {
    position: absolute;
    width: 250px;
    height: 150px;
    background: rgba(255, 105, 135, 0.6);
    filter: blur(40px);
    border-radius: 50%;
    animation: pulseGlow 2s infinite alternate;
}

@keyframes pulseGlow {
    from { transform: scale(1); opacity: 0.5; }
    to { transform: scale(1.3); opacity: 0.9; }
}

.envelope {
    position: relative;
    width: 300px;
    height: 200px;
    background: #fdf5e6;
    border-radius: 5px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
    z-index: 2;
}

.envelope .flap {
    position: absolute;
    top: 0;
    left: 0;
    border-left: 150px solid transparent;
    border-right: 150px solid transparent;
    border-top: 100px solid #e3dac9;
    transform-origin: top;
    transition: transform 0.6s ease 0.2s;
    z-index: 5;
}

.envelope-wrapper.open .flap {
    transform: rotateX(180deg);
}

.envelope .body {
    position: absolute;
    bottom: 0;
    left: 0;
    border-left: 150px solid #f4ecd8;
    border-right: 150px solid #f4ecd8;
    border-bottom: 100px solid #eee1c9;
    z-index: 4;
}

.envelope .letter {
    position: absolute;
    background: #fff;
    width: 280px;
    height: 180px;
    left: 10px;
    bottom: 10px;
    border-radius: 5px;
    z-index: 3;
    transition: transform 0.8s ease 0.6s;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.envelope-wrapper.open .letter {
    transform: translateY(-80px);
}

.heart-seal {
    position: absolute;
    top: 85px;
    left: 135px;
    font-size: 30px;
    z-index: 6;
    transition: opacity 0.3s;
}

.envelope-wrapper.open .heart-seal {
    opacity: 0;
}

.tap-text {
    margin-top: 30px;
    color: #fff;
    font-size: 1.2rem;
    font-family: 'Dancing Script', cursive;
    letter-spacing: 2px;
    animation: pulseText 1.5s infinite;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
    z-index: 2;
}

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

/* --- Polaroids --- */
.cards-container {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 1000px;
    z-index: 20;
    pointer-events: none; /* Only allow clicking active cards */
}

.polaroid {
    position: absolute;
    background: #fff;
    padding: 15px 15px 30px 15px;
    border-radius: 5px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.5);
    width: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    
    /* Initial hidden state */
    opacity: 0;
    transform: translateY(100vh) rotateZ(10deg) rotateY(20deg) scale(0.5);
    transition: all 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
}

.polaroid.active {
    opacity: 1;
    transform: translateY(0) rotateZ(0deg) rotateY(0deg) scale(1);
    pointer-events: auto;
    z-index: 30;
}

.polaroid.passed {
    opacity: 0;
    transform: translateY(-100vh) rotateZ(-10deg) scale(0.8);
    pointer-events: none;
}

.polaroid .photo {
    width: 100%;
    height: 290px; /* fixed size container */
    background: #f0f0f0;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid #ddd;
}

.polaroid .photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.polaroid .caption {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    color: #444;
    margin-top: 20px;
    text-align: center;
    line-height: 1.4;
    min-height: 60px;
}

button {
    margin-top: 20px;
    padding: 10px 25px;
    border: none;
    background: #ff4d6d;
    color: white;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    border-radius: 25px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255, 77, 109, 0.4);
    transition: all 0.3s ease;
}

button:hover {
    background: #c9184a;
    transform: scale(1.05);
}

.finale-btn {
    background: #ff0a54;
    font-size: 1.2rem;
    padding: 15px 30px;
    box-shadow: 0 4px 20px rgba(255, 10, 84, 0.6);
    animation: heartbeat 1.5s infinite;
}

@keyframes heartbeat {
    0% { transform: scale(1); }
    15% { transform: scale(1.1); }
    30% { transform: scale(1); }
    45% { transform: scale(1.1); }
    60% { transform: scale(1); }
}

.finale-text {
    font-family: 'Dancing Script', cursive;
    font-size: 2rem !important;
    color: #c9184a;
    font-weight: 700;
}

/* --- Heart Particles --- */
#heart-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
    overflow: hidden;
}

.heart-particle {
    position: absolute;
    top: -10vh;
    font-size: 24px;
    animation: fall linear forwards;
}

@keyframes fall {
    to {
        transform: translateY(110vh) rotate(360deg);
    }
}

@media (max-width: 480px) {
    .polaroid {
        width: 90%;
        max-width: 320px;
    }
    .envelope {
        width: 250px;
        height: 170px;
    }
    .envelope .flap {
        border-left-width: 125px;
        border-right-width: 125px;
        border-top-width: 85px;
    }
    .envelope .body {
        border-left-width: 125px;
        border-right-width: 125px;
        border-bottom-width: 85px;
    }
    .envelope .letter {
        width: 230px;
        height: 150px;
    }
    .heart-seal {
        top: 70px;
        left: 110px;
    }
}
