* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: #faf8ef;
    font-family: 'Clear Sans', 'Helvetica Neue', Arial, sans-serif;
}

/* 外层大容器 */
.game-container {
    max-width: 420px;
    margin: 20px auto;
    padding: 0 10px;
    width: 100%;
}

h1 {
    text-align: center;
    color: #776e65;
    font-size: 42px;
    margin-bottom: 15px;
}

/* 分数栏布局 */
.score-board {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    padding: 10px;
    background-color: #bbada0;
    border-radius: 6px;
    width: 100%;
}

.score-item {
    flex: 1 1 auto;
    text-align: center;
    min-width: 70px;
}

.score-board p {
    color: white;
    font-size: 14px;
    font-weight: bold;
    white-space: nowrap;
}

.score-board button {
    padding: 8px 10px;
    background-color: #8f7a66;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    flex-shrink: 0;
    transition: background-color 0.2s ease;
}

    .score-board button:hover {
        background-color: #9f8b76;
    }

/* 网格容器 正方形 */
#game-container.grid-container {
    width: 100%;
    height: 0;
    padding-top: 100%;
    position: relative;
    background-color: #bbada0;
    border-radius: 8px;
    outline: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
}

/* 7列7行网格 */
.grid-inner {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(7, 1fr);
    gap: 6px;
}

/* 单个格子 */
.grid-cell {
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    font-weight: bold;
    color: #776e65;
    transition: all 0.2s ease-in-out;
}

.empty {
    background-color: #cdc1b4;
}

/* ========== 7系列数字配色（渐变沿用原版风格） ========== */
.cell-7 {
    background-color: #eee4da;
}

.cell-14 {
    background-color: #ede0c8;
}

.cell-28 {
    background-color: #f2b179;
    color: #f9f6f2;
}

.cell-56 {
    background-color: #f59563;
    color: #f9f6f2;
}

.cell-112 {
    background-color: #f67c5f;
    color: #f9f6f2;
    font-size: 16px;
}

.cell-224 {
    background-color: #f65e3b;
    color: #f9f6f2;
    font-size: 16px;
}

.cell-448 {
    background-color: #edcf72;
    color: #f9f6f2;
    font-size: 15px;
}

.cell-896 {
    background-color: #edcc61;
    color: #f9f6f2;
    font-size: 14px;
}

.cell-1792 {
    background-color: #edc850;
    color: #f9f6f2;
    font-size: 13px;
}

.cell-3584 {
    background-color: #edc53f;
    color: #f9f6f2;
    font-size: 12px;
}

.cell-high {
    background-color: #3c3a32;
    color: #f9f6f2;
    font-size: 11px;
}

/* 新方块弹出动画 */
.spawn-animation {
    animation: spawn 0.2s ease-in-out;
    will-change: transform, opacity;
}

@keyframes spawn {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 游戏结束弹窗 + 遮罩 */
.game-over {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

    .game-over::before {
        content: "";
        position: absolute;
        inset: 0;
        background-color: rgba(0, 0, 0, 0.4);
    }

    .game-over > div {
        position: relative;
        background-color: rgba(238, 228, 218, 0.98);
        padding: 25px;
        border-radius: 10px;
        text-align: center;
        box-shadow: 0 0 30px rgba(0,0,0,0.3);
        max-width: 90vw;
    }

    .game-over h2 {
        color: #776e65;
        margin-bottom: 15px;
    }

    .game-over p {
        margin-bottom: 18px;
        font-size: 17px;
    }

    .game-over button {
        padding: 9px 18px;
        background-color: #8f7a66;
        color: white;
        border: none;
        border-radius: 4px;
        cursor: pointer;
        font-size: 15px;
        font-weight: bold;
        transition: background-color 0.2s ease;
    }

        .game-over button:hover {
            background-color: #9f8b76;
        }

/* 继续游戏弹窗 + 遮罩 */
.continue-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 101;
}

    .continue-modal::before {
        content: "";
        position: absolute;
        inset: 0;
        background-color: rgba(0, 0, 0, 0.4);
    }

    .continue-modal > div {
        position: relative;
        background-color: rgba(238, 228, 218, 0.98);
        padding: 25px;
        border-radius: 10px;
        text-align: center;
        box-shadow: 0 0 30px rgba(0,0,0,0.3);
        max-width: 90vw;
    }

    .continue-modal h2 {
        color: #776e65;
        margin-bottom: 18px;
    }

    .continue-modal .btn-group {
        display: flex;
        gap: 12px;
        justify-content: center;
        flex-wrap: wrap;
    }

    .continue-modal button {
        padding: 9px 18px;
        background-color: #8f7a66;
        color: white;
        border: none;
        border-radius: 4px;
        cursor: pointer;
        font-size: 15px;
        font-weight: bold;
        transition: background-color 0.2s ease;
    }

        .continue-modal button:hover {
            background-color: #9f8b76;
        }

/* 小屏手机适配 */
@media (max-width: 360px) {
    h1 {
        font-size: 34px;
    }

    .grid-cell {
        font-size: 16px;
    }

    .cell-112, .cell-224 {
        font-size: 14px;
    }

    .cell-448, .cell-896 {
        font-size: 12px;
    }

    .cell-1792, .cell-3584, .cell-high {
        font-size: 10px;
    }

    .grid-inner {
        gap: 4px;
        top: 8px;
        left: 8px;
        right: 8px;
        bottom: 8px;
    }

    .game-over > div,
    .continue-modal > div {
        padding: 18px;
    }
}
