body {
    font-family: Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    background-color: #faf8ef;
    padding: 10px;
    box-sizing: border-box;
}

.container {
    text-align: center;
    width: 100%;
    max-width: 500px;
    padding: 15px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.subtitle {
    font-size: 24px;
    color: #776e65;
    margin-bottom: 10px;
}

h1 {
    font-size: 36px;
    color: #776e65;
    margin-bottom: 20px;
}

#game-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-gap: 2%;
    background-color: #bbada0;
    border-radius: 5px;
    padding: 2%;
    margin-bottom: 20px;
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1 / 1;
}

.tile {
    aspect-ratio: 1 / 1;
    background-color: #cdc1b4;
    border-radius: 3px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0;
    font-weight: bold;
    color: #776e65;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

#new-game {
    padding: 10px 20px;
    font-size: 18px;
    background-color: #8f7a66;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

.custom-alert {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.alert-content {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    animation: pop-in 0.3s ease-out;
    max-width: 80%;
}

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

#alert-message {
    font-size: 24px;
    margin-bottom: 20px;
    color: #776e65;
}

#alert-close {
    padding: 10px 20px;
    font-size: 18px;
    background-color: #8f7a66;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

.celebration {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: #f2b179;
    border-radius: 50%;
    animation: celebrate 1s ease-out;
    opacity: 0;
}

@keyframes celebrate {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(-100px); opacity: 0; }
}

.firework {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: firework 1.5s ease-out;
    opacity: 0;
}

@keyframes firework {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
     50% { opacity: 1; }
    100% { transform: translate(var(--x), var(--y)) scale(0); opacity: 0; }
}

#fireworks-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
}

/* 媒体查询，适应不同屏幕大小 */
@media (max-width: 500px) {
    body {
        padding: 5px;
    }

    .container {
        padding: 10px;
    }

    .subtitle {
        font-size: 20px;
    }

    h1 {
        font-size: 28px;
        margin-bottom: 15px;
    }

    #game-board {
        grid-gap: 1.5%;
        padding: 1.5%;
    }

    #new-game {
        padding: 8px 16px;
        font-size: 16px;
    }

    #alert-message {
        font-size: 20px;
    }

    #alert-close {
        padding: 8px 16px;
        font-size: 16px;
    }
}

/* 保持其他类的样式不变 */
.tile-2 { background-image: url('images/corn_kernel.png'); }
.tile-4 { background-image: url('images/four_corn_kernels.png'); }
.tile-8 { background-image: url('images/corn_cob.png'); }
.tile-16 { background-image: url('images/four_corn_cobs.png'); }
.tile-32 { background-image: url('images/popcorn_kernel.png'); }
.tile-64 { background-image: url('images/four_popcorn_kernels.png'); }
.tile-128 { background-image: url('images/popcorn_bag.png'); }
.tile-256 { background-image: url('images/popcorn_bucket.png'); }
.tile-512 { background-image: url('images/i_love_you.png'); }
.tile-1024 { background-image: url('images/1024.png'); }
.tile-2048 { background-image: url('images/2048.png'); }