:root {
  --bg: #f5f5f5;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #d1d5db;
  --cell-hidden: #d1d5db;
  --cell-hidden-hover: #b8bfc8;
  --cell-revealed: #f3f4f6;
  --cell-mine: #dc2626;
  --cell-flagged: #f59e0b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.panel {
  width: min(92vw, 420px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}

h1 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}

.back {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: normal;
  margin-right: 0.25rem;
}

.back:hover {
  color: var(--text);
}

.meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 3px;
  user-select: none;
}

.cell {
  aspect-ratio: 1;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.6rem, 2.5vw, 0.85rem);
  font-weight: 700;
  cursor: pointer;
  background: var(--cell-hidden);
  border: 1px solid rgba(0,0,0,0.1);
  transition: background 0.08s;
  touch-action: manipulation;
}

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

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

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

.cell.exploded {
  background: var(--cell-mine);
}

.cell[data-adj="1"] { color: #1d4ed8; }
.cell[data-adj="2"] { color: #16a34a; }
.cell[data-adj="3"] { color: #dc2626; }
.cell[data-adj="4"] { color: #7c3aed; }
.cell[data-adj="5"] { color: #9a3412; }
.cell[data-adj="6"] { color: #0891b2; }
.cell[data-adj="7"] { color: #1f2937; }
.cell[data-adj="8"] { color: #6b7280; }

.actions {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

button {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
}

button:active {
  transform: translateY(1px);
}

.hint {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}
