* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Georgia', serif;
    background: radial-gradient(ellipse at center, #3d1f3a 0%, #2a1525 50%, #1a0e18 100%);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    color: #f0ddd0;
}

/* ============================================
   INTRO OVERLAY + BUSTA
   ============================================ */
.intro-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, #3d1f3a 0%, #2a1525 50%, #1a0e18 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    transition: opacity 1.2s ease, visibility 1.2s ease;
    overflow: hidden;
}

#introCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.intro-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.envelope-wrapper {
    text-align: center;
    z-index: 2;
    position: relative;
}

/* === BUSTA === */
.envelope {
    position: relative;
    width: 380px;
    height: 240px;
    margin: 0 auto;
    cursor: pointer;
    transition: transform 0.4s ease;
    filter: drop-shadow(0 8px 20px rgba(0,0,0,0.18));
    animation: envelopeWiggle 2.5s ease-in-out infinite;
}

.envelope:hover {
    transform: scale(1.04) translateY(-4px);
    animation: none;
}

@keyframes envelopeWiggle {
    0%, 100% { transform: rotate(0deg) scale(1); }
    15% { transform: rotate(-3deg) scale(1.02); }
    30% { transform: rotate(3deg) scale(1.02); }
    45% { transform: rotate(-2deg) scale(1.01); }
    60% { transform: rotate(2deg) scale(1.01); }
    75% { transform: rotate(-1deg); }
    90% { transform: rotate(0deg); }
}

.envelope-body {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 50% 40%,
            rgba(255,255,255,0.45) 0%,
            rgba(255,255,255,0.15) 25%,
            rgba(255,255,255,0) 60%
        ),
        radial-gradient(circle at 20% 80%, #ffd6dc 0%, transparent 60%),
        radial-gradient(circle at 80% 20%, #ffc0cb 0%, transparent 60%),
        linear-gradient(
            135deg,
            #ffe9ee 0%,
            #ffd6dc 30%,
            #ffc0cb 55%,
            #f4a7b9 75%,
            #e891a4 100%
        );
    border-radius: 14px;
    z-index: 2;
    box-shadow:
        inset 0 2px 10px rgba(255,255,255,0.6),
        inset 0 -4px 12px rgba(180,80,100,0.15);
}

.envelope-flap {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 140px;
    z-index: 4;
    transform-origin: top center;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    clip-path: polygon(4% 0, 50% 100%, 96% 0);
    background:
        radial-gradient(circle at 50% 30%,
            rgba(255,255,255,0.35) 0%,
            rgba(255,255,255,0) 50%
        ),
        linear-gradient(
            180deg,
            #ffe9ee 0%,
            #ffd6dc 40%,
            #f4a7b9 100%
        );
    border-radius: 14px 14px 0 0;
}

.envelope.open .envelope-flap {
    transform: rotateX(180deg);
    z-index: 0;
}

.envelope.open {
    animation: none;
    transform: scale(1);
}

.envelope-front {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    overflow: hidden;
    border-radius: 14px;
}

.envelope-fold-left {
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    height: 100%;
    background:
        radial-gradient(circle at 30% 60%,
            rgba(255,255,255,0.25) 0%,
            transparent 50%
        ),
        linear-gradient(145deg, #ffd6dc 0%, #f4a7b9 60%, #e891a4 100%);
    clip-path: polygon(0 0, 100% 50%, 0 100%);
}

.envelope-fold-right {
    position: absolute;
    top: 0;
    right: 0;
    width: 50%;
    height: 100%;
    background:
        radial-gradient(circle at 70% 60%,
            rgba(255,255,255,0.25) 0%,
            transparent 50%
        ),
        linear-gradient(215deg, #ffd6dc 0%, #f4a7b9 60%, #e891a4 100%);
    clip-path: polygon(100% 0, 0 50%, 100% 100%);
}

.envelope-heart {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 65px;
    height: 60px;
    z-index: 10;
    animation: heartPulse 2s ease-in-out infinite;
    filter: drop-shadow(0 5px 15px rgba(150, 30, 50, 0.5));
}

.envelope-heart::before,
.envelope-heart::after {
    content: "";
    position: absolute;
    top: 0;
    width: 33px;
    height: 50px;
    background: linear-gradient(180deg, #b5394a 0%, #8c1c2d 100%);
    border-radius: 33px 33px 0 0;
}

.envelope-heart::before {
    left: 33px;
    transform: rotate(-45deg);
    transform-origin: 0 100%;
}

.envelope-heart::after {
    left: 0;
    transform: rotate(45deg);
    transform-origin: 100% 100%;
}

@keyframes heartPulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.12); }
}

/* Lettera */
.letter {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 320px;
    height: 210px;
    background: linear-gradient(180deg, #f7f0e3 0%, #ede0cb 100%);
    border-radius: 8px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
    z-index: 1;
    opacity: 0;
    transition: transform 1s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.5s ease;
    transition-delay: 0s;
    padding: 30px;
}

.letter-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: opacity 0.5s ease;
}

.letter-title {
    font-size: 2rem;
    color: #8c1c2d;
    font-style: italic;
    font-weight: bold;
    font-family: 'Georgia', serif;
    margin-bottom: 10px;
}

.letter-line {
    width: 80%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #c8b8a0, transparent);
    border-radius: 2px;
}

.letter-line.short {
    width: 50%;
}

/* Step 1: lettera sale dalla busta */
.envelope.open .letter {
    transform: translate(-50%, -180%);
    opacity: 1;
    transition-delay: 0.4s;
}

/* Step 2: lettera rientra nella busta */
.envelope.open .letter.returning {
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: transform 1s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.6s ease 0.4s !important;
    transition-delay: 0s !important;
}

/* ============================================
   PAGINA PRINCIPALE
   ============================================ */

/* Canvas cuoricini */
#heartsCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

/* Container */
.container {
    position: relative;
    z-index: 2;
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 20px;
}



@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}


.heart {
    position: relative;
    width: 140px;
    height: 140px;
    animation: heartbeat 1.5s ease-in-out infinite;
}

.heart::before,
.heart::after {
    content: "";
    position: absolute;
    top: 0;
    width: 70px;
    height: 112px;
    background: linear-gradient(135deg, #c97b84 0%, #a05a68 100%);
    border-radius: 70px 70px 0 0;
    box-shadow: 0 0 40px rgba(169, 90, 104, 0.6);
}

.heart::before {
    left: 70px;
    transform: rotate(-45deg);
    transform-origin: 0 100%;
}

.heart::after {
    left: 0;
    transform: rotate(45deg);
    transform-origin: 100% 100%;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.1); }
    50% { transform: scale(1); }
    75% { transform: scale(1.15); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Messaggio */
.message {
    text-align: center;
    margin: 35px 0;
    animation: fadeInUp 1.5s ease-out;
}

.main-message {
    font-size: 1.8rem;
    color: #e8b4a0;
    text-shadow: 0 0 20px rgba(200, 140, 110, 0.4);
    margin-bottom: 12px;
    font-style: italic;
}

.sub-message {
    font-size: 1.3rem;
    color: #c99a8e;
    text-shadow: 0 0 15px rgba(200, 140, 110, 0.3);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Galleria Polaroid — stile Instax Mini */
.polaroid-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin: 40px 0;
    padding: 5px;
}

.polaroid {
    background: #f7f0e3;
    padding: 8px 8px 40px 8px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    transform: rotate(var(--rotation));
    transition: all 0.4s ease;
    cursor: pointer;
    animation: fadeInScale var(--delay) ease-out;
    animation-fill-mode: backwards;
    border-radius: 3px;
    aspect-ratio: auto;
}

@keyframes fadeInScale {
    from { opacity: 0; transform: rotate(var(--rotation)) scale(0.5); }
    to { opacity: 1; transform: rotate(var(--rotation)) scale(1); }
}

.polaroid:hover {
    transform: rotate(0deg) scale(1.05);
    box-shadow: 0 15px 50px rgba(169, 90, 104, 0.5);
    z-index: 10;
}

.polaroid-image {
    width: 100%;
    aspect-ratio: 6 / 7;
    overflow: hidden;
    background: #2a1525;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
}

.polaroid-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.polaroid-caption {
    text-align: center;
    margin-top: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    color: #6b4a4a;
    font-weight: bold;
    letter-spacing: 0.5px;
}

/* Bottone */
.love-button {
    display: block;
    margin: 40px auto;
    padding: 16px 40px;
    font-size: 1.2rem;
    background: linear-gradient(135deg, #c97b84, #a05a68);
    color: #fff;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 8px 30px rgba(169, 90, 104, 0.5);
    transition: all 0.3s ease;
    font-family: 'Georgia', serif;
    animation: pulse 2s ease-in-out infinite;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.love-button:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 40px rgba(169, 90, 104, 0.7);
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 8px 30px rgba(169, 90, 104, 0.5); }
    50% { box-shadow: 0 8px 40px rgba(169, 90, 104, 0.8); }
}

/* ============================================
   POPUP SORPRESA — slide da destra
   ============================================ */
.surprise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 5, 15, 0.7);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    backdrop-filter: blur(4px);
}

.surprise-overlay.active {
    opacity: 1;
    visibility: visible;
}

.surprise-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 85%;
    max-width: 420px;
    height: 100%;
    background: linear-gradient(180deg, #3d1f3a 0%, #2a1525 50%, #1a0e18 100%);
    z-index: 9999;
    transform: translateX(100%);
    transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 40px 30px;
    box-shadow: -10px 0 50px rgba(0, 0, 0, 0.5);
    overflow-y: auto;
}

.surprise-panel.active {
    transform: translateX(0);
}

/* .surprise-heart-icon {
    font-size: 5rem;
    margin-bottom: 25px;
    animation: heartbeat 1.5s ease-in-out infinite;
    filter: drop-shadow(0 0 30px rgba(200, 100, 100, 0.6));
    line-height: 1;
} */

.surprise-panel h2 {
    font-size: 1.8rem;
    color: #e8b4a0;
    text-align: center;
    margin-bottom: 15px;
    text-shadow: 0 0 20px rgba(200, 120, 100, 0.5);
    flex-shrink: 0;
}

.surprise-panel h2:first-child {
    margin-top: auto;
}

.surprise-panel p {
    font-size: 1.1rem;
    color: #c99a8e;
    text-align: center;
    margin-bottom: 30px;
    line-height: 1.7;
    flex-shrink: 0;
}

.surprise-image {
    width: 80%;
    max-width: 280px;
    margin-bottom: 20px;
    border-radius: 12px;
    overflow: visible;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    border: 4px solid rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
}

.surprise-image img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
}

.surprise-close {
    padding: 14px 40px;
    font-size: 1.1rem;
    background: linear-gradient(135deg, #c97b84, #a05a68);
    color: white;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    font-family: 'Georgia', serif;
    box-shadow: 0 5px 20px rgba(169, 90, 104, 0.5);
    transition: all 0.3s ease;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
    margin-bottom: auto;
}

.surprise-close:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 30px rgba(169, 90, 104, 0.7);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .container {
        padding: 25px 15px;
    }

    .heart {
        width: 100px;
        height: 100px;
    }

    .heart::before,
    .heart::after {
        width: 50px;
        height: 80px;
        border-radius: 50px 50px 0 0;
    }

    .heart::before {
        left: 50px;
    }


    .message {
        margin: 20px 0;
    }

    .main-message {
        font-size: 1.3rem;
    }

    .sub-message {
        font-size: 1rem;
    }

    .polaroid-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        margin: 25px 0;
        padding: 0;
    }

    .polaroid {
        padding: 6px 6px 30px 6px;
        width: 100%;
    }

    .polaroid-image {
        aspect-ratio: 6 / 7;
    }

    .polaroid-caption {
        font-size: 0.65rem;
        margin-top: 6px;
    }

    .love-button {
        font-size: 1.05rem;
        padding: 14px 32px;
        margin: 30px auto;
    }

    /* Busta mobile */
    .envelope {
        width: 280px;
        height: 180px;
    }

    .envelope-wrapper {
        padding-top: 50px;
    }

    .envelope-flap {
        height: 105px;
    }

    .envelope.open .letter {
        transform: translate(-50%, -155%);
    }

    .letter {
        width: 240px;
        height: 150px;
        padding: 18px;
    }

    .letter-title {
        font-size: 1.4rem;
    }

    .envelope-heart {
        width: 45px;
        height: 42px;
    }

    .envelope-heart::before,
    .envelope-heart::after {
        width: 23px;
        height: 36px;
        border-radius: 23px 23px 0 0;
    }

    .envelope-heart::before {
        left: 23px;
    }

    /* Sorpresa mobile */
    .surprise-panel {
        width: 100%;
        max-width: 100%;
        padding: 30px 25px;
        padding-top: 40px;
    }

    .surprise-panel h2:first-child {
        margin-top: 0;
    }

    .surprise-image {
        width: 90%;
        max-width: 100%;
        flex-shrink: 0;
    }

    /* .surprise-heart-icon {
        font-size: 4rem;
    } */

    .surprise-panel h2 {
        font-size: 1.5rem;
    }

    .surprise-panel p {
        font-size: 1rem;
    }
}

@media (max-width: 400px) {
    .heart {
        width: 80px;
        height: 80px;
    }

    .heart::before,
    .heart::after {
        width: 40px;
        height: 64px;
        border-radius: 40px 40px 0 0;
    }

    .heart::before {
        left: 40px;
    }

    .main-message {
        font-size: 1.15rem;
    }

    .sub-message {
        font-size: 0.95rem;
    }

    .envelope {
        width: 240px;
        height: 155px;
    }

    .envelope-flap {
        height: 90px;
    }

    .letter {
        width: 210px;
        height: 130px;
        padding: 14px;
    }

    .letter-title {
        font-size: 1.2rem;
    }

    .envelope.open .letter {
        transform: translate(-50%, -145%);
    }

    .envelope-heart {
        width: 38px;
        height: 35px;
    }

    .envelope-heart::before,
    .envelope-heart::after {
        width: 19px;
        height: 30px;
        border-radius: 19px 19px 0 0;
    }

    .envelope-heart::before {
        left: 19px;
    }

    .love-button {
        font-size: 1rem;
        padding: 12px 28px;
    }
}
