/* ===================================
   OVERLAY - Модальные оверлеи
   =================================== */

/* Base Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: calc(100vh - 80px);
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-modal-backdrop);
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
    pointer-events: none;
    display: flex;
}

/* Hidden State */
.overlay.hidden {
    display: none;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Show State */
.overlay.show {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

.overlay:not(.hidden) {
    display: flex !important;
    opacity: 1;
}

/* Transparent Background for Theme/Background Selection */
.overlay:has(.background-selection-panel),
.overlay:has(.theme-modal) {
    background: transparent !important;
}

/* Panel Show States */
.overlay.show .inventory-compact-panel,
.overlay.show .shop-compact-panel,
.overlay.show .profile-compact-panel,
.overlay.show .exchange-compact-panel,
.overlay.show .fishing-compact-panel {
    opacity: 1;
}

.overlay.show .settings-compact-panel {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* Achievement/Background Selection Modals */
.achievement-modal,
.background-selection-panel {
    width: 95%;
    max-width: 450px;
    max-height: calc(85vh + 20vh);
    min-height: calc(300px + 60px);
    background: linear-gradient(135deg,
        var(--glass-bg) 0%,
        rgba(255, 255, 255, 0.05) 100%);
    backdrop-filter: var(--blur-md);
    -webkit-backdrop-filter: var(--blur-md);
    border: 1px solid var(--glass-border);
    border-radius: 25px;
    overflow: hidden;
    transform: scale(0.8);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow:
        0 25px 50px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    z-index: var(--z-modal);
    position: relative;
}

.overlay.show .achievement-modal,
.overlay.show .background-selection-panel {
    transform: scale(1);
}

/* Profile Panel Specific */
#profilePanel.show {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    z-index: 100001 !important;
}

/* Currency Modals */
#creditsModal, #gemsModal, #starsModal, #tonModal {
    z-index: var(--z-modal);
}
