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

html,
body {
    width: 100%;
    height: 100%;
    background: #f4f0eb;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.loader {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f4f0eb;
    z-index: 200;
    transition: opacity .6s
}

.loader.hide {
    opacity: 0;
    pointer-events: none
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid #2C2C2C;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin .8s linear infinite
}

@keyframes spin {
    to {
        transform: rotate(360deg)
    }
}

/* Container 9:16 care umple ecranul */
.scene-wrapper {
    width: 100vw;
    height: 100svh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f4f0eb;
}

.envelope-scene {
    position: relative;
    width: 100%;
    height: 100%;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
    overflow: visible;
}

/* Pe Desktop păstrăm un aspect elegant de telefon (9:16) */
@media (min-width: 768px) {
    .envelope-scene {
        width: 100vw;
        height: 100svh;
        max-width: calc(100svh * 9 / 16);
        max-height: calc(100vw * 16 / 9);
    }
}

/* ====== LAYERE PLIC ====== */

.layer-plic {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.layer-plic img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block
}

.layer-inv {
    position: absolute;
    left: 1%;
    right: 1%;
    top: 8%;
    bottom: 2%;
    z-index: 2;
    background: #ffffff;
    border-radius: 3px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.layer-inv img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
}

/* Masca z:3 */
.layer-masca {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
}

.layer-masca img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block
}

/* Clapa z:4 */
.layer-flap {
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    z-index: 4;
    transform-origin: top center;
    transform-style: preserve-3d;
    overflow: visible;
}

.layer-flap img {
    width: 100%;
    height: auto;
    display: block;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.15));
}

/* Conținut suprapus pe clapetă — zona roșie (jumătatea superioară a clapetei) */
.flap-content {
    position: absolute;
    top: 18%;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    pointer-events: none;
    z-index: 5;
}

.flap-names {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-weight: 500;
    font-size: clamp(22px, 6vw, 34px);
    color: #5a4a3a;
    letter-spacing: 1px;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.4);
}

.wedding-date {
    font-family: 'Outfit', sans-serif;
    font-size: clamp(11px, 2.8vw, 15px);
    font-weight: 400;
    color: #7a6a5a;
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* "DESCHIDE" cu Icon */
.hint {
    position: absolute;
    bottom: 6%;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 6;
    transition: opacity .4s;
}

.tap-icon {
    width: 32px;
    height: 32px;
    color: #8a7a6a;
    animation: pulse-tap 1.5s ease-in-out infinite;
}

@keyframes pulse-tap {

    0%,
    100% {
        transform: translateY(0) scale(1);
        opacity: 0.8;
    }

    50% {
        transform: translateY(-6px) scale(1.1);
        opacity: 1;
    }
}

.hint span {
    font-family: "Cormorant Garamond", serif;
    font-style: italic;
    font-size: 14px;
    letter-spacing: 3px;
    color: #8a7a6a;
}

.hint.hidden {
    opacity: 0
}

/* Particule */
.particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;
    overflow: visible
}

.particle {
    position: absolute;
    border-radius: 50%;
    opacity: 0;
    animation: pfly var(--dur) var(--del) forwards ease-out
}

@keyframes pfly {
    0% {
        opacity: 0;
        transform: translate(0, 0) scale(0)
    }

    25% {
        opacity: 1;
        transform: translate(var(--x1), var(--y1)) scale(1.5)
    }

    100% {
        opacity: 0;
        transform: translate(var(--x2), var(--y2)) scale(.2)
    }
}

/* Buton închidere */
.close-btn {
    position: fixed;
    top: 18px;
    right: 18px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid rgba(44, 44, 44, .25);
    background: rgba(255, 255, 255, .85);
    backdrop-filter: blur(8px);
    font-size: 18px;
    color: #2C2C2C;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .4s, background .2s;
    z-index: 110;
}

.close-btn.visible {
    opacity: 1;
    pointer-events: all;
}

.close-btn:hover {
    background: #fff;
}

/* Muzică Control */
.music-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(201, 169, 110, 0.3);
    color: #3a2e22;
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

.music-toggle:active {
    transform: scale(0.9);
}