@font-face { font-family: 'Amiri Quran'; src: url(fonts/amiri-quran-arabic.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Nunito'; src: url(fonts/nunito-latin.woff2) format('woff2'); font-weight: 500 800; font-display: swap; }

:root {
  --bg: #F3F8F5; --card: #FFFFFF; --ink: #17312A; --muted: #55665F; --line: #DCE8E2; --line-soft: #EDF2EF;
  --green: #1A7F55; --green-dark: #135F40; --green-soft: #DFF3E8; --on-green: #FFFFFF;
  --orange: #B4541B; --orange-dark: #8C3F12; --orange-soft: #FDEBDD; --orange-line: #E8B48F;
  --blue: #2459B8; --blue-soft: #E1EBFB;
  --gold: #F2B53A; --gold-line: #D9982A; --star-off: #DCE8E2;
  --hl: #FFF1BF; --warn-bg: #FFF4E0; --warn-ink: #7A4B00; --warn-line: #E6C58F;
  --bad: #A8402F; --bad-soft: #F9E1DC; --used: #EDF2EF; --used-ink: #C3CFC9;
  --shadow: 0 2px 10px rgba(23, 49, 42, .07);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1714; --card: #18221E; --ink: #E6EFEA; --muted: #9BB0A6; --line: #2A3832; --line-soft: #212D28;
    --green: #3DBB84; --green-dark: #2C9467; --green-soft: #1D3A2D; --on-green: #08130E;
    --orange: #F0995E; --orange-dark: #F0995E; --orange-soft: #3A2618; --orange-line: #6B4128;
    --blue: #86AEF5; --blue-soft: #1C2A44;
    --gold-line: #B98420; --star-off: #2A3832;
    --hl: #4A3D17; --warn-bg: #3A2E14; --warn-ink: #F3D08B; --warn-line: #6B5426;
    --bad: #F08A78; --bad-soft: #3D211C; --used: #1C2622; --used-ink: #3D4C45;
    --shadow: 0 1px 3px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1714; --card: #18221E; --ink: #E6EFEA; --muted: #9BB0A6; --line: #2A3832; --line-soft: #212D28;
  --green: #3DBB84; --green-dark: #2C9467; --green-soft: #1D3A2D; --on-green: #08130E;
  --orange: #F0995E; --orange-dark: #F0995E; --orange-soft: #3A2618; --orange-line: #6B4128;
  --blue: #86AEF5; --blue-soft: #1C2A44;
  --gold-line: #B98420; --star-off: #2A3832;
  --hl: #4A3D17; --warn-bg: #3A2E14; --warn-ink: #F3D08B; --warn-line: #6B5426;
  --bad: #F08A78; --bad-soft: #3D211C; --used: #1C2622; --used-ink: #3D4C45;
  --shadow: 0 1px 3px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: Nunito, system-ui, sans-serif; font-size: 16px; line-height: 1.4;
  -webkit-text-size-adjust: 100%; overscroll-behavior-y: none;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: default; }
a { color: var(--green); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.ic { display: inline-flex; flex: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 13px; }

/* ---------- screen frame ---------- */
.screen {
  max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; gap: 14px;
  padding: calc(16px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom));
}
.screen.flush { padding-bottom: 0; }
.grow { flex: 1 1 auto; }
.topbar { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.topbar .title { font-size: 21px; font-weight: 800; flex: 1; }
.round-btn {
  flex: none; width: 46px; height: 46px; border-radius: 50%; background: var(--card); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; box-shadow: var(--shadow);
}
.round-btn.quiet { color: var(--muted); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; }
.brand .logo { width: 36px; height: 36px; border-radius: 12px; background: var(--green); color: var(--on-green); display: inline-flex; align-items: center; justify-content: center; }

.card { background: var(--card); border-radius: 20px; padding: 16px 18px; box-shadow: var(--shadow); }
.section-label { font-size: 13px; font-weight: 800; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; padding: 4px 6px 0; }
.h1 { font-size: 30px; font-weight: 800; text-align: center; margin: 24px 0 0; }
.h2 { font-size: 18px; font-weight: 800; padding: 0 4px; }
.center { text-align: center; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  border-radius: 18px; padding: 16px; font-size: 19px; font-weight: 800; text-decoration: none;
}
.btn.primary { background: var(--green); color: var(--on-green); box-shadow: 0 3px 0 var(--green-dark); }
.btn.primary:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--green-dark); }
.btn.primary:disabled { opacity: .45; box-shadow: none; }
.btn.secondary { background: var(--card); color: var(--ink); border: 2px solid var(--line); font-size: 17px; }
.link-btn { color: var(--green); font-weight: 800; font-size: 15px; padding: 10px 6px; }
.link-btn.muted { color: var(--muted); }
.link-btn.danger { color: var(--bad); }

/* ---------- avatars / players ---------- */
.av { flex: none; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
.av.lg { width: 88px; height: 88px; font-size: 48px; }
.av.md { width: 40px; height: 40px; font-size: 22px; }
.players { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.player-card {
  background: var(--card); border-radius: 24px; padding: 22px 12px 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; gap: 12px; font-size: 20px; font-weight: 800;
  overflow-wrap: anywhere; text-align: center;
}
.player-card.add { background: transparent; border: 2px dashed var(--line); box-shadow: none; color: var(--green); }
.player-card.add .av { background: var(--green-soft); }
.who-pill {
  display: flex; align-items: center; gap: 10px; padding: 4px 12px 4px 4px; background: var(--card);
  border-radius: 999px; box-shadow: var(--shadow); font-weight: 800; font-size: 17px; max-width: 70%;
}
.who-pill span.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.avatar-opt { aspect-ratio: 1; border-radius: 20px; font-size: 34px; border: 3px solid transparent; display: flex; align-items: center; justify-content: center; }
.avatar-opt[aria-pressed="true"] { border-color: var(--green); }
.text-input {
  width: 100%; height: 56px; border-radius: 16px; border: 2px solid var(--line); background: var(--card);
  padding: 0 16px; font-size: 20px; font-weight: 700;
}
.text-input:focus { border-color: var(--green); outline: none; }

/* ---------- home ---------- */
.batas-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
  background: var(--green-soft); color: var(--green-dark); border-radius: 14px; padding: 12px 16px;
  font-size: 22px; font-weight: 800; text-align: left;
}
:root[data-theme="dark"] .batas-btn { color: var(--green); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .batas-btn { color: var(--green); } }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--line-soft); border-radius: 14px; padding: 4px; }
.seg button { border-radius: 10px; padding: 11px 14px; font-size: 16px; font-weight: 800; color: var(--muted); min-width: 60px; }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 4px rgba(23, 49, 42, .12); }
.seg.green button[aria-pressed="true"] { background: var(--green); color: var(--on-green); }
.mode-card {
  display: flex; align-items: center; gap: 16px; width: 100%; text-align: left; background: var(--card);
  border-radius: 22px; padding: 16px; min-height: 92px; box-shadow: var(--shadow);
}
.mode-card .mi { flex: none; width: 60px; height: 60px; border-radius: 18px; display: flex; align-items: center; justify-content: center; }
.mode-card b { display: block; font-size: 20px; }
.mode-card small { display: block; font-size: 15px; color: var(--muted); }
.mode-card .txt { flex: 1; }
.m-sambung .mi { background: var(--green-soft); color: var(--green); } .m-sambung > .ic:last-child { color: var(--green); }
.m-susun .mi { background: var(--orange-soft); color: var(--orange); } .m-susun > .ic:last-child { color: var(--orange); }
.m-tebak .mi { background: var(--blue-soft); color: var(--blue); } .m-tebak > .ic:last-child { color: var(--blue); }

/* ---------- surah lists ---------- */
.search {
  display: flex; align-items: center; gap: 10px; background: var(--card); border: 2px solid var(--line);
  border-radius: 14px; padding: 0 14px; height: 50px; color: var(--muted);
}
.search input { flex: 1; border: 0; background: none; outline: none; font-size: 17px; color: var(--ink); min-width: 0; }
.slist { display: flex; flex-direction: column; gap: 4px; padding-bottom: 12px; }
.juz-h { display: flex; align-items: center; justify-content: space-between; padding: 14px 6px 4px; font-size: 13px; font-weight: 800; color: var(--muted); letter-spacing: .04em; }
.s-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border-radius: 14px;
  padding: 12px; border: 2px solid transparent; font-size: 17px; font-weight: 800; min-height: 52px;
}
.s-row .num { width: 32px; text-align: center; font-size: 13px; font-weight: 700; color: var(--muted); }
.s-row .nm { flex: 1; }
.s-row.in { background: var(--card); }
.s-row.sel { background: var(--green-soft); border-color: var(--green); }
.s-row input[type=checkbox] { width: 24px; height: 24px; margin: 0; accent-color: var(--green); flex: none; }
.s-row.checked { background: var(--green-soft); }
.s-row.unchecked { background: var(--card); }
.bottom-bar {
  position: sticky; bottom: 0; margin: 0 -20px; background: var(--card); border-top: 1px solid var(--line);
  padding: 14px 20px calc(16px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 12px;
}
.bottom-bar .btn { width: auto; padding: 14px 28px; }

/* ---------- game ---------- */
.progress { flex: 1; height: 12px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress > div { height: 100%; border-radius: 999px; background: var(--green); transition: width .3s; }
.count { font-size: 16px; font-weight: 800; color: var(--muted); min-width: 36px; text-align: right; }
.ar { font-family: 'Amiri Quran', 'Amiri', serif; direction: rtl; font-weight: 400; }
.passage { font-size: 29px; line-height: 2.15; text-align: right; }
.passage.center { text-align: center; }
.ayah { border-radius: 10px; padding: 2px 4px; transition: background-color .2s, box-shadow .2s; -webkit-box-decoration-break: clone; box-decoration-break: clone; cursor: pointer; }
.ayah .mark { color: var(--green); font-size: .75em; }
.ayah.reading { background: var(--hl); box-shadow: 0 0 0 3px var(--hl); }
.tr-box { font-size: 15px; color: var(--muted); border-top: 1px solid var(--line-soft); padding-top: 10px; }
.tap-hint { font-size: 13px; color: var(--muted); text-align: center; }
.q-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.q-head .lbl { font-size: 14px; font-weight: 700; color: var(--muted); }
.play-pill {
  display: inline-flex; align-items: center; gap: 8px; background: var(--green); color: var(--on-green);
  border-radius: 999px; padding: 10px 18px 10px 14px; font-size: 15px; font-weight: 800; white-space: nowrap;
}
.play-big {
  display: flex; align-items: center; justify-content: center; gap: 12px; margin: 8px auto; width: 132px; height: 132px;
  border-radius: 50%; background: var(--blue); color: #fff; box-shadow: 0 4px 0 rgba(0, 0, 0, .15);
}
:root[data-theme="dark"] .play-big { color: #0B1424; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .play-big { color: #0B1424; } }
.play-big-label { text-align: center; font-weight: 800; color: var(--muted); font-size: 15px; }

@keyframes spin { to { transform: rotate(360deg); } }
.loading-dot { display: inline-block; width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid currentColor; border-top-color: transparent; animation: spin .7s linear infinite; vertical-align: middle; }
.ayah.loading::after { content: ''; display: inline-block; width: 14px; height: 14px; margin-inline-start: 8px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--green); animation: spin .7s linear infinite; vertical-align: middle; }
@media (prefers-reduced-motion: reduce) { .loading-dot, .ayah.loading::after { animation-duration: 2s; } .progress > div { transition: none; } }

.options { display: flex; flex-direction: column; gap: 10px; }
.opt-row { display: flex; align-items: stretch; gap: 8px; }
.opt-play { flex: none; width: 52px; border-radius: 16px; background: var(--green-soft); color: var(--green); display: flex; align-items: center; justify-content: center; }
.opt {
  flex: 1; min-width: 0; background: var(--card); border: 2px solid var(--line); border-radius: 16px;
  padding: 10px 16px; font-size: 25px; line-height: 1.85; text-align: right;
}
.opt.name { font-family: Nunito, system-ui, sans-serif; direction: ltr; text-align: center; line-height: 1.3; padding: 16px 10px; display: flex; flex-direction: column; align-items: center; }
.opt.name b { font-size: 20px; } .opt.name small { font-size: 13px; color: var(--muted); }
.opt.correct { border-color: var(--green); background: var(--green-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.name-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.hint-btn {
  display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%;
  background: var(--orange-soft); color: var(--orange-dark); border-radius: 20px; padding: 16px; font-size: 18px; font-weight: 800;
}
.slot {
  background: var(--card); border: 2px dashed var(--orange-line); border-radius: 22px; padding: 14px; min-height: 112px;
  display: flex; flex-direction: column; gap: 10px;
}
.slot.correct { border-style: solid; border-color: var(--green); background: var(--green-soft); }
.slot.wrong { border-style: solid; border-color: var(--bad); background: var(--bad-soft); }
.words { display: flex; flex-wrap: wrap; gap: 10px; direction: rtl; }
.words.pool { justify-content: center; gap: 12px; }
.word { border-radius: 16px; padding: 6px 18px; font-size: 30px; line-height: 1.8; }
.slot .word { background: var(--orange); color: #fff; font-size: 27px; padding: 4px 14px; }
:root[data-theme="dark"] .slot .word { color: #1E120A; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .slot .word { color: #1E120A; } }
.pool .word { background: var(--card); border: 2px solid var(--orange-line); box-shadow: 0 2px 0 var(--orange-line); }
.pool .word.used { background: var(--used); border-color: var(--used); color: var(--used-ink); box-shadow: none; }

.warn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--warn-bg);
  color: var(--warn-ink); border-radius: 14px; padding: 10px 10px 10px 14px; font-size: 14px; font-weight: 700;
}
.warn > span { display: flex; align-items: center; gap: 8px; }
.warn button { display: inline-flex; align-items: center; gap: 6px; background: var(--card); border: 1.5px solid var(--warn-line); border-radius: 999px; padding: 8px 14px; font-weight: 800; color: var(--warn-ink); white-space: nowrap; }

.feedback { border-radius: 20px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.feedback.ok { background: var(--green-soft); }
.feedback.bad { background: var(--bad-soft); }
.feedback b { font-size: 18px; }
.feedback .passage { font-size: 25px; }
.feedback .row-between .lbl { font-size: 14px; font-weight: 700; color: var(--muted); }
.mini-play { flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--card); color: var(--green); display: inline-flex; align-items: center; justify-content: center; }
.sticky-next { position: sticky; bottom: 0; padding: 10px 0 calc(4px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 70%, transparent); }

/* ---------- result ---------- */
.stars { display: flex; align-items: flex-end; justify-content: center; gap: 6px; padding-top: 28px; }
.stars .on { color: var(--gold); } .stars .off { color: var(--star-off); }
.stars .ic:nth-child(2) svg { width: 96px; height: 96px; }
.result-num { font-size: 34px; font-weight: 800; text-align: center; }
.result-msg { font-size: 17px; color: var(--muted); text-align: center; }
.mistake { display: flex; flex-direction: column; gap: 4px; padding: 8px 0; border-top: 1px solid var(--line-soft); }
.mistake:first-of-type { border-top: 0; }
.mistake .passage { font-size: 26px; line-height: 2; }

/* ---------- settings / lists ---------- */
.choice { display: flex; align-items: center; justify-content: space-between; width: 100%; border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; font-size: 16px; font-weight: 700; text-align: left; }
.choice[aria-pressed="true"] { border-color: var(--green); background: var(--green-soft); }
.choice[aria-pressed="true"] .ic { color: var(--green); }
.stack { display: flex; flex-direction: column; gap: 8px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; font-weight: 800; }
.switch-row small { display: block; font-weight: 500; color: var(--muted); font-size: 13px; }
.switch-row input { width: 26px; height: 26px; accent-color: var(--green); flex: none; margin: 0; }
.list-card { background: var(--card); border-radius: 20px; padding: 4px 14px; box-shadow: var(--shadow); }
.list-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 2px; text-align: left; border-bottom: 1px solid var(--line-soft); color: var(--ink); text-decoration: none; }
.list-item:last-child { border-bottom: 0; }
.list-item .txt { flex: 1; min-width: 0; }
.list-item b { display: block; font-size: 17px; }
.list-item small { display: block; color: var(--muted); font-size: 13px; }
.list-item.add { color: var(--green); font-weight: 800; }
.hist-row { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--line-soft); }
.hist-row:last-child { border-bottom: 0; }
.hist-row .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.hist-row .txt { flex: 1; }
.hist-row b { display: block; font-size: 16px; }
.hist-row small { color: var(--muted); font-size: 13px; }
.hist-row .score { display: flex; flex-direction: column; align-items: flex-end; font-size: 13px; font-weight: 700; color: var(--muted); }
.mini-stars { display: flex; gap: 1px; } .mini-stars .on { color: var(--gold); } .mini-stars .off { color: var(--star-off); }
.changelog h3 { font-size: 17px; margin: 14px 0 4px; }
.changelog ul { margin: 0; padding-left: 20px; color: var(--muted); font-size: 15px; }
.changelog li { margin: 3px 0; }

.splash { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--muted); text-align: center; padding: 24px; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-size: 15px; font-weight: 700;
  max-width: calc(100% - 32px); z-index: 10; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.install-hint {
  position: fixed; left: 50%; top: calc(10px + env(safe-area-inset-top)); transform: translate(-50%, -16px);
  width: min(440px, calc(100% - 24px)); z-index: 11; display: flex; align-items: center; gap: 10px;
  background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 16px; padding: 10px 8px 10px 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .14); opacity: 0; transition: opacity .25s, transform .25s;
}
.install-hint.show { opacity: 1; transform: translate(-50%, 0); }
.install-hint img { border-radius: 9px; flex: none; }
.install-text { flex: 1; font-size: 14px; line-height: 1.35; font-weight: 600; }
.install-go { flex: none; border: 0; border-radius: 10px; padding: 9px 14px; background: var(--green); color: var(--on-green); font: inherit; font-size: 14px; font-weight: 800; cursor: pointer; }
.install-x { flex: none; border: 0; background: none; color: var(--muted); padding: 6px; display: grid; place-items: center; cursor: pointer; }
