/* SWEEP — night-range board. Two accent colors carry the identity because
   they ARE the mechanic. Space Grotesk wordmark, IBM Plex Mono instruments. */

:root {
  --bg: #171c26;
  --panel: #1f2632;
  --line: #39445a;
  --hidden: #2a3342;
  --hidden-hi: #333e50;
  --revealed: #131822;
  --text: #e8ecf2;
  --muted: #8b96a8;
  --red: #ff5c5c;
  --red-deep: #b8323f;
  --blue: #4c8dff;
  --blue-deep: #2a5cb8;
  --gold: #ffc94d;
  --radius: 10px;
  --cell-gap: 4px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 50% -10%, #1d2433 0%, var(--bg) 60%);
  color: var(--text);
  font-family: 'Space Grotesk', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 14px 28px;
}

.mono { font-family: 'IBM Plex Mono', monospace; }

/* ---------- header ---------- */
.top {
  width: 100%; max-width: 480px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 2px 10px;
}
.wordmark {
  margin: 0;
  font-size: 34px; font-weight: 700; letter-spacing: 0.22em;
  line-height: 1;
}
.wordmark .wm-p {
  background: linear-gradient(135deg, var(--red) 0 50%, var(--blue) 50% 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.sub { color: var(--muted); font-size: 12px; margin-top: 5px; letter-spacing: 0.02em; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  font-family: 'IBM Plex Mono', monospace; font-size: 17px; cursor: pointer;
}
.icon-btn:hover { background: var(--hidden-hi); }

/* ---------- tabs ---------- */
.tabs {
  width: 100%; max-width: 480px;
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px;
  margin-bottom: 10px;
}
.tab {
  padding: 8px 0 7px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  font-family: inherit; font-weight: 500; font-size: 14px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.tab-meta { font-family: 'IBM Plex Mono', monospace; font-size: 10px; opacity: 0.7; }
.tab[aria-selected="true"] {
  color: var(--text); border-color: var(--text); background: var(--hidden);
}
.tab.done { border-color: var(--gold); }
.tab.done::after { content: '✓'; font-size: 10px; color: var(--gold); }

/* ---------- HUD ---------- */
.hud {
  width: 100%; max-width: 480px;
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.hud-cell {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 0; font-size: 16px;
}
.dot { width: 11px; height: 11px; border-radius: 50%; }
.dot-red { background: var(--red); box-shadow: 0 0 8px #ff5c5c66; }
.dot-blue { background: var(--blue); box-shadow: 0 0 8px #4c8dff66; }
.hud-lives { letter-spacing: 3px; font-size: 15px; }
.life { transition: opacity 0.3s; }
.life.lost { opacity: 0.22; filter: grayscale(1); }

/* ---------- board ---------- */
.board-wrap { width: 100%; max-width: 480px; }
.board {
  display: grid; gap: var(--cell-gap);
  background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px;
  padding: 8px;
  touch-action: manipulation;
  user-select: none; -webkit-user-select: none;
}
.cell {
  position: relative; aspect-ratio: 1;
  border: none; border-radius: 6px; padding: 0;
  font-family: 'IBM Plex Mono', monospace; cursor: pointer;
  background: linear-gradient(160deg, var(--hidden-hi), var(--hidden));
  box-shadow: inset 0 1px 0 #ffffff14, 0 1px 2px #0006;
}
.cell:not(.revealed):not(.flag):hover { filter: brightness(1.15); }
.cell:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }

.cell.revealed {
  background: var(--revealed);
  box-shadow: inset 0 1px 3px #0009;
  cursor: default;
}
.cell.given { box-shadow: inset 0 1px 3px #0009, inset 0 0 0 1px #39445a; }

/* split diagonal clue: red count upper-left, blue lower-right */
.clue { position: absolute; inset: 0; }
.clue::before {
  content: '';
  position: absolute; inset: 14%;
  background: linear-gradient(135deg, transparent calc(50% - 0.5px), var(--line) calc(50% - 0.5px), var(--line) calc(50% + 0.5px), transparent calc(50% + 0.5px));
  opacity: 0.8;
}
.clue-r, .clue-b {
  position: absolute; font-weight: 700;
  font-size: clamp(11px, 2.4vh, 15px); line-height: 1;
}
.clue-r { top: 16%; left: 20%; color: var(--red); }
.clue-b { bottom: 16%; right: 20%; color: var(--blue); }
.clue-r.zero, .clue-b.zero { color: #4a5468; font-weight: 500; }
.cell.blank .clue::before { display: none; }

/* flags */
.cell.flag { cursor: default; }
.cell.flag-red { background: linear-gradient(160deg, #5a2530, #3d1b24); box-shadow: inset 0 0 0 1.5px var(--red-deep); }
.cell.flag-blue { background: linear-gradient(160deg, #21365c, #182741); box-shadow: inset 0 0 0 1.5px var(--blue-deep); }
.flag-glyph { font-size: clamp(13px, 2.6vh, 18px); }
.flag-red .flag-glyph { color: var(--red); }
.flag-blue .flag-glyph { color: var(--blue); }

/* mistakes flash + detonated mine on game over */
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-4px)} 75%{transform:translateX(4px)} }
.cell.mistake { animation: shake 0.28s ease; }
.cell.boom { box-shadow: inset 0 0 0 2px var(--gold); }
@media (prefers-reduced-motion: reduce) {
  .cell.mistake { animation: none; }
  .life { transition: none; }
}

/* ---------- tools ---------- */
.tools {
  width: 100%; max-width: 480px;
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;
  margin-top: 12px;
}
.tool {
  padding: 12px 0; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  font-family: inherit; font-size: 15px; font-weight: 500; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 7px;
}
.tool kbd {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px;
}
.tool[aria-pressed="true"] { border-color: var(--text); background: var(--hidden); }
.tool-red[aria-pressed="true"] { border-color: var(--red); color: var(--red); }
.tool-blue[aria-pressed="true"] { border-color: var(--blue); color: var(--blue); }
.tool-glyph { font-size: 16px; }
.tool-red .tool-glyph { color: var(--red); }
.tool-blue .tool-glyph { color: var(--blue); }
@media (hover: hover) and (min-width: 700px) { .tool kbd { display: inline; } }
@media (max-width: 699px) { .tool kbd { display: none; } }

.hint-line { max-width: 480px; color: var(--muted); font-size: 12.5px; text-align: center; margin: 12px 0 0; }
.c-red { color: var(--red); } .c-blue { color: var(--blue); }

/* ---------- dialogs ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 16px;
  background: var(--panel); color: var(--text);
  max-width: 420px; width: calc(100vw - 40px);
  padding: 0;
}
dialog::backdrop { background: #0b0e14cc; }
.dlg-inner { padding: 22px 22px 18px; }
.dlg-inner h2 { margin: 0 0 10px; letter-spacing: 0.04em; }
.dlg-inner p { line-height: 1.55; font-size: 14.5px; color: #c6cdd9; }
.fine { font-size: 12px; color: var(--muted); }
.btn {
  padding: 10px 18px; border-radius: var(--radius); cursor: pointer;
  border: 1px solid var(--line); background: var(--hidden); color: var(--text);
  font-family: inherit; font-size: 14px; font-weight: 500;
}
.btn-primary { border-color: var(--gold); color: var(--gold); }
.btn:hover { filter: brightness(1.15); }
.dlg-actions { display: flex; gap: 10px; margin-top: 6px; }
.result-row { font-size: 15px; margin: 12px 0 14px; letter-spacing: 0.05em; }

.foot { margin-top: 18px; color: var(--muted); font-size: 11.5px; font-family: 'IBM Plex Mono', monospace; }
