@font-face { font-family: 'KFGQPC'; src: local('KFGQPC Uthman Taha Naskh'), local('KFGQPC HAFS Uthmanic Script'), url('fonts/UthmanicHafs.woff2') format('woff2'); font-display: swap; }

:root {
  --fs: 100%; --warmA: 0;
  --bgc: #f6f0e8; --card: #fffdf9; --card2: #f7efe3; --tx: #272a1c; --mut: #6b6c58;
  --g: #5f6b2f; --g2: #7a8a3c; --gold: #b5524a; --line: #e3d9c6; --ok: #1f8a4c; --bad: #b4452f;
  --sh: 0 3px 12px rgba(60, 55, 30, .13); --sheet: rgba(255, 253, 249, .95);
}
[data-theme=eye] { --bgc: #efe6cf; --card: #f8f0da; --card2: #f1e7cb; --tx: #34301f; --mut: #6f6a4e; --line: #d9ccaa; --sheet: rgba(248, 240, 218, .96); }
[data-theme=night] { --bgc: #12150c; --card: #1b2013; --card2: #222819; --tx: #eceadb; --mut: #aeb39a; --g: #8da04a; --g2: #a7ba62; --gold: #e8896f; --line: #2d3520; --sh: 0 3px 14px rgba(0, 0, 0, .5); --sheet: rgba(27, 32, 19, .96); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: var(--fs); }
body { margin: 0; font-family: 'Prompt', 'Sarabun', 'Noto Sans Thai', system-ui, sans-serif; color: var(--tx); background: var(--bgc); line-height: 1.7; min-height: 100vh; overflow-x: hidden; }
#bg { position: fixed; inset: 0; z-index: 0; opacity: 0; transition: opacity .8s; }
body.scene #bg { opacity: 1; }
#bg svg { width: 100%; height: 100%; display: block; }
body.scene[data-theme=night] #bg { filter: brightness(.7); }
#fx { position: fixed; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
#warm { position: fixed; inset: 0; z-index: 90; pointer-events: none; background: rgb(255, 150, 50); opacity: var(--warmA); mix-blend-mode: multiply; }

/* ดาววิบวับ + ใบไม้ปลิว */
.sp { position: absolute; width: 14px; height: 14px; opacity: 0; animation: spk 3.4s ease-in-out infinite; }
.sp svg { width: 100%; height: 100%; fill: var(--gold); }
@keyframes spk { 0%, 100% { opacity: 0; transform: scale(.3) rotate(0); } 50% { opacity: .95; transform: scale(1) rotate(45deg); } }
.rs { position: absolute; bottom: -14px; border-radius: 50%; background: radial-gradient(circle, #fff6d8, rgba(255, 220, 140, .0) 70%); box-shadow: 0 0 10px 3px rgba(255, 220, 140, .55); animation: rise linear infinite; }
@keyframes rise { 0% { transform: translate(0, 0); opacity: 0; } 12% { opacity: .9; } 100% { transform: translate(24px, -112vh); opacity: 0; } }
.afl { position: absolute; left: -90px; height: 2px; width: 70px; background: linear-gradient(90deg, rgba(90, 70, 48, 0), #6a4f30); opacity: .55; animation: afl linear infinite; }
.afl::after { content: ''; position: absolute; right: -6px; top: -3px; border-left: 9px solid #c4622d; border-top: 4px solid transparent; border-bottom: 4px solid transparent; }
@keyframes afl { 0% { transform: translate(0, 40px) rotate(-8deg); } 50% { transform: translate(55vw, -14px) rotate(0); } 100% { transform: translate(115vw, 44px) rotate(9deg); } }
@keyframes fall { 0% { transform: translate(0, -30px) rotate(0); } 25% { transform: translate(40px, 25vh) rotate(90deg); } 50% { transform: translate(-30px, 50vh) rotate(180deg); } 75% { transform: translate(50px, 75vh) rotate(270deg); } 100% { transform: translate(-10px, 108vh) rotate(360deg); } }
body.scene .afl { opacity: .7; }

/* ฉาก */
.tw { animation: tw 4s ease-in-out infinite alternate; } @keyframes tw { from { opacity: .25; } to { opacity: 1; } }
.dr { animation: dr 60s ease-in-out infinite alternate; } @keyframes dr { from { transform: translateX(-24px); } to { transform: translateX(24px); } }
.orb { animation: orb 5s ease-in-out infinite alternate; transform-origin: center; transform-box: fill-box; } @keyframes orb { from { opacity: .75; transform: scale(.94); } to { opacity: 1; transform: scale(1.06); } }
.orbg { animation: fl 7s ease-in-out infinite alternate; } @keyframes fl { from { transform: translateY(0); } to { transform: translateY(-12px); } }
.fl { animation: fl 8s ease-in-out infinite alternate; } .f1 { animation-delay: 1s; } .f2 { animation-delay: 2s; } .f3 { animation-delay: 3s; } .f4 { animation-delay: 4s; }
.beam { animation: bm 6s ease-in-out infinite alternate; } .b1 { animation-delay: 1.5s; } .b2 { animation-delay: 3s; } @keyframes bm { from { opacity: .2; } to { opacity: .6; } }
.sway { animation: sw 6s ease-in-out infinite alternate; transform-origin: bottom center; transform-box: fill-box; } @keyframes sw { from { rotate: -1.5deg; } to { rotate: 1.5deg; } }
.wv { animation: wv 10s linear infinite; } .w1 { animation-duration: 13s; } .w2 { animation-duration: 16s; animation-direction: reverse; } .w3 { animation-duration: 20s; } @keyframes wv { from { transform: translateX(0); } to { transform: translateX(-100px); } }
.wtr, .glow { animation: orb 3s ease-in-out infinite alternate; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } .sp, .rs, .afl { display: none; } }

/* โครงหน้า */
#view { position: relative; z-index: 5; max-width: 430px; margin: 0 auto; padding: 14px 14px calc(60px + env(safe-area-inset-bottom)); animation: in .45s ease; }
@keyframes in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.bar { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; padding: 8px 8px; background: var(--sheet); border-bottom: 1px solid var(--line); border-radius: 12px; box-shadow: var(--sh); position: sticky; top: 6px; z-index: 20; backdrop-filter: blur(8px); }
.bar .bt { flex: 1; text-align: center; font-weight: 600; font-size: .92rem; line-height: 1.3; }
.rb { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--tx); display: grid; place-items: center; cursor: pointer; text-decoration: none; font-size: 1.05rem; flex: none; }
.pbar { height: 4px; background: var(--line); border-radius: 4px; margin: -6px 6px 10px; overflow: hidden; } .pbar i { display: block; height: 100%; background: var(--gold); transition: width .5s; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 0 0 12px; box-shadow: var(--sh); }
.card h3, .card h2 { margin: 0 0 4px; line-height: 1.35; }
.mut { color: var(--mut); } .sm { font-size: .84rem; } .gold { color: var(--gold); font-weight: 600; }
.btn { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; padding: 12px 16px; border-radius: 12px; border: 0; background: var(--g); color: #fff; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; min-height: 46px; box-shadow: var(--sh); }
.btn small { display: block; font-weight: 400; font-size: .74rem; opacity: .9; }
.btn.gold { background: var(--gold); } .btn.alt { background: var(--card); color: var(--tx); border: 1px solid var(--line); box-shadow: none; }
.btn.sm { width: auto; min-height: 36px; padding: 6px 14px; font-size: .84rem; } .btn:disabled { opacity: .45; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chip { flex: none; padding: 5px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); color: var(--tx); font: inherit; font-size: .84rem; cursor: pointer; text-decoration: none; }
.chip.on { background: var(--g); color: #fff; border-color: transparent; }
.badge { display: inline-block; padding: 0 10px; border-radius: 99px; font-size: .72rem; border: 1px solid var(--line); color: var(--mut); }
.badge.s { color: var(--ok); border-color: var(--ok); } .badge.h { color: var(--gold); border-color: var(--gold); }
.hon { font-family: 'KFGQPC', 'Amiri Quran', 'Amiri', serif; color: var(--gold); font-size: 1.04em; white-space: nowrap; }
.ar { font-family: 'KFGQPC', 'Amiri Quran', 'Amiri', 'Noto Naskh Arabic', serif; direction: rtl; text-align: right; font-size: 1.6rem; line-height: 2.3; margin: 8px 0; } .ar.h { font-size: 1.3rem; line-height: 2.1; }

/* หน้าหลัก */
.home { text-align: center; padding-top: 10px; }
.logo { width: 60px; height: 60px; margin: 0 auto 8px; border-radius: 50%; background: var(--g); border: 3px solid var(--gold); display: grid; place-items: center; box-shadow: var(--sh); }
.logo svg { width: 34px; height: 34px; }
.home h1 { margin: 6px 0 2px; font-size: 1.55rem; color: var(--g); min-height: 2.2rem; }
.home .sub { font-weight: 600; min-height: 1.6em; } .home .tag { font-size: .8rem; color: var(--mut); margin: 4px 6px 14px; min-height: 2.6em; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 6px 2px; box-shadow: var(--sh); font-size: .7rem; color: var(--mut); line-height: 1.3; }
.tile b { display: block; font-size: 1.05rem; color: var(--tx); } .tile.sc b { color: var(--gold); font-size: 1.25rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.mn { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 6px; box-shadow: var(--sh); text-decoration: none; color: var(--tx); font-weight: 600; font-size: .86rem; min-height: 62px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; }
.mn span { font-size: 1.5rem; line-height: 1; }
.foot { font-size: .7rem; color: var(--mut); margin: 12px 8px 0; }

/* แผนที่บท */
.ch { display: flex; align-items: center; gap: 12px; padding: 10px 14px; margin-bottom: 8px; background: var(--card); border: 1.5px solid var(--line); border-radius: 12px; box-shadow: var(--sh); text-decoration: none; color: var(--tx); }
.ch.done { border-color: var(--g); } .ch.lock { opacity: .55; filter: grayscale(.6); pointer-events: none; }
.ch .ic { width: 38px; height: 38px; border-radius: 50%; background: var(--card2); display: grid; place-items: center; font-size: 1.3rem; flex: none; }
.ch .tt { flex: 1; font-weight: 600; font-size: .9rem; line-height: 1.35; } .ch .tt small { display: block; font-weight: 400; color: var(--mut); font-size: .74rem; }
.ch .st { color: var(--gold); letter-spacing: 2px; font-size: .78rem; }

/* ฉากเล่าเรื่อง */
.sheet { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(14px + env(safe-area-inset-bottom)); width: calc(100% - 28px); max-width: 402px; max-height: 64vh; overflow: auto; background: var(--sheet); border-radius: 22px; padding: 16px; box-shadow: 0 8px 30px rgba(0, 0, 0, .25); backdrop-filter: blur(8px); z-index: 30; animation: in .4s; }
.pill { display: inline-block; padding: 1px 10px; border-radius: 99px; background: var(--g); color: #fff; font-size: .7rem; font-weight: 600; }
.sheet h3 { display: inline; margin: 0 0 0 6px; font-size: 1rem; }
.at { color: var(--gold); font-size: .78rem; font-weight: 600; margin: 4px 0 6px; }
.tx { font-size: .95rem; min-height: 4.5em; }
.caret::after { content: '▍'; color: var(--gold); animation: blink .8s steps(1) infinite; margin-left: 1px; } @keyframes blink { 50% { opacity: 0; } }
.opt { display: block; width: 100%; text-align: left; margin: 7px 0; padding: 10px 12px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); color: var(--tx); font: inherit; font-size: .9rem; cursor: pointer; }
.opt.ok { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, var(--card)); } .opt.no { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--card)); } .opt:disabled { cursor: default; }
.fb { padding: 9px 12px; border-radius: 10px; background: color-mix(in srgb, var(--gold) 12%, transparent); border-left: 4px solid var(--gold); margin: 8px 0; font-size: .88rem; animation: in .4s; }
.slots { min-height: 48px; padding: 6px; border: 2px dashed var(--line); border-radius: 12px; display: flex; flex-direction: column; gap: 6px; margin: 6px 0; } .slots .opt { margin: 0; }
.stars { color: var(--gold); letter-spacing: 3px; font-size: 1.6rem; text-align: center; }

/* ไทม์ไลน์ / เล่าก่อนนอน / สมุด */
.tl { margin-left: 8px; padding-left: 18px; border-left: 2px dashed var(--gold); } .tl .it { position: relative; margin-bottom: 12px; } .tl .it::before { content: ''; position: absolute; left: -26px; top: 18px; width: 12px; height: 12px; border-radius: 50%; background: var(--gold); }
.bed { text-align: center; min-height: 52vh; display: flex; flex-direction: column; justify-content: center; } .bed .tx { font-size: 1.15rem; line-height: 2; min-height: 8em; }
.nb { display: grid; grid-template-columns: 1fr; gap: 8px; } .nb .card { margin: 0; } .nb .lk { opacity: .5; text-align: center; }
details > summary { cursor: pointer; color: var(--g2); font-size: .85rem; }
.fab { position: fixed; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 40; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--sheet); color: var(--tx); font-size: 1.1rem; cursor: pointer; box-shadow: var(--sh); }
body.playing .fab { bottom: auto; top: 64px; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 100; background: var(--g); color: #fff; padding: 9px 18px; border-radius: 99px; box-shadow: var(--sh); font-size: .88rem; max-width: 90vw; }
input, select { font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--tx); width: 100%; margin: 4px 0; } input[type=range] { padding: 0; }
a { color: var(--g2); } table.lb { width: 100%; border-collapse: collapse; font-size: .9rem; } .lb td { padding: 4px 8px; border-bottom: 1px solid var(--line); }

.walk { animation: walk 55s linear infinite; } @keyframes walk { from { transform: translateX(-880px); } to { transform: translateX(1100px); } }
.bob { animation: bob 1.1s ease-in-out infinite alternate; } @keyframes bob { from { transform: translateY(0); } to { transform: translateY(-5px); } }
.swing { animation: swing 4.5s ease-in-out infinite alternate; transform-origin: 0 0; transform-box: view-box; } @keyframes swing { from { rotate: -6deg; } to { rotate: 6deg; } }
.sway2 { animation: sw2 5s ease-in-out infinite alternate; transform-origin: 50% 0; transform-box: fill-box; } @keyframes sw2 { from { transform: skewX(-2deg); } to { transform: skewX(2deg); } }
.cvn { width: 100%; height: 64px; margin: 2px 0 10px; overflow: hidden; } .cvn svg { width: 100%; height: 100%; display: block; }
.walkh { animation: walkh 26s linear infinite; } @keyframes walkh { from { transform: translateX(-340px); } to { transform: translateX(470px); } }
.logo { background: var(--g); }

.fly { animation: flyx 4.2s ease-in infinite; } @keyframes flyx { 0% { transform: translate(-140px, 36px) rotate(-10deg); opacity: 0; } 12% { opacity: 1; } 55% { transform: translate(520px, -26px) rotate(0); opacity: 1; } 100% { transform: translate(1180px, 44px) rotate(10deg); opacity: 0; } }
.walk2 { animation: walk2 80s linear infinite; } @keyframes walk2 { from { transform: translateX(-880px); } to { transform: translateX(1100px); } }
.walk3 { animation: walk3 38s linear infinite; } @keyframes walk3 { from { transform: translateX(-760px); } to { transform: translateX(1100px); } }
.rise { animation: riseS 9s linear infinite; } @keyframes riseS { 0% { transform: translateY(0); opacity: 0; } 15% { opacity: .95; } 100% { transform: translateY(-480px); opacity: 0; } }
.cvn { width: 100%; height: 64px; margin: 2px 0 10px; overflow: hidden; } .cvn svg { width: 100%; height: 100%; display: block; }
.shoot { animation: shoot 4.2s cubic-bezier(.2, .6, .2, 1) infinite; } @keyframes shoot { 0% { transform: translateX(-420px); opacity: 0; } 8% { opacity: 1; } 50%, 85% { transform: translateX(0); opacity: 1; } 100% { transform: translateX(0); opacity: 0; } }
.tgt { animation: tg 4.2s ease-in-out infinite; transform-origin: 388px 32px; } @keyframes tg { 0%, 48% { transform: scale(1); } 52% { transform: scale(1.06); } 60%, 100% { transform: scale(1); } }
.logo { background: var(--g); }

/* เมนูและหมวดหมู่หลากสี */
.mn { border-bottom: 4px solid var(--mc, var(--g)); }
.mn span { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; background: color-mix(in srgb, var(--mc, var(--g)) 16%, transparent); }
.chip { border-color: color-mix(in srgb, var(--chc, var(--line)) 55%, var(--line)); color: color-mix(in srgb, var(--chc, var(--tx)) 65%, var(--tx)); }
.chip.on { background: var(--chc, var(--g)); color: #fff; border-color: transparent; }
.ch { border-left: 6px solid var(--mc, var(--line)); }
.ch .ic { background: color-mix(in srgb, var(--mc, var(--g)) 15%, var(--card)); }

/* เมนูลอย */
.fm-btn { position: fixed; left: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 70; width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--g); color: #fff; font-size: 1.3rem; cursor: pointer; box-shadow: 0 4px 14px rgba(0, 0, 0, .3); transition: transform .2s; }
.fm-btn.on { transform: rotate(90deg); background: var(--gold); }
body.playing .fm-btn { bottom: auto; top: 64px; }
.fmp { position: fixed; inset: 0; z-index: 65; }
.fmp[hidden] { display: none; }
.fmb { position: absolute; inset: 0; background: rgba(15, 20, 8, .5); backdrop-filter: blur(3px); animation: in .25s; }
.fmc { position: absolute; left: 12px; right: 12px; bottom: calc(70px + env(safe-area-inset-bottom)); max-width: 406px; margin: 0 auto; background: var(--sheet); border-radius: 20px; padding: 12px; box-shadow: 0 10px 34px rgba(0, 0, 0, .35); animation: in .3s; max-height: 78vh; overflow: auto; }
body.playing .fmc { bottom: auto; top: 108px; }
.fmh { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; } .fmh .btn { flex: 1; }
.fmg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fmi { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); border-bottom: 4px solid var(--mc); text-decoration: none; color: var(--tx); font-size: .78rem; font-weight: 600; text-align: center; line-height: 1.25; }
.fmi span { font-size: 1.4rem; line-height: 1.1; } .fmi.cur { background: color-mix(in srgb, var(--mc) 18%, var(--card)); }

/* เสียงอ่านอัลกุรอาน */
.qmini { position: sticky; top: 58px; z-index: 18; display: flex; align-items: center; gap: 8px; margin: 0 0 10px; padding: 8px 10px; background: var(--g); color: #fff; border-radius: 14px; box-shadow: var(--sh); }
.qmini .qn { flex: 1; font-size: .84rem; font-weight: 600; line-height: 1.3; } .qmini .rb { background: rgba(255, 255, 255, .18); color: #fff; border-color: transparent; }
.eq { display: flex; align-items: flex-end; gap: 3px; height: 22px; width: 24px; } .eq i { flex: 1; background: #fff; border-radius: 2px; height: 30%; }
.eq.on i { animation: eqb .9s ease-in-out infinite; } .eq.on i:nth-child(2) { animation-delay: .2s; } .eq.on i:nth-child(3) { animation-delay: .4s; } .eq.on i:nth-child(4) { animation-delay: .1s; }
@keyframes eqb { 0%, 100% { height: 25%; } 50% { height: 100%; } }
.qc.now { outline: 2px solid var(--gold); box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 20%, transparent), var(--sh); }
.qc .ar { transition: background .4s; } .qc.now .ar { background: color-mix(in srgb, var(--gold) 8%, transparent); border-radius: 10px; }

/* หิ่งห้อยและดาวสิบดวง */
.ff { position: absolute; width: 7px; height: 7px; border-radius: 50%; background: radial-gradient(circle, #f6fbb0, rgba(200, 230, 100, 0) 70%); box-shadow: 0 0 10px 3px rgba(225, 240, 120, .55); animation: ffly 16s ease-in-out infinite, ffb 2.6s ease-in-out infinite; }
@keyframes ffly { 0% { transform: translate(0, 0); } 25% { transform: translate(40px, -30px); } 50% { transform: translate(-20px, -70px); } 75% { transform: translate(50px, -35px); } 100% { transform: translate(0, 0); } }
@keyframes ffb { 0%, 100% { opacity: .15; } 50% { opacity: .95; } }
.tst { animation: tst 2.8s ease-in-out infinite; transform-box: fill-box; transform-origin: center; } @keyframes tst { 0%, 100% { opacity: .35; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.18); } }
.quake { animation: quake 1.4s ease-in-out infinite; transform-box: fill-box; transform-origin: bottom center; } @keyframes quake { 0%, 100% { transform: translate(0, 0); } 20% { transform: translate(-2px, 1px); } 40% { transform: translate(2px, -1px); } 60% { transform: translate(-1px, 1px); } 80% { transform: translate(1px, 0); } }
.logo { background: var(--g); }
@media (prefers-reduced-motion: reduce) { .ff { display: none; } }
