/* ผังสนธิ — หน้า "ดูโครง" แบบใหม่ของเกมสนธิ (/sandhi/memorize/study) · หลวงพี่เคาะ ๑ ต.ค. ๒๕๖๙
   ตารางเดิมยังอยู่ที่ /sandhi/memorize/classic · ข้อมูลจาก app/data/kitaka/sandhi.json (ดู app/js/sandhi-map.js)
   ชุดสีห้องฉายเดียวกับผังเสียงบาลี · โหมดสีใช้คีย์ pt_cinema_theme ร่วมกับเกมซ้อมเร็วทั้งหมด */
@font-face { font-family: "Sriracha Local"; src: url("/assets/fonts/sriracha/Sriracha-Regular.ttf?v=20260806.1") format("truetype"); font-weight: 400; font-display: swap; }
/* Layout: ฉากเปิด → เส้นทาง ๘ ด่าน → ต้นไม้ตัวเลข ๓ / ๘ → ผัง ๓ ประเภท × ๘ วิธี (ช่องคำจริง) + แผงรอยต่อ → ตารางท่องจำ
   ชุดสีห้องฉายเดียวกับผังเสียงบาลี · สีประจำประเภท: สระ ฟ้า · พยัญชนะ ม่วง · นิคคหิต ชมพู · ทอง = รอยต่อ */
@font-face { font-family: "Thunder Pali"; font-weight: 400 900; font-display: swap; src: url("/assets/fonts/thunder-pali/ThunderPali-800.woff2") format("woff2"); unicode-range: U+0E00-0E7F, U+25CC; }
:root {
	color-scheme: dark;
	--bg: #0a0f1e; --bg2: #10183a; --panel: #141d3d; --panel2: #1a2550; --strong: #ffffff;
	--ink: #f3f6ff; --ink2: #d7deef; --muted: #aab4d0; --dim: #7f8aa8;
	--gold: #f5bf45; --on-gold: #3b2600; --quote: #fde9b0; --shadow: rgba(0,0,0,.5);
	--line: color-mix(in srgb, var(--strong) 10%, transparent);
	--t-sara: #7dd3fc; --t-byan: #c4b5fd; --t-nikk: #f9a8d4;
	--f: "Sarabun", "Thonburi", sans-serif; --fp: "Thunder Pali", "Sarabun", sans-serif; --fh: "Sriracha Local", "Sarabun", sans-serif;
}
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) {
	color-scheme: light; --bg: #f5f7fc; --bg2: #ffffff; --panel: #ffffff; --panel2: #eef2fb; --strong: #141a33;
	--ink: #141a33; --ink2: #333c5c; --muted: #525b78; --dim: #69728f; --gold: #b45309; --on-gold: #fff; --quote: #8a4b06; --shadow: transparent;
	--t-sara: #0369a1; --t-byan: #6d28d9; --t-nikk: #be185d;
} }
:root[data-theme="light"] { color-scheme: light; --bg: #f5f7fc; --bg2: #ffffff; --panel: #ffffff; --panel2: #eef2fb; --strong: #141a33;
	--ink: #141a33; --ink2: #333c5c; --muted: #525b78; --dim: #69728f; --gold: #b45309; --on-gold: #fff; --quote: #8a4b06; --shadow: transparent;
	--t-sara: #0369a1; --t-byan: #6d28d9; --t-nikk: #be185d; }
:root[data-theme="dark"] { color-scheme: dark; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body.sdm-page { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--f); font-size: 16px; line-height: 1.6; }
.wrap { max-width: 1120px; margin: 0 auto; padding-inline: 20px; }
h1, h2, h3 { margin: 0; text-wrap: balance; overflow-wrap: anywhere; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.p { font-family: var(--fp); }

/* ฉากเปิด */
.bar { display: flex; justify-content: flex-end; padding-top: 1rem; }
.theme { min-height: 44px; padding: 0 1rem; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--strong) 22%, transparent); background: color-mix(in srgb, var(--bg) 72%, transparent); backdrop-filter: blur(8px); font-weight: 800; font-size: .88rem; cursor: pointer; }
.hero { position: relative; isolation: isolate; overflow: hidden; }
/* ภาพเต็มจอแบบเดียวกับผังเสียงบาลี · จุดตัด ๕๕% ให้เห็นทั้งหน้าสามเณรและใบลานที่กำลังต่อกัน */
.hero-art { position: absolute; inset: 0; z-index: -2; background: var(--hero-img) center 55% / cover no-repeat; }
.hero::before { content: ""; position: absolute; inset: 0; z-index: -1;
	background: linear-gradient(90deg, var(--bg) 0%, color-mix(in srgb, var(--bg) 90%, transparent) 36%, color-mix(in srgb, var(--bg) 25%, transparent) 72%, color-mix(in srgb, var(--bg) 5%, transparent) 100%), linear-gradient(0deg, var(--bg) 0%, transparent 42%); }
.hero-in { display: flex; flex-direction: column; gap: .7rem; padding-block: 2.4rem 2rem; max-width: 620px; }
.pills { display: flex; flex-wrap: wrap; gap: .4rem; }
.pill { display: inline-flex; padding: .12rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 800; white-space: nowrap; }
.pill-gold { background: var(--gold); color: var(--on-gold); }
.pill-ghost { background: color-mix(in srgb, var(--strong) 10%, transparent); border: 1px solid color-mix(in srgb, var(--strong) 20%, transparent); }
.hero h1 { font-size: clamp(2.2rem, 6vw, 3.7rem); font-weight: 800; line-height: 1.22; text-shadow: 0 2px 24px var(--shadow); }
.hero h1 em { font-style: normal; color: var(--gold); }
.quote { font-family: var(--fh); font-size: 1.08rem; color: var(--quote); margin: 0; }
.lead { color: var(--ink2); margin: 0; max-width: 36em; }
.path { display: flex; overflow-x: auto; scrollbar-width: none; padding-block: .4rem 1rem; }
.path::-webkit-scrollbar { display: none; }
.stop { position: relative; flex: 1 0 98px; display: flex; flex-direction: column; align-items: center; gap: .3rem; text-align: center; text-decoration: none; color: inherit; }
.stop::before { content: ""; position: absolute; top: 19px; left: calc(-50% + 22px); right: calc(50% + 22px); height: 2px; background: var(--line); }
.stop:first-child::before { display: none; }
.stop.now::before { background: var(--gold); }
.dot { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--panel); border: 2px solid var(--line); color: var(--muted); }
.stop.now .dot { background: var(--gold); border-color: var(--gold); color: var(--on-gold); box-shadow: 0 0 0 6px color-mix(in srgb, var(--gold) 18%, transparent); }
.stop-n { font-size: .8rem; font-weight: 700; color: var(--muted); line-height: 1.35; }
.stop.now .stop-n { color: var(--ink); }
.stop-z { font-size: .68rem; color: var(--dim); }

/* ส่วนเนื้อหา */
.sec { padding-block: 2rem; }
.sec-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .5rem 1.5rem; margin-bottom: 1.1rem; }
.kick { font-size: .78rem; font-weight: 800; letter-spacing: .06em; color: var(--gold); }
.sec h2 { font-size: clamp(1.45rem, 3vw, 1.9rem); font-weight: 800; line-height: 1.3; }
.sub { color: var(--muted); margin: .2rem 0 0; font-size: .95rem; max-width: 42em; }

/* ต้นไม้ตัวเลข */
.tree { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.tcard { display: flex; flex-direction: column; gap: .8rem; padding: 1.1rem; border-radius: 18px; background: linear-gradient(160deg, var(--bg2), var(--panel)); border: 1px solid var(--line); min-width: 0; }
.big { display: flex; align-items: baseline; gap: .7rem; }
.big b { font-size: clamp(3rem, 7vw, 4.2rem); line-height: 1; color: var(--gold); font-weight: 800; }
.big span { font-weight: 800; font-size: 1.05rem; }
.kids { display: flex; flex-wrap: wrap; gap: .45rem; }
.kid { --c: var(--gold); display: inline-flex; align-items: center; gap: .45rem; padding: .4rem .75rem; border-radius: 12px; background: color-mix(in srgb, var(--c) 12%, transparent); border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); font-weight: 700; font-size: .92rem; cursor: pointer; }
.kid b { color: var(--c); font-size: 1.2rem; }
.kid[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--c); }
.kid.p { font-family: var(--fp); }

/* ผัง ๓ × ๘ */
.lenses { display: flex; flex-wrap: wrap; gap: .4rem; }
.lens { min-height: 44px; padding: 0 1rem; border-radius: 999px; border: 1px solid var(--line); background: color-mix(in srgb, var(--strong) 5%, transparent); font-weight: 800; font-size: .9rem; cursor: pointer; color: var(--ink2); }
.lens[aria-checked="true"] { background: var(--strong); color: var(--bg); border-color: var(--strong); }
.board { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 1.3rem; align-items: start; }
.mx { display: grid; grid-template-columns: 9.5rem repeat(3, minmax(0, 1fr)); gap: .45rem; padding: 1rem; border-radius: 20px; background: linear-gradient(160deg, var(--bg2), var(--panel)); border: 1px solid var(--line); min-width: 0; }
.mx-h { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; text-align: center; gap: .1rem; padding: .3rem .2rem .5rem; border-radius: 12px; cursor: pointer; border: 1px solid transparent; background: none; }
.mx-h b { font-size: 1rem; color: var(--c); }
.mx-h span { font-size: .78rem; color: var(--muted); font-weight: 700; }
.mx-h[aria-pressed="true"] { border-color: var(--c); background: color-mix(in srgb, var(--c) 10%, transparent); }
.mx-m { display: flex; flex-direction: column; justify-content: center; padding: .3rem .4rem; border-radius: 12px; cursor: pointer; text-align: left; border: 1px solid transparent; background: none; }
.mx-m b { font-family: var(--fp); font-size: 1.05rem; font-weight: 800; }
.mx-m span { font-size: .78rem; color: var(--muted); }
.mx-m[aria-pressed="true"] { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 10%, transparent); }
.cell { --c: var(--gold); --heat: 0; position: relative; display: flex; flex-wrap: wrap; align-content: flex-start; gap: .3rem; min-height: 3.6rem; padding: .45rem; border-radius: 12px;
	background: color-mix(in srgb, var(--c) calc(8% + var(--heat) * 34%), var(--panel2)); border: 1px solid color-mix(in srgb, var(--c) 35%, transparent); transition: opacity .25s, background-color .3s; min-width: 0; }
.cell.off { background: repeating-linear-gradient(135deg, transparent 0 8px, color-mix(in srgb, var(--strong) 4%, transparent) 8px 16px); border: 1px dashed var(--line); align-items: center; justify-content: center; }
.cell.off span { font-size: .72rem; color: var(--dim); font-weight: 700; }
.cell.empty { align-items: center; justify-content: center; }
.cell.empty span { font-size: .72rem; color: var(--muted); }
.mx.dim .cell:not(.lit), .mx.dim .mx-m:not(.lit), .mx.dim .mx-h:not(.lit) { opacity: .25; }
.chip { display: inline-flex; align-items: center; gap: .25rem; min-height: 32px; padding: .1rem .5rem; border-radius: 9px; border: 1px solid color-mix(in srgb, var(--strong) 16%, transparent);
	background: var(--panel); font-family: var(--fp); font-weight: 800; font-size: .95rem; cursor: pointer; line-height: 1.3; }
.chip { white-space: nowrap; }   /* คำบาลีห้ามตัดกลางคำ */
.chip.long { font-size: .8rem; }
.chip:hover { border-color: var(--gold); }
.cnt { display: none; }
.picklist { display: none; }
.chip[aria-pressed="true"] { background: var(--gold); color: var(--on-gold); border-color: var(--gold); }
.chip i { font-style: normal; font-family: var(--f); font-size: .66rem; font-weight: 800; color: var(--gold); }
.chip[aria-pressed="true"] i { color: var(--on-gold); }
.legend { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .8rem; padding-top: .4rem; font-size: .8rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.sw { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }

/* แผงรอยต่อ */
.panel { position: sticky; top: 16px; display: flex; flex-direction: column; gap: .8rem; padding: 1.2rem; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); }
.forge { display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: .9rem .6rem; border-radius: 16px; background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--gold) 14%, transparent), transparent 70%); }
.parts { font-family: var(--fp); font-size: 1.35rem; font-weight: 800; color: var(--ink2); text-align: center; }
.parts .plus { color: var(--dim); margin: 0 .35rem; font-family: var(--f); }
.arrow { color: var(--gold); font-weight: 800; font-size: .9rem; }
.word { font-family: var(--fp); font-size: 2.4rem; font-weight: 800; line-height: 1.2; text-align: center; }
.hl { color: var(--gold); text-decoration: underline 3px; text-underline-offset: 6px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: .4rem .9rem; margin: 0; font-size: .92rem; }
.facts dt { color: var(--dim); font-weight: 700; }
.facts dd { margin: 0; font-weight: 700; min-width: 0; }
.years { display: flex; flex-wrap: wrap; gap: .3rem; }
.yr { font-size: .74rem; font-weight: 800; padding: .1rem .5rem; border-radius: 999px; background: color-mix(in srgb, var(--gold) 16%, transparent); color: var(--gold); }
.none { color: var(--dim); font-size: .85rem; }
.hint { color: var(--dim); font-size: .85rem; margin: 0; text-align: center; }

/* ท่องจำ */
.sw2 { min-height: 44px; padding: 0 1rem; border-radius: 999px; border: 1px solid var(--line); background: color-mix(in srgb, var(--strong) 5%, transparent); font-weight: 800; cursor: pointer; }
.sw2[aria-pressed="true"] { background: var(--gold); color: var(--on-gold); border-color: var(--gold); }
.list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.item { display: grid; grid-template-columns: 4rem minmax(0, 1fr); gap: .9rem; align-items: center; padding: .75rem .9rem; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
.item-n { font-size: 1.9rem; font-weight: 800; color: var(--gold); text-align: center; border: 0; background: none; border-radius: 10px; transition: filter .25s; }
.item-d { color: var(--muted); font-size: .9rem; font-family: var(--fp); }
.hide .item-n { filter: blur(9px); background: color-mix(in srgb, var(--gold) 12%, transparent); cursor: pointer; }
.hide .item-n.shown { filter: none; background: none; }

.dock { position: sticky; bottom: 0; z-index: 5; background: linear-gradient(0deg, var(--bg) 60%, transparent); }
.dock .wrap { display: flex; gap: .6rem; padding-block: 1rem; }
.btn { flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; min-height: 52px; padding: 0 1.3rem; border-radius: 14px; border: 0; font-weight: 800; cursor: pointer; white-space: nowrap; }
.btn-main { background: var(--strong); color: var(--bg); }
.btn-ghost { flex: 0 1 auto; background: color-mix(in srgb, var(--strong) 12%, transparent); }
.note { color: var(--dim); font-size: .8rem; text-align: center; padding-block: 1rem 5rem; margin: 0; }

@media (max-width: 900px) {
	.board { grid-template-columns: 1fr; }
	.panel { position: static; order: -1; }
}
@media (max-width: 640px) {
	.hero-art { background-position: 65% 45%; }
	.hero::before { background: linear-gradient(0deg, var(--bg) 8%, color-mix(in srgb, var(--bg) 82%, transparent) 55%, color-mix(in srgb, var(--bg) 30%, transparent) 100%); }
	.hero-in { padding-top: 6rem; }
	.tree { grid-template-columns: 1fr; }
	.mx { grid-template-columns: 5.6rem repeat(3, minmax(0, 1fr)); gap: .3rem; padding: .6rem; }
	.mx-m b { font-size: .92rem; } .mx-m span { font-size: .68rem; }
	.mx-h b { font-size: .82rem; } .mx-h span { font-size: .68rem; }
	/* มือถือ: ช่องแคบเกินกว่าจะใส่คำ — ช่องบอกจำนวนคำ แตะแล้วคำทั้งหมดขึ้นในรายการใต้ผัง */
	.cell { padding: .3rem; min-height: 3rem; align-items: center; justify-content: center; cursor: pointer; }
	.cell .chip { display: none; }
	.cell .cnt { display: block; font-size: 1.15rem; font-weight: 800; color: var(--c); }
	.cell.sel { box-shadow: 0 0 0 2px var(--gold); }
	.picklist { display: flex; flex-direction: column; gap: .5rem; grid-column: 1 / -1; padding: .7rem; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
	.picklist h3 { font-size: .9rem; }
	.picklist .chips { display: flex; flex-wrap: wrap; gap: .35rem; }
	.list { grid-template-columns: 1fr; }
	.word { font-size: 2rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* แถบบน (ห้องเกม · ชื่อเกม · แบบเดิม · โหมดสี) — แบบเดียวกับผังเสียงบาลี */
.sdm-bar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.sdm-bar-in { display: flex; align-items: center; justify-content: space-between; gap: .75rem; min-height: 60px; }
.sdm-back, .sdm-classic { display: inline-flex; align-items: center; gap: .45rem; min-height: 44px; color: var(--ink); font-weight: 800; font-size: .9rem; text-decoration: none; }
.sdm-back:hover, .sdm-classic:hover { color: var(--gold); }
.sdm-title { font-weight: 800; font-size: .95rem; color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sdm-title i { color: var(--gold); margin-right: .25rem; }
.sdm-actions { display: flex; align-items: center; gap: .5rem; }
.sdm-classic { padding: 0 .9rem; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--strong) 22%, transparent); }
.theme { display: inline-flex; align-items: center; gap: .45rem; }
.sdm-error { margin-block: 2rem 0; font-weight: 700; }
.sdm-error a, .note a { color: var(--gold); font-weight: 800; }
a.btn { text-decoration: none; }
a.stop:hover .dot { border-color: var(--gold); color: var(--ink); }
@media (max-width: 640px) {
	.sdm-title { display: none; }
	.sdm-back span, .sdm-classic span, .theme span { display: none; }
	.sdm-classic, .theme { width: 44px; padding: 0; justify-content: center; }
}
