:root {
  --bg: #f4efe6; --card: #fffdf8; --ink: #1f1a14; --muted: #6b625a; --line: #d9d0c3;
  --accent: #2f6f5e; --accent-ink: #ffffff; --joker: #b8862b; --sel: #2f6f5e; --low: #a1522d;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17140f; --card: #211d17; --ink: #efe8dc; --muted: #a79d90; --line: #3a332a;
    --accent: #6fb39d; --accent-ink: #10201a; --joker: #d9a441; --sel: #6fb39d; --low: #d68a5a;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.top { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 16px; max-width: 560px; margin: 0 auto; }
.brand { font-weight: 800; font-size: 22px; text-decoration: none; color: var(--ink); }
.brand span { color: var(--accent); }
.seq { color: var(--muted); }
main { max-width: 560px; margin: 0 auto; padding: 0 16px 32px; }
.screen { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px 16px; }
h2 { margin: 0 0 8px; font-size: 22px; }
label { display: block; margin: 12px 0; font-weight: 600; }
input, select { display: block; width: 100%; margin-top: 6px; padding: 12px; font: inherit; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); min-height: 48px; }
.btn { display: inline-block; min-height: 48px; padding: 12px 18px; font: inherit; font-weight: 700; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 40px; padding: 8px 12px; }
.btn.big-btn { flex: 1; padding: 20px 12px; font-size: 18px; }
.btn.active, .btn.sel, .tile.sel { outline: 3px solid var(--sel); outline-offset: -3px; }
.row { display: flex; gap: 10px; margin: 12px 0; flex-wrap: wrap; }
.row .btn { flex: 1; }
.fine { color: var(--muted); font-size: 14px; }
.err { color: var(--low); font-weight: 600; min-height: 1.2em; margin: 6px 0; }
.msg { min-height: 1.4em; font-weight: 600; }
.big { font-size: 28px; font-weight: 800; margin: 6px 0 14px; }
.rules { padding-left: 20px; margin: 8px 0 16px; }
.timer { position: relative; height: 14px; background: var(--line); border-radius: 7px; margin: 28px 0 16px; overflow: visible; }
.bar { height: 100%; width: 100%; border-radius: 7px; background: var(--accent); transition: width 0.1s linear; }
.bar.low { background: var(--low); }
.time { position: absolute; right: 0; top: -26px; font-size: 14px; color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0; }
.tile { min-height: 60px; font-size: 26px; font-weight: 800; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer; text-transform: uppercase; }
.tile.joker { border-color: var(--joker); box-shadow: inset 0 0 0 2px var(--joker); }
.tiles.nums { grid-template-columns: repeat(3, 1fr); }
.tile.num { text-transform: none; }
.ops { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.op { min-height: 52px; font-size: 24px; }
.target { font-size: 18px; margin: 0; }
.target b { font-size: 34px; margin-left: 8px; }
.expr { min-height: 1.4em; color: var(--muted); font-size: 15px; }
.breakdown dt { font-weight: 700; margin-top: 10px; }
.breakdown dd { margin: 2px 0 0; }
.board { list-style: none; padding: 0; margin: 12px 0; counter-reset: n; }
.board li { display: flex; gap: 10px; align-items: baseline; padding: 10px 4px; border-bottom: 1px solid var(--line); counter-increment: n; }
.board li::before { content: counter(n) "."; width: 28px; color: var(--muted); font-weight: 700; }
.board .nick { flex: 1; font-weight: 600; }
.board .prov { color: var(--muted); font-size: 14px; }
footer { text-align: center; padding: 16px; }
@media (prefers-reduced-motion: reduce) { .bar { transition: none; } }
