:root { --bg: #15171c; --panel: #1f2229; --fg: #f3f3f3; --muted: #9a9a9e; --border: #3a3a40; --accent: #5b8def; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
body { display: flex; flex-direction: column; min-height: 100dvh; }
button { font: inherit; color: inherit; cursor: pointer; }
.top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border); min-height: 52px; }
.top .left, .top .right { display: flex; gap: 8px; align-items: center; }
.top .right { justify-content: flex-end; }
.top h1 { margin: 0; font-size: 20px; letter-spacing: .04em; font-weight: 800; }
.top h1 b { color: var(--accent); }
.icon { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: transparent; font-weight: 700; display: grid; place-items: center; padding: 0; }
.chip { border: 1px solid var(--border); background: var(--panel); border-radius: 999px; padding: 6px 12px; font-size: 13px; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.active, .chip.primary { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--panel)); color: var(--fg); }
main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 8px 8px max(10px, env(safe-area-inset-bottom)); gap: 10px; min-height: 0; }
.toast { position: fixed; top: 150px; left: 50%; transform: translateX(-50%); background: #f3f3f3; color: #121213; font-weight: 700; padding: 10px 16px; border-radius: 6px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 5; }
.toast.show { opacity: 1; }
.dlg { background: var(--panel); color: var(--fg); border: 1px solid var(--border); border-radius: 12px; padding: 20px 22px; width: min(92vw, 420px); }
.dlg::backdrop { background: rgba(0,0,0,.6); }
.dlg h2 { margin: 0 0 10px; }
.dlg p, .dlg li { color: #d6d6d8; font-size: 15px; line-height: 1.45; }
.dlg .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.dlg .big { font-size: 40px; font-weight: 800; text-align: center; margin: 8px 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; margin: 8px 0; }
.stats b { display: block; font-size: 24px; }
.stats span { color: var(--muted); font-size: 12px; }
.hud { display: flex; gap: 14px; justify-content: center; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; flex-wrap: wrap; }
.hud b { color: var(--fg); }
.pad { display: grid; gap: 6px; width: min(100vw - 16px, 520px); user-select: none; }
.pad button { height: 48px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel); font-weight: 700; font-size: 18px; touch-action: manipulation; }
.pad button:active, .pad button.on { background: color-mix(in srgb, var(--accent) 30%, var(--panel)); }

.levels { display: flex; justify-content: center; gap: 6px; padding: 10px 6px 2px; flex-wrap: wrap; }
.lvl { color: var(--muted); }
.lvl.active { color: var(--fg); }
.board { --cell: min(calc((100vw - 16px) / 9), 52px); display: grid; grid-template-columns: repeat(9, var(--cell)); grid-template-rows: repeat(9, var(--cell)); background: var(--border); gap: 1px; border: 2px solid #6b6b75; border-radius: 4px; overflow: hidden; }
.cell { position: relative; display: grid; place-items: center; background: var(--panel); font-size: calc(var(--cell) * 0.52); font-weight: 600; user-select: none; cursor: pointer; }
.cell.given { color: #e6e6ea; background: #262a33; }
.cell:not(.given) { color: var(--accent); }
.cell.c3 { border-right: 2px solid #6b6b75; } .cell.r3 { border-bottom: 2px solid #6b6b75; }
.cell.sel { background: color-mix(in srgb, var(--accent) 38%, var(--panel)) !important; }
.cell.peer { background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }
.cell.same { background: color-mix(in srgb, var(--accent) 24%, var(--panel)); }
.cell.bad { color: #ff5c5c !important; }
.cell.hint { animation: flash .6s ease; }
.cell .notes { position: absolute; inset: 2px; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); font-size: calc(var(--cell) * 0.24); font-weight: 500; color: #b8b8c0; line-height: 1; }
.cell .notes span { display: grid; place-items: center; }
.nums { grid-template-columns: repeat(9, 1fr); }
.nums button { font-size: 22px; height: 46px; position: relative; }
.nums button small { position: absolute; right: 4px; bottom: 2px; font-size: 10px; color: var(--muted); }
.nums button.done { opacity: .3; }
.tools { grid-template-columns: repeat(5, 1fr); }
.tools button { font-size: 13px; height: 42px; }
@keyframes flash { from { background: #fff3; } }
@media (min-width: 700px) { main { padding-top: 16px; } .board { --cell: 52px; } }
