:root {
  --bg: #f3f6ff;
  --card: #ffffff;
  --ink: #1d2340;
  --muted: #6b7394;
  --primary: #4f7cff;
  --kid: #ff3b3b;
  --border: #dfe5f7;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Nunito", system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; gap: 8px; background: var(--card); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 800; font-size: 18px; white-space: nowrap; }
.tools { display: flex; gap: 6px; overflow-x: auto; }
.btn {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 52px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 14px;
  background: var(--card); font: inherit; font-size: 20px; cursor: pointer; color: var(--ink);
}
.btn span { font-size: 11px; color: var(--muted); }
.btn:active { transform: scale(0.95); }
.btn.small { min-width: 44px; font-size: 18px; }
.btn.small.on { background: #fff3c4; border-color: #f5c400; }
.btn.big { font-size: 22px; padding: 12px 24px; background: var(--primary); color: #fff; border: 0; }

#boardWrap { flex: 1; position: relative; display: flex; min-height: 0; }
/* papan bisa di-scroll ke atas-bawah: penjelasan lama tidak dihapus, tinggal digulir */
#boardScroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 8px; display: flex; flex-direction: column; align-items: center; overscroll-behavior: contain; }
/* soal yang di-zoom "nempel" di atas: papan di bawahnya bergulir, soalnya tetap terlihat */
#problemLayer { position: sticky; top: 0; z-index: 2; flex: none; background: #fff; border-radius: 12px 12px 0 0; box-shadow: 0 8px 14px -8px rgba(30, 50, 120, 0.45); touch-action: none; cursor: crosshair; }
#problemLayer[hidden] { display: none; }
#board { position: relative; flex: none; margin: auto 0; box-shadow: 0 4px 20px rgba(30, 50, 120, 0.12); border-radius: 12px; overflow: hidden; background: #fff; }
#board canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#kidLayer { touch-action: none; cursor: crosshair; }
#hint {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: rgba(29, 35, 64, 0.85); color: #fff; padding: 8px 14px; border-radius: 20px;
  font-size: 14px; pointer-events: none; text-align: center; max-width: 90%;
}

#captionBar {
  display: flex; align-items: center; gap: 10px; margin: 0 8px; padding: 10px 12px;
  background: var(--card); border-radius: 16px; border: 1px solid var(--border);
}
#avatar { font-size: 32px; transition: transform 0.2s; cursor: pointer; }
#avatar.talking { animation: bob 0.5s infinite alternate; }
@keyframes bob { from { transform: translateY(0) rotate(-4deg); } to { transform: translateY(-4px) rotate(4deg); } }
#caption { flex: 1; font-family: "Patrick Hand", cursive; font-size: 22px; line-height: 1.2; }
#caption.thinking::after { content: ""; animation: dots 1.2s infinite; }
@keyframes dots { 0% { content: ""; } 33% { content: "."; } 66% { content: ".."; } 100% { content: "..."; } }

.bottombar { display: flex; gap: 8px; padding: 8px; align-items: center; }
.mic {
  width: 64px; height: 64px; border-radius: 50%; border: 0; font-size: 28px; cursor: pointer;
  background: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(79, 124, 255, 0.4); flex: none;
}
.mic.listening { background: var(--kid); animation: pulse 1s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 12px rgba(255, 59, 59, 0.2); } }
#textInput {
  flex: 1; min-width: 0; height: 48px; border-radius: 24px; border: 1px solid var(--border);
  padding: 0 16px; font: inherit; font-size: 16px; background: var(--card);
}
.send { height: 48px; padding: 0 16px; border-radius: 24px; border: 0; background: #22b07d; color: #fff; font: inherit; font-weight: 800; cursor: pointer; }
.send:disabled, .mic:disabled { opacity: 0.5; }

.modal { position: fixed; inset: 0; background: #000; display: flex; flex-direction: column; z-index: 10; }
.modal[hidden] { display: none; }
.modal video { flex: 1; width: 100%; object-fit: contain; min-height: 0; }
.modal-actions { display: flex; justify-content: space-around; padding: 16px; }

/* HP kecil: sembunyikan nama supaya semua tombol muat */
@media (max-width: 480px) {
  .brand { display: none; }
  .tools { width: 100%; justify-content: space-between; }
  .btn { min-width: 0; flex: 1; }
}

/* tombol gulir papan (di HP, jari di papan dipakai untuk mencoret, jadi scroll pakai tombol ini) */
#scrollBtns { position: absolute; right: 12px; bottom: 56px; display: flex; flex-direction: column; gap: 8px; z-index: 3; }
#scrollBtns[hidden] { display: none; }
#scrollBtns button { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border); background: rgba(255,255,255,0.92); font-size: 20px; cursor: pointer; box-shadow: 0 3px 10px rgba(30, 50, 120, 0.2); }
#scrollBtns button:active { transform: scale(0.92); }
.pill { position: absolute; z-index: 3; border: 0; border-radius: 22px; padding: 10px 16px; font: inherit; font-weight: 800; font-size: 15px; cursor: pointer; box-shadow: 0 4px 14px rgba(30, 50, 120, 0.25); }
.pill[hidden] { display: none; }
.pill.left { top: 14px; left: 14px; background: #fff; color: var(--ink); }
.pill.go { top: 14px; right: 14px; background: #ff8a00; color: #fff; font-size: 17px; animation: pop 0.25s; }
@keyframes pop { from { transform: scale(0.6); } to { transform: scale(1); } }
.btn.small { flex: none; }
.pill.left { font-size: 13px; padding: 7px 12px; top: 2px; left: 10px; }
.pill.bottom { top: auto; bottom: 56px; left: 14px; right: auto; background: #22b07d; }

/* logo Master Obe (versi bulat): bulatannya kecil supaya papan tetap luas, gambarnya di-zoom sampai lingkarannya penuh */
.brand { display: flex; align-items: center; gap: 8px; }
.logoWrap, #avatar { border-radius: 50%; overflow: hidden; flex: none; box-shadow: 0 2px 8px rgba(30, 50, 120, 0.3); border: 2px solid #fff; background: #cfe3ff; }
.logoWrap img, #avatar img { width: 100%; height: 100%; object-fit: cover; display: block; transform: scale(1.52); }
.logoWrap { width: 34px; height: 34px; }
#avatar { width: 54px; height: 54px; }

/* ---------- akun anak, poin & target ---------- */
.chip { border: 1px solid #f5c400; background: #fff8e1; border-radius: 20px; padding: 6px 12px; font: inherit; font-weight: 800; font-size: 14px; cursor: pointer; white-space: nowrap; flex: none; }
.chip:active { transform: scale(0.95); }
.chip.pop { animation: pop 0.3s; }
.modal.light { background: rgba(29, 35, 64, 0.55); align-items: center; justify-content: center; padding: 16px; }
.sheet { background: var(--card); border-radius: 20px; padding: 20px; width: 100%; max-width: 480px; max-height: 92dvh; overflow: auto; }
.sheet h2 { margin: 0 0 14px; font-size: 20px; }
.sheet h3 { margin: 16px 0 6px; font-size: 15px; color: var(--muted); }
.cards { display: grid; gap: 10px; margin-bottom: 12px; }
.card { border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; background: #fff; }
.card:hover { border-color: var(--primary); }
.card small { color: var(--muted); }
.muted { color: var(--muted); font-size: 14px; }
.form { display: grid; gap: 10px; margin-top: 10px; }
.form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.form input { height: 42px; border-radius: 12px; border: 1px solid var(--border); padding: 0 12px; font: inherit; font-size: 16px; color: var(--ink); }
.form .btn.big { font-size: 16px; }
details summary { cursor: pointer; font-weight: 800; padding: 8px 0; }
.bar { height: 12px; background: #e6ecfb; border-radius: 6px; overflow: hidden; margin: 6px 0 4px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #ffb300, #ff8a00); border-radius: 6px; transition: width 0.4s; }
.list { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.5; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.row .btn { flex-direction: row; gap: 6px; font-size: 15px; padding: 10px 14px; }
.row .btn.primary { background: var(--primary); color: #fff; border: 0; }
@media (max-width: 480px) { .chip { font-size: 13px; padding: 5px 10px; } }
