:root {
  --paper: #f5f1e8;
  --ink: #1e2b2b;
  --muted: #697474;
  --line: #c8cbc1;
  --line-strong: #50605c;
  --panel: #fffdf8;
  --accent: #d85f3f;
  --accent-dark: #b7472d;
  --mint: #d8e5d5;
  --blue: #d9e5e5;
  --red: #f7d7d0;
  --shadow: 0 18px 45px rgba(34, 44, 39, .08);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--paper); font-family: Manrope, sans-serif; }
body::before { content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .28; background-image: radial-gradient(#bdc2b8 .7px, transparent .7px); background-size: 18px 18px; mask-image: linear-gradient(to bottom, black, transparent 75%); }
a { color: inherit; }
.site-header, .site-footer { width: min(1180px, calc(100% - 40px)); margin: auto; display: flex; align-items: center; justify-content: space-between; }
.site-header { height: 84px; position: relative; z-index: 1; }
.brand { display: inline-flex; align-items: center; gap: 11px; font-size: 12px; font-weight: 800; letter-spacing: .18em; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border: 2px solid var(--ink); border-radius: 50%; font-family: "DM Mono", monospace; font-size: 14px; letter-spacing: 0; }
nav { display: flex; gap: 28px; font-size: 13px; font-weight: 700; } nav a { text-decoration: none; opacity: .55; } nav a:hover, nav a[aria-current="page"] { opacity: 1; }
main { width: min(1180px, calc(100% - 40px)); margin: 34px auto 74px; position: relative; z-index: 1; }
.game-layout { display: grid; grid-template-columns: minmax(0, 680px) minmax(270px, 1fr); gap: 70px; align-items: start; }
.eyebrow { color: var(--accent-dark); font: 500 11px "DM Mono", monospace; letter-spacing: .16em; text-transform: uppercase; }
h1 { margin: 10px 0 11px; font-size: clamp(32px, 5vw, 58px); line-height: .98; letter-spacing: -.055em; max-width: 620px; } h1 em { color: var(--accent); font-style: normal; }
.intro { max-width: 480px; color: var(--muted); line-height: 1.7; font-size: 14px; }
.game-top { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 35px 0 15px; }
.timer-label { color: var(--muted); font: 500 11px "DM Mono", monospace; letter-spacing: .13em; text-transform: uppercase; } .timer { margin-top: 3px; font: 500 clamp(28px, 5vw, 42px) "DM Mono", monospace; letter-spacing: -.06em; }
.badge { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font: 500 11px "DM Mono", monospace; text-transform: uppercase; letter-spacing: .08em; } .badge::before { content: ""; width: 7px; height: 7px; background: var(--accent); border-radius: 50%; }
.board-wrap { background: var(--panel); padding: clamp(8px, 1.5vw, 14px); box-shadow: var(--shadow); }
.board { width: 100%; aspect-ratio: 1; display: grid; grid-template-columns: repeat(9, 1fr); grid-template-rows: repeat(9, 1fr); border: 2px solid var(--line-strong); }
.cell { position: relative; min-width: 0; min-height: 0; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: transparent; color: var(--ink); cursor: pointer; font: 600 clamp(18px, 4vw, 31px) Manrope, sans-serif; transition: background .15s ease, color .15s ease; }
.cell:nth-child(9n) { border-right: 0; } .cell:nth-child(n+73) { border-bottom: 0; } .cell:nth-child(3n) { border-right: 2px solid var(--line-strong); } .cell:nth-child(27n+19), .cell:nth-child(27n+20), .cell:nth-child(27n+21), .cell:nth-child(27n+22), .cell:nth-child(27n+23), .cell:nth-child(27n+24), .cell:nth-child(27n+25), .cell:nth-child(27n+26), .cell:nth-child(27n+27) { border-top: 2px solid var(--line-strong); }
.cell:nth-child(9n+1) { border-left: 0; } .cell.given { font-weight: 800; cursor: default; } .cell.selected { background: var(--blue); } .cell.related { background: #edf2ed; } .cell.same-number { background: #e4ece4; } .cell.error { background: var(--red); color: var(--accent-dark); box-shadow: inset 0 0 0 2px var(--accent); } .cell.revealed { color: var(--accent-dark); background: #f8eee8; }
.notes { position: absolute; inset: 5px 3px; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); align-items: center; justify-items: center; color: #6e7b78; font: 500 clamp(8px, 1.65vw, 13px) "DM Mono", monospace; pointer-events: none; }.notes span { line-height: 1; }
.controls { margin-top: 16px; display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; }.number-pad { display: grid; grid-template-columns: repeat(9, 1fr); gap: 5px; }.number-pad button { aspect-ratio: 1; border: 1px solid var(--line); border-radius: 3px; background: var(--panel); color: var(--ink); font: 500 16px "DM Mono", monospace; cursor: pointer; }.number-pad button:hover, .number-pad button.active { color: white; background: var(--ink); border-color: var(--ink); }
.tool-row { display: flex; gap: 7px; justify-content: flex-end; }.tool, .button { border: 1px solid var(--line-strong); border-radius: 3px; padding: 12px 15px; background: transparent; color: var(--ink); cursor: pointer; font: 700 12px Manrope, sans-serif; white-space: nowrap; }.tool:hover, .button:hover { background: var(--ink); color: white; }.tool.active { background: var(--mint); border-color: #90aa91; }.button.primary { background: var(--accent); border-color: var(--accent); color: white; }.button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }.button.secondary { border-color: var(--line); color: var(--muted); }
.side-panel { border-top: 2px solid var(--ink); padding-top: 18px; margin-top: 73px; }.side-panel h2 { font-size: 18px; letter-spacing: -.03em; margin: 0 0 14px; }.side-panel p { color: var(--muted); font-size: 13px; line-height: 1.65; margin: 0 0 22px; }.difficulty { display: flex; gap: 6px; flex-wrap: wrap; }.difficulty button { border: 1px solid var(--line); background: transparent; color: var(--muted); padding: 9px 12px; border-radius: 3px; cursor: pointer; font: 500 11px "DM Mono", monospace; }.difficulty button.active { color: white; background: var(--ink); border-color: var(--ink); }.side-actions { display: grid; gap: 9px; margin-top: 24px; }
.message { min-height: 24px; color: var(--muted); font-size: 13px; line-height: 1.5; margin: 15px 0 0; }.message.success { color: #327044; }.message.error-message { color: var(--accent-dark); }
.score-box { margin-top: 22px; padding: 17px; background: var(--mint); border-left: 3px solid #789879; }.score-box strong { display: block; font: 500 27px "DM Mono", monospace; margin: 5px 0 15px; }.score-form { display: flex; gap: 7px; }.score-form input { min-width: 0; width: 100%; border: 1px solid #aabdaa; background: rgba(255,255,255,.6); padding: 10px; font: 600 12px Manrope, sans-serif; }.score-form button { padding-inline: 12px; }
.page-heading { margin-bottom: 38px; }.leaderboard { overflow-x: auto; background: var(--panel); box-shadow: var(--shadow); }.score-table { width: 100%; border-collapse: collapse; min-width: 630px; text-align: left; }.score-table th { padding: 15px 18px; color: var(--muted); border-bottom: 2px solid var(--line-strong); font: 500 10px "DM Mono", monospace; letter-spacing: .12em; text-transform: uppercase; }.score-table td { padding: 15px 18px; border-bottom: 1px solid var(--line); font-size: 13px; }.score-table tr:last-child td { border-bottom: 0; }.score-table td:first-child, .score-table td:nth-child(3) { font-family: "DM Mono", monospace; }.filter-row { display: flex; gap: 7px; margin-bottom: 14px; }.empty { padding: 42px 20px; color: var(--muted); text-align: center; font-size: 13px; }
.site-footer { border-top: 1px solid var(--line); padding: 18px 0 25px; color: var(--muted); font: 500 10px "DM Mono", monospace; letter-spacing: .08em; }
@media (max-width: 850px) { .game-layout { grid-template-columns: 1fr; gap: 35px; } .side-panel { margin-top: 0; } .game-layout > section:first-child { max-width: 680px; } }
@media (max-width: 530px) { .site-header, .site-footer, main { width: min(100% - 24px, 680px); } .site-header { height: 67px; } nav { gap: 14px; font-size: 11px; } .brand { font-size: 10px; }.game-top { margin-top: 24px; }.controls { grid-template-columns: 1fr; }.tool-row { justify-content: stretch; }.tool-row .tool { flex: 1; }.number-pad { gap: 3px; }.number-pad button { font-size: 13px; }.score-form { flex-wrap: wrap; }.score-form button { width: 100%; } h1 { font-size: 39px; } .site-footer { font-size: 8px; } }
.cell { border-top: 0 !important; }
.cell:nth-child(n+19):nth-child(-n+27), .cell:nth-child(n+46):nth-child(-n+54) { border-bottom: 2px solid var(--line-strong); }
.cell:nth-child(9n) { border-right: 0; }
.cell:not(.given) { color: #276e7b; font-weight: 500; }
.cell.same-number { background: #dbe8e8; box-shadow: inset 0 0 0 1px #9dbcbc; }
.cell.selected { background: #c8dfdf; box-shadow: inset 0 0 0 2px #477f85; }
.cell.error { background: #f7d7d0; color: #a62d23; box-shadow: inset 0 0 0 2px #c34334; }
.cell:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid #276e7b; outline-offset: 2px; z-index: 2; }
button:disabled { opacity: .5; cursor: default; }
dialog { border: 1px solid var(--line); border-radius: 12px; padding: 28px; max-width: min(460px, calc(100% - 32px)); background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
dialog::backdrop { background: #1e2b2b80; backdrop-filter: blur(4px); }
dialog p { line-height: 1.7; color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 25px; }
.filter-row button { border: 1px solid var(--line); padding: 10px 16px; background: var(--panel); border-radius: 4px; cursor: pointer; }
.filter-row button.active { background: var(--ink); color: white; }
.game-layout { grid-template-columns: minmax(0, 560px) minmax(260px, 330px); justify-content: center; }
.side-panel { position: sticky; top: 30px; }
.controls { grid-template-columns: 1fr; }
.tool-row .tool { flex: 1; }
.number-pad button { min-height: 38px; }
.number-pad button.all-placed { background: #dbe8e8; border-color: #477f85; color: var(--ink); box-shadow: inset 0 -3px 0 #477f85; }
.number-pad button.all-placed:hover { background: #c8dfdf; }
dialog[data-print-preview] { width: min(760px, calc(100% - 24px)); max-width: 760px; max-height: 95vh; overflow: auto; }
.print-toolbar { display:flex; align-items:center; gap:10px; }
.print-toolbar strong { margin-right:auto; }
.print-sheet { background:white; }
.print-sheet svg { display:block; width:100%; height:auto; }
@media print {
  @page { size:auto; margin:0; }
  html, body { margin:0 !important; padding:0 !important; min-width:0; background:white !important; overflow:visible !important; }
  body > :not([data-print-preview]), body::before { display:none !important; }
  dialog[data-print-preview] { display:block !important; position:static !important; width:100% !important; max-width:none !important; max-height:none !important; height:auto !important; margin:0 !important; padding:8mm !important; border:0 !important; border-radius:0; box-shadow:none !important; overflow:visible !important; background:white !important; }
  dialog[data-print-preview]::backdrop, .print-toolbar, dialog[data-print-preview] > p { display:none !important; }
  .print-sheet { break-inside:avoid; }
}
@media(max-width:850px){ .game-layout { width:min(100%,680px); margin-inline:auto; grid-template-columns:minmax(0,1fr); } .game-layout > section:first-child { width:100%; max-width:none; } .side-panel { position:static; width:100%; } }
@media(prefers-reduced-motion:reduce){ * { transition: none !important; } }
.help-card { border-top: 1px solid var(--line); margin-top: 30px; padding-top: 20px; }
.help-card h3 { font-size: 13px; margin: 0 0 10px; }
.help-card p { font-size: 12px; }
kbd { font: 11px "DM Mono", monospace; background: var(--panel); padding: 3px 5px; border: 1px solid var(--line); border-radius: 3px; line-height: 2.4; }

/* Keep controls usable at touch sizes without shrinking the Sudoku grid. */
@media screen {
  button, a { touch-action: manipulation; }
  .button, .tool, .difficulty button, .filter-row button { min-height: 44px; }
  nav a { display: inline-flex; align-items: center; min-height: 44px; }
  .score-form input { font-size: 16px; }
  .game-layout > *, .number-pad { min-width: 0; }
  .number-pad { grid-template-columns: repeat(9, minmax(0, 1fr)); }
  .number-pad button { min-width: 0; min-height: 44px; aspect-ratio: auto; padding: 10px 0; }
  .filter-row, .dialog-actions, .print-toolbar { flex-wrap: wrap; }
  dialog { max-height: calc(100dvh - 24px); overflow-y: auto; }
}
@media screen and (max-width: 530px) {
  .site-header, .site-footer, main { width: calc(100% - 24px); }
  main { margin-top: 16px; }
  .number-pad { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
  .number-pad button { font-size: 18px; }
  .notes { inset: 2px 1px; font-size: clamp(9px, 2.4vw, 12px); }
  .cell { padding: 0; }
  dialog, dialog[data-print-preview] { padding: 16px; }
  .print-toolbar strong { flex-basis: 100%; }
  .print-toolbar .button { flex: 1; }
  .dialog-actions .button { white-space: normal; }
  .filter-row { gap: 5px; }
  .filter-row button { padding-inline: 12px; }
}


.scores-new-game { margin-top:18px; }

.score-dialog { width:min(700px,calc(100% - 32px)); max-width:700px; padding:0; border:0; border-radius:0; overflow:visible; background:transparent; }
.score-dialog .score-box { margin:0; padding:clamp(26px,5vw,44px); border-left:4px solid #789879; background:var(--mint); box-shadow:0 24px 70px rgba(30,43,43,.24); }
.score-congratulations { margin:0 0 25px; color:#477f57!important; font-size:16px; }
.score-error { min-height:18px; margin:10px 0 0!important; color:var(--accent-dark)!important; font-size:12px; }
.score-success { min-height:180px; display:grid; place-items:center; align-content:center; text-align:center; }
.score-success .success-mark { display:grid; width:48px; height:48px; place-items:center; margin-bottom:14px; border:2px solid #477f57; border-radius:50%; color:#477f57; font-size:24px; }
.score-success h2 { margin:0; font-size:32px; }
.score-success p { margin:8px 0 0; color:var(--muted); }
/* Strong matching-digit frame */
.cell.same-number { box-shadow:inset 0 0 0 3px #3d767c; }
.cell.selected.same-number { box-shadow:inset 0 0 0 4px #285d63; }
.erase-all { border-color:var(--accent-dark); color:var(--accent-dark); }

.radio-button { display:inline-flex; align-items:center; gap:7px; border:1px solid var(--line-strong); border-radius:100px; padding:7px 10px; background:transparent; color:var(--ink); cursor:pointer; font:700 11px Manrope,sans-serif; white-space:nowrap; }
.radio-button:hover,.radio-button[aria-pressed="true"] { background:var(--ink); color:var(--paper); }
.radio-button:disabled { cursor:wait; opacity:.65; }
.radio-button #radioIcon { width:11px; color:var(--accent); font-size:10px; text-align:center; }
@media (max-width:530px) { .radio-button { padding:6px 8px; } .radio-button #radioLabel { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0,0,0,0); } }

/* Tablet portrait: use the screen instead of squeezing the game into a desktop-sized column. */
@media screen and (min-width:531px) and (max-width:850px) {
  main { width:calc(100% - 32px); margin-top:22px; }
  .site-header,.site-footer { width:calc(100% - 32px); }
  .site-header { height:72px; }
  nav { gap:14px; font-size:12px; }
  .game-top { margin-top:28px; }
  .board-wrap { width:100%; padding:10px; }
  .tool-row { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); }
  .tool-row .tool { min-width:0; padding-inline:8px; }
}

/* Immediate duplicate feedback for rows and columns. */
.cell.conflict-line { background:#fae9e5; }
.cell.conflict-number { background:#f4c9c0; color:#9f2f24; box-shadow:inset 0 0 0 3px #c34334; font-weight:800; }
.cell.selected.conflict-number { background:#efb8ad; box-shadow:inset 0 0 0 4px #9f2f24; }

/* Complete site navigation */
@media screen and (max-width: 900px) {
  .site-header { height:auto; min-height:72px; padding-block:10px; gap:10px 20px; flex-wrap:wrap; }
  .site-header nav { width:100%; justify-content:flex-end; flex-wrap:wrap; gap:10px 16px; }
}
@media screen and (max-width: 530px) {
  .site-header { align-items:flex-start; }
  .site-header nav { justify-content:flex-start; }
}