/* Voice lounge page — AGENT-T4 — #/lounge (ตามเดโม่ voice-room-themed)
 * prefix .lg- ทั้งหมด / ธีมบรรยากาศ scoped ในหน้า (คลาส + ตัวแปรบน .lg-root เท่านั้น) */

.lg-root{position:relative;--lg-glow:rgba(96,165,250,.55)}
.lg-layers{position:absolute;inset:0;z-index:0;pointer-events:none}
.lg-layer{position:absolute;inset:0;opacity:0;transition:opacity .6s ease}
.lg-layer.on{opacity:1}
.lg-l-read{background:radial-gradient(120% 80% at 50% 0%,#eaf4ff 0%,#cfe4f9 60%,#b9d4f0 100%)}
.lg-l-karaoke{background:radial-gradient(120% 80% at 50% 0%,#fde6f7 0%,#e9c9f0 55%,#cfa8e6 100%)}
.lg-l-sleep{background:radial-gradient(120% 80% at 50% 0%,#24395f 0%,#142748 55%,#0a1830 100%)}
.lg-l-murder{background:radial-gradient(120% 80% at 50% 0%,#501a2c 0%,#330f1d 55%,#1a0710 100%)}

.lg-content{position:relative;z-index:1;flex:1;display:flex;flex-direction:column;gap:12px;
  padding:0 14px calc(122px + env(safe-area-inset-bottom))}
.lg-title{font-size:16px;font-weight:700;line-height:1.2;color:var(--card-ink)}
.lg-sub{font-size:11px;color:var(--card-ink-dim);margin-top:2px}
/* ธีมมืด (นอนหลับ/ฆาตกรรม): ตัวอักษรบนพื้นหลังต้องสว่าง */
.lg-root.lg-t-sleep .lg-title,.lg-root.lg-t-murder .lg-title{color:#eaf3ff}
.lg-root.lg-t-sleep .lg-sub,.lg-root.lg-t-murder .lg-sub{color:#9db4d6}
.lg-root.lg-t-sleep .top-bar .icon-btn,.lg-root.lg-t-murder .top-bar .icon-btn{
  color:#eaf3ff;background:rgba(255,255,255,.12);border-color:rgba(160,200,255,.3)}

.lg-card{border-radius:24px;padding:14px}
.lg-root .lg-card{background:var(--card-glass);border:1px solid var(--card-brd);
  backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);
  box-shadow:0 6px 20px rgba(80,140,220,.15)}
.lg-root.lg-t-sleep .lg-card,.lg-root.lg-t-murder .lg-card{
  background:rgba(255,255,255,.86);box-shadow:0 8px 24px rgba(0,0,0,.35)}
.lg-h{font-size:14px;font-weight:700;color:var(--card-ink)}

/* ---------- ชิปธีม 4 อัน ---------- */
.lg-chips{display:flex;gap:8px}
.lg-chip{flex:1;min-width:0;display:flex;flex-direction:column;align-items:center;gap:3px;
  padding:8px 2px;border-radius:14px;font-size:11px;font-weight:600;line-height:1.2;
  color:var(--card-ink);background:var(--card-glass);border:1px solid var(--card-brd);
  backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);
  box-shadow:0 4px 14px rgba(80,140,220,.14);
  transition:transform .15s, background .3s, color .3s, box-shadow .3s, border-color .3s}
.lg-chip:active{transform:scale(.94)}
.lg-chip .lg-chip-emo{font-size:16px;line-height:1}
.lg-chip span:last-child{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}
.lg-chip.active{color:#fff;background:linear-gradient(to right,#34d399,#4ade80);
  border-color:rgba(167,243,208,.6);box-shadow:0 0 18px rgba(74,222,128,.45)}

/* ---------- กริดไมค์ 3x3 ---------- */
.lg-grid-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}
.lg-openmic{padding:6px 14px;border-radius:var(--r-pill);font-size:11.5px;font-weight:700;
  color:#064e3b;background:linear-gradient(to right,#6ee7a0,#4ade80);
  box-shadow:0 0 16px rgba(74,222,128,.45);transition:transform .12s}
.lg-openmic:active{transform:scale(.95)}
.lg-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:14px 8px}
.lg-seat{display:flex;flex-direction:column;align-items:center;gap:6px;min-width:0}
.lg-seat-av{position:relative}
.lg-seat .avatar{box-shadow:0 0 16px 2px var(--lg-glow);transition:box-shadow .6s ease}
.lg-crown{position:absolute;top:-8px;right:-4px;font-size:15px;
  filter:drop-shadow(0 1px 2px rgba(0,0,0,.3))}
@keyframes lgBreathe{
  0%,100%{box-shadow:0 0 0 3px rgba(74,222,128,.85), 0 0 14px 4px rgba(74,222,128,.45)}
  50%{box-shadow:0 0 0 5px rgba(74,222,128,.55), 0 0 26px 10px rgba(74,222,128,.65)}
}
.lg-seat.speaking .avatar{animation:lgBreathe 1.8s ease-in-out infinite}
.lg-seat-name{font-size:11.5px;font-weight:600;color:var(--card-ink);max-width:100%;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.lg-seat-empty{width:56px;height:56px;border-radius:50%;
  border:2px dashed rgba(125,146,173,.5);background:rgba(255,255,255,.3);
  display:flex;align-items:center;justify-content:center}
.lg-seat-empty svg{width:20px;height:20px;stroke:#7d92ad;fill:none;stroke-width:2;stroke-linecap:round}
.lg-seat-name.empty{color:var(--card-ink-dim);font-weight:400}

/* ---------- การ์ด 4 ทางเข้า ---------- */
.lg-fns{display:grid;grid-template-columns:repeat(4,1fr);padding:12px 4px}
.lg-fn{display:flex;flex-direction:column;align-items:center;gap:6px;transition:transform .15s}
.lg-fn:active{transform:scale(.92)}
.lg-fn-ico{width:44px;height:44px;border-radius:50%;background:rgba(209,250,229,.8);
  box-shadow:0 0 16px rgba(74,222,128,.35);display:flex;align-items:center;justify-content:center}
.lg-fn-ico svg{width:20px;height:20px;stroke:#059669;fill:none;stroke-width:2;
  stroke-linecap:round;stroke-linejoin:round}
.lg-fn span:last-child{font-size:10.5px;font-weight:500;color:var(--card-ink);text-align:center;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}

/* ---------- แชทสาธารณะ ---------- */
.lg-chat-list{display:flex;flex-direction:column;gap:10px;margin:10px 0 12px;
  max-height:220px;overflow-y:auto}
.lg-msg{display:flex;align-items:flex-start;gap:8px}
.lg-msg .avatar{border-width:1px}
.lg-msg p{font-size:12.5px;line-height:1.45;min-width:0;word-break:break-word;color:var(--card-ink-dim)}
.lg-msg p b{font-weight:600}
.lg-c1{color:#2f8bff}.lg-c2{color:#10b981}.lg-c3{color:#8b5cf6}.lg-cme{color:#f59e0b}
.lg-chat-form{display:flex;gap:8px}
.lg-input{flex:1;min-width:0;padding:10px 14px;border-radius:14px;font-size:13px;color:var(--card-ink);
  background:var(--card-glass);border:1px solid rgba(150,200,250,.8);
  transition:border-color .15s}
.lg-input::placeholder{color:var(--card-ink-dim)}
.lg-input:focus{border-color:rgba(47,139,255,.6)}
.lg-send{flex:none;width:44px;border-radius:14px;display:flex;align-items:center;
  justify-content:center;background:linear-gradient(135deg,#38bdf8,#2f8bff);
  box-shadow:0 6px 18px rgba(47,139,255,.35);transition:transform .12s}
.lg-send:active{transform:scale(.92)}
.lg-send svg{width:18px;height:18px;stroke:#fff;fill:none;stroke-width:2;
  stroke-linecap:round;stroke-linejoin:round}

/* ---------- แถบควบคุมเสียงตรึงล่าง 5 ปุ่ม ---------- */
.lg-ctrlbar{position:fixed;left:50%;transform:translateX(-50%);z-index:60;
  bottom:calc(14px + env(safe-area-inset-bottom));
  width:min(452px,calc(100% - 28px));
  display:flex;align-items:flex-end;justify-content:space-around;padding:10px 6px 8px;
  border-radius:26px;background:var(--card-glass);
  border:1px solid var(--card-brd);
  backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);
  box-shadow:0 14px 36px rgba(47,139,255,.22), 0 4px 12px rgba(9,30,60,.18)}
.lg-ctl{display:flex;flex-direction:column;align-items:center;gap:4px;width:58px;
  transition:transform .15s}
.lg-ctl:active{transform:scale(.92)}
.lg-ctl-face{width:42px;height:42px;border-radius:14px;display:flex;align-items:center;
  justify-content:center;color:var(--card-ink);background:var(--card-glass);
  border:1px solid var(--card-brd);box-shadow:0 4px 14px rgba(80,140,220,.16);
  transition:background .25s, color .25s, box-shadow .25s}
.lg-ctl-face svg{width:19px;height:19px;stroke:currentColor;fill:none;stroke-width:2;
  stroke-linecap:round;stroke-linejoin:round}
.lg-ctl-lb{font-size:9.5px;font-weight:600;color:var(--card-ink);line-height:1.2;text-align:center;
  transition:color .25s}
.lg-root.lg-t-sleep .lg-ctl-lb,.lg-root.lg-t-murder .lg-ctl-lb{color:var(--card-ink)}
.lg-ctl.off .lg-ctl-face{color:var(--card-ink-dim);background:rgba(230,238,248,.8)}
.lg-ctl.off .lg-ctl-lb{color:var(--card-ink-dim)}
.lg-ctl-green .lg-ctl-face{color:#059669;background:rgba(209,250,229,.85);
  border-color:rgba(167,243,208,.8);box-shadow:0 0 16px rgba(74,222,128,.4)}
.lg-ctl-green .lg-ctl-lb{color:#059669}
.lg-ctl-red .lg-ctl-face{color:#ef4444;background:rgba(254,226,226,.85);
  border-color:rgba(254,202,202,.9)}
.lg-ctl-red .lg-ctl-lb{color:#ef4444}

/* ปุ่มไมค์ใหญ่กลาง */
.lg-mic{width:70px;margin-top:-18px}
.lg-mic-face{position:relative;width:54px;height:54px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;color:var(--card-ink);background:#fff;
  border:1px solid var(--card-brd);box-shadow:0 8px 24px rgba(47,139,255,.25);
  transition:background .3s, color .3s, box-shadow .3s}
.lg-mic-face svg{width:23px;height:23px;stroke:currentColor;fill:none;stroke-width:2;
  stroke-linecap:round;stroke-linejoin:round}
.lg-mic-dot{position:absolute;top:2px;right:2px;width:12px;height:12px;border-radius:50%;
  background:#ef4444;border:2px solid #fff}
.lg-mic.on .lg-mic-face{color:#064e3b;background:linear-gradient(135deg,#6ee7a0,#4ade80);
  border-color:rgba(167,243,208,.8);box-shadow:0 0 18px rgba(74,222,128,.5)}
.lg-mic.on .lg-mic-dot{display:none}
.lg-mic .lg-ctl-lb{color:#ef4444;font-weight:700}
.lg-mic.on .lg-ctl-lb{color:#059669}

/* ---------- modal ยืนยันออกจากห้อง ---------- */
.lg-modal-root{position:fixed;inset:0;z-index:120;display:none;align-items:center;
  justify-content:center;padding:0 28px;background:rgba(7,20,41,.5);
  backdrop-filter:blur(4px);-webkit-backdrop-filter:blur(4px)}
.lg-modal-root.open{display:flex}
.lg-modal{width:100%;max-width:290px;padding:20px;border-radius:24px;text-align:center;
  background:var(--card-glass);border:1px solid var(--card-brd);
  backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px);
  box-shadow:0 18px 60px rgba(9,30,60,.4);animation:lgModalIn .25s ease}
@keyframes lgModalIn{from{opacity:0;transform:scale(.92)}to{opacity:1;transform:none}}
.lg-m-warn{width:48px;height:48px;margin:0 auto 12px;border-radius:50%;
  background:rgba(254,226,226,.9);display:flex;align-items:center;justify-content:center}
.lg-m-warn svg{width:24px;height:24px;stroke:#ef4444;fill:none;stroke-width:2;
  stroke-linecap:round;stroke-linejoin:round}
.lg-m-title{font-size:15px;font-weight:700;color:var(--card-ink);margin-bottom:4px}
.lg-m-desc{font-size:12px;color:var(--card-ink-dim);margin-bottom:16px;line-height:1.5}
.lg-m-row{display:flex;gap:10px}
.lg-m-btn{flex:1;padding:10px;border-radius:14px;font-size:13px;font-weight:600;
  transition:transform .12s}
.lg-m-btn:active{transform:scale(.97)}
.lg-m-cancel{color:var(--card-ink);background:var(--card-glass);border:1px solid var(--card-brd)}
.lg-m-ok{color:#fff;font-weight:700;background:linear-gradient(to right,#f87171,#ef4444);
  box-shadow:0 8px 22px rgba(239,68,68,.35)}

@media (max-width:379px){
  .lg-content{padding-left:10px;padding-right:10px}
  .lg-chip{font-size:10px}
  .lg-ctl{width:52px}
  .lg-mic{width:62px}
}

/* ===== FIX-TEAM-D: sheet จริงของการ์ด 4 ทางเข้า + เมนูเพิ่มเติม ===== */
.lg-sheet-bg{position:fixed;inset:0;z-index:120;background:rgba(3,8,22,.6);
  backdrop-filter:blur(4px);-webkit-backdrop-filter:blur(4px);animation:lgFade .22s ease}
@keyframes lgFade{from{opacity:0}to{opacity:1}}
.lg-sheet{position:fixed;left:50%;transform:translateX(-50%);bottom:0;z-index:121;
  width:min(480px,100%);max-height:84dvh;overflow-y:auto;color:#eaf2ff;
  background:rgba(16,26,48,.92);border:1px solid rgba(255,255,255,.14);border-bottom:none;
  backdrop-filter:blur(22px) saturate(150%);-webkit-backdrop-filter:blur(22px) saturate(150%);
  border-radius:26px 26px 0 0;padding:12px 18px calc(18px + env(safe-area-inset-bottom));
  box-shadow:0 -18px 60px rgba(0,0,0,.6);
  animation:lgUp .32s cubic-bezier(.32,.72,.22,1)}
@keyframes lgUp{from{transform:translate(-50%,100%)}to{transform:translate(-50%,0)}}
.lg-sheet.closing{animation:lgDown .2s ease forwards}
.lg-sheet-bg.closing{animation:lgFadeOut .2s ease forwards}
@keyframes lgDown{to{transform:translate(-50%,100%)}}
@keyframes lgFadeOut{to{opacity:0}}
.lg-sheet .grab{width:40px;height:6px;border-radius:3px;background:rgba(255,255,255,.22);
  margin:0 auto 13px}
.lg-sheet-h{font-size:16px;font-weight:700;margin-bottom:8px}
.lg-sheet-note{font-size:12px;line-height:1.7;color:rgba(226,238,255,.62);margin-bottom:10px}
.lg-sheet-cancel{display:block;width:100%;text-align:center;padding:12px;margin-top:10px;
  font-size:14px;color:rgba(226,238,255,.6)}
.lg-link{width:100%;font-size:12.5px;overflow-wrap:anywhere}

/* สมาชิก */
.lg-mem-list{display:flex;flex-direction:column;gap:7px;max-height:52dvh;overflow-y:auto}
.lg-mem{display:flex;align-items:center;gap:11px;padding:9px 11px;border-radius:16px;
  background:rgba(255,255,255,.06);border:1px solid rgba(255,255,255,.1)}
.lg-mem-txt{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}
.lg-mem-name{font-size:13.5px;font-weight:600}
.lg-mem-me{font-style:normal;font-size:10px;font-weight:700;padding:1px 7px;border-radius:8px;
  background:rgba(74,222,128,.2);color:#7ef2c0}
.lg-mem-sub{font-size:11px;color:rgba(226,238,255,.55)}
.lg-mem-mic{flex:none;display:flex;color:rgba(226,238,255,.35)}
.lg-mem-mic.on{color:#4ade80}
.lg-mem-mic svg{width:17px;height:17px}

/* แชทใน sheet */
.lg-chat-sheet{max-height:46dvh;overflow-y:auto;margin-bottom:10px}
.lg-chat-empty{padding:20px 6px;text-align:center;font-size:12.5px;color:rgba(226,238,255,.5)}
.lg-msg-sys p{width:100%;text-align:center;font-size:11.5px;color:rgba(226,238,255,.62);
  padding:5px 10px;border-radius:11px;background:rgba(255,255,255,.07)}

/* ของขวัญ */
.lg-gift-to{display:flex;gap:8px;overflow-x:auto;padding-bottom:6px;margin-bottom:12px}
.lg-gift-who{display:flex;flex-direction:column;align-items:center;gap:5px;flex:none;width:64px;
  padding:7px 4px;border-radius:15px;font-size:10.5px;color:rgba(226,238,255,.7);
  background:rgba(255,255,255,.06);border:1px solid transparent;transition:all .18s}
.lg-gift-who.active{border-color:rgba(74,222,128,.7);background:rgba(74,222,128,.14);color:#eaf2ff}
.lg-gift-who span{max-width:56px}
.lg-gift-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(72px,1fr));gap:9px}
.lg-gift{display:flex;flex-direction:column;align-items:center;gap:4px;padding:12px 6px;
  border-radius:17px;background:rgba(255,255,255,.06);border:1px solid rgba(255,255,255,.12);
  transition:transform .12s,border-color .15s,background .15s}
.lg-gift:hover{border-color:rgba(74,222,128,.6);background:rgba(74,222,128,.1)}
.lg-gift:active{transform:scale(.94)}
.lg-gift[disabled]{opacity:.5;pointer-events:none}
.lg-gift-emo{font-size:26px;line-height:1}
.lg-gift-price{font-size:11px;font-weight:700;color:#fbbf24}

/* ตั้งค่าห้อง */
.lg-set-themes{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:14px}
.lg-set-list{display:flex;flex-direction:column;gap:8px}
.lg-set-row{display:flex;align-items:center;gap:12px;padding:12px 13px;border-radius:16px;
  font-size:13px;background:rgba(255,255,255,.06);border:1px solid rgba(255,255,255,.1)}
.lg-set-sw{flex:none;width:46px;height:26px;border-radius:13px;padding:3px;
  background:rgba(255,255,255,.16);transition:background .2s}
.lg-set-sw span{display:block;width:20px;height:20px;border-radius:50%;background:#fff;
  transition:transform .2s}
.lg-set-sw.on{background:linear-gradient(135deg,#7ef2c0,#4ade80)}
.lg-set-sw.on span{transform:translateX(20px)}

/* เมนูเพิ่มเติม */
.lg-more-list{display:flex;flex-direction:column;gap:7px}
.lg-more-item{display:flex;align-items:center;gap:12px;width:100%;text-align:left;
  padding:13px 14px;border-radius:16px;font-size:13.5px;font-weight:600;color:#eaf2ff;
  background:rgba(255,255,255,.06);border:1px solid rgba(255,255,255,.1);transition:transform .12s}
.lg-more-item:active{transform:scale(.985)}
.lg-more-item svg{width:18px;height:18px;flex:none;color:rgba(226,238,255,.75)}
.lg-more-item.danger{color:#fda4af}
.lg-more-item.danger svg{color:#fda4af}

/* จุดไมค์เต้นตามระดับเสียงจริง (--lg-level มาจาก analyser) */
.lg-ctl.lg-mic.on .lg-mic-dot{
  transform:scale(calc(1 + var(--lg-level, 0) * 1.6));
  opacity:calc(.45 + var(--lg-level, 0) * .55);
  transition:transform .08s linear, opacity .08s linear}

/* ===== TEAM-L2: ห้องเสียงจริง (คนจริงในกริด + เสียงจาก WebRTC mesh) ===== */
/* ที่เก็บ <audio> ของแต่ละ peer — ไม่กินพื้นที่และไม่รบกวนดีไซน์ */
.lg-audio{position:absolute;width:0;height:0;overflow:hidden;opacity:0;pointer-events:none}
/* ป้ายไมค์ปิดบนที่นั่ง (มุมเดียวกับมงกุฎ แต่คนละมุม) */
.lg-seat-mute{position:absolute;bottom:-1px;right:-1px;width:19px;height:19px;border-radius:50%;
  background:#ef4444;border:2px solid rgba(255,255,255,.92);display:flex;align-items:center;
  justify-content:center;box-shadow:0 1px 4px rgba(9,30,60,.35)}
.lg-seat-mute svg{width:11px;height:11px;stroke:#fff;fill:none;stroke-width:2.6;
  stroke-linecap:round;stroke-linejoin:round}
/* ข้อความ "ยังไม่มีข้อความ" ตอนอยู่บนการ์ดพื้นสว่าง (ใน sheet ยังใช้สีเดิม) */
.lg-content .lg-chat-empty{color:var(--card-ink-dim)}
.lg-root.lg-t-sleep .lg-content .lg-chat-empty,
.lg-root.lg-t-murder .lg-content .lg-chat-empty{color:var(--card-ink-dim)}
