/* Little Sudoku
   Palette is defined once on :root; the dark block redefines only tokens, so
   nothing can end up painting one theme's text on the other's ground. */
:root {
  --paper:      #FBFCFD;
  --surface:    #FFFFFF;
  --sunk:       #EEF2F6;
  --ink:        #11161D;
  --ink-2:      #46525F;
  --ink-3:      #75828F;
  --line:       #C9D4DE;
  --line-bold:  #2B3642;
  --accent:     #1A5FA8;
  --accent-bg:  #E4EEF9;
  --peer:       #EDF2F7;
  --same:       #D5E5F6;
  --bad:        #B3261E;
  --bad-bg:     #FBEAE8;
  --good:       #0B6B49;
  --hint:       #8A5A06;
  --hint-bg:    #FCF3DF;
  --focus:      #1A5FA8;
  --shadow:     0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --num: ui-rounded, "SF Pro Rounded", ui-sans-serif, system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0E1319; --surface: #161C24; --sunk: #1D242D;
    --ink: #E7EDF4; --ink-2: #AEBAC6; --ink-3: #7E8B98;
    --line: #2C3641; --line-bold: #6C7A88;
    --accent: #6AAEEC; --accent-bg: #14283C;
    --peer: #1B242E; --same: #24384E;
    --bad: #F08878; --bad-bg: #2E1714;
    --good: #5FC79B; --hint: #E0B056; --hint-bg: #2B2109;
    --focus: #6AAEEC;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  --paper: #0E1319; --surface: #161C24; --sunk: #1D242D;
  --ink: #E7EDF4; --ink-2: #AEBAC6; --ink-3: #7E8B98;
  --line: #2C3641; --line-bold: #6C7A88;
  --accent: #6AAEEC; --accent-bg: #14283C;
  --peer: #1B242E; --same: #24384E;
  --bad: #F08878; --bad-bg: #2E1714;
  --good: #5FC79B; --hint: #E0B056; --hint-bg: #2B2109;
  --focus: #6AAEEC;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
/* A class rule with `display` out-specifies the UA stylesheet's
   `[hidden] { display: none }`, which silently un-hides anything toggled via
   the hidden attribute. This has to win. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; overflow-x: hidden; background: var(--paper); color: var(--ink);
  font-family: var(--sans); line-height: 1.55;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.skip {
  position: absolute; left: -9999px; top: 0; background: var(--accent);
  color: #fff; padding: 10px 16px; z-index: 20;
}
.skip:focus { left: 8px; top: 8px; }

.topbar {
  display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand {
  font-weight: 700; text-decoration: none; color: var(--ink);
  display: inline-flex; align-items: center; gap: 8px; font-size: 1.05rem;
}
.brand .mark {
  display: grid; place-items: center; width: 26px; height: 26px;
  border: 2px solid var(--accent); color: var(--accent);
  border-radius: 6px; font-family: var(--num); font-size: .85rem; font-weight: 700;
}
.topbar nav { display: flex; flex-wrap: wrap; gap: 4px; margin-left: auto; min-width: 0; }
.topbar nav a {
  text-decoration: none; color: var(--ink-2); padding: 6px 10px;
  border-radius: 7px; font-size: .88rem;
}
.topbar nav a:hover { background: var(--sunk); }
.topbar nav a[aria-current="page"] { background: var(--accent-bg); color: var(--accent); font-weight: 600; }

main { max-width: 1000px; margin: 0 auto; padding: 20px 16px 48px; }

.meta h1 { font-size: 1.4rem; margin: 0 0 6px; letter-spacing: -.02em; }
.rating {
  display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center;
  margin: 0 0 18px; color: var(--ink-2); font-size: .87rem;
}
.pill {
  background: var(--accent-bg); color: var(--accent); font-weight: 600;
  padding: 3px 10px; border-radius: 999px; font-size: .8rem;
}
.rating .score {
  margin-left: auto; font-family: var(--num); color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.playfield { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
/* min-width:0 on every flex child: the default `auto` means an item refuses to
   shrink below its min-content width, which is how a 9-column table and a
   six-item nav both end up wider than a phone. */
.playfield > * { min-width: 0; }
.board-wrap { position: relative; flex: 1 1 320px; max-width: 560px; }

.board {
  width: 100%; aspect-ratio: 1; border-collapse: collapse; table-layout: fixed;
  background: var(--surface); box-shadow: var(--shadow);
  border: 3px solid var(--line-bold); border-radius: 4px;
  touch-action: manipulation; user-select: none;
}
.board td {
  position: relative; border: 1px solid var(--line); padding: 0;
  text-align: center; vertical-align: middle; cursor: pointer;
}
.board tr:nth-child(3n) td { border-bottom: 2.5px solid var(--line-bold); }
.board tr:last-child td { border-bottom: none; }
.board td:nth-child(3n) { border-right: 2.5px solid var(--line-bold); }
.board td:last-child { border-right: none; }

.cell .val {
  font-family: var(--num); font-size: clamp(1.1rem, 5.2vw, 1.9rem);
  font-weight: 500; color: var(--accent); line-height: 1;
  display: grid; place-items: center; height: 100%;
}
.cell.given .val { color: var(--ink); font-weight: 700; }
.cell .notes {
  position: absolute; inset: 2px; display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  font-size: clamp(.42rem, 1.7vw, .62rem); color: var(--ink-3);
  font-family: var(--num); line-height: 1; pointer-events: none;
}
.cell .notes span { display: grid; place-items: center; }

.cell.peer { background: var(--peer); }
.cell.same { background: var(--same); }
.cell.sel  { background: var(--accent-bg); box-shadow: inset 0 0 0 2px var(--accent); }
/* Conflicts are never signalled by colour alone. */
.cell.bad  { background: var(--bad-bg); }
.cell.bad .val { color: var(--bad); text-decoration: line-through; }
.cell.hl-house { background: var(--hint-bg); }
.cell.hl   { background: var(--hint-bg); box-shadow: inset 0 0 0 2px var(--hint); }
.cell.hl-target { background: var(--hint-bg); box-shadow: inset 0 0 0 3px var(--bad); }
/* Candidate-level marks. A technique hint is unreadable without them. */
.cell .notes .m-on  { color: var(--hint); font-weight: 700; }
.cell .notes .m-off { color: var(--bad); font-weight: 700; text-decoration: line-through; }

.overlay {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(3px); border-radius: 4px;
}
.overlay-card { text-align: center; }
.overlay-card p { font-weight: 600; margin: 0 0 12px; }

.side { flex: 1 1 260px; max-width: 360px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.statline {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--num); font-variant-numeric: tabular-nums; font-size: 1.15rem;
}
.statline .icon {
  margin-left: auto; font-size: .82rem; font-family: var(--sans);
  background: none; border: 1px solid var(--line); color: var(--ink-2);
  padding: 6px 12px; border-radius: 8px; cursor: pointer; min-height: 36px;
}

.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.key {
  position: relative; min-height: 58px; border: 1px solid var(--line);
  background: var(--surface); color: var(--accent); border-radius: 10px;
  font-family: var(--num); font-size: 1.5rem; font-weight: 600;
  cursor: pointer; box-shadow: var(--shadow);
}
.key:hover { background: var(--sunk); }
.key:active { transform: translateY(1px); }
.key.done { color: var(--ink-3); background: var(--sunk); }
.key .left {
  position: absolute; right: 6px; bottom: 3px; font-size: .62rem;
  color: var(--ink-3); font-weight: 500;
}
.key.noting { background: var(--accent-bg); }

.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tool {
  min-height: 46px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); border-radius: 10px; cursor: pointer;
  font-size: .82rem; font-weight: 600; display: grid; place-items: center; gap: 0;
}
.tool:hover { background: var(--sunk); }
.tool .state { font-size: .64rem; font-weight: 500; color: var(--ink-3); text-transform: uppercase; }
.tool[aria-pressed="true"] { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }
.tool[aria-pressed="true"] .state { color: var(--accent); }
.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.primary:hover { background: var(--accent); filter: brightness(1.08); }
button.primary { padding: 10px 18px; border-radius: 10px; font-weight: 600; cursor: pointer; }

.hintbox {
  border: 1px solid var(--hint); background: var(--hint-bg);
  border-radius: 10px; padding: 12px 14px;
}
.hint-tech { margin: 0 0 4px; font-weight: 700; font-size: .9rem; color: var(--hint); }
.hint-text { margin: 0 0 10px; font-size: .88rem; color: var(--ink); }
.hint-actions { display: flex; gap: 8px; }
.hint-actions .tool { min-height: 34px; font-size: .75rem; padding: 0 10px; }

.nojs { font-size: .8rem; color: var(--ink-3); margin: 0; }
body.js .nojs { display: none; }

.prose { margin-top: 40px; max-width: 68ch; color: var(--ink-2); }
.prose h2 { font-size: 1.15rem; color: var(--ink); margin: 0 0 10px; }
.prose h3 { font-size: 1rem; color: var(--ink); margin: 26px 0 8px; }
.prose p { margin: 0 0 14px; }
.bandlist { padding-left: 20px; margin: 0; }
.bandlist li { margin-bottom: 6px; }

footer {
  border-top: 1px solid var(--line); margin-top: 48px; padding: 22px 16px 40px;
  color: var(--ink-3); font-size: .84rem;
}
footer nav { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 10px; }
footer p { margin: 0; max-width: 60ch; }

@media (max-width: 720px) {
  main { padding: 14px 12px 40px; }
  .playfield { gap: 14px; }
  .board-wrap { flex-basis: 100%; max-width: none; }
  .side { flex-basis: 100%; max-width: none; }
  .rating .score { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
