/* ========================================
   TREASURE HUNTER VFX OVERHAUL
   Premium Box Opening Animations
   ======================================== */

/* Full Screen Modal Overlay */
#lootOpeningModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    background: radial-gradient(circle at center, #1a1a24 0%, #000000 100%);
    z-index: 20000 !important;
    /* Above everything */
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    overflow: hidden;
}

/* The Scene Container */
.loot-opening-scene {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

/* Background Rays/Glow */
#lootGlow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200vw;
    height: 200vw;
    background: conic-gradient(from 0deg, transparent 0%, rgba(255, 215, 0, 0.1) 10%, transparent 20%, rgba(255, 215, 0, 0.1) 30%, transparent 40%, rgba(255, 215, 0, 0.1) 50%, transparent 60%, rgba(255, 215, 0, 0.1) 70%, transparent 80%, rgba(255, 215, 0, 0.1) 90%, transparent 100%);
    animation: rotateRays 10s linear infinite;
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

@keyframes rotateRays {
    from {
        transform: translate(-50%, -50%) rotate(0deg);
    }

    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Chest Image */
#lootBoxImage,
.loot-box-display {
    width: 280px;
    height: 280px;
    object-fit: contain;
    position: relative;
    z-index: 2;
    filter: drop-shadow(0 0 20px rgba(0, 0, 0, 0.8));
    transition: all 0.3s ease;
}

/* Shaking Animation (Anticipation) */
#lootBoxImage.shaking,
.loot-box-display.shaking {
    animation: intenseShake 0.5s cubic-bezier(.36, .07, .19, .97) both infinite;
}

@keyframes intenseShake {

    10%,
    90% {
        transform: translate3d(-2px, 0, 0) rotate(-1deg);
    }

    20%,
    80% {
        transform: translate3d(4px, 0, 0) rotate(2deg);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-6px, 0, 0) rotate(-2deg);
    }

    40%,
    60% {
        transform: translate3d(6px, 0, 0) rotate(2deg);
    }
}

/* Flash Effect (Explosion) */
#lootFlash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    opacity: 0;
    pointer-events: none;
    z-index: 20001;
    transition: opacity 0.1s ease-out;
}

#lootFlash.active {
    opacity: 1;
}

/* Reward Container */
#lootReward {
    position: relative;
    top: auto;
    left: auto;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding: 2rem;
    border-radius: 20px;
    background: rgba(20, 20, 30, 0.9);
    backdrop-filter: blur(20px);
    border: 2px solid var(--tier-color, #ffd700);
    box-shadow:
        0 0 30px rgba(0, 0, 0, 0.8),
        0 0 50px var(--tier-color, rgba(255, 215, 0, 0.3)),
        inset 0 0 20px var(--tier-color, rgba(255, 215, 0, 0.1));
    transform: scale(0.8);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-width: 90vw;
    text-align: center;
}

#lootReward:not(.hidden) {
    transform: scale(1);
    opacity: 1;
    animation: rewardPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes rewardPop {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    50% {
        transform: scale(1.1);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Reward Content styling */
.reward-icon {
    width: 100px;
    height: 100px;
    object-fit: contain;
    filter: drop-shadow(0 0 15px var(--tier-color, #ffd700));
    animation: floatIcon 3s ease-in-out infinite;
}

@keyframes floatIcon {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.reward-name {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--tier-color, #ffd700);
    text-transform: uppercase;
    text-shadow: 0 0 10px var(--tier-color, rgba(255, 215, 0, 0.5));
    margin: 0;
}

.reward-rarity {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1rem;
    color: #ccc;
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* Continue Button */
.btn-continue,
#continueFromLoot {
    margin-top: 1rem;
    background: linear-gradient(90deg, #ffd700, #ffaa00);
    border: none;
    padding: 0.75rem 3rem;
    border-radius: 50px;
    color: #000;
    font-weight: 900;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
    transition: all 0.3s ease;
    text-transform: uppercase;
}

.btn-continue:hover,
#continueFromLoot:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.6);
}

/* Mobile Responsiveness & Centering Fix */
@media (max-width: 768px) {

    #lootBoxImage,
    .loot-box-display {
        width: 180px;
        height: 180px;
    }

    #lootReward {
        /* FORCE CENTERING ON MOBILE */
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        margin: 0 !important;

        width: 85vw !important;
        max-width: 320px !important;
        padding: 1.5rem;
        gap: 1rem;
        z-index: 20002 !important;
    }

    /* Animation override for centering to work */
    #lootReward:not(.hidden) {
        animation: none !important;
        /* Disable conflicting animation */
        opacity: 1 !important;
        transform: translate(-50%, -50%) scale(1) !important;
    }

    /* Add simple fade in instead of complex pop that breaks transform */
    #lootReward.hidden {
        display: none !important;
    }

    .reward-icon {
        width: 80px;
        height: 80px;
    }

    .reward-name {
        font-size: 1.25rem;
    }
}