﻿@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 {
    --board-size: min(75vw, 75vh, 1200px);
}

body {
    background: #1a1a2e;
    color: #fff;
    padding: 20px;
    min-height: 100vh;
}

.app-container { max-width: 1400px; margin: 0 auto; }
.main-layout { display: flex; gap: 20px; flex-wrap: wrap; }

.left-panel {
    width: 250px;
    background: rgba(0,0,0,0.3);
    border-radius: 16px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: calc(100vh - 40px);
    overflow-y: auto;
    position: sticky;
    top: 20px;
}

.panel-btn {
    background: #0f3460;
    border: 1px solid #ffd700;
    border-radius: 30px;
    padding: 8px 12px;
    cursor: pointer;
    color: white;
    font-size: 0.9rem;
    transition: 0.2s;
    width: 100%;
    text-align: center;
    text-decoration: none;
    display: block;
}
.panel-btn:hover { background: #1a4b8c; }

.mode-switch {
    display: flex;
    gap: 5px;
    background: #0f3460;
    padding: 5px;
    border-radius: 30px;
    border: 1px solid #ffd700;
}
.mode-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: #aaa;
    cursor: pointer;
    border-radius: 20px;
    padding: 6px 0;
    font-weight: bold;
    transition: 0.2s;
    font-size: 13px;
}
.mode-btn.active { background: #ffd700; color: #1a1a2e; }

.stats-block {
    background: #0f3460;
    border: 1px solid #4a8fe0;
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.stat-row { display: flex; justify-content: space-between; align-items: center; }
.stat-title { font-size: 13px; color: #aaa; }
.stat-val { font-size: 16px; font-weight: bold; color: #ffd700; }

.lang-buttons { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; margin-top: 5px; }
.lang-btn {
    background: #0f3460;
    border: 1px solid #ffd700;
    border-radius: 20px;
    padding: 5px 8px;
    cursor: pointer;
    color: white;
    font-size: 0.7rem;
    transition: 0.2s;
}
.lang-btn.active { background: #ffd700; color: #1a1a2e; }

.game-field-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.game-field-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: var(--board-size);
}

.selection-screen {
    width: 100%;
    max-width: 1000px;
    background: rgba(0,0,0,0.3);
    padding: 20px;
    border-radius: 16px;
    border: 1px solid #ffd700;
}

.selection-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr); /* 8 колонок для ПК */
    gap: 8px;
    max-height: 70vh;
    overflow-y: auto;
    padding: 5px;
}
.selection-grid.mode-b { grid-template-columns: repeat(5, 1fr); } /* 5 колонок для пар */

.selection-item {
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: 0.2s;
    position: relative;
    aspect-ratio: 1;
}
.selection-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.selection-item:hover {
    border-color: #ffd700;
    transform: scale(1.05);
    z-index: 10;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

.board-3d-wrapper { width: var(--board-size); height: var(--board-size); perspective: 2000px; }
.game-board {
    width: 100% !important;
    height: 100% !important;
    display: grid;
    gap: 0px;
    border: 2px solid #ffd700 !important;
    border-radius: 8px;
    overflow: hidden;
    background: #1a1a2e;
    transition: opacity 0.4s ease-in-out;
}
.game-board.fade-out { opacity: 0; }
.game-board.fade-in { opacity: 1; }

.cell { display: flex; align-items: center; justify-content: center; cursor: pointer; transition: 0.1s; position: relative; border: 1px solid #3a6a8e; padding: 1px; }
.cell img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s ease; }
.cell.highlight { outline: 3px solid #ffd700; outline-offset: -3px; z-index: 10; }

.controls-panel {
    display: flex;
    gap: 15px;
    background: rgba(0,0,0,0.3);
    padding: 10px 20px;
    border-radius: 30px;
    border: 1px solid #4a8fe0;
}

.ctrl-btn {
    background: #0f3460;
    border: 1px solid #00bfff;
    color: #00bfff;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}
.ctrl-btn:active { background: #00bfff; color: #0f3460; }

.modal { position: fixed; z-index: 2000; left: 0; top: 0; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.8); }
.modal-content { background: #16213e; padding: 20px; border: 2px solid #ffd700; border-radius: 15px; width: 90%; max-width: 400px; max-height: 80vh; overflow-y: auto; position: relative; }
.close { position: absolute; top: 10px; right: 15px; font-size: 24px; cursor: pointer; color: #aaa; }
.close:hover { color: #ffd700; }

.history-content { margin-top: 15px; font-size: 14px; line-height: 1.6; color: #fcf6ba; }
.history-item { border-bottom: 1px solid rgba(255, 215, 0, 0.2); padding: 8px 0; }
.history-sub { padding-left: 10px; color: #aaa; font-size: 12px; margin-top: 4px; }

/* ===== МОБИЛЬНАЯ ВЕРСИЯ ===== */
@media (max-width: 768px) {
    body { padding: 0; margin: 0; background: #0f172a; }
    .left-panel { display: none !important; }
    .main-layout { flex-direction: column; gap: 0; justify-content: center; }
    .game-field-wrapper { margin-top: 70px; padding: 0 5px; align-items: center; }
    .game-field-container { min-height: auto; margin-bottom: 20px; }

    .board-3d-wrapper {
        width: calc(100vw - 20px) !important;
        height: calc(100vw - 20px) !important;
        max-width: 500px !important;
        max-height: 500px !important;
        margin: 0 auto !important;
    }
    
    .selection-screen { padding: 10px; margin-top: 10px; }
    .selection-grid { grid-template-columns: repeat(8, 1fr); gap: 3px; max-height: 65vh; } /* ТАКАЯ ЖЕ СЕТКА, КАК НА ПК */
    .selection-grid.mode-b { grid-template-columns: repeat(5, 1fr); }

    .mobile-top-bar { position: fixed; top: 0; left: 0; right: 0; height: 60px; background: #0f3460; display: flex; align-items: center; justify-content: space-between; padding: 0 10px; z-index: 10000; border-bottom: 2px solid #ffd700; }
    .mobile-top-btn { background: #1a1a2e; border: 1px solid #00bfff; color: #00bfff; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 18px; cursor: pointer; }
    .mobile-stats-group { display: flex; gap: 5px; }
    .stat-box { background: #1a1a2e; border: 1px solid #4a8fe0; border-radius: 8px; padding: 4px 8px; display: flex; flex-direction: column; align-items: center; min-width: 60px; }
    .stat-label { font-size: 9px; color: #aaa; }
    .stat-value { font-size: 13px; font-weight: bold; color: #ffd700; }

    .mobile-dropdown { position: fixed; top: 65px; right: 10px; background: #0f3460; border: 1px solid #ffd700; border-radius: 12px; padding: 10px; z-index: 10001; flex-direction: column; gap: 8px; width: 200px; }
    .mobile-menu-btn { background: none; border: none; color: #fcf6ba; text-decoration: none; text-align: center; padding: 8px; border-bottom: 1px solid #1a4b8c; cursor: pointer; font-size: 14px; font-family: inherit; }
    .mobile-mode-switch { display: flex; gap: 5px; background: #1a1a2e; padding: 5px; border-radius: 20px; }
    .mobile-mode-switch .mode-btn { font-size: 12px; padding: 4px 0; }

    .controls-panel { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #0f3460; border: 2px solid #ffd700; border-radius: 50px; padding: 10px 15px; display: flex; gap: 10px; z-index: 9999; box-shadow: 0 5px 15px rgba(0,0,0,0.5); }
    .ctrl-btn { width: 45px; height: 45px; font-size: 20px; }
}

/* Скрываем мобильную панель на ПК */
@media (min-width: 769px) {
    .mobile-top-bar {
        display: none !important;
    }
}

/* Блок истории на ПК */
.pc-history-block {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}