/* ===== CUSTOM POPUP ===== */
.mafia-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.82);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.22s ease;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    will-change: opacity;
    backface-visibility: hidden;
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    box-sizing: border-box;
    overflow-y: auto;
}

.mafia-popup-overlay.active {
    opacity: 1;
}

.mafia-popup {
    background: var(--card-bg, linear-gradient(145deg, #2a1e14, #1a120b));
    border: 2px solid var(--border-color, #b89b7a);
    border-radius: 16px;
    padding: 28px 26px 22px;
    max-width: 420px;
    width: 92%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.85);
    text-align: center;
    position: relative;
    opacity: 0;
    transform: scale(0.92) translateY(12px);
    transition: opacity 0.24s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
    will-change: opacity, transform;
    backface-visibility: hidden;
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
    margin: auto;
}

.mafia-popup-overlay.active .mafia-popup {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.mafia-popup.mafia-popup-modal {
    /* Modal class for distinguishing from other popup types */
}

.mafia-popup-icon {
    font-size: 52px;
    margin-bottom: 10px;
    line-height: 1;
    display: block;
    filter: drop-shadow(0 0 12px rgba(255,215,0,0.25));
}

.mafia-popup-title {
    font-size: 20px;
    font-weight: 900;
    color: var(--accent, #ffd700);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 3px;
    text-shadow: 0 0 20px rgba(255,215,0,0.25);
}

.mafia-popup-message {
    font-size: 15px;
    color: var(--text-color, #e0d3b0);
    margin-bottom: 22px;
    line-height: 1.6;
    opacity: 0.92;
    white-space: normal;
    overflow-wrap: anywhere;
}

.mafia-popup-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
}

.mafia-popup-btn {
    padding: 10px 26px;
    font-size: 14px;
    border: 2px solid;
    border-radius: 9px;
    cursor: pointer;
    font-weight: 900;
    font-family: 'Mafia', 'Cinzel', serif;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    transition: all 0.18s ease;
    min-width: 110px;
}

.mafia-popup-btn.ok {
    background: var(--btn-bg, rgba(42,26,14,0.9));
    border-color: var(--border-color, #b89b7a);
    color: var(--text-color, #e0d3b0);
}

.mafia-popup-btn.ok:hover {
    background: var(--border-color, #b89b7a);
    color: #100a04;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(var(--border-color-rgb, 184,155,122), 0.45);
}

.mafia-popup-btn.popup-btn-danger {
    background: rgba(160,30,30,0.12);
    border-color: rgba(200,60,60,0.55);
    color: #e05050;
}

.mafia-popup-btn.popup-btn-danger:hover {
    background: rgba(200,50,50,0.88);
    border-color: #e04040;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(200,50,50,0.4);
}

.mafia-popup-btn.popup-btn-success {
    background: rgba(30,130,50,0.12);
    border-color: rgba(60,180,80,0.55);
    color: #4caf50;
}

.mafia-popup-btn.popup-btn-success:hover {
    background: rgba(50,160,70,0.88);
    border-color: #4caf50;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(50,160,70,0.4);
}

.chest-popup,
.angel-game-popup,
.door-popup-content {
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
}

/* ─── Win/Loss notification popups ─── */
.mafia-popup.popup-win {
    border-color: #4caf50;
    box-shadow: 0 0 0 1px rgba(76,175,80,0.15), 0 20px 60px rgba(0,0,0,0.85), 0 0 30px rgba(76,175,80,0.12);
}

.mafia-popup.popup-win .mafia-popup-title {
    color: #4caf50;
    text-shadow: 0 0 20px rgba(76,175,80,0.3);
}

.mafia-popup.popup-loss {
    border-color: #e05050;
    box-shadow: 0 0 0 1px rgba(224,80,80,0.1), 0 20px 60px rgba(0,0,0,0.85);
}

.mafia-popup.popup-loss .mafia-popup-title {
    color: #e05050;
    text-shadow: 0 0 20px rgba(224,80,80,0.3);
}

@keyframes popOverlayIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes popIn {
    from { transform: scale(0.82) translateY(12px); opacity: 0; }
    to   { transform: scale(1) translateY(0); opacity: 1; }
}

@media (max-width: 480px) {
    .mafia-popup-overlay {
        align-items: flex-start;
    }
    .mafia-popup {
        width: calc(100vw - 24px);
        max-width: none;
        padding: 22px 18px 18px;
        margin-top: 12px;
    }
    .mafia-popup-title {
        font-size: 17px;
        letter-spacing: 2px;
    }
    .mafia-popup-message {
        font-size: 14px;
    }
    /* Normalize older game-specific popup implementations */
    .chest-popup,
    .angel-game-popup,
    .door-popup-content {
        width: calc(100vw - 24px) !important;
        max-width: none !important;
        max-height: calc(100dvh - 24px);
        overflow-y: auto;
    }
}