/* 基础布局 */
.game-list {
    max-width: 800px;
    margin: 20px auto;
    padding: 20px;
}

.game-item {
    margin-bottom: 30px;
}

/* 游戏标题样式 */
.game-title {
    background: var(--grid-bg);
    color: var(--text-color);
    padding: 15px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.game-title:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* 游戏容器样式 */
.game-content {
    display: none;
}

.game-content.show {
    display: block;
}

.container {
    padding: 20px;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s ease;
}

.container.show {
    opacity: 1;
    transform: translateY(0);
}

/* 网格和方块基础样式 */
.grid-container {
    position: relative;
    width: 470px;
    height: 470px;
    padding: 15px;
    background: #bbada0;
    border-radius: 6px;
    margin: 0 auto;
}

.tile {
    position: absolute;
    width: 100px;
    height: 100px;
    line-height: 100px;
    font-size: 40px;
    font-weight: bold;
    border-radius: 3px;
    background-color: var(--tile-bg);
    color: var(--tile-text);
    text-align: center;
    transition: all 0.2s ease-out;
    z-index: 1;
    will-change: transform;
    backface-visibility: hidden;
    transform: translateZ(0);
}

/* 移动端适配 */
@media (max-width: 520px) {
    .game-list {
        margin: 10px;
        padding: 10px;
    }

    .game-title {
        font-size: 18px;
        padding: 12px;
        margin-bottom: 15px;
    }

    .container {
        padding: 10px 5px;
    }

    .grid-container {
        width: 280px !important;
        height: 280px !important;
        padding: 8px !important;
        margin: 10px auto !important;
        border-radius: 6px !important;
        background: #bbada0 !important;
        position: relative !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }

    /* 网格背景 */
    .grid-background {
        position: absolute !important;
        top: 8px !important;
        left: 8px !important;
        width: 264px !important;        /* 精确计算: 容器宽度 - padding * 2 */
        height: 264px !important;       /* 精确计算: 容器高度 - padding * 2 */
        display: grid !important;
        grid-template-columns: repeat(4, 62px) !important;  /* 固定列宽 */
        grid-gap: 5px !important;       /* 减小间距使对齐更精确 */
        z-index: 1 !important;
    }

    /* 网格单元格样式 */
    .grid-cell {
        width: 62px !important;         /* 与方块大小一致 */
        height: 62px !important;
        margin: 0 !important;
        border-radius: 3px !important;
        background: rgba(238, 228, 218, 0.35) !important;
    }

    .grid-row {
        margin-bottom: 5px !important;
    }

    .score-board {
        gap: 8px;
        margin: 8px 0;
    }

    .button-container {
        gap: 8px;
        margin: 8px 0;
    }

    .settings {
        gap: 8px;
        margin: 8px 0;
    }

    /* 移动端方块样式 */
    .tile {
        width: 62px !important;
        height: 62px !important;
        margin: 0 !important;
        border-radius: 3px !important;
        font-size: 24px !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        padding: 0 !important;
        position: absolute !important;
        box-sizing: border-box !important;
        z-index: 2 !important;
        transform-origin: center !important;
        left: 8px !important;
        top: 8px !important;
        transition: all 0.2s cubic-bezier(0.4, 0.0, 0.2, 1) !important;
        will-change: transform !important;
        backface-visibility: hidden !important;
        -webkit-backface-visibility: hidden !important;
        -webkit-perspective: 1000 !important;
        perspective: 1000 !important;
    }

    /* 根据文字长度调整字体大小 */
    .tile[data-length="2"] {
        font-size: 20px !important;
    }

    .tile[data-length="3"] {
        font-size: 16px !important;
    }

    .tile[data-length="4"] {
        font-size: 14px !important;
    }

    /* 调整方块位置 - 使用固定位置 */
    .tile-position-1-1 { transform: translate(0, 0) translateZ(0) !important; }
    .tile-position-1-2 { transform: translate(67px, 0) translateZ(0) !important; }
    .tile-position-1-3 { transform: translate(134px, 0) translateZ(0) !important; }
    .tile-position-1-4 { transform: translate(201px, 0) translateZ(0) !important; }

    .tile-position-2-1 { transform: translate(0, 67px) translateZ(0) !important; }
    .tile-position-2-2 { transform: translate(67px, 67px) translateZ(0) !important; }
    .tile-position-2-3 { transform: translate(134px, 67px) translateZ(0) !important; }
    .tile-position-2-4 { transform: translate(201px, 67px) translateZ(0) !important; }

    .tile-position-3-1 { transform: translate(0, 134px) translateZ(0) !important; }
    .tile-position-3-2 { transform: translate(67px, 134px) translateZ(0) !important; }
    .tile-position-3-3 { transform: translate(134px, 134px) translateZ(0) !important; }
    .tile-position-3-4 { transform: translate(201px, 134px) translateZ(0) !important; }

    .tile-position-4-1 { transform: translate(0, 201px) translateZ(0) !important; }
    .tile-position-4-2 { transform: translate(67px, 201px) translateZ(0) !important; }
    .tile-position-4-3 { transform: translate(134px, 201px) translateZ(0) !important; }
    .tile-position-4-4 { transform: translate(201px, 201px) translateZ(0) !important; }

    /* 方块合并动画 */
    .tile-merged {
        animation: tile-merge 0.25s cubic-bezier(0.4, 0.0, 0.2, 1) forwards !important;
        z-index: 3 !important;
    }

    @keyframes tile-merge {
        0% {
            transform: scale(1) translateZ(0);
        }
        50% {
            transform: scale(1.2) translateZ(0);
        }
        100% {
            transform: scale(1) translateZ(0);
        }
    }

    /* 新方块出现动画 */
    .tile-new {
        animation: tile-appear 0.25s cubic-bezier(0.4, 0.0, 0.2, 1) forwards !important;
    }

    @keyframes tile-appear {
        0% {
            transform: scale(0) translateZ(0);
            opacity: 0;
        }
        50% {
            transform: scale(1.1) translateZ(0);
            opacity: 0.5;
        }
        100% {
            transform: scale(1) translateZ(0);
            opacity: 1;
        }
    }
}

/* 游戏特定样式 */
#game2048-content .tile {
    font-size: 40px;
    line-height: 100px;
}

#game2048-xzd-content .tile-xzd {
    font-size: 32px;
    font-family: "Microsoft YaHei", "微软雅黑", sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 5px;
    line-height: 1.2;
}

/* 移动端游戏特定样式 */
@media (max-width: 520px) {
    #game2048-content .tile {
        width: 67.5px !important;
        height: 67.5px !important;
        line-height: 67.5px !important;
        font-size: 28px !important;
    }

    #game2048-xzd-content .tile-xzd {
        width: 67.5px !important;
        height: 67.5px !important;
        font-size: 20px !important;
        padding: 2px !important;
    }
}

/* 基础颜色变量 */
:root {
    --bg-color: #faf8ef;
    --text-color: #776e65;
    --grid-bg: #bbada0;
    --tile-bg: #eee4da;
    --tile-text: #776e65;
}

/* 深色主题 */
[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --text-color: #f9f6f2;
    --grid-bg: #4a4a4a;
    --tile-bg: #525252;
    --tile-text: #f9f6f2;
}

/* 方块颜色样式 */
.tile[data-value="2"] {
    background-color: #eee4da;
    color: #776e65;
}

.tile[data-value="4"] {
    background-color: #ede0c8;
    color: #776e65;
}

.tile[data-value="8"] {
    background-color: #f2b179;
    color: #f9f6f2;
}

.tile[data-value="16"] {
    background-color: #f59563;
    color: #f9f6f2;
}

.tile[data-value="32"] {
    background-color: #f67c5f;
    color: #f9f6f2;
}

.tile[data-value="64"] {
    background-color: #f65e3b;
    color: #f9f6f2;
}

.tile[data-value="128"] {
    background-color: #edcf72;
    color: #f9f6f2;
    font-size: 35px;
}

.tile[data-value="256"] {
    background-color: #edcc61;
    color: #f9f6f2;
    font-size: 35px;
}

.tile[data-value="512"] {
    background-color: #edc850;
    color: #f9f6f2;
    font-size: 35px;
}

.tile[data-value="1024"] {
    background-color: #edc53f;
    color: #f9f6f2;
    font-size: 30px;
}

.tile[data-value="2048"] {
    background-color: #edc22e;
    color: #f9f6f2;
    font-size: 30px;
}

/* 动画效果 */
.tile-new {
    animation: tile-appear 0.2s ease-out;
}

@keyframes tile-appear {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.tile-merged {
    animation: tile-merge 0.2s ease-out;
    z-index: 2;
}

@keyframes tile-merge {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

/* 其他UI元素样式 */
.score-board {
    display: flex;
    justify-content: space-between;
    margin: 20px 0;
    gap: 20px;
}

.score-box {
    background: var(--grid-bg);
    padding: 10px 25px;
    border-radius: 6px;
    color: white;
}

.score-box span {
    display: block;
    text-align: center;
}

.score-box span:first-child {
    font-size: 16px;
    margin-bottom: 5px;
}

.score-box span:last-child {
    font-size: 24px;
}

.button-container {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
}

.button-container button,
.settings button {
    background-color: var(--grid-bg);
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 16px;
    border-radius: 3px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.button-container button:hover,
.settings button:hover {
    background-color: var(--text-color);
}

/* 键盘提示样式 */
.keyboard-tips {
    margin-top: 20px;
    color: var(--text-color);
    font-size: 14px;
}

.keyboard-tips kbd {
    background: #f4f4f4;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 2px 6px;
    margin: 0 3px;
}

/* 统计信息样式 */
.stats {
    margin-top: 20px;
    padding: 15px;
    background: var(--grid-bg);
    border-radius: 6px;
    color: white;
}

.stats p {
    margin: 5px 0;
    font-size: 16px;
} 
