/* ---- Design tokens ---- */
:root {
  --bg: #DDF7EF;
  --surface-1: #CFF2EA;
  --surface-2: #FFFFFF;
  --border: #BCE7DF;
  --border-strong: #9CD8CE;
  --text-primary: #2E3A59;
  --text-secondary: #5C6884;
  --text-muted: #8C97AE;

  /* --teal / --coral dipakai sebagai LATAR di belakang teks putih, jadi harus
     cukup gelap untuk lolos WCAG AA. Varian -bright hanya untuk hiasan
     (garis tepi, bar progres) yang tidak menanggung teks. */
  --teal: #17796F;
  --teal-bright: #2BB3A3;
  --teal-deep: #12645C;
  --coral: #CE4034;
  --coral-bright: #F4695F;
  --coral-deep: #9E2F26;
  --gold: #F5B335;

  --accent: var(--teal);
  --accent-soft: #DCF3EF;

  --bg-success: #DDF3EA;
  --text-success: #146B54;
  --bg-danger: #FDE6E3;
  --text-danger: #A83324;

  color-scheme: light;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 1px 2px rgba(46, 58, 89, .05), 0 6px 18px rgba(46, 58, 89, .06);
  --shadow-lift: 0 8px 24px rgba(46, 58, 89, .12);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #1A1E2B;
    --surface-1: #232838;
    --surface-2: #2B3145;
    --border: #363D53;
    --border-strong: #48506B;
    --text-primary: #EEF1F8;
    --text-secondary: #A7B0C7;
    --text-muted: #737D96;
    --teal: #17796F;
    --teal-bright: #35C7B5;
    --teal-deep: #7FDCC0;
    --coral: #CE4034;
    --coral-bright: #FF7C71;
    --coral-deep: #9E2F26;
    --gold: #FFC658;
    --accent-soft: #1E3D3A;
    --bg-success: #17392F;
    --text-success: #7FDCC0;
    --bg-danger: #45211C;
    --text-danger: #F7A99C;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .28);
    --shadow-lift: 0 8px 24px rgba(0, 0, 0, .4);
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #DDF7EF; --surface-1: #CFF2EA; --surface-2: #FFFFFF;
  --border: #BCE7DF; --border-strong: #9CD8CE;
  --text-primary: #2E3A59; --text-secondary: #5C6884; --text-muted: #8C97AE;
  --teal: #17796F; --teal-bright: #2BB3A3; --teal-deep: #12645C;
  --coral: #CE4034; --coral-bright: #F4695F; --coral-deep: #9E2F26;
  --gold: #F5B335; --accent-soft: #DCF3EF;
  --bg-success: #DDF3EA; --text-success: #146B54;
  --bg-danger: #FDE6E3; --text-danger: #A83324;
  --shadow: 0 1px 2px rgba(46, 58, 89, .05), 0 6px 18px rgba(46, 58, 89, .06);
  --shadow-lift: 0 8px 24px rgba(46, 58, 89, .12);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1A1E2B; --surface-1: #232838; --surface-2: #2B3145;
  --border: #363D53; --border-strong: #48506B;
  --text-primary: #EEF1F8; --text-secondary: #A7B0C7; --text-muted: #737D96;
  --teal: #17796F; --teal-bright: #35C7B5; --teal-deep: #7FDCC0;
  --coral: #CE4034; --coral-bright: #FF7C71; --coral-deep: #9E2F26;
  --gold: #FFC658; --accent-soft: #1E3D3A;
  --bg-success: #17392F; --text-success: #7FDCC0;
  --bg-danger: #45211C; --text-danger: #F7A99C;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .28);
  --shadow-lift: 0 8px 24px rgba(0, 0, 0, .4);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: "Nunito", "Quicksand", system-ui, -apple-system, "Segoe UI", Roboto,
    "Noto Sans SC", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
p, h1, h2, h3, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
[hidden] { display: none !important; }

.wrap { max-width: 900px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem;
  margin-bottom: 1rem;
}

/* ---- App bar ---- */
.appbar { background: var(--teal); color: #fff; }
.appbar-in {
  max-width: 900px; margin: 0 auto;
  padding: 1rem; display: flex; align-items: center; gap: 12px;
}
.brand-logo { font-size: 26px; line-height: 1; flex: none; }
.brand-name { font-size: 20px; font-weight: 800; letter-spacing: -.2px; }
.brand-tag { font-size: 12.5px; opacity: .92; }
.appbar-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.ghost-btn {
  /* Wajib: <a> tidak mewarisi color appbar dan akan memakai biru bawaan
     browser di atas latar merek — gagal kontras. */
  color: #fff;
  background: rgba(255, 255, 255, .18);
  border: 0; border-radius: 999px;
  padding: 7px 10px; font-size: 15px; line-height: 1; cursor: pointer;
}
.ghost-btn:hover { background: rgba(255, 255, 255, .3); }
.install-btn {
  min-width: 70px;
  font-weight: 900;
}
.starpill {
  /* Latarnya selalu putih, jadi warna teksnya harus tetap gelap — memakai
     --text-primary membuatnya putih-di-atas-putih saat tema gelap. */
  background: #fff; color: #2E3A59;
  border-radius: 999px; padding: 7px 16px;
  font-weight: 800; font-size: 15px; white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .12);
}
.starpill span[aria-hidden] { color: var(--gold); }

/* ---- Buttons ---- */
button { font-family: inherit; cursor: pointer; }
.btn-cta {
  background: var(--coral); color: #fff;
  border: 0; border-radius: 999px;
  padding: 12px 22px; font-size: 15px; font-weight: 800;
  box-shadow: 0 4px 0 var(--coral-deep);
  transition: transform .08s, box-shadow .08s, filter .12s;
}
.btn-cta:hover { filter: brightness(1.05); }
.btn-cta:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--coral-deep); }
.btn-plain {
  background: var(--surface-2); color: var(--text-primary);
  border: 1.5px solid var(--border-strong); border-radius: 999px;
  padding: 10px 18px; font-size: 14px; font-weight: 700;
  transition: background .12s, border-color .12s, transform .08s;
}
.btn-plain:hover { background: var(--surface-1); border-color: var(--text-muted); }
.btn-plain:active { transform: scale(.97); }
.btn-plain.sm { padding: 6px 14px; font-size: 13px; }

:where(button, .gcard, .text-input, .mem):focus-visible {
  outline: 3px solid var(--teal-bright);
  outline-offset: 2px;
}

/* ---- Onboarding ---- */
.onboard { max-width: 560px; margin: 2.5rem auto; text-align: center; padding: 2.5rem 1.5rem; }
.onboard-star { font-size: 46px; line-height: 1; }
.onboard-title { font-size: 27px; font-weight: 800; margin-top: 12px; }
.onboard-sub { font-size: 14.5px; color: var(--text-secondary); margin-top: 6px; }
.onboard-form {
  display: flex; gap: 10px; justify-content: center;
  margin-top: 1.5rem; flex-wrap: wrap;
}
.text-input {
  flex: 1 1 240px; max-width: 300px;
  padding: 12px 16px; font-size: 16px; font-family: inherit;
  border: 2px solid var(--teal-bright); border-radius: 12px;
  background: var(--surface-2); color: var(--text-primary);
}
.text-input::placeholder { color: var(--text-muted); }
.err { color: var(--text-danger); font-size: 13.5px; margin-top: 10px; min-height: 1em; }

/* ---- Hello ---- */
.hello { display: flex; align-items: center; gap: 12px; margin-bottom: 1.1rem; flex-wrap: wrap; }
.hello-title { font-size: 26px; font-weight: 800; }
.hello-sub { font-size: 13.5px; color: var(--text-secondary); }
.hello .btn-plain { margin-left: auto; }

/* ---- Pickers ---- */
.picker { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.picker-label { flex: 1 1 180px; }
.kicker {
  /* 11px butuh kontras penuh 4.5:1 — --text-muted terlalu pucat untuk teks. */
  font-size: 11px; font-weight: 800; letter-spacing: .09em;
  text-transform: uppercase; color: var(--text-secondary);
}
.picker-title { font-size: 18px; font-weight: 800; margin-top: 2px; }
.picker-hint { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }
.picker-opts {
  flex: 2 1 380px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px;
}
.pick {
  text-align: left; padding: 11px 13px;
  background: var(--surface-2); color: var(--text-primary);
  border: 1.5px solid var(--border); border-radius: 12px;
  transition: transform .08s, border-color .12s, background .12s;
}
.pick:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.pick-name { display: block; font-size: 14.5px; font-weight: 800; }
.pick-desc { display: block; font-size: 11.5px; color: var(--text-secondary); margin-top: 2px; }
.pick[aria-pressed="true"] { border-color: transparent; color: #fff; }
.pick[aria-pressed="true"] .pick-desc { color: rgba(255, 255, 255, .88); }
.pick[data-kind="level"][aria-pressed="true"] { background: var(--teal); }
.pick[data-kind="focus"][aria-pressed="true"] { background: var(--coral); }

/* ---- Wizard level & fokus ---- */
.wiz-bar { display: flex; align-items: center; gap: 12px; margin-bottom: .8rem; }
.wiz-step {
  font-size: 11px; font-weight: 800; letter-spacing: .09em;
  text-transform: uppercase; color: var(--text-secondary);
}
.wiz-dots { margin-left: auto; display: flex; gap: 6px; }
.wiz-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border-strong); transition: background .12s, transform .12s;
}
.wiz-dot.on { background: var(--teal-bright); transform: scale(1.35); }

.summary {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: rgba(255, 255, 255, .55); border: 1.5px solid var(--border);
  border-radius: 999px; padding: 8px; margin-bottom: .7rem;
}
.summary-txt { font-size: 14px; font-weight: 800; }
.summary-dot { color: var(--text-muted); margin: 0 8px; }
.summary .btn-plain { margin-left: auto; background: var(--surface-2); }
.journey-steps {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.journey-step {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 900;
}
.journey-step.done {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}
.journey-step.on {
  background: var(--gold);
  border-color: #E6A124;
  color: #5B3F05;
}

/* ---- Game sections ---- */
.dash-hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin: 10px 0 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #E9FBF6, #D1F1F7);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.hero-avatar {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--teal-bright);
  font-size: 28px;
}
.hero-copy h3 {
  margin: 2px 0 3px;
  font-size: 23px;
  line-height: 1.1;
  font-weight: 900;
}
.hero-copy p:last-child {
  color: var(--text-secondary);
  font-size: 13px;
}

.dash-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.dash-head > :last-child { margin-left: auto; }
.dash-title {
  font-size: 17px;
  line-height: 1.2;
  font-weight: 900;
}
.mission-card { border-radius: 16px; }
.mission-list { display: grid; gap: 10px; }
.mission-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 48px;
  gap: 10px;
  align-items: center;
}
.mission-ico {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--surface-1);
}
.mission-title {
  display: block;
  font-size: 13px;
  font-weight: 800;
}
.mission-bar {
  display: block;
  height: 7px;
  margin-top: 5px;
  background: var(--surface-1);
  border-radius: 999px;
  overflow: hidden;
}
.mission-bar > span {
  display: block;
  height: 100%;
  background: var(--gold);
  border-radius: inherit;
}
.mission-row.done .mission-bar > span { background: var(--teal-bright); }
.mission-count {
  justify-self: end;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 900;
}

.practice-card { margin-bottom: 1rem; }
.practice-main {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 10px;
}
.practice-main > div:first-child { min-width: 0; flex: 1; }
.practice-sub {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 13px;
}
.practice-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.practice-actions .gcard {
  width: auto;
  min-width: 116px;
  margin: 0;
  border-radius: 999px;
  box-shadow: none;
  text-align: center;
}
.practice-actions .btn-cta.gcard {
  background: var(--coral);
  color: #fff;
  border: 0;
  padding: 12px 18px;
}
.practice-actions .btn-plain.gcard {
  background: var(--surface-2);
  color: var(--text-primary);
  padding: 10px 16px;
}
.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.mini-stat {
  min-height: 58px;
  display: grid;
  place-items: center;
  padding: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.mini-stat strong {
  color: var(--teal);
  font-size: 18px;
  line-height: 1;
}
.mini-stat span {
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.adventure {
  margin: 1.2rem 0 1rem;
}
.seg-pill {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--teal);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}
.path-map {
  position: relative;
  display: grid;
  gap: 12px;
  padding: 4px 0 4px;
}
.path-map::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 50%;
  border-left: 2px dashed var(--border-strong);
  transform: translateX(-1px);
}
.path-stop {
  position: relative;
  display: flex;
}
.path-stop.left { justify-content: flex-start; }
.path-stop.right { justify-content: flex-end; }
.path-card.gcard {
  width: min(48%, 380px);
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  text-align: left;
  padding: 12px;
  border-radius: 14px;
}
.path-card[disabled] {
  opacity: .68;
  filter: grayscale(.25);
}
.path-card.cleared { border-color: var(--teal-bright); }
.path-pin {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--teal);
  font-weight: 900;
}
.path-title {
  display: block;
  font-size: 14px;
  font-weight: 900;
}
.path-sub {
  display: block;
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 700;
}

.all-games-card { border-radius: 16px; }
.sec-head.compact {
  margin: 1rem 0 .55rem;
}
.sec-head.compact:first-of-type { margin-top: .2rem; }
.menugrid.compact {
  grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
  gap: 9px;
}
.menugrid.compact .gcard {
  padding: .8rem .55rem;
  border-radius: 12px;
}
.menugrid.compact .gcard .emoji {
  width: 42px;
  height: 42px;
  font-size: 21px;
  margin-bottom: 7px;
}

.collection-card { border-radius: 16px; }
.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 9px;
}
.badge-tile {
  min-height: 96px;
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 10px 8px;
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: 13px;
  background: var(--surface-1);
  color: var(--text-secondary);
}
.badge-tile.unlocked {
  border-style: solid;
  background: #FFF7DF;
  color: var(--text-primary);
}
.badge-tile > span {
  font-size: 23px;
  line-height: 1;
}
.badge-tile strong {
  font-size: 12px;
  line-height: 1.1;
}
.badge-tile small {
  color: var(--text-secondary);
  font-size: 10.5px;
  line-height: 1.2;
}
:root[data-theme="dark"] .dash-hero {
  background: linear-gradient(135deg, #203D3A, #223646);
}
:root[data-theme="dark"] .badge-tile.unlocked {
  background: #4A3513;
  color: var(--text-primary);
}

.sec-head {
  display: flex; align-items: center; gap: 10px;
  margin: 1.6rem 0 .7rem;
}
.sec-title { font-size: 17px; font-weight: 800; }
.count-badge {
  margin-left: auto; font-size: 12px; font-weight: 800;
  background: var(--surface-1); color: var(--text-secondary);
  border-radius: 999px; padding: 3px 11px;
}
/* auto-fill, bukan auto-fit: kategori berisi 2 game tetap memakai kartu
   seukuran kategori lain, tidak melar memenuhi baris. */
.menugrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }
.gcard {
  position: relative; text-align: center;
  /* Tombol tidak mewarisi color; tanpa baris ini browser memakai `buttontext`
     (hitam) dan nama game jadi hitam di atas kartu gelap saat tema gelap. */
  color: var(--text-primary);
  background: var(--surface-2); border: 1.5px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.1rem .8rem;
  transition: transform .1s, box-shadow .12s, border-color .12s;
}
.gcard:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); border-color: var(--border-strong); }
.gcard:active { transform: translateY(0) scale(.98); }
.gcard[disabled] { opacity: .5; cursor: not-allowed; }
.gcard[disabled]:hover { transform: none; box-shadow: var(--shadow); }
.gcard .emoji {
  width: 52px; height: 52px; border-radius: 50%; margin: 0 auto 10px;
  display: flex; align-items: center; justify-content: center; font-size: 25px;
}
.gcard .gname { display: block; font-size: 14.5px; font-weight: 800; }
.gcard .gdesc { display: block; font-size: 11.5px; color: var(--text-secondary); margin-top: 2px; }
.gcard .best {
  position: absolute; top: 9px; right: 11px;
  font-size: 11px; color: var(--gold); letter-spacing: -1px;
}

/* ---- Leaderboard ---- */
.board { margin-top: 1.6rem; }
.board-head { display: flex; align-items: center; gap: 10px; margin-bottom: .8rem; }
.board-title { font-size: 16px; font-weight: 800; }
.board-note { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.board-head .btn-plain { margin-left: auto; }
.board-list { display: grid; gap: 8px; }
.board-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-1); border-radius: 12px; padding: 10px 14px;
}
.board-row.me { background: var(--accent-soft); }
.board-rank { font-size: 17px; width: 26px; text-align: center; }
.board-name { font-weight: 800; font-size: 14.5px; }
.board-last { font-size: 11.5px; color: var(--text-secondary); }
.board-stars { margin-left: auto; font-weight: 800; font-size: 14.5px; white-space: nowrap; }
.board-stars span { color: var(--gold); }
.board-empty { font-size: 13.5px; color: var(--text-secondary); padding: 4px 2px; }

/* ---- Game chrome ---- */
.ghead { display: flex; align-items: center; gap: 10px; margin: 0 0 1rem; flex-wrap: wrap; }
.ghead .gtitle { font-size: 15px; font-weight: 800; }
.ghead .gcount { font-size: 13px; color: var(--text-secondary); margin-left: auto; }
.pill {
  font-size: 13px; font-weight: 800; padding: 4px 12px; border-radius: 999px;
  background: var(--surface-1); color: var(--text-secondary); white-space: nowrap;
}
.progress { height: 8px; background: var(--surface-1); border-radius: 999px; margin: 0 0 1.25rem; overflow: hidden; }
.progress > div { height: 100%; background: var(--teal-bright); border-radius: 999px; transition: width .25s; }

.qprompt { font-size: 14px; color: var(--text-secondary); margin: 0 0 6px; }
.qbig { font-size: 44px; font-weight: 700; margin: 0; line-height: 1.2; }
.qsub { font-size: 15px; color: var(--teal-deep); margin: 4px 0 1rem; font-style: italic; }
.qgap { height: 1rem; }
.bubble {
  background: var(--surface-1); border-radius: 16px 16px 16px 4px;
  padding: 12px 16px; margin: 0 0 1rem; max-width: 85%;
}

/* ---- Options ---- */
.opts-list .opt { display: block; width: 100%; text-align: left; margin: 9px 0; padding: 13px 17px; font-size: 16px; }
.opts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.opts-grid .opt { margin: 0; text-align: center; padding: 13px 10px; }
.opt {
  background: var(--surface-2); color: var(--text-primary);
  border: 1.5px solid var(--border-strong); border-radius: 12px;
  font-weight: 700; transition: background .12s, border-color .12s, transform .08s;
}
.opt:hover:not(:disabled) { background: var(--surface-1); border-color: var(--teal-bright); }
.opt:active:not(:disabled) { transform: scale(.98); }
.opt.correct { background: var(--bg-success); color: var(--text-success); border-color: var(--text-success); }
.opt.wrong { background: var(--bg-danger); color: var(--text-danger); border-color: var(--text-danger); }
.opt-main { display: block; font-size: 19px; font-weight: 800; }
.opt-sub { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.opt.correct .opt-sub, .opt.wrong .opt-sub { color: inherit; opacity: .8; }
.chip {
  display: inline-block; margin: 5px; padding: 11px 18px; font-size: 17px;
  background: var(--surface-2); color: var(--text-primary);
  border: 1.5px solid var(--border-strong); border-radius: 999px; font-weight: 700;
}
.chip:hover:not(:disabled) { background: var(--surface-1); border-color: var(--teal-bright); }

/* ---- Feedback ---- */
.fb { margin: 12px 0; padding: 12px 16px; border-radius: 12px; font-size: 14px; font-weight: 700; }
.fb.ok { background: var(--bg-success); color: var(--text-success); }
.fb.no { background: var(--bg-danger); color: var(--text-danger); }

/* ---- Sentence builder ---- */
.slot {
  min-height: 56px; border: 2px dashed var(--border-strong); border-radius: 12px;
  padding: 10px; margin: 0 0 12px; font-size: 22px;
}
.slot.ok { border-color: var(--teal-bright); border-style: solid; }
.slot.no { border-color: var(--coral-bright); border-style: solid; }

/* ---- Memory ---- */
.memgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.mem {
  height: 68px; border: 1.5px solid var(--border-strong); border-radius: 12px;
  background: var(--surface-2); color: var(--text-primary);
  font-size: 15px; font-weight: 700; font-family: inherit;
  display: flex; align-items: center; justify-content: center;
  padding: 4px; text-align: center;
}
.mem:hover { background: var(--surface-1); }
.mem.open { background: var(--accent-soft); color: var(--teal-deep); border-color: var(--teal-bright); }
.mem.done { background: var(--bg-success); color: var(--text-success); border-color: transparent; cursor: default; }
@media (max-width: 430px) { .memgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ---- Typing ---- */
.tinput {
  width: 100%; padding: 13px 16px; font-size: 18px; font-family: inherit;
  border-radius: 12px; border: 2px solid var(--border-strong);
  background: var(--surface-2); color: var(--text-primary);
}
.tinput:focus { outline: 3px solid var(--teal-bright); outline-offset: 1px; }
.toolbar { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.hintrow { font-size: 13px; color: var(--text-secondary); margin-top: 8px; }

/* ---- Speaker ---- */
.speaker {
  width: 100%; padding: 1.6rem; font-size: 42px;
  border-radius: 18px; background: var(--accent-soft);
  border: 2px solid var(--teal-bright); color: var(--teal-deep); margin: 0 0 1rem;
}
.speaker:hover { background: var(--surface-1); }

/* ---- Modal ---- */
.modal-back {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(46, 58, 89, .5);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
  animation: fade .16s ease-out;
}
.modal {
  position: relative; width: 100%; max-width: 470px;
  background: var(--surface-2); border-radius: 24px;
  padding: 1.8rem 1.5rem 1.5rem; text-align: center;
  box-shadow: var(--shadow-lift);
  animation: pop .18s ease-out;
  max-height: 90vh; overflow-y: auto;
}
.modal-x {
  position: absolute; top: 12px; right: 12px;
  width: 34px; height: 34px; border-radius: 50%;
  border: 1.5px solid var(--border); background: var(--surface-2);
  color: var(--text-secondary); font-size: 14px; line-height: 1;
}
.modal-x:hover { background: var(--surface-1); }
.modal-stars { font-size: 26px; letter-spacing: 3px; color: var(--gold); }
.modal-name { font-size: 22px; font-weight: 800; margin-top: 4px; }
.modal-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px; margin: 1.2rem 0 1.4rem; text-align: left;
}
.stat { background: var(--surface-1); border-radius: 12px; padding: 10px 13px; }
.stat-k { font-size: 11.5px; color: var(--text-secondary); font-weight: 700; }
.stat-v { font-size: 16px; font-weight: 800; margin-top: 1px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
@media (max-width: 400px) { .modal-grid { grid-template-columns: 1fr; } }

.star-off { opacity: .28; filter: grayscale(1); }

/* ---- Popup pasang aplikasi (PWA) ---- */
.pwa-back {
  backdrop-filter: blur(3px);
  background: rgba(46, 58, 89, .58);
}
.pwa-modal {
  max-width: 420px;
  padding: 1.9rem 1.4rem 1.2rem;
}
.pwa-appmark {
  position: relative;
  width: 74px;
  height: 74px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: linear-gradient(160deg, var(--accent-soft), var(--surface-1));
  border: 1px solid var(--border);
  box-shadow: 0 8px 22px rgba(23, 121, 111, .18);
  animation: pwa-mark-in .4s ease-out;
}
.pwa-appmark img {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  display: block;
}
.pwa-appmark-badge {
  position: absolute;
  right: -6px;
  bottom: -4px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--teal);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  border: 2.5px solid var(--surface-2);
}
.pwa-tag {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--surface-1);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .3px;
  text-transform: uppercase;
}
.pwa-modal .modal-name { margin-top: 8px; font-size: 21px; }
.pwa-lead {
  margin: 8px auto 14px;
  max-width: 330px;
  color: var(--text-secondary);
  font-size: 13.5px;
}
.pwa-benefits {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}
.pwa-benefits span {
  min-height: 62px;
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 8px 6px;
  border-radius: 14px;
  background: var(--surface-1);
  color: var(--text-primary);
  font-size: 11.5px;
  font-weight: 800;
  line-height: 1.25;
}
.pwa-benefits b { font-size: 19px; line-height: 1; }
.pwa-steps {
  display: grid;
  gap: 8px;
  margin: 14px 0 12px;
  text-align: left;
}
.pwa-steps li {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
}
.pwa-steps b { color: var(--text-primary); font-weight: 900; }
.pwa-step-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--teal);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}
.pwa-note {
  margin: 0 auto 14px;
  max-width: 330px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}
.pwa-modal .modal-actions .btn-cta { min-width: 168px; }
/* Tombol asli browser tersedia — beri sedikit penekanan. */
.pwa-cta-ready { box-shadow: 0 6px 18px rgba(23, 121, 111, .32); }
.pwa-cta-ready[disabled] { opacity: .6; }
.pwa-never {
  margin: 12px auto 0;
  display: block;
  border: 0;
  background: none;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}
.pwa-never:hover { color: var(--text-secondary); }

/* Tombol Install di bilah atas: berdenyut halus saat browser siap memasang. */
.install-btn.ready {
  background: #fff;
  color: var(--teal-deep);
  animation: install-pulse 2.6s ease-in-out infinite;
}
.install-btn.ready:hover { background: #fff; }

/* Pesan singkat setelah aplikasi terpasang / gagal dipasang. */
.pwa-toast {
  position: fixed;
  z-index: 70;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: max-content;
  max-width: min(92vw, 420px);
  padding: 11px 16px;
  border-radius: 14px;
  background: var(--text-primary);
  color: var(--bg);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  box-shadow: var(--shadow-lift);
  animation: toast-in .22s ease-out;
}
/* Saat popup terbuka (lembar bawah di ponsel), pesan pindah ke atas supaya
   tidak menutupi tombolnya. */
.modal-lock .pwa-toast {
  top: calc(16px + env(safe-area-inset-top));
  bottom: auto;
}

/* Layar sempit: popup tampil sebagai lembar yang naik dari bawah. */
@media (max-width: 520px) {
  .pwa-back { align-items: flex-end; padding: 0; }
  .pwa-modal {
    max-width: none;
    max-height: 92vh;
    border-radius: 26px 26px 0 0;
    padding-bottom: calc(1.2rem + env(safe-area-inset-bottom));
    animation: pwa-sheet .24s ease-out;
  }
  .pwa-modal .modal-actions { flex-direction: column-reverse; }
  .pwa-modal .modal-actions button { width: 100%; }
}
@media (max-width: 360px) {
  .pwa-benefits { grid-template-columns: repeat(3, minmax(0, 1fr)); font-size: 10.5px; }
}

@keyframes pwa-sheet { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes pwa-mark-in { 0% { transform: scale(.7) rotate(-8deg); } 60% { transform: scale(1.07); } 100% { transform: scale(1) rotate(0); } }
@keyframes toast-in { from { transform: translate(-50%, 12px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
@keyframes install-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, .55); }
  50% { box-shadow: 0 0 0 7px rgba(255, 255, 255, 0); }
}

/* Kunci gulir halaman selama popup terbuka. */
.modal-lock, .modal-lock body { overflow: hidden; }

/* ---- Footer ---- */
.site-foot { margin-top: 2rem; text-align: center; }
.foot-link {
  /* --text-muted terlalu pucat untuk teks 12.5px (gagal AA); pakai secondary. */
  font-size: 12.5px; color: var(--text-secondary); text-decoration: none;
  padding: 6px 12px; border-radius: 999px;
}
.foot-link:hover { color: var(--text-primary); background: var(--surface-1); }

@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---- Avatar ---- */
.avatar-label { font-size: 13px; font-weight: 700; color: var(--text-secondary); margin-top: 1.4rem; }
.avatar-pick {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 10px;
}
.avatar-opt {
  width: 48px; height: 48px; font-size: 24px; line-height: 1;
  border: 2px solid var(--border); border-radius: 50%;
  background: var(--surface-1); padding: 0;
  transition: transform .1s, border-color .12s, background .12s;
}
.avatar-opt:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.avatar-opt[aria-checked="true"] {
  border-color: var(--teal); background: var(--accent-soft); transform: scale(1.08);
}
.head-avatar { margin-right: 2px; }
.hello-avatar {
  font-size: 34px; line-height: 1; width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-1); border-radius: 50%; flex: none;
}
.board-avatar { font-size: 20px; line-height: 1; }

/* ---- Streak ---- */
.pill.streak {
  background: #FDEBD0; color: #9A5B08;
  animation: streak-pop .3s ease-out;
}
:root[data-theme="dark"] .pill.streak { background: #4A3410; color: #F5C877; }
@keyframes streak-pop { from { transform: scale(1.4); } to { transform: scale(1); } }

/* ---- Umpan balik jawaban ---- */
.opt.correct { animation: opt-pop .32s ease-out; }
.opt.wrong { animation: opt-shake .34s ease-out; }
@keyframes opt-pop {
  0% { transform: scale(1); } 40% { transform: scale(1.06); } 100% { transform: scale(1); }
}
@keyframes opt-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(4px); }
}
.modal-stars { animation: star-bounce .5s ease-out; }
@keyframes star-bounce {
  0% { transform: scale(0) rotate(-12deg); } 60% { transform: scale(1.15); }
  100% { transform: scale(1) rotate(0); }
}

/* ---- Nomor pintasan pada opsi (dibaca keyboard 1-9) ---- */
.opts-list { counter-reset: opt; }
.opts-list .opt { position: relative; padding-left: 46px; }
.opts-list .opt::before {
  counter-increment: opt; content: counter(opt);
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
  background: var(--surface-1); color: var(--text-secondary);
}
.opt.correct::before { background: rgba(255,255,255,.5); color: inherit; }
.opt.wrong::before { background: rgba(255,255,255,.5); color: inherit; }
@media (max-width: 480px) { .opts-list .opt::before { opacity: .6; } }

/* ---- Efek: semburan & confetti ---- */
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.fx-bit {
  position: absolute; will-change: transform, opacity;
  animation: fx-fly .8s ease-out forwards;
}
@keyframes fx-fly {
  0% { transform: translate(0, 0) scale(.5); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1.1); opacity: 0; }
}
.fx-confetti {
  position: absolute; top: -14px; width: 9px; height: 14px; border-radius: 2px;
  will-change: transform, opacity; animation: fx-fall 2s linear forwards;
}
@keyframes fx-fall {
  0% { transform: translateY(-10px) rotate(0); opacity: 1; }
  100% { transform: translateY(105vh) rotate(540deg); opacity: .9; }
}

/* Di layar sempit, teks sekunder ini menumpuk jadi beberapa baris dan
   menyempitkan ruang yang dibutuhkan tombol. */
@media (max-width: 480px) {
  .brand-tag, .board-note { display: none; }
  .brand-name { font-size: 18px; }
  .hello-title { font-size: 22px; }
  .qbig { font-size: 38px; }
  .dash-hero {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .dash-hero .btn-plain {
    grid-column: 1 / -1;
    justify-self: start;
  }
  .practice-main {
    align-items: stretch;
    flex-direction: column;
  }
  .practice-actions {
    justify-content: stretch;
  }
  .practice-actions .gcard {
    flex: 1 1 130px;
  }
  .stat-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .path-map::before {
    left: 20px;
  }
  .path-stop,
  .path-stop.left,
  .path-stop.right {
    justify-content: flex-start;
    padding-left: 38px;
  }
  .path-card.gcard {
    width: 100%;
  }
  .mission-row {
    grid-template-columns: 28px minmax(0, 1fr) 42px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
