/* ===== SIMS - UI belajar untuk anak SD ===== */
:root {
    --bg: #FFF6EA;
    --surface: #FFFFFF;
    --ink: #1F2937;
    --ink-soft: #5B6472;
    --ink-faint: #9AA3AF;
    --primary: #FF8A3D;
    --primary-deep: #E96F1F;
    --primary-soft: #FFE3CF;
    --sky: #3B82F6;
    --sky-soft: #DBEAFE;
    --green: #22C55E;
    --green-soft: #DCFCE7;
    --amber: #F59E0B;
    --amber-soft: #FEF3C7;
    --teal: #14B8A6;
    --teal-soft: #CCFBF1;
    --violet: #8B5CF6;
    --violet-soft: #EDE9FE;
    --rose: #F43F5E;
    --rose-soft: #FFE4E6;
    --danger: #EF4444;
    --radius: 20px;
    --radius-sm: 14px;
    --shadow: 0 10px 30px rgba(249, 115, 22, .10), 0 2px 8px rgba(31, 41, 55, .06);
    --shadow-lift: 0 16px 40px rgba(249, 115, 22, .16), 0 4px 12px rgba(31, 41, 55, .08);
    --font-display: 'Fredoka', 'Nunito', system-ui, sans-serif;
    --font-body: 'Nunito', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.6;
    color: var(--ink);
    background: var(--bg);
    min-height: 100vh;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
button { font: inherit; border: 0; cursor: pointer; background: none; color: inherit; }

.skip-link {
    position: absolute; left: -9999px; top: 0; z-index: 100;
    background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 0 0 12px 0;
    font-weight: 700;
}
.skip-link:focus { left: 0; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; border-radius: 8px; }

/* ===== Topbar ===== */
.topbar {
    position: sticky; top: 0; z-index: 50;
    background: rgba(255, 246, 234, .92);
    backdrop-filter: blur(8px);
    border-bottom: 3px solid #FFE1C4;
}
.topbar-inner {
    max-width: 1080px; margin: 0 auto; padding: 12px 20px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-badge {
    width: 46px; height: 46px; border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), #FFB25E);
    display: grid; place-items: center; font-size: 24px;
    box-shadow: var(--shadow);
}
.logo-text {
    font-family: var(--font-display); font-weight: 700; font-size: 26px;
    letter-spacing: 1px; color: var(--primary-deep);
}
.topbar-chips { display: flex; align-items: center; gap: 10px; }
.chip {
    display: flex; align-items: center; gap: 6px;
    background: var(--surface); border-radius: 999px; padding: 8px 14px;
    box-shadow: var(--shadow); font-weight: 800; font-size: 15px; white-space: nowrap;
}
.chip-ico { font-size: 18px; }
.chip-val { font-variant-numeric: tabular-nums; }
.chip-label { color: var(--ink-soft); font-size: 13px; font-weight: 700; }
.chip-xp .chip-val { color: var(--amber); }
.chip-streak .chip-val { color: var(--rose); }
.avatar {
    width: 46px; height: 46px; border-radius: 50%;
    background: var(--sky-soft); display: grid; place-items: center; font-size: 24px;
    border: 3px solid #fff; box-shadow: var(--shadow);
}

/* ===== Layout umum ===== */
.page { max-width: 1080px; margin: 0 auto; padding: 28px 20px 64px; }
.foot { text-align: center; padding: 24px 16px 32px; color: var(--ink-faint); font-size: 14px; }
.section-title {
    font-family: var(--font-display); font-weight: 600; font-size: 24px;
    margin: 34px 0 16px; display: flex; align-items: center; gap: 10px;
}

/* ===== Hero ===== */
.hero {
    display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center;
    background: linear-gradient(135deg, #FF9A56 0%, #FF7A2F 55%, #F4511E 100%);
    border-radius: 28px; padding: 28px 32px; color: #fff; box-shadow: var(--shadow-lift);
    position: relative; overflow: hidden;
}
.hero::after {
    content: ''; position: absolute; right: -40px; top: -40px;
    width: 200px; height: 200px; border-radius: 50%; background: rgba(255,255,255,.14);
}
.hero-halo { font-size: 84px; filter: drop-shadow(0 6px 12px rgba(0,0,0,.15)); transform: rotate(-6deg); }
.hero-kicker { font-weight: 800; letter-spacing: 2px; text-transform: uppercase; font-size: 13px; opacity: .92; }
.hero-name { font-family: var(--font-display); font-weight: 700; font-size: 36px; line-height: 1.15; margin-top: 2px; }
.hero-sub { opacity: .95; font-weight: 600; margin-top: 6px; }
.xp-card {
    background: rgba(255,255,255,.96); color: var(--ink);
    border-radius: var(--radius); padding: 18px 22px; min-width: 250px; box-shadow: var(--shadow);
}
.xp-card-head { display: flex; justify-content: space-between; align-items: center; font-weight: 800; }
.xp-count { font-size: 13px; color: var(--ink-soft); font-weight: 700; margin-top: 2px; }
.level-pill {
    background: var(--amber-soft); color: #92400E; border-radius: 999px;
    padding: 6px 14px; font-size: 14px; font-weight: 800;
}
.xp-bar { height: 14px; border-radius: 999px; background: #F3E8D8; margin-top: 12px; overflow: hidden; }
.xp-bar-fill {
    height: 100%; width: 0; border-radius: 999px;
    background: linear-gradient(90deg, var(--amber), #FBBF24);
    transition: width .8s cubic-bezier(.2,.8,.2,1);
}
.xp-hint { font-size: 12.5px; color: var(--ink-soft); font-weight: 700; margin-top: 6px; }

/* ===== Grid mapel ===== */
.mapel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.mapel-card {
    position: relative; display: flex; flex-direction: column; gap: 10px;
    background: var(--surface); border-radius: var(--radius); padding: 20px;
    box-shadow: var(--shadow); border: 2px solid transparent; border-top-width: 6px;
    transition: transform .18s ease, box-shadow .18s ease;
    min-height: 190px;
}
.mapel-card::after {
    content: 'Mulai \279C'; position: absolute; right: 18px; bottom: 16px;
    font-weight: 800; font-size: 14px; color: var(--ink-faint); transition: color .18s ease;
}
.mapel-card:hover, .mapel-card:focus-visible { transform: translateY(-4px); box-shadow: var(--shadow-lift); }
.mapel-card:hover::after, .mapel-card:focus-visible::after { color: var(--primary-deep); }
.mapel-card:active { transform: translateY(-1px) scale(.99); }
.mapel-emoji { font-size: 44px; line-height: 1; }
.mapel-card h3 { font-family: var(--font-display); font-weight: 600; font-size: 21px; }
.mapel-desc { color: var(--ink-soft); font-size: 14px; font-weight: 600; }
.mapel-meta { display: flex; gap: 8px; align-items: center; margin-top: auto; flex-wrap: wrap; }
.pill { font-size: 13px; font-weight: 800; border-radius: 999px; padding: 5px 12px; white-space: nowrap; }
.pill-neutral { background: #F1F5F9; color: var(--ink-soft); }

.m-biru   { border-top-color: var(--sky); }     .m-biru   .mapel-emoji { background: var(--sky-soft); }
.m-oranye { border-top-color: var(--primary); } .m-oranye .mapel-emoji { background: var(--primary-soft); }
.m-hijau  { border-top-color: var(--green); }   .m-hijau  .mapel-emoji { background: var(--green-soft); }
.m-teal   { border-top-color: var(--teal); }    .m-teal   .mapel-emoji { background: var(--teal-soft); }
.m-biru .mapel-emoji, .m-oranye .mapel-emoji, .m-hijau .mapel-emoji, .m-teal .mapel-emoji {
    width: 66px; height: 66px; border-radius: 18px; display: grid; place-items: center;
}
.c-biru { background: var(--sky-soft); } .c-hijau { background: var(--green-soft); }
.c-teal { background: var(--teal-soft); } .c-violet { background: var(--violet-soft); }
.c-amber { background: var(--amber-soft); } .c-rose { background: var(--rose-soft); }
.c-primary { background: var(--primary-soft); }

/* ===== Bar progres ===== */
.progress { height: 12px; border-radius: 999px; background: #EEF1F5; overflow: hidden; flex: 1; min-width: 90px; }
.progress-fill {
    height: 100%; border-radius: 999px; width: 0;
    background: linear-gradient(90deg, var(--green), #4ADE80);
    transition: width .6s cubic-bezier(.2,.8,.2,1);
}
.progress-label { font-size: 13px; font-weight: 800; color: var(--ink-soft); }

/* ===== Misi harian ===== */
.misi-list { display: flex; flex-direction: column; gap: 12px; }
.misi-item {
    display: flex; align-items: center; gap: 14px;
    background: var(--surface); border-radius: var(--radius-sm); padding: 14px 18px; box-shadow: var(--shadow);
}
.misi-check {
    width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
    font-size: 20px; flex-shrink: 0; background: var(--green-soft);
}
.misi-check.pending { background: #F1F5F9; }
.misi-teks { font-weight: 700; }
.misi-teks.done { text-decoration: line-through; color: var(--ink-faint); }
.misi-xp { margin-left: auto; font-weight: 800; color: var(--amber); font-size: 14px; white-space: nowrap; }

/* ===== Halaman mapel ===== */
.back-link {
    display: inline-flex; align-items: center; gap: 8px;
    font-weight: 800; color: var(--ink-soft); padding: 8px 14px; border-radius: 999px;
    background: var(--surface); box-shadow: var(--shadow); margin-bottom: 16px;
}
.back-link:hover { color: var(--primary-deep); }
.mapel-hero { display: flex; align-items: center; gap: 18px; border-radius: 24px; padding: 22px 26px; box-shadow: var(--shadow); }
.mapel-hero .mapel-emoji { font-size: 56px; width: 84px; height: 84px; }
.mapel-hero h2 { font-family: var(--font-display); font-weight: 700; font-size: 30px; }
.mapel-hero p { color: var(--ink-soft); font-weight: 600; }

.bab-list { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.bab-card {
    display: flex; align-items: center; gap: 16px; width: 100%; text-align: left;
    background: var(--surface); border-radius: var(--radius); padding: 18px 22px;
    box-shadow: var(--shadow); border: 2px solid transparent;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
    min-height: 76px;
}
.bab-card.playable:hover, .bab-card.playable:focus-visible {
    transform: translateY(-3px); box-shadow: var(--shadow-lift); border-color: var(--primary);
}
.bab-emoji { font-size: 34px; width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; flex-shrink: 0; }
.bab-info h4 { font-family: var(--font-display); font-weight: 600; font-size: 20px; }
.bab-info p { color: var(--ink-soft); font-size: 14px; font-weight: 600; }
.bab-status { margin-left: auto; flex-shrink: 0; }
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 14px; font-weight: 800; border-radius: 999px; padding: 8px 16px;
}
.badge-done { background: var(--green-soft); color: #166534; }
.badge-aktif { background: var(--amber-soft); color: #92400E; }
.badge-lock { background: #F1F5F9; color: var(--ink-faint); }
.bab-card.locked { opacity: .55; cursor: not-allowed; }

/* ===== Halaman latihan ===== */
.latihan-wrap { max-width: 720px; margin: 0 auto; }
.latihan-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.btn-ghost {
    display: inline-flex; align-items: center; gap: 8px; font-weight: 800;
    padding: 10px 18px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow);
}
.btn-ghost:hover { color: var(--primary-deep); }
.progress--lg { height: 16px; }
.latihan-progress { display: flex; align-items: center; gap: 12px; flex: 1; max-width: 420px; }

.quiz-card { background: var(--surface); border-radius: 24px; padding: 28px; box-shadow: var(--shadow-lift); }
.quiz-soal { font-family: var(--font-display); font-weight: 600; font-size: 26px; line-height: 1.35; }
.quiz-opsi { display: grid; gap: 12px; margin-top: 22px; }
.opsi-btn {
    display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
    background: #F8FAFC; border: 3px solid #E8ECF1; border-radius: var(--radius-sm);
    padding: 16px 18px; font-weight: 800; font-size: 19px;
    transition: border-color .15s ease, background .15s ease, transform .15s ease;
    min-height: 64px;
}
.opsi-btn:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-soft); transform: translateY(-2px); }
.opsi-btn:disabled { cursor: default; }
.opsi-key {
    width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0;
    background: #E8ECF1; font-family: var(--font-display); font-weight: 700; font-size: 18px;
}
.opsi-btn.benar { border-color: var(--green); background: var(--green-soft); }
.opsi-btn.benar .opsi-key { background: var(--green); color: #fff; }
.opsi-btn.salah { border-color: var(--danger); background: var(--rose-soft); }
.opsi-btn.salah .opsi-key { background: var(--danger); color: #fff; }
.opsi-btn.dim { opacity: .5; }

.quiz-feedback { display: none; border-radius: var(--radius-sm); padding: 16px 18px; margin-top: 18px; font-weight: 700; }
.quiz-aksi { display: flex; justify-content: flex-end; margin-top: 20px; }
.btn-primary {
    display: inline-flex; align-items: center; gap: 10px;
    font-family: var(--font-display); font-weight: 600; font-size: 19px; color: #fff;
    background: linear-gradient(135deg, var(--primary), #FF9D52);
    border-radius: 999px; padding: 14px 30px; box-shadow: 0 8px 20px rgba(255, 138, 61, .35);
    transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
    min-height: 56px;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(255, 138, 61, .42); }
.btn-primary:active { transform: translateY(0) scale(.98); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }

/* ===== Layar hasil ===== */
.hasil { text-align: center; padding: 12px 0 6px; }
.hasil-emoji { font-size: 96px; line-height: 1; }
.hasil-judul { font-family: var(--font-display); font-weight: 700; font-size: 34px; margin-top: 10px; }
.hasil-xp {
    display: inline-flex; align-items: center; gap: 10px; margin-top: 14px;
    background: var(--amber-soft); color: #92400E; font-weight: 800; font-size: 20px;
    border-radius: 999px; padding: 12px 26px;
}
.hasil-aksi { display: flex; gap: 12px; justify-content: center; margin-top: 26px; flex-wrap: wrap; }

/* ===== Toast ===== */
.toast-region { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 80; display: grid; gap: 10px; width: min(420px, calc(100vw - 32px)); }
.toast {
    display: flex; align-items: center; gap: 12px;
    background: var(--ink); color: #fff; font-weight: 700;
    border-radius: 16px; padding: 14px 18px; box-shadow: 0 10px 30px rgba(0,0,0,.25);
    animation: toast-in .3s cubic-bezier(.2,.9,.3,1.2);
}
.toast.out { animation: toast-out .25s ease forwards; }
.toast-ico { font-size: 22px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.95); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px); } }

/* ===== Confetti ===== */
#confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.confetti-piece { position: absolute; will-change: transform; animation: confetti-fall linear forwards; }
@keyframes confetti-fall {
    from { transform: translate3d(0, -40px, 0) rotate(0deg); }
    to   { transform: translate3d(var(--drift, 0px), 105vh, 0) rotate(720deg); }
}

/* ===== Skeleton ===== */
.skeleton {
    border-radius: var(--radius); background: linear-gradient(100deg, #F1F5F9 40%, #FAFBFD 50%, #F1F5F9 60%);
    background-size: 200% 100%; animation: skeleton-wave 1.4s infinite;
}
@keyframes skeleton-wave { to { background-position: -200% 0; } }

/* ===== Responsif ===== */
@media (max-width: 720px) {
    body { font-size: 16px; }
    .hero { grid-template-columns: 1fr; padding: 24px 22px; }
    .hero-halo { position: absolute; right: 12px; top: 14px; font-size: 56px; opacity: .9; }
    .hero-name { font-size: 29px; }
    .xp-card { width: 100%; }
    .chip-label { display: none; }
    .logo-text { font-size: 22px; }
    .section-title { font-size: 21px; }
    .quiz-soal { font-size: 22px; }
    .quiz-opsi { grid-template-columns: 1fr; }
    .mapel-hero { flex-direction: column; text-align: center; }
    .latihan-wrap { padding: 0; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
