/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
}

body {
    background-color: #faf8ef;
    color: #776e65;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 500px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* 游戏标题 */
.game-title {
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 20px;
    color: #776e65;
    text-align: center;
}

/* 游戏信息栏 */
.game-info {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 20px;
    gap: 10px;
}

.info-item {
    background-color: #bbada0;
    color: white;
    border-radius: 4px;
    padding: 10px;
    text-align: center;
    flex: 1;
    min-width: 80px;
}

.info-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.info-value {
    font-size: 1.5rem;
    font-weight: bold;
}

/* 游戏容器 */
.game-container {
    width: 100%;
    background-color: #bbada0;
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 20px;
}

/* 游戏棋盘 */
.game-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 10px;
    aspect-ratio: 1;
    background-color: #cdc1b4;
    border-radius: 4px;
    padding: 10px;
}

/* 游戏格子 */
.grid-cell {
    background-color: #eee4da;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: bold;
    transition: all 0.15s ease;
    position: relative;
    overflow: hidden;
}

/* 数字方块 */
.tile {
    position: absolute;
    width: calc(25% - 10px);
    height: calc(25% - 10px);
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: bold;
    transition: all 0.15s ease;
    z-index: 10;
    cursor: default;
    user-select: none;
}

/* 不同数字的背景颜色 */
.tile-2 {
    background-color: #eee4da;
    color: #776e65;
}

.tile-4 {
    background-color: #ede0c8;
    color: #776e65;
}

.tile-8 {
    background-color: #f2b179;
    color: white;
}

.tile-16 {
    background-color: #f59563;
    color: white;
}

.tile-32 {
    background-color: #f67c5f;
    color: white;
}

.tile-64 {
    background-color: #f65e3b;
    color: white;
}

.tile-128 {
    background-color: #edcf72;
    color: white;
    font-size: 1.5rem;
    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.2381), inset 0 0 0 1px rgba(255, 255, 255, 0.1429);
}

.tile-256 {
    background-color: #edcc61;
    color: white;
    font-size: 1.5rem;
    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.3174), inset 0 0 0 1px rgba(255, 255, 255, 0.1905);
}

.tile-512 {
    background-color: #edc850;
    color: white;
    font-size: 1.5rem;
    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.3968), inset 0 0 0 1px rgba(255, 255, 255, 0.2381);
}

.tile-1024 {
    background-color: #edc53f;
    color: white;
    font-size: 1.2rem;
    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.4762), inset 0 0 0 1px rgba(255, 255, 255, 0.2857);
}

.tile-2048 {
    background-color: #edc22e;
    color: white;
    font-size: 1.2rem;
    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.5556), inset 0 0 0 1px rgba(255, 255, 255, 0.3333);
}

/* 更高数字的样式 */
.tile-super {
    background-color: #3c3a32;
    color: white;
    font-size: 1rem;
    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.5556), inset 0 0 0 1px rgba(255, 255, 255, 0.3333);
}

/* 合并动画 */
.tile-merged {
    animation: tileMerge 0.2s ease-in-out;
}

@keyframes tileMerge {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

/* 新生成的方块动画 */
.tile-new {
    animation: tileNew 0.2s ease-in-out;
}

@keyframes tileNew {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 控制按钮 */
.control-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    width: 100%;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
}

.btn-primary {
    background-color: #8f7a66;
    color: white;
}

.btn-primary:hover {
    background-color: #9f8b77;
}

.btn-secondary {
    background-color: #bbada0;
    color: white;
}

.btn-secondary:hover {
    background-color: #cbbab0;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 游戏说明 */
.game-instructions {
    background-color: rgba(238, 228, 218, 0.5);
    padding: 15px;
    border-radius: 6px;
    width: 100%;
    margin-top: 20px;
}

.game-instructions h3 {
    margin-bottom: 10px;
    color: #776e65;
}

.game-instructions ul {
    list-style-position: inside;
    color: #776e65;
    line-height: 1.5;
}

.game-instructions li {
    margin-bottom: 5px;
}

/* 游戏结束遮罩 */
.game-over-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(238, 228, 218, 0.73);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.game-over-overlay.show {
    opacity: 1;
    visibility: visible;
}

.game-over-content {
    background-color: white;
    padding: 30px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-width: 90%;
    width: 400px;
}

.game-over-content h2 {
    color: #776e65;
    margin-bottom: 20px;
}

.game-over-content p {
    color: #776e65;
    margin-bottom: 20px;
    font-size: 1.2rem;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .game-title {
        font-size: 2rem;
    }
    
    .info-value {
        font-size: 1.2rem;
    }
    
    .tile {
        font-size: 1.5rem;
    }
    
    .tile-128, .tile-256, .tile-512 {
        font-size: 1.2rem;
    }
    
    .tile-1024, .tile-2048 {
        font-size: 1rem;
    }
    
    .tile-super {
        font-size: 0.8rem;
    }
    
    .game-instructions {
        padding: 10px;
    }
    
    .game-instructions ul {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .game-title {
        font-size: 1.8rem;
    }
    
    .game-info {
        gap: 5px;
    }
    
    .info-item {
        padding: 8px;
    }
    
    .info-value {
        font-size: 1rem;
    }
    
    .tile {
        font-size: 1.2rem;
    }
    
    .tile-128, .tile-256, .tile-512 {
        font-size: 1rem;
    }
    
    .tile-1024, .tile-2048 {
        font-size: 0.8rem;
    }
    
    .tile-super {
        font-size: 0.7rem;
    }
}