/* Minesweeper — Dark Theme */

#controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin: 0 auto 20px;
  max-width: 720px;
}

.difficulty-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.diff-pill {
  position: relative;
  cursor: pointer;
  user-select: none;
}

.diff-pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.diff-pill span {
  display: inline-block;
  padding: 10px 18px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
}

.diff-pill:hover span {
  border-color: var(--accent);
  color: var(--text-primary);
}

.diff-pill input:checked + span {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(233, 69, 96, 0.4);
}

.options-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.checkbox-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.checkbox-pill:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.checkbox-pill input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* HUD */
#hud {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin: 0 auto 18px;
  padding: 12px 20px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 14px;
  max-width: 480px;
}

.hud-box {
  background: #000;
  border: 2px inset #2a2a4a;
  border-radius: 8px;
  padding: 8px 18px;
  min-width: 90px;
  text-align: center;
}

.hud-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 2px;
}

.hud-value {
  font-family: 'Courier New', monospace;
  font-size: 1.6rem;
  font-weight: 800;
  color: #ff5252;
  line-height: 1;
  text-shadow: 0 0 8px rgba(255, 82, 82, 0.4);
  min-height: 1.6rem;
}

.smiley {
  width: 52px;
  height: 52px;
  font-size: 2rem;
  background: var(--accent);
  border: 3px solid var(--bg-secondary);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, background 0.2s;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.smiley:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.smiley:active {
  transform: scale(0.95);
}

.smiley.win {
  background: var(--success);
}

.smiley.lose {
  background: #2c2c2c;
}

/* Board */
#board-wrapper {
  display: flex;
  justify-content: center;
  margin: 0 auto 30px;
  overflow-x: auto;
  padding: 4px;
}

#board {
  display: grid;
  gap: 2px;
  padding: 8px;
  background: var(--bg-card);
  border: 3px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.cell {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 800;
  font-family: 'Courier New', monospace;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.08s;
}

.cell.unrevealed {
  background: linear-gradient(145deg, #2a2a4a, #1f1f38);
  border: 2px solid;
  border-color: #3a3a5a #15152a #15152a #3a3a5a;
  box-shadow: inset 1px 1px 2px rgba(255, 255, 255, 0.08);
}

.cell.unrevealed:hover {
  background: linear-gradient(145deg, #353555, #2a2a45);
}

.cell.revealed {
  background: #15152a;
  border: 1px solid #1a1a2e;
  cursor: default;
  animation: reveal 0.18s ease-out;
}

@keyframes reveal {
  0% { transform: scale(0.6); opacity: 0.4; }
  60% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.cell.mine {
  background: #4a1010;
  color: white;
}

.cell.mine.wrong-flag {
  background: #5a2a2a;
}

.cell.flagged {
  background: linear-gradient(145deg, #4a3050, #3a2540);
  border-color: #5a4060 #2a1a30 #2a1a30 #5a4060;
  color: #ff5252;
}

.cell.question {
  color: var(--warning);
  background: linear-gradient(145deg, #3a3a5a, #2a2a4a);
  border-color: #4a4a6a #1a1a30 #1a1a30 #4a4a6a;
}

.cell.n1 { color: #5a9eff; }
.cell.n2 { color: #4ecca3; }
.cell.n3 { color: #ff5252; }
.cell.n4 { color: #8a4fff; }
.cell.n5 { color: #ff8c42; }
.cell.n6 { color: #42d4d4; }
.cell.n7 { color: #eee; }
.cell.n8 { color: #a0a0b8; }

/* Best Times */
#best-times {
  max-width: 600px;
  margin: 0 auto 30px;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
}

#best-times h3 {
  text-align: center;
  margin-bottom: 14px;
  color: var(--text-primary);
}

.best-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.best-col {
  text-align: center;
}

.best-header {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  font-weight: 600;
}

.best-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-family: 'Courier New', monospace;
  font-size: 0.95rem;
  color: var(--text-primary);
  min-height: 90px;
}

.best-list li {
  padding: 4px 0;
  color: var(--text-secondary);
}

.best-list li.top {
  color: var(--warning);
  font-weight: 700;
}

.best-list li.empty {
  color: #555;
  font-style: italic;
  font-size: 0.85rem;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fade-in 0.2s ease-out;
}

.modal.hidden {
  display: none;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--bg-card);
  border: 2px solid var(--accent);
  border-radius: 16px;
  padding: 32px 40px;
  text-align: center;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(233, 69, 96, 0.3);
  animation: pop-in 0.3s ease-out;
}

@keyframes pop-in {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-content h2 {
  font-size: 1.8rem;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--accent), #f0a500);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.modal-content p {
  color: var(--text-secondary);
  margin-bottom: 20px;
  font-size: 1.05rem;
}

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

/* Mobile */
@media (max-width: 600px) {
  .cell {
    width: 26px;
    height: 26px;
    font-size: 0.85rem;
  }
  .hud-value { font-size: 1.3rem; }
  .smiley { width: 44px; height: 44px; font-size: 1.5rem; }
  .best-grid { grid-template-columns: 1fr; }
  .best-list { min-height: 0; }
}

/* ============================================

/* ============================================
   Help button (in header)
   ============================================ */
.site-header .container {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.help-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.help-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

/* ============================================
   Help modal content
   ============================================ */
.help-content {
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  text-align: left;
  position: relative;
}
.help-content h3 {
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  color: #ff9800;
  font-size: 1.1rem;
}
.help-content h3:first-of-type { margin-top: 0; }
.help-content ul, .help-content ol {
  margin: 0.5rem 0 1rem 1.5rem;
  line-height: 1.7;
}
.help-content li { margin: 0.25rem 0; }
.help-content strong { color: #ff5722; }
.close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* ============================================
   Mobile improvements
   ============================================ */
@media (max-width: 600px) {
  .help-btn { font-size: 0.85rem; padding: 0.4rem 0.75rem; }
  .help-content { padding: 1.5rem 1rem; font-size: 0.9rem; }
  #board { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
  /* Larger tap targets on small screens */
  .btn { padding: 0.5rem 0.85rem; font-size: 0.85rem; }
  .diff-pill { padding: 0.4rem 0.7rem; font-size: 0.85rem; }
}

/* Flag-mode active state — make it visually obvious */
.checkbox-pill:has(input:checked) {
  border-color: #ff5722;
  background: rgba(255, 87, 34, 0.15);
  color: var(--text-primary);
}
.action-toggle:has(input:checked) {
  border-color: #ff5722;
  background: linear-gradient(135deg, rgba(255,87,34,0.25), rgba(255,152,0,0.2));
  color: #fff;
  box-shadow: 0 0 0 2px rgba(255, 87, 34, 0.3);
}

/* Ensure cells give clear tap feedback on mobile */
.cell:active {
  transform: scale(0.92);
  transition: transform 0.08s;
}
