/* style.css */

/* 通用样式 */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; /* 现代字体 */
    display: flex;
    flex-direction: column;
    align-items: center;
    /* justify-content: center; /* 移除此行，它会强制内容居中，可能导致溢出时不出现滚动条 */
    min-height: 100vh;
    background: linear-gradient(to bottom right, #e0f2f7, #c1e4ed); /* 渐变背景 */
    margin: 0;
    /* overflow: hidden; /* 移除此行，它会隐藏溢出内容，阻止滚动条出现 */

    /* 增加以下两行，允许垂直滚动 */
    overflow-y: auto; /* 允许垂直方向的滚动条 */
    padding: 20px 0; /* 给顶部和底部留一些空间，让内容不至于紧贴边缘 */
}

/* 游戏容器 */
.game-container {
    background-color: #ffffff;
    padding: 30px 40px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); /* 更深的阴影 */
    text-align: center;
    border: 1px solid #dcdcdc; /* 轻微边框 */
    max-width: 90vw; /* 限制最大宽度，防止大网格超出屏幕 */
    overflow-x: auto; /* 允许横向滚动 */
}

h1 {
    color: #334e68; /* 深蓝色标题 */
    margin-bottom: 25px;
    font-size: 2.5em;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

/* --- 难度控制区样式 --- */
.controls {
    margin-bottom: 20px;
    display: flex; /* 让子元素水平排列 */
    align-items: center; /* 垂直居中 */
    justify-content: center; /* 水平居中 */
    gap: 15px; /* 元素之间的间距 */
    flex-wrap: wrap; /* 空间不足时换行 */
}

.controls label {
    font-size: 1.1em;
    color: #555;
    font-weight: 600;
}

#difficulty {
    padding: 10px 15px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1em;
    background-color: #f8f8f8;
    appearance: none; /* 移除默认的系统样式 */
    -webkit-appearance: none; /* 针对WebKit浏览器 */
    -moz-appearance: none; /* 针对Firefox */
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23000%22%20d%3D%22M287%2C197.3l-136.2%2C136.2c-5.1%2C5.1-11.8%2C7.9-19%2C7.9s-13.8-2.8-19-7.9L5.3%2C197.3c-10.4-10.4-10.4-27.3%2C0-37.7s27.3-10.4%2C37.7%2C0l116.7%2C116.7l116.7-116.7c10.4-10.4%2C27.3-10.4%2C37.7%2C0S297.4%2C186.9%2C287%2C197.3z%22%2F%3E%3C%2Fsvg%3E'); /* 自定义下拉箭头 */
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
    cursor: pointer;
    outline: none; /* 移除聚焦时的边框 */
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    min-width: 150px; /* 最小宽度 */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

#difficulty:hover {
    border-color: #888;
}

#difficulty:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3); /* 聚焦时的蓝色光晕 */
}

/* --- 自定义难度控制区样式 --- */
.custom-controls {
    display: flex; /* 默认隐藏，JavaScript 控制显示 */
    align-items: center;
    justify-content: center;
    gap: 10px; /* 元素之间的间距 */
    margin-top: 15px;
    padding: 15px;
    background-color: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 8px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
    flex-wrap: wrap; /* 允许换行 */
}

.custom-controls label {
    font-size: 0.95em;
    color: #666;
    font-weight: normal;
}

.custom-controls input[type="number"] {
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    width: 60px; /* 宽度适中 */
    font-size: 0.9em;
    text-align: center;
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.custom-controls input[type="number"]:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.custom-controls button#setCustomButton {
    padding: 8px 15px; /* 稍小的按钮 */
    font-size: 0.9em;
    margin-top: 0; /* 保持对齐 */
    background-color: #2ecc71; /* 绿色按钮 */
}

.custom-controls button#setCustomButton:hover {
    background-color: #27ae60;
}


/* 游戏板 */
#game-board {
    display: grid;
    border: 3px solid #7f8c8d; /* 深灰色边框 */
    background-color: #ecf0f1; /* 浅灰色背景 */
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1); /* 内阴影 */
    border-radius: 5px;
    overflow: hidden; /* 确保格子圆角不溢出 */
    margin-top: 25px; /* 与上方控制区保持距离 */
}

/* 单元格（格子） */
.cell {
    width: 35px; /* 稍微大一点的格子 */
    height: 35px;
    background-color: #c0c0c0; /* 未揭示格子的默认颜色 */
    border: 1px solid #95a5a6; /* 边框 */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em; /* 字号 */
    font-weight: bold;
    color: #2c3e50; /* 默认文字颜色 */
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.1s ease; /* 平滑过渡 */
}

.cell:hover:not(.revealed):not(.flag) {
    background-color: #b0b0b0; /* 悬停效果 */
    transform: scale(1.02); /* 微微放大 */
}

/* 已揭示的格子 */
.cell.revealed {
    background-color: #e0e0e0; /* 揭示后的背景色 */
    border: 1px solid #bdc3c7;
    cursor: default; /* 揭示后移除指针 */
}

/* 地雷格子 */
.cell.mine {
    background-color: #e74c3c; /* 醒目的红色 */
    color: white;
    font-size: 1.5em; /* 地雷符号大一点 */
    animation: bombReveal 0.3s ease-out; /* 爆炸动画 */
}

/* 旗帜格子 */
.cell.flag {
    background-color: #f1c40f; /* 鲜艳的黄色 */
    color: #333;
    font-size: 1.2em;
    animation: flagAppear 0.2s ease-out; /* 旗帜出现动画 */
}

/* 数字颜色 */
.cell.number-1 { color: #0000ff; } /* 蓝色 */
.cell.number-2 { color: #008000; } /* 绿色 */
.cell.number-3 { color: #ff0000; } /* 红色 */
.cell.number-4 { color: #000080; } /* 深蓝 */
.cell.number-5 { color: #800000; } /* 深红 */
.cell.number-6 { color: #008080; } /* 青色 */
.cell.number-7 { color: #000000; } /* 黑色 */
.cell.number-8 { color: #808080; } /* 灰色 */

/* 消息显示 */
#message {
    margin-top: 25px;
    font-size: 1.3em;
    font-weight: bold;
    color: #2c3e50;
    min-height: 25px; /* 确保消息区域有最小高度，避免布局跳动 */
}

/* 胜利时的消息颜色 */
#message[style*="green"] {
    color: #27ae60; /* 翠绿色 */
    animation: pulse 0.8s infinite alternate; /* 闪烁动画 */
}

/* 失败时的消息颜色 */
#message[style*="red"] {
    color: #c0392b; /* 暗红色 */
    animation: shake 0.5s ease-in-out; /* 震动动画 */
}

/* --- 按钮通用样式 (应用于所有按钮) --- */
button {
    padding: 12px 25px;
    margin-top: 20px; /* 默认按钮的上外边距 */
    background-color: #3498db; /* 蓝色 */
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: bold;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    outline: none; /* 移除聚焦时的边框 */
}

button:hover {
    background-color: #2980b9; /* 悬停深色 */
    transform: translateY(-2px); /* 微微上浮 */
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
}

button:active {
    transform: translateY(0); /* 点击下沉效果 */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* --- 按钮美化：主按钮 (给重新开始按钮使用) --- */
.main-button {
    background-color: #e67e22; /* 橙色 */
    font-size: 1.2em; /* 稍大 */
    padding: 15px 30px; /* 稍大 */
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
}

.main-button:hover {
    background-color: #d35400; /* 深橙色 */
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}


/* --- 动画 --- */
@keyframes bombReveal {
    0% { transform: scale(0.5); opacity: 0; }
    80% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); }
}

@keyframes flagAppear {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes pulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.03); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}