:root {
    --primary-purple: #9b6dff;
    --soft-purple: #f3e8ff;
    --deep-purple: #6d28d9;
    --bg-gradient: linear-gradient(135deg, #fdf4ff 0%, #f3e8ff 100%);
    --envelope-color: #ffffff;
    --flap-color: #f1f5f9;
    --letter-color: #ffffff;
    --heart-color: #9b6dff;
    --text-color: #4b5563;
}

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

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

/* Floral Belt Decorations */
.flower-belt {
    position: fixed;
    left: 0;
    bottom: -70px;
    /* Lowered further to avoid covering the letter */
    width: 100%;
    height: 220px;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    z-index: 0;
    /* Keep it behind the envelope and letter */
    overflow: hidden;
    white-space: nowrap;
}

.f-item {
    width: 200px;
    height: 200px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    flex-shrink: 0;
    margin: 0 -40px;
    opacity: 0.9;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.1));
    transition: transform 0.5s ease;
}

.f-item:hover {
    transform: translateY(-10px) scale(1.05);
}

.f1 {
    background-image: url('flower1.png');
}

.f2 {
    background-image: url('flower2.png');
}


/* Envelope Styling */
.container {
    perspective: 1200px;
    z-index: 10;
    width: 100%;
    max-width: 500px;
    display: flex;
    justify-content: center;
}

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

.envelope-wrapper:hover {
    transform: translateY(-8px);
}

.envelope {
    position: relative;
    width: 320px;
    height: 220px;
    background: var(--envelope-color);
    box-shadow: 0 20px 50px rgba(155, 109, 255, 0.15);
    border-radius: 12px;
}

.flap {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 160px solid transparent;
    border-right: 160px solid transparent;
    border-top: 120px solid var(--flap-color);
    transform-origin: top;
    transition: transform 0.5s ease-in-out, z-index 0.2s;
    z-index: 3;
}

.pocket {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 160px solid #f8fafc;
    border-right: 160px solid #f8fafc;
    border-bottom: 110px solid #ffffff;
    border-top: 110px solid transparent;
    z-index: 4;
    border-radius: 0 0 12px 12px;
}

.pocket::after {
    content: '💜';
    position: absolute;
    left: -20px;
    bottom: 35px;
    width: 40px;
    height: 40px;
    background: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    font-size: 20px;
    box-shadow: 0 4px 15px rgba(155, 109, 255, 0.2);
    z-index: 5;
    transition: transform 0.4s ease;
    border: 2px solid var(--soft-purple);
}

.letter {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 300px;
    height: 200px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(5px);
    border-radius: 8px;
    z-index: 2;
    transition: transform 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275), height 0.7s ease, width 0.7s ease, left 0.7s ease, box-shadow 0.7s ease;
    padding: 30px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.letter-content {
    opacity: 0;
    transition: opacity 0.4s ease;
    height: 100%;
    overflow-y: auto;
    padding-right: 10px;
}

.letter-content::-webkit-scrollbar {
    width: 5px;
}

.letter-content::-webkit-scrollbar-thumb {
    background: var(--soft-purple);
    border-radius: 10px;
}

.letter-content h1 {
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    color: var(--deep-purple);
    margin-bottom: 8px;
    text-align: center;
}

.date {
    font-size: 0.9rem;
    color: #94a3b8;
    text-align: center;
    margin-bottom: 25px;
}

.text p {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-color);
    margin-bottom: 18px;
    text-align: justify;
    hyphens: auto;
    text-wrap: pretty;
}

.signature {
    margin-top: 30px;
    font-weight: 700;
    color: var(--deep-purple);
    text-align: right;
    font-size: 1.2rem;
}

/* Open State - Mobile Optimized Dimensions */
.envelope-wrapper.open .flap {
    transform: rotateX(180deg);
    z-index: 1;
}

.envelope-wrapper.open .letter {
    transform: translateY(-220px);
    width: 380px;
    /* Wider than envelope */
    height: 550px;
    left: -30px;
    /* Center adjustment */
    z-index: 5;
    box-shadow: 0 30px 60px rgba(155, 109, 255, 0.25);
    padding: 40px;
}

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

.envelope-wrapper.open .pocket::after {
    transform: scale(0);
}

.instruction {
    text-align: center;
    margin-top: 40px;
    color: var(--deep-purple);
    font-size: 1.1rem;
    font-weight: 700;
    opacity: 0.8;
    animation: bounce 2s infinite;
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-10px);
    }

    60% {
        transform: translateY(-5px);
    }
}

.envelope-wrapper.open .instruction {
    display: none;
}

/* Mobile Optimizations */
@media (max-width: 480px) {
    .envelope {
        width: 280px;
        height: 180px;
    }

    .flap {
        border-left-width: 140px;
        border-right-width: 140px;
        border-top-width: 100px;
    }

    .pocket {
        border-left-width: 140px;
        border-right-width: 140px;
        border-bottom-width: 90px;
        border-top-width: 90px;
    }

    .letter {
        width: 260px;
        height: 160px;
        left: 10px;
        padding: 20px;
    }

    .envelope-wrapper.open .letter {
        width: 90vw;
        height: 70vh;
        left: calc((280px - 90vw) / 2);
        transform: translateY(-240px);
        padding: 30px 20px;
    }

    .letter-content h1 {
        font-size: 1.5rem;
    }

    .text p {
        font-size: 0.95rem;
    }

    .f1,
    .f2 {
        opacity: 0.7;
    }
}