/* style.css -- light/dark themes, board grid, palette, dev modal.
 *
 * Every colour the game draws comes from custom properties, so switching
 * `data-theme` on <html> recolours the whole board.  The black/white palette
 * entry is one logical colour whose value flips between themes, which is what
 * makes the already filled cells swap black <-> white on a theme switch.
 */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #6b7280;
  --line: #d7dbe2;
  --line-strong: #9aa3b0;
  --accent: #2563eb;
  --danger: #dc2626;
  --clue-done: #cccccc;

  /* filled cells: index 0 is the black/white entry */
  --fill-0: #111318;
  --fill-1: #f97316;
  --fill-2: #eab308;
  --fill-3: #22c55e;
  --fill-4: #06b6d4;
  --fill-5: #3b82f6;
  --fill-6: #8b5cf6;
  --fill-7: #ec4899;

  /* empty marks: 30% of the mark colour over 70% of the page background */
  --cross-0: #b3b5b9;
  --cross-1: #fbd7bd;
  --cross-2: #f8eeb7;
  --cross-3: #bceacb;
  --cross-4: #b3e7f0;
  --cross-5: #c1d3fb;
  --cross-6: #d5c8fb;
  --cross-7: #f8c6de;

  --given-cross: #6b7280;
  --frame: #dc2626;
}

html[data-theme="dark"] {
  --bg: #14161a;
  --surface: #1c1f25;
  --text: #e8eaee;
  --muted: #9aa3b0;
  --line: #333941;
  --line-strong: #5b636f;
  --accent: #60a5fa;
  --danger: #f87171;
  --clue-done: #333333;

  --fill-0: #f2f4f8;
  --fill-1: #fb923c;
  --fill-2: #facc15;
  --fill-3: #4ade80;
  --fill-4: #22d3ee;
  --fill-5: #60a5fa;
  --fill-6: #a78bfa;
  --fill-7: #f472b6;

  --cross-0: #4a4d53;
  --cross-1: #5b4632;
  --cross-2: #5c5526;
  --cross-3: #28532f;
  --cross-4: #1e5560;
  --cross-5: #294268;
  --cross-6: #413566;
  --cross-7: #612a47;

  --given-cross: #9aa3b0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans SC", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 10px 14px 18px;
  gap: 10px;
}

/* ---------------------------------------------------------------- topbar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.title {
  font-size: 20px;
  font-weight: 650;
  letter-spacing: 0.02em;
  margin: 0;
  cursor: default;
  user-select: none;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.level-picker { display: flex; gap: 6px; }

select {
  font: inherit;
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}

.icon-button:hover { border-color: var(--line-strong); }
.icon-button svg { width: 20px; height: 20px; }
.icon-button svg path { fill: currentColor; }
.icon-button svg .stroke-only,
.icon-button svg .stroke-only-thick {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

html[data-theme="light"] .icon-moon { display: none; }
html[data-theme="dark"] .icon-sun { display: none; }

/* ----------------------------------------------------------------- stage */

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.mode-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.mode-button[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.status {
  font-size: 12px;
  color: var(--muted);
  min-height: 1em;
  transition: opacity 0.3s ease;
}
.status.flash { color: var(--accent); }

/* ----------------------------------------------------------------- board */

.board-wrap {
  position: relative;
  display: inline-block;
  max-width: 100%;
  overflow: auto;
}

.board {
  display: grid;
  background: var(--surface);
  border: 2px solid var(--line-strong);
  border-radius: 6px;
  padding: 0;
  position: relative;
}

.board .corner { background: var(--surface); }

.cell {
  position: relative;
  width: var(--cell);
  height: var(--cell);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
}

.cell.filled { background: var(--cell-fill); }

/* the empty mark: two bars forming a small cross */
.cell .cross,
.cell .cross::before,
.cell .cross::after {
  position: absolute;
  content: "";
}

.cell .cross {
  inset: 0;
  display: none;
}

.cell.marked .cross { display: block; }

.cell .cross::before,
.cell .cross::after {
  left: 50%;
  top: 50%;
  width: 58%;
  height: 10%;
  min-height: 1.5px;
  border-radius: 2px;
  background: var(--cell-cross);
}

.cell .cross::before { transform: translate(-50%, -50%) rotate(45deg); }
.cell .cross::after { transform: translate(-50%, -50%) rotate(-45deg); }

.cell.marked .cross::before,
.cell.marked .cross::after { background: var(--cell-cross); }

.cell.given .cross::before,
.cell.given .cross::after {
  background: var(--given-cross);
  height: 13%;
}

.cell.given { cursor: default; }

.cell:hover:not(.given) { box-shadow: inset 0 0 0 2px var(--accent); }

.clue {
  display: flex;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  line-height: 1;
  user-select: none;
}

.clue.row {
  flex-direction: row;
  justify-content: flex-end;
  align-items: center;
  gap: 0.32em;
  padding-right: 0.32em;
  font-size: var(--clue-font-row);
}

.clue.col {
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 0.14em;
  padding-bottom: 0.3em;
  font-size: var(--clue-font-col);
}

.clue.done { color: var(--clue-done); }

.overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.red-frame {
  position: absolute;
  border: 3px solid var(--frame);
  border-radius: 3px;
  box-sizing: border-box;
}

/* --------------------------------------------------------------- palette */

.palette {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--swatch);
  cursor: pointer;
  padding: 0;
  position: relative;
}

.swatch[aria-pressed="true"] {
  border-color: var(--text);
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--text);
}

/* ----------------------------------------------------------------- actions */

.actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.text-button {
  font: inherit;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.text-button:hover:not(:disabled) { border-color: var(--line-strong); }
.text-button:disabled { opacity: 0.45; cursor: default; }
.text-button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ------------------------------------------------------------------ modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 20px;
}

.modal-backdrop[hidden] { display: none; }

.modal {
  background: var(--surface);
  color: var(--text);
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 18px 20px;
  width: min(360px, 100%);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.modal h2 { margin: 0 0 6px; font-size: 16px; }
.modal-hint { margin: 0 0 12px; font-size: 12px; color: var(--muted); }

.modal-options { display: flex; flex-direction: column; gap: 8px; }

.modal-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
}

.modal-options label:hover { border-color: var(--line-strong); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

@media (max-width: 480px) {
  .title { font-size: 17px; }
  .swatch { width: 26px; height: 26px; }
  .text-button { padding: 7px 10px; font-size: 12px; }
}
