:root {
  --bg: #0b0f14;
  --panel: #0f1722;
  --tile: #121c27;
  --tile-hover: #152235;
  --revealed: #2e7d32;
  --revealed-hover: #368c3a;
  --mine: #7a1f1f;
  --flagged: #1a2230;
  --border: rgba(255, 255, 255, 0.12);
  --text: #e8eef6;
  --muted: rgba(232, 238, 246, 0.7);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 12px;
  --radius-large: 16px;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.top {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
}

.brand {
  display: inline-block;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  opacity: 0.9;
}

.top h1 {
  margin: 10px 0 0;
  font-size: 22px;
  letter-spacing: 0.2px;
}

.game {
  padding: 20px;
  max-width: 980px;
  margin: 0 auto;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}

button {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #111a24;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}

button:hover {
  background: #142033;
}

button:active {
  transform: scale(0.98);
}

.info {
  display: flex;
  gap: 14px;
  font-weight: 700;
  opacity: 0.95;
  flex-wrap: wrap;
}

.board {
  margin-top: 16px;
  display: grid;
  gap: 6px;
  width: fit-content;
  padding: 14px;
  border-radius: var(--radius-large);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
  box-shadow: var(--shadow);
}

.cell {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--tile);
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.cell:hover {
  background: var(--tile-hover);
}

.cell:active {
  transform: scale(0.98);
}

/* revealed squares */
.cell.revealed {
  background: var(--revealed);
  cursor: default;
  opacity: 1;
}

.cell.revealed:hover {
  background: var(--revealed-hover);
}

/* mine squares */
.cell.mine {
  background: var(--mine);
  color: white;
}

/* flagged squares */
.cell.flagged {
  background: var(--flagged);
}

/* optional number colours */
.cell[data-number="1"] { color: #9fd3ff; }
.cell[data-number="2"] { color: #7CFC98; }
.cell[data-number="3"] { color: #ff9b9b; }
.cell[data-number="4"] { color: #c5a3ff; }
.cell[data-number="5"] { color: #ffb870; }
.cell[data-number="6"] { color: #7ee7e7; }
.cell[data-number="7"] { color: #f0f0f0; }
.cell[data-number="8"] { color: #c0c0c0; }

.help {
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
}

/* smaller screens */
@media (max-width: 420px) {
  .cell {
    width: 30px;
    height: 30px;
    border-radius: 10px;
  }

  .board {
    padding: 12px;
    gap: 5px;
  }

  .top h1 {
    font-size: 18px;
  }

  .game {
    padding: 14px;
  }
}