/* Killer Sudoku — grille de chiffres on the design-system paper. A 9×9 Sudoku
   with no givens: the grid is partitioned into cages drawn as dashed outlines,
   each showing a target sum in its top-left cell. Player digits in accent, the
   few seed givens in ink; row/column/box/cage violations flagged (signal, not
   correction). Scoped under .ks-root. */

.ks-root { padding: clamp(6px, 2.5vw, 16px); color: var(--color-text); }

/* One 9×9 grid so every column and row is sized together — all lines align.
   Cells carry a thin border on right+bottom only (no doubling); 3×3 region
   boundaries get a thick border on that same single side. --line / --line2 are
   the thin and thick rule colours, --cage the dashed cage outline. */
.ks-grid {
  --line: var(--color-neutral-300);
  --line2: var(--color-text);
  --cage: color-mix(in srgb, var(--color-text) 55%, transparent);
  display: grid; grid-template-columns: repeat(9, 1fr); grid-template-rows: repeat(9, 1fr);
  inline-size: min(92vw, 396px); aspect-ratio: 1; margin: 0 auto var(--space-4);
  box-sizing: border-box;
  border: 2px solid var(--line2);
  background: var(--color-neutral-100);
}
.ks-cell {
  position: relative; display: flex; align-items: center; justify-content: center;
  box-sizing: border-box; cursor: pointer; user-select: none;
  font-family: var(--font-body); font-weight: 500; font-size: clamp(15px, 4.6vw, 22px);
  font-variant-numeric: tabular-nums; line-height: 1;
  background: var(--color-neutral-100);
  color: var(--color-accent-700);
  border-inline-end: 1px solid var(--line);
  border-block-end: 1px solid var(--line);
}
.ks-cell.rr { border-inline-end: 2px solid var(--line2); } /* right edge of a box */
.ks-cell.rb { border-block-end: 2px solid var(--line2); }  /* bottom edge of a box */
.ks-cell.nr { border-inline-end: none; }                    /* last column */
.ks-cell.nb { border-block-end: none; }                     /* last row */

/* dashed cage outline: an inset overlay whose sides are drawn where the
   neighbour belongs to a different cage. */
.ks-cage { position: absolute; inset: 3px; pointer-events: none; }
.ks-cell.ct > .ks-cage { border-block-start: 1.5px dashed var(--cage); }
.ks-cell.cr > .ks-cage { border-inline-end: 1.5px dashed var(--cage); }
.ks-cell.cb > .ks-cage { border-block-end: 1.5px dashed var(--cage); }
.ks-cell.cl > .ks-cage { border-inline-start: 1.5px dashed var(--cage); }

.ks-sum {
  position: absolute; inset-block-start: 1px; inset-inline-start: 3px;
  font-size: 9px; font-weight: 700; line-height: 1; color: var(--color-text);
  font-variant-numeric: tabular-nums; pointer-events: none;
}
.ks-val { display: flex; }

.ks-cell.given { color: var(--color-text); font-weight: 600; }
.ks-cell.peer { background: var(--color-neutral-200); }
.ks-cell.same { background: var(--color-accent-100); }
.ks-cell.sel { background: var(--color-accent-200); box-shadow: inset 0 0 0 2px var(--color-accent); }
.ks-cell.conflict { color: var(--madder, #c0182b); background: color-mix(in srgb, var(--madder, #c0182b) 12%, transparent); }
.ks-cell.conflict .ks-sum { color: var(--madder, #c0182b); }

.ks-notes { position: absolute; inset: 1px; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); }
.ks-notes span { display: flex; align-items: center; justify-content: center; font-size: 8px; font-weight: 400; color: var(--color-neutral-600); }

.ks-pad {
  display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px;
  max-inline-size: min(96vw, 460px); margin: 0 auto;
}
.ks-key {
  min-block-size: 44px; padding: 0;
  font-family: var(--font-body); font-size: 17px; font-weight: 600;
  font-variant-numeric: tabular-nums; cursor: pointer;
  border: 1px solid var(--color-neutral-300); border-radius: var(--radius-sm);
  background: var(--color-neutral-100); color: var(--color-text);
}
.ks-key:hover { background: color-mix(in srgb, var(--color-text) 6%, transparent); }
.ks-notes-btn[aria-pressed="true"] { border-color: var(--color-accent); color: var(--color-accent-700); background: var(--color-accent-100); }

/* Dark page — legible cells, brighter region and cage lines, dark highlights
   (the light neutral ramp would otherwise show as bright patches). */
.ks-root.mode-dark .ks-grid { --line: #524d45; --line2: #9c948a; --cage: #b6ad9f; background: #26241f; border-color: #9c948a; }
.ks-root.mode-dark .ks-cell { background: #26241f; color: var(--color-accent-400); }
.ks-root.mode-dark .ks-cell.given { color: #f2eee8; }
.ks-root.mode-dark .ks-sum { color: #f2eee8; }
.ks-root.mode-dark .ks-cell.peer { background: #322f28; }
.ks-root.mode-dark .ks-cell.same { background: #403715; }
.ks-root.mode-dark .ks-cell.sel { background: #4d3f18; box-shadow: inset 0 0 0 2px var(--color-accent-400); }
.ks-root.mode-dark .ks-cell.conflict { color: #ff9384; background: rgba(192, 24, 43, 0.3); }
.ks-root.mode-dark .ks-cell.conflict .ks-sum { color: #ff9384; }
.ks-root.mode-dark .ks-notes span { color: #8f8a82; }
.ks-root.mode-dark .ks-key { background: #2d2b26; border-color: #4a463f; color: #ece8e2; }
.ks-root.mode-dark .ks-notes-btn[aria-pressed="true"] { border-color: var(--color-accent-400); color: var(--color-accent-400); background: #403715; }
