﻿@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 {
    --card-large-width: 280px;
    --board-size: min(80vw, 80vh, 1500px);
}

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: 280px;
    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;
}

.auth-btn, .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%;
}
.auth-btn:hover, .panel-btn:hover {
    background: #1a4b8c;
}

.card-size-control {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #0f3460;
    padding: 6px 10px;
    border-radius: 30px;
    font-size: 10px;
}

.lang-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
}
.lang-btn {
    background: #0f3460;
    border: 1px solid #ffd700;
    border-radius: 20px;
    padding: 5px 8px;
    cursor: pointer;
    color: white;
    font-size: 0.7rem;
}
.lang-btn.active {
    background: #ffd700;
    color: #1a1a2e;
}

.level-game-btn {
    background: #0f3460;
    border: 1px solid #ffd700;
    border-radius: 20px;
    padding: 8px 0;
    cursor: pointer;
    color: white;
    font-weight: bold;
}
.level-game-btn.active {
    background: #ffd700;
    color: #1a1a2e;
}
.level-game-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Игровое поле */
.game-field-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    overflow: visible;
}
.game-field-container {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: 1fr auto;
    gap: 5px;
    padding-bottom: 20px;
}
.row-labels {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    height: var(--board-size);
    margin-right: 5px;
}
.row-label {
    width: 35px;
    text-align: center;
    font-weight: bold;
    cursor: pointer;
    background: rgba(0,0,0,0.5);
    border-radius: 8px;
    padding: 5px 0;
}
.row-label:hover {
    background: #ffd700;
    color: #1a1a2e;
}

/* ==================== 3D АНИМАЦИЯ ПЕРЕВОРОТА ==================== */
.board-3d-wrapper {
    grid-column: 2;
    grid-row: 1;
    width: var(--board-size);
    height: var(--board-size);
    perspective: 2000px;
}

.game-board {
    width: 100% !important;
    height: 100% !important;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    
    gap: 0px; /* Убираем зазор, рамки теперь у ячеек */
    
    border: 2px solid #ffd700 !important;
    border-radius: 8px;
    overflow: hidden;
    
    transform-style: preserve-3d;
    transform-origin: center center;
    transition: transform 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* Фон для сетки (чтобы не было пустот при загрузке) */
.game-board.front-side { background: #1a1a2e; }
.game-board.back-side { background: #1a1a2e; }

/* Ячейки с рамками */
.cell {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.1s;
    position: relative;
    
    /* ТОЛЩИНА РАМКИ И ОТСТУП */
    border: 1px solid #3a6a8e; /* По умолчанию синяя (для обратной стороны) */
    padding: 1px; 
}

/* Золотая рамка для лицевой стороны */
.game-board.front-side .cell {
    border: 1px solid #fceea7; 
}

/* Картинки внутри ячеек */
.cell img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.cell.highlight {
    outline: 3px solid #ffd700;
    outline-offset: -3px;
    z-index: 10;
}
.cell.hint-green { box-shadow: 0 0 0 3px #00ff00; z-index: 10; }
.cell.hint-red { box-shadow: 0 0 0 3px #ff0000; z-index: 10; }

.col-labels {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    justify-content: space-around;
    margin-top: 5px;
}
.col-label {
    width: calc(var(--board-size) / 8);
    text-align: center;
    font-weight: bold;
    cursor: pointer;
    background: rgba(0,0,0,0.5);
    border-radius: 8px;
    padding: 5px 0;
}
.col-label:hover {
    background: #ffd700;
    color: #1a1a2e;
}
.level-indicator-pc {
    background: #ffd700;
    color: #1a1a2e;
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: bold;
}

/* Модальные окна */
.modal {
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.transparent-modal {
    background: transparent !important;
    pointer-events: none;
}
.transparent-modal .transparent-content {
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(8px);
    border: 1px solid #ffd700;
    border-radius: 12px;
    padding: 15px;
    pointer-events: auto;
    max-width: 300px;
    text-align: center;
    position: relative;
}
.transparent-modal .image-modal-content {
    background: transparent;
    border: none;
    padding: 0;
    pointer-events: auto;
    cursor: pointer;
}
.transparent-modal .image-modal-content img {
    max-width: 85vw;
    max-height: 85vh;
    border-radius: 12px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}
.row-info-list, .col-info-list {
    text-align: left;
    margin-top: 10px;
}
.row-info-list div, .col-info-list div {
    padding: 5px;
    border-bottom: none;
    color: #fff;
    font-size: 14px;
}

/* ===== МОБИЛЬНАЯ ВЕРСИЯ (в стиле 4-й игры) ===== */
@media (max-width: 768px) {
    body { padding: 0; margin: 0; background: #1a1a2e; }
    
    .left-panel { display: none; }
    .main-layout { flex-direction: column; gap: 0; }
    .game-field-wrapper { margin-top: 60px; padding: 0 5px; }
    
    /* Сетка */
    .game-field-container { 
        display: grid; 
        grid-template-columns: auto 1fr; 
        grid-template-rows: 1fr auto; 
        gap: 0px; 
        justify-content: center; 
        padding-bottom: 20px; 
    }
    .level-indicator-pc { display: none; }
    .board-3d-wrapper {
        grid-column: 2;
        grid-row: 1;
        width: calc(100vw - 20px) !important;
        height: calc(100vw - 20px) !important;
        max-width: 500px !important;
        max-height: 500px !important;
        aspect-ratio: 1 / 1;
    }
    .game-board {
        gap: 1px;
        grid-template-columns: repeat(8, 1fr) !important;
        grid-template-rows: repeat(8, 1fr) !important;
        border-radius: 8px;
        overflow: hidden;
    }
    .cell {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 0;
        min-width: 0;
    }
    .cell img {
        width: 100%;
        height: 100%;
        object-fit: contain;
        transform: scale(1);
    }

    /* Микроскопические цифры и буквы */
    .row-labels {
        grid-column: 1;
        grid-row: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        height: calc(100vw - 20px);
        margin-right: 0px;
        gap: 2px;
    }
    .col-labels {
        grid-column: 2;
        grid-row: 2;
        display: flex;
        justify-content: space-between;
        margin-top: 2px;
        gap: 2px;
        width: calc(100vw - 20px);
    }
    .row-label, .col-label {
        width: 20px !important;
        min-width: 20px !important;
        font-size: 9px !important;
        padding: 0 !important;
        background: none !important;
        border: none !important;
        color: #ffd700;
        cursor: pointer;
        text-align: center;
        line-height: 1;
    }
    .row-label {
        height: calc((100vw - 20px) / 8);
        display: flex;
        align-items: center;
        justify-content: center;
        margin-left: -15px;
    }
    .col-label {
        width: calc((100vw - 20px) / 8);
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .row-label:hover, .col-label:hover {
        background: none !important;
        color: #ffd700;
    }

    /* Верхняя панель */
    .mobile-top-bar {
        position: fixed; top: 0; left: 0; right: 0; height: 55px; background: #0f3460; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; 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-top-btn:active { background: #00bfff; color: #1a1a2e; }
    .mobile-level-indicator {
        background: #1a1a2e; border: 1px solid #ffd700; color: #ffd700; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 16px;
    }
    .mobile-coord-buttons {
        display: flex;
        gap: 8px;
        align-items: center;
    }
}

/* На ПК скрываем мобильные элементы */
@media (min-width: 769px) {
    .mobile-top-bar, .mobile-dropdown { display: none !important; }
}

/* Сдвиг модалок на ПК (чтобы не перекрывали поле) */
@media (min-width: 769px) {
    /* Прижимаем окно со сказками (цифры) к левому краю */
    #rowInfoModal {
        justify-content: flex-start;
        padding-left: 300px; /* Отступ, чтобы не налезало на левую панель */
    }
    /* Прижимаем окно с сюжетами (буквы) к правому краю */
    #colInfoModal {
        justify-content: flex-end;
        padding-right: 50px; /* Отступ от правого края экрана */
    }
    
    /* Убираем абсолютное позиционирование, чтобы флекс работал */
    #rowInfoModal .transparent-content,
    #colInfoModal .transparent-content {
        position: relative;
        left: auto;
        right: auto;
        transform: none;
    }
}