/* ==========================================================================
   1. ОФОРМЛЕНИЕ СТАРТОВОЙ ЗАСТАВКИ И КОНТЕЙНЕРОВ
   ========================================================================== */
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;
    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;
    border-radius: 16px !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.04) !important;
    border: 2px solid #a3c1ad !important;
}

body #gameScreen {
    width: 100% !important;
    max-width: 640px !important;
    margin: 0 auto !important;
    padding: 10px 0px !important;
    box-sizing: border-box !important;
    display: none; /* Скрыт по умолчанию, включается через loader.js */
    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: 26px !important; color: #2c3e50 !important; font-weight: bold !important; text-align: center !important; }
body .menu-subtitle { margin: 0 0 20px 0 !important; font-size: 13px !important; color: #7f8c8d !important; font-weight: 500 !important; text-align: center !important; }
body .menu-section { margin-bottom: 16px !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: 6px !important; }

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

body #startScreen .options-grid.length-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
}

body #startScreen .options-grid button.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;
    display: flex !important;
    align-items: center !important;
    box-sizing: border-box !important;
    width: 100% !important;
}
body #startScreen .options-grid .menu-btn:hover { background-color: #f1f3f5 !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; 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 !important; gap: 12px !important; 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;
}
.launch-btn:hover { background-color: #219653; transform: translateY(-2px); }

#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: 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;
}
#uiFloor .stats-line { display: flex; justify-content: space-between; align-items: center; font-size: 15px; font-weight: bold; color: #2c3e50; margin-bottom: 8px; }
#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: 13px; }

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

/* КНОПКА ОТВЕТИТЬ И ПОЛЗТИ (МАТЕМАТИЧЕСКАЯ) */
.snake-answer-btn {
    font-size: 15px; padding: 8px 18px; background: #27ae60; color: #fff; border: none; border-radius: 6px; margin-left: 10px; cursor: pointer; font-weight: bold; transition: background 0.1s ease;
}
.snake-answer-btn:hover { background: #219653; }

/* ==========================================================================
   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: 460px; padding: 22px; box-sizing: border-box; position: relative; text-align: left; box-shadow: 0 10px 40px rgba(0,0,0,0.15); }
.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; }
.info-box-title { margin: 0 0 8px 0; font-size: 16px; 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; outline: none; text-align: center; }

.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; outline: none; }
.ctrl-btn:active { background-color: #eaf5ec; border-color: #27ae60; }
.ctrl-up { grid-column: 2; grid-row: 1; }
.ctrl-left { grid-column: 1; grid-row: 2; }
.ctrl-down { grid-column: 2; grid-row: 2; }
.ctrl-right { grid-column: 3; grid-row: 2; }

/* ==========================================================================
   6. АДАПТИВНОСТЬ ДЛЯ СМАРТФОНОВ
   ========================================================================== */
@media (max-width: 480px) {
    .mobile-controls { display: grid; }
    #gameCanvas { max-height: 400px; }
    #uiFloor { padding: 8px 10px; margin-top: 8px; min-height: 90px; }
    #uiFloor .stats-line { font-size: 13px; margin-bottom: 8px; padding: 0 4px; }
    #uiFloor #hintLine { font-size: 12px; padding: 5px 10px; min-height: 16px; }
    .level-badge { padding: 2px 8px; font-size: 12px; }
    #livesContainer, #keysContainer { display: flex; flex-direction: column; align-items: center; text-align: center; line-height: 1.3; }
}
