@import url('../fonts/fonts.css');
/* Sains Adventure Tahun 1 — gaya */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --ink: #23324a;
  --paper: #f4f7ff;
  --sky: #dbe7ff;
  --green: #3d7bff;
  --green-d: #2b57d6;
  --blue: #6d3fe0;
  --red: #e85d4a;
  --teal: #3d7bff;
  --yellow: #ffd23f;
  --yellow-d: #8a5f00;
  --coral: #e85d4a;
  --shadow: 0 4px 0 rgba(35, 50, 74, .16), 0 10px 22px rgba(35, 50, 74, .10);
}
html { font-size: 17px; }
body {
  font-family: "Nunito", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120"><circle cx="20" cy="30" r="4" fill="%233d7bff" fill-opacity=".07"/><circle cx="90" cy="70" r="5" fill="%238b5cf6" fill-opacity=".07"/><circle cx="55" cy="100" r="3" fill="%23ffd23f" fill-opacity=".12"/></svg>'), linear-gradient(180deg, #dfeaff 0%, #efe4ff 55%, #fff5d6 100%);
  min-height: 100vh;
  overscroll-behavior: none; /* halang pull-to-refresh semasa seret */
}
/* tajuk: Fredoka (fon dimuat dari _core/fonts); teks kekal Nunito */
h1, h2, h3, h4, .brandmini, .gtitle2, .qtext, .qsub, .wtitle, .gtitle, .rmsg, .memcount {
  font-family: "Fredoka", "Nunito", system-ui, sans-serif;
}
button:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; } /* a11y papan kekunci */
.opt, .chip, .memitem, .mitem, .diffopt, .slot, .bslot { user-select: none; -webkit-user-select: none; } /* elak sorotan teks bila tekan lama */
#app { max-width: 980px; margin: 0 auto; padding: 12px 14px 60px; }
button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }

/* topbar */
.topbar { display: flex; align-items: center; gap: 10px; padding: 6px 0 14px; }
.brandmini { font-weight: 800; font-size: .85rem; color: #5b6b85; flex: 1; text-align: center; }
.iconbtn {
  width: 48px; height: 48px; border-radius: 16px; background: #fff;
  box-shadow: var(--shadow); font-size: 1.3rem; display: grid; place-items: center;
}
.iconbtn.ghost { background: transparent; box-shadow: none; }
.iconbtn svg { width: 26px; height: 26px; display: block; }
.iconbtn.lang { font-size: .8rem; font-weight: 900; letter-spacing: .02em; }
#hubmus svg { width: 26px; height: 26px; display: block; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px;
  font-weight: 700; opacity: 0; pointer-events: none; transition: .25s; z-index: 90; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* home */
.homehead { text-align: center; padding: 18px 0 22px; }
.homehead h1 { font-size: clamp(1.9rem, 6vw, 3rem); color: var(--blue); }
.homehead p { font-size: 1.15rem; font-weight: 700; color: #5b6b85; margin-top: 6px; }
.trophy {
  margin: 14px auto 0; display: inline-block; background: var(--yellow); color: var(--ink);
  font-weight: 900; padding: 10px 22px; border-radius: 999px; box-shadow: var(--shadow);
}
.worldgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; }
/* pelangi per-dunia dari content (--wc) dipulihkan — tepu supaya warna pucat pun menyerlah */
.worldcard, .worldhead { filter: saturate(1.55); }
.worldcard {
  background: var(--wc, #fff); border: 3px solid #fff; border-radius: 26px; padding: 20px 18px;
  box-shadow: var(--shadow); text-align: left; display: flex; flex-direction: column; gap: 8px;
  transition: transform .15s; position: relative; overflow: hidden;
}
.worldcard:hover, .gamecard:hover, .opt:hover, .chip:hover, .btn:hover { transform: translateY(-2px); }
.worldcard.locked { filter: grayscale(.85); opacity: .75; }
.worldcard.done { border-color: var(--green); }
.wicon { font-size: 2.6rem; }
.wicon.big { font-size: 3.6rem; }
.wnum { font-weight: 900; font-size: .8rem; color: #5b6b85; }
.wtitle { font-weight: 800; font-size: 1.15rem; line-height: 1.25; }
.bar { display: block; height: 14px; background: #ffffffcc; border-radius: 999px; overflow: hidden; border: 1px solid #0001; }
.fill { display: block; height: 100%; background: linear-gradient(90deg, var(--green), #7ea0ff); border-radius: 999px; }
.wmeta { font-weight: 700; font-size: .92rem; color: #4a5a74; }
.wbadge {
  background: #fff; border: 2px dashed var(--green); color: var(--green-d); font-weight: 900;
  border-radius: 999px; padding: 6px 14px; font-size: .9rem; align-self: flex-start;
}

/* dunia */
.worldhead {
  display: flex; gap: 16px; align-items: center; background: var(--wc, #fff);
  border-radius: 26px; padding: 18px; box-shadow: var(--shadow); margin-bottom: 18px; flex-wrap: wrap;
}
.worldhead h2 { font-size: 1.35rem; margin: 2px 0 8px; }
.badgechip {
  margin-left: auto; background: #fff; border: 2px dashed var(--green); color: var(--green-d);
  font-weight: 900; padding: 8px 16px; border-radius: 999px;
}
.gamelist { display: flex; flex-direction: column; gap: 12px; }
.gamecard {
  display: flex; align-items: center; gap: 14px; background: #fff; border-radius: 22px;
  padding: 14px 16px; box-shadow: var(--shadow); text-align: left; transition: transform .15s;
}
.gamecard.locked { filter: grayscale(.9); opacity: .7; }
.gamecard.done { border: 2px solid var(--green); }
.gnum {
  width: 54px; height: 54px; border-radius: 18px; background: var(--sky); display: grid;
  place-items: center; font-size: 1.7rem; flex: none;
}
.bosslot { display: inline-flex; vertical-align: middle; }
.bosslot svg { width: 1.5em; height: 1.5em; display: block; }
.ginfo { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.gtitle { font-weight: 800; font-size: 1.05rem; }
.goal { color: #5b6b85; font-size: .92rem; font-weight: 600; }
.gstars { font-size: 1.15rem; font-weight: 900; color: var(--yellow-d); }

/* game */
.gamehead { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.gtitle2 { font-weight: 900; font-size: 1.2rem; }
.dots { display: flex; gap: 6px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: #c3cfff; }
.dot.cur { background: var(--yellow); transform: scale(1.25); }
.dot.on { background: var(--green); }
.stage { background: #fff; border-radius: 28px; padding: 22px 18px; box-shadow: var(--shadow); }
.stage.rin > * { animation: rin .32s backwards; }
@keyframes rin { from { opacity: 0; transform: translateY(12px); } }
.qblock { text-align: center; margin-bottom: 18px; }
.listenbtn {
  font-size: 1.5rem; width: 76px; height: 76px; border-radius: 50%; margin-top: 10px;
  background: var(--sky); border: 3px solid #b9c6ff; box-shadow: var(--shadow);
  display: inline-grid; place-items: center; transition: transform .12s;
}
.listenbtn:hover { transform: scale(1.06); }
.qsub { font-size: clamp(2.6rem, 9vw, 4rem); line-height: 1.15; margin-bottom: 8px; }
.qtext { font-size: clamp(1.15rem, 3.5vw, 1.5rem); font-weight: 800; line-height: 1.35; white-space: pre-line; }

.opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.opts.two { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); max-width: 520px; margin: 0 auto; }
.opt {
  background: var(--sky); border: 3px solid #b9c6ff; border-radius: 22px; min-height: 96px;
  padding: 14px 10px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; font-weight: 800; font-size: 1.1rem; transition: transform .12s, background .2s;
}
.opt .oe { font-size: clamp(2.2rem, 7vw, 3rem); line-height: 1; }
.opt .ot { font-size: 1.05rem; text-align: center; }
.opt .ot.solo { font-size: 1.35rem; font-weight: 900; color: #23324a; }
.mitem .ot.solo { font-size: 1.15rem; font-weight: 900; color: #23324a; }
.chip .ct.solo { font-size: 1.25rem; font-weight: 900; color: #23324a; }
.opt.good { background: #c9f2e3; border-color: #17a86a; }
.opt.bad { background: #fde3dc; border-color: var(--red); }
.opt.picked { background: #fff3cf; border-color: var(--yellow-d); }
.opt.yes { background: #c9f2e3; }
.opt.no { background: #fde3dc; }
.opt .tres { font-size: .95rem; font-weight: 900; color: #0f7a4f; }
.opt.tested { opacity: .95; }
.opt.tested.nope .tres { color: var(--red); }
/* test: kad + bar YA/TIDAK (pertimbangan sebenar, bukan ketik-lalu) */
.testhead { font-weight: 900; font-size: .9rem; color: #2b57d6; background: #eef3ff; border-radius: 12px; padding: 8px 12px; margin: 0 0 10px; text-align: center; }
.testcard { display: flex; flex-direction: column; gap: 6px; border-radius: 22px; }
.testcard > .opt { width: 100%; }
.testbar { display: flex; gap: 8px; }
.tbtn { flex: 1; min-height: 52px; border-radius: 16px; font-weight: 900; font-size: .95rem; background: #fff; border: 3px solid #b9c6ff; box-shadow: var(--shadow); }
.tbtn.yes { border-color: #17a86a; color: #0d4f43; }
.tbtn.no { border-color: var(--red); color: #a03a2c; }
.tbtn:active { transform: translateY(3px); }
.semak { margin-top: 16px; }
.semak.dim { opacity: .55; }
.multihead { font-weight: 900; font-size: .9rem; color: #2b57d6; background: #eef3ff; border-radius: 12px; padding: 8px 12px; margin: 0 0 10px; }

/* diff */
.diffwrap { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.diffrow { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
/* ponytail: width auto — kandungan (cth. 4 emoji ~280px) melebihi 84px & melimpah ke
   tengah sel jiran → klik disekat. Sel ikut kandungan; seragamkan semula jika perlu. */
.dcell { min-height: 84px; min-width: 84px; width: auto; border-radius: 18px; }

/* tray + bins (sort) */
.tray { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 6px; }
.chip {
  background: #fff; border: 3px solid #b9c6ff; border-radius: 18px; min-width: 76px; min-height: 76px;
  padding: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  touch-action: none; transition: transform .12s;
}
.chip .oe { font-size: 2.2rem; }
.chip .ct { font-size: .8rem; font-weight: 700; color: #5b6b85; }
.chip.sel { border: 3px solid #2b57d6; background: #fff3cf; box-shadow: 0 4px 0 rgba(43,87,214,.35); transform: translateY(-2px) scale(1.06); position: relative; }
.chip.sel::after { content: "\2713"; font-weight: 900; color: #2b57d6; position: absolute; right: 6px; top: 4px; margin: 0; }
.chip.good { border-color: #17a86a; background: #c9f2e3; }
.chip.junk { opacity: .75; }
.ghost {
  position: fixed; z-index: 999; pointer-events: none; transform: scale(1.1);
  box-shadow: 0 12px 24px rgba(0, 0, 0, .25); background: #fff;
}
.bins { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-top: 18px; }
.bin {
  background: #eef1ff; border: 3px dashed #a3b4ff; border-radius: 22px; padding: 12px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 130px;
}
.bin .oe { font-size: 1.9rem; }
.bin .bt { font-weight: 900; font-size: .95rem; text-align: center; }
.bslot { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; width: 100%; min-height: 44px; }
/* chip yang sudah diletak: disabled + jangan tangkap klik — supaya tap pada bin
   selepas chip pertama sampai ke bin (bukan ditelan button mati bertindan) */
.bslot .chip { min-width: 52px; min-height: 52px; border-width: 2px; pointer-events: none; }
.bslot .chip .oe { font-size: 1.6rem; }

/* match */
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mcol { display: flex; flex-direction: column; gap: 10px; }
.mitem {
  background: var(--sky); border: 3px solid #b9c6ff; border-radius: 18px; min-height: 64px;
  padding: 10px; display: flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 800; text-align: center; transition: transform .12s;
}
.mitem .oe { font-size: 1.7rem; }
.mitem.picked { border-color: var(--blue); background: #fdf3d1; }
.mitem.good { border-color: #17a86a; background: #c9f2e3; }
/* UX1: kumpulan berlabel + lencana pasangan + pilihan ketara (cahaya siang) */
.mhead { font-weight: 900; font-size: .85rem; color: #5b6b85; margin: 0 2px 2px; }
.mcol { background: #f2f6ff; border-radius: 14px; padding: 10px; }
.mcol.R { background: #fdf6ec; }
.pbadge { display: inline-flex; min-width: 22px; height: 22px; border-radius: 11px; background: #23324a; color: #fff; font-size: .8rem; font-weight: 900; align-items: center; justify-content: center; margin-left: 6px; }
.mitem.picked, .opt.picked { border: 3px solid #2b57d6; background: #fff3cf; box-shadow: 0 4px 0 rgba(43,87,214,.35); transform: translateY(-2px); }
.mitem.picked::after { content: "\2713"; font-weight: 900; color: #2b57d6; margin-left: 6px; }
.opt.picked { position: relative; }
.opt.picked::after { content: "\2713"; font-weight: 900; color: #2b57d6; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); margin: 0; }

/* order */
.answerrow {
  min-height: 84px; border: 3px dashed #a3b4ff; border-radius: 20px; margin-bottom: 16px;
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; padding: 8px;
}
.answerrow:empty::after { content: attr(data-empty); color: #7b8f8a; font-weight: 700; align-self: center; }

/* build */
.slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-bottom: 18px; }
.slot {
  background: #eef1ff; border: 3px dashed #a3b4ff; border-radius: 20px; min-height: 120px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
}
.slot .slotimg { font-size: 2.4rem; min-height: 46px; display: grid; place-items: center; }
.slot.filled { border-style: solid; border-color: #17a86a; background: #c9f2e3; }
/* slot kosong berdenyut halus sebagai pandangan tap (bbox tak berubah — selamat untuk ujian) */
.slot:not(.filled) { animation: slotglow 1.5s ease-in-out infinite; }
@keyframes slotglow { 50% { box-shadow: 0 0 0 5px rgba(15, 107, 107, .18); } }
.slot .bt { font-weight: 900; font-size: .95rem; }

/* memory */
.mempanel { text-align: center; }
.memgrid { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin: 22px 0; }
.memitem {
  font-size: clamp(2.4rem, 8vw, 3.4rem); background: var(--sky); border: 3px solid #b9c6ff;
  border-radius: 20px; padding: 14px 18px; animation: pop .4s backwards;
}
.memcount { font-size: 2rem; font-weight: 900; color: var(--blue); }

/* feedback — hanya ambil ruang bila .show; ruang mati sebelum jawapan = sifar */
.fb {
  position: sticky; bottom: 12px; margin-top: 0; border-radius: 22px; padding: 0 18px;
  max-height: 0; overflow: hidden; opacity: 0; transition: .3s; text-align: center; font-weight: 800;
}
.fb:empty { display: none; }
.fb.show { max-height: 260px; opacity: 1; padding: 14px 18px; margin-top: 16px; }
.fb.ok { background: #c9f2e3; border: 3px solid #17a86a; color: #0d4f43; }
.fb.no { background: #fff3cf; border: 3px solid var(--yellow-d); color: #7a5600; }
.fb.info { background: var(--paper); border: 3px dashed var(--blue); color: var(--ink); }
.fact { font-weight: 600; margin-top: 6px; font-size: .98rem; }
.fb b { font-size: 1.15rem; }

/* result */
.result { text-align: center; padding: 14px 0; }
.rstars { font-size: clamp(2.4rem, 9vw, 3.4rem); }
.rstars .rst { display: inline-block; animation: pop .4s backwards; animation-delay: calc(var(--i) * .22s); }
/* bintang SVG (markup datang dari app.js — kontrak W3/G10) */
.starsvg { width: 1.15em; height: 1.15em; vertical-align: -0.15em; fill: #ffe9a8; transition: fill .2s; }
.starsvg.on { fill: #ffd23f; }
.starsvg.half { fill: #ffd23f; opacity: .5; }
.rmsg { font-size: 1.3rem; font-weight: 900; margin: 10px 0; }
.rwon { color: var(--green-d); font-weight: 800; margin-bottom: 18px; }
.rowbtns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.btn {
  background: #eef1ff; border: 3px solid #b9c6ff; border-radius: 999px; padding: 14px 24px;
  font-weight: 900; font-size: 1rem; transition: transform .12s;
}
.btn.primary { background: var(--green); border-color: var(--green-d); color: #fff; }

/* celebration */
.celebrate {
  position: fixed; inset: 0; background: rgba(20, 35, 60, .55); display: grid; place-items: center;
  z-index: 100; padding: 20px;
}
.celcard {
  background: var(--paper); border-radius: 30px; padding: 34px 28px; text-align: center;
  max-width: 460px; width: 100%; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); animation: pop .4s;
}
.celicon { font-size: 3.4rem; }
.celcard h2 { margin: 10px 0 6px; font-size: 1.5rem; color: var(--blue); }
.celcard p { color: #4a5a74; font-weight: 600; margin-bottom: 16px; }
.conf { color: var(--yellow-d); letter-spacing: .3em; animation: floaty 1.6s infinite alternate; }

/* nama */
.namecard {
  background: #fff; border-radius: 30px; box-shadow: var(--shadow); max-width: 460px;
  margin: 6vh auto 0; padding: 34px 26px; text-align: center; display: flex;
  flex-direction: column; gap: 14px; align-items: center; animation: pop .35s;
}
.nameicon { font-size: 3.6rem; }
.namecard h1, .namecard h2 { margin: 0; font-size: clamp(1.5rem, 6vw, 2rem); color: var(--blue); }
.namecard p { color: #5b6b85; font-weight: 700; }
.nameinput {
  width: 100%; font: inherit; font-size: 1.4rem; font-weight: 800; text-align: center;
  padding: 16px; border: 3px solid #b9c6ff; border-radius: 20px; background: var(--sky);
  outline: none;
}
.nameinput:focus { border-color: var(--blue); }
.nameinput::placeholder { color: #9aa7c0; font-weight: 700; }
/* avatar bulat premium — seluruh bulatan boleh ketik, kapsyen jelaskan pilihan */
.avarow { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.avawrap { position: relative; }
.avacircle { display: block; width: 96px; height: 96px; border-radius: 50%; cursor: pointer; position: relative; outline: none; }
.avacircle:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
.avacircle .avano { display: flex; align-items: center; justify-content: center; width: 96px; height: 96px; font-size: 2.6rem; border-radius: 50%; background: var(--sky); border: 3px dashed #ffd88a; }
.avacircle.filled .ava { width: 96px; height: 96px; border: 3px solid #ffd88a; box-shadow: var(--shadow); }
.avaplus { position: absolute; right: 0; bottom: 0; width: 30px; height: 30px; line-height: 26px; border-radius: 50%; background: #12803c; color: #fff; font-size: 1.4rem; font-weight: 900; border: 3px solid #fff; }
.avacap { font-size: .8rem; color: #8a97ad; font-weight: 800; }
.avadel { position: absolute; top: -6px; right: -6px; width: 30px; height: 30px; line-height: 1; border-radius: 50%; border: 2px solid #fff; background: #fff; box-shadow: var(--shadow); font-size: 1.2rem; color: #c0392b; cursor: pointer; }
.ava { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; border: 3px solid #b9c6ff; background: var(--sky); }
.ava.small { width: 34px; height: 34px; border-width: 2px; vertical-align: -9px; margin-right: 6px; }
.ava.small { width: 34px; height: 34px; border-width: 2px; vertical-align: -9px; margin-right: 6px; }
.btn.big { font-size: 1.2rem; padding: 18px 34px; width: 100%; }
.editname {
  font-size: .95rem; background: #fff; border-radius: 999px; padding: 4px 10px;
  box-shadow: var(--shadow); vertical-align: middle; margin-left: 6px;
  min-width: 44px; min-height: 44px; /* saiz sentuh minimum */
}

/* animasi Lottie (SVG) */
.lolli { display: grid; place-items: center; }
.lolli svg { width: 100%; height: 100%; }
.hero { width: min(74vw, 210px); height: 132px; margin: 0 auto -6px; }
.namepic { width: min(260px, 70vw); height: min(260px, 70vw); margin-top: -6px; }
.langpic { width: 110px; height: 110px; }
.rstar { width: 96px; height: 96px; margin: 0 auto -6px; }
.fbicon { display: inline-block; width: 46px; height: 46px; vertical-align: -12px; margin-right: 6px; }
.fbicon svg { width: 100%; height: 100%; }
.celicon.big { width: 150px; height: 150px; margin: 0 auto; }
.celicon svg { width: 100%; height: 100%; }

/* pilih bahasa */
.langrow { display: flex; gap: 14px; width: 100%; flex-wrap: wrap; }
.langbtn {
  flex: 1 1 160px; background: var(--sky); border: 3px solid #b9c6ff; border-radius: 24px;
  padding: 20px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  font-weight: 900; font-size: 1.05rem; transition: transform .12s;
}
.langbtn:hover { transform: translateY(-3px); }
.langbtn.on { border-color: #17a86a; background: #c9f2e3; }
.langbtn .flag { font-size: 2.4rem; }

@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
/* konfeti — lapisan tetap, tak menyekat klik */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 95; overflow: hidden; }
.cf { position: absolute; top: -7vh; font-size: 1.7rem; animation: cfdrop 1.15s cubic-bezier(.25, .7, .4, 1) forwards; animation-delay: var(--d, 0s); }
@keyframes cfdrop { to { transform: translateY(115vh) translateX(var(--x, 0)) rotate(340deg); } }
@keyframes floaty { from { transform: translateY(-4px); } to { transform: translateY(4px); } }
.shake { animation: shk .35s; }
@keyframes shk { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-7px)} 75%{transform:translateX(7px)} }

@media (max-width: 560px) {
  html { font-size: 16px; }
  .opt { min-height: 84px; }
  .match { grid-template-columns: 1fr; }
  /* diff: sel kekal boleh ketik (min 76px sasaran sentuh) — glyph hampir serupa (🐪/🐫) perlu ruang */
  .dcell { min-width: 76px; width: auto; min-height: 76px; }
  /* kepala game: tajuk penuh sebaris sendiri, Soalan+dots kanan di bawahnya */
  .gamehead { gap: 4px 8px; flex-wrap: wrap; }
  .gtitle2 { flex: 1 1 100%; min-width: 0; font-size: 1.05rem; }
  .dots { flex: none; gap: 4px; margin-left: auto; }
  .dot { width: 9px; height: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ——— engine aras 3+: passage · cloze · label · input ——— */
.passage {
  background: #fff4d6; border: 3px solid #ffd67e; border-radius: 18px; padding: 14px 16px;
  font-size: clamp(1rem, 3vw, 1.15rem); font-weight: 700; line-height: 1.5; text-align: left;
  margin: 0 auto 12px; max-width: 640px;
}
.clozeline {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 8px;
  font-size: clamp(1.05rem, 3.2vw, 1.35rem); font-weight: 800; line-height: 1.8;
  background: var(--paper); border-radius: 18px; padding: 14px; margin-bottom: 14px;
}
.ctext { white-space: pre-wrap; }
/* huruf Jawi/Arab dalam ayat cloze ({e:"…"}) — fon skrip, saiz lebih besar & terasing RTL */
.ctext.cte {
  font-family: "Traditional Arabic", "Scheherazade New", "Amiri", "Noto Naskh Arabic",
               "Segoe UI Historic", serif;
  font-size: 1.9em; line-height: 1; direction: rtl; unicode-bidi: isolate;
  padding: 0 2px; color: #1f2d44;
}
.blank {
  min-width: 92px; min-height: 52px; padding: 6px 12px; border-radius: 14px;
  border: 3px dashed #a3b4ff; background: #eef1ff; font-weight: 900; font-size: 1.1rem;
  display: inline-grid; place-items: center; vertical-align: middle;
}
.blank.filled { border-style: solid; border-color: #17a86a; background: #c9f2e3; }
/* blank masih kosong: denyut lembut jemput ketik perkataan di bawah (tidak gerak layout) */
.blank.need:not(.filled) { animation: needpulse 1.8s ease-in-out infinite; }
@keyframes needpulse { 50% { box-shadow: 0 0 0 6px rgba(43, 87, 214, .22); background: #fff; } }
@media (prefers-reduced-motion: reduce) { .blank.need:not(.filled) { animation: none; } }
.labelarea {
  position: relative; width: 100%; max-width: 540px; aspect-ratio: 1 / 1;
  margin: 0 auto 16px; border: 3px solid #b9c6ff; border-radius: 24px;
  background: linear-gradient(#eef1ff, #dbe7ff); overflow: hidden;
}
.labelbg {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: clamp(7rem, 28vw, 14rem); line-height: 1;
}
.slot.lbl {
  position: absolute; transform: translate(-50%, -50%); min-height: 0; min-width: 74px;
  padding: 4px 6px; background: rgba(255, 255, 255, .92);
}
.slot.lbl .bt { font-size: .8rem; }
.slot.lbl .slotimg { font-size: 1.8rem; min-height: 28px; }
.typeinput {
  display: block; width: min(420px, 100%); margin: 0 auto 14px; padding: 14px 16px;
  font-size: 1.3rem; font-weight: 800; text-align: center; border-radius: 18px;
  border: 3px solid #a3b4ff; background: #fff; font-family: inherit;
}
.typeinput:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

/* butang petunjuk (💡) — muncul apabila round ada medan `hint` */
.hintbtn {
  font-size: 1.35rem; width: 52px; height: 52px; border-radius: 50%; margin: 8px 4px 0;
  background: #fff4d6; border: 3px solid #ffd67e; box-shadow: var(--shadow);
  display: inline-grid; place-items: center; transition: transform .12s;
}
.hintbtn:hover { transform: scale(1.08); }
.hintbtn:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

/* ——— jiwa v2: sticker pop + gerakan (transform/opacity sahaja; hormat reduced-motion) ——— */
.opt, .chip, .mitem, .btn, .langbtn { box-shadow: 0 4px 0 rgba(35, 50, 74, .15); }
.opt:active, .chip:active, .mitem:active, .btn:active, .iconbtn:active, .gamecard:active,
.worldcard:active, .langbtn:active, .listenbtn:active, .hintbtn:active { transform: translateY(3px); }
.btn.primary {
  background: linear-gradient(#6f9dff, var(--green)); border-color: var(--green-d); color: #fff;
  box-shadow: 0 5px 0 var(--green-d);
}
.btn.primary:active { box-shadow: 0 1px 0 var(--green-d); }
.trophy { box-shadow: 0 4px 0 #d9a514, 0 8px 18px rgba(35, 50, 74, .12); }
.celcard { border: 4px solid var(--yellow); }
@keyframes punch { 0% { transform: scale(1); } 40% { transform: scale(1.09); } 70% { transform: scale(.98); } 100% { transform: scale(1); } }
.opt.good, .chip.good, .mitem.good, .blank.filled, .slot.filled { animation: punch .35s; }
@keyframes hop { 0% { transform: translateY(0); } 45% { transform: translateY(-9px) scale(1.08); } 75% { transform: translateY(0) scale(.97, 1.03); } 100% { transform: translateY(0); } }
.gmascot { display: inline-block; font-size: 1.5rem; margin-right: 6px; animation: floaty 1.8s infinite alternate; }
.gmascot.hop { animation: hop .55s; }
.celmascot { font-size: 3.4rem; animation: hop 1.1s infinite; }
.wicon { animation: floaty 2.4s infinite alternate; }
.dot.cur { animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1.25); } 50% { transform: scale(1.5); } }
.rstars .rst { animation: stpop .55s backwards; animation-delay: calc(var(--i) * .22s); }
@keyframes stpop { 0% { transform: scale(.3) translateY(18px); opacity: 0; } 60% { transform: scale(1.25) translateY(-8px); opacity: 1; } 100% { transform: scale(1) translateY(0); } }
.starsvg.on { filter: drop-shadow(0 2px 0 rgba(35, 50, 74, .2)); }
.cf { font-size: 2.1rem; animation: cfdrop 1.5s cubic-bezier(.25, .7, .4, 1) forwards; animation-delay: var(--d, 0s); }
/* ——— pemuat berjenama (ganti #app kosong sebelum render pertama; render ganti innerHTML) ——— */
.eqload { text-align: center; padding: 16vh 16px 40px; color: #5b6b85; font-weight: 800; }
.eqload-r { font-size: 3rem; animation: eqfly 1.1s infinite ease-in-out; }
.eqload-s { font-size: 1.1rem; letter-spacing: .35em; text-indent: .35em; animation: eqtw 1.1s infinite ease-in-out; }
.eqload p { margin: 10px 0 0; font-size: .95rem; }
@keyframes eqfly { 0%, 100% { transform: translateY(8px) rotate(-8deg); } 50% { transform: translateY(-10px) rotate(6deg); } }
@keyframes eqtw { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
/* B/M3 — jurulatih tunjuk-cara sekali setiap jenis */
.coach { position: fixed; inset: 0; background: rgba(20,28,45,.55); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px; }
.coachcard { background: #fff; border-radius: 18px; padding: 18px 16px; max-width: 320px; width: 100%; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.3); }
.coachcard p { font-weight: 800; color: #23324a; margin: 10px 0 12px; }
.ghostrow { display: flex; align-items: center; justify-content: center; gap: 14px; }
.gdot { width: 26px; height: 26px; border-radius: 8px; background: #dce6ff; border: 2px dashed #2b57d6; }
.ghost { font-size: 1.8rem; animation: tapdemo 1.6s ease-in-out infinite; }
@keyframes tapdemo { 0%, 100% { transform: translateX(-22px); } 50% { transform: translateX(22px); } }
@media (prefers-reduced-motion: reduce) { .ghost { animation: none; } }
.coachq { margin-left: 8px; border: 2px solid #a3b4ff; background: #eef1ff; color: #2b57d6; border-radius: 50%; width: 28px; height: 28px; font-weight: 900; cursor: pointer; }

/* ——— crop avatar bulat ——— */
.cropsheet{position:fixed;inset:0;z-index:1200;background:rgba(20,28,45,.62);display:flex;align-items:center;justify-content:center;padding:16px}
.cropcard{background:#fff;border-radius:22px;padding:18px;max-width:320px;width:100%;text-align:center;box-shadow:0 18px 50px rgba(0,0,0,.35)}
.cropview{width:240px;height:240px;border-radius:50%;overflow:hidden;position:relative;margin:2px auto 10px;touch-action:none;background:#101a2e;outline:3px solid #2b57d6;cursor:grab}
.cropview:active{cursor:grabbing}
.cropview:focus-visible{outline:4px solid #ffb020}
.cropimg{position:absolute;max-width:none;user-select:none;-webkit-user-select:none;pointer-events:none}
.croprow{display:flex;gap:10px;justify-content:center;margin:8px 0}
.cbtn{width:44px;height:44px;border-radius:12px;border:2px solid #d7e1ff;background:#eef3ff;font-size:1.3rem;font-weight:900;color:#2b57d6}
.cropuse,.cropcancel{flex:1}

/* UX8 pin label (§A) — slot bernombor, gaya pin peta */
.slot.lbl{min-width:96px;min-height:56px;border:3px dashed #7d8ff0;background:rgba(255,255,255,.92);border-radius:16px}
.pinnum{display:inline-grid;place-items:center;width:26px;height:26px;border-radius:50%;background:#23324a;color:#fff;font-weight:900;font-size:.85rem;margin-right:4px;vertical-align:middle}
.slot.lbl::before{content:"";position:absolute;left:50%;bottom:-9px;transform:translateX(-50%);width:8px;height:8px;border-radius:50%;background:#7d8ff0}
.slot.lbl.filled{border-style:solid;border-color:#17a86a;background:#c9f2e3}
.slot.lbl.filled::before{background:#17a86a}
.slot.lbl.filled::after{content:"\2713";position:absolute;right:4px;top:2px;font-weight:900;color:#17a86a;font-size:1rem}
.slot.lbl .bt{font-size:.9rem}
/* UX9 drag-glow (§B) — outline sahaja: transform akan pecahkan penentududukan .slot.lbl (translate -50%,-50%) */
.droptgt{outline:3px solid #2b57d6;outline-offset:2px;filter:brightness(1.07)}
@media (prefers-reduced-motion:reduce){.droptgt{filter:none}}
/* UX11 petunjuk bijak (§D+§E) — denyut outline sahaja (tiada transform: .slot.lbl guna translate -50%,-50%) */
.hintpulse{animation:hpulse 1.9s ease-out}
@keyframes hpulse{0%{outline:3px solid #2b57d6;outline-offset:2px}70%{outline:6px solid rgba(43,87,214,.35);outline-offset:6px}100%{outline:3px solid transparent}}
@media (prefers-reduced-motion:reduce){.hintpulse{animation:none;outline:3px solid #2b57d6;outline-offset:2px}}
/* Kertas Conteng (workspace) — helaian conteng soalan Matematik berfikir */
.wsbtn { margin-left: 8px; border: 2px solid #a3b4ff; background: #eef1ff; border-radius: 14px; min-width: 58px; min-height: 58px; font-size: 28px; cursor: pointer; }
.ws { position: fixed; inset: 0; background: rgba(20,24,60,.55); z-index: 90; display: flex; align-items: flex-end; justify-content: center; }
.wscard { background: #fffdf5; width: 100%; max-width: 560px; border-radius: 22px 22px 0 0; padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); }
.ws-canvas { width: 100%; height: 52vh; min-height: 300px; background: #fff; border: 2px solid #e5ddc4; border-radius: 14px; touch-action: none; }
.wsrow { display: flex; gap: 10px; margin-top: 10px; }
.wsrow .btn { min-height: 58px; flex: 1; }
/* Exam menyusul lock: padding sisi skrin kecil (kad bawa gaya inline sendiri) */
#saExamEmpty{padding-left:16px;padding-right:16px;box-sizing:border-box;}
/* structured (Kertas-2 a/b/c) — enjin menulis .structbox/.structrecap/.structcur/.structdone */
.structbox { margin: 6px auto 0; width: min(520px, 100%); }
.structrecap { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.structdone { background: #e8f7f0; border: 2px solid #17a86a; border-radius: 14px; padding: 8px 12px; font-weight: 800; font-size: .92rem; color: #0d4f43; text-align: left; }
.structcur { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.structcur .qtext { text-align: left; width: 100%; }
.structcur .typeinput { margin-bottom: 0; }
/* ── profil anak (M1) ── */
.profchip{width:44px;height:44px;border-radius:50%;display:grid;place-items:center;font-weight:900;font-size:.85rem;background:rgba(255,255,255,.85);color:#1e3a8a;border:1.5px solid #93c5fd;padding:0;overflow:hidden}
.profchip img{width:100%;height:100%;object-fit:cover;display:block}
.profsheet{position:fixed;inset:0;z-index:9000;background:rgba(15,23,42,.55);display:flex;align-items:flex-end;justify-content:center}
.profbox{position:relative;background:#fff;width:100%;max-width:520px;border-radius:22px 22px 0 0;padding:18px 18px 24px;box-shadow:0 -12px 40px rgba(15,23,42,.25);max-height:88vh;overflow:auto}
.profbox h3{margin:2px 0 12px;font-size:1.05rem;font-weight:900;color:#1e293b}
.profrow{display:flex;align-items:center;gap:12px;width:100%;background:#f8fafc;border:2px solid #e2e8f0;border-radius:14px;padding:10px 12px;margin:8px 0;min-height:56px;cursor:pointer;text-align:left}
.profrow[aria-current="true"]{border-color:#2563eb;background:#eff6ff}
.profava{width:38px;height:38px;border-radius:50%;object-fit:cover;flex:0 0 38px}
.profini{width:38px;height:38px;border-radius:50%;flex:0 0 38px;display:grid;place-items:center;background:#dbeafe;color:#1e3a8a;font-weight:900}
.profname{font-weight:800;color:#1e293b;flex:1;overflow-wrap:anywhere}
.profadd{margin-top:10px;width:100%;min-height:48px;border-radius:14px;border:2px dashed #93c5fd;background:#f8fbff;color:#1d4ed8;font-weight:800;cursor:pointer}
.profnote{font-size:.8rem;color:#64748b;margin:8px 0 0;line-height:1.5}
.profclose{position:absolute;top:10px;right:12px;border:0;background:none;font-size:1.3rem;color:#334155;cursor:pointer}
