/* =========================================================
   Robo Matematika — gaya tampilan
   ========================================================= */
/* Font Baloo 2 disimpan lokal (SIL Open Font License, lihat css/fonts/OFL.txt) — tanpa permintaan ke Google Fonts */
@font-face {
  font-family: 'Baloo 2'; font-style: normal; font-weight: 500 800; font-display: swap;
  src: url('fonts/baloo2-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Baloo 2'; font-style: normal; font-weight: 500 800; font-display: swap;
  src: url('fonts/baloo2-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #FFF7EC;
  --bg-dots: #FBE6C8;
  --card: #FFFFFF;
  --ink: #1F2A44;
  --ink-soft: #5B6782;
  --line: #E8DCCB;
  --go: #22B35E;
  --go-dark: #178A47;
  --soft: #F6F1EA;
  --danger: #E5484D;
  --gold: #FFC531;
  --tier: #FF8A3D;
  --radius: 22px;
  --shadow: 0 6px 0 rgba(31, 42, 68, .08), 0 12px 28px rgba(31, 42, 68, .10);
  --font: 'Baloo 2', 'Nunito', 'Trebuchet MS', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; font-family: var(--font); color: var(--ink);
  background-color: var(--bg);
  background-image: radial-gradient(var(--bg-dots) 2px, transparent 2.5px);
  background-size: 26px 26px;
  -webkit-tap-highlight-color: transparent; overflow-x: hidden;
}
button, select { font-family: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, [tabindex]:focus-visible, select:focus-visible { outline: 4px solid #FFB020; outline-offset: 3px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; }
svg text { font-family: var(--font); }

#app { max-width: 980px; margin: 0 auto; padding: 0 16px 48px; }
.screen { display: none; }
.screen.active { display: block; animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- tombol ---------- */
.btn {
  border: 0; border-radius: 999px; padding: 12px 22px; font-size: 1.1rem; font-weight: 700;
  background: var(--soft); box-shadow: 0 4px 0 rgba(31, 42, 68, .15);
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(31, 42, 68, .15); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-go { background: var(--go); color: #fff; box-shadow: 0 4px 0 var(--go-dark); }
.btn-go:active { box-shadow: 0 1px 0 var(--go-dark); }
.btn-soft { background: #fff; border: 2px solid var(--line); }
.btn-danger { background: #fff; color: var(--danger); border: 2px solid #F6C6C8; }
.btn-big { font-size: 1.5rem; padding: 16px 40px; }
.btn-small { font-size: .95rem; padding: 8px 16px; }
.icon-btn {
  flex: none; width: 48px; height: 48px; border-radius: 16px; border: 2px solid var(--line);
  background: #fff; font-size: 1.35rem; display: grid; place-items: center; box-shadow: 0 3px 0 rgba(31, 42, 68, .1);
}
.icon-btn:active { transform: translateY(2px); box-shadow: none; }
.fs-btn svg { width: 58%; height: 58%; }
.home-corner { position: absolute; top: max(14px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right)); z-index: 2; }
html:fullscreen { background: var(--bg); overflow-y: auto; }
html:-webkit-full-screen { background: var(--bg); overflow-y: auto; }

/* ---------- beranda ---------- */
#screen-home.active { display: grid; place-items: center; min-height: 100vh; position: relative; }
.home-card {
  position: relative; z-index: 1; text-align: center; background: var(--card); border-radius: 36px;
  padding: 28px 28px 32px; box-shadow: var(--shadow); max-width: 470px; width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.home-bot { width: 150px; height: 150px; margin-top: -90px; filter: drop-shadow(0 8px 10px rgba(31,42,68,.15)); }
.home-bot svg, .win-bot svg, .coach-bot svg { width: 100%; height: 100%; display: block; }
.logo { font-size: clamp(2.3rem, 8.5vw, 3.3rem); font-weight: 800; letter-spacing: -.5px; }
.logo .l1 { color: #2F8CF0; }
.logo .l2 { color: #FF8A3D; }
.home-sub { margin: 0; color: var(--ink-soft); font-size: 1.15rem; }
.home-stars { font-size: 1.2rem; background: #FFF1C9; padding: 6px 16px; border-radius: 999px; margin: 4px 0 8px; }
.home-shapes { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.home-shapes .fs {
  position: absolute; width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center;
  font-size: 2.4rem; font-weight: 800; color: #fff; box-shadow: 0 4px 0 rgba(0,0,0,.12); animation: float 6s ease-in-out infinite;
}
.fs1 { top: 10%; left: 6%; background: #FF8A3D; } .fs2 { top: 15%; right: 8%; background: #2F8CF0; animation-delay: -1s !important; }
.fs3 { bottom: 14%; left: 9%; background: #8B5CF6; animation-delay: -2s !important; } .fs4 { bottom: 10%; right: 10%; background: #22B35E; animation-delay: -3s !important; }
.fs5 { top: 48%; left: 2%; background: #E5488F; animation-delay: -4s !important; } .fs6 { top: 44%; right: 3%; background: #0E9F9A; animation-delay: -5s !important; }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-16px) rotate(10deg); } }
.bob { animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

/* ---------- bar atas ---------- */
.topbar { display: flex; align-items: center; gap: 10px; padding: 14px 0 10px; position: sticky; top: 0; z-index: 5; background: linear-gradient(var(--bg) 75%, transparent); }
#screen-play .topbar { position: static; background: none; }
.topbar-title { font-size: clamp(1.2rem, 4vw, 1.65rem); min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.lvl-head { flex: 1; min-width: 0; }
.lvl-kicker { font-size: .88rem; color: var(--tier); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-stars { background: #FFF1C9; border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.intro { color: var(--ink-soft); margin: 0 0 16px; font-size: 1.05rem; }

/* ---------- pilih kelas ---------- */
.grade-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.grade-card {
  text-align: left; border: 0; background: var(--card); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
  border-top: 8px solid var(--tier); display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; transition: transform .1s;
}
.grade-card:hover { transform: translateY(-2px); }
.grade-card:active { transform: translateY(2px); }
.gc-emoji { grid-row: span 2; font-size: 2.3rem; width: 64px; height: 64px; display: grid; place-items: center; border-radius: 20px; background: color-mix(in srgb, var(--tier) 15%, white); }
.gc-body { display: flex; flex-direction: column; }
.gc-kicker { font-size: .85rem; font-weight: 700; color: var(--tier); }
.gc-name { font-size: 1.55rem; font-weight: 800; line-height: 1.1; }
.gc-note { color: var(--ink-soft); font-size: .95rem; line-height: 1.3; margin-top: 2px; }
.gc-foot { grid-column: 2; display: flex; flex-direction: column; gap: 4px; }
.gc-bar { height: 10px; background: #EEE6DA; border-radius: 99px; overflow: hidden; }
.gc-bar i { display: block; height: 100%; background: var(--tier); border-radius: 99px; }
.gc-stats { display: flex; justify-content: space-between; font-weight: 700; font-size: .9rem; color: var(--ink-soft); }

/* ---------- daftar topik ---------- */
.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.topic {
  border: 3px solid color-mix(in srgb, var(--tier) 35%, white); background: #fff; border-radius: 20px; padding: 12px 14px;
  display: flex; gap: 12px; align-items: center; text-align: left; box-shadow: 0 4px 0 color-mix(in srgb, var(--tier) 35%, white); transition: transform .1s;
}
.topic:hover { transform: translateY(-2px); }
.topic:active { transform: translateY(3px); box-shadow: none; }
.topic.done { background: color-mix(in srgb, var(--tier) 7%, white); }
.tp-emoji { font-size: 2rem; width: 54px; height: 54px; flex: none; display: grid; place-items: center; border-radius: 16px; background: color-mix(in srgb, var(--tier) 14%, white); }
.tp-body { display: flex; flex-direction: column; min-width: 0; }
.tp-title { font-weight: 800; font-size: 1.08rem; line-height: 1.2; }
.tp-desc { font-size: .9rem; color: var(--ink-soft); }
.tp-foot { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.tp-need { font-size: .75rem; font-weight: 800; color: #8A6D00; background: #FFF3C4; border-radius: 99px; padding: 0 8px; }
.tp-lv { font-size: .75rem; font-weight: 700; color: var(--tier); background: color-mix(in srgb, var(--tier) 12%, white); border-radius: 99px; padding: 0 8px; }
.stars-mini i { font-style: normal; color: #DDD3C4; font-size: 1.15rem; }
.stars-mini i.on { color: var(--gold); text-shadow: 0 1px 0 #D99A00; }
.grade-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 20px; }

/* ---------- sesi soal ---------- */
.play-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.qdots { display: flex; gap: 6px; }
.qdots i { width: 16px; height: 16px; border-radius: 50%; background: #E9E0D3; transition: transform .2s; }
.qdots i.now { background: #fff; box-shadow: inset 0 0 0 3px var(--tier); transform: scale(1.15); }
.qdots i.ok { background: var(--go); }
.qdots i.late { background: var(--gold); }
.qdots i.miss { background: #F59E9E; }
.lv-badge { font-weight: 700; font-size: .9rem; color: var(--ink-soft); background: #fff; border: 2px solid var(--line); border-radius: 99px; padding: 2px 12px; display: flex; align-items: center; gap: 4px; }
.lv-dots { display: inline-flex; gap: 3px; }
.lv-dots i { width: 9px; height: 9px; border-radius: 50%; background: #E3D9CB; }
.lv-dots i.on { background: var(--tier); }
.coach { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.coach-bot { width: 64px; height: 64px; flex: none; }
.coach-bot.jump { animation: jump .5s ease; }
@keyframes jump { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-14px); } }
.bubble {
  position: relative; background: #fff; border-radius: 20px; padding: 12px 16px; font-size: clamp(1.05rem, 3.4vw, 1.3rem);
  font-weight: 700; box-shadow: var(--shadow); line-height: 1.35; flex: 1;
}
.bubble::before { content: ''; position: absolute; left: -10px; top: 50%; margin-top: -10px; border: 10px solid transparent; border-right-color: #fff; border-left: 0; }
.stage { background: var(--card); border-radius: var(--radius); padding: clamp(14px, 3vw, 22px); box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 16px; }
.stage.locked { pointer-events: none; }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
.tip { margin: -6px 0 0; color: var(--ink-soft); font-size: .95rem; text-align: center; }
.check-btn { min-width: 200px; font-size: 1.25rem; }

.feedback:empty { display: none; }
.feedback { margin-top: 14px; border-radius: 18px; padding: 12px 16px; font-size: 1.08rem; line-height: 1.45; animation: fadeIn .25s; }
.feedback.hint { background: #FFF6D8; border: 2px solid #F4D77B; display: flex; gap: 10px; align-items: flex-start; }
.fb-ico { font-size: 1.4rem; line-height: 1.2; }
.feedback.explain { background: #EAF7EF; border: 2px solid #9FDDB6; }
.feedback.explain h3 { font-size: 1.2rem; margin-bottom: 4px; }
.feedback.explain p { margin: 0 0 10px; }
.fb-btns { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
.fb-btns .check-btn { min-width: 160px; }

/* ---------- teks hitung & pecahan ---------- */
.expr { font-size: clamp(1.9rem, 7vw, 2.8rem); font-weight: 800; text-align: center; line-height: 1.2; display: flex; align-items: center; justify-content: center; gap: .35em; flex-wrap: wrap; }
.qmark { display: inline-grid; place-items: center; min-width: 1.4em; padding: 0 .15em; border-radius: 12px; background: color-mix(in srgb, var(--tier) 16%, white); color: var(--tier); }
.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; line-height: 1; margin: 0 .08em; font-weight: 800; }
.frac > span { padding: 0 .12em; }
.frac > span:first-child { border-bottom: .09em solid currentColor; padding-bottom: .06em; }
.frac > span:last-child { padding-top: .06em; }
.bubble .frac, .feedback .frac, .story .frac { font-size: .9em; }
.expr .frac { font-size: .82em; }
.expr .frac .qmark { min-width: 1.1em; }

/* ---------- keypad ---------- */
.keypad { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; max-width: 330px; }
.kp-disp { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 2rem; font-weight: 800; }
.kp-box {
  min-width: 130px; height: 64px; border-radius: 16px; border: 3px solid var(--tier); background: #fff; font-size: 2rem; font-weight: 800;
  padding: 0 14px; display: grid; place-items: center;
}
.kp-box.empty { color: #CBBFAE; }
.kp-disp.is-frac .kp-box { min-width: 90px; height: 54px; border-color: #D8CCBB; }
.kp-disp.is-frac .kp-box.focus { border-color: var(--tier); box-shadow: 0 0 0 4px color-mix(in srgb, var(--tier) 20%, white); }
.kp-fr { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.kp-bar { display: block; width: 110px; height: 5px; border-radius: 3px; background: var(--ink); }
.kp-unit { font-size: 1.4rem; color: var(--ink-soft); }
.kp-disp.reveal .kp-box { border-color: var(--go); background: #EAF7EF; color: var(--go-dark); }
.kp-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; }
.kp-key {
  height: 58px; border-radius: 16px; border: 2px solid var(--line); background: #fff; font-size: 1.6rem; font-weight: 800;
  box-shadow: 0 3px 0 rgba(31, 42, 68, .1);
}
.kp-key:active { transform: translateY(2px); box-shadow: none; background: #FFF4E5; }
.kp-fn { background: var(--soft); }
.kp-go { width: 100%; font-size: 1.3rem; }

/* ---------- pilihan ---------- */
.choices { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; width: 100%; }
.choice {
  min-width: 76px; min-height: 60px; padding: 8px 18px; border-radius: 18px; border: 3px solid var(--line); background: #fff;
  font-size: 1.5rem; font-weight: 800; box-shadow: 0 4px 0 rgba(31, 42, 68, .1); transition: transform .08s;
}
.choice:active { transform: translateY(3px); box-shadow: none; }
.choices.words .choice { font-size: 1.15rem; flex: 1 1 40%; max-width: 280px; }
.choices.signs .choice { font-size: 2.2rem; min-width: 84px; }
.choices.fracs .choice { font-size: 1.6rem; min-width: 84px; }
.choice.right { border-color: var(--go); background: #DDF5E6; color: var(--go-dark); }
.choice.wrong { border-color: #F3B4B4; background: #FDECEC; color: #C2474B; text-decoration: line-through; opacity: .75; }

/* ---------- hitung & bandingkan ---------- */
.count-grid { display: grid; grid-template-columns: repeat(5, auto); gap: 6px; justify-content: center; }
.count-grid.big .cnt { font-size: clamp(1.9rem, 7vw, 2.6rem); }
.cnt { position: relative; border: 0; background: none; font-size: 1.8rem; line-height: 1.1; padding: 2px; border-radius: 12px; }
.cnt.counted { background: #FFF1C9; }
.cnt.counted::after {
  content: attr(data-n); position: absolute; right: -4px; top: -6px; background: var(--tier); color: #fff; font-size: .8rem; font-weight: 800;
  min-width: 22px; height: 22px; border-radius: 11px; display: grid; place-items: center; padding: 0 4px;
}
.cmp-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: 100%; }
.cmp-box { border: 3px solid var(--line); border-radius: 20px; background: #FFFBF5; padding: 14px 8px; min-height: 120px; display: grid; place-items: center; box-shadow: 0 4px 0 rgba(31,42,68,.08); }
.cmp-box.right { border-color: var(--go); background: #DDF5E6; }
.cmp-box.wrong { border-color: #F3B4B4; background: #FDECEC; }
.cmp-row > * { min-width: 0; }
.cmp-box .count-grid { gap: 2px; }
.cmp-box .cnt { font-size: clamp(1.05rem, 4.6vw, 1.9rem); padding: 0; }
.sign-row { display: flex; align-items: center; justify-content: center; gap: 18px; }
.sign-num { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.sign-num b { font-size: 3rem; line-height: 1; }
.sign-slot { width: 64px; height: 64px; border-radius: 16px; border: 3px dashed var(--tier); display: inline-grid; place-items: center; font-size: 2rem; color: var(--tier); font-weight: 800; }
.dot-i { width: 16px; height: 16px; border-radius: 50%; background: #FF8A3D; display: inline-block; }
.dot-i.b { background: #2F8CF0; }
.dot-i.x { background: #E3D9CB; position: relative; }
.dot-i.x::after { content: ''; position: absolute; left: -3px; right: -3px; top: 7px; height: 3px; background: var(--danger); transform: rotate(-35deg); border-radius: 2px; }
.count-grid.small { gap: 5px; }
.aid-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: center; }
.aid-op { font-size: 2rem; font-weight: 800; color: var(--ink-soft); }
.aid-groups { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 520px; }
.aid-group { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; border: 2px dashed #E3D2BC; border-radius: 12px; max-width: 120px; justify-content: center; }

/* ---------- bersusun ---------- */
.colsum { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; background: #FFFBF5; border-radius: 16px; padding: 10px 18px; border: 2px solid var(--line); }
.cs-row { display: flex; }
.cs-op, .cs-d { width: 1.15em; text-align: center; }
.cs-op { color: var(--tier); }
.cs-d.q { color: #CBBFAE; }
.cs-line { height: 4px; background: var(--ink); border-radius: 2px; margin: 4px 0; }

/* ---------- pola ---------- */
.train { display: flex; align-items: flex-end; gap: 6px; flex-wrap: wrap; justify-content: center; }
.train-loco { font-size: 2.6rem; transform: scaleX(-1); }
.car {
  min-width: 64px; height: 58px; border-radius: 12px; background: #fff; border: 3px solid var(--tier); font-size: 1.6rem; font-weight: 800;
  display: grid; place-items: center; position: relative; padding: 0 6px; margin-bottom: 10px;
}
.car::before, .car::after { content: ''; position: absolute; bottom: -12px; width: 14px; height: 14px; border-radius: 50%; background: var(--ink); }
.car::before { left: 10px; } .car::after { right: 10px; }
.car.miss { background: color-mix(in srgb, var(--tier) 15%, white); color: var(--tier); border-style: dashed; }

/* ---------- garis bilangan ---------- */
.nl-wrap { width: 100%; overflow-x: auto; border-radius: 14px; }
.nl { display: block; width: 100%; height: auto; cursor: pointer; touch-action: manipulation; }
.nl-lab { font-size: 23px; font-weight: 700; fill: var(--ink); }
.nl-lab.sm { font-size: 23px; }
.nl-lab.ok { fill: var(--go-dark); font-weight: 800; }
.nl-robo { font-size: 30px; }
.nl-pin-t { font-size: 17px; font-weight: 800; fill: var(--ink); }

/* ---------- nilai tempat ---------- */
.pv-num { font-size: 3rem; font-weight: 800; letter-spacing: .08em; }
.pv-num span.hl { color: var(--tier); background: color-mix(in srgb, var(--tier) 15%, white); border-radius: 10px; padding: 0 .1em; }
.blk-board { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; width: 100%; }
.blk-board.reveal .blk-col { border-color: var(--go); }
.blk-col { border: 2px solid var(--line); border-radius: 16px; padding: 8px; min-width: 110px; flex: 1; max-width: 260px; display: flex; flex-direction: column; align-items: center; gap: 8px; background: #FFFBF5; }
.blk-name { font-weight: 800; text-transform: capitalize; color: var(--ink-soft); }
.blk-col-in { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; align-items: flex-end; min-height: 66px; }
.blk-o, .blk-t, .blk-h { display: block; background-color: #7FB8F5; border: 1.5px solid #1F4E8A; }
.blk-o { width: 13px; height: 13px; }
.blk-t { width: 13px; height: 66px; background-image: repeating-linear-gradient(to bottom, transparent 0 5px, #1F4E8A 5px 6.5px); background-color: #F5B76A; border-color: #8A4E1F; }
.blk-h { width: 66px; height: 66px; background-color: #9BE3B4; border-color: #1F6B3A; background-image: repeating-linear-gradient(to bottom, transparent 0 5px, #1F6B3A 5px 6.5px), repeating-linear-gradient(to right, transparent 0 5px, #1F6B3A 5px 6.5px); }
.blk-ctl { display: flex; align-items: center; gap: 10px; font-size: 1.5rem; }
.blk-btn { width: 48px; height: 48px; border-radius: 14px; border: 2px solid var(--line); background: #fff; font-size: 1.6rem; font-weight: 800; box-shadow: 0 3px 0 rgba(31,42,68,.1); }
.blk-btn:active { transform: translateY(2px); box-shadow: none; }

/* ---------- pecahan ---------- */
.fig { width: 100%; display: flex; justify-content: center; }
.fbar { width: min(100%, 380px); height: auto; }
.fpie { width: min(70vw, 220px); height: auto; }
.tappable .fpart { cursor: pointer; transition: fill .15s; }
.tappable .fpart:hover { filter: brightness(.96); }
.cmp-fr { display: flex; flex-direction: column; gap: 10px; width: 100%; align-items: center; }
.cmp-fr .fbar { width: min(100%, 340px); }
.cf-row { display: flex; align-items: center; gap: 12px; width: 100%; justify-content: center; }
.cf-lab { font-size: 1.6rem; width: 2.2em; text-align: center; }

/* ---------- jam ---------- */
.clock-box { width: min(64vw, 240px); }
.clock { width: 100%; height: auto; display: block; }
.clock-n { font-size: 21px; font-weight: 800; fill: var(--ink); }
.clock-legend { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; font-weight: 700; font-size: .95rem; }
.lg-h { color: #C5373C; } .lg-m { color: #1F6FCC; }
.clock-pair { display: flex; align-items: center; gap: 10px; justify-content: center; flex-wrap: wrap; }
.clock-pair figure { margin: 0; width: min(38vw, 180px); text-align: center; font-weight: 800; }
.clock-pair figcaption { margin-top: 4px; font-size: 1.1rem; }
.clock-arrow { font-size: 2rem; color: var(--ink-soft); }
.clock-ctl { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.cc-grp { display: flex; align-items: center; gap: 8px; background: #FFFBF5; border: 2px solid var(--line); border-radius: 16px; padding: 6px 10px; font-weight: 800; }

/* ---------- uang ---------- */
.money { display: inline-grid; place-items: center; font-weight: 800; color: #1F2A44; border: 2px solid rgba(31,42,68,.55); background: var(--m); box-shadow: 0 3px 0 rgba(31,42,68,.15); }
button.money:active { transform: translateY(2px); box-shadow: none; }
.money.coin { width: 58px; height: 58px; border-radius: 50%; font-size: 1rem; box-shadow: inset 0 0 0 4px rgba(255,255,255,.45), 0 3px 0 rgba(31,42,68,.15); }
.money.note { min-width: 112px; height: 56px; border-radius: 8px; font-size: 1.15rem; padding: 0 10px; background-image: linear-gradient(135deg, rgba(255,255,255,.35) 0 30%, transparent 30%); }
.money.note small { font-size: .7em; margin-right: 1px; }
.shop { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: center; }
.shop-item { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.si-emoji { font-size: 3.4rem; line-height: 1; }
.si-tag { background: #FFF1C9; border: 2px dashed #E5B33A; border-radius: 10px; padding: 2px 10px; font-weight: 800; font-size: 1.2rem; }
.shop-op { font-size: 2rem; }
.tray-box { width: 100%; border: 3px dashed var(--line); border-radius: 18px; padding: 10px; background: #FFFBF5; }
.tray-head, .wallet-head { font-weight: 800; color: var(--ink-soft); }
.tray { display: flex; flex-wrap: wrap; gap: 8px; min-height: 64px; align-items: center; justify-content: center; padding: 6px 0; }
.tray-empty { color: #B3A690; }
.tray-total { text-align: center; font-weight: 800; font-size: 1.15rem; }
.tray-total:empty { display: none; }
.wallet { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

/* ---------- petak & koordinat ---------- */
.grid-box { width: 100%; display: flex; justify-content: center; }
.grid-svg { width: min(100%, 420px); height: auto; }
.cell-tap { cursor: pointer; }
.coord { width: min(100%, 460px); height: auto; cursor: pointer; touch-action: manipulation; }
.ax-lab { font-size: 18px; font-weight: 800; font-style: italic; fill: var(--ink); }
.ax-num { font-size: 14px; font-weight: 700; fill: var(--ink-soft); }

/* ---------- bangun & sudut & volume ---------- */
.shape-svg { width: min(56vw, 210px); height: auto; }
.side-tap { cursor: pointer; }
.side-tap.on { stroke: #E5484D; stroke-width: 7; }
.angle-svg { width: min(100%, 380px); height: auto; }
.prot-n { font-size: 13px; font-weight: 700; fill: #1F6FCC; }
.box-svg { width: min(100%, 360px); height: auto; max-height: 300px; }
.box-lab { font-size: 18px; font-weight: 800; fill: var(--ink); }

/* ---------- faktor, kelipatan, KPK ---------- */
.lamp-legend { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; font-weight: 700; }
.la, .lb { display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: -1px; }
.la { background: #E5484D; box-shadow: 0 0 6px #E5484D; } .lb { background: #2F8CF0; box-shadow: 0 0 6px #2F8CF0; }
.lamps { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px; width: 100%; }
.lamp { border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 4px 0; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 1.1rem; }
.lamp-dots { display: flex; gap: 3px; height: 14px; }
.lamp.right { border-color: var(--go); background: #DDF5E6; }
.lamp.wrong { border-color: #F3B4B4; background: #FDECEC; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px; width: 100%; }
.pick-n { height: 50px; border-radius: 12px; border: 2px solid var(--line); background: #fff; font-size: 1.2rem; font-weight: 800; }
.pick-n.on { background: color-mix(in srgb, var(--tier) 22%, white); border-color: var(--tier); }
.pick-n.right { background: #DDF5E6; border-color: var(--go); }
.mlist { display: flex; flex-direction: column; gap: 6px; width: 100%; max-width: 600px; }
.ml-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 1.1rem; }
.ml-row b { min-width: 2.4em; }
.ml-row span { background: #FFFBF5; border: 2px solid var(--line); border-radius: 10px; padding: 0 8px; font-weight: 700; }
.ml-row .ml-more { border: 0; background: none; }

/* ---------- data ---------- */
.pikto, .chart-box { width: 100%; max-width: 520px; background: #FFFBF5; border: 2px solid var(--line); border-radius: 16px; padding: 10px 14px; }
.pk-title { font-weight: 800; text-align: center; margin-bottom: 6px; }
.pk-row { display: flex; align-items: center; gap: 8px; border-top: 1px dashed var(--line); padding: 4px 0; }
.pk-lab { width: 6.5em; flex: none; font-weight: 700; }
.pk-icons { font-size: 1.5rem; letter-spacing: 2px; }
.pk-key { margin-top: 6px; font-size: .95rem; font-weight: 700; color: var(--tier); text-align: right; }
.bar-chart { width: 100%; height: auto; }
.bc-num { font-size: 13px; font-weight: 700; fill: var(--ink-soft); }
.bc-lab { font-size: 13px; font-weight: 700; fill: var(--ink); }
.stat-cards { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.stat-cards span { background: #fff; border: 3px solid var(--tier); border-radius: 14px; min-width: 64px; padding: 6px 10px; text-align: center; font-size: 1.5rem; font-weight: 800; }
.stat-cards small { font-size: .55em; color: var(--ink-soft); }
.dice { display: flex; gap: 6px; font-size: 2.6rem; color: var(--ink); }
.bag { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.bag-balls { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; max-width: 260px; padding: 14px 18px 18px; background: #F3E1C4; border-radius: 20px 20px 60px 60px; border: 3px solid #B88A4E; }
.ball { display: inline-block; width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(31,42,68,.5); background-image: radial-gradient(circle at 35% 30%, rgba(255,255,255,.7) 0 18%, transparent 20%) !important; }
.ball.sm { width: 14px; height: 14px; vertical-align: -2px; }
.bag-legend { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; font-weight: 700; }

/* ---------- soal cerita ---------- */
.story { display: flex; gap: 14px; align-items: center; background: #FFFBF5; border: 2px solid var(--line); border-radius: 18px; padding: 12px 16px; width: 100%; max-width: 620px; }
.story-emoji { font-size: 3rem; }
.story p { margin: 0; font-size: 1.2rem; line-height: 1.45; font-weight: 600; }

/* ---------- modal & hasil ---------- */
#modal { display: none; }
#modal.open { display: block; }
.modal-bg { position: fixed; inset: 0; background: rgba(20, 30, 55, .45); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fadeIn .2s; }
.modal-card { background: #fff; border-radius: 30px; padding: 24px; max-width: 580px; width: 100%; max-height: 90vh; overflow: auto; box-shadow: var(--shadow); animation: pop .35s ease; }
@keyframes pop { 0% { transform: scale(.85); opacity: 0; } 70% { transform: scale(1.03); } 100% { transform: scale(1); opacity: 1; } }
.modal-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.win { text-align: center; }
.win-bot { width: 110px; height: 110px; margin: 0 auto; }
.win h2 { font-size: 2rem; margin-top: 6px; }
.win p { font-size: 1.15rem; color: var(--ink-soft); margin: 6px 0 0; }
.win-lv { font-weight: 700; }
.win-tip { font-size: 1rem !important; }
.win-tip.need { color: #8A6D00 !important; font-weight: 700; background: #FFF9DB; border-radius: 14px; padding: 8px 12px; }
.win-stars { font-size: 3.6rem; letter-spacing: 6px; line-height: 1.2; }
.win-stars span { color: #DDD3C4; display: inline-block; animation: pop .5s ease both; }
.win-stars span.on { color: var(--gold); text-shadow: 0 3px 0 #D99A00; }
.guide h2 { margin-bottom: 8px; }
.guide h3 { margin: 18px 0 6px; font-size: 1.15rem; }
.guide p, .guide li { color: var(--ink-soft); line-height: 1.45; }
.guide ul { padding-left: 20px; margin: 4px 0; }
.guide-note { margin: 0 0 8px; font-size: .95rem; }
.rep-grade { margin-bottom: 12px; border-left: 6px solid var(--tier); padding-left: 10px; }
.rep-grade h4 { margin-bottom: 4px; }
table.rep { width: 100%; border-collapse: collapse; font-size: .95rem; }
.rep th { text-align: left; color: var(--ink-soft); font-weight: 700; border-bottom: 2px solid var(--line); padding: 4px; }
.rep td { padding: 4px; border-bottom: 1px solid #F0E8DC; }
.rep td:nth-child(2) { font-weight: 800; white-space: nowrap; }
.rep td:nth-child(3) { white-space: nowrap; }
.voice-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.voice-row select { flex: 1; min-width: 0; font-size: 1rem; padding: 8px; border-radius: 12px; border: 2px solid var(--line); background: #fff; }
.voice-hint { font-size: .9rem; margin: 4px 0 0; }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti i { position: absolute; top: -20px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { transform: translate(var(--dx), 110vh) rotate(var(--rot)); } }

/* ---------- bagian (bab) di daftar topik ---------- */
.tier-concept { margin: 0 0 14px; padding: 10px 14px; border-radius: 16px; background: color-mix(in srgb, var(--tier) 10%, white); color: var(--ink-soft); font-weight: 600; }
.sections { display: flex; flex-direction: column; gap: 22px; }
.sec-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 10px; color: var(--tier); font-size: 1.1rem; }
.sec-badge {
  font-size: 1.6rem; width: 48px; height: 48px; border-radius: 15px; display: grid; place-items: center; flex: none;
  background: color-mix(in srgb, var(--tier) 12%, white); filter: grayscale(1); opacity: .55;
}
.sec.complete .sec-badge { filter: none; opacity: 1; background: #FFF3C4; box-shadow: 0 0 0 3px var(--gold); }
.sec-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.sec-name { font-size: 1.15rem; font-weight: 800; }
.sec-text small { font-size: .85rem; color: var(--ink-soft); font-weight: 700; }
.sec-line { flex: 1; height: 3px; min-width: 20px; border-radius: 3px; background: color-mix(in srgb, var(--tier) 25%, white); }
.sec-count { font-size: .95rem; font-weight: 800; color: var(--ink-soft); background: #fff; border: 2px solid color-mix(in srgb, var(--tier) 30%, white); border-radius: 999px; padding: 2px 12px; white-space: nowrap; }
.sec.complete .sec-count { color: #8A6D00; border-color: var(--gold); background: #FFF9DB; }
.topic.locked { cursor: not-allowed; filter: grayscale(1); opacity: .6; box-shadow: none; }
.topic.locked:hover { transform: none; }
.gc-badges { grid-column: 2; display: flex; flex-wrap: wrap; gap: 4px; }
.gc-badges i { font-style: normal; font-size: 1.15rem; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: color-mix(in srgb, var(--tier) 10%, white); filter: grayscale(1); opacity: .5; }
.gc-badges i.on { filter: none; opacity: 1; background: #FFF3C4; box-shadow: 0 0 0 2px var(--gold); }
.win-badge { display: inline-flex; flex-direction: column; align-items: center; margin: 10px auto 0; padding: 8px 22px; border-radius: 20px; background: #FFF9DB; box-shadow: 0 0 0 3px var(--gold); animation: pop .6s ease both .4s; }
.win-badge span { font-size: 2.6rem; line-height: 1.1; }
.win-badge b { font-size: 1.15rem; color: #8A6D00; }
.win-badge small { font-size: .9rem; color: var(--ink-soft); font-weight: 700; }
.toggle { display: flex; align-items: center; gap: 8px; font-weight: 700; margin: 4px 0 12px; cursor: pointer; }
.toggle input { width: 22px; height: 22px; accent-color: var(--go); }

/* ---------- ulangan bagian & latihan hari ini ---------- */
.topic.quiz { border-style: dashed; border-color: #E8B931; background: #FFFBEA; box-shadow: 0 4px 0 #F5DC8C; }
.topic.quiz .tp-emoji { background: #FFF1C2; }
.topic.quiz.done { background: #FFF6D6; }
.daily {
  width: 100%; display: flex; align-items: center; gap: 14px; text-align: left; margin: 0 0 18px; padding: 12px 16px; border-radius: 20px;
  border: 3px solid var(--tier); background: color-mix(in srgb, var(--tier) 8%, white); box-shadow: 0 5px 0 color-mix(in srgb, var(--tier) 40%, white); transition: transform .1s;
}
button.daily:hover { transform: translateY(-2px); }
button.daily:active { transform: translateY(3px); box-shadow: none; }
.daily.done { border-color: var(--go); background: #EEFAF2; box-shadow: 0 5px 0 #A9E2C0; }
.daily.off { border-style: dashed; box-shadow: none; opacity: .75; }
.dl-emoji { font-size: 2.2rem; width: 58px; height: 58px; flex: none; display: grid; place-items: center; border-radius: 18px; background: #fff; }
.dl-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.dl-body b { font-size: 1.15rem; }
.dl-body small { color: var(--ink-soft); font-size: .92rem; line-height: 1.3; }
.dl-go { font-size: 1.4rem; color: var(--tier); }
.qtopic { font-size: .85rem; font-weight: 800; color: var(--tier); background: color-mix(in srgb, var(--tier) 12%, white); border-radius: 999px; padding: 2px 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46%; }

/* ---------- kelas 1: bingkai sepuluh, bangun ruang, ukur ---------- */
.dot-i.g { background: #22B35E; }
.ten-frame { display: grid; grid-template-columns: repeat(5, 46px); gap: 4px; padding: 6px; border: 3px solid var(--ink); border-radius: 10px; background: #fff; }
.ten-frame span { height: 46px; border-radius: 6px; background: #F6F1EA; border: 2px dashed #D9CBB6; }
.ten-frame span.on { background: radial-gradient(circle, #FF8A3D 0 15px, transparent 16px), #FFF4EA; border-style: solid; border-color: #F3C9A4; }
.ten-frame span.off { background: #E2E8F0; border-color: #E2E8F0; }
.tf-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.tf-empty {
  height: 46px; border-radius: 6px; border: 2px dashed var(--tier); background: color-mix(in srgb, var(--tier) 8%, white);
  color: var(--tier); font-size: 1.3rem; font-weight: 800; display: grid; place-items: center; cursor: pointer; padding: 0;
}
.tf-empty.fill { border: 2px solid #9CC3F5; background: radial-gradient(circle, #2F8CF0 0 15px, transparent 16px), #EEF5FF; color: #fff; font-size: 1.05rem; }
.obj-emoji { font-size: clamp(5rem, 24vw, 7.5rem); line-height: 1.1; }
.corner-tap { cursor: pointer; }
.corner-tap.on { fill: #E5484D; }
.sign-num b.long { font-size: clamp(1.7rem, 8vw, 3rem); }
.choices.ribbons { flex-direction: column; align-items: stretch; max-width: 560px; }
.choices.ribbons .choice { padding: 6px 10px; min-height: 0; }
.ribbon-svg { display: block; width: 100%; height: auto; }
.choices.towers { align-items: flex-end; }
.choices.towers .choice { padding: 8px 10px; }
.tower-svg { display: block; width: 64px; height: auto; }
.measure-box { width: 100%; max-width: 640px; }
.measure-svg { display: block; width: 100%; height: auto; }
.ruler-n { font-size: 20px; font-weight: 700; fill: var(--ink); }
.ruler-u { font-size: 16px; font-weight: 800; fill: var(--ink-soft); }

/* ---------- layar kecil ---------- */
@media (max-width: 560px) {
  #app { padding: 0 12px 40px; }
  .icon-btn { width: 42px; height: 42px; font-size: 1.15rem; border-radius: 14px; }
  .topbar { gap: 6px; }
  .chip-stars { display: none; }
  .home-shapes .fs { width: 46px; height: 46px; font-size: 1.7rem; border-radius: 14px; }
  .coach-bot { width: 50px; height: 50px; }
  .kp-key { height: 52px; }
  .choice { min-height: 54px; font-size: 1.3rem; }
  .money.note { min-width: 96px; height: 50px; font-size: 1rem; }
  .money.coin { width: 52px; height: 52px; }
  .story { flex-direction: column; text-align: center; }
  .pk-lab { width: 5.2em; font-size: .9rem; }
  .pk-icons { font-size: 1.2rem; }
  .ten-frame { grid-template-columns: repeat(5, 40px); }
  .ten-frame span, .tf-empty { height: 40px; }
  .sec-line { display: none; }
  .sec-count { margin-left: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
