.page-loader {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    /*background-image: url('../bg/loader.png'); */
    background-image: url('../bg/loader.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    opacity: 1;
    transition: opacity 0.6s ease;
    perspective: 1000px;
}

.page-loader.fade-out {
    opacity: 0;
}

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

.envelope {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.8s ease;
    transform-style: preserve-3d;
}

.envelope.open {
    transform: rotateX(180deg);
    opacity: 0;
}

.envelope-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.loader-text {
    font-size: 1.4rem;
    letter-spacing: 2px;
    color: var(--gold-brown);
    margin-top: 20px;
    opacity: 1;
    transition: opacity 0.6s ease;
}

.loader-text.fade-out {
    opacity: 0;
}

.loader-ring {
    width: 60px;
    height: 60px;
    border: 3px solid rgba(139, 115, 85, 0.2);
    border-top: 3px solid var(--gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    transition: opacity 0.6s ease;
    position: relative;
}

.loader-ring::before {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.1) 0%, transparent 70%);
    animation: sparklePulse 2s ease-in-out infinite;
}

.loader-ring::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 4px;
    background: var(--gold);
    border-radius: 50%;
    animation: sparkleBurst 3s ease-in-out infinite;
}

.loader-ring.fade-out {
    opacity: 0;
    animation: none;
}

/* ENTER BUTTON */
.enter-btn {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 12px 30px;
    border: 1px solid var(--gold);
    background: transparent;
    color: var(--gold);
    font-family: 'Playfair Display', serif;
    text-transform: uppercase;
    letter-spacing: 2px;
    cursor: pointer;
    transition: opacity 0.6s ease;
    z-index: 9999;
    display: block;
    opacity: 0;
}

.enter-btn.fade-in {
    opacity: 1;
}

.enter-btn.fade-out {
    opacity: 0;
}

.enter-btn.hidden {
    display: none !important;
}

.enter-btn:hover:not(.fade-out) {
    background: var(--gold);
    color: white;
}

/* MAGICAL SPARKLE EFFECTS */
.sparkles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.sparkle {
    position: absolute;
    width: 2px;
    height: 2px;
    background: var(--regal-gold);
    border-radius: 50%;
    opacity: 0;
    animation: sparkleFloat 4s ease-in-out infinite;
}

.sparkle:nth-child(1) { animation-delay: 0s; left: 20%; top: 30%; }
.sparkle:nth-child(2) { animation-delay: 0.5s; left: 80%; top: 20%; }
.sparkle:nth-child(3) { animation-delay: 1s; left: 40%; top: 80%; }
.sparkle:nth-child(4) { animation-delay: 1.5s; left: 70%; top: 60%; }
.sparkle:nth-child(5) { animation-delay: 2s; left: 10%; top: 70%; }
.sparkle:nth-child(6) { animation-delay: 2.5s; left: 90%; top: 40%; }
.sparkle:nth-child(7) { animation-delay: 3s; left: 30%; top: 10%; }
.sparkle:nth-child(8) { animation-delay: 3.5s; left: 60%; top: 90%; }
.sparkle:nth-child(9) { animation-delay: 0.2s; left: 15%; top: 50%; }
.sparkle:nth-child(10) { animation-delay: 0.7s; left: 85%; top: 75%; }
.sparkle:nth-child(11) { animation-delay: 1.2s; left: 50%; top: 15%; }
.sparkle:nth-child(12) { animation-delay: 1.7s; left: 25%; top: 85%; }
.sparkle:nth-child(13) { animation-delay: 2.2s; left: 75%; top: 35%; }
.sparkle:nth-child(14) { animation-delay: 2.7s; left: 5%; top: 25%; }
.sparkle:nth-child(15) { animation-delay: 3.2s; left: 95%; top: 65%; }
.sparkle:nth-child(17) { animation-delay: 0.3s; left: 35%; top: 45%; animation: sparkleTwinkle 3s ease-in-out infinite; }
.sparkle:nth-child(18) { animation-delay: 1.1s; left: 65%; top: 55%; animation: sparkleTwinkle 3s ease-in-out infinite; }
.sparkle:nth-child(19) { animation-delay: 2.3s; left: 55%; top: 25%; animation: sparkleTwinkle 3s ease-in-out infinite; }
.sparkle:nth-child(20) { animation-delay: 3.1s; left: 45%; top: 75%; animation: sparkleTwinkle 3s ease-in-out infinite; }

.sparkle.large {
    width: 4px;
    height: 4px;
    box-shadow: 0 0 6px var(--gold-yellow), 0 0 12px var(--gold-yellow);
}

.sparkle.medium {
    width: 3px;
    height: 3px;
    box-shadow: 0 0 4px var(--regal-gold);
}

.sparkle.small {
    width: 1px;
    height: 1px;
    box-shadow: 0 0 2px var(--gold);
}

.sparkle.star {
    width: 6px;
    height: 6px;
    background: transparent;
    box-shadow: none;
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    background: var(--gold-yellow);
    animation: sparkleTwinkle 3s ease-in-out infinite;
}

.sparkle.star::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    background: inherit;
    clip-path: inherit;
    animation: sparkleRotate 4s linear infinite;
}

/* Burst effect for button appearance */
.burst-sparkles {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    pointer-events: none;
    opacity: 0;
    display: none;
    animation: burstEffect 0.8s ease-out forwards;
}

.burst-sparkle {
    position: absolute;
    width: 3px;
    height: 3px;
    background: var(--regal-gold);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--gold-yellow);
    opacity: 0;
}

.burst-sparkle.large {
    width: 5px;
    height: 5px;
    box-shadow: 0 0 8px var(--gold-yellow), 0 0 16px var(--gold-yellow);
}

.burst-sparkle.medium {
    width: 4px;
    height: 4px;
    box-shadow: 0 0 6px var(--regal-gold);
}

.burst-sparkle.star {
    width: 8px;
    height: 8px;
    background: transparent;
    box-shadow: none;
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    background: var(--gold-yellow);
    animation: sparkleTwinkle 1.5s ease-in-out infinite;
}

.burst-sparkle.star::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    background: inherit;
    clip-path: inherit;
    animation: sparkleRotate 2s linear infinite;
}

.burst-sparkle:nth-child(1) { 
    top: 50%; left: 50%; 
    --tx: 0px; --ty: -80px;
    animation: burstParticle 1.2s ease-out forwards;
    animation-delay: 0s;
}
.burst-sparkle:nth-child(2) { 
    top: 30%; left: 70%; 
    --tx: 60px; --ty: -50px;
    animation: burstParticle 1.2s ease-out forwards;
    animation-delay: 0.05s;
}
.burst-sparkle:nth-child(3) { 
    top: 70%; left: 30%; 
    --tx: -60px; --ty: 50px;
    animation: burstParticle 1.2s ease-out forwards;
    animation-delay: 0.1s;
}
.burst-sparkle:nth-child(4) { 
    top: 20%; left: 40%; 
    --tx: -40px; --ty: -70px;
    animation: burstParticle 1.2s ease-out forwards;
    animation-delay: 0.15s;
}
.burst-sparkle:nth-child(5) { 
    top: 80%; left: 60%; 
    --tx: 40px; --ty: 70px;
    animation: burstParticle 1.2s ease-out forwards;
    animation-delay: 0.2s;
}
.burst-sparkle:nth-child(6) { 
    top: 40%; left: 80%; 
    --tx: 70px; --ty: -30px;
    animation: burstParticle 1.2s ease-out forwards;
    animation-delay: 0.25s;
}
.burst-sparkle:nth-child(7) { 
    top: 60%; left: 20%; 
    --tx: -70px; --ty: 30px;
    animation: burstParticle 1.2s ease-out forwards;
    animation-delay: 0.3s;
}
.burst-sparkle:nth-child(8) { 
    top: 10%; left: 90%; 
    --tx: 80px; --ty: -40px;
    animation: burstParticle 1.2s ease-out forwards;
    animation-delay: 0.35s;
}
.burst-sparkle:nth-child(9) { 
    top: 25%; left: 25%; 
    --tx: -50px; --ty: -60px;
    animation: burstParticle 1.2s ease-out forwards;
    animation-delay: 0.4s;
}
.burst-sparkle:nth-child(10) { 
    top: 75%; left: 75%; 
    --tx: 50px; --ty: 60px;
    animation: burstParticle 1.2s ease-out forwards;
    animation-delay: 0.45s;
}
.burst-sparkle:nth-child(11) { 
    top: 15%; left: 65%; 
    --tx: 30px; --ty: -75px;
    animation: burstParticle 1.2s ease-out forwards;
    animation-delay: 0.5s;
}
.burst-sparkle:nth-child(12) { 
    top: 85%; left: 35%; 
    --tx: -30px; --ty: 75px;
    animation: burstParticle 1.2s ease-out forwards;
    animation-delay: 0.55s;
}
.burst-sparkle:nth-child(13) { 
    top: 35%; left: 15%; 
    --tx: -75px; --ty: -25px;
    animation: burstParticle 1.2s ease-out forwards;
    animation-delay: 0.6s;
}
.burst-sparkle:nth-child(14) { 
    top: 65%; left: 85%; 
    --tx: 75px; --ty: 25px;
    animation: burstParticle 1.2s ease-out forwards;
    animation-delay: 0.65s;
}
.burst-sparkle:nth-child(15) { 
    top: 5%; left: 50%; 
    --tx: 0px; --ty: -90px;
    animation: burstParticle 1.2s ease-out forwards;
    animation-delay: 0.7s;
}
.burst-sparkle:nth-child(16) { 
    top: 95%; left: 50%; 
    --tx: 0px; --ty: 90px;
    animation: burstParticle 1.2s ease-out forwards;
    animation-delay: 0.75s;
}
.burst-sparkle:nth-child(17) { 
    top: 45%; left: 45%; 
    --tx: -20px; --ty: -85px;
    animation: burstParticle 1.2s ease-out forwards;
    animation-delay: 0.8s;
}
.burst-sparkle:nth-child(18) { 
    top: 55%; left: 55%; 
    --tx: 20px; --ty: 85px;
    animation: burstParticle 1.2s ease-out forwards;
    animation-delay: 0.85s;
}
.burst-sparkle:nth-child(19) { 
    top: 30%; left: 50%; 
    --tx: 0px; --ty: -95px;
    animation: burstParticle 1.2s ease-out forwards;
    animation-delay: 0.9s;
}
.burst-sparkle:nth-child(20) { 
    top: 70%; left: 50%; 
    --tx: 0px; --ty: 95px;
    animation: burstParticle 1.2s ease-out forwards;
    animation-delay: 0.95s;
}

/* ---------------------------------
   FADING INVITATION
---------------------------------- */
#invitation {
  opacity: 0;
  transform: translateY(20px);
  filter: blur(12px);
  transition: 
    opacity 1.2s ease,
    transform 1.2s ease,
    filter 1.2s ease;
}

#invitation.visible {
  opacity: 1;
  transform: translateY(0);
  filter: blur(0);
}

/* ---------------------------------
   FLOATING MUSIC BUTTON
---------------------------------- */

.music-toggle {
    position: fixed;
    bottom: 90px;
    right: 20px;
    top: auto;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--gold), var(--gray-green));
    color: white;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.music-toggle:hover {
    transform: scale(1.1);
}

.music-toggle.paused {
    opacity: 0.6;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes sparklePulse {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.2);
    }
}

@keyframes sparkleBurst {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.5);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0);
    }
}

@keyframes sparkleFloat {
    0% {
        opacity: 0;
        transform: translateY(0) scale(0);
    }
    10% {
        opacity: 1;
        transform: translateY(-20px) scale(1);
    }
    90% {
        opacity: 1;
        transform: translateY(-40px) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-60px) scale(0);
    }
}

@keyframes burstEffect {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
}

@keyframes sparkleTwinkle {
    0%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

@keyframes sparkleRotate {
    from {
        transform: translate(-50%, -50%) rotate(0deg);
    }
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

@keyframes burstParticle {
    0% {
        opacity: 0;
        transform: translate(0, 0) scale(0);
    }
    20% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(var(--tx, 50px), var(--ty, -50px)) scale(0);
    }
}