:root {
    --pink: #ff4d6d;
    --light-pink: #ffccd5;
    --bg-pink: #fff0f3;
    --envelope-body: #ffe6ed;
    --envelope-flap: #f79cb5;
    --envelope-front: #ffb3c5;
    --ink-deep: #4a2434;
    --ink-soft: #6b3f52;
    --accent-rose: #d6456b;
    --accent-warm: #a44f6b;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
    user-select: none;
    height: 100vh; width: 100vw;
    background: radial-gradient(circle, #ffffff 0%, var(--bg-pink) 100%);
    font-family: 'Caudex', serif;
    color: var(--ink-deep);
    overflow: hidden;
    display: flex; justify-content: center; align-items: center;
}

.main-wrapper { display: flex; justify-content: center; align-items: center; width: 100%; height: 100%; }

/* --- ENVELOPE --- */
#envelope-stage { text-align: center; transition: opacity 1s cubic-bezier(0.22, 1, 0.36, 1); }
.envelope {
    position: relative; width: 280px; height: 180px;
    background: linear-gradient(180deg, #fff1f5 0%, var(--envelope-body) 100%);
    border-radius: 0 0 15px 15px;
    border: 1px solid #f6bfd0;
    box-shadow: 0 15px 40px rgba(255, 77, 109, 0.2);
    cursor: pointer; transform-style: preserve-3d; perspective: 900px;
    will-change: transform;
    transition: background-color 0.8s ease, box-shadow 0.8s ease;
}

.envelope.open {
    animation: envelopeSlideDown 2.1s cubic-bezier(0.22, 0.61, 0.36, 1) 0.9s forwards;
}

.flap {
    position: absolute; top: 0; width: 0; height: 0;
    border-left: 140px solid transparent; border-right: 140px solid transparent;
    border-top: 110px solid var(--envelope-flap); transform-origin: top;
    filter: drop-shadow(0 2px 1px rgba(183, 74, 106, 0.22));
    transition: transform 0.85s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.55s ease;
    z-index: 1000;
}

.envelope.open .flap { transform: rotateX(180deg); z-index: 1; }
.envelope.open .letter {
    animation: letterPop3d 2.1s cubic-bezier(0.22, 0.61, 0.36, 1) 0.9s forwards;
    box-shadow: 0 26px 52px rgba(0, 0, 0, 0.2), 0 10px 22px rgba(0, 0, 0, 0.12), inset 0 -1px 0 rgba(0, 0, 0, 0.08);
}

.envelope.open .heart-seal {
    animation: heartSealPop 2s cubic-bezier(0.22, 1, 0.36, 1) 0.06s 1 both;
}

/* .envelope.raise-letter .letter {
    /* z-index: 8; */
/* } */ */

.envelope.remove-shell {
    background: transparent;
    box-shadow: none;
}

.envelope.remove-shell .flap,
.envelope.remove-shell .envelope-front,
.envelope.remove-shell .heart-seal {
    opacity: 0;
    pointer-events: none;
}

.letter {
    position: absolute; bottom: 10px; left: 10px;
    width: 260px; height: 160px; background: white;
    border-radius: 10px; display: flex; justify-content: center; 
    align-items: center;
    transition: transform 1s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.7s ease;
    z-index: 2;
    will-change: transform;
    transform: translate3d(0, 0, 0);
    overflow: hidden;
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.16), 0 4px 12px rgba(0, 0, 0, 0.1), inset 0 -1px 0 rgba(0, 0, 0, 0.06);
}

.letter::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url("assets/white-paper-texture.jpg");
    background-size: cover;
    background-position: center;
    opacity: 0.2;
    pointer-events: none;
}

.letter .letter-content {
    position: relative;
    z-index: 1;
    font-family: 'Caudex', serif;
    color: var(--ink-soft);
}

.letter .letter-content h1 {
    font-family: 'Carter One', cursive;
    color: var(--accent-rose);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.75);
}

@keyframes letterPop3d {
    0% { transform: translate3d(0, 0, 0) scale(1); }
    66% { transform: translate3d(0, -180px, 0) scale(1); }
    100% { transform: translate3d(0, 0, 70px) scale(1.08); }
}

@keyframes envelopeSlideDown {
    0% { transform: translateY(0); }
    68% { transform: translateY(120px); }
    100% { transform: translateY(28px); }
}

@keyframes heartSealPop {
    0% { transform: translateX(-50%) scale(1); }
    100% { transform: translateX(-50%) scale(30) ;opacity: 0; }
}

.envelope-front {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 0 0 15px 15px;
    z-index: 5;
    pointer-events: none;
    transition: opacity 0.55s ease;
}

.envelope-front .front-main {
    fill: #ff9fb7;
}

.envelope-front .front-left {
    fill: #ffbcd0;
}

.envelope-front .front-right {
    fill: #ffb2c7;
}

.envelope-front .front-seam {
    stroke: rgba(171, 67, 100, 0.42);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.heart-seal {
    position: absolute; top: 70px; left: 50%; transform: translateX(-50%);
    width: 70px;
    height: 50px;
    display: block;
    z-index: 10000;
    overflow: visible;
    transition: opacity 0.45s ease, transform 0.45s ease;
}

.heart-seal .heart-fill {
    fill: #e53939;
}

.hint {
    margin-top: 35px;
    color: var(--accent-warm);
    font-weight: bold;
    font-family: 'Lugrasimo', cursive;
    opacity: 1;
    transition: opacity 0.6s ease;
}

.hint.fade-out {
    opacity: 0;
}

/* --- CARDS --- */
#card-stage.hidden { display: none; opacity: 0; }
#card-stage { animation: fadeIn 0.8s ease forwards; }

.card {
    background: white; padding: 25px; border-radius: 40px;
    width: 90vw; max-width: 340px; text-align: center;
    box-shadow: 0 25px 60px rgba(255, 77, 109, 0.15);
}

.name-header { color: var(--pink); font-size: 2.2rem; letter-spacing: 7px; margin-bottom: 15px; }
.name-header { font-family: 'Carter One', cursive; }
.name-header { color: var(--accent-rose); }

#main-title {
    color: var(--accent-rose);
    font-family: 'Lugrasimo', cursive;
}

#main-desc {
    color: var(--ink-soft);
}
.image-box img { width: 100%; border-radius: 25px; margin-bottom: 20px; }

.footer-badge {
    margin-top: 20px; padding: 12px;
    background: linear-gradient(90deg, #fff0f3, #ffccd5, #fff0f3);
    color: var(--accent-warm); border-radius: 50px; font-weight: bold; font-size: 0.9rem;
}

/* --- EFFECTS --- */
.pop-effect {
    position: fixed; pointer-events: none; z-index: 9999;
    font-size: 2rem; animation: floatUp 1s ease-out forwards;
}

@keyframes floatUp {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
    100% { transform: translate(-50%, -150px) scale(1.5); opacity: 0; }
}

.flip-anim { animation: flipCard 0.6s ease-in-out; }
@keyframes flipCard {
    50% { transform: rotateY(90deg) scale(0.9); }
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
