:root {
  --bone: #d9d0bd;
  --dim: #8f877a;
  --blood: #c9341f;
  --ember: #e0782e;
  --panel: rgba(10, 8, 7, 0.88);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overscroll-behavior: none;
  background: #000;
  color: var(--bone);
  font-family: 'Mitr', 'Leelawadee UI', Tahoma, sans-serif;
  font-weight: 300;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- ฉากและเอฟเฟกต์ ---------- */

#stage { position: fixed; inset: 0; }
#view { width: 100%; height: 100%; display: block; image-rendering: pixelated; touch-action: none; -webkit-touch-callout: none; }
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.vlayer { position: absolute; inset: 0; }

.vlabel {
  position: absolute; left: 0; top: 0;
  font-size: 12px; line-height: 1.2; padding: 1px 6px; border-radius: 3px;
  background: rgba(0, 0, 0, 0.5); color: var(--bone); white-space: nowrap; will-change: transform;
}
.vlabel b { color: #fff; font-weight: 500; }
.vlabel.shaman { color: #f0d78a; }
.vlabel.exposed { color: #ff6a5a; background: rgba(70, 0, 0, 0.7); }
.vlabel.hover { outline: 1px solid rgba(255, 255, 255, 0.7); }
.vlabel.picked { outline: 1px solid #e8c88a; background: rgba(60, 40, 10, 0.85); }
.vlabel.alt { margin-top: -18px; }
.vlabel.alt2 { margin-top: -36px; }
.vlabel.speaking { z-index: 2; }
.vlabel .tag { color: var(--dim); font-size: 10px; margin-left: 5px; }
.vlabel .tag.red { color: #ff5a4a; }
.vlabel.glabel { background: none; color: #7d766b; font-size: 10px; text-shadow: 0 0 3px #000; }
.vlabel.glabel b { color: #a59d90; }

.hlabel {
  position: absolute; left: 0; top: 0; text-align: center;
  font-size: 14px; line-height: 1.25; white-space: nowrap; will-change: transform;
  text-shadow: 0 0 4px #000, 0 0 10px #000;
}
.hlabel .hname { font-weight: 500; }
.hlabel .hcount { margin-left: 6px; color: var(--dim); }
.hlabel .badge { display: block; font-size: 12px; }
.hlabel .badge.red { color: #ff5a4a; }
.hlabel .badge.ok { color: #a9c6ff; }
.hlabel.hover .hname { color: var(--ember); }
/* บ้านนอกจอ: ป้ายเกาะขอบจอ บอกแค่ชื่อกับทิศ */
.hlabel.edge-l, .hlabel.edge-r {
  opacity: 0.85; font-size: 12px; padding: 1px 8px; border-radius: 10px;
  background: rgba(10, 8, 6, 0.75); border: 1px solid #5a4632;
}
.hlabel.edge-l .badge, .hlabel.edge-r .badge { display: none; }
.hlabel.edge-l::before { content: '◀ '; }
.hlabel.edge-r::after { content: ' ▶'; }

#fx-vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 42%, rgba(0, 0, 0, 0.92) 100%);
}
#fx-grain {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; mix-blend-mode: overlay; /* overlay ไม่ยกส่วนดำ เงายังเห็นเป็นเงา */
}
.lid { position: absolute; left: -10%; width: 120%; height: 0; background: #000; pointer-events: none; }
#fx-lid-top { top: 0; border-radius: 0 0 50% 50% / 0 0 40% 40%; }
#fx-lid-bot { bottom: 0; border-radius: 50% 50% 0 0 / 40% 40% 0 0; }
#fx-flash { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
#fx-black { position: absolute; inset: 0; background: #000; opacity: 1; pointer-events: none; }

/* ---------- HUD ---------- */

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud-left { position: absolute; left: calc(16px + env(safe-area-inset-left, 0px)); top: calc(12px + env(safe-area-inset-top, 0px)); }
#hud-title { font-family: 'Chonburi', serif; font-size: 24px; color: var(--blood); text-shadow: 0 2px 0 #000; }
#hud-day { font-size: 14px; color: var(--dim); }
#hud-right {
  position: absolute; right: calc(12px + env(safe-area-inset-right, 0px)); top: calc(10px + env(safe-area-inset-top, 0px));
  display: flex; flex-direction: column; align-items: flex-end; text-align: right; font-size: 14px; text-shadow: 0 0 4px #000;
  padding: 16px 10px 8px; border-radius: 10px;
  background: radial-gradient(ellipse at 70% 40%, rgba(6, 5, 4, 0.55), rgba(6, 5, 4, 0) 75%);
}
#hud-right .dim { color: var(--dim); }
#hud-controls { margin-top: 10px; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 11px; color: #8a8174; }
#hud-controls > div { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
#hud-controls span { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
#hud-controls kbd {
  font: inherit; font-size: 10px; line-height: 1; color: #c9bfae; padding: 3px 5px; border-radius: 4px;
  background: rgba(20, 15, 11, 0.75); border: 1px solid rgba(217, 208, 189, 0.18);
}
#hud-controls .ctl-touch { display: none; }
@media (pointer: coarse) {
  #hud-controls .ctl-mouse { display: none; }
  #hud-controls .ctl-touch { display: flex; }
}
.lives { display: flex; gap: 8px; justify-content: flex-end; height: 34px; align-items: flex-end; }
.life { width: 9px; height: 20px; position: relative; background: #d8cdb0; border-radius: 2px; }
.life::before {
  content: ''; position: absolute; left: 50%; top: -12px; width: 9px; height: 12px;
  background: radial-gradient(ellipse at 50% 70%, #fff3b0 0%, #ffa43a 50%, rgba(255, 120, 30, 0) 75%);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  transform: translateX(-50%); animation: flick 0.18s infinite alternate;
}
.life.out { background: #3e3830; height: 14px; }
.life.out::before { display: none; }

/* เทียนผี: เทียนดำ เปลวไฟเขียวซีด ดับเมื่อผีตนนั้นถูกเผาแล้ว */
.gcandles { display: flex; gap: 8px; justify-content: flex-end; align-items: flex-end; height: 32px; margin-top: 2px; }
.gcandle {
  width: 9px; height: 19px; position: relative; border-radius: 2px;
  background: linear-gradient(90deg, #2c2c33, #121216 70%); box-shadow: 0 0 0 1px #3d3d48 inset;
}
.gcandle::before {
  content: ''; position: absolute; left: 50%; top: -13px; width: 9px; height: 13px;
  background: radial-gradient(ellipse at 50% 70%, #eafff2 0%, #5dffa2 45%, rgba(40, 255, 140, 0) 75%);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  transform: translateX(-50%); animation: gflick 0.33s infinite alternate;
  filter: drop-shadow(0 0 5px rgba(61, 255, 138, 0.8));
}
.gcandle.out { height: 12px; background: #1a1a1f; }
.gcandle.out::before { display: none; }
@keyframes gflick {
  from { transform: translateX(-50%) scale(1, 1) skewX(0deg); opacity: 0.9; }
  to { transform: translateX(-50%) scale(0.8, 1.2) skewX(6deg); opacity: 1; }
}
@keyframes flick {
  from { transform: translateX(-50%) scale(1, 1); }
  to { transform: translateX(-50%) scale(0.85, 1.15); }
}
#hud-bottom {
  position: absolute; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  width: min(92vw, 680px); text-align: center;
}
#hud-hint { font-size: 15px; text-shadow: 0 0 4px #000, 0 0 12px #000; min-height: 1.4em; text-wrap: balance; padding: 5px 16px; border-radius: 999px; }
#hud-hint:not(:empty) { background: rgba(8, 6, 5, 0.55); }
#hud-action, #hud-action2 { pointer-events: auto; }
.hud-acts { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.btn {
  touch-action: manipulation;
  font-family: inherit; font-size: 16px; font-weight: 400; color: var(--bone);
  background: #1a1410; border: 1px solid #5a4632; padding: 10px 24px; border-radius: 4px;
  cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.btn:hover:not(:disabled) { background: #2a1d14; border-color: var(--ember); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.danger { background: #3a0d0a; border-color: #8b2018; }
.btn.danger:hover { background: #5a120d; }
.btn.big { font-size: 20px; padding: 12px 44px; }

/* ---------- หมอผีโผล่จากขอบจอตอนเลือกบ้าน ---------- */

#shaman {
  position: fixed; left: 0; bottom: 0; z-index: 9; pointer-events: none;
  aspect-ratio: 320 / 440; height: 40vh;
  transform: translateY(105%); opacity: 0;
  transition: transform 0.75s cubic-bezier(0.2, 0.9, 0.25, 1), opacity 0.5s;
}
#shaman[hidden] { display: none; }
#shaman.right { left: auto; right: 0; }
#shaman.show { transform: translateY(0); opacity: 1; }
#shaman svg { display: block; width: 100%; height: 100%; overflow: visible; }
#shaman.right svg { transform: scaleX(-1); }
/* จอแคบ: คำแนะนำตอนหมอผีโผล่ ย้ายไปกลางพื้นที่ที่เหลือข้างหมอผี */
@media (max-width: 760px) {
  body.sham-l #hud-bottom { left: calc(var(--sham-w) + (100vw - var(--sham-w)) / 2); width: calc(100vw - var(--sham-w) - 12px); }
  body.sham-r #hud-bottom { left: calc((100vw - var(--sham-w)) / 2); width: calc(100vw - var(--sham-w) - 12px); }
}

#shaman .sh-figure { animation: sh-breathe 4.2s ease-in-out infinite; }
#shaman .sh-orb { opacity: 0; transition: opacity 0.45s; }
#shaman .sh-orb-blue { opacity: 1; }
#shaman.ghost .sh-orb-blue, #shaman.clear .sh-orb-blue { opacity: 0; }
#shaman.ghost .sh-orb-red, #shaman.clear .sh-orb-white { opacity: 1; }
#shaman .sh-tint { opacity: 0; transition: opacity 0.45s; mix-blend-mode: screen; }
#shaman .sh-tint-blue { opacity: 1; }
#shaman.ghost .sh-tint-blue, #shaman.clear .sh-tint-blue { opacity: 0; }
#shaman.ghost .sh-tint-red, #shaman.clear .sh-tint-white { opacity: 1; }
#shaman .sh-swirl { transform-box: view-box; transform-origin: 210px 300px; animation: sh-spin 7s linear infinite; }
#shaman.ghost .sh-swirl, #shaman.clear .sh-swirl { animation-duration: 1.6s; }
#shaman .sh-core { transform-box: fill-box; transform-origin: center; animation: sh-pulse 2.4s ease-in-out infinite; }
#shaman .sh-halo { animation: sh-halo 2.4s ease-in-out infinite; }
#shaman .sh-cast { animation: sh-halo 2.4s ease-in-out infinite; }
#shaman .sh-eye { animation: sh-halo 2.4s ease-in-out infinite; }
#shaman .sh-spark { transform-box: fill-box; transform-origin: center; animation: sh-twinkle 2.8s ease-in-out infinite; opacity: 0; }
#shaman .sh-wisp { transform-box: fill-box; transform-origin: center; animation: sh-wisp 3.6s ease-out infinite; opacity: 0; }

@keyframes sh-breathe { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes sh-spin { to { transform: rotate(360deg); } }
@keyframes sh-pulse { 0%, 100% { transform: scale(0.8); opacity: 0.75; } 50% { transform: scale(1.25); opacity: 1; } }
@keyframes sh-halo { 0%, 100% { opacity: 0.75; } 50% { opacity: 1; } }
@keyframes sh-twinkle {
  0%, 100% { opacity: 0; transform: scale(0.3) rotate(0deg); }
  45% { opacity: 1; transform: scale(1) rotate(45deg); }
  70% { opacity: 0; transform: scale(0.4) rotate(90deg); }
}
@keyframes sh-wisp {
  0% { opacity: 0; transform: translateY(0) scale(0.8); }
  25% { opacity: 0.55; }
  100% { opacity: 0; transform: translateY(-70px) scale(1.8); }
}

#toast {
  position: fixed; left: 50%; top: 20%; transform: translateX(-50%); z-index: 20;
  width: max-content; max-width: min(92vw, 720px); text-align: center; font-size: 22px; line-height: 1.5;
  /* พื้นหลังมืดจางๆ กันข้อความทับป้ายชื่อบ้านแล้วอ่านไม่ออก */
  padding: 10px 24px; border-radius: 6px;
  background: rgba(6, 5, 4, 0.8); box-shadow: 0 0 40px 10px rgba(0, 0, 0, 0.55);
  text-shadow: 0 0 6px #000;
  opacity: 0; transition: opacity 0.5s; pointer-events: none;
}
#toast.show { opacity: 1; }
#skip {
  position: fixed; right: 16px; bottom: 14px; z-index: 25; pointer-events: none;
  font-size: 12px; color: #8f877a; opacity: 0; transition: opacity 0.6s;
}
#skip.show { opacity: 0.6; transition-delay: 1.2s; }
#toast b { font-weight: 500; color: #fff; }
.red { color: #ff4a3a; }

#modal { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, 0.55); z-index: 30; }
#modal[hidden] { display: none; }
.panel { background: var(--panel); border: 1px solid #4a3a2a; padding: 22px 28px; border-radius: 6px; text-align: center; min-width: 260px; }
#modal-text { font-size: 20px; margin-bottom: 16px; }
.row { display: flex; gap: 12px; justify-content: center; }

/* ---------- เมนู / จบเกม ---------- */

.screen {
  position: fixed; inset: 0; z-index: 40; overflow-y: auto;
  padding: calc(24px + env(safe-area-inset-top, 0px)) 16px calc(24px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; align-items: center;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.88));
}
.screen[hidden] { display: none; }
.menu-inner { width: min(100%, 760px); text-align: center; margin-block: auto; }
h1 {
  font-family: 'Chonburi', serif; font-weight: 400; margin: 0;
  font-size: clamp(56px, 12vw, 112px); line-height: 1.15; color: var(--blood);
  text-shadow: 0 0 24px rgba(200, 40, 20, 0.45), 0 5px 0 #000;
}
h1.win { color: #e8c88a; text-shadow: 0 0 24px rgba(230, 160, 60, 0.4), 0 5px 0 #000; }
.tagline { color: var(--dim); font-size: 17px; margin: 6px 0 22px; text-wrap: balance; }
#menu { background: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.5) 40%, rgba(0, 0, 0, 0.82) 75%, rgba(0, 0, 0, 0.92)); }
.menu-corner {
  position: absolute; top: calc(14px + env(safe-area-inset-top, 0px)); right: calc(14px + env(safe-area-inset-right, 0px));
  display: flex; gap: 8px; z-index: 1;
}
.diffs { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 12px; }
.btn.diff { min-width: 112px; padding: 9px 14px; font-size: 15px; font-weight: 500; background: rgba(26, 20, 16, 0.85); }
.btn.diff.selected { border-color: var(--blood); background: #2a0c08; color: #fff; }
.diff-info {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 0 auto 20px; max-width: 620px; min-height: 24px;
  font-size: 12px; color: #a99f8f;
}
.diff-info span { white-space: nowrap; padding: 3px 9px; border-radius: 999px; background: rgba(12, 9, 7, 0.7); border: 1px solid rgba(217, 208, 189, 0.14); }
.nw { white-space: nowrap; }
.howto { text-align: left; margin: 18px auto 0; max-width: 620px; font-size: 14px; color: #bdb4a3; }
/* พื้นหลังมืดใต้วิธีเล่น ตัวหนังสือไม่จมไปกับกองไฟและชาวบ้านที่อยู่ข้างหลัง */
.howto[open] ol { background: rgba(8, 6, 5, 0.78); border-radius: 8px; padding: 10px 12px 8px 30px; }
.howto summary { cursor: pointer; text-align: center; color: var(--dim); margin-bottom: 6px; font-size: 13px; }
.howto summary:hover, .howto[open] summary { color: var(--bone); }
.howto li { margin-bottom: 4px; }
.warn { display: flex; align-items: center; justify-content: center; gap: 6px; color: #8f6a5a; font-size: 12px; margin: 10px 0 0; }
.warn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.stats { display: flex; justify-content: center; gap: 26px; margin: 4px 0 26px; flex-wrap: wrap; }

/* ---------- เผาผี 2 ---------- */

.title-row { display: grid; grid-template-columns: 56px auto 56px; align-items: center; justify-content: center; gap: 12px; }
.mode-arrow {
  position: relative; display: grid; place-items: center; width: 48px; height: 48px; padding: 0 0 0 3px;
  font: inherit; font-size: 20px; line-height: 1; color: var(--bone); cursor: pointer;
  background: rgba(20, 14, 10, 0.75); border: 1px solid #5a4632; border-radius: 50%;
}
#mode-prev { grid-column: 1; padding: 0 3px 0 0; }
#mode-next { grid-column: 3; }
.title-row h1 { grid-column: 2; }
.mode-arrow:hover { border-color: var(--ember); color: #fff; }
.mode-arrow.locked { color: #7d7264; }
.mode-arrow.locked::after {
  content: '🔒'; position: absolute; right: -6px; bottom: -6px; font-size: 13px;
  background: #140e0a; border: 1px solid #5a4632; border-radius: 50%; width: 22px; height: 22px; line-height: 21px; padding: 0;
}
.mode-arrow[hidden] { visibility: hidden; display: grid; }
.mode-note { margin: -14px 0 16px; font-size: 14px; color: #e0b07a; min-height: 1.4em; opacity: 0; transition: opacity 0.25s; }
.mode-note.show { opacity: 1; }
#menu.v2 h1 { color: #7fd0c4; text-shadow: 0 0 24px rgba(60, 180, 170, 0.45), 0 5px 0 #000; }
#hud-title.v2 { color: #7fd0c4; }
#hud-omen { font-size: 13px; color: #9fd8d0; min-height: 1em; }
/* ---------- เผาผี 3 ---------- */
#menu.v3 h1 { color: #b9a86a; text-shadow: 0 0 24px rgba(120, 200, 120, 0.35), 0 5px 0 #000; }
#hud-title.v3 { color: #b9a86a; }
/* ชาติของปอบ: เปลวเขียว = ยังไม่คลั่ง, แดง = คลั่ง, แดงสั่นเร็ว = ชาติสุดท้าย */
.gcandles.rage .gcandle::before, .gcandles.last .gcandle::before {
  background: radial-gradient(ellipse at 50% 70%, #fff0e0 0%, #ff4a2a 45%, rgba(255, 40, 20, 0) 75%);
  filter: drop-shadow(0 0 5px rgba(255, 60, 30, 0.8));
}
.gcandles.last .gcandle::before { animation-duration: 0.12s; }
/* ฤๅษีบน HUD: ไอคอนหัวฤๅษี จุดทอง = ตะกรุดยังดี */
#hud-shaman.hermits { display: flex; gap: 6px; justify-content: flex-end; margin-top: 6px; }
.hicon { width: 22px; height: 26px; display: block; }
.hicon svg { width: 100%; height: 100%; overflow: visible; }
.hicon .face { fill: #a98a6c; }
.hicon .hat { fill: #8a6a3c; stroke: #1e140c; stroke-width: 1; }
.hicon .beard { fill: #d6d0c2; }
.hicon .tak { fill: #e0b04a; }
.hicon.cracked .tak { fill: none; stroke: #ff5a4a; stroke-width: 1.4; }
.hicon.dead { opacity: 0.3; filter: grayscale(1); }
/* ไอคอนบนป้ายชื่อ: หยดเลือด = เลือดกำเดา, วงแตก = ตะกรุดแตก */
.vlabel .ico { display: inline-block; width: 7px; height: 9px; margin-left: 5px; vertical-align: -1px; }
.vlabel .ico.mark {
  width: 13px; height: 13px; margin: 0 4px 0 0; border-radius: 50%; vertical-align: 0;
  background: #a8261a; color: #fff; font-style: normal; font-weight: 600; font-size: 10px; line-height: 13px; text-align: center;
}
.vlabel .ico.safe {
  width: 13px; height: 13px; margin: 0 4px 0 0; border-radius: 50%; vertical-align: 0;
  background: #3f6a48; color: #fff; font-style: normal; font-weight: 600; font-size: 9px; line-height: 13px; text-align: center;
}
.vlabel .ico.blood { background: #d0261a; border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%; transform: rotate(180deg); }
.vlabel .ico.crack { width: 9px; height: 5px; border: 1.5px solid #e0b04a; border-radius: 2px; transform: skewX(-20deg); border-right-color: transparent; }
/* ---------- บทสอน ---------- */
#tut { position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, 0.25); }
#tut[hidden] { display: none; }
.tut-card {
  position: absolute; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  width: min(92vw, 520px); background: var(--panel); border: 1px solid #6a5232; border-radius: 8px;
  padding: 16px 20px 10px; text-align: center; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}
#tut.top .tut-card { bottom: auto; top: calc(14px + env(safe-area-inset-top, 0px)); }
#tut-title { font-family: 'Chonburi', serif; font-size: 22px; color: #e8d39a; margin-bottom: 6px; }
#tut-body { font-size: 15px; line-height: 1.6; margin-bottom: 12px; text-wrap: balance; }
#tut-body b { color: #fff; font-weight: 500; }
.tut-skip { margin-top: 8px; background: none; border: 0; color: var(--dim); font: inherit; font-size: 12px; cursor: pointer; text-decoration: underline; }
#tut-ring {
  position: absolute; left: 0; top: 0; width: 120px; height: 120px; border-radius: 50%; pointer-events: none;
  border: 2px solid #e8d39a; box-shadow: 0 0 18px rgba(232, 211, 154, 0.6), inset 0 0 18px rgba(232, 211, 154, 0.35);
  animation: tut-pulse 1.4s ease-in-out infinite;
}
#tut-ring[hidden] { display: none; }
@keyframes tut-pulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }
.tut-focus { outline: 2px solid #e8d39a; outline-offset: 4px; border-radius: 6px; box-shadow: 0 0 18px rgba(232, 211, 154, 0.6); position: relative; z-index: 36; }
@media (max-width: 600px), (max-height: 500px) {
  #tut-title { font-size: 18px; }
  #tut-body { font-size: 13px; margin-bottom: 8px; }
  .tut-card { padding: 12px 14px 8px; }
}
.vlabel.hermit { color: #e8d39a; background: rgba(40, 30, 10, 0.7); }
.vlabel.hermit b { color: #f3e3b0; }
/* ตัวช่วยระดับ Normal: ป้ายส้ม = ยังอาจเป็นร่างของปอบ, ป้ายจาง = พ้นสงสัยแล้ว */
.vlabel.sus { outline: 1px solid #e0782e; background: rgba(80, 34, 8, 0.8); }
.vlabel.cleared { opacity: 0.5; }
.stats .perfect b { color: #e8c88a; }
.hud-btns { display: flex; gap: 8px; margin-top: 8px; }
/* ปุ่มไอคอนเล็กบน HUD: ลำโพง = เสียง, กระดาษโน้ต = บันทึก */
.hud-icon {
  pointer-events: auto; touch-action: manipulation; cursor: pointer;
  width: 36px; height: 36px; padding: 0; display: grid; place-items: center;
  color: var(--bone); background: rgba(10, 8, 6, 0.55);
  border: 1px solid rgba(217, 208, 189, 0.22); border-radius: 8px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.hud-icon[hidden] { display: none; }
.hud-icon:hover { color: #fff; background: rgba(42, 29, 20, 0.85); border-color: var(--ember); }
.hud-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#hud-mark { display: none; position: relative; }
#hud-mark .q { stroke-width: 1.5; }
#hud-mark.on { color: #fff; background: #6a1d12; border-color: #e0782e; }
#hud-mark .mark-tip {
  display: none; position: absolute; left: calc(100% + 8px); top: 50%; transform: translateY(-50%);
  white-space: nowrap; font-size: 12px; color: #ffe2c0; padding: 4px 9px; border-radius: 6px; background: rgba(60, 20, 10, 0.88);
}
#hud-mark.on .mark-tip { display: block; }
@media (pointer: coarse) { #hud-mark { display: grid; } }
/* ---------- ตั้งค่า ---------- */
#settings { z-index: 47; background: rgba(6, 4, 3, 0.95); }
.set-head {
  max-width: 460px; margin: 18px auto 10px; font-size: 13px; font-weight: 400; color: var(--dim); text-align: left;
  padding-bottom: 6px; border-bottom: 1px solid #2c221a;
}
.set-list { display: flex; flex-direction: column; gap: 4px; max-width: 460px; margin: 0 auto 8px; text-align: left; }
.set-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 14px; padding: 8px 0; cursor: pointer; }
.set-row b { display: block; font-weight: 400; font-size: 15px; color: var(--bone); }
.set-row small { display: block; font-size: 12px; color: var(--dim); margin-top: 1px; }
.set-row.locked { cursor: default; }
.set-row.locked b { color: var(--dim); }
.switch {
  appearance: none; -webkit-appearance: none; margin: 0; position: relative; cursor: pointer;
  width: 46px; height: 26px; border-radius: 13px; background: #211913; border: 1px solid #5a4632; transition: background 0.15s, border-color 0.15s;
}
.switch::after {
  content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #8f877a; transition: transform 0.15s, background 0.15s;
}
.switch:checked { background: #5a1d12; border-color: var(--ember); }
.switch:checked::after { transform: translateX(20px); background: #f0d7a8; }
.switch:disabled { opacity: 0.35; cursor: default; }
.switch:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; }
#settings .btn { margin-top: 18px; }
.sound-list { display: flex; flex-direction: column; gap: 16px; max-width: 460px; margin: 6px auto 10px; text-align: left; }
.sound-list label { display: grid; grid-template-columns: 9.5em 1fr 3em; align-items: center; gap: 12px; font-size: 15px; color: var(--bone); }
.sound-list input[type='range'] { width: 100%; accent-color: var(--ember); }
.sound-list b { font-weight: 400; color: var(--dim); text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 600px) {
  .sound-list label { grid-template-columns: 1fr 3em; }
  .sound-list label span { grid-column: 1 / -1; }
}
.deaths { display: flex; gap: 3px; justify-content: flex-end; margin-top: 4px; font-size: 15px; }
.deaths[hidden] { display: none; }
.dmark { color: #e2d8c6; opacity: 0.5; text-shadow: 0 1px 3px #000; }
.dmark.dead { color: #ff4a3a; opacity: 1; text-shadow: 0 0 6px rgba(255, 60, 40, 0.6), 0 1px 3px #000; }
.badge.water { background: #12302e; color: #9fe0d6; }
.vlabel .say { display: block; font-size: 12px; color: #ffe9b0; background: rgba(10, 8, 6, 0.85); padding: 2px 6px; border-radius: 4px; margin-bottom: 2px; white-space: nowrap; }
.log-list { list-style: none; text-align: left; max-width: 620px; margin: 0 auto 16px; padding: 0; font-size: 14px; color: #d6cdbd; }
.log-list li { padding: 4px 8px; border-bottom: 1px solid #241b14; }
.log-list .logday { color: #e8c88a; font-weight: 500; margin-top: 8px; border-bottom-color: #4a3a2a; }
#log { z-index: 46; background: #060403; }
.unlock { color: #7fd0c4; }
.small { font-size: 14px; }

/* ---------- บันทึกคะแนน / อันดับ ---------- */

.stats .score b { color: #e8c88a; }
.save { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 0 auto 22px; max-width: 420px; }
.save[hidden] { display: none; }
.save label { font-size: 15px; color: var(--bone); }
.btn.small { font-size: 14px; padding: 6px 14px; }
#board { z-index: 45; background: #060403; }
.board-title { font-family: 'Chonburi', serif; font-weight: 400; font-size: 44px; margin: 0 0 12px; color: #e8c88a; }
.tabs { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-bottom: 14px; }
.tabs .btn.selected { border-color: var(--blood); background: #2a0c08; }
.board-list { list-style: none; margin: 0 auto 10px; padding: 0; max-width: 620px; text-align: left; }
.board-list li {
  display: grid; grid-template-columns: 2.4em 1fr auto 3em 5.5em; gap: 10px; align-items: baseline;
  padding: 7px 10px; border-bottom: 1px solid #2c221a; font-size: 15px;
}
.board-list li:nth-child(-n+3) .rank { color: #e8c88a; font-weight: 500; }
.board-list li.me { background: #2a0c08; }
.board-list .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; }
.board-list .diff, .board-list .res { color: var(--dim); font-size: 13px; white-space: nowrap; }
.board-list .pts { text-align: right; color: #e8c88a; font-variant-numeric: tabular-nums; }
@media (max-width: 600px) {
  .board-list li { grid-template-columns: 2em 1fr auto 4.6em; gap: 8px; font-size: 14px; }
  .board-list .res { display: none; }
}

/* ---------- ใบประกาศตอนชนะ ---------- */

.cert { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 0 auto 22px; max-width: 420px; }
.cert[hidden] { display: none; }
.cert label { font-size: 15px; color: var(--bone); }
.save input,
.cert input {
  width: 100%; font: inherit; font-size: 18px; text-align: center; color: var(--bone);
  background: #120d0a; border: 1px solid #5a4632; border-radius: 4px; padding: 10px 12px;
  user-select: text; -webkit-user-select: text;
}
.save input:focus,
.cert input:focus { outline: none; border-color: var(--ember); }
.cert img { width: min(100%, 340px); height: auto; aspect-ratio: 4 / 5; max-width: 100%; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.7); }
.cert-tip, .cert-note { margin: 0; font-size: 12px; color: var(--dim); min-height: 1em; }
.stats div { display: flex; flex-direction: column; }
.stats b { font-size: 30px; font-weight: 500; color: #fff; }
.stats span { font-size: 13px; color: var(--dim); }

/* ---------- จอเล็ก: มือถือแนวตั้ง / แนวนอน ---------- */

@media (max-width: 600px), (max-height: 500px) {
  #hud-title { font-size: 18px; }
  #hud-day, #hud-right { font-size: 12px; }
  .hud-icon { width: 32px; height: 32px; }
  .hud-icon svg { width: 18px; height: 18px; }
  .lives { height: 26px; gap: 6px; }
  .life { width: 7px; height: 15px; }
  .life.out { height: 10px; }
  .life::before { top: -9px; width: 7px; height: 9px; }
  .gcandles { height: 26px; gap: 6px; }
  .gcandle { width: 7px; height: 15px; }
  .gcandle.out { height: 9px; }
  .gcandle::before { top: -10px; width: 7px; height: 10px; }
  #hud-hint { font-size: 13px; }
  #hud-bottom { gap: 8px; }
  .btn { font-size: 15px; padding: 9px 18px; }
  .btn.big { font-size: 18px; padding: 11px 32px; }
  #toast { font-size: 17px; top: 18%; }
  #modal-text { font-size: 18px; }
  .vlabel { font-size: 11px; padding: 0 4px; }
  .vlabel.alt { margin-top: -16px; }
  .vlabel.alt2 { margin-top: -32px; }
  .hlabel { font-size: 12px; }
  .hlabel .badge { font-size: 11px; }
  .tagline { font-size: 15px; margin-bottom: 16px; }
  .btn.diff { min-width: 96px; font-size: 14px; padding: 8px 10px; }
  .diff-info { font-size: 11px; gap: 5px; }
  #hud-hint { font-size: 13px; padding: 4px 12px; }
  #hud-right { padding: 14px 6px 6px; }
  .howto { font-size: 13px; }
  .stats { gap: 18px; }
  .stats b { font-size: 24px; }
}

/* มือถือแนวนอน: ความสูงน้อย บีบหัวข้อกับระยะห่าง */
@media (max-height: 500px) {
  h1 { font-size: 46px; }
  .tagline { margin: 2px 0 10px; }
  .diffs { flex-wrap: nowrap; gap: 6px; margin-bottom: 8px; }
  .btn.diff { min-width: 0; padding: 6px 10px; }
  .diff-info { margin-bottom: 10px; }
  .howto { margin-top: 10px; }
  .warn { margin: 6px 0 0; }
  #hud-bottom { bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
  #toast { top: 12%; }
}

/* ---------- เผาผี 4: HUD ---------- */
#menu.v4 h1 { color: #9db0b8; text-shadow: 0 0 24px rgba(120, 160, 190, 0.35), 0 5px 0 #000; }
#hud-title.v4 { color: #9db0b8; }
#hud-clock { font-size: 13px; color: #b9c4cc; min-height: 1em; font-variant-numeric: tabular-nums; }
.q-dots { display: flex; gap: 5px; justify-content: flex-end; margin-top: 6px; }
.q-dots[hidden] { display: none; }
.q-dot { width: 20px; height: 18px; display: block; }
.q-dot path { fill: #e8d39a; }
.q-dot.used path { fill: none; stroke: #5f584e; stroke-width: 1.4; }
.vac { display: flex; gap: 4px; justify-content: flex-end; margin-top: 6px; }
.vac[hidden] { display: none; }
.vac i { width: 12px; height: 14px; border-radius: 2px; background: #f0b25e; box-shadow: 0 0 6px rgba(240, 170, 90, 0.6), inset 0 0 0 1px rgba(0, 0, 0, 0.3); }
.vac i.out { background: #20232a; box-shadow: inset 0 0 0 1px #3a3e46; }
/* เผาผี 4: ตอนเย็นแตะที่ตึก ดูว่าห้องนั้นมีใครอยู่ */
.rpop {
  position: absolute; left: 0; top: 0; padding: 7px 11px 8px; border-radius: 10px;
  background: rgba(14, 12, 10, 0.86); border: 1px solid rgba(232, 200, 138, 0.16); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  color: var(--bone); font-size: 13px; line-height: 1.3; white-space: nowrap; will-change: transform;
}
.rpop > b { display: block; font-size: 11px; font-weight: 500; color: var(--dim); margin-bottom: 5px; }
.rp-who { display: flex; align-items: center; gap: 7px; }
.rp-who + .rp-who { margin-top: 5px; }
.rp-who .badge4 { width: 20px; height: 20px; font-size: 11px; }
.rp-none { color: var(--dim); font-size: 12px; }
.badge4 { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; flex: none; font-family: 'Chonburi', serif; font-size: 13px; color: #f1e6cf; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12); }

/* ---------- เผาผี 4: หน้าคุยกับผู้เช่า (ซ้ายตัวละคร ขวาบทสนทนา) ---------- */
#talk4 { position: fixed; inset: 0; z-index: 32; display: grid; grid-template-columns: minmax(260px, 40%) 1fr; align-items: center;
  background: radial-gradient(ellipse at 28% 60%, rgba(40, 26, 14, 0.35), rgba(3, 2, 2, 0.88) 70%); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  opacity: 0; transition: opacity 0.25s; }
#talk4.show { opacity: 1; }
#talk4[hidden] { display: none; }
.tk-fig { position: relative; height: 100%; }
#tk-portrait { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
.tk-fig::after { content: ''; position: absolute; left: 18%; right: 18%; bottom: 9%; height: 26px; border-radius: 50%; background: radial-gradient(ellipse, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0) 70%); }
.tk-panel { position: relative; width: min(100%, 560px); margin: 0 auto 0 0; padding: 22px 24px 18px; border-radius: 14px;
  background: linear-gradient(180deg, rgba(24, 18, 13, 0.97), rgba(13, 10, 8, 0.97)); border: 1px solid #3c2f23; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  transform: translateX(16px); transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.25, 1); }
#talk4.show .tk-panel { transform: none; }
.tk-head { display: flex; align-items: flex-start; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid #2a2119; }
.tk-name { font-family: 'Chonburi', serif; font-size: 30px; line-height: 1.1; color: #e8d39a; }
.tk-meta { font-size: 13px; color: var(--dim); margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; }
.tk-meta span { padding: 1px 8px; border-radius: 999px; border: 1px solid #2a2119; background: rgba(0, 0, 0, 0.25); }
.tk-tools { margin-left: auto; display: flex; gap: 6px; }
.tk-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; border: 1px solid #3c2f23; background: rgba(0, 0, 0, 0.3); color: var(--dim); cursor: pointer; transition: color 0.15s, border-color 0.15s, background 0.15s; }
.tk-icon:hover { color: #fff; border-color: var(--ember); }
.tk-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tk-icon.on { color: #fff; background: #6a1d12; border-color: var(--ember); }
.tk-icon.safe.on { background: #2f5238; border-color: #6a9a72; }
/* ลูกศรเลื่อนไปคุยคนก่อน/ถัดไป อยู่สองข้างตัวละคร */
.tk-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid #3c2f23; background: rgba(12, 9, 7, 0.72); color: var(--bone); cursor: pointer; transition: border-color 0.15s, color 0.15s; }
.tk-nav:hover { border-color: var(--ember); color: #fff; }
.tk-nav svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#tk-prev { left: 14px; }
#tk-next { right: 14px; }
/* คำในคำตอบที่กดไปคุยกับคนนั้นได้ */
.tk-ref { color: #e8d39a; text-decoration: underline dotted; text-underline-offset: 3px; cursor: pointer; }
.tk-ref:hover { color: #fff; }
.tk-pick-h { width: 100%; font-size: 12px; color: var(--dim); margin-bottom: 2px; }
.tk-who small { color: var(--dim); font-size: 11px; margin-left: 2px; }
.tk-log { min-height: 110px; max-height: min(40vh, 340px); overflow-y: auto; padding: 14px 2px 6px; display: flex; flex-direction: column; gap: 12px; scrollbar-width: thin; scrollbar-color: #3c2f23 transparent; }
.tk-greet { color: #5f584e; font-size: 14px; }
.tk-ask { align-self: flex-end; max-width: 85%; font-size: 13px; color: #b7ac98; padding: 5px 12px; border-radius: 12px 12px 3px 12px; background: #231a12; border: 1px solid #2a2119; }
.tk-say { position: relative; font-size: 18px; line-height: 1.55; padding-left: 14px; color: var(--bone); }
.tk-say::before { content: ''; position: absolute; left: 0; top: 0.3em; bottom: 0.3em; width: 3px; border-radius: 2px; background: #6a5232; }
.tk-say.typing::after { content: '▍'; color: var(--dim); animation: tk-blink 0.8s steps(1) infinite; }
@keyframes tk-blink { 50% { opacity: 0; } }
.tk-choices { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.tk-choice { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 11px 14px; border-radius: 10px; border: 1px solid #3c2f23; background: #1a130e; cursor: pointer; font: inherit; font-size: 15px; color: var(--bone); transition: border-color 0.15s, background 0.15s, transform 0.1s; }
.tk-choice:hover:not(:disabled) { border-color: var(--ember); background: #24180f; }
.tk-choice:active:not(:disabled) { transform: scale(0.99); }
.tk-choice:disabled { opacity: 0.38; cursor: default; }
.tk-choice svg { flex: none; width: 20px; height: 20px; fill: none; stroke: #c9a46a; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tk-choice .done { margin-left: auto; font-size: 12px; color: #5f584e; }
.tk-pick { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; border-radius: 10px; border: 1px solid #2a2119; background: rgba(0, 0, 0, 0.25); max-height: 150px; overflow-y: auto; }
.tk-pick[hidden] { display: none; }
.tk-who { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 999px; background: rgba(12, 9, 7, 0.82); border: 1px solid #3c2f23; cursor: pointer; font: inherit; font-size: 13px; color: var(--bone); }
.tk-who:hover:not(:disabled) { border-color: var(--ember); }
.tk-who:disabled { opacity: 0.35; cursor: default; }
.tk-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; font-size: 12px; color: #5f584e; gap: 8px; }
.tk-quota { display: flex; gap: 4px; align-items: center; }
@media (max-width: 760px) {
  /* แผงคุยสูงตามเนื้อหาแต่ไม่ล้นจอ ตัวละครด้านบนหดให้แทน · ส่วนที่ยุบได้คือบทสนทนา (เลื่อนดูได้) */
  #talk4 { grid-template-columns: 1fr; grid-template-rows: minmax(90px, 1fr) auto; align-items: stretch; }
  .tk-fig::after { bottom: 4%; }
  .tk-panel { width: 100%; margin: 0; border-radius: 18px 18px 0 0; padding: 16px 16px calc(14px + env(safe-area-inset-bottom, 0px)); align-self: end; transform: translateY(20px);
    display: flex; flex-direction: column; max-height: calc(100vh - 90px); max-height: calc(100dvh - 90px); }
  .tk-panel > * { flex: none; }
  .tk-name { font-size: 24px; }
  .tk-say { font-size: 16px; }
  .tk-panel > .tk-log { flex: 0 1 auto; min-height: 56px; max-height: 30vh; }
  .tk-pick { max-height: 120px; }
}

/* ---------- เผาผี 4: มือถือ (คอม = กลางจอ · มือถือ = เต็มจอ ไม่มี UI อื่น) ---------- */
#phone4 { position: fixed; inset: 0; z-index: 34; display: grid; place-items: center; background: rgba(2, 2, 2, 0.72); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); opacity: 0; transition: opacity 0.3s; color: #e9e2d4; }
#phone4.show { opacity: 1; }
#phone4[hidden] { display: none; }
#phone4 button { font: inherit; color: inherit; touch-action: manipulation; }
.ph-device { position: relative; width: 372px; height: 780px; max-height: 94vh; aspect-ratio: 372 / 780; padding: 12px; border-radius: 54px;
  background: linear-gradient(145deg, #2a2a2c, #0c0c0d 40%, #1b1b1d); box-shadow: 0 0 0 1px #3a3a3e inset, 0 30px 80px rgba(0, 0, 0, 0.8);
  transform: translateY(70vh) rotate(4deg); transition: transform 0.45s cubic-bezier(0.2, 0.9, 0.25, 1); }
#phone4.show .ph-device { transform: none; }
.ph-power { position: absolute; right: -4px; top: 190px; width: 5px; height: 78px; border-radius: 0 4px 4px 0; background: #2e2e31; border: 0; padding: 0; cursor: pointer; box-shadow: 1px 0 0 #444 inset; }
.ph-power:hover { background: #4a3a2a; }
.ph-screen { position: relative; width: 100%; height: 100%; border-radius: 42px; overflow: hidden; background: #0b0a09; }
.ph-screen.off::after { content: ''; position: absolute; inset: 0; background: #000; z-index: 50; animation: ph-off 0.3s forwards; }
@keyframes ph-off { from { opacity: 0; } to { opacity: 1; } }
.ph-island { position: absolute; left: 50%; top: 11px; transform: translateX(-50%); width: 104px; height: 30px; border-radius: 20px; background: #000; z-index: 40; }
.ph-status { position: absolute; left: 0; right: 0; top: 0; height: 50px; display: flex; align-items: center; justify-content: space-between; padding: 6px 30px 0; font-size: 14px; font-weight: 500; z-index: 30; }
.ph-status .r { display: flex; gap: 6px; align-items: center; font-size: 12px; }
.ph-status svg { width: 17px; height: 12px; }
.ph-pwr { display: none; }
.ph-homebar { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); width: 120px; height: 5px; border-radius: 3px; background: rgba(233, 226, 212, 0.55); z-index: 30; border: 0; padding: 0; cursor: pointer; }
.ph-app { position: absolute; inset: 0; padding-top: 50px; display: flex; flex-direction: column; }
.ph-app[hidden] { display: none; }
#ph-home { background: radial-gradient(ellipse at 50% 0%, #1d2a33 0%, #0d1216 45%, #070606 100%), #070606; }
#ph-home::before { content: ''; position: absolute; left: -20%; right: -20%; bottom: -10%; height: 55%; background: radial-gradient(ellipse at 50% 100%, rgba(176, 134, 74, 0.16), rgba(176, 134, 74, 0) 65%); pointer-events: none; }
.ph-clock { text-align: center; margin-top: 28px; }
.ph-clock b { display: block; font-size: 76px; font-weight: 300; letter-spacing: 1px; color: #efe7d6; line-height: 1; }
.ph-clock span { font-size: 15px; color: #b7b0a2; }
.ph-widget { margin: 22px 22px 0; padding: 14px 16px; border-radius: 20px; background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.06); display: flex; align-items: center; gap: 14px; }
.ph-widget svg { width: 34px; height: 34px; fill: none; stroke: #9db0b8; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.ph-widget b { display: block; font-weight: 400; font-size: 15px; }
.ph-widget span { font-size: 12px; color: #9a9384; }
.ph-notif { margin: 12px 14px 0; padding: 10px 14px; border-radius: 18px; background: rgba(20, 30, 24, 0.9); border: 1px solid rgba(120, 170, 130, 0.25); display: flex; gap: 10px; align-items: center; font-size: 13px; animation: ph-drop 0.35s cubic-bezier(0.2, 0.9, 0.25, 1); }
.ph-notif[hidden] { display: none; }
@keyframes ph-drop { from { transform: translateY(-20px); opacity: 0; } }
.ph-dock { position: absolute; left: 14px; right: 14px; bottom: 28px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 16px 10px 12px; border-radius: 30px; background: rgba(255, 255, 255, 0.07); }
.ph-ic { display: flex; flex-direction: column; align-items: center; gap: 6px; background: none; border: 0; cursor: pointer; font-size: 12px; color: #ddd5c6; }
.ph-ic i { width: 60px; height: 60px; border-radius: 17px; display: grid; place-items: center; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 6px 14px rgba(0, 0, 0, 0.4); transition: transform 0.12s; }
.ph-ic:active i { transform: scale(0.92); }
.ph-ic i svg { width: 30px; height: 30px; fill: none; stroke: #f3ecdf; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ph-ic .call { background: linear-gradient(160deg, #4f7a58, #2d4a34); }
.ph-ic .note { background: linear-gradient(160deg, #b8964c, #7a5f2a); }
.ph-ic .dino { background: linear-gradient(160deg, #5d5e5a, #2e2f2c); }
.ph-bar { display: flex; align-items: center; gap: 6px; padding: 8px 14px 10px; font-size: 17px; font-weight: 500; }
.ph-bar[hidden] { display: none; }
.ph-back { background: none; border: 0; color: #c9a46a; font-size: 16px; padding: 4px 6px; cursor: pointer; display: flex; align-items: center; gap: 2px; }
.ph-back svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ph-scroll { flex: 1; overflow-y: auto; padding: 0 16px 40px; scrollbar-width: none; }
.ph-scroll::-webkit-scrollbar { display: none; }
#ph-notes { background: #12100d; }
.ph-seg { display: flex; margin: 0 16px 12px; padding: 3px; border-radius: 10px; background: #1f1b16; }
.ph-seg button { flex: 1; border: 0; background: none; padding: 6px; border-radius: 8px; font-size: 13px; color: #9a9384; cursor: pointer; }
.ph-seg button.on { background: #3a3126; color: #f0e8d8; }
.ph-day { font-size: 13px; color: #c9a46a; margin: 16px 2px 8px; display: flex; justify-content: space-between; }
.ph-item { padding: 10px 12px; border-radius: 12px; background: #1b1814; margin-bottom: 8px; }
.ph-who { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; }
.ph-who small { color: #8b8476; font-weight: 300; }
.ph-q { font-size: 11px; color: #8b8476; margin: 5px 0 2px; }
.ph-a { font-size: 14px; line-height: 1.5; color: #e5dccb; }
.ph-news { font-size: 13px; line-height: 1.5; color: #c9bfae; padding: 8px 12px; border-left: 3px solid #6a3a2c; background: #1a1512; border-radius: 0 10px 10px 0; margin-bottom: 8px; }
.ph-mark { width: 15px; height: 15px; border-radius: 50%; background: #a8261a; color: #fff; font-size: 10px; display: inline-grid; place-items: center; font-weight: 600; }
.ph-mark.safe { background: #3f6a48; }
.ph-widget[hidden] { display: none; }
/* ตอนเช้ากดโทร: ความคิดของเราเอง (ยังไม่มีเหตุผลให้โทร) */
.ph-think { margin: 18px 20px 0; padding: 10px 14px; border-radius: 14px; background: rgba(255, 255, 255, 0.07); color: #d8d1c2; font-size: 14px; line-height: 1.5; font-style: italic; animation: ph-pop 0.25s ease-out; }
.ph-person { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border-radius: 12px; background: #1b1814; margin-bottom: 6px; border: 0; cursor: pointer; text-align: left; }
.ph-person .cnt { margin-left: auto; font-size: 12px; color: #8b8476; }
.ph-empty { color: #6f685d; font-size: 13px; text-align: center; margin-top: 40px; }
#ph-call { background: linear-gradient(180deg, #121a15, #0b0d0c); }
.ph-contact { margin: 20px 16px; padding: 18px; border-radius: 20px; background: #18211b; display: flex; align-items: center; gap: 14px; }
.ph-shield { width: 54px; height: 54px; border-radius: 50%; background: #233a5a; display: grid; place-items: center; flex: none; }
.ph-shield svg { width: 28px; height: 28px; fill: none; stroke: #d9e3f0; stroke-width: 1.6; stroke-linejoin: round; }
.ph-contact b { display: block; font-weight: 500; font-size: 17px; }
.ph-contact span { font-size: 13px; color: #8fa596; }
.ph-dial { margin-left: auto; width: 50px; height: 50px; border-radius: 50%; border: 0; background: #3f8a52; display: grid; place-items: center; cursor: pointer; }
.ph-dial svg, .ph-hang svg { width: 24px; height: 24px; fill: #fff; }
.ph-dial:disabled { background: #2c3a30; cursor: default; }
.ph-note { margin: 0 20px; font-size: 12px; color: #6f7f73; line-height: 1.6; }
.ph-incall { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 22px 16px 26px; min-height: 0; }
.ph-incall .ph-shield { width: 84px; height: 84px; margin-top: 6px; }
.ph-incall .ph-shield svg { width: 40px; height: 40px; }
.ph-incall h3 { margin: 12px 0 2px; font-weight: 400; font-size: 22px; }
.ph-timer { font-size: 13px; color: #8fa596; }
.ph-talk { width: 100%; flex: 1; margin-top: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; scrollbar-width: none; min-height: 60px; }
.ph-op { align-self: flex-start; max-width: 86%; padding: 8px 12px; border-radius: 14px 14px 14px 4px; background: #1f2b23; font-size: 14px; line-height: 1.5; animation: ph-pop 0.25s ease-out; }
.ph-me { align-self: flex-end; max-width: 86%; padding: 8px 12px; border-radius: 14px 14px 4px 14px; background: #3a3126; font-size: 14px; animation: ph-pop 0.25s ease-out; }
@keyframes ph-pop { from { transform: translateY(6px); opacity: 0; } }
.ph-opts { width: 100%; display: flex; flex-direction: column; gap: 8px; margin-top: 10px; max-height: 50%; overflow-y: auto; scrollbar-width: none; }
.ph-opt { width: 100%; text-align: left; padding: 12px 14px; border-radius: 14px; border: 1px solid #2c3a30; background: #16201a; cursor: pointer; }
.ph-opt b { display: block; font-weight: 500; font-size: 15px; }
.ph-opt span { font-size: 12px; color: #8fa596; }
.ph-opt:hover { border-color: #5a8a66; }
.ph-opt.warn span { color: #c98a6a; }
.ph-hang { width: 64px; height: 64px; border-radius: 50%; border: 0; background: #b0392b; display: grid; place-items: center; cursor: pointer; margin-top: 14px; flex: none; }
.ph-hang svg { transform: rotate(135deg); }
.ph-opts.map { max-height: 72%; }
.ph-incall.map .ph-shield { display: none; }
.ph-incall.map h3 { margin-top: 0; font-size: 18px; }
.ph-rooms { width: 100%; display: grid; gap: 5px; }
.ph-room { min-width: 0; padding: 5px 3px 6px; border-radius: 10px; border: 1px solid #2c3a30; background: #16201a; cursor: pointer; line-height: 1.2;
  display: flex; flex-direction: column; align-items: center; gap: 2px; }
.ph-room b { font-size: 12px; font-weight: 500; white-space: nowrap; }
.ph-rn { display: flex; align-items: center; justify-content: center; gap: 2px; max-width: 100%; color: #8fa596; font-size: 10px; white-space: nowrap; overflow: hidden; }
.ph-rn.none { color: #5f7064; }
.ph-rn .ph-mark { width: 11px; height: 11px; font-size: 8px; flex: none; }
.ph-room:hover { border-color: #5a8a66; }
.ph-park { border-radius: 10px; background: #18241a; display: grid; place-items: center; font-size: 10px; color: #6f8a73; }
.ph-plist { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.ph-pitem { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 12px; border: 1px solid #2c3a30; background: #16201a; cursor: pointer; text-align: left; font-size: 14px; }
.ph-pitem small { color: #8fa596; font-size: 11px; margin-left: auto; }
#ph-dino { background: #ece6d8; color: #2a2723; }
.ph-screen.light .ph-status { color: #2a2723; }
.ph-screen.light .ph-status svg rect { fill: #2a2723; stroke: #2a2723; }
.ph-screen.light .ph-homebar { background: rgba(42, 39, 35, 0.45); }
#ph-dino .ph-back { color: #6a5232; }
#ph-dino canvas { width: 100%; flex: 1; image-rendering: pixelated; cursor: pointer; touch-action: manipulation; }
.ph-dhint { text-align: center; font-size: 13px; color: #6f685d; padding: 0 0 46px; }
@media (max-width: 600px), (pointer: coarse) and (max-height: 600px) {
  #phone4 { background: #000; backdrop-filter: none; }
  .ph-device { width: 100vw; height: 100dvh; max-height: none; aspect-ratio: auto; padding: 0; border-radius: 0; background: #000; box-shadow: none; transform: translateY(100%); }
  .ph-screen { border-radius: 0; }
  .ph-power, .ph-island { display: none; }
  .ph-pwr { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, 0.1); cursor: pointer; }
  .ph-pwr svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
  .ph-status { padding: calc(6px + env(safe-area-inset-top, 0px)) 18px 0; height: calc(50px + env(safe-area-inset-top, 0px)); }
  .ph-app { padding-top: calc(50px + env(safe-area-inset-top, 0px)); }
}
