:root {
  --bg: #14142a;
  --panel: #22223b;
  --panel-2: #2c2c4a;
  --line: #3d3d63;
  --text: #f4ecd8;
  --muted: #a9a3bf;
  --gold: #ffcc4d;
  --hp: #e5484d;
  --mp: #3e8cff;
  --xp: #7bd88f;
  --good: #7bd88f;
  --bad: #ff6b6b;
  --px: 'Pixelify Sans', 'Mitr', monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: 'Mitr', sans-serif; font-weight: 300; }
button { font-family: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }
.num { font-family: var(--px); }

#app { width: 100vw; height: 100vh; display: grid; grid-template-rows: auto 1fr; overflow: hidden; }

/* ---------- แถบบน ---------- */
#topbar {
  display: flex; align-items: center; gap: 24px; padding: 8px 16px;
  background: var(--panel); border-bottom: 3px solid #0b0b18;
}
.tb-char { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.portrait { width: 44px; height: 44px; background: var(--panel-2); border: 2px solid var(--line); overflow: hidden; image-rendering: pixelated; }
.portrait svg { width: 100%; height: auto; display: block; }
.tb-name { font-weight: 500; font-size: 16px; }
.tb-name small { color: var(--muted); font-weight: 300; font-size: 12px; }
.tb-lv { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.xpbar { display: inline-block; width: 90px; height: 6px; background: #0b0b18; }
.xpbar i { display: block; height: 100%; background: var(--xp); }
.bars { display: flex; flex-direction: column; gap: 4px; flex: 1; max-width: 360px; }
.bar { display: grid; grid-template-columns: 28px 1fr 70px; align-items: center; gap: 6px; font-size: 13px; }
.bar label { font-family: var(--px); font-weight: 700; }
.bar .track { height: 12px; background: #0b0b18; border: 2px solid #0b0b18; }
.bar .track i { display: block; height: 100%; transition: width .4s; }
.bar.hp i { background: linear-gradient(#ff7a7d, var(--hp)); }
.bar.mp i { background: linear-gradient(#7fb4ff, var(--mp)); }
.bar span { text-align: right; }
.gold { display: flex; align-items: center; gap: 6px; font-size: 20px; color: var(--gold); }
.coin { width: 16px; height: 16px; background: var(--gold); box-shadow: inset -3px -3px 0 #c9921b, inset 3px 3px 0 #fff2b0; }
.clock { margin-left: auto; text-align: right; font-size: 14px; }
.clock small { color: var(--bad); font-size: 12px; }

/* ---------- พื้นที่หลัก ---------- */
#main { display: grid; grid-template-columns: 1fr 380px; min-height: 0; }
#stage { position: relative; overflow: hidden; min-height: 0; }
#bg, #pro-bg { position: absolute; inset: 0; }
#bg svg, #pro-bg svg { width: 100%; height: 100%; display: block; }
#actors { position: absolute; left: 0; right: 0; bottom: 170px; height: 62%; pointer-events: none; }
.actor { position: absolute; bottom: 0; height: 100%; display: flex; align-items: flex-end; transition: opacity .4s, transform .4s; }
.actor svg { height: 100%; width: auto; filter: drop-shadow(0 6px 0 rgba(0,0,0,.35)); }
.actor.left { left: 8%; }
.actor.right { right: 10%; }
.actor.hide { opacity: 0; transform: translateY(20px); }
.actor.speaking { animation: bob 1.2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px); } }
.actor.hit { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

#act-banner { position: absolute; top: 12px; left: 16px; font-size: 13px; background: rgba(20,20,42,.75); padding: 4px 10px; border-left: 3px solid var(--gold); }
#festival { position: absolute; top: 12px; right: 16px; font-size: 13px; background: rgba(255,204,77,.9); color: #2a1a00; padding: 4px 10px; font-weight: 500; }
#narrator-badge { position: absolute; top: 44px; left: 16px; font-size: 11px; color: var(--muted); background: rgba(20,20,42,.6); padding: 2px 8px; }

/* ---------- กล่องบทพูด ---------- */
#dialog {
  position: absolute; left: 16px; right: 16px; bottom: 16px; min-height: 150px; max-height: 58%;
  overflow-y: auto; background: rgba(20,20,42,.94); border: 3px solid var(--text);
  box-shadow: 0 0 0 3px #0b0b18, 6px 6px 0 3px rgba(0,0,0,.4); padding: 14px 18px 12px;
}
#speaker { position: absolute; top: -18px; left: 16px; background: var(--gold); color: #2a1a00; font-weight: 600; padding: 2px 12px; border: 3px solid #0b0b18; }
#narration { font-size: 18px; line-height: 1.65; min-height: 3.3em; white-space: pre-wrap; cursor: pointer; }
#narration.typing::after { content: '▌'; animation: blink .8s steps(2) infinite; color: var(--gold); }
@keyframes blink { 50% { opacity: 0; } }
#roll { display: inline-block; font-family: var(--px); font-size: 14px; margin-bottom: 6px; padding: 2px 10px; border: 2px solid; }
#roll.ok { color: var(--good); border-color: var(--good); }
#roll.no { color: var(--bad); border-color: var(--bad); }
#applied { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
#applied span { font-size: 12px; background: var(--panel-2); padding: 2px 8px; border-left: 3px solid var(--gold); }
#choices { display: grid; gap: 6px; margin-top: 8px; }
.choice {
  text-align: left; font-size: 16px; padding: 8px 12px; background: var(--panel); border: 2px solid var(--line);
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
}
.choice:hover:not(:disabled) { border-color: var(--gold); background: var(--panel-2); }
.choice:hover:not(:disabled)::before { content: '▶ '; color: var(--gold); }
.choice:disabled { opacity: .45; cursor: not-allowed; }
.choice .tag { font-size: 12px; color: var(--muted); white-space: nowrap; }
.choice .tag.special { color: var(--gold); }
#thinking { color: var(--muted); font-size: 14px; margin-top: 8px; }
#thinking span { display: inline-block; width: 8px; height: 8px; background: var(--gold); margin-right: 3px; animation: dot 1s infinite; }
#thinking span:nth-child(2) { animation-delay: .2s; }
#thinking span:nth-child(3) { animation-delay: .4s; }
@keyframes dot { 50% { opacity: .2; transform: translateY(-3px); } }

/* ---------- แผงขวา ---------- */
#panel { background: var(--panel); border-left: 3px solid #0b0b18; display: flex; flex-direction: column; min-height: 0; }
#tabs { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 3px solid #0b0b18; }
#tabs button { background: var(--panel-2); border: 0; border-right: 1px solid #0b0b18; border-bottom: 1px solid #0b0b18; padding: 8px 4px; font-size: 14px; }
#tabs button.on { background: var(--gold); color: #2a1a00; font-weight: 500; }
.tab { display: none; padding: 12px; overflow-y: auto; flex: 1; min-height: 0; }
.tab.on { display: block; }
.tab h3 { font-size: 14px; font-weight: 500; color: var(--gold); margin: 12px 0 6px; }
.tab h3:first-child { margin-top: 0; }
.muted { color: var(--muted); font-size: 13px; }
.card { background: var(--panel-2); border: 2px solid var(--line); padding: 8px 10px; margin-bottom: 8px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.btn { background: var(--gold); color: #2a1a00; border: 2px solid #0b0b18; padding: 4px 10px; font-size: 13px; font-weight: 500; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.risk-ปลอดภัย { color: var(--good); }
.risk-ปานกลาง { color: var(--gold); }
.risk-อันตราย { color: var(--bad); }
.timer { font-family: var(--px); font-size: 26px; color: var(--gold); }
.prog { height: 8px; background: #0b0b18; margin-top: 6px; }
.prog i { display: block; height: 100%; background: var(--gold); transition: width 1s linear; }
.exp.done .timer { color: var(--good); animation: blink 1s steps(2) infinite; }
select { background: var(--bg); color: var(--text); border: 2px solid var(--line); font-family: inherit; padding: 3px; }

.grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.slot { aspect-ratio: 1; background: #17172e; border: 2px solid var(--line); position: relative; display: flex; align-items: center; justify-content: center; }
.slot svg { width: 72%; height: 72%; }
.slot b { position: absolute; right: 2px; bottom: 0; font-family: var(--px); font-size: 12px; text-shadow: 1px 1px 0 #000; }
.slot.sel { border-color: var(--gold); }
.slot.eq::after { content: 'E'; position: absolute; left: 2px; top: 0; font-family: var(--px); font-size: 11px; color: var(--gold); }
.slot.filled { cursor: pointer; }
.slot.filled:hover { border-color: var(--text); }
.repbar { display: grid; grid-template-columns: 110px 1fr 36px; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 6px; }
.repbar .track { height: 8px; background: #0b0b18; position: relative; }
.repbar .track::before { content: ''; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--muted); }
.repbar .track i { position: absolute; top: 0; bottom: 0; }
.statrow { display: grid; grid-template-columns: 1fr 40px 30px; align-items: center; font-size: 14px; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.statrow .num { text-align: right; font-size: 16px; }
.plus { background: var(--gold); color: #2a1a00; border: 0; width: 22px; height: 22px; font-weight: 700; justify-self: end; }
.npc { display: grid; grid-template-columns: 48px 1fr; gap: 8px; align-items: center; }
.npc .portrait { width: 48px; height: 48px; }
.log { font-size: 12px; color: var(--muted); border-left: 2px solid var(--line); padding-left: 8px; margin-bottom: 4px; }

/* ---------- บทนำ ---------- */
#prologue { position: fixed; inset: 0; z-index: 5; }
#pro-goddess { position: absolute; left: 50%; top: 4%; height: 52%; transform: translateX(-50%); animation: float 4s ease-in-out infinite; }
#pro-goddess svg { height: 100%; width: auto; filter: drop-shadow(0 0 24px rgba(255,204,77,.5)); }
@keyframes float { 50% { transform: translate(-50%, -10px); } }
#pro-box {
  position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); width: min(1100px, calc(100% - 32px));
  max-height: 58%; overflow-y: auto; background: rgba(20,20,42,.95); border: 3px solid var(--text); box-shadow: 0 0 0 3px #0b0b18; padding: 22px 20px 16px;
}
#pro-speaker { position: sticky; top: -22px; display: inline-block; background: var(--gold); color: #2a1a00; font-weight: 600; padding: 2px 12px; border: 3px solid #0b0b18; margin: -8px 0 10px; z-index: 1; }
#pro-text { font-size: 18px; line-height: 1.7; min-height: 2em; white-space: pre-wrap; }
#pro-body { margin-top: 12px; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.pick { text-align: left; background: var(--panel); border: 2px solid var(--line); padding: 10px 12px; }
.pick:hover, .pick.on { border-color: var(--gold); background: var(--panel-2); }
.pick b { display: block; font-weight: 500; color: var(--gold); margin-bottom: 4px; font-size: 16px; }
.pick span { font-size: 13px; color: var(--muted); line-height: 1.5; display: block; }
.pick .look { float: right; width: 44px; height: 60px; margin-left: 6px; }
.pick .look svg { width: 100%; height: 100%; }
.name-input { font-family: inherit; font-size: 20px; background: var(--bg); color: var(--text); border: 2px solid var(--gold); padding: 8px 12px; width: 280px; }
.pro-actions { display: flex; gap: 8px; margin-top: 12px; justify-content: flex-end; }
.pro-actions .btn { font-size: 16px; padding: 8px 18px; }

/* ---------- หน้าต่างลอย / แจ้งเตือน ---------- */
#modal { position: fixed; inset: 0; background: rgba(5,5,15,.7); display: flex; align-items: center; justify-content: center; z-index: 10; }
#modal-box { width: min(560px, calc(100% - 32px)); max-height: 80vh; overflow-y: auto; background: var(--panel); border: 3px solid var(--text); box-shadow: 0 0 0 3px #0b0b18; padding: 18px 20px; }
#modal-box h2 { margin: 0 0 10px; font-weight: 500; color: var(--gold); font-size: 20px; }
#modal-box p { line-height: 1.7; }
.loot { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.loot span { background: var(--panel-2); padding: 4px 8px; display: flex; align-items: center; gap: 6px; font-size: 14px; }
.loot svg { width: 20px; height: 20px; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120px); background: var(--gold); color: #2a1a00; padding: 8px 16px; border: 3px solid #0b0b18; font-weight: 500; transition: transform .3s; z-index: 20; max-width: 90vw; }
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--bad); color: #fff; }

/* จอแคบ (มือถือ/แท็บเล็ต) */
@media (max-width: 900px) {
  #app { height: auto; min-height: 100vh; overflow: visible; }
  #topbar { flex-wrap: wrap; gap: 10px; }
  .clock { margin-left: 0; }
  #main { grid-template-columns: 1fr; }
  #stage { height: 78vh; }
  #panel { border-left: 0; border-top: 3px solid #0b0b18; min-height: 60vh; }
  #actors { bottom: 200px; height: 45%; }
  #narration { font-size: 16px; }
}

/* ---------- ภาพวาดอนิเมะชุดใหม่ ---------- */
.actor img.chibi { height: 100%; width: auto; filter: drop-shadow(0 8px 0 rgba(0,0,0,.28)); user-select: none; }
.actor img.chibi.is-slime { height: 46%; }
.actor img.chibi.flip { transform: scaleX(-1); }
.actor[data-mood="sad"] img.chibi { filter: drop-shadow(0 8px 0 rgba(0,0,0,.28)) saturate(.75) brightness(.92); }
#actors { height: 58%; }
#face { position: absolute; left: 10px; bottom: 16px; height: min(340px, 62%); z-index: 3; pointer-events: none; animation: faceIn .35s ease-out; }
#face img { height: 100%; width: auto; filter: drop-shadow(4px 0 0 rgba(0,0,0,.3)); }
@keyframes faceIn { from { opacity: 0; transform: translateX(-24px); } }
#dialog { z-index: 2; }
#dialog.has-face { padding-left: 250px; }
#dialog.has-face #speaker { left: 250px; }
#pro-goddess { top: 2%; height: 56%; }
#pro-goddess img { height: 100%; width: auto; filter: drop-shadow(0 0 28px rgba(255,204,77,.55)); }
.pick .look img { height: 100%; width: auto; }
.portrait { position: relative; }
.portrait img { width: 100%; height: 100%; object-fit: cover; }
.portrait img.avatar-face { object-position: 50% 0%; transform: scale(1.5); transform-origin: 50% 12%; }
.portrait img.avatar-chibi { object-position: 50% 0%; height: 230%; width: 100%; object-fit: cover; }
.portrait img.avatar-chibi.is-slime { height: 100%; object-fit: contain; }
.npc .portrait { background: linear-gradient(#ffe7f2, #d9c7f0); }
@media (max-width: 900px) {
  #face { height: 170px; bottom: auto; top: calc(22vh - 40px); }
  #dialog.has-face { padding-left: 18px; }
  #dialog.has-face #speaker { left: 16px; }
}
#dialog { max-height: 46%; }
#actors { bottom: 120px; }
@media (max-width: 900px) {
  #actors { height: 36%; bottom: 290px; }
  .actor.left { left: 0; } .actor.right { right: 0; }
  #face { height: 150px; top: 120px; left: auto; right: 8px; }
}
@media (max-width: 900px) { #face { display: none !important; } }
/* ฉากหลังภาพวาด */
#bg img.bg-img, #pro-bg img.bg-img { width: 100%; height: 100%; object-fit: cover; display: block; transition: filter .6s; }
#bg img.bg-img.is-night { filter: brightness(.55) saturate(.8) hue-rotate(-12deg); }
.actor img.chibi.is-small { height: 55%; }

/* ---------- หน้าเลือกช่องเซฟ ---------- */
#title { position: fixed; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center; }
#title-bg { position: absolute; inset: 0; }
#title-bg img { width: 100%; height: 100%; object-fit: cover; filter: brightness(.55); }
#title-box { position: relative; width: min(760px, calc(100% - 32px)); max-height: 90vh; overflow-y: auto; background: rgba(20,20,42,.92); border: 3px solid var(--text); box-shadow: 0 0 0 3px #0b0b18; padding: 18px; }
.title-head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.title-head img { width: 64px; height: 64px; image-rendering: pixelated; }
.title-head h1 { margin: 0; font-weight: 600; color: var(--gold); font-size: 30px; }
.title-head p { margin: 0; color: var(--muted); }
.sv { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center; background: var(--panel); border: 2px solid var(--line); padding: 10px 12px; margin-bottom: 8px; }
.sv.current { border-color: var(--gold); }
.sv .pic { width: 64px; height: 64px; background: linear-gradient(#ffe7f2, #d9c7f0); overflow: hidden; display: flex; align-items: flex-start; justify-content: center; }
.sv .pic img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 0; }
.sv .pic img.avatar-face { transform: scale(1.45); transform-origin: 50% 12%; }
.sv .pic img.avatar-chibi { height: 230%; }
.sv .pic.empty { background: var(--panel-2); color: var(--muted); align-items: center; font-size: 28px; }
.sv b { color: var(--gold); font-weight: 500; font-size: 17px; }
.sv .meta { color: var(--muted); font-size: 13px; }
.sv .acts { display: flex; gap: 6px; }
.sv .btn { font-size: 14px; padding: 6px 14px; }
@media (max-width: 600px) { .sv { grid-template-columns: 48px 1fr; } .sv .pic { width: 48px; height: 48px; } .sv .acts { grid-column: 1 / -1; } }
/* สกิลโกง */
.talent-count { margin-bottom: 8px; color: var(--muted); }
.talent-count b { color: var(--gold); }
.rank { font-style: normal; font-family: var(--px); font-size: 12px; padding: 1px 6px; margin-right: 6px; border: 2px solid; vertical-align: 2px; }
.rank.r-SSS { color: #ff7ad9; border-color: #ff7ad9; text-shadow: 0 0 6px #ff7ad9; }
.rank.r-SS { color: #ffcc4d; border-color: #ffcc4d; }
.rank.r-S { color: #7fd0ff; border-color: #7fd0ff; }
.rank.r-A { color: #7bd88f; border-color: #7bd88f; }
.rank.r-B { color: #a9a3bf; border-color: #a9a3bf; }
.pick.on { box-shadow: 0 0 0 2px var(--gold) inset; }

.pick .fx { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.pick .fx i { font-style: normal; font-size: 12px; background: var(--bg); color: var(--gold); padding: 1px 6px; }
/* ป้ายชื่อคนพูด: วางในกรอบ ไม่ลอยเกินขอบ (เดิมโดนกรอบตัดครึ่ง) */
#speaker { position: static; display: inline-block; margin: 0 8px 8px 0; font-size: 16px; padding: 1px 12px; }
#dialog.has-face #speaker { left: auto; }
#roll:not(.hidden) { vertical-align: top; }
/* ตอนมีรูปหน้าในกรอบคำพูด เลื่อนตัวเราไปทางขวา ไม่ให้โดนรูปหน้าบัง */
#stage:has(#dialog.has-face) .actor.left { left: 24%; }
.actor.left { transition: left .4s; }

#bug-btn { position: fixed; right: 10px; bottom: 10px; z-index: 30; background: rgba(20,20,42,.85); color: var(--muted); border: 2px solid var(--line); padding: 4px 10px; font-size: 13px; }
#bug-btn:hover { color: var(--gold); border-color: var(--gold); }
/* ตัวละครยืนเหนือกรอบคำพูด ตัวเล็ก (สไลม์) จะไม่จมหายหลังกรอบ */
#actors { bottom: 36%; height: 56%; }
@media (max-width: 900px) { #actors { bottom: 290px; height: 36%; } }

#ver-badge { position: fixed; left: 10px; bottom: 10px; z-index: 30; font-size: 11px; color: var(--muted); background: rgba(20,20,42,.75); padding: 2px 8px; pointer-events: auto; }
#update-bar { position: fixed; left: 50%; top: 10px; transform: translateX(-50%); z-index: 40; background: var(--gold); color: #2a1a00; border: 3px solid #0b0b18; padding: 6px 8px 6px 14px; display: flex; gap: 10px; align-items: center; font-weight: 500; max-width: 92vw; }
#update-bar .btn { background: #2a1a00; color: var(--gold); }

.gender-pick { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; color: var(--muted); }
.gender-pick .btn { font-size: 14px; padding: 4px 16px; }

/* ตัวเรา: ป้ายชื่อใต้ตัว + ขนาดสไลม์ (ทับกฎ is-small) */
.actor.left { flex-direction: column; justify-content: flex-end; align-items: center; }
.me-tag { margin-top: 4px; background: rgba(20,20,42,.85); color: var(--gold); border: 2px solid var(--gold); font-size: 13px; padding: 1px 10px; white-space: nowrap; }
.actor img.chibi.is-slime { height: 42%; }
.actor.left img.chibi { max-height: calc(100% - 28px); }
/* ให้ตัวละคร+ป้ายชื่อตัวเราอยู่เหนือกรอบคำพูดเสมอ */
#dialog { max-height: 42%; }
#actors { bottom: 43%; height: 52%; }
@media (max-width: 900px) { #actors { bottom: 290px; height: 36%; } #dialog { max-height: 58%; } }

/* หลายตัวในฉากเดียว */
.actor.right.multi { right: 3%; width: 62%; display: flex; flex-direction: row-reverse; justify-content: flex-start; align-items: flex-end; }
.actor.right.multi .cast-one { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; margin-left: -4%; min-width: 0; flex: 0 1 auto; }
.actor.right.multi[data-n="3"] .cast-one, .actor.right.multi[data-n="4"] .cast-one { height: 86%; margin-left: -7%; }
.actor.right.multi .cast-one img.chibi { height: calc(100% - 24px); width: auto; max-width: 100%; object-fit: contain; }
.actor.right.multi .cast-one img.chibi.is-small, .actor.right.multi .cast-one img.chibi.is-slime { height: 48%; }
.actor.right.multi .cast-one:not(.is-speaker) img.chibi { filter: drop-shadow(0 8px 0 rgba(0,0,0,.28)) brightness(.88); }
.cast-name { margin-top: 4px; background: rgba(20,20,42,.85); color: var(--text); border: 2px solid var(--line); font-size: 12px; padding: 0 8px; white-space: nowrap; }
.actor.right.multi .cast-one.is-speaker .cast-name { border-color: var(--gold); color: var(--gold); }

/* ตัวเรา + เพื่อนร่วมทาง */
.actor.left { flex-direction: row; align-items: flex-end; }
.actor.left .cast-one { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.actor.left .cast-one img.chibi { height: calc(100% - 28px); width: auto; }
.actor.left .cast-one img.chibi.is-slime, .actor.left .cast-one img.chibi.is-small { height: 42%; }
.actor.left .cast-one.ally { margin-left: -2%; }
.actor.left .cast-one.ally img.chibi { filter: drop-shadow(0 8px 0 rgba(0,0,0,.28)); }

/* ตัวซ้ำ (เช่น ยาม 2 คน) ให้ดูต่างกันนิด ไม่เหมือนฝาแฝดก๊อปวาง */
.actor.right.multi .cast-one.dup-1 img.chibi { transform: scale(.95) translateY(2%); filter: drop-shadow(0 8px 0 rgba(0,0,0,.28)) brightness(.86) hue-rotate(18deg); }
.actor.right.multi .cast-one.dup-2 img.chibi { transform: scale(.92) translateY(3%); filter: drop-shadow(0 8px 0 rgba(0,0,0,.28)) brightness(.82) hue-rotate(-20deg); }
.actor.right.multi .cast-one.dup-3 img.chibi { transform: scale(.9) translateY(4%); filter: drop-shadow(0 8px 0 rgba(0,0,0,.28)) brightness(.8) hue-rotate(35deg); }
.actor img.chibi.flip { transform: scaleX(-1); }
.actor.right.multi .cast-one.dup-1 img.chibi.flip { transform: scaleX(-1) scale(.95) translateY(2%); }
.actor.right.multi .cast-one.dup-2 img.chibi.flip { transform: scaleX(-1) scale(.92) translateY(3%); }
.actor.right.multi .cast-one.dup-3 img.chibi.flip { transform: scaleX(-1) scale(.9) translateY(4%); }

.away-box { background: var(--panel); border: 2px dashed var(--gold); padding: 10px 12px; }
.away-box .timer { font-size: 20px; margin-left: 8px; }
.actor.left.hide { opacity: 0; }

/* หน้าใส่รหัสเข้าเกม */
#login { position: fixed; inset: 0; z-index: 50; background: rgba(10,10,24,.94); display: flex; align-items: center; justify-content: center; }
.login-box { background: var(--panel); border: 3px solid var(--text); box-shadow: 0 0 0 3px #0b0b18; padding: 24px; width: min(360px, 90vw); text-align: center; }
.login-box img { width: 56px; image-rendering: pixelated; }
.login-box h2 { color: var(--gold); font-weight: 600; margin: 8px 0 4px; }
.login-box input { font-family: var(--px); font-size: 26px; text-align: center; letter-spacing: 6px; width: 100%; margin: 12px 0; background: var(--bg); color: var(--text); border: 2px solid var(--gold); padding: 8px; }
.login-box .btn { width: 100%; font-size: 16px; padding: 8px; }
/* แป้นตัวเลขบนจอหน้าใส่รหัส */
.login-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0 0 10px; }
.login-pad .btn { font-family: var(--px); font-size: 22px; padding: 10px 0; touch-action: manipulation; }
