.game-container-2048 {
    width: 100%;
    max-width: 480px;
    margin: 20px auto;
    background-color: #bbada0;
    padding: 15px;
    border-radius: 6px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    font-family: Arial, sans-serif;
    user-select: none;
}

.game-header-2048 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.game-header-2048 h1 {
    font-size: 48px;
    color: #776e65;
    margin: 0;
}

.score-container-2048, .new-game-button-container-2048 {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.score-container-2048 {
    background-color: #bbada0;
    padding: 5px 15px;
    border-radius: 3px;
    color: #eee4da;
    font-size: 14px;
    font-weight: bold;
}

#score-2048 {
    font-size: 24px;
    color: #fff;
}
/* 這是新的、修正後的程式碼 */
.tile-2048 {
    width: 100%;
    /* 使用 aspect-ratio 來完美定義正方形，取代 padding-bottom 技巧 */
    aspect-ratio: 1 / 1; 
    background-color: #cdc1b4;
    border-radius: 3px;
    /* 以下的 flex 屬性現在可以正常運作了 */
    display: flex;
    align-items: center; /* 垂直置中 */
    justify-content: center; /* 水平置中 */
    font-size: 45px;
    font-weight: bold;
    color: #776e65;
    transition: transform 0.1s ease-in-out, background-color 0.1s ease-in-out;
}
.new-game-button-2048 {
    padding: 10px 15px;
    background-color: #8f7a66;
    color: #f9f6f2;
    border: none;
    border-radius: 3px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

.new-game-button-2048:hover {
    background-color: #9f8b77;
}

.grid-container-2048 {
    position: relative;
    background-color: #ccc0b3;
    border-radius: 4px;
}

.grid-2048 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 15px;
    padding: 15px;
}

/* 方塊顏色 */
.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; font-size: 35px; }
.tile-256 { background-color: #edcc61; color: #f9f6f2; font-size: 35px; }
.tile-512 { background-color: #edc850; color: #f9f6f2; font-size: 35px; }
.tile-1024 { background-color: #edc53f; color: #f9f6f2; font-size: 28px; }
.tile-2048 { background-color: #edc22e; color: #f9f6f2; font-size: 28px; }
.tile-4096 { background-color: #3c3a32; color: #f9f6f2; font-size: 28px; }
.tile-8192 { background-color: #3c3a32; color: #f9f6f2; font-size: 28px; }

.game-message-2048 {
    display: none;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background-color: rgba(238, 228, 218, 0.73);
    z-index: 100;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.game-message-2048 p {
    font-size: 60px;
    font-weight: bold;
    color: #776e65;
    margin: 0;
}
.game-message-2048.game-over p {
    color: #d9534f;
}
.game-message-2048.game-won p {
    color: #5cb85c;
}

@media (max-width: 520px) {
    .tile-2048 { font-size: 30px; }
    .tile-128, .tile-256, .tile-512 { font-size: 25px; }
    .tile-1024, .tile-2048, .tile-4096, .tile-8192 { font-size: 20px; }
}
