/* Sudoku — clean, high-contrast, senior-friendly, mobile-first. No frameworks. */
:root {
  --bg: #f4f1ea; --panel: #fffdf7; --ink: #1f2430; --line: #2b2f3a;
  --thin: #b9c0cc; --accent: #2563eb; --accent-soft: #dbe6ff;
  --given: #1f2430; --user: #2563eb; --bad: #dc2626; --bad-soft: #fde2e2;
  --peer: #efeee8; --same: #fff0c2; --ok: #15803d;
  --pad: #eef1f6; --radius: 12px; --cell: clamp(30px, 9.8vw, 58px);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}
.wrap { max-width: 620px; margin: 0 auto; padding: 14px 14px 40px; }

header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
header h1 { font-size: 1.5rem; margin: 0; letter-spacing: .5px; }
header .sub { flex: 1 1 100%; color: #6b7280; font-size: .92rem; margin: 2px 0 8px; }
.spacer { flex: 1; }
.iconbtn {
  border: 1px solid var(--thin); background: var(--panel); color: var(--ink);
  border-radius: 999px; padding: 8px 14px; font-size: .95rem; cursor: pointer;
  min-height: 40px;
}
.iconbtn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.toolbar { display: flex; align-items: center; gap: 10px; margin: 8px 0 12px; flex-wrap: wrap; }
.toolbar select, .toolbar button {
  min-height: 44px; border-radius: 10px; border: 1px solid var(--thin);
  background: var(--panel); color: var(--ink); font-size: 1rem; padding: 0 14px; cursor: pointer;
}
#newBtn { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.meta { margin-left: auto; display: flex; gap: 16px; font-variant-numeric: tabular-nums; }
.meta b { font-weight: 700; }

/* board */
.board {
  display: grid; grid-template-columns: repeat(9, var(--cell));
  grid-template-rows: repeat(9, var(--cell)); gap: 0;
  width: calc(var(--cell) * 9); margin: 0 auto;
  background: var(--panel); border: 3px solid var(--line);
  touch-action: manipulation; user-select: none;
}
.cell {
  position: relative; display: flex; align-items: center; justify-content: center;
  border-right: 1px solid var(--thin); border-bottom: 1px solid var(--thin);
  font-size: calc(var(--cell) * .58); font-weight: 600; color: var(--user);
  cursor: pointer; background: transparent;
}
.cell.given { color: var(--given); font-weight: 800; }
.cell.peer { background: var(--peer); }
.cell.same { background: var(--same); }
.cell.sel { background: var(--accent-soft); box-shadow: inset 0 0 0 3px var(--accent); }
.cell.bad { color: var(--bad); background: var(--bad-soft); }
/* thick 3x3 separators (set per-cell in JS) */
.cell.cr { border-right: 3px solid var(--line); }
.cell.rb { border-bottom: 3px solid var(--line); }

.notes {
  position: absolute; inset: 2px; display: grid;
  grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  font-size: calc(var(--cell) * .26); color: #8a8f9a; font-weight: 500;
}
.notes span { display: flex; align-items: center; justify-content: center; }

/* number pad */
.pad { display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px; margin: 14px auto 8px;
  max-width: calc(var(--cell) * 9); }
.num {
  min-height: 52px; border-radius: 10px; border: 1px solid var(--thin);
  background: var(--panel); color: var(--accent); font-size: 1.5rem; font-weight: 700; cursor: pointer;
}
.num.done { color: var(--thin); background: #f6f5f0; }
.num:active { background: var(--accent-soft); }

.actions { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; max-width: calc(var(--cell) * 9);
  margin: 0 auto; }
.actions button {
  min-height: 48px; border-radius: 10px; border: 1px solid var(--thin);
  background: var(--panel); color: var(--ink); font-size: .92rem; cursor: pointer; padding: 4px;
}
.actions button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.status { text-align: center; min-height: 26px; margin: 12px 0; font-weight: 600; }
.status.ok { color: var(--ok); }
.status.err { color: var(--bad); }

/* large-print mode: bigger everything */
body.large { --cell: clamp(34px, 11vw, 68px); }
body.large .num { min-height: 60px; font-size: 1.7rem; }
body.large .actions button { min-height: 54px; font-size: 1rem; }

/* book cross-promo */
.book { background: var(--panel); border: 1px solid var(--thin); border-radius: var(--radius);
  padding: 16px; margin: 22px 0 14px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.book h3 { margin: 0 0 4px; font-size: 1.05rem; }
.book p { margin: 0; color: #555; font-size: .92rem; }
.book .grid-ico { width: 54px; height: 54px; flex: none; border: 2px solid var(--line); border-radius: 8px;
  background:
    linear-gradient(var(--line),var(--line)) 0 33%/100% 2px no-repeat,
    linear-gradient(var(--line),var(--line)) 0 66%/100% 2px no-repeat,
    linear-gradient(var(--line),var(--line)) 33% 0/2px 100% no-repeat,
    linear-gradient(var(--line),var(--line)) 66% 0/2px 100% no-repeat; }

footer { text-align: center; color: #8a8f9a; font-size: .82rem; margin-top: 18px; }
footer .links a { color: #6b7280; text-decoration: none; margin: 0 6px; }
footer .links a:hover { text-decoration: underline; }
.privacy { margin-top: 6px; }

/* print: only the board + header line, clean B&W */
@media print {
  body { background: #fff; }
  .toolbar, .pad, .actions, .book, footer, header .sub, #langBtn, #largeBtn, .meta, .status { display: none !important; }
  .wrap { max-width: none; }
  header h1 { text-align: center; }
  .board { --cell: 56px; border-color: #000; }
  .cell { color: #000 !important; border-color: #888 !important; }
  .cell.given { color: #000 !important; }
  .cell.cr { border-right: 3px solid #000 !important; }
  .cell.rb { border-bottom: 3px solid #000 !important; }
  .cell.sel, .cell.peer, .cell.same, .cell.bad { background: #fff !important; box-shadow: none !important; }
  .notes { display: none; }
}

@media (max-width: 420px) {
  .actions { grid-template-columns: repeat(3, 1fr); }
  header h1 { font-size: 1.3rem; }
}
