:root {
    --primary-color: #fce4ec;
    /* Rose poudré plus doux */
    --secondary-color: #fff9fb;
    /* Blanc cassé */
    --bg-gradient: linear-gradient(135deg, #fce4ec 0%, #fff1f3 100%);
    --envelope-color: #ffffff;
    --letter-color: #fffaf0;
    /* Floral White */
    --heart-color: #ff4081;
    --text-color: #5d4037;
    /* Marron doux pour le texte */
    --accent-color: #c2185b;
}

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

body {
    font-family: 'Montserrat', sans-serif;
    height: 100vh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-gradient);
    overflow: hidden;
    position: relative;
}

.background-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, transparent 0%, rgba(255, 175, 189, 0.1) 100%);
    pointer-events: none;
}

.container {
    z-index: 10;
    perspective: 1000px;
}

.content-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    margin-top: 100px;
    /* Descend l'ensemble pour donner de la place en haut */
}

/* Enveloppe */
.envelope-wrapper {
    position: relative;
    cursor: pointer;
    transition: transform 0.3s ease;
}

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

.envelope {
    position: relative;
    width: 280px;
    height: 180px;
    background: var(--envelope-color);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    transition: 0.5s;
    z-index: 1;
}

.envelope .front {
    position: absolute;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 90px 140px 90px 140px;
    border-color: transparent #f9f9f9 #f2f2f2 #f9f9f9;
    z-index: 3;
}

.envelope .top {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 95px 140px 0 140px;
    border-color: #efefef transparent transparent transparent;
    z-index: 4;
    transform-origin: top;
    transition: transform 0.4s ease-in-out 0.2s, z-index 0.2s 0.4s;
}

.letter {
    position: absolute;
    bottom: 0;
    left: 10px;
    width: 260px;
    height: 160px;
    background: var(--letter-color);
    z-index: 2;
    padding: 20px;
    text-align: center;
    transition: 0.5s;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.05);
    overflow-y: auto;
    /* Permettre le défilement si le texte est trop long */
    scrollbar-width: none;
    /* Cacher la scrollbar sur Firefox */
}

.letter::-webkit-scrollbar {
    display: none;
    /* Cacher la scrollbar sur Chrome/Safari */
}

.letter-content {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.love-title {
    font-family: 'Dancing Script', cursive;
    font-size: 1.8rem;
    color: var(--accent-color);
    margin-bottom: 15px;
}

.love-text {
    font-family: 'Playfair Display', serif;
    font-size: 0.85rem;
    /* Légère réduction pour gagner de la place */
    line-height: 1.4;
    color: var(--text-color);
    margin-bottom: 10px;
}

.love-signature {
    font-family: 'Dancing Script', cursive;
    font-size: 1.2rem;
    color: var(--accent-color);
}

/* Heart Button */
.heart {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    background: var(--heart-color);
    z-index: 5;
    transform: translate(-50%, -20%) rotate(45deg);
    box-shadow: 0 10px 20px rgba(233, 30, 99, 0.3);
    cursor: pointer;
    transition: 0.4s;
}

.heart:before,
.heart:after {
    content: "";
    position: absolute;
    width: 50px;
    height: 50px;
    background: var(--heart-color);
    border-radius: 50%;
}

.heart:before {
    top: -25px;
    left: 0;
}

.heart:after {
    top: 0;
    left: -25px;
}

/* Animations d'ouverture */
.envelope-wrapper.open .top {
    transform: rotateX(180deg);
    z-index: 0;
}

.envelope-wrapper.open .letter {
    transform: translateY(-160px);
    height: 400px;
    /* On augmente encore un peu la hauteur max */
    z-index: 5;
}

.envelope-wrapper.open .letter-content {
    opacity: 1;
    transition-delay: 0.6s;
}

.envelope-wrapper.open .heart {
    transform: translate(-50%, 150%) rotate(45deg) scale(0.5);
    opacity: 0;
    pointer-events: none;
}

/* Zone d'interaction et Bouton Surprise */
.interaction-area {
    margin-top: 20px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.instruction {
    text-align: center;
    color: var(--accent-color);
    font-weight: 300;
    letter-spacing: 1px;
    animation: pulse 2s infinite;
    transition: opacity 0.5s ease;
}

.surprise-btn {
    display: none;
    padding: 12px 25px;
    background: var(--heart-color);
    color: white;
    border: none;
    border-radius: 25px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(255, 64, 129, 0.3);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease, opacity 0.5s ease;
    opacity: 0;
}

.surprise-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 15px 25px rgba(255, 64, 129, 0.5);
}

.surprise-btn:active {
    transform: scale(0.95);
}

/* Coeurs flottants aux coins */
.floating-hearts-container {
    position: fixed;
    /* Fixed pour rester accroché à la fenêtre */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    /* Juste au dessus du fond */
}

.floating-heart {
    position: absolute;
    font-size: 1.8rem;
    /* Un peu plus petit sur mobile peut-être */
    opacity: 0.4;
    animation: floatHeart 6s ease-in-out infinite;
}

.heart-top-left {
    top: 20px;
    left: 20px;
    animation-delay: 0s;
}

.heart-top-right {
    top: 20px;
    right: 20px;
    animation-delay: 1.5s;
}

.heart-bottom-left {
    bottom: 20px;
    left: 20px;
    animation-delay: 3s;
}

.heart-bottom-right {
    bottom: 20px;
    right: 20px;
    animation-delay: 4.5s;
}

@media (max-width: 480px) {
    .floating-heart {
        font-size: 1.5rem;
        /* Plus discret sur mobile */
    }

    .heart-top-left {
        top: 10px;
        left: 10px;
    }

    .heart-top-right {
        top: 10px;
        right: 10px;
    }

    .heart-bottom-left {
        bottom: 10px;
        left: 10px;
    }

    .heart-bottom-right {
        bottom: 10px;
        right: 10px;
    }
}

@keyframes floatHeart {

    0%,
    100% {
        transform: translateY(0) scale(1) rotate(0deg);
        opacity: 0.3;
    }

    50% {
        transform: translateY(-20px) scale(1.2) rotate(10deg);
        opacity: 0.6;
    }
}

/* Nouvelles classes pour la logique JS */
.hide-instruction {
    opacity: 0;
    pointer-events: none;
    display: none !important;
}

.show-btn {
    display: block !important;
    animation: fadeInScale 0.8s forwards 0.8s;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {
    0% {
        opacity: 0.6;
        transform: translateY(0);
    }

    50% {
        opacity: 1;
        transform: translateY(-5px);
    }

    100% {
        opacity: 0.6;
        transform: translateY(0);
    }
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .envelope {
        width: 240px;
        height: 160px;
    }

    .envelope .front {
        border-width: 80px 120px 80px 120px;
    }

    .envelope .top {
        border-width: 85px 120px 0 120px;
    }

    .letter {
        width: 220px;
        height: 140px;
    }

    .envelope-wrapper.open {
        transform: translateY(120px);
        /* Fait descendre l'enveloppe pour laisser la place à la lettre */
    }

    .envelope-wrapper.open .letter {
        transform: translateY(-140px);
        height: 380px;
    }

    .interaction-area {
        margin-top: 80px;
        /* Plus d'espace sur mobile car l'enveloppe descend */
    }

    .surprise-btn {
        width: 80%;
        max-width: 280px;
    }

    .love-title {
        font-size: 1.5rem;
    }

    .love-text {
        font-size: 0.85rem;
    }
}