:root {
  color-scheme: light;
  --ink: #18221f;
  --muted: #60706b;
  --paper: #fbfcf8;
  --wash: #eef5f2;
  --panel: #ffffff;
  --panel-glass: rgba(255, 255, 255, 0.84);
  --line: #d8e0dc;
  --teal: #0f766e;
  --coral: #b7463b;
  --gold: #c39b37;
  --charcoal: #24302d;
  --shadow: 0 24px 70px rgba(24, 34, 31, 0.14);
  --header-height: 72px;
  --content-max: 1200px;
  --page-x: clamp(18px, 5vw, 72px);
  --cell: #dfe8e0;
  --cell-open: #f7faf4;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100svh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(
      circle at 18% 14%,
      rgba(15, 118, 110, 0.12),
      transparent 28%
    ),
    linear-gradient(135deg, #fbfcf8 0%, #eef5f1 100%);
}

button,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--header-height);
  padding: 14px max(var(--page-x), calc((100vw - var(--content-max)) / 2));
  background: rgba(251, 252, 248, 0.86);
  border-bottom: 1px solid rgba(216, 224, 220, 0.7);
  backdrop-filter: blur(18px);
}

.home-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  color: var(--charcoal);
  font-weight: 800;
  text-decoration: none;
}

.home-link span:first-child {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: #fff;
  background: var(--charcoal);
  border-radius: 8px;
  font-size: 1.5rem;
  line-height: 1;
}

.status-row {
  display: flex;
  gap: 10px;
}

.status-box {
  min-width: 92px;
  padding: 9px 12px;
  text-align: center;
  background: var(--panel-glass);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.status-box span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.status-box strong {
  display: block;
  margin-top: 2px;
  color: var(--charcoal);
  font-size: 1.25rem;
}

.game-shell {
  display: grid;
  place-items: center;
  min-height: calc(100svh - var(--header-height));
  padding: 8px clamp(14px, 4vw, 44px) 42px;
}

.game-panel {
  width: min(100%, 760px);
}

.game-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

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

h1 {
  margin: 0;
  font-size: 5.2rem;
  line-height: 0.95;
}

.solid-button,
.mode-button,
.segmented button {
  min-height: 44px;
  border-radius: 8px;
  font-weight: 800;
  transition:
    transform 150ms ease,
    background 150ms ease,
    color 150ms ease,
    border-color 150ms ease;
}

.solid-button {
  padding: 0 18px;
  color: #fff;
  background: var(--teal);
  border: 1px solid var(--teal);
}

.mode-button {
  min-width: 92px;
  padding: 0 16px;
  color: var(--charcoal);
  background: var(--panel);
  border: 1px solid var(--line);
}

.mode-button[aria-pressed="true"] {
  color: #fff;
  background: var(--coral);
  border-color: var(--coral);
}

.solid-button:hover,
.mode-button:hover,
.segmented button:hover {
  transform: translateY(-2px);
}

.top-actions {
  display: flex;
  gap: 10px;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.segmented {
  display: inline-flex;
  gap: 6px;
  padding: 5px;
  background: var(--panel-glass);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.segmented button {
  min-width: 72px;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
}

.segmented button[aria-pressed="true"] {
  color: #fff;
  background: var(--charcoal);
  border-color: var(--charcoal);
}

.board-wrap {
  position: relative;
  width: 100%;
  padding: clamp(10px, 2.2vw, 14px);
  overflow: hidden;
  background: var(--charcoal);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.board-scroll {
  overflow-x: auto;
}

.board {
  display: grid;
  gap: 4px;
  width: max-content;
  min-width: 100%;
  margin: 0 auto;
  touch-action: manipulation;
  user-select: none;
}

.cell {
  display: grid;
  place-items: center;
  width: var(--cell-size);
  height: var(--cell-size);
  padding: 0;
  color: var(--charcoal);
  background: var(--cell);
  border: 0;
  border-radius: 6px;
  font-size: var(--cell-font);
  font-weight: 900;
  line-height: 1;
}

.cell:not(.is-open):hover {
  background: #eaf1e8;
}

.cell.is-open {
  background: var(--cell-open);
  box-shadow: inset 0 0 0 1px rgba(37, 50, 45, 0.06);
}

.cell.is-flagged {
  color: #fff;
  background: var(--coral);
}

.cell.is-mine {
  color: #fff;
  background: var(--charcoal);
}

.cell.is-hit {
  color: #fff;
  background: var(--coral);
}

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

.cell[data-adjacent="2"] {
  color: var(--teal);
}

.cell[data-adjacent="3"] {
  color: var(--coral);
}

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

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

.game-message {
  position: absolute;
  inset: clamp(10px, 2.2vw, 14px);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  min-width: 260px;
  background: rgba(249, 251, 246, 0.9);
  border-radius: 8px;
  backdrop-filter: blur(6px);
}

.game-message[hidden] {
  display: none;
}

.game-message strong {
  font-size: 3.3rem;
}

@media (max-width: 620px) {
  .game-shell {
    place-items: start center;
    min-height: auto;
    padding-bottom: 26px;
  }

  .game-top,
  .controls {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 4rem;
  }

  .top-actions,
  .solid-button,
  .mode-button {
    width: 100%;
  }

  .segmented {
    width: 100%;
  }

  .segmented button {
    flex: 1;
    min-width: 0;
  }

  .game-message strong {
    font-size: 2.35rem;
  }
}

@media (max-width: 560px) {
  .app-header {
    align-items: stretch;
    flex-direction: column;
  }

  .status-row {
    width: 100%;
  }

  .status-box {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .solid-button,
  .mode-button,
  .segmented button {
    transition: none;
  }

  .solid-button:hover,
  .mode-button:hover,
  .segmented button:hover {
    transform: none;
  }
}
