:root {
  color-scheme: light;
  --bg: #edf2f7;
  --panel: #ffffff;
  --ink: #18212f;
  --muted: #626e7f;
  --line: #d3dce8;
  --accent: #1864ab;
  --accent-strong: #0b4f8a;
  --danger: #c92a2a;
  --ok: #087f5b;
  --cell: #dfe7f1;
  --cell-edge: #b9c6d5;
  --cell-open: #f7f9fc;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(24, 100, 171, 0.12), transparent 34%),
    linear-gradient(225deg, rgba(8, 127, 91, 0.11), transparent 30%),
    var(--bg);
}

button,
select {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0;
  display: grid;
  place-items: center;
}

.game-panel {
  width: 100%;
  padding: clamp(18px, 3vw, 32px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 48px rgba(32, 45, 65, 0.12);
}

.game-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 6vw, 4.5rem);
  line-height: 1;
  letter-spacing: 0;
}

.new-game {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

.new-game:hover,
.new-game:focus-visible {
  background: var(--accent-strong);
}

.toolbar {
  margin-top: 24px;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 140px 140px;
  gap: 12px;
}

.select-field,
.stat {
  min-height: 72px;
  padding: 12px 14px;
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfe;
}

.select-field {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

select {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #ffffff;
}

.stat span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.stat strong {
  font-variant-numeric: tabular-nums;
  font-size: 1.45rem;
  line-height: 1;
}

.status {
  min-height: 28px;
  margin: 18px 0;
  color: var(--muted);
  font-weight: 700;
}

.status.win {
  color: var(--ok);
}

.status.lose {
  color: var(--danger);
}

.board-wrap {
  width: 100%;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #d9e2ec;
}

.board {
  --cols: 16;
  display: grid;
  grid-template-columns: repeat(var(--cols), 32px);
  grid-auto-rows: 32px;
  gap: 2px;
  width: max-content;
  margin: 0 auto;
  user-select: none;
}

.cell {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--cell-edge);
  border-radius: 4px;
  background: linear-gradient(180deg, #edf3fa, var(--cell));
  color: var(--ink);
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.cell:hover,
.cell:focus-visible {
  outline: 2px solid rgba(24, 100, 171, 0.35);
  outline-offset: -2px;
}

.cell.open {
  border-color: #d9e0e9;
  background: var(--cell-open);
  cursor: default;
}

.cell.flagged {
  color: var(--danger);
}

.cell.mine {
  color: #ffffff;
  background: var(--danger);
}

.cell[data-adjacent="1"] {
  color: #1864ab;
}

.cell[data-adjacent="2"] {
  color: #087f5b;
}

.cell[data-adjacent="3"] {
  color: #c92a2a;
}

.cell[data-adjacent="4"] {
  color: #5f3dc4;
}

.cell[data-adjacent="5"],
.cell[data-adjacent="6"],
.cell[data-adjacent="7"],
.cell[data-adjacent="8"] {
  color: #9c36b5;
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 680px);
    align-items: start;
    padding: 16px 0;
  }

  .game-header,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .game-header {
    display: grid;
  }

  .new-game {
    width: 100%;
  }

  .board {
    grid-template-columns: repeat(var(--cols), 28px);
    grid-auto-rows: 28px;
  }

  .cell {
    width: 28px;
    height: 28px;
    font-size: 0.9rem;
  }
}
