:root {
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --surface-2: #ece7dc;
  --ink: #1d2433;
  --muted: #6d6a63;
  --line: #d3ccbd;
  --line-thick: #1d2433;
  --accent: #2f5bd3;
  --accent-ink: #ffffff;
  --user: #2f5bd3;
  --hint: #7c4dd6;
  --sel: #c9dbff;
  --peer: #ebe5d7;
  --same: #b3cbff;
  --err: #c62828;
  --err-bg: #fbdcdc;
  --gold: #d99a00;
  --gold-soft: #fff1c7;
  --flame: #e4572e;
  --shadow: 0 1px 2px rgba(29,36,51,.06), 0 8px 24px rgba(29,36,51,.08);
  --radius: 14px;
  --digits: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121418; --surface: #1b1e24; --surface-2: #262a32; --ink: #e9e6df; --muted: #9a978f;
    --line: #353a44; --line-thick: #a4acba; --accent: #7aa2ff; --accent-ink: #0e1220;
    --user: #8fb1ff; --hint: #c3a3ff; --sel: #2b3d63; --peer: #20252e; --same: #33497a;
    --err: #ff8080; --err-bg: #43212a; --gold: #ffc23d; --gold-soft: #3a3020; --flame: #ff7a4d;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121418; --surface: #1b1e24; --surface-2: #262a32; --ink: #e9e6df; --muted: #9a978f;
  --line: #353a44; --line-thick: #a4acba; --accent: #7aa2ff; --accent-ink: #0e1220;
  --user: #8fb1ff; --hint: #c3a3ff; --sel: #2b3d63; --peer: #20252e; --same: #33497a;
  --err: #ff8080; --err-bg: #43212a; --gold: #ffc23d; --gold-soft: #3a3020; --flame: #ff7a4d;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.app {
  min-height: 100dvh;
  max-width: 1040px;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  display: flex; flex-direction: column;
}

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; padding: 4px 2px 10px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 22px; letter-spacing: -.02em; margin: 0; font-weight: 750; }
.logo {
  width: 28px; height: 28px; border-radius: 8px; background:
    linear-gradient(var(--ink),var(--ink)) 33% 0/2px 100% no-repeat,
    linear-gradient(var(--ink),var(--ink)) 66% 0/2px 100% no-repeat,
    linear-gradient(var(--ink),var(--ink)) 0 33%/100% 2px no-repeat,
    linear-gradient(var(--ink),var(--ink)) 0 66%/100% 2px no-repeat,
    var(--gold);
  border: 2px solid var(--ink);
}
.top-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent;
  display: grid; place-items: center; color: var(--ink);
}
.icon-btn:hover { background: var(--surface-2); }
.chip.streak {
  display: inline-flex; align-items: center; gap: 4px; height: 36px; padding: 0 12px 0 9px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.chip.streak svg { width: 18px; height: 18px; fill: var(--flame); stroke: none; }
.chip.streak.cold svg { fill: var(--muted); opacity: .6; }
.chip.streak.pending { box-shadow: 0 0 0 3px var(--gold-soft); border-color: var(--gold); }

/* Layout */
.play { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.board-wrap { position: relative; width: var(--board); }
:root { --board: min(calc(100vw - 24px), 520px, calc(100dvh - 330px)); }
@media (max-height: 640px) and (max-width: 819px) { :root { --board: min(calc(100vw - 24px), 520px, calc(100dvh - 290px)); } }
@media (min-width: 820px) {
  :root { --board: min(560px, calc(100dvh - 130px), calc(100vw - 420px)); }
  .play { flex-direction: row; align-items: flex-start; justify-content: center; gap: 36px; padding-top: 8px; }
  .controls { width: 300px; margin-top: 36px; }
  .pad { grid-template-columns: repeat(3, 1fr) !important; }
  .pad button { aspect-ratio: 1.25 !important; font-size: 30px !important; padding-bottom: 8px; }
}

.status {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 14px; color: var(--muted); padding: 0 2px 8px; min-height: 32px;
}
.status .mode { font-weight: 650; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status .mistakes { white-space: nowrap; }
.status .mistakes.has { color: var(--err); }
.timer {
  display: inline-flex; align-items: center; gap: 4px; border: 0; background: var(--surface-2);
  border-radius: 999px; padding: 4px 8px 4px 12px; font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600;
}
.timer svg { width: 16px; height: 16px; }
.timer.hidden-time #timerLabel { display: none; }
.timer.hidden-time { padding: 4px 8px; }

/* Board */
.board {
  container-type: inline-size;
  width: var(--board); aspect-ratio: 1;
  display: grid; grid-template-columns: repeat(9, 1fr); grid-template-rows: repeat(9, 1fr);
  background: var(--surface); border: 2.5px solid var(--line-thick); border-radius: 10px; overflow: hidden;
  box-shadow: var(--shadow); user-select: none; -webkit-user-select: none;
}
.cell {
  position: relative; display: grid; place-items: center;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  font-family: var(--digits); font-size: var(--digit-size); line-height: 1; font-variant-numeric: tabular-nums;
  cursor: pointer; transition: background-color .08s;
}
.cell.c8 { border-right: 0; }
.cell.r8 { border-bottom: 0; }
.cell.bx { border-right: 2px solid var(--line-thick); }
.cell.by { border-bottom: 2px solid var(--line-thick); }
.cell.peer { background: var(--peer); }
.cell.same { background: var(--same); }
.cell.sel { background: var(--sel); box-shadow: inset 0 0 0 2px var(--accent); }
.cell .v { font-weight: 500; }
.cell.given .v { font-weight: 700; color: var(--ink); }
.cell.user .v { color: var(--user); }
.cell.hinted .v { color: var(--hint); }
.cell.err .v { color: var(--err); }
.cell.err { background: var(--err-bg); }
.cell.sel.err { background: var(--err-bg); }
.cell.conflict .v { text-decoration: underline wavy var(--err); text-underline-offset: 18%; text-decoration-thickness: 1.5px; }
.cell .notes {
  position: absolute; inset: 1px 2px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr));
  font-family: var(--ui); font-size: var(--note-size); line-height: .85; color: var(--note-ink); font-weight: 700;
}
.cell .notes span { display: grid; place-items: center; border-radius: 3px; min-width: 0; min-height: 0; overflow: hidden; }
.cell .notes span.hl { background: var(--accent); color: var(--accent-ink); }
.cell.pop .v { animation: pop .22s ease-out; }
.cell.flash { animation: flash .6s ease-out; }
@keyframes pop { from { transform: scale(.6); opacity: .3; } to { transform: scale(1); opacity: 1; } }
@keyframes flash { 0% { background: var(--gold-soft); } 100% { } }
.board.won .cell { animation: wave .5s ease-out both; animation-delay: calc(var(--d) * 18ms); }
@keyframes wave { 40% { background: var(--gold-soft); } }

.paused, .busy {
  position: absolute; left: 0; right: 0; bottom: 0; top: 40px; height: var(--board);
  display: grid; place-content: center; justify-items: center; gap: 12px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px);
  border-radius: 10px; border: 2.5px solid var(--line-thick);
}
.paused[hidden], .busy[hidden] { display: none; }
.paused p { margin: 0; font-size: 22px; font-weight: 700; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Controls */
.controls { width: var(--board); display: flex; flex-direction: column; gap: 12px; }
.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.tool {
  position: relative; border: 0; background: transparent; border-radius: 12px; padding: 6px 0;
  display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 12px; color: var(--muted); font-weight: 600;
}
.tool svg { width: 24px; height: 24px; color: var(--ink); }
.tool:hover { background: var(--surface-2); }
.tool:disabled { opacity: .35; cursor: default; }
.tool .flag {
  position: absolute; top: 0; left: 55%; font-style: normal; font-size: 9px; font-weight: 800; letter-spacing: .02em;
  background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: 1px 5px; border: 1.5px solid var(--bg);
}
.tool[aria-pressed="true"] { color: var(--accent); }
.tool[aria-pressed="true"] svg { color: var(--accent); }
.tool[aria-pressed="true"] .flag { background: var(--accent); color: var(--accent-ink); }

.pad { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 5px; }
.pad button {
  position: relative; border: 0; border-radius: 10px; background: var(--surface); box-shadow: var(--shadow);
  aspect-ratio: .72; padding: 0 0 12px; font-family: var(--digits); font-size: clamp(22px, 7.2vw, 34px); color: var(--user); font-weight: 600;
  display: grid; place-items: center; transition: transform .06s;
}
.pad button:active { transform: scale(.94); }
.pad button small { position: absolute; bottom: 3px; font-size: 10px; color: var(--muted); font-family: var(--ui); font-weight: 600; }
.pad button.done { opacity: .28; }
.pad.notes button { color: var(--muted); font-size: clamp(16px, 5vw, 24px); padding-bottom: 0; }
.pad.notes button small { display: none; }

/* Sheets / dialogs */
dialog.sheet {
  border: 0; border-radius: 20px; padding: 20px; width: min(420px, calc(100vw - 24px));
  background: var(--surface); color: var(--ink); box-shadow: 0 24px 80px rgba(0,0,0,.35);
  max-height: calc(100dvh - 32px); overflow: auto;
}
dialog.sheet.wide { width: min(560px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(10, 12, 18, .45); backdrop-filter: blur(2px); }
dialog[open] { animation: rise .2s ease-out; }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
.sheet h2 { margin: 0 0 14px; font-size: 20px; letter-spacing: -.01em; }
.sheet h3 { margin: 20px 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sheet-head h2 { margin: 0; }
.fine { font-size: 12.5px; color: var(--muted); margin: 10px 0; line-height: 1.4; }
.fine:empty { display: none; }

#dlgNew form { display: flex; flex-direction: column; gap: 10px; }
.daily-card {
  text-align: left; border: 0; border-radius: 14px; padding: 14px 16px;
  background: linear-gradient(135deg, var(--gold-soft), var(--surface-2)); display: flex; flex-direction: column; gap: 2px;
  box-shadow: inset 0 0 0 1.5px var(--gold);
}
.dc-title { font-weight: 750; font-size: 16px; }
.dc-sub { color: var(--muted); font-size: 13px; }
.levels { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.levels button, .ghost, .primary, .danger {
  border: 0; border-radius: 12px; padding: 13px 14px; font-weight: 650; background: var(--surface-2);
}
.levels button:hover, .ghost:hover { filter: brightness(.97); }
.ghost { background: transparent; color: var(--muted); }
.primary { background: var(--accent); color: var(--accent-ink); }
.danger { background: transparent; color: var(--err); width: 100%; margin-top: 6px; }

.toggle { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); gap: 12px; }
.toggle input {
  appearance: none; width: 44px; height: 26px; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; flex: none; transition: background .15s; margin: 0;
}
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.toggle input:checked { background: var(--accent); }
.toggle input:checked::after { transform: translateX(18px); }
.seg-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* Progress */
.today {
  border-radius: 16px; padding: 16px; margin: 8px 0 14px; display: flex; align-items: center; gap: 14px;
  background: linear-gradient(135deg, var(--gold-soft), var(--surface-2));
}
.today .t-main { flex: 1; min-width: 0; }
.today .t-title { font-weight: 750; font-size: 16px; }
.today .t-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.today .primary { padding: 10px 16px; white-space: nowrap; }
.stars { display: inline-flex; gap: 2px; }
.stars svg { width: 20px; height: 20px; stroke: none; fill: var(--line); }
.stars svg.on { fill: var(--gold); }
.streak-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.streak-row div { background: var(--surface-2); border-radius: 12px; padding: 10px 4px; }
.streak-row strong { display: block; font-size: 24px; font-variant-numeric: tabular-nums; }
.streak-row span { font-size: 11.5px; color: var(--muted); }
.cal { margin-top: 14px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; font-weight: 700; }
.cal-head .icon-btn:disabled { opacity: .25; cursor: default; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin-top: 6px; }
.cal-grid .dow { font-size: 11px; color: var(--muted); text-align: center; font-weight: 700; padding: 2px 0; }
.cal-grid .day {
  aspect-ratio: 1; min-width: 0; border: 0; border-radius: 10px; background: var(--surface-2); position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: 12px; font-weight: 650; padding: 0;
}
.cal-grid .day.empty { background: transparent; pointer-events: none; }
.cal-grid .day.future { opacity: .35; pointer-events: none; }
.cal-grid .day.is-today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-grid .day.done { background: var(--gold-soft); }
.cal-grid .day.started::after { content: ""; position: absolute; top: 5px; right: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.cal-grid .day .mini { display: flex; gap: 0; position: absolute; bottom: 12%; left: 0; right: 0; justify-content: center; }
.cal-grid .day .mini svg { width: 9px; height: 9px; fill: var(--line); stroke: none; }
.cal-grid .day .mini svg.on { fill: var(--gold); }
.cal-grid .day.late .mini svg.on { fill: color-mix(in srgb, var(--gold) 55%, var(--muted)); }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.badge { border-radius: 14px; padding: 12px 10px; background: var(--surface-2); text-align: center; }
.badge .b-ico { font-size: 28px; line-height: 1; filter: grayscale(1); opacity: .35; }
.badge.got .b-ico { filter: none; opacity: 1; }
.badge.got { background: var(--gold-soft); }
.badge .b-name { font-weight: 700; font-size: 13px; margin-top: 6px; }
.badge .b-desc { font-size: 11px; color: var(--muted); margin-top: 2px; line-height: 1.3; }
.stats { display: grid; grid-template-columns: auto repeat(3, 1fr); gap: 0; font-size: 13px; }
.stats > div { padding: 8px 6px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.stats > .h { font-weight: 700; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; }
.stats > .l { font-weight: 650; }

/* Win */
.win { text-align: center; padding: 6px 4px; }
.win h2 { font-size: 26px; margin: 8px 0 4px; }
.win p { color: var(--muted); margin: 0 0 14px; }
.win-stars { display: flex; justify-content: center; gap: 6px; min-height: 8px; }
.win-stars svg { width: 44px; height: 44px; stroke: none; fill: var(--line); }
.win-stars svg.on { fill: var(--gold); animation: starpop .45s cubic-bezier(.3,1.6,.5,1) both; }
.win-stars svg:nth-child(2) { animation-delay: .15s; transform: translateY(-8px); }
.win-stars svg:nth-child(3) { animation-delay: .3s; }
@keyframes starpop { from { transform: scale(0) rotate(-40deg); } }
.win-badges { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.win-badges:empty { display: none; }
.win-badges .nb { display: flex; align-items: center; gap: 10px; text-align: left; background: var(--gold-soft); border-radius: 12px; padding: 10px 12px; font-size: 13px; }
.win-badges .nb b { display: block; font-size: 14px; }
.win-badges .nb .b-ico { font-size: 26px; }
.win-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1000; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------------------------------------------------------------
   Readability (v2): bigger numbers and notes, size setting,
   phone layout that uses the full screen height.
   --------------------------------------------------------------- */
:root { --digit-size: 7.6cqw; --note-size: 3.4cqw; --note-ink: #3f3c36; }
:root[data-size="large"] { --digit-size: 8.6cqw; --note-size: 3.95cqw; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --note-ink: #d2cec5; } }
:root[data-theme="dark"] { --note-ink: #d2cec5; }

.status { font-size: 15px; }
.tool { font-size: 13px; }
.tool svg { width: 26px; height: 26px; }
.pad .erase-key { display: none; }
.pad .erase-key svg { width: 30px; height: 30px; }

@media (max-width: 819px) {
  .app { padding-left: max(6px, env(safe-area-inset-left)); padding-right: max(6px, env(safe-area-inset-right)); padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  :root { --board: min(calc(100vw - 12px), 560px, calc(100dvh - 300px)); }
  .top { padding-bottom: 6px; }
  .play { gap: 10px; }
  .status { padding-bottom: 6px; }
  .controls { flex: 1; gap: 8px; min-height: 0; }
  .tools { grid-template-columns: repeat(3, 1fr); }
  #btnErase { display: none; }
  /* Two rows of five big keys: 1-5 / 6-9 + erase, stretched into the spare space */
  .pad {
    flex: 1; grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-auto-rows: minmax(52px, 1fr); max-height: 200px; gap: 8px;
  }
  .pad button { aspect-ratio: auto; font-size: clamp(30px, 9vw, 40px); padding: 0 0 10px; border-radius: 14px; }
  .pad button small { font-size: 12px; bottom: 5px; }
  .pad .erase-key { display: grid; color: var(--ink); padding-bottom: 0; }
  .pad.notes button { color: var(--note-ink); font-size: clamp(24px, 7vw, 32px); }
  .pad.notes .erase-key { color: var(--ink); }
  .status .mode .date { display: none; }
}
@media (min-width: 431px) and (max-width: 819px) { .status .mode .date { display: inline; } }

/* ---------------------------------------------------------------
   Teaching hints (v5)
   --------------------------------------------------------------- */
:root { --hint-unit: #fff3cf; --hint-pattern: #2f8f5b; --strike: #d32f2f; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --hint-unit: #3a3220; --hint-pattern: #5fd39a; --strike: #ff7a7a; } }
:root[data-theme="dark"] { --hint-unit: #3a3220; --hint-pattern: #5fd39a; --strike: #ff7a7a; }

.hint-btn svg { width: 24px; height: 24px; }
.tools { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 819px) { .tools { grid-template-columns: repeat(2, 1fr); } }

/* While a hint is open the panel replaces the tools and number pad */
.hint-panel {
  flex: 1; display: flex; flex-direction: column; gap: 10px; min-height: 0;
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); padding: 14px 16px;
  border: 1.5px solid var(--gold);
}
.hint-panel[hidden] { display: none; }
body.hinting .tools, body.hinting .pad { display: none; }
.hp-head { display: flex; align-items: center; gap: 10px; }
.hp-ico { font-size: 26px; line-height: 1; }
.hp-tech { font-weight: 750; font-size: 18px; }
.hp-level { font-size: 13px; color: var(--muted); }
.hp-level:empty { display: none; }
.hp-body { flex: 1; min-height: 0; overflow: auto; font-size: 16px; line-height: 1.45; }
.hp-body p { margin: 0 0 8px; }
.hp-actions { display: flex; gap: 8px; }
.hp-actions button { flex: 1; font-size: 17px; padding: 14px; }
.hp-actions button[hidden] { display: none; }
.hp-actions .primary.bad { background: var(--err); color: #fff; }
@media (min-width: 820px) { .hint-panel { flex: none; max-height: calc(100dvh - 160px); } }

/* Board highlights during a hint */
.cell.hint-unit { background: var(--hint-unit); }
.cell.hint-pattern { box-shadow: inset 0 0 0 2.5px var(--hint-pattern); }
.cell.hint-target { background: var(--gold-soft); box-shadow: inset 0 0 0 3px var(--gold); }
.cell.hint-bad { background: var(--err-bg); box-shadow: inset 0 0 0 3px var(--err); }
.cell .notes span.gcand { color: var(--hint-pattern); }
.cell .notes span.strike { color: var(--strike); text-decoration: line-through; text-decoration-thickness: 2px; }


.busy p { margin: 0; font-weight: 650; color: var(--muted); }

/* ---------------------------------------------------------------
   Selected-number visibility (v6)
   A pencil mark matching the selected number tints its whole square,
   the matching mark is large and bold, and the other marks fade back.
   --------------------------------------------------------------- */
:root { --match-bg: var(--sel); --match-ink: #1d2433; --same: #8fb0ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --match-bg: var(--sel); --match-ink: #ffffff; --same: #3d5ea8; } }
:root[data-theme="dark"] { --match-bg: var(--sel); --match-ink: #ffffff; --same: #3d5ea8; }

.cell.same .v { font-weight: 800; }
.cell.note-match { background: var(--match-bg); }
.cell.note-match.peer { background: var(--match-bg); }
.cell.note-match .notes span { opacity: .35; }
.cell .notes span.hl {
  background: none; color: var(--match-ink); opacity: 1;
  font-weight: 900; transform: scale(1.35); z-index: 1;
}

/* App name + version (v8) */
.brand h1 { display: flex; align-items: baseline; gap: 5px; white-space: nowrap; }
.brand h1 .ver { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
@media (max-width: 380px) { .brand h1 { font-size: 20px; } .brand { gap: 8px; } }
@media (max-width: 430px) {
  .top-actions { gap: 0; }
  .top-actions .icon-btn { width: 36px; }
  .chip.streak { height: 32px; padding: 0 10px 0 7px; margin-right: 2px; }
  .brand { gap: 7px; }
  .logo { width: 24px; height: 24px; border-radius: 7px; }
  .brand h1 { font-size: 19px; gap: 3px; }
}

/* Wing pivot (v9) */
:root { --pivot: #7c3aed; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --pivot: #c4a1ff; } }
:root[data-theme="dark"] { --pivot: #c4a1ff; }
.cell.hint-pivot { box-shadow: inset 0 0 0 3px var(--pivot); }
.cell.hint-pivot .notes span.gcand { color: var(--pivot); }
