#cs378.chapter-one-art { font-family: Tahoma, system-ui, sans-serif; background: #526a35; }
#cs378.chapter-one-art .stage { background-image: url('./village.webp') !important; background-size: cover; background-position: center; }
#cs378.chapter-one-art .stage:after { background: linear-gradient(transparent 65%, #16200d55); }
#cs378.chapter-one-art .pt { display: none; }
#cs378.chapter-one-art .btn { border-radius: 4px; box-shadow: 0 3px 0 #38210d88; min-height: 42px; }
#cs378.chapter-one-art .chapter-title { position: absolute; top: calc(12px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); padding: 5px 16px; color: #fff1c7; background: #442c1be8; border: 2px solid #d5ac65; box-shadow: 0 3px 0 #24150d88; white-space: nowrap; font-weight: bold; }
#cs378.chapter-one-art .cast { position: absolute; left: 50%; top: 60%; transform: translate(-50%, -100%); width: min(76%, 790px); height: clamp(60px, 13vw, 130px); display: flex; align-items: flex-end; justify-content: center; gap: clamp(9px, 2vw, 35px); z-index: 1; pointer-events: none; }
#cs378.chapter-one-art .actor { flex: 0 1 auto; height: 100%; min-width: 0; width: auto; object-fit: contain; filter: drop-shadow(0 5px 2px #1d261c66); image-rendering: pixelated; transition: filter .2s, translate .2s; }
#cs378.chapter-one-art .actor.cart { height: 78%; max-width: 27%; }
#cs378.chapter-one-art .actor.soldier { height: 98%; }
#cs378.chapter-one-art .actor.farmer { height: 93%; margin-left: clamp(0px, 2vw, 35px); }
#cs378.chapter-one-art .actor.speaking { translate: 0 -4px; filter: drop-shadow(0 6px 3px #1d261c88) brightness(1.1); }
#cs378.chapter-one-art .dlg { box-sizing: border-box; margin: 0 clamp(8px, 2vw, 30px) calc(8px + env(safe-area-inset-bottom)); padding: 45px clamp(22px, 3vw, 48px) 45px; min-height: 205px; border: 0; background: #f6e6c5; border-radius: 8px; box-shadow: 0 8px 20px #15200f88; isolation: isolate; }
#cs378.chapter-one-art .dlg:before { content: ''; position: absolute; inset: 0; background: url('./dialogue.png') center / 100% 100% no-repeat; pointer-events: none; z-index: -1; }
#cs378.chapter-one-art .nm { left: clamp(140px, 15vw, 205px); top: 12px; padding: 0 8px; background: #4c301b; border: 0; border-radius: 2px; font-size: 17px; }
#cs378.chapter-one-art .tx { font-size: clamp(16px, 1.7vw, 22px); line-height: 1.65; padding-left: clamp(105px, 12vw, 165px); }
#cs378.chapter-one-art .tx.nar, #cs378.chapter-one-art .dlg.no-portrait .tx { padding-left: 0; }
#cs378.chapter-one-art .dialogue-portrait { position: absolute; left: 22px; bottom: 25px; width: clamp(95px, 11vw, 150px); height: 145px; object-fit: contain; object-position: center bottom; image-rendering: pixelated; }
#cs378.chapter-one-art .dialogue-portrait[hidden] { display: none; }
#cs378.chapter-one-art .nx { cursor: pointer; right: 23px; bottom: 13px; min-height: 32px; padding: 0 10px; border: 2px solid #805428; border-radius: 4px; color: #3a2814; background: #ffd375; animation: none; font: bold 14px/1.6 Tahoma, sans-serif; }
#cs378.chapter-one-art .nx:focus-visible, #cs378.chapter-one-art .btn:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
#cs378.chapter-one-art .go { margin-top: 8px; }
@media (max-width: 600px) {
  #cs378.chapter-one-art .chapter-title { top: calc(66px + env(safe-area-inset-top)); font-size: 14px; }
  #cs378.chapter-one-art .cast { width: 92%; height: clamp(55px, 18vw, 92px); gap: 8px; }
  #cs378.chapter-one-art .dlg { min-height: 240px; padding: 42px 20px 52px; }
  #cs378.chapter-one-art .dialogue-portrait { left: 15px; bottom: 53px; width: 75px; height: 105px; }
  #cs378.chapter-one-art .tx { padding-left: 80px; font-size: 16px; }
  #cs378.chapter-one-art .nm { left: 105px; font-size: 16px; }
}
@media (max-height: 520px) and (min-width: 601px) {
  #cs378.chapter-one-art .dlg { min-height: 150px; padding-top: 38px; padding-bottom: 36px; }
  #cs378.chapter-one-art .dialogue-portrait { height: 105px; width: 90px; bottom: 18px; }
  #cs378.chapter-one-art .tx { font-size: 15px; padding-left: 95px; }
  #cs378.chapter-one-art .cast { height: 62px; }
  #cs378.chapter-one-art .gl { font-size: 13px; line-height: 1.25; }
  #cs378.chapter-one-art .go { font-size: 15px; padding: 3px; margin-top: 3px; }
}
@media (prefers-reduced-motion: reduce) {
  #cs378.chapter-one-art .actor { transition: none; }
}

/* v389: ชื่อผู้พูดวางลงในป้ายไม้ของกรอบ และเลื่อนข้อความลงมาใต้ป้าย (กรอบยืดเต็มกว้าง ป้ายอยู่ ~18–34% ของความกว้าง, ~8–28% ของความสูง) */
#cs378.chapter-one-art .nm { left: 18.5%; width: 15%; top: 9%; height: 17%; box-sizing: border-box; padding: 0; background: transparent; color: #fff4d8; text-align: center; line-height: 36px; font-size: 17px; overflow: hidden; white-space: nowrap; text-shadow: 0 1px 0 #2a170a; }
#cs378.chapter-one-art .dlg { min-height: 235px; padding-top: 74px; padding-bottom: 40px; }
@media (max-width: 600px) {
  #cs378.chapter-one-art .nm { left: 18.5%; font-size: 15px; line-height: 34px; }
  #cs378.chapter-one-art .dlg { min-height: 250px; padding-top: 74px; padding-bottom: 52px; }
}
@media (max-height: 520px) and (min-width: 601px) {
  #cs378.chapter-one-art .nm { line-height: 24px; font-size: 14px; }
  #cs378.chapter-one-art .dlg { min-height: 175px; padding-top: 50px; padding-bottom: 30px; }
}

/* v390: ภาพฉากเต็มจอ + กรอบบทสนทนาวางทับขอบล่าง · ตัวละครเล็กลง 50% · ป้ายไม้แสดงเฉพาะตอนมีชื่อ */
#cs378.chapter-one-art .dlg { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; }
#cs378.chapter-one-art .cast { width: min(38%, 395px); height: clamp(30px, 6.5vw, 65px); gap: clamp(5px, 1vw, 18px); }
#cs378.chapter-one-art .actor.farmer { margin-left: clamp(0px, 1vw, 18px); }
#cs378.chapter-one-art .dlg.no-plate:before { background-image: url('./dialogue-noplate.png'); }
#cs378.chapter-one-art .dlg.no-plate { padding-top: 46px; }
@media (max-width: 600px) {
  #cs378.chapter-one-art .cast { width: 46%; height: clamp(28px, 9vw, 46px); gap: 4px; }
}
@media (max-height: 520px) and (min-width: 601px) {
  #cs378.chapter-one-art .cast { height: 31px; }
  #cs378.chapter-one-art .dlg.no-plate { padding-top: 34px; }
}

/* v391: ฉากเห็นครบขึ้น — ภาพจริงอยู่ใน .bgfit, ส่วนที่เหลือเติมด้วยภาพเบลอ, ตัวละครขนาดตามฉาก (JS กำหนด) */
#cs378.chapter-one-art .stage { background-image: none !important; background-color: #3f5a2a; }
#cs378.chapter-one-art .stage:before { content: ''; position: absolute; inset: -24px; background: var(--bgfull, url('./village.webp')) center / cover no-repeat; filter: blur(12px) brightness(.85); }
#cs378.chapter-one-art .bgfit { position: absolute; background: url('./village.webp') center / 100% 100% no-repeat; image-rendering: auto; -webkit-mask-image: linear-gradient(transparent, #000 5%, #000 95%, transparent); mask-image: linear-gradient(transparent, #000 5%, #000 95%, transparent); }
#cs378.chapter-one-art .cast { transform: translate(-50%, -100%); max-width: none; }

/* v394: กรอบบทสนทนาตัดเป็น 9 ส่วน (มุม/ความหนาขอบไม้ไม่บีบตามขนาดจอ) · ป้ายไม้เป็นรูปแยก แสดงพร้อมชื่อเท่านั้น */
#cs378.chapter-one-art .dlg { background: transparent; border-radius: 0; }
#cs378.chapter-one-art .dlg:before, #cs378.chapter-one-art .dlg.no-plate:before { background: none; box-sizing: border-box; border: 28px solid transparent; border-image: url('./dialogue-noplate.png') 34 fill / 28px / 0 stretch; image-rendering: pixelated; }
#cs378.chapter-one-art .nm { left: 18.5%; top: 7px; width: 173px; height: 52px; line-height: 44px; background: url('./plaque.png') center / 100% 100% no-repeat; image-rendering: pixelated; }
@media (max-width: 600px) {
  #cs378.chapter-one-art .dlg:before, #cs378.chapter-one-art .dlg.no-plate:before { border-width: 22px; border-image-width: 22px; }
  #cs378.chapter-one-art .nm { left: 62px; top: 4px; width: 130px; height: 39px; line-height: 33px; font-size: 15px; }
}
@media (max-height: 520px) and (min-width: 601px) {
  #cs378.chapter-one-art .dlg:before, #cs378.chapter-one-art .dlg.no-plate:before { border-width: 22px; border-image-width: 22px; }
  #cs378.chapter-one-art .nm { left: 18.5%; top: 4px; width: 130px; height: 39px; line-height: 33px; font-size: 14px; }
}

/* v395: iPad/แท็บเล็ตแนวนอน — กรอบบทสนทนาเตี้ยลง ให้ฉากเห็นมากขึ้น */
@media (min-width: 601px) and (min-height: 521px) and (max-height: 900px) and (orientation: landscape) {
  #cs378.chapter-one-art .dlg { min-height: 190px; padding-bottom: 34px; }
}

/* v396: เงาวงรีใต้เท้าตัวละคร + รูปหน้า/ป้ายชื่อชาวนาอยู่ฝั่งขวา */
#cs378.chapter-one-art .aw { position: relative; isolation: isolate; flex: 0 1 auto; height: 100%; min-width: 0; display: flex; align-items: flex-end; }
#cs378.chapter-one-art .aw:after { content: ''; position: absolute; left: 8%; right: 8%; bottom: -5%; height: 16%; border-radius: 50%; background: radial-gradient(ellipse at center, rgba(25, 35, 12, .6) 0%, rgba(25, 35, 12, .45) 55%, rgba(25, 35, 12, 0) 100%); z-index: -1; pointer-events: none; }
#cs378.chapter-one-art .aw.cart { max-width: 27%; }
#cs378.chapter-one-art .aw.cart:after { left: 4%; right: 14%; }
#cs378.chapter-one-art .aw.farmer { margin-left: clamp(0px, 1vw, 18px); }
#cs378.chapter-one-art .aw .actor { height: 98%; max-width: 100%; margin: 0; filter: none; }
#cs378.chapter-one-art .aw .actor.cart { height: 78%; }
#cs378.chapter-one-art .aw .actor.farmer { height: 93%; margin: 0; }
#cs378.chapter-one-art .aw .actor.captain { height: 100%; }
#cs378.chapter-one-art .aw .actor.speaking { translate: 0 -4px; filter: brightness(1.12); }
#cs378.chapter-one-art .dlg.side-r .dialogue-portrait { left: auto; right: 22px; }
#cs378.chapter-one-art .dlg.side-r .tx { padding-left: 0; padding-right: clamp(105px, 12vw, 165px); }
#cs378.chapter-one-art .dlg.side-r .nm { left: auto; right: 18.5%; }
@media (max-width: 600px) {
  #cs378.chapter-one-art .dlg.side-r .dialogue-portrait { right: 15px; }
  #cs378.chapter-one-art .dlg.side-r .tx { padding-right: 80px; }
  #cs378.chapter-one-art .dlg.side-r .nm { right: 62px; }
}
@media (max-height: 520px) and (min-width: 601px) {
  #cs378.chapter-one-art .dlg.side-r .tx { padding-right: 95px; }
}
#cs378.chapter-one-art .dlg.side-r .nx { right: auto; left: 23px; }

/* v397: ตัวละครนำของด่าน 2 (ซาร่า) */
#cs378.chapter-one-art .aw .actor.sara, #cs378.chapter-one-art .aw .actor.ray, #cs378.chapter-one-art .aw .actor.leena, #cs378.chapter-one-art .aw .actor.bronze { height: 100%; }

/* v407: คนตัดไม้ (ยืนต่อจากชาวนา) */
#cs378.chapter-one-art .aw.woodcutter { margin-left: clamp(0px, 0.6vw, 10px); }
#cs378.chapter-one-art .aw .actor.woodcutter { height: 100%; margin: 0; }

/* v426: ตัวละครชุดใหม่ (ภาพตัดแล้วเติมขอบบนให้ทุกตัวสูงเท่ากัน 560px รวมหอก) → ขยาย 112% ให้ตัวสูงเท่าเดิม ส่วนหอกยื่นขึ้นด้านบน */
#cs378.chapter-one-art .aw .actor.captain, #cs378.chapter-one-art .aw .actor.soldier, #cs378.chapter-one-art .aw .actor.farmer,
#cs378.chapter-one-art .aw .actor.woodcutter, #cs378.chapter-one-art .aw .actor.sara, #cs378.chapter-one-art .aw .actor.ray,
#cs378.chapter-one-art .aw .actor.leena, #cs378.chapter-one-art .aw .actor.bronze, #cs378.chapter-one-art .aw .actor.vance { height: 112%; }

/* v430: ภาพตัวละครชุดใหม่ แวนซ์ในไฟล์หันขวาอยู่แล้ว จึงไม่กลับด้านตัวเต็ม (ครึ่งตัวยังกลับ)
   v427: ทิศหันให้ตรงกับตำแหน่งยืน/ตำแหน่งในกล่องคำพูด (วัดจากตาในไฟล์จริง: ทุกตัวหันขวา ยกเว้นทหาร/บรอนซ์/แวนซ์ที่ต้นฉบับหันซ้าย)
   - ตัวเต็ม: เรียงจากซ้าย รถ · ทหาร · หัวหน้า · ชาวนา · คนตัดไม้ → ทหารและหัวหน้าหันขวา (เข้าหาชาวบ้าน) · ชาวนา/คนตัดไม้ต้องหันซ้าย (หาหัวหน้า)
   - รูปครึ่งตัว: รูปอยู่ซ้ายกล่อง → หันขวาเข้าหาข้อความ · รูปอยู่ขวากล่อง (ชาวนา/คนตัดไม้) → หันซ้ายเข้าหาข้อความ */
#cs378.chapter-one-art .aw .actor.soldier, #cs378.chapter-one-art .aw .actor.bronze,
#cs378.chapter-one-art .aw .actor.farmer, #cs378.chapter-one-art .aw .actor.woodcutter { transform: scaleX(-1); }
#cs378.chapter-one-art .dlg.side-r .dialogue-portrait, #cs378.chapter-one-art .dlg.flip-p .dialogue-portrait { transform: scaleX(-1); }
