:root {
  --bg: #fff8ec;          /* cream, not pure white: easier on struggling readers */
  --card: #ffffff;
  --ink: #2d2b3a;         /* dark grey-blue instead of pure black */
  --muted: #6b6880;
  --line: #ece3d2;
  --primary: #6c5ce7;
  --primary-soft: #ece9ff;
  --green: #00a884;
  --green-soft: #dcf7ef;
  --yellow: #fdcb6e;
  --yellow-soft: #fff1cf;
  --orange: #e17055;
  --orange-soft: #ffe6de;
  --blue: #0984e3;
  --blue-soft: #e0f0ff;
  --radius: 20px;
  --shadow: 0 3px 0 rgba(45, 43, 58, .08), 0 8px 24px rgba(45, 43, 58, .06);
  --rs: 26px;             /* reading font size (setting) */
  --ls: 0.03em;           /* letter spacing (setting) */
  --ws: 0.25em;           /* word spacing (setting) */
  --ui: 'Varela Round', 'Noto Sans Hebrew', system-ui, sans-serif;
  --read: 'Noto Sans Hebrew', Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 18px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}
#app {
  max-width: 760px;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom));
}
h1, h2, h3 { margin: 0 0 10px; line-height: 1.25; }
h1 { font-size: 28px; }
h2 { font-size: 23px; }
h3 { font-size: 19px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); font-size: 15px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 14px; }
.grow { flex: 1; }
.center { text-align: center; }
.hidden { display: none !important; }

/* ---------- buttons ---------- */
button, .btn {
  font: inherit;
  border: 0;
  cursor: pointer;
  border-radius: 16px;
  padding: 12px 18px;
  min-height: 52px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 0 rgba(0,0,0,.18);
  transition: transform .08s, box-shadow .08s, background .2s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none;
}
button:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.18); }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.btn-big { font-size: 22px; min-height: 64px; padding: 14px 26px; border-radius: 20px; }
.btn-ghost { background: var(--card); color: var(--ink); box-shadow: 0 3px 0 var(--line); border: 2px solid var(--line); }
.btn-green { background: var(--green); }
.btn-yellow { background: var(--yellow); color: var(--ink); }
.btn-orange { background: var(--orange); }
.btn-blue { background: var(--blue); }
.btn-small { min-height: 40px; padding: 6px 12px; font-size: 15px; border-radius: 12px; }
.icon-btn { min-height: 44px; min-width: 44px; padding: 6px 10px; font-size: 20px; border-radius: 14px; }
.btn-full { width: 100%; }
.rec-on { background: var(--orange) !important; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(225,112,85,.18); } }

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card.tap { cursor: pointer; transition: transform .1s; }
.card.tap:active { transform: scale(.98); }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.tile {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 12px; text-align: center; cursor: pointer; border: 3px solid transparent;
  display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--ink);
  font-weight: 700; min-height: 130px; justify-content: center;
}
.tile:active { transform: scale(.97); }
.tile .emo { font-size: 46px; line-height: 1; }
.tile .sub { font-weight: 400; font-size: 14px; color: var(--muted); }
.tile.done { border-color: var(--green); }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.topbar .title { flex: 1; font-size: 20px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { background: var(--yellow-soft); border-radius: 999px; padding: 6px 12px; font-weight: 700; white-space: nowrap; }

/* ---------- mascot ---------- */
.mascot { display: flex; align-items: flex-end; gap: 10px; margin: 6px 0 14px; }
.mascot .owl { font-size: 54px; line-height: 1; flex: none; animation: bob 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px) rotate(-3deg); } }
.bubble {
  position: relative; background: var(--card); border-radius: 18px; padding: 12px 14px;
  box-shadow: var(--shadow); font-size: 18px; flex: 1; display: flex; gap: 8px; align-items: center;
}
.bubble::after {
  content: ''; position: absolute; right: -8px; bottom: 14px; border: 8px solid transparent;
  border-left-color: var(--card); border-right: 0;
}
.bubble .say { flex: none; }

/* ---------- reader ---------- */
.reader {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 18px;
  font-family: var(--read);
  font-size: var(--rs);
  line-height: 2.15;
  letter-spacing: var(--ls);
  word-spacing: var(--ws);
}
.reader p { margin: 0 0 .6em; }
.reader .s { border-radius: 10px; transition: background .2s, opacity .25s; padding: 2px 0; }
.reader .w { cursor: pointer; border-radius: 8px; padding: 0 2px; transition: background .15s; }
.reader .w:hover { background: var(--primary-soft); }
.reader .w.wspeak { background: var(--yellow); }
.reader .w.found { background: var(--green-soft); box-shadow: inset 0 -3px 0 var(--green); }
.reader .s.speaking { background: var(--yellow-soft); }
.reader .s.hint { background: var(--green-soft); box-shadow: 0 0 0 3px var(--green-soft); }
.reader.focus .s { opacity: .22; }
.reader.focus .s.cur { opacity: 1; background: var(--blue-soft); }
.reader .w.nik { color: var(--primary); }
.reading-title { font-family: var(--read); font-size: calc(var(--rs) + 4px); font-weight: 800; text-align: center; margin: 4px 0 12px; }

/* ---------- stepper ---------- */
.stepper { display: flex; gap: 6px; justify-content: center; margin-bottom: 12px; flex-wrap: wrap; }
.stepper button {
  min-height: 40px; min-width: 40px; padding: 4px 8px; border-radius: 999px; font-size: 18px;
  background: var(--card); color: var(--ink); box-shadow: none; border: 2px solid var(--line);
}
.stepper button.cur { border-color: var(--primary); background: var(--primary-soft); }
.stepper button.ok { border-color: var(--green); }
.step-name { text-align: center; font-weight: 700; color: var(--primary); margin-bottom: 4px; }

/* ---------- words/chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-family: var(--read); font-size: 20px; background: var(--primary-soft); color: var(--ink);
  border-radius: 14px; padding: 6px 14px; min-height: 46px; box-shadow: 0 3px 0 rgba(108,92,231,.25); font-weight: 600;
}
.chip.starter { background: var(--yellow-soft); box-shadow: 0 3px 0 rgba(253,203,110,.6); }
.chip.sel { background: var(--primary); color: #fff; }
.chip.ok { background: var(--green-soft); box-shadow: 0 3px 0 rgba(0,168,132,.35); }
.hardword { display: flex; align-items: center; gap: 12px; }
.hardword .hw { font-family: var(--read); font-size: calc(var(--rs) + 4px); font-weight: 800; }
.hardword .hint { color: var(--muted); font-size: 17px; }

/* ---------- quiz ---------- */
.options { display: grid; gap: 10px; }
.opt {
  font-family: var(--read); font-size: 21px; text-align: right; justify-content: flex-start;
  background: var(--card); color: var(--ink); border: 3px solid var(--line); box-shadow: 0 3px 0 var(--line);
  font-weight: 600; line-height: 1.7;
}
.opt.right { border-color: var(--green); background: var(--green-soft); }
.opt.notyet { border-color: var(--orange-soft); background: var(--orange-soft); color: var(--muted); }
.qtext { font-family: var(--read); font-size: 23px; font-weight: 700; line-height: 1.8; }

/* ---------- writing ---------- */
textarea, input[type=text], input[type=number], select {
  font: inherit; width: 100%; border: 3px solid var(--line); border-radius: 16px; padding: 12px 14px;
  background: #fffdf8; color: var(--ink);
}
textarea { font-family: var(--read); font-size: 21px; line-height: 1.9; min-height: 140px; resize: vertical; }
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--primary); }
label { font-weight: 700; display: block; margin-bottom: 6px; }
.feedback { background: var(--green-soft); border-radius: 16px; padding: 14px; }
.tip { background: var(--yellow-soft); border-radius: 16px; padding: 14px; }

/* ---------- games ---------- */
.bigword {
  font-family: var(--read); font-size: 54px; font-weight: 800; letter-spacing: .08em; text-align: center;
  direction: rtl; margin: 10px 0 16px;
}
.bigword .gap {
  display: inline-block; min-width: 1.1em; border-bottom: 5px solid var(--primary); color: var(--primary);
  background: var(--primary-soft); border-radius: 10px 10px 0 0; text-align: center;
}
.bigword .gap.filled { border-color: var(--green); color: var(--green); background: var(--green-soft); }
.letter-choices { display: flex; gap: 18px; justify-content: center; }
.letter-choices button { font-family: var(--read); font-size: 46px; min-width: 110px; min-height: 100px; }
.trees { display: grid; gap: 8px; grid-template-columns: repeat(3, 1fr); }
.tree { background: var(--green-soft); border-radius: var(--radius); padding: 10px 6px; min-height: 150px; cursor: pointer; border: 3px dashed transparent; }
.tree.target { border-color: var(--green); }
.tree .root { font-family: var(--read); font-size: 24px; font-weight: 800; text-align: center; letter-spacing: .05em; }
.tree .chip { font-size: 17px; padding: 4px 8px; min-height: 36px; }
.tree .meaning { text-align: center; color: var(--muted); font-size: 15px; margin-bottom: 8px; }
.rootl { color: var(--green); font-weight: 800; }
.answer-row {
  min-height: 72px; border: 3px dashed var(--line); border-radius: 18px; padding: 10px;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: #fffdf8;
}
.kbd { display: grid; gap: 6px; margin-top: 12px; direction: rtl; }
.kbd .krow { display: flex; gap: 5px; justify-content: center; }
.kbd button {
  min-height: 48px; min-width: 0; flex: 1; max-width: 52px; padding: 0; font-family: var(--read); font-size: 22px;
  background: var(--card); color: var(--ink); border: 2px solid var(--line); box-shadow: 0 3px 0 var(--line); border-radius: 10px;
}
.kbd button.wide { max-width: 110px; flex: 2; font-size: 18px; }
.diff .bad { background: var(--orange-soft); border-radius: 6px; }

/* ---------- home ---------- */
.hello { display: flex; align-items: center; gap: 12px; }
.avatar { font-size: 44px; background: var(--card); border-radius: 50%; width: 64px; height: 64px; display: grid; place-items: center; box-shadow: var(--shadow); flex: none; }
.week { display: flex; gap: 6px; justify-content: space-between; }
.day { flex: 1; text-align: center; font-size: 13px; color: var(--muted); }
.day .dot { width: 100%; aspect-ratio: 1; max-width: 46px; margin: 0 auto 4px; border-radius: 50%; background: var(--line); display: grid; place-items: center; font-size: 22px; }
.day.on .dot { background: var(--yellow); }
.day.today .dot { box-shadow: 0 0 0 3px var(--primary); }
.mission { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 16px; background: var(--bg); cursor: pointer; }
.mission + .mission { margin-top: 8px; }
.mission .emo { font-size: 32px; }
.mission .check { font-size: 26px; }
.mission.done { background: var(--green-soft); }

/* ---------- stickers ---------- */
.stickers { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 10px; }
.sticker { aspect-ratio: 1; background: var(--card); border-radius: 18px; box-shadow: var(--shadow); display: grid; place-items: center; font-size: 40px; }
.sticker.locked { filter: grayscale(1); opacity: .35; font-size: 28px; }

/* ---------- parent ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; padding-bottom: 4px; }
.tabs button { background: var(--card); color: var(--ink); box-shadow: none; border: 2px solid var(--line); white-space: nowrap; min-height: 44px; }
.tabs button.cur { background: var(--primary); color: #fff; border-color: var(--primary); }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 130px; border-bottom: 2px solid var(--line); }
.bars .b { flex: 1; background: var(--primary); border-radius: 6px 6px 0 0; min-height: 2px; position: relative; }
.bars .b span { position: absolute; top: -20px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--muted); }
.bar-labels { display: flex; gap: 4px; }
.bar-labels span { flex: 1; text-align: center; font-size: 10px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: right; padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
audio { width: 100%; height: 40px; }
.stat { background: var(--bg); border-radius: 14px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 26px; color: var(--primary); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.field + .field { margin-top: 12px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { background: var(--card); color: var(--ink); border: 2px solid var(--line); box-shadow: none; min-height: 46px; }
.seg button.cur { background: var(--primary-soft); border-color: var(--primary); }

/* ---------- overlays ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(150%);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; max-width: 90vw; z-index: 50;
  transition: transform .3s, opacity .3s; font-size: 16px; text-align: center; opacity: 0; pointer-events: none;
}
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.overlay {
  position: fixed; inset: 0; background: rgba(45,43,58,.45); display: grid; place-items: center; z-index: 40; padding: 16px;
  animation: fade .2s;
}
@keyframes fade { from { opacity: 0; } }
.pop { background: var(--card); border-radius: 26px; padding: 26px 22px; text-align: center; max-width: 380px; width: 100%; animation: popin .35s cubic-bezier(.2,1.6,.5,1); }
@keyframes popin { from { transform: scale(.6); opacity: 0; } }
.pop .big { font-size: 72px; line-height: 1.1; }
.confetti { position: fixed; top: -40px; font-size: 28px; z-index: 45; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(6px); } 75% { transform: translateX(-6px); } }

@media (max-width: 420px) {
  h1 { font-size: 24px; }
  .bigword { font-size: 44px; }
  .letter-choices button { min-width: 90px; min-height: 86px; font-size: 40px; }
  .kbd button { font-size: 19px; min-height: 44px; }
  .btn-big { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
