:root {
  --paper: #f6f1e7;
  --card: #fffdf8;
  --ink: #2b2a28;
  --muted: #6f6a62;
  --line: #e6dfd2;
  --blue: #2f6fed;
  --blue-soft: #e4ecfd;
  --green: #238f55;
  --green-soft: #dff3e6;
  --red: #d2453f;
  --red-soft: #fbe3e1;
  --amber: #d99a00;
  --amber-soft: #fff1cc;
  --radius: 18px;
  --shadow: 0 2px 0 rgba(60, 40, 10, .06), 0 10px 30px -18px rgba(60, 40, 10, .35);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 19px; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45; min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 22px; max-width: 900px; margin: 0 auto;
}
.brand { text-decoration: none; color: var(--ink); font-weight: 700; font-size: 1.05rem; }
.who { font-weight: 600; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.who .av { font-size: 1.5rem; }

main { max-width: 900px; margin: 0 auto; padding: 6px 18px 60px; }
h1 { font-size: 1.9rem; margin: 10px 0 18px; letter-spacing: -.01em; }
h2 { font-size: 1.3rem; margin: 0 0 10px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 24px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.card.center { text-align: center; }
.big { font-size: 4rem; line-height: 1; }

/* ---------- home */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.tile {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 12px 16px; text-align: center; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 150px;
  transition: transform .08s;
}
.tile:active { transform: scale(.97); }
.tile .av { font-size: 3rem; line-height: 1; }
.tile .nm { font-weight: 700; font-size: 1.1rem; }
.tile .gr { color: var(--muted); font-size: .85rem; }
.tile .lock { font-size: .8rem; color: var(--muted); }

.newplayer { background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); padding: 6px 20px; }
.newplayer summary { cursor: pointer; font-weight: 700; padding: 12px 0; list-style: none; font-size: 1.1rem; }
.newplayer summary::-webkit-details-marker { display: none; }
.newplayer form { display: grid; gap: 18px; padding: 6px 0 22px; }
label, .field { display: grid; gap: 8px; font-weight: 600; }
label small { font-weight: 400; color: var(--muted); }
input[type=text], input:not([type]), textarea {
  border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; background: #fff;
  width: 100%; outline: none;
}
input:focus, textarea:focus { border-color: var(--blue); }
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg button, .avatars button {
  border: 2px solid var(--line); background: #fff; border-radius: 14px; padding: 12px 18px; font-weight: 600;
}
.seg button.on, .avatars button.on { border-color: var(--blue); background: var(--blue-soft); }
.avatars { display: flex; gap: 8px; flex-wrap: wrap; }
.avatars button { font-size: 1.7rem; padding: 8px 12px; line-height: 1; }

.primary {
  background: var(--blue); color: #fff; border: 0; border-radius: 16px; padding: 16px 26px;
  font-weight: 700; font-size: 1.1rem; box-shadow: 0 3px 0 #1f4fae; min-height: 58px;
}
.primary:disabled { opacity: .45; box-shadow: none; cursor: default; }
.primary:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #1f4fae; }
.primary.green { background: var(--green); box-shadow: 0 3px 0 #176a3d; }
.ghost { background: transparent; border: 2px solid var(--line); border-radius: 16px; padding: 12px 20px; font-weight: 600; }

/* ---------- session */
.progress { display: flex; gap: 6px; margin: 6px 0 18px; align-items: center; }
.progress .dot { flex: 1; height: 8px; border-radius: 4px; background: var(--line); }
.progress .dot.done { background: var(--green); }
.progress .dot.now { background: var(--blue); }
.progress .cnt { color: var(--muted); font-size: .85rem; margin-left: 8px; white-space: nowrap; }

.prompt { font-size: 1.7rem; font-weight: 700; margin: 6px 0 18px; line-height: 1.3; }
.prompt.small { font-size: 1.25rem; }
.tag { display: inline-block; font-size: .8rem; font-weight: 700; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; margin-bottom: 8px; }
.tag.review { color: var(--amber); }

.answerline {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 2px solid var(--line); border-radius: 16px; padding: 14px 18px; background: #fff;
  font-size: 1.8rem; font-weight: 700; min-height: 68px; margin-bottom: 14px;
}
.answerline .ph { color: #c9c2b6; font-weight: 400; font-size: 1.1rem; }
.answerline.ok { border-color: var(--green); background: var(--green-soft); }
.answerline.bad { border-color: var(--red); background: var(--red-soft); animation: shake .35s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }

.numpad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; max-width: 440px; }
.numpad button {
  background: #fff; border: 2px solid var(--line); border-radius: 16px; font-size: 1.6rem; font-weight: 700;
  min-height: 62px; box-shadow: 0 2px 0 var(--line);
}
.numpad button:active { transform: translateY(2px); box-shadow: none; }
.numpad button.wide { grid-column: span 2; }
.numpad button.go { background: var(--blue); color: #fff; border-color: var(--blue); box-shadow: 0 2px 0 #1f4fae; grid-row: span 2; }
.numpad button.sym { color: var(--blue); }
.numpad button.del { color: var(--red); }
.numpad button:disabled { visibility: hidden; }

.feedback { margin-top: 14px; font-size: 1.15rem; font-weight: 600; min-height: 1.6em; }
.feedback.ok { color: var(--green); }
.feedback.bad { color: var(--red); }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; align-items: center; }

/* early reading */
.story { font-size: 1.45rem; line-height: 1.6; margin-bottom: 14px; }
.speak { background: var(--blue-soft); border: 0; border-radius: 999px; padding: 10px 16px; font-weight: 700; color: var(--blue); }
.textans { font-size: 1.4rem; min-height: 62px; }

/* toddler */
.todd .display { font-size: 4.2rem; text-align: center; line-height: 1.2; letter-spacing: .1em; margin: 10px 0 20px; word-break: break-all; }
.todd .opts { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.todd .opts button {
  min-width: 120px; min-height: 120px; font-size: 3rem; font-weight: 800; border-radius: 28px;
  background: #fff; border: 3px solid var(--line); box-shadow: 0 4px 0 var(--line);
}
.todd .opts button.ok { border-color: var(--green); background: var(--green-soft); }
.todd .opts button.bad { border-color: var(--red); background: var(--red-soft); animation: shake .35s; }

/* passage */
.passage { font-size: 1.2rem; line-height: 1.65; }
.passage p { margin: 0 0 1em; }
.passage .s { border-radius: 6px; padding: 1px 2px; transition: background .15s; }
.passage.tappable .s { cursor: pointer; }
.passage.tappable .s:hover { background: #f3eee4; }
.passage .s.sel { background: var(--amber-soft); box-shadow: 0 0 0 2px var(--amber); }
.vocab { background: var(--amber-soft); border-radius: 14px; padding: 12px 16px; margin-bottom: 16px; font-size: 1.02rem; }
.vocab b { font-size: 1.1rem; }
.readgate { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 10px; }
.readgate .timer { color: var(--muted); font-weight: 600; }
details.fold summary { cursor: pointer; font-weight: 700; color: var(--blue); padding: 6px 0; }

.rubric { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.rubric li {
  display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: start;
  padding: 10px 12px; border-radius: 12px; background: #faf6ee; border: 1px solid var(--line);
}
.rubric li .box {
  width: 28px; height: 28px; border-radius: 8px; border: 2px solid #c9c2b6; display: grid; place-items: center;
  font-weight: 800; font-size: 1rem; background: #fff;
}
.rubric li.met { background: var(--green-soft); border-color: #b8e3c8; }
.rubric li.met .box { background: var(--green); border-color: var(--green); color: #fff; }
.rubric li.miss { background: var(--red-soft); border-color: #f0c2bf; }
.rubric li.miss .box { border-color: var(--red); color: var(--red); }
.rubric li .lbl { font-weight: 600; }
.rubric li .hint { display: block; font-weight: 400; color: #8a3a36; margin-top: 4px; font-size: .95rem; }
.rubric li .pts { color: var(--muted); font-size: .8rem; margin-left: 6px; font-weight: 500; }

.score {
  display: inline-flex; align-items: baseline; gap: 4px; font-weight: 800; font-size: 1.6rem;
  padding: 4px 14px; border-radius: 12px; background: var(--blue-soft); color: var(--blue);
}
.score.pass { background: var(--green-soft); color: var(--green); }
.score.fail { background: var(--red-soft); color: var(--red); }
.score small { font-size: 1rem; font-weight: 600; }

textarea.ans { min-height: 150px; resize: vertical; font-size: 1.2rem; line-height: 1.5; }
textarea.ans.locked { background: #f7f3ea; }
.note { font-style: italic; color: var(--muted); margin: 10px 0; }
.evhint { color: var(--amber); font-weight: 600; margin: 6px 0 10px; }
.evhint.ok { color: var(--green); }
.model { background: #eef4ff; border-radius: 14px; padding: 14px 18px; margin-top: 14px; font-size: 1.1rem; line-height: 1.55; }
.model .tag { color: var(--blue); display: block; }
.qnum { color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.marker { color: var(--muted); font-size: .8rem; }

/* summary */
#summary { display: grid; gap: 10px; margin: 16px 0 24px; font-size: 1.15rem; }
#summary .row { display: flex; justify-content: space-between; gap: 20px; padding: 10px 14px; background: #faf6ee; border-radius: 12px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(43, 42, 40, .45); display: grid; place-items: center; padding: 20px; z-index: 10; }
.modal-card { background: var(--card); border-radius: 22px; padding: 24px; width: min(420px, 100%); display: grid; gap: 16px; justify-items: center; }
.pindots { display: flex; gap: 14px; font-size: 2rem; letter-spacing: .2em; min-height: 1.4em; }
.pindots span { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); }
.pindots span.on { background: var(--ink); border-color: var(--ink); }
.pindots.bad span { border-color: var(--red); background: var(--red-soft); }
.modal .numpad { grid-template-columns: repeat(3, 1fr); width: 100%; }

@media (max-width: 600px) {
  html { font-size: 17px; }
  .numpad button { min-height: 56px; }
  .todd .opts button { min-width: 96px; min-height: 96px; font-size: 2.4rem; }
}
