/* Killer Sudoku (/killer-sudoku): only what is the game's own - the grid of cells under the drawing of the lines, cages
   and sums, and the number pad. Tiles, buttons, fields and the accent come from the app kit (css/app-kit,
   docs/app-kit.md), the button row from css/app-kit/games.css (every game). Loaded only on this page (StylePaths). The
   board's colours are custom properties, so Save image and the pencil paint the same ones. */

.killer-sudoku-landing-app {
    --ks-line: #cbd5e1;
    --ks-box: #334155;
    --ks-cage: #64748b;
    --ks-sum: #1e293b;
    --ks-digit: #1d4ed8;
    --ks-note: #64748b;
}

.killer-sudoku-landing-app[data-theme="dark"] {
    --ks-line: #334155;
    --ks-box: #cbd5e1;
    --ks-cage: #94a3b8;
    --ks-sum: #e2e8f0;
    --ks-digit: #93c5fd;
    --ks-note: #94a3b8;
}

.killer-sudoku-board {
    position: relative;
    display: grid;
    grid-template-columns: repeat(var(--ks-n, 9), 1fr);
    width: min(100%, calc(100vh - 330px));
    min-width: min(100%, 260px);
    margin-inline: auto;
    border-radius: 8px;
    background: var(--ak-field);
    overflow: hidden;
    container-type: inline-size;
    box-sizing: border-box;
}

.killer-sudoku-board.is-making {
    opacity: 0.55;
}

/* The lines, cages and sums over the cells; clicks go through to the cells. */
.ks-lines {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
}

.ks-line {
    fill: none;
    stroke: var(--ks-line);
    stroke-width: 2;
}

.ks-box {
    fill: none;
    stroke: var(--ks-box);
    stroke-width: 5;
}

.ks-cage {
    fill: none;
    stroke: var(--ks-cage);
    stroke-width: 2;
    stroke-dasharray: 7 5;
}

.ks-sum {
    fill: var(--ks-sum);
    font: 700 22px var(--ak-font, system-ui, sans-serif);
}

.ks-sum.is-bad {
    fill: var(--ak-danger);
}

.ks-cell {
    position: relative;
    display: grid;
    place-items: center;
    aspect-ratio: 1 / 1;
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--ks-digit);
    font: 600 calc(55cqi / var(--ks-n, 9)) / 1 var(--ak-font, system-ui, sans-serif);
    padding-top: 6%;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.ks-cell:hover {
    background: var(--ak-hover);
}

/* The chosen cell's row, column and box, its cage, the same digit elsewhere, and the chosen cell itself. */
.ks-cell.is-peer {
    background: color-mix(in srgb, var(--ak-accent) 6%, transparent);
}

.ks-cell.is-cage {
    background: color-mix(in srgb, var(--ak-accent) 14%, transparent);
}

.ks-cell.is-same {
    background: color-mix(in srgb, var(--ak-accent) 20%, transparent);
}

.ks-cell.is-selected {
    background: color-mix(in srgb, var(--ak-accent) 32%, transparent);
    outline: none;
}

.ks-cell:focus-visible {
    outline: 3px solid var(--ak-accent);
    outline-offset: -3px;
}

.ks-cell.is-bad {
    color: var(--ak-danger);
    box-shadow: inset 0 0 0 2px var(--ak-danger);
}

.ks-cell.is-hint {
    animation: ks-pulse 0.8s ease-in-out infinite alternate;
}

@keyframes ks-pulse {
    from { box-shadow: inset 0 0 0 2px var(--ak-info); }
    to { box-shadow: inset 0 0 0 5px var(--ak-info); }
}

/* Notes: three small columns below the cage sum, each digit in its own place. */
.ks-notes {
    position: absolute;
    inset: 30% 8% 6%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    align-items: center;
    justify-items: center;
    color: var(--ks-note);
    font: 500 calc(19cqi / var(--ks-n, 9)) / 1 var(--ak-font, system-ui, sans-serif);
}

.killer-sudoku-board.is-solving {
    pointer-events: none;
}

.killer-sudoku-combos {
    min-height: 1.4em;
    margin: 6px 0 0;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* The number pad: the digits, the eraser and Notes in one row, two rows on a narrow screen. */
.killer-sudoku-pad {
    display: grid;
    grid-template-columns: repeat(var(--ks-keys, 11), 1fr);
    gap: 6px;
    width: min(100%, 640px);
    margin: 8px auto 0;
}

.ks-pad-btn {
    min-height: 40px;
    padding: 0;
    border: 1px solid var(--ak-border);
    border-radius: 10px;
    background: var(--ak-field);
    color: var(--ak-text);
    font: 600 18px / 1 var(--ak-font, system-ui, sans-serif);
    cursor: pointer;
}

.ks-pad-btn:hover:not(:disabled) {
    border-color: var(--ak-accent);
}

.ks-pad-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

.ks-pad-btn--notes {
    font-size: 14px;
}

.ks-pad-btn--notes[aria-pressed="true"] {
    border-color: var(--ak-accent);
    background: var(--ak-accent);
    color: var(--ak-on-accent);
}

@media (max-width: 520px) {
    .killer-sudoku-pad { grid-template-columns: repeat(6, 1fr); }
}

.killer-sudoku-status.is-solved {
    color: var(--ak-success);
    font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
    .ks-cell.is-hint { animation: none; box-shadow: inset 0 0 0 4px var(--ak-info); }
}
