:root {
  --ink: #14233b;
  --muted: #5b6b82;
  --bg: #eaf2fb;
  --card: #ffffff;
  --line: #d5e0ee;
  --brand: #14304f;
  --accent: #ffb703;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --c: #2563eb;
  --radius: 16px;
  --shadow: 0 2px 0 rgba(20, 48, 79, .08), 0 8px 24px rgba(20, 48, 79, .08);
  --font: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.45;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.3rem; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.skip { position: absolute; left: -999px; top: 0; background: #fff; padding: .5rem 1rem; z-index: 10; }
.skip:focus { left: 8px; top: 8px; }

/* nagłówek */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--brand); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  background: var(--accent); color: var(--brand); font-weight: 800; letter-spacing: .02em;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text small { opacity: .75; font-size: .75rem; }
.print { color: #fff; font-size: .85rem; text-decoration: none; border: 1px solid rgba(255, 255, 255, .35); padding: 6px 10px; border-radius: 999px; white-space: nowrap; }
.print:hover { background: rgba(255, 255, 255, .12); }

main { flex: 1; width: 100%; max-width: 720px; margin: 0 auto; padding: 16px 16px 40px; outline: none; }
.screen { animation: pop .25s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.loading { text-align: center; color: var(--muted); }

.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }

/* menu */
.hero { text-align: center; padding: 8px 0 4px; }
.hero-emoji { font-size: 3.2rem; }
.hero p { color: var(--muted); margin: 0 auto; max-width: 34ch; }
.sec { font-size: 1rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 26px 0 10px; }

.bigcard {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.bigcard:hover { border-color: var(--brand); }
.bigcard.start { background: var(--brand); color: #fff; border-color: var(--brand); }
.bigcard.final { border-color: var(--accent); }
.bc-ico { display: grid; place-items: center; width: 52px; height: 52px; flex: none; font-size: 1.6rem; border-radius: 14px; background: var(--accent); color: var(--brand); }
.bigcard.final .bc-ico { background: var(--brand); color: #fff; }
.bc-txt { display: flex; flex-direction: column; }
.bc-txt small { opacity: .8; font-size: .85rem; }

.stages { display: grid; gap: 12px; }
.stage { background: var(--card); border-radius: var(--radius); border-left: 8px solid var(--c); padding: 14px; box-shadow: var(--shadow); }
.st-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.st-head > div { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.st-head small { color: var(--muted); font-size: .85rem; }
.st-ico { font-size: 1.8rem; }
.st-score { font-size: .85rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: #eef2f7; color: var(--muted); white-space: nowrap; }
.st-score.pass { background: var(--ok-bg); color: var(--ok); }
.st-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.st-btns .btn { flex: 1 1 140px; }

/* przyciski */
.btn {
  min-height: 48px; padding: 10px 18px; border-radius: 14px; border: 2px solid var(--brand);
  background: var(--card); color: var(--brand); font-weight: 700;
}
.btn.primary { background: var(--c, var(--brand)); border-color: var(--c, var(--brand)); color: #fff; }
.btn.ghost:hover { background: #f1f6fc; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { width: 100%; min-height: 54px; font-size: 1.05rem; }
.btn.wide { width: 100%; margin-top: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link { background: none; border: 0; color: var(--brand); font-weight: 700; padding: 8px 0; text-decoration: underline; text-underline-offset: 3px; }
.row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.row.spread { justify-content: space-between; margin-top: 22px; }
.col-btns { display: grid; gap: 10px; margin-top: 18px; }
.mini { color: var(--muted); font-size: .9rem; margin: .4rem 0; }
.center { text-align: center; }

/* quiz i nauka */
.qtop { display: flex; justify-content: space-between; align-items: center; }
.qcount { font-weight: 800; color: var(--c); }
.qlabel { margin: 6px 0 8px; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; }
.bar { height: 10px; background: #dbe6f3; border-radius: 99px; overflow: hidden; margin-bottom: 18px; }
.bar i { display: block; height: 100%; background: var(--c); border-radius: 99px; transition: width .3s; }
.badge { display: inline-block; font-size: .75rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; background: var(--c); color: #fff; padding: 3px 10px; border-radius: 999px; margin-bottom: 8px; }
.qtext { font-size: 1.45rem; margin-bottom: 16px; }
.ltitle { font-size: 1.5rem; color: var(--c); }
.hint { color: var(--muted); font-size: .9rem; margin: 0 0 10px; }

.opts { display: grid; gap: 10px; }
.opts.tf { grid-template-columns: 1fr 1fr; }
.opt, .mt, .tok {
  min-height: 54px; padding: 10px 14px; text-align: left; font-weight: 600;
  background: var(--card); border: 2px solid var(--line); border-radius: 14px; box-shadow: 0 2px 0 rgba(20, 48, 79, .06);
}
.opts.tf .opt { text-align: center; font-size: 1.1rem; }
.opt:hover:not(:disabled), .mt:hover:not(:disabled):not(.done), .tok:hover:not(:disabled) { border-color: var(--c); }
.opt.ok, .mt.done, .line.ok, .txt.ok { background: var(--ok-bg); border-color: var(--ok); color: #14532d; }
.opt.bad, .line.bad, .txt.bad { background: var(--bad-bg); border-color: var(--bad); color: #7f1d1d; }
.opt:disabled { cursor: default; }

.inrow { display: flex; gap: 10px; flex-wrap: wrap; }
.txt { flex: 1 1 200px; min-height: 54px; padding: 10px 14px; border: 2px solid var(--line); border-radius: 14px; background: #fff; font-size: 1.1rem; }
.txt:focus { border-color: var(--c); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 25%, transparent); }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.col { display: grid; gap: 8px; align-content: start; }
.mt { font-size: .95rem; text-align: center; }
.mt.sel { background: #fff7e0; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 183, 3, .35); }
.mt.done { opacity: .75; cursor: default; }
.shake { animation: shake .35s; border-color: var(--bad); }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

.line { min-height: 62px; display: flex; flex-wrap: wrap; gap: 8px; padding: 8px; background: #fff; border: 2px dashed var(--line); border-radius: 14px; align-content: flex-start; }
.line.empty::before { content: "Tu ułóż zdanie…"; color: var(--muted); padding: 10px 6px; }
.pool { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tok { min-height: 46px; text-align: center; }
.line .tok { background: #eef5ff; }

.fb { margin-top: 18px; padding: 14px 16px; border-radius: 14px; display: flex; flex-direction: column; gap: 2px; }
.fb.ok { background: var(--ok-bg); color: #14532d; }
.fb.bad { background: var(--bad-bg); color: #7f1d1d; }
.fb[hidden], .nextrow[hidden] { display: none; }
.nextrow { margin-top: 12px; }
.nextrow .btn { width: 100%; }

/* tabele nauki */
.tbl-wrap { overflow-x: auto; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { background: var(--c); color: #fff; text-align: left; padding: 10px 14px; font-size: .9rem; }
.tbl td { padding: 10px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:nth-child(even) { background: #f6f9fd; }
.say { margin-left: 8px; border: 0; background: transparent; font-size: 1rem; padding: 2px 6px; border-radius: 8px; vertical-align: middle; }
.say:hover { background: #e3edf9; }
.note { background: var(--card); border-left: 6px solid var(--c); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); margin: 12px 0; }

/* wynik */
.result { text-align: center; }
.res-emoji { font-size: 4rem; text-align: center; }
.res-score { font-size: 3rem; font-weight: 800; color: var(--c); margin: 0; }
.hofsave { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin: 18px 0; text-align: left; }
.mist { text-align: left; background: var(--card); border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow); margin-top: 16px; }
.mist summary { cursor: pointer; font-weight: 800; }
.wrong { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 10px; }
.wrong li { border-top: 1px solid var(--line); padding-top: 8px; display: flex; flex-direction: column; }
.wq { color: var(--muted); font-size: .9rem; }
.wa { font-weight: 700; color: var(--ok); }

.hof td:first-child { width: 3rem; text-align: center; }
.hof tr.me { background: #fff7e0 !important; font-weight: 700; }

@media (max-width: 420px) {
  body { font-size: 17px; }
  .print { font-size: .75rem; padding: 5px 8px; }
  .cols { gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
