/* 基本的界面設置 */
html,
body {
    height: 100%;
    background-color: #000000;
    margin: 0;
    padding: 0;
}

#game-container {
    display: flex;
    flex-direction: column;
    gap: 18px;
    justify-content: center;
    align-items: center;
    min-height: 90vh;
    padding: 24px 0;
    box-sizing: border-box;
    background-color: #000000;
}

.game-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 430px;
}

.game-actions h1 {
    margin: 0;
    color: #ffffff;
    font: bold 36px 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#restart-button {
    border: 0;
    border-radius: 6px;
    min-height: 48px;
    padding: 12px 24px;
    background-color: #a8e6a0;
    color: #000000;
    font: bold 18px 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    cursor: pointer;
}

#restart-button:hover {
    background-color: #5ae65e;
}

#restart-button:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 3px;
}

.score-panel {
    display: flex;
    gap: 12px;
    width: 430px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.score-card {
    flex: 1;
    min-width: 0;
    padding: 14px 16px;
    border-radius: 8px;
    background-color: #202020;
    color: #ffffff;
}

.score-label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    color: #bbbbbb;
}

.score-card strong {
    display: block;
    font-size: 28px;
    overflow-wrap: anywhere;
}

.score-note {
    width: 430px;
    margin: 0;
    color: #bbbbbb;
    font: 13px/1.6 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#grid-container {
    position: relative;
    display: grid;
    grid-template-columns: repeat(4, 100px);
    grid-template-rows: repeat(4, 100px);
    gap: 10px;
}

.grid {
    width: 100px;
    height: 100px;
    background-color: #ffffff;
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 50px;
    font-weight: bold;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #000000;
    box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.1);
    user-select: none;
}

/* 背景格子固定，數字方塊在上方獨立移動。 */
.grid {
    background-color: #d3d3d3;
}

.tile {
    position: absolute;
    top: 0;
    left: 0;
    width: 100px;
    height: 100px;
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    font: bold 50px 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #000000;
    user-select: none;
    pointer-events: none;
}

/* 根据方块的值设置不同的背景颜色 */
.grid-0 {
    background-color: #d3d3d3;
}

.grid-2 {
    background-color: #a8e6a0;
}

.grid-4 {
    background-color: #5ae65e;
}

.grid-8 {
    background-color: #ffeb3b;
}

.grid-16 {
    background-color: #fdd835;
}

.grid-32 {
    background-color: #ff9800;
}

.grid-64 {
    background-color: #f57c00;
}

.grid-128 {
    background-color: #f44336;
}

.grid-256 {
    background-color: #e53935;
}

.grid-512 {
    background-color: #9c27b0;
}

.grid-1024 {
    background-color: #7b1fa2;
}

.grid-2048 {
    background-color: #2196f3;
}