/* ==========================================
   📱 MOBILE RESPONSIVENESS
   ========================================================================= */
@media (max-width: 950px) {

    .mobile-only { display: block; }
    .desktop-only { display: none !important; }
    #minimap { display: none !important; }

    #map-wrapper {
        width: 100% !important;
        height: 100% !important;
        max-width: calc(100vh * (6194 / 3876)) !important;
        max-height: calc(100vw * (3876 / 6194)) !important;
        transform: translate(-50%, -50%) scale(0.94) !important;
    }
    
    #map-wrapper::after {
        box-shadow: 
            inset 0 0 20px 5px rgba(30, 15, 5, 0.8),
            inset 0 0 0 1px rgba(230, 194, 122, 0.5), 
            0 0 0 1px #26170d, 
            0 0 0 3px #ffd700, 
            0 0 0 4px #5c4002,
            0 0 0 6px #e6c27a, 
            0 0 0 7px #996e17, 
            0 0 0 8px #ffeb99, 
            0 0 0 11px #2a1103, 
            0 0 0 12px #0f0601,
            0 10px 20px 8px rgba(0, 0, 0, 0.8) !important;
    }

    .checkbox-label.disabled-limit {
        opacity: 0.35 !important;
        filter: grayscale(100%) !important;
        cursor: not-allowed !important;
        transition: all 0.3s ease !important;
    }

    .sidebar-item-wrapper.disabled-limit .checkbox-custom {
        background: rgba(15, 23, 42, 0.4) !important;
        border-color: rgba(255, 255, 255, 0.1) !important;
    }

    .sidebar-item-wrapper.disabled-limit .checkbox-custom::after {
        background: #475569 !important;
    }

    .mobile-toast {
        position: fixed;
        top: 2rem; left: 50%; transform: translateX(-50%) translateY(-20px);
        background: rgba(239, 68, 68, 0.95); backdrop-filter: blur(10px);
        color: white; padding: 12px 20px; border-radius: 8px;
        font-size: 0.9rem; font-weight: 600; line-height: 1.4;
        z-index: 999999; opacity: 0; pointer-events: none;
        transition: all 0.3s ease; text-align: center; width: 90%; max-width: 340px;
        box-shadow: 0 10px 25px rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.2);
    }
    .mobile-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

    .demo-item {
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.1);
        margin-bottom: 12px; position: relative; padding-right: 32px;
    }
    .mobile-click-icon {
        position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
        width: 18px; height: 18px; color: #a5b4fc; opacity: 0.8;
    }

    .dynamic-dossier {
        position: fixed !important;
        width: 100vw !important; max-width: 100vw !important;
        padding: 1.5rem !important;
        top: auto !important; bottom: 0 !important; left: 0 !important;
        transform: none !important;
        border-radius: 24px 24px 0 0 !important;
        height: 55dvh !important; 
        max-height: 55dvh !important;
        border-bottom: none !important;
        overflow-y: auto !important; 
        overflow-x: hidden !important;
        display: flex !important;
        flex-direction: column !important;
        z-index: 3000 !important;
    }

    /* 🔥 FIXED: Mobile Regional Modal docks perfectly to the bottom */
    #regional-ethnic-modal {
        position: fixed !important;
        left: 0 !important;
        top: auto !important; 
        bottom: 0 !important;
        width: 100vw !important; 
        max-width: 100vw !important;
        padding: 1.5rem !important;
        
        /* Slides up natively from the bottom */
        transform: translateY(120%) scale(0.9) !important; 
        
        border-radius: 24px 24px 0 0 !important;
        height: 55dvh !important; 
        max-height: 55dvh !important;
        border-bottom: none !important;
        
        /* Ensures the user can scroll perfectly through the options */
        overflow-y: auto !important; 
        overflow-x: hidden !important;
        display: flex !important;
        flex-direction: column !important;
        z-index: 3000 !important;
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease !important;
    }

    #regional-ethnic-modal.active {
        transform: translateY(0) scale(1) !important;
    }

    #close-ethnic-modal-desktop { display: none !important; }
    
    #close-ethnic-modal-mobile {
        position: relative !important;
        top: 0 !important; left: 0 !important;
        width: 100% !important; 
        min-height: 48px !important;
        border-radius: 12px !important;
        display: flex !important; align-items: center !important; justify-content: center !important; gap: 8px !important;
        font-size: 1.1rem !important; font-weight: 700 !important; font-family: inherit !important;
        background: rgba(99, 102, 241, 0.15) !important;
        color: #a5b4fc !important;
        margin-bottom: 1.2rem !important; border: 1px solid rgba(99, 102, 241, 0.3) !important;
        padding: 0 !important;
        flex-shrink: 0 !important;
        cursor: pointer !important;
    }

    .regional-ethnic-grid {
        max-height: none !important; /* Lets the whole panel scroll naturally */
        overflow: visible !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
    
    .regional-grid-item {
        padding: 12px 6px !important;
        font-size: 0.95rem !important;
    }

    .dossier-back-btn {
        position: relative !important;
        top: 0 !important; left: 0 !important;
        width: 100% !important; 
        min-height: 48px !important;
        border-radius: 12px !important;
        display: flex !important; align-items: center !important; justify-content: center !important; gap: 8px !important;
        font-size: 1.1rem !important; font-weight: 700 !important; font-family: inherit !important;
        background: rgba(99, 102, 241, 0.15) !important;
        color: #a5b4fc !important;
        margin-bottom: 1.2rem !important; border: 1px solid rgba(99, 102, 241, 0.3) !important;
        padding: 0 !important;
        flex-shrink: 0 !important;
        cursor: pointer !important;
    }

    .dossier-image { max-height: 160px !important; margin-bottom: 12px !important; flex-shrink: 0 !important; }
    .dossier-drag-handle { font-size: 1.6rem !important; cursor: default !important; margin-bottom: 0.5rem !important; flex-shrink: 0 !important; }
    
    .dossier-desc {
        max-height: none !important;
        overflow: visible !important;
        padding-bottom: 2rem !important;
    }

    .donation-btn { left: 1.5rem; bottom: 1.5rem; width: 44px; height: 44px; }
    .donation-btn svg { width: 20px; height: 20px; }
    .donation-callout-card { left: 0; transform: translateX(0) scale(0); transform-origin: bottom left; }
    .donation-btn:hover .donation-callout-card:not(.show) { transform: translateX(0) scale(0); opacity: 0; pointer-events: none; }
    .donation-callout-card.show { transform: translateX(0) scale(1) !important; opacity: 1 !important; pointer-events: auto !important; }
    .donation-callout-card::after { left: 18px; }
    .compass-btn { top: 5rem; left: 1.5rem; width: 44px; height: 44px; }
    
    #regional-ethnic-btn {
        top: 8.5rem;
        left: 1.5rem;
        width: 44px;
        height: 44px;
    }
    
    #mobile-settings-container { position: absolute; top: 1.5rem; left: 1.5rem; z-index: 2100; }
    #mobile-settings-toggle { width: 44px; height: 44px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.1); display: flex; align-items: center; justify-content: center; font-size: 1.25rem; color: #fff; cursor: pointer; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3); }
    #mobile-settings-menu { position: absolute; top: calc(100% + 8px); left: 0; display: flex; flex-direction: column; gap: 8px; padding: 8px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.1); opacity: 0; visibility: hidden; transform: translateY(-10px); transition: all 0.3s ease; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5); }
    #mobile-settings-menu.active { opacity: 1; visibility: visible; transform: translateY(0); }
    .desktop-header-settings { display: none !important; }
    
    .info-panel { top: 50% !important; bottom: auto !important; left: 50% !important; right: auto !important; width: 90% !important; max-width: 340px !important; max-height: 70vh !important; max-height: 70dvh !important; transform: translate(-50%, 150%) scale(0.9) !important; opacity: 0 !important; }
    .info-panel.active { transform: translate(-50%, -50%) scale(1) !important; opacity: 1 !important; }
    .info-panel.hidden-by-dossier { transform: translate(-50%, 150%) scale(0.9) !important; opacity: 0 !important; pointer-events: none !important; }
    .close-info-btn { width: 44px !important; height: 44px !important; font-size: 1.8rem !important; }
    .donut-container { display: none !important; }
    
    .sidebar { width: 85%; max-width: 340px; }
    .sidebar-title { font-size: 1.1rem; }
    .sidebar-scrollable { padding: 1.2rem 1rem; gap: 1.2rem; }
    .checkbox-label { min-height: 44px; padding: 0.5rem; font-size: 1rem; flex-grow: 1; }
    .sidebar-info-btn { display: flex; width: 44px; height: 44px; }
    .sidebar-info-btn svg { width: 22px; height: 22px; }
    .theme-toggle-btn { min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; }
    .toggle-sidebar-btn { width: 44px; height: 56px; left: -44px; }
    
    .sidebar:not(.collapsed)~.info-panel:not(.hidden-by-dossier),
    .sidebar:not(.collapsed)~.dynamic-dossier { transform: translate(-50%, 150%) scale(0.9) !important; opacity: 0 !important; pointer-events: none !important; }
    
    .powered-by-badge { bottom: 1.5rem; right: 1.5rem; font-size: 0.7rem; padding: 0.4rem 0.8rem; }
    .development-badge { font-size: 0.75rem; padding: 0.3rem 1rem; }
}