* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #faf8ef;
    color: #776e65;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 500px;
    width: 100%;
}

.title {
    font-size: 80px;
    font-weight: bold;
    margin-bottom: 20px;
    color: #776e65;
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.score-box, .best-box {
    background-color: #bbada0;
    color: white;
    padding: 10px 15px;
    border-radius: 5px;
    text-align: center;
    min-width: 100px;
}

.score-label, .best-label {
    font-size: 12px;
    text-transform: uppercase;
    font-weight: bold;
}

.score, .best {
    font-size: 24px;
    font-weight: bold;
    margin-top: 5px;
}

.restart-btn {
    background-color: #8f7a66;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    transition: background-color 0.2s;
}

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

.game-board {
    background-color: #bbada0;
    border-radius: 10px;
    padding: 15px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 15px;
    width: 100%;
    aspect-ratio: 1;
}

.tile {
    background-color: #cdc1b4;
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 40px;
    font-weight: bold;
    transition: all 0.2s ease;
    position: relative;
}

.tile-2 { background-color: #eee4da; color: #776e65; }
.tile-4 { background-color: #ede0c8; color: #776e65; }
.tile-8 { background-color: #f2b179; color: #f9f6f2; }
.tile-16 { background-color: #f59563; color: #f9f6f2; }
.tile-32 { background-color: #f67c5f; color: #f9f6f2; }
.tile-64 { background-color: #f65e3b; color: #f9f6f2; }
.tile-128 { background-color: #edcf72; color: #f9f6f2; 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: #f9f6f2; 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: #f9f6f2; 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: #f9f6f2; font-size: 30px; 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: #f9f6f2; font-size: 30px; box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.5556), inset 0 0 0 1px rgba(255, 255, 255, 0.3333); }

.tile-new {
    animation: appear 0.2s ease-in-out;
}

.tile-merged {
    animation: merge 0.2s ease-in-out;
}

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

@keyframes merge {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

.game-over {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(238, 228, 218, 0.73);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.game-over-content {
    background-color: white;
    padding: 40px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

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

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

.game-over-content button {
    background-color: #8f7a66;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 5px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    transition: background-color 0.2s;
}

.game-over-content button:hover {
    background-color: #9f8b77;
}

.instructions {
    margin-top: 20px;
    text-align: center;
    color: #776e65;
    font-size: 16px;
}

/* 响应式设计 */
@media (max-width: 500px) {
    .title {
        font-size: 60px;
    }
    
    .game-info {
        flex-direction: column;
        gap: 15px;
    }
    
    .score-box, .best-box, .restart-btn {
        width: 100%;
    }
    
    .tile {
        font-size: 30px;
    }
    
    .tile-1024, .tile-2048 {
        font-size: 24px;
    }
    
    .game-board {
        gap: 10px;
        padding: 10px;
    }
}