:root {
  color-scheme: dark;
  --bg: #000;
  --ink: #fff;
  --mute: #9a9a9a;
  --line: #fff;
  --flag: #ffe100;
  --error: #ff5a4a;
  --hint: #ffe100;
  --cell: min(64px, calc((100vw - 80px) / var(--n)));
  font-family: "Open Sans", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); -webkit-tap-highlight-color: transparent; background: var(--bg); color: var(--ink); min-height: 100vh; display: flex; flex-direction: column; }
button, select, input { font: inherit; color: var(--ink); background: transparent; border: 2px solid var(--ink); border-radius: 0; padding: 6px 12px; min-height: 44px; }
button { cursor: pointer; font-weight: 700; }
button:hover { background: #1a1a1a; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid var(--flag); outline-offset: 2px; }
button[aria-pressed="true"] { border-color: var(--flag); color: var(--flag); }
select option { background: #000; }

.top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; padding: 24px clamp(16px, 4vw, 48px) 0; }
.rules p { margin: 0 0 6px; font-weight: 700; font-size: clamp(15px, 2vw, 20px); }
.rules u { text-underline-offset: 3px; }
.tools { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }

main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.board-wrap { display: grid; grid-template-columns: 24px auto; grid-template-rows: 24px auto; }
.cols { grid-column: 2; display: grid; grid-template-columns: repeat(var(--n), var(--cell)); text-align: center; color: var(--ink); font-size: 14px; }
.rows { grid-row: 2; display: grid; grid-template-rows: repeat(var(--n), var(--cell)); align-items: center; font-size: 14px; }
.board { grid-column: 2; grid-row: 2; display: grid; grid-template-columns: repeat(var(--n), var(--cell)); border: 1px solid var(--line); }

.cell {
  width: var(--cell); height: var(--cell); min-height: 0; padding: 0;
  border: 1px solid var(--line); background: transparent;
  font: 600 calc(var(--cell) * 0.5) "Quicksand", "Avenir Next", system-ui, sans-serif;
  display: grid; place-items: center; color: var(--ink);
}
.cell.open { cursor: default; }
.cell.open:hover { background: transparent; }
.cell.flag { color: var(--flag); }
.cell.qm { color: var(--mute); }
.cell.done { color: #6f6f6f; }
.cell.flag svg { width: 55%; height: 55%; }
.cell.hint { box-shadow: inset 0 0 0 4px var(--hint); }
.cell.bad { animation: bad .6s ease-out; }
@keyframes bad { 0%, 40% { background: var(--error); } 100% { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .cell.bad { animation: none; background: #3a0d09; } }

.status { min-height: 1.6em; margin: 20px 0 0; font-weight: 700; font-size: 18px; text-align: center; }
.status.error { color: var(--error); }
.status.win { color: var(--flag); }

.bottom { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding: 0 clamp(16px, 4vw, 48px) 24px; }
.code { font-weight: 700; font-size: 20px; }
.new { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.new label { display: grid; gap: 2px; font-size: 13px; color: var(--mute); }
.mistakes { font-weight: 700; font-size: 20px; }
