:root {
  --cream: #faf6ee;
  --surface: #ffffff;
  --surface-2: #f3ecdf;
  --ink: #2a2118;
  --muted: #6d6153;
  --line: #e1d6c3;
  --brown: #8a5a2b;
  --brown-d: #6e4520;
  --navy: #1f3557;
  --navy-on-brown: #1f3557;
  --on-accent: #ffffff;
  --cell: #ffffff;
  --cell-line: #b9a98e;
  --hl: #f1e3c8;
  --active: #cfe0f6;
  --active-line: #1f3557;
  --ok: #2f7d4a;
  --ok-bg: #dcefe2;
  --bad: #b3372b;
  --bad-bg: #f7dcd8;
  --shadow: 0 1px 2px rgba(42, 33, 24, .06), 0 4px 14px rgba(42, 33, 24, .05);
  --radius: 12px;
  --serif: Georgia, "Times New Roman", "Noto Serif", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --cream: #16191f;
  --surface: #1e232b;
  --surface-2: #262c36;
  --ink: #ece6da;
  --muted: #a39b8c;
  --line: #333a46;
  --brown: #d1a56b;
  --brown-d: #e0b982;
  --navy: #8fb0e0;
  --navy-on-brown: #16191f;
  --on-accent: #16191f;
  --cell: #262c36;
  --cell-line: #566073;
  --hl: #3a3426;
  --active: #29436b;
  --active-line: #8fb0e0;
  --ok: #7cc795;
  --ok-bg: #213a2a;
  --bad: #ef8d82;
  --bad-bg: #432522;
  --shadow: none;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --cream: #16191f;
    --surface: #1e232b;
    --surface-2: #262c36;
    --ink: #ece6da;
    --muted: #a39b8c;
    --line: #333a46;
    --brown: #d1a56b;
    --brown-d: #e0b982;
    --navy: #8fb0e0;
    --navy-on-brown: #16191f;
    --on-accent: #16191f;
    --cell: #262c36;
    --cell-line: #566073;
    --hl: #3a3426;
    --active: #29436b;
    --active-line: #8fb0e0;
    --ok: #7cc795;
    --ok-bg: #213a2a;
    --bad: #ef8d82;
    --bad-bg: #432522;
    --shadow: none;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--cream);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}
main { flex: 1; outline: none; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; margin: 0 0 .5em; font-weight: 700; }
h1 { font-size: clamp(1.7rem, 5vw, 2.5rem); }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .9em; }
a { color: var(--navy); }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9em; background: var(--surface-2); padding: 0 .3em; border-radius: 4px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.skip { position: absolute; left: -999px; top: 0; background: var(--navy); color: var(--cream); padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }
:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; }

/* header */
.bar {
  position: sticky; top: 0; z-index: 20;
  background: var(--cream);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.bar-in {
  max-width: 1100px; margin: 0 auto;
  display: flex; align-items: center; gap: .5rem;
  padding: .55rem max(1rem, env(safe-area-inset-left)) .55rem max(1rem, env(safe-area-inset-right));
}
.brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--ink); font-family: var(--serif); font-weight: 700; font-size: 1.1rem; }
.nav { margin-left: auto; display: flex; gap: .15rem; }
.nav a { text-decoration: none; color: var(--muted); padding: .5rem .7rem; border-radius: 8px; font-weight: 600; font-size: .95rem; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { color: var(--navy); background: var(--surface-2); }
.icon-btn { background: none; border: 1px solid var(--line); color: var(--ink); width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }
@media (max-width: 480px) {
  .brand span { display: none; }
  .nav { margin-left: 0; flex: 1; justify-content: space-around; }
}

/* layout */
.wrap { max-width: 1100px; margin: 0 auto; padding: 1.5rem max(1rem, env(safe-area-inset-left)) 2.5rem max(1rem, env(safe-area-inset-right)); }
.wrap.narrow { max-width: 760px; }
.wrap.wide { max-width: 1200px; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 880px) { .grid-2 { grid-template-columns: 1.25fr 1fr; align-items: start; } }
.stack { display: grid; gap: 1rem; }
.section { margin-top: 2rem; }
.eyebrow { margin: 0 0 .35rem; font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--brown); }
.lead { font-size: 1.08rem; color: var(--muted); max-width: 60ch; }

.hero { padding: .5rem 0 1.5rem; }
.hero-act { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.1rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.15rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.grid-2 .card, .stack .card { margin-bottom: 0; }
.card > h2:first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.2rem; margin: 0 0 .9em; }
.prose li { margin-bottom: .35em; }
.prose ul.anggota { list-style: none; padding: 0; margin: 0; }
.anggota li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem .2rem; margin: 0; border-bottom: 1px solid var(--line); font-weight: 600; }
.anggota li:last-child { border-bottom: 0; }
.anggota b { font-variant-numeric: tabular-nums; color: var(--navy); background: var(--surface-2); border-radius: 8px; padding: .15rem .6rem; }

/* buttons */
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px;
  padding: .6rem 1rem; min-height: 44px;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  touch-action: manipulation;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--navy); color: var(--cream); border-color: var(--navy); }
:root[data-theme="dark"] .btn.primary { color: #10151c; }
@media (prefers-color-scheme: dark) { :root[data-theme="auto"] .btn.primary { color: #10151c; } }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.big { padding: .75rem 1.3rem; font-size: 1.02rem; }
.btn.small { padding: .4rem .75rem; min-height: 40px; font-size: .9rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* chips */
.field { margin-bottom: 1.1rem; }
.label { display: block; font-size: .85rem; font-weight: 700; color: var(--muted); margin-bottom: .4rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  font: inherit; font-size: .92rem; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: .45rem .85rem; border-radius: 999px; min-height: 40px;
  touch-action: manipulation;
}
.chip:hover { background: var(--surface-2); }
.chip[aria-checked="true"] { background: var(--brown); color: var(--on-accent); border-color: var(--brown); }
.hint { font-size: .88rem; color: var(--muted); margin: .5rem 0 0; }

/* switch */
.switch { display: flex; align-items: center; gap: .7rem; cursor: pointer; min-height: 44px; font-weight: 600; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 44px; height: 26px; border-radius: 99px; background: var(--line); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .15s; }
.switch input:checked + .track { background: var(--navy); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 3px solid var(--navy); outline-offset: 2px; }

/* packs */
.packs { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.pack {
  display: flex; align-items: center; gap: .8rem; width: 100%;
  text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--cream); border: 1px solid var(--line); border-radius: 10px; padding: .7rem .85rem; min-height: 56px;
  touch-action: manipulation;
}
.pack:hover { border-color: var(--brown); }
.pack-n { font-family: var(--serif); font-weight: 700; font-size: 1.2rem; width: 2rem; text-align: center; color: var(--brown); }
.pack-b { flex: 1; min-width: 0; }
.pack-b strong { display: block; }
.pack-b span { font-size: .85rem; color: var(--muted); }
.badge { font-size: .78rem; font-weight: 700; padding: .15rem .55rem; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.done { background: var(--ok-bg); color: var(--ok); }

/* progress */
.prog-row { margin-bottom: .8rem; }
.prog-row-h { display: flex; justify-content: space-between; font-size: .92rem; margin-bottom: .25rem; }
.progress { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.progress-fill { height: 100%; width: 0; background: var(--brown); transition: width .25s; }

.topic-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .8rem; }
.topic-card { display: block; text-decoration: none; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); text-align: left; font: inherit; cursor: pointer; }
.topic-card:hover { border-color: var(--brown); }
.topic-card b { font-family: var(--serif); font-size: 1.1rem; display: block; color: var(--navy); }
.topic-card small { color: var(--muted); display: block; margin-top: .25rem; }

/* game */
.game-top { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: .7rem; }
.game-title { flex: 1; min-width: 140px; display: flex; flex-direction: column; line-height: 1.25; }
.game-title strong { font-family: var(--serif); font-size: 1.15rem; }
.stats { display: flex; gap: .5rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .25rem .7rem; text-align: center; min-width: 70px; }
.stat-l { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.stat-v { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 1.1rem; }
#g-prog-teks { margin: .35rem 0 .8rem; }

.game { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 759px) {
  .clue-now { position: sticky; top: calc(58px + env(safe-area-inset-top)); z-index: 12; min-height: 56px; }
  .clue-now-t { font-size: .9rem; }
  .game-top { gap: .5rem; }
  .stat { min-width: 62px; padding: .15rem .5rem; }
  .stat-v { font-size: 1rem; }
  #g-prog-teks { font-size: .8rem; margin: .3rem 0 .6rem; }
}
@media (min-width: 760px) { .game { grid-template-columns: minmax(0, 1fr) 320px; } }
@media (min-width: 1000px) { .game { grid-template-columns: minmax(0, 1fr) 380px; } }

.clue-now {
  display: flex; align-items: center; gap: .5rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: .45rem .5rem; margin-bottom: .7rem; min-height: 64px;
}
.clue-now-t { flex: 1; font-size: .98rem; line-height: 1.35; }
.clue-now-t b { color: var(--brown); font-family: var(--serif); }
.mini { font: inherit; font-size: 1.5rem; line-height: 1; width: 42px; height: 42px; flex: none; border-radius: 8px; border: 1px solid var(--line); background: var(--cream); color: var(--ink); cursor: pointer; touch-action: manipulation; }
.mini:hover { background: var(--surface-2); }

.grid-wrap { overflow-x: auto; display: flex; justify-content: center; padding: .3rem 0 .6rem; }
.tts { position: relative; display: grid; user-select: none; -webkit-user-select: none; touch-action: manipulation; flex: none; }
.c {
  position: relative; width: var(--cs); height: var(--cs);
  background: var(--cell); border: 1px solid var(--cell-line);
  margin: 0 -1px -1px 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--sans); font-weight: 700; color: var(--ink);
  font-size: calc(var(--cs) * .52);
  cursor: pointer;
}
.c .n { position: absolute; left: 2px; top: 1px; font-size: max(8px, calc(var(--cs) * .27)); font-weight: 600; line-height: 1; color: var(--muted); }
.c.hl { background: var(--hl); }
.c.act { background: var(--active); outline: 2px solid var(--active-line); outline-offset: -2px; z-index: 2; }
.c.ok { background: var(--ok-bg); color: var(--ok); }
.c.salah { background: var(--bad-bg); color: var(--bad); }
.c.hint-c { color: var(--navy); }
.c.hint-c::after { content: ""; position: absolute; right: 2px; bottom: 2px; width: 5px; height: 5px; border-radius: 50%; background: var(--navy); }

.tools { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; }
.status { min-height: 1.5em; margin: .6rem 0 0; font-size: .92rem; color: var(--muted); }
.status.ok { color: var(--ok); }
.status.bad { color: var(--bad); }

.clues { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; }
.clues h3 { margin: 0 0 .4rem; color: var(--brown); font-size: .95rem; text-transform: uppercase; letter-spacing: .06em; font-family: var(--sans); }
.clue-col + .clue-col { margin-top: 1rem; }
.clue-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .15rem; }
@media (min-width: 760px) {
  .clues { max-height: calc(100dvh - 190px); overflow: auto; position: sticky; top: 70px; }
}
.clue { display: flex; gap: .55rem; padding: .45rem .5rem; border-radius: 8px; cursor: pointer; font-size: .93rem; line-height: 1.35; border: 1px solid transparent; touch-action: manipulation; }
.clue:hover { background: var(--surface-2); }
.clue .no { font-family: var(--serif); font-weight: 700; color: var(--brown); min-width: 1.5rem; text-align: right; }
.clue.current { background: var(--active); border-color: var(--active-line); }
.clue.done { color: var(--muted); }
.clue.done .no::after { content: " \2713"; font-size: .75em; }
.clue small { color: var(--muted); white-space: nowrap; }

.tabs { display: none; gap: .3rem; margin-bottom: .6rem; }
.tabs button { flex: 1; font: inherit; font-weight: 600; cursor: pointer; padding: .55rem .6rem; border: 1px solid var(--line); background: var(--cream); color: var(--ink); border-radius: 8px; min-height: 44px; }
.tabs button[aria-selected="true"] { background: var(--navy); color: var(--cream); border-color: var(--navy); }
:root[data-theme="dark"] .tabs button[aria-selected="true"] { color: #10151c; }
@media (prefers-color-scheme: dark) { :root[data-theme="auto"] .tabs button[aria-selected="true"] { color: #10151c; } }
@media (max-width: 759px) {
  .clues .tabs { display: flex; }
  .clues[data-tab="m"] .clue-col[data-col="d"], .clues[data-tab="d"] .clue-col[data-col="m"] { display: none; }
  .clue-col h3 { display: none; }
}
.tabs.scroll { display: flex; overflow-x: auto; margin: .2rem 0 1rem; padding-bottom: .2rem; scrollbar-width: thin; }
.tabs.scroll button { flex: none; }

.finish { margin-top: 1.2rem; display: flex; justify-content: center; }

/* papan ketik di layar */
.kb { position: sticky; bottom: 0; z-index: 15; background: var(--surface-2); border-top: 1px solid var(--line); padding: .45rem .3rem calc(.45rem + env(safe-area-inset-bottom)); margin: 1rem -1rem -2.5rem; }
.kb-row { display: flex; justify-content: center; gap: .3rem; margin-bottom: .3rem; }
.kb-row:last-child { margin-bottom: 0; }
.key { flex: 1 1 0; max-width: 44px; height: 46px; font: inherit; font-weight: 700; font-size: 1.05rem; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; touch-action: manipulation; padding: 0; }
.key:active { background: var(--active); }
.key.wide { max-width: 64px; flex: 1.4 1 0; }

/* hasil */
.result-top { display: flex; flex-wrap: wrap; gap: 1.2rem; align-items: center; }
.score-big { text-align: center; padding: .5rem 1.2rem; border-right: 1px solid var(--line); }
.score-big span { display: block; font-family: var(--serif); font-weight: 700; font-size: 3.4rem; line-height: 1; color: var(--navy); }
.score-big small { color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .8rem 1.2rem; margin: 0; flex: 1; min-width: 240px; }
.facts dt { font-size: .8rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 700; font-size: 1.15rem; }
@media (max-width: 520px) { .score-big { border-right: 0; border-bottom: 1px solid var(--line); width: 100%; padding-bottom: .8rem; } }
.review { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: .7rem; }
.rv { background: var(--surface); border: 1px solid var(--line); border-left-width: 5px; border-radius: 10px; padding: .8rem .95rem; }
.rv.benar { border-left-color: var(--ok); }
.rv.salah { border-left-color: var(--bad); }
.rv-h { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; font-weight: 700; margin-bottom: .2rem; }
.rv-h .tag { font-size: .75rem; padding: .1rem .5rem; border-radius: 99px; }
.tag.benar { background: var(--ok-bg); color: var(--ok); }
.tag.salah { background: var(--bad-bg); color: var(--bad); }
.rv-q { margin: 0 0 .4rem; }
.rv-a { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .08em; }
.rv-a b { color: var(--ok); }
.rv-your.salah { color: var(--bad); text-decoration: line-through; text-decoration-thickness: 1px; }
.rv-e { margin: .4rem 0 0; font-size: .93rem; color: var(--muted); }

/* materi */
.materi h2 { margin-top: 1.6rem; color: var(--navy); }
.materi h2:first-child { margin-top: 0; }
.materi h3 { margin-top: 1.1rem; color: var(--brown); }
.materi p { max-width: 68ch; }
.tl { list-style: none; margin: 0; padding: 0 0 0 1.1rem; border-left: 2px solid var(--line); }
.tl li { position: relative; padding: 0 0 1rem 1rem; }
.tl li::before { content: ""; position: absolute; left: -1.62rem; top: .45rem; width: 11px; height: 11px; border-radius: 50%; background: var(--brown); border: 2px solid var(--cream); }
.tl .yr { font-family: var(--serif); font-weight: 700; color: var(--navy); }
.tl .tp { font-size: .75rem; margin-left: .4rem; padding: .05rem .5rem; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .7rem; }
.mini-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .8rem .9rem; }
.mini-card b { display: block; font-family: var(--serif); }
.mini-card .role { font-size: .82rem; color: var(--brown); font-weight: 600; margin-bottom: .25rem; display: block; }
.mini-card p { margin: 0; font-size: .92rem; }
.compare { display: grid; gap: .5rem; }
.cmp-head, .cmp-row { display: grid; grid-template-columns: 130px 1fr 1fr; gap: .6rem; }
.cmp-head { font-weight: 700; color: var(--navy); font-size: .9rem; padding: 0 .8rem; }
.cmp-row { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .7rem .8rem; }
.cmp-row b { color: var(--brown); }
@media (max-width: 640px) {
  .cmp-head { display: none; }
  .cmp-row { grid-template-columns: 1fr; gap: .2rem; }
  .cmp-row span[data-l]::before { content: attr(data-l) ": "; font-weight: 700; color: var(--navy); }
}
.empty { color: var(--muted); }

.foot { text-align: center; padding: 1.5rem 1rem calc(1.5rem + env(safe-area-inset-bottom)); color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); }
.foot p { margin: 0; }

/* modal & toast */
.overlay { position: fixed; inset: 0; background: rgba(15, 12, 8, .5); display: grid; place-items: center; padding: 1rem; z-index: 50; }
.dialog { background: var(--surface); color: var(--ink); border-radius: 14px; padding: 1.3rem; max-width: 420px; width: 100%; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.dialog h2 { margin-top: 0; }
.dialog-act { display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: calc(1.2rem + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--ink); color: var(--cream); padding: .6rem 1rem; border-radius: 10px; font-size: .92rem; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
body.has-kb .toast { bottom: calc(210px + env(safe-area-inset-bottom)); }

@media (max-height: 500px) and (orientation: landscape) {
  .key { height: 34px; font-size: .95rem; }
  .kb { padding-top: .3rem; padding-bottom: .3rem; }
  .kb-row { margin-bottom: .2rem; }
  .clue-now { position: static; min-height: 48px; }
  .bar { position: static; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
  .bar, .foot, .tools, .kb, .finish, .hero-act, .nav { display: none !important; }
  body { background: #fff; color: #000; }
}
