:root {
  --bg: #f3f7f4; --card: #fff; --ink: #14201a; --muted: #6b7a72; --line: #dce6df;
  --accent: #1f7a4d; --accent-ink: #fff; --soft: #e1f2e8; --ok: #1f8f4e; --bad: #c92a2a; --okbg: #dff3e6; --badbg: #fbe3e3;
  --red: #d6212f; --blk: #14201a; --warn: #b7791f;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1612; --card: #17231c; --ink: #eaf3ed; --muted: #94a69b; --line: #2a3a31;
    --accent: #4cc38a; --accent-ink: #07130c; --soft: #1d3327; --ok: #5fd68e; --bad: #ff7a7a; --okbg: #17382a; --badbg: #3d2020;
    --warn: #e8b04b;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  margin: 0; color: var(--ink); background: var(--bg);
  font: 17px/1.45 -apple-system, system-ui, sans-serif;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
}
main { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; padding-bottom: 8px; }
h1 { margin: 0; font-size: 24px; line-height: 1.15; flex: 1; }
h2 { margin: 14px 0 4px; font-size: 19px; }
h3 { margin: 12px 0 4px; font-size: 16px; }
p { margin: 6px 0; }
button { font: inherit; color: inherit; }
.muted { color: var(--muted); } .small { font-size: 14px; } .center { text-align: center; } .grow { flex: 1; }
small { color: var(--muted); font-size: 13px; }

.head { display: flex; align-items: center; gap: 8px; min-height: 48px; min-width: 0; }
.head h1 { min-width: 0; font-size: 21px; }
.head .chip { flex: none; }
.back { width: 44px; height: 44px; border: 0; background: var(--card); border-radius: 12px; font-size: 30px; line-height: 1; padding: 0 0 4px; color: var(--accent); }
.chip { min-height: 44px; padding: 0 16px; border: 1px solid var(--line); background: var(--card); border-radius: 22px; font-weight: 600; color: var(--accent); }
.link { background: none; border: 0; color: var(--accent); font-weight: 600; min-height: 44px; padding: 0 4px; text-decoration: underline; }
.link.danger { color: var(--bad); justify-self: center; margin: 8px 0 20px; }
.icon-btn { min-width: 44px; min-height: 44px; border: 0; background: none; font-size: 18px; color: var(--muted); }
.hint { display: flex; align-items: center; gap: 8px; background: var(--soft); border-radius: 14px; padding: 4px 4px 4px 14px; font-size: 15px; }
.hint span { flex: 1; }

.card { background: var(--card); border-radius: 18px; padding: 14px 16px; box-shadow: 0 1px 0 var(--line); }

/* home */
.mods { display: grid; gap: 12px; }
.mod { background: var(--card); border-radius: 18px; padding: 6px 6px 12px; box-shadow: 0 1px 0 var(--line); }
.mod.locked { opacity: .85; }
.mod-main { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; background: none; border: 0; text-align: left; padding: 8px 10px; }
.mod-main:disabled { color: inherit; }
.num { flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; font-size: 20px; }
.locked .num { background: var(--line); font-size: 18px; }
.mt { flex: 1; display: grid; gap: 1px; } .mt b { font-size: 18px; line-height: 1.2; } .mt small { font-size: 14px; }
.chev { font-size: 28px; color: var(--muted); }
.mod-prog { padding: 0 12px; display: grid; gap: 4px; }
.bar-track { position: relative; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar-fill { height: 100%; background: var(--warn); border-radius: 4px; transition: width .3s; }
.bar-fill.good { background: var(--ok); }
.goal { position: absolute; left: 80%; top: 0; bottom: 0; width: 2px; background: var(--ink); opacity: .5; }

/* quiz */
.strip { display: flex; align-items: center; gap: 12px; }
.streak { font-weight: 800; font-size: 18px; min-width: 52px; }
.strip .grow { display: grid; gap: 3px; }
.focus { font-size: 14px; background: var(--soft); border-radius: 12px; padding: 2px 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.q { display: grid; gap: 6px; }
.qtag { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.q p { font-size: 18px; }
.spot { display: grid; gap: 3px; margin: 4px 0; }
.spot .k { font-size: 14px; color: var(--muted); font-weight: 600; }
.cards { display: inline-flex; gap: 5px; flex-wrap: wrap; }
.pc { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; width: 44px; height: 60px; border-radius: 8px; background: #fff; border: 1px solid #c9d3cc; box-shadow: 0 1px 2px rgba(0,0,0,.18); line-height: 1; font-weight: 800; }
.pc b { font-size: 22px; } .pc i { font-style: normal; font-size: 22px; margin-top: 2px; }
.pc.red, .red { color: var(--red); }
.pc.blk { color: #14201a; }
.blk { color: var(--blk); }
@media (prefers-color-scheme: dark) { .blk, .cgrid .blk, .steps .blk { color: #eaf3ed; } .pc.blk { color: #14201a; } .red { color: #ff6b78; } .pc.red { color: #d6212f; } }
.range { display: grid; gap: 6px; background: var(--bg); border-radius: 12px; padding: 8px 12px; font-size: 17px; }
.tag { font-style: normal; font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 10px; text-transform: uppercase; letter-spacing: .04em; }
.tag.value { background: var(--badbg); color: var(--bad); } .tag.bluff { background: var(--okbg); color: var(--ok); }

.field { display: grid; gap: 4px; margin-top: 8px; }
.field label { font-weight: 600; font-size: 15px; }
.inwrap { display: flex; align-items: center; gap: 6px; background: var(--bg); border: 2px solid var(--line); border-radius: 14px; padding: 0 12px; min-height: 52px; }
.inwrap:focus-within { border-color: var(--accent); }
.inwrap input { flex: 1; min-width: 0; border: 0; background: none; color: var(--ink); font: inherit; font-size: 22px; font-weight: 700; min-height: 48px; outline: none; font-variant-numeric: tabular-nums; }
.unit { font-size: 20px; font-weight: 700; color: var(--muted); }
.sign { min-width: 44px; min-height: 44px; border: 0; border-radius: 10px; background: var(--card); font-size: 22px; font-weight: 700; color: var(--accent); }
.field.ok .inwrap { border-color: var(--ok); background: var(--okbg); }
.field.bad .inwrap { border-color: var(--bad); background: var(--badbg); }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.choice { min-height: 56px; border-radius: 14px; border: 2px solid var(--line); background: var(--bg); font-size: 18px; font-weight: 700; padding: 6px 10px; }
.choice.picked { border-color: var(--accent); background: var(--soft); }
.choice.right { border-color: var(--ok); background: var(--okbg); color: var(--ink); }
.choice.wrong { border-color: var(--bad); background: var(--badbg); color: var(--ink); }
.choice:disabled { color: var(--ink); }

.dock { position: sticky; bottom: 0; padding: 10px 0 max(12px, env(safe-area-inset-bottom)); background: linear-gradient(to bottom, transparent, var(--bg) 24%); }
.dock-note { margin: 0; }
.primary { width: 100%; min-height: 56px; border: 0; border-radius: 16px; background: var(--accent); color: var(--accent-ink); font-size: 19px; font-weight: 800; }
.primary:disabled { opacity: .35; }

.result { border-radius: 16px; padding: 12px 16px; font-size: 18px; }
.result.ok { background: var(--okbg); color: var(--ok); } .result.bad { background: var(--badbg); color: var(--bad); }
.parts { margin: 6px 0 0; padding: 0; list-style: none; font-size: 16px; display: grid; gap: 2px; }
.parts .ok { color: var(--ok); } .parts .bad { color: var(--bad); }
.unlock { margin: 8px 0 0; color: var(--ink); font-weight: 700; }
.solution h3 { margin: 0 0 6px; }
.steps { margin: 6px 0; padding-left: 22px; display: grid; gap: 8px; }
.steps li::marker { font-weight: 800; color: var(--accent); }
.note { background: var(--bg); border-radius: 10px; padding: 8px 12px; font-size: 16px; }
.answer-line { font-weight: 800; font-size: 18px; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 10px; }
.lbl { font-weight: 700; margin: 12px 0 2px; }
.hand-line { margin: 6px 0; padding: 6px 0; border-top: 1px dashed var(--line); font-weight: 400; }
details summary { min-height: 44px; display: flex; align-items: center; color: var(--accent); font-weight: 600; cursor: pointer; }

/* lesson */
.lesson h2:first-child { margin-top: 0; }
.formula { background: var(--soft); border-radius: 12px; padding: 10px 14px; font-weight: 700; margin: 8px 0; }
.example { background: var(--bg); border-radius: 12px; padding: 10px 14px; margin: 8px 0; }
.tbl { width: 100%; border-collapse: collapse; margin: 6px 0; }
.tbl td { padding: 10px 4px; border-bottom: 1px solid var(--line); min-height: 44px; } .tbl td:last-child { text-align: right; }

/* combo grid: rows = suits of rank 1, columns = suits of rank 2 */
.cgrid { display: grid; grid-template-columns: 50px repeat(4, 1fr); gap: 4px; margin: 8px 0 4px; font-variant-numeric: tabular-nums; }
.gh { min-height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 800; font-size: 18px; border-radius: 8px; line-height: 1.1; }
.gh small { font-size: 11px; font-weight: 600; }
.gh.dead { background: var(--badbg); text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: var(--bad); }
.gh.dead small { text-decoration: none; color: var(--bad); }
.gc { min-height: 48px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; position: relative; border: 2px solid transparent; letter-spacing: -.02em; }
.gc.v { background: var(--okbg); border-color: var(--ok); }
.gc.b { background: var(--badbg); }
.gc.o { background: var(--bg); opacity: .55; }
.gc.u { background: repeating-linear-gradient(135deg, var(--bg) 0 5px, transparent 5px 10px); }
/* a dead row is struck through horizontally, a dead column vertically */
.gc.xr::before, .gc.xc::after { content: ''; position: absolute; background: var(--bad); }
.gc.xr::before { left: 0; right: 0; top: calc(50% - 1px); height: 2px; }
.gc.xc::after { top: 0; bottom: 0; left: calc(50% - 1px); width: 2px; }
.glegend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.glegend span { display: inline-flex; align-items: center; gap: 5px; }
.sw { width: 14px; height: 14px; border-radius: 4px; display: inline-block; border: 2px solid transparent; }
.sw.v { background: var(--okbg); border-color: var(--ok); } .sw.b { background: var(--badbg); border-color: var(--bad); } .sw.o { background: var(--bg); border-color: var(--line); } .sw.u { background: var(--line); }

/* stats */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tile { background: var(--card); border-radius: 14px; padding: 10px 4px; text-align: center; display: grid; gap: 0; }
.tile b { font-size: 20px; } .tile small { font-size: 12px; }
.srow { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); min-height: 52px; }
.srow:first-of-type { border-top: 0; }
.srow.slim { min-height: 44px; padding: 4px 0; }
.sl { flex: 1; display: grid; gap: 0; line-height: 1.25; }
.sv { font-size: 22px; font-weight: 800; } .sv.sm { font-size: 17px; }
.card h2:first-child { margin-top: 0; }
