* {
    margin: 0;
    padding: 0;
    /* box-sizing: border-box; */
    -webkit-tap-highlight-color: transparent;
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
}

button.difficulty {
    padding: 1px 6px;
}

body {
    background-color: #f0f0f0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    margin: 0 auto;
    /* overflow: hidden; */
    /* 防止页面滚动 */
    user-select: none;
    -webkit-user-select: none;
    cursor: default;
    /* 消除移动端点击高亮 */
    -webkit-tap-highlight-color: transparent;
}

main {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 450px;
    height: 96vh;
}

h1.title {
    padding: 0;
    margin: 0;
    font-size: 18px;
    position: absolute;
    text-align: center;
    top: 0;
    left: 0;
    right: 0;
}

footer {
    text-align: center;
}

/* 缩放容器：用于整体缩放游戏窗口 */
#scaler {
    transform-origin: center center;
    transition: transform 0.2s ease-out;
}

/* ============ CSS 样式 ============ */
#game-window {
    background: linear-gradient(to bottom, #eef3fa 0%, #d4e3f3 100%);
    border: 1px solid #688caf;
    border-radius: 4px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
    padding: 3px;
    display: inline-block;
}

/* 菜单栏 - 手机端加大一点点击区域 */
.menubar {
    font-size: 14px;
    color: #000;
    padding: 5px;
    background: transparent;
    margin-bottom: 2px;
    display: flex;
    gap: 15px;
}

.menubar span {
    cursor: pointer;
    padding: 2px 6px;
}

.menubar span:active {
    color: #0066cc;
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 2px;
}

.game-panel {
    background-color: #c0c0c0;
    border-left: 2px solid #fff;
    border-top: 2px solid #fff;
    border-right: 2px solid #808080;
    border-bottom: 2px solid #808080;
    padding: 5px;
}

/* 头部：修复了对齐问题 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 2px solid #808080;
    border-top: 2px solid #808080;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    padding: 4px 7px;
    margin-bottom: 5px;
    background: #c0c0c0;
    height: 30px;
}

.counter {
    background-color: #000;
    color: #ff0000;
    font-family: "Courier New", Courier, monospace;
    font-weight: bold;
    font-size: 24px;
    line-height: 24px;
    padding: 1px;
    width: 42px;
    text-align: right;
    border-left: 1px solid #808080;
    border-top: 1px solid #808080;
    border-right: 1px solid #fff;
    border-bottom: 1px solid #fff;
    letter-spacing: 1px;
    height: 24px;
    box-sizing: content-box;
}

/* 笑脸按钮 - Flex居中 */
#face-btn {
    width: 26px;
    height: 26px;
    border: 1px solid #808080;
    outline: none;
    background: #c0c0c0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    margin: 0;
    font-size: 18px;
    cursor: pointer;
    border-left: 1px solid #fff;
    border-top: 1px solid #fff;
    border-right: 1px solid #808080;
    border-bottom: 1px solid #808080;
    box-shadow: inset 1px 1px 0 #fff;
}

#face-btn:active {
    border-left: 1px solid #808080;
    border-top: 1px solid #808080;
    border-right: 1px solid #fff;
    border-bottom: 1px solid #fff;
    box-shadow: none;
    padding-top: 2px;
    padding-left: 2px;
}

#grid {
    display: grid;
    border-left: 3px solid #808080;
    border-top: 3px solid #808080;
    border-right: 3px solid #fff;
    border-bottom: 3px solid #fff;
    touch-action: none;
    /* 禁止浏览器默认触摸行为（滚动缩放） */
}

.cell {
    width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    font-size: 12px;
    font-weight: 900;
    background: #c0c0c0;
    border-left: 2px solid #fff;
    border-top: 2px solid #fff;
    border-right: 2px solid #808080;
    border-bottom: 2px solid #808080;
}

/* 触摸反馈样式 */
.cell.pressed {
    border: none;
    width: 20px;
    height: 20px;
    background: #bdbdbd;
}

.cell.open {
    border: 1px solid #777;
    width: 18px;
    height: 18px;
    background: #c0c0c0;
}

/* 颜色定义 */
.c1 {
    color: blue;
}

.c2 {
    color: green;
}

.c3 {
    color: red;
}

.c4 {
    color: darkblue;
}

.c5 {
    color: darkred;
}

.c6 {
    color: darkcyan;
}

.c7 {
    color: black;
}

.c8 {
    color: gray;
}

.cell.mine {
    background-color: #c0c0c0;
}

.cell.mine-exploded {
    background-color: red;
    border: 1px solid #777;
    width: 18px;
    height: 18px;
}

.cell.flag {
    color: red;
}

.cell.wrong-mine {
    position: relative;
}

.cell.wrong-mine::after {
    content: "❌";
    color: red;
    font-size: 14px;
    position: absolute;
    left: -1px;
    top: 0;
    width: 100%;
    height: 100%;
}