:root {
  --bg: #0e1a3a;
  --bg-glow: #2a4aa8;
  --panel: #ffffff;
  --panel-2: #f3f5fb;
  --ink: #1b2140;
  --muted: #5b6386;
  --line: #e1e5f2;
  --accent: #ffc83d;
  --accent-ink: #3a2a00;
  --accent-shadow: #c9921a;
  --good: #16a34a;
  --good-bg: #dcfce7;
  --bad: #dc2626;
  --bad-bg: #fee2e2;
  --sel: #3b82f6;
  --sel-bg: #dbeafe;
  --foe: #f97316;
  --on-bg: #ffffff;
  --scrim: rgba(5, 10, 30, .72);
  color-scheme: dark; /* satu tampilan arena malam, sengaja tidak ikut tema terang/gelap */
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(circle at 50% -10%, var(--bg-glow) 0, var(--bg) 65%) fixed;
  background-color: var(--bg);
  color: var(--on-bg);
  font-family: "Baloo 2", system-ui, sans-serif;
  font-size: 20px;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}
#app {
  max-width: 1100px; margin: 0 auto;
  padding-block: 16px 40px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.modal { position: fixed; inset: 0; background: var(--scrim); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal .panel { max-width: 460px; width: 100%; text-align: center; margin: 0; }
.modal .panel p { font-size: 20px; margin: 0 0 6px; }
.sync { text-align: center; font-size: 15px; opacity: .7; margin-top: 18px; }
button { font: inherit; cursor: pointer; border: 0; touch-action: manipulation; color: inherit; }
h1, h2, h3 { line-height: 1.15; }

/* ---------- tombol ---------- */
.btn {
  background: var(--accent); color: var(--accent-ink); font-weight: 800;
  padding: 12px 24px; border-radius: 18px; box-shadow: 0 5px 0 var(--accent-shadow);
  font-size: 22px; min-height: 60px;
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--accent-shadow); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.alt { background: #fff; color: var(--ink); box-shadow: 0 5px 0 #b9c0dc; }
.btn.ghost { background: transparent; color: #fff; border: 2px solid rgba(255,255,255,.45); box-shadow: none; }
.btn.small { min-height: 44px; font-size: 18px; padding: 6px 16px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 18px; }
.row.center { justify-content: center; }

/* ---------- header & peta ---------- */
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.title { font-weight: 800; font-size: 26px; letter-spacing: .5px; }
.coins { background: rgba(0,0,0,.3); padding: 6px 16px; border-radius: 999px; font-weight: 800; white-space: nowrap; }
.hero { display: flex; align-items: center; gap: 20px; margin: 12px 0 22px; }
.hero h1 { margin: 0; font-size: 34px; }
.hero p { margin: 2px 0 0; opacity: .85; }
.hero .chara { width: 120px; height: 140px; flex: none; }

.path { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.node {
  background: #fff; color: var(--ink); border-radius: 22px; padding: 16px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  box-shadow: 0 6px 0 #b9c0dc; min-height: 170px; justify-content: center;
}
.node:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 #b9c0dc; }
.node .ico { font-size: 54px; line-height: 1.1; }
.node .nm { font-weight: 800; font-size: 21px; text-align: center; }
.node .no { font-size: 15px; color: var(--muted); font-weight: 700; }
.node .stars { font-size: 24px; letter-spacing: 2px; }
.node.locked { background: rgba(255,255,255,.12); color: rgba(255,255,255,.6); box-shadow: none; }
.node.boss { background: linear-gradient(160deg, #fde68a, #f59e0b); box-shadow: 0 6px 0 #b45309; }
.node.boss.locked { background: rgba(255,255,255,.12); box-shadow: none; }

.mapel-h { font-size: 28px; margin: 22px 0 12px; }
.mapel-h small { font-size: 17px; opacity: .7; font-weight: 600; margin-left: 6px; }
.meter { width: 80%; height: 12px; border-radius: 999px; background: var(--line); overflow: hidden; margin: 8px 0 2px; }
.meter i { display: block; height: 100%; background: var(--accent); }
details { border-top: 1px solid var(--line); padding: 10px 0; }
summary { font-weight: 800; font-size: 19px; cursor: pointer; padding: 4px 0; }

/* ---------- jagoan ---------- */
.chara { display: block; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 8px 6px rgba(0,0,0,.4)); }
.chara .bob { animation: bob 1.1s ease-in-out infinite; transform-box: fill-box; transform-origin: center bottom; }
@keyframes bob { 50% { transform: translateY(-5px) scaleY(1.03); } }
.tired .chara { filter: grayscale(.75) drop-shadow(0 8px 6px rgba(0,0,0,.4)); }
.tired .chara .bob { animation: none; transform: rotate(-14deg) translateY(10px); }
.tabs { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.tabb { background: rgba(255,255,255,.12); color: #fff; border-radius: 14px; padding: 10px 18px; font-weight: 800; font-size: 20px; min-height: 52px; }
.tabb.on { background: var(--accent); color: var(--accent-ink); }
.name-in { font: inherit; font-size: 32px; font-weight: 800; text-align: center; width: min(420px, 100%); border-radius: 16px; border: 4px solid var(--accent); padding: 8px 14px; margin-top: 14px; color: var(--ink); }

/* ---------- cerita ---------- */
.card {
  background: #fff; color: var(--ink); border-radius: 26px; padding: 28px;
  font-size: 27px; line-height: 1.45; min-height: 300px; margin-top: 16px;
  display: flex; flex-direction: column; justify-content: center; gap: 10px;
  animation: pop .35s ease-out;
}
.card .emo { font-size: 66px; line-height: 1; }
.card b { color: #1d4ed8; }
.dots { display: flex; gap: 8px; justify-content: center; margin-top: 14px; }
.dots i { width: 12px; height: 12px; border-radius: 50%; background: rgba(255,255,255,.3); }
.dots i.on { background: var(--accent); }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- battle ---------- */
.battle { display: grid; gap: 16px; }
@media (min-width: 900px) and (orientation: landscape) {
  .battle { grid-template-columns: 1fr 1.25fr; align-items: start; }
  .arena { position: sticky; top: 16px; }
}
.arena { background: rgba(0,0,0,.25); border-radius: 24px; padding: 14px; }
.bars { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bar { background: rgba(255,255,255,.15); border-radius: 12px; height: 30px; position: relative; overflow: hidden; }
.bar i { position: absolute; top: 0; bottom: 0; left: 0; background: var(--good); transition: width .5s; }
.bar.foe i { left: auto; right: 0; background: var(--foe); }
.bar span { position: relative; z-index: 1; font-size: 16px; font-weight: 800; padding: 0 10px; line-height: 30px; text-shadow: 0 1px 2px #000; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar.foe span { text-align: right; }
.dish {
  position: relative; height: 210px; margin-top: 12px; border-radius: 50%;
  background: radial-gradient(ellipse at center, #6475b3 0, #2b3a6e 58%, #121a3f 100%);
  box-shadow: inset 0 12px 30px rgba(0,0,0,.6), 0 0 0 6px rgba(255,255,255,.08);
  overflow: visible;
}
.p { position: absolute; top: 50%; width: 140px; height: 162px; margin-top: -96px; }
.p.me { left: 14%; }
.p.foe { right: 14%; }
.p.me.atk { animation: atkR .55s ease-in-out; }
.p.foe.atk { animation: atkL .55s ease-in-out; }
.p.hit { animation: hit .45s .2s; }
@keyframes atkR { 50% { transform: translateX(70%) scale(1.12); } }
@keyframes atkL { 50% { transform: translateX(-70%) scale(1.12); } }
@keyframes hit { 25% { transform: translateX(12px) rotate(10deg); } 75% { transform: translateX(-12px) rotate(-10deg); } }
.boom { position: absolute; top: 50%; left: 50%; font-size: 60px; transform: translate(-50%,-50%); animation: boom .6s .15s both; pointer-events: none; }
@keyframes boom { from { opacity: 0; transform: translate(-50%,-50%) scale(.3); } 50% { opacity: 1; } to { opacity: 0; transform: translate(-50%,-50%) scale(1.6); } }
.prog { text-align: center; margin-top: 10px; font-weight: 700; }
.combo { color: var(--accent); margin-left: 8px; display: inline-block; animation: pulse .5s infinite alternate; }
@keyframes pulse { to { transform: scale(1.15); } }

.qpanel { background: var(--panel); color: var(--ink); border-radius: 24px; padding: 20px; animation: pop .3s ease-out; }
.q { display: flex; gap: 12px; align-items: flex-start; }
.q p { margin: 0; font-size: 26px; font-weight: 700; line-height: 1.3; flex: 1; }
.speak { background: #eef2ff; border-radius: 50%; width: 54px; height: 54px; font-size: 24px; flex: none; }
.tag { display: inline-block; font-size: 14px; font-weight: 800; color: var(--muted); background: var(--panel-2); border-radius: 8px; padding: 0 8px; margin-bottom: 6px; }
.blank { display: inline-block; min-width: 70px; border-bottom: 3px dashed var(--muted); }

.opts { display: grid; gap: 12px; margin-top: 18px; }
.opt {
  background: var(--panel-2); border: 3px solid var(--line); color: var(--ink); border-radius: 18px;
  padding: 12px 16px; text-align: left; font-size: 22px; font-weight: 600;
  display: flex; gap: 12px; align-items: center; min-height: 66px; line-height: 1.25;
}
.opt .k { background: var(--ink); color: #fff; border-radius: 10px; width: 38px; height: 38px; display: grid; place-items: center; flex: none; font-weight: 800; }
.opt.on { border-color: var(--sel); background: var(--sel-bg); }
.opt.right { border-color: var(--good); background: var(--good-bg); }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt:disabled { cursor: default; }
.tf { grid-template-columns: 1fr 1fr; }
.tf .opt { justify-content: center; font-size: 28px; font-weight: 800; min-height: 96px; }
.hint { font-size: 17px; color: var(--muted); margin: 10px 0 0; }

.boxes { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 20px 0; }
.box { width: 50px; height: 58px; border-radius: 12px; border: 3px solid var(--line); display: grid; place-items: center; font-size: 30px; font-weight: 800; background: #f8f9fd; }
.box.f { border-color: var(--sel); background: var(--sel-bg); }
.box.next { border-color: var(--accent); border-style: dashed; }
.boxes.words .box { width: auto; min-width: 90px; padding: 0 14px; font-size: 22px; }
.boxes.right .box { border-color: var(--good); background: var(--good-bg); }
.boxes.wrong .box { border-color: var(--bad); background: var(--bad-bg); }
.tiles { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.tile { min-width: 62px; height: 62px; border-radius: 14px; background: var(--accent); color: var(--accent-ink); font-size: 30px; font-weight: 800; box-shadow: 0 4px 0 var(--accent-shadow); padding: 0 10px; }
.tile.word { font-size: 22px; padding: 0 18px; }
.tile:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--accent-shadow); }
.tile:disabled { opacity: .2; cursor: default; }

.match { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
.match .col { display: grid; gap: 10px; align-content: start; }
.mi { background: var(--panel-2); border: 3px solid var(--line); border-radius: 16px; min-height: 60px; font-size: 21px; font-weight: 700; color: var(--ink); padding: 6px 10px; }
.mi.on { border-color: var(--sel); background: var(--sel-bg); }
.mi.done { border-color: var(--good); background: var(--good-bg); }
.mi.shake { border-color: var(--bad); background: var(--bad-bg); animation: hit .4s; }
.mi:disabled { cursor: default; }
.mi .n { display: inline-block; background: var(--good); color: #fff; border-radius: 8px; padding: 0 7px; margin-right: 6px; font-size: 16px; }

.fb { margin-top: 18px; border-radius: 18px; padding: 16px 18px; animation: pop .3s ease-out; }
.fb.good { background: var(--good-bg); border: 3px solid var(--good); }
.fb.bad { background: #fff7ed; border: 3px solid var(--foe); }
.fb h3 { margin: 0 0 4px; font-size: 28px; }
.fb p { margin: 4px 0; font-size: 21px; line-height: 1.35; }
.fb .row { margin-top: 12px; }

/* ---------- hasil ---------- */
.result { text-align: center; margin-top: 24px; }
.result .gasing-box { width: 160px; height: 185px; margin: 0 auto; }
.result h1 { font-size: 44px; margin: 14px 0 4px; }
.result .big-stars { font-size: 64px; letter-spacing: 6px; }
.result p { font-size: 22px; margin: 6px 0; opacity: .9; }

/* ---------- toko ---------- */
.shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-top: 16px; }
.item { background: #fff; color: var(--ink); border-radius: 22px; padding: 16px; text-align: center; }
.item .chara { width: 120px; height: 140px; margin: 0 auto 6px; }
.item h3 { margin: 0 0 8px; font-size: 22px; }
.item.using { outline: 4px solid var(--accent); }

/* ---------- ortu ---------- */
.panel { background: #fff; color: var(--ink); border-radius: 22px; padding: 18px; margin-top: 16px; font-size: 18px; }
.panel h2 { margin: 0 0 10px; font-size: 24px; }
.panel h3 { margin: 18px 0 8px; font-size: 20px; }
.stats { width: 100%; border-collapse: collapse; }
.stats th, .stats td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.stats th { font-size: 15px; color: var(--muted); }
.qrow { display: grid; grid-template-columns: auto 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.qrow.off { opacity: .45; }
.qrow input { width: 26px; height: 26px; margin-top: 2px; }
.qrow .meta { font-size: 14px; color: var(--muted); }
.qrow .kunci { color: var(--good); font-weight: 700; }
.gate { max-width: 420px; margin: 40px auto; text-align: center; }
.gate input { font: inherit; font-size: 32px; width: 160px; text-align: center; border-radius: 14px; border: 3px solid var(--line); padding: 6px; margin: 12px 0; }

/* ---------- konfeti ---------- */
.cf { position: fixed; top: -20px; width: 12px; height: 18px; border-radius: 3px; z-index: 50; pointer-events: none; animation: fall 2.6s linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

@media (orientation: portrait) {
  .dish { height: 180px; }
  .p { width: 130px; height: 150px; margin-top: -90px; }
  .arena .row { margin-top: 6px; }
}
.iconbar { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.ib { background: rgba(255,255,255,.14); border-radius: 14px; padding: 4px 10px; min-width: 56px; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; font-weight: 700; }
.ib span { font-size: 24px; line-height: 1.1; }
.ib small { font-size: 12px; line-height: 1.1; }
.syncst { margin-left: auto; font-size: 13px; opacity: .75; white-space: nowrap; }
.err { color: #fca5a5; min-height: 1.2em; font-size: 17px; }
.pickgrid { justify-content: center; grid-template-columns: repeat(auto-fit, minmax(150px, 220px)); }
.item.pick { font: inherit; cursor: pointer; border: 0; box-shadow: 0 6px 0 #b9c0dc; }
.item.pick:active { transform: translateY(4px); box-shadow: 0 2px 0 #b9c0dc; }
.item.pick .sub { font-size: 15px; color: var(--muted); font-weight: 700; }
.item.add { display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(255,255,255,.12); color: #fff; box-shadow: none; }
.item.add .plus { font-size: 56px; }
@media (max-width: 600px) {
  body { font-size: 18px; }
  #app { padding-block: 10px 28px; }
  .title { font-size: 21px; }
  .hero { margin: 8px 0 10px; gap: 12px; }
  .hero p { display: none; }
  .hero h1 { font-size: 22px; }
  .hero .chara { width: 64px; height: 76px; }
  .mapel-h { font-size: 21px; margin: 14px 0 8px; }
  .mapel-h small { font-size: 14px; }
  .path { grid-template-columns: 1fr 1fr; gap: 10px; }
  .node { min-height: 84px; padding: 8px 6px; border-radius: 16px; box-shadow: 0 4px 0 #b9c0dc; }
  .node .ico { font-size: 34px; }
  .node .nm { font-size: 16px; line-height: 1.15; }
  .node .no { font-size: 13px; }
  .node .stars { font-size: 18px; }
  .node.boss { grid-column: 1 / -1; min-height: 64px; flex-direction: row; gap: 10px; flex-wrap: wrap; }
  .node.boss .ico { font-size: 28px; }
  .btn { min-height: 52px; font-size: 19px; padding: 8px 18px; }
  .ib { min-width: 50px; padding: 4px 6px; }
  .shop { grid-template-columns: 1fr 1fr; gap: 10px; }
  .item { padding: 10px; }
  .item .chara { width: 84px; height: 98px; }
  .item h3 { font-size: 18px; }
  .result h1 { font-size: 32px; }
  .q p { font-size: 22px; }
  .opt { font-size: 19px; }
  .card { font-size: 22px; padding: 20px; }
  .p { width: 80px; height: 94px; margin-top: -56px; }
  .dish { height: 170px; }
  .box { width: 40px; height: 48px; font-size: 24px; }
  .tile { min-width: 50px; height: 52px; font-size: 24px; }
  .mi { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  .chara .bob { animation: none; }
  .card, .qpanel, .fb { animation: none; }
}

/* ---------- huruf Arab & gambar pecahan ---------- */
.ar { font-family: "Noto Naskh Arabic", "Amiri", "Traditional Arabic", serif; font-size: 1.4em; line-height: 1.7; font-weight: 700; unicode-bidi: isolate; }
.qpic { display: flex; justify-content: center; margin: 14px 0 4px; }
.qpic .frac { width: 200px; height: auto; }
.opts.pics { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.opts.pics .opt { flex-direction: column; justify-content: center; padding: 12px; }
.opts.pics .opt .k { align-self: flex-start; }
.pic .frac { width: 130px; height: auto; display: block; }
.group { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; max-width: 240px; font-size: 30px; line-height: 1.2; }
.gi { opacity: .28; filter: grayscale(1); }
.gi.on { opacity: 1; filter: none; }
.qpic .frac.line { width: 100%; max-width: 560px; }
