/* =========================================
   MOBILE ADAPTATION (FINAL FIX)
   ========================================= */

   @media only screen and (max-width: 900px) {

    /* --- 1. СБРОС И БАЗА --- */
    html, body {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        min-height: 100vh !important;
        overflow-y: scroll !important;
        overflow-x: hidden !important;
        margin: 0 !important;
        padding: 0 !important;
        background-color: #202020 !important;
        position: relative !important;
    }

    /* Скрываем ПК элементы */
    .side-column, .col-left, .col-right, #mobile-menu {
        display: none !important;
    }

   /* --- 2. ЗАГРУЗОЧНЫЙ ЭКРАН (ЦЕНТРОВКА) --- */
   * --- БЕЗОПАСНАЯ МОБИЛЬНАЯ ШАПКА --- */
   #mobile-overlay {
       position: relative !important; /* БЫЛО fixed - ЭТО ВАЖНО ИЗМЕНИТЬ */
       width: 100% !important; 
       height: auto !important;       /* Высота по содержимому, а не на весь экран */
       background: #202020 !important;
       z-index: 10 !important;        /* Убрали безумный z-index */
       display: flex !important;
       flex-direction: column !important;
       align-items: center !important;
       justify-content: center !important;
       padding-bottom: 20px;
       border-bottom: 4px solid #000;
       margin-bottom: 20px;
   }
   
   /* Скрываем крутящийся лоадер, он больше не нужен и пугает Google */
   #loading-section {
       display: none !important;
   }
   
   /* Меню показываем сразу */
   #mobile-menu-box {
       display: flex !important;
       flex-direction: column !important;
       gap: 15px !important;
       width: 80% !important;
       align-items: center !important;
   }

    .emc-logo {
        font-family: 'Press Start 2P', cursive;
        text-align: center !important;
        font-size: 30px !important;
        color: #ffd700 !important;
        text-shadow: 4px 4px #000 !important;
        margin-bottom: 40px !important;
        width: 100% !important;
        display: block !important;
    }

    /* --- 3. МОБИЛЬНОЕ МЕНЮ --- */
    #mobile-menu-box {
        display: none; /* JS включит flex */
        width: 80% !important;
        flex-direction: column !important;
        gap: 15px !important;
        align-items: center !important;
    }

    .mob-btn {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 100% !important;
        padding: 20px 0 !important;
        font-family: 'Press Start 2P', cursive !important;
        font-size: 14px !important;
        text-transform: uppercase !important;
        border: 4px solid #000 !important;
        box-shadow: 4px 4px 0 #000 !important;
        cursor: pointer !important;
        text-decoration: none !important;
        box-sizing: border-box !important;
    }
    
    .mob-btn:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 #000 !important; }

    .btn-girls { background: #333 !important; color: #ff9f43 !important; border-color: #ff9f43 !important; }
    .btn-boys  { background: #333 !important; color: #54a0ff !important; border-color: #54a0ff !important; }
    
    /* Кнопка "УЧАСТНИКИ" - контрастная */
    .btn-main  { 
        background: #2ecc71 !important; 
        color: #000 !important; 
        border-color: #fff !important; 
        font-weight: bold !important;
        text-shadow: none !important;
    }

    /* --- 4. ГЛАВНАЯ СТРАНИЦА --- */
    .col-center {
        width: 100% !important;
        padding: 10px !important;
        display: flex !important;
        flex-direction: column !important;
        box-sizing: border-box !important;
    }

    .heads-grid {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
    }
    .grid-item {
        width: 100% !important;
        aspect-ratio: 1 / 1.3 !important;
        height: auto !important;
        padding: 5px !important;
    }
    .grid-head { transform: scale(0.9); margin-bottom: 5px !important; }
    .grid-name { font-size: 8px !important; white-space: normal !important; line-height: 1.2 !important; }

    /* --- 5. СТРАНИЦЫ РЕЙТИНГОВ --- */
    .container-page { width: 100% !important; padding: 10px !important; box-sizing: border-box !important; }
    
    /* Кнопка назад */
    .btn-back {
        display: block !important;
        width: 100% !important;
        background: #555 !important;
        color: #fff !important;
        text-align: center !important;
        padding: 15px 0 !important;
        margin-bottom: 20px !important;
        text-decoration: none !important;
        border: 4px solid #000 !important;
        font-family: 'Press Start 2P', cursive !important;
        font-size: 12px !important;
        box-sizing: border-box !important;
        box-shadow: 4px 4px 0 #000 !important;
    }

    .list-container { display: flex !important; flex-direction: column !important; gap: 8px !important; }
    
    .player-row {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding: 10px !important;
        height: auto !important;
    }
    .player-info { display: flex !important; align-items: center !important; flex-grow: 1 !important; }
    
    /* ЦЕНТРОВКА НИКОВ */
    .nick-text { 
        margin-left: 15px !important; 
        font-size: 10px !important; 
        margin-top: 2px !important;
    }

    /* --- 6. ГОЛОВА (CROP) --- */
    .mini-head-mobile {
        width: 32px !important;
        height: 32px !important;
        border: 2px solid #000 !important;
        background-color: #222 !important;
        flex-shrink: 0 !important;
        
        /* Магия кропа лица */
        background-repeat: no-repeat !important;
        background-size: 256px !important; /* (32px * 8) */
        background-position: -32px -32px !important; /* Сдвиг (8px * 4) */
        image-rendering: pixelated !important;
    }

    /* --- 7. СТРАНИЦА ГОЛОСОВАНИЯ (СМЕНА МЕСТ) --- */
    #voting-screen {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 20px !important;
    }

    /* Порядок элементов: Скин -> Управление -> Соцсети */
    .socials-container { 
        order: 1 !important; 
        width: 100% !important; 
        display: flex !important; 
        flex-direction: column !important; 
        align-items: center !important; 
    }
    
    #skin-container {
        width: 280px !important;
        height: 350px !important;
        margin: 0 auto !important;
        order: 1 !important;
    }

    #social-buttons-list {
        order: 3 !important; /* В самый низ */
        flex-direction: row !important;
        justify-content: center !important;
        margin-top: 20px !important;
    }

    .controls-box {
        order: 2 !important; /* Под скином */
        width: 100% !important;
    }

    /* Кнопка "Назад" на странице голосования */
    .btn-back-link {
        width: 100% !important;
        box-sizing: border-box !important;
        text-align: center !important;
    }

    /* --- 8. МОДАЛКА ПОИСКА (УМЕНЬШЕНИЕ) --- */
    #search-modal > div {
        width: 85% !important;
        max-width: 300px !important;
        padding: 20px !important;
        border-width: 4px !important;
    }
    #search-modal h2 { font-size: 12px !important; margin-bottom: 10px !important; }
    #search-modal p { font-size: 8px !important; line-height: 1.4 !important; }
}