/* =========================================
   ТЕМА: WALNUT & FIELD CLOTH (V1.4 - Premium UI)
   СТРУКТУРА ФАЙЛА:
   1. Переменные (Colors, Sizes)
   2. Базовые стили (Body, Reset)
   3. Типографика (Headings, Links, Text)
   4. Сетка и Layout (Board, Panels, Menus)
   5. Игровые элементы (Cells, Pieces, Cursors)
   6. Формы и Кнопки (Inputs, Buttons)
   7. Спецэффекты и Анимации (Hover, Active, Keyframes)
   8. Админ-панель
   ========================================= */

/* --- 1. ПЕРЕМЕННЫЕ --- */
:root {
    --bg-site: #1e1613;      
    --panel-bg: #281f1a;     
    --text-main: #d9d0c7;     
    --text-muted: #8c7d70;    
    
    /* Акценты (Латунь, Рубин, Олива, Янтарь) */
    --accent-brass: #b5935b;  
    --accent-ruby: #7a1d1d;   
    --accent-olive: #455530;  
    --accent-amber: #9e6421;  
    
    /* Поле */
    --board-light: #a39783;   
    --board-dark:  #968b77;   
    --board-lines: #2a1f1a;   
    
    /* Идеальный баланс: всё влезает, но без лишней пустоты */
    --cell-size: clamp(30px, min(calc((100vh - 370px) / 8), calc((100vw - 60px) / 8)), 86px);
    
    /* Упрощаем: 8 клеток + 20px на толстые внешние рамки доски */
    --game-width: calc(8 * var(--cell-size) + 20px);
}

/* --- 2. БАЗОВЫЕ СТИЛИ --- */
body {
    display: flex; flex-direction: column; align-items: center;
    min-height: 100vh; margin: 0; 
    font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, serif; 
    color: var(--text-main);
    background-color: var(--bg-site);
    background-image: radial-gradient(circle at center, #2d221c 0%, #1e1613 100%);
    overflow-x: hidden;
    padding-bottom: 40px;
}

/* Фикс курсоров (Геймдев чистка) */
.board-wrapper, .board, .cell, .piece, .graveyard, img, .cell.possible-move, .cell.attack-move {
    cursor: default !important;

    /* ДОБАВИТЬ ЭТИ СТРОКИ: Запрет выделения синим цветом */
    -webkit-user-select: none; /* Safari */
    -ms-user-select: none;     /* IE 10 and IE 11 */
    user-select: none;         /* Standard syntax */
}
.cell.possible-move, .cell.attack-move {
    /* cursor: pointer !important; Оставляем кликабельность для ходов */
    cursor: default !important; /* Отключаем руку, оставляем обычный курсор */
}

/* Запрет перетаскивания (Ghost image) */
img {
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    /* user-drag: none; */
    pointer-events: none;
}

/* --- 3. ТИПОГРАФИКА И СПИСКИ --- */
#main-title { 
    color: var(--accent-brass); 
    text-transform: uppercase; letter-spacing: 5px;
    font-size: clamp(24px, 5vw, 32px);
    margin: 15px 0; font-weight: normal;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}
h2, h3 { font-weight: normal; margin-bottom: 10px; letter-spacing: 1px; color: var(--text-main);}
h4 { color: var(--text-muted); font-size: 12px; font-weight: normal; text-transform: uppercase; letter-spacing: 1px; border-bottom: 1px solid rgba(181, 147, 91, 0.1); padding-bottom: 5px; margin-bottom: 10px;}

a, .rules-link { 
    color: var(--accent-brass) !important; text-decoration: none !important; 
    border-bottom: 1px solid rgba(181, 147, 91, 0.3); 
    font-size: 14px; font-style: italic; transition: 0.2s;
}
a:hover { color: #fff !important; }

.rules-list { list-style: none; padding: 0; margin: 0; font-size: 14px;}
.rules-list li { margin-bottom: 12px; padding-left: 15px; position: relative; color: var(--text-muted); line-height: 1.5;}
.rules-list li::before { content: "◆"; position: absolute; left: 0; color: var(--accent-brass); font-size: 11px; top: 3px; }
.rules-list strong { color: var(--text-main); font-weight: bold;}

/* --- 4. СЕТКА И LAYOUT (Панели, Меню) --- */

/* Идеальная монолитная колонна: Шапка, интерфейс и доска теперь ВСЕГДА одной ширины */
#top-bar, .navbar-content, #ui, .mode-block, .rules-block, #setup-buttons, .action-panel, .graveyard, #army-panel, #rules-section, .invite-block, .spectator-auth-panel {
    width: 100% !important;
    max-width: var(--game-width) !important; 
    box-sizing: border-box;
    margin-left: auto !important;
    margin-right: auto !important;
}

#ui {
    padding-left: 0;
    padding-right: 0;
}

/* 3. ДОБАВЛЕНО: Жесткая центровка самой доски внутри широкого контейнера */
#board-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.info-panel, .invite-block, .spectator-auth-panel {
    background-color: var(--panel-bg); 
    border: 1px solid rgba(181, 147, 91, 0.15); 
    padding: 20px; border-radius: 6px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

#action-panel {
    width: 100%; max-width: 450px;
    background: var(--panel-bg); border: 1px solid var(--accent-brass); border-radius: 6px;
    padding: 15px; display: none; flex-direction: column; align-items: center; justify-content: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5); margin: 0 auto;
}
#action-panel img { width: 55px !important; height: 55px !important; background: transparent; filter: drop-shadow(1px 2px 3px rgba(0,0,0,0.5)) !important;}
#action-panel h3 { margin: 0 0 5px 0; font-size: 18px; color: var(--accent-brass);}
#action-panel p { margin: 0; font-size: 14px; color: var(--text-main); }

#army-panel { display: flex; flex-direction: column; gap: 10px; padding: 15px; }

.scrollable-panel { max-height: 350px; overflow-y: auto; padding-right: 10px; }
.scrollable-panel::-webkit-scrollbar, .scrollable-legend::-webkit-scrollbar { width: 5px; }
.scrollable-legend::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.1); }
.scrollable-panel::-webkit-scrollbar-thumb, .scrollable-legend::-webkit-scrollbar-thumb { background: var(--accent-brass); border-radius: 10px; }

/* AFK Меню */
#afk-warning {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(30, 20, 10, 0.9) !important;
    backdrop-filter: blur(5px);
    display: flex; justify-content: center; align-items: center;
    z-index: 9999;
}
.afk-warning-content {
    background: #2a1f19 !important;
    border: 2px solid var(--accent-brass) !important;
    padding: 30px; border-radius: 6px; text-align: center;
    box-shadow: 0 15px 50px rgba(0,0,0,0.9);
    color: var(--text-main);
    max-width: 350px;
}
.afk-warning-content h3 { color: var(--accent-brass) !important; margin-top: 0; text-transform: uppercase; letter-spacing: 1px; font-size: 18px; }

#menu-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 999; }

/* --- 5. ИГРОВЫЕ ЭЛЕМЕНТЫ (Доска, Фишки, Трофеи) --- */
#board {
    display: grid;
    grid-template-columns: repeat(8, var(--cell-size));
    grid-template-rows: repeat(8, var(--cell-size));
    /* Внешняя рамка доски */
    border: 10px solid var(--board-lines); 
    gap: 0 !important;
    background-color: var(--board-lines);
    box-shadow: 0 20px 50px rgba(0,0,0,0.7);
    border-radius: 4px;
    width: fit-content;
    margin: 0 auto;
}

.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    box-sizing: border-box; /* Важно: граница входит в размер клетки */
    
    /* Вместо outline используем border. 
       0.5px часто глючит, поэтому ставим 1px с полупрозрачностью */
    border: 0.5px solid rgba(181, 147, 91, 0.2);
    
    transform: translateZ(0);
}

.cell-light { background-color: var(--board-light); }
.cell-dark { background-color: var(--board-dark); }

.barrier {
    width: 100%; height: 100%; background-color: #3d352b; 
    background-image: 
        repeating-linear-gradient(45deg, rgba(0,0,0,0.3) 0, rgba(0,0,0,0.3) 2px, transparent 2px, transparent 6px),
        repeating-linear-gradient(-45deg, rgba(0,0,0,0.1) 0, rgba(0,0,0,0.1) 1px, transparent 1px, transparent 8px);
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}

body .piece {
    width: 95% !important; height: 95% !important; 
    background: transparent !important; border: none !important; box-shadow: none !important;
}
.piece img { 
    width: 100%; height: 100%; object-fit: contain; 
    filter: drop-shadow(2px 3px 4px rgba(0,0,0,0.5)) !important; 
}
.piece:not(:has(img)) {
    background: linear-gradient(135deg, #2c3e50, #16222d) !important;
    border: 1px solid #0d151d !important; border-radius: 4px !important; box-shadow: 2px 3px 5px rgba(0,0,0,0.5) !important;
}

/* --- ПАНЕЛЬ ТРОФЕЕВ (ЖЕСТКАЯ ФИКСАЦИЯ БЕЗ СДВИГА ДОСКИ) --- */
.graveyard {
    display: flex; 
    flex-wrap: wrap; 
    gap: 4px; 
    justify-content: center; 
    align-content: flex-start;
    padding: 8px 10px; 
    background: rgba(181, 147, 91, 0.05) !important; 
    border: 1px solid rgba(181, 147, 91, 0.2) !important; 
    border-radius: 4px;
    width: 100%; 
    box-sizing: border-box; 
    
    /* ЖЕСТКАЯ ВЫСОТА: Место под заголовок + 2 ряда трофеев. Больше не прыгает! */
    height: 100px !important; 
    min-height: 100px !important;
    max-height: 100px !important; 

    /* Если трофеев станет очень много, они уйдут в скролл, а не сдвинут доску */
    overflow-y: auto;
    scrollbar-width: none; /* Прячем ползунок скролла в Firefox */
}

/* Прячем ползунок скролла в Chrome/Safari/Edge */
.graveyard::-webkit-scrollbar { 
    display: none; 
}

/* Сами трофеи: делаем их чуть компактнее (32px вместо 38px), чтобы влезало больше */
body .graveyard .piece { 
    width: 32px !important; 
    height: 32px !important; 
    margin: 0;
}

/* Заголовок трофеев (перехватываем стили из JS для надежности) */
.graveyard-title {
    width: 100%;
    text-align: center;
    margin-bottom: 6px !important;
    font-size: 13px !important;
    color: var(--accent-brass) !important;
    opacity: 0.8;
}

.legend-item { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid rgba(181, 147, 91, 0.05); padding: 8px 0; }
.legend-left { display: flex; align-items: center; gap: 12px; }
body .legend-img { width: 38px !important; height: 38px !important; filter: drop-shadow(1px 2px 2px rgba(0,0,0,0.5)) !important; }
.legend-count { color: var(--accent-brass); font-family: monospace; font-weight: bold; font-size: 15px;}

/* --- 6. ФОРМЫ, ИНПУТЫ И КНОПКИ --- */
input[type="text"] {
    background: #15100d; border: 1px solid #3d2d25; color: #fff;
    padding: 8px 12px; border-radius: 4px; font-family: monospace; width: 100%; box-sizing: border-box;
}

/* Кастомные радио и чекбоксы */
input[type="radio"], input[type="checkbox"] {
    -webkit-appearance: none; appearance: none;
    width: 18px; height: 18px; border: 2px solid var(--accent-brass); background: transparent;
    display: inline-block; vertical-align: middle; margin-right: 8px; cursor: pointer; transition: 0.2s; position: relative; top: -1px;
}
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"] { border-radius: 3px; }
input[type="radio"]:checked { background: var(--accent-brass); box-shadow: inset 0 0 0 4px var(--panel-bg); }
input[type="checkbox"]:checked {
    background: var(--accent-brass);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23281f1a' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
    background-size: 70%; background-position: center; background-repeat: no-repeat;
}
label { cursor: pointer; font-size: 14px; color: var(--text-main); display: inline-block; margin: 5px 15px 5px 0;}
label:hover { color: #fff; }

/* Общие стили кнопок */
button, .btn-primary, .btn-success, .btn-danger, .switch, .toggle-container {
    cursor: pointer !important;
}
button {
    padding: 10px 20px; font-size: 13px; font-weight: bold; text-transform: uppercase; 
    background: #3d2d25; color: var(--accent-brass); 
    border: 1px solid var(--accent-brass); border-radius: 3px; 
    letter-spacing: 1px; transition: 0.2s; font-family: inherit; margin: 5px;
}
button:hover { background: #4d3a31; color: #fff; }

.main-action-btn {
    width: 100%; max-width: 360px; padding: 12px !important; font-size: 15px !important;
    font-weight: bold; margin: 0 auto; border-radius: 8px; display: flex; justify-content: center; align-items: center; box-sizing: border-box;
    white-space: nowrap;
}

/* Цветовые вариации кнопок (Сведенные вместе) */
.btn-success, #ready-btn, #accept-rules-btn, #accept-mode-btn, #confirm-rules-btn, .btn-primary {
    background: #5d6d3e !important; color: #e8e2d4 !important;
    border: 1px solid #3e4a28 !important; box-shadow: 0 3px 0 #2a331a, 0 4px 10px rgba(0,0,0,0.3) !important;
}
.btn-success:hover, #ready-btn:hover, #accept-rules-btn:hover, #accept-mode-btn:hover, #confirm-rules-btn:hover { 
    background: #6e814a !important; transform: translateY(-1px); 
}
.btn-success:active, #ready-btn:active { transform: translateY(2px); box-shadow: none !important; }

.btn-warning {
    background: #8b5a2b !important; color: #e8e2d4 !important;
    border: 1px solid #5d3d1d !important; box-shadow: 0 3px 0 #3e2813, 0 4px 10px rgba(0,0,0,0.3) !important;
}
.btn-warning:hover { background: #a06832 !important; color: #ffffff !important; }

.btn-danger { 
    background: var(--accent-ruby) !important; color: #ffffff !important; 
    border: 1px solid #5a1212 !important; box-shadow: 0 3px 0 #4a0d0d, 0 4px 10px rgba(0,0,0,0.3) !important;
}
.btn-danger:hover { background: #8f2323 !important; }

/* Кнопка Telegram (Сведена вместе) */
#tg-invite-area button#tg-invite-btn {
    background-color: #5d7c50 !important; color: #e8dcc5 !important;            
    border: 2px solid #3e5138 !important; border-radius: 8px; 
    padding: 12px 24px; font-weight: 800; font-size: 1.1em; font-family: 'Times New Roman', Times, serif; 
    text-transform: uppercase; letter-spacing: 1px; box-shadow: 0 4px 0 #3e5138 !important; 
    transition: all 0.2s ease-in-out;
}
#tg-invite-area button#tg-invite-btn:hover { background-color: #4c6641 !important; transform: translateY(1px); }
#tg-invite-area button#tg-invite-btn:focus { outline: none; box-shadow: 0 0 0 3px rgba(139, 115, 85, 0.5) !important; }
#tg-invite-area button#tg-invite-btn:active { box-shadow: none !important; transform: translateY(4px); }

/* Вспомогательные кнопки */
#randomize-barriers-btn { border: 1px dashed var(--text-muted); opacity: 0.8; }
#randomize-barriers-btn:hover { background: rgba(181, 147, 91, 0.2) !important; border-color: rgba(181, 147, 91, 0.6) !important; color: #fff !important; }
#randomize-barriers-btn:active { transform: scale(0.95); background: rgba(0, 0, 0, 0.3) !important; }

/* #user-profile-top {
    display: inline-flex; background: rgba(181, 147, 91, 0.1); border: 1px solid rgba(181, 147, 91, 0.4);
    color: #b5935b; font-family: inherit; text-transform: uppercase; font-weight: bold; transition: all 0.2s ease;
}
#user-profile-top:hover { background: rgba(181, 147, 91, 0.25); border-color: #b5935b; }
#user-profile-top:active { transform: scale(0.95); } */

/* --- 7. ЭФФЕКТЫ И АНИМАЦИИ --- */
.cell.selected {
    background-color: rgba(181, 147, 91, 0.15) !important; 
    box-shadow: inset 0 0 0 2px var(--accent-brass), inset 0 0 10px rgba(181, 147, 91, 0.3) !important; 
    z-index: 10;
}

.possible-move::after { content: ""; position: absolute; width: 10px; height: 10px; background: rgba(0,0,0,0.3); border-radius: 50%; }

.move-target::after {
    content: ""; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 14px; height: 14px; background: #d4af37; border-radius: 50%; pointer-events: none; z-index: 5;
    box-shadow: 0 0 6px rgba(212, 175, 55, 0.8); animation: dotGlow 1s infinite alternate ease-in-out;
}

.attack-target { position: relative; }
.attack-target::after {
    content: "⚔️"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    font-size: clamp(22px, 5vw, 30px); text-shadow: 0 2px 5px rgba(0,0,0,0.9), 0 0 20px rgba(122, 29, 29, 1);
    z-index: 20; pointer-events: none; animation: swordBounce 0.8s infinite alternate ease-in-out;
}

.sniper-target { position: relative; cursor: crosshair !important; box-shadow: inset 0 0 20px rgba(122, 29, 29, 0.8) !important; }
.sniper-target::after {
    content: '🎯'; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 28px;
    pointer-events: none; animation: sniperPulse 1.5s infinite; z-index: 20; text-shadow: 0 2px 10px rgba(0,0,0,0.8);
}

/* МЕРЦАНИЕ ДОСКИ ВО ВРЕМЯ СВОЕГО ХОДА */

#board.my-turn { animation: boardTurnPulseSoft 4s infinite ease-in-out; }

@keyframes dotGlow {
    from { opacity: 0.7; transform: translate(-50%, -50%) scale(0.95); }
    to   { opacity: 1.0; transform: translate(-50%, -50%) scale(1.1); }
}
@keyframes swordBounce {
    from { transform: translate(-50%, -50%) scale(1); }
    to   { transform: translate(-50%, -50%) scale(1.2); }
}
@keyframes sniperPulse {
    0% { transform: translate(-50%, -50%) scale(0.9); opacity: 0.8; }
    50% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(0.9); opacity: 0.8; }
}
@keyframes boardTurnPulseSoft {
    0%   { 
        box-shadow: 0 0 0 rgba(181, 147, 91, 0); 
        border-color: var(--board-lines); 
    }
    50%  { 
        /* Мягкое золотое свечение наружу и внутрь */
        box-shadow: 0 0 25px rgba(181, 147, 91, 0.25), 
                    inset 0 0 15px rgba(181, 147, 91, 0.15); 
        border-color: rgba(181, 147, 91, 0.6); 
    }
    100% { 
        box-shadow: 0 0 0 rgba(181, 147, 91, 0); 
        border-color: var(--board-lines); 
    }
}

/* --- 8. АДМИН-ПАНЕЛЬ --- */
/* .segmented-control { display: flex; justify-content: center; gap: 5px; }
.admin-radio input, .admin-radio input[type="radio"] { display: none; }
.admin-radio span {
    display: inline-block; background: #1e1613; border: 1px solid #3c3028; color: var(--text-muted);
    padding: 6px 12px; border-radius: 4px; font-size: 12px; font-weight: bold; text-transform: uppercase; cursor: pointer; transition: all 0.2s ease;
}
.admin-radio span:hover { border-color: var(--text-main); color: var(--text-main); }

.admin-radio input[value="all"]:checked + .btn-all, .admin-radio input:checked + .btn-all { background: var(--accent-brass); color: #1e1613; border-color: var(--accent-brass); }
.admin-radio input[value="red"]:checked + .btn-red, .admin-radio input:checked + .btn-red { background: var(--accent-ruby); color: white; border-color: var(--accent-ruby); box-shadow: 0 0 10px rgba(122, 29, 29, 0.5); }
.admin-radio input[value="blue"]:checked + .btn-blue, .admin-radio input:checked + .btn-blue { background: #2980b9; color: white; border-color: #2980b9; box-shadow: 0 0 10px rgba(41, 128, 185, 0.5); }
.admin-radio input[value="spectator"]:checked + .btn-spec, .admin-radio input:checked + .btn-spec { background: var(--text-main); color: #1e1613; border-color: var(--text-main); } */

/* --- 8. СЕГМЕНТИРОВАННЫЕ ПЕРЕКЛЮЧАТЕЛИ (РЕЖИМЫ) --- */
/* __________ */
.segmented-control { 
    display: flex; 
    width: 100%; 
    border: 1px solid rgba(181, 147, 91, 0.4); 
    border-radius: 6px; 
    overflow: hidden; 
    background: rgba(0, 0, 0, 0.6); /* Тот самый глубокий темный */
}

.admin-radio { 
    flex: 1; 
    margin: 0 !important; 
    display: flex; 
}

.admin-radio input { display: none; }

.admin-radio span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px 5px;
    background: transparent; /* Фон берется от родителя */
    color: var(--text-muted);
    font-size: 13px;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    box-sizing: border-box;
}

/* Разделительная линия между кнопками */
.admin-radio:not(:last-child) span {
    border-right: 1px solid rgba(181, 147, 91, 0.2);
}

/* Эффект при наведении */
.admin-radio span:hover {
    color: var(--text-main);
    background: rgba(181, 147, 91, 0.05);
}

/* СТИЛЬ ВЫБРАННОЙ КНОПКИ (Активный режим) */
.admin-radio input:checked + span {
    background: var(--accent-brass) !important;
    color: #1e1613 !important;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.2);
}
/* __________ */

.btn-admin-exit:hover { background: #3c3028 !important; color: var(--text-main) !important; }

/* --- 9. ВЕРХНЯЯ ПАНЕЛЬ (NAVBAR) --- */
.top-navbar {
    height: auto;
    min-height: 60px; 
    padding-bottom: 5px;
    position: sticky;
    top: 0;
    left: 0;
    width: 100%;
    background-color: #1a1512;
    border-bottom: 2px solid #b5935b;
    z-index: 1000;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6);

    background: linear-gradient(180deg, rgba(0, 0, 0, 0.85) 0%, rgba(40, 31, 26, 0.95) 100%) !important;
    border-bottom: 1px solid rgba(181, 147, 91, 0.25);
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.6);
    
    /* Эффект дорогого матового стекла при скролле элементов под шапку */
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.navbar-content {
    /* Делаем блок "контейнером", чтобы внутренние кнопки могли следить за его шириной */
    container-type: inline-size;
    container-name: navcontent;
    
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: var(--game-width) !important;
    margin: 0 auto;
    padding: 8px 15px;
    box-sizing: border-box;
    min-height: 55px;
    gap: 10px; /* Защита от налипания кнопок на логотип */
}

/* Фокус с flex: 1 заставляет центр быть ровно посередине */
.nav-left, .nav-right {
    display: flex;
    align-items: center;
    flex: 1; 
    min-width: 0; /* КРИТИЧНО: разрешаем блокам сжиматься, а не выпирать наружу */
}

.nav-left { justify-content: flex-start; }
.nav-right { justify-content: flex-end; gap: 8px; }

.nav-center {
    display: flex;
    justify-content: center;
    flex-shrink: 0; /* Логотип FOW не должен сплющиваться */
    white-space: nowrap;
}

/* Даем никнейму больше свободы (было 100px, стало 160px) */
#display-username {
    display: inline-block;
    max-width: 100%; /* Тянется до краев кнопки */
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

.top-navbar .logo {
    font-size: 1.2rem;
    font-weight: 900;
    color: #d9d0c7;
    text-transform: uppercase;
    letter-spacing: 2px;
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.top-navbar .subtitle {
    font-size: 0.75rem;
    color: #b5935b;
    font-weight: normal;
    letter-spacing: 1px;
}

/* Стили красивых кнопок в шапке */
.nav-btn {
    background: rgba(181, 147, 91, 0.1);
    color: #b5935b;
    border: 1px solid rgba(181, 147, 91, 0.4);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: 0.2s;
    white-space: nowrap;
}

.btn-small { 
    white-space: nowrap; 
}

.nav-btn:hover {
    background: rgba(181, 147, 91, 0.2);
}

.nav-danger {
    color: #e74c3c;
    border-color: rgba(231, 76, 60, 0.4);
    background: rgba(231, 76, 60, 0.1);
}

.nav-danger:hover {
    background: rgba(231, 76, 60, 0.2);
}

/* Общий стиль для обеих плашек (чтобы они были одинаковой высоты и формы) */
.spectator-pill, .nav-profile-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: bold;
    box-sizing: border-box;
    white-space: nowrap; /* <--- ДОБАВИТЬ ЭТО, чтобы запретить перенос текста */
}

/* Стиль счетчика зрителей */
.spectator-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 32px; /* Фиксированная высота */
    padding: 0 12px;
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #485460;
    color: #fff;
    font-size: 13px;
    font-weight: bold;
    white-space: nowrap;
}

/* Стиль профиля */
/* Убираем старый лимит в 140px, даем кнопке дышать */
.nav-profile-btn {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(181, 147, 91, 0.4);
    color: #d9d0c7;
    cursor: pointer;
    max-width: 250px !important; /* Увеличили лимит, чтобы влезли любые ники */
    transition: 0.2s;
    white-space: nowrap;
}

.nav-profile-btn:hover {
    border-color: #b5935b;
    background: rgba(181, 147, 91, 0.1);
}

/* =========================================
   УКРУПНЕНИЕ ШРИФТОВ (TYPOGRAPHY BOOST)
   ========================================= */

/* 1. Шапка сайта */
.top-navbar .logo { font-size: 22px; }
.top-navbar .subtitle { font-size: 13px; }
.nav-btn, .nav-profile-btn, .spectator-pill { 
    font-size: 14px; /* Было 12px */
    height: 38px;    /* Сделали кнопки чуть выше */
    padding: 0 16px; 
}

/* 2. Основные кнопки */
button { 
    font-size: 14px; /* Было 13px */
    padding: 12px 22px; 
}
.main-action-btn { 
    font-size: 18px !important; /* Было 15px */
    padding: 14px !important; 
    letter-spacing: 1px;
}

/* 3. Тексты, ссылки и заголовки панелей */
.rules-link { font-size: 15px !important; } /* Ссылка на правила */
h4 { font-size: 14px; } /* Заголовки вроде "Состав армии" и "Трофеи" */
.legend-count { font-size: 17px; } /* Цифры количества фигурок (x1, x2) */
label { font-size: 15px; } /* Текст у чекбоксов и радио-кнопок */

/* === УМНЫЙ АДАПТИВ ШАПКИ (Ослабленные рамки) === */

/* Снизили порог с 650px до 520px. Теперь "туман войны" будет виден дольше */
@container navcontent (max-width: 520px) {
    .top-navbar .subtitle { display: none; }
    .nav-btn, .nav-profile-btn { font-size: 11px; padding: 6px 10px; }
}

/* Снизили порог с 480px до 420px для полного скрытия текста в иконки */
@container navcontent (max-width: 420px) {
    .nav-text, #display-username { display: none !important; }
    .nav-btn, .nav-profile-btn { padding: 8px 12px; justify-content: center; }
    .top-navbar .logo { font-size: 1.1rem !important; }
    .spectator-pill { padding: 0 8px; font-size: 11px; }
}

/* =========================================
   АДАПТИВ И МАСШТАБИРОВАНИЕ (ZOOM)
   ========================================= */

/* БАЗОВЫЙ ДЕСКТОПНЫЙ СТИЛЬ (Для компов, ноутов и при зуме на ПК) 
   Этот блок работает ВСЕГДА, кроме совсем маленьких мобилок */
#leaderboard-page {
    width: 100% !important;
    max-width: var(--game-width, 430px) !important; /* Намертво держим ширину игрового поля на ПК */
    box-sizing: border-box;
    margin-left: auto !important;
    margin-right: auto !important;
    padding: 20px;
}

/* Принудительно заставляем внутренности таблицы сжиматься на десктопе под общую ширину */
#leaderboard-page table,
#leaderboard-page .leaderboard-box,
#leaderboard-page .leaderboard-container {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
    table-layout: fixed; /* Железно запрещает длинным строкам распирать таблицу вширь */
}

#leaderboard-page td, 
#leaderboard-page th {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap; /* Ники аккуратно спрячут хвост, если не влезут */
}


/* 1 СТУПЕНЬ: Средний зум (125-150%) или небольшие экраны (до 850px) */
@media (max-width: 850px) {
    /* Прячем подзаголовок "Туман войны", чтобы освободить центр */
    .top-navbar .subtitle {
        display: none;
    }
    
    /* Делаем кнопки чуть компактнее, но текст пока оставляем */
    .nav-btn, .nav-profile-btn {
        font-size: 11px;
        padding: 6px 10px;
    }
    
    .navbar-content {
        padding: 8px 10px;
    }
}


/* 2 СТУПЕНЬ: Экстремальный зум (200%+) или смартфоны (до 550px) */
@media (max-width: 550px) {
    .nav-text, #display-username {
        display: none;
    }
    
    .nav-btn, .nav-profile-btn {
        padding: 8px 12px;
        justify-content: center;
        max-width: none;
    }
    
    .top-navbar .logo {
        font-size: 1rem;
    }
    
    .spectator-pill {
        padding: 0 8px;
    }

    /* === МОНОЛИТ НА ТЕЛЕФОНЕ === */
    :root {
        /* На мобилке занимаем 100vw, рамку доски делаем тонкой (по 4px) */
        --cell-size: calc((100vw - 15px) / 8) !important;
        --game-width: 100vw; 
    }
    
    #board {
        border-width: 4px !important; 
        border-radius: 4px !important;
    }
    
    .navbar-content, #ui {
        padding: 0 5px !important;
    }

    /* На смартфонах переключаемся на настоящую резиновую мобильную ширину */
    #leaderboard-page {
        max-width: var(--game-width) !important; 
        padding: 10px 15px !important; 
    }

    /* Уменьшаем шрифты и отступы в строках рейтинга, чтобы на мобилке текст не переносился кашей */
    #leaderboard-page td, 
    #leaderboard-page th,
    #leaderboard-page .leaderboard-row {
        font-size: 12px !important;
        padding: 8px 6px !important; 
    }

    /* Если на телефоне длинные имена игроков, они будут аккуратно скрываться троеточием */
    #leaderboard-page .player-name, 
    #leaderboard-page td:nth-child(2) {
        max-width: 120px;
    }
}

/* АНИМАЦИЯ ВЗРЫВА МИНЫ */
.explosion-anim {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 50px;
    animation: boomEffect 1.5s ease-out forwards;
    pointer-events: none;
    z-index: 50;
    text-shadow: 0 0 20px #e74c3c;
}
@keyframes boomEffect {
    0% { transform: translate(-50%, -50%) scale(0.1); opacity: 1; }
    20% { transform: translate(-50%, -50%) scale(1.5); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
}

/* =========================================
   ПОДСВЕТКА ПОСЛЕДНЕГО ХОДА И ТРОФЕЕВ (V3 - Идеал)
   ========================================= */

/* 1. Клетка, ОТКУДА ушли (идеальный баланс: легкая золотая заливка + заметная рамочка) */
.last-move-from {
    box-shadow: inset 0 0 0 50px rgba(224, 186, 73, 0.2), /* Мягкий, слегка желтый тон */
                inset 0 0 0 1.5px rgba(229, 201, 99, 0.4) !important; /* Более яркая рамочка */
}

/* 2. Клетка, КУДА пришли */
.last-move-to {
    box-shadow: inset 0 0 20px rgba(224, 186, 73, 0.2), 
                inset 0 0 0 2px rgba(231, 186, 41, 0.8) !important;
}

/* 3. Сама фигура, сделавшая ход */
.last-move-piece img {
    filter: drop-shadow(0 0 6px rgba(231, 186, 41, 0.8)) !important;
}

/* 4. Последний трофей (ПРОБИВАЕМ БЛОКИРОВКУ через body .piece) */
body .piece.latest-trophy {
    border: 2px solid rgba(181, 147, 91, 0.9) !important;
    background: rgba(181, 147, 91, 0.25) !important;
    box-shadow: 0 0 8px rgba(181, 147, 91, 0.4) !important;
    transform: scale(1.08) !important; /* Чуть увеличиваем для акцента */
}

/* === ВСПЛЫВАЮЩИЕ ОКНА (МОДАЛКИ: ПРОФИЛЬ И РЕЙТИНГ) === */
.fow-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85); /* Темный полупрозрачный фон */
    z-index: 2000; /* Поверх вообще всего */
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(3px);
}

.fow-modal .modal-content {
    background: #281f1a;
    border: 2px solid var(--accent-brass);
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    padding: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.9);
    color: var(--text-light);
    animation: modalPop 0.3s ease-out;
}

@keyframes modalPop {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.fow-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(181, 147, 91, 0.2);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.fow-modal .modal-header h3 {
    margin: 0;
    color: var(--accent-brass);
    font-size: 1.2rem;
    text-transform: uppercase;
}

.fow-modal .close-btn {
    background: none;
    border: none;
    color: #7f8c8d;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    transition: 0.2s;
}

.fow-modal .close-btn:hover {
    color: var(--danger-red);
}

/* Списки внутри окна рейтинга */
.leader-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 350px;
    overflow-y: auto;
    scrollbar-width: thin; /* Тонкий скролл для Firefox */
    scrollbar-color: var(--accent-brass) #1a1512;
}

/* Оформление скроллбара для Chrome/Safari */
.leader-list::-webkit-scrollbar { width: 6px; }
.leader-list::-webkit-scrollbar-track { background: #1a1512; border-radius: 4px; }
.leader-list::-webkit-scrollbar-thumb { background: var(--accent-brass); border-radius: 4px; }

/* КНОПКА АДМИНА */
.btn-admin-premium {
    background-color: #5b2c6f; 
    color: #e8daef; 
    border: 1px solid #4a235a;
    border-radius: 4px;
    box-shadow: 0 4px 0 #31153d;
    transition: all 0.1s ease;
    width: 100%; 
    padding: 12px; 
    font-weight: bold; 
    text-transform: uppercase; 
    margin-bottom: 5px; 
    margin-top: 5px; 
    cursor: pointer; 
    letter-spacing: 1px;
}
.btn-admin-premium:hover {
    background-color: #6c3483;
    color: #ffffff;
}
.btn-admin-premium:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #31153d;
    border-bottom-width: 1px;
}