/* Основной стиль */
body{
    margin: 0;
    padding: 0;
    border: 0;
}
.main {
    /*font-family: Arial, sans-serif;*/
    background-image: -webkit-linear-gradient( #F2AF00, #cdc1b4 50%);
    background-image: linear-gradient( #F2AF00, #cdc1b4 50%);
    display: flex;
    justify-content: center;
    align-items: start;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Jost", serif;
    font-optical-sizing: auto;
    font-weight: 800;
    font-style: normal;
}

.game-container {
    text-align: center;
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    /*gap: 20px;*/
}

h1 {
    font-size: 1.4em;
    color: black;
    margin: 5px 0 0 0;
}

#game-board {
    display: grid;
    gap: 10px;
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1;
    padding: 10px;
    border-radius: 10px;
    background-color: black;
    box-shadow: 0 0 20px black;
    touch-action: none;
}

/* Стиль для плиток */
.tile {
    background: #cdc1b4;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5em;
    font-weight: bold;
    color: #776e65;
    border-radius: 5px;
    transition: all 0.2s ease;
}

.tile[data-value="2"] { background: #eee4da; }
.tile[data-value="4"] { background: #ede0c8; }
.tile[data-value="8"] { background: #f2b179; color: #f9f6f2; }
.tile[data-value="16"] { background: #f59563; color: #f9f6f2; }
.tile[data-value="32"] { background: #f67c5f; color: #f9f6f2; }
.tile[data-value="64"] { background: #f65e3b; color: #f9f6f2; }
.tile[data-value="128"] { background: #edcf72; color: #f9f6f2; }
.tile[data-value="256"] { background: #edcc61; color: #f9f6f2; }
.tile[data-value="512"] { background: #edc850; color: #f9f6f2; }
.tile[data-value="1024"] { background: #edc53f; color: #f9f6f2; }
.tile[data-value="2048"] { background: #edc22e; color: #f9f6f2; }

/* Стиль для заблокированных плиток */
.blocked {
    background: #000000 !important; /* Черный фон для заблокированных плиток */
    color: transparent !important; /* Делаем текст невидимым */
    pointer-events: none; /* Отключаем взаимодействие */
    position: relative; /* Позволяет разместить таймер поверх клетки */
    opacity: 0.8; /* Немного прозрачности для эффекта */
}

/* Отображение таймера оставшихся ходов */
.blocked::after {
    content: attr(data-lock-counter) " 🔒"; /* Отображаем значение таймера */
    position: absolute;
    color: #ff6347; /* Красный цвет текста таймера */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Скрытие содержимого плитки, если она заблокирована */
.blocked .tile-content {
    visibility: hidden; /* Прячем содержимое плитки */
}


/* Стили для кнопок и счетчиков */
#reset-button {
    padding: 4px 8px;
    background-color: transparent;
    text-transform: uppercase;
    color: #776e65;
    font-weight: 700;
    font-size: 1em;
    cursor: pointer;
    transition: background-color 0.3s ease;
    justify-self: center;
    border-radius: 25px;
    margin: 10px 0 0 0;
    letter-spacing: 1px;
    border: 1px solid #bbada0;
}

#reset-button:hover {
    background-color: #bbada0;
}

#undo-button{
    padding: 4px 8px;
    text-transform: uppercase;
    color: #776e65;
    font-weight: 700;
    font-size: 1em;
    justify-self: center;
    border-radius: 25px;
    margin: 10px 0 0 0;
    letter-spacing: 1px;
    border: 1px solid #bbada0;
    cursor: pointer;
}
#undo-button:disabled{
    cursor: not-allowed;
}

.score-info {
    display: grid; /* Включаем Grid */
    grid-template-columns: 1fr; /* Две равные колонки */
    gap: 10px; /* Расстояние между колонками */
    width: 100%; /* Ширина контейнера */
    margin-bottom: 10px;
}

.score-info > div {
    text-align: center;
    padding: 2px;
    box-sizing: border-box;
    background: floralwhite;
    border-radius: 25px;
    margin: 2px 2px 5px 2px;
    font-size: .8rem;
}

#language-select{
    border-radius: 25px;
    padding: 3px 4px;
    background: border-box;
}

#move-counter, #move-limit, #moveTitle{
    font-size: 1em;
    margin: 0;
    font-weight: bold;
    color: black;
}

/* Стиль для блока информации о игре */
.game-info, .game-info-classic {
    display: grid;
    align-items: center;
    justify-items: center;
    gap: 10px;
    margin: 5px auto 10px;
    color: #776e65;
    font-size: 12px;
    font-weight: 400;
}

.info-item {
    text-align: center;
    font-size: 1em;
    color: #776e65;
}

.mode-switch {
    display: flex;
    align-items: center;
    justify-content: center;
    background: black;
    padding: 0 8px 8px;
    border-radius: 0 0 25px 25px;
    font-size: 0.9rem;
}

#mode-toggle {
    display: none; /* Скрываем стандартный чекбокс */
}

.switch-label {
    display: flex;
    justify-content: space-between;
    width: 337px;
    background-color: #4CAF50;
    border-radius: 5px 5px 16px 16px;
    position: relative;
    cursor: pointer;
    padding: 2px 16px;
    transition: background-color 0.3s;
}

.switch-label .classic,
.switch-label .hard {
    color: white;
    transition: opacity 0.3s;
}

.switch-label .classic {
    opacity: 1;
}

.switch-label .hard {
    opacity: 0.3;
}

#mode-toggle:checked + .switch-label {
    background-color: brown;
}

#mode-toggle:checked + .switch-label .classic {
    opacity: 0.3;
}

#mode-toggle:checked + .switch-label .hard {
    opacity: 1;
}


/* Модальное окно по умолчанию скрыто */
.modal {
    display: none;
    position: fixed;
    z-index: 1;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4); /* Черный фон с прозрачностью */
}

/* Содержимое модального окна */
.modal-content {
    background-color:#cdc1b4;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 500px;
    border-radius: 25px;
}

/* Кнопка закрытия */
.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    top: 0;
    right: 10px;
}

.close:hover,
.close:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

/* Стили для кнопки закрытия */
.close-btn {
    background-color: transparent;
    color: #776e65;
    padding: 10px 20px;
    cursor: pointer;
    border-radius: 25px;
    margin: 10px 0 0 0;
    letter-spacing: 1px;
    border: 1px solid #bbada0;
    text-transform: uppercase;
    font-weight: 700;
    font-size: 1em;

}

.close-btn:hover {
    background-color: #bbada0;
}


#leaderboard{
    cursor: pointer;
}


/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    #game-board {
        gap: 8px;
        box-shadow: none !important;
    }

    .tile {
        font-size: 1.5em;
    }

    #reset-button, #undo-button {
        font-size: 0.9em;
        padding: 4px 8px;
    }

    .game-info {
        grid-template-columns: 1fr; /* Все элементы в один столбец */
        gap: 8px;
    }
}

@media (max-width: 480px) {
    body{
        padding: 0 !important;
    }
    #game-board {
        gap: 5px;
        box-shadow: none !important;
        width: 94%;
    }

    .tile {
        font-size: 1.5em;
    }

    #reset-button, #undo-button {
        font-size: 0.8em;
        padding: 4px 8px;
    }

    .game-info {
        grid-template-columns: 1fr; /* Все элементы в один столбец */
        gap: 5px;
    }
}
