/* 游戏棋盘样式 */
.game-board {
    display: grid;
    gap: 3px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

/* 不同尺寸的棋盘 */
.game-board.size-3 {
    grid-template-columns: repeat(3, 80px);
    grid-template-rows: repeat(3, 80px);
    width: 270px;
    height: 270px;
}

.game-board.size-4 {
    grid-template-columns: repeat(4, 70px);
    grid-template-rows: repeat(4, 70px);
    width: 295px;
    height: 295px;
}

.game-board.size-5 {
    grid-template-columns: repeat(5, 60px);
    grid-template-rows: repeat(5, 60px);
    width: 315px;
    height: 315px;
}

.game-board.size-6 {
    grid-template-columns: repeat(6, 50px);
    grid-template-rows: repeat(6, 50px);
    width: 315px;
    height: 315px;
}

/* 棋盘格子样式 */
.tile {
    background: linear-gradient(145deg, #ffffff, #e2e8f0);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.5rem;
    color: #2d3748;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    box-shadow:
        0 4px 8px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
    position: relative;
    overflow: hidden;
}

.tile:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(145deg, transparent 0%, rgba(255, 255, 255, 0.1) 50%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tile:hover:before {
    opacity: 1;
}

/* 可移动的格子悬停效果 */
.tile.movable {
    cursor: pointer;
    transform: scale(1);
}

.tile.movable:hover {
    transform: scale(1.05);
    box-shadow:
        0 6px 15px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    background: linear-gradient(145deg, #f7fafc, #edf2f7);
}

.tile.movable:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

/* 空格子样式 */
.tile.empty {
    background: rgba(0, 0, 0, 0.1);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.2);
    cursor: default;
}

.tile.empty:hover {
    transform: none;
    background: rgba(0, 0, 0, 0.1);
}

/* 移动动画 */
.tile.moving {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

/* 胜利状态动画 */
.game-board.victory {
    animation: victoryPulse 0.6s ease-in-out;
}

@keyframes victoryPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

.tile.victory-tile {
    animation: victoryGlow 0.8s ease-in-out infinite alternate;
}

@keyframes victoryGlow {
    from {
        box-shadow:
            0 4px 8px rgba(0, 0, 0, 0.1),
            inset 0 1px 0 rgba(255, 255, 255, 0.6);
    }

    to {
        box-shadow:
            0 4px 8px rgba(0, 0, 0, 0.1),
            inset 0 1px 0 rgba(255, 255, 255, 0.6),
            0 0 20px rgba(102, 126, 234, 0.5);
    }
}

/* 数字样式调整 */
.tile span {
    font-family: 'Microsoft YaHei', 'Segoe UI', Arial, sans-serif;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* 特殊数字颜色 */
.tile[data-number="1"] {
    color: #e53e3e;
}

.tile[data-number="2"] {
    color: #dd6b20;
}

.tile[data-number="3"] {
    color: #d69e2e;
}

.tile[data-number="4"] {
    color: #38a169;
}

.tile[data-number="5"] {
    color: #3182ce;
}

.tile[data-number="6"] {
    color: #805ad5;
}

.tile[data-number="7"] {
    color: #d53f8c;
}

.tile[data-number="8"] {
    color: #319795;
}

.tile[data-number="9"] {
    color: #2d3748;
}

/* 较大数字的字体调整 */
.size-4 .tile {
    font-size: 1.3rem;
}

.size-5 .tile {
    font-size: 1.1rem;
}

.size-6 .tile {
    font-size: 1rem;
}

/* 无效移动的反馈动画 */
.tile.invalid-move {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-3px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(3px);
    }
}

/* 加载状态 */
.game-board.loading {
    opacity: 0.6;
    pointer-events: none;
}

.game-board.loading .tile {
    animation: loadingPulse 1.5s ease-in-out infinite;
}

@keyframes loadingPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* 提示高亮 */
.tile.hint {
    animation: hintBlink 1s ease-in-out 3;
    border: 2px solid #667eea;
}

@keyframes hintBlink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* 暂停状态遮罩 */
.game-board.paused::after {
    content: '游戏已暂停';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 20px 30px;
    border-radius: 10px;
    font-size: 1.2rem;
    font-weight: bold;
    z-index: 100;
}

.game-board.paused {
    position: relative;
    filter: blur(2px);
    pointer-events: none;
}