/* ===== 全局样式 ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #008080;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  font-family: 'Segoe UI', Tahoma, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* ===== 游戏容器 ===== */
.game-wrapper {
  background: #c0c0c0;
  border: 3px solid;
  border-color: #ffffff #808080 #808080 #ffffff;
  padding: 2px;
  box-shadow: 2px 2px 0 #000;
}

.title-bar {
  background: #000080;
  color: #fff;
  padding: 4px 8px;
  font-size: 14px;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.title-icon {
  font-size: 16px;
}

.game-container {
  padding: 6px;
  background: #c0c0c0;
  border: 2px solid;
  border-color: #808080 #ffffff #ffffff #808080;
}

/* ===== 难度选择栏 ===== */
.difficulty-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
  justify-content: center;
}

.diff-btn {
  font-family: inherit;
  font-size: 12px;
  padding: 3px 10px;
  background: #c0c0c0;
  border: 2px solid;
  border-color: #ffffff #808080 #808080 #ffffff;
  cursor: pointer;
  outline: none;
}

.diff-btn:active,
.diff-btn.active {
  border-color: #808080 #ffffff #ffffff #808080;
  padding: 4px 9px 2px 11px;
}

/* ===== 信息面板 ===== */
.info-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  margin-bottom: 6px;
  background: #c0c0c0;
  border: 2px solid;
  border-color: #808080 #ffffff #ffffff #808080;
}

/* LED 计数器 */
.counter {
  background: #000;
  color: #ff0000;
  font-family: 'Courier New', monospace;
  font-size: 28px;
  font-weight: bold;
  padding: 4px 8px;
  min-width: 62px;
  text-align: center;
  border: 2px solid;
  border-color: #808080 #ffffff #ffffff #808080;
  letter-spacing: 2px;
  line-height: 1;
}

/* 笑脸按钮 */
.face-btn {
  width: 42px;
  height: 42px;
  font-size: 22px;
  background: #c0c0c0;
  border: 3px solid;
  border-color: #ffffff #808080 #808080 #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
  padding: 0;
  line-height: 1;
}

.face-btn:active {
  border-color: #808080 #ffffff #ffffff #808080;
}

.face-btn.win {
  font-size: 24px;
}

/* ===== 游戏面板 ===== */
.board-wrapper {
  border: 3px solid;
  border-color: #808080 #ffffff #ffffff #808080;
  display: inline-block;
  background: #c0c0c0;
  max-width: min(100vw - 32px, 100%);
  overflow-x: auto;
  overflow-y: hidden;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
}

.board {
  display: grid;
  gap: 0;
}

/* ===== 单元格 ===== */
.cell {
  width: 24px;
  height: 24px;
  background: #c0c0c0;
  border: 3px solid;
  border-color: #ffffff #808080 #808080 #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.cell:active:not(.revealed),
.cell.pressing:not(.revealed) {
  border-color: #808080 #ffffff #ffffff #808080;
  background: #b8b8b8;
}

/* 已揭露的格子 */
.cell.revealed {
  border: 1px solid #808080;
  background: #c0c0c0;
  cursor: default;
}

/* 数字颜色 */
.cell.num-1 { color: #0000ff; }
.cell.num-2 { color: #008000; }
.cell.num-3 { color: #ff0000; }
.cell.num-4 { color: #000080; }
.cell.num-5 { color: #800000; }
.cell.num-6 { color: #008080; }
.cell.num-7 { color: #000000; }
.cell.num-8 { color: #808080; }

/* 地雷 */
.cell.mine {
  background: #ff0000;
}

.cell.mine-exploded {
  background: #ff0000;
}

/* 旗子 */
.cell.flagged {
  font-size: 14px;
}

/* 错误标记（游戏结束显示） */
.cell.wrong-flag {
  text-decoration: line-through;
  color: #ff0000;
}

/* 游戏结束 - 禁用交互 */
.board.game-over .cell {
  pointer-events: none;
}

.board.game-over .cell.revealed {
  pointer-events: none;
}

/* ===== 自定义模式弹窗 ===== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  justify-content: center;
  align-items: center;
}

.modal-overlay.show {
  display: flex;
}

.modal-box {
  background: #c0c0c0;
  border: 3px solid;
  border-color: #ffffff #808080 #808080 #ffffff;
  box-shadow: 3px 3px 0 #000;
  min-width: 280px;
}

.modal-title-bar {
  background: #000080;
  color: #fff;
  padding: 4px 6px 4px 8px;
  font-size: 13px;
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-close-btn {
  width: 18px;
  height: 18px;
  background: #c0c0c0;
  border: 2px solid;
  border-color: #ffffff #808080 #808080 #ffffff;
  cursor: pointer;
  font-size: 11px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  color: #000;
}

.modal-close-btn:active {
  border-color: #808080 #ffffff #ffffff #808080;
}

.modal-body {
  padding: 16px 20px;
}

.modal-field {
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-field label {
  font-size: 13px;
  white-space: nowrap;
  min-width: 100px;
}

.modal-field input {
  width: 70px;
  padding: 3px 6px;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  background: #fff;
  border: 2px solid;
  border-color: #808080 #ffffff #ffffff #808080;
  outline: none;
}

.modal-field input:focus {
  border-color: #808080 #ffffff #ffffff #808080;
}

.modal-hint {
  font-size: 11px;
  color: #800000;
  min-height: 16px;
  margin-bottom: 8px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}

.modal-btn {
  font-family: inherit;
  font-size: 12px;
  padding: 5px 18px;
  background: #c0c0c0;
  border: 2px solid;
  border-color: #ffffff #808080 #808080 #ffffff;
  cursor: pointer;
  outline: none;
}

.modal-btn:active {
  border-color: #808080 #ffffff #ffffff #808080;
}

.modal-btn-ok {
  font-weight: bold;
  min-width: 60px;
}

/* 响应式：小屏幕时缩小格子 */
@media (max-width: 500px) {
  body {
    align-items: flex-start;
    padding: 16px 8px;
  }

  .game-wrapper {
    max-width: 100%;
  }

  .difficulty-bar {
    flex-wrap: wrap;
  }

  .board-wrapper {
    max-width: 100%;
  }

  .cell {
    width: 22px;
    height: 22px;
    font-size: 12px;
  }
  .counter {
    font-size: 22px;
    min-width: 50px;
    padding: 3px 6px;
  }
  .face-btn {
    width: 34px;
    height: 34px;
    font-size: 18px;
  }
}
