:root {
  --bg: #fbf8f1;
  --bg-veil: rgb(251 248 241 / 0.85); /* --bg, see-through: covers a task behind "Mulai" */
  --surface: #fff;
  --ink: #1f2a26;
  --muted: #5b6662;
  --brand: #2f6f5e;
  --brand-soft: #dcefe8;
  --good: #2e7d32;
  --good-soft: #e3f3e4;
  --hint: #8a5a00;
  --hint-soft: #fff1d6;
  --bad: #9a3412;
  --bad-soft: #fde8de;
  --radius: 16px;
  --tap: 56px; /* PRD: tap targets >= 48px */
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; padding: 4px 16px; background: var(--brand); }
/* "Orang tua" (F2, #101): a small lock button in the top-right of every child screen. */
.parent-lock {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 2px 8px;
  border-radius: var(--radius);
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
}
.parent-lock-icon { font-size: 1.2rem; }
.brand { color: #fff; font-weight: 700; text-decoration: none; }
.page { max-width: 720px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.6rem; margin: 0.5rem 0; }
h2 { font-size: 1.2rem; }

.task-list { list-style: none; padding: 0; display: grid; gap: 12px; }

/* Landing page (/ signed out, #104): one column, buttons full width at 390 px. */
.landing > .big-button { margin: 12px 0; }
.landing-mascot { display: block; width: 96px; height: 96px; }
.landing-points { padding-left: 1.2em; }
.landing-points li { margin: 6px 0; }
.landing-note { color: var(--muted); font-size: 0.95rem; }

.big-button {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 12px 16px;
  border: 2px solid var(--brand);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 1.15rem;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.big-button:active { background: var(--brand-soft); }
.big-button.primary { background: var(--brand); color: var(--surface); font-weight: 700; }
.big-button.primary:active { opacity: 0.85; }

/* Sign-in forms (/masuk): one column, full width at 390 px. */
.signin form { display: grid; gap: 12px; margin: 16px 0; }
.signin label { font-weight: 700; }
.field {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 16px;
  border: 2px solid var(--muted);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
.field:focus { border-color: var(--brand); outline: none; }
.code-field { font-size: 1.6rem; letter-spacing: 0.4em; text-align: center; }
.link-button:disabled { color: var(--muted); text-decoration: none; cursor: default; }
.big-button:disabled { opacity: 0.4; }

/* First-time setup (/mulai/…): a big checkbox and tap-sized pickers for grade and avatar. */
.signin label.check { display: flex; gap: 12px; align-items: center; min-height: var(--tap); }
.check input { width: 28px; height: 28px; accent-color: var(--brand); flex: none; }
.picker { border: 0; padding: 0; margin: 0; }
.picker legend { font-weight: 700; padding: 0; margin-bottom: 8px; }
.picker-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.picker-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pick { position: relative; display: block; }
.pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pick span, .pick .avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: var(--tap);
  border: 2px solid var(--muted);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}
.pick .avatar { height: auto; aspect-ratio: 1; padding: 6px; object-fit: contain; }
.pick input:checked + span, .pick input:checked + .avatar { border-color: var(--brand); background: var(--brand-soft); font-weight: 700; }
.pick input:focus-visible + span, .pick input:focus-visible + .avatar { outline: 3px solid var(--brand); outline-offset: 2px; }
.child-card { display: flex; gap: 12px; align-items: center; }
.child-card .avatar { width: 56px; height: 56px; }

/* Parent home and settings (F9, F10): a card, links styled as buttons with room between them. */
.signin > .big-button, .signin > .card { margin: 12px 0; }
.card { padding: 4px 16px 16px; border-radius: var(--radius); background: var(--surface); border: 2px solid var(--brand-soft); }

/* Parent progress screen (F8): short lists, a muted line per item, the exam score line. */
.progress ul, .progress ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.progress .muted { color: var(--muted); }
.progress .level { font-weight: 700; }
.progress .level.kuat { color: var(--good); }
.progress .level.perlu-latihan { color: var(--hint); }
.score-line { width: 100%; height: auto; margin: 8px 0; background: var(--brand-soft); border-radius: var(--radius); }
.score-line polyline { fill: none; stroke: var(--brand); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }

/* PIN screen: a 3×4 number pad with tap-sized keys. The fieldset disables it while locked. */
.pin-fieldset { display: grid; gap: 12px; min-width: 0; margin: 0; padding: 0; border: 0; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pin-pad .big-button { font-size: 1.5rem; }
/* "Ya, keluar dan buat PIN baru" (#101): the fill grows while held; 1.5 s = HOLD_MS in app.js. */
.hold-button { position: relative; overflow: hidden; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; }
.hold-fill { position: absolute; inset: 0; background: var(--ink); opacity: 0.3; transform: scaleX(0); transform-origin: left; }
.hold-button.holding .hold-fill { transform: scaleX(1); transition: transform 1.5s linear; }
.hold-label { position: relative; }
.hold-tip { margin: 0; color: var(--muted); text-align: center; }
.hold-tip:empty { display: none; }

/* Settings "Keluar" (#101): the summary is the button; opening it asks first. */
.confirm > summary { list-style: none; }
.confirm > summary::-webkit-details-marker { display: none; }
.confirm[open] > summary { background: var(--brand-soft); }

/* Child home (F2): greeting, stars, one big button; "Orang tua" is in the top bar. */
.child-home { display: flex; flex-direction: column; gap: 16px; }
.child-home .child-card { margin: 0; font-size: 1.4rem; }
.stars { margin: 0; font-size: 1.4rem; font-weight: 700; }
.practice-button { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: calc(var(--tap) * 2); font-size: 1.6rem; }
/* Held to hear its label (#103): no text selection or callout menu on a long press. */
.practice-button { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.berang-hello { display: flex; gap: 12px; align-items: center; justify-content: center; }
.home-mascot, .mascot { display: block; width: 96px; height: 96px; }
/* Today's goal: the open set's dots beside the lifetime stars. */
.today { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.set-dots.goal-dots { margin: 0; }
.set-progress { font-size: 1rem; font-weight: 400; }
.practice-form { margin: 0; }

/* Practice set (F3): one dot per task, filled once the task is done. */
.set-dots { display: flex; gap: 8px; justify-content: center; list-style: none; margin: 0 0 16px; padding: 0; }
.set-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--brand); }
.set-dot.done { background: var(--brand); }
/* "Lanjut" sticks to the bottom of the screen, so a tall task never hides it (W6). */
.next-bar { position: sticky; bottom: 12px; margin-top: 16px; }
.set-end { display: grid; gap: 12px; justify-items: center; text-align: center; padding: 12px; border-radius: var(--radius); background: var(--good-soft); color: var(--good); font-size: 1.3rem; font-weight: 700; }
.set-end .big-button { justify-self: stretch; }
.set-end-line { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: center; margin: 0; }
/* End of set (#103): each dot becomes a star; reduced motion skips the pop. */
.set-dot.starred { width: 1.25rem; height: 1.25rem; display: grid; place-items: center; border-color: transparent; background: none; font-size: 1rem; line-height: 1; animation: pop 0.25s ease-out; }
@keyframes pop { from { transform: scale(0.4); } to { transform: none; } }
.audio-button.nudge { outline: 3px solid var(--brand); outline-offset: 2px; }

/* Mock exam (F7): the timer and "Selesai" stick to the top, the step buttons to the bottom, so
   both stay on screen above a tall task (W6). One task shows at a time. */
task-player[hidden], .exam-confirm[hidden] { display: none; }
.exam { display: grid; gap: 12px; }
.exam-bar { position: sticky; top: 0; z-index: 2; display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 8px 0; background: var(--bg); }
.exam-timer { margin: 0; font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.exam-low .exam-timer { color: var(--hint); }
.exam-done { width: auto; }
.exam-reminder { margin: 0; padding: 12px; border-radius: var(--radius); background: var(--hint-soft); color: var(--hint); font-weight: 700; }
.exam-dots { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; list-style: none; margin: 0; padding: 0; }
.exam-dot { width: 100%; min-height: 48px; border: 2px solid var(--brand); border-radius: 50%; background: var(--surface); color: var(--brand); font: inherit; font-weight: 700; cursor: pointer; }
.exam-dot.answered { background: var(--brand); color: var(--surface); }
.exam-dot[aria-current] { outline: 3px solid var(--ink); outline-offset: 2px; }
.exam .big-button.picked { background: var(--brand-soft); }
.exam-nav { position: sticky; bottom: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.exam-confirm { display: grid; gap: 8px; padding: 12px; border-radius: var(--radius); background: var(--surface); border: 2px solid var(--brand); font-size: 1.2rem; text-align: center; }
.exam-confirm p { margin: 0; font-weight: 700; }
.exam-points { margin: 0; font-size: 1.6rem; }
.exam-review { display: grid; gap: 8px; list-style: none; margin: 0; padding: 0; }
.review-item { border: 2px solid var(--brand-soft); border-radius: var(--radius); background: var(--surface); padding: 0 12px; }
.review-item > summary { display: flex; gap: 12px; align-items: center; min-height: var(--tap); cursor: pointer; font-weight: 700; }
.review-item.correct .review-mark { color: var(--good); }
.review-item.wrong .review-mark { color: var(--hint); }
.review-item.blank .review-mark { color: var(--muted); }
.review-num { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; background: var(--brand-soft); }
.forbidden { align-items: center; text-align: center; }
.forbidden .big-button { display: flex; align-items: center; justify-content: center; min-height: calc(var(--tap) * 1.5); }

/* DEV ribbon (docs/ENVIRONMENTS.md §1): on every page on dev, never in the way of a tap. Top
   centre, so it covers neither the brand nor the "Orang tua" button. */
.dev-ribbon {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  padding: 2px 12px;
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
  background: var(--bad);
  color: var(--surface);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  pointer-events: none;
}

.question { display: flex; gap: 12px; align-items: flex-start; font-size: 1.25rem; }
.answers { display: grid; gap: 12px; margin: 16px 0; }
.pool { display: grid; gap: 12px; min-height: var(--tap); }

/* Task pictures (#42). Hidden until loaded, so a missing file never shows a broken icon. Sized
   so that at 390×844 the picture, the question and all choices fit without scrolling. */
.pic { display: block; visibility: hidden; pointer-events: none; -webkit-user-drag: none; }
.pic.loaded { visibility: visible; }
.question-pic { margin-bottom: 8px; }
.question-pic .pic { width: 100%; height: auto; max-height: 22vh; object-fit: contain; }
.answers.pic-grid { grid-template-columns: 1fr 1fr; }
.pic-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 8px; }
/* Square pictures show at 72×72; a wide one (a map of three places) keeps its shape and fits the card. */
.pic-card .pic { width: auto; max-width: 100%; height: 72px; object-fit: contain; }

/* Order tasks (F5, #100): the pool of cards first, then a row of square numbered slots; side by
   side from 600 px. Cards have their own class, never the parent-home .card. */
.order { display: grid; gap: 16px; }
.pool { grid-template-columns: 1fr 1fr; }
@media (min-width: 600px) {
  .order { grid-template-columns: 1fr 1fr; align-items: start; }
  .pool { grid-template-columns: 1fr; }
}
.order-card {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  padding: 8px;
  font-size: 1rem;
  font-weight: 700;
  box-shadow: 0 3px 0 var(--brand); /* raised, so it looks like something to pick up */
  cursor: grab;
}
.order-card.pic-card { flex-direction: row; gap: 8px; }
.order-card.pic-card .pic { width: 40px; height: 40px; flex: none; }
.order-card.dragging { position: relative; z-index: 10; box-shadow: 0 8px 20px rgb(0 0 0 / 0.2); cursor: grabbing; }
.slots { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); gap: 10px; }
.slot {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: 4px;
  border: 2px dashed var(--brand);
  border-radius: var(--radius);
  background: var(--surface);
}
.slot.over { background: var(--brand-soft); border-style: solid; }
.slot-num { font-size: 1.6rem; font-weight: 700; color: var(--brand); }
/* A filled slot keeps its number as a small badge in the corner. */
.slot:has(.order-card) .slot-num {
  position: absolute;
  top: -8px;
  left: -8px;
  z-index: 1;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--brand);
  color: var(--surface);
  font-size: 0.85rem;
  line-height: 24px;
  text-align: center;
}
.slot-num, .slot .order-card { grid-area: 1 / 1; }
.slot .order-card { display: flex; align-items: center; justify-content: center; place-self: stretch; width: auto; min-height: 0; padding: 4px; font-size: 0.8rem; line-height: 1.2; box-shadow: none; overflow-wrap: anywhere; }
.slot .order-card.pic-card { flex-direction: column; gap: 2px; }
.slot .order-card.pic-card .pic { width: 32px; height: 32px; }
.slot .order-card:disabled { opacity: 1; background: var(--brand-soft); cursor: default; }
/* "Ulangi" (F5): a secondary button with ↺, never an underlined link. */
.big-button.secondary { color: var(--brand); font-weight: 700; }
.reset-button { width: auto; justify-self: start; padding-inline: 24px; }

.audio-button {
  min-width: var(--tap);
  min-height: var(--tap);
  border: none;
  border-radius: 50%;
  background: var(--brand-soft);
  font-size: 1.5rem;
  cursor: pointer;
}
/* "Mulai" (F4): the first tap of the session, which also unlocks audio. */
.start-button { margin: 32px 0; min-height: calc(var(--tap) * 2); font-size: 1.6rem; font-weight: 700; background: var(--brand); color: #fff; }
.start-button:active { background: var(--brand); opacity: 0.85; }
task-player { display: block; position: relative; }
.start-overlay { position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; background: var(--bg-veil); }
/* Sticky keeps "Mulai" on screen when the task is taller than the viewport. */
.start-overlay .start-button { position: sticky; top: 16px; bottom: 16px; }
.link-button { min-height: var(--tap); background: none; border: none; color: var(--brand); font: inherit; text-decoration: underline; cursor: pointer; }

.feedback { border-radius: var(--radius); padding: 0 16px; }
.feedback:empty { display: none; }
.feedback.good { background: var(--good-soft); color: var(--good); }
.feedback.hint { background: var(--hint-soft); color: var(--hint); }
.feedback.bad { background: var(--bad-soft); color: var(--bad); }
/* The explanation after a 2nd miss is something to learn, never an error (AC6.3). */
.feedback.learn { background: var(--brand-soft); color: var(--ink); }
.feedback { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; scroll-margin: 16px; }
/* Room for the sticky "Lanjut" bar (its height, set by the player, + its 12px offset + 16px). */
.feedback { scroll-margin-bottom: calc(var(--bar-room, 0px) + 28px); }

/* Answer states (#99): a missed card fades, the tapped one stays bright while the server checks,
   and the right card (picked, or shown after the explanation) keeps full colour with a ✓. */
.big-button.checking:disabled, .big-button.picked:disabled, .big-button.right:disabled { opacity: 1; }
.big-button.right { background: var(--brand-soft); border-width: 4px; }
.big-button.picked { border-width: 4px; }
.tick { margin-left: 8px; font-weight: 700; color: var(--brand); }
.big-button.checking::after {
  content: "";
  display: inline-block;
  width: 1em;
  height: 1em;
  margin-left: 8px;
  vertical-align: middle;
  border: 3px solid var(--brand-soft);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.wait { margin: 0 0 8px; color: var(--muted); }
.wait:empty { display: none; }
.star-counter { margin: 0 0 8px; text-align: right; font-size: 1.3rem; font-weight: 700; }
.earned-star { font-size: 2rem; }
.earned-star.flying { position: fixed; z-index: 30; margin: 0; pointer-events: none; }
@media (prefers-reduced-motion: reduce) {
  .big-button.checking::after { animation: none; }
  .set-dot.starred { animation: none; }
}
/* Set start (#103): Berang above "Mulai". */
.start-screen { display: flex; flex-direction: column; align-items: center; }
.start-screen .start-button { align-self: stretch; margin-top: 16px; }

.back-link { color: var(--muted); }

/* Dev-only illustration kit review (/dev/gambar). */
.kit-grid { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.kit-item { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px; border: 2px solid var(--brand-soft); border-radius: var(--radius); background: var(--surface); }
.kit-item img { width: 128px; height: 128px; }
.kit-item code { font-size: 0.85rem; color: var(--muted); }
