:root {
  --bg: #f4f1ea; --panel: #fffdf8; --ink: #1d1b16; --muted: #6f6a5e; --line: #ddd6c6;
  --accent: #1f6f54; --accent-ink: #fff; --red: #c0392b; --black: #1d1b16;
  --ok: #1f7a4d; --bad: #b3261e; --warn: #9a6200; --card: #fff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a; --panel: #1c2024; --ink: #ece8df; --muted: #9a958a; --line: #30363c;
    --accent: #3fa37f; --accent-ink: #0d1512; --red: #ff6b5e; --black: #ece8df;
    --ok: #55c08a; --bad: #ff7a70; --warn: #e0a84a; --card: #262b30;
  }
}
* { box-sizing: border-box; }
body { font-variant-emoji: text; margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
header { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line); padding: 10px 16px 0; }
h1 { margin: 0 0 8px; font-size: 20px; letter-spacing: .02em; }
h2 { margin: 24px 0 8px; font-size: 17px; }
nav { display: flex; gap: 4px; overflow-x: auto; }
nav button { border: 0; background: none; color: var(--muted); font: inherit; padding: 8px 9px; border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; }
nav button[aria-selected=true] { color: var(--ink); border-color: var(--accent); font-weight: 600; }
main { max-width: 760px; margin: 0 auto; padding: 16px 16px 64px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
button.btn, .chips button { font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 10px; padding: 9px 14px; cursor: pointer; min-height: 42px; }
button.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.btn.ok { border-color: var(--ok); color: var(--ok); }
button.btn.bad { border-color: var(--bad); color: var(--bad); }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 12px; }
.chips button { padding: 6px 12px; min-height: 36px; border-radius: 999px; }
.chips button[aria-pressed=true] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.label { font-size: 13px; color: var(--muted); margin-top: 8px; }

/* игральная карта */
.pc { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; background: var(--card); color: var(--black); border: 1px solid var(--line); border-radius: 8px; width: 44px; height: 58px; font-weight: 700; line-height: 1.05; flex: none; }
.pc.red { color: var(--red); }
.pc .s { font-size: 1.15em; }
.pc.big { width: 150px; height: 205px; font-size: 44px; border-radius: 16px; box-shadow: 0 6px 18px rgba(0,0,0,.12); }
.pc.mid { width: 64px; height: 84px; font-size: 22px; border-radius: 10px; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 700; letter-spacing: .08em; }

/* список */
.scheme { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; margin-top: 8px; }
.scheme div { text-align: center; border: 1px solid var(--line); border-radius: 8px; padding: 4px; font-size: 14px; }
.scheme b { display: block; font-size: 17px; }
.item { display: grid; grid-template-columns: 44px 44px 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.item input { width: 100%; min-width: 0; font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.item .hint { grid-column: 3 / -1; font-size: 13px; margin-top: -4px; }
.item .hint button { font: inherit; background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 4px 2px; }
.warn { color: var(--warn); } .bad { color: var(--bad); } .ok { color: var(--ok); }
.icon { border: 0; background: none; color: var(--muted); font-size: 20px; cursor: pointer; min-width: 40px; min-height: 40px; }

/* тренировка */
.stage { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-top: 12px; text-align: center; }
.flip { border: 0; background: none; padding: 0; cursor: pointer; color: inherit; font: inherit; }
.word { font-size: 30px; font-weight: 700; min-height: 44px; overflow-wrap: anywhere; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; max-width: 420px; }
.opts button { min-height: 64px; font-size: 18px; display: flex; align-items: center; justify-content: center; }
.opts button.right { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 18%, var(--panel)); }
.opts button.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 18%, var(--panel)); }
.result { display: grid; grid-template-columns: 44px 44px 1fr; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); text-align: left; }
.pick { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.pick button { padding: 0; border: 0; background: none; cursor: pointer; border-radius: 8px; }
.pick button:disabled { opacity: .25; cursor: default; }
.big-num { font-size: 40px; font-weight: 700; }
