/* [2026-08-05] ฟอนต์ไทย "ไม่มีหัว" ของเกม — ประกาศไว้ในไฟล์นี้เองให้พึ่งพาตัวเองได้
   (เดิมไฟล์นี้ไม่เคยประกาศ @font-face ทุกกฎที่ขอ NotoSansThai จึงตกไปใช้ฟอนต์ระบบ
   และหลายกฎยังใช้ 'Sarabun' ซึ่งเป็นฟอนต์ "มีหัว" ⇒ มินิเกมเลยขึ้นฟอนต์ปกติ)
   path ชุดเดียวกับ room-lobby.css */
@font-face { font-family:'NotoSansThai'; src:url('/Create%20Room/FONTS/NotoSansThai-Medium.ttf') format('truetype');
  font-weight:500; font-style:normal; font-display:swap; }
@font-face { font-family:'NotoSansThai'; src:url('/Create%20Room/FONTS/NotoSansThai-SemiBold.ttf') format('truetype');
  font-weight:600; font-style:normal; font-display:swap; }
@font-face { font-family:'NotoSansThai'; src:url('/Create%20Room/FONTS/NotoSansThai-Bold.ttf') format('truetype');
  font-weight:700; font-style:normal; font-display:swap; }
@font-face { font-family:'NotoSansThai'; src:url('/Create%20Room/FONTS/NotoSansThai-Black.ttf') format('truetype');
  font-weight:800 900; font-style:normal; font-display:swap; }

* { box-sizing: border-box; }
body { font-family: 'NotoSansThai', sans-serif; margin: 0; background: #1a1b26; color: #c0caf5; }
.container { max-width: 720px; margin: 1rem auto; padding: 1rem; }

/* โครง Editor — แยกแถบเครื่องมือ / พื้นที่วาด */
.editor-page {
  display: block;
}

/* Editor ฝังใน Admin (?embed=1) — เต็มความสูง iframe, พื้นที่แคนวาสใหญ่ + เลื่อนแยก */
html.editor-embed-admin {
  height: 100%;
}
html.editor-embed-admin body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}
body.editor-embed-admin .version-tag {
  display: none !important;
}
body.editor-embed-admin .container.editor-page {
  max-width: none !important;
  width: 100%;
  height: 100%;
  margin: 0 !important;
  padding: 0.35rem 0.5rem 0.45rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  box-sizing: border-box;
}
body.editor-embed-admin .container.editor-page > h1 {
  display: none;
}
body.editor-embed-admin .editor-toolbar-wrap {
  /* อย่าให้แถบเครื่องมือถูก flex บีบแล้วล้นไปทับแคนวาส (body overflow:hidden) */
  flex: 0 0 auto;
  min-height: 0;
  max-height: min(56vh, 520px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0.15rem 0.35rem 0.5rem 0;
  margin: 0 0 0.35rem;
  border-bottom: 1px solid rgba(65, 72, 104, 0.9);
  position: relative;
  z-index: 1;
  background: linear-gradient(180deg, #1a1b26 0%, #16171f 100%);
}
body.editor-embed-admin .editor-workspace {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 0;
}
body.editor-embed-admin .canvas-wrap {
  flex: 1 1 auto;
  min-height: 140px;
  overflow: auto;
  margin: 0 !important;
  border-radius: 10px;
  border: 1px solid #414868;
  background: #0f1018;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
}
body.editor-embed-admin #editor-status {
  flex: 0 0 auto;
  margin: 0.3rem 0 0;
  font-size: 0.8rem;
  line-height: 1.35;
}
body.editor-embed-admin .editor-legend-short {
  margin: 0;
  font-size: 0.76rem;
  line-height: 1.45;
  color: #a8b0d0;
}
body.editor-embed-admin .editor-toolbar-grid {
  gap: 0.45rem;
}
/* การ์ด «ประเภทเกม» ข้อความยาว — ให้กว้างเต็มแถวบนจอแคบ ลดการอัดคอลัมน์ */
@media (max-width: 720px) {
  body.editor-embed-admin .editor-toolbar-grid .editor-card:first-child {
    grid-column: 1 / -1;
  }
}
body.editor-embed-admin .editor-card {
  padding: 0.45rem 0.55rem;
  margin-bottom: 0;
}
body.editor-embed-admin .editor-card__title {
  font-size: 0.68rem;
  margin-bottom: 0.3rem;
}
body.editor-embed-admin .editor-card__hint {
  font-size: 0.72rem;
  margin-top: 0.3rem;
  overflow-wrap: break-word;
  word-break: break-word;
}
body.editor-embed-admin .game-type-hint .editor-hint-lead {
  font-size: 0.78rem;
  margin-bottom: 0.35rem;
}
body.editor-embed-admin .game-type-hint .editor-hint-bullets {
  padding-left: 1.05rem;
}
body.editor-embed-admin .game-type-hint .editor-hint-bullets li {
  margin: 0.26rem 0;
  font-size: 0.72rem;
  line-height: 1.45;
}
body.editor-embed-admin .frogger-lanes {
  margin: 0.35rem 0;
  position: relative;
  z-index: auto;
}
body.editor-embed-admin .editor-card--bg {
  margin-top: 0.25rem;
}
body.editor-embed-admin .editor-card--help {
  margin-top: 0.2rem;
}
h1 { color: #7aa2f7; }
a { color: #9ece6a; }
label { display: inline-block; margin: 0.25rem 0.5rem 0.25rem 0; }
input, button { padding: 0.4rem 0.6rem; margin: 0 0.25rem 0 0; border-radius: 6px; border: 1px solid #414868; }
input { background: #24283b; color: #c0caf5; }
button { background: #7aa2f7; color: #1a1b26; cursor: pointer; border: none; }
.legend { font-size: 0.9rem; color: #a9b1d6; margin: 0.5rem 0; }
.frogger-lanes { margin: 1rem 0; padding: 0.75rem; background: #24283b; border-radius: 8px; position: relative; z-index: 2; min-height: 80px; }
.frogger-lanes h3 { margin: 0 0 0.5rem 0; color: #7aa2f7; font-size: 1rem; }
.frogger-lanes table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.frogger-lanes th, .frogger-lanes td { padding: 0.25rem 0.5rem; text-align: left; border: 1px solid #414868; }
.frogger-lanes select, .frogger-lanes input[type="number"] { padding: 0.35rem 0.5rem; min-width: 4rem; background: #1a1b26; color: #c0caf5; border: 1px solid #414868; border-radius: 4px; cursor: pointer; font-size: 0.9rem; }
.frogger-lanes select { min-width: 6rem; }
.frogger-lanes .lane-speed { width: 4rem; }
.frogger-lanes .lane-spacing { width: 4rem; }
.frogger-lanes td { vertical-align: middle; }
.frogger-lanes select:disabled, .frogger-lanes input:disabled { opacity: 0.6; cursor: not-allowed; }
.game-type-hint {
  font-size: 0.85rem;
  color: #a9b1d6;
  margin: 0;
  line-height: 1.5;
  display: block;
}
.game-type-hint .editor-hint-lead {
  margin: 0 0 0.45rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: #c0caf5;
  line-height: 1.4;
}
.game-type-hint .editor-hint-lead:last-child {
  margin-bottom: 0;
}
.editor-hint-bullets {
  margin: 0;
  padding-left: 1.2rem;
  list-style: disc;
}
.editor-hint-bullets li {
  margin: 0.35rem 0;
}
.editor-hint-bullets li:first-child {
  margin-top: 0;
}
.editor-hint-bullets li:last-child {
  margin-bottom: 0;
}
.game-type-hint .editor-hint-bullets code {
  font-size: 0.88em;
}
.game-type-hint kbd {
  display: inline-block;
  font-size: 0.82em;
  padding: 0.1em 0.38em;
  margin: 0 0.06em;
  border-radius: 4px;
  background: #1a1b26;
  border: 1px solid #414868;
  font-family: ui-monospace, monospace;
  color: #c0caf5;
}

/* Editor — การ์ดจัดกลุ่มเครื่องมือ (อ่านง่าย ไม่บีบเป็นแถบเดียวยาว) */
.editor-toolbar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 0.65rem;
  margin: 0.75rem 0 0.5rem;
  align-items: start;
}
.editor-card {
  margin: 0;
  padding: 0.65rem 0.75rem;
  background: #24283b;
  border: 1px solid rgba(65, 72, 104, 0.95);
  border-radius: 10px;
}
.editor-card--wide {
  grid-column: 1 / -1;
}
.editor-card__title {
  margin: 0 0 0.45rem 0;
  padding: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #7aa2f7;
}
.editor-card__row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.45rem 0.75rem;
}
.editor-card__row--wrap {
  align-items: center;
}
.editor-card__row--actions {
  margin-top: 0.55rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(65, 72, 104, 0.75);
  gap: 0.5rem;
}
.editor-card__hint {
  margin: 0.4rem 0 0;
  padding: 0.45rem 0.55rem;
  background: rgba(15, 16, 24, 0.55);
  border-radius: 6px;
  border-left: 3px solid #7aa2f7;
}
.editor-card label { margin: 0; }
/* กลุ่มกล่องตรวจ: ชนกำแพง vs โซนห้ามซ้อน — แยกมองชัดจากแถว label เปล่า ๆ */
.editor-footprint-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.85rem;
  width: 100%;
  padding: 0.42rem 0.55rem 0.48rem;
  border-radius: 8px;
  border: 1px solid rgba(122, 162, 247, 0.38);
  background: rgba(20, 22, 34, 0.72);
  box-sizing: border-box;
}
.editor-footprint-row--wall {
  border-color: rgba(122, 162, 247, 0.45);
  background: rgba(26, 32, 52, 0.65);
}
.editor-footprint-row--no-overlap {
  border-color: rgba(158, 206, 106, 0.5);
  background: rgba(22, 34, 26, 0.55);
}
.editor-footprint-row__head {
  flex: 0 0 100%;
  margin: 0 0 0.08rem 0;
  padding: 0;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #7aa2f7;
}
.editor-footprint-row--no-overlap .editor-footprint-row__head {
  color: #9ece6a;
}
.editor-footprint-row .editor-footprint-row__field input[type="number"] {
  width: 3.1rem;
  margin-left: 0.2rem;
}
.editor-field-grow {
  flex: 1 1 180px;
  min-width: min(100%, 200px);
}
.editor-field-grow select,
.editor-field-grow input[type="text"] {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
.editor-field-drawmode {
  flex: 1 1 280px;
  min-width: min(100%, 240px);
}
.editor-field-drawmode select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
.editor-cell-color {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.75rem;
}
.editor-grid-image-tools {
  display: none;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  max-width: 100%;
  width: min(100%, 520px);
}
.editor-grid-image-size-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
}
.editor-grid-image-size-row input[type="number"] {
  width: 3.2rem;
  margin-left: 0.25rem;
}
.editor-grid-image-carry-bind-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  align-items: center;
  font-size: 0.72rem;
  color: #a9b1d6;
}
.editor-grid-image-carry-bind-row select {
  margin-left: 0.35rem;
  max-width: 12rem;
}
.editor-hint-inline {
  font-size: 0.68rem;
  color: #787c99;
  line-height: 1.35;
  flex: 1 1 140px;
}
.editor-grid-image-gallery-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.editor-grid-image-gallery-label {
  font-size: 0.72rem;
  color: #a9b1d6;
  font-weight: 600;
}
.editor-grid-image-gallery-note {
  margin: 0.1rem 0 0.35rem;
  font-size: 0.65rem;
  line-height: 1.35;
  color: #787c99;
  max-width: 36rem;
}
.grid-cell-image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
  gap: 0.4rem;
  max-height: 200px;
  overflow-y: auto;
  padding: 0.35rem;
  border-radius: 8px;
  border: 1px solid rgba(65, 72, 104, 0.85);
  background: rgba(15, 16, 24, 0.6);
}
.grid-cell-image-gallery-empty {
  font-size: 0.72rem;
  color: #787c99;
  padding: 0.35rem;
}
.grid-cell-image-gallery-item {
  position: relative;
  padding: 0;
  margin: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: #24283b;
  line-height: 0;
}
.grid-cell-image-gallery-item.is-selected {
  border-color: #9ece6a;
  box-shadow: 0 0 0 1px rgba(158, 206, 106, 0.35);
}
.grid-cell-image-gallery-item img {
  display: block;
  width: 100%;
  height: 56px;
  object-fit: cover;
}
.grid-cell-image-gallery-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: stretch;
}
.grid-cell-image-gallery-same-hint {
  font-size: 0.62rem;
  line-height: 1.35;
  color: #f7768e;
  padding: 0.2rem 0.35rem;
  border-radius: 4px;
  background: rgba(247, 118, 142, 0.12);
  border: 1px solid rgba(247, 118, 142, 0.35);
}
.grid-cell-image-gallery-held-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem 0.1rem 0.25rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.22);
}
.grid-cell-image-gallery-held-label {
  font-size: 0.58rem;
  font-weight: 700;
  color: #7dcfff;
  letter-spacing: 0.04em;
}
.grid-cell-image-gallery-held-thumb {
  display: block;
  width: 100%;
  max-height: 44px;
  object-fit: cover;
  border-radius: 4px;
  background: #1a1b26;
}
.grid-cell-image-gallery-held-btn {
  font-size: 0.58rem;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  border: 1px solid rgba(125, 207, 255, 0.45);
  background: rgba(26, 27, 38, 0.95);
  color: #c0caf5;
  cursor: pointer;
}
.grid-cell-image-gallery-held-btn:hover {
  border-color: rgba(158, 206, 106, 0.65);
  color: #9ece6a;
}
.grid-cell-image-gallery-clear-held {
  font-size: 0.7rem;
  line-height: 1;
  padding: 0.05rem 0.25rem;
  border: none;
  border-radius: 4px;
  background: rgba(247, 118, 142, 0.25);
  color: #f7768e;
  cursor: pointer;
}
.grid-cell-image-gallery-clear-held:hover {
  background: rgba(247, 118, 142, 0.45);
}
.grid-cell-image-gallery-cap {
  display: block;
  font-size: 0.65rem;
  text-align: center;
  padding: 0.15rem 0;
  color: #c0caf5;
  background: rgba(0, 0, 0, 0.35);
}
.editor-grid-image-upload-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
body.editor-embed-admin .grid-cell-image-gallery {
  max-height: 160px;
}
body.editor-embed-admin .grid-cell-image-gallery-item img {
  height: 48px;
}
.editor-btn-primary {
  font-weight: 600;
}
.editor-card--bg {
  margin: 0.5rem 0 0.35rem;
}
.editor-card--help {
  margin: 0.35rem 0 0.15rem;
}
.editor-help-list {
  margin: 0;
  padding-left: 1.15rem;
  list-style: disc;
}
.editor-help-list li {
  margin-bottom: 0.28rem;
}
@media (min-width: 900px) {
  .editor-help-list {
    columns: 2;
    column-gap: 1.5rem;
  }
  .editor-help-list li {
    break-inside: avoid;
  }
}
.canvas-wrap { margin: 1rem 0; }
.container { padding-left: 1rem; padding-right: 1rem; }
#editor-canvas {
  background: #1a1b26;
  display: block;
  touch-action: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.editor-map-zoom-bar {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(8, 12, 28, 0.88);
  border: 1px solid #2a3357;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}
.editor-map-zoom-btn {
  border: 1px solid #2a3357;
  background: #0d1430;
  color: #eef2ff;
  border-radius: 8px;
  min-width: 34px;
  height: 32px;
  padding: 0 8px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  line-height: 1;
}
.editor-map-zoom-btn:hover { filter: brightness(1.2); }
.editor-map-zoom-label {
  min-width: 46px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: #c7d2fe;
  user-select: none;
}
.game-wrap { display: flex; flex-direction: column; height: 100vh; height: 100dvh; min-height: 0; }
.game-header { flex-shrink: 0; background: #24283b; padding: 0.5rem 1rem; display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.game-header span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-header button { flex-shrink: 0; }
#game-canvas {
  flex: 1 1 auto;
  display: block;
  width: 100%;
  /* [2026-07-31] ล็อกอัตราส่วนภาพ — เดิมมีแต่ width:100% ไม่มี height เลย
     ผลคือกล่องแสดงผล "กว้างตามจอ แต่สูงตามบัฟเฟอร์" พอ canvas.width ยังเป็นค่าเก่า
     (ช่วงหมุนจอ / แถบ URL ของมือถือยุบ) เบราว์เซอร์จะยืดบิตแมปตามแนวนอนอย่างเดียว
     = อาการ "ภาพในเกมยืดแปลก ๆ" ที่ผู้เล่นมือถือเจอ
     object-fit: contain ทำให้ยืดแบบไม่เท่ากันสองแกน "เป็นไปไม่ได้" แม้ในเฟรมที่ค่ายังค้าง
     (ระหว่างนั้นเห็นเป็นขอบว่างแทน ซึ่งดีกว่าภาพเพี้ยน)
     บน PC บัฟเฟอร์เท่ากล่องเสมอ → contain ไม่ทำอะไร = ภาพเดิมทุกพิกเซล
     ต้นแบบ: MG3 ใช้วิธีนี้อยู่แล้ว (ดู html.play-stack-tower-pixel-canvas ด้านล่าง) */
  height: 100%;
  object-fit: contain;
  object-position: center center;
  min-height: 0;
  min-width: 0;
  touch-action: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.game-wrap .chat-panel { flex-shrink: 0; }
.chat-panel { height: 160px; border-top: 1px solid #414868; display: flex; flex-direction: column; }
#chat-messages { flex: 1; overflow-y: auto; padding: 0.5rem; font-size: 0.9rem; }
#chat-form { display: flex; padding: 0.5rem; gap: 0.5rem; }
#chat-input { flex: 1; }

.lobby-section { margin: 1.25rem 0; padding: 1rem; background: #24283b; border-radius: 8px; }
.lobby-section h2 { margin: 0 0 0.75rem 0; font-size: 1rem; color: #7aa2f7; }
#room-list { list-style: none; margin: 0; padding: 0; }
#room-list .room-item { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.5rem 0; border-bottom: 1px solid #414868; }
#room-list .room-item:last-child { border-bottom: none; }
#room-list .room-name { font-weight: 600; color: #c0caf5; min-width: 0; }
#room-list .room-meta { font-size: 0.85rem; color: #a9b1d6; }
#room-list .room-meta-inline { font-size: 0.8rem; color: #565f89; font-weight: normal; }
#room-list-status { margin: 0; color: #a9b1d6; font-size: 0.9rem; }

.room-lobby-peers { margin: 1rem 0; padding: 0.75rem; background: #24283b; border-radius: 8px; }
.room-lobby-peer { padding: 0.35rem 0; color: #c0caf5; }
.room-lobby-peer:not(:last-child) { border-bottom: 1px solid #414868; }
#lobby-map-wrap { position: fixed; top: 0; left: 0; right: 0; bottom: 0; width: 100%; height: 100%; min-width: 100vw; min-height: 100vh; min-height: 100dvh; z-index: 0; }
#lobby-map-canvas {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  min-width: 100%;
  min-height: 100%;
  margin: 0;
  padding: 0;
  background: #303770;
  box-sizing: border-box;
}
#lobby-map-canvas:focus {
  outline: none;
}
#lobby-map-canvas:focus-visible {
  outline: 2px solid rgba(122, 162, 247, 0.45);
  outline-offset: -2px;
}
/* LobbyB (mn8nx46h) — ไม่แสดงปุ่มพร้อม */
body.room-lobby--lobby-b .room-lobby-ready-fixed {
  display: none !important;
}
.lobby-interact-hint {
  position: absolute;
  bottom: max(10px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  margin: 0;
  padding: 0.2rem 0.55rem;
  /* [2026-08-22] ลูกค้าบ่นซ้ำ "ตัวหนังสือเล็กเกินไป" — บรรทัดนี้โผล่ทุกจอในเกม
     เพดาน 0.85rem = 13.6px ชนตั้งแต่จอ 756px ขึ้นไป ⇒ จอ 1920 ก็ยัง 13.6px
     ยกเพดานเป็น 1.05rem (16.8px) · ค่าต่ำสุดคงเดิม จอเล็กจึงไม่กระทบเลย
     ปลอดภัยเพราะ nowrap + จัดกลางล่าง ข้อความสั้น และซ่อนบนจอสัมผัสอยู่แล้ว
     (@media pointer:coarse ตั้ง display:none ไว้ — ดู room-lobby.css:2334) */
  font-size: clamp(0.72rem, 1.8vw, 1.05rem);
  color: rgba(203, 213, 245, 0.9);
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  font-family: 'NotoSansThai', system-ui, sans-serif;
  white-space: nowrap;
}
.lobby-interact-hint kbd {
  display: inline-block;
  padding: 0.06em 0.32em;
  border-radius: 4px;
  background: rgba(26, 27, 38, 0.88);
  border: 1px solid rgba(122, 162, 247, 0.45);
  font-size: 0.88em;
  font-family: inherit;
}
.lobby-zoom-pct {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(26, 27, 38, 0.85);
  color: #c0caf5;
  font-size: 1rem;
  font-weight: 600;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.lobby-zoom-pct.lobby-zoom-pct-visible { opacity: 1; }
/* ซ่อนแผง overlay รายชื่อ / host / แชท — โถงโฟกัสแผนที่ + ปุ่ม READY/ไมค์ ด้านนอก */
.room-lobby-overlay { display: none !important; }
.room-lobby-top-left-cluster {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  z-index: 55;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.65rem;
  pointer-events: none;
}
.room-lobby-top-left-cluster .room-lobby-exit-fixed {
  pointer-events: auto;
}

/* มุมขวาบน — โปรไฟล์ตัวละคร */
.room-lobby-top-right-cluster {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 56;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.65rem;
  pointer-events: none;
}
.room-lobby-top-right-cluster > * {
  pointer-events: auto;
}
.room-lobby-profile-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}
.room-lobby-profile-frame {
  width: clamp(56px, 12vw, 72px);
  height: clamp(56px, 12vw, 72px);
  border-radius: 14px;
  border: 2px solid rgba(0, 212, 255, 0.65);
  overflow: hidden;
  background: rgba(18, 22, 42, 0.92);
  box-shadow:
    0 0 0 1px rgba(34, 211, 238, 0.2),
    0 0 22px rgba(34, 211, 238, 0.28);
}
.room-lobby-profile-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center bottom;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.room-lobby-actions { margin-top: 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; }
.room-lobby-actions .room-lobby-btn-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; opacity: 0; pointer-events: none; }
.room-lobby-actions label { margin: 0; }
.room-lobby-actions #btn-start { background: #9ece6a; color: #1a1b26; }
#host-only { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; }
#host-only select { padding: 0.4rem 0.6rem; border-radius: 6px; border: 1px solid #414868; background: #24283b; color: #c0caf5; }
.host-start-area-hint {
  flex-basis: 100%;
  margin: 0;
  font-size: 0.88rem;
  color: #e0af68;
  line-height: 1.35;
  max-width: 100%;
}
#host-only #btn-start:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.25);
}
.room-lobby-chat { margin-top: 1rem; }
.room-lobby-chat.chat-panel {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: none;
}
.room-lobby-chat-peers.chat-panel {
  position: fixed;
  right: 1.25rem;
  bottom: 5.5rem;
  width: 576px;
  height: 525px;
  max-width: calc(100vw - 2.5rem);
  z-index: 52;
  margin-top: 0;
  display: flex;
  flex-flow: column;
  padding: 2rem;
  box-sizing: border-box;
  border-top: 0px solid #414868;
  background: url(/Game/img/chat-msg-bg-alpha.webp) center/100% 100% no-repeat;
  background-color: transparent;
}
.room-lobby-chat-peers.chat-panel .chat-header-title.chat-header-title-img img { width: 90px; height: 77px; }
.room-lobby-chat-peers.chat-panel .chat-close-btn { width: 48px; height: 48px; }
.room-lobby-chat-peers.chat-panel .chat-close-btn img { width: 50px; height: 50px; }
.room-lobby-chat-peers.chat-panel #chat-messages { padding: 0.75rem; font-size: 1.05rem; gap: 0.5rem; }
.room-lobby-chat-peers.chat-panel .chat-form-bar { padding: 0.6rem 0; gap: 0.5rem; }
.room-lobby-chat-peers.chat-panel #chat-input { padding: 0.6rem 0.85rem; font-size: 1.05rem; }
.room-lobby-chat-peers.chat-panel .chat-send-btn { width: 52px; height: 52px; }
.room-lobby-chat-peers.chat-panel .chat-send-btn img { width: 58px; height: 58px; }
.room-lobby-chat-peers.chat-panel .chat-msg { padding: 0.6rem 1rem; font-size: 1.05rem; }
.room-lobby-chat-peers.chat-panel .chat-header-bar {
  margin: 0 -2rem 0 -2rem;
  padding-left: 2rem;
  padding-right: 2rem;
  justify-content: space-between;
  align-items: center;
  min-height: 72px;
  height: 72px;
}
.room-lobby-chat-peers.chat-panel #chat-messages {
  flex: 1;
  min-height: 0;
  height: auto;
}
.room-lobby-chat .chat-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0;
  min-height: 48px;
  height: 48px;
  background: url(/Game/img/chat-line.webp) bottom repeat-x;
  background-size: 100% 4px;
  background-color: transparent;
}
.room-lobby-chat-peers .chat-header-title.chat-header-title-img {
  display: inline-flex;
  align-items: center;
  line-height: 0;
}
.room-lobby-chat-peers .chat-header-title.chat-header-title-img img {
  width: 60px;
  height: 51px;
  object-fit: contain;
  display: block;
}
.room-lobby-chat-ai .chat-header-title.chat-header-title-img {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  line-height: 0;
}
.room-lobby-chat-ai .chat-header-title.chat-header-title-img .ai-chat-title-label {
  height: 52px;
  width: auto;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
  margin-bottom: -2px;
}
/* รูปหัวแชท AI — ยกขึ้นเหนือเส้น */
.room-lobby-chat-ai .chat-header-title.chat-header-title-img img {
  width: 86px;
  height: 92px;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
  margin-top: -27px;
  margin-left: -6px;
  position: relative;
  z-index: 1;
}
.room-lobby-chat .chat-header-title {
  font-size: 1rem;
  font-weight: 600;
  color: #a0aec0;
}
.room-lobby-chat .chat-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  margin-left: auto;
}
.room-lobby-chat-peers .chat-header-bar .chat-close-btn { margin-left: 0; }
.room-lobby-chat .chat-close-btn img { width: 34px; height: 34px; object-fit: contain; }
.room-lobby-chat .chat-close-btn:hover { opacity: 0.9; }
.room-lobby-chat.chat-panel-collapsed #chat-messages,
.room-lobby-chat.chat-panel-collapsed .chat-form-bar { display: none !important; }
.room-lobby-chat-peers.chat-panel-collapsed .chat-header-title { display: none !important; }
.room-lobby-chat-peers.chat-panel-collapsed .chat-header-bar {
  justify-content: center;
  padding: 0;
  background: none !important;
  border: none;
}
.room-lobby-chat-peers.chat-panel-collapsed.chat-panel {
  width: 80px;
  height: 80px;
  min-height: 0;
  padding: 0;
  right: 1.25rem;
  bottom: 6.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none !important;
  background-color: transparent !important;
  border: none;
  box-shadow: none;
}
.room-lobby-chat-peers.chat-panel-collapsed .chat-close-btn {
  width: 80px;
  height: 80px;
  overflow: visible;
}
.room-lobby-chat-peers.chat-panel-collapsed .chat-close-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}
.room-lobby-chat #chat-messages,
.room-lobby-chat #ai-chat-messages {
  height: 100px;
  overflow-y: auto;
  padding: 0.5rem;
  font-size: 0.85rem;
  border: none;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: none;
  background-color: transparent;
  box-shadow: none;
}
.room-lobby-chat .chat-messages-bg { border-radius: 0; }
.room-lobby-chat #chat-form.chat-form-bar,
.room-lobby-chat #ai-chat-form.chat-form-bar {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  padding: 0.4rem 0;
  background: none;
  background-color: transparent;
  border-top: none;
  flex-shrink: 0;
}
.room-lobby-chat-peers .chat-form-bar {
  padding-left: 0;
  padding-right: 0;
}
.room-lobby-chat #chat-input,
.room-lobby-chat #ai-chat-input {
  flex: 1;
  min-width: 0;
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
  border: 1px solid rgba(0, 212, 255, 0.25);
  background: rgba(30, 35, 50, 0.8);
  color: #c0caf5;
  font-size: 0.9rem;
  box-sizing: border-box;
  margin-left: 9px;
}
.room-lobby-chat .chat-send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
}
.room-lobby-chat .chat-send-btn img { width: 45px; height: 45px; object-fit: contain; }
.room-lobby-chat .chat-send-btn:hover { opacity: 0.9; }
.room-lobby-chat .chat-msg {
  padding: 0.4rem 0.75rem;
  border-radius: 12px;
  max-width: 85%;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
}
.room-lobby-chat .chat-msg-mine {
  align-self: flex-end;
  text-align: right;
  background-image: url(/Game/img/chat-bubble-me.webp);
  background-color: rgba(122, 162, 247, 0.9);
  color: #1a1b26;
}
.room-lobby-chat .chat-msg-other {
  align-self: flex-start;
  text-align: left;
  background-image: url(/Game/img/chat-bubble-friend.webp);
  background-color: rgba(65, 72, 104, 0.9);
  color: #c0caf5;
}
.room-lobby-chat .chat-msg-ai {
  align-self: flex-start;
  text-align: left;
  background-image: url(/Game/img/chat-bubble-friend.webp);
  background-color: rgba(158, 206, 106, 0.9);
  color: #1a1b26;
}
.room-lobby-chat .chat-msg-system {
  align-self: center;
  text-align: center;
  max-width: 95%;
  background-image: none;
  background-color: rgba(26, 27, 38, 0.72);
  color: #9aa5ce;
  font-size: 0.88rem;
  font-style: italic;
  padding: 0.35rem 0.6rem;
}

/* AI chat — loading แบบ Messenger (จุดกระโดด 3 จุด), อยู่ติดข้อความล่าสุดในลิสต์ */
.room-lobby-chat .ai-chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 14px;
  min-height: 24px;
  flex-shrink: 0;
  background-image: url(/Game/img/chat-bubble-friend.webp);
  background-color: rgba(158, 206, 106, 0.9);
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
}
.room-lobby-chat .ai-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #1a1b26;
  animation: ai-typing-bounce 1.4s ease-in-out infinite both;
}
.room-lobby-chat .ai-typing-dot:nth-child(1) { animation-delay: 0s; }
.room-lobby-chat .ai-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.room-lobby-chat .ai-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes ai-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* AI chat panel — ขนาดและตำแหน่งตาม reference (วงซ้าย) */
.room-lobby-chat-ai.chat-panel {
  position: fixed;
  left: 20px;
  right: auto;
  bottom: 5.5rem;
  width: 576px;
  height: 525px;
  max-width: calc(100vw - 2.5rem);
  z-index: 51;
  margin-top: 0;
  display: flex;
  flex-flow: column;
  padding: 2rem;
  box-sizing: border-box;
  border-top: 0;
  background: url(/Game/img/chat-msg-bg-alpha.webp) center/100% 100% no-repeat;
  background-color: transparent;
}
.room-lobby-chat-ai.chat-panel .chat-header-bar {
  margin: 0 -2rem 0 -2rem;
  padding-left: 2rem;
  padding-right: 2rem;
  justify-content: space-between;
  align-items: center;
  min-height: 80px;
  height: 80px;
  overflow: visible;
}
.room-lobby-chat-ai.chat-panel .chat-header-title.chat-header-title-img img { width: 130px; height: 138px; margin-top: -38px; margin-left: -8px; }
.room-lobby-chat-ai.chat-panel .chat-header-title.chat-header-title-img .ai-chat-title-label { height: 78px; }
.room-lobby-chat-ai.chat-panel .chat-close-btn { width: 48px; height: 48px; }
.room-lobby-chat-ai.chat-panel .chat-close-btn img { width: 50px; height: 50px; }
.room-lobby-chat-ai.chat-panel #ai-chat-messages { padding: 0.75rem; font-size: 1.05rem; gap: 0.5rem; }
.room-lobby-chat-ai.chat-panel .chat-form-bar { padding: 0.6rem 0; gap: 0.5rem; }
.room-lobby-chat-ai.chat-panel #ai-chat-input { padding: 0.6rem 0.85rem; font-size: 1.05rem; }
.room-lobby-chat-ai.chat-panel .chat-send-btn { width: 52px; height: 52px; }
.room-lobby-chat-ai.chat-panel .chat-send-btn img { width: 58px; height: 58px; }
.room-lobby-chat-ai.chat-panel .chat-msg { padding: 0.6rem 1rem; font-size: 1.05rem; }
.room-lobby-chat-ai.chat-panel .ai-chat-typing { padding: 14px 18px; min-height: 28px; }
.room-lobby-chat-ai.chat-panel .ai-typing-dot { width: 8px; height: 8px; }
.room-lobby-chat-ai.chat-panel {
  overflow: visible;
}
.room-lobby-chat-ai.chat-panel #ai-chat-messages {
  flex: 1;
  min-height: 0;
  height: auto;
}
.room-lobby-chat-ai .chat-form-bar {
  padding-left: 0;
  padding-right: 0;
}
.room-lobby-chat-ai .ai-chat-admin-link {
  margin: 0.35rem 0 0 0;
  font-size: 0.75rem;
  flex-shrink: 0;
}
/* AI chat collapsed */
.room-lobby-chat-ai.chat-panel-collapsed #ai-chat-messages,
.room-lobby-chat-ai.chat-panel-collapsed .chat-form-bar,
.room-lobby-chat-ai.chat-panel-collapsed .ai-chat-admin-link { display: none !important; }
.room-lobby-chat-ai.chat-panel-collapsed .chat-header-title { display: none !important; }
.room-lobby-chat-ai.chat-panel-collapsed .chat-header-bar {
  justify-content: center;
  padding: 0;
  background: none !important;
  border: none;
}
.room-lobby-chat-ai.chat-panel-collapsed.chat-panel {
  width: 80px;
  height: 80px;
  min-height: 0;
  padding: 0;
  left: 20px;
  bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none !important;
  background-color: transparent !important;
  border: none;
  box-shadow: none;
}
.room-lobby-chat-ai.chat-panel-collapsed .chat-close-btn {
  width: 80px;
  height: 80px;
  overflow: visible;
}
.room-lobby-chat-ai.chat-panel-collapsed .chat-close-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}

.room-lobby-exit-fixed {
  position: static;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: max-content;
  max-width: calc(100vw - 24px);
  box-sizing: border-box;
}
.room-lobby-exit-fixed .btn-exit-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 80px;
  height: 80px;
  min-width: 80px;
  padding: 0;
  border: none;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
}
.room-lobby-exit-fixed .btn-exit-icon:hover {
  opacity: 0.9;
}
.room-lobby-exit-fixed .btn-exit-icon img {
  width: 100%;
  height: auto;
  object-fit: contain;
  display: block;
}

.room-lobby-ready-fixed {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  pointer-events: none;
}
.room-lobby-ready-fixed .ready-label,
.room-lobby-ready-fixed .ready-check-input {
  pointer-events: auto;
}
.room-lobby-ready-fixed .ready-label {
  position: relative;
  display: inline-block;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
  line-height: 0;
}
.room-lobby-ready-fixed .ready-label:hover {
  transform: scale(1.04);
  filter: brightness(1.08);
}
.room-lobby-ready-fixed .ready-label:active {
  transform: scale(0.98);
}
.room-lobby-ready-fixed .ready-check-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}
.room-lobby-ready-fixed .ready-label-img {
  display: block;
  height: clamp(44px, 8vh, 72px);
  width: auto;
  max-width: min(240px, 78vw);
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.room-lobby-ready-fixed .ready-label--active .ready-label-img {
  filter: drop-shadow(0 0 10px rgba(158, 206, 106, 0.45));
}

/* มุมขวาล่าง — ไมค์ทุกห้อง + ปุ่ม LobbyB (แว่น/ถ้วย) */
.room-lobby-br-fixed {
  --lobby-br-btn: 80px;
  position: fixed;
  bottom: 1.25rem;
  right: max(1.25rem, env(safe-area-inset-right));
  z-index: 400;
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}
.room-lobby-br-fixed .lobby-b-extra-row,
.room-lobby-br-fixed .btn-voice-icon {
  pointer-events: auto;
}
.lobby-b-extra-row {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 10px;
}
.lobby-b-extra-row.is-hidden {
  display: none !important;
}
/* โหมดเกม (ควิซ) ใน room-lobby — ไม่โชว์แว่น/ถ้วย LobbyB */
body.room-lobby--quiz-active .lobby-b-extra-row {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
/* ปุ่มมุมขวาล่าง — ขนาดเดียวกัน (กัน UA border / box model ต่างกัน) */
.room-lobby-br-fixed .lobby-b-sq-btn,
.room-lobby-br-fixed .btn-voice-icon {
  box-sizing: border-box;
  width: var(--lobby-br-btn);
  height: var(--lobby-br-btn);
  min-width: var(--lobby-br-btn);
  min-height: var(--lobby-br-btn);
  max-width: var(--lobby-br-btn);
  max-height: var(--lobby-br-btn);
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 12px;
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  cursor: pointer;
}
/* สไตล์เดียวกับปุ่มไมค์ — ไม่มีกรอบ cyan / bg-item */
.lobby-b-sq-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  box-shadow: none;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.lobby-b-sq-btn:hover {
  transform: scale(1.04);
  filter: brightness(1.08);
}
.lobby-b-sq-btn:active { transform: scale(0.98); }
.room-lobby-br-fixed .lobby-b-sq-btn img,
.room-lobby-br-fixed .btn-voice-icon img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.room-lobby-br-fixed .btn-voice-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}

/* —— แฟ้มหลักฐาน LobbyB (รูปจาก /Main-Lobby/IMAGE/See evidence) —— */
.lobby-evidence-overlay {
  position: fixed;
  inset: 0;
  z-index: 10047;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  box-sizing: border-box;
}
.lobby-evidence-overlay.is-hidden {
  display: none !important;
}
.lobby-evidence-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 22, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
}
.lobby-evidence-dialog {
  position: relative;
  z-index: 1;
  width: min(96vw, 900px);
  max-height: min(92vh, 920px);
  pointer-events: none;
}
.lobby-evidence-dialog * {
  pointer-events: auto;
}
.lobby-evidence-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1684 / 963;
  filter: drop-shadow(0 0 24px rgba(0, 255, 255, 0.12)) drop-shadow(0 0 40px rgba(255, 0, 255, 0.08));
}
.lobby-evidence-bg {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center top;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.lobby-evidence-close {
  position: absolute;
  top: 5.5%;
  right: 4%;
  width: 8%;
  max-width: 56px;
  aspect-ratio: 1;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: rgba(0, 255, 255, 0.95);
  font-size: clamp(1.25rem, 4vw, 2rem);
  line-height: 1;
  cursor: pointer;
  text-shadow: 0 0 12px rgba(0, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.lobby-evidence-close:hover {
  transform: scale(1.08);
  filter: brightness(1.15);
}
.lobby-evidence-tabs-layer {
  position: absolute;
  left: 7%;
  right: 7%;
  top: 15.5%;
  height: 13.5%;
  min-height: 36px;
}
.lobby-evidence-tabs-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: left center;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.lobby-evidence-tab-hits {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  padding-left: 1.5%;
  padding-right: 0;
  box-sizing: border-box;
}
.lobby-evidence-tab-hit {
  flex: 0 0 13.2%;
  min-width: 0;
  height: 100%;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 8px;
}
.lobby-evidence-tab-hit:focus-visible {
  outline: 2px solid rgba(0, 255, 255, 0.9);
  outline-offset: 2px;
}
.lobby-evidence-tab-hit-spacer {
  flex: 1 1 auto;
  pointer-events: none;
}
.lobby-evidence-cards-root {
  position: absolute;
  left: 5%;
  right: 5%;
  top: 31%;
  bottom: 7%;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: clamp(6px, 1.2vw, 14px);
  align-items: stretch;
  justify-content: center;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  padding-bottom: 4px;
  box-sizing: border-box;
}
.lobby-evidence-card {
  flex: 1 1 0;
  min-width: min(200px, 28vw);
  max-width: 320px;
  display: flex;
  flex-direction: column;
  border-radius: 10px;
  padding: clamp(6px, 1vw, 10px);
  background: rgba(15, 20, 36, 0.92);
  box-sizing: border-box;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 8px 24px rgba(0, 0, 0, 0.35);
}
.lobby-evidence-card--common {
  box-shadow: 0 0 0 2px rgba(180, 190, 200, 0.65), 0 0 16px rgba(200, 210, 220, 0.2), 0 8px 24px rgba(0, 0, 0, 0.35);
}
.lobby-evidence-card--rare {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.85), 0 0 20px rgba(59, 130, 246, 0.35), 0 8px 24px rgba(0, 0, 0, 0.35);
}
.lobby-evidence-card--legendary {
  box-shadow: 0 0 0 2px rgba(234, 179, 8, 0.9), 0 0 22px rgba(250, 204, 21, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
}
.lobby-evidence-card-head {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}
.lobby-evidence-card-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(0, 255, 255, 0.25), rgba(255, 0, 255, 0.15));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
}
.lobby-evidence-card-titles {
  flex: 1;
  min-width: 0;
}
.lobby-evidence-card-title-th {
  font-family: 'NotoSansThai', system-ui, sans-serif;
  font-size: clamp(0.68rem, 1.35vw, 0.82rem);
  font-weight: 700;
  color: #e8ecff;
  line-height: 1.25;
  margin: 0;
}
.lobby-evidence-card-title-en {
  font-family: 'NotoSansThai', system-ui, sans-serif;
  font-size: clamp(0.58rem, 1.05vw, 0.68rem);
  color: rgba(180, 190, 220, 0.85);
  margin: 2px 0 0;
  line-height: 1.2;
}
.lobby-evidence-card-art {
  flex: 1 1 auto;
  min-height: clamp(72px, 14vh, 140px);
  max-height: min(22vh, 200px);
  border-radius: 8px;
  background: linear-gradient(160deg, rgba(30, 40, 70, 0.95), rgba(12, 16, 32, 0.98));
  border: 1px solid rgba(0, 255, 255, 0.12);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(0, 255, 255, 0.35);
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  user-select: none;
}
.lobby-evidence-card-body {
  font-family: 'NotoSansThai', system-ui, sans-serif;
  font-size: clamp(0.6rem, 1.15vw, 0.72rem);
  color: rgba(210, 218, 240, 0.92);
  line-height: 1.4;
  margin: 0 0 8px;
  flex-shrink: 0;
  max-height: 4.5em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}
.lobby-evidence-card-foot {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  flex-shrink: 0;
}
.lobby-evidence-link {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.lobby-evidence-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(145deg, #7aa2f7, #565f89);
  color: #1a1b26;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(0, 255, 255, 0.25);
}
.lobby-evidence-link-name {
  font-size: clamp(0.62rem, 1.1vw, 0.74rem);
  font-weight: 600;
  color: #c0caf5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lobby-evidence-foot-meta {
  text-align: right;
  flex-shrink: 0;
}
.lobby-evidence-rarity {
  display: block;
  font-size: clamp(0.55rem, 0.95vw, 0.65rem);
  color: rgba(170, 180, 210, 0.9);
  margin-bottom: 2px;
}
.lobby-evidence-stars {
  font-size: clamp(0.65rem, 1.2vw, 0.78rem);
  letter-spacing: 1px;
  line-height: 1;
}
.lobby-evidence-card--common .lobby-evidence-stars { color: #d4d4d8; text-shadow: 0 0 8px rgba(200, 200, 210, 0.4); }
.lobby-evidence-card--rare .lobby-evidence-stars { color: #60a5fa; text-shadow: 0 0 10px rgba(59, 130, 246, 0.5); }
.lobby-evidence-card--legendary .lobby-evidence-stars { color: #fcd34d; text-shadow: 0 0 10px rgba(234, 179, 8, 0.55); }
@media (max-width: 720px) {
  .lobby-evidence-cards-root {
    flex-wrap: wrap;
    overflow-y: auto;
    align-content: flex-start;
  }
  .lobby-evidence-card {
    flex: 1 1 100%;
    max-width: none;
    min-width: 0;
  }
}

/* —— กระดานอันดับ LobbyB (เหรียญ leaderboard-1/2/3 จาก Main-Lobby) —— */
.lobby-rank-overlay {
  position: fixed;
  inset: 0;
  z-index: 10048;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  box-sizing: border-box;
}
.lobby-rank-overlay.is-hidden {
  display: none !important;
}
.lobby-rank-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 4, 14, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
}
.lobby-rank-dialog {
  position: relative;
  z-index: 1;
  width: min(96vw, 520px);
  max-height: min(90vh, 720px);
  pointer-events: none;
}
.lobby-rank-dialog * {
  pointer-events: auto;
}
.lobby-rank-panel {
  background: linear-gradient(165deg, rgba(28, 36, 58, 0.96), rgba(12, 16, 32, 0.98));
  border-radius: 16px;
  border: 2px solid rgba(0, 255, 255, 0.45);
  box-shadow:
    0 0 0 1px rgba(255, 0, 200, 0.25),
    0 0 32px rgba(0, 255, 255, 0.12),
    0 0 48px rgba(255, 0, 180, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  padding: clamp(10px, 2.5vw, 16px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  font-family: 'NotoSansThai', system-ui, sans-serif;
}
.lobby-rank-head {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 6px 44px 12px 12px;
  border-bottom: 1px solid rgba(0, 255, 255, 0.28);
  margin-bottom: 8px;
}
.lobby-rank-case-title {
  margin: 0;
  font-size: clamp(0.95rem, 2.8vw, 1.15rem);
  font-weight: 700;
  color: #e8f4ff;
  text-align: center;
  text-shadow: 0 0 12px rgba(0, 255, 255, 0.35);
  line-height: 1.25;
}
.lobby-rank-close {
  position: absolute;
  top: 2px;
  right: 4px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: rgba(0, 255, 255, 0.95);
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  text-shadow: 0 0 14px rgba(0, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.lobby-rank-close:hover {
  transform: scale(1.06);
  filter: brightness(1.12);
}
.lobby-rank-podium {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(6px, 2vw, 14px);
  padding: 8px 4px 14px;
  flex-shrink: 0;
}
.lobby-rank-ped {
  flex: 1 1 0;
  min-width: 0;
  max-width: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 10px 6px 12px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(0, 255, 255, 0.22);
  box-sizing: border-box;
}
.lobby-rank-ped--2 {
  order: 1;
  min-height: 148px;
}
.lobby-rank-ped--1 {
  order: 2;
  min-height: 188px;
  border-color: rgba(255, 215, 0, 0.45);
  box-shadow: 0 0 22px rgba(255, 200, 0, 0.12);
}
.lobby-rank-ped--3 {
  order: 3;
  min-height: 132px;
}
.lobby-rank-crown {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-bottom: 4px;
  font-size: 1.1rem;
  line-height: 1;
  filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.6));
}
.lobby-rank-crown-n {
  font-size: 0.85rem;
  font-weight: 800;
  color: #ffe066;
}
.lobby-rank-medal-wrap {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}
.lobby-rank-medal-img {
  width: auto;
  height: 34px;
  object-fit: contain;
  display: block;
}
.lobby-rank-ped-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(145deg, #7aa2f7, #565f89);
  color: #1a1b26;
  font-size: 1.1rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
  box-shadow: 0 0 0 2px rgba(0, 255, 255, 0.3);
  flex-shrink: 0;
}
.lobby-rank-ped--1 .lobby-rank-ped-avatar {
  width: 56px;
  height: 56px;
  font-size: 1.25rem;
}
.lobby-rank-ped-name {
  font-size: clamp(0.68rem, 2vw, 0.8rem);
  font-weight: 600;
  color: #e8ecff;
  line-height: 1.2;
  word-break: break-word;
  max-width: 100%;
}
.lobby-rank-ped-score {
  margin-top: 4px;
  font-size: clamp(0.75rem, 2.2vw, 0.9rem);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
}
.lobby-rank-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  margin: 0 -4px;
  padding: 0 4px;
  scrollbar-width: thin;
}
.lobby-rank-table {
  width: 100%;
  border-collapse: collapse;
  font-size: clamp(0.65rem, 1.9vw, 0.78rem);
}
.lobby-rank-table thead th {
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(0, 255, 255, 0.85);
  font-weight: 700;
  padding: 8px 6px;
  border-bottom: 1px solid rgba(0, 255, 255, 0.25);
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, rgba(20, 26, 44, 0.98), rgba(20, 26, 44, 0.92));
  z-index: 1;
}
.lobby-rank-table thead th:nth-child(1) { width: 3.2rem; }
.lobby-rank-table thead th:nth-child(3) { text-align: right; width: 4rem; }
.lobby-rank-table tbody td {
  padding: 7px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  vertical-align: middle;
}
.lobby-rank-table tbody td:nth-child(3) {
  text-align: right;
  font-weight: 600;
  color: #fff;
}
.lobby-rank-table .lobby-rank-row-av {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.lobby-rank-table .lobby-rank-mini-av {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(145deg, #9ece6a, #565f89);
  color: #1a1b26;
  font-size: 0.65rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0, 255, 255, 0.2);
}
.lobby-rank-table .lobby-rank-row-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}
.lobby-rank-self {
  flex-shrink: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 12px 10px 6px;
  margin-top: 6px;
  border-top: 1px solid rgba(255, 0, 180, 0.42);
  background: linear-gradient(90deg, rgba(255, 0, 180, 0.07), transparent);
}
.lobby-rank-self-rank {
  font-weight: 800;
  color: #c0caf5;
  min-width: 2.5rem;
  font-size: clamp(0.75rem, 2vw, 0.88rem);
}
.lobby-rank-self-av {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(145deg, #f472b6, #a855f7);
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255, 100, 200, 0.45);
}
.lobby-rank-self-meta {
  flex: 1;
  min-width: 0;
}
.lobby-rank-self-name {
  font-size: clamp(0.85rem, 2.4vw, 1rem);
  font-weight: 800;
  color: #fff;
  line-height: 1.2;
}
.lobby-rank-self-score {
  font-size: clamp(0.85rem, 2.4vw, 1rem);
  font-weight: 800;
  color: #ff4ecd;
  text-shadow: 0 0 12px rgba(255, 78, 205, 0.45);
  flex-shrink: 0;
}

.version-tag {
  position: fixed;
  right: 8px;
  bottom: 4px;
  left: auto;
  font-size: 10px;
  color: #a9b1d6;
  opacity: 0.7;
  pointer-events: none;
}

/* play — quiz carry pregame (สอดคล้อง play.html) */
.quiz-carry-pregame-card {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  max-width: min(94vw, 900px);
  width: 100%;
  max-height: min(94vh, 900px);
  overflow: hidden;
  background: rgba(10, 12, 26, 0.55);
  border: none;
  border-radius: 4px;
  box-shadow: none;
  pointer-events: auto;
}
.quiz-carry-pregame-footer {
  flex: 0 0 auto;
  padding: 0.85rem 1rem 1rem;
  background: linear-gradient(180deg, rgba(8, 10, 22, 0.2), rgba(8, 10, 22, 0.96));
  border-top: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
}

/* Editor — เกมตอบคำถาม */
.quiz-editor-wrap {
  margin: 1rem 0;
  padding: 1rem;
  background: #24283b;
  border-radius: 8px;
  border: 1px solid #414868;
}
.quiz-editor-wrap h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: #7aa2f7;
}
.quiz-questions-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 0.75rem 0;
}
.quiz-q-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.5rem;
  align-items: center;
}
@media (max-width: 600px) {
  .quiz-q-row {
    grid-template-columns: 1fr;
  }
}
.quiz-q-row input[type="text"] {
  min-width: 0;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  border: 1px solid #565f89;
  background: #1a1b26;
  color: #c0caf5;
}
.quiz-q-row select {
  padding: 0.35rem;
  border-radius: 6px;
  border: 1px solid #565f89;
  background: #1a1b26;
  color: #c0caf5;
}
.btn-quiz-add,
.quiz-q-remove {
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid #565f89;
  background: #414868;
  color: #c0caf5;
  font: inherit;
}
.quiz-q-remove {
  font-size: 0.8rem;
}

/* Stack Tower play — เฟรมกล้องต้อง "คงที่ทุก resolution"
   cover สเกลตามด้านที่ใหญ่กว่า → จอกว้าง/เตี้ย ต่างกัน = เฟรม/ซูมเปลี่ยน (กล้องเพี้ยนเวลาเปลี่ยน resolution + บล็อกห้อย/จุดวางหลุดเฟรม)
   contain = เห็นทั้งฉาก 16:9 (บล็อกห้อย+จุดวาง+หอ) เหมือนกันเป๊ะทุกจอ; แถบ letterbox กลืนสีฉาก (#0a0e22) ไม่ดูจอเสีย */
/* [2026-08-06] แถบ letterbox ซ้าย-ขวา เดิมเป็นสีทึบ ⇒ เจ้าของเกมแจ้ง "BG ไม่เต็มจอ"
   เปลี่ยนเป็น object-fit: cover ไม่ได้ (เหตุผลด้านบน: เฟรมกล้องจะเปลี่ยนตามจอ)
   จึงเอา "ภาพฉากของแมป" มาวางเป็นพื้นหลังของ stage แบบ cover ให้เต็มจอแทนสีทึบ
   (play.js เป็นคนใส่ background-image เพราะรูปเก็บเป็น data URI อยู่ในไฟล์แมป)
   ⇒ เห็นเต็มจอ แต่เฟรมเกม 16:9 บนแคนวาสยังเท่าเดิมเป๊ะทุกจอ ไม่กระทบจุดวาง/บล็อกห้อย
   ใช้ background-color แยก (ไม่ใช้ shorthand) ไม่งั้นจะล้าง background-image ที่ JS ใส่ */
html.play-stack-tower-pixel-canvas #play-canvas-stage.play-canvas-stage {
  background-color: #0a0e22 !important;
  background-size: cover !important;
  background-position: center center !important;
  background-repeat: no-repeat !important;
}
/* [2026-08-06] แคนวาสต้อง "โปร่งใส" ไม่งั้นแถบ letterbox ที่เกิดจาก object-fit:contain
   จะถูกทาทับด้วยสีพื้นของตัวแคนวาสเอง (กล่องแคนวาสกว้างเต็มจอ 932px แต่เนื้อภาพ 16:9
   ย่อเหลือ 764px ⇒ เหลือแถบข้างละ 84px) ทำให้ background-image ของ stage ที่วางไว้ข้างหลัง
   มองไม่เห็นเลย — เป็นเหตุผลที่รอบก่อนแก้แล้ว "ยังไม่เต็มจอ"
   ตั้ง transparent ⇒ เห็นภาพฉาก (cover, รักษาสัดส่วน ไม่ยืดเพี้ยน) เต็มจอผ่านแถบนั้น */
html.play-stack-tower-pixel-canvas #play-canvas-stage #game-canvas {
  object-fit: contain !important;
  object-position: center center !important;
  background: transparent !important;
}
