/* game.css */

/* Контейнер игрового поля */
.game-board {
    display: grid;
    grid-template-columns: repeat(5, 60px);
    grid-template-rows: repeat(5, 60px);
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 20px auto;
    perspective: 1000px; /* Добавляет глубину для анимаций */
}

/* Стили каждой ячейки (плитки) */
.game-board div {
    width: 60px;
    height: 60px;
    background-color: rgba(255, 255, 255, 0.1);
    border: 2px solid #ffd700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    user-select: none; /* Запрещаем выделение текста символов */
    position: relative;
    
    /* Плавное перемещение при гравитации (падении) */
    /* cubic-bezier делает падение более "физичным" (ускорение в конце) */
    transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                opacity 0.2s, 
                background-color 0.3s ease;
}

/* Ховер-эффект */
.game-board div:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Состояние при перетаскивании (мышь/тач) */
.dragging {
    transform: scale(1.1);
    z-index: 100;
    opacity: 0.7;
    background-color: rgba(255, 215, 0, 0.3) !important;
    border-color: #fff !important;
}

/* Эффект сгорающей бумаги/фотографии */
.cell-burn {
    pointer-events: none;
    z-index: 100;
    animation: paperBurn 0.6s forwards ease-in-out;
    border-color: #222 !important; /* Цвет пепла */
}

@keyframes paperBurn {
    0% {
        transform: scale(1);
        filter: brightness(1) sepia(0);
        background-color: rgba(255, 255, 255, 0.1);
    }
    30% {
        /* Плитка начинает желтеть и обугливаться по краям */
        filter: brightness(0.8) sepia(0.5) contrast(1.2);
        background-color: #5c4033; /* Цвет жженой бумаги */
        box-shadow: inset 0 0 20px #000;
        transform: scale(1.05) rotate(2deg);
    }
    60% {
        /* Появление "дыр" и раскаленных краев */
        filter: brightness(0.5) sepia(1) saturate(2);
        box-shadow: inset 0 0 30px #ff4500, 0 0 15px #ff4500;
        opacity: 0.8;
    }
    100% {
        /* Плитка рассыпается в пепел */
        transform: scale(0.8) translateY(10px) rotate(-5deg);
        filter: brightness(0) blur(3px);
        opacity: 0;
        /* Создаем рваный край через clip-path */
        clip-path: polygon(10% 0%, 90% 10%, 100% 50%, 80% 95%, 10% 80%, 0% 40%);
    }
}

@keyframes astrologicalBurn {
    0% { 
        transform: scale(1); 
        filter: brightness(1); 
    }
    40% { 
        transform: scale(1.3); 
        filter: brightness(2) hue-rotate(90deg); 
    }
    100% { 
        transform: scale(0); 
        filter: brightness(3) opacity(0); 
    }
}

/* Эффект появления новых плиток, прилетающих сверху */
.cell-new {
    animation: slideInDown 0.25s ease-out;
}

@keyframes slideInDown {
    from { 
        transform: translateY(-60px); 
        opacity: 0; 
    }
    to { 
        transform: translateY(0); 
        opacity: 1; 
    }
}

/* Вспышка поля при автоматическом перемешивании (когда нет ходов) */
.shuffle-flash {
    animation: flash 0.6s ease-in-out;
}

@keyframes flash {
    0% { filter: contrast(1); }
    50% { filter: contrast(1.5) brightness(1.2); }
    100% { filter: contrast(1); }
}

/* Стили интерфейса */
#game-info {
    text-align: center;
    margin: 20px 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #ffd700;
}

#restart-game {
    display: block;
    margin: 20px auto;
    padding: 10px 20px;
    background: transparent;
    border: 1px solid #ffd700;
    color: #ffd700;
    cursor: pointer;
    transition: 0.3s;
}

#restart-game:hover {
    background: #ffd700;
    color: #000;
}

/* Таблица лидеров */
#leaderboard {
    max-width: 300px;
    margin: 20px auto;
    color: #fff;
}

#leaderboard table {
    width: 100%;
    border-collapse: collapse;
}

#leaderboard th, #leaderboard td {
    padding: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    text-align: left;
}