/* СТАРТОВАЯ ЗАСТАВКА — СОХРАНЯЕМ КЛАССИЧЕСКИЙ PADDING 20px */
body .menu-container {
    width: 100% !important;
    max-width: 640px !important;
    margin: 0 auto !important;
    padding: 20px !important; /* Оставляем как было для красоты меню */
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    border-radius: 16px !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05) !important;
	border: 1px solid #a3c1ad;
	background-color: #fbf9f1 !important; 
    background-image: 
        linear-gradient(90deg, rgba(163, 193, 173, 0.15) 1px, transparent 1px),
        linear-gradient(rgba(163, 193, 173, 0.15) 1px, transparent 1px) !important;
    background-size: 20px 20px !important; /* Размер декоративной клетки */
}

/* ЭКРАН ИГРЫ — ДЕЛАЕМ КОМПАКТНЫЙ PADDING 10px 0px */
body #gameScreen {
    width: 100% !important;
    max-width: 640px !important;
    margin: 0 auto !important;
    padding: 5px 0px !important; /* ИСПРАВЛЕНО: убрали боковые отступы, ужали верх/низ */
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    background-color: #ffffff !important;
    border-radius: 16px !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05) !important;
	border: 1px solid #a3c1ad;
}


body .menu-title { margin: 0 0 4px 0 !important; font-size: 28px !important; color: #2c3e50 !important; font-weight: bold !important; text-align: center !important; }
body .menu-subtitle { margin: 0 0 20px 0 !important; font-size: 14px !important; color: #7f8c8d !important; font-weight: 500 !important; text-align: center !important; }
body .menu-section { margin-bottom: 18px !important; text-align: left !important; width: 100% !important; }
body .section-label { display: block !important; font-size: 14px !important; font-weight: bold !important; color: #34495e !important; margin-bottom: 8px !important; }



/* ==========================================================================
   2. СЕТКИ И ПАСТЕЛЬНЫЕ КНОПКИ ЗАСТАВКИ (ЖЕСТКАЯ ИЗОЛЯЦИЯ ОТ ТЕМЫ)
   ========================================================================== */
/* ЖЕСТКО ЗАСТАВЛЯЕМ ГЕРОЕВ И КЛАССЫ СТАТЬ В 4 КОЛОНКИ */
body #startScreen .options-grid {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(60px, 1fr)) !important; 
    gap: 8px !important;
    width: 100% !important;
    margin-top: 8px !important;
    box-sizing: border-box !important;
    float: none !important;
}


body #startScreen .options-grid.length-grid {
    /* ИСПРАВЛЕНО: возвращаем 2 аккуратные колонки в ряд для длинных кнопок */
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
}

/* СБИВАЕМ ПОПЫТКИ ТЕМЫ WORDPRESS СЖАТЬ КНОПКИ ДО 50% */
body #startScreen .options-grid button.menu-btn,
body #startScreen .options-grid .hero-btn,
body #startScreen .options-grid .class-btn {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    flex: none !important;
    flex-basis: auto !important;
    display: flex !important;
    box-sizing: border-box !important;
}

/* ВОЗВРАЩАЕМ И УСИЛИВАЕМ ДИЗАЙН ПАСТЕЛЬНЫХ КНОПОК */
body #startScreen .options-grid .menu-btn {
    justify-content: center !important;
    padding: 12px 4px !important;
    font-size: 14px !important;
    font-weight: bold !important;
    border-radius: 10px !important;
    cursor: pointer !important;
    min-height: 46px !important;
    margin: 0 !important;
    
    background-color: #f8f9fa !important;
    border: 2px solid #dee2e6 !important;	
    color: #2c3e50 !important;
    box-shadow: none !important;
    text-transform: none !important;
}

body #startScreen .options-grid .menu-btn:hover { 
    background-color: #f8f9fa !important;
    border: 2px solid #dee2e6 !important;	
}

body #startScreen .options-grid .menu-btn.active { 
    background-color: #e8f4f8 !important;
    border-color: #3498db !important;
    color: #2980b9 !important;
}

body #startScreen .options-grid .hero-btn span { 
    font-size: 24px !important; 
    display: inline-block !important; 
    line-height: 1 !important; 
    vertical-align: middle !important; 
    pointer-events: none !important; 
}
body #startScreen .options-grid .hero-btn { 
    padding: 6px 0 !important; 
    min-height: 44px !important; 
}
/* ==========================================================================
   3. КНОПКИ ЗАПУСКА, ПРАВИЛ И СКРЫТИЕ ЭКРАНА ИГРЫ
   ========================================================================== */
.menu-footer-actions { margin: 14px 0; display: flex; justify-content: center; }
.rules-toggle-btn {
    background-color: #f0f7f4; border: 2px solid #a3c1ad; border-radius: 8px;
    padding: 8px 16px; font-size: 13px; font-weight: bold; color: #2c3e50;
    cursor: pointer; transition: all 0.15s ease; outline: none;
}
.rules-toggle-btn:hover { background-color: #e2f0ea; border-color: #27ae60; }

.launch-btn { 
    width: 100%; background-color: #27ae60; border: none; border-radius: 10px; padding: 14px; 
    font-size: 18px; font-weight: bold; color: #ffffff; cursor: pointer; box-shadow: 0 4px 15px rgba(39, 174, 96, 0.3); transition: all 0.2s ease; margin-top: 4px; 
}
.launch-btn:hover { background-color: #219653; transform: translateY(-2px); box-shadow: 0 6px 20px rgba(39, 174, 96, 0.4); }

/* ЖЕСТКОЕ СКРЫТИЕ: Прячем игровой экран от WordPress на старте заставки */
body div#gameScreen {
    display: none !important;
}

/* ЭТАЛОННЫЙ ХОЛСТ И UI КАНВАСА */
#gameCanvas {
    background-color: #ffffff; border: 3px solid #a3c1ad; border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.06); max-width: 600px; max-height: 600px; width: 95%; height: auto; aspect-ratio: 1 / 1;
    image-rendering: -webkit-optimize-contrast; image-rendering: crisp-edges; touch-action: none;
}

/* ==========================================================================
   4. СТАБИЛЬНЫЙ ПОДВАЛ UI (ПЛАШКА СВОБОДНО РАСТЕТ СТРОГО ВНИЗ)
   ========================================================================== */
#uiFloor {
    width: 95%; 
    max-width: 600px; 
    margin: 12px auto 0 auto; 
    box-sizing: border-box;
    background-color: #ffffff; 
    border: 3px solid #a3c1ad; 
    border-radius: 12px; 
    padding: 12px; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.04);
    
    /* Свободный рост вниз, скроллбары полностью вырезаны */
    height: auto; 
    min-height: 80px;
    overflow: hidden; 
    scrollbar-width: none; /* Для Firefox */
}
#uiFloor::-webkit-scrollbar {
    display: none; /* Для Chrome и Safari */
}

#uiFloor .stats-line { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    font-size: 16px; 
    font-weight: bold; 
    color: #2c3e50; 
    margin-bottom: 10px !important;
}
#uiFloor #hintLine { 
    font-size: 14px; 
    color: #7f8c8d; 
    background: #e8f4f8; 
    border-left: 4px solid #3498db; 
    padding: 6px 12px; 
    border-radius: 6px; 
    min-height: 20px; 
    line-height: 1.4; 
    text-align: left;
}

.level-badge { background: #e8f4f8; color: #2980b9; padding: 4px 10px; border-radius: 20px; border: 1px solid #d4e6f1; font-size: 14px; }

.timer-bar-container { 
    width: 100%; 
    height: 6px; 
    background: #e9ecef; 
    border-radius: 3px; 
    margin-top: 10px !important;
    overflow: hidden; 
}
.timer-bar-fill { 
    height: 100%; 
    width: 100%; 
    background: #e74c3c; 
    transition: width 1s linear; 
}

/* КНОПКА АВАРИЙНОГО ВЫХОДА В КОНЦЕ ТЕКСТОВОЙ СТРОКИ */
.exit-game-btn {
    background-color: #fdf2f2 !important;  
    border: 1.5px solid #f5b7b1 !important; 
    border-radius: 6px !important;
    padding: 3px 8px !important;
    font-size: 11px !important;
    font-weight: bold !important;
    color: #c0392b !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
    outline: none !important;
}
.exit-game-btn:hover {
    background-color: #fadbd8 !important;
    border-color: #e74c3c !important;
}

/* ==========================================================================
   5. МОДАЛЬНОЕ ОКНО ПРАВИЛ И МОБИЛЬНЫЙ ДЖОЙСТИК
   ========================================================================== */
.modal-overlay {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(44, 62, 80, 0.5); z-index: 10000; align-items: center; justify-content: center;
}
.modal-content {
    background-color: #fffde7; border: 3px solid #f0e6b2; border-radius: 16px;
    width: 90%; max-width: 440px; padding: 24px; box-sizing: border-box;
    position: relative; text-align: left; box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    animation: modalFadeIn 0.2s ease-out;
}
@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-15px); }
    to { opacity: 1; transform: translateY(0); }
}
.modal-close-x {
    position: absolute; top: 12px; right: 16px; background: none; border: none;
    font-size: 28px; color: #b7950b; cursor: pointer; line-height: 1; outline: none; padding: 0;
}
.modal-close-x:hover { color: #c0392b; }
.info-box-title { margin: 0 0 6px 0; font-size: 15px; color: #b7950b; font-weight: bold; }
.info-box-list { margin: 0 0 16px 0; padding-left: 0; list-style-type: none; font-size: 13px; color: #5d6d7e; line-height: 1.5; }
.info-box-list li { margin-bottom: 7px; }
.modal-ok-btn {
    width: 100%; background-color: #27ae60; border: none; border-radius: 8px;
    padding: 10px; font-size: 14px; font-weight: bold; color: #ffffff;
    cursor: pointer; transition: background-color 0.15s ease; outline: none;
}
.modal-ok-btn:hover { background-color: #219653; }

.mobile-controls { display: none; grid-template-columns: repeat(3, 46px); grid-template-rows: repeat(2, 42px); gap: 8px; justify-content: center; margin-top: 12px; width: 100%; }
.ctrl-btn { background-color: #ffffff; border: 2px solid #a3c1ad; border-radius: 10px; font-size: 18px; font-weight: bold; color: #2c3e50; display: flex; align-items: center; justify-content: center; cursor: pointer; user-select: none; box-shadow: 0 3px 8px rgba(0,0,0,0.05); -webkit-user-select: none; outline: none; transition: background-color 0.1s ease, border-color 0.1s ease, transform 0.1s ease; }
.ctrl-btn:active { background-color: #eaf5ec; border-color: #27ae60; transform: scale(0.95); }

.ctrl-up { grid-column: 2 !important; grid-row: 1 !important; }
.ctrl-left { grid-column: 1 !important; grid-row: 2 !important; }
.ctrl-down { grid-column: 2 !important; grid-row: 2 !important; }
.ctrl-right { grid-column: 3 !important; grid-row: 2 !important; }

/* ==========================================================================
   6. АДАПТИВНОСТЬ ДЛЯ СМАРТФОНОВ
   ========================================================================== */
@media (max-width: 480px) {
    .mobile-controls { display: grid; }
    #gameCanvas { max-height: 400px; }
    
    #uiFloor { 
        padding: 8px 10px; 
        margin-top: 8px; 
        height: auto;
        min-height: 90px;
        overflow: hidden !important;
    }
    #uiFloor .stats-line { 
        font-size: 13px; 
        margin-bottom: 10px !important;
        padding: 0 4px; 
    }
    #uiFloor #hintLine { 
        font-size: 12px; 
        padding: 5px 10px; 
        min-height: 16px; 
    }
    
    .level-badge { padding: 2px 8px; font-size: 12px; }
    .modal-content { padding: 18px; width: 95%; }

    /* Перенос значков жизней и ключей строго под заголовки на смартфонах */
    #livesContainer, #keysContainer {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        line-height: 1.3;
    }
    .exit-game-btn {
        padding: 4px 6px !important;
        font-size: 10px !important;
    }
}
