/*!
 * Solvers Sudoku - front-end styles
 *
 * Everything is scoped under .sds and namespaced with sds- so it cannot clash
 * with the active theme.
 *
 * Layout: on wide screens the board sits on the left and the controls (tools,
 * number pad, key facts) form a side column on the right - the arrangement
 * players already expect from the big sudoku sites. Narrow screens fall back to
 * the stacked board-then-pad order. Only CSS decides this: the markup stays
 * exactly what PHP renders, so the server-rendered board (and its SEO value) is
 * untouched by this file.
 */

.sds {
	--sds-bg: #f5f7fb;
	--sds-card: #ffffff;
	--sds-ink: #1e2433;
	--sds-muted: #8b93a7;
	--sds-line: #e4e8f0;
	--sds-strong: #2b3242;
	--sds-accent: #2f6fed;
	--sds-accent-soft: #e9f0fe;
	--sds-peer: #f3f6fc;
	--sds-same: #dbe7fd;
	--sds-err: #e0483f;
	--sds-err-soft: #fdeceb;
	--sds-ok: #1e9e6a;
	--sds-key: #f2f5fa;
	--sds-key-hover: #e7eefb;
	--sds-radius: 14px;
	--sds-side: 240px;

	box-sizing: border-box;
	max-width: 880px;
	margin: 1.5rem auto;
	display: grid;
	grid-template-columns: minmax(0, 1fr) var(--sds-side);
	grid-template-areas:
		"head  head"
		"tabs  tabs"
		"board hint"
		"board tools"
		"board pad"
		"board info";
	align-content: start;
	align-items: start;
	gap: 12px 18px;
	color: var(--sds-ink);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 16px;
	line-height: 1.45;
	-webkit-tap-highlight-color: transparent;
}

.sds *,
.sds *::before,
.sds *::after { box-sizing: border-box; }

/*
 * THE `hidden` ATTRIBUTE MUST WIN, ON SCREEN, ALWAYS.
 *
 * `hidden` is only a presentational hint: the UA stylesheet says
 * `[hidden] { display: none }`, and an author rule beats a UA rule for normal
 * declarations no matter how specific the UA rule is. So the moment any rule in
 * this file gives such an element a `display` of its own, the element is visible
 * again while every script still believes it is hidden.
 *
 * That is not hypothetical. The 4x4 pool ships 48 boards and puts `hidden` on
 * the 36 that were not picked. `.sds-mini-figure { display: grid }` (below)
 * defeated the UA rule, so on screen ALL 48 boards were painted -- while
 * mini.js isShown() read the property, agreed the 36 were hidden, and gave them
 * no click listener. Three quarters of the boards a visitor could see and tap
 * did nothing at all. The rule meant to prevent it,
 * `.sds-mini-figure[hidden] { display: none !important }`, had been written
 * inside `@media print` and so never applied on screen.
 *
 * Ten per-selector `[hidden]` rules already lived in this file, and that is the
 * approach that failed: it relies on remembering to add an eleventh every time.
 * One global rule ends the whole class of bug. `!important` is deliberate -- it
 * has to outrank an ordinary author `display`, which is exactly what the UA rule
 * could not do. Removing it is a regression; test-hidden-attribute.js checks it.
 */
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- head */

.sds-head {
	grid-area: head;
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 8px 14px;
	flex-wrap: wrap;
}

.sds-title {
	margin: 0;
	font-size: 18px;
	font-weight: 700;
	letter-spacing: -.2px;
	color: var(--sds-ink);
}

.sds-meta {
	display: flex;
	gap: 14px;
	font-size: 14px;
	color: var(--sds-muted);
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.sds-meta b { color: var(--sds-ink); font-weight: 600; }
.sds-meta .sds-danger, .sds-meta .sds-danger b { color: var(--sds-err); }

/* ---------------------------------------------------------------- tabs */

.sds-tabs {
	grid-area: tabs;
	display: grid;
	grid-template-columns: repeat(5, 1fr);
	gap: 5px;
	background: var(--sds-card);
	padding: 5px;
	border-radius: var(--sds-radius);
	box-shadow: 0 1px 2px rgba(20, 30, 60, .06);
}

.sds-tab {
	appearance: none;
	border: 0;
	background: transparent;
	color: var(--sds-muted);
	font-weight: 600;
	font-size: 13px;
	line-height: 1;
	padding: 10px 4px;
	border-radius: 10px;
	cursor: pointer;
	transition: background .12s, color .12s;
}

.sds-tab:hover { color: var(--sds-ink); background: var(--sds-key); }
.sds-tab.sds-on { background: var(--sds-accent); color: #fff; }

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

.sds-boardwrap {
	grid-area: board;
	position: relative;
	width: 100%;
	max-width: 560px;
	justify-self: center;
}

/* The board is nine `role="row"` containers, each a 9-column grid, so the
   markup is a valid ARIA grid (grid > row > gridcell) and still lays out as a
   plain 9x9. Nine 1fr columns inside nine 1fr rows keep every cell square
   because the board itself is `aspect-ratio: 1/1`. */
.sds-board {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	grid-auto-rows: minmax(0, 1fr);
	background: var(--sds-card);
	border: 2px solid var(--sds-strong);
	border-radius: 10px;
	overflow: hidden;
	aspect-ratio: 1 / 1;
	width: 100%;
	box-shadow: 0 2px 10px rgba(20, 30, 60, .07);
	user-select: none;
	-webkit-user-select: none;
}

.sds-row {
	display: grid;
	grid-template-columns: repeat(9, minmax(0, 1fr));
	min-height: 0;
}

.sds-cell {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	border-right: 1px solid var(--sds-line);
	border-bottom: 1px solid var(--sds-line);
	font-size: clamp(18px, 3.4vw, 27px);
	font-weight: 500;
	color: var(--sds-accent);
	cursor: pointer;
	transition: background .08s;
	background: var(--sds-card);
	line-height: 1;
	min-width: 0;
	min-height: 0;
}

.sds-cell.sds-br { border-right: 2px solid var(--sds-strong); }
.sds-cell.sds-bb { border-bottom: 2px solid var(--sds-strong); }
/* the last cell of each row, now that a row -- not the board -- is the parent */
.sds-row .sds-cell:nth-child(9n) { border-right: 0; }
.sds-row:last-child .sds-cell { border-bottom: 0; }

.sds-board:focus { outline: none; }
.sds-board:focus-visible { box-shadow: 0 0 0 3px rgba(47, 111, 237, .35); }

/* While a fresh puzzle is being generated. */
.sds-busy .sds-board { opacity: .35; pointer-events: none; transition: opacity .15s; }
.sds-busy .sds-tabs, .sds-busy .sds-tools, .sds-busy .sds-pad { opacity: .5; pointer-events: none; }
.sds-busy .sds-boardwrap::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 34px;
	height: 34px;
	margin: -17px 0 0 -17px;
	border: 3px solid var(--sds-line);
	border-top-color: var(--sds-accent);
	border-radius: 50%;
	animation: sds-spin .7s linear infinite;
}

@keyframes sds-spin {
	to { transform: rotate(360deg); }
}

.sds-cell.sds-given { color: var(--sds-ink); font-weight: 600; }
.sds-cell.sds-peer { background: var(--sds-peer); }
.sds-cell.sds-same { background: var(--sds-same); }
.sds-cell.sds-sel { background: var(--sds-accent-soft); box-shadow: inset 0 0 0 2px var(--sds-accent); }
.sds-cell.sds-bad { color: var(--sds-err); }
.sds-cell.sds-bad.sds-sel { background: var(--sds-err-soft); box-shadow: inset 0 0 0 2px var(--sds-err); }
.sds-cell.sds-hinted { color: var(--sds-ok); }
.sds-cell.sds-pop { animation: sds-pop .18s ease-out; }
.sds-cell.sds-shake { animation: sds-shake .3s ease-in-out; }

@keyframes sds-pop {
	from { transform: scale(.78); }
	to   { transform: scale(1); }
}

@keyframes sds-shake {
	0%, 100% { transform: translateX(0); }
	25%      { transform: translateX(-3px); }
	75%      { transform: translateX(3px); }
}

.sds-notes {
	position: absolute;
	inset: 2px;
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	grid-template-rows: repeat(3, 1fr);
	font-size: clamp(7px, 1.4vw, 10px);
	font-weight: 500;
	color: var(--sds-muted);
	line-height: 1;
	pointer-events: none;
}

.sds-notes i {
	display: flex;
	align-items: center;
	justify-content: center;
	font-style: normal;
}

/* ------------------------------------------------------------- overlay */

.sds-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	background: rgba(255, 255, 255, .94);
	backdrop-filter: blur(4px);
	border-radius: 10px;
	text-align: center;
	padding: 20px;
	z-index: 2;
}

.sds-overlay[hidden] { display: none; }
.sds-overlay h4 { margin: 0; font-size: 23px; letter-spacing: -.3px; }
.sds-overlay.sds-lose h4 { color: var(--sds-err); }
.sds-overlay p { margin: 0; color: var(--sds-muted); font-size: 14px; max-width: 32ch; }

.sds-stats { display: flex; gap: 22px; margin: 4px 0; }
.sds-stats div { font-size: 12px; color: var(--sds-muted); }
.sds-stats b {
	display: block;
	font-size: 19px;
	color: var(--sds-ink);
	font-variant-numeric: tabular-nums;
}

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

/* ------------------------------------------------------------- debrief */
/* Shown with the end-of-game panel: what the puzzle needed, and what the
   player leaned on. Text-heavy on purpose - this is the teaching payoff. */

.sds-debrief {
	display: grid;
	gap: 5px;
	max-width: 46ch;
	text-align: left;
	font-size: 12.5px;
	line-height: 1.45;
	color: var(--sds-muted);
	background: var(--sds-bg);
	border-radius: 10px;
	padding: 11px 13px;
}

.sds-debrief[hidden] { display: none; }

.sds-debrief > b {
	color: var(--sds-ink);
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: .06em;
}

.sds-debrief span { display: block; }
.sds-debrief span b { color: var(--sds-accent); font-weight: 600; }

/* The "where to go next" line: the only part of the debrief that is a link, so
   it gets its own accent and keeps the underline -- the rest of the card is
   prose, and a link you cannot tell from prose is a link nobody clicks. */
.sds-debrief .sds-debrief-next { margin-top: 6px; }
.sds-debrief .sds-debrief-next a {
	color: var(--sds-accent);
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 2px;
}

/* ---------------------------------------------------------- share card */

.sds-share {
	display: grid;
	gap: 8px;
	justify-items: center;
	width: 100%;
	max-width: 46ch;
}

.sds-share[hidden] { display: none; }

.sds-share-box {
	width: 100%;
	font: 500 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	color: var(--sds-ink);
	background: var(--sds-bg);
	border: 1.5px solid var(--sds-line);
	border-radius: 10px;
	padding: 10px;
	resize: vertical;
	white-space: pre;
	overflow-x: auto;
}

.sds-share-box[hidden] { display: none; }
.sds-share-box:focus { outline: none; border-color: var(--sds-accent); }

.sds-btn {
	appearance: none;
	border: 0;
	background: var(--sds-accent);
	color: #fff;
	font-weight: 600;
	font-size: 15px;
	line-height: 1;
	padding: 13px 26px;
	border-radius: 11px;
	cursor: pointer;
}

.sds-btn:hover { filter: brightness(1.06); }
.sds-btn[hidden] { display: none; }
.sds-btn.sds-ghost {
	background: var(--sds-card);
	color: var(--sds-ink);
	box-shadow: inset 0 0 0 1.5px var(--sds-line);
}

/* ----------------------------------------------------------- info line */

.sds-info {
	grid-area: info;
	display: flex;
	flex-wrap: wrap;
	gap: 6px 8px;
	justify-content: flex-start;
	font-size: 11.5px;
	color: var(--sds-muted);
	margin: 0;
	padding: 0;
}

.sds-info b { color: var(--sds-ink); font-weight: 600; }
.sds-info > span {
	background: var(--sds-card);
	border-radius: 999px;
	padding: 3px 9px;
	box-shadow: 0 1px 2px rgba(20, 30, 60, .05);
}
.sds-info > span[hidden] { display: none; }

/* --------------------------------------------------------------- tools */

.sds-tools {
	grid-area: tools;
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 8px;
}

.sds-tool {
	appearance: none;
	border: 0;
	background: var(--sds-card);
	border-radius: 12px;
	padding: 12px 4px;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	font-weight: 600;
	font-size: 12px;
	line-height: 1;
	color: var(--sds-ink);
	cursor: pointer;
	box-shadow: 0 1px 2px rgba(20, 30, 60, .06);
	transition: transform .08s, background .12s;
}

.sds-tool:hover { background: var(--sds-key); }
.sds-tool:active { transform: scale(.96); }
.sds-tool > span { font-size: 19px; line-height: 1; }
.sds-tool i {
	font-size: 10px;
	font-weight: 500;
	font-style: normal;
	color: var(--sds-muted);
	font-variant-numeric: tabular-nums;
}

.sds-tool.sds-on { background: var(--sds-accent); color: #fff; }
.sds-tool.sds-on i { color: rgba(255, 255, 255, .75); }
.sds-tool:disabled { opacity: .4; cursor: default; }

/* ----------------------------------------------------------------- pad */

.sds-pad {
	grid-area: pad;
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 8px;
}

.sds-key {
	appearance: none;
	border: 0;
	background: var(--sds-key);
	border-radius: 12px;
	aspect-ratio: 1 / 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 2px;
	font-weight: 600;
	font-size: clamp(19px, 3vw, 24px);
	line-height: 1;
	color: var(--sds-accent);
	cursor: pointer;
	transition: transform .08s, background .12s, opacity .12s;
}

.sds-key:hover { background: var(--sds-key-hover); }
.sds-key:active { transform: scale(.94); }
.sds-key i {
	font-size: 10px;
	font-weight: 500;
	font-style: normal;
	color: var(--sds-muted);
	font-variant-numeric: tabular-nums;
}

.sds-key.sds-done { opacity: .3; }

/* ------------------------------------------------- step-by-step solver */
/* [sudoku-solver] reuses the board, cells and hint panel; only the furniture
   around them changes: an entry row and the explanatory copy. */

.sds-solver {
	grid-template-areas:
		"head  head"
		"board hint"
		"board tools"
		"board pad"
		"entry entry"
		"notes notes";
}

.sds-solver .sds-tools { grid-template-columns: repeat(2, 1fr); }

.sds-entry {
	grid-area: entry;
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 10px;
	background: var(--sds-card);
	border-radius: var(--sds-radius);
	padding: 12px;
	box-shadow: 0 1px 2px rgba(20, 30, 60, .06);
}

.sds-field {
	flex: 1 1 300px;
	display: flex;
	flex-direction: column;
	gap: 5px;
	font-size: 12px;
	color: var(--sds-muted);
}

.sds-input {
	width: 100%;
	font: 500 14px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	letter-spacing: .04em;
	color: var(--sds-ink);
	background: var(--sds-key);
	border: 1px solid var(--sds-line);
	border-radius: 9px;
	padding: 9px 11px;
}

.sds-input:focus {
	outline: none;
	background: #fff;
	border-color: var(--sds-accent);
	box-shadow: 0 0 0 3px rgba(47, 111, 237, .18);
}

.sds-entry .sds-actions { flex: 0 0 auto; }
.sds-entry .sds-btn { padding: 10px 16px; font-size: 14px; }

.sds-solver-notes {
	grid-area: notes;
	font-size: 14px;
	color: var(--sds-ink);
}

.sds-solver-notes h4 { margin: 4px 0 6px; font-size: 16px; }
.sds-solver-notes p { margin: 0 0 10px; color: #4a5266; }
.sds-techniques { margin: 0; padding-left: 18px; color: #4a5266; }
.sds-techniques li { margin: 3px 0; }
.sds-techniques b { color: var(--sds-ink); }

/* ------------------------------------------------- technique guides */
/* [sudoku-technique] reuses the solver layout; only the hub list is new. */

.sds-technique-index { display: block; max-width: 720px; }

.sds-technique-list {
	margin: 0;
	padding: 0;
	list-style: none;
	display: grid;
	gap: 8px;
}

.sds-technique-list li {
	background: var(--sds-card);
	border-radius: 10px;
	padding: 11px 14px;
	box-shadow: 0 1px 2px rgba(20, 30, 60, .06);
}

.sds-technique-list a {
	display: block;
	/*
	 * The whole first line of the card is the target, not just the words.
	 * An inline link here measured 21px tall -- under the 24px minimum -- and a
	 * thumb should not have to hit a 21px strip inside a 43px card.
	 */
	margin: -11px -14px;
	padding: 12px 14px;
	font-weight: 700;
	color: var(--sds-accent);
	text-decoration: none;
}

.sds-technique-list a:hover { text-decoration: underline; }
.sds-technique-list span { display: block; color: #4a5266; font-size: 13.5px; }

.sds-guide-links { font-size: 13px; color: var(--sds-muted); }
.sds-guide-links a { color: var(--sds-accent); }

/* ------------------------------------------------------- teaching hint */
/* The hint panel is created by game.js, so it needs no PHP markup. */

.sds-hintbox {
	grid-area: hint;
	position: relative;
	background: var(--sds-accent-soft);
	border-left: 3px solid var(--sds-accent);
	border-radius: 10px;
	padding: 10px 34px 11px 12px;
	font-size: 13.5px;
	line-height: 1.5;
	color: var(--sds-ink);
}

.sds-hintbox[hidden] { display: none; }

.sds-hint-technique {
	display: block;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--sds-accent);
	margin-bottom: 2px;
}

.sds-hint-text { display: block; }

.sds-hint-close {
	position: absolute;
	top: 6px;
	right: 6px;
	appearance: none;
	border: 0;
	background: transparent;
	color: var(--sds-muted);
	font-weight: 400;
	font-size: 18px;
	line-height: 1;
	padding: 2px 6px;
	border-radius: 6px;
	cursor: pointer;
}

.sds-hint-close:hover { background: rgba(47, 111, 237, .12); color: var(--sds-ink); }

/* Cells the explanation talks about. */
.sds-cell.sds-hl { background: var(--sds-same); box-shadow: inset 0 0 0 2px var(--sds-accent); }
.sds-cell.sds-hl-x { background: var(--sds-err-soft); box-shadow: inset 0 0 0 2px var(--sds-err); }

.sds-cell.sds-hl, .sds-cell.sds-hl-x { animation: sds-hl .9s ease-in-out 2; }

@keyframes sds-hl {
	0%, 100% { filter: none; }
	50%      { filter: brightness(.94); }
}

/* --------------------------------------------------------- drill mode */
/* [sudoku-drill] - the tactics trainer. Same board, a different question. */

.sds-drill {
	grid-template-columns: minmax(0, 1fr);
	grid-template-areas:
		"head"
		"ask"
		"board"
		"hint"
		"bar"
		"tools"
		"pad"
		"feedback"
		"info"
		"notes";
	max-width: 560px;
}

.sds-drill-ask {
	grid-area: ask;
	margin: 0;
	font-size: 15px;
	font-weight: 600;
	color: var(--sds-ink);
	background: var(--sds-card);
	border-radius: 10px;
	padding: 11px 14px;
	box-shadow: 0 1px 2px rgba(20, 30, 60, .05);
}

.sds-drill-bar {
	grid-area: bar;
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 8px;
}

.sds-drill-bar .sds-btn { padding: 12px 8px; font-size: 14px; }

.sds-drill-feedback {
	grid-area: feedback;
	font-size: 13.5px;
	line-height: 1.5;
	border-radius: 10px;
	padding: 11px 14px;
	background: var(--sds-card);
	box-shadow: inset 0 0 0 1.5px var(--sds-line);
}
.sds-drill-feedback[hidden] { display: none; }
.sds-drill-feedback b { display: block; margin-bottom: 2px; }
.sds-drill-feedback.sds-right { box-shadow: inset 0 0 0 1.5px var(--sds-ok); }
.sds-drill-feedback.sds-right b { color: var(--sds-ok); }
.sds-drill-feedback.sds-wrong { box-shadow: inset 0 0 0 1.5px var(--sds-err); }
.sds-drill-feedback.sds-wrong b { color: var(--sds-err); }
.sds-drill-feedback.sds-revealed { box-shadow: inset 0 0 0 1.5px var(--sds-accent); }
.sds-drill-feedback.sds-revealed b { color: var(--sds-accent); }

/* In the drill the pencil marks are live: tapping one takes that candidate
   away, which is the whole point of an elimination drill. */
.sds-drill .sds-notes { pointer-events: auto; }
.sds-drill .sds-notes i { cursor: pointer; border-radius: 3px; }
.sds-drill .sds-notes i:hover { background: var(--sds-same); }

@media (min-width: 860px) {
	.sds-drill {
		grid-template-columns: minmax(0, 1fr) var(--sds-side);
		grid-template-areas:
			"head     head"
			"ask      ask"
			"board    bar"
			"board    tools"
			"board    pad"
			"board    feedback"
			"info     info"
			"notes    notes";
		max-width: 100%;
	}
	.sds-drill .sds-drill-bar { grid-template-columns: minmax(0, 1fr); }
	.sds-drill .sds-tools { grid-template-columns: repeat(2, 1fr); }
	.sds-drill .sds-pad { grid-template-columns: repeat(3, 1fr); }
}

/* --------------------------------------------------------------- toast */

.sds-toast {
	position: fixed;
	left: 50%;
	bottom: 22px;
	transform: translate(-50%, 20px);
	background: var(--sds-strong);
	color: #fff;
	font-size: 13px;
	font-weight: 500;
	padding: 10px 16px;
	border-radius: 10px;
	opacity: 0;
	pointer-events: none;
	transition: all .2s;
	z-index: 9999;
	max-width: 88vw;
	text-align: center;
}

.sds-toast.sds-on { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------------------------------------ fallback */

.sds-noscript {
	background: var(--sds-card);
	border-radius: 10px;
	padding: 12px;
	font-size: 14px;
	color: var(--sds-muted);
	text-align: center;
}

/* ------------------------------------------------------- narrow screens */
/* Board first, controls under it - the order the DOM already has. */

@media (max-width: 859px) {
	.sds {
		max-width: 520px;
		grid-template-columns: minmax(0, 1fr);
		grid-template-areas:
			"head"
			"tabs"
			"board"
			"hint"
			"tools"
			"pad"
			"info";
		gap: 10px;
	}

	.sds-boardwrap { max-width: none; }
	.sds-cell { font-size: clamp(18px, 5.6vw, 28px); }
	.sds-notes { font-size: clamp(7px, 2.1vw, 10px); }
	.sds-tools { grid-template-columns: repeat(4, 1fr); }
	/*
	 * `minmax(0, 1fr)` rather than `1fr`: a bare `1fr` track cannot shrink below
	 * its item's min-content width, and the erase key's label is a word, not a
	 * digit. Kadence's body font is wider than Twenty Twenty-Five's, which pushed
	 * that minimum to 48px -- nine of those plus gaps overflows a 374px pad and
	 * the seatbelt below had to clip it. Zeroing the floor restores the
	 * digit-sized key (measured 38x47 at 390px again) without shrinking digits,
	 * whose min-content is about 10px.
	 */
	.sds-pad { grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 5px; }
	.sds-key { aspect-ratio: 1 / 1.25; font-weight: 600; font-size: clamp(17px, 4.6vw, 22px); line-height: 1; min-width: 0; }
	.sds-info { justify-content: center; }

	.sds-solver {
		grid-template-areas:
			"head"
			"board"
			"hint"
			"tools"
			"pad"
			"entry"
			"notes";
	}
	.sds-solver .sds-tools { grid-template-columns: repeat(4, 1fr); }
	.sds-entry .sds-actions { width: 100%; }
	.sds-entry .sds-actions .sds-btn { flex: 1 1 auto; }

	/* The drill names areas the game page has never heard of -- ask, bar,
	   feedback, notes. If the `.sds` template above is allowed to win, those
	   names stop matching a real line, and a grid then looks for them among the
	   *implicit* lines: every one of them opens a new column, which squeezes the
	   column that holds the board down to 0px and drops the rest into a single
	   pile. On a phone that reads as "no board and everything on top of itself".
	   The drill keeps the single-column template it is authored with. */
	.sds-drill {
		max-width: 560px;
		grid-template-columns: minmax(0, 1fr);
		grid-template-areas:
			"head"
			"ask"
			"board"
			"hint"
			"bar"
			"tools"
			"pad"
			"feedback"
			"info"
			"notes";
	}
	.sds-drill .sds-tools { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 360px) {
	.sds-info { font-size: 10.5px; }
	.sds-tab { font-size: 12px; }
	.sds-pad { gap: 4px; }
}

/*
 * PHONE WIDTH: GIVE THE GRID THE WHOLE SCREEN
 *
 * A 360-390px phone is the one place where the theme's side gutter costs real
 * estate the game cannot spare: it squeezed the board to 33px squares and the
 * number pad to 30px keys, both well under the 44px a thumb reliably hits.
 * Pulling the board and the pad into the gutter buys back about a fifth of the
 * width with no extra height.
 *
 * The pull is capped at the theme's ACTUAL gutter, so it can never push the page
 * sideways -- a hard 100vw bleed would add the scrollbar width to the document on
 * a narrow desktop window. Two variable names are tried because the gutter is
 * named differently by theme family: the block themes (Twenty Twenty-Five here)
 * expose `--wp--style--root--padding-*`, classic themes like Kadence use
 * `--global-content-edge-padding`. When a theme names neither, the fallback is
 * ZERO, not a guess: pulling a gutter the theme does not have is the one way this
 * rule could overflow the page, and losing the pull simply keeps the old width.
 */
@media (max-width: 480px) {
	/*
	 * stretch + width:auto, not the base rule's `width:100%; justify-self:center`:
	 * a centred grid item is sized to its content, so negative margins would only
	 * slide the board sideways instead of widening it (measured: the pad, which
	 * stretches, picked up the whole 48px and the board picked up none).
	 *
	 * The third term of the min() is the self-limiter: (100vw - 100%) / 2 is the
	 * real space between the content column and the viewport edge, so the borrow
	 * can never exceed it. On an honest theme it is >= the gutter and the first
	 * two terms decide; on a theme that claims a gutter it does not have, it
	 * shrinks the borrow to the space that is actually there (often 0) instead of
	 * pushing the board past the screen edge. That is why no clipping (and no
	 * page-level overflow guard) is needed here at all -- an earlier version put
	 * `overflow-x: clip` on .sds as a seatbelt and it cut 24px off each side of
	 * the very board the borrow had just widened; that is exactly the "the board
	 * runs off the screen" report that came back from a real phone.
	 */
	.sds-boardwrap {
		justify-self: stretch;
		width: auto;
		margin-left: calc(-1 * min(24px, var(--wp--style--root--padding-left, var(--global-content-edge-padding, 0px)), (100vw - 100%) / 2));
		margin-right: calc(-1 * min(24px, var(--wp--style--root--padding-right, var(--global-content-edge-padding, 0px)), (100vw - 100%) / 2));
	}
	.sds-pad {
		margin-left: calc(-1 * min(24px, var(--wp--style--root--padding-left, var(--global-content-edge-padding, 0px)), (100vw - 100%) / 2));
		margin-right: calc(-1 * min(24px, var(--wp--style--root--padding-right, var(--global-content-edge-padding, 0px)), (100vw - 100%) / 2));
		padding-left: 4px;
		padding-right: 4px;
		gap: 4px;
	}
	.sds-btn,
	.sds-tool { min-height: 44px; }
	/* A shipped 0.1.38 sheet put `overflow-x: clip` here. Cache/merge layers can
	 * keep serving that copy after the rule is deleted, and a clip at the content
	 * column is what cut the borrowed 24px off each side of the board. An explicit
	 * visible wins the cascade even against a stale merged bundle. */
	.sds { overflow-x: visible; }
	/* 44px is the smallest comfortable thumb target; 40 was measurably short. */
	.sds-tab { min-height: 44px; }
}

/* ------------------------------------------------------- printable pack */
/* [sudoku-printable]: a sheet of grids plus an answer key. On screen it is a
   readable preview; on paper the browser chrome, buttons and page furniture
   disappear and one puzzle per page is kept whole. */

/* The pack borrows .sds for its palette and its type, but it is not the game:
   it has no side column. Inheriting the two-column game grid put the whole
   puzzle stack in the 240px side track and the answer key in the other one,
   which is what made this page read as a jumble. */
.sds-printable {
	max-width: 900px;
	display: block;
}

.sds-print-head { margin-bottom: 18px; }
.sds-print-title { margin: 0 0 4px; font-size: 24px; letter-spacing: -.3px; }
.sds-print-sub { margin: 0 0 12px; color: var(--sds-muted); font-size: 14px; }
/* The rule line: quiet on screen, but it must survive the printer, because the
   sheet is often handed to someone who was not told how the puzzle works. */
.sds-print-rule { margin: 0 0 14px; color: var(--sds-ink); font-size: 13px; font-weight: 600; }
.sds-print-actions { margin: 0; }

/* ---------------------------------------------------- printable picker */
/* Level / how many / answer key. Kept to one row where it fits, wrapping on
   phones. Fully hidden on paper - it is a control, not part of the sheet. */

.sds-print-form {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 14px 18px;
	padding: 14px 16px;
	margin: 0 0 6px;
	background: var(--sds-card);
	border-radius: var(--sds-radius);
	box-shadow: 0 1px 2px rgba(20, 30, 60, .06);
}

.sds-print-field {
	display: grid;
	gap: 5px;
	font-size: 12px;
	font-weight: 600;
	color: var(--sds-muted);
}

.sds-print-field select {
	appearance: none;
	font-weight: 500;
	font-size: 15px;
	line-height: 1;
	color: var(--sds-ink);
	background: var(--sds-key);
	border: 1.5px solid var(--sds-line);
	border-radius: 10px;
	padding: 10px 32px 10px 12px;
	min-width: 9rem;
	cursor: pointer;
	/* A small caret, drawn with gradients so there is no external asset. */
	background-image: linear-gradient(45deg, transparent 50%, var(--sds-muted) 50%),
		linear-gradient(135deg, var(--sds-muted) 50%, transparent 50%);
	background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
	background-size: 5px 5px, 5px 5px;
	background-repeat: no-repeat;
}

.sds-print-field select:focus-visible {
	outline: none;
	border-color: var(--sds-accent);
	box-shadow: 0 0 0 3px var(--sds-accent-soft);
}

.sds-print-check {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 13.5px;
	font-weight: 500;
	color: var(--sds-ink);
	cursor: pointer;
	padding-bottom: 10px;
}

.sds-print-check input { width: 17px; height: 17px; accent-color: var(--sds-accent); cursor: pointer; }

.sds-print-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }

.sds-print-status {
	margin: 6px 0 0;
	min-height: 18px;
	font-size: 12.5px;
	color: var(--sds-muted);
}

/* One puzzle: heading + a board that keeps its 9x9 shape. */
.sds-sheet {
	margin: 0 0 26px;
	padding: 14px;
	background: var(--sds-card);
	border-radius: var(--sds-radius);
	box-shadow: 0 1px 2px rgba(20, 30, 60, .06);
}

.sds-sheet-title {
	margin: 0 0 10px;
	font-size: 15px;
	font-weight: 600;
	color: var(--sds-ink);
}

.sds-sheet .sds-board,
.sds-answer .sds-board {
	max-width: 460px;
	margin: 0 auto;
}

/* Answer keys: a plain grid, no interaction affordances. */
.sds-answers { margin-top: 34px; }
.sds-answers-head {
	font-size: 18px;
	margin: 0 0 14px;
	padding-top: 14px;
	border-top: 1px solid var(--sds-line);
}
.sds-answer { margin: 0 0 18px; }
.sds-answer-title { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--sds-muted); }
.sds-answer .sds-cell { cursor: default; }
/* Digits an answer key supplies (rather than the puzzle) are set apart. */
.sds-cell.sds-fixed { color: var(--sds-ink); font-weight: 600; }

/* Screen preview. A pack is a sheet, not the game: puzzles and answer keys
   wrap into as many columns as fit, so six puzzles read as one screen instead
   of a 5000px scroll. Scoped to screen so paper cannot be affected at all -
   the print block below still puts exactly one puzzle on each page. */
@media screen {
	.sds-sheets {
		display: grid;
		/* 340px is the width a sheet wants; min(340px, 100%) keeps that wish on a
		   desktop and lets it give way on a phone, where 340px does not fit inside
		   the theme's content column and used to push the page sideways. */
		grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr));
		gap: 18px;
		align-items: start;
	}
	.sds-sheet { margin: 0; }

	/* The sections sit inside the list wrapper the renderer emits, so the grid
	   belongs on that element - putting it on .sds-answers would make the whole
	   list a single 207px column with the h2 alongside it. */
	[data-sds-answer-list] {
		display: grid;
		grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
		gap: 16px 18px;
	}
	.sds-answer { margin: 0; }
	/* Four answer keys abreast means ~23px cells, so the digits scale down with
	   them - the 27px board type would spill out of the cell. */
	.sds-answer .sds-cell { font-size: clamp(11px, 1.6vw, 15px); }
}

@media print {
	/* The pack is the whole document: nothing else should reach paper. The
	   picker is a control, so it never prints. */
	.sds-print-actions, .sds-print-sub, .sds-print-form, .sds-print-status { display: none !important; }
	.sds-print-title { font-size: 15pt; margin-bottom: 8pt; }
	/* The rule line stays on paper (it is the one control-free sentence a reader
	   without the site needs), but the picker's own copy is dropped above. */
	.sds-print-rule { font-size: 9pt; font-weight: 600; margin: 0 0 10pt; }

	.sds-printable { max-width: none; }

	/* One puzzle per page, never split down the middle. Sizing in cm keeps the
		east-west pair square on both A4 and Letter. */
	.sds-sheet {
		background: transparent;
		border-radius: 0;
		box-shadow: none;
		padding: 0;
		margin: 0;
		page-break-after: always;
		page-break-inside: avoid;
		break-inside: avoid;
	}
	.sds-sheet-title { margin: 0 0 6pt; font-size: 11pt; }
	.sds-sheet .sds-board,
	.sds-answer .sds-board {
		width: 13cm;
		height: 13cm;
		max-width: none;
		margin: 0 auto;
		border: 2px solid #000;
		box-shadow: none;
	}
	.sds-cell { color: #000; border-color: #999; }
	.sds-cell.sds-br, .sds-cell.sds-bb { border-color: #000; }
	.sds-cell.sds-peer, .sds-cell.sds-same, .sds-cell.sds-sel {
		background: #fff !important;
		box-shadow: none !important;
	}

	/* The answer key starts on its own page and then packs two per sheet. */
	.sds-answers { margin-top: 0; page-break-before: always; break-before: page; }
	.sds-answers-head { font-size: 13pt; margin-bottom: 8pt; }
	.sds-answer {
		page-break-inside: avoid;
		break-inside: avoid;
		margin: 0 0 6pt;
	}
	.sds-answer .sds-board { width: 8cm; height: 8cm; }
	.sds-answer-title { font-size: 9pt; margin-bottom: 3pt; }
	.sds-title { font-size: 16pt; }
}



@media print {
	.sds { display: block; max-width: 100%; margin: 0; }
	.sds-tabs, .sds-tools, .sds-pad, .sds-meta, .sds-overlay, .sds-toast, .sds-info { display: none !important; }
	.sds-boardwrap { max-width: none; }
	.sds-board {
		border: 2px solid #000;
		box-shadow: none;
		width: 15cm;
		height: 15cm;
		page-break-inside: avoid;
	}
	.sds-cell { color: #000; border-color: #999; }
	.sds-cell.sds-br, .sds-cell.sds-bb { border-color: #000; }
	.sds-cell.sds-peer, .sds-cell.sds-same, .sds-cell.sds-sel { background: #fff !important; box-shadow: none !important; }
	.sds-title { font-size: 16pt; }
}

/* ==========================================================================
   4x4 mini boards (the kids page)
   ==========================================================================
   Sized for a child: big touch targets, only sixteen squares, and the 2x2 boxes
   marked with the thick lines the rule depends on. Shares the colour tokens
   above and nothing else -- there is no engine behind this board.
   ========================================================================== */

.sds-minis-lead {
	margin: 0 0 14px;
	color: var(--sds-ink);
	font-size: 15px;
	font-weight: 600;
}

/*
 * CRITICAL: kill the shared two-column grid.
 *
 * `.sds` is `display: grid` with `grid-template-columns: minmax(0,1fr) 240px` and
 * named areas (head/tabs/board/hint/tools/pad/info) for the 9x9 game. None of the
 * mini markup claims a grid area, so it was auto-placed into that 240px sidebar:
 * boards ended up in a narrow right-hand column ("Mini sudoku (4x4)" stranded on
 * the left) and the layout overflowed a 390px phone viewport, cutting off text.
 * This component is a normal block flow, so it says so explicitly.
 */
.sds-minis {
	display: block;
	grid-template-columns: none;
	grid-template-areas: none;
	max-width: 940px;
}
.sds-minis > * { grid-area: auto; }

.sds-mini-level {
	margin: 0 0 26px;
	padding: 16px 18px 6px;
	background: var(--sds-card);
	border-radius: var(--sds-radius);
	box-shadow: 0 1px 2px rgba(20, 30, 60, .06);
}

.sds-mini-heading {
	margin: 0 0 4px;
	font-size: 17px;
	color: var(--sds-ink);
}

.sds-mini-hint {
	margin: 0 0 14px;
	font-size: 13.5px;
	color: var(--sds-muted);
	max-width: 62ch;
}

.sds-mini-row {
	display: flex;
	flex-wrap: wrap;
	gap: 18px 22px;
	align-items: flex-start;
	margin-bottom: 14px;
}

.sds-mini-figure {
	margin: 0;
	display: grid;
	justify-items: center;
	gap: 6px;
}

/* --- the grid --- */
.sds-mini {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	/* A 4x4 a small child can tap: ~13mm squares, near a real pencil-and-paper size. */
	width: 208px;
	max-width: 100%;
	background: var(--sds-card);
	border: 3px solid var(--sds-strong);
	border-radius: 8px;
	overflow: hidden;
	user-select: none;
}

.sds-mini:focus { outline: none; }
.sds-mini:focus-visible { box-shadow: 0 0 0 3px var(--sds-accent-soft); }

.sds-mini-cell {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	aspect-ratio: 1 / 1;
	font-size: 30px;
	font-weight: 500;
	line-height: 1;
	color: var(--sds-accent);
	background: var(--sds-card);
	border-right: 1px solid var(--sds-line);
	border-bottom: 1px solid var(--sds-line);
	cursor: pointer;
	transition: background .12s ease;
}

/* The 2x2 boxes are the rule the child has to hold in mind, so mark them clearly. */
.sds-mini-cell.sds-mini-br { border-right: 3px solid var(--sds-strong); }
.sds-mini-cell.sds-mini-bb { border-bottom: 3px solid var(--sds-strong); }
.sds-mini-cell:nth-child(4n) { border-right: 0; }
.sds-mini-cell:nth-child(n+13) { border-bottom: 0; }

.sds-mini-cell.sds-mini-given { color: var(--sds-ink); font-weight: 700; }
.sds-mini-cell.sds-mini-mine { color: var(--sds-accent); font-weight: 600; }
.sds-mini-cell.sds-mini-sel {
	background: var(--sds-accent-soft);
	box-shadow: inset 0 0 0 3px var(--sds-accent);
}
.sds-mini-cell.sds-mini-bad {
	background: var(--sds-err-soft);
	color: var(--sds-err);
	animation: sds-mini-shake .3s ease-in-out;
}

@keyframes sds-mini-shake {
	0%, 100% { transform: translateX(0); }
	25% { transform: translateX(-3px); }
	75% { transform: translateX(3px); }
}

/* --- faint candidate marks in empty squares --- */
.sds-mini-cands {
	position: absolute;
	inset: 3px;
	display: grid;
	grid-template-columns: 1fr 1fr;
	grid-template-rows: 1fr 1fr;
	font-size: 9px;
	font-weight: 600;
	color: var(--sds-muted);
	pointer-events: none;
}
.sds-mini-cand { display: flex; align-items: center; justify-content: center; font-style: normal; }

/* --- per-board caption and answer --- */
.sds-mini-cap {
	font-size: 12px;
	font-variant-numeric: tabular-nums;
	color: var(--sds-muted);
	min-height: 16px;
}

.sds-mini-answer { font-size: 12px; color: var(--sds-muted); }
/*
 * "Show the answer" is a control, not a caption: at 96x17 it was the smallest
 * tap target on the page (below the 24px minimum). Keep the disclosure marker,
 * give it room.
 */
.sds-mini-answer summary {
	cursor: pointer;
	color: var(--sds-accent);
	min-height: 44px;
	padding: 12px 0;
	font-size: 13.5px;
}
.sds-mini-answer-grid {
	margin: 6px 0 0;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	letter-spacing: .16em;
}

/*
 * The number pad: ONE pad for the whole component, stuck to the bottom of the
 * viewport.
 *
 * It used to be one pad per level, sitting after that level's four boards. On a
 * phone that put it a screen or more below the board a child had just tapped, so
 * they had to scroll to reach it -- exactly the wrong interaction for a
 * six-year-old. A single sticky pad is always under the thumb, wherever on the
 * page the child is.
 */
.sds-mini-pad {
	position: sticky;
	bottom: 0;
	z-index: 20;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 10px;
	margin: 0;
	padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
	background: var(--sds-card);
	border-top: 1px solid var(--sds-line);
	box-shadow: 0 -6px 18px rgba(20, 30, 60, .10);
}
.sds-mini-pad[hidden] { display: none; }

.sds-mini-pad-label {
	font-size: 13px;
	font-weight: 600;
	color: var(--sds-muted);
	margin-right: 4px;
}

.sds-mini-key {
	min-width: 58px;
	min-height: 58px;
	font-size: 24px;
	font-weight: 600;
	color: var(--sds-ink);
	background: var(--sds-key);
	border: 1.5px solid var(--sds-line);
	border-radius: 12px;
	cursor: pointer;
	transition: background .12s ease, border-color .12s ease;
}
.sds-mini-key:hover { background: var(--sds-key-hover); border-color: var(--sds-accent); }
.sds-mini-key:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--sds-accent-soft); }
.sds-mini-key-clear { font-size: 14px; min-width: 72px; color: var(--sds-muted); }

.sds-mini-status {
	margin: 0;
	min-height: 20px;
	font-size: 14px;
	font-weight: 500;
	color: var(--sds-muted);
}

/* --- "Show me different ones" --- */
.sds-mini-swap { margin: 4px 0 0; }

.sds-mini-swap-btn {
	width: 100%;
	min-height: 52px;          /* a comfortable target for a child */
	font-size: 16px;
	font-weight: 600;
	color: var(--sds-accent);
	background: var(--sds-accent-soft);
	border: 1.5px solid transparent;
	border-radius: 12px;
	cursor: pointer;
	transition: background .12s ease, border-color .12s ease;
}
.sds-mini-swap-btn:hover { border-color: var(--sds-accent); }
.sds-mini-swap-btn:focus-visible { outline: none; border-color: var(--sds-accent); box-shadow: 0 0 0 3px var(--sds-accent-soft); }
.sds-mini-swap-btn:active { background: var(--sds-key-hover); }

/* Phones: ONE board per row, as wide as the space allows.
 *
 * Two attempts got the arithmetic wrong before this:
 *   - `42vw` per board: vw ignores the container padding, so two boards plus the
 *     gap needed 0.84 x viewport + 14px while the content box was only about
 *     318px on a 390px phone. The page scrolled sideways.
 *   - two equal tracks: still clipped in practice.
 * One board per row removes the arithmetic entirely and is better for the actual
 * user -- a 4x4 gets roughly 300px, so each square is ~75px, which is a far easier
 * tap for a small child than a 150px board with 37px squares. */
@media (max-width: 640px) {
	.sds-minis { overflow-wrap: anywhere; }   /* no long word may widen the page */
	.sds-mini-row {
		display: grid;
		grid-template-columns: minmax(0, 1fr);
		justify-items: center;
		gap: 18px;
	}
	.sds-mini-figure { width: 100%; }
	.sds-mini {
		width: 100%;
		max-width: 340px;      /* a child's board does not need to be huge */
		margin: 0 auto;
	}
	.sds-mini-cell { font-size: 34px; }
	.sds-mini-level { padding: 14px 12px 4px; }
	.sds-mini-key { min-width: 54px; min-height: 54px; font-size: 22px; }
	.sds-mini-pad-label { display: none; }   /* the buttons say it well enough */
}

@media print {
	.sds-mini-level { break-inside: avoid; box-shadow: none; padding: 0; }
	/*
	 * A hidden pool board must not appear on the sheet either, so the sheet shows
	 * what the child was actually working on. No rule is needed here: the global
	 * `[hidden] { display: none !important }` at the top of this file covers every
	 * medium. The rule that used to sit here -- and ONLY here -- is what made the
	 * boards visible but dead on screen; see that rule's comment.
	 */
	.sds-mini { width: 5cm; border-color: #000; }
	.sds-mini-cell { color: #000; }
	.sds-mini-cell.sds-mini-br, .sds-mini-cell.sds-mini-bb { border-color: #000; }
	.sds-mini-cell { border-color: #999; }
	.sds-mini-cell.sds-mini-sel { background: #fff !important; box-shadow: none !important; }
	.sds-mini-cands, .sds-mini-pad, .sds-mini-status, .sds-mini-cap,
	.sds-mini-swap { display: none !important; }
	.sds-mini-answer { display: none !important; }
}

/* =====================================================================
 * Polish layer (2026-10-16)
 *
 * Same markup, same class names -- this section only decides how the game
 * *looks* and *feels*. It sits at the end of the file on purpose: equal
 * specificity means the later rule wins, so nothing above has to be edited
 * to change a value here, and the original layout rules stay readable.
 *
 * Two rules of the road:
 *   1. Sizes that the 859px block above already tunes are re-tuned inside a
 *      matching @media here -- never with a bare rule that would silently
 *      override the phone layout at every width.
 *   2. States come after hover, so `:hover` cannot repaint a selected or
 *      peer cell out of its meaning.
 * ===================================================================== */

.sds {
	--sds-ink: #151b2b;
	--sds-muted: #6f7891;
	--sds-line: #e4e9f2;
	--sds-cell-line: #e9edf5;
	--sds-strong: #202737;
	--sds-amber: #d98421;
	--sds-amber-soft: #fdf3e6;
	--sds-radius: 16px;
	--sds-shadow-sm: 0 1px 2px rgba(21, 27, 43, .06);
	--sds-shadow-md: 0 8px 24px rgba(21, 27, 43, .07);
	--sds-shadow-key: 0 4px 14px rgba(47, 111, 237, .28);
}

/* --- the board is the hero ------------------------------------------ */

.sds-board {
	border-radius: var(--sds-radius);
	box-shadow: 0 1px 1px rgba(21, 27, 43, .04), 0 12px 28px rgba(21, 27, 43, .10);
	transition: box-shadow .3s ease;
}

/* A solved board keeps a green halo for the rest of the visit. */
.sds-board.sds-won {
	box-shadow: 0 0 0 3px rgba(30, 158, 106, .28), 0 12px 28px rgba(21, 27, 43, .10);
}

.sds-cell {
	border-right-color: var(--sds-cell-line);
	border-bottom-color: var(--sds-cell-line);
	font-weight: 600;
	transition: background .1s ease, color .1s ease;
}

.sds-cell.sds-given { color: var(--sds-ink); font-weight: 700; }

/* Only a device with a real pointer gets a hover wash. */
@media (hover: hover) {
	.sds-cell:hover { background: var(--sds-key-hover); }
}

.sds-cell.sds-peer { background: var(--sds-peer); }
.sds-cell.sds-same { background: var(--sds-same); font-weight: 800; }
.sds-cell.sds-sel { background: var(--sds-accent-soft); box-shadow: inset 0 0 0 2px var(--sds-accent); }
.sds-cell.sds-bad { color: var(--sds-err); background: var(--sds-err-soft); }
.sds-cell.sds-bad.sds-sel { box-shadow: inset 0 0 0 2px var(--sds-err); }
.sds-cell.sds-hinted { color: var(--sds-ok); }

.sds-cell.sds-ok { animation: sds-okflash .55s ease-out; }

@keyframes sds-okflash {
	0%   { background: rgba(30, 158, 106, .22); }
	100% { background: transparent; }
}

@media (min-width: 860px) {
	.sds-cell { font-size: clamp(22px, 2.6vw, 30px); }
	.sds-notes { font-size: clamp(8.5px, .95vw, 11px); }
}

@media (max-width: 859px) {
	.sds-notes { font-size: clamp(8.5px, 2.3vw, 11.5px); }
}

/* The digit you are working on, echoed inside everybody's pencil marks. */
.sds-notes i.sds-nsel { color: var(--sds-accent); font-weight: 800; }

/* --- number pad: a controller, not a list of links ------------------- */

.sds-key {
	background: var(--sds-card);
	border: 1.5px solid var(--sds-line);
	border-radius: 14px;
	font-weight: 700;
	box-shadow: var(--sds-shadow-sm);
}

.sds-key:hover { border-color: var(--sds-accent); background: var(--sds-accent-soft); }
.sds-key i { font-weight: 600; }

/* A digit with all nine placed is finished, not disabled: it goes quiet and
   its counter turns into a tick (game.js swaps the glyph). */
.sds-key.sds-done {
	opacity: 1;
	background: var(--sds-key);
	border-color: transparent;
	color: var(--sds-muted);
	box-shadow: none;
}

.sds-key.sds-done i { color: var(--sds-ok); font-weight: 700; }
.sds-key.sds-done:hover { background: var(--sds-key); border-color: transparent; }

.sds-key.sds-key-pop { animation: sds-keydone .6s ease-out; }

@keyframes sds-keydone {
	0%   { transform: scale(1); box-shadow: 0 0 0 0 rgba(30, 158, 106, .45); }
	35%  { transform: scale(1.08); }
	100% { transform: scale(1); box-shadow: 0 0 0 14px rgba(30, 158, 106, 0); }
}

/* --- tools ---------------------------------------------------------- */

.sds-tool {
	border: 1.5px solid var(--sds-line);
	border-radius: 14px;
	box-shadow: var(--sds-shadow-sm);
}

.sds-tool:hover { border-color: var(--sds-accent); background: var(--sds-accent-soft); color: var(--sds-accent); }
.sds-tool.sds-on {
	border-color: transparent;
	background: var(--sds-accent);
	color: #fff;
	box-shadow: var(--sds-shadow-key);
}
.sds-tool.sds-on:hover { color: #fff; }

/* --- head: stats read as chips, plus the progress bar --------------- */

.sds-meta { align-items: center; }
.sds-meta > span {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	background: var(--sds-card);
	border-radius: 999px;
	padding: 5px 12px;
	font-weight: 600;
	color: var(--sds-ink);
	box-shadow: var(--sds-shadow-sm);
}
.sds-meta > span.sds-danger { background: var(--sds-err-soft); color: var(--sds-err); }
.sds-meta > span.sds-danger b { color: var(--sds-err); }

.sds-progress > i {
	display: block;
	position: relative;
	width: 84px;
	height: 7px;
	border-radius: 999px;
	background: var(--sds-line);
	overflow: hidden;
}

.sds-progress > i::after {
	content: '';
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	width: var(--sds-pct, 0%);
	border-radius: 999px;
	background: linear-gradient(90deg, var(--sds-accent), #61a0ff);
	transition: width .3s ease;
}

/* --- buttons -------------------------------------------------------- */

.sds-btn {
	background: linear-gradient(180deg, #4180f2, var(--sds-accent));
	border: 0;
	border-radius: 12px;
	padding: 11px 18px;
	font-weight: 700;
	font-size: 14px;
	line-height: 1;
	color: #fff;
	cursor: pointer;
	box-shadow: var(--sds-shadow-key);
	transition: transform .08s ease, box-shadow .15s ease, filter .15s ease;
}

.sds-btn:hover { filter: brightness(1.06); box-shadow: 0 6px 18px rgba(47, 111, 237, .34); }
.sds-btn:active { transform: translateY(1px); }

.sds-btn.sds-ghost {
	background: var(--sds-card);
	color: var(--sds-ink);
	border: 1.5px solid var(--sds-line);
	box-shadow: var(--sds-shadow-sm);
}
.sds-btn.sds-ghost:hover { border-color: var(--sds-accent); color: var(--sds-accent); filter: none; }

/* --- end-of-game panel ---------------------------------------------- */

.sds-overlay {
	border-radius: var(--sds-radius);
	background: rgba(255, 255, 255, .93);
	backdrop-filter: blur(6px) saturate(1.15);
	padding: 24px 20px;
	gap: 11px;
	overflow: hidden;
}

.sds-overlay h4 { font-size: clamp(22px, 3vw, 28px); letter-spacing: -.4px; }
.sds-overlay:not(.sds-lose) h4 { color: var(--sds-ok); }
.sds-overlay p { font-size: 13.5px; }

.sds-stats { gap: 10px; }
.sds-stats > div {
	background: var(--sds-card);
	border: 1.5px solid var(--sds-line);
	border-radius: 14px;
	padding: 8px 14px 7px;
	min-width: 76px;
	font-size: 10.5px;
	font-weight: 700;
	letter-spacing: .07em;
	text-transform: uppercase;
	color: var(--sds-muted);
}
.sds-stats b { font-size: 22px; font-weight: 800; margin-bottom: 1px; }

/* "New best time" and the record line are rewards: they must look like one.
 * `.sds-overlay p` sets the muted grey and outranks a bare class, so this is
 * written as a two-class selector on purpose -- the pill is green with white
 * text, not grey text on a green blob. */
.sds-overlay p.sds-record {
	background: linear-gradient(180deg, #23b477, var(--sds-ok));
	color: #fff;
	font-size: 13px;
	font-weight: 700;
	line-height: 1;
	border-radius: 999px;
	padding: 7px 15px;
	box-shadow: 0 4px 14px rgba(30, 158, 106, .3);
	animation: sds-badge .5s ease-out;
}

@keyframes sds-badge {
	0%   { transform: scale(.7); opacity: 0; }
	60%  { transform: scale(1.06); }
	100% { transform: scale(1); opacity: 1; }
}

.sds-records { display: flex; gap: 18px; font-size: 11px; color: var(--sds-muted); }
.sds-records b {
	display: block;
	font-size: 17px;
	font-weight: 700;
	color: var(--sds-ink);
	font-variant-numeric: tabular-nums;
}

.sds-confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.sds-confetti i {
	position: absolute;
	top: -18px;
	width: 8px;
	height: 13px;
	border-radius: 2px;
	animation: sds-fall 1.7s cubic-bezier(.25, .6, .35, 1) forwards;
}

@keyframes sds-fall {
	0%   { transform: translate3d(0, -18px, 0) rotate(0deg); opacity: 0; }
	12%  { opacity: 1; }
	100% { transform: translate3d(var(--sds-dx, 0px), var(--sds-dy, 460px), 0) rotate(var(--sds-rot, 540deg)); opacity: .85; }
}

/* Motion is decoration here; when it is unwelcome, it is simply gone. */
@media (prefers-reduced-motion: reduce) {
	.sds-cell, .sds-key, .sds-tool, .sds-btn,
	.sds-progress > i::after, .sds-board { transition: none !important; }
	.sds-cell.sds-pop, .sds-cell.sds-shake, .sds-cell.sds-ok,
	.sds-key.sds-key-pop, .sds-record { animation: none !important; }
	.sds-confetti { display: none !important; }
}

/*
 * The finishing card is taller than the board once it carries the record line,
 * the achievement row and the debrief, and the overlay clips to its own box --
 * that clip is what keeps confetti inside the card. On a phone the box is a
 * 440px square, so `justify-content: center` pushed the card out of BOTH ends
 * of that box and the clip then cut "Solved!" off the top and "Next puzzle" off
 * the bottom (measured at 500px, 0.1.31 work). Under 860px the card stops being
 * an overlay: it flows under the board, the finished grid stays visible with
 * the confetti falling across the top of it, and nothing is cut off. The
 * confetti keeps its own overflow clip, which is why it can stay visible here.
 */
@media (max-width: 859px) {
	.sds-overlay { position: static; overflow: visible; }
}

/* =====================================================================
 * Dark mode (2026-10-16)
 *
 * Two layers, because a game page is more than the game:
 *
 *   1. The theme's palette. Twenty Twenty-Five paints the page from
 *      --wp--preset--color--* and reuses those same variables in every
 *      block utility class, so redefining them flips the page background,
 *      the body text, the header, the footer and the tables without
 *      touching a single theme file. They are set on BOTH html and body on
 *      purpose: if the theme defines them on :root (specificity 0-1-0, so
 *      it would beat a bare `body` selector), defining them on body still
 *      wins for body and everything inside it; if the theme defines them
 *      on body, an equal-specificity later rule wins there instead.
 *   2. The game's own tokens. The polish layer above redefines them last,
 *      so this block has to sit after it. No rule changes here, only
 *      values -- every rule above keeps reading the same variables.
 *
 * `screen and` is not decoration: prefers-color-scheme is evaluated while
 * printing too, and the printable sheets force white paper inside their own
 * @media print block. Printing this site must never come out dark.
 *
 * This follows the device and is not a switch the visitor can flip. A manual
 * toggle would need a button, a stored choice and a class on the root
 * element -- a bigger change than this pass.
 * ===================================================================== */

@media screen and (prefers-color-scheme: dark) {
	/*
	 * Two palettes are repainted on purpose, because a theme names its colours
	 * either way: the block themes (Twenty Twenty-Five) use the WordPress preset
	 * variables, classic themes like Kadence use `--global-palette1..9` plus
	 * `--global-palette9rgb` for their translucent layers. Overriding only one
	 * family means the dark page silently stays light after a theme switch -- no
	 * error, just a white page at night.
	 */
	:root,
	body {
		/* Twenty Twenty-Five / any theme driven by theme.json presets. */
		--wp--preset--color--base: #0e1424;
		--wp--preset--color--base-2: #161d2f;
		--wp--preset--color--contrast: #e9edf8;
		--wp--preset--color--contrast-2: #b7c0d4;
		--wp--preset--color--contrast-3: #8b95ad;

		/* Kadence (free + Pro): palette9 is the page sheet, 8/7 the light
		 * fills, 3/4 the headings and body text, 1/2 the accent. */
		--global-palette1: #5b93ff;
		--global-palette2: #7fb0ff;
		--global-palette3: #e9edf8;
		--global-palette4: #e9edf8;
		--global-palette5: #b7c0d4;
		--global-palette6: #9aa4bd;
		--global-palette7: #242e46;
		--global-palette8: #161d2f;
		--global-palette9: #0e1424;
		/* Kadence composes its translucent bars as rgba(var(--global-palette9rgb), x). */
		--global-palette9rgb: 14, 20, 36;
		/*
		 * Kadence defines --global-palette-btn as var(--global-palette9), so
		 * remapping palette9 to ink-dark would print DARK labels on the blue
		 * buttons. Pin the label, leave the rest of that chain alone.
		 */
		--global-palette-btn: #ffffff;
		--global-palette-btn-hover: #ffffff;
	}

	/*
	 * Chrome painted from a hardcoded literal rather than from a palette variable.
	 * Kadence ships `#masthead{background:#ffffff}` in its own inline customizer CSS,
	 * so a correctly dark page still kept a WHITE header while the header text
	 * inherited our light ink -- measured on the live site as #ffffff behind
	 * rgb(233,237,248), i.e. the navigation was invisible at night.
	 *
	 * `!important` is deliberate and used only here: the theme's sticky-header rule
	 * carries four :not() clauses, so nothing short of copying it verbatim could
	 * out-specify it, and the failure mode is invisible text rather than a slightly
	 * wrong shade. The dropdown panel gets the same treatment because a white
	 * sub-menu on a dark page has light links on it.
	 */
	#masthead,
	#masthead .site-header-row-container-inner,
	.site-header-row-container-inner,
	.header-navigation ul ul.sub-menu,
	.header-navigation ul ul.submenu {
		background-color: #0e1424 !important;
	}

	/*
	 * Literal colours, not variables: whatever the theme calls its sheet, a dark
	 * page is dark. The variable overrides above still cover the blocks, tables
	 * and prose that compose their own colours from the theme palette.
	 */
	body {
		background-color: #0e1424;
		color: #e9edf8;
	}

	/* Same twelve meanings, repainted for a dark page. */
	.sds {
		--sds-bg: #0e1424;
		--sds-card: #161d2f;
		--sds-ink: #e9edf8;
		--sds-muted: #9aa4bd;
		--sds-line: #2a3450;
		--sds-cell-line: #242e46;
		--sds-strong: #f4f7ff;
		--sds-accent: #5b93ff;
		--sds-accent-soft: #1e2b4d;
		--sds-peer: #1a2236;
		--sds-same: #24325a;
		--sds-err: #ff6f63;
		--sds-err-soft: #3b2126;
		--sds-ok: #37c68f;
		--sds-key: #1a2133;
		--sds-key-hover: #24304a;
		--sds-amber: #e8a350;
		--sds-amber-soft: #3a2c1c;
		--sds-shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
		--sds-shadow-md: 0 10px 28px rgba(0, 0, 0, .55);
		--sds-shadow-key: 0 4px 14px rgba(0, 0, 0, .45);
	}

	/* The finishing card is frosted glass: keep the frost, change the sheet. */
	.sds-overlay { background: rgba(14, 20, 36, .94); }

	/* Shadows have to carry the card on a dark page, where a faint one just
	 * vanishes. Same shapes, deeper ink. */
	.sds-board { box-shadow: 0 1px 1px rgba(0, 0, 0, .45), 0 14px 30px rgba(0, 0, 0, .55); }
	.sds-key, .sds-tool, .sds-btn.sds-ghost { box-shadow: 0 1px 2px rgba(0, 0, 0, .45); }

	/* Inputs inherit a white background from the browser, not from the page. */
	.sds input, .sds select, .sds textarea { background-color: var(--sds-key); color: var(--sds-ink); }

	/* A focused field must not fall back to that white either. */
	.sds-input:focus { background: var(--sds-key); }

	/* The pad keys sit on a card of the same colour; lift them one step so a key is a key. */
	.sds-key { background: var(--sds-key); }

	/* The toast paints itself in --sds-strong and hard-codes `color: #fff`. On a dark page
	 * --sds-strong is light ink, so white-on-light would be invisible: flip the pill instead
	 * of the ink. */
	.sds-toast { background: #e9edf8; color: #0e1424; }
}


/* ------------------------------------------------------------------ calendar */

/*
 * The daily check-in calendar under the board.
 *
 * It follows the same twelve colour meanings as the board (.sds) so a theme
 * swap or a dark page repaints it the same way: the tokens are declared here
 * again because this section is a sibling of .sds, not a child of it.
 *
 * Three states and nothing else: played (done), played without mistakes
 * (clean, the filled square), and missed (a day that has passed with no
 * record). Today is an outline, never a colour, so it cannot be confused with
 * a result.
 */
.sds-cal {
	--sds-bg: #f5f7fb;
	--sds-card: #ffffff;
	--sds-ink: #1e2433;
	--sds-muted: #8b93a7;
	--sds-line: #e4e8f0;
	--sds-strong: #2b3242;
	--sds-accent: #2f6fed;
	--sds-accent-soft: #e9f0fe;
	--sds-ok: #1e9e6a;
	--sds-key: #f2f5fa;
	--sds-key-hover: #e7eefb;
	--sds-radius: 14px;

	box-sizing: border-box;
	max-width: 29rem;
	margin: 1.25rem auto 1.5rem;
	padding: 16px 18px 14px;
	background: var(--sds-card);
	border: 1px solid var(--sds-line);
	border-radius: var(--sds-radius);
	color: var(--sds-ink);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.45;
}

.sds-cal *,
.sds-cal *::before,
.sds-cal *::after { box-sizing: border-box; }

.sds-cal-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 8px 16px;
	flex-wrap: wrap;
}

.sds-cal-title { margin: 0; font-size: 17px; line-height: 1.3; }

.sds-cal-sum {
	margin: 0;
	display: flex;
	gap: 14px;
	flex-wrap: wrap;
	color: var(--sds-muted);
	font-size: 13px;
}

.sds-cal-sum b { color: var(--sds-ink); font-variant-numeric: tabular-nums; }

.sds-cal-bar { display: flex; align-items: center; gap: 6px; max-width: 26rem; margin: 12px auto 8px; }

.sds-cal-nav {
	flex: none;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 1px solid var(--sds-line);
	border-radius: 10px;
	background: var(--sds-key);
	color: var(--sds-ink);
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
}

.sds-cal-nav:hover { background: var(--sds-key-hover); }
.sds-cal-nav:disabled { opacity: .4; cursor: default; }
.sds-cal-nav:focus-visible { outline: 2px solid var(--sds-accent); outline-offset: 2px; }

.sds-cal-month {
	flex: 1;
	margin: 0;
	text-align: center;
	font-size: 14px;
	font-weight: 600;
}

.sds-cal-grid { max-width: 26rem; margin: 0 auto; }
.sds-cal-num { font-weight: 600; font-size: 13px; line-height: 1; }
.sds-cal-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }

.sds-cal-dow,
.sds-cal-week {
	display: grid;
	grid-template-columns: repeat(7, minmax(0, 1fr));
	gap: 4px;
}

.sds-cal-dow span {
	text-align: center;
	font-size: 11px;
	letter-spacing: .03em;
	text-transform: uppercase;
	color: var(--sds-muted);
	padding-bottom: 2px;
}

.sds-cal-weeks { display: grid; gap: 4px; }

.sds-cal-cell {
	display: flex;
	align-items: center;
	justify-content: center;
	aspect-ratio: 1 / 1;
	border: 1px solid transparent;
	border-radius: 9px;
	background: var(--sds-key);
	color: var(--sds-ink);
	font-size: 13px;
	font-variant-numeric: tabular-nums;
}

.sds-cal-blank { background: transparent; }
.sds-cal-future { opacity: .35; }
.sds-cal-cell[data-state="done"] { background: var(--sds-accent-soft); color: var(--sds-accent); font-weight: 700; }
.sds-cal-cell[data-state="clean"] { background: var(--sds-accent); color: #ffffff; font-weight: 700; }
.sds-cal-cell[data-state="missed"] { background: transparent; color: var(--sds-muted); opacity: .7; }
.sds-cal-today { border-color: var(--sds-accent); }

.sds-cal-legend {
	display: flex;
	gap: 14px;
	flex-wrap: wrap;
	margin: 12px 0 0;
	font-size: 12px;
	color: var(--sds-muted);
}

.sds-cal-legend span { display: inline-flex; align-items: center; }

.sds-cal-dot {
	width: 10px;
	height: 10px;
	border-radius: 3px;
	margin-right: 6px;
	background: var(--sds-key);
	display: inline-block;
}

.sds-cal-dot-done { background: var(--sds-accent-soft); }
.sds-cal-dot-clean { background: var(--sds-accent); }
.sds-cal-dot-missed { background: transparent; border: 1px solid var(--sds-line); }

.sds-cal-note { margin: 6px 0 0; font-size: 12px; color: var(--sds-muted); }

@media (max-width: 480px) {
	.sds-cal { margin: 1rem auto 1.25rem; padding: 14px 12px 12px; font-size: 14px; }
	.sds-cal-title { font-size: 16px; }
	.sds-cal-sum { font-size: 12px; gap: 10px; }
	.sds-cal-cell { font-size: 12px; border-radius: 8px; }
	.sds-cal-dow span { font-size: 10px; }
	.sds-cal-dow, .sds-cal-week { gap: 3px; }
	.sds-cal-weeks { gap: 3px; }
}

@media print {
	.sds-cal { display: none; }
}

/* The same repaint as the board's dark block. Kept next to the calendar so a
 * reader can check it without scrolling 1800 lines. */
@media screen and (prefers-color-scheme: dark) {
	.sds-cal {
		--sds-bg: #0e1424;
		--sds-card: #161d2f;
		--sds-ink: #e9edf8;
		--sds-muted: #9aa4bd;
		--sds-line: #2a3450;
		--sds-strong: #f4f7ff;
		--sds-accent: #5b93ff;
		--sds-accent-soft: #1e2b4d;
		--sds-key: #1a2133;
		--sds-key-hover: #24304a;
	}

	.sds-cal-cell[data-state="clean"] { color: #0e1424; }
}