/* 扫雷游戏样式 - 深色主题 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  color: #fff;
  overflow-x: hidden;
  padding: 16px;
  user-select: none;
  -webkit-user-select: none;
}

.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 600px;
}

/* 头部信息栏 */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  backdrop-filter: blur(10px);
}

.game-title {
  text-align: left;
}

.title-main {
  font-size: 22px;
  font-weight: bold;
  color: #fff;
}

.title-sub {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.control-buttons {
  display: flex;
  gap: 8px;
}

.btn {
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn-home {
  background: #e74c3c;
  color: #fff;
}

.btn-home:hover {
  background: #c0392b;
  transform: translateY(-2px);
}

.btn-restart {
  background: #27ae60;
  color: #fff;
}

.btn-restart:hover {
  background: #219a52;
  transform: translateY(-2px);
}

.btn-help {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.btn-help:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
}

/* 难度选择 */
.difficulty-bar {
  display: flex;
  gap: 8px;
  width: 100%;
}

.diff-btn {
  flex: 1;
  padding: 10px 8px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  transition: all 0.3s ease;
}

.diff-btn .diff-desc {
  font-size: 10px;
  font-weight: 400;
  opacity: 0.6;
  margin-top: 2px;
}

.diff-btn:hover {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
}

.diff-btn.active {
  border-color: #4ecca3;
  background: rgba(78, 204, 163, 0.15);
  color: #4ecca3;
}

.diff-btn.active .diff-desc {
  opacity: 0.8;
}

/* 状态栏 */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}

.status-value {
  font-size: 24px;
  font-weight: bold;
  color: #4ecca3;
  min-width: 40px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.status-item.mines .status-value {
  color: #e74c3c;
}

.face-btn {
  font-size: 28px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.face-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.face-btn:active {
  transform: scale(0.95);
}

/* 操作提示 */
.mode-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

.mode-hint {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.45);
}

.mode-status {
  font-size: 13px;
  color: #ffd54f;
  min-width: 60px;
  transition: opacity 0.3s;
}

/* 棋盘 */
.board-wrapper {
  width: 100%;
  overflow: auto;
  display: flex;
  justify-content: center;
  -webkit-overflow-scrolling: touch;
}

.board {
  display: grid;
  gap: 2px;
  background: rgba(255, 255, 255, 0.05);
  padding: 6px;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.1);
}

.cell {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
  position: relative;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.cell.hidden {
  background: rgba(78, 204, 163, 0.25);
  border: 1px solid rgba(78, 204, 163, 0.15);
}

.cell.hidden:hover {
  background: rgba(78, 204, 163, 0.4);
  transform: scale(1.05);
}

.cell.hidden:active {
  transform: scale(0.95);
}

.cell.flagged {
  background: rgba(231, 76, 60, 0.3);
  border: 1px solid rgba(231, 76, 60, 0.3);
}

.cell.flagged::after {
  content: '🚩';
  font-size: 16px;
}

.cell.revealed {
  background: rgba(255, 255, 255, 0.06);
  cursor: default;
}

.cell.revealed:hover {
  transform: none;
}

.cell.mine {
  background: rgba(231, 76, 60, 0.3);
}

.cell.mine-hit {
  background: rgba(231, 76, 60, 0.6);
  animation: shake 0.3s;
}

.cell.mine::after {
  content: '💣';
  font-size: 16px;
}

.cell.wrong-flag {
  background: rgba(231, 76, 60, 0.2);
}

.cell.wrong-flag::after {
  content: '❌';
  font-size: 14px;
}

/* 数字颜色 */
.cell[data-num="1"] { color: #3498db; }
.cell[data-num="2"] { color: #27ae60; }
.cell[data-num="3"] { color: #e74c3c; }
.cell[data-num="4"] { color: #8e44ad; }
.cell[data-num="5"] { color: #e67e22; }
.cell[data-num="6"] { color: #1abc9c; }
.cell[data-num="7"] { color: #ecf0f1; }
.cell[data-num="8"] { color: #95a5a6; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* 最佳记录按钮 */
.btn-records {
  background: rgba(255, 215, 0, 0.15);
  color: #ffd700;
}

.btn-records:hover {
  background: rgba(255, 215, 0, 0.25);
  transform: translateY(-2px);
}

/* 弹窗 */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.3s;
}

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

.modal {
  background: linear-gradient(135deg, #2a2a4a, #1a1a3e);
  border-radius: 16px;
  padding: 30px;
  max-width: 380px;
  width: 90%;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.3s ease;
}

.modal-title {
  font-size: 32px;
  margin-bottom: 4px;
}

.modal-subtitle {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 20px;
}

.modal-info {
  font-size: 18px;
  margin: 12px 0;
  color: rgba(255, 255, 255, 0.9);
}

.modal-record {
  color: #ffd700;
  font-size: 16px;
  margin: 8px 0;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  justify-content: center;
}

.modal-btn {
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  transition: all 0.3s;
}

.modal-btn-primary {
  background: #4ecca3;
  color: #1a1a2e;
}

.modal-btn-primary:hover {
  background: #45b08c;
  transform: translateY(-2px);
}

.modal-btn-secondary {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.modal-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
}

/* 说明弹窗 */
.modal-content {
  text-align: left;
  font-size: 14px;
  line-height: 1.8;
  color: rgba(255, 255, 255, 0.85);
  margin: 16px 0;
}

/* 记录弹窗 */
.records-table {
  width: 100%;
  margin: 16px 0;
  border-collapse: collapse;
}

.records-table th,
.records-table td {
  padding: 10px 16px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.records-table th {
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  text-transform: uppercase;
}

.records-table td {
  font-size: 16px;
  color: #4ecca3;
}

.btn-clear {
  background: transparent;
  border: 1px solid rgba(231, 76, 60, 0.5);
  color: rgba(231, 76, 60, 0.8);
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  margin-top: 8px;
  transition: all 0.3s;
}

.btn-clear:hover {
  background: rgba(231, 76, 60, 0.15);
  border-color: #e74c3c;
  color: #e74c3c;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* 响应式 */
@media (max-width: 480px) {
  body {
    padding: 10px;
  }

  .game-header {
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .title-main {
    font-size: 18px;
  }

  .btn {
    padding: 6px 10px;
    font-size: 12px;
  }

  .difficulty-bar {
    gap: 6px;
  }

  .diff-btn {
    padding: 8px 4px;
    font-size: 12px;
  }

  .diff-btn .diff-desc {
    font-size: 9px;
  }

  .status-bar {
    padding: 8px 14px;
  }

  .status-value {
    font-size: 20px;
  }

  .face-btn {
    font-size: 24px;
    width: 38px;
    height: 38px;
  }

  .cell {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  .cell.flagged::after,
  .cell.mine::after {
    font-size: 14px;
  }
}

@media (max-width: 360px) {
  .cell {
    width: 24px;
    height: 24px;
    font-size: 11px;
    border-radius: 3px;
  }

  .cell.flagged::after,
  .cell.mine::after {
    font-size: 12px;
  }

  .board {
    gap: 1px;
    padding: 4px;
  }
}
