/* ... (前面大部分样式保持不变) ... */

/* 【新增】通用控制按钮样式 */
.control-button,
.new-game-button {
    background-color: #8f7a66;
    color: #f9f6f2;
    padding: 18px 20px;
    border-radius: var(--border-radius);
    font-weight: bold;
    cursor: pointer;
    border: none;
    user-select: none;
    align-self: flex-end;
    white-space: nowrap;
}

.control-button:hover,
.new-game-button:hover {
    background-color: #9e8b77;
}

/* 【新增】按钮禁用时的样式 */
.control-button:disabled {
    background-color: #d1c7bd;
    cursor: not-allowed;
    opacity: 0.6;
}

/* ... (后面所有样式保持不变) ... */

/* --- 样式文件其余部分与上一版本完全相同 --- */
:root {
    --board-size: 450px;
    --grid-gap: 15px;
    --border-radius: 6px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #faf8ef;
    color: #776e65;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
    padding: 20px;
    touch-action: none;
}

.container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: var(--board-size);
    margin-bottom: 10px;
}

h1 {
    font-size: 80px;
    font-weight: bold;
    margin: 0;
}

.header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.scores-container {
    display: flex;
    gap: 8px;
}

.score-box {
    background-color: #bbada0;
    padding: 8px 25px;
    border-radius: var(--border-radius);
    text-align: center;
    color: #eee4da;
    font-weight: bold;
}

.score-box .label {
    font-size: 13px;
    display: block;
}

.score-box .value {
    font-size: 25px;
    color: white;
    display: block;
}

.game-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.control-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.control-label {
    font-size: 13px;
    color: #bbada0;
    font-weight: bold;
    margin-bottom: 2px;
}

#board-size-selector {
    background-color: #bbada0;
    color: #f9f6f2;
    border: none;
    border-radius: var(--border-radius);
    padding: 8px;
    font-weight: bold;
    cursor: pointer;
}

#board-size-selector:focus {
    outline: none;
}

.instructions {
    width: var(--board-size);
    text-align: center;
    margin-bottom: 20px;
    line-height: 1.6;
}

#game-board {
    width: var(--board-size);
    height: var(--board-size);
    background-color: #bbada0;
    border-radius: var(--border-radius);
    padding: var(--grid-gap);
    display: grid;
    gap: var(--grid-gap);
    position: relative;
}

.grid-cell {
    background-color: #cdc1b4;
    border-radius: var(--border-radius);
}

.tile {
    position: absolute;
    width: var(--tile-size);
    height: var(--tile-size);
    border-radius: var(--border-radius);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 55px;
    
    --r: 0;
    --c: 0;
    top: calc(var(--r) * (var(--tile-size) + var(--grid-gap)) + var(--grid-gap));
    left: calc(var(--c) * (var(--tile-size) + var(--grid-gap)) + var(--grid-gap));
    
    transition: top 100ms ease-in-out, left 100ms ease-in-out;

    animation-duration: 200ms;
    animation-timing-function: ease;
}

.container.board-size-3 .tile { font-size: 65px; }
.container.board-size-5 .tile { font-size: 40px; }
.container.board-size-5 .tile-1024,
.container.board-size-5 .tile-2048,
.container.board-size-5 .tile-super { font-size: 30px; }


.tile.new-tile { animation-name: appear; }
.tile.merged-tile { animation-name: pop; animation-delay: 100ms; }

@keyframes appear { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes pop { 0% { transform: scale(1); } 50% { transform: scale(1.2); } 100% { transform: scale(1); } }

.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: 45px; }
.tile-256 { background-color: #edcc61; color: #f9f6f2; font-size: 45px; }
.tile-512 { background-color: #edc850; color: #f9f6f2; font-size: 45px; }
.tile-1024 { background-color: #edc53f; color: #f9f6f2; font-size: 35px; }
.tile-2048 { background-color: #edc22e; color: #f9f6f2; font-size: 35px; }
.tile-super { background-color: #3c3a32; color: #f9f6f2; font-size: 30px; }

#game-over-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(238, 228, 218, 0.73);
    display: flex; justify-content: center; align-items: center; flex-direction: column;
    z-index: 100; opacity: 0; visibility: hidden; transition: opacity 0.5s; border-radius: var(--border-radius);
}
#game-over-overlay.show { opacity: 1; visibility: visible; }
#game-over-overlay h2 { font-size: 60px; color: #776e65; margin: 0 0 20px 0; }

@media (max-width: 500px) {
    :root { --board-size: 90vw; --grid-gap: 3vw; }
    h1 { font-size: 15vw; }
    .header { flex-direction: column; gap: 15px; }
    .header-right { align-items: center; }
    .score-box .label { font-size: 12px; }
    .score-box .value { font-size: 20px; }
    .tile { font-size: 8vw; }
    .container.board-size-3 .tile { font-size: 10vw; }
    .container.board-size-5 .tile { font-size: 6vw; }
    .tile-128, .tile-256, .tile-512 { font-size: 7vw; }
    .tile-1024, .tile-2048, .tile-super { font-size: 5vw; }
    #game-over-overlay h2 { font-size: 10vw; }
}