/* Mobile-first styles; no external fonts or CDNs. */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-alt: #f4f6f8;
  --text: #1c2430;
  --muted: #55606e;
  --accent: #1f5fbf;
  --accent-text: #ffffff;
  --max: 64rem;
  --border: #e3e7ec;
  --border-strong: #dde2e8;
  --cell-line: #d5dae1;
  --control-border: #c8cfd8;
  --disabled: #aab3bf;
  --focus: #f5a623;
  --cell-same-given: #cdddf6;
  --cell-peer: #eef2f7;
  --cell-same: #b7d3f7;
  --cell-same-value: #123f7d;
  --cell-selected: #fce8b8;
  --cell-selected-same: #f5df9a;
  --danger: #b3261e;
  --danger-border: #e3b9b5;
  --danger-bg: #fbe9e7;
  --danger-bg-selected: #f6d9d5;
  --solved-bg: #e6f4ea;
  --solved-text: #137333;
  --solved-given-bg: #d7ecdb;
}

/* Dark theme: applied by toggling .theme-dark on <html> (see sudoku.js). */
:root.theme-dark {
  color-scheme: dark;
  --bg: #12161d;
  --bg-alt: #1a212b;
  --text: #e8ecf2;
  --muted: #9aa7b8;
  --accent: #7ab0f5;
  --accent-text: #10141b;
  --border: #2a323e;
  --border-strong: #333d4a;
  --cell-line: #2e3742;
  --control-border: #455364;
  --disabled: #6d7887;
  --cell-same-given: #27436e;
  --cell-peer: #1d2530;
  --cell-same: #2d5490;
  --cell-same-value: #b0d0ff;
  --cell-selected: #6a5420;
  --cell-selected-same: #7d6626;
  --danger: #ff8a80;
  --danger-border: #7d3d37;
  --danger-bg: #3d201c;
  --danger-bg-selected: #5d2a26;
  --solved-bg: #1d3527;
  --solved-text: #7bd88f;
  --solved-given-bg: #274434;
}

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

html { scroll-behavior: smooth; scroll-padding-top: 10rem; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.container { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 1rem; }

a { color: var(--accent); }
a:focus-visible, .button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-text);
  padding: 0.5rem 1rem;
  z-index: 10;
}
.skip-link:focus { left: 0; }

.site-header { border-bottom: 1px solid var(--border); background: var(--bg); position: sticky; top: 0; z-index: 10; }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; padding-top: 0.75rem; padding-bottom: 0.75rem; }
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.nav { display: flex; flex-wrap: wrap; gap: 0 1rem; list-style: none; margin: 0; padding: 0; }
.nav a { display: flex; align-items: center; padding: 0.6rem 0; text-decoration: none; }
.nav a:hover { text-decoration: underline; }
.nav .nav-cta { color: var(--accent); font-weight: 700; }

.hero { background: var(--bg-alt); padding: 3rem 0; }
.hero h1 { margin: 0 0 1rem; font-size: 2rem; line-height: 1.2; }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 40rem; margin: 0 0 1.5rem; }

.button {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-text);
  padding: 0.75rem 1.5rem;
  border-radius: 0.4rem;
  text-decoration: none;
  font-weight: 600;
}
.button:hover { filter: brightness(1.1); }

.section { padding: 3rem 0; }
.section-alt { background: var(--bg-alt); }
.section h2 { margin-top: 0; }

.site-footer { padding: 1.5rem 0; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.9rem; }
.site-footer p { margin: 0; }

@media (min-width: 48rem) {
  html { scroll-padding-top: 7.5rem; }
  .hero { padding: 5rem 0; }
  .hero h1 { font-size: 3rem; }
  .section { padding: 4rem 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* Components shared by the site's sections and pages */
.narrow { max-width: 44rem; }
.section-head { max-width: 40rem; margin-bottom: 2rem; }
.section-head p { color: var(--muted); margin: 0; }
.grid { display: grid; gap: 1.25rem; grid-template-columns: 1fr; list-style: none; margin: 0; padding: 0; }
.card { background: var(--bg); border: 1px solid var(--border); border-radius: 0.6rem; padding: 1.25rem; }
.section-alt .card { border-color: var(--border-strong); }
.card h3 { margin: 0 0 0.5rem; font-size: 1.15rem; }
.card p { margin: 0 0 0.5rem; }
.card img { display: block; width: 100%; height: auto; border-radius: 0.4rem; margin-bottom: 0.75rem; background: var(--bg-alt); }
.meta { color: var(--muted); font-size: 0.9rem; }
.price { font-weight: 700; }
.badge { display: inline-block; padding: 0.1rem 0.6rem; border-radius: 1rem; background: var(--bg-alt); color: var(--muted); font-size: 0.85rem; }
.empty { padding: 1.5rem; border: 1px dashed var(--disabled); border-radius: 0.6rem; color: var(--muted); text-align: center; }
.split { display: grid; gap: 2rem; grid-template-columns: 1fr; align-items: start; }
.split img { display: block; width: 100%; height: auto; border-radius: 0.6rem; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.breadcrumbs { font-size: 0.9rem; color: var(--muted); margin: 0 0 1rem; }
.breadcrumbs a { color: inherit; }
.toc { background: var(--bg-alt); border-radius: 0.6rem; padding: 1rem 1.25rem; margin: 0 0 2rem; }
.toc ol, .toc ul { margin: 0.5rem 0 0; padding-left: 1.25rem; }
details { border-bottom: 1px solid var(--border); padding: 0.75rem 0; }
summary { cursor: pointer; font-weight: 600; }
.button-secondary { background: transparent; color: var(--accent); border: 2px solid var(--accent); }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }

@media (min-width: 40rem) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 60rem) {
  .grid { grid-template-columns: repeat(3, 1fr); }
  .split { grid-template-columns: 1fr 1fr; }
}

/* ---------------- Sudoku game ---------------- */

.statusbar { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 0.4rem 1rem; margin: 0 0 0.75rem; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.05rem; }
.status { color: var(--muted); font-size: 0.95rem; }

#board {
  display: block;
  margin-inline: auto;
  border: 2px solid var(--text);
  border-radius: 0.4rem;
  background: var(--bg);
  width: 100%;
  max-width: 30rem;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
.srow { display: grid; grid-template-columns: repeat(9, 1fr); }
.cell {
  position: relative;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--cell-line);
  border-bottom: 1px solid var(--cell-line);
  cursor: pointer;
  font-weight: 600;
}
.srow .cell:last-child { border-right: none; }
.srow:last-child .cell { border-bottom: none; }
.cell.edge-r { border-right: 2px solid var(--text); }
.cell.edge-b { border-bottom: 2px solid var(--text); }
.cell:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.cell .value { font-size: clamp(1rem, 4.5vw, 1.5rem); line-height: 1; }
.cell.given { color: var(--text); background: var(--bg-alt); }
.cell.given.same { background: var(--cell-same-given); }
.cell:not(.given) .value { color: var(--accent); }
.cell.peer { background: var(--cell-peer); }
.cell.same:not(.given) { background: var(--cell-same); }
.cell.same .value { color: var(--cell-same-value); }
.cell.selected { background: var(--cell-selected); }
.cell.selected.same { background: var(--cell-selected-same); }
.cell.wrong .value { color: var(--danger); }
.cell.wrong { background: var(--danger-bg); }
.cell.selected.wrong { background: var(--danger-bg-selected); }
#board.solved .cell { background: var(--solved-bg); }
#board.solved .cell .value { color: var(--solved-text); }
#board.solved .cell.given { background: var(--solved-given-bg); }
#board.solved .cell.given .value { color: var(--solved-text); }

.cell .notes {
  position: absolute;
  inset: 2%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  pointer-events: none;
}
.cell .notes span {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.5rem, 1.9vw, 0.68rem);
  font-weight: 500;
  line-height: 1;
  color: var(--muted);
  visibility: hidden;
}
.cell .notes span.on { visibility: visible; }

.pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  max-width: 30rem;
  margin: 1rem auto 0.75rem;
}
.key {
  font: inherit;
  font-weight: 700;
  font-size: 1.15rem;
  padding: 0.55rem 0;
  min-height: 44px;
  border: 1px solid var(--control-border);
  border-radius: 0.4rem;
  background: var(--bg);
  color: var(--accent);
  cursor: pointer;
}
.key:hover:not(:disabled) { background: var(--bg-alt); }
.key:disabled { color: var(--disabled); cursor: default; background: var(--bg); text-decoration: line-through; }
.key-erase { color: var(--muted); font-size: 1rem; }

.game-actions { margin-top: 0.5rem; justify-content: center; }
.tool {
  font: inherit;
  font-size: 0.92rem;
  padding: 0.55rem 0.9rem;
  min-height: 44px;
  border: 1px solid var(--control-border);
  border-radius: 0.4rem;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
.tool:hover { background: var(--bg-alt); }
.tool.active { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.tool-danger { color: var(--danger); border-color: var(--danger-border); }
.tool-danger:hover { background: var(--danger-bg); }

/* Center the whole play block: heading, status line, tools and save note. */
#play .container { text-align: center; }

/* Center the hero block: headline, lead text and difficulty buttons. */
.hero .container { text-align: center; }
.hero .lead { margin-inline: auto; }
.hero .actions { justify-content: center; }

.save-note { margin-top: 1rem; }

.theme-toggle { padding: 0.3rem 0.75rem; min-height: 36px; font-size: 0.85rem; }
.theme-label-light { display: none; }
.theme-dark .theme-label-light { display: inline; }
.theme-dark .theme-label-dark { display: none; }

@media (min-width: 30rem) {
  .pad { grid-template-columns: repeat(5, 1fr); }
  .key { padding: 0.6rem 0; }
}

@media (prefers-reduced-motion: reduce) {
  #board, .cell, .key, .tool { transition: none; }
}
