﻿@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Montserrat', sans-serif; }

:root {
    --bg-color: #1a1a2e;
    --panel-color: #0f3460;
    --gold: #ffd700;
    --text-light: #fcf6ba;
    --cell-size: 70px;
}

body { background: var(--bg-color); color: var(--text-light); min-height: 100vh; display: flex; overflow: hidden; }

/* ==================== ЛЕВАЯ ПАНЕЛЬ ==================== */
.left-panel {
    width: 220px;
    background: rgba(0, 0, 0, 0.3);
    border-right: 1px solid rgba(255, 215, 0, 0.3);
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 100vh;
    overflow-y: auto;
    flex-shrink: 0;
    z-index: 10;
}
.panel-header h2 { color: var(--gold); text-align: center; font-size: 1.2rem; margin-bottom: 10px; }
.lang-buttons { display: flex; justify-content: center; gap: 5px; margin-bottom: 10px; }
.lang-btn { background: var(--panel-color); border: 1px solid var(--gold); border-radius: 20px; padding: 5px 10px; color: var(--text-light); cursor: pointer; font-size: 0.8rem; transition: 0.2s; }
.lang-btn.active, .lang-btn:hover { background: var(--gold); color: var(--bg-color); font-weight: bold; }

.panel-btn { background: var(--panel-color); border: 1px solid var(--gold); border-radius: 30px; padding: 10px; color: var(--text-light); cursor: pointer; font-size: 0.9rem; transition: 0.2s; width: 100%; text-align: center; }
.panel-btn:hover { background: #1a4b8c; }

.mode-toggle { background: rgba(15, 52, 96, 0.5); padding: 10px; border-radius: 12px; text-align: center; font-size: 0.85rem; border: 1px solid var(--gold); }

/* ==================== ЦЕНТРАЛЬНАЯ ЧАСТЬ ==================== */
.main-layout { flex: 1; display: flex; justify-content: flex-start; align-items: center; gap: 5px; padding: 5px; position: relative; }

/* Фишки слева */
.left-players-panel { display: flex; flex-direction: column; gap: 8px; width: 150px; flex-shrink: 0; }
.pc-player-btn { display: flex; align-items: center; gap: 10px; background: rgba(0, 0, 0, 0.5); padding: 8px 12px; border-radius: 20px; cursor: pointer; transition: 0.2s; border: 1px solid transparent; }
.pc-player-btn:hover { background: rgba(255, 215, 0, 0.2); }
.pc-player-btn.active { background: rgba(255, 215, 0, 0.3); border-color: var(--gold); }
.pc-player-color { width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0; }
.pc-player-stats { display: flex; flex-direction: column; font-size: 0.75rem; line-height: 1.3; }

/* Большой квадрат */
.big-square-container { background: var(--panel-color); border: 3px solid var(--gold); border-radius: 10px; box-shadow: 0 0 20px rgba(0, 0, 0, 0.5); padding: 10px; position: relative; flex-shrink: 0; }
.big-square { display: grid; grid-template-columns: repeat(8, var(--cell-size)); grid-template-rows: repeat(8, var(--cell-size)); gap: 2px; background: #000; border: 1px solid #333; }

.square-cell { background: #16213e; position: relative; cursor: pointer; display: flex; justify-content: center; align-items: center; overflow: hidden; transition: 0.2s; }
.square-cell img { width: 100%; height: 100%; object-fit: cover; }
.square-cell:hover { filter: brightness(1.3); z-index: 10; }

.square-cell.highlight-from { border: 3px solid #00ff00; box-shadow: inset 0 0 10px #00ff00; z-index: 5; }
.square-cell.highlight-to { border: 3px solid #ffff00; box-shadow: inset 0 0 10px #ffff00; z-index: 5; }
.square-cell.highlight-card { border: 3px solid #ffa500; box-shadow: inset 0 0 10px #ffa500; z-index: 5; }

.token { width: 60%; height: 60%; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 5px rgba(0,0,0,0.8); position: absolute; z-index: 20; transition: all 0.3s ease; }

/* Правая панель (Кубик, Миникарта) */
.right-widgets { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 20px; 
    width: 320px; 
    flex-shrink: 0;
    margin-left: 120px; /* Отодвигает от большого квадрата */
}

/* Картинка куба сверху */
.cube-schema img {
    width: 150px;
    height: auto;
}

/* Миникарта (БЕЗ РАМКИ) */
.minimap-container { 
    background: transparent; 
    border: none; 
    padding: 0; 
    text-align: center; 
    width: 100%; 
}
/* Надпись "Схема поля" скрываем */
.minimap-title { display: none; } 
.minimap-cross { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.minimap-row { display: flex; gap: 4px; }

/* УВЕЛИЧИЛИ МИНИКАРТУ НА ПК (с 75px до 130px) */
.minimap-square { background: #16213e; border: 1px solid #0f3460; width: 130px; height: 130px; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); cursor: pointer; transition: 0.2s; position: relative; }
.minimap-square.active-minimap { border: 2px solid var(--gold); box-shadow: 0 0 10px var(--gold); z-index: 2; }
.minimap-square:hover { filter: brightness(1.5); }
.minimap-cell { border: 1px solid rgba(255, 255, 255, 0.05); background: #000; position: relative; }
.minimap-token { position: absolute; width: 6px; height: 6px; border-radius: 50%; border: 1px solid #fff; z-index: 10; transform: translate(-50%, -50%); }

.minimap-cell.mm-from { background: #00ff00 !important; }
.minimap-cell.mm-to { background: #ffff00 !important; }

/* Пустые места в кресте (чтобы сетка не съезжала) */
.minimap-empty { width: 130px; height: 130px; visibility: hidden; }

/* Кнопка-кубик (КРУГЛАЯ) */
.dice-btn { 
    background: var(--gold); 
    border: 2px solid var(--bg-color); 
    border-radius: 50%; 
    width: 60px; 
    height: 60px; 
    padding: 0; 
    cursor: pointer; 
    font-size: 2rem; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    transition: 0.2s;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}
.dice-btn:hover { transform: scale(1.05); }

/* Значение кубика на ПК */
.dice-value-box {
    background: var(--gold);
    color: var(--bg-color);
    font-weight: bold;
    font-size: 28px;
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 5px;
}

/* ==================== МОБИЛКИ ==================== */
.mobile-top-bar, .mobile-players-bar { display: none; }

.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 1000; display: flex; justify-content: center; align-items: center; background: transparent; backdrop-filter: none; }
#cardModal { pointer-events: none; }

.modal-content { background: var(--panel-color); border: 2px solid var(--gold); border-radius: 15px; padding: 20px; max-width: 90%; max-height: 90vh; overflow-y: auto; position: relative; color: var(--text-light); box-shadow: 0 0 30px rgba(255, 215, 0, 0.2); }
.modal-large { width: 800px; }
.close { position: absolute; top: 10px; right: 15px; font-size: 28px; color: var(--gold); cursor: pointer; transition: 0.2s; }
.close:hover { color: #fff; }


.card-item { background: #16213e; border: 1px solid var(--gold); border-radius: 10px; padding: 10px; width: 250px; text-align: center; display: flex; flex-direction: column; gap: 10px; }
.card-item img { width: 100%; border-radius: 5px; }
.card-item .card-text { font-size: 0.9rem; line-height: 1.4; max-height: 150px; overflow-y: auto; }

.history-table { width: 100%; border-collapse: collapse; margin-top: 15px; font-size: 0.85rem; }
.history-table th, .history-table td { border: 1px solid rgba(255, 215, 0, 0.3); padding: 6px; text-align: left; }
.history-table th { background: rgba(255, 215, 0, 0.1); color: var(--gold); }

/* ==================== АДАПТИВ (МОБИЛКИ) ==================== */
@media (max-width: 1024px) {
    body { flex-direction: column; overflow: hidden; }
    .left-panel { display: none; }
    
    /* Центрируем и поднимаем элементы */
    .main-layout { flex-direction: column; padding: 70px 10px 80px 10px; justify-content: flex-start; gap: 15px; }
    
    :root { --cell-size: calc((100vw - 30px) / 8); }
    .big-square-container { padding: 4px; }
    .left-players-panel { display: none; }
    
    .right-widgets { 
        flex-direction: row; 
        width: 100%; 
        justify-content: center; 
        align-items: center; 
        gap: 20px; 
        margin-top: 0; 
        margin-left: 0; 
    }
    .cube-schema { display: none; }
    .dice-value-box { display: none; }
    
    .minimap-container { width: auto; max-width: 100%; padding: 0; margin: 0; }
    .minimap-cross { gap: 3px; }
    .minimap-row { gap: 3px; }
    
    /* Размеры миникарты на мобилке */
    .minimap-square { width: calc((100vw - 100px) / 4.5); height: calc((100vw - 100px) / 4.5); }
    .minimap-empty { width: calc((100vw - 100px) / 4.5); height: calc((100vw - 100px) / 4.5); visibility: hidden; }
    
        .dice-btn { 
        width: 55px !important; 
        height: 55px !important; 
        min-width: 55px; 
        min-height: 55px; 
        padding: 0; 
        font-size: 1.8rem; 
        flex-shrink: 0; 
        border-radius: 50%; 
        aspect-ratio: 1 / 1; /* Жестко задает пропорцию 1:1 */
    }
    
    /* Верхняя панель */
    .mobile-top-bar { 
        display: flex; 
        position: fixed; 
        top: 0; 
        left: 0; 
        right: 0; 
        height: 60px; 
        background: var(--panel-color); 
        border-bottom: 2px solid var(--gold); 
        align-items: center; 
        justify-content: space-between; 
        padding: 0 15px; 
        z-index: 100; 
    }
    .mobile-hamburger, .mobile-btn { background: none; border: none; color: var(--gold); font-size: 28px; cursor: pointer; }
    .mobile-dice-value { background: var(--gold); color: var(--bg-color); font-weight: bold; font-size: 24px; width: 50px; height: 50px; border-radius: 12px; display: flex; justify-content: center; align-items: center; cursor: pointer; }

    .mobile-players-bar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; height: 60px; background: rgba(15, 52, 96, 0.95); border-top: 2px solid var(--gold); justify-content: space-around; align-items: center; padding: 0 5px; z-index: 100; }
    .mobile-player-btn { display: flex; flex-direction: column; align-items: center; background: none; border: none; cursor: pointer; gap: 2px; padding: 5px; }
    .mobile-player-color { width: 25px; height: 25px; border-radius: 50%; border: 2px solid transparent; }
    .mobile-player-btn.active .mobile-player-color { border-color: var(--gold); transform: scale(1.1); }
    .mobile-player-moves { color: var(--gold); font-size: 10px; font-weight: bold; }
    
    .modal-content { width: 95%; padding: 15px; }
    .card-view-container { flex-direction: column; align-items: center; }
    .card-item { width: 100%; max-width: 300px; }
}

/* На ПК скрываем мобильное меню */
@media (min-width: 1025px) {
    .mobile-dropdown { display: none !important; }
}


/* ===== РАЗМЕР КАРТЫ (ползунок) ===== */
.card-size-control {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #0f3460;
    padding: 6px 10px;
    border-radius: 30px;
    margin-bottom: 10px;
}
.card-size-control label {
    font-size: 0.75rem;
    white-space: nowrap;
    flex-shrink: 0;
    color: #fcf6ba;
}
.card-size-control input {
    flex: 1;
    min-width: 70px;
    accent-color: #ffd700;
}
.card-size-control span {
    font-size: 0.7rem;
    min-width: 38px;
    text-align: right;
    flex-shrink: 0;
    color: #ffd700;
}

#cardModal .modal-content {
    background: transparent;
    padding: 0;
    border: none;
    box-shadow: none;
    width: var(--card-large-width, 280px);
    height: calc(var(--card-large-width, 280px) * 1.5);
    max-width: 95vw;
    max-height: 90vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
 pointer-events: auto;
}
.card-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

/* Обертка для одной карты */
.interactive-card-wrapper {
    background: #16213e;
    border: 1px solid #ffd700;
    border-radius: 8px;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    margin: 0 auto;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: block;
    color: #fff;
    position: relative;
    box-shadow: 0 0 20px rgba(0,0,0,0.7);
}

/* Заголовок карты */
.interactive-card-wrapper .card-title {
    text-align: center;
    color: #ffd700;
    font-weight: bold;
    font-size: 0.9rem;
    margin-bottom: 8px;
}

/* Область контента (картинка + текст) */
.interactive-card-wrapper .card-content-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;

}

.interactive-card-wrapper .card-img {
    width: 100%;
    height: auto;
    border-radius: 4px;
    margin-bottom: 8px;
}

.interactive-card-wrapper .card-text-body {
    width: 100%;
    font-size: 0.8rem;
    line-height: 1.3;
    color: #fcf6ba;
    display: none; /* Скрыт на первом клике */
    text-align: left;
}



/* Состояние 1 — только картинка */
.interactive-card-wrapper.state-1 .card-text-body {
    display: none;
}
.interactive-card-wrapper.state-1 .card-img {
    margin-bottom: 0;
}

/* Состояние 2 — картинка + текст (full-mode) */
.interactive-card-wrapper.state-2 {
    background: #F5F5DC !important;
    border: 2px solid #4A2C2C !important;
    color: #4A2C2C !important;
    padding: 10px !important;
}
.interactive-card-wrapper.state-2 .card-title {
    color: #4A2C2C;
}
/* Убираем flex, чтобы работал float */
.interactive-card-wrapper.state-2 .card-content-area {
    display: block;
    overflow: visible; /* Позволяем картинке обтекаться текстом */
}
/* Картинка слева */
.interactive-card-wrapper.state-2 .card-img {
    width: 80px;
    height: 120px;
    float: left;
    margin: 0 15px 10px 0;
    border: 1px solid #4A2C2C;
    border-radius: 4px;
}
/* Текст без прокрутки (прокручивается вся карта) */
.interactive-card-wrapper.state-2 .card-text-body {
    display: block;
    color: #4A2C2C;
    font-size: 0.9rem;
    line-height: 1.4;
    padding-bottom: 10px;
}


/* Адаптив для мобилки */
@media (max-width: 1024px) {
        .interactive-card-wrapper {
        width: 100%;
        height: 100%;
    }
    .interactive-card-wrapper.state-2 .card-img {
        width: 60px;
        height: 90px;
        margin: 0 10px 5px 0;
    }
    .interactive-card-wrapper.state-2 .card-text-body {
        font-size: 0.75rem;
    }
}


#cardModalContent {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Карты в ряду (для 2+ карт) */
.card-view-container {
    display: flex;
    flex-direction: row;
    gap: 20px;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
    max-width: 95vw;
}

.card-view-container .interactive-card-wrapper {
    width: var(--card-large-width, 280px) !important;
    min-width: var(--card-large-width, 280px) !important; /* Запрещаем сжиматься */
    height: calc(var(--card-large-width, 280px) * 1.5) !important;
    max-height: 90vh;
    margin: 0;
    flex-shrink: 0;
}

/* Модалка расширяется, если внутри 2 и более карт */
#cardModal .modal-content:has(.card-view-container) {
    width: auto !important;
    max-width: 95vw !important;
    height: auto !important; /* Высоту тоже даем auto, чтобы карты не сплющивало */
}
#historyModal {
    pointer-events: auto !important;
    z-index: 99999 !important;
}
#historyModal .modal-content {
    pointer-events: auto !important;
}
#historyModal .close {
    pointer-events: auto !important;
    cursor: pointer;
}