:root {
  --scale: 1;
  --bg: #f6f5f1; --surface: #ffffff; --surface-2: #efede7; --ink: #15191f; --muted: #5d6470; --line: #dcd9d1;
  --accent: #1d5f8a; --accent-ink: #ffffff; --ok: #1f8a4c; --bad: #c4352d; --warn: #b7791f;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 6px 20px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1720; --surface: #17212c; --surface-2: #1f2b38; --ink: #e8ecf1; --muted: #9aa6b4; --line: #2b3949;
    --accent: #6fb3e0; --accent-ink: #0b1520; --ok: #4cc287; --bad: #f07a70; --warn: #e8b45a; --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1720; --surface: #17212c; --surface-2: #1f2b38; --ink: #e8ecf1; --muted: #9aa6b4; --line: #2b3949;
  --accent: #6fb3e0; --accent-ink: #0b1520; --ok: #4cc287; --bad: #f07a70; --warn: #e8b45a; --shadow: none;
  color-scheme: dark;
}
:root.hc { --muted: var(--ink); --line: var(--ink); }
:root.hc .btn { border-width: 2px; }

* { box-sizing: border-box; }
html { font-size: calc(16px * var(--scale)); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 1rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5rem; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); letter-spacing: -.01em; }
h2 { font-size: 1.4rem; margin-top: 1.5rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.fine { color: var(--muted); font-size: .85rem; }
.small { font-size: .88rem; }
.center { text-align: center; }

.page { max-width: 1080px; margin: 0 auto; padding: 24px 16px 64px; }
.page.narrow { max-width: 680px; }
.hero { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.sub { color: var(--muted); margin: 0; }

.btn { appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 10px; padding: .7rem 1rem; font: inherit; font-weight: 550; cursor: pointer; touch-action: manipulation; user-select: none; min-height: 44px; transition: background .12s, border-color .12s, transform .06s; }
.btn:hover { border-color: var(--accent); }
.btn:active { transform: scale(.98); }
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.sm { padding: .4rem .7rem; min-height: 36px; font-size: .9rem; }
.btn.big { padding: 1rem 1.3rem; font-size: 1.05rem; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.left { text-align: left; }
.btn.sel { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.btn.right { border-color: var(--ok); box-shadow: inset 0 0 0 2px var(--ok); }
.btn.wrong { border-color: var(--bad); box-shadow: inset 0 0 0 2px var(--bad); }
.back { margin-bottom: 10px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.row.center { justify-content: center; }
.stack { display: grid; gap: 8px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 8px 0 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .85rem; }
.cta { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; }
@media (max-width: 700px) { .cta { grid-template-columns: 1fr; } }
.plan { margin-top: 10px; font-size: .9rem; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
@media (max-width: 700px) { .modes { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card.mode p { color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.card.ex { display: flex; flex-direction: column; margin: 0; }
.card.ex p { margin-bottom: .4rem; }
.card.ex .btn { margin-top: auto; }
.ex-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.num { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.diff { font-size: .78rem; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 2px 8px; }
.foot { color: var(--muted); font-size: .85rem; margin-top: 32px; border-top: 1px solid var(--line); padding-top: 14px; }

.form { display: grid; gap: 12px; margin: 14px 0; }
.form label { display: grid; gap: 6px; font-weight: 550; }
select, input[type="time"], input[type="number"], textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .6rem .7rem; min-height: 44px; }
textarea { width: 100%; resize: vertical; margin-bottom: 8px; }
.chk { display: flex !important; grid-template-columns: none; align-items: center; gap: 10px; font-weight: 450 !important; }
.chk input { width: 20px; height: 20px; accent-color: var(--accent); }
.chk.custom span { flex: 1; }
.num-in { width: 70px; }
.lbl { display: block; font-weight: 600; margin: 10px 0 6px; }
.instr { font-size: 1.05rem; }

/* Екран вправи */
.run { min-height: 100dvh; display: flex; flex-direction: column; }
.run-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 3; flex-wrap: wrap; }
.run-title { display: grid; flex: 1; min-width: 150px; }
.run-title small { color: var(--muted); }
.run-meta { display: flex; gap: 12px; font-variant-numeric: tabular-nums; color: var(--muted); }
.run-timer { font-weight: 650; color: var(--ink); }
.run-ctrl { display: flex; gap: 6px; }
.focus .run-head .run-title small, .focus .run-meta .run-prog { display: none; }
.stage { flex: 1; display: flex; justify-content: center; padding: 16px; }
.ex-col { width: 100%; max-width: 560px; display: flex; flex-direction: column; gap: 14px; align-items: stretch; }
.ex-col.wide { max-width: 720px; }
.ex-col.text { max-width: 640px; }
.ex-col.center { align-items: center; text-align: center; justify-content: center; }
.stim { min-height: 200px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.rule { text-align: center; font-weight: 750; letter-spacing: .08em; padding: 8px; border-radius: 10px; background: var(--surface-2); min-height: 2.6em; display: grid; place-items: center; }
.rule[data-k="word"], .rule[data-k="same"], .rule[data-k="shape"] { background: color-mix(in srgb, var(--warn) 22%, var(--surface)); }
.rule[data-k="size"] { background: color-mix(in srgb, var(--ok) 20%, var(--surface)); }
.rule.pulse { animation: pulse .6s; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.06); } }
.flash { position: fixed; inset: 0; pointer-events: none; z-index: 2; border: 0 solid transparent; transition: border-width .1s; }
.flash.ok { border: 6px solid var(--ok); }
.flash.bad { border: 6px solid var(--bad); }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 10; padding: 16px; }
.overlay[hidden] { display: none; }
.overlay-box { background: var(--surface); border-radius: var(--radius); padding: 24px; max-width: 380px; text-align: center; }

.pad { display: grid; gap: 10px; }
.pad.cols-2 { grid-template-columns: 1fr 1fr; }
.pad.cols-3 { grid-template-columns: repeat(3, 1fr); }
.pad.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 420px) { .pad.cols-3 { grid-template-columns: 1fr 1fr; } }
.btn.color { display: flex; align-items: center; gap: 8px; justify-content: flex-start; font-weight: 500; }
.sw { width: 26px; height: 26px; border-radius: 6px; flex: none; display: grid; place-items: center; }
.sw em { font-style: normal; font-weight: 800; color: #fff; font-size: .8rem; display: none; text-shadow: 0 0 2px rgba(0,0,0,.6); }
.marks .sw em, .marks .shape .mark { display: block; }
.shape .mark { display: none; fill: #fff; font-weight: 800; }
.stroop-word { font-size: clamp(2rem, 9vw, 3.6rem); font-weight: 800; letter-spacing: .03em; min-height: 1.2em; }

.abc { position: relative; gap: 8px; }
.abc-letter { font-size: clamp(4rem, 18vw, 7rem); font-weight: 800; line-height: 1; }
.abc-cmd { font-size: 2.4rem; font-weight: 800; color: var(--accent); min-height: 1.2em; }
.abc-cmd[data-c="О"] { color: var(--warn); }
.abc-hint { color: var(--muted); min-height: 1.5em; }
.abc-signal { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: var(--bad); color: #fff; font-weight: 800; letter-spacing: .1em; padding: 4px 14px; border-radius: 99px; }
.abc-signal[hidden] { display: none; }

.arrows { font-size: clamp(3.5rem, 15vw, 6rem); font-weight: 700; gap: 0; display: flex; align-items: center; justify-content: center; }
.arrows .fl { color: var(--muted); font-size: .55em; opacity: .7; padding: 0 .3em; min-width: 1em; }
.cross { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-areas: ". u ." "l . r" ". d ."; gap: 8px; max-width: 300px; margin: 0 auto; width: 100%; }
.btn.arrow { font-size: 1.8rem; min-height: 64px; }
.a-up { grid-area: u; } .a-left { grid-area: l; } .a-right { grid-area: r; } .a-down { grid-area: d; }

.nb-letter { font-size: clamp(4rem, 18vw, 7rem); font-weight: 800; min-height: 1.2em; }
.cd { gap: 6px; }
.cd-input { font-size: 3rem; font-weight: 750; font-variant-numeric: tabular-nums; min-height: 1.2em; }
.cd-msg { color: var(--muted); min-height: 1.5em; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad .btn { font-size: 1.3rem; min-height: 56px; }
.mem { font-size: 2.4rem; letter-spacing: .2em; min-height: 1.4em; }
.seq { font-size: clamp(1.4rem, 6vw, 2.2rem); font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.btn.opt { font-size: 1.15rem; min-height: 56px; }
.why p { background: var(--surface-2); border-radius: 10px; padding: 12px; }
.why { display: grid; gap: 8px; }
.shape { width: 160px; height: 160px; }

.stop-circle { width: 170px; height: 170px; border-radius: 50%; display: grid; place-items: center; font-size: 2.4rem; color: var(--muted); border: 2px dashed var(--line); }
.stop-circle.fix { border-color: transparent; }
.stop-circle.go { background: var(--ok); border-color: var(--ok); }
.stop-circle.halt { background: var(--bad); border-color: var(--bad); }
.stop-btn { min-height: 90px; font-size: 1.3rem; }

.grid { display: grid; gap: 4px; }
.cell { aspect-ratio: 1; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 6px; font: inherit; font-weight: 700; font-size: clamp(.8rem, 3.6vw, 1.3rem); padding: 0; cursor: pointer; touch-action: manipulation; }
.cell.found { background: var(--ok); color: #fff; border-color: var(--ok); }
.cell.wrongcell { background: var(--bad); color: #fff; }
.cell.missed { outline: 3px solid var(--warn); outline-offset: -3px; }
.c-red { color: #d8322b; } .c-blue { color: #2f6fe0; }
.cell.found.c-red, .cell.found.c-blue { color: #fff; }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 100%; background: var(--accent); transition: width .2s linear; }

.igt-bal { font-size: 1.6rem; font-weight: 750; text-align: center; font-variant-numeric: tabular-nums; }
.igt-last { text-align: center; min-height: 2em; font-size: 1.3rem; font-weight: 650; }
.gain { color: var(--ok); } .loss { color: var(--bad); }
.decks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 480px) { .decks { grid-template-columns: 1fr 1fr; } }
.btn.deck { min-height: 130px; background: linear-gradient(160deg, var(--surface), var(--surface-2)); }
.btn.deck.picked { border-color: var(--accent); }

.tag { align-self: flex-start; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 2px 10px; }
.scenario { font-size: 1.2rem; line-height: 1.45; background: var(--surface); border-left: 4px solid var(--accent); padding: 12px 14px; border-radius: 0 10px 10px 0; }
.scenario.small { font-size: 1rem; }
.range { width: 100%; accent-color: var(--accent); min-height: 32px; }
.range-row { display: flex; align-items: center; gap: 12px; }
.big-num { font-size: 2.6rem; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 1.5em; text-align: center; }
.effect { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--surface); }
.effect.chosen { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }
.effect p { margin: .3rem 0 0; }
.note { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.fact { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.btn.clue { text-align: left; }
.stepper { display: flex; align-items: center; gap: 14px; }

.breath { width: 120px; height: 120px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 25%, transparent); border: 2px solid var(--accent); margin: 10px auto; transform: scale(.7); transition: transform 4s ease-in-out; }
.breath.in { transform: scale(1); }
.breath:not(.in) { transition-duration: 6s; }
.breath.short { animation: breathe 5s ease-in-out; }
@keyframes breathe { 0% { transform: scale(.7); } 40% { transform: scale(1); } 100% { transform: scale(.7); } }
.breath-phase { font-size: 1.2rem; font-weight: 650; }

.kv { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 16px; margin: 8px 0 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; display: block; overflow-x: auto; }
.tbl th, .tbl td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.chart-wrap { overflow: hidden; }
.chart { width: 100%; height: auto; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .axis { stroke: var(--line); }
.chart .tick { fill: var(--muted); font-size: 11px; }
.chart .lv { stroke: var(--surface); stroke-width: 1.5; }
.chart .lv1 { fill: #7aa7c7; } .chart .lv2 { fill: #3f86b8; } .chart .lv3 { fill: #d39b2a; } .chart .lv4 { fill: #d0612d; } .chart .lv5 { fill: #b0303a; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 20; max-width: calc(100% - 32px); }

.no-motion *, .no-motion *::before, .no-motion *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

@media (max-width: 560px) {
  .gear-t { display: none; }
  .stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat { padding: 8px 10px; }
  .stat b { font-size: 1.05rem; }
  .stat span { font-size: .75rem; line-height: 1.25; display: block; }
  .hero h1 { font-size: 1.5rem; }
}

.rules { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 10px 0 14px; text-align: left; }
.rules ol { margin: .4rem 0 .6rem; padding-left: 1.3rem; }
.rules li { margin: .2rem 0; }
.rules-goal { font-size: 1.08rem; }
.rules-ex { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; font-size: .95rem; }
.rules.compact { font-size: .95rem; }
.overlay-box { max-height: 90dvh; overflow-y: auto; }

.rules-trains { color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.rules-trains b { color: var(--ink); }
.trains b { color: var(--ink); font-weight: 600; }

/* Публічна сторінка */
.by { color: var(--muted); font-size: .9rem; margin-top: .35rem; }
.perks { list-style: none; padding: 0; margin: 8px 0 18px; display: grid; gap: 8px; }
.perks li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.share-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 24px; padding: 14px 16px; border: 1px dashed var(--line); border-radius: var(--radius); }
.share-row p { margin: 0; color: var(--muted); }
html[data-view]:not([data-view="home"]) #about { display: none; }

.about { padding-top: 0; }
.about section { margin-top: 28px; }
.about h2 { margin-top: 0; }
.lead { font-size: 1.08rem; max-width: 760px; }
.why-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.why-cards .card { margin: 0; }
.why-cards h3 { font-size: 1.05rem; }
.honest { padding-left: 1.2rem; display: grid; gap: 8px; max-width: 800px; }
.author .row { margin-top: 8px; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }
.faq { display: grid; gap: 8px; max-width: 800px; }
.faq details { margin: 0; padding: 12px 16px; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { margin: .5rem 0 0; }
.foot a, .about a:not(.btn) { color: var(--accent); }

@media (min-width: 760px) { .perks { grid-template-columns: repeat(3, 1fr); } }
/* Посилання на сайт у підзаголовку — синє й підкреслене, щоб було видно, що це посилання */
.by a { color: #1767c2; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.by a:hover { color: #0f4f99; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .by a { color: #6fb3e0; } :root:not([data-theme="light"]) .by a:hover { color: #9fd0f2; } }
:root[data-theme="dark"] .by a { color: #6fb3e0; }
:root[data-theme="dark"] .by a:hover { color: #9fd0f2; }
