:root {
    --bg-body: #f0f2f5;       
    --bg-panel: #ffffff;      
    --text-main: #2c3e50;     
    --text-secondary: #7f8c8d;
    --primary-color: #3498db; 
    --accent-color: #e74c3c;  
    --cell-bg: #ffffff;       
    --cell-hover: #ecf0f1;
    --nav-hover: #e8f4f8;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    background-color: var(--bg-body);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden; 
    
    display: grid;
    grid-template-columns: 220px 1fr 280px 320px;
    grid-template-rows: 100vh;
}

/* --- ЛЕВАЯ КОЛОНКА (Навигация) --- */
.sidebar-left {
    background-color: var(--bg-panel);
    display: flex;
    flex-direction: column;
    padding: 15px;
    border-right: 1px solid #e1e4e8;
    z-index: 10;
}

.logo { font-size: 1.3rem; font-weight: 800; color: var(--text-main); margin-bottom: 25px; letter-spacing: -0.5px; }
.nav-links { display: flex; flex-direction: column; gap: 5px; }
.nav-link { text-decoration: none; color: var(--text-main); padding: 10px 12px; border-radius: 8px; transition: all 0.2s; font-weight: 600; display: flex; align-items: center; gap: 10px; font-size: 0.95rem; }
.nav-link:hover { background-color: var(--nav-hover); color: var(--primary-color); }
.nav-link.active { background-color: var(--primary-color); color: white; }
.lang-container { margin-top: auto; padding-top: 15px; border-top: 1px solid #eee; }
.lang-select { padding: 6px; width: 100%; border: 1px solid #ddd; border-radius: 5px; font-weight: bold; }

/* --- ЦЕНТРАЛЬНАЯ КОЛОНКА (Оболочка) --- */
.main-area {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    background-color: var(--bg-body);
    padding: 10px;
    overflow: hidden;
}

.game-header-bar {
    width: 100%;
    max-width: 85vh; 
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 15px;
    padding: 0 2px;
}

h1 { margin: 0; font-size: 1.8rem; color: var(--text-main); line-height: 1; white-space: nowrap; }

/* Статус (ПК) */
#status { font-size: 1.2rem; font-weight: bold; color: var(--primary-color); text-align: right; line-height: 1; white-space: nowrap; }

/* --- ПРАВАЯ КОЛОНКА (Настройки) --- */
.controls-panel {
    background-color: var(--bg-panel);
    padding: 20px;
    border-left: 1px solid #e1e4e8;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    z-index: 10;
}

.control-group { display: flex; flex-direction: column; gap: 8px; }
.control-label { font-weight: 700; color: var(--text-secondary); font-size: 0.85rem; text-transform: uppercase; }
.selector-group { display: flex; gap: 3px; background: #f1f2f6; padding: 3px; border-radius: 6px; }
.selector-btn { flex: 1; padding: 8px 0; border: none; background: transparent; color: var(--text-secondary); cursor: pointer; border-radius: 4px; font-weight: 700; transition: all 0.2s; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.selector-btn:hover { color: var(--primary-color); }
.selector-btn.active { background-color: white; color: var(--primary-color); box-shadow: 0 2px 4px rgba(0,0,0,0.05); }

/* Кнопки "Новая игра" (Общий стиль, скрытие управляется отдельно) */
#reset-btn, #reset-btn-mobile {
    display: none;
    background-color: var(--text-main);
    color: white;
    border: none;
    padding: 12px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    width: 100%;
    transition: background 0.2s;
}
#reset-btn:hover, #reset-btn-mobile:hover { background-color: #1a252f; }

/* Анимация кнопки */
.show-btn { display: block !important; animation: fadeIn 0.3s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

#rules-block { font-size: 0.9rem; color: #000000; font-weight: 500; background: #f8f9fa; padding: 15px; border-radius: 8px; border: 1px solid #ddd; margin-top: auto; line-height: 1.4; }

/* --- РЕКЛАМА --- */
.ad-column { background-color: #eef2f7; display: flex; justify-content: center; align-items: flex-start; padding: 20px; border-left: 1px solid #e1e4e8; }
.ad-placeholder { width: 300px; height: 600px; background-color: #dfe4ea; color: #95a5a6; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; border: 2px dashed #bdc3c7; border-radius: 4px; }

#confetti-canvas { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 9999; }

/* --- МОБИЛЬНЫЕ ЭЛЕМЕНТЫ --- */
.mobile-controls {
    display: none; 
    width: 100%;
    max-width: 85vh;
    margin-top: 20px;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
#status-mobile {
    font-size: 1.4rem; font-weight: bold; color: var(--primary-color);
    margin-bottom: 15px; min-height: 1.5em;
}
#reset-btn-mobile {
    margin-top: 0; padding: 14px; font-size: 1.1rem; box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

/* --- АДАПТИВНОСТЬ --- */

/* 1. Планшеты (без рекламы) */
@media (max-width: 1200px) {
    body { grid-template-columns: 200px 1fr 280px; }
    .ad-column { display: none !important; }
}

/* 2. МОБИЛЬНЫЕ (вертикальный стек) */
@media (max-width: 900px) {
    body {
        display: flex;
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        overflow-y: auto;
        overflow-x: hidden;
    }

    /* Скрываем только рекламу и десктопные элементы */
    .ad-column, .desktop-only { 
        display: none !important; 
    }

    /* === НАВИГАЦИЯ ВНИЗУ === */
    .sidebar-left {
        display: flex !important;
        order: 100; /* Ставим в самый конец потока */
        width: 100%;
        height: auto;
        border-right: none;
        border-top: 1px solid #e1e4e8; /* Линия сверху */
        padding: 20px;
        box-shadow: 0 -4px 15px rgba(0,0,0,0.05); /* Тень сверху для красоты */
    }
    
    .sidebar-left .logo {
        justify-content: center; /* Центрируем логотип */
    }

    /* Панель настроек (под игрой, но перед навигацией) */
    .controls-panel {
        width: 100%;
        border-left: none;
        border-top: 1px solid #e1e4e8;
        padding: 20px;
        box-shadow: none;
        overflow: visible;
        flex: 1;
        order: 50; /* Середина */
    }

    /* Игровая зона (вверху) */
    .main-area {
        width: 100%;
        padding: 15px;
        flex: 0 0 auto;
        order: 1; /* Начало */
    }

    .game-header-bar {
        justify-content: center;
        margin-bottom: 20px;
    }
    .game-header-bar h1 { font-size: 2rem; }

    .mobile-controls { display: flex !important; }
    
    #rules-block { margin-top: 20px; }
}