@font-face { font-family: "Nunito"; font-style: normal; font-weight: 300 700; font-display: swap; src: url(fonts/nunito-latin.woff2) format("woff2"); }
:root { --gap-bottom: 40px; } /* the host badge is fixed 10px from the bottom of the layout viewport and ~21px tall */
b, strong, h1, h2, h3, th { font-weight: 600; }
:root {
  --bg: #f6f7fb; --surface: #ffffff; --ink: #1c2233; --muted: #7a8296; --line: #c9cedd; --line-strong: #1c2233;
  --accent: #4f5bd5; --accent-ink: #ffffff; --given: #1c2233; --entered: #3a49c9;
  --sel: #cfd6ff; --peer: #eceffb; --same: #d9ddf7; --hl: #4f5bd5; --hl-ink: #fff; --wrong: #d93a4a; --wrong-bg: #fde4e7;
  --tool: #eceef6; --shadow: 0 10px 40px rgba(20, 25, 50, .25);
  --note: #323a86; --note-hl: #92400a;
}
:root[data-theme="dark"] {
  --bg: #0e1118; --surface: #171b26; --ink: #e8ebf5; --muted: #8b93a8; --line: #2b3144; --line-strong: #8e97b5;
  --accent: #7b86ff; --accent-ink: #0e1118; --given: #e8ebf5; --entered: #8ea0ff;
  --sel: #33407f; --peer: #1d2233; --same: #2a3260; --hl: #7b86ff; --hl-ink: #0e1118; --wrong: #ff6b7b; --wrong-bg: #3b1d25;
  --tool: #1f2433; --shadow: 0 10px 40px rgba(0, 0, 0, .6);
  --note: #c9d0ea; --note-hl: #ffb547;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0e1118; --surface: #171b26; --ink: #e8ebf5; --muted: #8b93a8; --line: #2b3144; --line-strong: #8e97b5;
    --accent: #7b86ff; --accent-ink: #0e1118; --given: #e8ebf5; --entered: #8ea0ff;
    --sel: #33407f; --peer: #1d2233; --same: #2a3260; --hl: #7b86ff; --hl-ink: #0e1118; --wrong: #ff6b7b; --wrong-bg: #3b1d25;
    --tool: #1f2433; --shadow: 0 10px 40px rgba(0, 0, 0, .6);
    --note: #c9d0ea; --note-hl: #ffb547;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overscroll-behavior: none; }
body { font: 400 16px/1.3 ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; overflow: hidden; position: fixed; inset: 0; width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }

#app { height: 100%; height: 100dvh; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 6px) calc(env(safe-area-inset-right) + 12px) var(--gap-bottom) calc(env(safe-area-inset-left) + 12px); background: var(--bg); }
#stack { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.top { display: flex; align-items: center; gap: 2px; min-height: 38px; background: var(--bg); isolation: isolate; }
.titles { flex: 1; text-align: center; min-width: 0; height: 38px; border-radius: 12px; display: grid; place-items: center; text-align: left; justify-items: start; padding: 0 4px; overflow: hidden; }
.titles:active { background: var(--tool); }
.mode { font-weight: 500; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.icon-btn { width: 40px; height: 38px; border-radius: 14px; display: grid; place-items: center; color: var(--ink); }
.icon-btn:active { background: var(--tool); }

.infobar { display: flex; flex: none; align-items: center; gap: 2px; }
.info { display: flex; flex-direction: row; align-items: baseline; min-height: 38px; align-items: center; justify-content: center; gap: 4px; padding: 0 5px; border-radius: 10px; }
.info .k { font-size: 11px; font-weight: 400; color: var(--muted); }
.info .val { font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; }
.timer-btn:active { background: var(--tool); }

#stage { flex: 1; min-height: 0; display: grid; place-items: center; position: relative; }
/* the play stack is always fixed; JS sets --stack-bottom (centered when video mode is off, 40px when on) and slides it */
#stack { position: fixed; left: 0; right: 0; bottom: var(--stack-bottom, 40px); margin: 0 auto; flex: none;
  width: calc(100% - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)); max-width: 560px; }
html.anim #stack { transition: bottom .5s cubic-bezier(.22, .8, .28, 1); }
@media (prefers-reduced-motion: reduce) { html.anim #stack { transition: none; } }
#stage { flex: none; height: var(--bs, 360px); }
#board { display: grid; grid-template-columns: repeat(9, 1fr); grid-template-rows: repeat(9, 1fr);
  width: var(--bs, 340px); height: var(--bs, 340px); background: var(--surface); border: 2px solid var(--line-strong); border-radius: 10px; overflow: hidden;
  font-size: calc(var(--bs, 340px) / 9 * .62); }
.cell { position: relative; display: grid; place-items: center; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); min-width: 0; min-height: 0; }
.cell.c2, .cell.c5 { border-right: 2px solid var(--line-strong); }
.cell.r2, .cell.r5 { border-bottom: 2px solid var(--line-strong); }
.cell.c8 { border-right: 0; } .cell.r8 { border-bottom: 0; }
.cell.peer { background: var(--peer); }
.cell.same { background: var(--same); }
.cell.sel { background: var(--sel); }
.cell .v { line-height: 1; font-weight: 400; color: var(--entered); }
.cell.given .v { color: var(--given); font-weight: 500; }
.cell.wrong { background: var(--wrong-bg); }
.cell.wrong .v { color: var(--wrong); }
.cell .notes { position: absolute; inset: 1px; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  font-size: calc(var(--bs, 340px) / 9 * 0.26); color: var(--note); line-height: 1; font-weight: 600; font-variant-numeric: tabular-nums; }
#app.large-notes .cell .notes { font-size: calc(var(--bs, 340px) / 9 * 0.32); }
.cell .notes i { font-style: normal; display: grid; place-items: center; min-width: 0; min-height: 0; }
.cell.pop .v { animation: pop .22s ease-out; }
.cell.shake { animation: shake .3s; }
@keyframes pop { 0% { transform: scale(.6); } 70% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes shake { 20% { transform: translateX(-3px); } 60% { transform: translateX(3px); } }
#board.solved .cell { animation: win .6s ease-out; }
@keyframes win { 50% { background: var(--sel); } }

.pause { position: absolute; width: var(--bs, 340px); height: var(--bs, 340px); background: var(--surface); border: 2px solid var(--line-strong); border-radius: 10px;
  display: grid; place-items: center; text-align: center; z-index: 3; }
.pause b { display: block; font-size: 24px; font-weight: 500; } .pause span { color: var(--muted); }

.tools { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; padding: 3px 0; }
.tool { min-height: 40px; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11.5px; color: var(--ink); background: var(--tool); }
.tool svg { width: 22px; height: 22px; }
.tool:active { transform: scale(.96); }
.tool[disabled] { opacity: .35; }
.tool em { font-style: normal; font-weight: 600; }
.tool.on { background: var(--accent); color: var(--accent-ink); }
.pad { display: grid; grid-template-columns: repeat(9, 1fr); gap: 5px; }
.num { height: 44px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; box-shadow: 0 1px 0 var(--line); }
.num b { font-size: 28px; font-weight: 400; color: var(--entered); line-height: 1; }
.num small { font-size: 10px; color: var(--muted); margin-top: 2px; }
.num:active { background: var(--sel); }
.num.done { opacity: .28; }
.pad.dim .num { opacity: .4; }
.pad.notes .num b { font-size: 22px; color: var(--muted); }

@media (max-height: 700px) { .num { height: 44px; } .tool span { font-size: 10.5px; } }
@media (max-width: 350px) { .tool span { font-size: 9.5px; } .num b { font-size: 24px; } }
@media (min-width: 600px) and (min-height: 800px) { #app { max-width: 640px; } }

.scrim { position: fixed; inset: 0; background: rgba(8, 10, 20, .5); z-index: 10; }
.sheet { position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: min(100%, 560px); background: var(--surface); z-index: 11;
  border-radius: 22px 22px 0 0; box-shadow: var(--shadow); padding: 8px 18px calc(env(safe-area-inset-bottom) + 16px); max-height: 92dvh; overflow: auto; animation: up .22s ease-out; }
@keyframes up { from { transform: translate(-50%, 40px); opacity: 0; } }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.sheet h2 { margin: 0 0 14px; font-size: 22px; text-align: center; }
.grid-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.grid-btns button { min-height: 62px; border-radius: 16px; background: var(--tool); font-size: 18px; font-weight: 500; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.grid-btns small { font-size: 11px; font-weight: 400; color: var(--muted); }
.grid-btns button:active, .wide:active { filter: brightness(.92); }
.wide { display: flex; width: 100%; min-height: 56px; border-radius: 16px; background: var(--tool); font-size: 17px; font-weight: 500; align-items: center; justify-content: center; margin-top: 10px; padding: 0 16px; }
.wide.primary { background: var(--accent); color: var(--accent-ink); }
.wide.ghost { background: transparent; color: var(--muted); }
.wide.danger { color: var(--wrong); }
.wide.daily { justify-content: space-between; text-align: left; background: var(--accent); color: var(--accent-ink); }
.wide.daily span { display: flex; flex-direction: column; } .wide.daily small { font-weight: 400; opacity: .85; font-size: 12.5px; }
.wide.daily i { font-style: normal; font-size: 13px; background: rgba(255,255,255,.22); border-radius: 10px; padding: 4px 9px; }
.fine { color: var(--muted); font-size: 12.5px; text-align: center; margin: 12px 0 0; min-height: 1em; }
.streaks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.streaks div { background: var(--tool); border-radius: 14px; padding: 12px 6px; text-align: center; }
.streaks b { display: block; font-size: 26px; font-variant-numeric: tabular-nums; } .streaks span { font-size: 11.5px; color: var(--muted); }
.stat-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.stat-table th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 500; text-align: right; padding: 6px 4px; }
.stat-table td { text-align: right; padding: 11px 4px; border-top: 1px solid var(--line); }
.stat-table th:first-child, .stat-table td:first-child { text-align: left; font-weight: 500; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; border-top: 1px solid var(--line); }
.row:first-of-type { border-top: 0; }
.row span { display: flex; flex-direction: column; } .row small { color: var(--muted); font-size: 12px; margin-top: 2px; max-width: 250px; }
.row input[type=checkbox] { appearance: none; -webkit-appearance: none; width: 51px; height: 31px; border-radius: 16px; background: var(--line); position: relative; flex: none; transition: background .15s; }
.row input[type=checkbox]::after { content: ""; position: absolute; left: 2px; top: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.row input[type=checkbox]:checked { background: var(--accent); } .row input[type=checkbox]:checked::after { transform: translateX(20px); }
.seg { display: flex; background: var(--tool); border-radius: 12px; padding: 3px; }
.seg button { padding: 9px 12px; border-radius: 9px; font-size: 14px; min-height: 40px; }
.seg button.on { background: var(--surface); font-weight: 500; box-shadow: 0 1px 3px rgba(0,0,0,.2); }

/* active-digit highlight */
.cell.same { background: var(--same); box-shadow: inset 0 0 0 2px var(--note-hl); }
.cell.same .v, .cell.given.same .v { color: var(--note-hl); font-weight: 700; }
.cell .notes i.hl { background: none; color: var(--note-hl); font-weight: 700; border: 0; border-radius: 0; box-shadow: none; outline: none; transform: none; }
.cell, .num, .tool { touch-action: manipulation; }
.num.active { border-color: var(--note-hl); box-shadow: 0 0 0 2px var(--note-hl); }
.num.active b { color: var(--note-hl) !important; }

/* video-mode button (soft), lock mode */
.vid-btn { color: var(--muted); border-radius: 12px; }
.vid-btn.on { background: var(--sel); color: var(--entered); }
.vid-btn svg { width: 22px; height: 22px; }
.titles::after { content: ""; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid var(--muted); margin-left: 5px; display: inline-block; vertical-align: middle; opacity: .7; }
.titles { grid-auto-flow: column; justify-content: start; align-content: center; }
.tool { font-size: 11px; }
#tLock.armed { outline: 2px dashed var(--entered); outline-offset: -2px; }
.num { position: relative; }
.num .lk { display: none; position: absolute; top: 3px; right: 4px; width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; color: var(--entered); }
.num.locked .lk { display: block; }
.num.locked { background: var(--sel); border-color: var(--entered); box-shadow: 0 0 0 2px var(--entered) inset; }
/* header row budget: video button, title, stats, two icons */
.icon-btn { width: 36px; }
.info { padding: 0 3px; gap: 3px; }
.infobar { gap: 0; }
.titles { flex: 1 0 auto; min-width: 66px; }
.titles::after { margin-left: 4px; }
.num .lk { top: 2px; right: 3px; width: 10px; height: 10px; }
