@font-face{
  font-family:'Naskh';
  src:url('fonts/naskh-400.ttf') format('truetype');
  font-weight:400;
  font-display:swap;
}
@font-face{
  font-family:'Naskh';
  src:url('fonts/naskh-700.ttf') format('truetype');
  font-weight:700;
  font-display:swap;
}

@font-face{
  font-family:'Emoji';
  src:url('fonts/emoji-sub.ttf') format('truetype');
  font-display:swap;
}

:root{
  --s:1;
  --cream:#F8F4EA;
  --paper:#FFFFFF;
  --ink:#241F1A;
  --muted:#6F665A;
  --teal:#0F5B54;
  --teal-deep:#0B4640;
  --teal-soft:#DCEBE7;
  --ochre:#B87A2E;
  --line:#E7DFCE;
  --ok:#2E7D5B;
  --bad:#B4553F;
}

html{
  font-size:calc(17px * var(--s));
  -webkit-text-size-adjust:100%;
}
html[data-size="2"]{ --s:1.13; }
html[data-size="3"]{ --s:1.26; }

*{ box-sizing:border-box; }

body{
  margin:0;
  background:var(--cream);
  color:var(--ink);
  font-family:'Naskh', 'Noto Naskh Arabic', 'Emoji', system-ui, sans-serif;
  font-size:1rem;
  line-height:1.6;
}

.app{
  max-width:520px;
  margin:0 auto;
  min-height:100dvh;
  display:flex;
  flex-direction:column;
  padding:1.1rem 1.05rem calc(0.6rem + env(safe-area-inset-bottom));
}

/* ---------- top bar ---------- */
.top{
  display:flex;
  align-items:center;
  gap:.7rem;
  min-height:2.6rem;
  margin-bottom:.9rem;
}
.top .spacer{ flex:1; }
.iconbtn{
  width:2.9rem; height:2.9rem;
  border:0; border-radius:50%;
  background:#fff;
  border:1px solid var(--line);
  color:var(--teal);
  font-size:1.4rem;
  line-height:1;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer;
  font-family:inherit;
}
.dots{ display:flex; gap:.35rem; align-items:center; }
.dot{ width:.55rem; height:.55rem; border-radius:50%; background:#DCD4C3; }
.dot.on{ background:var(--teal); }
.dot.now{ background:var(--ochre); transform:scale(1.25); }

/* ---------- type ---------- */
h1{ font-size:1.9rem; line-height:1.25; margin:0 0 .4rem; font-weight:700; }
h2{ font-size:1.35rem; margin:0 0 .5rem; font-weight:700; }
p{ margin:0 0 .8rem; }
.lead{ font-size:1.1rem; color:var(--muted); }
.small{ font-size:.85rem; color:var(--muted); }
.center{ text-align:center; }

/* ---------- buttons ---------- */
.btn{
  border:0;
  border-radius:1.1rem;
  font-family:inherit;
  font-weight:700;
  font-size:1.25rem;
  min-height:4.1rem;
  padding:1rem 1.3rem;
  cursor:pointer;
  display:flex; align-items:center; justify-content:center; gap:.6rem;
  transition:transform .08s ease, background .15s ease;
}
.btn:active{ transform:scale(.985); }
.btn.primary{ background:var(--teal); color:#fff; }
.btn.primary:active{ background:var(--teal-deep); }
.btn.ghost{ background:#fff; color:var(--teal); border:2px solid var(--teal); }
.btn.xl{ font-size:1.6rem; min-height:5.2rem; width:100%; border-radius:1.4rem; }
.btn.sm{ font-size:1rem; min-height:3.2rem; padding:.6rem 1rem; border-radius:.9rem; }
.btn[disabled]{ opacity:.5; }

.bar{
  display:flex; gap:.7rem; align-items:center;
  margin-top:auto;
  padding-top:1.2rem;
}
.bar .grow{ flex:1; }

/* ---------- splash ---------- */
.splash{
  flex:1; display:flex; flex-direction:column;
  align-items:center; justify-content:center;
  gap:1.1rem; text-align:center; padding:2rem 0;
}
.brand{
  font-size:3.6rem; font-weight:700; color:var(--teal);
  letter-spacing:.02em; line-height:1.1;
}
.brand span{ color:var(--ochre); }
.tagline{ font-size:1.25rem; color:var(--muted); margin:0; }
.mark{
  width:6.2rem; height:6.2rem; border-radius:1.9rem;
  background:var(--teal); color:var(--cream);
  display:flex; align-items:center; justify-content:center;
  font-size:3.4rem; font-weight:700; line-height:1;
  box-shadow:0 10px 30px rgba(15,91,84,.18);
}
.link{
  background:none; border:0; font-family:inherit;
  color:var(--muted); font-size:1rem; text-decoration:underline;
  cursor:pointer; padding:.6rem;
}

/* ---------- cards / list ---------- */
.list{ display:flex; flex-direction:column; gap:.75rem; }
.item{
  display:flex; align-items:center; gap:.9rem;
  background:var(--paper);
  border:1px solid var(--line);
  border-radius:1.3rem;
  padding:1rem 1.1rem;
  min-height:5.2rem;
  cursor:pointer;
  text-align:right;
  font-family:inherit;
  width:100%;
  color:inherit;
  transition:border-color .15s ease;
}
.item:active{ border-color:var(--teal); }
.item .num{
  width:2.7rem; height:2.7rem; border-radius:50%;
  background:var(--teal-soft); color:var(--teal-deep);
  display:flex; align-items:center; justify-content:center;
  font-weight:700; font-size:1.15rem; flex:0 0 auto;
}
.item .num.done{ background:var(--teal); color:#fff; }
.item .txt{ flex:1; }
.item .t{ font-size:1.2rem; font-weight:700; line-height:1.3; }
.item .s{ font-size:.9rem; color:var(--muted); line-height:1.4; }
.item .arrow{ color:#C4BAA6; font-size:1.4rem; }

/* ---------- glyph / tiles ---------- */
.glyph{
  font-size:11rem;
  line-height:1;
  text-align:center;
  font-weight:700;
  color:var(--teal);
  padding:1rem 0 .6rem;
  direction:rtl;
}
.glyph.big{ font-size:13rem; }
.glyph.word{ font-size:7rem; }

.tiles{ display:flex; gap:.7rem; justify-content:center; flex-wrap:wrap; }
.tiles.two .tile{ width:calc(50% - .35rem); }
.tile{
  background:var(--paper);
  border:2px solid var(--line);
  border-radius:1.3rem;
  padding:.9rem .4rem .7rem;
  text-align:center;
  cursor:pointer;
  font-family:inherit;
  color:inherit;
  flex:1 1 0;
  min-width:0;
  transition:border-color .15s ease, background .15s ease;
}
.tile .ch{ font-size:4.4rem; font-weight:700; line-height:1.1; color:var(--teal-deep); }
.tile .ch,.tile .cap{ display:block; }
.tile .cap{ font-size:.85rem; color:var(--muted); line-height:1.3; margin-top:.3rem; }
.tile.on{ border-color:var(--ochre); background:#FDF7EC; }
.tile.right{ border-color:var(--ok); background:#EDF7F1; }
.tile.wrong{ border-color:var(--bad); background:#FBEFEC; animation:shake .28s; }
@keyframes shake{
  0%,100%{ transform:translateX(0); }
  25%{ transform:translateX(-6px); }
  75%{ transform:translateX(6px); }
}

.card{
  background:var(--paper);
  border:1px solid var(--line);
  border-radius:1.4rem;
  padding:1.1rem;
}
.card.tight{ padding:.8rem; }

.wordcard{ text-align:center; }
.wordcard .emoji{ font-size:4.2rem; line-height:1.2; }
.wordcard .w{ font-size:5rem; font-weight:700; color:var(--teal-deep); line-height:1.2; }

.row{ display:flex; gap:.7rem; align-items:center; }

/* ---------- trace ---------- */
.trace{
  position:relative;
  background:var(--paper);
  border:2px dashed var(--line);
  border-radius:1.4rem;
  height:16rem;
  overflow:hidden;
}
.trace canvas{ width:100%; height:100%; display:block; touch-action:none; }
.trace .hint{
  position:absolute; inset:auto 0 .6rem 0;
  text-align:center; font-size:.85rem; color:#B9AE99;
  pointer-events:none;
}

/* ---------- setup form ---------- */
.field{ margin-bottom:1.1rem; }
.field label{ display:block; font-size:1.05rem; font-weight:700; margin-bottom:.4rem; }
.field input[type=text]{
  width:100%;
  font-family:inherit;
  font-size:1.25rem;
  padding:.9rem 1rem;
  border:2px solid var(--line);
  border-radius:1rem;
  background:#fff;
  color:var(--ink);
}
.field input[type=text]:focus{ outline:none; border-color:var(--teal); }
.seg{ display:flex; gap:.5rem; }
.seg button{
  flex:1;
  font-family:inherit;
  font-size:1rem;
  padding:.8rem .4rem;
  border-radius:.9rem;
  border:2px solid var(--line);
  background:#fff;
  color:var(--muted);
  cursor:pointer;
}
.seg button.on{ border-color:var(--teal); color:var(--teal-deep); background:var(--teal-soft); font-weight:700; }

/* ---------- misc ---------- */
.praise{
  text-align:center; color:var(--ok); font-weight:700; font-size:1.3rem;
  min-height:1.8rem;
}
.note{
  background:#FCF8EE; border:1px solid #EFE4CC; border-radius:1rem;
  padding:.8rem 1rem; font-size:.9rem; color:#7A6A4E;
}
.toast{
  position:fixed; inset:auto 0 1.2rem 0; margin:0 auto;
  width:max-content; max-width:90vw;
  background:var(--teal-deep); color:#fff;
  padding:.7rem 1.1rem; border-radius:2rem; font-size:1rem;
  opacity:0; transform:translateY(8px); transition:opacity .2s, transform .2s;
  pointer-events:none;
}
.toast.on{ opacity:1; transform:translateY(0); }
