/* สองทะเลที่มาพบกัน — สไตล์หลัก (มือถือก่อน, รองรับโหมดถนอมสายตา/กลางคืน) */
:root {
  --bg: #f3fafc; --surface: #ffffff; --surface2: #eaf6f9; --ink: #0d2a3a; --muted: #4a6573;
  --line: #d3e5eb; --sea: #0b7a95; --sea2: #075a73; --deep: #0a2f4a; --fresh: #7fd8f0; --fresh2: #c8f0fa;
  --salt: #1f56a3; --salt2: #123a78; --gold: #d9971f; --gold2: #f4c95d; --ok: #1a8f5f; --bad: #d1453f;
  --shadow: 0 10px 30px rgba(10, 47, 74, .12); --r: 18px; --r-sm: 12px;
  --th: 'Noto Sans Thai', 'Prompt', 'Sarabun', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --head: 'Prompt', 'Noto Sans Thai', system-ui, sans-serif;
  --ar: 'Amiri Quran', 'Scheherazade New', 'Traditional Arabic', 'Noto Naskh Arabic', 'Geeza Pro', serif;
}
:root[data-theme="eye"] {
  --bg: #f5ead2; --surface: #fbf3df; --surface2: #f1e3c3; --ink: #3a2f1b; --muted: #6a5a3c; --line: #e2d1a9;
  --sea: #2c7571; --sea2: #225c59; --deep: #2f4a45; --fresh: #a8d8c8; --fresh2: #d3ebdf; --salt: #4a7193; --salt2: #34546f;
  --gold: #b9811d; --gold2: #dcb55a; --shadow: 0 10px 26px rgba(80, 60, 20, .14);
}
:root[data-theme="night"] {
  --bg: #0a141c; --surface: #11212d; --surface2: #162a38; --ink: #e2eef3; --muted: #9bb3c0; --line: #24394a;
  --sea: #43b8d4; --sea2: #7fd8f0; --deep: #cfe9f3; --fresh: #6ccbe6; --fresh2: #14465a; --salt: #4a86d8; --salt2: #9cc0f2;
  --gold: #f0bd55; --gold2: #f0bd55; --shadow: 0 10px 30px rgba(0, 0, 0, .45);
}
html { font-size: 100%; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
html[data-fs="l"] { font-size: 112.5%; } html[data-fs="xl"] { font-size: 125%; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--th); line-height: 1.75; -webkit-tap-highlight-color: transparent; min-height: 100vh; }
:root[data-theme="eye"] body::after { content: ""; position: fixed; inset: 0; background: rgba(255, 160, 50, .08); mix-blend-mode: multiply; pointer-events: none; z-index: 9998; }
h1, h2, h3, h4 { font-family: var(--head); line-height: 1.35; margin: 0 0 .5em; color: var(--deep); }
h1 { font-size: clamp(1.7rem, 5.2vw, 2.6rem); } h2 { font-size: clamp(1.3rem, 3.8vw, 1.8rem); } h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; } a { color: var(--sea2); }
button { font: inherit; cursor: pointer; color: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
#view:focus, #view:focus-visible { outline: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { width: min(100% - 32px, 1040px); margin-inline: auto; }

/* header */
.top { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--deep); font-family: var(--head); font-weight: 700; flex: 1; min-width: 0; }
.brand svg { width: 38px; height: 38px; flex: none; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1.02rem; }
.ibtn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; font-size: 1.2rem; position: relative; }
.ibtn:hover { background: var(--surface2); } .ibtn[aria-pressed="true"] { background: var(--sea); color: #fff; border-color: var(--sea); }
.ring { position: absolute; inset: -3px; pointer-events: none; }
.ring circle { fill: none; stroke-width: 3; } .ring .bg { stroke: transparent; } .ring .fg { stroke: var(--gold); stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset .6s; }

/* drawer */
.drawer { position: fixed; inset: 0; z-index: 60; display: none; }
.drawer.open { display: block; } .drawer .shade { position: absolute; inset: 0; background: rgba(5, 20, 30, .5); }
.drawer nav { position: absolute; top: 0; right: 0; width: min(88vw, 360px); height: 100%; background: var(--surface); padding: 18px; overflow: auto; box-shadow: var(--shadow); animation: slidein .25s ease; }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer a.nl { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; text-decoration: none; color: var(--ink); font-weight: 600; }
.drawer a.nl:hover, .drawer a.nl.on { background: var(--surface2); } .drawer a.nl .st { margin-left: auto; font-size: .85rem; color: var(--gold); letter-spacing: 1px; }

/* hero */
.hero { position: relative; overflow: hidden; color: #fff; background: linear-gradient(180deg, #8fe0f4 0%, #3fb6d6 38%, #0b6e8f 72%, #0a2f4a 100%); }
:root[data-theme="eye"] .hero { background: linear-gradient(180deg, #e9dcb4 0%, #9cc7b5 40%, #3e7f78 74%, #2f4a45 100%); }
:root[data-theme="night"] .hero { background: linear-gradient(180deg, #123b54 0%, #0e5a78 45%, #0a3550 75%, #061622 100%); }
.hero .wrap { position: relative; z-index: 2; padding: 34px 0 150px; }
.hero h1 { color: #fff; text-shadow: 0 2px 14px rgba(5, 40, 60, .45); margin-bottom: .2em; }
.hero p.lead { font-size: 1.08rem; max-width: 36rem; text-shadow: 0 1px 8px rgba(5, 40, 60, .5); }
.hero .ayah { font-family: var(--ar); font-size: clamp(1.4rem, 5vw, 2.2rem); line-height: 2.2; direction: rtl; margin: .2em 0; text-shadow: 0 2px 10px rgba(5, 40, 60, .55); }
.hero svg.scene { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 190px; z-index: 1; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.chip { background: rgba(255, 255, 255, .2); border: 1px solid rgba(255, 255, 255, .45); padding: 4px 12px; border-radius: 99px; font-size: .9rem; backdrop-filter: blur(4px); }

/* cards / buttons */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; }
.btn { border: 0; border-radius: 999px; padding: 10px 20px; background: var(--sea); color: #fff; font-weight: 700; display: inline-flex; gap: 8px; align-items: center; justify-content: center; min-height: 44px; text-decoration: none; transition: transform .12s, filter .12s; }
:root[data-theme="night"] .btn { color: #04202c; }
.btn:hover { filter: brightness(1.08); } .btn:active { transform: scale(.97); }
.btn.ghost { background: var(--surface); color: var(--sea2); border: 2px solid var(--sea); } :root[data-theme="night"] .btn.ghost { color: var(--sea); }
.btn.gold { background: var(--gold); color: #2b1b00; } .btn.small { padding: 6px 14px; min-height: 36px; font-size: .92rem; } .btn[disabled] { opacity: .45; pointer-events: none; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; } .grow { flex: 1; } .center { text-align: center; }
.grid { display: grid; gap: 16px; } .g2 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); } .g3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
main { padding: 22px 0 90px; } .view > * + * { margin-top: 18px; }
.mission-card { display: block; text-decoration: none; color: inherit; position: relative; overflow: hidden; transition: transform .15s; }
.mission-card:hover { transform: translateY(-3px); } .mission-card .no { position: absolute; top: 10px; left: 14px; font-family: var(--head); font-size: 2.6rem; font-weight: 800; color: var(--fresh); opacity: .55; line-height: 1; }
.mission-card h3 { margin-top: 1.6rem; } .mission-card .stars { color: var(--gold); letter-spacing: 2px; font-size: 1.1rem; } .mission-card .stars i { color: var(--line); font-style: normal; }
.crumb { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .92rem; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--surface2); font-size: .85rem; color: var(--sea2); border: 1px solid var(--line); }
.note { border-inline-start: 5px solid var(--gold); background: color-mix(in srgb, var(--gold2) 20%, var(--surface)); padding: 12px 16px; border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.note.sci { border-color: var(--sea); background: color-mix(in srgb, var(--fresh) 18%, var(--surface)); } .note.warn { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--surface)); }
.note b.t { display: block; margin-bottom: 2px; color: var(--deep); }

/* ayah block */
.ayah-box { background: linear-gradient(135deg, var(--surface), var(--surface2)); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; position: relative; }
.ayah-box .ar { font-family: var(--ar); direction: rtl; text-align: right; font-size: clamp(1.5rem, 4.6vw, 2.1rem); line-height: 2.3; color: var(--deep); }
.ayah-box .th { margin-top: 8px; color: var(--ink); } .ayah-box .ref { font-size: .86rem; color: var(--muted); margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ayah-box .ar .w { cursor: pointer; border-radius: 8px; padding: 0 3px; transition: background .15s; } .ayah-box .ar .w:hover, .ayah-box .ar .w.on { background: color-mix(in srgb, var(--gold2) 55%, transparent); }
.wordbar { min-height: 3.2em; background: var(--surface); border: 2px dashed var(--gold); border-radius: var(--r-sm); padding: 8px 14px; margin-top: 10px; display: flex; gap: 12px; align-items: center; }
.wordbar .ar { font-size: 1.7rem; font-family: var(--ar); direction: rtl; }

/* tabs */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.tab { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 16px; white-space: nowrap; font-weight: 600; min-height: 40px; }
.tab[aria-selected="true"] { background: var(--sea); color: #fff; border-color: var(--sea); } :root[data-theme="night"] .tab[aria-selected="true"] { color: #04202c; }

/* sims */
.sim { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.sim canvas { display: block; width: 100%; height: auto; touch-action: manipulation; background: #0c2a40; }
.sim .ctl { padding: 14px 16px; display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.sim label { display: block; font-weight: 600; font-size: .95rem; } .sim label small { font-weight: 400; color: var(--muted); }
input[type=range] { width: 100%; accent-color: var(--sea); height: 32px; }
.readout { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 16px 14px; } .readout .pill b { color: var(--deep); }
.task { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; background: var(--surface2); border-radius: var(--r-sm); border: 1px solid var(--line); }
.task.done { background: color-mix(in srgb, var(--ok) 14%, var(--surface)); border-color: var(--ok); } .task .ck { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--muted); display: grid; place-items: center; font-weight: 800; font-size: .9rem; }
.task.done .ck { background: var(--ok); border-color: var(--ok); color: #fff; }

/* games */
.pairs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pair { min-height: 62px; border: 2px solid var(--line); background: var(--surface); border-radius: var(--r-sm); padding: 8px 10px; display: grid; place-items: center; text-align: center; font-weight: 600; transition: .15s; }
.pair.ar { font-family: var(--ar); font-size: 1.45rem; font-weight: 400; direction: rtl; line-height: 1.8; }
.pair.sel { border-color: var(--gold); background: color-mix(in srgb, var(--gold2) 35%, var(--surface)); transform: scale(1.02); }
.pair.ok { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 16%, var(--surface)); pointer-events: none; } .pair.no { animation: shake .35s; border-color: var(--bad); }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.bins { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; } .bin { padding: 12px 6px; border-radius: var(--r-sm); border: 2px solid var(--line); background: var(--surface); font-weight: 700; min-height: 56px; }
.bin.fresh { border-color: var(--fresh); } .bin.brackish { border-color: var(--gold); } .bin.salt { border-color: var(--salt); }
.bin:hover { background: var(--surface2); }
.bigitem { font-size: 1.6rem; text-align: center; padding: 22px 12px; font-family: var(--head); background: var(--surface2); border-radius: var(--r); border: 1px solid var(--line); }
.bigitem .em { font-size: 3rem; display: block; line-height: 1.2; }
.feedback { min-height: 3.5em; padding: 10px 14px; border-radius: var(--r-sm); background: var(--surface2); }
.feedback.ok { background: color-mix(in srgb, var(--ok) 14%, var(--surface)); } .feedback.no { background: color-mix(in srgb, var(--bad) 12%, var(--surface)); }
.arena { position: relative; height: min(62vh, 440px); overflow: hidden; border-radius: var(--r); background: linear-gradient(180deg, #4fc0dc, #0b6e8f 60%, #0a3550); user-select: none; touch-action: manipulation; }
.arena .drift { position: absolute; font-size: 2.6rem; line-height: 1; cursor: pointer; padding: 8px; border: 0; background: none; will-change: transform; filter: drop-shadow(0 4px 4px rgba(0, 0, 0, .35)); }
.arena .pop { position: absolute; font-weight: 800; font-family: var(--head); pointer-events: none; animation: pop .8s forwards; text-shadow: 0 1px 4px #000; }
@keyframes pop { to { transform: translateY(-40px); opacity: 0; } }
.hud { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; flex-wrap: wrap; }
.quiz .opt { display: block; width: 100%; text-align: start; border: 2px solid var(--line); background: var(--surface); border-radius: var(--r-sm); padding: 12px 14px; margin-top: 10px; transition: .15s; font-weight: 600; }
.quiz .opt:hover { border-color: var(--sea); } .quiz .opt.ok { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 15%, var(--surface)); } .quiz .opt.no { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--surface)); }
.bar { height: 10px; background: var(--surface2); border-radius: 99px; overflow: hidden; } .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--fresh), var(--sea)); border-radius: 99px; transition: width .4s; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px; background: var(--surface2); border: 1px solid var(--gold); font-weight: 600; }
.badge.lock { filter: grayscale(1); opacity: .5; border-color: var(--line); }
table.t { width: 100%; border-collapse: collapse; } table.t th, table.t td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: start; } table.t th { color: var(--muted); font-size: .9rem; }
input[type=text], textarea, select { width: 100%; font: inherit; padding: 10px 12px; border-radius: var(--r-sm); border: 2px solid var(--line); background: var(--surface); color: var(--ink); }
input[type=text]:focus, textarea:focus { border-color: var(--sea); outline: none; }
figure { margin: 0; } figcaption { font-size: .9rem; color: var(--muted); padding: 6px 4px; } figure svg { width: 100%; height: auto; display: block; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); }
.svg-ink { fill: var(--ink); } .svg-muted { fill: var(--muted); }

/* modal / toast */
.modal { position: fixed; inset: 0; z-index: 80; display: none; place-items: center; background: rgba(4, 18, 28, .72); padding: 16px; } .modal.open { display: grid; }
.modal .box { width: min(100%, 520px); max-height: 92vh; overflow: auto; background: var(--surface); border-radius: 24px; padding: 24px; text-align: center; box-shadow: var(--shadow); animation: slidein .3s ease; }
.modal .zikr { font-family: var(--ar); font-size: clamp(1.9rem, 7vw, 2.8rem); direction: rtl; line-height: 2.2; color: var(--deep); margin: 6px 0; } .modal .count { font-family: var(--head); font-size: 3rem; font-weight: 800; color: var(--sea); line-height: 1; }
.modal .box.left { text-align: start; } .setrow { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.seg { display: inline-flex; border: 2px solid var(--sea); border-radius: 999px; overflow: hidden; } .seg button { border: 0; background: transparent; padding: 6px 14px; min-height: 38px; font-weight: 600; } .seg button[aria-pressed="true"] { background: var(--sea); color: #fff; }
#toasts { position: fixed; bottom: 18px; inset-inline: 0; display: grid; justify-items: center; gap: 8px; z-index: 90; pointer-events: none; padding: 0 12px; }
.toast { background: var(--deep); color: #fff; padding: 10px 18px; border-radius: 999px; box-shadow: var(--shadow); animation: slidein .25s ease; max-width: 94vw; } :root[data-theme="night"] .toast { background: var(--sea); color: #04202c; }
footer { border-top: 1px solid var(--line); padding: 22px 0 40px; color: var(--muted); font-size: .92rem; background: var(--surface); }
.wave-sep { height: 40px; }
.install { display: none; } .install.show { display: inline-flex; }
@media (min-width: 760px) { .hero .wrap { padding: 56px 0 170px; } main { padding-top: 30px; } .brand span { font-size: 1.15rem; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; } }
@media print { .top, footer, .drawer, .modal { display: none !important; } }
