/* ============================================================
   PokStack — Dark Luxury Theme
   Navy + Gold + Velvet
   ============================================================ */

/* ฟ้อนต์โหลดผ่าน <link> ใน HTML แล้ว — แต่ใส่ @import เผื่อ standalone CSS */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700;800&family=Cinzel:wght@600;800&display=swap');

* { margin:0; padding:0; box-sizing:border-box; }

:root {
  --bg-deep: #0a0e27;
  --bg-mid: #131737;
  --bg-light: #1d2148;
  --gold: #d4af37;
  --gold-bright: #f0c75e;
  --gold-soft: #b8941f;
  --red: #c8102e;
  --green-felt: #1a4d3e;
  --green-felt-light: #246b56;
  --text: #f5f1e8;
  --text-dim: #b8b3a3;
  --shadow: rgba(0,0,0,0.6);
}

html {
  /* ★ สำรอง scrollbar space ทั้ง 2 ฝั่ง — กัน content เลื่อนซ้ายตอน scrollbar โผล่ (Windows) */
  scrollbar-gutter: stable both-edges;
}
body {
  font-family: 'Sarabun', 'TH Sarabun New', 'Segoe UI', sans-serif;
  font-size: 16px;
  background:
    radial-gradient(ellipse at top, #1d2148 0%, #0a0e27 60%),
    linear-gradient(135deg, #0a0e27 0%, #131737 100%);
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--text);
  overflow-x: hidden;
  position: relative;
}
/* PC mode — แสดงขอบ "อุปกรณ์มือถือ" ตรงกลาง */
@media (min-width: 600px) {
  body {
    background:
      radial-gradient(ellipse at center, #1d2148 0%, #0a0e27 70%),
      linear-gradient(135deg, #0a0e27 0%, #131737 100%);
  }
  body::after {
    content: '';
    position: fixed;
    top: 0; bottom: 0;
    left: 50%; transform: translateX(-50%);
    width: 100%; max-width: 480px;
    border-left: 1px solid rgba(212,175,55,0.15);
    border-right: 1px solid rgba(212,175,55,0.15);
    pointer-events: none;
    z-index: 0;
  }
}
body.in-game {
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
}
/* ============================================================
   ★ How-to-Play modal — โทนหรู + ใบไพ่จริง
============================================================ */
#howtoModal .modal-box {
  background: linear-gradient(160deg, rgba(15,12,28,0.97) 0%, rgba(40,15,60,0.96) 50%, rgba(28,18,55,0.97) 100%);
  border: 2px solid rgba(255,215,0,0.4);
  box-shadow: 0 20px 60px rgba(0,0,0,0.85), 0 0 60px rgba(255,180,0,0.2);
}
#howtoModal h3 {
  background: linear-gradient(110deg, #ffd700, #ff9d3a, #ff6b6b, #c084fc, #00f5ff, #ffd700);
  background-size: 220% auto;
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 12px rgba(255,215,0,0.5));
  animation: knockTitleShine 3s linear infinite;
  font-family: 'Cinzel','Sarabun',serif;
}
.ht-content {
  font-size: 0.95em; line-height: 1.65;
  color: var(--text);
}
.ht-hero {
  text-align: center;
  padding: 18px 14px;
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(0,245,255,0.15), rgba(192,132,252,0.15));
  border: 1px solid rgba(0,245,255,0.3);
  margin-bottom: 16px;
}
.ht-hero.ht-hero-red {
  background: linear-gradient(160deg, rgba(255,107,107,0.18), rgba(255,180,0,0.15));
  border-color: rgba(255,107,107,0.4);
}
.ht-hero-icon {
  font-size: 2.8em; line-height: 1;
  filter: drop-shadow(0 0 14px rgba(255,215,0,0.55));
  margin-bottom: 4px;
}
.ht-hero h3 {
  font-size: 1.4em;
  margin: 4px 0 2px;
}
.ht-hero-sub {
  color: var(--text-dim, #bbb);
  font-size: 0.85em;
  margin: 0;
  letter-spacing: 0.5px;
}
.ht-quickfacts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.ht-fact {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,215,0,0.18);
  border-radius: 10px;
  padding: 10px 6px;
  text-align: center;
}
.ht-fact-num {
  font-size: 1.3em;
  font-weight: 800;
  color: var(--gold-bright, #ffd700);
  font-family: 'Cinzel','Sarabun',serif;
}
.ht-fact-lbl {
  font-size: 0.78em;
  color: var(--text-dim, #aaa);
  margin-top: 2px;
}
.ht-section {
  margin-bottom: 16px;
}
.ht-section h4 {
  font-size: 1em;
  color: var(--neon, #00f5ff);
  margin: 6px 0 8px;
  padding: 6px 10px;
  background: linear-gradient(90deg, rgba(0,245,255,0.12), transparent);
  border-left: 3px solid var(--neon, #00f5ff);
  border-radius: 4px;
  font-weight: 700;
}
.ht-step {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.ht-step:last-child { border-bottom: none; }
.ht-step-num {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-bright, #ffd700), #ff9d3a);
  color: #1a0a0a;
  font-weight: 900;
  font-size: 0.95em;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(255,180,0,0.45);
}
.ht-step-body {
  flex: 1;
  font-size: 0.92em;
  padding-top: 4px;
}
.ht-card-example {
  margin: 10px 0;
  padding: 10px 12px;
  background: rgba(0,0,0,0.35);
  border-radius: 10px;
  border: 1px solid rgba(255,215,0,0.12);
}
.ht-ex-label {
  font-size: 0.85em;
  color: var(--text, #fff);
  margin-bottom: 8px;
  font-weight: 600;
}
.ht-card-row {
  display: flex; gap: 6px;
  flex-wrap: wrap;
}
.ht-card-row .card.small {
  margin-left: 0 !important;
  cursor: default;
  flex-shrink: 0;
}
.ht-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 4px;
  font-size: 0.88em;
}
.ht-table td {
  padding: 8px 10px;
  background: rgba(0,0,0,0.3);
  vertical-align: top;
}
.ht-table td:first-child {
  width: 110px;
  border-radius: 8px 0 0 8px;
}
.ht-table td:last-child {
  border-radius: 0 8px 8px 0;
}
.ht-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.78em;
  font-weight: 700;
  white-space: nowrap;
}
.ht-tag.good {
  background: rgba(74,222,128,0.18);
  color: #7be087;
  border: 1px solid rgba(74,222,128,0.4);
}
.ht-tag.bad {
  background: rgba(248,113,113,0.18);
  color: #ff8590;
  border: 1px solid rgba(248,113,113,0.4);
}
.ht-mult-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  margin-top: 6px;
}
.ht-mult {
  text-align: center;
  padding: 12px 8px;
  background: rgba(0,0,0,0.35);
  border-radius: 10px;
  border: 1px solid rgba(255,215,0,0.18);
}
.ht-mult-x {
  font-size: 1.6em;
  font-weight: 900;
  color: var(--gold-bright, #ffd700);
  font-family: 'Cinzel','Sarabun',serif;
  line-height: 1;
}
.ht-mult-lbl {
  font-size: 0.82em;
  color: var(--text, #fff);
  margin-top: 4px;
  line-height: 1.3;
}
.ht-mult-lbl small {
  display: block;
  color: var(--text-dim, #999);
  font-size: 0.85em;
  margin-top: 2px;
}

/* ★ Music player buttons */
.mp-btn {
  width: 48px; height: 48px; border-radius: 50%;
  background: linear-gradient(135deg, #00f5ff, #c084fc);
  border: none; color: #0a0e27;
  font-size: 1.1em; font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
  box-shadow: 0 4px 14px rgba(0,245,255,0.35);
}
.mp-btn:hover { transform: scale(1.08); filter: brightness(1.1); }
.mp-btn:active { transform: scale(0.96); }
.mp-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  cursor: pointer;
  transition: background 0.12s ease;
}
.mp-item.active { background: rgba(255,215,0,0.12); border-left: 3px solid var(--gold-bright); }
.mp-item:hover { background: rgba(255,255,255,0.06); }
.mp-item .mp-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-item .mp-name small { color: #888; }
.mp-item .mp-star {
  background: transparent; border: none; cursor: pointer;
  font-size: 1.1em; color: #555;
  padding: 2px 6px; border-radius: 4px;
  transition: color 0.15s ease, transform 0.12s ease;
}
.mp-item .mp-star.active { color: #ffd700; text-shadow: 0 0 8px rgba(255,215,0,0.5); }
.mp-item .mp-star:hover { transform: scale(1.2); }
.mp-item .mp-kind {
  font-size: 0.68em; padding: 2px 6px; border-radius: 4px;
  background: rgba(255,255,255,0.06); color: #aaa; flex-shrink: 0;
}
.mp-btn.active { background: linear-gradient(135deg, #ffd700, #ff8c00); color: #1a1a2e; box-shadow: 0 4px 14px rgba(255,215,0,0.5); }

/* ★ ซ่อน mini music player ตอนอยู่ในเกม/ห้อง — เพลงยังเล่น แต่ไม่บังจอ */
body.hide-mini-music #miniPlayer { display: none !important; }

/* ★ Toggle switch (ใช้ใน admin event panel) */
.toggle-switch { position: relative; display: inline-block; width: 46px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-switch span {
  position: absolute; cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.15);
  border-radius: 24px;
  transition: 0.3s;
}
.toggle-switch span::before {
  position: absolute; content: '';
  height: 18px; width: 18px;
  left: 3px; bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.3s;
}
.toggle-switch input:checked + span {
  background: linear-gradient(135deg, #4ade80, #22c55e);
}
.toggle-switch input:checked + span::before { transform: translateX(22px); }

/* ★ Leaderboard tabs (ดัมมี่/ป๊อกเด้ง) ใน rank modal */
.lb-tabs { gap: 6px; }
.lb-tab-btn {
  flex: 1;
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  color: var(--text-dim, #9ca3cf);
  font-family: inherit; font-weight: 700; font-size: 0.86em;
  cursor: pointer;
  transition: all 0.18s ease;
}
.lb-tab-btn:hover { color: #fff; border-color: rgba(0,245,255,0.4); }
.lb-tab-btn.active {
  background: linear-gradient(135deg, #00f5ff, #c084fc);
  color: #0a0e27;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(0,245,255,0.4);
}

/* iOS fake fullscreen — เต็มจอผ่าน CSS (จับ URL bar ของ Safari ไม่ได้ แต่ขยายใช้พื้นที่เต็มที่) */
body.fake-fullscreen {
  position: fixed; inset: 0;
  height: 100vh; height: 100dvh;
  width: 100vw;
  overflow: hidden;
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
body.fake-fullscreen .top-bar {
  padding-top: calc(10px + env(safe-area-inset-top, 0));
}

/* ★ iOS-only: ระหว่างเล่นเกม (ดัมมี่/ป๊อกเด้ง) — ซ่อนเมนูบาร์ทั้งแถบ
   เหลือแค่ปุ่ม ☰ ลอยมุมขวาบน (เพราะ iOS Safari เข้าเต็มจอ Fullscreen API ไม่ได้)
   ตอนออกจากเกม → bar กลับมาปกติเอง (class ถูกถอดใน show()) */
body.ios-game-slim #topBar {
  background: transparent !important;
  border-bottom: none !important;
  backdrop-filter: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  pointer-events: none;          /* คลิกทะลุ bar ได้ — ยกเว้นปุ่ม ☰ ที่ re-enable */
  width: auto !important;
  max-width: none !important;
  left: auto !important;
  right: 0 !important;
  transform: none !important;
}
body.ios-game-slim #topBar > *:not(#profileMenuBtn):not(#profileMenu) {
  display: none !important;
}
body.ios-game-slim #topBar #profileMenuBtn.menu-trigger {
  pointer-events: auto;
  margin: calc(env(safe-area-inset-top, 0) + 6px) 8px 0 0;
  background: rgba(13,17,46,0.7);
  border-color: rgba(212,175,55,0.55);
  box-shadow: 0 4px 12px rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);
}
/* dropdown menu — ให้ยังเปิดได้ และอยู่ใต้ ☰ */
body.ios-game-slim #topBar #profileMenu {
  pointer-events: auto;
  right: 8px;
  top: calc(env(safe-area-inset-top, 0) + 52px);
}
/* ★ ขยับเนื้อหาเกมขึ้นชิดบน — เพราะ topBar ถูกซ่อนแล้ว
   safe-area-inset-top เผื่อ notch ของ iPhone
   padding-bottom เผื่อ Safari URL bar ล่าง (~32-44px) — กันมือไพ่โดนบัง */
body.ios-game-slim #screen-game.active {
  padding-top: calc(env(safe-area-inset-top, 0px) + 4px) !important;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 32px) !important;
  gap: 2px !important;                      /* บีบช่องว่างระหว่างส่วน */
}
body.ios-game-slim #screen-pokdeng.active {
  padding-top: calc(env(safe-area-inset-top, 0px) + 4px) !important;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 32px) !important;
}
/* บีบ game-top ให้แคบลง — เพื่อให้โต๊ะ + มือไพ่ ขยับขึ้นได้ */
body.ios-game-slim #screen-game .game-top {
  gap: 3px !important;
}
body.ios-game-slim #screen-game .game-top-row {
  padding: 4px 6px !important;
  gap: 3px !important;
}
body.ios-game-slim #screen-game .game-top-row .info-pill {
  padding: 3px 7px !important;
  font-size: 0.78em !important;
}
body.ios-game-slim #screen-game .turn-msg-row {
  padding: 4px 8px !important;
  font-size: 0.78em !important;
}
/* บีบ discard pile (กองทิ้ง) */
body.ios-game-slim #screen-game .discard-pile {
  min-height: 64px !important;
  padding: 4px 6px 4px 14px !important;
}
body.ios-game-slim #screen-game .discard-row {
  gap: 6px !important;
}
/* บีบช่อง meld (ช่องเกิด) — เอาช่องว่างให้มือไพ่ */
body.ios-game-slim #screen-game .melds-grid {
  gap: 3px !important;
}
body.ios-game-slim #screen-game .meld-slot {
  padding: 3px !important;
  font-size: 0.78em !important;
}
/* ★ ดันมือไพ่ขึ้น — ลด padding-top จาก 40px → 22px (ยังพอลอย hover ได้)
   เพิ่ม margin-bottom ให้ห่างจากขอบล่างของ Safari */
body.ios-game-slim .my-area .my-hand {
  padding-top: 22px !important;
  padding-bottom: 4px !important;
  min-height: 86px !important;
}
body.ios-game-slim .my-area .hand-toolbar {
  margin-bottom: 3px !important;
}
body.ios-game-slim .log-panel {
  max-height: 22px !important;  /* แสดงแค่ 1 บรรทัด — ประหยัดพื้นที่ */
  padding: 3px 8px !important;
  font-size: 0.75em !important;
}

/* ============================================================
   iOS Install Guide modal — สอนวิธี Add to Home Screen
============================================================ */
.ios-fs-guide { z-index: 99999; }
.ios-fs-guide .ios-fs-box {
  max-width: 360px;
  background: linear-gradient(160deg, rgba(15,18,40,0.98) 0%, rgba(28,18,55,0.98) 60%, rgba(45,20,70,0.98) 100%);
  border: 2px solid rgba(0,245,255,0.55);
  border-radius: 22px;
  padding: 24px 22px 18px;
  text-align: center;
  box-shadow:
    0 0 0 1px rgba(192,132,252,0.4),
    0 0 60px rgba(0,245,255,0.35),
    0 20px 60px rgba(0,0,0,0.85);
  animation: iosFsBoxIn 0.45s cubic-bezier(.18,.89,.32,1.28) forwards;
}
@keyframes iosFsBoxIn {
  0%   { transform: scale(0.6) translateY(20px); opacity: 0; }
  60%  { transform: scale(1.04) translateY(0); opacity: 1; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}
.ios-fs-icon {
  font-size: 3em;
  filter: drop-shadow(0 0 12px rgba(0,245,255,0.7));
  animation: iosFsIconBob 1.8s ease-in-out infinite;
}
@keyframes iosFsIconBob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%      { transform: translateY(-4px) rotate(3deg); }
}
.ios-fs-title {
  margin: 8px 0 4px;
  font-size: 1.35em;
  font-weight: 900;
  letter-spacing: 0.5px;
  background: linear-gradient(110deg, #00f5ff, #c084fc, #f0abfc, #00f5ff);
  background-size: 220% auto;
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 10px rgba(0,245,255,0.5));
  animation: knockTitleShine 3s linear infinite;
}
.ios-fs-desc {
  font-size: 0.82em;
  color: #d4d8ee;
  line-height: 1.45;
  margin: 6px 6px 14px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
.ios-fs-steps {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
  text-align: left;
  display: flex; flex-direction: column; gap: 9px;
}
.ios-fs-steps li {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  background: rgba(0,245,255,0.06);
  border: 1px solid rgba(0,245,255,0.22);
  border-radius: 10px;
  font-size: 0.85em;
  color: #eef2ff;
}
.ios-fs-steps li strong { color: #ffd54a; }
.ios-fs-num {
  flex-shrink: 0;
  width: 24px; height: 24px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.85em;
  background: linear-gradient(135deg, #00f5ff, #c084fc);
  color: #0a0e27;
  box-shadow: 0 2px 6px rgba(0,245,255,0.5);
}
.ios-fs-share, .ios-fs-plus {
  display: inline-block;
  font-size: 1.1em;
  filter: drop-shadow(0 0 4px rgba(255,215,0,0.6));
}
.ios-fs-close {
  width: 100%;
  padding: 11px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #00f5ff 0%, #c084fc 100%);
  color: #0a0e27;
  font-weight: 800;
  font-size: 0.95em;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,245,255,0.45), inset 0 1px 0 rgba(255,255,255,0.4);
  transition: transform 0.18s ease, filter 0.18s ease;
}
.ios-fs-close:hover { transform: translateY(-2px); filter: brightness(1.1); }
.ios-fs-close:active { transform: translateY(0); }

/* Subtle pattern overlay */
body::before {
  content:'';
  position: fixed; inset:0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(212,175,55,0.08) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(200,16,46,0.06) 0%, transparent 40%);
  pointer-events: none;
  z-index: 0;
}

/* Mobile-first: ทุก screen เต็มความกว้างมือถือ — บน PC จำกัด max-width ให้เห็นเหมือนเล่นมือถือ */
.screen {
  display:none;
  padding: 16px 14px;
  min-height: 100vh;
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  box-sizing: border-box;
}
.screen.active { display: block; animation: screen-fade-in 0.18s ease-out; }
/* ★ Screen transition — fade in นุ่มนวลทุกครั้งที่เปลี่ยน screen */
@keyframes screen-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* ★ Splash overlay — ลอยทับทุกอย่าง / มี class .hidden เพื่อปิด */
.splash-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: linear-gradient(135deg, #0d1320 0%, #1a2438 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.splash-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.splash-inner {
  text-align: center;
  animation: splash-fade 0.4s ease-out;
}
.splash-emoji {
  font-size: 5em;
  margin-bottom: 8px;
  animation: splash-pulse 1.4s ease-in-out infinite;
}
.splash-title {
  font-family: 'Cinzel', serif;
  color: var(--gold-bright);
  margin: 0 0 6px;
  font-size: 1.6em;
}
.splash-loading {
  color: #aaa;
  font-size: 0.95em;
}
.splash-dots {
  margin-top: 18px;
  display: flex;
  gap: 6px;
  justify-content: center;
}
@keyframes splash-fade {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes splash-pulse {
  0%, 100% { transform: scale(1) rotate(-2deg); filter: drop-shadow(0 0 12px rgba(212,175,55,0.4)); }
  50%      { transform: scale(1.08) rotate(2deg); filter: drop-shadow(0 0 22px rgba(212,175,55,0.7)); }
}
.splash-dot {
  width: 8px; height: 8px;
  background: var(--gold-bright);
  border-radius: 50%;
  animation: splash-bounce 1.2s ease-in-out infinite;
}
.splash-dot:nth-child(2) { animation-delay: 0.2s; }
.splash-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes splash-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40%           { transform: translateY(-10px); opacity: 1; }
}
#screen-auth.active, #screen-lobby.active {
  display: flex; flex-direction: column;
  justify-content: center;
  align-items: center;     /* ★ จัดให้ card-box อยู่กลางแนวนอน (max-width 420px ภายใน screen 480px) */
}

/* ============================================================
   Card Box → กลายเป็น "Section wrapper" แบบโปร่ง mobile-app
   ============================================================ */
.card-box {
  color: var(--text);
  padding: 12px 0;
  width: 100%;
  text-align: center;
  position: relative;
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
}
/* ลบเส้นทองรอบ card-box ออก */
.card-box::before { display: none; }
/* หน้า auth คงไว้ให้ดูพิเศษ */
#screen-auth .card-box {
  background:
    radial-gradient(ellipse at top, rgba(212,175,55,0.08), transparent 60%),
    linear-gradient(145deg, rgba(29,33,72,0.95), rgba(19,23,55,0.98));
  padding: 28px;
  border-radius: 20px;
  box-shadow:
    0 20px 60px rgba(0,0,0,0.8),
    0 0 0 1px rgba(212,175,55,0.3),
    inset 0 1px 0 rgba(255,255,255,0.1);
  max-width: 420px;
}
.card-box h1 {
  font-family: 'Cinzel', serif;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold-soft));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  font-size: 2.4em; margin-bottom: 6px;
  letter-spacing: 2px;
  filter: drop-shadow(0 2px 4px rgba(212,175,55,0.4));
}
.card-box h2 {
  color: var(--gold-bright);
  margin: 14px 0 12px;
  font-size: 1.25em; font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-family: 'Cinzel', 'Sarabun', serif;
  text-align: center;
  position: relative;
  padding-bottom: 8px;
}
.card-box h2::after {
  content:''; position:absolute;
  bottom: 0; left: 50%; transform: translateX(-50%);
  width: 60px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.subtitle { color: var(--text-dim); margin-bottom:20px; font-size:0.9em; }
.divider {
  color: var(--text-dim); margin: 16px 0; font-size:0.85em;
  position:relative; display:flex; align-items:center; gap:10px;
}
.divider::before, .divider::after {
  content:''; flex:1; height:1px;
  background: linear-gradient(90deg, transparent, rgba(212,175,55,0.3), transparent);
}

/* ============================================================
   Inputs
   ============================================================ */
input[type="text"], input[type="password"], input[type="number"] {
  width: 100%;
  padding: 12px 16px;
  background: rgba(10,14,39,0.6);
  border: 1px solid rgba(212,175,55,0.3);
  border-radius: 10px;
  font-size: 0.95em;
  margin-bottom: 10px;
  font-family: inherit;
  color: var(--text);
  transition: all 0.2s;
}
input:focus {
  outline:none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212,175,55,0.15);
}
input::placeholder { color: rgba(184,179,163,0.5); }

/* ============================================================
   Buttons
   ============================================================ */
button {
  font-family: inherit; cursor:pointer; border:none;
  font-weight: 600; transition: all 0.2s;
}
.btn-primary {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold-soft));
  color: #1a1500;
  width: 100%; padding: 13px;
  border-radius: 10px;
  font-size: 1em; margin-bottom: 8px;
  box-shadow: 0 4px 12px rgba(212,175,55,0.3),
              inset 0 1px 0 rgba(255,255,255,0.4);
  text-shadow: 0 1px 0 rgba(255,255,255,0.3);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(212,175,55,0.5),
              inset 0 1px 0 rgba(255,255,255,0.4);
  filter: brightness(1.05);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
  background: linear-gradient(180deg, #555, #333);
  color: #888; cursor:not-allowed; box-shadow: none;
}

.btn-secondary {
  background: rgba(255,255,255,0.05);
  color: var(--text);
  width: 100%; padding: 12px;
  border-radius: 10px;
  font-size: 0.95em; margin-bottom: 8px;
  border: 1px solid rgba(212,175,55,0.3);
}
.btn-secondary:hover {
  background: rgba(212,175,55,0.1);
  border-color: var(--gold);
}

.btn-mini {
  background: rgba(0,0,0,0.4);
  color: var(--text);
  padding: 6px 14px; border-radius: 8px;
  font-size: 0.85em;
  border: 1px solid rgba(212,175,55,0.2);
}
.btn-mini:hover { border-color: var(--gold); background: rgba(212,175,55,0.15); }

/* Game watermark — mode/rate ลอยทับจอเป็นตัวอ่อน 5% */
#screen-game { position: relative; }
.game-watermark {
  position: relative;
  pointer-events: none;
  z-index: 1;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: 'Cinzel', serif;
  color: rgba(255,255,255,0.28);
  text-align: center;
  user-select: none;
  padding: 1px 6px;
  margin: 0;
  flex-wrap: wrap;
  min-height: 18px;          /* ★ คุมระยะห่างระหว่าง discard กับ meld-grid ≈ 20-25px */
}
.game-watermark .gw-rate {
  font-size: clamp(0.62em, 2.2vw, 0.82em);
  font-weight: 700;
  letter-spacing: 1px;
  line-height: 1;
}
.game-watermark .gw-mode {
  font-size: clamp(0.58em, 1.9vw, 0.74em);
  font-weight: 500;
  letter-spacing: 1px;
  opacity: 0.85;
  margin: 0;
}
.game-watermark .gw-mode::before {
  content: '·';
  margin-right: 6px;
  opacity: 0.6;
}

.btn-action {
  background: linear-gradient(180deg, #2d3672, #1d2148);
  color: var(--text);
  padding: 2.5px 18px;
  border-radius: 8px;
  font-size: 1.6em;
  font-weight: 800;
  margin: 4px;
  min-width: 80px;
  border: 1px solid rgba(212,175,55,0.4);
  box-shadow: 0 3px 10px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.08);
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.18s ease;
  line-height: 1.4;
}
.btn-action:hover {
  background: linear-gradient(180deg, #3d4690, #2d3672);
  border-color: var(--gold);
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(212,175,55,0.25);
}
.btn-action:active { transform: translateY(0); filter: brightness(1.1); }
.btn-action:disabled {
  opacity: 0.4; cursor: not-allowed; transform: none;
}
.btn-action.btn-primary-action {
  background: linear-gradient(180deg, var(--gold-bright), #b8860b);
  color: #1a1a2e;
  border-color: var(--gold-bright);
  box-shadow: 0 4px 14px rgba(212,175,55,0.45), inset 0 1px 0 rgba(255,255,255,0.3);
}
.btn-action.btn-primary-action:hover {
  filter: brightness(1.08);
  box-shadow: 0 6px 18px rgba(212,175,55,0.6);
}
@media (max-width: 480px) {
  .btn-action {
    padding: 2.5px 16px;
    font-size: 1.55em;
    min-width: 76px;
    flex: 1;
  }
}
.btn-danger {
  background: linear-gradient(180deg, #d8243f, #8a0a1f);
  border-color: rgba(255,255,255,0.15);
}
.btn-danger:hover {
  background: linear-gradient(180deg, #e83855, #c8102e);
}

/* ============================================================
   Tabs
   ============================================================ */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; }
.tab-btn {
  flex: 1; padding: 10px;
  background: rgba(255,255,255,0.05);
  color: var(--text-dim);
  border-radius: 8px;
  font-size: 0.9em; font-weight: 600;
  border: 1px solid transparent;
}
.tab-btn.active {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold-soft));
  color: #1a1500;
  border-color: var(--gold);
}
.tab-pane { display:none; }
.tab-pane.active { display:block; }

/* ============================================================
   User bar
   ============================================================ */
.user-bar {
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(135deg, rgba(212,175,55,0.1), rgba(212,175,55,0.05));
  border: 1px solid rgba(212,175,55,0.2);
  padding: 10px 14px;
  border-radius: 10px; margin-bottom: 16px;
  font-size: 0.9em; gap: 8px;
  flex-wrap: wrap;
}

/* ============================================================
   Game cards (selectors)
   ============================================================ */
.game-select { display: flex; gap: 8px; margin-bottom: 12px; }
.game-card {
  flex: 1; padding: 16px 8px;
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border-radius: 10px;
  font-weight: 600; cursor: pointer;
  border: 2px solid transparent;
}
.game-card.active {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold-soft));
  color: #1a1500; border-color: var(--gold);
}
.game-card.disabled {
  opacity: 0.4; cursor: not-allowed;
  border: 1px dashed rgba(255,255,255,0.2);
}

.rate-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px; margin-bottom: 16px;
}
.rate-card {
  background:
    linear-gradient(180deg, rgba(29,33,72,0.85), rgba(13,17,46,0.92));
  padding: 14px 8px;
  border-radius: 12px;
  border: 2px solid rgba(212,175,55,0.25);
  cursor: pointer; text-align: center;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0,0,0,0.4);
}
.rate-card::before {
  content:''; position:absolute; top:0; left:0; right:0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.6;
}
.rate-card:hover {
  border-color: var(--gold);
  transform: translateY(-3px);
  box-shadow: 0 10px 20px rgba(212,175,55,0.35);
}
.rate-card.active {
  background:
    radial-gradient(ellipse at top, rgba(212,175,55,0.3), transparent 60%),
    linear-gradient(180deg, rgba(29,33,72,0.85), rgba(13,17,46,0.92));
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(212,175,55,0.5), inset 0 1px 0 rgba(255,255,255,0.15);
}
.rate-card .rate-name {
  font-weight: 800; font-size: 1.05em;
  color: var(--gold-bright);
  font-family: 'Cinzel', sans-serif;
  letter-spacing: 1px;
  margin-bottom: 4px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}
.rate-card .rate-fee {
  font-size: 0.78em; color: var(--text-dim);
  background: rgba(0,0,0,0.3);
  padding: 2px 8px;
  border-radius: 8px;
  display: inline-block;
}
.rate-rooms {
  margin-top: 6px;
  display: flex; gap: 4px; justify-content: center;
  flex-wrap: wrap;
  font-size: 0.72em;
}
.rate-rooms .rr-wait {
  background: rgba(78,255,122,0.15);
  color: #4eff7a;
  padding: 2px 6px; border-radius: 8px;
  border: 1px solid rgba(78,255,122,0.3);
}
.rate-rooms .rr-play {
  background: rgba(200,16,46,0.15);
  color: #ff7a8c;
  padding: 2px 6px; border-radius: 8px;
  border: 1px solid rgba(200,16,46,0.3);
}
/* ★ v3.8: badge "คนออนไลน์" — โทนทอง เหมือนหน้า game-pick (legacy ใน .rate-rooms ยังคงไว้เผื่อใช้ที่อื่น) */
.rate-rooms .rr-online {
  background: rgba(212,175,55,0.15);
  color: var(--gold-bright);
  padding: 2px 6px; border-radius: 8px;
  border: 1px solid rgba(212,175,55,0.35);
}
.rate-rooms .rr-empty {
  color: var(--text-dim);
  opacity: 0.6;
}

/* ★ v3.9: Online badge ฟิกขวาบนของ rate-card — เห็นเด่นตลอด ไม่กระจายกับ wait/play */
.rate-card .rate-online-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: linear-gradient(135deg, rgba(212,175,55,0.28), rgba(212,175,55,0.15));
  color: #ffd54a;
  padding: 3px 8px;
  border-radius: 10px;
  border: 1px solid rgba(212,175,55,0.5);
  font-size: 0.72em;
  font-weight: 700;
  letter-spacing: 0.3px;
  z-index: 2;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  text-shadow: 0 1px 1px rgba(0,0,0,0.5);
}
@media (max-width: 600px) {
  .rate-card .rate-online-badge { top: 4px; right: 4px; padding: 2px 6px; font-size: 0.68em; }
}

/* ============================================================
   Lobby - players list
   ============================================================ */
.player-list {
  background: rgba(0,0,0,0.3);
  border-radius: 10px;
  padding: 12px; margin-bottom: 16px; min-height: 80px;
  border: 1px solid rgba(212,175,55,0.15);
}
.player-list .player {
  background: linear-gradient(135deg, rgba(212,175,55,0.1), transparent);
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 6px;
  display: flex; justify-content: space-between;
  border-left: 3px solid var(--gold);
}
.note { color: var(--text-dim); font-size: 0.82em; margin-top: 8px; }

/* ============================================================
   GAME SCREEN — Casino Felt Table
   ============================================================ */
#screen-game.active {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 77px 6px 6px;
  height: 100vh;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  overflow: hidden;
  background:
    radial-gradient(ellipse at center, rgba(36,107,86,0.4) 0%, transparent 70%),
    radial-gradient(ellipse at top, #1d2148 0%, #0a0e27 60%);
  background-attachment: fixed;
}

.game-top {
  display: flex; flex-direction: column; gap: 6px;
  flex-shrink: 0;
  background: transparent;
  padding: 0;
  border: none;
}
.game-top-row {
  display: flex; gap: 4px; align-items: center;
  flex-wrap: wrap;
  background: linear-gradient(180deg, rgba(0,0,0,0.6), rgba(0,0,0,0.4));
  border: 1px solid rgba(212,175,55,0.2);
  backdrop-filter: blur(8px);
  border-radius: 10px;
  padding: 6px 8px;
}
.turn-msg-row {
  width: 100%;
  text-align: center;
  font-size: 0.85em !important;
  padding: 6px 10px !important;
  background: linear-gradient(180deg, rgba(0,0,0,0.55), rgba(0,0,0,0.35)) !important;
  border: 1px solid rgba(212,175,55,0.18) !important;
  border-radius: 10px !important;
  color: var(--text-dim) !important;
  margin: 0 !important;
  backdrop-filter: blur(8px);
}
.info-pill {
  background: rgba(0,0,0,0.4);
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.7em;
  border: 1px solid rgba(212,175,55,0.2);
}
.info-pill span { font-weight: bold; color: var(--gold-bright); }

/* ★ Pok Deng banner themes — applied to #pdTurnMsg (info-pill) ตอน countdown/pause/success */
.turn-msg-row.pd-banner-pending {
  background: linear-gradient(180deg, rgba(212,175,55,0.28), rgba(184,134,11,0.20)) !important;
  color: #fff8d8 !important;
  border-color: rgba(212,175,55,0.55) !important;
  font-weight: 700 !important;
  animation: pd-banner-pulse 1.6s ease-in-out infinite;
}
.turn-msg-row.pd-banner-paused {
  background: linear-gradient(180deg, rgba(196,30,58,0.22), rgba(120,20,40,0.18)) !important;
  color: #ffd0d0 !important;
  border-color: rgba(196,30,58,0.55) !important;
  font-weight: 700 !important;
}
.turn-msg-row.pd-banner-success {
  background: linear-gradient(180deg, rgba(78,255,122,0.22), rgba(20,120,40,0.18)) !important;
  color: #d6ffe0 !important;
  border-color: rgba(78,255,122,0.55) !important;
  font-weight: 700 !important;
}
.turn-msg-row.pd-banner-pending strong,
.turn-msg-row.pd-banner-paused strong,
.turn-msg-row.pd-banner-success strong {
  color: inherit;
  font-size: 1.2em;
}
@keyframes pd-banner-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212,175,55,0.0); }
  50%      { box-shadow: 0 0 12px 0 rgba(212,175,55,0.45); }
}

/* Opponents */
.opponents {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}
.opponent {
  background: linear-gradient(145deg, rgba(29,33,72,0.8), rgba(19,23,55,0.95));
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 10px;
  text-align: center;
  position: relative;
  transition: all 0.3s;
}
.opponent.current {
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(212,175,55,0.5);
  animation: pulse-glow 1.6s ease-in-out infinite;
}
@keyframes pulse-glow {
  0%,100% { box-shadow: 0 0 12px rgba(212,175,55,0.4); }
  50% { box-shadow: 0 0 24px rgba(212,175,55,0.7); }
}
.opponent .opp-name {
  font-weight: bold; margin-bottom: 4px;
  color: var(--text); font-size: 0.92em;
}
.opponent .opp-info { font-size: 0.75em; color: var(--text-dim); }
.opponent .opp-cards {
  display: flex; gap: 2px; justify-content: center; margin-top: 6px;
}
.opp-cards .mini-back {
  width: 18px; height: 26px;
  background:
    repeating-linear-gradient(45deg, #c8102e 0 4px, #8a0a1f 4px 8px);
  border: 1px solid var(--gold-soft);
  border-radius: 3px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.melded-tag, .offline-tag {
  display: inline-block;
  font-size: 0.7em; padding: 1px 6px;
  border-radius: 8px; margin-left: 4px;
}
.melded-tag { background: linear-gradient(180deg, #4caf50, #2e7d32); color: #fff; }
.offline-tag { background: #555; color: #ccc; }

.opponent.offline { opacity: 0.45; filter: grayscale(0.8); }

/* ============================================================
   Table area — felt
   ============================================================ */
.table-area {
  background:
    radial-gradient(ellipse at center, rgba(36,107,86,0.95) 0%, rgba(26,77,62,0.95) 80%);
  border-radius: 14px;
  padding: 8px;
  display: flex; flex-direction: column; gap: 4px;
  min-height: 0;
  flex: 1;
  border: 3px solid var(--gold-soft);
  box-shadow:
    inset 0 0 40px rgba(0,0,0,0.5),
    0 8px 24px rgba(0,0,0,0.6),
    0 0 0 1px var(--gold);
  position: relative;
  overflow: hidden;
}
.discard-pile-area { flex-shrink: 0; }
/* table-row (กองจั่ว) เว้นที่ให้ seat บน */
.table-area .table-row { padding: 0 24%; min-height: 0; }

/* กองจั่วอยู่หน้ากองทิ้ง (ซ้าย) — แถวเดียวกัน */
.discard-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
}
.draw-pile-inline {
  flex-shrink: 0;
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  gap: 2px;
}
/* drawPile ขนาดเดียวกับไพ่ในกองทิ้ง — ปรับตาม viewport */
.draw-pile-inline .draw-pile,
.draw-pile-inline .card-back {
  width: 50px;
  height: 70px;
}
@media (max-width: 480px) {
  .draw-pile-inline .draw-pile,
  .draw-pile-inline .card-back {
    width: 38px;
    height: 54px;
  }
}
.draw-pile-inline .deck-count {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  font-size: 0.72em;
  color: var(--gold-bright);
  font-weight: 700;
  text-align: center;
  background: rgba(0,0,0,0.85);
  padding: 1px 8px;
  border-radius: 8px;
  border: 1px solid rgba(212,175,55,0.55);
  white-space: nowrap;
}
.discard-row .discard-pile { flex: 1; }
.table-area::before {
  content:''; position:absolute; inset:6px;
  border: 1px solid rgba(212,175,55,0.3);
  border-radius: 10px;
  pointer-events: none;
}

.table-row {
  display: flex; justify-content: center; gap: 24px; flex-wrap: wrap;
  align-items: flex-end;
}
.pile-group { text-align: center; }
.pile-label {
  font-size: 0.72em; color: var(--gold-bright);
  margin-bottom: 4px; font-weight: 600;
  letter-spacing: 1px; text-transform: uppercase;
}

.head-card, .draw-pile {
  width: 60px; height: 84px;
  display: flex; align-items: center; justify-content: center;
}
.head-card.empty {
  border: 2px dashed rgba(255,255,255,0.2);
  border-radius: 8px;
  font-size: 0.7em; color: var(--text-dim);
}
.head-card .card { box-shadow: 0 0 16px rgba(212,175,55,0.6); }

.draw-pile { cursor: pointer; transition: transform 0.15s; }
.draw-pile:hover { transform: translateY(-3px); }
.card-back {
  width: 60px; height: 84px;
  background:
    repeating-linear-gradient(45deg, #c8102e 0 6px, #8a0a1f 6px 12px),
    linear-gradient(135deg, #c8102e, #6a0a1f);
  border: 2px solid var(--gold);
  border-radius: 8px;
  box-shadow:
    2px 2px 0 #6a0a1f,
    0 4px 8px rgba(0,0,0,0.6),
    inset 0 0 0 2px rgba(212,175,55,0.3);
  position: relative;
}
.card-back::after {
  content: '♣'; position:absolute;
  top:50%; left:50%; transform: translate(-50%,-50%);
  color: var(--gold); font-size: 1.5em;
  text-shadow: 0 0 8px rgba(0,0,0,0.7);
}

/* ============================================================
   Discard pile — fanned row
   ============================================================ */
.discard-pile-area {
  flex: 1; min-width: 200px;
  text-align: center;
}
.discard-pile {
  display: flex; align-items: flex-start; justify-content: flex-start;
  flex-wrap: wrap;
  min-height: 88px;
  padding: 8px 8px 8px 16px; /* เพิ่ม padding-left เผื่อที่ให้ icon มงกุฏ/ดาวลอยซ้ายของใบแรก */
  gap: 4px 0;
  background: rgba(0,0,0,0.25);
  border-radius: 10px;
  overflow: visible; /* ให้ icon มงกุฏ/ดาว ที่ลอยออกซ้ายแสดงได้เต็ม ไม่ถูกตัด */
  border: 1px dashed rgba(212,175,55,0.2);
  /* ★ Smooth transition เวลากองโตขยาย/ย่อ (melds-grid ที่อยู่ล่างจะเลื่อนตามอัตโนมัติ) */
  transition: min-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.discard-pile.empty {
  justify-content: center;
  color: var(--text-dim); font-size: 0.8em;
}
.discard-pile .card {
  flex-shrink: 0;
  margin-left: -36px; cursor: pointer;
  /* ★ Transition เฉพาะ transform/box-shadow (hover effect) — ไม่ใส่ width/height/margin
     เพราะจะกระพริบทุกครั้งที่ renderGame setStyle ใหม่ ไพ่ใบที่เพิ่งทิ้งใช้ animation .fresh แทน */
  transition: transform 0.2s, box-shadow 0.2s;
}
/* Animation เฉพาะ "ใบใหม่" ที่เพิ่งถูกทิ้ง — ใส่ class ทาง JS ตอน detect ว่าใหม่ */
.discard-pile .card.fresh {
  animation: discard-slide 0.4s ease-out;
}
.discard-pile .card:first-child { margin-left: 0; }
.discard-pile .card:hover {
  transform: translateY(-10px);
  z-index: 10;
  box-shadow: 0 6px 16px rgba(212,175,55,0.6);
}
.discard-pile .card.pickable-from {
  /* ลอยขึ้นเหมือน :hover */
  transform: translateY(-10px);
  z-index: 10;
  outline: 2px solid var(--gold-bright);
  box-shadow: 0 0 14px rgba(212,175,55,0.7), 0 6px 16px rgba(212,175,55,0.5);
}

@keyframes discard-slide {
  from { transform: translateY(-30px) translateX(20px); opacity: 0; }
  to { transform: translateY(0) translateX(0); opacity: 1; }
}

/* ============================================================
   Melds
   ============================================================ */
.melds-area {
  display: flex; flex-wrap: wrap; gap: 10px;
  min-height: 90px;
  background: rgba(0,0,0,0.25);
  border-radius: 10px;
  padding: 10px;
  border: 1px solid rgba(212,175,55,0.15);
}
.melds-empty {
  opacity: 0.4; font-size: 0.85em; padding: 8px;
  color: var(--text-dim); width: 100%; text-align: center;
}
.meld-group {
  background: linear-gradient(135deg, rgba(212,175,55,0.15), rgba(212,175,55,0.05));
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid rgba(212,175,55,0.3);
  transition: all 0.2s;
}
.meld-group.selectable:hover {
  border-color: var(--gold-bright);
  box-shadow: 0 0 12px rgba(212,175,55,0.4);
}
.meld-group .meld-owner {
  font-size: 0.7em; color: var(--gold-bright);
  margin-bottom: 4px; text-transform: uppercase;
  letter-spacing: 0.5px;
}
.meld-group .meld-cards { display: flex; gap: 2px; }

/* ============================================================
   Cards — SVG-style faces
   ============================================================ */
.card {
  width: 50px; height: 70px;
  background: linear-gradient(155deg, #fffef9 0%, #f5efe0 100%);
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-weight: bold;
  user-select: none; cursor: pointer;
  position: relative;
  box-shadow:
    0 2px 4px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.6);
  transition: transform 0.15s, box-shadow 0.15s;
  overflow: hidden;
}
.card.small { width: 38px; height: 54px; font-size: 0.78em; }
/* ไพ่เล็ก: เหลือแค่มุมซ้ายบนเดียว (ตัวเลข + ดอก) */
.card.small .rank,
.card.small .suit,
.card.small .corner-br { display: none; }
.card.small .corner-tl { font-size: 1em; }
.card.large { width: 60px; height: 84px; font-size: 1.1em; }
.card .rank {
  font-size: 1.05em; line-height: 1;
  font-weight: 700; letter-spacing: -1px;
}
.card .suit {
  font-size: 1.15em; line-height: 1;
  margin-top: 2px;
}
.card .corner {
  position: absolute;
  font-size: 0.6em; line-height: 1;
  font-weight: 700;
}
.card .corner-tl { top: 3px; left: 4px; text-align: left; }
.card .corner-br {
  bottom: 3px; right: 4px;
  text-align: right;
  transform: rotate(180deg);
}
.card.red, .card.red .corner { color: #c8102e; }
.card.black, .card.black .corner { color: #1a1a1a; }

.card.speto {
  position: relative;
  overflow: visible !important;
}
.card.speto::after {
  content: '⭐';
  position: absolute;
  top: 50%; left: -10px;
  transform: translateY(-50%);
  font-size: 1em;
  text-shadow: 0 1px 3px rgba(0,0,0,0.85), 0 0 4px rgba(0,0,0,0.6);
  pointer-events: none;
  z-index: 5;
}
/* สเปโตเป็นหัว → ดาวขยับลงล่าง เปิดที่ให้มงกุฏด้านบน */
.card.speto.head-card-glow::after {
  top: auto; bottom: -8px; left: -8px; transform: none;
  font-size: 0.95em;
}

/* My hand */
.my-area {
  background: linear-gradient(180deg, rgba(0,0,0,0.4), rgba(0,0,0,0.2));
  border-radius: 12px; padding: 12px;
  border: 1px solid rgba(212,175,55,0.2);
  /* ★ iOS safe-area: เผื่อพื้นที่ home indicator + Safari bottom bar */
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px) + 28px);
  margin-bottom: env(safe-area-inset-bottom, 0px);
}
.my-info {
  margin-bottom: 8px; font-weight: 600;
  color: var(--gold-bright); font-size: 0.95em;
}
.badge {
  background: linear-gradient(180deg, #4caf50, #2e7d32);
  color: #fff; font-size: 0.72em;
  padding: 2px 8px; border-radius: 10px; margin-left: 8px;
}
.my-hand {
  display: flex; flex-wrap: wrap; gap: 5px;
  min-height: 80px; padding: 8px;
  background: rgba(0,0,0,0.25);
  border-radius: 8px; margin-bottom: 10px;
  border: 1px dashed rgba(212,175,55,0.2);
}
.my-hand .card { cursor: pointer; }
.my-hand .card:hover {
  transform: translateY(-8px);
  box-shadow: 0 6px 12px rgba(212,175,55,0.4);
}
.my-hand .card.selected {
  transform: translateY(-14px);
  box-shadow:
    0 0 0 3px var(--gold),
    0 8px 16px rgba(212,175,55,0.6);
}

.actions { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.hint {
  font-size: 0.83em; color: var(--text);
  background: rgba(212,175,55,0.08);
  padding: 7px 12px;
  border-radius: 8px;
  border-left: 3px solid var(--gold);
}

/* Log — hidden on game screen for mobile */
.log-panel {
  display: none;
  background: rgba(0,0,0,0.5);
  border-radius: 8px;
  padding: 6px 10px;
  max-height: 60px; overflow-y: auto;
  font-size: 0.72em;
  border: 1px solid rgba(212,175,55,0.15);
}
.log-panel .log-line { margin-bottom: 2px; color: var(--text-dim); }
.log-panel .log-system { color: var(--gold-bright); }
.log-panel .log-pay { color: #f0c75e; font-weight: 500; }
.log-panel .log-action { color: #b3d4f5; }

/* ============================================================
   Modals
   ============================================================ */
.modal {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(4px);
  z-index: 1000;
  justify-content: center; align-items: center;
  /* padding 5px ทุกขอบ + 60px ล่าง = เผื่อพื้นที่ปุ่มปิด fixed (ไม่ทับ modal-box) */
  padding: 5px 5px 60px 5px;
}
.modal.active { display:flex; }
.modal-box {
  background: linear-gradient(145deg, var(--bg-light), var(--bg-mid));
  color: var(--text);
  padding: 20px;
  border-radius: 14px;
  max-width: 640px;
  width: 100%;
  /* fill .modal padding area (.modal มี padding 5px 5px 60px → modal-box max = 100%) */
  max-height: 100%;
  overflow-y: auto;
  border: 1px solid rgba(212,175,55,0.4);
  box-shadow:
    0 20px 60px rgba(0,0,0,0.8),
    inset 0 1px 0 rgba(255,255,255,0.1);
}
.modal-box h2, .modal-box h3 {
  color: var(--gold-bright);
  margin-bottom: 14px;
  font-family: 'Cinzel', serif;
}
.modal-box h4 { color: var(--gold); margin-bottom: 8px; }
.modal-box button { margin-top: 8px; }

/* ===== ปุ่มปิด/ยกเลิก/ตกลง (ปุ่มสุดท้ายของ modal-box) ลอย FIX ที่ viewport bottom
   ผู้ใช้ไม่ต้อง scroll ไปหาปุ่มเอง — ปุ่มอยู่ขอบล่างจอทุกครั้ง 5px กันขอบ
   ใช้ position: fixed เพื่อ "หลุดออกจาก modal-box" → ไม่ขึ้นอยู่กับเนื้อหาในกล่อง
   เฉพาะ .modal.active — modal อื่น display:none เลยไม่โผล่ปุ่มซ้อน
   ===== */
.modal.active > .modal-box > button:last-child {
  position: fixed;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 10px);
  max-width: 640px; /* ตรงกับ max-width ของ modal-box → button align กับกล่องบนจอใหญ่ */
  margin: 0;
  z-index: 1100;
  padding: 14px 20px;
  border-radius: 12px;
  border: 1px solid rgba(212,175,55,0.5);
  box-shadow:
    0 12px 32px rgba(0,0,0,0.7),
    inset 0 1px 0 rgba(255,255,255,0.06);
  font-weight: 700;
  font-size: 1em;
}
/* btn-secondary โปร่งใสเดิม — เปลี่ยนเป็น dark solid เพื่อชัดเจน */
.modal.active > .modal-box > button.btn-secondary:last-child {
  background: linear-gradient(180deg, rgba(35,40,55,0.96), rgba(20,24,34,1));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text);
}

/* Toast */
.toast {
  position: fixed; bottom: 30px; left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: linear-gradient(135deg, rgba(29,33,72,0.95), rgba(19,23,55,0.98));
  color: var(--gold-bright);
  padding: 12px 24px; border-radius: 10px;
  opacity: 0; transition: all 0.3s;
  z-index: 2000; pointer-events: none;
  font-weight: 600;
  border: 1px solid var(--gold);
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* End results */
#endResults { margin: 16px 0; }
#endResults .result-row {
  display: flex; justify-content: space-between;
  padding: 10px 12px;
  background: rgba(0,0,0,0.3);
  border-radius: 8px; margin-bottom: 6px;
  border-left: 3px solid transparent;
}
#endResults .result-row.winner {
  background: linear-gradient(135deg, rgba(212,175,55,0.25), rgba(212,175,55,0.05));
  border-left-color: var(--gold);
  font-weight: bold;
  box-shadow: 0 0 16px rgba(212,175,55,0.3);
}
.breakdown { font-size: 0.78em; color: var(--text-dim); margin-top: 4px; }

/* ★ History modal — tab buttons (🎮 ประวัติเกม / 💰 ประวัติพ้อย) — modern pill style */
.htab-btn {
  flex: 1;
  padding: 9px 14px;
  font-size: 0.95em;
  font-weight: 700;
  background: linear-gradient(180deg, rgba(40,30,60,0.55), rgba(20,15,35,0.7));
  color: #cfd0e8;
  border: 1px solid rgba(192,132,252,0.25);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.18s ease;
  letter-spacing: 0.3px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}
.htab-btn:hover {
  background: linear-gradient(180deg, rgba(60,40,90,0.7), rgba(30,20,50,0.8));
  border-color: rgba(192,132,252,0.5);
  color: #fff;
}
.htab-btn.active {
  background: linear-gradient(135deg, #c084fc 0%, #f0abfc 50%, #ffd700 100%);
  background-size: 200% auto;
  color: #1a0a2e;
  border-color: rgba(255,215,0,0.7);
  font-weight: 900;
  letter-spacing: 0.5px;
  box-shadow:
    0 4px 14px rgba(192,132,252,0.45),
    0 0 0 1px rgba(255,215,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.4);
  animation: htabBtnShine 3.5s linear infinite;
}
@keyframes htabBtnShine {
  0%   { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

/* ★ Date filter row + pagination */
.hist-daterange {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-bottom: 10px;
  padding: 8px 10px;
  background: linear-gradient(180deg, rgba(20,15,30,0.6), rgba(10,8,20,0.8));
  border: 1px solid rgba(192,132,252,0.2);
  border-radius: 10px;
}
.hist-daterange label { font-size: 0.82em; color: #aaa; }
.hist-daterange input[type="date"] {
  background: rgba(0,0,0,0.45);
  color: #ddd;
  border: 1px solid rgba(212,175,55,0.3);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.85em;
  font-family: inherit;
}
.hist-daterange button {
  padding: 5px 12px;
  font-size: 0.82em;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid rgba(212,175,55,0.5);
  background: linear-gradient(180deg, var(--gold-bright), #b8860b);
  color: #1a1a2e;
  transition: filter 0.15s;
}
.hist-daterange button:hover { filter: brightness(1.1); }
.hist-daterange .clear {
  background: rgba(255,255,255,0.06);
  color: #aaa;
  border-color: rgba(255,255,255,0.18);
}
.hist-pagination {
  display: flex; gap: 8px; justify-content: center; align-items: center;
  margin-top: 12px;
  padding: 8px 0;
  font-size: 0.88em;
  color: #aaa;
}
.hist-pagination button {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid rgba(192,132,252,0.35);
  background: rgba(40,30,60,0.65);
  color: #ddd;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.hist-pagination button:hover:not(:disabled) {
  background: rgba(60,45,90,0.85);
  border-color: rgba(192,132,252,0.6);
  color: #fff;
}
.hist-pagination button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.hist-pagination .page-info {
  font-weight: 700;
  color: #ffd54a;
  letter-spacing: 0.3px;
}

/* ★ Wallet history table — modern card-style rows */
.tx-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 14px;
  margin-bottom: 6px;
  background: linear-gradient(135deg, rgba(20,15,30,0.6), rgba(15,10,25,0.7));
  border: 1px solid rgba(255,255,255,0.06);
  border-left: 3px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  font-size: 0.92em;
  transition: background 0.15s;
}
.tx-row:hover { background: linear-gradient(135deg, rgba(30,20,45,0.75), rgba(20,15,35,0.85)); }
.tx-row.plus { border-left-color: #4eff7a; }
.tx-row.plus .tx-amt { color: #4eff7a; text-shadow: 0 0 6px rgba(78,255,122,0.45); }
.tx-row.minus { border-left-color: #ff6b6b; }
.tx-row.minus .tx-amt { color: #ff6b6b; text-shadow: 0 0 6px rgba(255,107,107,0.45); }
.tx-row .tx-info { flex: 1; min-width: 0; }
.tx-row .tx-reason {
  color: #ddd;
  font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tx-row .tx-date {
  font-size: 0.75em;
  color: #888;
  margin-top: 2px;
}
.tx-row .tx-right { text-align: right; flex-shrink: 0; }
.tx-row .tx-amt {
  font-weight: 800;
  font-size: 1.05em;
  letter-spacing: 0.3px;
}
.tx-row .tx-balance {
  font-size: 0.7em;
  color: #888;
  margin-top: 2px;
  font-weight: 600;
}
.tx-row .tx-balance::before { content: '→ '; opacity: 0.6; }

/* ★ Game history page (member side) */
.hist-filters {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  padding: 8px 10px;
  background: rgba(0,0,0,0.25);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.06);
}
.hist-fbar { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.hist-flabel { font-size: 0.82em; color: #888; min-width: 38px; }
.hist-fbtn {
  padding: 5px 10px;
  background: rgba(255,255,255,0.04);
  color: #aaa;
  border: 1px solid rgba(212,175,55,0.18);
  border-radius: 14px;
  font-size: 0.82em;
  cursor: pointer;
  transition: all 0.15s;
}
.hist-fbtn:hover { background: rgba(212,175,55,0.1); color: #ddd; }
.hist-fbtn.active {
  background: linear-gradient(180deg, var(--gold-bright), #b8860b);
  color: #1a1a2e;
  border-color: var(--gold-bright);
  font-weight: 700;
}
.game-history-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid rgba(212,175,55,0.2);
  border-radius: 8px;
  margin-bottom: 6px;
  cursor: pointer;
  background: rgba(0,0,0,0.3);
  transition: all 0.15s;
}
.game-history-row:hover {
  background: rgba(212,175,55,0.08);
  border-color: rgba(212,175,55,0.4);
  transform: translateX(2px);
}
.hist-meta { flex: 1; min-width: 0; }
.hist-row-top { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.hist-rate { font-weight: 700; color: var(--gold-bright); font-size: 1em; }
.hist-mode { color: #888; font-size: 0.78em; font-weight: 400; }
.hist-detail { font-size: 0.78em; color: #aaa; margin-top: 2px; }
.hist-players {
  font-size: 0.74em;
  color: #777;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hist-result {
  font-weight: 800;
  font-size: 0.95em;
  text-align: right;
  white-space: nowrap;
  min-width: 80px;
}
.hist-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 0.7em;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.hist-badge.dm { background: rgba(60,140,255,0.15); color: #9fdfff; border: 1px solid rgba(60,140,255,0.35); }
.hist-badge.pd { background: rgba(212,175,55,0.18); color: #ffd700; border: 1px solid rgba(212,175,55,0.4); }
.hist-badge.mh { background: rgba(150,80,200,0.18); color: #e0baff; border: 1px solid rgba(150,80,200,0.45); }
.hist-badge.bot { background: rgba(150,100,255,0.15); color: #c9a8ff; border: 1px solid rgba(150,100,255,0.35); }
.hist-badge.real { background: rgba(78,255,122,0.12); color: #8aff9f; border: 1px solid rgba(78,255,122,0.3); }

.public-room-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px;
  background: rgba(0,0,0,0.3);
  border-left: 4px solid #2a7d2a;
  border-radius: 8px; margin-bottom: 8px;
}
.public-room-row .btn-mini {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold-soft));
  color: #1a1500; padding: 6px 14px;
  border-radius: 6px; cursor: pointer; margin-top: 4px;
  border: none;
}

.friend-tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.ftab-btn {
  flex:1; padding:8px;
  background: rgba(255,255,255,0.05);
  color: var(--text-dim);
  border-radius: 6px; font-size: 0.85em; font-weight: 600;
}
.ftab-btn.active {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold-soft));
  color: #1a1500;
}
.ftab-pane { display:none; padding: 4px; }
.ftab-pane.active { display:block; }

.friend-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px; background: rgba(0,0,0,0.3);
  border-radius: 8px; margin-bottom: 6px;
  border-left: 4px solid #2a7d2a;
}
.friend-row.offline { border-left-color: #555; opacity: 0.7; }
.friend-row .friend-info { font-size: 0.9em; }
.friend-row .friend-info small { color: var(--text-dim); }
.friend-row .friend-actions button {
  padding: 4px 10px; border-radius: 4px;
  font-size: 0.8em; margin-left: 4px; border: none;
}
.btn-accept { background: #2e7d32; color: #fff; }
.btn-reject, .btn-remove { background: #555; color: #fff; }
.btn-invite { background: var(--gold); color: #1a1500; }

/* Rank */
.rank-card {
  background: linear-gradient(135deg, rgba(212,175,55,0.2), rgba(212,175,55,0.05));
  border: 2px solid var(--gold);
  border-radius: 12px;
  padding: 18px; margin-bottom: 14px; text-align: center;
}
.rank-card .tier-icon { font-size: 3em; }
.rank-card .tier-name {
  font-size: 1.5em; font-weight: bold;
  color: var(--gold-bright); margin: 4px 0;
  font-family: 'Cinzel', serif;
}
.rank-card .stats {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 8px; margin-top: 12px; font-size: 0.85em;
}
.rank-card .stats div strong {
  display: block; color: var(--gold-bright); font-size: 1.2em;
}
.progress-bar {
  background: rgba(0,0,0,0.4);
  border-radius: 6px; height: 10px;
  overflow: hidden; margin-top: 10px;
}
.progress-bar > div {
  background: linear-gradient(90deg, var(--gold-bright), var(--red));
  height: 100%;
  transition: width 0.4s;
}
.tier-row {
  display: flex; align-items: center; padding: 8px;
  background: rgba(0,0,0,0.3);
  border-radius: 6px; margin-bottom: 4px;
}
.tier-row.current {
  background: linear-gradient(135deg, rgba(212,175,55,0.2), transparent);
  border: 1px solid var(--gold);
}
.tier-row .tier-ico { font-size: 1.5em; margin-right: 10px; }
.tier-row .tier-info { flex:1; }
.tier-row .tier-info small { color: var(--text-dim); font-size:0.8em; }

.lb-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px; background: rgba(0,0,0,0.3);
  border-radius: 6px; margin-bottom: 4px;
  border-left: 4px solid transparent;
}
.lb-row.you {
  background: linear-gradient(135deg, rgba(212,175,55,0.2), transparent);
  border-left-color: var(--gold);
  font-weight: bold;
}
.lb-row .lb-rank { width: 30px; font-weight: bold; color: var(--gold-bright); }

/* Admin */
.admin-tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.atab-btn {
  flex:1; padding:8px;
  background: rgba(255,255,255,0.05);
  color: var(--text-dim);
  border-radius: 6px; font-size: 0.85em; font-weight: 600;
}
.atab-btn.active { background: #2e7d32; color: #fff; }
.atab-pane { display:none; }
.atab-pane.active { display:block; }
/* Summary modal tabs (round/end) */
.summary-tabs {
  display: flex; gap: 6px;
  margin: 8px 0 14px;
  padding: 4px;
  background: rgba(0,0,0,0.4);
  border-radius: 10px;
}
.summary-tabs .sum-tab,
.summary-tabs .end-tab {
  flex: 1;
  padding: 8px 12px;
  background: transparent;
  color: var(--text-dim);
  border: none;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.95em;
  transition: all 0.15s;
}
.summary-tabs .sum-tab:hover,
.summary-tabs .end-tab:hover {
  color: var(--gold-bright);
}
.summary-tabs .sum-tab.active,
.summary-tabs .end-tab.active {
  background: linear-gradient(180deg, rgba(212,175,55,0.25), rgba(212,175,55,0.12));
  color: var(--gold-bright);
  box-shadow: 0 0 8px rgba(212,175,55,0.2);
}

/* ====== สรุปไพ่ tab (rsc = round-summary-cards) ====== */
.rsc-player {
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
}
.rsc-player.winner {
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(212,175,55,0.25);
}
.rsc-player-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 6px;
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.rsc-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1em;
  border: 2px solid;
  flex-shrink: 0;
}
.rsc-name {
  font-weight: 700;
  font-size: 0.95em;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rsc-dark {
  background: #3d0808;
  color: #ff7a8c;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.72em;
  font-weight: 700;
  margin-left: 4px;
}
.rsc-score {
  font-size: 0.78em;
  color: #aaa;
  white-space: nowrap;
}
.rsc-score strong {
  color: #ffd700;
}
.rsc-row {
  margin: 4px 0;
  padding: 4px 6px;
  background: rgba(0,0,0,0.2);
  border-radius: 6px;
  border-left: 2px solid rgba(123,232,255,0.4);
}
.rsc-row-dep {
  border-left-color: rgba(255,180,80,0.5);
}
.rsc-row-hand {
  border-left-color: rgba(255,122,140,0.5);
}
.rsc-row-lbl {
  font-size: 0.72em;
  color: #7be8ff;
  font-weight: 700;
  margin-bottom: 3px;
}
.rsc-row-dep .rsc-row-lbl { color: #ffb450; }
.rsc-row-hand .rsc-row-lbl { color: #ff9aa9; }
.rsc-empty-hand { color: #4eff7a !important; }
.rsc-cards {
  display: flex; gap: 2px; flex-wrap: wrap;
}
.rsc-cards .card {
  width: 28px; height: 40px; font-size: 0.65em;
  margin-left: -6px;
}
.rsc-cards .card:first-child { margin-left: 0; }
.rsc-empty {
  font-size: 0.8em;
  color: #888;
  padding: 4px 6px;
  font-style: italic;
}
.rsc-discard {
  margin-top: 12px;
  padding: 10px;
  background: rgba(40, 30, 60, 0.4);
  border: 1px dashed rgba(192,132,252,0.4);
  border-radius: 10px;
}
.rsc-discard-head {
  font-size: 0.9em;
  font-weight: 700;
  color: #c084fc;
  margin-bottom: 6px;
}
@media (max-width: 480px) {
  .rsc-cards .card {
    width: 24px; height: 34px; font-size: 0.55em;
    margin-left: -6px;
  }
}
.paylog-card {
  display: inline-block;
  padding: 2px 6px;
  margin: 2px;
  background: rgba(255,255,255,0.95);
  color: #1a1a2e;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.88em;
  font-family: monospace;
}
/* ----- ไพ่ซ้อนกัน (fan) สำหรับหน้าประวัติ — ★ overlap น้อยลง เห็นรหัสไพ่ทุกใบ ----- */
.hist-fan {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  margin-top: 4px;
  padding: 4px 0;
  gap: 4px;                  /* ★ ระยะห่างปกติ ไม่ทับกัน */
  row-gap: 6px;
}
.hist-fan .card {
  margin-left: 0 !important; /* ★ override negative margin จาก .card style เก่า */
  cursor: default;
  flex-shrink: 0;
  transition: transform 0.15s, box-shadow 0.15s;
  z-index: 1;
}
.hist-fan .card:first-child { margin-left: 0; }
.hist-fan .card:hover {
  transform: translateY(-4px);
  z-index: 10;
  box-shadow: 0 6px 14px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.6);
}
.hist-fan .card.speto::after {
  /* สเปโตในหน้าประวัติ — โชว์ดาวให้พอดี */
  font-size: 0.85em;
}
.admin-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px; background: rgba(0,0,0,0.3);
  border-radius: 6px; margin-bottom: 4px;
  font-size: 0.85em;
}
.admin-row.admin-user { border-left: 4px solid #2e7d32; }
.admin-row .admin-actions button {
  padding: 4px 8px; border-radius: 4px;
  font-size: 0.75em; margin-left: 2px;
  background: var(--red); color: #fff; border:none;
}

/* ============================================================
   Mode buttons
   ============================================================ */
.mode-btn {
  flex: 1; padding: 12px;
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border-radius: 10px;
  font-weight: 600; cursor: pointer;
  border: 2px solid transparent;
}
.mode-btn.active {
  background: linear-gradient(135deg, rgba(212,175,55,0.25), rgba(212,175,55,0.05));
  border-color: var(--gold);
  color: var(--gold-bright);
}

/* ============================================================
   Character grid
   ============================================================ */
.char-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
  /* ไม่จำกัด max-height — ให้ modal-box เป็น scroll เดียว ไม่มี scrollbar ซ้อน */
}
.char-card {
  background: rgba(0,0,0,0.3);
  border: 2px solid rgba(212,175,55,0.2);
  border-radius: 12px;
  padding: 14px 8px;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
}
.char-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.char-card.active {
  background: linear-gradient(135deg, rgba(212,175,55,0.25), rgba(212,175,55,0.05));
  border-color: var(--gold);
  box-shadow: 0 0 14px rgba(212,175,55,0.4);
}
.char-card.locked { opacity: 0.55; }
.char-card .char-emoji {
  font-size: 3em; line-height: 1; margin-bottom: 4px;
  display: block;
}
.char-card .char-name {
  color: var(--gold-bright);
  font-size: 0.9em; font-weight: 600;
}
.char-card .char-price {
  color: var(--text-dim);
  font-size: 0.78em; margin-top: 4px;
}
.char-card .char-badge {
  position: absolute; top: 4px; right: 4px;
  background: var(--green-felt-light); color:#fff;
  font-size: 0.65em; padding: 2px 6px; border-radius: 8px;
}

/* Avatar in opponent / player */
.avatar-circle {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.7em; line-height: 1;
  border: 2px solid var(--gold);
  margin: 0 auto 6px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.5);
}
.opponent.current .avatar-circle {
  box-shadow: 0 0 16px rgba(212,175,55,0.7);
  animation: pulse-glow 1.6s ease-in-out infinite;
}

/* ============================================================
   Floating +XP animation
   ============================================================ */
.xp-float {
  position: absolute;
  pointer-events: none;
  font-size: 1.4em;
  font-weight: 700;
  z-index: 100;
  text-shadow: 0 2px 4px rgba(0,0,0,0.8), 0 0 8px currentColor;
  animation: xp-rise 1.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.xp-float.plus { color: #4eff7a; }
.xp-float.minus { color: #ff6b6b; }
@keyframes xp-rise {
  0% { transform: translateY(0) scale(0.6); opacity: 0; }
  20% { transform: translateY(-10px) scale(1.2); opacity: 1; }
  80% { transform: translateY(-50px) scale(1); opacity: 1; }
  100% { transform: translateY(-80px) scale(0.85); opacity: 0; }
}

/* Coin float — animation หักเงิน/ได้เงิน บนช่อง meld */
.coin-float {
  position: fixed;
  pointer-events: none;
  font-size: 1.55em;
  font-weight: 800;
  z-index: 300;
  transform: translate(-50%, -50%);
  text-shadow:
    0 2px 4px rgba(0,0,0,0.9),
    0 0 12px currentColor,
    0 0 4px rgba(0,0,0,0.95);
  animation: coin-rise 1.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  white-space: nowrap;
  letter-spacing: 0.5px;
}
.coin-float .coin-icon {
  font-size: 0.85em;
  filter: drop-shadow(0 0 6px currentColor);
}
.coin-float.plus  { color: #4eff7a; }
.coin-float.minus { color: #ff5c6b; }

/* ★ Mini slot toast — แจ้งเตือนเล็กๆ ตอนเกิด/ฝาก (ไม่ตูมตามเหมือน event ใหญ่) */
.mini-slot-toast {
  position: fixed;
  pointer-events: none;
  z-index: 280;
  transform: translate(-50%, -50%);
  background: rgba(20, 24, 36, 0.92);
  color: #ffe88a;
  font-size: 0.82em;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 14px;
  border: 1px solid rgba(245,210,90,0.5);
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  white-space: nowrap;
  letter-spacing: 0.3px;
  animation: mini-toast-in 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  transition: opacity 0.5s ease, transform 0.5s ease;
  opacity: 1;
}
.mini-slot-toast.fade-out {
  opacity: 0;
  transform: translate(-50%, calc(-50% - 14px));
}
.mini-slot-toast--meld           { color: #7be8ff; border-color: rgba(123,232,255,0.5); }
.mini-slot-toast--deposit        { color: #ffb450; border-color: rgba(255,180,80,0.5); }
.mini-slot-toast--deposit-target { color: #ff8590; border-color: rgba(255,133,144,0.55); }
.mini-slot-toast--pick           { color: #c084fc; border-color: rgba(192,132,252,0.5); }
@keyframes mini-toast-in {
  0%   { transform: translate(-50%, calc(-50% + 10px)) scale(0.7); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1);                opacity: 1; }
}
@keyframes coin-rise {
  0%   { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
  18%  { transform: translate(-50%, calc(-50% - 12px)) scale(1.35); opacity: 1; }
  35%  { transform: translate(-50%, calc(-50% - 22px)) scale(1.05); opacity: 1; }
  85%  { transform: translate(-50%, calc(-50% - 70px)) scale(1); opacity: 1; }
  100% { transform: translate(-50%, calc(-50% - 100px)) scale(0.85); opacity: 0; }
}

/* Flash glow บน meld slot ตอนได้/เสียเงิน */
.meld-slot.flash-gain,
.pd-seat.flash-gain {           /* ★ pokdeng — เก้าอี้กระพริบเขียวตอนได้เงิน */
  animation: flash-green 0.7s ease-out;
}
.meld-slot.flash-loss,
.pd-seat.flash-loss {           /* ★ pokdeng — เก้าอี้กระพริบแดงตอนเสียเงิน */
  animation: flash-red 0.7s ease-out;
}
@keyframes flash-green {
  0%   { box-shadow: 0 0 0 0 rgba(78,255,122,0); }
  30%  { box-shadow: 0 0 28px 6px rgba(78,255,122,0.7), inset 0 0 22px rgba(78,255,122,0.4); }
  100% { box-shadow: 0 0 0 0 rgba(78,255,122,0); }
}
@keyframes flash-red {
  0%   { box-shadow: 0 0 0 0 rgba(255,92,107,0); }
  30%  { box-shadow: 0 0 28px 6px rgba(255,92,107,0.7), inset 0 0 22px rgba(255,92,107,0.4); }
  100% { box-shadow: 0 0 0 0 rgba(255,92,107,0); }
}

/* round summary */
.round-tbl {
  background: rgba(0,0,0,0.3);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 10px;
}
.round-row {
  display: grid;
  grid-template-columns: 50px 1fr 80px;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(212,175,55,0.15);
  align-items: center;
  font-size: 0.85em;
}
.round-row:last-child { border-bottom: none; }
.round-row.winner { background: linear-gradient(135deg, rgba(212,175,55,0.15), transparent); border-radius: 6px; padding: 8px; }
.round-row .delta { font-weight: 700; text-align: right; }
.round-row .delta.plus { color: #4eff7a; }
.round-row .delta.minus { color: #ff6b6b; }
.round-row .summary-cards { display: flex; gap: 2px; flex-wrap: wrap; margin-top: 4px; }

/* ============================================================
   Card deal animation
   ============================================================ */
@keyframes card-deal {
  from { transform: translateY(-200px) rotate(180deg); opacity: 0; }
  to { transform: translateY(0) rotate(0); opacity: 1; }
}
.card-dealt { animation: card-deal 0.4s ease-out; }

@keyframes card-flip {
  0% { transform: rotateY(0); }
  50% { transform: rotateY(90deg); }
  100% { transform: rotateY(0); }
}

/* ============================================================
   Top Bar + Profile dropdown
   ============================================================ */
.top-bar {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  z-index: 500;
  background: linear-gradient(180deg, rgba(13,17,46,0.97), rgba(13,17,46,0.85));
  border-bottom: 1px solid rgba(212,175,55,0.3);
  backdrop-filter: blur(8px);
  padding: 10px 14px;
  display: flex; flex-wrap: nowrap;
  align-items: center; gap: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}
#topBar[style*="display: none"] { display: none !important; }
#topBar #profileMenuBtn.menu-trigger { margin-left: auto; }

/* ★ Tournament status pill in topbar */
.tourn-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  margin-left: auto;
  background: linear-gradient(135deg, rgba(255,215,0,0.25), rgba(255,136,0,0.15));
  border: 1px solid rgba(255,215,0,0.55);
  border-radius: 12px;
  color: var(--gold-bright, #ffd700);
  font-size: 0.82em;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  animation: tournPillGlow 2s ease-in-out infinite;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tourn-pill:hover { transform: scale(1.04); box-shadow: 0 4px 12px rgba(255,215,0,0.4); }
.tourn-pill .tp-icon { font-size: 1.15em; }
.tourn-pill .tp-text { overflow: hidden; text-overflow: ellipsis; }
.tourn-pill.match-ready {
  background: linear-gradient(135deg, rgba(255,107,107,0.35), rgba(255,80,80,0.20));
  border-color: rgba(255,107,107,0.65);
  color: #ffd0d0;
  animation: tournPillUrgent 0.7s ease-in-out infinite;
}
@keyframes tournPillGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,215,0,0.4); }
  50%      { box-shadow: 0 0 0 6px rgba(255,215,0,0); }
}
@keyframes tournPillUrgent {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255,107,107,0.6); }
  50%      { transform: scale(1.05); box-shadow: 0 0 0 8px rgba(255,107,107,0); }
}
#topBar .tourn-pill ~ .menu-trigger { margin-left: 4px; }
/* ★ เมื่อมี pill แสดงอยู่ — profileMenuBtn ไม่ต้องชิดขวาสุด (pill ใช้ margin-left:auto แทน)
   หมายเหตุ: ต้อง match ทั้ง "display:none" และ "display: none" — JS เซ็ตแบบมีช่องว่าง แต่ HTML attr เขียนแบบไม่มี */
#topBar:has(#tournamentPill:not([style*="display:none"]):not([style*="display: none"])) #profileMenuBtn { margin-left: 4px; }
.menu-trigger {
  background: rgba(212,175,55,0.12);
  border: 1px solid rgba(212,175,55,0.4);
  color: var(--gold-bright);
  width: 40px; height: 40px;
  border-radius: 10px;
  font-size: 1.3em;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.menu-trigger:hover { background: rgba(212,175,55,0.25); }
.profile-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: transparent;
  border: none;
  padding: 4px 6px;
}
.avatar-mini {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3em;
  border: 2px solid var(--gold);
}
.profile-meta { font-size: 0.85em; }
.profile-meta div:first-child { font-weight: 700; color: var(--gold-bright); }
.balance-line { color: var(--text-dim); font-size: 0.85em; }
.dropdown-caret { color: var(--gold); font-size: 0.7em; }

.profile-menu {
  display: none;
  position: fixed; top: 60px; right: 12px;
  background: linear-gradient(145deg, var(--bg-light), var(--bg-mid));
  border: 1px solid rgba(212,175,55,0.4);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.7);
  min-width: 200px;
  z-index: 600;
}
.profile-menu.open { display: block; }
.profile-menu button {
  display: block; width: 100%; text-align: left;
  background: transparent; color: var(--text);
  padding: 10px 14px; border-radius: 8px;
  font-size: 0.9em;
}
.profile-menu button:hover { background: rgba(212,175,55,0.15); color: var(--gold-bright); }

/* Padding screen เพื่อกัน top bar ทับ + เว้นระยะ */
#screen-game-pick.active, #screen-mode-pick.active,
#screen-rate-pick.active, #screen-room-list.active,
#screen-lobby.active {
  padding-top: 76px;
}

/* ============================================================
   ★ Game-pick v2 — Modern hero + game-card-v2
   ============================================================ */
#screen-game-pick.active {
  padding: 0;
  /* ★ ดันให้พ้น top-bar เป๊ะ — gap จาก top-bar ถึง hero ใช้ padding ของ .game-pick-wrap (10px) */
  padding-top: calc(var(--topbar-h, 50px) + env(safe-area-inset-top, 0px));
}
.game-pick-wrap {
  max-width: 1100px; margin: 0 auto;
  padding: 10px 16px 80px;        /* ★ top 10px = ระยะห่างจาก top-bar ถึง "เลือกเกมที่ต้องการเล่น" */
}
@media (max-width: 600px) {
  .game-pick-wrap {
    padding: 10px 12px 60px;
  }
}
.game-pick-hero {
  text-align: center;
  margin-bottom: 22px;
  position: relative;
}
.game-pick-hero::before {
  content: '';
  position: absolute; inset: -10px;
  background:
    radial-gradient(ellipse at 50% 50%, rgba(255,215,0,0.12) 0%, transparent 60%);
  pointer-events: none;
  z-index: -1;
}
.gp-title {
  font-family: 'Cinzel','Sarabun',serif;
  font-size: clamp(1.4em, 4vw, 2.2em);
  font-weight: 900;
  letter-spacing: 1.5px;
  margin: 0 0 6px;
  background: linear-gradient(110deg, #ffd700 0%, #ff9d3a 30%, #ff6b6b 55%, #c084fc 75%, #00f5ff 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 14px rgba(255,215,0,0.55));
  animation: gpTitleShine 4s linear infinite;
}
@keyframes gpTitleShine {
  0%   { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}
.gp-subtitle {
  color: var(--text-dim, #9ca3cf);
  font-size: 0.95em;
  margin: 0;
}

/* Grid */
#screen-game-pick .game-pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin: 0;
}
@media (max-width: 480px) {
  #screen-game-pick .game-pick-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .gp-title { font-size: 1.3em; }
  .gp-subtitle { font-size: 0.82em; }
}

/* ★ Game card v2 — luxury */
.game-card-v2 {
  position: relative; overflow: hidden;
  background: linear-gradient(160deg, rgba(30,15,55,0.95), rgba(15,10,40,0.98));
  border: 2px solid rgba(255,215,0,0.35);
  border-radius: 22px;
  padding: 0;
  cursor: pointer;
  transition: all 0.28s cubic-bezier(.18,.89,.32,1.28);
  box-shadow:
    0 8px 24px rgba(0,0,0,0.55),
    0 0 0 1px rgba(255,215,0,0.15) inset,
    inset 0 1px 0 rgba(255,255,255,0.08);
  display: flex; flex-direction: column;
  min-height: 220px;
  font-family: inherit;
  color: #fff;
}
.game-card-v2.active:hover {
  transform: translateY(-6px) scale(1.04);
  border-color: var(--gold-bright, #ffd700);
  box-shadow:
    0 18px 40px rgba(255,180,0,0.5),
    0 0 0 2px var(--gold-bright, #ffd700),
    0 0 60px rgba(255,107,107,0.3) inset;
}
.game-card-v2.active:active { transform: translateY(-2px) scale(1.01); }
.game-card-v2.soon {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.4);
}
.game-card-v2.soon:hover { transform: none; }

/* ★ Per-game status: ปิดปรับปรุง — แสดงการ์ดแต่ทำให้ดูปิด + overlay ปิดปรับปรุงทับ */
.game-card-v2.game-card-closed {
  filter: grayscale(0.7) brightness(0.6);
  cursor: not-allowed;
  pointer-events: auto; /* ยังให้กดได้เพื่อแสดง popup ปิดปรับปรุง */
}
.game-card-v2.game-card-closed:hover { transform: none; }

/* ★ Online count badge (มุมขวาบนของการ์ด) — แสดงจำนวนคนที่กำลังเล่นเกมนี้ */
.gc-online {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  background: linear-gradient(135deg, rgba(0,0,0,0.78), rgba(15,30,15,0.85));
  color: #4ade80;
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 0.74em;
  font-weight: 700;
  letter-spacing: 0.3px;
  border: 1px solid rgba(74,222,128,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4), 0 0 12px rgba(74,222,128,0.2);
  display: flex;
  align-items: center;
  gap: 3px;
  animation: gcOnlinePulse 2.4s ease-in-out infinite;
  white-space: nowrap;
  pointer-events: none;
}
@keyframes gcOnlinePulse {
  0%, 100% { box-shadow: 0 2px 8px rgba(0,0,0,0.4), 0 0 12px rgba(74,222,128,0.2); }
  50%      { box-shadow: 0 2px 8px rgba(0,0,0,0.4), 0 0 22px rgba(74,222,128,0.55); }
}
@media (max-width: 600px) {
  .gc-online { top: 8px; right: 8px; padding: 3px 8px; font-size: 0.68em; }
}

/* glow ring */
.gc-glow {
  position: absolute;
  inset: -25%;
  background: conic-gradient(
    from 0deg,
    rgba(255,215,0,0.4),
    rgba(192,132,252,0.5),
    rgba(255,107,107,0.4),
    rgba(255,215,0,0.4)
  );
  filter: blur(40px);
  opacity: 0.55;
  animation: gcRing 6s linear infinite;
  z-index: -1;
}
.gc-glow-red {
  background: conic-gradient(
    from 0deg,
    rgba(255,107,107,0.55),
    rgba(255,180,0,0.5),
    rgba(255,80,80,0.55),
    rgba(255,107,107,0.55)
  );
}
.gc-glow-purple {
  background: conic-gradient(
    from 0deg,
    rgba(192,132,252,0.55),
    rgba(150,80,200,0.5),
    rgba(224,186,255,0.55),
    rgba(192,132,252,0.55)
  );
}
@keyframes gcRing {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
/* image area */
.gc-img-wrap {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 18px 14px 8px;
  position: relative;
  z-index: 1;
}
.gc-img-wrap img {
  width: 100%; height: auto;
  max-width: 200px;
  display: block;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,0.6));
  transition: transform 0.4s cubic-bezier(.18,.89,.32,1.28);
}
.game-card-v2.active:hover .gc-img-wrap img {
  transform: scale(1.06) rotate(-2deg);
}
/* emoji fallback for "soon" cards */
.gc-emoji {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 4.2em;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.55));
}
/* label section */
.gc-label {
  background: linear-gradient(180deg, rgba(0,0,0,0.4), rgba(0,0,0,0.7));
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(255,215,0,0.2);
  text-align: center;
}
.gc-name {
  font-size: 1.05em;
  font-weight: 800;
  color: var(--gold-bright, #ffd700);
  margin-bottom: 4px;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
.gc-tag {
  display: inline-block;
  font-size: 0.72em;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  letter-spacing: 0.3px;
}
.gc-tag.live {
  background: rgba(74,222,128,0.18);
  color: #7be087;
  border: 1px solid rgba(74,222,128,0.4);
}
.gc-tag.soon {
  background: rgba(180,180,180,0.15);
  color: #999;
  border: 1px solid rgba(180,180,180,0.25);
}
/* shine sweep on active hover */
.game-card-v2.active::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,0.15) 50%, transparent 70%);
  background-size: 220% 100%;
  background-position: -120% 0;
  pointer-events: none;
  transition: background-position 0.7s ease;
  border-radius: 22px;
}
.game-card-v2.active:hover::after {
  background-position: 220% 0;
}

/* ============================================================
   Game-pick / Mode-pick big cards (luxury arena) — legacy
   ============================================================ */
.game-pick-grid {
  display: grid; gap: 14px;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 10px;
}
#screen-game-pick .game-pick-grid {
  grid-template-columns: repeat(2, 1fr);   /* ★ 2 คอลัมน์ */
  gap: 12px;
}
.game-big-card {
  background:
    radial-gradient(ellipse at top, rgba(212,175,55,0.18), transparent 70%),
    linear-gradient(180deg, rgba(29,33,72,0.95), rgba(13,17,46,0.98));
  border: 2px solid rgba(212,175,55,0.35);
  border-radius: 16px;
  padding: 28px 14px 22px;
  text-align: center;
  color: var(--text);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
  box-shadow: 0 6px 16px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.08);
}
.game-big-card::before {
  content:''; position:absolute; inset:0;
  background: linear-gradient(135deg, transparent 40%, rgba(212,175,55,0.08) 50%, transparent 60%);
  background-size: 200% 200%;
  background-position: 0% 0%;
  transition: background-position 0.5s;
  pointer-events: none;
}
.game-big-card:hover {
  border-color: var(--gold);
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 16px 32px rgba(212,175,55,0.4), 0 0 0 1px var(--gold), inset 0 1px 0 rgba(255,255,255,0.12);
}
.game-big-card:hover::before { background-position: 100% 100%; }
.game-big-card.active {
  border-color: var(--gold);
  background:
    radial-gradient(ellipse at top, rgba(212,175,55,0.35), transparent 70%),
    linear-gradient(180deg, rgba(29,33,72,0.95), rgba(13,17,46,0.98));
  box-shadow: 0 0 24px rgba(212,175,55,0.5), inset 0 1px 0 rgba(255,255,255,0.2);
}
.game-big-card.disabled { opacity: 0.35; cursor: not-allowed; }
.game-big-card.disabled:hover { transform: none; box-shadow: 0 6px 16px rgba(0,0,0,0.5); border-color: rgba(212,175,55,0.2); }
.game-big-card .big-icon {
  font-size: 4em; margin-bottom: 10px; line-height: 1;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
  display: block;
}
.game-big-card .big-icon img {
  width: 80px; height: 80px;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.6));
}
.game-big-card.game-img-btn {
  background: none; border: none; padding: 0; margin: 0;
  box-shadow: none;
  cursor: pointer; display: block;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,0.6));
  transition: transform 0.2s ease;
}
.game-big-card.game-img-btn::before { display: none; }
.game-big-card.game-img-btn:hover { transform: translateY(-4px) scale(1.04); box-shadow: none; border: none; }
.game-img-btn img {
  width: 100%; height: auto; display: block;
  max-width: 220px;
}
.game-big-card .big-name {
  font-size: 1.3em; font-weight: 800;
  color: var(--gold-bright);
  margin-bottom: 4px;
  font-family: 'Cinzel', 'Sarabun', serif;
  letter-spacing: 1px;
}
.game-big-card .big-sub {
  color: var(--text-dim); font-size: 0.82em;
  font-style: italic;
}

/* ★ Floating Back Button (ลอยซ้ายล่าง — เหมือนหน้า admin/api-docs/downline) */
.btn-back {
  position: fixed; left: 16px; bottom: 16px; z-index: 9999;
  padding: 10px 18px;
  background: linear-gradient(135deg, rgba(15,18,40,0.92), rgba(28,18,55,0.92));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(212,175,55,0.45);
  border-radius: 22px;
  color: #ffd54a;
  font-size: 0.92em; font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0,0,0,0.55);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn-back:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(212,175,55,0.35);
  background: linear-gradient(135deg, rgba(20,25,55,0.96), rgba(38,22,72,0.96));
}
@media (max-width: 600px) {
  .btn-back { left: 10px; bottom: 10px; padding: 8px 14px; font-size: 0.85em; }
}

/* Breadcrumb */
.breadcrumb {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 6px;
  font-size: 0.82em;
  margin: 0 0 10px;
  padding: 6px 10px;
  background: rgba(0,0,0,0.25);
  border-radius: 8px;
  border: 1px solid rgba(212,175,55,0.15);
  min-height: 32px;
}
.breadcrumb .bc-step {
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s;
}
.breadcrumb .bc-step:hover { color: var(--gold-bright); text-decoration: underline; }
.breadcrumb .bc-sep {
  color: rgba(212,175,55,0.4);
  font-weight: 700;
}
.breadcrumb .bc-cur {
  color: var(--gold-bright);
  font-weight: 700;
}

/* ============================================================
   Room list
   ============================================================ */
/* Inline game panel — รวม mode/rate/room ใน screen-game-pick */
.inline-game-panel {
  margin-top: 18px;
  animation: igp-fade 0.3s ease;
}
@keyframes igp-fade {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.igp-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(212,175,55,0.4), transparent);
  margin-bottom: 16px;
}
.igp-tabs {
  display: flex; gap: 8px; margin-bottom: 14px;
}
.igp-tab {
  flex: 1;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(212,175,55,0.3);
  background: linear-gradient(180deg, rgba(0,0,0,0.4), rgba(0,0,0,0.2));
  color: var(--text-dim);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.95em;
}
.igp-tab small { display: block; font-size: 0.72em; opacity: 0.7; font-weight: 500; margin-top: 2px; }
.igp-tab:hover { border-color: var(--gold); color: var(--gold-bright); }
.igp-tab.active {
  background: linear-gradient(180deg, rgba(212,175,55,0.25), rgba(212,175,55,0.1));
  border-color: var(--gold-bright);
  color: var(--gold-bright);
  box-shadow: 0 0 12px rgba(212,175,55,0.25);
}
.igp-room-heading {
  margin: 18px 0 8px;
  font-size: 0.95em;
  color: var(--gold-bright);
  letter-spacing: 0.5px;
}

.room-list-body {
  background: linear-gradient(180deg, rgba(0,0,0,0.45), rgba(0,0,0,0.25));
  border-radius: 12px;
  padding: 12px;
  /* ★ ขยาย max-height: ใช้ viewport-aware (เห็นห้องเยอะขึ้น)
     desktop: ~70vh แต่ไม่ทะลุ 760px
     mobile : คำนวณจาก viewport ลบ header/buttons (~ 280px) → ได้พื้นที่เกือบทั้งจอ */
  max-height: min(70vh, 760px);
  overflow-y: auto;
  overflow-x: hidden;
  margin-bottom: 12px;
  min-height: 120px;
  border: 1px solid rgba(212,175,55,0.2);
  box-shadow: inset 0 0 24px rgba(0,0,0,0.4);
  /* ★ Touch scroll นุ่มขึ้นบน iOS */
  -webkit-overflow-scrolling: touch;
}
/* ★ Mobile (≤ 600px) — ขยายเต็มที่ลบ ~ ระยะ header+ปุ่ม */
@media (max-width: 600px) {
  .room-list-body {
    max-height: calc(100vh - 280px);
    min-height: 220px;
    padding: 10px;
  }
}
/* ★ มือถือเล็ก (≤ 400px) — ให้รอบโชว์ห้องเยอะที่สุด */
@media (max-width: 400px) {
  .room-list-body {
    max-height: calc(100vh - 250px);
    padding: 8px;
  }
}
/* Custom scrollbar — เนียนกว่าเริ่มต้น */
.room-list-body::-webkit-scrollbar { width: 6px; }
.room-list-body::-webkit-scrollbar-track { background: transparent; }
.room-list-body::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(212,175,55,0.4), rgba(212,175,55,0.15));
  border-radius: 3px;
}
.room-list-body::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
}
.room-list-outer {
  max-width: 640px;
  margin: 14px auto 0;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}
/* ★ Mobile — outer ใช้ฟูลกว้าง ขอบจอ */
@media (max-width: 600px) {
  .room-list-outer { margin: 10px 6px 0; max-width: 100%; }
}
.room-row-public {
  position: relative;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-radius: 10px; margin-bottom: 8px;
  background:
    linear-gradient(90deg, rgba(78,255,122,0.08), rgba(29,33,72,0.85));
  border: 1px solid rgba(78,255,122,0.3);
  border-left: 4px solid #4eff7a;
  cursor: pointer;
  transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  overflow: hidden;
  /* ★ Touch tap-target — มือถือกดง่ายขึ้น */
  min-height: 44px;
}
/* ★ Mobile — row compact ขึ้นเล็กน้อย ให้เห็นห้องเยอะขึ้น */
@media (max-width: 600px) {
  .room-row-public {
    padding: 10px 12px;
    margin-bottom: 6px;
    border-radius: 9px;
  }
}
/* shimmer sweep on hover */
.room-row-public::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg,
    transparent 0%,
    transparent 40%,
    rgba(212,175,55,0.18) 50%,
    transparent 60%,
    transparent 100%);
  transform: translateX(-110%);
  transition: transform 0.6s ease;
  pointer-events: none;
}
.room-row-public:hover {
  background:
    linear-gradient(90deg, rgba(212,175,55,0.22), rgba(29,33,72,0.95));
  border-color: var(--gold-bright);
  border-left-color: var(--gold-bright);
  box-shadow:
    0 0 0 1px rgba(212,175,55,0.35) inset,
    0 6px 18px rgba(212,175,55,0.18);
}
.room-row-public:hover::before {
  transform: translateX(110%);
}
.room-row-public:hover .rrm-info strong {
  text-shadow: 0 0 8px rgba(212,175,55,0.6);
}
.room-row-public:active {
  filter: brightness(1.08);
}
.room-row-public.in-game {
  background:
    linear-gradient(90deg, rgba(200,16,46,0.1), rgba(29,33,72,0.85));
  border: 1px solid rgba(200,16,46,0.3);
  border-left: 4px solid #c8102e;
  opacity: 0.7;
  cursor: not-allowed;
}
.room-row-public.in-game:hover {
  transform: none;
  box-shadow: none;
  border-color: rgba(200,16,46,0.3);
  border-left-color: #c8102e;
}
.room-row-public .rrm-info { font-size: 0.9em; flex: 1; }
.room-row-public .rrm-rate {
  font-size: 1.45em;
  font-weight: 800;
  font-family: 'Cinzel', sans-serif;
  letter-spacing: 1px;
  color: var(--gold-bright);
  line-height: 1.1;
}
.room-row-public .rrm-mode {
  font-size: 0.78em;
  color: var(--text-dim);
  margin-top: 3px;
}
.room-row-public .rrm-info strong {
  color: var(--gold-bright);
  font-family: 'Cinzel', sans-serif;
  letter-spacing: 1px;
}
.room-row-public .rrm-info small { color: var(--text-dim); }
.room-row-public .rrm-status {
  font-size: 0.78em;
  padding: 4px 10px;
  border-radius: 12px;
  background: linear-gradient(180deg, #4eff7a, #2e7d32);
  color: #fff;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  box-shadow: 0 2px 6px rgba(78,255,122,0.4);
}
.room-row-public.in-game .rrm-status {
  background: linear-gradient(180deg, #ff6b7e, #8a0a1f);
  box-shadow: 0 2px 6px rgba(200,16,46,0.4);
}
/* ★ ป๊อกเด้ง: ห้องคลิกเข้าได้ (รวม in-game) — override .in-game */
.room-row-public.clickable {
  cursor: pointer;
  opacity: 1 !important;
}
.room-row-public.clickable.in-game {
  background: linear-gradient(90deg, rgba(212,175,55,0.15), rgba(29,33,72,0.92));
  border-color: rgba(212,175,55,0.45);
  border-left-color: var(--gold-bright);
  opacity: 1;
  cursor: pointer;
}
.room-row-public.clickable.in-game:hover {
  background: linear-gradient(90deg, rgba(212,175,55,0.28), rgba(29,33,72,0.95));
  border-color: var(--gold-bright);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(212,175,55,0.25);
}
/* รายการห้อง informational only — ไม่กดได้ ปิด cursor + hover effect */
.room-row-public.no-click {
  cursor: default;
}
.room-row-public.no-click:hover {
  background: linear-gradient(90deg, rgba(78,255,122,0.08), rgba(29,33,72,0.85));
  border-color: rgba(78,255,122,0.3);
  border-left-color: #4eff7a;
  box-shadow: none;
  transform: none;
}
.room-row-public.no-click:hover::before { transform: translateX(-110%); }
.room-row-public.no-click:hover .rrm-info strong { text-shadow: none; }
.room-row-public.no-click:active { filter: none; }
.empty-rooms {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
}
.empty-rooms .empty-icon {
  font-size: 3em;
  margin-bottom: 12px;
  opacity: 0.5;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
}
.empty-rooms .empty-title {
  color: var(--gold-bright);
  font-size: 1.1em;
  font-weight: 700;
  margin-bottom: 4px;
  font-family: 'Cinzel', sans-serif;
}
.empty-rooms .empty-sub {
  font-size: 0.85em;
  font-style: italic;
}

.room-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}
.room-actions button {
  padding: 16px 6px;
  font-size: 0.85em;
  font-weight: 700;
  white-space: nowrap;
  line-height: 1.4;
  border-radius: 12px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  box-shadow: 0 4px 10px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.1);
}
.room-actions button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.15);
}
.room-actions button:active { transform: translateY(0); }

/* ============================================================
   4-corner game board — seats floating at corners over table
   ============================================================ */
.game-board {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
}
.game-board .table-area {
  position: absolute;
  inset: 0;
  display: flex; flex-direction: column;
  margin: 0;
}

.seat {
  position: absolute;
  width: 22%;
  max-width: 110px;
  background: linear-gradient(145deg, rgba(13,17,46,0.95), rgba(19,23,55,0.98));
  border: 2px solid rgba(212,175,55,0.5);
  border-radius: 10px;
  padding: 4px 3px;
  text-align: center;
  font-size: 0.75em;
  z-index: 15;
  backdrop-filter: blur(6px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.7);
}
.seat-tl { top: -2px; left: -2px; }
.seat-tr { top: -2px; right: -2px; }
.seat-bl { bottom: -2px; left: -2px; }
.seat-br { bottom: -2px; right: -2px; }
.seat.empty { display: none; }
.seat.current {
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(212,175,55,0.8), 0 6px 16px rgba(0,0,0,0.6);
  animation: pulse-glow 1.6s ease-in-out infinite;
}
.seat .avatar-circle {
  width: 28px; height: 28px;
  font-size: 1.1em;
  margin: 0 auto 1px;
  border-width: 2px;
}
.seat .seat-name {
  font-weight: 700; color: var(--gold-bright);
  font-size: 0.85em; margin: 2px 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.seat .seat-points {
  font-size: 0.78em; font-weight: 700;
}
.seat .seat-points.plus { color: #4eff7a; }
.seat .seat-points.minus { color: #ff6b6b; }
.seat .seat-cards { display: flex; gap: 1px; justify-content: center; margin-top: 2px; }
.seat .opp-cards .mini-back, .seat .seat-cards .mini-back {
  width: 12px; height: 17px;
}
.seat .turn-countdown {
  font-size: 0.7em; color: var(--gold-bright);
  margin-top: 2px;
  font-weight: 700;
  background: rgba(0,0,0,0.5);
  padding: 1px 6px; border-radius: 8px;
  display: inline-block;
}

.my-area {
  background: linear-gradient(180deg, rgba(0,0,0,0.6), rgba(0,0,0,0.4));
  border-radius: 10px; padding: 6px;
  border: 2px solid rgba(212,175,55,0.3);
  flex-shrink: 0;
  max-height: 260px;
  display: flex; flex-direction: column; gap: 4px;
  position: relative;
  z-index: 150; /* my-area อยู่หน้า seat (5-10) แต่ต่ำกว่า hand */
  overflow: visible;
}
.my-area.current {
  border-color: var(--gold);
  box-shadow: 0 0 16px rgba(212,175,55,0.5);
}
.hand-toolbar {
  display: flex; gap: 6px; align-items: center;
  margin-bottom: 0;
}
.hand-toolbar .btn-mini { font-size: 0.7em; padding: 3px 8px; }
.toolbar-actions {
  display: flex; gap: 6px;
  flex: 1; flex-wrap: wrap;
  margin: 0;
}
.toolbar-actions button {
  padding: 12px 18px;
  font-size: 1em;
  font-weight: 700;
  margin: 0;
  white-space: nowrap;
  border-radius: 10px;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.4);
}
.toolbar-actions button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(212,175,55,0.4);
}

/* Top countdown badge — เห็นชัดบนสุด */
.top-countdown {
  background: linear-gradient(180deg, rgba(212,175,55,0.3), rgba(212,175,55,0.1));
  border-color: var(--gold) !important;
  font-weight: 700;
  animation: pulse-soft 1.4s ease-in-out infinite;
}
.turn-msg {
  background: linear-gradient(180deg, rgba(78,255,122,0.18), rgba(78,255,122,0.05));
  border-color: rgba(78,255,122,0.5) !important;
  color: #4eff7a !important;
  font-weight: 700;
  flex: 1;
  min-width: 0;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-countdown.warn {
  background: linear-gradient(180deg, rgba(255,107,107,0.3), rgba(255,107,107,0.1));
  border-color: #ff6b6b !important;
  color: #ff6b6b !important;
}
.top-countdown span { color: inherit; }
/* ★ Private room code pill */
.pd-room-code {
  background: linear-gradient(180deg, rgba(150,80,200,0.3), rgba(150,80,200,0.1));
  border-color: rgba(200,150,255,0.55) !important;
  color: #e0baff !important;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.pd-room-code:hover { filter: brightness(1.15); }
.pd-room-code span { color: #fff; font-family: 'Cinzel','Sarabun',monospace; }
@keyframes pulse-soft {
  0%,100% { box-shadow: 0 0 0 0 rgba(212,175,55,0.4); }
  50% { box-shadow: 0 0 8px 2px rgba(212,175,55,0.5); }
}

/* Meld view modal */
.meld-view-box { max-width: 640px; }
.meld-tabs {
  display: flex; gap: 2px;
  margin-bottom: 10px;
  border-bottom: 2px solid rgba(212,175,55,0.3);
  padding-bottom: 4px;
  overflow: hidden;          /* no scrollbar — tabs flex-shrink ให้พอดี */
  width: 100%;
}
.meld-tab {
  flex: 1 1 0;               /* แบ่งความกว้างเท่าๆ กัน — ไม่มี scroll */
  min-width: 0;
  padding: 6px 4px;
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 8px 8px 0 0;
  display: flex;
  flex-direction: column;     /* icon บน, ชื่อล่าง */
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.78em;
  cursor: pointer;
  overflow: hidden;
}
.meld-tab .mt-icon { font-size: 1.2em; line-height: 1; }
.meld-tab .mt-name {
  font-size: 0.88em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.meld-tab.active {
  background: linear-gradient(180deg, rgba(212,175,55,0.3), rgba(212,175,55,0.1));
  border-color: var(--gold);
  color: var(--gold-bright);
  font-weight: 700;
}
.meld-tab-body {
  min-height: 200px;
  /* ไม่จำกัด max-height — ให้ modal-box เป็น scroll เดียว */
}
/* "เกิดรวม" tab — แต่ละคนเป็น section */
.meld-all-section {
  border: 1px solid rgba(212,175,55,0.15);
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 10px;
  background: rgba(0,0,0,0.2);
}
.meld-all-section .meld-all-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(212,175,55,0.2);
}
/* override CSS อื่นที่อาจ apply margin: auto กับ avatar — บังคับให้ชิดซ้าย */
.meld-all-section .meld-all-header .avatar-circle {
  margin: 0 !important;
}
.meld-all-section .meld-all-header strong {
  margin: 0;
  flex-shrink: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* avatar + ชื่อ ชิดซ้าย, จำนวนชุด → ขวาบน (margin-left: auto) */
.meld-all-section .meld-all-count {
  margin-left: auto;
  font-size: 0.78em;
  color: #aaa;
  font-weight: 600;
}
.meld-all-section .meld-view-row {
  margin-bottom: 4px;
  padding: 6px;
}
/* ★ "เกิดรวม" — 2×2 grid 4 ช่อง (มือถือเห็นครบจอเดียว ไม่ต้องเลื่อน) */
.meld-all-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
/* compact card layout — ขนาดเล็กกว่าปกติเพื่อให้ใส่ได้ครบ */
.meld-all-section.mv-compact {
  margin-bottom: 0;
  padding: 6px;
  font-size: 0.78em;
}
.meld-all-section.mv-compact .meld-all-header {
  gap: 5px;
  margin-bottom: 4px;
  padding-bottom: 3px;
  font-size: 0.95em;
}
.meld-all-section.mv-compact .meld-all-count {
  font-size: 0.72em;
}
.meld-all-section.mv-compact .meld-view-row {
  padding: 4px;
  margin-bottom: 3px;
}
.meld-all-section.mv-compact .mvr-label {
  font-size: 0.7em !important;
  margin-bottom: 2px;
}
.meld-all-section.mv-compact .mvr-cards {
  gap: 1px;
}
/* card ภายใน "เกิดรวม" — บีบให้เล็กลง โชว์ครบ */
.meld-all-section.mv-compact .mvr-cards .card {
  width: 26px; height: 36px; font-size: 0.6em;
  margin-left: -6px;
}
.meld-all-section.mv-compact .mvr-cards .card:first-child {
  margin-left: 0;
}
.meld-all-section.mv-compact .mv-empty {
  font-size: 0.78em; color: #888;
  padding: 4px 0;
}
@media (max-width: 480px) {
  .meld-all-grid { gap: 4px; }
  .meld-all-section.mv-compact .mvr-cards .card {
    width: 22px; height: 30px; font-size: 0.5em;
    margin-left: -6px;
  }
}

/* ============================================================
   วิธีเล่น (How to Play) modal
   ============================================================ */
/* htp-box ไม่ override max-height/overflow แล้ว — ใช้ของ modal-box เป็นค่าตั้งต้น */
.htp-rate-banner {
  text-align: center;
  padding: 10px;
  background: linear-gradient(180deg, rgba(212,175,55,0.18), rgba(212,175,55,0.06));
  border: 1px solid rgba(212,175,55,0.4);
  border-radius: 10px;
  margin-bottom: 14px;
}
.htp-rate-name {
  font-size: 1.2em;
  font-weight: 800;
  color: var(--gold-bright);
  font-family: 'Cinzel', serif;
  letter-spacing: 0.5px;
  margin: 2px 0;
}
.htp-rate-detail {
  font-size: 0.85em;
  color: var(--text);
}
.htp-rate-detail strong { color: var(--gold-bright); }
.htp-h3 {
  margin: 14px 0 8px;
  font-size: 1.05em;
  color: var(--gold-bright);
  border-bottom: 1px solid rgba(212,175,55,0.25);
  padding-bottom: 4px;
}
.htp-list {
  margin: 4px 0 8px;
  padding-left: 22px;
  font-size: 0.92em;
  line-height: 1.6;
}
.htp-list li { margin-bottom: 2px; }
.htp-row {
  display: flex; gap: 10px; flex-wrap: wrap;
  align-items: flex-start;          /* ไม่ stretch ให้สูงเท่ากัน */
  margin-bottom: 8px;
}
.htp-col {
  flex: 1 1 220px;
  min-width: 0;
  background: rgba(0,0,0,0.25);
  border-radius: 8px;
  padding: 8px;
  /* ขนาดตาม content ไม่ขยายเกิน */
  height: auto !important;
  align-self: flex-start;          /* บังคับ shrink to content เสมอ */
}
.htp-cards {
  display: inline-flex;             /* ขยายตาม cards ไม่เต็มแถว */
  gap: 2px;
  padding: 4px 0;
}
.htp-label {
  font-size: 0.82em;
  color: var(--gold-bright);
  font-weight: 700;
  margin-bottom: 4px;
}
/* old .htp-cards rule replaced above by inline-flex variant — keep this stub for clarity */
.htp-events {
  display: grid; gap: 6px;
}
.htp-event {
  background: rgba(0,0,0,0.3);
  border-left: 3px solid #ff7a8c;
  border-radius: 6px;
  padding: 6px 10px;
}
.htp-event.htp-event-plus { border-left-color: #4eff7a; }
.htp-event.htp-event-pi   { border-left-color: var(--gold-bright); }
.htp-event-name {
  font-weight: 700;
  font-size: 0.95em;
  color: var(--text);
}
.htp-event-desc {
  font-size: 0.82em;
  color: #bbb;
  margin: 2px 0;
}
.htp-event-pay {
  font-size: 0.85em;
  color: var(--gold-bright);
}
.htp-event.htp-event-plus .htp-event-pay { color: #4eff7a; }
.htp-tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88em;
  margin-top: 6px;
}
.htp-tbl th {
  background: rgba(212,175,55,0.18);
  color: var(--gold-bright);
  padding: 6px;
  text-align: left;
}
.htp-tbl td {
  padding: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
@media (max-width: 480px) {
  .htp-box { max-height: 90dvh; }
  .htp-row { flex-direction: column; }
  /* บนมือถือ flex-direction:column → flex-basis 220px จะกลายเป็น HEIGHT
     ต้อง reset เป็น auto + ให้ width เต็มแถว */
  .htp-col {
    flex: 0 0 auto;
    width: 100%;
  }
}

/* Modal บนมือถือ — modal-box เต็มความกว้าง (5px gap), max-height ตาม viewport */
@media (max-width: 480px) {
  .modal-box {
    max-width: 100% !important;
    border-radius: 10px !important;
    padding: 14px !important;
  }
  /* ปลดล็อก max-height ของ scroll body ภายใน modal — ให้ใช้ scroll ของ modal-box เดียว */
  #meldsViewModal .meld-tab-body,
  #roomHistoryModal #roomHistoryBody,
  #payLogDetailModal #payLogDetailBody {
    max-height: none !important;
  }
}
.meld-view-row {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(212,175,55,0.2);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 6px;
}
.meld-view-row .mvr-label {
  font-size: 0.78em;
  color: var(--gold-bright);
  margin-bottom: 4px;
  font-weight: 700;
}
.meld-view-row .mvr-cards {
  display: flex; gap: 2px; flex-wrap: wrap;
}
.my-area {
  /* overflow-x: clip ตัดเฉพาะแกน X (ไพ่ไม่เลยจอ) แต่ปล่อยแกน Y ให้ visible
     เพื่อให้ sticker picker ที่ position:absolute ลอยขึ้นเหนือ toolbar ได้
     (ถ้าใช้ overflow-x:hidden browser จะบีบ overflow-y เป็น auto ด้วย → picker ถูก clip) */
  overflow-x: clip;
  overflow-y: visible;
}
.my-area .my-hand {
  min-height: 110px;
  padding: 40px 4px 8px;
  margin-bottom: 0;
  overflow: visible;
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  justify-content: flex-start;
  position: relative;
  z-index: 200;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.my-area .my-hand::-webkit-scrollbar { height: 4px; }
.my-area .my-hand::-webkit-scrollbar-thumb { background: var(--gold-soft); border-radius: 2px; }
.my-area .my-hand .card {
  width: 72px; height: 104px; font-size: 1.15em;
  margin-left: -38px;
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.18s ease-out, margin-left 0.18s ease-out, box-shadow 0.18s, z-index 0s;
  position: relative;
  /* กัน Android Chrome กรองด้วย browser gestures (scroll/zoom) → drag-reorder ไม่ทำงาน */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.my-area .my-hand .card:first-child { margin-left: 0; }
.my-area .my-hand .card .rank { font-size: 1.2em; }
.my-area .my-hand .card .suit { font-size: 1.3em; margin-top: 4px; }
.my-area .my-hand .card .corner { font-size: 0.7em; }
/* hover ไพ่ในมือ — เด้งขึ้น + อยู่หน้า (ไม่ขยับ margin เหมือนกองทิ้ง) */
.my-area .my-hand .card:hover {
  transform: translateY(-26px);
  z-index: 50;
  box-shadow: 0 14px 28px rgba(212,175,55,0.85);
}
/* selected — ค้างอยู่ + glow ทอง */
.my-area .my-hand .card.selected {
  transform: translateY(-26px);
  z-index: 40;
  outline: 2px solid var(--gold-bright);
  outline-offset: -2px;
  box-shadow: 0 0 0 3px var(--gold), 0 14px 28px rgba(212,175,55,0.9);
}
.my-area .my-hand .card.selected:hover {
  transform: translateY(-32px);
  z-index: 60;
}
.my-area .my-hand .card.dragging {
  opacity: 0.85;
  transform: translateY(-30px) rotate(3deg);
  z-index: 100;
  box-shadow: 0 0 0 3px var(--gold-bright), 0 16px 32px rgba(212,175,55,0.9);
  cursor: grabbing;
  pointer-events: none;
}

/* Sort button — icon only */
.sort-btn {
  background: linear-gradient(180deg, rgba(212,175,55,0.18), rgba(212,175,55,0.06));
  border: 1px solid rgba(212,175,55,0.5);
  color: var(--gold-bright);
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.78em;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.18s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 50px; min-height: 28px;
  flex-shrink: 0;
  font-family: 'Cinzel', 'Sarabun', sans-serif;
}
.sort-btn:hover {
  background: linear-gradient(180deg, rgba(212,175,55,0.3), rgba(212,175,55,0.12));
  border-color: var(--gold);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(212,175,55,0.4);
}
.sort-btn:active { transform: translateY(0); }
.sort-icon { display: inline-flex; gap: 3px; font-size: 1.05em; line-height: 1; align-items: center; }
.sort-icon .s-black { color: #f5f1e8; text-shadow: 0 1px 2px rgba(0,0,0,0.6); }
.sort-icon .s-red { color: #ff6b7e; text-shadow: 0 1px 2px rgba(0,0,0,0.6); }
.sort-icon[data-mode="rank"] {
  color: var(--gold-bright);
  letter-spacing: 2px;
}
.my-area .actions {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 3px; margin: 0;
}
.my-area .actions button {
  padding: 6px 2px;
  font-size: 0.68em;
  margin: 0;
  white-space: nowrap;
  line-height: 1.1;
}
.my-area .hint {
  padding: 3px 8px;
  font-size: 0.7em;
  margin: 0;
}
.my-info {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px;
}
.my-name-block { flex: 1; font-size: 0.88em; }
.my-name-block .my-sub {
  display: flex; gap: 8px; align-items: center;
  font-size: 0.85em; margin-top: 2px;
}
.turn-countdown {
  background: rgba(0,0,0,0.4);
  padding: 2px 8px; border-radius: 10px;
  font-size: 0.78em; color: var(--gold-bright);
  display: inline-block;
}

.hand-toolbar {
  display: flex; gap: 6px; margin-bottom: 6px;
}
.hand-toolbar .btn-mini { font-size: 0.78em; padding: 4px 10px; }

/* Discard pile — fan but visible */
.discard-pile .card { margin-left: -25px; } /* less overlap so rank visible */
.discard-pile .card:first-child { margin-left: 0; }

/* ============================================================
   Event popup overlay
   ============================================================ */
.event-overlay {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1500; pointer-events: none;     /* ★ สูงกว่า modal (1000) → popup ไม่โดน modal บัง */
  display: flex; flex-direction: column; gap: 8px;
}

/* ============================================================
   Knock Modal v2 — Modern neon design (impactful, celebratory)
============================================================ */
.knock-modal-v2 .knock-box {
  position: relative;
  max-width: 380px !important;
  background: linear-gradient(160deg, rgba(15,12,28,0.96) 0%, rgba(40,15,30,0.96) 60%, rgba(60,15,40,0.96) 100%);
  border: 2px solid rgba(255,215,0,0.55);
  border-radius: 22px;
  padding: 28px 24px 22px;
  text-align: center;
  overflow: visible;
  box-shadow:
    0 0 0 1px rgba(255,107,107,0.35),
    0 0 60px rgba(255,180,0,0.45),
    0 0 100px rgba(255,80,80,0.3),
    0 20px 60px rgba(0,0,0,0.8),
    inset 0 1px 0 rgba(255,255,255,0.15);
  animation: knockBoxIn 0.45s cubic-bezier(.18,.89,.32,1.28) forwards;
}
@keyframes knockBoxIn {
  0%   { transform: scale(0.5) rotate(-6deg); opacity: 0; filter: blur(6px); }
  60%  { transform: scale(1.05) rotate(2deg); opacity: 1; filter: blur(0); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* Animated halo glow ring behind box */
.knock-glow-ring {
  position: absolute;
  inset: -25px;
  border-radius: 28px;
  background: conic-gradient(
    from 0deg,
    rgba(255,215,0,0.5),
    rgba(255,80,80,0.6),
    rgba(255,140,0,0.5),
    rgba(255,215,0,0.5)
  );
  filter: blur(28px);
  z-index: -1;
  opacity: 0.65;
  animation: knockRing 3s linear infinite;
}
@keyframes knockRing {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.knock-modal-v2 .knock-title {
  font-family: 'Cinzel', 'Sarabun', serif;
  font-size: 3.2em;
  font-weight: 900;
  letter-spacing: 4px;
  background: linear-gradient(110deg, #ffd700 0%, #ff6b6b 40%, #ff9d3a 70%, #ffd700 100%);
  background-size: 220% auto;
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
          color: transparent;
  filter:
    drop-shadow(0 0 14px rgba(255,215,0,0.8))
    drop-shadow(0 0 26px rgba(255,107,107,0.55))
    drop-shadow(0 4px 8px rgba(0,0,0,0.7));
  line-height: 1;
  animation: knockTitleShine 2.4s linear infinite;
}
@keyframes knockTitleShine {
  0%   { background-position: 0% 50%; }
  100% { background-position: 220% 50%; }
}

.knock-modal-v2 .knock-subtitle {
  margin-top: 8px;
  font-size: 0.95em;
  color: #fff8d8;
  font-weight: 600;
  letter-spacing: 0.5px;
  opacity: 0.9;
  text-shadow: 0 2px 4px rgba(0,0,0,0.6);
}

/* Card preview */
.knock-modal-v2 .knock-card-preview {
  display: flex; justify-content: center;
  margin: 18px 0 12px;
}
.knock-mini-card {
  width: 90px; height: 126px;
  background: linear-gradient(180deg, #fff 0%, #f0e8d8 100%);
  color: #111;
  border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 800;
  box-shadow:
    0 0 0 2px rgba(255,215,0,0.7),
    0 0 30px rgba(255,180,0,0.6),
    0 12px 30px rgba(0,0,0,0.7);
  position: relative;
  animation: knockCardPulse 1.4s ease-in-out infinite;
}
.knock-mini-card.red { color: #c41e3a; }
.knock-mini-card .knock-mc-rank { font-size: 2.6em; line-height: 1; }
.knock-mini-card .knock-mc-suit { font-size: 1.8em; line-height: 1; margin-top: 4px; }
@keyframes knockCardPulse {
  0%, 100% {
    transform: rotate(-3deg) scale(1);
    box-shadow: 0 0 0 2px rgba(255,215,0,0.7), 0 0 30px rgba(255,180,0,0.5), 0 12px 30px rgba(0,0,0,0.7);
  }
  50% {
    transform: rotate(3deg) scale(1.06);
    box-shadow: 0 0 0 3px rgba(255,215,0,0.95), 0 0 50px rgba(255,180,0,0.85), 0 14px 40px rgba(0,0,0,0.8);
  }
}

.knock-modal-v2 .knock-hint {
  font-size: 0.95em;
  color: #ffd54a;
  font-weight: 700;
  letter-spacing: 0.3px;
  margin: 2px 0 18px;
  text-shadow: 0 0 8px rgba(255,215,0,0.5);
}

/* Action buttons */
.knock-modal-v2 .knock-actions {
  display: flex; gap: 10px;
  margin-top: 6px;
}
.knock-modal-v2 .knock-actions button {
  flex: 1;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  border-radius: 12px;
  padding: 12px 16px;
  transition: all 0.18s ease;
  letter-spacing: 0.5px;
}
.knock-modal-v2 .knock-btn-cancel {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.18);
  color: #ddd;
  font-size: 0.92em;
  flex: 0 0 90px;
}
.knock-modal-v2 .knock-btn-cancel:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.3);
}
.knock-modal-v2 .knock-btn-confirm {
  background: linear-gradient(135deg, #ffd700 0%, #ff6b6b 100%);
  color: #1a0a0a;
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.4),
    0 8px 24px rgba(255,180,0,0.6),
    0 4px 14px rgba(255,107,107,0.5),
    inset 0 1px 0 rgba(255,255,255,0.4);
  text-shadow: 0 1px 0 rgba(255,255,255,0.3);
}
.knock-modal-v2 .knock-btn-confirm::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,0.5) 50%, transparent 70%);
  background-size: 220% 100%;
  animation: knockBtnShine 2.2s linear infinite;
  pointer-events: none;
}
@keyframes knockBtnShine {
  0%   { background-position: 0% 0; }
  100% { background-position: 220% 0; }
}
.knock-modal-v2 .knock-btn-confirm:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.5),
    0 12px 30px rgba(255,180,0,0.75),
    0 6px 18px rgba(255,107,107,0.65);
}
.knock-modal-v2 .knock-btn-confirm:active { transform: translateY(0); filter: brightness(1.15); }
.knock-modal-v2 .knock-btn-label { font-size: 1.15em; font-weight: 900; line-height: 1.1; }
.knock-modal-v2 .knock-btn-sub { font-size: 0.72em; opacity: 0.78; font-weight: 600; }

@media (max-width: 380px) {
  .knock-modal-v2 .knock-box { padding: 22px 18px 18px; }
  .knock-modal-v2 .knock-title { font-size: 2.6em; letter-spacing: 3px; }
  .knock-mini-card { width: 76px; height: 108px; }
  .knock-mini-card .knock-mc-rank { font-size: 2.2em; }
  .knock-mini-card .knock-mc-suit { font-size: 1.5em; }
}

/* ============================================================
   Knock Modal v3 — Sparkles + Trophy + Holographic
============================================================ */
.knock-modal-v3 .knock-box {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255,215,0,0.18) 0%, transparent 60%),
    linear-gradient(160deg, rgba(15,12,28,0.97) 0%, rgba(40,15,60,0.96) 50%, rgba(70,15,50,0.96) 100%);
  border: 2px solid rgba(255,215,0,0.65);
  padding-top: 56px;
}
.knock-modal-v3 .knock-trophy {
  position: absolute;
  top: -24px; left: 50%;
  transform: translateX(-50%);
  font-size: 3.2em;
  filter:
    drop-shadow(0 0 14px rgba(255,215,0,0.95))
    drop-shadow(0 0 26px rgba(255,140,0,0.7))
    drop-shadow(0 6px 12px rgba(0,0,0,0.7));
  animation: knockTrophyBob 1.6s ease-in-out infinite;
  z-index: 3;
}
@keyframes knockTrophyBob {
  0%, 100% { transform: translateX(-50%) translateY(0) rotate(-4deg); }
  50%      { transform: translateX(-50%) translateY(-6px) rotate(4deg); }
}
/* Sparkles — เกล็ดดาวลอยรอบกล่อง */
.knock-modal-v3 .knock-sparkles {
  position: absolute; inset: 0;
  pointer-events: none; overflow: hidden;
  border-radius: 22px;
}
.knock-modal-v3 .kspark {
  position: absolute;
  font-size: 1.4em;
  color: #ffd700;
  text-shadow: 0 0 8px rgba(255,215,0,0.95), 0 0 16px rgba(255,140,0,0.6);
  animation: ksparkFloat 3s ease-in-out infinite;
  opacity: 0.9;
}
.knock-modal-v3 .kspark.s1 { top: 12%;  left: 8%;  animation-delay: 0.0s; color:#ffd700; }
.knock-modal-v3 .kspark.s2 { top: 22%;  right: 10%; animation-delay: 0.4s; color:#ff9d3a; font-size: 1.1em; }
.knock-modal-v3 .kspark.s3 { top: 50%;  left: 4%;  animation-delay: 0.8s; color:#ffaa55; }
.knock-modal-v3 .kspark.s4 { top: 60%;  right: 6%; animation-delay: 1.2s; color:#ffd700; font-size: 1.2em; }
.knock-modal-v3 .kspark.s5 { bottom: 22%; left: 14%; animation-delay: 1.6s; color:#fff8d8; font-size: 0.9em; }
.knock-modal-v3 .kspark.s6 { top: 6%; left: 50%; animation-delay: 0.6s; color:#ffd54a; font-size: 1.3em; }
.knock-modal-v3 .kspark.s7 { bottom: 12%; right: 18%; animation-delay: 1.0s; color:#ff6b6b; }
.knock-modal-v3 .kspark.s8 { top: 38%; right: 4%; animation-delay: 2.0s; color:#fff; font-size: 0.85em; }
@keyframes ksparkFloat {
  0%, 100% { transform: translateY(0) scale(1) rotate(0); opacity: 0.4; }
  50%      { transform: translateY(-10px) scale(1.4) rotate(180deg); opacity: 1; }
}
/* Title — holographic prismatic */
.knock-modal-v3 .knock-title {
  font-size: 3.4em;
  background: linear-gradient(110deg,
    #ffd700 0%, #ff9d3a 22%, #ff6b6b 44%, #c084fc 66%, #00f5ff 88%, #ffd700 100%);
  background-size: 280% auto;
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  filter:
    drop-shadow(0 0 16px rgba(255,215,0,0.85))
    drop-shadow(0 0 30px rgba(192,132,252,0.45))
    drop-shadow(0 4px 8px rgba(0,0,0,0.8));
  animation: knockTitleShine 2.6s linear infinite;
}
/* Win banner — แสดงรับประกันชนะ */
.knock-modal-v3 .knock-win-banner {
  margin: 4px 4px 14px;
  padding: 8px 12px;
  border-radius: 10px;
  background: linear-gradient(90deg,
    rgba(255,215,0,0.18) 0%,
    rgba(192,132,252,0.18) 50%,
    rgba(255,107,107,0.18) 100%);
  border: 1px solid rgba(255,215,0,0.35);
  color: #fff8d8;
  font-size: 0.82em;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
  box-shadow: inset 0 0 10px rgba(255,215,0,0.12), 0 2px 8px rgba(0,0,0,0.4);
  animation: knockBannerGlow 2.4s ease-in-out infinite;
}
@keyframes knockBannerGlow {
  0%, 100% { box-shadow: inset 0 0 10px rgba(255,215,0,0.10), 0 2px 8px rgba(0,0,0,0.4); }
  50%      { box-shadow: inset 0 0 16px rgba(255,215,0,0.30), 0 2px 14px rgba(255,180,0,0.4); }
}

/* ============================================================
   btnKnock — ปุ่มน็อกมีเอฟเฟค (พัลส์ + รัศมี + ไอคอนเด้ง)
============================================================ */
/* ปุ่มน็อก — display: inline-flex (ไม่มี !important) เพื่อให้ inline style="display:none" override ได้ */
.btn-knock {
  display: inline-flex;
  align-items: center; gap: 5px;
  background: linear-gradient(135deg, #ffd700 0%, #ff9d3a 50%, #ff6b6b 100%);
  color: #1a0a0a;
  font-weight: 900;
  letter-spacing: 0.5px;
  position: relative;
  overflow: visible;
  padding: 8px 16px;
  border-radius: 12px;
  border: 2px solid rgba(255,255,255,0.4);
  box-shadow:
    0 0 0 2px rgba(255,215,0,0.5),
    0 6px 20px rgba(255,180,0,0.65),
    0 4px 12px rgba(255,107,107,0.5),
    inset 0 1px 0 rgba(255,255,255,0.5);
  text-shadow: 0 1px 0 rgba(255,255,255,0.35);
  animation: btnKnockPulse 1.4s ease-in-out infinite;
}
.btn-knock::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 14px;
  background: conic-gradient(from 0deg,
    rgba(255,215,0,0.5),
    rgba(255,107,107,0.55),
    rgba(192,132,252,0.4),
    rgba(255,215,0,0.5));
  filter: blur(10px);
  z-index: -1;
  opacity: 0.85;
  animation: btnKnockHalo 2.4s linear infinite;
}
.btn-knock::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,0.55) 50%, transparent 70%);
  background-size: 220% 100%;
  animation: knockBtnShine 1.8s linear infinite;
  pointer-events: none;
}
.btn-knock .bk-icon {
  display: inline-block;
  font-size: 1.15em;
  animation: btnKnockIconBounce 0.9s ease-in-out infinite;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}
.btn-knock .bk-label {
  font-size: 1em;
  font-weight: 900;
  font-family: 'Cinzel','Sarabun',serif;
}
.btn-knock:hover {
  transform: translateY(-2px) scale(1.04);
  filter: brightness(1.1);
}
.btn-knock:active { transform: translateY(0) scale(0.98); }
@keyframes btnKnockPulse {
  0%, 100% {
    box-shadow:
      0 0 0 2px rgba(255,215,0,0.5),
      0 6px 20px rgba(255,180,0,0.55),
      0 4px 12px rgba(255,107,107,0.4),
      inset 0 1px 0 rgba(255,255,255,0.5);
  }
  50% {
    box-shadow:
      0 0 0 3px rgba(255,215,0,0.85),
      0 10px 32px rgba(255,180,0,0.85),
      0 6px 18px rgba(255,107,107,0.7),
      inset 0 1px 0 rgba(255,255,255,0.6);
  }
}
@keyframes btnKnockHalo {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
@keyframes btnKnockIconBounce {
  0%, 100% { transform: scale(1) rotate(-8deg); }
  50%      { transform: scale(1.18) rotate(8deg); }
}
/* ============================================================
   Event Popup v3 — color-coded, glassmorphism, mobile-first
   Categories: knock (gold) | bonus (green) | penalty (red)
              | pi (purple/orange) | dumb (cobalt-violet) | info (slate)
============================================================ */
.evp {
  --evp-c1: #ffd700;
  --evp-c2: #c8102e;
  --evp-glow: rgba(255,215,0,0.55);
  --evp-text: #fff8e7;
  position: relative;
  min-width: 220px;
  max-width: min(86vw, 380px);
  padding: 14px 22px 16px;
  border-radius: 18px;
  text-align: center;
  font-family: 'Cinzel','Sarabun',serif;
  font-weight: 800;
  color: var(--evp-text);
  background:
    linear-gradient(155deg, color-mix(in srgb, var(--evp-c1) 65%, #000) 0%,
                            color-mix(in srgb, var(--evp-c2) 75%, #000) 100%);
  border: 2px solid color-mix(in srgb, var(--evp-c1) 80%, #fff 0%);
  box-shadow:
    0 14px 38px rgba(0,0,0,0.55),
    0 0 32px var(--evp-glow),
    inset 0 1px 0 rgba(255,255,255,0.22),
    inset 0 -2px 8px rgba(0,0,0,0.35);
  text-shadow: 0 2px 6px rgba(0,0,0,0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  overflow: hidden;
  isolation: isolate;
  animation: evp-in 0.5s cubic-bezier(.18,.89,.32,1.28) forwards;
  pointer-events: none;
}
.evp.evp-out { animation: evp-out 0.55s ease-in forwards; }

/* shine sweep */
.evp .evp-shine {
  position: absolute; inset: 0;
  background: linear-gradient(110deg,
    transparent 30%,
    rgba(255,255,255,0.28) 48%,
    rgba(255,255,255,0.08) 56%,
    transparent 72%);
  transform: translateX(-120%);
  animation: evp-shine 1.6s ease 0.25s 1 forwards;
  pointer-events: none;
  z-index: 0;
}
@keyframes evp-shine {
  to { transform: translateX(120%); }
}

.evp .evp-header {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  gap: 8px;
  font-size: 1.7em;
  line-height: 1.05;
  letter-spacing: 0.5px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}
.evp .evp-icon {
  font-size: 1.15em;
  display: inline-block;
  animation: evp-icon-bounce 0.9s ease-in-out infinite;
  filter: drop-shadow(0 0 10px var(--evp-glow));
}
.evp .evp-kind { white-space: nowrap; }
.evp .evp-bang {
  color: color-mix(in srgb, var(--evp-c1) 90%, #fff);
  filter: drop-shadow(0 0 6px var(--evp-glow));
}
.evp .evp-tagline {
  position: relative; z-index: 1;
  font-size: 0.78em;
  font-weight: 700;
  margin-top: 4px;
  opacity: 0.92;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--evp-c1) 60%, #fff);
}
.evp .evp-by {
  position: relative; z-index: 1;
  font-size: 0.86em;
  font-weight: 700;
  margin-top: 8px;
  padding: 4px 10px;
  background: rgba(0,0,0,0.32);
  border-radius: 999px;
  display: inline-block;
  border: 1px solid rgba(255,255,255,0.14);
}
.evp .evp-rows {
  position: relative; z-index: 1;
  margin-top: 10px;
  display: flex; flex-direction: column; gap: 5px;
}
.evp .evp-row {
  display: flex; align-items: center; justify-content: center;
  gap: 6px;
  font-size: 0.84em;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0,0,0,0.28);
  border: 1px solid rgba(255,255,255,0.12);
}
.evp .evp-row .evp-arrow { font-size: 0.85em; }
.evp .evp-row-gain { color: #d2ffd6; border-color: rgba(80,255,120,0.4); }
.evp .evp-row-gain .evp-arrow { color: #4eff7a; }
.evp .evp-row-loss { color: #ffd9d9; border-color: rgba(255,90,90,0.4); }
.evp .evp-row-loss .evp-arrow { color: #ff6b6b; }
.evp .evp-name { font-weight: 800; }
.evp .evp-tag { opacity: 0.85; font-size: 0.92em; }

/* === Categories === */
/* KNOCK — gold + crimson, big & celebratory */
.evp-knock {
  --evp-c1: #ffd700;
  --evp-c2: #c8102e;
  --evp-glow: rgba(255,180,40,0.7);
}
.evp-knock .evp-header { font-size: 2.0em; }
.evp-knock { animation: evp-in 0.55s cubic-bezier(.18,.89,.32,1.28) forwards, evp-knock-pulse 1.2s ease-in-out 0.5s 2; }
@keyframes evp-knock-pulse {
  0%,100% { box-shadow: 0 14px 38px rgba(0,0,0,0.55), 0 0 32px var(--evp-glow), inset 0 1px 0 rgba(255,255,255,0.22); }
  50%     { box-shadow: 0 14px 38px rgba(0,0,0,0.55), 0 0 60px var(--evp-glow), 0 0 80px rgba(255,107,107,0.4), inset 0 1px 0 rgba(255,255,255,0.3); }
}

/* BONUS — emerald + mint (gain) */
.evp-bonus {
  --evp-c1: #4eff9a;
  --evp-c2: #0a7a3f;
  --evp-glow: rgba(80,255,160,0.55);
  --evp-text: #eafff2;
}

/* PENALTY — crimson + magenta (loss) */
.evp-penalty {
  --evp-c1: #ff6b6b;
  --evp-c2: #7a0a1f;
  --evp-glow: rgba(255,90,90,0.55);
  --evp-text: #fff0f0;
}

/* PI — violet + amber (transfer) */
.evp-pi {
  --evp-c1: #ffae3d;
  --evp-c2: #6b21a8;
  --evp-glow: rgba(192,132,252,0.55);
  --evp-text: #fff5e6;
}

/* DUMB — cobalt + violet w/ shake */
.evp-dumb {
  --evp-c1: #facc15;
  --evp-c2: #4338ca;
  --evp-glow: rgba(250,204,21,0.55);
  --evp-text: #fff7d6;
  animation: evp-in 0.5s cubic-bezier(.18,.89,.32,1.28) forwards, evp-shake 0.5s ease-in-out 0.4s 2;
}
.evp-dumb::before, .evp-dumb::after {
  content: '💢';
  position: absolute;
  font-size: 1.2em;
  filter: drop-shadow(0 0 6px rgba(255,200,80,0.85));
  z-index: 2;
}
.evp-dumb::before { top: -10px; right: -10px; animation: evp-spin 1.6s linear infinite; }
.evp-dumb::after  { top: -8px;  left: -12px; animation: evp-spin 1.4s linear infinite reverse; }

/* INFO — slate */
.evp-info {
  --evp-c1: #94a3b8;
  --evp-c2: #1e293b;
  --evp-glow: rgba(148,163,184,0.45);
  --evp-text: #e2e8f0;
}

/* Mobile tighten */
@media (max-width: 480px) {
  .evp { min-width: 180px; padding: 12px 16px 14px; border-radius: 16px; }
  .evp .evp-header { font-size: 1.4em; gap: 6px; }
  .evp-knock .evp-header { font-size: 1.65em; }
  .evp .evp-tagline { font-size: 0.72em; }
  .evp .evp-by, .evp .evp-row { font-size: 0.78em; }
}

/* === Animations === */
@keyframes evp-in {
  0%   { transform: translateY(-18px) scale(0.5) rotate(-6deg); opacity: 0; filter: blur(4px); }
  60%  { transform: translateY(0) scale(1.06) rotate(1deg); opacity: 1; filter: blur(0); }
  100% { transform: translateY(0) scale(1) rotate(0); opacity: 1; }
}
@keyframes evp-out {
  0%   { transform: scale(1) translateY(0); opacity: 1; }
  100% { transform: scale(0.85) translateY(-24px); opacity: 0; filter: blur(3px); }
}
@keyframes evp-icon-bounce {
  0%, 100% { transform: scale(1) rotate(-6deg); }
  50%      { transform: scale(1.18) rotate(6deg); }
}
@keyframes evp-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
@keyframes evp-spin {
  to { transform: rotate(360deg); }
}

/* Legacy fallback (in case old class names linger) */
.event-popup:not(.evp) {
  background: linear-gradient(135deg, #c8102e 0%, #6a0a1f 100%);
  color: #fff; padding: 18px 32px; border-radius: 14px;
  font-size: 1.5em; font-weight: 800; border: 3px solid var(--gold);
  box-shadow: 0 12px 40px rgba(0,0,0,0.7), 0 0 30px rgba(212,175,55,0.5);
  text-align: center; font-family: 'Cinzel','Sarabun',serif;
  animation: evp-in 0.5s cubic-bezier(.18,.89,.32,1.28) forwards;
}

/* ============================================================
   Ready stage (Battle royale)
   ============================================================ */
#screen-lobby.active {
  display: flex !important;
  flex-direction: column;
  justify-content: stretch;
  padding: 76px 12px 12px;
  height: 100vh;
  height: 100dvh;
  box-sizing: border-box;
}
.ready-stage {
  width: 100%;
  display: flex; flex-direction: column;
  gap: 14px;
  flex: 1;
  min-height: 0;
  /* ★ Push ลงให้ไม่โดน menu bar บนบัง (มือถือ + เดสก์ท็อป) */
  padding-top: 14px;
}
/* ★ Mobile — menu bar สูงกว่า → push ลงมากขึ้น */
@media (max-width: 600px) {
  .ready-stage { padding-top: 22px; }
}
.ready-stage .ready-arena { flex: 1; }
.ready-header {
  text-align: center;
  background: linear-gradient(180deg, rgba(0,0,0,0.5), rgba(0,0,0,0.3));
  border-radius: 14px;
  padding: 14px;
  border: 2px solid rgba(212,175,55,0.4);
}
/* ★ เรท เป็นหัวข้อหลัก — ใหญ่ ทอง */
.ready-rate {
  font-family: 'Cinzel', serif;
  font-size: 1.4em;
  color: var(--gold-bright);
  letter-spacing: 2px;
  font-weight: 700;
}
/* ★ ห้อง + เสียได้สูงสุด — เป็นรอง */
.ready-room {
  color: var(--text-dim);
  margin-top: 4px;
  font-size: 0.92em;
}
.ready-room #roomIdLabel { color: var(--text); font-weight: 600; letter-spacing: 1px; }
.ready-room #readyMaxBet { color: var(--text-dim); }
.ready-status {
  margin-top: 8px;
  color: var(--text);
  font-weight: 600;
  font-size: 1em;
}
.ready-countdown-big {
  font-family: 'Cinzel', serif;
  font-size: 4em; line-height: 1;
  color: var(--gold-bright);
  text-shadow: 0 0 24px var(--gold);
  margin-top: 8px;
  min-height: 0;
  transition: all 0.3s;
  display: none;
}
.ready-countdown-big.active { display: block; animation: pulse-grow 1s ease-out; }
@keyframes pulse-grow {
  0% { transform: scale(0.5); opacity: 0; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.ready-arena {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  flex: 1;
  background:
    radial-gradient(ellipse at center, rgba(36,107,86,0.3) 0%, transparent 70%);
  padding: 12px;
  border-radius: 14px;
  min-height: 320px;
}
.ready-slot {
  background: rgba(0,0,0,0.3);
  border: 2px dashed rgba(212,175,55,0.25);
  border-radius: 12px;
  padding: 14px 8px;
  text-align: center;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  position: relative;
  transition: all 0.3s;
}
.ready-slot.empty {
  opacity: 0.4;
}
.ready-slot.empty::after {
  content: 'รอผู้เล่น';
  color: var(--text-dim);
  font-size: 0.85em;
}
.ready-slot.filled {
  background: linear-gradient(145deg, rgba(13,17,46,0.85), rgba(19,23,55,0.95));
  border-style: solid;
  border-color: rgba(212,175,55,0.4);
}
.ready-slot.is-ready {
  border-color: #4eff7a;
  box-shadow: 0 0 18px rgba(78,255,122,0.4);
}
.ready-slot .big-avatar {
  font-size: 4em;
  width: 90px; height: 90px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
  border: 3px solid var(--gold);
  background: var(--bg-mid);
}
.ready-slot .ready-name {
  font-weight: 700;
  color: var(--gold-bright);
  font-size: 1em;
}
.ready-slot .ready-tag {
  position: absolute; top: 4px;
  background: linear-gradient(180deg, #4eff7a, #2e7d32);
  color: #fff;
  padding: 3px 12px;
  border-radius: 12px;
  font-size: 0.7em;
  font-weight: 700;
  letter-spacing: 1px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  display: none;
}
.ready-slot.is-ready .ready-tag {
  display: block;
  animation: ready-pulse 1.6s ease-in-out infinite;
}
@keyframes ready-pulse {
  0%, 100% { transform: translateY(0) scale(1); opacity: 1; box-shadow: 0 2px 6px rgba(78,255,122,0.4); }
  50% { transform: translateY(-2px) scale(1.05); opacity: 1; box-shadow: 0 4px 14px rgba(78,255,122,0.7); }
}
.ready-slot.is-host .host-crown {
  position: absolute; top: -10px; right: 8px;
  font-size: 1.4em;
}
.ready-slot .friend-tag {
  position: absolute; top: 4px; left: 4px;
  background: rgba(78,255,122,0.2);
  border: 1px solid #4eff7a;
  color: #4eff7a;
  padding: 2px 6px;
  border-radius: 8px;
  font-size: 0.65em;
  font-weight: 700;
}
.ready-slot.is-warned {
  border-color: #ff6b6b;
  box-shadow: 0 0 18px rgba(255,107,107,0.5);
  animation: warn-pulse 0.8s infinite;
}
@keyframes warn-pulse {
  0%,100% { box-shadow: 0 0 18px rgba(255,107,107,0.5); }
  50% { box-shadow: 0 0 28px rgba(255,107,107,0.9); }
}
.warn-countdown {
  position: absolute; bottom: 4px; left: 50%;
  transform: translateX(-50%);
  background: rgba(255,107,107,0.2);
  border: 1px solid #ff6b6b;
  color: #ff6b6b;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75em;
  font-weight: 700;
}

.ready-actions {
  display: flex; gap: 8px; align-items: stretch;
}
.ready-actions .btn-primary.big-ready { flex: 3; font-size: 1.2em; }
.ready-actions .leave-small { flex: 1; font-size: 0.85em; padding: 12px 8px; }
.ready-actions .leave-small.locked,
.ready-actions .leave-small:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.7);
}
.btn-primary.big-ready {
  font-size: 1.1em;
  padding: 16px;
  background: linear-gradient(180deg, #4eff7a, #2e7d32);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.btn-primary.big-ready.is-ready {
  background: linear-gradient(180deg, #555, #333);
  color: #ccc;
}

/* ============================================================
   Meld slots — 4 colored areas (by seat)
   ============================================================ */
.melds-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  flex: 1;
  min-height: 0;
  margin: 0;
  align-items: stretch;
}
/* ★ Layout ตามจำนวนผู้เล่นจริง — ซ่อนช่องว่างให้ช่องอื่นขยายเต็ม */
.melds-grid[data-players="2"] {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr 1fr;
}
.melds-grid[data-players="3"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}
/* 3 คน: ของฉัน (bl) อยู่แถวล่างเต็มความกว้าง */
.melds-grid[data-players="3"] .meld-slot.slot-bl {
  grid-column: 1 / -1;
}
.melds-grid[data-players="4"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.meld-slot {
  border-radius: 10px;
  padding: 3px 3px 4px;
  border: 2px solid transparent;
  display: flex; flex-direction: column;
  gap: 2px;
  font-size: 0.85em;
  position: relative;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
/* ★ ทุกช่อง — overflow: visible เพื่อให้ slot-header ลอยเลยขอบขึ้นไปได้
   (slot-melds ภายในยังเป็น overflow: hidden — ไพ่จะไม่ทะลุออกไป) */
.meld-slot {
  overflow: visible;
}
.slot-header {
  display: flex; align-items: center; gap: 5px;
  padding: 0;
  min-height: 0;
}
/* ★ ลอย header เลยขอบช่องขึ้นไปเยอะๆ ทั้ง 4 ช่อง — เพิ่มพื้นที่ slot-melds */
.meld-slot .slot-header {
  margin-top: -18px;
  z-index: 3;
  position: relative;
}
/* ★ slot-melds มี padding-top เล็กน้อยเพื่อ breathing room ไม่ให้ไพ่ติด header */
.meld-slot .slot-melds {
  padding-top: 2px;
}
.slot-owner { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* AFK badge บน avatar — ไม่มี animation ไม่มีเสียง */
.slot-avatar.is-afk {
  filter: grayscale(0.6);
  opacity: 0.7;
}
.slot-avatar .afk-tag {
  position: absolute;
  bottom: -4px; right: -6px;
  background: #555;
  color: #ddd;
  font-size: 8px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 6px;
  border: 1px solid #888;
  letter-spacing: 0.5px;
  pointer-events: none;
}
.slot-avatar { position: relative; }
.slot-handcount {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 5px;
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(212,175,55,0.35);
  border-radius: 10px;
  font-size: 0.72em; font-weight: 700;
  color: var(--gold-bright, #d4af37);
  flex-shrink: 0;
}
.slot-handcount .hc-num { line-height: 1; }
.slot-balance {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 6px;
  /* ★ พื้นทึบ (ไม่โปร่งใส) เพื่อให้เห็นยอดชัดเจน แม้มีไพ่หลังหรือพื้นเข้ม */
  background: #1a1530;
  border: 1px solid rgba(245,210,90,0.7);
  border-radius: 10px;
  font-size: 0.72em; font-weight: 800;
  color: #ffe88a;
  text-shadow: 0 1px 2px rgba(0,0,0,0.55);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.45);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.slot-balance::before {
  content: '💰';
  font-size: 0.92em;
  filter: drop-shadow(0 0 2px rgba(255,200,80,0.65));
}
.slot-balance:empty { display: none; }
.meld-slot.flash-gain .slot-balance {
  box-shadow: 0 0 12px rgba(120,255,140,0.55), inset 0 0 8px rgba(120,255,140,0.20);
  transform: scale(1.06);
}
.meld-slot.flash-loss .slot-balance {
  box-shadow: 0 0 12px rgba(255,90,110,0.55), inset 0 0 8px rgba(255,90,110,0.20);
  transform: scale(1.06);
}
.card-back-mini {
  display: inline-block;
  width: 11px; height: 15px;
  border-radius: 2px;
  background:
    repeating-linear-gradient(45deg, #1a3a8a 0 2px, #2a5cb8 2px 4px),
    #1a3a8a;
  border: 1px solid rgba(255,255,255,0.4);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.3);
}
.slot-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1em; line-height: 1;
  background: var(--bg-mid);
  flex-shrink: 0;
  transition: transform 0.2s, box-shadow 0.2s;
}
.meld-slot.is-current .slot-avatar {
  transform: scale(1.18);
  /* white ring (3px) ครอบรอบรูป + glow ทองเดิม */
  box-shadow: 0 0 0 3px #fff, 0 0 14px var(--gold-bright), 0 0 6px rgba(255,215,0,0.8);
  animation: avatar-glow 1.4s ease-in-out infinite;
}
@keyframes avatar-glow {
  0%,100% { box-shadow: 0 0 0 3px #fff, 0 0 14px var(--gold-bright), 0 0 6px rgba(255,215,0,0.8); }
  50% { box-shadow: 0 0 0 3px #fff, 0 0 24px var(--gold-bright), 0 0 12px rgba(255,215,0,1); }
}

/* ตาใครก็ตาม — slot ของคนนั้นมี border ขาว + shadow ขาว กระพริบช้าๆ */
.meld-slot.slot-tl.is-current,
.meld-slot.slot-tr.is-current,
.meld-slot.slot-bl.is-current,
.meld-slot.slot-br.is-current {
  animation: slot-pulse-white 2.4s ease-in-out infinite;
}
@keyframes slot-pulse-white {
  0%,100% {
    border-color: rgba(255,255,255,0.7);
    box-shadow: 0 0 0 rgba(255,255,255,0);
    background: rgba(255,255,255,0.06);
  }
  50% {
    border-color: rgba(255,255,255,1);
    box-shadow: 0 0 24px rgba(255,255,255,0.85), inset 0 0 16px rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.14);
  }
}
/* checkmark "เกิดแล้ว" — เอาออก เพราะดูได้จากช่องเกิดอยู่แล้ว */
#myMeldedBadge { display: none !important; }

/* hand-toolbar needs relative for absolute picker */
.hand-toolbar { position: relative; }

/* Sticker picker (popup above sticker button) */
.sticker-picker {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  background: rgba(20,24,34,0.96);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 12px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  z-index: 50;
  min-width: 240px;
  max-width: 90vw;
  max-height: 60vh;
  overflow-y: auto;
}
.sticker-picker .sticker-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sticker-picker .sticker-set-tab {
  flex: 0 0 auto;
  background: rgba(255,255,255,0.06);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 1.2em;
  cursor: pointer;
  color: var(--text);
  transition: all 0.12s;
}
.sticker-picker .sticker-set-tab.active {
  background: rgba(212,175,55,0.18);
  border-color: var(--gold-bright);
}
.sticker-picker .sticker-set-tab.locked { opacity: 0.5; font-size: 0.95em; }
.sticker-picker .sticker-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}
.sticker-picker .sticker-grid button {
  background: rgba(255,255,255,0.06);
  border: none;
  border-radius: 8px;
  padding: 6px 4px;
  font-size: 1.5em;
  cursor: pointer;
  transition: transform 0.1s, background 0.1s;
  color: var(--text);
}
.sticker-picker .sticker-grid button:hover { background: rgba(255,255,255,0.18); transform: scale(1.15); }
.sticker-picker .sticker-grid button:active { transform: scale(0.92); }

/* ★ Text-pack mode — แพ็คที่เป็น "ตัวหนังสือ" (เช่น textbasic, ขอโทษ/สวัสดี) ตัวเล็กลง + word-wrap
   ใช้ class is-text-pack บน .sticker-grid → button ใน grid จะปรับขนาดให้อ่านพอดี ไม่ล้น */
.sticker-picker .sticker-grid.is-text-pack {
  grid-template-columns: repeat(3, 1fr);   /* ★ 3 คอลัมน์ — ให้พื้นที่กว้างขึ้นต่อปุ่ม */
  gap: 6px;
}
.sticker-picker .sticker-grid.is-text-pack button {
  font-size: 0.85em;            /* ★ ลดจาก 1.5em → 0.85em */
  font-weight: 600;
  padding: 10px 6px;             /* ★ padding เยอะขึ้น (กดง่ายขึ้นเพราะตัวอักษรเล็ก) */
  line-height: 1.25;
  white-space: normal;           /* ★ wrap ได้ ไม่ล้น */
  word-break: break-word;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.sticker-picker .sticker-grid.is-text-pack button:hover { transform: scale(1.05); }

/* Cooldown state — ปุ่ม emoji ใน picker จะ disable ตอนรอ cooldown */
.sticker-picker.cooldown .sticker-grid button {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
  filter: grayscale(0.5);
}
/* ปุ่ม trigger sticker (😀 → 5s) — แสดงสถานะรออย่างชัด */
#btnSticker.cooldown {
  opacity: 0.55;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.15);
  font-size: 0.85em;
  font-weight: 700;
  color: var(--gold-bright);
  letter-spacing: 0.5px;
  cursor: not-allowed;
}
.sticker-picker .sticker-locked-msg {
  text-align: center;
  padding: 16px 10px;
  color: var(--text);
}
.sticker-picker .sticker-locked-msg .btn-buy-pack {
  margin-top: 6px;
  background: linear-gradient(180deg, var(--gold-bright), #b8860b);
  color: #1a1a2e;
  border: none;
  padding: 8px 18px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}

/* Sticker overlay (full-screen display when received) */
.sticker-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.sticker-overlay .sticker-fly {
  font-size: clamp(120px, 40vw, 280px);
  filter: drop-shadow(0 6px 18px rgba(0,0,0,0.55));
  /* ★ Animation 3.00s — pop in (0.33s) + settle (0.48s) + hold เต็มตา 2.00s + fade out (0.20s) */
  animation: stickerPop 3.0s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  text-align: center;
  line-height: 1;
  max-width: 92vw;
  word-break: break-word;
  /* ★ จัด emoji + ชื่อให้กึ่งกลางในแนวตั้ง — ใช้ flex column */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.05em;
}
/* ★ Text mode — เวลาผู้ใช้ใส่ข้อความ ("ขอโทษ", "สวัสดี" ฯลฯ)
   ลดขนาดให้พอดีหน้าจอ + เพิ่ม shadow ให้อ่านง่าย */
.sticker-overlay .sticker-fly.is-text {
  font-size: clamp(34px, 9vw, 88px);
  font-weight: 800;
  color: #fff;
  text-shadow:
    0 2px 4px rgba(0,0,0,0.7),
    0 4px 18px rgba(0,0,0,0.55),
    0 0 24px rgba(255,215,0,0.45);
  filter: none;
  letter-spacing: 0.5px;
  padding: 0 12px;
}
.sticker-overlay .sticker-fly .sticker-from {
  /* ★ ใช้ขนาด absolute (ไม่อิงตัว emoji) — ให้ชื่อมีขนาดคงที่และเล็กลง */
  font-size: clamp(11px, 1.8vw, 15px);
  display: block;
  margin-top: 10px;
  color: rgba(255,255,255,0.92);
  font-weight: 600;
  text-shadow: 0 2px 6px rgba(0,0,0,0.85);
  font-family: 'Sarabun', sans-serif;
  letter-spacing: 0.3px;
  opacity: 0.85;
}
.sticker-overlay .sticker-fly.is-text .sticker-from {
  margin-top: 6px;
}
/* ★ Animation — pop เข้านุ่มๆ ค้างเต็มตา 2.00 วิ (ชัดเจน) เบลอนิดเดียวตอนหายไป
   Total 3.00s: pop in 0-11% (0.33s) → settle 18% (0.54s) → hold ชัด 27-93% (0.81s-2.79s = 1.98s) → fade 93-100% (0.21s)
   ★ filter: blur(0) ทุก keyframe ระหว่าง pop-end → fade-start (กัน interpolate) */
@keyframes stickerPop {
  0%   { transform: scale(0.4)  translateY(20px);  opacity: 0; filter: blur(8px); }
  11%  { transform: scale(1.08) translateY(0);     opacity: 1; filter: blur(0);   }
  18%  { transform: scale(0.98) translateY(0);     opacity: 1; filter: blur(0);   }
  27%  { transform: scale(1.0)  translateY(0);     opacity: 1; filter: blur(0);   }
  93%  { transform: scale(1.0)  translateY(0);     opacity: 1; filter: blur(0);   }
  100% { transform: scale(1.08) translateY(-16px); opacity: 0; filter: blur(2px); }
}

.meld-slot.slot-tl { background: rgba(64,120,220,0.15); border-color: rgba(64,120,220,0.5); }
.meld-slot.slot-tr { background: rgba(220,64,80,0.15);  border-color: rgba(220,64,80,0.5); }
.meld-slot.slot-bl { background: rgba(212,175,55,0.18); border-color: rgba(212,175,55,0.6); }
.meld-slot.slot-br { background: rgba(64,200,100,0.15); border-color: rgba(64,200,100,0.5); }
.meld-slot .slot-owner {
  font-size: 0.78em;
  font-weight: 700;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  /* ★ พื้นทึบ + ขอบรอบชื่อเพื่ออ่านชัดเจน (ก่อนหน้านี้สีตัวอักษรซ้อนกับพื้นช่อง) */
  background: #1a1530;
  padding: 1px 7px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.meld-slot.slot-tl .slot-owner { color: #6da5ff; }
.meld-slot.slot-tr .slot-owner { color: #ff8590; }
.meld-slot.slot-bl .slot-owner { color: var(--gold-bright); }
.meld-slot.slot-br .slot-owner { color: #67e090; }

/* ใบที่ฝากโดยผู้เล่นอื่น — มีสี border ของผู้ฝาก (สื่อว่าใครฝาก) */
.card.deposited-by-tl {
  box-shadow: 0 0 0 2px #6da5ff inset, 0 0 6px rgba(109,165,255,0.6);
}
.card.deposited-by-tr {
  box-shadow: 0 0 0 2px #ff8590 inset, 0 0 6px rgba(255,133,144,0.6);
}
.card.deposited-by-bl {
  box-shadow: 0 0 0 2px var(--gold-bright) inset, 0 0 6px rgba(212,175,55,0.6);
}
.card.deposited-by-br {
  box-shadow: 0 0 0 2px #67e090 inset, 0 0 6px rgba(103,224,144,0.6);
}
.meld-slot .slot-melds {
  display: flex; flex-direction: row; flex-wrap: wrap; gap: 4px;
  flex: 1; min-height: 0;
  align-content: flex-start;
  justify-content: center;        /* ★ จัดกึ่งกลาง — กันบัค "ไพ่กระจุกซ้าย ช่องขวาว่าง" ในช่องแคบ */
  overflow: hidden;
}
/* ★ meld-row จัดวางตามธรรมชาติ (row + wrap)
   - ช่องกว้าง (2-player ทุกช่อง, 3-player ช่อง bl): melds เรียงข้างกันหลายชุดต่อแถว → ตรงกลาง
   - ช่องแคบ (4-player, 3-player ช่อง tl/tr): meld 1 ชุดต่อแถว → meld อยู่ตรงกลางช่อง */
.meld-slot .meld-row {
  display: flex;
  flex-wrap: wrap;                   /* ★ wrap ไพ่ลงบรรทัดถัดไปถ้าไม่พอ (มือถือ) */
  row-gap: 2px;
  gap: 0;                            /* ใช้ margin-left ติดลบแทน gap เพื่อ fan/overlap */
  background: rgba(0,0,0,0.25);
  padding: 1px 3px;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 1;
  min-width: 0;
  max-width: 100%;
}
.meld-slot .meld-row .card.small {
  flex-shrink: 0;
  width: 38px; height: 54px; font-size: 0.82em;
  margin-left: -10px;                /* visible 28px ≈ 74% — เห็นรหัส (rank+suit) ชัดเจน */
}
.meld-slot .meld-row .card.small:first-child { margin-left: 0; }
/* ★ Auto-shrink ตามจำนวนไพ่รวมในช่อง (ตั้งจาก client.js: data-cards = xl/lg/md/sm/xs) */
.slot-melds[data-cards="xl"] .meld-row .card.small {
  width: 40px; height: 56px; font-size: 0.85em; margin-left: -8px;
}
.slot-melds[data-cards="lg"] .meld-row .card.small {
  width: 36px; height: 50px; font-size: 0.78em; margin-left: -10px;
}
.slot-melds[data-cards="md"] .meld-row .card.small {
  width: 32px; height: 46px; font-size: 0.72em; margin-left: -10px;
}
.slot-melds[data-cards="sm"] .meld-row .card.small {
  width: 28px; height: 40px; font-size: 0.64em; margin-left: -9px;
}
.slot-melds[data-cards="xs"] .meld-row .card.small {
  width: 22px; height: 32px; font-size: 0.52em; margin-left: -10px;
}
.slot-melds[data-cards="xxs"] .meld-row .card.small {
  width: 18px; height: 26px; font-size: 0.44em; margin-left: -10px;
}
.slot-melds[data-cards="xxxs"] .meld-row .card.small {
  width: 15px; height: 22px; font-size: 0.36em; margin-left: -9px;
}
/* ใบแรกของทุก row ไม่ overlap */
.slot-melds[data-cards] .meld-row .card.small:first-child { margin-left: 0; }
.meld-slot .meld-row:hover { background: rgba(212,175,55,0.2); }
.meld-slot .empty-msg {
  opacity: 0.4; font-size: 0.7em; align-self: center;
  margin: auto;
}

/* Head card — มงกุฏ icon ด้านซ้ายของไพ่ ลอยออกนิดๆ (ทั้งกองทิ้ง + ช่องเกิด + popup) */
.card.head-card-glow {
  position: relative;
  overflow: visible !important;
}
.card.head-card-glow::before {
  content: '👑';
  position: absolute;
  top: 50%; left: -10px;
  transform: translateY(-50%);
  font-size: 1em;
  text-shadow: 0 1px 3px rgba(0,0,0,0.85), 0 0 4px rgba(0,0,0,0.6);
  pointer-events: none;
  z-index: 5;
}
.card.small.head-card-glow::before {
  font-size: 0.85em;
  left: -8px;
}

/* Mobile tweaks */
@media (max-width: 480px) {
  .card { width: 38px; height: 54px; font-size: 0.78em; }
  .card.small { width: 28px; height: 40px; font-size: 0.65em; }
  .head-card, .draw-pile, .card-back { width: 44px; height: 62px; }
  .table-row { gap: 10px; }
  .seat { width: 26%; max-width: 110px; padding: 4px 2px; }
  /* ★ Meld slot (มือถือ) — auto-shrink ตามจำนวนไพ่รวม (data-cards) */
  .meld-slot .meld-row .card.small {
    width: 32px; height: 46px; font-size: 0.72em;
    margin-left: -8px;
  }
  .slot-melds[data-cards="xl"] .meld-row .card.small {
    width: 34px; height: 48px; font-size: 0.74em; margin-left: -7px;
  }
  .slot-melds[data-cards="lg"] .meld-row .card.small {
    width: 30px; height: 42px; font-size: 0.66em; margin-left: -8px;
  }
  .slot-melds[data-cards="md"] .meld-row .card.small {
    width: 26px; height: 38px; font-size: 0.6em; margin-left: -8px;
  }
  .slot-melds[data-cards="sm"] .meld-row .card.small {
    width: 22px; height: 32px; font-size: 0.52em; margin-left: -7px;
  }
  .slot-melds[data-cards="xs"] .meld-row .card.small {
    width: 19px; height: 26px; font-size: 0.42em; margin-left: -10px;
  }
  .slot-melds[data-cards="xxs"] .meld-row .card.small {
    width: 16px; height: 22px; font-size: 0.36em; margin-left: -9px;
  }
  .slot-melds[data-cards="xxxs"] .meld-row .card.small {
    width: 13px; height: 18px; font-size: 0.32em; margin-left: -8px;
  }
  .seat .avatar-circle { width: 30px; height: 30px; font-size: 1.1em; }
  .seat .seat-name { font-size: 0.78em; }
  .seat .seat-points { font-size: 0.72em; }
  .seat .opp-cards .mini-back { width: 8px; height: 12px; }
  /* ไพ่ในมือ user — ใหญ่กว่าไพ่อื่นเพื่อให้กดง่าย */
  .my-area .my-hand .card { width: 64px; height: 92px; font-size: 1.05em; margin-left: -34px; }
  .my-area .my-hand { min-height: 100px; }
  .actions button { font-size: 0.72em; padding: 6px 8px; }
}
@media (max-height: 700px) {
  .my-area .my-hand { min-height: 50px; }
  .seat { padding: 3px; }
}

/* ============================================================
   Pok Deng styles
============================================================ */
/* ★ กัน top-bar ทับเนื้อหา (ทุกขนาดมือถือ) + เลื่อนได้ถ้าเนื้อหายาว */
#screen-pokdeng.active {
  padding-top: calc(72px + env(safe-area-inset-top, 0px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  height: 100vh; height: 100dvh;
}
#screen-pokdeng .pd-board {
  display: flex; flex-direction: column; gap: 12px;
  padding: 8px 12px 16px; max-width: 920px; margin: 0 auto;
}
#screen-pokdeng .game-top {
  position: relative;
  z-index: 10;
}
/* ★ ปุ่มออกห้อง — เล็กๆ มุมขวาบนของ .game-top */
.pd-leave-btn {
  position: absolute;
  top: 4px; right: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 13px;
  border: 1px solid rgba(255,107,107,0.55);
  background: rgba(50,15,15,0.9);
  color: #ff8a8a;
  font-size: 0.78em;
  font-weight: 700;
  cursor: pointer;
  z-index: 20;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  transition: all 0.15s;
}
.pd-leave-btn:hover {
  background: rgba(180,40,40,0.9);
  color: #fff;
  transform: scale(1.06);
}

/* ★ Pok Deng — Round Summary Fullscreen Overlay */
.pd-summary-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(15,40,28,0.92) 0%, rgba(0,0,0,0.96) 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  animation: pds-fade-in 0.28s ease-out;
}
.pd-summary-overlay.closing {
  animation: pds-fade-out 0.28s ease-in forwards;
}
@keyframes pds-fade-in {
  from { opacity: 0; backdrop-filter: blur(0); }
  to { opacity: 1; backdrop-filter: blur(8px); }
}
@keyframes pds-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}
.pd-summary-box {
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  overflow-y: auto;
  background: linear-gradient(165deg, #1a2230 0%, #0f1620 100%);
  border: 2px solid var(--gold);
  border-radius: 16px;
  box-shadow:
    0 20px 60px rgba(0,0,0,0.7),
    0 0 0 1px rgba(212,175,55,0.2) inset,
    0 0 80px rgba(212,175,55,0.15);
  animation: pds-slide-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pds-slide-in {
  from { transform: translateY(20px) scale(0.92); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.pd-summary-box.win {
  border-color: #4eff7a;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7), 0 0 80px rgba(78,255,122,0.25);
}
.pd-summary-box.lose {
  border-color: #ff6b6b;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7), 0 0 80px rgba(255,107,107,0.25);
}
.pds-header {
  text-align: center;
  padding: 18px 16px 12px;
  border-bottom: 1px solid rgba(212,175,55,0.25);
}
.pds-title {
  font-family: 'Cinzel', serif;
  font-size: 1.4em;
  color: var(--gold-bright);
  letter-spacing: 2px;
  margin-bottom: 6px;
}
.pds-myresult {
  font-size: 1.5em;
  font-weight: 800;
}
.pds-myresult strong { font-size: 1.1em; }
.pds-table-wrap {
  padding: 6px 12px;
}
.pds-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88em;
}
.pds-table th {
  padding: 8px 6px;
  color: #888;
  font-weight: 600;
  text-align: left;
  border-bottom: 1px solid rgba(212,175,55,0.15);
  font-size: 0.85em;
}
.pds-table td {
  padding: 8px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.pds-table tr.pds-me { background: rgba(212,175,55,0.10); }
.pds-table tr.pds-dealer { background: rgba(212,175,55,0.05); }
.pds-table tr.pds-dealer.pds-me { background: rgba(212,175,55,0.15); }
.pds-name strong { color: #ddd; }
.pds-you { color: var(--gold-bright); font-size: 0.85em; }
.pds-hand { font-size: 0.92em; padding: 4px 6px; }
/* ★ Mini cards ใน summary popup — แสดงไพ่จริง ขนาดเล็กพอดีตาราง */
.pds-cards { display: inline-flex; gap: 3px; flex-wrap: wrap; align-items: center; }
.pds-mini-card {
  width: 28px; height: 38px;
  background: linear-gradient(180deg, #ffffff, #f5f5f5);
  color: #1a1a2e;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.15);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-weight: 800;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4), 0 0 0 1px rgba(0,0,0,0.05) inset;
  flex-shrink: 0;
  line-height: 1;
}
.pds-mini-card.red { color: #c41e3a; }
.pds-mc-rank { font-size: 0.95em; line-height: 1; }
.pds-mc-suit { font-size: 0.85em; line-height: 1; }
.pds-card {
  display: inline-block;
  padding: 1px 4px;
  margin: 0 1px;
  background: #fff;
  color: #111;
  border-radius: 3px;
  font-weight: 700;
  font-size: 0.9em;
  min-width: 22px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.pds-card.red { color: #c41e3a; }
.pds-info { color: #ccc; font-size: 0.85em; font-weight: 600; }

/* ★ Highlight ช่อง "ชนิด" ตามมือพิเศษ — เรืองแสงสีต่างกัน */
.pds-info.tier-pok9 {
  color: #ffd700;
  text-shadow: 0 0 8px rgba(255,215,0,0.85), 0 0 16px rgba(255,215,0,0.5);
  font-weight: 800;
  letter-spacing: 0.3px;
  animation: pdsTierPulse 1.5s ease-in-out infinite;
}
.pds-info.tier-pok8 {
  color: #ffa726;
  text-shadow: 0 0 8px rgba(255,167,38,0.8), 0 0 16px rgba(255,167,38,0.45);
  font-weight: 800;
  letter-spacing: 0.3px;
  animation: pdsTierPulse 1.5s ease-in-out infinite;
}
.pds-info.tier-tong {
  background: linear-gradient(110deg, #c084fc, #f0abfc, #c084fc);
  background-size: 220% auto;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  filter: drop-shadow(0 0 6px rgba(192,132,252,0.7));
  font-weight: 800;
  animation: pdsTierShine 2.4s linear infinite;
}
.pds-info.tier-strflush {
  background: linear-gradient(110deg, #00f5ff, #c084fc, #ffd700, #ff6b6b, #00f5ff);
  background-size: 280% auto;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  filter: drop-shadow(0 0 8px rgba(255,215,0,0.6)) drop-shadow(0 0 12px rgba(0,245,255,0.5));
  font-weight: 900;
  letter-spacing: 0.5px;
  animation: pdsTierShine 2.4s linear infinite;
}
.pds-info.tier-sian {
  color: #93c5fd;
  text-shadow: 0 0 8px rgba(147,197,253,0.7), 0 0 14px rgba(147,197,253,0.4);
  font-weight: 700;
}
.pds-info.tier-straight {
  color: #6ee7b7;
  text-shadow: 0 0 8px rgba(110,231,183,0.7), 0 0 14px rgba(110,231,183,0.4);
  font-weight: 700;
}
.pds-info.tier-bounce {
  color: #67e8f9;
  text-shadow: 0 0 6px rgba(103,232,249,0.55);
  font-weight: 700;
}
@keyframes pdsTierPulse {
  0%, 100% { filter: brightness(1); }
  50%      { filter: brightness(1.25); }
}
@keyframes pdsTierShine {
  0%   { background-position: 0% 50%; }
  100% { background-position: 280% 50%; }
}
.pds-delta {
  text-align: right;
  font-weight: 800;
  font-size: 1em;
  white-space: nowrap;
}
.pds-footer {
  padding: 14px 16px 18px;
  text-align: center;
  border-top: 1px solid rgba(212,175,55,0.2);
}
.pds-countdown-label {
  color: #aaa;
  font-size: 0.9em;
  margin-bottom: 4px;
}
.pds-countdown-num {
  font-size: 3em;
  font-weight: 800;
  font-family: 'Cinzel', serif;
  color: var(--gold-bright);
  text-shadow: 0 0 20px rgba(212,175,55,0.5);
  line-height: 1;
  margin: 4px 0;
}
.pds-countdown-num.pulse {
  animation: pds-num-pulse 0.5s ease-out;
}
@keyframes pds-num-pulse {
  0% { transform: scale(1.3); color: #fff; text-shadow: 0 0 30px var(--gold-bright); }
  100% { transform: scale(1); color: var(--gold-bright); text-shadow: 0 0 20px rgba(212,175,55,0.5); }
}
/* ★ Banner เจ้ามือกินรอบวง / เสียรอบวง */
.pds-roundwide {
  margin: 10px 14px 6px;
  padding: 10px 14px;
  border-radius: 10px;
  text-align: center;
  font-weight: 800;
  font-size: 1.05em;
  letter-spacing: 0.5px;
  animation: pds-rw-in 0.45s ease-out;
}
.pds-roundwide-win {
  background: linear-gradient(180deg, rgba(78,255,122,0.22), rgba(20,120,40,0.18));
  border: 1.5px solid rgba(78,255,122,0.55);
  color: #b6ffd0;
  text-shadow: 0 0 10px rgba(78,255,122,0.5);
}
.pds-roundwide-lose {
  background: linear-gradient(180deg, rgba(255,107,107,0.22), rgba(140,30,30,0.2));
  border: 1.5px solid rgba(255,107,107,0.55);
  color: #ffd0d0;
  text-shadow: 0 0 10px rgba(255,107,107,0.5);
}
@keyframes pds-rw-in {
  0%   { transform: scale(0.85); opacity: 0; }
  60%  { transform: scale(1.04); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.pds-progress {
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 10px;
}
.pds-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #4eff7a, var(--gold-bright));
  width: 0%;
  transition: width 0.1s linear;
  box-shadow: 0 0 8px rgba(212,175,55,0.5);
}

/* ★ Pok Deng styled confirm modal */
.pd-confirm-box {
  max-width: 380px !important;
  text-align: center;
  animation: pdConfirmIn 0.2s ease-out;
}
@keyframes pdConfirmIn {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.pd-confirm-box h3 {
  text-align: center;
  font-size: 1.3em;
  margin-bottom: 14px;
}
.pd-confirm-msg {
  margin: 12px 0 18px;
  font-size: 0.95em;
}
.pd-confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 6px;
}
.pd-confirm-actions button {
  flex: 1;
  max-width: 160px;
  padding: 10px 16px !important;
  font-size: 0.95em;
  font-weight: 700;
  border-radius: 10px;
  margin: 0 !important;
}
.pd-confirm-actions .btn-danger {
  background: linear-gradient(180deg, #c83333, #802020);
  color: #fff;
  border: 1px solid #ff5555;
  cursor: pointer;
  transition: all 0.15s;
}
.pd-confirm-actions .btn-danger:hover {
  background: linear-gradient(180deg, #e04040, #a02828);
  transform: translateY(-1px);
}
/* ★ ปุ่มใน pd-confirm ไม่เป็น fixed bottom (override modal-box rule) */
.modal.active > .pd-confirm-box > .pd-confirm-actions > button:last-child {
  position: static !important;
  bottom: auto !important;
  left: auto !important;
  transform: none !important;
  width: auto !important;
  max-width: 160px !important;
}

/* ===== Round Table (วงกลม — พอดีจอมือถือ + เก้าอี้นอกโต๊ะ) ===== */
.pd-table-wrap {
  display: flex; justify-content: center;
  padding: 50px 8px;            /* ★ เผื่อพื้นที่เก้าอี้ที่ยื่นออกนอกโต๊ะ */
}
.pd-table {
  position: relative;
  width: min(360px, 80vw);            /* ★ ลดขนาดโต๊ะ เผื่อพื้นที่เก้าอี้ */
  aspect-ratio: 1 / 1;                /* ★ วงกลม */
  border-radius: 50%;
  background: radial-gradient(ellipse at center, #1c5d3a 0%, #0f3a23 65%, #082014 100%);
  border: 6px solid #5a3a1f;
  box-shadow: 0 18px 50px rgba(0,0,0,0.55), inset 0 0 60px rgba(0,0,0,0.45);
  /* ให้เก้าอี้ที่ยื่นออกนอกโต๊ะ visible ไม่ถูก clip */
  overflow: visible;
}
.pd-seats {
  overflow: visible !important;
}
/* กลางโต๊ะ — กล่องข้อมูลรอบ (เรท / phase) — เล็กลงเพราะเจ้ามืออยู่เก้าอี้ 0 แล้ว */
.pd-table-center {
  position: absolute;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 30%; min-height: 22%;
  background: rgba(0,0,0,0.45);
  border: 1px dashed rgba(255,215,0,0.35);
  border-radius: 12px; padding: 10px; text-align: center;
  pointer-events: none;
}
.pd-dealer-cards { min-height: 70px; }
.pd-seats {
  position: absolute; inset: 0; pointer-events: none;
}
.pd-seat {
  position: absolute;
  width: 110px; max-width: 22vw;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  text-align: center;
  background: rgba(20,30,40,0.8);
  border: 2px solid rgba(180,200,255,0.25);
  border-radius: 12px;
  padding: 6px 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  transition: transform 0.15s, border-color 0.15s;
}
.pd-seat.empty {
  background: rgba(40,40,40,0.35);
  border-style: dashed;
  border-color: rgba(255,255,255,0.18);
  color: #aaa;
  cursor: default;
}
.pd-seat.empty.swappable {
  cursor: pointer;
  pointer-events: auto;            /* override .pd-seats pointer-events:none */
  border-color: rgba(212,175,55,0.45);
  color: #d4af37;
  animation: pdSeatPulse 1.6s ease-in-out infinite;
}
.pd-seat.empty.swappable:hover {
  transform: translate(-50%, -50%) scale(1.05);
  border-color: #d4af37;
  background: rgba(60,50,20,0.55);
}
.pd-seat.empty.locked {
  border-color: rgba(255,107,107,0.5);
  color: #ff8a8a;
  cursor: not-allowed;
  pointer-events: auto;
  opacity: 0.65;
}
@keyframes pdSeatPulse {
  0%, 100% { box-shadow: 0 4px 12px rgba(0,0,0,0.5), 0 0 0 0 rgba(212,175,55,0); }
  50% { box-shadow: 0 4px 12px rgba(0,0,0,0.5), 0 0 0 6px rgba(212,175,55,0.25); }
}
.pd-seat.me { border-color: #ffd54a; box-shadow: 0 0 0 2px rgba(255,213,74,0.4), 0 4px 12px rgba(0,0,0,0.5); }
.pd-seat.dealer-seat {
  border-color: #ff8c50;
  background: linear-gradient(135deg, rgba(180,40,60,0.7), rgba(40,20,80,0.75));
  box-shadow: 0 0 0 2px rgba(255,140,80,0.5), 0 6px 18px rgba(0,0,0,0.6);
  width: 130px; max-width: 26vw;
}
.pd-seat.dealer-seat .pd-seat-name::before { content: '🎩 '; }
.pd-seat.busted { opacity: 0.45; }
.pd-seat .pd-seat-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5em; margin: 2px auto 4px;
  background: rgba(0,0,0,0.4);
}
.pd-seat .pd-seat-name {
  font-size: 0.78em; color: #ffd; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
}
.pd-seat .pd-seat-credit {
  font-size: 0.68em; color: #ffd700; margin-top: 1px; font-weight: 700;
  background: rgba(0,0,0,0.32);
  border: 1px solid rgba(212,175,55,0.35);
  border-radius: 8px;
  padding: 1px 6px;
  display: inline-block;
  letter-spacing: 0.3px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.pd-seat .pd-seat-status { font-size: 0.7em; color: #fc8; margin-top: 2px; }
.pd-seat .pd-seat-bet { font-size: 0.68em; color: #d4af37; margin-top: 1px; font-weight: 700; }
.pd-seat .pd-seat-bet.win { color: #4eff7a; text-shadow: 0 0 6px rgba(78,255,122,0.6); }
.pd-seat .pd-seat-bet.lose { color: #ff6b6b; text-shadow: 0 0 6px rgba(255,107,107,0.6); }
.pd-seat .pd-cards {
  min-height: 32px; gap: 3px; padding: 2px;
  display: flex; justify-content: center; align-items: center;
  flex-wrap: wrap;
}
.pd-seat .pd-card { width: 24px; height: 32px; font-size: 0.65em; padding: 0; }
.pd-seat .pd-card .pd-rank { font-size: 0.85em; }
.pd-seat .pd-card .pd-suit { font-size: 0.65em; }
.pd-seat .pd-result-tag {
  display: inline-block; padding: 2px 6px; border-radius: 8px;
  font-size: 0.68em; margin-top: 3px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.pd-seat .pd-result-tag.win {
  background: linear-gradient(135deg, #1d6f3a, #2a9d4f);
  color: #fff;
  box-shadow: 0 0 10px rgba(45,200,80,0.5);
  animation: pdResultGlow 1.5s ease-out;
}
.pd-seat .pd-result-tag.lose {
  background: linear-gradient(135deg, #6f1d1d, #9d2a2a);
  color: #ffcaca;
}
@keyframes pdResultGlow {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}
/* ★ ผู้เล่นกำลังคิด — เก้าอี้กระพริบสว่าง */
.pd-seat.thinking {
  animation: pdThinking 1s ease-in-out infinite;
  border-color: #ffd54a !important;
}
@keyframes pdThinking {
  0%, 100% { box-shadow: 0 4px 12px rgba(0,0,0,0.5), 0 0 0 0 rgba(255,213,74,0); }
  50% { box-shadow: 0 4px 12px rgba(0,0,0,0.5), 0 0 0 6px rgba(255,213,74,0.5); }
}
/* ★ ป๊อก! — เก้าอี้สว่างทอง */
.pd-seat.pok {
  border-color: #ffd700 !important;
  background: linear-gradient(135deg, rgba(180,140,30,0.6), rgba(80,60,10,0.85));
  box-shadow: 0 0 0 2px rgba(255,215,0,0.7), 0 6px 18px rgba(255,215,0,0.4);
}
.pd-seat.pok .pd-seat-status {
  color: #ffd700;
  font-weight: 700;
}
/* ★ เปิดไพ่ animation */
.pd-card.revealing {
  animation: pdCardFlip 0.5s ease-out;
}
@keyframes pdCardFlip {
  0% { transform: rotateY(180deg) scale(0.9); }
  50% { transform: rotateY(90deg) scale(1.05); }
  100% { transform: rotateY(0deg) scale(1); }
}

/* ★ แจกไพ่ animation — ลอยจากกลางโต๊ะ (ตามแกน --deal-from-x/y) มาที่ตำแหน่งเก้าอี้
   ใช้ stagger delay ผ่าน --deal-order (จำนวน step = 0,1,2,…)
   duration 0.6s + stagger 0.28s ต่อใบ (ช้าขึ้นเพื่อความสมจริง) */
.pd-card.dealing {
  --deal-from-x: 0px;
  --deal-from-y: 0px;
  --deal-order: 0;
  animation: pdCardDeal 0.6s cubic-bezier(.2,.8,.3,1) backwards;
  animation-delay: calc(var(--deal-order) * 0.28s);
  z-index: 5;
}
@keyframes pdCardDeal {
  0% {
    transform: translate(var(--deal-from-x), var(--deal-from-y)) rotate(180deg) scale(0.55);
    opacity: 0;
    box-shadow: 0 0 12px rgba(255,215,0,0.8);
  }
  55% {
    opacity: 1;
    box-shadow: 0 0 10px rgba(255,215,0,0.5);
  }
  100% {
    transform: translate(0, 0) rotate(0deg) scale(1);
    opacity: 1;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
  }
}

@media (max-width: 600px) {
  .pd-seat { width: 72px; padding: 3px 2px; max-width: 20vw; }
  .pd-seat .pd-seat-avatar { width: 26px; height: 26px; font-size: 1em; }
  .pd-seat .pd-seat-name { font-size: 0.65em; }
  .pd-seat .pd-seat-credit { font-size: 0.58em; padding: 0 4px; }
  .pd-seat .pd-seat-status { font-size: 0.6em; }
  .pd-seat .pd-seat-bet { font-size: 0.6em; }
  .pd-seat .pd-card { width: 18px; height: 24px; font-size: 0.55em; }
  .pd-seat.dealer-seat { width: 88px; max-width: 24vw; }
}

.pd-dealer-area {
  background: linear-gradient(135deg, rgba(180,40,60,0.22), rgba(40,20,80,0.4));
  border: 2px solid rgba(255,180,80,0.4);
  border-radius: 14px; padding: 16px; text-align: center;
}
.pd-label { font-size: 0.95em; color: #ffd; opacity: 0.9; margin-bottom: 6px; font-weight: 700; }
.pd-dealer-info { font-size: 1.05em; color: #fff; margin: 4px 0; min-height: 1.2em; }

/* ★ pd-me-info — chip เล็กๆใต้ไพ่ (แสดงเฉพาะตอนมีข้อความ "Xแต้ม Yเด้ง") */
.pd-me-info {
  display: inline-block;
  font-size: 0.85em;
  font-weight: 700;
  color: #ffd54a;
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(212,175,55,0.45);
  border-radius: 999px;
  padding: 3px 12px;
  margin-top: 4px;
  letter-spacing: 0.3px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  line-height: 1.3;
}
.pd-me-info:empty { display: none; }      /* ไม่มี info → ซ่อนทั้งกล่อง ไม่กินที่ */
@media (max-width: 480px) {
  .pd-me-info { font-size: 0.78em; padding: 2px 10px; }
}
.pd-cards {
  display: flex; gap: 6px; justify-content: center; flex-wrap: wrap;
  min-height: 72px; padding: 4px;
}
/* ★ ขนาดไพ่: เล็กลงสำหรับมือถือ */
.pd-card {
  width: 48px; height: 68px; border-radius: 6px;
  background: linear-gradient(180deg, #ffffff, #f0f0f0);
  color: #111; display: flex; align-items: center; justify-content: center;
  font-size: 1em; font-weight: 700;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4), 0 0 0 1px rgba(0,0,0,0.1) inset;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
}
.pd-card.red { color: #c41e3a; }
/* ★ Card back ใหม่ — น้ำเงินเข้มมีลายเฮชบล็อก ไม่มีตัวอักษร 🂠 */
.pd-card.back {
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.04) 0 4px, transparent 4px 8px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,0.04) 0 4px, transparent 4px 8px),
    radial-gradient(ellipse at center, #2a3f7a 0%, #142255 70%, #0a1538 100%);
  border: 1.5px solid rgba(255,255,255,0.15);
  box-shadow:
    0 2px 6px rgba(0,0,0,0.5),
    0 0 0 2px rgba(212,175,55,0.18) inset,
    0 0 0 4px rgba(20,30,80,0.6) inset;
  color: transparent;
  font-size: 0;
  position: relative;
}
/* ลายตรงกลางเป็น diamond ทอง */
.pd-card.back::before {
  content: '';
  position: absolute;
  inset: 18% 22%;
  background:
    linear-gradient(135deg, transparent 35%, rgba(212,175,55,0.4) 50%, transparent 65%),
    linear-gradient(45deg, transparent 35%, rgba(212,175,55,0.4) 50%, transparent 65%);
  border-radius: 4px;
}
.pd-card.back::after {
  content: '♦';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(212,175,55,0.55);
  font-size: 1.2em;
  text-shadow: 0 0 8px rgba(212,175,55,0.4);
}
.pd-card .pd-rank { font-size: 1.15em; line-height: 1; font-weight: 800; }
.pd-card .pd-suit { font-size: 0.95em; line-height: 1; }
.pd-players {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px;
}
.pd-player {
  background: rgba(20,30,60,0.55); border: 1px solid rgba(180,200,255,0.2);
  border-radius: 12px; padding: 10px; text-align: center;
}
.pd-player.me { border-color: #ffd54a; box-shadow: 0 0 0 2px rgba(255,213,74,0.3); }
.pd-player.dealer-player { border-color: rgba(255,140,80,0.7); }
.pd-player.fold { opacity: 0.4; }
.pd-player .pd-name { font-weight: 700; color: #ffd; margin-bottom: 4px; }
.pd-player .pd-status { font-size: 0.85em; color: #fc8; margin: 2px 0; }
.pd-player .pd-cards { min-height: 60px; }
.pd-player .pd-card { width: 42px; height: 60px; font-size: 0.9em; }
.pd-player .pd-card .pd-rank { font-size: 1.1em; }
.pd-player .pd-card .pd-suit { font-size: 0.9em; }
/* ★ pd-me — Layout: ปุ่มฝั่งซ้าย + ไพ่ฝั่งขวา (flex row) */
.pd-me {
  position: relative;
  background: rgba(60,40,100,0.4); border: 2px solid #ffd54a;
  border-radius: 14px; padding: 10px 12px;
  display: flex; flex-direction: row; align-items: center; gap: 10px;
}

/* ★ Side actions — ปุ่ม Hit/Stand/Dealer/ReleaseDealer ฝั่งซ้าย (vertical stack) */
.pd-side-actions {
  flex-shrink: 0;
  display: flex; flex-direction: column; gap: 6px; align-items: stretch;
}
.pd-side-actions .pd-actions {
  display: flex; flex-direction: column; gap: 6px;
  margin: 0;
}
.pd-side-actions button {
  min-width: 80px;
  padding: 7px 10px;
  font-size: 0.88em;
  font-weight: 700;
  border-radius: 8px;
  border: 1.5px solid rgba(212,175,55,0.7);
  background: linear-gradient(180deg, #2d3672, #1d2148);
  color: var(--text);
  box-shadow: 0 3px 8px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.1);
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}
.pd-side-actions button.btn-primary {
  background: linear-gradient(180deg, var(--gold-bright), #b8860b);
  color: #1a1a2e;
  border-color: var(--gold-bright);
  box-shadow: 0 3px 10px rgba(212,175,55,0.5), inset 0 1px 0 rgba(255,255,255,0.3);
}
.pd-side-actions button:hover { filter: brightness(1.1); transform: scale(1.04); }
.pd-side-actions button:active { transform: scale(0.97); filter: brightness(1.15); }

/* ★ ปุ่มออกจากเจ้ามือ — อยู่ใน side-actions stack ใต้ปุ่มอื่น */
.pd-actions-release {
  display: flex; flex-direction: column; gap: 6px; margin: 0;
}
.pd-actions-release:empty { display: none; }
.pd-actions-release button {
  min-width: 80px;
  padding: 6px 10px;
  font-size: 0.8em;
  font-weight: 700;
  border-radius: 8px;
  border: 1px solid rgba(255,140,80,0.55);
  background: linear-gradient(180deg, rgba(120,60,30,0.85), rgba(80,30,15,0.85));
  color: #ffd0b0;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.pd-actions-release button:hover { filter: brightness(1.12); border-color: rgba(255,140,80,0.85); }

/* ★ ฝั่งขวา: info + ไพ่ของฉัน */
.pd-me-content {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 0;
}

/* ★ ไพ่ในมือเรา — ขนาดใหญ่ให้พอดีกับช่องฝั่งขวา (responsive ลดบนมือถือเล็ก) */
.pd-me-cards { gap: 8px; min-height: 100px; }
.pd-me-cards .pd-card { width: 72px; height: 100px; font-size: 1.3em; }
.pd-me-cards .pd-card .pd-rank { font-size: 1.7em; }
.pd-me-cards .pd-card .pd-suit { font-size: 1.3em; }

@media (max-width: 480px) {
  .pd-me { padding: 8px 10px; gap: 8px; }
  .pd-side-actions button { min-width: 72px; padding: 6px 8px; font-size: 0.82em; }
  .pd-actions-release button { min-width: 72px; padding: 5px 8px; font-size: 0.74em; }
  .pd-me-cards { gap: 6px; min-height: 86px; }
  .pd-me-cards .pd-card { width: 60px; height: 86px; font-size: 1.1em; }
  .pd-me-cards .pd-card .pd-rank { font-size: 1.45em; }
  .pd-me-cards .pd-card .pd-suit { font-size: 1.1em; }
}
@media (max-width: 360px) {
  .pd-side-actions button { min-width: 64px; padding: 5px 6px; font-size: 0.76em; }
  .pd-me-cards { gap: 5px; min-height: 76px; }
  .pd-me-cards .pd-card { width: 54px; height: 76px; font-size: 1em; }
  .pd-me-cards .pd-card .pd-rank { font-size: 1.3em; }
  .pd-me-cards .pd-card .pd-suit { font-size: 1em; }
}
.pd-result-tag {
  display: inline-block; padding: 2px 10px; border-radius: 12px;
  background: rgba(255,213,74,0.25); color: #ffd54a; font-weight: 700; font-size: 0.85em;
}
.pd-result-tag.win { background: rgba(80,220,120,0.3); color: #80f0a0; }
.pd-result-tag.lose { background: rgba(220,80,80,0.3); color: #ff9090; }

/* ★ Pok effect — Modern neon (cyan + magenta gradient pulse) */
.pd-seat.pd-seat-pok {
  animation: pdSeatPokPulse 1.4s ease-in-out infinite;
  border-color: #00f5ff !important;
  z-index: 8;
}
.pd-seat.pd-seat-pok .pd-card {
  box-shadow: 0 0 14px rgba(0,245,255,0.7), 0 0 28px rgba(192,132,252,0.55);
}
@keyframes pdSeatPokPulse {
  0%, 100% {
    box-shadow:
      0 0 0 2px rgba(0,245,255,0.5),
      0 0 22px rgba(0,245,255,0.4),
      0 6px 18px rgba(0,0,0,0.6);
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    box-shadow:
      0 0 0 4px rgba(192,132,252,0.85),
      0 0 36px rgba(0,245,255,0.7),
      0 0 60px rgba(192,132,252,0.5);
    transform: translate(-50%, -50%) scale(1.06);
  }
}

/* ★ Pok announcement overlay — modern holographic gradient text */
.pd-pok-announce {
  position: fixed;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  z-index: 9999;
  pointer-events: none;
  text-align: center;
  font-family: 'Sarabun', 'Cinzel', sans-serif;
  animation: pdPokAnnounce 5s cubic-bezier(.18,.89,.32,1.28) forwards;
}
/* halo ring behind text */
.pd-pok-announce::before {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 130%; height: 130%;
  background: radial-gradient(ellipse at center,
    rgba(192,132,252,0.35) 0%,
    rgba(0,245,255,0.18) 35%,
    transparent 70%);
  filter: blur(20px);
  z-index: -1;
  pointer-events: none;
  animation: pdPokHalo 2.8s ease-in-out infinite alternate;
}
@keyframes pdPokHalo {
  0%   { opacity: 0.7; transform: translate(-50%, -50%) scale(0.95); }
  100% { opacity: 1.0; transform: translate(-50%, -50%) scale(1.1); }
}
.pd-pok-announce .pd-pok-big {
  font-size: 5.2em;
  font-weight: 900;
  letter-spacing: 2px;
  line-height: 1;
  background: linear-gradient(110deg,
    #00f5ff 0%,
    #93c5fd 18%,
    #c084fc 38%,
    #f0abfc 58%,
    #c084fc 78%,
    #00f5ff 100%);
  background-size: 220% auto;
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
          color: transparent;
  filter:
    drop-shadow(0 0 12px rgba(0,245,255,0.7))
    drop-shadow(0 0 24px rgba(192,132,252,0.55))
    drop-shadow(0 4px 18px rgba(0,0,0,0.55));
  animation: pdPokGradient 3.2s linear infinite;
}
@keyframes pdPokGradient {
  0%   { background-position: 0% 50%; }
  100% { background-position: 220% 50%; }
}
.pd-pok-announce .pd-pok-name {
  display: block;
  font-size: 1.15em;
  margin-top: 14px;
  color: #f0e9ff;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-shadow:
    0 0 10px rgba(192,132,252,0.6),
    0 0 20px rgba(0,245,255,0.35),
    0 2px 4px rgba(0,0,0,0.6);
}
@keyframes pdPokAnnounce {
  0%   { transform: translate(-50%, -50%) scale(0.4); opacity: 0; filter: blur(6px); }
  10%  { transform: translate(-50%, -50%) scale(1.1); opacity: 1; filter: blur(0); }
  16%  { transform: translate(-50%, -50%) scale(1); opacity: 1; filter: blur(0); }
  92%  { transform: translate(-50%, -50%) scale(1); opacity: 1; filter: blur(0); }    /* ★ ชัดยาวจนเกือบจบ */
  100% { transform: translate(-50%, -50%) scale(0.95); opacity: 0; filter: blur(8px); }   /* ★ มัวเฉพาะช่วงท้าย */
}
@media (max-width: 480px) {
  .pd-pok-announce .pd-pok-big { font-size: 3.4em; letter-spacing: 1px; }
  .pd-pok-announce .pd-pok-name { font-size: 1em; }
}

/* ★ Multi-pok announcement — glassmorphism + neon accents */
.pd-pok-announce.pd-pok-multi {
  background: linear-gradient(135deg, rgba(15,12,28,0.85) 0%, rgba(30,20,50,0.9) 100%);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid rgba(192,132,252,0.45);
  border-radius: 18px;
  padding: 20px 24px 22px;
  box-shadow:
    0 0 0 1px rgba(0,245,255,0.18),
    0 0 50px rgba(192,132,252,0.45),
    0 16px 48px rgba(0,0,0,0.7),
    inset 0 1px 0 rgba(255,255,255,0.12);
  min-width: 290px;
  max-width: min(92vw, 500px);
  overflow: hidden;
}
/* Animated gradient border line at top */
.pd-pok-announce.pd-pok-multi::after {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 2px;
  background: linear-gradient(90deg,
    transparent 0%,
    #00f5ff 25%,
    #c084fc 50%,
    #f0abfc 75%,
    transparent 100%);
  background-size: 200% auto;
  animation: pdPokMultiBorder 3s linear infinite;
}
@keyframes pdPokMultiBorder {
  0%   { background-position: 0% 0; }
  100% { background-position: 200% 0; }
}
.pd-pok-multi .pd-pok-multi-title {
  font-family: 'Sarabun', sans-serif;
  font-size: 2.2em;
  font-weight: 900;
  letter-spacing: 1px;
  margin-bottom: 16px;
  background: linear-gradient(110deg, #00f5ff 0%, #c084fc 50%, #f0abfc 100%);
  background-size: 220% auto;
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
          color: transparent;
  filter: drop-shadow(0 0 10px rgba(192,132,252,0.5));
  animation: pdPokGradient 3.2s linear infinite;
}
.pd-pok-multi .pd-pok-multi-list {
  display: flex; flex-direction: column; gap: 8px;
  font-family: 'Sarabun', sans-serif;
}
.pd-pok-multi .pd-pok-li {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  background: linear-gradient(110deg, rgba(0,245,255,0.08), rgba(192,132,252,0.12));
  border: 1px solid rgba(192,132,252,0.3);
  font-size: 1em;
  font-weight: 600;
  animation: pdPokLiPop 0.5s cubic-bezier(.2,.9,.3,1.2) backwards;
  position: relative;
  overflow: hidden;
}
.pd-pok-multi .pd-pok-li::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, #00f5ff, #c084fc);
  border-radius: 12px 0 0 12px;
}
.pd-pok-multi .pd-pok-li:nth-child(1) { animation-delay: 0.05s; }
.pd-pok-multi .pd-pok-li:nth-child(2) { animation-delay: 0.16s; }
.pd-pok-multi .pd-pok-li:nth-child(3) { animation-delay: 0.27s; }
.pd-pok-multi .pd-pok-li:nth-child(4) { animation-delay: 0.38s; }
.pd-pok-multi .pd-pok-li:nth-child(5) { animation-delay: 0.49s; }
.pd-pok-multi .pd-pok-li:nth-child(n+6) { animation-delay: 0.6s; }
.pd-pok-multi .pd-pok-li-who {
  color: #f0e9ff;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.pd-pok-multi .pd-pok-li-score {
  font-weight: 900;
  font-size: 1.05em;
  letter-spacing: 0.5px;
}
.pd-pok-multi .pd-pok-li-score.pok9 {
  background: linear-gradient(110deg, #00f5ff, #c084fc, #f0abfc);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  filter: drop-shadow(0 0 8px rgba(0,245,255,0.7));
}
.pd-pok-multi .pd-pok-li-score.pok8 {
  background: linear-gradient(110deg, #fbbf24, #f0abfc);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  filter: drop-shadow(0 0 8px rgba(251,191,36,0.6));
}
.pd-pok-multi .pd-pok-li-bounce {
  display: inline-block;
  background: linear-gradient(135deg, rgba(236,72,153,0.3), rgba(192,132,252,0.3));
  color: #fdf4ff;
  border: 1px solid rgba(236,72,153,0.5);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.75em;
  font-weight: 700;
  margin-left: 6px;
  vertical-align: middle;
  -webkit-text-fill-color: #fdf4ff;
}
@keyframes pdPokLiPop {
  0%   { transform: translateX(-20px) scale(0.95); opacity: 0; }
  60%  { transform: translateX(2px) scale(1.02); opacity: 1; }
  100% { transform: translateX(0) scale(1); opacity: 1; }
}
@media (max-width: 480px) {
  .pd-pok-announce.pd-pok-multi { padding: 16px 18px; min-width: 250px; border-radius: 14px; }
  .pd-pok-multi .pd-pok-multi-title { font-size: 1.7em; margin-bottom: 12px; }
  .pd-pok-multi .pd-pok-li { padding: 8px 12px; font-size: 0.92em; }
  .pd-pok-multi .pd-pok-li-score { font-size: 0.96em; }
}

/* ============================================================
   ★★★ LUXE casino redesign — Mode pick / Rate pick / Room list
   ทันสมัย + หรูหราคาสิโน — ไม่อลังกาลเกิน
   ============================================================ */

/* ── Section heading (ทุกหน้า) — ornate divider ใต้ h2 ── */
#screen-mode-pick .card-box h2,
#screen-rate-pick .card-box h2,
#screen-room-list .card-box h2 {
  text-align: center;
  font-family: 'Cinzel', 'Sarabun', serif;
  letter-spacing: 2px;
  font-size: 1.55em;
  font-weight: 700;
  background: linear-gradient(180deg, #fff5d4 0%, #f0c75e 50%, #b8860b 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
  margin: 4px 0 6px;
}
#screen-mode-pick .card-box h2::after,
#screen-rate-pick .card-box h2::after,
#screen-room-list .card-box h2::after {
  content: '◆ ◆ ◆';
  display: block;
  position: static;
  text-align: center;
  font-size: 0.45em;
  color: var(--gold);
  margin: 8px auto 14px;
  letter-spacing: 14px;
  padding-left: 14px; /* offset for last letter-spacing */
  text-shadow: 0 0 8px rgba(212,175,55,0.4);
  background: none;
  -webkit-text-fill-color: var(--gold);
  width: auto;
  height: auto;
  border: none;
  transform: none;
  bottom: auto;
  left: auto;
}

/* ============================================================
   Mode pick — luxe (2 cards เร็ว/ปกติ)
   ============================================================ */
#screen-mode-pick .game-pick-grid {
  gap: 16px;
  max-width: 480px;
  margin: 8px auto 0;
}
#screen-mode-pick .game-big-card {
  padding: 32px 16px 26px;
  border-radius: 18px;
  background:
    radial-gradient(ellipse at top, rgba(212,175,55,0.14), transparent 65%),
    linear-gradient(165deg, #1d2148 0%, #14193d 50%, #0a0e27 100%);
  border: 1px solid rgba(212,175,55,0.3);
  box-shadow:
    0 8px 24px rgba(0,0,0,0.55),
    inset 0 1px 0 rgba(255,255,255,0.06),
    inset 0 -1px 0 rgba(0,0,0,0.5);
}
/* Top gold rim */
#screen-mode-pick .game-big-card::after {
  content: '';
  position: absolute;
  top: 0; left: 14%; right: 14%;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--gold-bright) 50%, transparent 100%);
  opacity: 0.7;
  border-radius: 2px;
}
#screen-mode-pick .game-big-card:hover {
  border-color: var(--gold-bright);
  transform: translateY(-3px);
  box-shadow:
    0 14px 36px rgba(212,175,55,0.28),
    0 0 0 1px var(--gold-bright),
    inset 0 1px 0 rgba(255,255,255,0.1);
}
#screen-mode-pick .game-big-card .big-icon {
  font-size: 3.6em;
  margin-bottom: 12px;
  filter: drop-shadow(0 4px 10px rgba(212,175,55,0.35));
}
#screen-mode-pick .game-big-card .big-name {
  font-size: 1.4em;
  letter-spacing: 2px;
  margin-bottom: 6px;
  color: var(--gold-bright);
}
#screen-mode-pick .game-big-card .big-sub {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(212,175,55,0.25);
  font-size: 0.78em;
  color: var(--text-dim);
  font-style: normal;
  letter-spacing: 0.5px;
}

/* ============================================================
   Rate pick — luxe (tabs + chip cards)
   ============================================================ */
#screen-rate-pick .igp-tabs {
  background: linear-gradient(180deg, rgba(0,0,0,0.5), rgba(0,0,0,0.2));
  padding: 5px;
  border-radius: 14px;
  border: 1px solid rgba(212,175,55,0.18);
  gap: 4px;
  box-shadow: inset 0 1px 4px rgba(0,0,0,0.5);
  margin-bottom: 18px;
}
#screen-rate-pick .igp-tab {
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  padding: 11px 12px;
  letter-spacing: 0.5px;
}
#screen-rate-pick .igp-tab small { opacity: 0.65; }
#screen-rate-pick .igp-tab:hover {
  background: rgba(212,175,55,0.06);
  color: var(--gold-bright);
  border-color: transparent;
}
#screen-rate-pick .igp-tab.active {
  background: linear-gradient(180deg, #d4af37 0%, #b8860b 100%);
  color: #1a1500;
  border-color: var(--gold-bright);
  box-shadow:
    0 4px 14px rgba(212,175,55,0.35),
    inset 0 1px 0 rgba(255,255,255,0.4),
    inset 0 -1px 0 rgba(0,0,0,0.25);
  text-shadow: 0 1px 0 rgba(255,255,255,0.3);
}
#screen-rate-pick .igp-tab.active small { opacity: 0.85; color: #2a1f00; }

/* Rate card luxe — โทนชิปคาสิโน */
#screen-rate-pick .rate-list {
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (min-width: 520px) {
  #screen-rate-pick .rate-list { grid-template-columns: repeat(3, 1fr); }
}
#screen-rate-pick .rate-card {
  padding: 20px 10px 14px;
  border-radius: 14px;
  background:
    radial-gradient(ellipse at top, rgba(212,175,55,0.18), transparent 60%),
    linear-gradient(165deg, rgba(29,33,72,0.95), rgba(13,17,46,0.98));
  border: 1px solid rgba(212,175,55,0.3);
  box-shadow:
    0 4px 14px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.05);
}
/* Chip motif at top — concentric circle ลอย */
#screen-rate-pick .rate-card::before {
  content: '';
  position: absolute;
  top: -1px; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--gold-bright) 50%, transparent 100%);
  opacity: 0.6;
}
#screen-rate-pick .rate-card::after {
  content: '';
  position: absolute;
  top: -10px; right: -10px;
  width: 48px; height: 48px;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(212,175,55,0.25) 0%, rgba(212,175,55,0.08) 40%, transparent 70%);
  pointer-events: none;
  opacity: 0.5;
  transition: opacity 0.3s, transform 0.3s;
}
#screen-rate-pick .rate-card:hover::after {
  opacity: 1;
  transform: scale(1.4);
}
#screen-rate-pick .rate-card:hover {
  transform: translateY(-3px);
  border-color: var(--gold-bright);
  box-shadow:
    0 12px 28px rgba(212,175,55,0.3),
    0 0 0 1px var(--gold-bright);
}
#screen-rate-pick .rate-card .rate-name {
  font-size: 1.1em;
  letter-spacing: 1.5px;
  margin-bottom: 8px;
  background: linear-gradient(180deg, #fff5d4 0%, #f0c75e 70%, #b8860b 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
}
#screen-rate-pick .rate-card .rate-fee {
  background: linear-gradient(180deg, rgba(0,0,0,0.5), rgba(0,0,0,0.3));
  border: 1px solid rgba(212,175,55,0.22);
  padding: 4px 10px;
  font-size: 0.76em;
  color: #d8d4c0;
  letter-spacing: 0.3px;
}
#screen-rate-pick .rate-rooms { margin-top: 10px; }
#screen-rate-pick .rate-rooms span {
  font-weight: 700;
  font-size: 0.74em;
  letter-spacing: 0.3px;
}
#screen-rate-pick .rate-card.active {
  background:
    radial-gradient(ellipse at top, rgba(212,175,55,0.32), transparent 60%),
    linear-gradient(165deg, rgba(29,33,72,0.95), rgba(13,17,46,0.98));
  border-color: var(--gold-bright);
  box-shadow:
    0 0 0 1px var(--gold-bright),
    0 0 26px rgba(212,175,55,0.4),
    inset 0 1px 0 rgba(255,255,255,0.15);
}

/* ============================================================
   Room list — luxe (3 action chips + room rows)
   ============================================================ */
#screen-room-list .card-box {
  padding-bottom: 18px;
}
#screen-room-list .room-actions {
  gap: 10px;
  margin-top: 4px;
}
#screen-room-list .room-actions button {
  padding: 18px 6px 14px;
  border-radius: 14px;
  position: relative;
  font-weight: 800;
  font-size: 0.84em;
  letter-spacing: 0.5px;
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow:
    0 4px 14px rgba(0,0,0,0.45),
    inset 0 1px 0 rgba(255,255,255,0.18),
    inset 0 -2px 0 rgba(0,0,0,0.25);
  transition: transform 0.2s cubic-bezier(0.16,1,0.3,1), box-shadow 0.2s;
}
#screen-room-list .room-actions button::before {
  content: '';
  position: absolute;
  top: 6px; left: 50%; transform: translateX(-50%);
  width: 28px; height: 4px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  pointer-events: none;
}
/* 1) จับคู่ — green felt casino */
#screen-room-list #btnJoinPublic {
  background:
    radial-gradient(ellipse at top, rgba(78,255,122,0.35), transparent 70%),
    linear-gradient(180deg, #2a8252 0%, #14492f 100%);
  color: #fdf4ff;
  text-shadow: 0 1px 0 rgba(0,0,0,0.4);
  border-color: rgba(78,255,122,0.35);
}
#screen-room-list #btnJoinPublic:hover {
  box-shadow:
    0 10px 24px rgba(78,255,122,0.35),
    inset 0 1px 0 rgba(255,255,255,0.25),
    inset 0 -2px 0 rgba(0,0,0,0.3);
  border-color: rgba(78,255,122,0.6);
}
/* 2) สร้าง / เข้ารหัส — sapphire chip */
#screen-room-list #btnCreateOrJoin {
  background:
    radial-gradient(ellipse at top, rgba(123,158,255,0.3), transparent 70%),
    linear-gradient(180deg, #4d6dba 0%, #1f3578 100%) !important;
  color: #f0f4ff !important;
  border-color: rgba(123,158,255,0.4);
  text-shadow: 0 1px 0 rgba(0,0,0,0.4);
}
#screen-room-list #btnCreateOrJoin:hover {
  box-shadow:
    0 10px 24px rgba(123,158,255,0.35),
    inset 0 1px 0 rgba(255,255,255,0.25),
    inset 0 -2px 0 rgba(0,0,0,0.3);
}
/* 3) บอท — purple chip */
#screen-room-list #btnPracticeBots {
  background:
    radial-gradient(ellipse at top, rgba(192,132,252,0.32), transparent 70%),
    linear-gradient(180deg, #6f42c1 0%, #3a1f6e 100%) !important;
  color: #f5edff !important;
  border-color: rgba(192,132,252,0.4);
  text-shadow: 0 1px 0 rgba(0,0,0,0.4);
}
#screen-room-list #btnPracticeBots:hover {
  box-shadow:
    0 10px 24px rgba(192,132,252,0.35),
    inset 0 1px 0 rgba(255,255,255,0.25),
    inset 0 -2px 0 rgba(0,0,0,0.3);
}

/* Room rows — cleaner casino aesthetic */
#screen-room-list .room-list-body {
  background: linear-gradient(180deg, rgba(0,0,0,0.55), rgba(0,0,0,0.32));
  border-radius: 14px;
  border: 1px solid rgba(212,175,55,0.18);
  padding: 10px;
  box-shadow:
    inset 0 0 30px rgba(0,0,0,0.5),
    0 4px 14px rgba(0,0,0,0.3);
}
#screen-room-list .room-row-public {
  padding: 13px 14px;
  border-radius: 12px;
  margin-bottom: 8px;
  background: linear-gradient(90deg, rgba(78,255,122,0.07), rgba(15,18,40,0.9));
  border: 1px solid rgba(78,255,122,0.22);
  border-left: 3px solid #4eff7a;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.04),
    0 2px 6px rgba(0,0,0,0.3);
}
#screen-room-list .room-row-public:hover {
  background: linear-gradient(90deg, rgba(212,175,55,0.18), rgba(15,18,40,0.95));
  border-color: var(--gold-bright);
  border-left-color: var(--gold-bright);
  box-shadow:
    0 6px 18px rgba(212,175,55,0.22),
    inset 0 1px 0 rgba(255,255,255,0.07);
  transform: translateY(-1px);
}
#screen-room-list .room-row-public .rrm-rate {
  font-size: 1.3em;
  letter-spacing: 1.5px;
  background: linear-gradient(180deg, #fff5d4 0%, #f0c75e 70%, #b8860b 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
#screen-room-list .room-row-public.in-game {
  background: linear-gradient(90deg, rgba(200,16,46,0.08), rgba(15,18,40,0.9));
  border-color: rgba(200,16,46,0.25);
  border-left-color: #c8102e;
}
#screen-room-list .room-row-public .rrm-status {
  background: linear-gradient(180deg, #4eff7a 0%, #2a8252 100%);
  border: 1px solid rgba(255,255,255,0.15);
  font-size: 0.74em;
  padding: 3px 10px;
  border-radius: 999px;
  box-shadow:
    0 2px 6px rgba(78,255,122,0.4),
    inset 0 1px 0 rgba(255,255,255,0.25);
}
#screen-room-list .room-row-public.in-game .rrm-status {
  background: linear-gradient(180deg, #ff6b7e 0%, #8a0a1f 100%);
  box-shadow:
    0 2px 6px rgba(200,16,46,0.4),
    inset 0 1px 0 rgba(255,255,255,0.25);
}
#screen-room-list .empty-rooms {
  padding: 50px 20px;
}
#screen-room-list .empty-rooms .empty-icon {
  font-size: 3.4em;
  filter: drop-shadow(0 6px 12px rgba(212,175,55,0.25)) grayscale(0.2);
  opacity: 0.6;
}
#screen-room-list .empty-rooms .empty-title {
  letter-spacing: 1.5px;
  font-size: 1.15em;
  background: linear-gradient(180deg, #fff5d4, #f0c75e, #b8860b);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Mobile tweaks */
@media (max-width: 480px) {
  #screen-room-list .room-actions {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
  }
  #screen-room-list .room-actions button {
    padding: 14px 4px 11px;
    font-size: 0.78em;
  }
  #screen-rate-pick .rate-list {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  #screen-rate-pick .rate-card { padding: 16px 8px 12px; }
  #screen-rate-pick .rate-card .rate-name { font-size: 1em; letter-spacing: 1px; }
  #screen-mode-pick .game-big-card { padding: 26px 12px 20px; }
  #screen-mode-pick .game-big-card .big-icon { font-size: 3em; }
  #screen-mode-pick .game-big-card .big-name { font-size: 1.2em; letter-spacing: 1.5px; }
}

/* ============================================================
   Pok Deng — Polish v2 (เหมือนแอพไทยจริง)
   ★ active-turn glow + bet active + history strip + round-result modal
============================================================ */

/* ★ Active turn glow — เก้าอี้คนที่ยังต้อง action จะเด่นชัดด้วย gold ring + scale */
.pd-seat.active-turn {
  z-index: 5;
  transform: translate(-50%, -50%) scale(1.06) !important;
  box-shadow:
    0 0 0 3px rgba(255,213,74,0.85),
    0 0 24px rgba(255,213,74,0.55),
    0 6px 18px rgba(0,0,0,0.5);
  border-color: #ffd54a !important;
}
.pd-seat.active-turn::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255,213,74,0.4), transparent 50%, rgba(255,213,74,0.4));
  opacity: 0.7;
  animation: pdActiveTurnSweep 1.6s ease-in-out infinite;
  pointer-events: none;
  z-index: -1;
}
@keyframes pdActiveTurnSweep {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.85; }
}

/* ★ History strip — แถวจุดผลรอบล่าสุด (ช/พ/ส) */
.pd-history-strip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: linear-gradient(180deg, rgba(0,0,0,0.55), rgba(0,0,0,0.3));
  border: 1px solid rgba(212,175,55,0.2);
  border-radius: 10px;
  margin-top: 4px;
  font-size: 0.78em;
  overflow-x: auto;
  scrollbar-width: thin;
}
.pd-history-strip .pd-hist-label {
  color: #ddd;
  font-weight: 600;
  flex-shrink: 0;
  margin-right: 6px;
  font-size: 0.92em;
}
.pd-history-strip .pd-hist-dot {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.78em;
  flex-shrink: 0;
  border: 1.5px solid;
  cursor: help;
  font-family: 'Sarabun', sans-serif;
  letter-spacing: 0;
}
.pd-history-strip .pd-hist-dot.win {
  background: linear-gradient(180deg, #4eff7a, #2a8252);
  color: #fff;
  border-color: rgba(78,255,122,0.7);
  box-shadow: 0 0 6px rgba(78,255,122,0.4);
  text-shadow: 0 1px 0 rgba(0,0,0,0.4);
}
.pd-history-strip .pd-hist-dot.lose {
  background: linear-gradient(180deg, #ff6b7e, #8a0a1f);
  color: #fff;
  border-color: rgba(255,107,107,0.7);
  box-shadow: 0 0 6px rgba(255,107,107,0.4);
  text-shadow: 0 1px 0 rgba(0,0,0,0.4);
}
.pd-history-strip .pd-hist-dot.tie {
  background: linear-gradient(180deg, #aaa, #555);
  color: #fff;
  border-color: rgba(180,180,180,0.7);
  text-shadow: 0 1px 0 rgba(0,0,0,0.4);
}

/* ★ Round result modal — แจ้งผลรอบของฉันแบบใหญ่ */
.pd-round-result {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1700;
  min-width: 280px;
  padding: 22px 26px 18px;
  border-radius: 18px;
  background: linear-gradient(160deg, rgba(15,12,28,0.97) 0%, rgba(28,18,55,0.97) 60%, rgba(45,20,70,0.97) 100%);
  border: 2px solid rgba(255,215,0,0.5);
  box-shadow: 0 16px 48px rgba(0,0,0,0.7), inset 0 1px 0 rgba(255,255,255,0.1);
  text-align: center;
  animation: pdRoundResultIn 0.45s cubic-bezier(0.16,1,0.3,1);
  pointer-events: none;
}
.pd-round-result.win  { border-color: rgba(78,255,122,0.7); box-shadow: 0 16px 48px rgba(78,255,122,0.25), 0 0 0 2px rgba(78,255,122,0.5); }
.pd-round-result.lose { border-color: rgba(255,107,107,0.7); box-shadow: 0 16px 48px rgba(255,107,107,0.25), 0 0 0 2px rgba(255,107,107,0.5); }
.pd-round-result.tie  { border-color: rgba(180,180,180,0.7); box-shadow: 0 16px 48px rgba(0,0,0,0.5), 0 0 0 2px rgba(180,180,180,0.4); }
.pd-round-result .pd-rr-emoji {
  font-size: 3.4em;
  line-height: 1;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.5));
  animation: pdRoundResultEmoji 0.6s ease-out;
}
@keyframes pdRoundResultEmoji {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); }
}
.pd-round-result .pd-rr-title {
  font-size: 1.6em;
  font-weight: 800;
  letter-spacing: 1.5px;
  margin: 4px 0 6px;
  font-family: 'Cinzel', 'Sarabun', sans-serif;
}
.pd-round-result.win  .pd-rr-title { background: linear-gradient(180deg, #c8ffd6 0%, #4eff7a 60%, #2a8252 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.pd-round-result.lose .pd-rr-title { background: linear-gradient(180deg, #ffd6da 0%, #ff6b7e 60%, #8a0a1f 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.pd-round-result.tie  .pd-rr-title { color: #ddd; }
.pd-round-result .pd-rr-amount {
  font-size: 1.9em;
  font-weight: 900;
  margin-bottom: 14px;
  letter-spacing: 0.5px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 6px rgba(0,0,0,0.6);
}
.pd-round-result.win  .pd-rr-amount { color: #4eff7a; }
.pd-round-result.lose .pd-rr-amount { color: #ff6b7e; }
.pd-round-result.tie  .pd-rr-amount { color: #ccc; }
.pd-round-result .pd-rr-vs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.pd-round-result .pd-rr-side { flex: 1; }
.pd-round-result .pd-rr-side-label { font-size: 0.78em; color: #aaa; margin-bottom: 3px; }
.pd-round-result .pd-rr-side-hand {
  font-size: 0.92em;
  font-weight: 700;
  color: #ffd54a;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
.pd-round-result .pd-rr-vs-sep {
  font-size: 0.78em;
  font-weight: 800;
  color: #888;
  flex-shrink: 0;
  letter-spacing: 1.5px;
}
.pd-round-result .pd-rr-bounce {
  display: inline-block;
  padding: 1px 6px;
  font-size: 0.78em;
  background: linear-gradient(180deg, #ffd54a, #b8860b);
  color: #1a1500;
  border-radius: 999px;
  margin-left: 4px;
  font-weight: 800;
}
@keyframes pdRoundResultIn {
  from { opacity: 0; transform: translate(-50%, -45%) scale(0.85); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ★ Mobile tweaks */
@media (max-width: 480px) {
  .pd-history-strip { padding: 5px 8px; font-size: 0.74em; }
  .pd-history-strip .pd-hist-dot { width: 19px; height: 19px; font-size: 0.72em; }
  .pd-round-result { min-width: 260px; padding: 18px 20px 14px; }
  .pd-round-result .pd-rr-emoji { font-size: 2.8em; }
  .pd-round-result .pd-rr-title { font-size: 1.35em; }
  .pd-round-result .pd-rr-amount { font-size: 1.6em; }
}

/* ============================================================
   Dummy — Knock celebration + Round-result mini banner
============================================================ */
.dummy-knock-overlay {
  position: fixed;
  top: 38%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1700;
  min-width: 260px;
  padding: 18px 28px 16px;
  border-radius: 18px;
  background: linear-gradient(160deg, rgba(15,12,28,0.96) 0%, rgba(40,18,55,0.96) 60%, rgba(60,18,40,0.96) 100%);
  border: 2px solid rgba(255,107,107,0.7);
  box-shadow: 0 16px 48px rgba(255,107,107,0.35), 0 0 0 2px rgba(255,107,107,0.4) inset;
  text-align: center;
  animation: dummyKnockIn 0.4s cubic-bezier(0.16,1,0.3,1);
  pointer-events: none;
}
.dummy-knock-overlay.mine {
  border-color: rgba(255,213,74,0.85);
  box-shadow: 0 16px 48px rgba(255,213,74,0.45), 0 0 0 2px rgba(255,213,74,0.55) inset;
  background: linear-gradient(160deg, rgba(20,15,5,0.96) 0%, rgba(60,40,5,0.96) 60%, rgba(80,55,10,0.96) 100%);
}
.dummy-knock-overlay .dk-emoji {
  font-size: 3.6em;
  line-height: 1;
  filter: drop-shadow(0 4px 10px rgba(255,107,107,0.6));
  animation: dummyKnockShake 0.6s ease-out;
}
.dummy-knock-overlay.mine .dk-emoji {
  filter: drop-shadow(0 4px 10px rgba(255,213,74,0.7));
}
@keyframes dummyKnockShake {
  0% { transform: scale(0) rotate(-30deg); opacity: 0; }
  60% { transform: scale(1.25) rotate(15deg); opacity: 1; }
  80% { transform: scale(0.95) rotate(-8deg); }
  100% { transform: scale(1) rotate(0); }
}
.dummy-knock-overlay .dk-label {
  font-size: 1.8em;
  font-weight: 900;
  margin: 4px 0 6px;
  letter-spacing: 1.5px;
  font-family: 'Cinzel', 'Sarabun', sans-serif;
  background: linear-gradient(180deg, #ffd6da 0%, #ff6b7e 60%, #c41e3a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 2px 8px rgba(255,107,107,0.4);
}
.dummy-knock-overlay.mine .dk-label {
  background: linear-gradient(180deg, #fff5d4 0%, #ffd54a 60%, #b8860b 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.dummy-knock-overlay .dk-name {
  font-size: 1em;
  color: #fff;
  font-weight: 700;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}
@keyframes dummyKnockIn {
  from { opacity: 0; transform: translate(-50%, -45%) scale(0.7); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ★ Round result mini banner — แจ้งผลของฉัน 2 วิ */
.dummy-round-result {
  position: fixed;
  top: 38%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1700;
  min-width: 240px;
  padding: 16px 24px 14px;
  border-radius: 16px;
  background: linear-gradient(160deg, rgba(15,12,28,0.96) 0%, rgba(28,18,55,0.96) 60%, rgba(45,20,70,0.96) 100%);
  border: 2px solid rgba(255,215,0,0.5);
  box-shadow: 0 16px 48px rgba(0,0,0,0.65);
  text-align: center;
  animation: dummyRoundResultIn 0.4s cubic-bezier(0.16,1,0.3,1);
  pointer-events: none;
}
.dummy-round-result.win  { border-color: rgba(78,255,122,0.7); box-shadow: 0 16px 48px rgba(78,255,122,0.3), 0 0 0 2px rgba(78,255,122,0.45) inset; }
.dummy-round-result.lose { border-color: rgba(255,107,107,0.7); box-shadow: 0 16px 48px rgba(255,107,107,0.3), 0 0 0 2px rgba(255,107,107,0.45) inset; }
.dummy-round-result.tie  { border-color: rgba(180,180,180,0.6); }
.dummy-round-result .drr-emoji {
  font-size: 2.8em;
  line-height: 1;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
  animation: dummyRoundResultEmoji 0.5s ease-out;
}
@keyframes dummyRoundResultEmoji {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); }
}
.dummy-round-result .drr-title {
  font-size: 1.4em;
  font-weight: 800;
  margin: 2px 0 4px;
  letter-spacing: 1px;
  font-family: 'Cinzel', 'Sarabun', sans-serif;
}
.dummy-round-result.win  .drr-title { background: linear-gradient(180deg, #c8ffd6, #4eff7a, #2a8252); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.dummy-round-result.lose .drr-title { background: linear-gradient(180deg, #ffd6da, #ff6b7e, #8a0a1f); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.dummy-round-result.tie  .drr-title { color: #ddd; }
.dummy-round-result .drr-amount {
  font-size: 1.7em;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 6px rgba(0,0,0,0.6);
}
.dummy-round-result.win  .drr-amount { color: #4eff7a; }
.dummy-round-result.lose .drr-amount { color: #ff6b7e; }
.dummy-round-result.tie  .drr-amount { color: #ccc; }
@keyframes dummyRoundResultIn {
  from { opacity: 0; transform: translate(-50%, -45%) scale(0.85); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@media (max-width: 480px) {
  .dummy-knock-overlay { min-width: 240px; padding: 14px 22px 12px; }
  .dummy-knock-overlay .dk-emoji { font-size: 2.8em; }
  .dummy-knock-overlay .dk-label { font-size: 1.5em; }
  .dummy-round-result { min-width: 220px; padding: 14px 20px 12px; }
  .dummy-round-result .drr-emoji { font-size: 2.4em; }
  .dummy-round-result .drr-title { font-size: 1.2em; }
  .dummy-round-result .drr-amount { font-size: 1.5em; }
}

/* ============================================================
   Makhos (หมากฮอส) — 8x8 board styles
============================================================ */
#screen-makhos.active {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 72px 8px 8px;
  height: 100vh; height: 100dvh;
  max-width: 600px;
  margin: 0 auto;
  overflow: hidden;
  background:
    radial-gradient(ellipse at center top, rgba(150,80,200,0.14) 0%, transparent 55%),
    radial-gradient(ellipse at center, rgba(212,175,55,0.08) 0%, transparent 70%),
    radial-gradient(ellipse at bottom, #1a0f2a 0%, #0a0615 70%);
  background-attachment: fixed;
}

/* ★ Stage: board up top, not vertically centered */
.mh-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  min-height: 0;
  padding: 2px 0;
}
.mh-player-tag {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px;
  background: linear-gradient(180deg, rgba(0,0,0,0.55), rgba(0,0,0,0.3));
  border: 1px solid rgba(212,175,55,0.3);
  border-radius: 999px;
  font-size: 0.9em;
  width: 100%; max-width: 480px;
  justify-content: center;
}
.mh-player-tag.mh-active-turn {
  border-color: #ffd54a;
  box-shadow: 0 0 0 2px rgba(255,213,74,0.5), 0 0 14px rgba(255,213,74,0.4);
  animation: mh-tag-pulse 1.6s ease-in-out infinite;
}
@keyframes mh-tag-pulse {
  0%,100% { box-shadow: 0 0 0 2px rgba(255,213,74,0.4), 0 0 14px rgba(255,213,74,0.3); }
  50% { box-shadow: 0 0 0 3px rgba(255,213,74,0.7), 0 0 22px rgba(255,213,74,0.55); }
}
.mh-pawn-mini {
  display: inline-block;
  width: 18px; height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1.5px solid #1a1500;
}
.mh-pawn-mini.mh-p0 {
  background: radial-gradient(circle at 30% 30%, #fff, #d8d8d8 70%, #888);
}
.mh-pawn-mini.mh-p1 {
  background: radial-gradient(circle at 30% 30%, #555, #1a1a1a 70%, #000);
}
.mh-tag-name { color: var(--gold-bright); font-weight: 700; flex: 1; text-align: center; }
.mh-tag-pieces {
  background: rgba(0,0,0,0.5);
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.85em;
  color: #fff;
  font-weight: 700;
  border: 1px solid rgba(212,175,55,0.4);
}

.mh-board-wrap {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.mh-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: min(94vw, 460px);
  aspect-ratio: 1 / 1;
  /* ★ Dark purple/gold theme (เข้ากับธีมหลัก) */
  background: linear-gradient(135deg, #3b1f4a 0%, #1a0a2a 100%);
  border: 6px solid;
  border-image: linear-gradient(135deg, #d4af37 0%, #6b2a8a 50%, #d4af37 100%) 1;
  border-radius: 12px;
  box-shadow:
    0 14px 42px rgba(0,0,0,0.7),
    0 0 28px rgba(150,80,200,0.25),
    inset 0 0 0 2px rgba(212,175,55,0.45),
    inset 0 0 40px rgba(0,0,0,0.55);
  overflow: hidden;
}
.mh-cell {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  cursor: default;
  user-select: none;
  overflow: visible;
}
/* ★ สีเซลแบบ tournament classic — light = ไอวอรี่อ่อน / dark = เขียวเข้ม (เห็นหมากขาว/ดำชัด) */
.mh-cell.light { background: linear-gradient(135deg, #f5eed6 0%, #e4d9b0 100%); }
.mh-cell.dark  { background: linear-gradient(135deg, #2e7d5b 0%, #1e5a3f 100%); cursor: pointer; }
.mh-cell.dark:hover { background: linear-gradient(135deg, #3a9670 0%, #266d4c 100%); }

/* Highlight legal target */
.mh-cell.legal-target::before {
  content: '';
  position: absolute;
  inset: 22%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(78,255,122,0.5) 0%, rgba(78,255,122,0.2) 50%, transparent 80%);
  border: 2px solid rgba(78,255,122,0.8);
  pointer-events: none;
  animation: mh-target-pulse 1.2s ease-in-out infinite;
}
@keyframes mh-target-pulse {
  0%,100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}

/* Highlight selected piece's cell */
.mh-cell.selected {
  box-shadow: inset 0 0 0 3px #ffd54a, inset 0 0 16px rgba(255,213,74,0.4);
}

/* Last-move trail */
.mh-cell.last-from { box-shadow: inset 0 0 0 2px rgba(120,180,255,0.5); }
.mh-cell.last-to   { box-shadow: inset 0 0 0 2px rgba(120,180,255,0.7); }

/* Pieces */
.mh-piece {
  width: 78%;
  aspect-ratio: 1;
  border-radius: 50%;
  position: relative;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s;
  z-index: 2;
}
.mh-piece.p0 {
  background: radial-gradient(circle at 30% 25%, #ffffff 0%, #e0e0e0 40%, #999 100%);
  border: 2.5px solid #1a1500;
  box-shadow: 0 3px 6px rgba(0,0,0,0.5), inset 0 -3px 5px rgba(0,0,0,0.3);
}
.mh-piece.p1 {
  background: radial-gradient(circle at 30% 25%, #5a5a5a 0%, #2a2a2a 40%, #050505 100%);
  border: 2.5px solid #2a2a2a;               /* ★ ดำ: ขอบเข้มเข้าสี (เอาขอบทองออก) */
  box-shadow: 0 3px 6px rgba(0,0,0,0.5), inset 0 -3px 5px rgba(0,0,0,0.5);
}
/* ★ Forced-capture disabled — ตัวที่กินไม่ได้ตอนมีตัวอื่นต้องกิน (จาง + กดไม่ได้ + ไม่มี active glow) */
.mh-piece.disabled {
  opacity: 0.28 !important;
  filter: grayscale(0.85) blur(0.2px);
  pointer-events: none;
  animation: none !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.35) !important;
}
.mh-piece.disabled::after { opacity: 0.4 !important; }

/* ★ Turn indicator — ขอบ/เรืองสีทองรอบตัวหมากของฝั่งที่ถึงตา (สลับอัตโนมัติ) */
.mh-piece.active-turn {
  box-shadow:
    0 0 0 2.5px #ffd54a,
    0 0 10px rgba(255,213,74,0.75),
    0 3px 6px rgba(0,0,0,0.5),
    inset 0 -3px 5px rgba(0,0,0,0.35);
  animation: mh-turn-pulse 1.4s ease-in-out infinite;
}
@keyframes mh-turn-pulse {
  0%,100% { box-shadow: 0 0 0 2.5px #ffd54a, 0 0 8px rgba(255,213,74,0.55), 0 3px 6px rgba(0,0,0,0.5); }
  50%     { box-shadow: 0 0 0 3px   #ffe98a, 0 0 16px rgba(255,213,74,0.95), 0 3px 6px rgba(0,0,0,0.5); }
}
.mh-piece.king::after {
  content: '♛';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.4em;
  color: #ffd700;
  text-shadow: 0 0 6px rgba(0,0,0,0.7), 0 1px 2px rgba(0,0,0,0.9);
  pointer-events: none;
}
.mh-piece.p0.king::after { color: #d4af37; }
.mh-piece.p1.king::after { color: #ffd700; }
.mh-piece.selectable:hover { transform: scale(1.08); filter: brightness(1.12); }
.mh-piece.selected {
  transform: scale(1.12);
  box-shadow: 0 0 0 3px #ffd54a, 0 0 16px rgba(255,213,74,0.7);
}
.mh-piece.captured-anim {
  animation: mh-captured 0.5s ease-out forwards;
}
@keyframes mh-captured {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0); opacity: 0; }
}
.mh-piece.moving {
  z-index: 5;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Board labels (a-h, 1-8) */
.mh-cell .mh-coord {
  position: absolute;
  font-size: 0.55em;
  font-weight: 700;
  color: rgba(0,0,0,0.4);
  pointer-events: none;
}
.mh-cell.dark .mh-coord { color: rgba(255,255,255,0.3); }
.mh-cell .mh-coord-file { bottom: 2px; right: 4px; }
.mh-cell .mh-coord-rank { top: 2px; left: 4px; }

.mh-actions {
  display: flex; gap: 8px;
  justify-content: center;
  width: 100%; max-width: 480px;
  padding: 0 6px;
}
.mh-actions .btn-action {
  font-size: 0.85em;
  padding: 8px 16px;
}

/* ============================================================
   Makhos FX — capture burst / landing pulse / promote crown
============================================================ */
.mh-fx-capture {
  position: absolute; inset: 0;
  pointer-events: none; z-index: 5;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,100,100,0.85) 0%, rgba(255,80,80,0.4) 40%, transparent 70%);
  animation: mh-fx-capture 0.7s ease-out forwards;
}
@keyframes mh-fx-capture {
  0%   { transform: scale(0.4); opacity: 0.95; filter: blur(0); }
  60%  { transform: scale(1.6); opacity: 0.7;  filter: blur(2px); }
  100% { transform: scale(2.4); opacity: 0;    filter: blur(6px); }
}

/* ★ Shatter — หมากที่โดนกินแตกเป็นเศษเล็กๆกระจายรอบทิศ */
.mh-fx-shatter {
  position: absolute; inset: 0;
  pointer-events: none; z-index: 16;
  overflow: visible;
}
.mh-frag {
  position: absolute; left: 50%; top: 50%;
  width: 8px; height: 8px;
  background: radial-gradient(circle, #ffd0d0 0%, #ff7676 45%, #8a2020 100%);
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(255,100,100,0.9), 0 0 14px rgba(255,60,60,0.5);
  transform: translate(-50%, -50%) scale(1);
  opacity: 0;
  animation: mh-frag-fly 0.7s cubic-bezier(.25,.8,.4,1) forwards;
  animation-delay: var(--delay, 0ms);
}
@keyframes mh-frag-fly {
  0%   { transform: translate(-50%, -50%) scale(1) rotate(0); opacity: 1; }
  60%  { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.25) rotate(var(--rot)); opacity: 0; }
}

/* ★ Glow flash — แสงวาปบนหมากที่กิน (landing) */
.mh-fx-glow {
  position: absolute; inset: -10%;
  pointer-events: none; z-index: 17;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(255,255,255,1) 0%,
    rgba(255,240,170,0.95) 20%,
    rgba(255,200,80,0.7) 45%,
    rgba(255,120,40,0.3) 70%,
    transparent 85%);
  filter: blur(1px);
  animation: mh-fx-glow 0.6s cubic-bezier(.2,.8,.3,1) forwards;
}
@keyframes mh-fx-glow {
  0%   { transform: scale(0.3); opacity: 0; }
  25%  { transform: scale(1.25); opacity: 1; filter: blur(0); }
  60%  { transform: scale(1.45); opacity: 0.85; }
  100% { transform: scale(1.8); opacity: 0; filter: blur(4px); }
}
.mh-fx-land {
  position: absolute; inset: 0;
  pointer-events: none; z-index: 4;
  border-radius: 50%;
  animation: mh-fx-land 0.9s ease-out forwards;
  box-shadow: 0 0 0 0 rgba(255,215,0,0.7);
}
.mh-fx-land.capture { box-shadow: 0 0 0 0 rgba(255,120,120,0.8); }
.mh-fx-land.promote { box-shadow: 0 0 0 0 rgba(255,215,0,0.95); }
@keyframes mh-fx-land {
  0%   { box-shadow: 0 0 0 0 rgba(255,215,0,0.85), inset 0 0 0 3px rgba(255,215,0,0.9); opacity: 1; }
  60%  { box-shadow: 0 0 0 14px rgba(255,215,0,0.0), inset 0 0 0 3px rgba(255,215,0,0.4); opacity: 0.7; }
  100% { box-shadow: 0 0 0 22px rgba(255,215,0,0); inset 0 0 0 3px rgba(255,215,0,0); opacity: 0; }
}
/* ★ Combo multiplier popup — ขึ้นกลางจอใหญ่ๆ 0.7s (fade in 0.15s → hold → fade out 0.3s) */
.mh-fx-combo {
  position: fixed;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  font-family: 'Cinzel', serif;
  font-weight: 900;
  font-size: 10em;
  color: #ffd54a;
  text-shadow:
    0 0 14px rgba(255,213,74,0.95),
    0 0 32px rgba(255,150,40,0.9),
    0 0 60px rgba(255,80,20,0.75),
    0 4px 8px rgba(0,0,0,0.9);
  pointer-events: none;
  z-index: 9999;
  white-space: nowrap;
  letter-spacing: 3px;
  animation: mh-fx-combo 0.7s cubic-bezier(.2,1,.3,1) forwards;
}
.mh-fx-combo.combo-3 { color: #ffb347; font-size: 11em; }
.mh-fx-combo.combo-4 { color: #ff8c42; font-size: 12em; }
.mh-fx-combo.combo-5 { color: #ff6b35; font-size: 13em; }
.mh-fx-combo.combo-6,
.mh-fx-combo.combo-7,
.mh-fx-combo.combo-8,
.mh-fx-combo.combo-9 {
  color: #ff3b3b;
  font-size: 14em;
  text-shadow:
    0 0 18px #ff3b3b,
    0 0 40px #ff6b35,
    0 0 70px #ffd54a,
    0 4px 10px rgba(0,0,0,0.95);
}
@keyframes mh-fx-combo {
  0%   { transform: translate(-50%, -50%) scale(0.5) rotate(-10deg); opacity: 0; }
  25%  { transform: translate(-50%, -50%) scale(1.15) rotate(4deg);  opacity: 1; }
  55%  { transform: translate(-50%, -50%) scale(1.0)  rotate(0);     opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.3)  rotate(0);     opacity: 0; }
}

.mh-fx-crown {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%) scale(0);
  font-size: 2.2em;
  color: #ffd700;
  text-shadow: 0 0 10px rgba(255,215,0,0.9), 0 0 24px rgba(255,180,40,0.7), 0 2px 4px rgba(0,0,0,0.7);
  pointer-events: none; z-index: 10;
  animation: mh-fx-crown 1.2s cubic-bezier(.2,1,.3,1) forwards;
}
@keyframes mh-fx-crown {
  0%   { transform: translate(-50%, -50%) scale(0) rotate(-20deg); opacity: 0; }
  40%  { transform: translate(-50%, -120%) scale(1.3) rotate(6deg); opacity: 1; }
  80%  { transform: translate(-50%, -140%) scale(1.0) rotate(0); opacity: 0.85; }
  100% { transform: translate(-50%, -200%) scale(0.7); opacity: 0; }
}

/* ============================================================
   Makhos Result Banner v2 — modern + full overlay + dismissible
============================================================ */
.mh-result-banner {
  position: fixed; inset: 0;
  z-index: 1700;
  display: flex; align-items: center; justify-content: center;
  pointer-events: auto;
  animation: mh-rb-fadein 0.35s ease-out;
}
.mh-result-banner .mh-rb-backdrop {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0.85) 75%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.mh-result-banner .mh-rb-card {
  position: relative;
  min-width: 300px; max-width: min(92vw, 400px);
  padding: 28px 28px 22px;
  border-radius: 22px;
  background: linear-gradient(160deg, rgba(20,14,35,0.98), rgba(38,22,62,0.98), rgba(58,26,80,0.98));
  border: 2px solid rgba(255,215,0,0.55);
  box-shadow:
    0 24px 60px rgba(0,0,0,0.7),
    0 0 60px rgba(150,80,200,0.35),
    inset 0 1px 0 rgba(255,255,255,0.15);
  text-align: center;
  overflow: hidden;
  animation: mh-rb-pop 0.55s cubic-bezier(0.18,0.89,0.32,1.28) forwards;
  isolation: isolate;
}
.mh-result-banner .mh-rb-shine {
  position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,0.22) 48%, transparent 68%);
  transform: translateX(-120%);
  animation: mh-rb-shine 1.6s ease 0.3s 1 forwards;
  pointer-events: none; z-index: 0;
}
@keyframes mh-rb-shine { to { transform: translateX(120%); } }
.mh-result-banner.win  .mh-rb-card { border-color: rgba(78,255,122,0.7); box-shadow: 0 24px 60px rgba(0,0,0,0.7), 0 0 60px rgba(78,255,122,0.35), inset 0 1px 0 rgba(255,255,255,0.2); }
.mh-result-banner.lose .mh-rb-card { border-color: rgba(255,107,107,0.7); box-shadow: 0 24px 60px rgba(0,0,0,0.7), 0 0 60px rgba(255,107,107,0.35), inset 0 1px 0 rgba(255,255,255,0.2); }
.mh-result-banner.tie  .mh-rb-card { border-color: rgba(200,200,200,0.55); }
.mh-result-banner .mh-rb-emoji {
  position: relative; z-index: 1;
  font-size: 3.8em; line-height: 1;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,0.55));
  animation: mh-rb-emoji 0.7s ease-out, mh-rb-float 2.2s ease-in-out 0.7s infinite;
}
@keyframes mh-rb-emoji {
  0%   { transform: scale(0) rotate(-25deg); opacity: 0; }
  60%  { transform: scale(1.25) rotate(6deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}
@keyframes mh-rb-float {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-6px) scale(1.04); }
}
.mh-result-banner .mh-rb-title {
  position: relative; z-index: 1;
  font-size: 2em; font-weight: 900; letter-spacing: 2px;
  margin: 8px 0 4px;
  font-family: 'Cinzel','Sarabun',sans-serif;
}
.mh-result-banner.win  .mh-rb-title { background: linear-gradient(180deg, #d8ffde, #4eff7a 60%, #2a8252); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; filter: drop-shadow(0 2px 6px rgba(78,255,122,0.4)); }
.mh-result-banner.lose .mh-rb-title { background: linear-gradient(180deg, #ffe0e4, #ff6b7e 60%, #8a0a1f); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; filter: drop-shadow(0 2px 6px rgba(255,107,126,0.4)); }
.mh-result-banner.tie  .mh-rb-title { color: #eaeaea; }
.mh-result-banner .mh-rb-sub {
  position: relative; z-index: 1;
  font-size: 0.92em; color: #cbb6e8; opacity: 0.85;
  margin-bottom: 10px;
}
.mh-result-banner .mh-rb-winner {
  position: relative; z-index: 1;
  display: inline-block;
  padding: 4px 14px;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,215,0,0.35);
  border-radius: 999px;
  color: #ffd700; font-size: 0.9em; font-weight: 700;
  margin-bottom: 10px;
}
.mh-result-banner .mh-rb-amount {
  position: relative; z-index: 1;
  font-size: 2em; font-weight: 900;
  margin: 6px 0 16px;
  letter-spacing: 1px;
  text-shadow: 0 2px 6px rgba(0,0,0,0.55);
}
.mh-result-banner .mh-rb-amount.pos { color: #4eff7a; filter: drop-shadow(0 0 12px rgba(78,255,122,0.5)); }
.mh-result-banner .mh-rb-amount.neg { color: #ff6b7e; filter: drop-shadow(0 0 12px rgba(255,107,126,0.4)); }
.mh-result-banner .mh-rb-amount.neu { color: #cccccc; }
.mh-result-banner .mh-rb-btn {
  position: relative; z-index: 1;
  padding: 10px 26px;
  background: linear-gradient(180deg, #d4af37 0%, #8a6a1e 100%);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 10px;
  color: #1a0f2a;
  font-weight: 800; font-size: 1em;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(212,175,55,0.35), inset 0 1px 0 rgba(255,255,255,0.3);
  transition: transform 0.15s ease, filter 0.15s ease;
}
.mh-result-banner .mh-rb-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.mh-result-banner .mh-rb-btn:active { transform: translateY(0); }
@keyframes mh-rb-fadein {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes mh-rb-pop {
  0%   { opacity: 0; transform: scale(0.7) translateY(-20px); }
  60%  { opacity: 1; transform: scale(1.05) translateY(0); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* ============================================================
   Makhos — Resign confirm popup (โมดัลยืนยันยอมแพ้ สวยๆ)
============================================================ */
.mh-confirm-overlay {
  position: fixed; inset: 0;
  z-index: 1800;
  display: flex; align-items: center; justify-content: center;
  animation: mh-rb-fadein 0.2s ease-out;
}
.mh-confirm-backdrop {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, rgba(40,0,0,0.7) 0%, rgba(0,0,0,0.88) 70%);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
}
.mh-confirm-card {
  position: relative;
  min-width: 300px; max-width: min(92vw, 400px);
  padding: 28px 26px 22px;
  background: linear-gradient(180deg, #2a1010 0%, #1a0a0a 60%, #100505 100%);
  border: 1.5px solid rgba(255,120,120,0.55);
  border-radius: 18px;
  box-shadow:
    0 24px 60px rgba(0,0,0,0.75),
    0 0 50px rgba(255,80,80,0.25),
    inset 0 1px 0 rgba(255,255,255,0.18);
  text-align: center;
  animation: mh-rb-pop 0.32s cubic-bezier(.2,1,.3,1);
  color: #f5e6d3;
}
.mh-confirm-emoji {
  font-size: 3.2em; line-height: 1; margin-bottom: 6px;
  filter: drop-shadow(0 4px 10px rgba(255,100,100,0.5));
  animation: mh-confirm-wave 1.8s ease-in-out infinite;
}
@keyframes mh-confirm-wave {
  0%,100% { transform: rotate(-8deg); }
  50%     { transform: rotate(12deg); }
}
.mh-confirm-title {
  font-family: 'Cinzel', serif;
  font-size: 1.7em; font-weight: 800;
  color: #ffb8b8;
  letter-spacing: 1px;
  text-shadow: 0 2px 6px rgba(255,80,80,0.5);
  margin-bottom: 8px;
}
.mh-confirm-body {
  margin: 12px 0 18px;
  padding: 14px 12px;
  background: rgba(255,80,80,0.08);
  border: 1px solid rgba(255,120,120,0.25);
  border-radius: 10px;
}
.mh-confirm-msg {
  font-size: 0.95em; color: #e5c7c7;
  line-height: 1.5;
}
.mh-confirm-amount {
  margin-top: 10px;
  font-size: 1.05em;
  color: #ff8a8a;
}
.mh-confirm-amount strong {
  font-size: 1.25em; color: #ffd166;
  text-shadow: 0 0 8px rgba(255,180,80,0.6);
  margin-left: 4px;
}
.mh-confirm-actions {
  display: flex; gap: 10px; justify-content: center;
}
.mh-confirm-btn {
  flex: 1;
  padding: 12px 18px;
  border-radius: 10px;
  font-weight: 800; font-size: 1em;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.2);
  transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
}
.mh-confirm-btn.cancel {
  background: linear-gradient(180deg, #4a4a5a 0%, #2a2a38 100%);
  color: #e8e8f0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.15);
}
.mh-confirm-btn.danger {
  background: linear-gradient(180deg, #d84848 0%, #8a1818 100%);
  color: #fff5f5;
  box-shadow: 0 4px 14px rgba(216,72,72,0.45), inset 0 1px 0 rgba(255,255,255,0.25);
  border-color: rgba(255,150,150,0.5);
}
.mh-confirm-btn:hover { filter: brightness(1.12); transform: translateY(-1px); }
.mh-confirm-btn:active { transform: translateY(0); filter: brightness(0.95); }

@media (max-width: 480px) {
  .mh-confirm-card { min-width: 260px; padding: 22px 20px 18px; }
  .mh-confirm-emoji { font-size: 2.6em; }
  .mh-confirm-title { font-size: 1.4em; }
  .mh-confirm-btn { padding: 10px 14px; font-size: 0.95em; }
}

@media (max-width: 480px) {
  #screen-makhos.active { padding: 60px 4px 6px; gap: 4px; }
  .mh-board { width: 96vw; max-width: 96vw; }
  .mh-piece { width: 80%; }
  .mh-piece.king::after { font-size: 1.1em; }
  .mh-player-tag { font-size: 0.82em; padding: 4px 10px; }
  .mh-result-banner .mh-rb-card { min-width: 260px; padding: 22px 22px 18px; }
  .mh-result-banner .mh-rb-emoji { font-size: 3em; }
  .mh-result-banner .mh-rb-title { font-size: 1.6em; }
  .mh-result-banner .mh-rb-amount { font-size: 1.6em; }
}

/* iOS slim mode */
body.ios-game-slim #screen-makhos.active {
  padding-top: calc(env(safe-area-inset-top, 0px) + 4px) !important;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 28px) !important;
}

/* ★ iOS: ขยับ countdown / leave-btn ทุกเกมให้ห่างจากปุ่ม ☰ มุมขวาบน (~54px) */
body.ios-game-slim #screen-game .game-top-row,
body.ios-game-slim #screen-pokdeng .game-top-row,
body.ios-game-slim #screen-makhos .game-top-row {
  padding-right: 56px !important;   /* เว้นที่ให้ ☰ ไม่บังเนื้อหาขวา */
}
body.ios-game-slim #screen-pokdeng .pd-leave-btn,
body.ios-game-slim #screen-makhos .pd-leave-btn,
body.ios-game-slim #screen-game .pd-leave-btn {
  right: 58px !important;             /* ดันปุ่ม "ออก" ไปทางซ้ายหลบ ☰ */
  top: 6px !important;
}
/* ★ ตำแหน่ง top-countdown / mhCountdown / pdCountdown — อยู่ขวาสุดของแถว, ให้หลบ ☰ ด้วย padding-right */
body.ios-game-slim #screen-game .top-countdown,
body.ios-game-slim #screen-pokdeng .top-countdown,
body.ios-game-slim #screen-makhos .top-countdown {
  margin-right: 0 !important;
}

/* ===== Dummy money detail tab (round summary tab 2) ===== */
.mny-card {
  margin-bottom: 12px;
  padding: 10px 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(0,0,0,0.25));
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}
.mny-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px dashed rgba(255,255,255,0.12);
}
.mny-head-l { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mny-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  border: 2px solid #888;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3em; flex-shrink: 0;
}
.mny-name { font-weight: 800; font-size: 1.02em; }
.mny-dark { background:#3d0808; color:#ff7a8c; padding:1px 6px; border-radius:4px; font-size:0.72em; font-weight:700; }
.mny-tier { font-size: 0.82em; font-weight: 700; margin-top: 1px; }
.mny-total { font-size: 1.25em; font-weight: 900; white-space: nowrap; }
.mny-mini {
  display: flex; gap: 12px; flex-wrap: wrap;
  font-size: 0.78em; font-weight: 700;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 6px;
}
.mny-list { display: flex; flex-direction: column; gap: 4px; }
.mny-row {
  display: grid;
  grid-template-columns: 18px auto 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 0.86em;
}
.mny-icon { font-weight: 900; }
.mny-amt { font-weight: 800; white-space: nowrap; }
.mny-reason { color: #ddd; overflow: hidden; text-overflow: ellipsis; }
.mny-party { color: #aaa; font-size: 0.85em; white-space: nowrap; }
.mny-pot { color: #d4af37; }
.mny-empty { color: #888; font-size: 0.82em; padding: 6px 0; text-align: center; }

/* ============================================================
   ????????? (Hi-Lo)  Game UI
============================================================ */
#screen-hilo .hilo-stage {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  max-width: 720px;
  margin: 0 auto;
}

/* Dice */
.hilo-dice {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 12px;
  background: linear-gradient(180deg, rgba(212,175,55,0.08), rgba(0,0,0,0.4));
  border-radius: 14px;
  border: 1px solid rgba(212,175,55,0.3);
}
.hilo-die {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3em;
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 14px;
  box-shadow: inset 0 -4px 8px rgba(0,0,0,0.3);
  transition: transform 0.3s ease;
}
.hilo-die.rolled {
  animation: hiloDieRoll 0.6s ease-out;
  border-color: #ffd700;
  box-shadow: 0 0 20px rgba(255,215,0,0.5);
}
@keyframes hiloDieRoll {
  0% { transform: rotate(0) scale(0.8); }
  50% { transform: rotate(720deg) scale(1.2); }
  100% { transform: rotate(720deg) scale(1); }
}

/* Bet board: 6 cells in 3x2 grid */
.hilo-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.hilo-cell {
  position: relative;
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(0,0,0,0.3));
  border: 3px solid;
  border-radius: 14px;
  padding: 18px 8px 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  user-select: none;
}
.hilo-cell:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(0,0,0,0.4); }
.hilo-cell-emoji { font-size: 3em; line-height: 1; }
.hilo-cell-name { font-size: 0.9em; font-weight: 700; margin-top: 4px; color: #fff; }
.hilo-cell-mychip {
  position: absolute; top: 4px; right: 4px;
  background: #ffd700; color: #000;
  padding: 2px 7px; border-radius: 999px;
  font-size: 0.78em; font-weight: 800;
}
.hilo-cell-totalchip {
  font-size: 0.72em; color: #aaa; margin-top: 2px;
}
.hilo-cell-mult {
  position: absolute; top: 4px; left: 4px;
  background: #4eff7a; color: #000;
  padding: 2px 7px; border-radius: 6px;
  font-size: 0.85em; font-weight: 800;
  animation: hiloMultPop 0.4s ease-out;
}
@keyframes hiloMultPop {
  0% { transform: scale(0); }
  50% { transform: scale(1.4); }
  100% { transform: scale(1); }
}
.hilo-cell-win {
  background: linear-gradient(180deg, rgba(78,255,122,0.25), rgba(78,255,122,0.05));
  box-shadow: 0 0 18px rgba(78,255,122,0.5);
}
.hilo-cell-lose {
  opacity: 0.4;
  filter: grayscale(0.6);
}

/* Controls */
.hilo-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(0,0,0,0.3);
  border-radius: 10px;
  padding: 8px;
}
.hilo-chip-row, .hilo-action-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.hilo-chip-btn {
  background: linear-gradient(180deg, #fbbf24, #d97706);
  color: #000;
  border: 2px solid transparent;
  border-radius: 50%;
  width: 42px; height: 42px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s;
}
.hilo-chip-btn:hover { transform: scale(1.05); }
.hilo-chip-btn.active {
  border-color: #ffd700;
  box-shadow: 0 0 10px rgba(255,215,0,0.6);
  transform: scale(1.1);
}

/* Seats  small horizontal row below board */
.hilo-seats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 8px;
  background: rgba(0,0,0,0.2);
  border-radius: 10px;
  border: 1px dashed rgba(255,255,255,0.1);
}
.hilo-seat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 70px;
  padding: 6px 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  font-size: 0.78em;
}
.hilo-seat.is-dealer {
  background: linear-gradient(180deg, rgba(220,38,38,0.3), rgba(127,29,29,0.2));
  border-color: #fca5a5;
  box-shadow: 0 0 8px rgba(252,165,165,0.4);
}
.hilo-seat.is-me {
  border-color: #ffd700;
  box-shadow: 0 0 8px rgba(255,215,0,0.5);
}
.hilo-seat.is-off { opacity: 0.4; }
.hilo-seat-icon { font-size: 1.5em; }
.hilo-seat-name {
  font-weight: 700;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
}
.hilo-seat-delta {
  font-size: 0.85em;
  font-weight: 800;
  margin-top: 2px;
}

/* Game card glow amber */
.gc-glow-amber {
  position: absolute; inset: 0;
  background: radial-gradient(circle at 30% 30%, rgba(245,158,11,0.4), transparent 60%);
  pointer-events: none;
}

@media (max-width: 600px) {
  .hilo-die { width: 60px; height: 60px; font-size: 2.4em; }
  .hilo-cell-emoji { font-size: 2.4em; }
  .hilo-seat { min-width: 60px; font-size: 0.72em; }
}

/* ============================================================
   📢 Announcement bar — marquee ขวา→ซ้าย, single-line, fixed under top-bar
   ★ ใช้ --topbar-h ที่ JS วัดจริงจาก #topBar.getBoundingClientRect()
     → แม่นยำทุกอุปกรณ์ (iPhone notch, fake-fullscreen, ฯลฯ)
   ============================================================ */
:root { --topbar-h: 56px; --ann-h: 32px; }
.announcement-bar {
  position: fixed;
  top: var(--topbar-h);
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--ann-h);
  z-index: 100;                     /* ต่ำกว่า top-bar (500) + modal (1000) — สูงกว่า content (1) */
  background: linear-gradient(180deg, rgba(20,12,40,0.97), rgba(15,8,30,0.97));
  border-bottom: 1px solid rgba(255,215,0,0.3);
  box-shadow: 0 2px 10px rgba(0,0,0,0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  overflow: hidden;
  white-space: nowrap;
  display: flex;
  align-items: center;
  animation: annFadeIn 0.4s ease-out;
}
.announcement-bar .ann-marquee {
  display: inline-block;
  padding-left: 100%;               /* เริ่มที่ขอบขวา → เลื่อนเข้ามา */
  white-space: nowrap;
  font-size: 0.86em;
  font-weight: 600;
  line-height: var(--ann-h);
  padding-top: 2px;                 /* ★ ดันลง 2px ตามคำขอ */
  animation: annScroll 22s linear infinite;
  will-change: transform;
}
.announcement-bar .ann-icon {
  margin-right: 8px;
  filter: drop-shadow(0 0 4px rgba(255,215,0,0.4));
}
@keyframes annScroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}
@keyframes annFadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-4px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
/* ★ ซ่อนตอนอยู่ในเกมจริง — ป้องกันทับ UI เกม */
body.in-actual-game #announcementBar {
  display: none !important;
}
/* ★ ดัน content ลงเพิ่มเท่ากับความสูงของบาร์ เมื่อมีประกาศแสดง */
body.has-announcement #screen-game-pick.active {
  padding-top: calc(var(--topbar-h, 50px) + var(--ann-h) + env(safe-area-inset-top, 0px));
}
body.has-announcement #screen-mode-pick.active,
body.has-announcement #screen-rate-pick.active,
body.has-announcement #screen-room-list.active,
body.has-announcement #screen-lobby.active {
  /* ★ ดัน breadcrumb ให้อยู่ใต้บาร์ประกาศห่าง 5px (หัก card-box padding-top 12px) */
  padding-top: calc(var(--topbar-h, 56px) + var(--ann-h) + 5px - 12px);
}
@media (max-width: 600px) {
  :root { --ann-h: 28px; }
  .announcement-bar .ann-marquee { font-size: 0.78em; }
}
