/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* 重置所有元素的margin和padding，使用border-box盒模型 */
}

/* 页面基本样式 */
body {
    font-family: 'Arial', sans-serif;
    /* 设置页面字体 */
    background-color: #f0f0f0;
    /* 设置页面背景色 */
    color: #333;
    /* 设置默认文字颜色 */
    line-height: 1.6;
    /* 设置行高，提高可读性 */
}

/* 导航栏样式 */
nav {
    background-color: #4CAF50;
    /* 导航栏背景色 */
    padding: 1rem;
    /* 内边距 */
    position: sticky;
    /* 粘性定位，滚动时固定在顶部 */
    top: 0;
    /* 固定在顶部 */
    z-index: 1000;
    /* 层级设置，确保在其他元素之上 */
}

nav ul {
    list-style: none;
    /* 移除默认列表样式 */
    display: flex;
    /* 使用Flex布局 */
    justify-content: center;
    /* 水平居中 */
    gap: 2rem;
    /* 列表项间距 */
}

nav a {
    color: white;
    /* 导航链接文字颜色 */
    text-decoration: none;
    /* 移除下划线 */
    font-size: 1.1rem;
    /* 字体大小 */
    font-weight: bold;
    /* 字体加粗 */
    padding: 0.5rem 1rem;
    /* 内边距 */
    border-radius: 4px;
    /* 圆角 */
    transition: background-color 0.3s ease;
    /* 背景色过渡效果 */
}

nav a:hover, nav a.active {
    background-color: #45a049;
    /* 鼠标悬停和激活状态的背景色 */
}

/* 主内容区域 */
main {
    max-width: 1200px;
    /* 最大宽度 */
    margin: 0 auto;
    /* 水平居中 */
    padding: 2rem;
    /* 内边距 */
}

/* 页面标题 */
h1 {
    text-align: center;
    /* 居中对齐 */
    margin-bottom: 2rem;
    /* 底部外边距 */
    color: #333;
    /* 文字颜色 */
}

/* 页面显示控制 */
.page {
    display: none;
    /* 默认隐藏所有页面 */
}

.page.active {
    display: block;
    /* 只显示带有active类的页面 */
}

/* 扫雷游戏样式 */
.game-container {
    max-width: 1200px;
    /* 游戏容器最大宽度，调整为更大值以适应高难度棋盘 */
    margin: 0 auto;
    /* 水平居中 */
    background-color: white;
    /* 背景色 */
    padding: 1.5rem;
    /* 内边距 */
    border-radius: 8px;
    /* 圆角 */
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    /* 阴影效果 */
    overflow-x: auto;
    /* 允许水平滚动，确保在小屏幕上也能查看完整棋盘 */
}

/* 游戏头部 */
.game-header {
    display: flex;
    /* Flex布局 */
    justify-content: space-between;
    /* 两端对齐 */
    align-items: center;
    /* 垂直居中 */
    margin-bottom: 1rem;
    /* 底部外边距 */
    padding: 0.5rem;
    /* 内边距 */
    background-color: #f5f5f5;
    /* 背景色 */
    border-radius: 4px;
    /* 圆角 */
    flex-wrap: wrap;
    /* 允许换行 */
    gap: 1rem;
    /* 元素间距 */
}

/* 难度选择器 */
.difficulty-selector {
    display: flex;
    /* Flex布局 */
    align-items: center;
    /* 垂直居中 */
    gap: 0.5rem;
    /* 元素间距 */
}

.difficulty-selector label {
    font-weight: bold;
    /* 字体加粗 */
    font-size: 0.9rem;
    /* 字体大小 */
    color: #666;
    /* 文字颜色 */
}

.difficulty-selector select {
    padding: 0.3rem 0.5rem;
    /* 内边距 */
    border: 1px solid #ddd;
    /* 边框 */
    border-radius: 4px;
    /* 圆角 */
    background-color: white;
    /* 背景色 */
    font-size: 0.9rem;
    /* 字体大小 */
    cursor: pointer;
    /* 鼠标指针 */
}

.difficulty-selector select:hover {
    border-color: #4CAF50;
    /* 鼠标悬停时的边框颜色 */
}

/* 计数器样式 */
.counter {
    display: flex;
    /* Flex布局 */
    align-items: center;
    /* 垂直居中 */
    gap: 0.5rem;
    /* 元素间距 */
    font-weight: bold;
    /* 字体加粗 */
}

/* 标签样式 */
.label {
    font-size: 0.9rem;
    /* 字体大小 */
    color: #666;
    /* 文字颜色 */
}

/* 地雷数和计时器样式 */
#mine-count, #timer {
    font-family: 'Courier New', monospace;
    /* 等宽字体，适合显示数字 */
    background-color: #000;
    /* 背景色 */
    color: #ff0000;
    /* 文字颜色 */
    padding: 0.2rem 0.5rem;
    /* 内边距 */
    border-radius: 3px;
    /* 圆角 */
    min-width: 40px;
    /* 最小宽度 */
    text-align: center;
    /* 文字居中 */
}

/* 重新开始按钮 */
#reset-btn {
    padding: 0.5rem 1rem;
    /* 内边距 */
    background-color: #4CAF50;
    /* 背景色 */
    color: white;
    /* 文字颜色 */
    border: none;
    /* 无边框 */
    border-radius: 4px;
    /* 圆角 */
    cursor: pointer;
    /* 鼠标指针 */
    font-weight: bold;
    /* 字体加粗 */
    transition: background-color 0.3s ease;
    /* 背景色过渡效果 */
}

#reset-btn:hover {
    background-color: #45a049;
    /* 鼠标悬停时的背景色 */
}

/* 游戏棋盘 */
#game-board {
    display: grid;
    /* Grid布局 */
    gap: 2px;
    /* 格子间距 */
    background-color: #808080;
    /* 背景色，调整为更明显的边框颜色 */
    padding: 3px;
    /* 内边距，形成完整边框 */
    border-radius: 2px;
    /* 圆角 */
    max-width: 100%;
    /* 最大宽度 */
    overflow-x: auto;
    /* 水平滚动 */
    justify-content: center;
    /* 水平居中 */
    border: 3px solid #808080;
    /* 添加完整的边框，确保所有难度下边框完整 */
    box-sizing: border-box;
    /* 使用border-box盒模型，确保边框不影响宽度计算 */
}

/* 游戏格子 */
.cell {
    width: 30px;
    /* 宽度 */
    height: 30px;
    /* 高度 */
    background-color: #c0c0c0;
    /* 背景色 */
    border: 2px solid;
    /* 边框 */
    border-top-color: #ffffff;
    /* 上边框颜色 */
    border-left-color: #ffffff;
    /* 左边框颜色 */
    border-bottom-color: #808080;
    /* 下边框颜色 */
    border-right-color: #808080;
    /* 右边框颜色 */
    display: flex;
    /* Flex布局 */
    align-items: center;
    /* 垂直居中 */
    justify-content: center;
    /* 水平居中 */
    font-weight: bold;
    /* 字体加粗 */
    cursor: pointer;
    /* 鼠标指针 */
    font-size: 0.9rem;
    /* 字体大小 */
    user-select: none;
    /* 禁止文本选择 */
    min-width: 30px;
    /* 最小宽度 */
}

/* 响应式调整 - 平板设备 */
@media (max-width: 768px) {
    .cell {
        width: 25px;
        /* 调整格子大小 */
        height: 25px;
        /* 调整格子大小 */
        font-size: 0.8rem;
        /* 调整字体大小 */
        min-width: 25px;
        /* 调整最小宽度 */
    }
}

/* 响应式调整 - 手机设备 */
@media (max-width: 480px) {
    .cell {
        width: 20px;
        /* 调整格子大小 */
        height: 20px;
        /* 调整格子大小 */
        font-size: 0.7rem;
        /* 调整字体大小 */
        min-width: 20px;
        /* 调整最小宽度 */
    }
}

/* 格子鼠标悬停效果 */
.cell:hover {
    background-color: #d0d0d0;
    /* 鼠标悬停时的背景色 */
}

/* 已揭示的格子 */
.cell.revealed {
    background-color: #e0e0e0;
    /* 背景色 */
    border: 1px solid #808080;
    /* 边框样式 */
    cursor: default;
    /* 鼠标指针 */
}

/* 标记为地雷的格子 */
.cell.flagged {
    background-color: #c0c0c0;
    /* 背景色 */
}

/* 地雷格子 */
.cell.mine {
    background-color: #ff0000;
    /* 背景色 */
}

/* 已揭示的地雷格子 */
.cell.mine.revealed::after {
    content: "💣";
    /* 显示地雷图标 */
}

/* 标记为地雷的格子 */
.cell.flagged::after {
    content: "🚩";
    /* 显示旗帜图标 */
}

/* 数字颜色 */
.cell.number-1 { color: #0000ff; } /* 1个相邻地雷 - 蓝色 */
.cell.number-2 { color: #008000; } /* 2个相邻地雷 - 绿色 */
.cell.number-3 { color: #ff0000; } /* 3个相邻地雷 - 红色 */
.cell.number-4 { color: #000080; } /* 4个相邻地雷 - 深蓝色 */
.cell.number-5 { color: #800000; } /* 5个相邻地雷 - 深红色 */
.cell.number-6 { color: #008080; } /* 6个相邻地雷 - 青色 */
.cell.number-7 { color: #000000; } /* 7个相邻地雷 - 黑色 */
.cell.number-8 { color: #808080; } /* 8个相邻地雷 - 灰色 */

/* 日历样式 */
.calendar-container {
    max-width: 600px;
    /* 日历容器最大宽度 */
    margin: 0 auto;
    /* 水平居中 */
    background-color: white;
    /* 背景色 */
    padding: 1.5rem;
    /* 内边距 */
    border-radius: 8px;
    /* 圆角 */
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    /* 阴影效果 */
}

/* 日历头部 */
.calendar-header {
    display: flex;
    /* Flex布局 */
    justify-content: space-between;
    /* 两端对齐 */
    align-items: center;
    /* 垂直居中 */
    margin-bottom: 1rem;
    /* 底部外边距 */
}

/* 月份导航按钮 */
.calendar-header button {
    padding: 0.5rem 1rem;
    /* 内边距 */
    background-color: #4CAF50;
    /* 背景色 */
    color: white;
    /* 文字颜色 */
    border: none;
    /* 无边框 */
    border-radius: 4px;
    /* 圆角 */
    cursor: pointer;
    /* 鼠标指针 */
    font-size: 1.2rem;
    /* 字体大小 */
    transition: background-color 0.3s ease;
    /* 背景色过渡效果 */
}

.calendar-header button:hover {
    background-color: #45a049;
    /* 鼠标悬停时的背景色 */
}

/* 当前月份显示 */
#current-month {
    font-size: 1.5rem;
    /* 字体大小 */
    font-weight: bold;
    /* 字体加粗 */
    color: #333;
    /* 文字颜色 */
}

/* 日历网格 */
#calendar-grid {
    display: grid;
    /* Grid布局 */
    grid-template-columns: repeat(7, 1fr);
    /* 7列 */
    gap: 5px;
    /* 格子间距 */
}

/* 星期头部 */
.day-header {
    text-align: center;
    /* 居中对齐 */
    font-weight: bold;
    /* 字体加粗 */
    padding: 0.5rem;
    /* 内边距 */
    background-color: #f5f5f5;
    /* 背景色 */
    border-radius: 4px;
    /* 圆角 */
    font-size: 0.9rem;
    /* 字体大小 */
    color: #666;
    /* 文字颜色 */
}

/* 日期格子 */
.day-cell {
    aspect-ratio: 1;
    /* 宽高比1:1 */
    display: flex;
    /* Flex布局 */
    align-items: center;
    /* 垂直居中 */
    justify-content: center;
    /* 水平居中 */
    background-color: #f9f9f9;
    /* 背景色 */
    border: 1px solid #ddd;
    /* 边框 */
    border-radius: 4px;
    /* 圆角 */
    cursor: pointer;
    /* 鼠标指针 */
    transition: all 0.3s ease;
    /* 过渡效果 */
    position: relative;
    /* 相对定位，用于定位打卡标记 */
}

/* 日期格子鼠标悬停效果 */
.day-cell:hover {
    background-color: #e9e9e9;
    /* 背景色 */
}

/* 其他月份的日期 */
.day-cell.other-month {
    color: #ccc;
    /* 文字颜色 */
    background-color: #f0f0f0;
    /* 背景色 */
    cursor: default;
    /* 鼠标指针 */
}

/* 今天的日期 */
.day-cell.today {
    background-color: #e3f2fd;
    /* 背景色 */
    border-color: #2196f3;
    /* 边框颜色 */
    font-weight: bold;
    /* 字体加粗 */
}

/* 已打卡的日期 */
.day-cell.checked {
    background-color: #c8e6c9;
    /* 背景色 */
    border-color: #4CAF50;
    /* 边框颜色 */
}

/* 打卡标记 */
.day-cell.checked::after {
    content: "✓";
    /* 显示对勾 */
    position: absolute;
    /* 绝对定位 */
    bottom: 2px;
    /* 底部位置 */
    right: 2px;
    /* 右侧位置 */
    font-size: 0.8rem;
    /* 字体大小 */
    color: #4CAF50;
    /* 颜色 */
    font-weight: bold;
    /* 字体加粗 */
}

/* 统计信息 */
.stats {
    display: flex;
    /* Flex布局 */
    justify-content: space-around;
    /* 均匀分布 */
    margin-top: 1.5rem;
    /* 顶部外边距 */
    padding: 1rem;
    /* 内边距 */
    background-color: #f5f5f5;
    /* 背景色 */
    border-radius: 4px;
    /* 圆角 */
}

.stats > div {
    text-align: center;
    /* 居中对齐 */
}

.stats .label {
    display: block;
    /* 块级显示 */
    font-size: 0.9rem;
    /* 字体大小 */
    color: #666;
    /* 文字颜色 */
    margin-bottom: 0.2rem;
    /* 底部外边距 */
}

.stats span:last-child {
    font-size: 1.5rem;
    /* 字体大小 */
    font-weight: bold;
    /* 字体加粗 */
    color: #4CAF50;
    /* 文字颜色 */
}

/* 响应式设计 - 手机设备 */
@media (max-width: 480px) {
    .game-container {
        padding: 1rem;
        /* 调整内边距 */
    }
    
    .cell {
        width: 32px;
        /* 调整格子大小 */
        height: 32px;
        /* 调整格子大小 */
        font-size: 1rem;
        /* 调整字体大小 */
    }
    
    .calendar-container {
        padding: 1rem;
        /* 调整内边距 */
    }
    
    .day-cell {
        font-size: 0.9rem;
        /* 调整字体大小 */
    }
}