:root {
  --bg: #f0f4f8;
  --panel: #ffffff;
  --cell: clamp(16px, 4vw, 22px);
  --gap: 12px;
  --border: #222;
  --covered: #cfcfcf;
  --open: #ffffff;
  --flag: #ff4d4d;
  --mine: #111;
  --text: #0b1b2b;
  --primary: #1976d2;
  --primary-dark: #1565c0;
  --secondary: #4caf50;
  --danger: #f44336;
  --warning: #ff9800;
  --light-bg: #f8f9fa;
  --border-light: #dee2e6;
  --board-cell-scale: 1;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  --radius: 8px;
}

* { box-sizing: border-box; }
/* 确保 html 和 body 填充整个视窗 */
html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

/* 在你的 CSS 中确保这些样式 */
.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
  padding: var(--gap);
  height: auto;
  width: auto;
  max-width: none !important;
  min-width: 0;
  overflow: hidden;
  margin: 0;
}

.boardWrap {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-width: 0;
  overflow: hidden;
  background: var(--panel);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  height: auto;
  width: auto;
  max-width: none !important;
  margin: 0;
  box-sizing: border-box;
}


/* Persistent Controls */
.persistent-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  background: rgba(255, 255, 255, 0.9);
  padding: 12px;
  border-radius: var(--radius);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.persistent-controls > * {
  align-self: center;
}

.persistent-controls > .info-panel {
  flex: 1;
  min-width: 200px;
  margin: 0;
}

/* 显眼的折叠按钮样式 */
.toggle-panel-btn.prominent {
  background: #4CAF50;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  font-weight: bold;
  font-size: 14px;
  cursor: pointer;
  margin-right: 15px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.toggle-panel-btn.prominent:hover {
  background: #45a049;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-difficulty {
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
  height: fit-content;
  align-self: end;
  border: 1px solid var(--border-light);
}

.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  min-width: 100px;
  font-size: 15px;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0,0,0,0.15);
}

.btn-secondary, .btn-difficulty {
  background: var(--light-bg);
  color: var(--text);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  min-width: 100px;
  font-size: 15px;
}

.btn-secondary:hover:not(:disabled), .btn-difficulty:hover:not(:disabled) {
  background: #e9ecef;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0,0,0,0.1);
}

.btn-primary:active:not(:disabled), .btn-secondary:active:not(:disabled), .btn-difficulty:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled, .btn-secondary:disabled, .btn-difficulty:disabled {
  opacity: .6;
  cursor: not-allowed;
}

#btnUndo {
  background-color: #ff9800;
  border-color: #f57c00;
  color: white;
}

#btnUndo:hover:not(:disabled) {
  background-color: #f57c00;
  border-color: #ef6c00;
}

/* Controls Container */
.controls-container {
  position: relative;
  background: var(--light-bg);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
  transition: all 0.3s ease;
}

.controls-container {
  transition: all 0.3s ease;
  overflow: hidden;
}
.controls-container.collapsed {
  display: none !important;
}

/* 或者如果你不想用 display: none，可以这样做： */
.controls-container.collapsed {
  visibility: collapse !important; /* 专门用于grid items */
  height: 0 !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  overflow: hidden !important;
}


.main-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
  align-items: start;
}

/* Checkbox Group */
.checkbox-group {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background-color: var(--light-bg);
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-light);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  cursor: pointer;
  transition: background-color 0.2s ease;
  vertical-align: middle;
  height: 36px;
  box-sizing: border-box;
}

.checkbox-group:hover {
  background-color: #e9ecef;
}

.checkbox-group input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  margin: 0;
}

.checkbox-group label {
  margin: 0;
  cursor: pointer;
  white-space: nowrap;
}

/* Difficulty Buttons */
.difficulty-buttons {
  margin: 10px 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Size Controls */
.size-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}

.input-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}

.input-group label {
  font-weight: 600;
  font-size: 14px;
  min-width: 0;
  color: var(--text);
}

.input-group input[type="number"] {
  width: 60px;
  padding: 6px 8px;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  font-size: 14px;
  text-align: center;
  background: white;
}

/* 加宽的种子输入框 */
.seed-input.wide {
  width: 140px;
}

.adjust-btn {
  padding: 4px 8px;
  font-size: 13px;
  background: white;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  min-width: 32px;
  height: 32px;
}

.adjust-btn.tiny {
  padding: 2px 6px;
  font-size: 12px;
  min-width: 28px;
  height: 28px;
}

.adjust-btn.small {
  padding: 4px 6px;
  font-size: 13px;
  min-width: 36px;
  height: 32px;
}

.adjust-btn:hover:not(:disabled) {
  background: #e9ecef;
  transform: translateY(-1px);
}

/* Scale Controls */
.scale-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
}

.scale-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.scale-label {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.scale-btn {
  padding: 4px 10px;
  font-size: 14px;
  background: white;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  cursor: pointer;
  min-width: 36px;
  text-align: center;
  font-weight: 600;
  transition: all 0.2s ease;
}

.scale-btn:hover {
  background: #e9ecef;
  transform: translateY(-1px);
}

.scale-value {
  font-weight: 700;
  min-width: 45px;
  text-align: center;
  font-size: 14px;
  background: var(--light-bg);
  padding: 4px 8px;
  border-radius: 4px;
}

/* Status */
.status {
  padding: 10px 14px;
  background: rgba(255,255,255,.9);
  border: 1px solid rgba(0,0,0,.1);
  border-radius: 6px;
  font-weight: 600;
  text-align: center;
  font-size: 15px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Info Panel */
.info-panel {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 15px;
  padding: 10px 14px;
  background: rgba(255,255,255,.9);
  border: 1px solid rgba(0,0,0,.1);
  border-radius: 6px;
  font-size: 14px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: thin;
}

.info-panel::-webkit-scrollbar {
  height: 6px;
}

.info-panel::-webkit-scrollbar-thumb {
  background-color: rgba(0,0,0,0.2);
  border-radius: 3px;
}

.info-panel::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.05);
}

.info-item {
  display: inline-block;
  flex-shrink: 0;
  text-align: center;
  min-width: 80px;
}

.info-label {
  font-weight: 600;
  color: #555;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 2px;
}

.info-value {
  font-weight: 700;
  font-size: 15px;
  display: block;
}

/* Board */
.board {
  display: grid;
  gap: 1px;
  align-content: start;
  justify-content: start;
  background: var(--border);
  padding: 1px;
  overflow: auto;
  border-radius: 6px;
  max-height: calc(100vh - 280px);
  box-shadow: inset 0 0 4px rgba(0,0,0,0.1);
}

.cell {
  width: calc(var(--cell) * var(--board-cell-scale));
  height: calc(var(--cell) * var(--board-cell-scale));
  display: grid;
  place-items: center;
  background: var(--covered);
  font-size: calc(var(--cell) * var(--board-cell-scale) * 0.7);
  user-select: none;
  font-family: 'Arial Rounded MT Bold', 'Arial', sans-serif;
  font-weight: 900;
  position: relative;
  transition: all 0.1s ease;
}

.cell.open {
  background: var(--open);
  box-shadow: inset 0 0 2px rgba(0,0,0,0.1);
}

.cell[data-number='1'] { color: #1976d2; }
.cell[data-number='2'] { color: #388e3c; }
.cell[data-number='3'] { color: #d32f2f; }
.cell[data-number='4'] { color: #7b1fa2; }
.cell[data-number='5'] { color: #f57c00; }
.cell[data-number='6'] { color: #0097a7; }
.cell[data-number='7'] { color: #212121; }
.cell[data-number='8'] { color: #616161; }

.cell.flag {
  background: #ddd;
  display: grid;
  place-items: center;
}

.cell.flag svg {
  width: 80%;
  height: 80%;
}

.cell.mine {
  background: #ffd700;
  color: #000;
  font-weight: 900;
  font-size: calc(var(--cell) * var(--board-cell-scale) * 0.8);
}

/* Responsive */
@media screen and (max-width: 1024px) {
  .main-controls {
    grid-template-columns: 1fr;
  }
  
  .size-controls {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .scale-controls {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media screen and (max-width: 768px) {
  .layout {
    padding: 8px;
    gap: 8px;
  }
  
  .boardWrap {
    padding: 12px;
  }
  
  .controls-container {
    padding: 12px;
  }
  
  .board {
    max-height: 50vh;
  }
  
  .input-group input[type="number"] {
    width: 55px;
    padding: 5px 7px;
    font-size: 13px;
  }
  
  .adjust-btn {
    padding: 3px 6px;
    font-size: 12px;
    min-width: 30px;
    height: 30px;
  }
  
  .adjust-btn.tiny {
    padding: 2px 5px;
    font-size: 11px;
    min-width: 26px;
    height: 26px;
  }
  
  .adjust-btn.small {
    padding: 3px 5px;
    font-size: 12px;
    min-width: 32px;
    height: 30px;
  }
  
  .info-panel {
    padding: 10px;
    font-size: 13px;
  }
  
  .info-label {
    font-size: 12px;
  }
  
  .info-value {
    font-size: 15px;
  }
  
  .checkbox-group {
    padding: 6px 10px;
    font-size: 13px;
    height: 34px;
  }
  
  .checkbox-group input[type="checkbox"] {
    width: 15px;
    height: 15px;
  }
}

@media screen and (max-width: 480px) {
  :root {
    --cell: clamp(12px, 8vw, 20px);
    --gap: 6px;
  }
  
  .boardWrap {
    padding: 8px;
  }
  
  .controls-container {
    padding: 10px;
  }
  
  .input-group input[type="number"] {
    width: 50px;
    padding: 4px 6px;
    font-size: 12px;
  }
  
  .adjust-btn {
    padding: 2px 5px;
    font-size: 11px;
    min-width: 28px;
    height: 28px;
  }
  
  .adjust-btn.tiny {
    padding: 1px 4px;
    font-size: 10px;
    min-width: 24px;
    height: 24px;
  }
  
  .adjust-btn.small {
    padding: 2px 4px;
    font-size: 11px;
    min-width: 30px;
    height: 28px;
  }
  
  .scale-btn {
    padding: 3px 8px;
    font-size: 13px;
    min-width: 32px;
  }
  
  .scale-value {
    font-size: 13px;
    padding: 3px 6px;
    min-width: 40px;
  }
  
  .info-panel {
    padding: 8px;
    font-size: 12px;
    gap: 8px;
  }
  
  .info-label {
    font-size: 11px;
  }
  
  .info-value {
    font-size: 14px;
  }
}

