/* ═══════════════════════════════════════════════════════════════
   BotV8-WebLive — ธีมและผังจอ
   ───────────────────────────────────────────────────────────────
   ⚠️ ทุกเอฟเฟกต์ทำด้วย transform/opacity เท่านั้น (GPU)
      ขยับ top/left/width = มือถือรุ่นกลางกระตุกทันทีที่มีชิป 20 ตัวบนจอ

   ⚠️ ใช้ dvh ไม่ใช่ vh — แถบ URL ของ Safari บนมือถือทำให้ vh เพี้ยน
      จนกระดานถูกดันตกขอบจอ (มี fallback vh ไว้ให้เบราว์เซอร์เก่า)

   ⚠️ ทุกปุ่ม ≥ 44×44 px และ touch-action: manipulation
      เกมสดคนแตะรัวที่ปุ่มเดิม เบราว์เซอร์จะตีความเป็น double-tap แล้วซูมเข้า
   ═══════════════════════════════════════════════════════════════ */

/* ── โทเคนสี ─────────────────────────────────────────────────── */
:root {
  --bg:        #070a10;
  --bg-2:      #0d131d;
  --panel:     #121a26;
  --panel-2:   #18222f;
  --line:      #223047;
  --ink:       #e8eef7;
  --ink-dim:   #93a3b8;
  --ink-faint: #5d6f88;

  --tiger:     #f59e0b;
  --tiger-2:   #b45309;
  --dragon:    #ef4444;
  --dragon-2:  #991b1b;
  --pair:      #a855f7;
  --tie:       #22c55e;
  --gold:      #fbbf24;
  --danger:    #f43f5e;
  --line-green:#06c755;

  --accent:    #38bdf8;
  --accent-2:  #0ea5e9;

  --radius:    16px;
  --radius-sm: 10px;
  --shadow:    0 12px 34px rgba(0, 0, 0, .45);
  --safe-b:    env(safe-area-inset-bottom, 0px);
}

[data-theme="emerald"] {
  --bg: #04100c; --bg-2: #071a13; --panel: #0c2419; --panel-2: #113022;
  --line: #1c4733; --accent: #34d399; --accent-2: #10b981;
}

[data-theme="royal"] {
  --bg: #0b0716; --bg-2: #140d24; --panel: #1b1233; --panel-2: #241844;
  --line: #3b2a63; --accent: #c084fc; --accent-2: #a855f7;
}

/* ── พื้นฐาน ─────────────────────────────────────────────────── */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Prompt", "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
  /* ⚠️ กันการเลือกข้อความตอนแตะรัว — บนมือถือจะขึ้นเมนู copy มาบัง */
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; color: inherit; }

button {
  cursor: pointer;
  border: none;
  background: none;
  touch-action: manipulation;
}

a { color: var(--accent); text-decoration: none; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

/* ⚠️ ผู้ที่ตั้งค่า "ลดการเคลื่อนไหว" ต้องได้จอที่นิ่งจริง ๆ ไม่ใช่แค่ช้าลง */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* ═══ หน้าเข้าระบบ / สมัคร ══════════════════════════════════ */
.gate {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px calc(24px + var(--safe-b));
  position: relative;
  overflow: hidden;
  background: radial-gradient(120% 80% at 50% 0%, var(--bg-2), var(--bg) 70%);
}

.gate__glow {
  position: absolute;
  inset: -40% -20% auto -20%;
  height: 70%;
  background:
    radial-gradient(40% 60% at 25% 40%, rgba(245, 158, 11, .22), transparent 70%),
    radial-gradient(40% 60% at 75% 40%, rgba(239, 68, 68, .22), transparent 70%);
  filter: blur(30px);
  animation: drift 14s ease-in-out infinite alternate;
}

@keyframes drift {
  from { transform: translate3d(-3%, 0, 0) scale(1); }
  to   { transform: translate3d(3%, 2%, 0) scale(1.08); }
}

.gate__card {
  position: relative;
  width: min(420px, 100%);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
}

.gate__brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 14px;
}

.gate__mark { font-size: 38px; animation: breathe 3.4s ease-in-out infinite; }
.gate__mark:last-child { animation-delay: 1.7s; }

/* ⭐ ไอคอน "หายใจ" เบา ๆ — สื่อว่าหน้าจอยังมีชีวิตและระบบยังต่ออยู่ */
@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.12); }
}

.gate__vs {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--ink-faint);
}

.gate__title { margin: 0; font-size: 22px; text-align: center; }
.gate__sub   { margin: 6px 0 18px; text-align: center; color: var(--ink-dim); font-size: 14px; }
.gate__foot  { margin: 18px 0 0; text-align: center; color: var(--ink-dim); font-size: 14px; }

.gate__or {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0;
  color: var(--ink-faint);
  font-size: 13px;
}
.gate__or::before, .gate__or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ── ฟอร์ม ───────────────────────────────────────────────────── */
.form { display: grid; gap: 14px; }

.field { display: grid; gap: 6px; }
.field__label { font-size: 13px; color: var(--ink-dim); }
.field__hint  { font-size: 12px; color: var(--ink-faint); }

.field__input {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
  /* ⚠️ 16px ขั้นต่ำ — เล็กกว่านี้ iOS ซูมเข้าอัตโนมัติตอนโฟกัส */
  font-size: 16px;
  -webkit-user-select: text;
  user-select: text;
}

.field__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, .18);
}

.alert {
  margin: 0 0 14px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.5;
}
.alert--bad  { background: rgba(244, 63, 94, .14); border: 1px solid rgba(244, 63, 94, .4); }
.alert--warn { background: rgba(251, 191, 36, .12); border: 1px solid rgba(251, 191, 36, .38); }

/* ── ปุ่ม ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 15px;
  transition: transform .12s, filter .15s, background .15s;
}

.btn:active { transform: scale(.96); }
.btn--block { width: 100%; }
.btn__ico   { font-size: 16px; line-height: 1; }

.btn--primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #06121c; }
.btn--gold    { background: linear-gradient(135deg, var(--gold), #f59e0b); color: #2a1a00; }
.btn--line    { background: var(--line-green); color: #00230d; }
.btn--danger  { background: rgba(244, 63, 94, .16); color: #ffc9d2; border: 1px solid rgba(244, 63, 94, .42); }
.btn--ghost   { background: transparent; color: var(--ink-dim); border: 1px solid var(--line); }
.btn--quiet   { background: transparent; color: var(--ink-faint); padding: 10px 12px; }

.btn:disabled { opacity: .5; pointer-events: none; }

/* ═══ หน้าโต๊ะ ═══════════════════════════════════════════════ */
.live {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  background: radial-gradient(140% 90% at 50% -10%, var(--bg-2), var(--bg) 65%);
}

/* ── เวทีไลฟ์ ────────────────────────────────────────────────── */
.live__stage {
  position: relative;
  background: #000;
  overflow: hidden;
}

.stream { position: relative; width: 100%; height: 100%; }

.stream__video,
.stream__frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  /*
    ⭐ `contain` ไม่ใช่ `cover` — ไลฟ์แนวตั้งที่ถ่ายมาจากมือถือ ถ้า cover
       จะถูกครอบตัดหัวและท้ายทิ้ง ซึ่งเป็นตรงที่ไพ่วางอยู่พอดี
  */
  object-fit: contain;
  background: #000;
}

/* ⭐ ไลฟ์แนวตั้ง — js ติดคลาสนี้ให้เองหลังอ่านขนาดจริงจาก <video> */
.stream.is-portrait .stream__video { object-fit: cover; }

.stream__idle {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 180px;
}

.stream__poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: .35;
}

.stream__idleText { position: relative; text-align: center; color: var(--ink-dim); }
.stream__idleText p { margin: 6px 0 2px; font-weight: 600; }
.stream__idleText small { color: var(--ink-faint); }
.stream__idleIcon { font-size: 34px; opacity: .7; }

/* ไล่เฉดบน-ล่าง ให้ตัวหนังสือบนวิดีโออ่านออกไม่ว่าภาพจะสว่างแค่ไหน */
.stream__scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, .6), transparent 22%),
    linear-gradient(0deg, rgba(0, 0, 0, .5), transparent 25%);
}

.stream__unmute {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .55);
  border: 1px solid rgba(255, 255, 255, .18);
  font-size: 18px;
  backdrop-filter: blur(6px);
}

.stage__bar {
  position: absolute;
  inset: 0 0 auto 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  z-index: 3;
}

.stage__id { display: flex; align-items: center; gap: 8px; min-width: 0; }

.stage__title {
  font-weight: 700;
  font-size: 15px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, .8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ⭐ จุดแดงเต้น = การเชื่อมต่อยังดีอยู่ · js ดับให้เมื่อ pulse ล้มติดกัน */
.stage__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--dragon);
  box-shadow: 0 0 0 0 rgba(239, 68, 68, .7);
  animation: ping 1.8s ease-out infinite;
  flex: none;
}

.stage__dot.is-stale { background: var(--ink-faint); animation: none; }

@keyframes ping {
  0%   { box-shadow: 0 0 0 0 rgba(239, 68, 68, .7); }
  70%  { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.stage__round { display: flex; align-items: center; gap: 8px; flex: none; }
.stage__num   { font-size: 13px; color: #dbe6f5; text-shadow: 0 2px 8px rgba(0, 0, 0, .8); }

.pill {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(0, 0, 0, .55);
  border: 1px solid rgba(255, 255, 255, .16);
  backdrop-filter: blur(6px);
  white-space: nowrap;
}

.pill[data-can-bet="1"] { color: #86efac; border-color: rgba(34, 197, 94, .45); }
.pill[data-can-bet="0"] { color: #fca5a5; border-color: rgba(239, 68, 68, .45); }

/* ── แชทลอยมุมขวา ────────────────────────────────────────────── */
.chat {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 4;
  width: min(58%, 300px);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
  max-height: 42vh;
  overflow: hidden;
  /* ⚠️ ข้อความลอยทับกระดาน — ห้ามรับการแตะ ไม่งั้นกดประตูไม่โดน */
  pointer-events: none;
}

.chat__item {
  /* ⭐ ยิ่งเก่ายิ่งจาง แล้วหายเอง — ทำด้วย CSS ล้วน ไม่มี js ไล่ลบทีละตัว */
  animation: chatIn .28s ease-out, chatFade 12s linear forwards;
  padding: 5px 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, .48);
  backdrop-filter: blur(4px);
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
  max-width: 100%;
}

.chat__item.is-me            { background: rgba(56, 189, 248, .28); }
.chat__item--system          { background: rgba(148, 163, 184, .22); font-style: italic; }
.chat__item--win             { background: rgba(251, 191, 36, .26); font-weight: 600; }
.chat__who                   { color: var(--accent); font-weight: 700; margin-right: 6px; }

@keyframes chatIn {
  from { opacity: 0; transform: translate3d(24px, 0, 0); }
  to   { opacity: 1; transform: none; }
}

@keyframes chatFade {
  0%, 60% { opacity: 1; }
  100%    { opacity: 0; visibility: hidden; }
}

.chat__form {
  display: flex;
  gap: 6px;
  pointer-events: auto;
}

.chat__input {
  flex: 1;
  min-width: 0;
  min-height: 38px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .55);
  border: 1px solid rgba(255, 255, 255, .18);
  font-size: 16px;
  -webkit-user-select: text;
  user-select: text;
}

.chat__input:focus { outline: none; border-color: var(--accent); }

.chat__send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent);
  color: #06121c;
  font-size: 15px;
  flex: none;
}

/* ── แผงเล่น ─────────────────────────────────────────────────── */
.live__panel {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 10px;
  padding: 10px 10px calc(10px + var(--safe-b));
  min-height: 0;
}

/* ── กล่องผู้เล่น ─────────────────────────────────────────────── */
.player {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(135deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.player__avatar {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-2);
  display: grid;
  place-items: center;
  flex: none;
}

.player__avatar img { width: 100%; height: 100%; object-fit: cover; }
.player__initial    { font-weight: 800; color: var(--accent); font-size: 18px; }

.player__ring {
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  opacity: .5;
}

.player__id   { display: grid; gap: 2px; min-width: 0; }
.player__code { font-size: 11px; color: var(--gold); letter-spacing: .5px; }

.player__name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player__wallet     { grid-column: 2; grid-row: 2; }
.player__walletLabel{ display: block; font-size: 11px; color: var(--ink-faint); }

.player__credit {
  font-size: 22px;
  font-weight: 800;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  display: inline-block;
  transition: transform .2s;
}

/* ⭐ เครดิตขึ้น/ลง — เห็นทันทีว่าเงินขยับจริง ไม่ใช่แค่กระพริบ */
.player__credit.is-up   { animation: bumpUp .5s ease-out; color: #86efac; }
.player__credit.is-down { animation: bumpDown .5s ease-out; color: #fca5a5; }

@keyframes bumpUp {
  0%   { transform: translate3d(0, 6px, 0); }
  60%  { transform: translate3d(0, -3px, 0); }
  100% { transform: none; }
}

@keyframes bumpDown {
  0%   { transform: translate3d(0, -6px, 0); }
  60%  { transform: translate3d(0, 3px, 0); }
  100% { transform: none; }
}

.player__actions {
  grid-column: 3;
  grid-row: 1 / span 2;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.player__logout { margin: 0; }

/* ── ผลย้อนหลัง (เค้าไพ่อย่างย่อ) ─────────────────────────────── */
.road {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
}

.road__label { font-size: 11px; color: var(--ink-faint); flex: none; }

.road__track {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.road__track::-webkit-scrollbar { display: none; }

.bead {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: #0b0f16;
  /* ⭐ ผลใหม่เลื่อนเข้าจากขวา — เห็นทันทีว่ามีรอบใหม่เข้ามา */
  animation: beadIn .35s ease-out;
}

@keyframes beadIn {
  from { opacity: 0; transform: translate3d(16px, 0, 0) scale(.6); }
  to   { opacity: 1; transform: none; }
}

.bead--tiger       { background: var(--tiger); }
.bead--dragon      { background: var(--dragon); color: #fff; }
.bead--tiger-pair  { background: var(--tiger); box-shadow: inset 0 0 0 3px var(--pair); }
.bead--dragon-pair { background: var(--dragon); color: #fff; box-shadow: inset 0 0 0 3px var(--pair); }
.bead--tie         { background: var(--tie); }
.bead--muted       { background: var(--ink-faint); }

/* ── กระดาน ──────────────────────────────────────────────────── */
.board {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr;
  gap: 8px;
  padding: 10px;
  border-radius: var(--radius);
  background:
    radial-gradient(90% 70% at 50% 0%, rgba(56, 189, 248, .08), transparent 70%),
    linear-gradient(180deg, var(--panel), var(--bg-2));
  min-height: 220px;
}

/* ⭐ ขอบกระดานเรืองเมื่อเปิดรับ · หรี่ลงเมื่อปิด — บอกสถานะโดยไม่ต้องอ่าน */
.board__frame {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  border: 2px solid transparent;
  pointer-events: none;
  transition: border-color .3s, box-shadow .3s;
}

.board.is-open .board__frame {
  border-color: rgba(34, 197, 94, .45);
  box-shadow: inset 0 0 24px rgba(34, 197, 94, .12);
  animation: frameGlow 2.4s ease-in-out infinite;
}

.board.is-locked .board__frame { border-color: rgba(239, 68, 68, .3); }

@keyframes frameGlow {
  0%, 100% { box-shadow: inset 0 0 20px rgba(34, 197, 94, .10); }
  50%      { box-shadow: inset 0 0 34px rgba(34, 197, 94, .22); }
}

.board__mid { display: grid; grid-template-rows: 1fr 1fr; gap: 8px; }

.board__lock {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: rgba(7, 10, 16, .62);
  backdrop-filter: blur(2px);
  font-weight: 800;
  font-size: 16px;
  color: #fca5a5;
  letter-spacing: .5px;
  z-index: 5;
  animation: fadeIn .2s ease-out;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── ประตูแทง ────────────────────────────────────────────────── */
.gate {
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  align-content: start;
  justify-items: center;
  gap: 2px;
  padding: 12px 8px 10px;
  min-height: 96px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, .04), rgba(0, 0, 0, .22));
  color: var(--ink);
  overflow: hidden;
  transition: transform .12s, border-color .2s, box-shadow .25s;
}

.gate:active { transform: scale(.97); }

.gate--tiger  { border-color: rgba(245, 158, 11, .5); background: linear-gradient(180deg, rgba(245, 158, 11, .16), rgba(0, 0, 0, .25)); }
.gate--dragon { border-color: rgba(239, 68, 68, .5);  background: linear-gradient(180deg, rgba(239, 68, 68, .16), rgba(0, 0, 0, .25)); }
.gate--pair   { border-color: rgba(168, 85, 247, .5); background: linear-gradient(180deg, rgba(168, 85, 247, .14), rgba(0, 0, 0, .25)); }
.gate--tie    { border-color: rgba(34, 197, 94, .5);  background: linear-gradient(180deg, rgba(34, 197, 94, .14), rgba(0, 0, 0, .25)); }

.gate__icon { font-size: 30px; line-height: 1.1; animation: breathe 4s ease-in-out infinite; }
.gate--pair .gate__icon,
.gate--tie  .gate__icon { font-size: 22px; }

.gate__name { font-weight: 700; font-size: 15px; }
.gate__rate { font-size: 12px; color: var(--gold); font-weight: 700; }

.gate__table {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 10px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

/* ⭐ ประตูที่ชนะ — เรืองแสงและเด้ง */
.gate.is-won {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(251, 191, 36, .5), 0 0 30px rgba(251, 191, 36, .35);
  animation: winPulse 1s ease-out 3;
}

@keyframes winPulse {
  0%, 100% { transform: none; }
  40%      { transform: scale(1.04); }
}

/* ── กองชิป ──────────────────────────────────────────────────── */
.gate__stack {
  position: relative;
  margin-top: 6px;
  min-height: 30px;
  display: grid;
  place-items: center;
}

.stack__coin {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #fde68a, var(--gold) 45%, #b45309);
  box-shadow: 0 3px 0 #92400e, 0 6px 10px rgba(0, 0, 0, .45);
  /* ⭐ กองชิป "เด้ง" ทุกครั้งที่ยอดเพิ่ม — สื่อว่ารับคำสั่งแล้ว */
  animation: chipDrop .3s cubic-bezier(.2, 1.6, .4, 1);
}

@keyframes chipDrop {
  0%   { transform: translate3d(0, -22px, 0) scale(.7); opacity: .2; }
  70%  { transform: translate3d(0, 3px, 0) scale(1.06); opacity: 1; }
  100% { transform: none; }
}

.stack__sum {
  position: absolute;
  font-size: 12px;
  font-weight: 800;
  color: #3b2200;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .5);
  font-variant-numeric: tabular-nums;
}

/* ⭐ เหรียญบินจากแถบล่างไปที่ประตู — องค์ประกอบชั่วคราวที่ js สร้างแล้วลบทิ้ง */
.flying {
  position: fixed;
  z-index: 60;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #fde68a, var(--gold) 45%, #b45309);
  box-shadow: 0 4px 12px rgba(0, 0, 0, .5);
  pointer-events: none;
  transition: transform .34s cubic-bezier(.3, .9, .3, 1), opacity .34s;
}

/* ⚠️ เด้งกลับ = ไม่ผ่าน — ต้องรู้สึกต่างจากตอนสำเร็จอย่างชัดเจน */
.gate.is-rejected { animation: shake .32s ease-in-out; border-color: var(--danger); }

@keyframes shake {
  0%, 100% { transform: none; }
  25%      { transform: translate3d(-5px, 0, 0); }
  75%      { transform: translate3d(5px, 0, 0); }
}

/* ── แถบเหรียญ ───────────────────────────────────────────────── */
.tray {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.tray__coins {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px;
}

.tray__coins::-webkit-scrollbar { display: none; }

.coin {
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  color: #2a1a00;
  border: 3px solid rgba(255, 255, 255, .28);
  box-shadow: 0 3px 0 rgba(0, 0, 0, .35);
  transition: transform .14s, box-shadow .18s, filter .18s;
  filter: saturate(.65) brightness(.8);
}

.coin--1 { background: radial-gradient(circle at 32% 28%, #e2e8f0, #94a3b8 55%, #475569); }
.coin--2 { background: radial-gradient(circle at 32% 28%, #bbf7d0, #22c55e 55%, #15803d); }
.coin--3 { background: radial-gradient(circle at 32% 28%, #bfdbfe, #3b82f6 55%, #1d4ed8); color: #fff; }
.coin--4 { background: radial-gradient(circle at 32% 28%, #e9d5ff, #a855f7 55%, #6b21a8); color: #fff; }
.coin--5 { background: radial-gradient(circle at 32% 28%, #fde68a, #f59e0b 55%, #b45309); }

.coin.is-active {
  filter: none;
  transform: translate3d(0, -4px, 0) scale(1.06);
  box-shadow: 0 6px 0 rgba(0, 0, 0, .4), 0 0 0 3px var(--gold);
}

.coin:active { transform: scale(.94); }

.tray__ops { display: flex; align-items: center; gap: 10px; }

.tray__staked      { text-align: right; }
.tray__stakedLabel { display: block; font-size: 10px; color: var(--ink-faint); }

.tray__stakedValue {
  font-weight: 800;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

/* ═══ กล่องแจ้งเตือน ════════════════════════════════════════ */
.toast-stack {
  position: fixed;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  z-index: 90;
  display: grid;
  gap: 8px;
  width: min(420px, calc(100% - 24px));
  pointer-events: none;
}

.toast {
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
  box-shadow: var(--shadow);
  animation: toastIn .26s cubic-bezier(.2, 1.4, .4, 1);
  backdrop-filter: blur(8px);
}

.toast--ok   { background: rgba(34, 197, 94, .92);  color: #04240f; }
.toast--bad  { background: rgba(244, 63, 94, .92);  color: #2b0009; }
.toast--warn { background: rgba(251, 191, 36, .94); color: #2a1a00; }
.toast.is-out { animation: toastOut .22s ease-in forwards; }

@keyframes toastIn {
  from { opacity: 0; transform: translate3d(0, -16px, 0) scale(.94); }
  to   { opacity: 1; transform: none; }
}

@keyframes toastOut {
  to { opacity: 0; transform: translate3d(0, -12px, 0); }
}

/* ═══ โมดัล ═════════════════════════════════════════════════ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 6, 12, .72);
  backdrop-filter: blur(4px);
  animation: fadeIn .18s ease-out;
}

.modal__panel {
  position: relative;
  width: min(440px, 100%);
  max-height: 88dvh;
  overflow-y: auto;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  box-shadow: var(--shadow);
  animation: modalIn .24s cubic-bezier(.2, 1.3, .4, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: translate3d(0, 18px, 0) scale(.96); }
  to   { opacity: 1; transform: none; }
}

.modal__x {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--ink-dim);
  font-size: 15px;
}

.modal h2 { margin: 0 0 4px; font-size: 19px; }
.modal p  { margin: 0 0 14px; color: var(--ink-dim); font-size: 14px; line-height: 1.6; }

/* ── การ์ดบัญชีรับเงิน ───────────────────────────────────────── */
.bankcard {
  display: grid;
  gap: 8px;
  padding: 16px;
  margin-bottom: 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(251, 191, 36, .16), rgba(0, 0, 0, .26));
  border: 1px solid rgba(251, 191, 36, .34);
}

.bankcard__row   { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.bankcard__key   { color: var(--ink-dim); }
.bankcard__value { font-weight: 700; text-align: right; word-break: break-all; }

.bankcard__num {
  font-size: 22px;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
  -webkit-user-select: text;
  user-select: text;
}

.drop {
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 22px;
  border: 2px dashed var(--line);
  border-radius: 14px;
  color: var(--ink-dim);
  font-size: 14px;
  text-align: center;
  transition: border-color .18s, background .18s;
}

.drop.is-hot { border-color: var(--accent); background: rgba(56, 189, 248, .08); }
.drop__icon  { font-size: 30px; }

.drop__preview {
  max-height: 190px;
  border-radius: 10px;
  margin: 0 auto;
}

/* ⭐ วงกลมหมุนตอนกำลังตรวจสลิป — SlipOK ใช้เวลา 2-3 วินาที ห้ามปล่อยจอเงียบ */
.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid rgba(255, 255, 255, .18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ⭐ ฝนเหรียญตอนเติมเงินสำเร็จ / ชนะรอบใหญ่ */
.rain {
  position: fixed;
  inset: 0;
  z-index: 95;
  pointer-events: none;
  overflow: hidden;
}

.rain__coin {
  position: absolute;
  top: -40px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #fde68a, var(--gold) 45%, #b45309);
  animation: fall linear forwards;
}

@keyframes fall {
  to { transform: translate3d(0, 110vh, 0) rotate(540deg); opacity: .2; }
}

/* ═══ ผังจอแต่ละขนาด ═══════════════════════════════════════ */

/* ── มือถือแนวตั้ง (ค่าเริ่มต้น) ─────────────────────────────
   ไลฟ์ติดบน · กระดานเต็มจอ · แถบเหรียญลอยล่าง                */
.live__stage { height: 34dvh; min-height: 190px; }

/* ── มือถือแนวนอน ────────────────────────────────────────────
   ⚠️ จอเตี้ยมาก (< 480px) — ไลฟ์เต็มจอเป็นพื้นหลัง
      กระดานลอยทับแบบโปร่ง ไม่งั้นไม่เหลือที่ให้อะไรเลย        */
@media (orientation: landscape) and (max-height: 520px) {
  .live { grid-template-rows: 1fr; }

  .live__stage {
    position: fixed;
    inset: 0;
    height: 100dvh;
    z-index: 0;
  }

  .live__panel {
    position: relative;
    z-index: 2;
    grid-template-columns: 1fr;
    align-content: end;
    background: linear-gradient(0deg, rgba(7, 10, 16, .88), transparent);
  }

  .player, .road, .board, .tray {
    background: rgba(7, 10, 16, .62);
    backdrop-filter: blur(8px);
  }

  .road { display: none; }               /* พื้นที่ไม่พอ — เค้าไพ่ดูตอนตั้งจอได้ */
  .board { min-height: 130px; }
  .gate  { min-height: 62px; padding: 6px; }
  .gate__icon { font-size: 20px; }
  .chat { display: none; }               /* แชทบังกระดานตอนจอเตี้ย */
}

/* ── แท็บเล็ต / iPad ─────────────────────────────────────────── */
@media (min-width: 768px) {
  .live__stage { height: 42dvh; }
  .live__panel { padding: 14px; gap: 12px; }
  .board       { grid-template-columns: 1fr 1fr 1fr; min-height: 260px; gap: 12px; }
  .gate        { min-height: 130px; }
  .gate__icon  { font-size: 42px; }
  .gate__name  { font-size: 18px; }
  .coin        { width: 58px; height: 58px; font-size: 14px; }
  .chat        { width: min(40%, 320px); }
}

/* ── PC ──────────────────────────────────────────────────────
   ไลฟ์ซ้าย 2 ส่วน · กระดาน+กล่องผู้เล่นขวา 1 ส่วน            */
@media (min-width: 1280px) {
  .live {
    grid-template-rows: 1fr;
    grid-template-columns: 2fr minmax(420px, 1fr);
    height: 100dvh;
    overflow: hidden;
  }

  .live__stage { height: 100dvh; }

  .live__panel {
    overflow-y: auto;
    padding: 16px;
    gap: 14px;
    border-left: 1px solid var(--line);
    background: var(--bg-2);
  }

  .board      { min-height: 300px; }
  .gate       { min-height: 150px; }
  .gate__icon { font-size: 48px; }
  .chat       { width: min(34%, 340px); }
}
