/* Dział „Czytanie i pisanie” — wygląd przyjazny dla dzieci z dysleksją.
   Kolory, czcionka, wielkość i odstępy tekstu ustawia panel „Aa” (zmienne --t-* z js/tekst.js). */
* { box-sizing: border-box; }

:root {
  --t-font: 'Lexend', Verdana, sans-serif;
  --t-size: 30px;
  --t-letter: .08em;
  --t-word: .35em;
  --t-line: 2;
  --t-bg: #fdf6e3;
  --t-ink: #2d2a26;
  --t-s1: #1c5fbf;
  --t-s2: #c2255c;
  --ui: 'Baloo 2', 'Comic Sans MS', sans-serif;
  --violet: #7048e8;
  --card: rgba(255, 255, 255, .7);
}
.ciemne { --card: rgba(255, 255, 255, .08); }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--t-bg);
  color: var(--t-ink);
  font-family: var(--ui);
  display: flex;
  flex-direction: column;
}
a { color: inherit; }
.hidden { display: none !important; }

/* Tekst do czytania */
.tekst {
  font-family: var(--t-font);
  font-size: var(--t-size);
  letter-spacing: var(--t-letter);
  word-spacing: var(--t-word);
  line-height: var(--t-line);
  font-weight: 400;
  text-align: left;
}
.sylaby-on .syl.s1 { color: var(--t-s1); }
.sylaby-on .syl.s2 { color: var(--t-s2); }
/* Tryb „kolory liter”: każda litera ma swój kolor (--lc na jasnym tle, --ld na ciemnym) */
.litery-on .l { color: var(--lc); }
.ciemne.litery-on .l { color: var(--ld); }
.litery-on .caption .l, .litery-on .bubble .l, .litery-on .ans .l, .litery-on .piece .l, .litery-on .w-card .l { color: var(--lc) !important; }
.w-alfabet { display: none; margin: 2px 0 6px; padding: 4px 12px; border-radius: 14px; background: #fdf6e3; font-size: 24px; word-spacing: .2em; }
.litery-on .w-alfabet { display: block; }
.word { border-radius: .25em; transition: background .15s; }
.word.reading { background: #ffe066; color: #2d2a26; }
.word.reading .syl { color: inherit !important; }

/* ---------- Pasek górny ---------- */
.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px max(12px, 3vw);
}
.bar h1 { flex: 1; margin: 0; font-size: clamp(22px, 4vw, 34px); color: var(--violet); line-height: 1.1; }
.ciemne .bar h1 { color: #d0bfff; }
.btn-round {
  flex: none;
  display: grid;
  place-items: center;
  min-width: 52px;
  height: 52px;
  padding: 0 12px;
  border: 3px solid #fff;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .12);
  font: inherit;
  font-size: 24px;
  font-weight: 800;
  color: var(--violet);
  text-decoration: none;
  cursor: pointer;
}
.pager { font-weight: 800; opacity: .7; }

/* ---------- Czytnik ---------- */
main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 max(12px, 3vw) 12px; }
.pic-wrap { border-radius: 24px; overflow: hidden; border: 5px solid #fff; box-shadow: 0 6px 0 rgba(0, 0, 0, .08); }
.pic-wrap canvas { display: block; width: 100%; height: auto; }
.lines { margin: 14px 4px 0; }
.line { margin: 0 0 .15em; padding: 0 .3em; border-radius: 14px; cursor: pointer; transition: opacity .2s, background .2s; }
.line:hover { background: var(--card); }
.line.active { background: var(--card); box-shadow: inset 6px 0 0 #fcc419; }
.linijka-on .reader .line:not(.active) { opacity: .25; }

.comic { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 760px) { .comic { grid-template-columns: 1fr; } }
.panel { display: flex; flex-direction: column; gap: 8px; }
.caption {
  margin: 0;
  background: #fff3bf;
  color: #2d2a26;
  border: 3px solid #fcc419;
  font-size: calc(var(--t-size) * .78);
}
.panel-pic { position: relative; border-radius: 18px; overflow: hidden; border: 5px solid #fff; box-shadow: 0 6px 0 rgba(0, 0, 0, .08); }
.panel-pic canvas { display: block; width: 100%; height: auto; }
.bubble {
  position: absolute;
  max-width: 47%;
  padding: .15em .6em;
  border: 3px solid #343a40;
  border-radius: 22px;
  background: #fff;
  color: #2d2a26;
  font-size: calc(var(--t-size) * .7);
  line-height: 1.6;
}
.bubble::after {
  content: '';
  position: absolute;
  left: 30%; bottom: -14px;
  border: 8px solid transparent;
  border-top: 10px solid #343a40;
}
.caption .s1, .bubble .s1 { color: #1c5fbf !important; }
.caption .s2, .bubble .s2 { color: #c2255c !important; }
.linijka-on .reader .bubble:not(.active) { opacity: .35; }

/* ---------- Przyciski na dole ---------- */
.controls {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 12px;
  background: linear-gradient(transparent, var(--t-bg) 30%);
}
.ctl {
  padding: 8px 22px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 5px 0 rgba(0, 0, 0, .15);
  font: inherit;
  font-size: 24px;
  font-weight: 800;
  color: var(--violet);
  cursor: pointer;
}
.ctl.big { background: #fcc419; color: #5c3d00; box-shadow: 0 5px 0 #f08c00; }
.ctl.read { background: #d0ebff; color: #1864ab; box-shadow: 0 5px 0 #74c0fc; }
.ctl:disabled { opacity: .35; cursor: default; }

/* ---------- Pytania i koniec bajki ---------- */
.quiz { max-width: 820px; margin: 10px auto; text-align: center; }
.quiz .q { margin: 10px 0 18px; text-align: center; }
.answers { display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.ans {
  padding: 8px 18px;
  border: 4px solid #d0bfff;
  border-radius: 22px;
  background: #fff;
  color: #2d2a26;
  cursor: pointer;
  text-align: left;
}
.ans .s1 { color: #1c5fbf !important; }
.ans .s2 { color: #c2255c !important; }
.ans:hover { border-color: var(--violet); }
.ans.good { border-color: #40c057; background: #ebfbee; }
.ans.bad { animation: shake .4s; border-color: #ff8787; }
.big-msg { font-size: clamp(30px, 6vw, 52px); margin: 10px 0; color: var(--violet); }
.ciemne .big-msg { color: #d0bfff; }
.stars { font-size: 46px; letter-spacing: .1em; }
.end-btns { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 18px; }

@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* ---------- Panel „Aa Wygląd tekstu” ---------- */
.look {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(30, 20, 50, .45);
}
.w-card {
  position: relative;
  width: min(720px, 100%);
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  padding: 16px 20px;
  border-radius: 24px;
  background: #fff;
  color: #343a40;
}
.w-card h3 { margin: 0 0 6px; color: var(--violet); font-size: 26px; }
.w-close { position: absolute; top: 10px; right: 10px; border: 0; background: #ffe3e3; border-radius: 999px; width: 40px; height: 40px; font-size: 18px; cursor: pointer; }
.w-preview { margin: 4px 0 10px; padding: 6px 12px; border-radius: 14px; background: var(--t-bg); color: var(--t-ink); }
.w-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 6px 0; border-top: 1px solid #f1f3f5; }
.w-label { min-width: 150px; font-weight: 800; color: #495057; }
.w-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.w-opt {
  padding: 3px 14px;
  border: 3px solid #e9ecef;
  border-radius: 999px;
  background: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.w-opt.on { border-color: var(--violet); background: #f3f0ff; color: var(--violet); }
.font-lexend { font-family: 'Lexend', sans-serif; }
.font-opendyslexic { font-family: 'OpenDyslexic', sans-serif; }
.font-prosta { font-family: Verdana, sans-serif; }

/* ---------- Menu działu ---------- */
.intro { margin: 0 0 10px; font-size: 18px; font-weight: 700; opacity: .8; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 14px; }
.chip {
  padding: 4px 18px;
  border: 3px solid #fff;
  border-radius: 999px;
  background: var(--card);
  font: inherit;
  font-size: 18px;
  font-weight: 800;
  color: inherit;
  cursor: pointer;
}
.chip.on { background: var(--violet); color: #fff; }
.section-title { margin: 18px 0 8px; font-size: 26px; color: #e64980; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 16px; }
.tile {
  display: flex;
  flex-direction: column;
  border: 4px solid #fff;
  border-radius: 22px;
  overflow: hidden;
  background: var(--card);
  box-shadow: 0 6px 0 rgba(0, 0, 0, .07);
  text-decoration: none;
  color: inherit;
  transition: transform .15s;
}
.tile:hover { transform: translateY(-4px); }
.tile canvas { display: block; width: 100%; height: auto; }
.tile .icon { display: grid; place-items: center; aspect-ratio: 16 / 9; font-size: 54px; background: rgba(255, 255, 255, .5); }
.tile .t-body { padding: 8px 14px 12px; }
.tile h3 { margin: 0; font-size: 22px; line-height: 1.15; color: var(--violet); }
.ciemne .tile h3 { color: #d0bfff; }
.tile p { margin: 4px 0 0; font-size: 15px; font-weight: 600; opacity: .85; }
.tile .lvl { display: inline-block; margin-top: 6px; padding: 0 10px; border-radius: 999px; background: #fff3bf; color: #5c3d00; font-size: 14px; font-weight: 800; }
.tile .done-mark { margin-left: 6px; font-weight: 800; color: #2b8a3e; }

/* ---------- Ćwiczenia ---------- */
.ex { max-width: 900px; margin: 0 auto; text-align: center; }
.ex-pic { font-size: clamp(70px, 14vw, 120px); line-height: 1.1; cursor: pointer; }
.ex-progress { margin: 4px 0; font-size: 28px; letter-spacing: .1em; }
.ex-task { margin: 4px 0 10px; font-size: 22px; font-weight: 800; opacity: .85; }
.slots { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin: 10px 0; min-height: 1.6em; }
.slot {
  min-width: 1.6em;
  padding: 0 .3em;
  border-bottom: 5px solid currentColor;
  opacity: .9;
}
.slot.filled { border-bottom-color: #40c057; }
.pool { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; margin: 16px 0; }
.piece {
  min-width: 2.2em;
  padding: .1em .5em;
  border: 4px solid #d0bfff;
  border-radius: 18px;
  background: #fff;
  color: #2d2a26;
  cursor: pointer;
}
.piece .s1 { color: #1c5fbf !important; }
.piece .s2 { color: #c2255c !important; }
.piece.used { visibility: hidden; }
.piece.bad { animation: shake .4s; border-color: #ff8787; }
.choices { display: flex; justify-content: center; flex-wrap: wrap; gap: 16px; margin: 14px 0; }
.choice-pic {
  width: clamp(110px, 22vw, 170px);
  aspect-ratio: 1;
  border: 5px solid #fff;
  border-radius: 26px;
  background: #fff;
  font-size: clamp(56px, 10vw, 90px);
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(0, 0, 0, .08);
}
.choice-pic.bad { animation: shake .4s; border-color: #ff8787; }
.choice-pic.good, .piece.good { border-color: #40c057; background: #ebfbee; }
/* W ćwiczeniach wszystko na środku, a słowo lub zdanie do przeczytania — duże i pogrubione */
.ex .tekst { text-align: center; }
.read-target, .gap-word {
  margin: 10px auto 6px;
  font-size: calc(var(--t-size) * 1.7);
  font-weight: 600;
  line-height: 1.5;
}
.gap-word { margin: 6px 0 4px; }
.gap { display: inline-block; min-width: 1.2em; border-bottom: 5px solid #fcc419; text-align: center; }
.hint-box { min-height: 1.6em; margin: 6px 0; font-size: 19px; font-weight: 700; color: #e67700; }

.trace-wrap { position: relative; width: min(640px, 100%); margin: 6px auto; }
.trace-wrap canvas { display: block; width: 100%; height: auto; border: 5px solid #fff; border-radius: 26px; background: #fff; touch-action: none; cursor: crosshair; }
.trace-word { font-size: 24px; font-weight: 800; }

/* ---------- Monetki, słowniczek, nowe ćwiczenia ---------- */
.btn-round.coin { color: #e67700; font-size: 20px; text-decoration: none; }
.ctl.coin { background: #fff3bf; color: #e67700; box-shadow: 0 5px 0 #ffd43b; text-decoration: none; }
.coins-msg { margin: 0; font-size: 34px; font-weight: 800; color: #e67700; }
.coins-msg small { display: block; font-size: 16px; }
.learned-msg { margin: 4px 0 0; font-size: 20px; font-weight: 700; }
.stats { display: flex; flex-wrap: wrap; gap: 8px; margin: -4px 0 6px; }
.stat {
  padding: 4px 14px; border: 3px solid #fff; border-radius: 16px; background: var(--card);
  font: inherit; font-size: 17px; font-weight: 700; color: inherit; text-decoration: none; cursor: pointer;
}
.stat.coin { background: #fff3bf; color: #5c3d00; }
.stat b { color: #e64980; }
.dict-card h4 { margin: 10px 0 4px; color: #e64980; font-size: 20px; }
.dict-list { display: flex; flex-wrap: wrap; gap: 6px; }
.dict-item {
  padding: 0 12px; border: 3px solid #e9ecef; border-radius: 14px; background: #fdf6e3; color: #2d2a26;
  font-size: 20px; line-height: 1.6; cursor: pointer; text-align: left;
}
.dict-pic { font-family: 'Segoe UI Emoji', 'Apple Color Emoji', sans-serif; }

.ex-pic.small { font-size: clamp(50px, 9vw, 76px); cursor: default; }
.ex-pic.secret { opacity: .35; cursor: default; }
.yesno { font-family: var(--ui); font-size: 26px; font-weight: 800; padding: .2em .8em; }
.story-text, .ex-question {
  max-width: 820px; margin: 6px auto; padding: .2em .6em; border-radius: 18px; background: var(--card);
  text-align: left !important; font-size: calc(var(--t-size) * 1.05);
}
.ex-question { background: #fff3bf; color: #2d2a26; font-weight: 600; }
.answers-col { flex-direction: column; align-items: stretch; max-width: 820px; margin: 12px auto; }
.answers-col .ans { text-align: center; }
.ans.good { border-color: #40c057; background: #ebfbee; }
.word-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; max-width: 760px; margin: 14px auto; }
@media (max-width: 560px) { .word-grid { grid-template-columns: repeat(3, 1fr); } }
.word-grid .piece { min-width: 0; padding: .1em .2em; }
.sentence-slots .slot { min-width: 3em; }
.keyboard { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 760px; margin: 14px auto 4px; }
.key {
  min-width: 1.8em; padding: 0 .3em; border: 3px solid #d0bfff; border-radius: 12px; background: #fff; color: #2d2a26;
  font-size: calc(var(--t-size) * .9); line-height: 1.5; cursor: pointer; box-shadow: 0 3px 0 rgba(0, 0, 0, .1);
}
.key:active { transform: translateY(2px); box-shadow: none; }
.key.bad { animation: shake .4s; border-color: #ff8787; }
.key.hint-key { border-color: #fcc419; background: #fff3bf; animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }
a.ctl { text-decoration: none; }
.btn-round.off { opacity: .45; }
@media (max-width: 560px) { .bar { gap: 6px; } .btn-round { min-width: 42px; height: 42px; font-size: 19px; padding: 0 8px; } }
