:root {
  --bg: #0f1216;
  --panel: #151a21;
  --tile: #1c232c;
  --tile-hover: #242e3a;
  --tile-rev: #0a0f14;
  --grid-gap: 4px;
  --radius: 10px;
  --text: #e7edf3;
  --accent: #11a37f;
  --danger: #ff5d5d;
  --warn: #ffb020;
  --muted: #9aa7b2;
  --cell-size: clamp(28px, 6.5vw, 42px);
  --font: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 800px at 20% -10%, #1b2330 0%, var(--bg) 60%) no-repeat fixed;
  color: var(--text);
  font-family: var(--font);
  display: flex;
  flex-direction: column;
}

/* --- top bar and controls --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid #202732;
}
.topbar h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 700;
  letter-spacing: .5px;
}
.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

button, select {
  background: var(--tile);
  color: var(--text);
  border: 1px solid #2a3542;
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
button:hover, select:hover { background: var(--tile-hover); }

/* ✅ Flag mode ON indicator */
#flagModeBtn[aria-pressed="true"] {
  background: #284636 !important;
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}

.stat {
  background: var(--tile);
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--muted);
}

.custom {
  display: grid;
  grid-template-columns: repeat(7, max-content);
  gap: 10px;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: var(--panel);
  border-bottom: 1px solid #202732;
}
.custom.hidden { display: none; }
.custom input {
  width: 70px;
  background: var(--tile);
  color: var(--text);
  border: 1px solid #2a3542;
  border-radius: 6px;
  padding: 6px;
}

#boardWrapper {
  display: grid;
  place-items: center;
  padding: 16px;
  flex: 1 1 auto;
  overflow: auto;
}

.board {
  display: grid;
  gap: var(--grid-gap);
  background: #0b0f14;
  padding: var(--grid-gap);
  border-radius: var(--radius);
  border: 1px solid #1e2631;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  touch-action: manipulation;
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #212a36 0%, #1a222c 100%);
  border: 1px solid #2a3542;
  border-radius: 7px;
  font-weight: 700;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.cell:hover { filter: brightness(1.05); }
.cell.revealed {
  background: var(--tile-rev);
  border-color: #1a222c;
}
.cell.flagged { background: #1a2620; border-color: #284636; }
.cell.mine.revealed { background: #3c1c1f; border-color: #5a272e; }

.num-1 { color: #7cc0ff; }
.num-2 { color: #7dffad; }
.num-3 { color: #ffb582; }
.num-4 { color: #c49dff; }
.num-5 { color: #ff8f8f; }
.num-6 { color: #ffe27a; }
.num-7 { color: #9ad1ff; }
.num-8 { color: #9aa7b2; }

.footer { text-align: center; padding: 12px; color: var(--muted); }

@media (min-width: 900px) {
  :root { --cell-size: 34px; }
}
