body {
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: #f0ebeF;
    overflow: hidden;
    transition: opacity 0.5s ease-out; /* Para la transición final */
}

/* Clase para la transición de salida */
body.exiting {
    opacity: 0;
}

.envelope-container {
    cursor: pointer;
    perspective: 1000px; /* Habilita la perspectiva 3D */
}

.envelope {
    position: relative;
    width: 320px;
    height: 210px;
    transform-style: preserve-3d;
    transition: transform 1.2s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

.flap {
    position: absolute;
    width: 50%;
    height: 100%;
    background-color: #f7f7f7;
    border: 1px solid #e9e9e9;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.left {
    top: 0;
    left: 0;
    clip-path: polygon(0 0, 100% 50%, 0 100%);
}
.right {
    top: 0;
    right: 0;
    clip-path: polygon(100% 0, 0 50%, 100% 100%);
}
.top {
    width: 100%;
    height: 50%;
    left: 0;
    top: 0;
    transform-origin: top;
    clip-path: polygon(0 0, 100% 0, 50% 100%);
    z-index: 10;
    transition: transform 1s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}
.bottom {
    width: 100%;
    height: 50%;
    left: 0;
    bottom: 0;
    clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.letter {
    position: absolute;
    width: 96%;
    height: 96%;
    top: 2%;
    left: 2%;
    background: white;
    box-shadow: 0 0 20px rgba(0,0,0,0.15);
    z-index: 5;
    transition: transform 1.2s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.8s ease-out;
    transition-delay: 0.5s;
}

.seal {
    position: absolute;
    width: 65px;
    height: 65px;
    background: #9B2226; /* Color Rojo Vino */
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 11;
    box-shadow: 1px 1px 5px rgba(0,0,0,0.2), inset 0 0 8px rgba(0,0,0,0.4);
    transition: opacity 0.5s ease;
}

.seal-initials {
    font-family: 'Playfair Display', serif;
    color: rgba(0,0,0,0.3);
    font-weight: 700;
    font-style: italic;
    font-size: 1.8rem;
    text-shadow: 1px 1px 1px rgba(255,255,255,0.1);
}

.tooltip {
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 5px 10px;
    border-radius: 5px;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 20;
}
.envelope-container:hover .tooltip {
    opacity: 1;
}

/* --- Animaciones de apertura --- */
.envelope.open .top {
    transform: rotateX(180deg);
}
.envelope.open .seal {
    opacity: 0;
}
.envelope.open .letter {
    transform: translateY(-150px) scale(1.1) rotate(2deg);
    opacity: 1;
}
.envelope.open {
    transform: translateY(100px);
}