/* ==========================================================================
   Cikgu Kancil — Matematik KSSR
   Reka bentuk: mesra kanak-kanak, kontras tinggi, sasaran sentuh besar.
   ========================================================================== */

:root {
  --bg:            #f6f4ff;
  --bg-2:          #ffffff;
  --surface:       #ffffff;
  --surface-2:     #f2f0fd;
  --ink:           #241c46;
  --ink-2:         #5b5480;
  --ink-3:         #8b85ab;
  --line:          #e5e1f7;

  --primary:       #5b45e0;
  --primary-ink:   #ffffff;
  --primary-soft:  #ece8ff;

  --accent:        #ff9f1c;
  --accent-soft:   #fff2dc;

  --hibiscus:      #e5384f;   /* bunga raya */
  --hibiscus-soft: #ffe6e9;

  --ok:            #129d6a;
  --ok-soft:       #dcf7ec;
  --bad:           #e0384e;
  --bad-soft:      #ffe4e7;

  --nombor:        #5b45e0;
  --sukatan:       #0f9bd7;
  --algebra:       #e5384f;
  --statistik:     #129d6a;

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-xl: 32px;

  --shadow-1: 0 2px 6px rgba(36, 28, 70, .07);
  --shadow-2: 0 8px 24px rgba(36, 28, 70, .10);
  --shadow-3: 0 18px 44px rgba(36, 28, 70, .16);

  --font: "Nunito", "Baloo 2", ui-rounded, "Segoe UI Rounded", "SF Pro Rounded",
          system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
  --bg:            #14112a;
  --bg-2:          #1b1737;
  --surface:       #201b3f;
  --surface-2:     #2a2450;
  --ink:           #f2efff;
  --ink-2:         #bab3e0;
  --ink-3:         #8e87b8;
  --line:          #342c60;

  --primary:       #8b78ff;
  --primary-ink:   #170f3a;
  --primary-soft:  #2e2660;

  --accent:        #ffb648;
  --accent-soft:   #40320f;

  --hibiscus:      #ff6577;
  --hibiscus-soft: #451822;

  --ok:            #35d69b;
  --ok-soft:       #10382a;
  --bad:           #ff6b7e;
  --bad-soft:      #3f1720;

  --nombor:        #8b78ff;
  --sukatan:       #4bc4f5;
  --algebra:       #ff6577;
  --statistik:     #35d69b;

  --shadow-1: 0 2px 6px rgba(0, 0, 0, .3);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, .38);
  --shadow-3: 0 18px 44px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  background:
    radial-gradient(1100px 520px at 12% -8%, var(--primary-soft), transparent 60%),
    radial-gradient(900px 460px at 92% 4%, var(--accent-soft), transparent 62%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .4em; font-weight: 800; letter-spacing: -.01em; }
p { margin: 0 0 .8em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--primary); color: var(--primary-ink);
  padding: 10px 16px; border-radius: 0 0 var(--r-md) 0; font-weight: 700;
}
.skip-link:focus { left: 0; }

/* ---------- Bar atas -------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  padding: 10px max(14px, env(safe-area-inset-left)) 10px max(14px, env(safe-area-inset-right));
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar[hidden] { display: none; }

.topbar__back {
  flex: none;
  width: 44px; height: 44px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 14px; font-size: 22px; font-weight: 800; cursor: pointer;
  box-shadow: var(--shadow-1);
  transition: transform .12s ease;
}
.topbar__back:active { transform: scale(.92); }

.topbar__title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar__title strong {
  font-size: 1.02rem; line-height: 1.15;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar__crumb {
  font-size: .7rem; font-weight: 800; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.topbar__right { display: flex; align-items: center; gap: 6px; flex: none; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 11px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  font-weight: 800; font-size: .85rem; color: var(--ink);
  box-shadow: var(--shadow-1); white-space: nowrap;
}
.chip--btn { cursor: pointer; font-family: inherit; min-width: 44px; justify-content: center; }
.chip--btn:active { transform: scale(.93); }
.chip--xp { background: var(--accent-soft); border-color: transparent; }
.chip--streak { background: var(--hibiscus-soft); border-color: transparent; }

/* ---------- Susun atur ------------------------------------------------ */

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 18px max(16px, env(safe-area-inset-left)) 72px max(16px, env(safe-area-inset-right));
}
.app:focus { outline: none; }

.stack   { display: flex; flex-direction: column; gap: 18px; }
.row     { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer  { flex: 1; }
.center  { text-align: center; }
.muted   { color: var(--ink-2); }
.small   { font-size: .88rem; }
.tiny    { font-size: .78rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-1);
}

.grid { display: grid; gap: 14px; }
.grid--2 { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

/* ---------- Butang ---------------------------------------------------- */

.btn {
  font-family: inherit; font-size: 1rem; font-weight: 800;
  padding: 14px 22px; border-radius: var(--r-md);
  border: 1px solid transparent; cursor: pointer;
  background: var(--surface-2); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 50px;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.btn:hover { filter: brightness(1.03); }
.btn:active { transform: translateY(2px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }

.btn--primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 88%, #fff), var(--primary));
  color: var(--primary-ink);
  box-shadow: 0 5px 0 color-mix(in srgb, var(--primary) 62%, #000), var(--shadow-2);
}
.btn--primary:active { box-shadow: 0 2px 0 color-mix(in srgb, var(--primary) 62%, #000); }

.btn--ok {
  background: linear-gradient(180deg, color-mix(in srgb, var(--ok) 88%, #fff), var(--ok));
  color: #fff;
  box-shadow: 0 5px 0 color-mix(in srgb, var(--ok) 60%, #000), var(--shadow-2);
}
.btn--ok:active { box-shadow: 0 2px 0 color-mix(in srgb, var(--ok) 60%, #000); }

.btn--ghost { background: transparent; border-color: var(--line); color: var(--ink-2); box-shadow: none; }
.btn--block { width: 100%; }
.btn--lg { font-size: 1.1rem; padding: 17px 28px; min-height: 60px; }
.btn--sm { font-size: .86rem; padding: 9px 14px; min-height: 40px; border-radius: 12px; }

/* ---------- Skrin selamat datang -------------------------------------- */

.hero {
  text-align: center;
  padding: 26px 20px 30px;
  border-radius: var(--r-xl);
  background: linear-gradient(160deg, var(--primary), color-mix(in srgb, var(--primary) 55%, var(--hibiscus)));
  color: #fff;
  box-shadow: var(--shadow-3);
}
.hero h1 { font-size: clamp(1.7rem, 5.2vw, 2.5rem); margin-bottom: .25em; }
.hero p { opacity: .93; margin: 0 auto; max-width: 46ch; }
.hero__mascot { font-size: clamp(3.2rem, 12vw, 4.6rem); line-height: 1; display: block; margin-bottom: 6px; }
.hero__flag {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.3);
  padding: 6px 14px; border-radius: 999px; font-weight: 800; font-size: .8rem;
  letter-spacing: .05em; text-transform: uppercase; margin-bottom: 14px;
}

.avatar-pick { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.avatar-pick button {
  width: 62px; height: 62px; font-size: 32px; line-height: 1;
  border-radius: 20px; border: 2px solid var(--line); background: var(--surface);
  cursor: pointer; transition: transform .12s ease;
}
.avatar-pick button[aria-pressed="true"] {
  border-color: var(--primary); background: var(--primary-soft); transform: scale(1.08);
  box-shadow: var(--shadow-2);
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 800; font-size: .9rem; color: var(--ink-2); }
.input {
  font-family: inherit; font-size: 1.05rem; font-weight: 700;
  padding: 14px 16px; border-radius: var(--r-md);
  border: 2px solid var(--line); background: var(--surface); color: var(--ink);
  width: 100%; min-height: 52px;
}
.input:focus { border-color: var(--primary); outline: none; }

/* ---------- Kad tahun ------------------------------------------------- */

.year-card {
  position: relative; overflow: hidden;
  border: 2px solid var(--line); background: var(--surface);
  border-radius: var(--r-lg); padding: 18px 14px; cursor: pointer;
  text-align: center; font-family: inherit; color: var(--ink);
  transition: transform .14s ease, border-color .14s ease, box-shadow .14s ease;
}
.year-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-2); }
.year-card[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); }
.year-card__num { display: block; font-size: 2.3rem; font-weight: 900; line-height: 1; color: var(--primary); }
.year-card__label { display: block; font-weight: 800; margin-top: 6px; }
.year-card__age { display: block; font-size: .76rem; color: var(--ink-3); font-weight: 700; }

/* ---------- Papan utama ----------------------------------------------- */

.greet {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 20px; border-radius: var(--r-lg);
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 60%, var(--sukatan)));
  color: #fff; box-shadow: var(--shadow-2);
}
.greet__avatar {
  width: 62px; height: 62px; flex: none; display: grid; place-items: center;
  font-size: 34px; border-radius: 20px; background: rgba(255,255,255,.2);
  border: 2px solid rgba(255,255,255,.35);
}
.greet__text { min-width: 0; flex: 1; }
.greet__hello { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; opacity: .85; }
.greet__name { font-size: 1.4rem; font-weight: 900; line-height: 1.15; }
.greet__meta { font-size: .85rem; opacity: .9; font-weight: 700; }

.levelbar {
  height: 12px; border-radius: 999px; background: rgba(255,255,255,.25);
  overflow: hidden; margin-top: 8px;
}
.levelbar > i { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width .5s cubic-bezier(.2,.8,.3,1); }

.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.quick button {
  font-family: inherit; cursor: pointer; text-align: left;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface);
  padding: 14px 16px; color: var(--ink); box-shadow: var(--shadow-1);
  transition: transform .12s ease, box-shadow .12s ease;
}
.quick button:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.quick b { display: block; font-size: 1rem; }
.quick span { display: block; font-size: .8rem; color: var(--ink-3); font-weight: 700; }
.quick i { font-style: normal; font-size: 1.5rem; display: block; margin-bottom: 4px; }

.section-title {
  display: flex; align-items: baseline; gap: 10px; margin: 6px 2px -2px;
}
.section-title h2 { font-size: 1.2rem; margin: 0; }
.section-title span { font-size: .82rem; color: var(--ink-3); font-weight: 800; }

/* ---------- Kad topik ------------------------------------------------- */

.topic {
  position: relative; display: flex; gap: 14px; align-items: flex-start;
  text-align: left; font-family: inherit; color: var(--ink); cursor: pointer;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 6px solid var(--tone, var(--primary));
  border-radius: var(--r-md); padding: 16px; box-shadow: var(--shadow-1);
  transition: transform .14s ease, box-shadow .14s ease;
}
.topic:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.topic__icon {
  flex: none; width: 48px; height: 48px; display: grid; place-items: center;
  font-size: 26px; border-radius: 14px;
  background: color-mix(in srgb, var(--tone, var(--primary)) 14%, var(--surface));
}
/* Anak-anak ini ialah <span>; jadikan blok supaya setiap satu pada barisnya sendiri. */
.topic__body { flex: 1; min-width: 0; }
.topic__code, .topic__name, .topic__sub { display: block; }
.topic__code { font-size: .7rem; font-weight: 900; letter-spacing: .07em; color: var(--tone, var(--primary)); text-transform: uppercase; margin-bottom: 2px; }
.topic__name { font-weight: 800; font-size: 1.02rem; line-height: 1.25; }
.topic__sub { font-size: .8rem; color: var(--ink-3); font-weight: 700; margin-top: 2px; }

.progress {
  display: block;
  height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 9px;
}
.progress > i { display: block; height: 100%; background: var(--tone, var(--primary)); border-radius: 999px; transition: width .5s ease; }

/* ---------- Kemahiran ------------------------------------------------- */

.skill {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 14px 16px; box-shadow: var(--shadow-1);
}
.skill__no {
  flex: none; width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 12px; background: var(--surface-2); font-weight: 900; color: var(--ink-2);
  font-size: .9rem;
}
.skill__body { flex: 1; min-width: 0; }
.skill__title, .skill__meta { display: block; }
.skill__title { font-weight: 800; line-height: 1.3; }
.skill__meta { font-size: .78rem; color: var(--ink-3); font-weight: 700; margin-top: 3px; }
.skill__actions { display: flex; gap: 8px; flex: none; }

.stars { letter-spacing: 1px; font-size: .95rem; }
.stars b { color: var(--accent); font-weight: 400; }
.stars i { color: var(--line); font-style: normal; }

/* ---------- Belajar --------------------------------------------------- */

.learn h2 { font-size: 1.35rem; }
.learn__intro { font-size: 1.05rem; color: var(--ink-2); }

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.steps li {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--surface-2); border-radius: var(--r-md); padding: 13px 15px;
}
.steps li::before {
  counter-increment: st; content: counter(st);
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary); color: var(--primary-ink);
  display: grid; place-items: center; font-weight: 900; font-size: .8rem;
}
.steps { counter-reset: st; }

.callout {
  border-radius: var(--r-md); padding: 14px 16px; font-weight: 700;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
.callout--ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.callout b { display: block; margin-bottom: 3px; }

.example {
  font-family: var(--mono); font-size: 1.05rem; font-weight: 700;
  background: var(--surface-2); border-radius: var(--r-md); padding: 14px 16px;
  white-space: pre-wrap; overflow-x: auto; line-height: 1.7;
}

/* ---------- Kuiz ------------------------------------------------------ */

.quizbar { display: flex; align-items: center; gap: 12px; }
.quizbar .progress { flex: 1; margin: 0; height: 12px; }
.quizbar__count { font-weight: 900; font-size: .88rem; color: var(--ink-2); white-space: nowrap; }
.quizbar__hearts { font-size: 1rem; letter-spacing: 2px; white-space: nowrap; }

.question {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 22px; box-shadow: var(--shadow-2);
}
.question__prompt { font-size: clamp(1.1rem, 3.4vw, 1.4rem); font-weight: 800; line-height: 1.4; margin-bottom: 4px; }
.question__sub { color: var(--ink-3); font-weight: 700; font-size: .85rem; margin-bottom: 14px; }

.choices { display: grid; gap: 11px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.choice {
  font-family: inherit; font-size: 1.15rem; font-weight: 800; cursor: pointer;
  padding: 18px 16px; border-radius: var(--r-md);
  border: 2px solid var(--line); background: var(--surface); color: var(--ink);
  min-height: 62px; display: flex; align-items: center; justify-content: center; gap: 8px;
  text-align: center; transition: transform .12s ease, border-color .12s ease, background .12s ease;
}
.choice:hover:not([disabled]) { border-color: var(--primary); transform: translateY(-2px); }
.choice[data-state="picked"]  { border-color: var(--primary); background: var(--primary-soft); }
.choice[data-state="right"]   { border-color: var(--ok);  background: var(--ok-soft);  color: var(--ink); }
.choice[data-state="wrong"]   { border-color: var(--bad); background: var(--bad-soft); color: var(--ink); }
.choice[disabled] { cursor: default; }

.answer-row { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; }
.answer-row .input { flex: 1; min-width: 160px; font-size: 1.4rem; text-align: center; font-family: var(--mono); }

.feedback {
  margin-top: 16px; border-radius: var(--r-md); padding: 15px 17px;
  border: 2px solid transparent; animation: pop .28s cubic-bezier(.2,1.4,.5,1);
}
.feedback--ok  { background: var(--ok-soft);  border-color: var(--ok); }
.feedback--bad { background: var(--bad-soft); border-color: var(--bad); }
.feedback__head { font-weight: 900; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.feedback__body { font-weight: 700; color: var(--ink-2); }

@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.shake { animation: shake .38s; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

/* ---------- Keputusan ------------------------------------------------- */

.result { text-align: center; padding: 30px 22px; }
.result__stars { font-size: 3.2rem; letter-spacing: 6px; line-height: 1; margin: 6px 0 14px; }
.result__score { font-size: 3rem; font-weight: 900; color: var(--primary); line-height: 1; }
.result__mascot { font-size: 3.4rem; }

.tally { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 18px 0; }
.tally div {
  background: var(--surface-2); border-radius: var(--r-md); padding: 12px 20px; min-width: 96px;
}
/* Butang tindakan: sebaris pada skrin lebar, bertindan pada telefon. */
.actions { display: flex; gap: 10px; }
.actions .btn { flex: 1; }

.tally b { display: block; font-size: 1.6rem; line-height: 1.1; }
.tally span { font-size: .76rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }

/* ---------- Lencana --------------------------------------------------- */

.badge {
  text-align: center; padding: 16px 12px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1);
}
.badge--locked { opacity: .45; filter: grayscale(1); }
.badge__icon { font-size: 2.4rem; line-height: 1; display: block; }
.badge__name { font-weight: 800; font-size: .92rem; margin-top: 6px; }
.badge__desc { font-size: .74rem; color: var(--ink-3); font-weight: 700; }

/* ---------- Widget visual --------------------------------------------- */

.w { display: flex; flex-direction: column; gap: 10px; align-items: center; margin: 4px 0 14px; max-width: 100%; }
.w > svg { max-width: 100%; height: auto; }

/* table-layout:fixed menghalang lajur terakhir daripada terpotong pada skrin sempit. */
.pv-table {
  width: 100%; max-width: 100%; table-layout: fixed;
  border-collapse: separate; border-spacing: 4px; text-align: center;
}
.pv-table th {
  font-size: .62rem; text-transform: uppercase; letter-spacing: .02em;
  color: var(--ink-3); padding: 4px 1px; font-weight: 900;
  overflow-wrap: anywhere;
}
.pv-table td {
  background: var(--surface-2); border-radius: 12px; padding: 12px 2px;
  font-family: var(--mono); font-size: clamp(1.05rem, 4.4vw, 1.5rem); font-weight: 800;
}
.pv-table td.hi { background: var(--accent-soft); color: var(--ink); box-shadow: inset 0 0 0 2px var(--accent); }

.frac-bar { display: flex; width: min(100%, 380px); height: 54px; border-radius: 12px; overflow: hidden; border: 2px solid var(--ink-3); }
.frac-bar div { flex: 1; border-right: 2px solid var(--ink-3); }
.frac-bar div:last-child { border-right: 0; }
.frac-bar div.on { background: var(--primary); }
.frac-bar div.on2 { background: var(--accent); }

.frac {
  display: inline-flex; flex-direction: column; align-items: center;
  vertical-align: middle; line-height: 1.05; margin: 0 2px; font-weight: 800;
}
.frac > span:first-child { border-bottom: 2.5px solid currentColor; padding: 0 5px; }
.frac > span:last-child { padding: 0 5px; }
.mixed { display: inline-flex; align-items: center; gap: 4px; font-weight: 800; }

.clock { width: 190px; height: 190px; }
.clock circle.face { fill: var(--surface); stroke: var(--ink); stroke-width: 4; }
.clock line { stroke-linecap: round; }
.clock .hh { stroke: var(--ink); stroke-width: 7; }
.clock .mm { stroke: var(--primary); stroke-width: 5; }
.clock .tick { stroke: var(--ink-3); stroke-width: 2.5; }
.clock text { font-size: 12px; font-weight: 800; fill: var(--ink-2); text-anchor: middle; dominant-baseline: middle; }

.grid-svg .gl { stroke: var(--line); stroke-width: 1.5; }
.grid-svg .ax { stroke: var(--ink-2); stroke-width: 2.5; }
.grid-svg text { font-size: 11px; font-weight: 800; fill: var(--ink-3); text-anchor: middle; }
.grid-svg .pt { fill: var(--hibiscus); }
.grid-svg .lbl { fill: var(--ink); font-size: 12px; }

.bar-chart .bar { fill: var(--primary); }
.bar-chart .bar.alt { fill: var(--accent); }
.bar-chart text { font-size: 11px; font-weight: 800; fill: var(--ink-2); text-anchor: middle; }
.bar-chart .axis { stroke: var(--ink-2); stroke-width: 2; }
.bar-chart .gl { stroke: var(--line); stroke-width: 1; }

.shape-svg .fill { fill: color-mix(in srgb, var(--primary) 22%, transparent); stroke: var(--primary); stroke-width: 3; }
.shape-svg .dim { fill: var(--ink-2); font-size: 13px; font-weight: 800; text-anchor: middle; }
.shape-svg .cell { fill: none; stroke: color-mix(in srgb, var(--primary) 40%, transparent); stroke-width: 1; }

.money { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.note {
  border-radius: 8px; padding: 10px 14px; font-weight: 900; font-size: .9rem;
  color: #10240f; box-shadow: var(--shadow-1); border: 1px solid rgba(0,0,0,.15);
  font-family: var(--mono);
}
.note[data-v="100"] { background: #a5c8e8; }
.note[data-v="50"]  { background: #9fd3a9; }
.note[data-v="20"]  { background: #f2c46a; }
.note[data-v="10"]  { background: #e8a5a5; }
.note[data-v="5"]   { background: #bfa8e0; }
.note[data-v="1"]   { background: #a8dbe0; }
.coin {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 900; font-size: .78rem; font-family: var(--mono);
  background: radial-gradient(circle at 32% 28%, #f3f3f3, #b9b9b9);
  color: #2c2c2c; box-shadow: var(--shadow-1); border: 1px solid rgba(0,0,0,.2);
}

.numline { width: 100%; max-width: 460px; }
.numline .ln { stroke: var(--ink-2); stroke-width: 2.5; }
.numline .tk { stroke: var(--ink-3); stroke-width: 2; }
.numline text { font-size: 11px; font-weight: 800; fill: var(--ink-2); text-anchor: middle; }
.numline .mk { fill: var(--hibiscus); }

.blocks { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; align-items: flex-end; }
.blk-100 { width: 54px; height: 54px; background: var(--primary); border-radius: 6px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.4); }
.blk-10  { width: 12px; height: 54px; background: var(--sukatan); border-radius: 4px; }
.blk-1   { width: 12px; height: 12px; background: var(--accent); border-radius: 3px; }
.blk-col { display: flex; gap: 4px; flex-wrap: wrap; max-width: 130px; }

/* ---------- Kemajuan -------------------------------------------------- */

.bars { display: flex; flex-direction: column; gap: 12px; }
.bars__row { display: grid; grid-template-columns: 1fr 62px; gap: 10px; align-items: center; }
.bars__label { font-weight: 800; font-size: .9rem; }
.bars__track { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 5px; }
.bars__track > i { display: block; height: 100%; border-radius: 999px; background: var(--tone, var(--primary)); }
.bars__pct { text-align: right; font-weight: 900; font-family: var(--mono); }

.tablewrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 340px; }
table.data th, table.data td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
table.data th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }
table.data td b { font-weight: 800; }
table.data td:first-child { width: 55%; }

.data__group th {
  background: color-mix(in srgb, var(--tone, var(--primary)) 12%, var(--surface));
  color: var(--tone, var(--primary));
  font-size: .8rem; text-transform: none; letter-spacing: 0; font-weight: 900;
  border-bottom: 0; padding-top: 14px;
}

/* ---------- Toast & confetti ------------------------------------------ */

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 13px 22px; border-radius: 999px;
  font-weight: 800; z-index: 90; box-shadow: var(--shadow-3);
  animation: rise .3s cubic-bezier(.2,1.3,.4,1);
  max-width: calc(100vw - 32px); text-align: center;
}
@keyframes rise { from { transform: translate(-50%, 20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 80; overflow: hidden; }
.confetti span {
  position: absolute; top: -14px; width: 10px; height: 14px; border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(105vh) rotate(720deg); opacity: .15; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .confetti { display: none; }
}

@media (max-width: 560px) {
  body { font-size: 16px; }
  .app { padding-bottom: 60px; }
  .card { padding: 16px; border-radius: var(--r-md); }
  .skill { flex-wrap: wrap; }
  .skill__actions { width: 100%; }
  .skill__actions .btn { flex: 1; }

  /* Kecilkan kelengkapan bar atas supaya tajuk mendapat ruang. */
  .topbar { gap: 8px; padding-left: 10px; padding-right: 10px; }
  .topbar__back { width: 40px; height: 40px; font-size: 20px; }
  .topbar__title strong { font-size: .95rem; }
  .topbar__right { gap: 4px; }
  .chip { padding: 6px 9px; font-size: .8rem; gap: 3px; }
  .chip--btn { min-width: 38px; }

  .actions { flex-direction: column; }
}

@media print {
  .topbar, .btn, .quick { display: none !important; }
  body { background: #fff; }
}
