.ms-difficulty {
  display: flex;
  gap: 6px;
  margin: 12px 0 0;
  padding: 4px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.ms-diff {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg-dim);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.1s ease, color 0.1s ease, border-color 0.1s ease;
}
.ms-diff[aria-selected="true"] {
  background: var(--bg-elev-2);
  color: var(--fg);
  border-color: var(--border);
  box-shadow: var(--shadow-card);
}
@media (hover: hover) {
  .ms-diff:hover:not([aria-selected="true"]) { color: var(--fg); }
}

.statbar .middle {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  text-align: center;
}
.ms-flag-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--fg);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.ms-flag-toggle[aria-pressed="true"] {
  background: color-mix(in srgb, var(--accent-2-fill) 20%, transparent);
  border-color: var(--accent-2);
  color: var(--accent-2);
}
.ms-flag-icon { font-size: 16px; line-height: 1; }

.ms-board-wrap {
  display: flex;
  justify-content: center;
  margin-top: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 6px;
}

.ms-board {
  --cell-size: clamp(22px, calc((100vw - 36px) / var(--cols, 14)), 38px);
  display: grid;
  grid-template-columns: repeat(var(--cols, 9), var(--cell-size));
  grid-auto-rows: var(--cell-size);
  background: var(--fg);
  border: 2px solid var(--fg);
  border-radius: 4px;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  gap: 1px;
}

.ms-cell {
  width: var(--cell-size);
  height: var(--cell-size);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: calc(var(--cell-size) * 0.55);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  background: var(--bg-elev-2);
  color: var(--fg);
  cursor: pointer;
  position: relative;
  transition: background 0.05s ease;
}
.ms-cell:not(.revealed):active { background: var(--bg-soft); }
@media (hover: hover) {
  .ms-cell:not(.revealed):hover { background: var(--bg-soft); }
}

.ms-cell.revealed {
  background: var(--bg-soft);
  cursor: default;
  font-weight: 700;
}
.ms-cell.revealed.zero { color: transparent; }

/* Classic Microsoft minesweeper number colors — these are iconic enough
   that overriding them per-theme would feel wrong. They're hard-coded
   instead of pulling from the theme variables. */
.ms-cell.n-1 { color: #1d4ed8; }
.ms-cell.n-2 { color: #047857; }
.ms-cell.n-3 { color: #b91c1c; }
.ms-cell.n-4 { color: #1e1b4b; }
.ms-cell.n-5 { color: #7f1d1d; }
.ms-cell.n-6 { color: #0e7490; }
.ms-cell.n-7 { color: var(--fg); }
.ms-cell.n-8 { color: var(--fg-dim); }

@media (prefers-color-scheme: dark) {
  .ms-cell.n-1 { color: #93c5fd; }
  .ms-cell.n-2 { color: #6ee7b7; }
  .ms-cell.n-3 { color: #fca5a5; }
  .ms-cell.n-4 { color: #c4b5fd; }
  .ms-cell.n-5 { color: #fcd34d; }
  .ms-cell.n-6 { color: #67e8f9; }
}

.ms-cell.flagged::after {
  content: "🚩";
  font-size: calc(var(--cell-size) * 0.55);
}
.ms-cell.flagged { color: transparent; }

.ms-cell.mine {
  background: var(--bg-soft);
}
.ms-cell.mine::after {
  content: "💣";
  font-size: calc(var(--cell-size) * 0.55);
}
.ms-cell.exploded {
  background: rgba(239, 68, 68, 0.40);
}
.ms-cell.wrong-flag {
  background: rgba(239, 68, 68, 0.20);
}
.ms-cell.wrong-flag::after {
  content: "✕";
  color: var(--accent-2);
}

.ms-board.locked .ms-cell { cursor: default; }
.ms-board.won { border-color: var(--accent-3); }
.ms-board.lost { border-color: var(--accent-2); }

.controls { margin-top: 14px; }

@media (max-width: 380px) {
  .ms-board {
    --cell-size: clamp(20px, calc((100vw - 24px) / var(--cols, 14)), 32px);
  }
}
