:root {
  --bg: #ffffff;
  --text: #344861;
  --muted: #6e7c8c;
  --line: #bfc6d4;
  --line-strong: #344861;
  --cell: #ffffff;
  --related: #e2ebf3;
  --same: #c3d7ea;
  --selected: #bbdefb;
  --error-bg: #f7cfd6;
  --given: #344861;
  --user: #325aaf;
  --error: #e55c6c;
  --note: #6e7c8c;
  --btn: #eaeef4;
  --btn-hover: #dce3ed;
  --accent: #325aaf;
  --accent-hover: #2c4f9a;
  --card: #ffffff;
  --shadow: 0 8px 30px rgba(0, 0, 0, .18);
  --overlay: rgba(255, 255, 255, .92);
}
[data-theme="dark"] {
  --bg: #15171c;
  --text: #d7dde6;
  --muted: #8b96a5;
  --line: #3a404b;
  --line-strong: #9aa6b8;
  --cell: #1e2128;
  --related: #262b35;
  --same: #33405a;
  --selected: #3d5581;
  --error-bg: #5a2a33;
  --given: #e8edf5;
  --user: #7fb2ff;
  --error: #ff7585;
  --note: #9aa6b8;
  --btn: #262b35;
  --btn-hover: #303747;
  --accent: #4c7ce0;
  --accent-hover: #3f6bc7;
  --card: #1e2128;
  --shadow: 0 8px 30px rgba(0, 0, 0, .5);
  --overlay: rgba(21, 23, 28, .94);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; touch-action: manipulation; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  max-width: 1100px; margin: 0 auto; padding: 12px 24px;
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 24px; font-weight: 700; color: var(--accent); letter-spacing: .2px; text-decoration: none; }
.difficulty { display: flex; align-items: center; gap: 2px; flex: 1; flex-wrap: wrap; }
.difficulty .label { color: var(--muted); margin-right: 8px; font-size: 15px; }
.difficulty button, .difficulty a {
  background: none; border: 0; padding: 6px 10px; border-radius: 6px; text-decoration: none;
  color: var(--muted); font-size: 15px; cursor: pointer;
}
.difficulty button:hover, .difficulty a:hover { color: var(--accent); }
.difficulty button.active, .difficulty a.active { color: var(--accent); font-weight: 600; background: var(--related); }
.difficulty .variant { margin-left: 10px; padding-left: 12px; border-left: 1px solid var(--line); border-radius: 0; color: var(--accent); }
.top-actions { display: flex; gap: 6px; }
.langs { display: flex; gap: 2px; }
.langs a { padding: 6px 8px; border-radius: 6px; font-size: 13px; font-weight: 600; letter-spacing: .03em; color: var(--muted); text-decoration: none; }
.langs a:hover { color: var(--accent); }
.langs a[aria-current] { color: var(--accent); background: var(--related); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--btn);
  color: var(--accent); display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn.text { font-size: 13px; font-weight: 600; }
.icon-btn:hover { background: var(--btn-hover); }

/* ---------- layout ---------- */
.game {
  max-width: 1100px; margin: 26px auto; padding: 0 24px;
  display: grid; grid-template-columns: minmax(280px, 520px) minmax(240px, 320px);
  gap: 44px; justify-content: center; align-items: start;
}
.status { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; color: var(--muted); font-size: 15px; }
.status b { color: var(--text); font-weight: 600; }
.stat.timer { display: flex; align-items: center; gap: 8px; }
.mini-btn {
  width: 26px; height: 26px; border-radius: 50%; border: 0; background: var(--btn); color: var(--accent);
  display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
}
.mini-btn svg { width: 14px; height: 14px; fill: currentColor; stroke: none; }
.mini-btn:hover { background: var(--btn-hover); }
.puzzle-meta { margin-top: 8px; font-size: 12px; color: var(--muted); text-align: right; min-height: 16px; }

/* ---------- board ---------- */
.board-wrap { position: relative; container-type: inline-size; }
.board {
  display: grid; grid-template-columns: repeat(9, 1fr); grid-template-rows: repeat(9, 1fr);
  aspect-ratio: 1; width: 100%;
  border: 2px solid var(--line-strong); background: var(--cell);
  user-select: none; -webkit-user-select: none; outline: none; touch-action: manipulation;
}
.cell {
  position: relative; display: flex; align-items: center; justify-content: center;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  font-size: clamp(18px, 4.8vmin, 34px); color: var(--user); background: var(--cell); cursor: pointer;
  min-width: 0; min-height: 0;
}
/* digit size follows the board width (container query units); the vmin clamp above is the fallback */
.cell { font-size: clamp(18px, 6.3cqw, 36px); }
.cell[data-c="2"], .cell[data-c="5"] { border-right: 2px solid var(--line-strong); }
.cell[data-c="8"] { border-right: 0; }
.cell[data-r="2"], .cell[data-r="5"] { border-bottom: 2px solid var(--line-strong); }
.cell[data-r="8"] { border-bottom: 0; }
.cell.given { color: var(--given); }
.cell.related { background: var(--related); }
.cell.same { background: var(--same); }
.cell.error { color: var(--error); background: var(--error-bg); }
.cell.selected { background: var(--selected); }
.cell .val { pointer-events: none; position: relative; z-index: 1; display: inline-block; }
.cell .fx { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: var(--accent); }
.cell .fx.wave { animation: wave .75s ease-out var(--d, 0ms) both; }
.cell .fx.wave-gold { animation: wave .9s ease-out var(--d, 0ms) both; background: #f5b400; }
.cell .val.pop { animation: pop .32s cubic-bezier(.2, .9, .3, 1.3); }
.cell .val.shake { animation: shake .3s ease-in-out; }
.score-float {
  position: absolute; left: 50%; top: 14%; z-index: 2; pointer-events: none; white-space: nowrap;
  font-size: .48em; font-weight: 700; color: var(--accent);
  animation: float-up .95s ease-out forwards;
}
.score-float.big { font-size: .62em; color: #e0a200; animation-duration: 1.3s; }
.score-float small { font-size: .6em; margin-left: 3px; vertical-align: 2px; }
@keyframes wave { 0% { opacity: 0; transform: scale(.55); } 35% { opacity: .55; transform: scale(1); } 100% { opacity: 0; transform: scale(1); } }
@keyframes pop { 0% { transform: scale(.5); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes float-up { 0% { opacity: 0; transform: translate(-50%, 0); } 15% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -150%); } }
.cell .notes {
  position: absolute; inset: 0; z-index: 1; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  font-size: max(9px, .38em); color: var(--note); line-height: 1; pointer-events: none;
}
.cell .notes span { display: flex; align-items: center; justify-content: center; }
.cell .notes span.hl { color: var(--accent); font-weight: 700; }
.board.paused .cell .val, .board.paused .cell .notes { visibility: hidden; }

/* ---------- killer cages ---------- */
:root { --cage: #5d6b80; }
[data-theme="dark"] { --cage: #8b96a5; }
.board.killer { position: relative; }
.board .cages {
  position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none;
  fill: none; stroke: none; overflow: visible;
}
.board .cages path { stroke: var(--cage); stroke-width: 2.6; stroke-dasharray: 7 5; stroke-linecap: butt; }
.board .cages path.active { stroke: var(--accent); stroke-width: 3.6; }
.cell .cage-sum {
  position: absolute; top: 2px; left: 3px; z-index: 2; padding: 0 2px 1px 1px; pointer-events: none;
  font-size: max(9px, .3em); font-weight: 600; line-height: 1; color: var(--text); background: inherit;
}
.cell.has-sum .notes { top: 18%; }
.board.killer .cell .val { font-size: .9em; }

/* ---------- overlays ---------- */
.overlay {
  position: absolute; inset: 0; background: var(--overlay); z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  color: var(--muted); font-size: 15px;
}
.big-play {
  width: 76px; height: 76px; border-radius: 50%; background: var(--accent); color: #fff; border: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 20px rgba(50, 90, 175, .35);
}
.big-play svg { width: 34px; height: 34px; fill: currentColor; stroke: none; margin-left: 4px; }
.big-play:hover { background: var(--accent-hover); }
.spinner {
  width: 40px; height: 40px; border-radius: 50%; border: 4px solid var(--related); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- controls ---------- */
.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 40px; }
.tool {
  position: relative; background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 8px;
  color: var(--accent); font-size: 13px; cursor: pointer; padding: 4px 0;
}
.tool .ico { width: 54px; height: 54px; border-radius: 50%; background: var(--btn); display: flex; align-items: center; justify-content: center; }
.tool .ico svg { width: 24px; height: 24px; }
.tool:hover .ico { background: var(--btn-hover); }
.tool:disabled { opacity: .4; cursor: default; }
.tool:disabled:hover .ico { background: var(--btn); }
.tool .badge {
  position: absolute; top: 0; left: calc(50% + 12px); background: var(--muted); color: #fff;
  font-size: 10px; font-weight: 700; border-radius: 10px; padding: 2px 6px; z-index: 1; line-height: 1.2;
}
.tool .badge.on { background: var(--accent); }
.tool .badge.ad { background: #e0a200; }
.btn-primary:disabled, .btn-secondary:disabled { opacity: .6; cursor: default; }
.tool.active .ico { background: var(--accent); color: #fff; }

.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 22px; }
.num {
  position: relative; background: var(--btn); border: 0; border-radius: 8px;
  font-size: 34px; color: var(--accent); height: 66px; cursor: pointer;
}
.num:hover { background: var(--btn-hover); }
.num .cnt { position: absolute; right: 7px; bottom: 5px; font-size: 11px; color: var(--muted); }
.num { transition: opacity .4s; }
.num.done { opacity: .25; pointer-events: none; }

.newgame-wrap { position: relative; }
.primary {
  width: 100%; margin-top: 18px; background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  height: 58px; font-size: 17px; font-weight: 600; cursor: pointer;
}
.primary:hover { background: var(--accent-hover); }
.menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); background: var(--card);
  box-shadow: var(--shadow); border-radius: 10px; padding: 8px; z-index: 20;
}
.menu button {
  display: block; width: 100%; text-align: left; background: none; border: 0; padding: 11px 12px;
  border-radius: 6px; font-size: 15px; color: var(--text); cursor: pointer;
}
.menu button:hover { background: var(--related); }
.menu .sep { height: 1px; background: var(--line); margin: 6px 4px; }
.menu button.restart { color: var(--accent); font-weight: 600; }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.card {
  background: var(--card); border-radius: 16px; padding: 28px; width: min(380px, 100%);
  text-align: center; box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 8px; font-size: 22px; }
.card p { color: var(--muted); margin: 0 0 20px; line-height: 1.5; font-size: 15px; }
.card .trophy { font-size: 48px; margin-bottom: 6px; }
.card .actions { display: flex; flex-direction: column; gap: 10px; }
.btn-primary {
  background: var(--accent); color: #fff; border: 0; border-radius: 8px; height: 50px; font-size: 16px; font-weight: 600; cursor: pointer;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
  background: var(--btn); color: var(--accent); border: 0; border-radius: 8px; height: 50px; font-size: 16px; font-weight: 600; cursor: pointer;
}
.btn-secondary:hover { background: var(--btn-hover); }
.win-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 20px; }
.win-stats div { background: var(--related); border-radius: 8px; padding: 10px 6px; }
.win-stats small { display: block; color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.win-stats b { font-size: 16px; }

.settings-list { text-align: left; display: flex; flex-direction: column; gap: 14px; margin-bottom: 22px; }
.setting { display: flex; justify-content: space-between; align-items: center; font-size: 15px; }
.switch {
  position: relative; width: 46px; height: 26px; border-radius: 13px; background: var(--line); border: 0;
  cursor: pointer; transition: background .2s; flex-shrink: 0; padding: 0;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; transition: left .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}
.switch.on { background: var(--accent); }
.switch.on::after { left: 23px; }

/* ---------- article / SEO content ---------- */
.seo-content {
  max-width: 820px; margin: 56px auto 0; padding: 0 24px 40px;
  font-size: 16px; line-height: 1.7; color: var(--text);
}
.seo-content h1 { font-size: 30px; line-height: 1.25; margin: 0 0 14px; }
.seo-content h2 { font-size: 22px; margin: 38px 0 10px; }
.seo-content h3 { font-size: 17px; margin: 22px 0 6px; }
.seo-content p { margin: 0 0 14px; }
.seo-content ul, .seo-content ol { padding-left: 22px; margin: 0 0 14px; }
.seo-content li { margin-bottom: 6px; }
.seo-content a { color: var(--accent); }
.seo-content table { width: 100%; border-collapse: collapse; font-size: 15px; margin: 0 0 16px; }
.seo-content th, .seo-content td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.seo-content th { background: var(--related); }
/* Score calculator on the scoring page */
.sc-calc { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 16px; margin: 8px 0 20px; }
.sc-box { display: grid; gap: 10px; align-content: start; padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.sc-box h3 { margin: 0 0 2px; font-size: 17px; }
.sc-box label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.sc-box select, .sc-box input { font: inherit; font-size: 16px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; min-width: 0; }
.sc-time { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.sc-time input { width: 5.5em; }
.sc-out { margin: 4px 0 0; padding-top: 10px; border-top: 1px solid var(--line); }
.sc-out b { display: block; font-size: 26px; color: var(--accent); line-height: 1.2; }
.sc-out span { font-size: 14px; color: var(--muted); }
.seo-content .tech-fig { margin: 4px 0 22px; }
.tech-grid { display: block; width: 100%; max-width: 420px; height: auto; font-family: inherit; }
.tech-grid text { text-anchor: middle; dominant-baseline: central; }
.tech-fig figcaption { font-size: 14px; line-height: 1.55; color: var(--muted); margin-top: 8px; max-width: 560px; }
.fg-cell { fill: var(--cell); }
.fg-shade { fill: var(--related); }
.fg-hit { fill: var(--selected); }
.fg-thin { stroke: var(--line); stroke-width: 1; }
.fg-thick { stroke: var(--line-strong); stroke-width: 2; }
.fg-frame { fill: none; stroke: var(--line-strong); stroke-width: 2.5; }
.fg-label { fill: var(--muted); font-size: 10px; }
.fg-given { fill: var(--given); font-size: 21px; }
.fg-place { fill: var(--user); font-size: 21px; font-weight: 700; }
.fg-cand { fill: var(--note); font-size: 11px; }
.fg-keycell { fill: var(--same); }
.fg-key { fill: var(--accent); font-weight: 700; }
.fg-out { fill: var(--error); }
.fg-strike { stroke: var(--error); stroke-width: 1.4; }
.fg-link { stroke: var(--accent); stroke-width: 2; opacity: .55; }
.fg-dashed { stroke-dasharray: 4 4; }
.seo-content .faq details { border-bottom: 1px solid var(--line); padding: 10px 0; }
.seo-content .faq summary { cursor: pointer; font-weight: 600; }
.seo-content .faq .faq-answer { padding: 8px 0 0 4px; color: var(--muted); }
.site-footer {
  border-top: 1px solid var(--line); padding: 20px 24px calc(20px + env(safe-area-inset-bottom));
  text-align: center; color: var(--muted); font-size: 13px;
}
.site-footer a { color: var(--accent); text-decoration: none; margin: 0 2px; }
.site-footer p { margin: 8px 0 0; }
.site-footer .footer-guides { margin-top: 8px; }

/* ---------- game tip, statistics, win badges ---------- */
.game-tip {
  position: absolute; left: 50%; bottom: calc(100% + 4px); transform: translate(-50%, -8px); z-index: 6;
  max-width: calc(100% - 24px); padding: 8px 14px; border-radius: 20px; background: var(--card); color: var(--text);
  box-shadow: var(--shadow); font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; transition: opacity .35s, transform .35s; pointer-events: none;
}
.game-tip.show { opacity: 1; transform: translate(-50%, 0); }
.card.card-wide { width: min(460px, 100%); text-align: left; }
.card.card-wide h2 { text-align: center; }
.stats-tabs { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; margin: 0 0 14px; }
.stats-tabs button { border: 0; background: var(--btn); color: var(--muted); border-radius: 14px; padding: 5px 10px; font-size: 13px; cursor: pointer; }
.stats-tabs button.active { background: var(--accent); color: #fff; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat-cell { background: var(--related); border-radius: 8px; padding: 8px 6px; text-align: center; }
.stat-cell small { display: block; color: var(--muted); font-size: 11px; margin-bottom: 4px; line-height: 1.2; }
.stat-cell b { font-size: 16px; }
.card h3 { font-size: 14px; margin: 16px 0 6px; color: var(--muted); font-weight: 600; }
.stats-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.stats-table th, .stats-table td { padding: 5px 6px; text-align: left; border-bottom: 1px solid var(--line); }
.stats-table th { color: var(--muted); font-weight: 600; }
.stats-empty { color: var(--muted); font-size: 13px; margin: 0; }
.actions.actions-row { flex-direction: row; margin-top: 18px; }
.actions.actions-row button { flex: 1; }
.win-badges { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; min-height: 0; }
.win-badge { background: #f5b400; color: #3a2a00; font-size: 12px; font-weight: 700; border-radius: 12px; padding: 3px 10px; }
.win-note { color: var(--muted); font-size: 12px; }

/* ---------- killer combinations page ---------- */
.combos { max-width: 980px; margin: 28px auto 0; padding: 0 24px; line-height: 1.6; }
.combos h1 { font-size: 30px; line-height: 1.25; margin: 0 0 10px; }
.combos .lead { color: var(--muted); margin: 0 0 22px; max-width: 760px; }
.combos a { color: var(--accent); }
.combos h2 { font-size: 20px; margin: 0 0 14px; }
.calc { background: var(--related); border-radius: 14px; padding: 20px 22px; margin-bottom: 34px; }
.calc-row { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; flex-wrap: wrap; }
.calc-label { width: 150px; font-weight: 600; font-size: 15px; }
.seg, .digits { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button, .digits button, .sum-box .step {
  min-width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--card);
  color: var(--text); font-size: 17px; font-weight: 600; cursor: pointer; padding: 0 8px;
}
.seg button[aria-pressed="true"], #incDigits button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
#excDigits button[aria-pressed="true"] { background: var(--error-bg); border-color: var(--error); color: var(--error); text-decoration: line-through; }
.sum-box { display: flex; align-items: center; gap: 6px; }
.sum-box input {
  width: 72px; height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text);
  font-size: 18px; font-weight: 600; text-align: center; font-family: inherit;
}
.sum-box .range { color: var(--muted); font-size: 13px; margin-left: 6px; }
.calc-out { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); min-height: 60px; }
.calc-count { margin: 0 0 8px; font-weight: 600; }
.calc-none { margin: 0; color: var(--error); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 3px 9px; font-size: 18px; font-weight: 600; letter-spacing: .12em; font-variant-numeric: tabular-nums; }
.calc-facts { margin: 0; color: var(--muted); font-size: 15px; white-space: pre-wrap; }
.calc-facts b { color: var(--text); }
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.chart-head h2 { margin: 0; }
.print-btn { height: 40px; padding: 0 16px; font-size: 14px; }
.chart-note { color: var(--muted); font-size: 14px; margin: 8px 0 14px; }
.combo-chart { columns: 3 280px; column-gap: 22px; }
.combo-size { break-inside: avoid; margin-bottom: 20px; }
.combo-size h3 { font-size: 16px; margin: 0 0 6px; }
.combo-size table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.combo-size th, .combo-size td { border-bottom: 1px solid var(--line); padding: 3px 6px; text-align: left; vertical-align: top; }
.combo-size thead th { color: var(--muted); font-size: 12px; font-weight: 600; }
.combo-size tbody th { width: 44px; font-weight: 700; }
.combo-size td { letter-spacing: .06em; word-spacing: .4em; }
.combo-size tr.unique { background: var(--same); }
.tool-page .seo-content { margin-top: 30px; }

/* the cheat sheet: the chart alone, all eight tables on one A4 or Letter page */
@page { margin: 9mm; }
@media print {
  .tool-page .topbar, .tool-page .calc, .tool-page .seo-content, .tool-page .site-footer, .tool-page .print-btn,
  .tool-page .chart-note, .tool-page .combos > :not(.chart-wrap) { display: none !important; }
  .tool-page { background: #fff; color: #000; }
  .combos { margin: 0; padding: 0; max-width: none; line-height: 1.25; }
  .chart-head h2 { font-size: 15px; margin: 0 0 6px; }
  .combo-chart { columns: 4; column-gap: 12px; }
  .combo-size { margin-bottom: 8px; }
  .combo-size h3 { font-size: 12px; margin: 0 0 2px; }
  .combo-size table { font-size: 10px; }
  .combo-size thead { display: none; }
  .combo-size th, .combo-size td { padding: 0 3px; border-color: #ccc; }
  .combo-size tbody th { width: 20px; }
  .combo-size td { letter-spacing: 0; word-spacing: .25em; }
  .combo-size tr.unique { background: #e6e6e6; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- printable puzzles page ---------- */
/* Each .sheet is one printed page. .sheet-inner is the printable area (Letter 7.5 x 10 in or A4 184.6 x 271.6 mm,
   a little shorter so rounding never spills onto an extra page) and sizes everything in cqw, so the screen
   preview and the printout share one layout. The sheets stay white paper in the dark theme. */
.printable { max-width: 980px; margin: 28px auto 0; padding: 0 24px; line-height: 1.6; }
.printable h1 { font-size: 30px; line-height: 1.25; margin: 0 0 10px; }
.printable .lead { color: var(--muted); margin: 0 0 22px; max-width: 760px; }
.printable a { color: var(--accent); }
.printable h2 { font-size: 20px; margin: 0 0 14px; }
.maker .checks { gap: 8px 22px; }
.maker .checks label { display: flex; align-items: center; gap: 8px; font-size: 15px; cursor: pointer; }
.maker .checks input { width: 18px; height: 18px; accent-color: var(--accent); }
.maker-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.maker-actions button { height: 44px; padding: 0 18px; font-size: 15px; }
.maker-status { color: var(--muted); font-size: 14px; }
.sheets { display: flex; flex-direction: column; align-items: center; gap: 24px; margin: 0 0 40px; }
.sheets.busy { opacity: .35; transition: opacity .2s; }
.sheet { width: min(100%, 640px); padding: 6%; background: #fff; color: #111; box-shadow: 0 2px 14px rgba(0, 0, 0, .18); border-radius: 2px; }
.sheet-inner { container-type: inline-size; aspect-ratio: 7.5 / 9.9; display: flex; flex-direction: column; font-family: Arial, Helvetica, sans-serif; }
.sheets[data-paper="a4"] .sheet-inner { aspect-ratio: 184.6 / 269.5; }
.sheet-head { display: flex; justify-content: space-between; align-items: baseline; gap: 3cqw; border-bottom: .3cqw solid #111; padding-bottom: 1.2cqw; margin-bottom: 2cqw; }
.sheet-head b { font-size: 3.6cqw; }
.sheet-name { font-size: 2.5cqw; color: #333; white-space: nowrap; }
.sheet-name i { display: inline-block; width: 22cqw; height: 1em; border-bottom: .2cqw solid #333; margin: 0 2cqw 0 .6cqw; vertical-align: -.2em; }
.sheet-name i.short { width: 13cqw; margin-right: 0; }
.sheet-grid { flex: 1; display: grid; justify-content: center; align-content: space-evenly; }
.sheet-grid.n1 { grid-template-columns: 90cqw; }
.sheet-grid.n2 { grid-template-columns: 54cqw; }
.sheet-grid.n4 { grid-template-columns: repeat(2, 45cqw); column-gap: 6cqw; }
.sheet-grid.n6 { grid-template-columns: repeat(2, 34cqw); column-gap: 12cqw; }
.pz { margin: 0; }
.pz svg { display: block; width: 100%; height: auto; }
.pz figcaption { text-align: center; font-size: 2.1cqw; color: #444; margin-top: .6cqw; }
.pz text { font-family: Arial, Helvetica, sans-serif; font-size: 30px; text-anchor: middle; dominant-baseline: central; }
.pz-thin { stroke: #666; stroke-width: 1.2; }
.pz-thick { stroke: #111; stroke-width: 3.2; }
.pz-frame { fill: none; stroke: #111; stroke-width: 5; }
.pz-given { fill: #111; }
.answers .pz-given { font-weight: 700; }
.pz-fill { fill: #777; }
.sheet-foot { display: flex; justify-content: space-between; gap: 2cqw; font-size: 1.9cqw; color: #666; border-top: .2cqw solid #bbb; padding-top: 1cqw; margin-top: 1.5cqw; }
@media print {
  .print-page .printable > :not(.sheets) { display: none !important; }
  .print-page .printable { margin: 0; padding: 0; max-width: none; }
  .print-page .sheets { display: block; margin: 0; }
  .print-page .sheet { width: 100%; padding: 0; box-shadow: none; border-radius: 0; }
  .print-page .sheet.next { break-before: page; }
  .print-page .sheet-inner { overflow: hidden; }
}
@media (max-width: 760px) {
  .printable { padding: 0 12px; margin-top: 18px; }
  .printable h1 { font-size: 24px; }
  .sheets { gap: 14px; }
}

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .topbar { padding: 10px 12px; gap: 12px; flex-wrap: wrap; }
  .brand { font-size: 20px; }
  .difficulty { order: 3; flex: 0 0 100%; gap: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; justify-content: space-between; }
  .difficulty::-webkit-scrollbar { display: none; }
  .difficulty .label { display: none; }
  .difficulty button, .difficulty a { padding: 6px 6px; font-size: 13px; white-space: nowrap; }
  .top-actions { margin-left: auto; }
  .game { grid-template-columns: 1fr; gap: 14px; padding: 0 12px; margin: 12px auto; }
  .tools { margin-top: 6px; }
  .numpad { grid-template-columns: repeat(9, 1fr); gap: 4px; margin-top: 12px; }
  .num { height: 58px; font-size: 26px; border-radius: 6px; padding: 0 0 14px; }
  .num .cnt { left: 0; right: 0; bottom: 5px; text-align: center; font-size: 10px; line-height: 1; }
  .primary { height: 50px; margin-top: 12px; }
  .puzzle-meta { display: none; }
  /* Killer: the line under the board lists the selected cage's combinations, so keep it */
  body[data-variant="killer"] .puzzle-meta { display: block; text-align: left; margin-top: 6px; }
  .game { padding-bottom: 16px; }
  .seo-content { margin-top: 32px; padding: 0 16px 24px; font-size: 15px; }
  .seo-content h1 { font-size: 24px; }
  .seo-content h2 { font-size: 19px; }
  .seo-content table { display: block; overflow-x: auto; }
  .combos { padding: 0 16px; margin-top: 18px; }
  .combos h1 { font-size: 24px; }
  .calc { padding: 16px 14px; }
  .calc-label { width: 100%; }
  .seg button, .digits button { min-width: 34px; height: 38px; font-size: 16px; padding: 0 6px; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .stat-cell b { font-size: 14px; }
  /* the New Game button sits at the bottom of the screen, so its menu opens upwards */
  .menu { top: auto; bottom: calc(100% + 6px); }
}

/* landscape phones: keep the whole board and the controls inside the viewport height */
@media (min-width: 761px) and (max-height: 560px) {
  .topbar { padding: 6px 16px; gap: 12px; }
  .difficulty { flex-wrap: nowrap; }
  .difficulty .label { display: none; }
  .difficulty button, .difficulty a { padding: 5px 7px; font-size: 14px; white-space: nowrap; }
  /* the board is narrow here, so let the tip grow from the board's left edge instead of truncating */
  .game-tip { left: 0; max-width: 70vw; transform: translate(0, -8px); font-size: 12px; padding: 6px 12px; }
  .game-tip.show { transform: translate(0, 0); }
  .game { margin: 8px auto; gap: 24px; }
  .status { margin-bottom: 6px; font-size: 14px; }
  .board-col { max-width: calc(100vh - 118px); }
  .puzzle-meta { display: none; }
  .tools { margin-top: 4px; gap: 4px; }
  .tool { font-size: 12px; gap: 4px; }
  .tool .ico { width: 40px; height: 40px; }
  .tool .ico svg { width: 20px; height: 20px; }
  .numpad { margin-top: 8px; gap: 6px; }
  .num { height: 40px; font-size: 22px; }
  .num .cnt { right: 6px; bottom: 3px; font-size: 10px; }
  .primary { height: 40px; margin-top: 8px; font-size: 15px; }
}
