:root {
  --bg: #FFF4DE;
  --bg-2: #FFE9C2;
  --ink: #22223B;
  --muted: #6E6A80;
  --card: #FFFFFF;
  --line: #EEDFC3;
  --coin: #FFB800;
  --xp: #7C5CFF;
  --good: #22B07D;
  --bad: #EF476F;
  --fire: #FF6B3D;
  --c: #3A86FF;
  --r: 22px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --head: "Baloo 2", "Nunito", system-ui, sans-serif;
  --body: "Nunito", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 700 17px/1.4 var(--body);
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  -webkit-text-size-adjust: 100%;
}
input, textarea, select { -webkit-user-select: text; user-select: text; font: inherit; color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
img { max-width: 100%; }
a { color: inherit; text-decoration: none; }
.cn { display: inline-block; width: .95em; height: .95em; border-radius: 50%; vertical-align: -0.12em; background: #FFC21A; border: .12em solid #E09A00; box-shadow: inset -.12em -.12em 0 rgba(0,0,0,.12); }
h1, h2, h3 { font-family: var(--head); line-height: 1.1; margin: 0; }
#app { min-height: 100%; padding-top: var(--safe-t); }
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 60; width: 100%; height: 100%; }
.wrap { max-width: 980px; margin: 0 auto; padding: 16px 16px calc(110px + var(--safe-b)); }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.hide { display: none !important; }

/* ---------- Tombol game (efek ditekan) ---------- */
.btn {
  --c: #3A86FF;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 10px 22px;
  border-radius: 18px;
  background: var(--c); color: #fff;
  font: 800 20px/1 var(--head);
  box-shadow: 0 5px 0 color-mix(in srgb, var(--c) 68%, #000);
  transition: transform .08s, box-shadow .08s, filter .15s;
  text-align: center;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 color-mix(in srgb, var(--c) 68%, #000); }
.btn[disabled] { filter: grayscale(1) opacity(.5); pointer-events: none; }
.btn.ghost { --c: #fff; color: var(--ink); box-shadow: 0 5px 0 var(--line); border: 2px solid var(--line); }
.btn.sm { min-height: 42px; font-size: 16px; padding: 6px 14px; border-radius: 14px; box-shadow: 0 4px 0 color-mix(in srgb, var(--c) 68%, #000); }
.btn.ghost.sm { box-shadow: 0 4px 0 var(--line); }
.btn.block { width: 100%; }
.btn.good { --c: var(--good); } .btn.bad { --c: var(--bad); } .btn.coin { --c: #F29E00; } .btn.xp { --c: var(--xp); }
.icon-btn { width: 48px; height: 48px; border-radius: 16px; background: #fff; border: 2px solid var(--line); display: grid; place-items: center; font-size: 22px; box-shadow: 0 4px 0 var(--line); }
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }

/* ---------- HUD ---------- */
.hud { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.avatar { width: 64px; height: 64px; border-radius: 20px; background: #fff; border: 3px solid var(--ink); display: grid; place-items: center; font-size: 38px; overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: contain; }
.hud .who { flex: 1; min-width: 0; }
.hud .name { font: 800 24px/1 var(--head); }
.lvl { display: inline-block; background: var(--xp); color: #fff; border-radius: 10px; padding: 2px 8px; font: 800 14px/1.3 var(--head); margin-right: 6px; }
.bar { height: 14px; background: #fff; border: 2px solid var(--ink); border-radius: 10px; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--xp); border-radius: 6px; transition: width .6s cubic-bezier(.3,1.4,.5,1); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: #fff; border: 2px solid var(--ink); border-radius: 14px; padding: 4px 10px; font: 800 18px/1.2 var(--head); white-space: nowrap; }
.chip.coin b { color: #C77F00; } .chip.fire b { color: var(--fire); }
.chip.gear { cursor: pointer; }

/* ---------- Kartu ---------- */
.card { background: var(--card); border: 2px solid var(--line); border-radius: var(--r); padding: 18px; }
.card + .card { margin-top: 14px; }
.kv .card, .grid .card, .thumbs .card, .gain .card { margin-top: 0; }
.sec-title { font: 800 22px/1.1 var(--head); margin: 22px 0 10px; display: flex; align-items: center; gap: 8px; }

/* Misi harian */
.missions { background: var(--ink); color: #fff; border: 0; position: relative; overflow: hidden; }
.missions h2 { font-size: 24px; margin-bottom: 10px; }
.mission { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid rgba(255,255,255,.12); }
.mission:first-of-type { border-top: 0; }
.mission .ico { width: 40px; height: 40px; border-radius: 12px; background: rgba(255,255,255,.1); display: grid; place-items: center; font-size: 22px; flex: none; }
.mission .mb { height: 8px; background: rgba(255,255,255,.15); border-radius: 6px; overflow: hidden; margin-top: 6px; }
.mission .mb i { display: block; height: 100%; background: var(--coin); }
.mission.done .txt { text-decoration: line-through; opacity: .6; }
.chest { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 12px; border-radius: 16px; background: rgba(255,255,255,.08); }
.chest .big { font-size: 40px; }
.chest.ready .big { animation: wobble 1s infinite; }

/* Peta pelajaran */
.islands { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.island { --c: #3A86FF; position: relative; background: var(--c); color: #fff; border-radius: 24px; padding: 16px 14px 14px; min-height: 150px; text-align: left; box-shadow: 0 6px 0 color-mix(in srgb, var(--c) 65%, #000); display: flex; flex-direction: column; transition: transform .08s, box-shadow .08s; }
.island:active { transform: translateY(5px); box-shadow: 0 1px 0 color-mix(in srgb, var(--c) 65%, #000); }
.island .em { font-size: 44px; line-height: 1; }
.island .nm { font: 800 21px/1.05 var(--head); margin-top: auto; }
.island .st { font-size: 14px; opacity: .9; margin-top: 4px; }
.island .new { position: absolute; top: 10px; right: 10px; background: #fff; color: var(--ink); font-size: 12px; border-radius: 8px; padding: 1px 7px; }

/* Jalur level dalam satu pelajaran */
.path { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.node { --c: #3A86FF; display: flex; align-items: center; gap: 14px; background: #fff; border: 2px solid var(--line); border-radius: 22px; padding: 12px 14px; text-align: left; width: 100%; box-shadow: 0 5px 0 var(--line); }
.node:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--line); }
.node .bub { width: 62px; height: 62px; border-radius: 50%; background: var(--c); color: #fff; display: grid; place-items: center; font: 800 26px/1 var(--head); flex: none; box-shadow: inset 0 -5px 0 rgba(0,0,0,.18); }
.node:nth-child(even) { margin-left: 28px; width: calc(100% - 28px); }
.node .t { font: 800 20px/1.15 var(--head); }
.stars { color: #E6DCC6; font-size: 20px; letter-spacing: 1px; }
.stars .on { color: var(--coin); }

/* ---------- Layar soal ---------- */
.play { max-width: 760px; margin: 0 auto; padding: 14px 16px calc(24px + var(--safe-b)); min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.pbody { flex: 1; display: flex; flex-direction: column; justify-content: center; padding-bottom: 8vh; }
.play-top { display: flex; align-items: center; gap: 12px; }
.prog { flex: 1; height: 18px; background: #fff; border: 2px solid var(--ink); border-radius: 12px; overflow: hidden; }
.prog i { display: block; height: 100%; background: var(--good); transition: width .35s; }
.combo { font: 800 18px/1 var(--head); color: var(--fire); min-width: 64px; text-align: right; }
.combo.pop { animation: pop .35s; }
.qcard { margin-top: 18px; background: #fff; border: 3px solid var(--ink); border-radius: 26px; padding: 22px 20px; position: relative; }
.qcard .tag { position: absolute; top: -14px; left: 18px; background: var(--c); color: #fff; border-radius: 10px; padding: 2px 10px; font: 800 14px/1.4 var(--head); }
.qtext { font: 800 clamp(22px, 4.2vw, 30px)/1.25 var(--head); white-space: pre-line; }
.qimg { display: block; margin: 12px auto 0; max-height: 180px; object-fit: contain; }
.speak { position: absolute; top: 10px; right: 10px; }
.answers { margin-top: 18px; display: grid; gap: 12px; }
.opt { background: #fff; border: 3px solid var(--line); border-radius: 20px; padding: 16px 18px; font: 800 21px/1.25 var(--head); text-align: left; box-shadow: 0 5px 0 var(--line); display: flex; gap: 12px; align-items: center; min-height: 64px; }
.opt .k { width: 34px; height: 34px; border-radius: 10px; background: var(--bg); display: grid; place-items: center; font-size: 17px; flex: none; }
.opt:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--line); }
.opt.right { border-color: var(--good); background: #E6F8F0; box-shadow: 0 5px 0 var(--good); }
.opt.wrong { border-color: var(--bad); background: #FDE8EE; box-shadow: 0 5px 0 var(--bad); animation: shake .35s; }
.tf { grid-template-columns: 1fr 1fr; }
.tf .opt { justify-content: center; font-size: 26px; min-height: 96px; }
.inbox { background: #fff; border: 3px solid var(--ink); border-radius: 18px; min-height: 66px; font: 800 34px/1 var(--head); display: flex; align-items: center; justify-content: center; letter-spacing: 2px; padding: 8px 14px; }
.inbox.wrong { border-color: var(--bad); animation: shake .35s; }
.inbox.right { border-color: var(--good); background: #E6F8F0; }
.inbox .cur { width: 3px; height: 34px; background: var(--ink); margin-left: 3px; animation: blink 1s infinite; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.keypad .btn { min-height: 64px; font-size: 28px; }
.textin { width: 100%; border: 3px solid var(--ink); border-radius: 18px; padding: 14px 16px; font: 800 26px/1.2 var(--head); background: #fff; outline: none; text-align: center; }
.textin:focus { border-color: var(--c); }
.order-ans { min-height: 76px; border: 3px dashed var(--ink); border-radius: 18px; padding: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; background: rgba(255,255,255,.6); }
.order-pool { display: flex; flex-wrap: wrap; gap: 10px; }
.tok { background: #fff; border: 3px solid var(--c); color: var(--ink); border-radius: 14px; padding: 10px 14px; font: 800 19px/1.2 var(--head); box-shadow: 0 4px 0 var(--c); text-align: left; }
.tok .n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 8px; background: var(--c); color: #fff; font-size: 14px; margin-right: 6px; }
.tok:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--c); }

/* Lembar umpan balik */
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding: 18px 18px calc(18px + var(--safe-b)); border-radius: 26px 26px 0 0; animation: up .25s cubic-bezier(.3,1.3,.5,1); }
.sheet .in { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.sheet.good { background: #D6F5E7; color: #0D6B4A; } .sheet.bad { background: #FFDCE5; color: #A11B43; }
.sheet h3 { font-size: 30px; }
.sheet .ans { font: 800 20px/1.3 var(--head); color: var(--ink); background: rgba(255,255,255,.7); border-radius: 14px; padding: 10px 14px; }
.sheet .hint { font-size: 16px; color: var(--ink); }

/* Hasil */
.result { text-align: center; max-width: 560px; margin: 0 auto; padding: 30px 16px calc(30px + var(--safe-b)); }
.bigstars { font-size: 76px; letter-spacing: 6px; margin: 16px 0 6px; }
.bigstars span { display: inline-block; color: #E6DCC6; }
.bigstars span.on { color: var(--coin); animation: starpop .5s backwards; }
.bigstars span:nth-child(2).on { animation-delay: .25s; } .bigstars span:nth-child(3).on { animation-delay: .5s; }
.gain { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin: 20px 0; }
.gain .card { padding: 14px; } .gain b { font: 800 34px/1 var(--head); display: block; }

/* ---------- Koleksi, toko, lencana ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.mon { background: #fff; border: 3px solid var(--line); border-radius: 20px; padding: 12px 10px; text-align: center; position: relative; }
.mon .pic { height: 92px; display: grid; place-items: center; font-size: 66px; }
.mon .pic img { max-height: 92px; object-fit: contain; }
.mon .nm { font: 800 17px/1.15 var(--head); margin-top: 6px; }
.mon.locked .pic { filter: brightness(0) opacity(.12); }
.mon.locked .nm { color: var(--muted); }
.mon .cnt { position: absolute; top: 8px; right: 8px; background: var(--ink); color: #fff; border-radius: 8px; padding: 0 6px; font-size: 13px; }
.rar { display: inline-block; font-size: 12px; border-radius: 8px; padding: 1px 8px; margin-top: 4px; color: #fff; }
.rar-biasa { background: #8D99AE; } .rar-langka { background: #3A86FF; } .rar-epik { background: #9B5DE5; } .rar-legenda { background: #F29E00; }
.mon.r-langka { border-color: #3A86FF; } .mon.r-epik { border-color: #9B5DE5; box-shadow: 0 0 0 3px #E9DDFB; } .mon.r-legenda { border-color: #F29E00; box-shadow: 0 0 0 3px #FFE7B0; }
.eggs { display: flex; align-items: center; gap: 16px; }
.egg { font-size: 84px; display: inline-block; }
.egg.shake { animation: wobble .5s 3; }
.reveal { text-align: center; padding: 10px 0; }
.reveal .pic { font-size: 120px; height: 160px; display: grid; place-items: center; animation: starpop .6s; }
.reveal .pic img { max-height: 160px; }
.reward { display: flex; align-items: center; gap: 14px; }
.reward .ri { width: 64px; height: 64px; border-radius: 18px; background: var(--bg); display: grid; place-items: center; font-size: 36px; flex: none; overflow: hidden; }
.reward .ri img { width: 100%; height: 100%; object-fit: contain; }
.reward .t { font: 800 20px/1.15 var(--head); }
.price { color: #C77F00; font: 800 18px/1 var(--head); }
.status { font-size: 14px; border-radius: 8px; padding: 2px 8px; display: inline-block; }
.status.pending { background: #FFF1C9; color: #8A5A00; } .status.ok { background: #D6F5E7; color: #0D6B4A; } .status.no { background: #FFDCE5; color: #A11B43; }
.badge { background: #fff; border: 3px solid var(--line); border-radius: 20px; padding: 14px 10px; text-align: center; }
.badge .e { font-size: 50px; }
.badge.off .e { filter: grayscale(1) opacity(.3); }
.badge .nm { font: 800 17px/1.1 var(--head); margin-top: 4px; }
.badge .d { font-size: 13px; color: var(--muted); margin-top: 4px; }
.tabs { display: flex; gap: 8px; margin: 4px 0 14px; flex-wrap: wrap; }
.tabs button { padding: 8px 16px; border-radius: 14px; background: #fff; border: 2px solid var(--line); font: 800 17px/1.2 var(--head); }
.tabs button.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- Navigasi bawah ---------- */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: #fff; border-top: 2px solid var(--line); padding: 8px 8px calc(8px + var(--safe-b)); }
.nav .in { max-width: 640px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: 14px; text-decoration: none; color: var(--muted); font: 800 13px/1.1 var(--head); position: relative; }
.nav a .e { font-size: 28px; line-height: 1; filter: grayscale(.6); }
.nav a.on { background: var(--bg); color: var(--ink); }
.nav a.on .e { filter: none; }
.nav a .dot { position: absolute; top: 4px; right: 18%; background: var(--bad); color: #fff; border-radius: 10px; font-size: 12px; padding: 0 6px; }

/* ---------- Arena ---------- */
.arena-q { font: 800 clamp(54px, 13vw, 96px)/1 var(--head); text-align: center; margin: 22px 0 10px; }
.timer { font: 800 30px/1 var(--head); }
.timer.low { color: var(--bad); animation: pop .5s infinite; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(34,34,59,.55); z-index: 50; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { background: var(--bg); border: 3px solid var(--ink); border-radius: 28px; padding: 22px; width: min(460px, 100%); max-height: 90vh; overflow: auto; animation: starpop .3s; }
.modal h2 { font-size: 28px; margin-bottom: 8px; }
.modal .acts { display: flex; gap: 10px; margin-top: 18px; }
.modal .acts .btn { flex: 1; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 14px 0; }
.pin-dots i { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--ink); }
.pin-dots i.f { background: var(--ink); }

/* ---------- Orang tua ---------- */
.parent { background: #F3F1F8; min-height: 100vh; }
.parent .wrap { padding-bottom: 40px; }
.parent .card { border-color: #E2DEEC; }
.ptable { width: 100%; border-collapse: collapse; font-size: 15px; }
.ptable th, .ptable td { text-align: left; padding: 7px 6px; border-bottom: 1px solid #ECE8F3; vertical-align: top; }
.ptable th { color: var(--muted); font-size: 13px; }
.field { display: block; width: 100%; border: 2px solid #DDD7EA; border-radius: 12px; padding: 10px 12px; background: #fff; font-size: 16px; }
textarea.field { min-height: 140px; font: 600 13px/1.4 ui-monospace, Menlo, monospace; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.kv .card { padding: 12px; } .kv b { font: 800 28px/1 var(--head); display: block; }
.days { display: flex; gap: 6px; align-items: flex-end; height: 90px; margin-top: 8px; }
.days div { flex: 1; text-align: center; font-size: 12px; color: var(--muted); }
.days span { display: block; background: var(--xp); border-radius: 6px 6px 2px 2px; margin: 0 auto 4px; width: 70%; min-height: 3px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.thumbs .card { padding: 8px; text-align: center; font-size: 13px; }
.thumbs img { height: 80px; object-fit: contain; display: block; margin: 0 auto 6px; }
.toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 14px; z-index: 70; font: 800 17px/1.2 var(--head); animation: up .25s; max-width: 90vw; text-align: center; }
.sync { font-size: 12px; color: var(--muted); text-align: center; margin-top: 18px; }

/* Setup */
.setup { max-width: 460px; margin: 0 auto; padding: 60px 20px; text-align: center; }
.logo { font-size: 90px; }

@keyframes pop { 50% { transform: scale(1.25); } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
@keyframes starpop { 0% { transform: scale(0) rotate(-30deg); opacity: 0; } 70% { transform: scale(1.2) rotate(6deg); opacity: 1; } 100% { transform: scale(1); } }
@keyframes wobble { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-10deg); } 75% { transform: rotate(10deg); } }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }
@media (min-width: 720px) {
  .answers.mc2 { grid-template-columns: 1fr 1fr; }
  .play-body { display: grid; grid-template-columns: 1fr; }
}
