/* Pingoplayroom — style.css (rebuild, minimal dark theme) */
:root {
  --bg:      #0e0f13;
  --card:    #181a20;
  --panel:   #1e2027;
  --text:    #f1e8d2;
  --muted:   #aab0bb;
  --primary: #c9a24a;
  --primary-h:#d8b057;
  --danger:  #e0584d;
  --ok:      #39c07f;
  --warn:    #f0c049;
  --border:  #343742;
  --gold:    #f3de93;
  --gold-dim: rgba(240,217,138,.4);
  --felt-rim: #c9a24a;
  /* table felt colour (default green) — overridden by [data-table] */
  --felt-a: #1aa05f;
  --felt-b: #0a6b3d;
  --felt-c: #053b22;
}
[data-table="pink"]  { --felt-a:#d65b94; --felt-b:#9b2d5e; --felt-c:#5e1538; }
[data-table="blue"]  { --felt-a:#2f7fc4; --felt-b:#10487f; --felt-c:#06294d; }
[data-table="black"] { --felt-a:#3c3c3c; --felt-b:#1c1c1c; --felt-c:#0a0a0a; }

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "Noto Sans Thai", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; row-gap: 6px;
  padding: 12px 20px;
  background: #0b1220;
  border-bottom: 1px solid var(--border);
}
.logo { font-weight: 700; font-size: 18px; }
.top-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

/* ===================== coins / wallet ===================== */
.coin-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px;
  background: linear-gradient(180deg, #3a2e0c, #2a2208);
  border: 1px solid #d4af37; color: #f5d97a;
  font-weight: 700; font-size: 14px; cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.coin-chip:hover { transform: translateY(-1px); box-shadow: 0 3px 12px rgba(212,175,55,.3); }
.coin-ico { font-size: 15px; line-height: 1; }

/* กล่องข้อความจากทีมงาน (inbox) */
#inboxBtn { position: relative; }
.inbox-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 16px; height: 16px; padding: 0 4px; box-sizing: border-box;
  background: #e0483d; color: #fff; font-size: 11px; font-weight: 700;
  line-height: 16px; text-align: center; border-radius: 9px;
}
.inbox-list { max-height: 60vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.inbox-item {
  position: relative;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px;
}
.inbox-item.unread { border-color: var(--gold); }
.inbox-meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; padding-right: 22px; }
.inbox-body { font-size: 15px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.inbox-del {
  position: absolute; top: 8px; right: 8px;
  background: none; border: none; color: var(--muted);
  font-size: 15px; line-height: 1; cursor: pointer; padding: 2px 6px; border-radius: 6px;
}
.inbox-del:hover { color: #e0483d; background: rgba(224,72,61,.12); }
.inbox-tools { display: flex; justify-content: flex-end; margin-bottom: 2px; }
.inbox-clear {
  background: none; border: 1px solid var(--border); color: var(--muted);
  font-size: 13px; cursor: pointer; padding: 4px 10px; border-radius: 8px;
}
.inbox-clear:hover { color: #e0483d; border-color: #e0483d; }

.wallet-panel {
  position: fixed; top: 60px; right: 16px; z-index: 300;
  width: 240px; padding: 16px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.55);
}
.wallet-head {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; margin-bottom: 10px;
}
.wallet-close {
  background: none; border: none; color: var(--muted);
  font-size: 16px; cursor: pointer; line-height: 1; padding: 2px 6px; border-radius: 6px;
}
.wallet-close:hover { background: rgba(255,255,255,.1); color: var(--text); }
.wallet-balance {
  font-size: 26px; font-weight: 800; color: #f5d97a; margin: 4px 0 8px;
}
.wallet-note { font-size: 13px; margin: 0 0 12px; }

.pcoin {
  margin-left: 10px; font-size: 13px; font-weight: 700;
  color: #f5d97a; white-space: nowrap; flex: 0 0 auto;
}
.status {
  font-size: 13px; color: var(--muted);
  padding: 4px 10px; border-radius: 999px; background: #0b1220;
  border: 1px solid var(--border);
}
.status.ok   { color: var(--ok);   border-color: var(--ok); }
.status.warn { color: var(--warn); border-color: var(--warn); }

.container { max-width: 760px; margin: 0 auto; padding: 24px 16px; }
/* computer mode (mouse, wide): use more of the screen so cards/table aren't tiny.
   pointer:fine excludes touch iPad; the arrange screen still fits ONCE then locks. */
@media (min-width: 1000px) and (pointer: fine) {
  .container { max-width: 1040px; }
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
}
.hidden { display: none !important; }

h1 { font-size: 22px; margin: 0 0 18px; }
h2 { font-size: 16px; margin: 0 0 10px; }
.muted { color: var(--muted); font-size: 14px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input {
  width: 100%; padding: 11px 12px;
  background: #0b1220; color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 15px;
}
input:focus { outline: none; border-color: var(--primary); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 8px; }
.panel { background: var(--panel); border-radius: 12px; padding: 16px; }
@media (max-width: 560px) { .two-col { grid-template-columns: 1fr; } }

.btn {
  display: inline-block; width: 100%;
  padding: 11px 14px; margin-top: 6px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-h); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: rgba(239,68,68,.12); }
.btn.small { width: auto; padding: 8px 14px; font-size: 13px; margin: 0; }

.error-text { color: var(--danger); font-size: 14px; min-height: 18px; margin: 14px 0 0; }

/* lobby */
.room-info {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  background: var(--panel); border-radius: 12px; padding: 16px; margin-bottom: 20px;
}
.big-code {
  font-size: 28px; font-weight: 800; letter-spacing: 4px;
  font-family: "Segoe UI Mono", ui-monospace, monospace;
}
.room-info .btn { margin-left: auto; }

.player-list { list-style: none; padding: 0; margin: 0 0 16px; }
.player {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: 10px;
  background: var(--panel); margin-bottom: 8px;
}
.player.me { outline: 1px solid var(--primary); }
.player.offline { opacity: .55; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.dot.on  { background: var(--ok);  box-shadow: 0 0 8px var(--ok); }
.dot.off { background: var(--muted); }
.pname { font-weight: 600; }
.ptag { margin-left: auto; font-size: 12px; color: var(--muted); }
.kick-btn { flex: 0 0 auto; }

.actions { display: flex; gap: 12px; margin-top: 8px; }
.actions .btn { width: auto; }

/* ===================== game (Phase 2) ===================== */
.game-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.game-head h1 { margin-bottom: 12px; }
.game-msg, #gameMsg { white-space: nowrap; }

.row-zone { margin: 10px 0 14px; }
.row-label {
  font-size: 13px; color: var(--muted); margin-bottom: 6px;
  display: flex; align-items: center; gap: 8px;
}
.row-label small { color: var(--muted); opacity: .75; }
.row-eval { margin-left: auto; font-size: 12px; color: var(--muted); }
.row-eval.ok { color: var(--ok); font-weight: 600; }

.slots {
  display: flex; flex-wrap: wrap; gap: 6px;
  min-height: 76px; padding: 8px;
  background: #0b1220; border: 1px dashed var(--border); border-radius: 10px;
}
.slots.drop-hover { border-color: var(--primary); background: #0d1a33; }
.hand-zone .slots { background: var(--panel); border-style: solid; }

/* playing card */
.pcard {
  position: relative;
  width: 46px; height: 64px;
  background: #f8fafc; color: #0f172a;
  border-radius: 8px; border: 1px solid #cbd5e1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 800; cursor: grab; user-select: none;
  box-shadow: 0 1px 2px rgba(0,0,0,.35);
}
.pcard.red { color: #dc2626; }
.pcard .pc-rank { font-size: 18px; line-height: 1; }
.pcard .pc-suit { font-size: 18px; line-height: 1; }
.pcard.dragging { opacity: .4; }
.pcard.selected { outline: 3px solid var(--primary); transform: translateY(-3px); }
.pcard:active { cursor: grabbing; }
.pcard.small { width: 38px; height: 52px; cursor: default; }
.pcard.small .pc-rank, .pcard.small .pc-suit { font-size: 14px; }

/* submit progress */
.submit-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: 10px;
  background: var(--panel); margin-bottom: 8px; font-weight: 600;
}
.submit-row.done { color: var(--ok); }

/* reveal — one row per player: [name | top | middle | bottom], 13 cards in a line */
.reveal-board {
  display: grid;
  grid-template-columns: minmax(44px, max-content) max-content max-content max-content;
  align-items: start; gap: 5px;
  background: var(--panel); border: 1px solid var(--gold-dim);
  border-radius: 10px; padding: 6px 5px; margin-bottom: 7px;
  max-width: 100%; overflow-x: auto;   /* never push the page wider; scroll inside if needed */
}
.reveal-board.me { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold-dim); }
.reveal-board.sweep-win { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-dim); }
.rb-namecell { min-width: 52px; }
.rb-name { font-weight: 700; color: var(--gold); font-size: 13px; line-height: 1.2; }
.rb-fault { display: block; color: var(--danger); font-size: 11px; font-weight: 700; margin-top: 1px; }
/* สรุปผลรอบใต้ชื่อ (จอเปิดไพ่): ตัวเลขใหญ่ราวเลขบนไพ่ สี +เขียว/−แดง (จาก .pos/.neg)
 * เว้นจากขอบซ้ายนิดหน่อย ไม่ให้ตัวเลขชิดกรอบ */
.rb-score { font-size: 12px; margin-top: 3px; padding-left: 7px; }
#revealBoards .rb-score strong { font-size: calc(var(--rbcard, 28px) * 0.72); font-weight: 800; }
#revealBoards .rb-score .muted { font-size: 11px; }
.rb-row { display: flex; flex-direction: column; gap: 3px; padding: 3px 4px; border-radius: 6px; transition: background .25s; }
.rb-row.active { background: rgba(243,222,147,.12); }
.rb-pts { font-weight: 700; }
/* reveal cards — ไพ่ 13 ใบต้องเต็มบรรทัดพอดีทุกจอ: ขนาดไพ่คิดจากความกว้างจอจริง
 * --rbcard = (100vw - พื้นที่ชื่อ+ช่องไฟ+ขอบ) / 13 (มี min/max กันเล็ก-ใหญ่เกิน)
 * แต่ละช่วงจอ override เฉพาะตัวเลขสำรองพื้นที่ — ไม่มีไพ่โดนตัดขอบอีก */
#revealBoards { --rbcard: clamp(12px, calc((100vw - 160px) / 13), 30px); }
#revealBoards .pcard.small {
  /* กล่องไพ่เล็กลงนิด (×0.92) แต่ตัวเลข/ดอกขนาดเท่าเดิม (ฟอนต์คิดจาก var เต็ม) */
  width: calc(var(--rbcard) * 0.92);
  height: calc(var(--rbcard) * 1.34);
  border-radius: 4px; padding: 1px;
}
#revealBoards .pcard.small .pc-rank { font-size: calc(var(--rbcard) * 0.52); }
#revealBoards .pcard.small .pc-suit { font-size: calc(var(--rbcard) * 0.46); }
.reveal-banner {
  text-align: center; font-weight: 700; font-size: 16px;
  padding: 10px 14px; border-radius: 10px; margin: 0 0 12px;
  background: linear-gradient(180deg, #f3de93, #c9a24a); color: #3a2c08;
}
.reveal-banner.derby { background: linear-gradient(180deg, #f3b04a, #c9601a); color: #2a1402; }
.rb-label { font-size: 10px; color: var(--muted); white-space: nowrap; }
.rb-label small { color: var(--text); font-weight: 600; }
/* all cards of a hand in a single straight line */
.rb-cards { display: flex; gap: 2px; opacity: 0; transition: opacity .3s; }
.rb-row.active .rb-cards { opacity: 1; }

/* scoring settings (collapsible) */
.scoring-details {
  margin: 10px 0;
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
.scoring-details summary {
  padding: 10px 14px; cursor: pointer; font-size: 13px; color: var(--muted);
  user-select: none; list-style: none;
}
.scoring-details summary::-webkit-details-marker { display: none; }
.scoring-details[open] summary { color: var(--text); border-bottom: 1px solid var(--border); }
.sc-body { padding: 12px 14px; }
.sc-section { margin-bottom: 12px; }
.sc-title { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.sc-grid { display: flex; flex-direction: column; gap: 8px; }
.sc-grid label {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--text);
}
.sc-grid .ex { display: inline-flex; gap: 2px; flex: 0 0 auto; width: 118px; font-size: 15px; }
.sc-grid .exn { flex: 1; color: var(--muted); }
.sc-grid input[type="number"] {
  width: 56px; flex: 0 0 auto; padding: 6px 7px; font-size: 14px;
  background: #0b0c10; color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
}
.sc-grid input[type="number"]:focus { border-color: var(--primary); outline: none; }
/* mini example card */
.mc {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 15px; height: 21px; padding: 0 2px;
  background: #fdfcf7; color: #161310; border: 1px solid #d8cfa8;
  border-radius: 3px; font-size: 11px; font-weight: 700; line-height: 1;
}
.mc.r { color: #c8102e; }

/* room creation — suit tiebreak toggle */
.toggle-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; cursor: pointer; margin: 10px 0;
}
.toggle-label input[type="checkbox"] {
  width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary);
}

/* lobby settings badge */
.settings-badge {
  font-size: 13px; color: var(--warn);
  background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.35);
  border-radius: 8px; padding: 6px 12px; margin-bottom: 12px;
}

/* lobby score badge */
.pscore {
  margin-left: auto; font-weight: 700; font-size: 14px; color: var(--muted);
}
.pscore:empty { display: none; }

/* scoreboard / round history */
.scoreboard {
  margin: 16px 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.scoreboard > summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  list-style: none;
}
.scoreboard > summary::-webkit-details-marker { display: none; }
.sb-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 13px;
}
.sb-table th, .sb-table td {
  padding: 6px 8px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.sb-table th { color: var(--muted); font-weight: 600; }
.sb-table th.me { color: var(--primary); }
.sb-table .sb-round, .sb-table tfoot td:first-child { color: var(--muted); }
.sb-table tfoot td { border-bottom: none; border-top: 2px solid var(--border); }
.sb-table tbody tr:last-child td { border-bottom: none; }

/* summary view */
.summary-list {
  list-style: none; padding: 0; margin: 14px 0;
}
.summary-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--gold-dim); margin-bottom: 8px;
}
.summary-row.me { border-color: var(--gold); }
.sum-rank  { font-size: 22px; min-width: 36px; }
.sum-name  { flex: 1; font-weight: 600; }
.sum-score { font-weight: 700; font-size: 16px; }

/* reveal — scoring (Phase 3) */
.rb-score {
  font-size: 14px; color: var(--muted); margin-bottom: 8px;
}
.pos { color: var(--ok); }
.neg { color: var(--danger); }
.neu { color: var(--muted); }

/* round summary + ready */
.round-score-list { list-style: none; padding: 0; margin: 12px 0; }
.rsl-row {
  display: grid; grid-template-columns: 22px 1fr auto auto; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px; background: var(--panel); margin-bottom: 8px;
}
.rsl-row.me { border: 1px solid var(--gold); }
.rsl-ready { color: var(--ok); font-weight: 700; text-align: center; }
.rsl-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rsl-delta { font-weight: 700; min-width: 34px; text-align: right; }
.rsl-total { color: var(--muted); font-size: 13px; white-space: nowrap; }
.ready-bar { display: flex; align-items: center; gap: 12px; justify-content: center; margin: 14px 0; flex-wrap: wrap; }
.ready-bar .btn { min-width: 170px; }
#readyInfo { font-weight: 600; color: var(--gold); }

.pair-section { margin-top: 20px; }
.pair-section-title { font-size: 15px; color: var(--muted); margin: 0 0 10px; }

.pair-table {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 10px;
}
.pt-header {
  font-weight: 700; margin-bottom: 8px;
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
}
.badge-sweep {
  font-size: 12px; font-weight: 600;
  background: #854d0e; color: #fef9c3;
  padding: 2px 8px; border-radius: 99px;
}
.pt-row {
  font-size: 13px; padding: 4px 8px; border-radius: 6px; margin: 3px 0;
}
.pt-win-a { background: rgba(34,197,94,.12); }
.pt-win-b { background: rgba(59,130,246,.12); }
.pt-tie   { color: var(--muted); }
.pt-total {
  font-size: 13px; margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--border);
}

@media (max-width: 560px) {
  .rb-label { font-size: 9px; }
  .rb-namecell { min-width: 40px; }
  .rb-name { font-size: 12px; }
  /* จอ ≤560px: ช่องไฟ/ชื่อเล็กลง → สำรองพื้นที่น้อยลง ไพ่ได้ใหญ่ขึ้น */
  #revealBoards { --rbcard: clamp(12px, calc((100vw - 134px) / 13), 24px); }
}

/* ===================== deal animation ===================== */
@keyframes dealIn {
  from { opacity: 0; transform: translateY(-44px) scale(.8) rotate(-7deg); }
  to   { opacity: 1; transform: none; }
}
.pcard.deal-in { animation: dealIn .34s ease both; }

/* ===================== touch drag ghost (mobile) ===================== */
.pcard { touch-action: none; }

.touch-ghost {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  will-change: transform;   /* ยกขึ้น GPU layer — ลากลื่นบน Safari/iOS */
  opacity: 0.88;
  transform: scale(1.08) rotate(-4deg);
  box-shadow: 0 10px 30px rgba(0,0,0,.55);
  border-radius: 8px;
}

/* ===================== WebRTC video bar ===================== */
/* Reserve space so the fixed bar never hides the bottom of the page. */
body:has(#videoBar:not(.hidden)) {
  padding-bottom: 116px;
}
@media (max-width: 560px) {
  body:has(#videoBar:not(.hidden)) { padding-bottom: 150px; }
}

.video-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(11, 18, 32, .92);
  border-top: 1px solid var(--border);
  -webkit-backdrop-filter: blur(6px);   /* Safari / iOS */
  backdrop-filter: blur(6px);
}

.video-tiles {
  display: flex;
  gap: 8px;
  flex: 1;
  overflow-x: auto;
  padding-bottom: 2px;
}

.video-tile {
  position: relative;
  flex: 0 0 auto;
  width: 112px;
  height: 84px;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border);
}

.video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}
.video-tile audio { display: none; }

.video-tile .tile-placeholder {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: var(--muted);
  background: #0b1220;
}
.video-tile.cam-off video { visibility: hidden; }
.video-tile.cam-off .tile-placeholder { display: flex; }

.video-tile .tile-name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,.75));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.video-tile.connecting { border-color: var(--warn, #d6a23a); }
.video-tile.lost       { border-color: var(--danger, #c0392b); opacity: .6; }

.video-ctrl {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

.vid-btn {
  border: 1px solid var(--border);
  background: var(--panel, #182236);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.vid-btn:hover { background: rgba(255,255,255,.08); }
.vid-btn.on {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

@media (max-width: 560px) {
  .video-tile { width: 92px; height: 68px; }
  .vid-btn { padding: 8px; font-size: 12px; }
}

/* ============================================================
 * Casino theme v2 — luxe felt + gold (Phase 1 redesign)
 * Overrides earlier rules; keeps all element IDs/classes intact.
 * ==========================================================*/
html { -webkit-text-size-adjust: 100%; }
body {
  background:
    radial-gradient(ellipse at 50% -8%, #24262e 0%, #131419 55%, #0a0b0e 100%);
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  background: rgba(10, 11, 14, .9);
  border-bottom: 1px solid var(--gold-dim);
  padding-top: calc(12px + env(safe-area-inset-top));
  -webkit-backdrop-filter: blur(6px);   /* Safari / iOS */
  backdrop-filter: blur(6px);
}
.logo {
  font-family: Georgia, "Noto Serif Thai", serif;
  color: var(--gold); letter-spacing: .3px;
}
.container {
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

/* gold primary + premium buttons */
.btn.primary {
  background: linear-gradient(180deg, #f3de93, #c9a24a);
  border-color: #c9a24a; color: #3a2c08; font-weight: 700;
}
.btn.primary:hover { background: linear-gradient(180deg, #f7e6a6, #d8b057); }
.vid-btn.on { color: #3a2c08; background: linear-gradient(180deg, #f3de93, #c9a24a); border-color: #c9a24a; }

/* premium playing card */
.pcard {
  width: 58px; height: 82px;
  background: #fdfcf7; border: 1px solid #d8cfa8; color: #161310;
  box-shadow: 0 2px 4px rgba(0,0,0,.4);
}
.pcard.red { color: #c8102e; }
.pcard.selected { outline: 3px solid var(--gold); }

/* suit colours — default 2-color (red / black) */
.pcard.s-h, .pcard.s-d { color: #c8102e; }
.pcard.s-s, .pcard.s-c { color: #161310; }
/* 4-color deck (opt-in): club = green, diamond = blue */
[data-deck="4"] .pcard.s-c { color: #1a7d3f; }
[data-deck="4"] .pcard.s-d { color: #1f63d6; }

.btn.small.active { background: linear-gradient(180deg, #f3de93, #c9a24a); color: #3a2c08; border-color: #c9a24a; font-weight: 700; }

/* topbar settings gear */
.icon-btn {
  background: rgba(255,255,255,.06); border: 1px solid var(--gold-dim);
  color: var(--gold); font-size: 16px; line-height: 1;
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: rgba(255,255,255,.12); }

/* settings modal */
.modal {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(0,0,0,.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 24px 14px; overflow-y: auto;
}
.modal-card {
  width: 100%; max-width: 460px;
  background: var(--card); border: 1px solid var(--gold-dim);
  border-radius: 16px; padding: 18px 18px 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 16px; margin-bottom: 6px; }
.set-section { font-size: 14px; color: var(--gold); margin: 18px 0 10px; border-bottom: 1px solid var(--gold-dim); padding-bottom: 6px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.seg { display: flex; gap: 8px; align-items: center; }
.swatch { width: 30px; height: 30px; border-radius: 8px; border: 2px solid transparent; cursor: pointer; padding: 0; }
.swatch.active { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(243,222,147,.3); }

/* big, sharp rank + suit — easier to read for older players */
.pcard .pc-rank { font-size: 33px; font-weight: 800; letter-spacing: -.5px; }
.pcard .pc-suit { font-size: 31px; line-height: 1; margin-top: 1px; }
.pcard.small { width: 48px; height: 67px; }
.pcard.small .pc-rank, .pcard.small .pc-suit { font-size: 23px; }

/* the green felt table that holds the three rows */
.felt-table {
  background: radial-gradient(ellipse at 50% 26%, var(--felt-a) 0%, var(--felt-b) 50%, var(--felt-c) 100%);
  border: 3px solid var(--felt-rim);
  border-radius: 16px;
  padding: 12px 12px 4px;
  margin: 10px 0 14px;
  box-shadow: inset 0 0 34px rgba(0,0,0,.4);
}
.felt-table .row-zone { margin: 0 0 10px; }
.felt-table .row-label { color: #e7d39a; font-weight: 600; }
.felt-table .row-label small { color: #cdbb86; }
.felt-table .row-eval { color: #ffe9a8; }
.felt-table .row-eval.ok { color: #ffe9a8; }
.felt-table .slots {
  background: rgba(0,0,0,.22);
  border: 1px solid rgba(240,217,138,.32);
  border-radius: 10px;
  min-height: 94px;
}
.felt-table .slots.drop-hover { border-color: var(--gold); background: rgba(0,0,0,.34); }
.arrange-hint { text-align: center; }

/* dotted card placeholders (one per empty position in a row) */
.cardslot {
  width: 58px; height: 82px; flex: 0 0 auto;
  border-radius: 8px;
  border: 2px dashed rgba(240,217,138,.45);
  background: rgba(0,0,0,.14);
  pointer-events: none;
}

/* hand zone (off the felt) */
.hand-zone .slots {
  background: rgba(255,255,255,.05);
  border: 1px solid var(--gold-dim);
}

/* lobby + cards luxe (shared classes) */
.room-info { background: linear-gradient(135deg, #16241b, #0e1813); border: 1px solid var(--gold-dim); }
.big-code { color: #fff; }
.player { background: rgba(255,255,255,.04); border: 1px solid rgba(240,217,138,.16); }
.player.me { outline: 1px solid var(--gold); }
.coin-chip { background: linear-gradient(180deg, #f3de93, #c9a24a); border-color: #b8902f; color: #3a2c08; }

/* ===================== lobby — invite pass + seats ===================== */
.invite-pass {
  background: linear-gradient(135deg, #1e2027, #15161b);
  border: 1px solid var(--felt-rim);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 18px;
}
.pass-head { color: var(--gold); font-weight: 600; font-size: 14px; margin-bottom: 12px; }
.pass-codes { display: flex; gap: 12px; margin-bottom: 14px; }
.pass-codes > div {
  flex: 1; min-width: 0; text-align: center;
  background: rgba(0,0,0,.28); border: 1px solid var(--gold-dim);
  border-radius: 10px; padding: 9px 12px;
}
.pass-codes .muted { font-size: 11px; display: block; margin-bottom: 3px; }
.pass-codes .big-code { color: #fff; font-size: 23px; letter-spacing: 3px; }
.invite-pass .btn.primary { width: 100%; }

.seats-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.seats-head .muted { color: var(--gold); font-weight: 600; font-size: 14px; }

.lobby-felt {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(243,222,147,.10), transparent 62%),
    linear-gradient(165deg, #1c1e25, #111217);
  border: 1px solid var(--gold-dim);
  border-radius: 16px;
  padding: 22px 12px;
  margin-bottom: 18px;
}
.seats { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: space-around; gap: 16px 6px; }
.seat { display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; width: 74px; }
.seat.offline { opacity: .5; }
.ava {
  width: 50px; height: 50px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 20px; color: #16110a;
  border: 2px solid var(--gold); position: relative;
}
.ava-empty { background: rgba(255,255,255,.05); border: 2px dashed var(--gold-dim); color: var(--gold); }
.seat.me .ava { box-shadow: 0 0 0 3px rgba(243,222,147,.35); }
.seat-name { font-size: 13px; font-weight: 600; color: var(--text); text-align: center; max-width: 82px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-crown { position: absolute; top: -13px; left: 50%; transform: translateX(-50%); font-size: 14px; }
.seat-kick {
  position: absolute; top: -5px; right: -5px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--danger); color: #fff; border: 1px solid var(--text);
  font-size: 11px; line-height: 1; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.seat-beg {
  position: absolute; top: -5px; left: -5px; width: 22px; height: 22px; border-radius: 50%;
  background: rgba(20,16,8,.85); color: #fff; border: 1px solid var(--gold-dim);
  font-size: 11px; line-height: 1; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center; opacity: .92;
  box-shadow: 0 1px 4px rgba(0,0,0,.5);
}
.seat-beg:hover { border-color: var(--gold); transform: scale(1.08); }
.seat-beg.on { background: var(--primary); color: #1a1305; opacity: 1; border-color: var(--gold); box-shadow: 0 0 0 2px rgba(243,222,147,.4); }
.seat-begbadge {
  margin-top: 2px; font-size: 10px; font-weight: 700; line-height: 1;
  color: #1a1305; background: var(--primary); border-radius: 8px;
  padding: 2px 6px; white-space: nowrap;
}
.seat-dot { position: absolute; bottom: -1px; right: 1px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid #0a6b3d; }
.seat-dot.on { background: var(--ok); }
.seat-dot.off { background: var(--muted); }

/* video bar relocated — top strip (portrait), left column (landscape) */
.stage { width: 100%; }
.video-bar {
  position: static;
  left: auto; right: auto; bottom: auto;
  width: 100%;
  border-top: none;
  border-bottom: 1px solid var(--gold-dim);
  background: rgba(8, 12, 9, .85);
}
body:has(#videoBar:not(.hidden)) { padding-bottom: 0; }

@media (orientation: landscape) {
  .stage { display: flex; align-items: stretch; }
  .stage > .container { flex: 1 1 auto; min-width: 0; }
  .video-bar {
    width: 120px;
    flex-direction: column;
    align-items: stretch;
    border-bottom: none;
    border-right: 1px solid var(--gold-dim);
    overflow-y: auto;
    padding-left: max(8px, env(safe-area-inset-left));
  }
  .video-bar .video-tiles { flex-direction: column; overflow-x: hidden; overflow-y: auto; }
  .video-bar .video-tile { width: 100%; height: 78px; }
  .video-bar .video-ctrl { flex-direction: column; }
}

/* ---- arrange view: fluid card size (driven by game.js fitArrange) so the
   whole hand-arranging screen fits on one screen without scrolling ---- */
#arrangeView .pcard:not(.small),
#arrangeView .cardslot {
  width: var(--card-w, 58px);
  height: calc(var(--card-w, 58px) * 1.4);
}
#arrangeView .pcard .pc-rank { font-size: calc(var(--card-w, 58px) * 0.57); }
#arrangeView .pcard .pc-suit { font-size: calc(var(--card-w, 58px) * 0.53); }
/* rows hug the card height instead of a fixed min-height (saves vertical space) */
#arrangeView .slots,
#arrangeView .felt-table .slots { min-height: 0; }

/* ---- โหมดโฟกัสตอนจัดไพ่ (arrange focus) ----
 * ระหว่างจัดไพ่ ซ่อนทุกอย่างยกเว้นแถบวิดีโอ ให้ fitArrange ได้พื้นที่สูงสุด
 * → ไพ่ใหญ่ขึ้นทุกจอ (มือถือ/iPad/คอม)
 * ใช้ :has() (Chrome 105+/iOS 15.4+) — เบราว์เซอร์เก่าแค่ไม่ได้โหมดนี้ ไม่พังอะไร
 * พอส่งไพ่/จบรอบ ทุกอย่างกลับมาเอง เพราะ #arrangeView ถูก hidden */
body:has(#game:not(.hidden) #arrangeView:not(.hidden)) .topbar { display: none; }
body:has(#game:not(.hidden) #arrangeView:not(.hidden)) #game .game-head { display: none; }
body:has(#game:not(.hidden) #arrangeView:not(.hidden)) .container { padding-top: 4px; padding-bottom: 4px; }
body:has(#game:not(.hidden) #arrangeView:not(.hidden)) #game.card { padding: 8px; margin-bottom: 4px; }
body:has(#game:not(.hidden) #arrangeView:not(.hidden)) #arrangeView .felt-table { padding: 8px 8px 2px; margin: 4px 0 8px; }
/* Safari: กันหน้าเด้งยาง/เลื่อนทั้งหน้าระหว่างลากไพ่ (อาการ "ไม่ลื่น" บน iOS) */
html:has(#game:not(.hidden) #arrangeView:not(.hidden)),
body:has(#game:not(.hidden) #arrangeView:not(.hidden)) {
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

/* responsive — phones */
@media (max-width: 430px) {
  .container { padding: 14px 12px; }
  /* portrait phones: tiny cards + tight spacing so all 13 fit in one line, none cut off */
  .reveal-board { padding: 4px 3px; gap: 4px; }
  .rb-row { padding: 2px 1px; }
  .rb-cards { gap: 1px; }
  .rb-namecell { min-width: 32px; }
  .rb-name { font-size: 11px; }
  /* จอเล็กสุด (≤430px): สำรองพื้นที่ต่ำสุด — เครื่อง 320px ก็ครบ 13 ใบ */
  #revealBoards { --rbcard: clamp(12px, calc((100vw - 104px) / 13), 22px); }
  h1 { font-size: 20px; }
}

/* portrait phones: tighten the arrange chrome so cards can stay as large as possible */
@media (max-width: 560px) and (orientation: portrait) {
  .stage > .container { padding-top: 8px; padding-bottom: 8px; }
  #game.card { padding: 10px; margin-bottom: 8px; }
  #game .game-head h1 { margin-bottom: 4px; font-size: 18px; }
  #arrangeView .row-zone,
  #arrangeView .felt-table .row-zone { margin: 0 0 4px; }
  #arrangeView .row-label { font-size: 11px; margin-bottom: 2px; }
  #arrangeView .felt-table { padding: 6px 8px 2px; margin: 4px 0 6px; }
  #arrangeView .slots,
  #arrangeView .felt-table .slots { gap: 4px; padding: 4px; }
  #arrangeView .actions { margin-top: 4px; }
  #arrangeView #foulWarn { margin: 2px 0; font-size: 12px; }
}

/* ============================================================
 * Phase 3 — video paywall + screen effects
 * ==========================================================*/

/* pay-to-open video button + "video on" tag */
.vid-btn.gold {
  background: linear-gradient(180deg, #f3de93, #c9a24a);
  border-color: #c9a24a; color: #3a2c08;
}
.vid-btn.gold:hover { background: linear-gradient(180deg, #f6e6a8, #d4af52); }
.vid-btn:disabled { opacity: .6; cursor: default; }
.vid-cost { font-weight: 700; }
.vid-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 10px; font-size: 12px; font-weight: 700;
  color: var(--gold); border: 1px solid var(--gold-dim);
  border-radius: 9px; white-space: nowrap;
}

/* collapse toggle: hide the control buttons so the camera tiles fill the bar */
.vid-collapse {
  flex: 0 0 auto; align-self: center;
  width: 34px; height: 34px; padding: 0;
  border: 1px solid var(--gold-dim); background: var(--panel);
  color: var(--gold); border-radius: 9px;
  font-size: 18px; font-weight: 700; line-height: 1; cursor: pointer;
}
.vid-collapse:hover { background: rgba(255,255,255,.08); }
.video-bar.ctrl-collapsed .video-ctrl { display: none; }
/* when collapsed, let the tiles breathe */
.video-bar.ctrl-collapsed .video-tiles { flex: 1 1 auto; }

/* effect picker popover (centered, modal-like) */
.fx-picker {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 400; width: min(380px, 92vw); max-height: 80vh; overflow: auto;
  background: var(--card); border: 1px solid var(--gold-dim);
  border-radius: 14px; box-shadow: 0 16px 50px rgba(0,0,0,.6); padding: 14px;
}
.fx-picker-head {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; color: var(--gold); margin-bottom: 12px; font-size: 15px;
}
.fx-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.fx-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 6px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 12px;
  cursor: pointer; color: var(--text);
  transition: border-color .12s, transform .12s;
}
.fx-item:hover { border-color: var(--gold); transform: translateY(-1px); }
.fx-item:active { transform: scale(.96); }
.fx-emoji { font-size: 30px; line-height: 1; }
.fx-name  { font-size: 12px; color: var(--muted); }
.fx-cost  { font-size: 12px; font-weight: 700; color: var(--gold); }

/* full-screen effect overlay (never intercepts taps) */
.fx-overlay {
  position: fixed; inset: 0; z-index: 9990;
  pointer-events: none; overflow: hidden;
}
.fx-particle { position: fixed; pointer-events: none; will-change: transform, opacity; }
/* v2: particle ที่เป็นรูป (สติกเกอร์อัปโหลด) — ขนาดตาม fontSize ของ particle */
.fx-pimg { width: 1.25em; height: 1.25em; object-fit: contain; display: block; }

.fx-float { bottom: 8vh; animation: fxFloat 2.4s ease-out forwards; opacity: 0; }
@keyframes fxFloat {
  0%   { transform: translate(0, 0); opacity: 0; }
  15%  { opacity: 1; }
  100% { transform: translate(var(--drift, 0), -78vh); opacity: 0; }
}

.fx-rain { top: -8vh; animation: fxRain 2.6s linear forwards; opacity: 0; }
@keyframes fxRain {
  0%   { transform: translateY(0); opacity: 0; }
  10%  { opacity: 1; }
  100% { transform: translateY(112vh); opacity: .9; }
}

.fx-burst-core { font-size: 64px; animation: fxBurstCore 1.4s ease-out forwards; }
@keyframes fxBurstCore {
  0%   { transform: translate(-50%, -50%) scale(.2); opacity: 0; }
  30%  { transform: translate(-50%, -50%) scale(1.5); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.1); opacity: 0; }
}
.fx-burst { animation: fxBurst 1.3s ease-out forwards; }
@keyframes fxBurst {
  0%   { transform: translate(-50%, -50%); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))); opacity: 0; }
}

.fx-shake { font-size: 72px; animation: fxShake 1.3s ease-in-out forwards; opacity: 0; }
@keyframes fxShake {
  0%   { transform: translate(-50%, -50%) scale(.6); opacity: 0; }
  15%  { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
  25%  { transform: translate(-52%, -50%) scale(1.2) rotate(-9deg); }
  40%  { transform: translate(-48%, -50%) scale(1.2) rotate(9deg); }
  55%  { transform: translate(-52%, -50%) scale(1.2) rotate(-9deg); }
  70%  { transform: translate(-48%, -50%) scale(1.2) rotate(9deg); }
  82%  { transform: translate(-50%, -50%) scale(1.2) rotate(0); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

/* "who sent it" label */
.fx-sender {
  position: fixed; top: 12vh; left: 50%; transform: translateX(-50%);
  z-index: 9991; pointer-events: none;
  background: rgba(0,0,0,.62); color: var(--gold);
  padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: 14px;
  border: 1px solid var(--gold-dim); white-space: nowrap;
  animation: fxSender 2.2s ease forwards;
}
@keyframes fxSender {
  0%   { opacity: 0; transform: translate(-50%, -8px); }
  12%  { opacity: 1; transform: translate(-50%, 0); }
  80%  { opacity: 1; }
  100% { opacity: 0; }
}

/* transient toast */
.app-toast {
  position: fixed; top: calc(64px + env(safe-area-inset-top)); left: 50%;
  transform: translateX(-50%) translateY(-12px);
  z-index: 9998; max-width: 86vw; text-align: center;
  background: rgba(10, 11, 14, .96); border: 1px solid var(--gold-dim);
  color: var(--text); padding: 10px 16px; border-radius: 10px;
  font-weight: 600; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.app-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.app-toast.warn { border-color: var(--warn); }
.app-toast.ok   { border-color: var(--ok); }

/* ---------- v2: targeted gifts (user-to-user) ---------- */
/* ไอคอนรูปในกริดเลือกของขวัญ */
.fx-img { width: 36px; height: 36px; object-fit: contain; }
.fx-img.sm { width: 26px; height: 26px; vertical-align: -7px; }

/* แผงเลือกเป้าหมาย (โผล่แทนกริดหลังแตะของขวัญแบบ targeted) */
.fx-targets { display: flex; flex-direction: column; gap: 12px; }
.fx-targets-head { font-weight: 700; color: var(--gold); font-size: 15px; }
.fx-target-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.fx-target-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 12px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 12px;
  cursor: pointer; color: var(--text); font-size: 14px; font-weight: 600;
  transition: border-color .12s, transform .12s;
}
.fx-target-btn:hover { border-color: var(--gold); transform: translateY(-1px); }
.fx-target-btn:active { transform: scale(.96); }
.fx-target-ava {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--gold-dim); color: #1a1206; font-weight: 800;
}
.fx-target-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-target-cancel {
  align-self: flex-start; background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 13px; padding: 4px 2px;
}
.fx-target-cancel:hover { color: var(--text); }

/* ชิ้นของขวัญที่บิน/เล่นท่าจบ — transform/opacity เท่านั้น (บทเรียน Safari) */
.fx-gift { position: fixed; left: 0; top: 0; pointer-events: none; will-change: transform, opacity; z-index: 9992; }
.fx-gift img { width: 92px; height: 92px; object-fit: contain; display: block;
               filter: drop-shadow(0 6px 14px rgba(0,0,0,.45)); }

/* ท่าจบ (เกาะที่ left/top ปลายทาง — keyframes ขยับเฉพาะ transform) */
.fxa-slap { animation: fxaSlap 1.1s ease-out forwards; }
@keyframes fxaSlap {
  0%   { transform: translate(-50%, -50%) scale(1.45) rotate(-14deg); }
  12%  { transform: translate(-50%, -50%) scale(.82)  rotate(6deg); }
  26%  { transform: translate(-50%, -50%) scale(1.18) rotate(-5deg); }
  40%  { transform: translate(-50%, -50%) scale(1)    rotate(0); opacity: 1; }
  78%  { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(.92); opacity: 0; }
}
.fxa-crack { animation: fxaCrack 1.7s ease-out forwards; }
@keyframes fxaCrack {
  0%   { transform: translate(-50%, -50%) scale(1.4); }
  14%  { transform: translate(-50%, -50%) scale(.8, 1.15); }
  28%  { transform: translate(-50%, -50%) scale(1.15, .85); opacity: 1; }
  55%  { transform: translate(-50%, -38%) scale(1.05, .95); }
  100% { transform: translate(-50%, -8%)  scale(1, .9); opacity: 0; }
}
.fxa-shake { animation: fxaShakeG 1.5s ease-in-out forwards; }
@keyframes fxaShakeG {
  0%   { transform: translate(-50%, -50%) scale(1.25); }
  15%  { transform: translate(-54%, -50%) scale(1.15) rotate(-12deg); opacity: 1; }
  30%  { transform: translate(-46%, -50%) scale(1.15) rotate(12deg); }
  45%  { transform: translate(-54%, -50%) scale(1.15) rotate(-12deg); }
  60%  { transform: translate(-46%, -50%) scale(1.15) rotate(12deg); }
  75%  { transform: translate(-50%, -50%) scale(1.1)  rotate(0); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}
.fxa-hover { animation: fxaHover 2.2s ease-in-out forwards; }
@keyframes fxaHover {
  0%   { transform: translate(-50%, -50%) scale(1.1); }
  25%  { transform: translate(-50%, -62%) scale(1.05); opacity: 1; }
  50%  { transform: translate(-50%, -50%) scale(1.08); }
  75%  { transform: translate(-50%, -60%) scale(1.05); opacity: 1; }
  100% { transform: translate(-50%, -54%) scale(1); opacity: 0; }
}
.fxa-burst { animation: fxaBurstG 1.2s ease-out forwards; }
@keyframes fxaBurstG {
  0%   { transform: translate(-50%, -50%) scale(.9); }
  18%  { transform: translate(-50%, -50%) scale(1.55); opacity: 1; }
  36%  { transform: translate(-50%, -50%) scale(1.2); }
  70%  { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.6); opacity: 0; }
}
.fxa-place { animation: fxaPlace 2.2s ease-out forwards; }
@keyframes fxaPlace {
  0%   { transform: translate(-50%, -64%) scale(1.1); }
  20%  { transform: translate(-50%, -48%) scale(1.04, .92); }
  32%  { transform: translate(-50%, -52%) scale(1); opacity: 1; }
  82%  { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(.95); opacity: 0; }
}

/* ประกายทองกระจายตอนของถึงตัว (burst/crack) */
.fx-spark {
  position: fixed; width: 10px; height: 10px; border-radius: 50%;
  background: var(--gold, #e2c06a); pointer-events: none; z-index: 9991;
  will-change: transform, opacity;
  animation: fxSpark .8s ease-out forwards;
}
@keyframes fxSpark {
  0%   { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.3); opacity: 0; }
}

/* เป้าหมายโดนของ → สั่น (ใส่กับ video tile / ที่นั่ง) */
.fx-hit-shake { animation: fxHitShake .55s ease-in-out; }
@keyframes fxHitShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px) rotate(-1deg); }
  40% { transform: translateX(7px)  rotate(1deg); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

/* ป้ายชื่อผู้ส่ง ➜ ผู้รับ + คำแซว (เกาะเหนือเป้าหมาย) */
.fx-gift-label {
  position: fixed; transform: translateX(-50%);
  z-index: 9993; pointer-events: none; text-align: center;
  background: rgba(0,0,0,.66); border: 1px solid var(--gold-dim);
  border-radius: 12px; padding: 6px 12px; white-space: nowrap;
  animation: fxGiftLabel 2.4s ease forwards;
}
.fx-gift-label b    { display: block; color: var(--gold); font-size: 13px; }
.fx-gift-label span { display: block; color: var(--text); font-size: 12px; }
@keyframes fxGiftLabel {
  0%   { opacity: 0; transform: translateX(-50%) translateY(8px); }
  14%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  80%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------- โหมดฝึกเล่น (practice.js) ---------- */
.prac-levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.prac-level {
  display: flex; align-items: center; justify-content: center;
  padding: 18px 6px; background: var(--panel);
  border: 2px solid var(--border); border-radius: 12px;
  cursor: pointer; color: var(--text);
  transition: border-color .12s, transform .12s;
}
.prac-level:hover { border-color: var(--gold); transform: translateY(-1px); }
.prac-level.active { border-color: var(--gold); background: rgba(243,222,147,.12); }
.pl-name  { font-size: 18px; font-weight: 700; }

/* ---------- v3: แพ็กสติกเกอร์ ---------- */
/* กริดของขวัญ: ตัวที่หมดสต็อก */
.fx-item.fx-out { opacity: .5; }
.fx-item.fx-out:hover { opacity: .75; }
.fx-cost-out { color: var(--warn, #e0a84d) !important; font-size: 11px !important; }

/* ร้านค้า: หมวดสติกเกอร์ */
.shop-stick-wrap { margin-top: 16px; }
.shop-stick-head { color: var(--gold); font-size: 16px; margin: 0 0 6px; text-align: center; }
.shop-stick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.shop-stick {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 6px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 12px;
  cursor: pointer; color: var(--text);
  transition: border-color .12s, transform .12s;
}
.shop-stick:hover { border-color: var(--gold); transform: translateY(-1px); }
.shop-stick:active { transform: scale(.96); }
.shop-stick.confirming { border-color: var(--gold); background: rgba(243,222,147,.12); }
.shop-stick-img { width: 44px; height: 44px; object-fit: contain; }
.shop-stick-emoji { font-size: 34px; line-height: 44px; }
.shop-stick-name { font-size: 12px; color: var(--text); }
.shop-stick-left { font-size: 11px; color: var(--ok, #39c07f); font-weight: 700; }
.shop-stick-left.none { color: var(--muted); font-weight: 400; }
.shop-stick-price { font-size: 12px; font-weight: 700; color: var(--gold); }

/* ป้ายจำนวนที่มี — มุมขวาบนของการ์ดสติกเกอร์ (เห็นชัดว่ามีกี่ครั้ง) */
.shop-stick { position: relative; }
.shop-stick-count {
  position: absolute; top: -7px; right: -7px;
  min-width: 26px; height: 26px; padding: 0 7px;
  display: flex; align-items: center; justify-content: center;
  background: var(--gold); color: #1c2747;
  border: 2px solid #1c2747; border-radius: 13px;
  font-size: 14px; font-weight: 800; line-height: 1;
  box-shadow: 0 2px 6px rgba(0,0,0,.35);
}
.shop-stick-count.none { background: #3a4566; color: #aab3cf; }
.shop-stick-count.bump { animation: stickBump .45s ease; }
@keyframes stickBump {
  0% { transform: scale(1); }
  35% { transform: scale(1.45); }
  100% { transform: scale(1); }
}
/* ป๊อปอัปยืนยันซื้อ ต้องลอยทับร้านในห้อง (coinShopModal z-1200) */
#purchaseModal.buy-modal { z-index: 1300; }

/* 🎒 ของฉัน: การ์ดโชว์เฉย ๆ (ไม่ใช่ปุ่มซื้อ) */
.shop-stick.mine { cursor: default; }
.shop-stick.mine:hover { border-color: var(--border); transform: none; }
.shop-stick.mine .shop-stick-left { font-size: 13px; }

/* 🧾 ประวัติการซื้อ */
.shop-hist { display: flex; flex-direction: column; gap: 6px; }
.shop-hist-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px;
}
.shop-hist-row .sh-date { color: var(--muted); font-size: 12px; min-width: 86px; }
.shop-hist-row .sh-what { flex: 1; color: var(--text); }
.shop-hist-row .sh-amt  { font-weight: 700; white-space: nowrap; }
.shop-hist-row .sh-amt.plus  { color: var(--ok, #39c07f); }
.shop-hist-row .sh-amt.minus { color: #e07a6a; }

/* ---------- v2: ฉลองทะลุ/ดาบี้กลางจอ (game.js celebrate()) ---------- */
.cele-layer { position: fixed; inset: 0; z-index: 9989; pointer-events: none; overflow: hidden; }

/* ดาบี้: จอทองทั้งจอ ~3 วิ */
.cele-flash {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at center, rgba(243,201,60,.42), rgba(201,162,74,.22) 60%, rgba(0,0,0,0));
  animation: celeFlash 3s ease forwards; will-change: opacity;
}
@keyframes celeFlash {
  0%   { opacity: 0; }
  12%  { opacity: 1; }
  70%  { opacity: .85; }
  100% { opacity: 0; }
}

/* ตัวอักษรทองกลางจอ */
.cele-text {
  position: fixed; top: 38vh; left: 50%;
  font-weight: 900; color: #ffe9a8; white-space: nowrap;
  text-shadow: 0 2px 0 #a87f2e, 0 6px 22px rgba(243,201,60,.65), 0 0 50px rgba(243,201,60,.5);
  will-change: transform, opacity; pointer-events: none;
}
.cele-text.sweep { font-size: clamp(56px, 14vw, 120px); animation: celeSweep 2s ease-in-out forwards; }
@keyframes celeSweep {
  0%   { transform: translateX(60vw)  translateX(-50%) rotate(-3deg) scale(.9); opacity: 0; }
  18%  { transform: translateX(8vw)   translateX(-50%) rotate(-3deg) scale(1.06); opacity: 1; }
  55%  { transform: translateX(-6vw)  translateX(-50%) rotate(-3deg) scale(1); opacity: 1; }
  100% { transform: translateX(-65vw) translateX(-50%) rotate(-3deg) scale(.92); opacity: 0; }
}
.cele-text.derby { font-size: clamp(68px, 18vw, 150px); animation: celeDerby 2.9s ease forwards; }
@keyframes celeDerby {
  0%   { transform: translateX(-50%) scale(.2)  rotate(-6deg); opacity: 0; }
  14%  { transform: translateX(-50%) scale(1.25) rotate(2deg); opacity: 1; }
  26%  { transform: translateX(-50%) scale(1)   rotate(-1deg); }
  38%  { transform: translateX(-50%) scale(1.12) rotate(1deg); }
  50%  { transform: translateX(-50%) scale(1.04) rotate(0); }
  82%  { transform: translateX(-50%) scale(1.08); opacity: 1; }
  100% { transform: translateX(-50%) scale(1.3); opacity: 0; }
}

/* ธนบัตร/พลุ/ประกายปลิวลงมา */
.cele-bill {
  position: fixed; top: -8vh; will-change: transform, opacity; pointer-events: none;
  animation: celeBill 2.8s linear forwards; opacity: 0;
}
@keyframes celeBill {
  0%   { transform: translateY(0) rotate(0); opacity: 0; }
  10%  { opacity: 1; }
  100% { transform: translateY(115vh) rotate(220deg); opacity: .9; }
}

@media (prefers-reduced-motion: reduce) {
  .fx-particle { animation-duration: .6s !important; }
  .fx-gift, .fx-spark, .cele-text, .cele-bill, .cele-flash { animation-duration: .6s !important; }
}

/* responsive — landscape phones: compact so the table fits without scroll */
@media (orientation: landscape) and (max-height: 560px) {
  .container { max-width: 920px; padding: 8px 16px; }
  .game-head h1 { margin-bottom: 6px; }
  .arrange-hint { display: none; }
  .felt-table { margin: 6px 0 8px; padding: 8px 10px 2px; }
  .felt-table .row-zone { margin: 0 0 6px; }
  .felt-table .slots { min-height: 66px; padding: 5px; }
  .pcard, .cardslot { width: 44px; height: 62px; }
  .pcard .pc-rank { font-size: 23px; }
  .pcard .pc-suit { font-size: 21px; }
  .actions { margin-top: 4px; }
}

/* ============ Accounts: login gate + invite (trial) ============ */
.auth-view {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(120% 120% at 50% 0%, #14161d 0%, #0b0c10 70%);
}
.auth-view.hidden { display: none; }
body.auth-locked { overflow: hidden; }
.auth-card {
  width: 100%; max-width: 340px;
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 26px 22px; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.auth-logo { font-size: 20px; color: var(--gold); margin-bottom: 10px; letter-spacing: .5px; }
.auth-card h2 { margin: 4px 0 14px; color: var(--text); font-size: 22px; }
.auth-card input {
  display: block; width: 100%; box-sizing: border-box; margin: 8px 0;
  padding: 12px 14px; border-radius: 10px;
  background: #0b1220; color: var(--text); border: 1px solid var(--border);
  font-size: 15px;
}
.auth-card input:focus { outline: none; border-color: var(--primary); }
.auth-card .btn { width: 100%; margin-top: 10px; padding: 12px; font-size: 16px; }
.auth-card .btn.primary, .auth-card #authSubmit {
  background: var(--primary); border-color: var(--primary); color: #1a1305; font-weight: 600;
}
.auth-card .link { color: var(--gold); cursor: pointer; text-decoration: underline; }
#authRefNote { color: var(--gold); margin: -4px 0 8px; }
#authError:empty { display: none; }

/* inline field hints under the username / password inputs */
.field-hint {
  display: block; text-align: left; font-size: 12px; line-height: 1.3;
  margin: -2px 2px 6px; color: var(--muted);
}
.field-hint.hidden { display: none; }
.field-hint.ok   { color: #4ade80; }   /* green: looks good */
.field-hint.warn { color: #fbbf24; }   /* amber: needs fixing */

/* loading state on the submit button (animated dots) */
.auth-card #authSubmit.loading { opacity: .8; cursor: progress; }
.auth-card #authSubmit.loading::after {
  content: ''; display: inline-block; width: 14px; height: 14px;
  margin-left: 8px; vertical-align: -2px;
  border: 2px solid rgba(26,19,5,.35); border-top-color: #1a1305;
  border-radius: 50%; animation: authSpin .7s linear infinite;
}
@keyframes authSpin { to { transform: rotate(360deg); } }

/* recovery: transient toast + forgot/reset modal inputs */
.auth-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 16px; font-size: 14px; z-index: 2000;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; max-width: 90vw; text-align: center;
}
.auth-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.auth-toast.ok   { border-color: #4ade80; }
.auth-toast.warn { border-color: #fbbf24; }
/* terms acceptance gate */
.terms-card { max-width: 420px; }
.terms-body {
  text-align: left; max-height: 42vh; overflow-y: auto;
  background: #0b1220; border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; margin: 6px 0 12px; font-size: 14px; color: var(--muted);
}
.terms-body p { margin: 0 0 8px; }
.terms-body code { color: var(--gold); }
.terms-clause { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 4px; }
.terms-clause:first-of-type { border-top: none; padding-top: 0; }
.terms-clause .terms-agree { color: var(--gold); margin: 6px 0 2px; }
.terms-agree {
  display: flex; align-items: center; gap: 8px; text-align: left;
  font-size: 14px; color: var(--text); margin: 4px 0 6px; cursor: pointer;
}
.terms-agree input { width: auto; margin: 0; }
#termsMsg:empty { display: none; }

#forgotModal { z-index: 1100; }   /* above the full-screen login gate (z-index 1000) */
#forgotModal input {
  display: block; width: 100%; box-sizing: border-box; margin: 8px 0;
  padding: 11px 14px; border-radius: 10px; font-size: 15px;
  background: #0b1220; color: var(--text); border: 1px solid var(--border);
}
#forgotModal input:focus { outline: none; border-color: var(--primary); }
#forgotModal .pw-wrap { margin: 8px 0; }
#forgotModal .pw-wrap input { margin: 0; }
#forgotModal .btn { width: 100%; margin-top: 6px; }
#recoveryCodeBox { word-break: break-all; }
#recoveryCodeBox:empty, #forgotMsg:empty, #resetMsg:empty { display: none; }
#genRecoveryBtn, #bindLineBtn { margin-top: 8px; }

/* how-to-play page */
.howto-body { text-align: left; }
.howto-body h2 { font-size: 17px; color: var(--gold); margin: 18px 0 6px; }
.howto-body h3 { font-size: 14px; color: var(--text); margin: 12px 0 4px; }
.howto-body > p { margin: 0 0 8px; font-size: 14px; line-height: 1.5; }
.howto-list, .howto-rank { margin: 4px 0 8px; padding-left: 22px; }
.howto-list li, .howto-rank li { margin: 4px 0; font-size: 14px; line-height: 1.45; }
.howto-table { width: 100%; border-collapse: collapse; margin: 4px 0 8px; font-size: 14px; }
.howto-table td { border: 1px solid var(--border); padding: 6px 10px; }
.howto-table td:last-child { width: 56px; text-align: center; color: var(--gold); font-weight: 700; }
.howto-rank li { margin-bottom: 12px; }
.howto-rank .rank-head { font-size: 14px; }
.howto-rank .rank-head .muted { font-size: 12px; }
.card-row { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 2px; }
/* reuse the existing .mc / .mc.r mini-card, just bigger inside how-to rows */
.card-row .mc { min-width: 27px; height: 33px; padding: 0 5px; border-radius: 5px; font-size: 14px; }
.card-row .mc.b { color: #161310; }

.invite-qr {
  display: flex; justify-content: center; align-items: center;
  background: #fff; padding: 12px; border-radius: 12px; margin: 12px auto; width: max-content;
}
.invite-qr img, .invite-qr canvas { display: block; }
.invite-link {
  word-break: break-all; font-size: 13px; color: var(--muted);
  background: #0b1220; border: 1px solid var(--border); border-radius: 8px; padding: 8px;
}

/* ============ Main menu / profile / shop ============ */
.menu-screen { text-align: center; }
.menu-logo { width: 120px; height: 120px; display: block; margin: 6px auto 22px; }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.menu-btn {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 20px 14px; cursor: pointer; color: var(--text);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-family: inherit; transition: transform .08s, border-color .15s;
}
.menu-btn:hover { border-color: var(--gold); transform: translateY(-2px); }
.menu-btn:active { transform: translateY(0); }
.menu-btn.wide { grid-column: 1 / -1; padding: 22px 16px; }
.menu-btn .mi { font-size: 30px; line-height: 1; }
.menu-btn.wide .mi { font-size: 34px; }
.menu-btn .ml { font-size: 16px; }
.menu-btn.wide .ml { font-size: 18px; color: var(--gold); }
.menu-btn .ms { font-size: 12px; color: var(--muted); }

/* game selection cards */
.games-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.game-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 20px 18px; display: flex; align-items: center; gap: 14px; text-align: left;
  color: var(--text); font-family: inherit; cursor: pointer;
  transition: border-color .15s, transform .08s; width: 100%;
}
.game-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.game-card .gc-emoji { font-size: 34px; line-height: 1; }
.game-card .gc-text { display: flex; flex-direction: column; gap: 3px; }
.game-card .gc-title { font-size: 18px; }
.game-card .gc-sub { font-size: 12px; color: var(--muted); }
.game-card.soon { opacity: .45; cursor: default; }
.game-card.soon:hover { border-color: var(--border); transform: none; }

/* create / join table choice */
.table-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 8px; }
.choice-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 26px 14px; cursor: pointer; color: var(--text); font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: border-color .15s, transform .08s;
}
.choice-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.choice-card:active { transform: translateY(0); }
.choice-card .cc-emoji { font-size: 36px; line-height: 1; }
.choice-card .cc-title { font-size: 17px; color: var(--gold); }
.choice-card .cc-sub { font-size: 12px; color: var(--muted); text-align: center; }

/* game-length chooser + countdown */
.btn.on { background: var(--primary); color: #1a140d; border-color: var(--primary); }
.time-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.time-row input { width: 72px; }
#limitBadge { color: var(--gold); font-weight: 600; }

.back-btn {
  display: inline-block; background: var(--panel); border: 1px solid var(--border);
  color: var(--text); cursor: pointer; font-size: 14px; padding: 8px 16px;
  border-radius: 10px; margin-bottom: 14px; font-family: inherit;
  transition: border-color .15s;
}
.back-btn:hover { border-color: var(--gold); }
.profile-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 2px; border-bottom: 1px solid var(--border);
}
.profile-val { color: var(--gold); font-weight: 500; }
#profile .btn, #shop .btn { width: 100%; margin-top: 10px; }
#profile .pw-wrap { margin: 14px 0 0; }
#profile input { width: 100%; box-sizing: border-box; }
#profilePwMsg:empty { display: none; }

/* show/hide password toggle */
.auth-card .pw-wrap { margin: 8px 0; }         /* spacing on the wrapper, not the input */
.pw-wrap { position: relative; }
.pw-wrap input { margin: 0; padding-right: 46px; }   /* no margin (keeps the eye centered) + room for button */
.pw-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  font-size: 18px; line-height: 1; padding: 4px 6px; color: var(--muted);
}
.pw-toggle:hover { color: var(--text); }

/* ---------------- ร้านค้า / เติมเหรียญ (shop.js) ---------------- */
.shop-packages {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.shop-pkg {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 12px;
  border-radius: 12px;
  cursor: pointer;
}
.shop-pkg-coins { font-size: 1.1em; font-weight: 700; }
.shop-pkg-price { opacity: 0.85; font-size: 0.95em; }
.shop-pkg:disabled { opacity: 0.5; cursor: default; }

/* ============================================================
 * Premium theme v3 — luxe depth, gold sheen (VISUAL ONLY)
 * Appended last so it layers over earlier rules. Delete this block to revert.
 * ==========================================================*/
:root {
  --gold-grad:   linear-gradient(180deg, #f7e7a8 0%, #e6c462 45%, #c9a24a 100%);
  --gold-grad-h: linear-gradient(180deg, #fbeeb8 0%, #edcf73 45%, #d4ad55 100%);
  --card-grad:   linear-gradient(165deg, #1d2028 0%, #141519 100%);
  --shadow-1: 0 8px 24px rgba(0,0,0,.45);
}

/* deep luxe backdrop: soft gold glow at top + vignette */
body {
  background:
    radial-gradient(80% 48% at 50% -6%, rgba(243,222,147,.10), transparent 60%),
    radial-gradient(125% 120% at 50% 0%, #20222a 0%, #131419 55%, #0a0b0e 100%) fixed;
}

/* premium surfaces */
.card, .modal-card, .menu-btn, .game-card, .choice-card {
  background: var(--card-grad);
  border: 1px solid rgba(243,222,147,.16);
  box-shadow: var(--shadow-1);
}
.card { border-radius: 18px; }

/* primary / gold buttons — gradient + sheen + press */
.btn.primary, .vid-btn.gold, .auth-card #authSubmit {
  background: var(--gold-grad);
  border: 1px solid #b8902f; color: #2a2008; font-weight: 700;
  box-shadow: 0 4px 14px rgba(201,162,74,.35), inset 0 1px 0 rgba(255,255,255,.45);
  transition: transform .08s, box-shadow .15s, filter .15s;
}
.btn.primary:hover, .vid-btn.gold:hover { background: var(--gold-grad-h); filter: brightness(1.03); }
.btn.primary:active { transform: translateY(1px); }

/* secondary buttons — subtle glass + gold hairline */
.btn:not(.primary) {
  background: linear-gradient(180deg, #20232b, #181a20);
  border: 1px solid var(--gold-dim); color: var(--text);
}
.btn:not(.primary):hover { border-color: var(--gold); }

/* tappable cards — lift + gold glow on hover */
.menu-btn:hover, .game-card:hover, .choice-card:hover {
  border-color: var(--gold);
  box-shadow: 0 10px 30px rgba(0,0,0,.5), 0 0 0 1px rgba(243,222,147,.25);
  transform: translateY(-2px);
}

/* playing cards — crisper depth + sheen */
.pcard {
  background: linear-gradient(160deg, #ffffff 0%, #f4f1e6 100%);
  border: 1px solid #cdc4a4;
  box-shadow: 0 3px 8px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.85);
}
.pcard.selected {
  outline: 3px solid var(--gold);
  box-shadow: 0 0 0 4px rgba(243,222,147,.35), 0 6px 16px rgba(0,0,0,.5);
}

/* felt table — deeper vignette + inset gold rim */
.felt-table {
  box-shadow: inset 0 0 60px rgba(0,0,0,.55), 0 8px 30px rgba(0,0,0,.45);
  outline: 1px solid rgba(243,222,147,.25); outline-offset: -6px;
}

/* coin chip — SILVER, high-contrast number (same on every device) */
:root { --silver-grad: linear-gradient(180deg, #fdfdfe 0%, #d2d7de 45%, #aab0bb 100%); }
.coin-chip {
  background: var(--silver-grad);
  border: 1px solid #8d949f;
  color: #1f2530;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 2px 8px rgba(0,0,0,.35);
}
.coin-chip #coinAmount { color: #161a22; font-weight: 800; }
/* coin amounts shown on dark panels → light metallic silver so they stand out */
.wallet-balance, .pcoin { color: #e6eaf0; }

/* custom silver "P" coin icon (SVG) — replaces the 🪙 emoji everywhere.
   font-size:0 hides any literal 🪙 text left inside a .coin-ico span. */
.coin-ico {
  display: inline-block; width: 18px; height: 18px;
  background: url(../assets/coin.svg) center / contain no-repeat;
  font-size: 0; line-height: 0; vertical-align: -3px;
}
.wallet-balance .coin-ico { width: 24px; height: 24px; vertical-align: -5px; }
.shop-pkg-coins .coin-ico { width: 20px; height: 20px; vertical-align: -4px; }

/* topbar — glass + gold hairline */
.topbar {
  background: linear-gradient(180deg, rgba(14,15,19,.94), rgba(10,11,14,.86));
  border-bottom: 1px solid var(--gold-dim);
}

/* input focus — gold ring */
input:focus, .auth-card input:focus, #forgotModal input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(243,222,147,.18);
}

/* desktop — thin premium scrollbars + gold text selection */
@media (pointer: fine) {
  * { scrollbar-width: thin; scrollbar-color: var(--primary) transparent; }
  *::-webkit-scrollbar { width: 10px; height: 10px; }
  *::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #c9a24a, #8a6f2f);
    border-radius: 8px; border: 2px solid transparent; background-clip: padding-box;
  }
  *::-webkit-scrollbar-track { background: transparent; }
}
::selection { background: rgba(243,222,147,.35); color: #fff; }

/* ============================================================
 * Tablet / iPad fixes (>=768px) — phones (<768) unchanged
 * ==========================================================*/
/* reveal: identical column widths across ALL boards = rows line up between players */
@media (min-width: 768px) {
  #revealBoards .pcard.small { width: 34px; height: 48px; border-radius: 5px; }
  #revealBoards .pcard.small .pc-rank { font-size: 17px; }
  #revealBoards .pcard.small .pc-suit { font-size: 15px; }
  .reveal-board {
    grid-template-columns: 74px 116px 192px 192px;   /* name | top(3) | middle(5) | bottom(5) */
  }
  .reveal-board .rb-row   { overflow: hidden; }       /* fixed track: clip long labels, keep alignment */
  .reveal-board .rb-label { overflow: hidden; text-overflow: ellipsis; }
}
/* iPad (touch tablet): use more of the screen so the arrange cards get larger */
@media (min-width: 768px) and (pointer: coarse) {
  .container { max-width: min(96vw, 1100px); }
}

/* ============================================================
 * Depth v4 — add elevation, bevels & 3D feel (VISUAL ONLY)
 * Appended last. Delete this block to revert.
 * ==========================================================*/
/* panels / cards: float off the page with a top bevel + bottom edge */
.card, .modal-card {
  box-shadow:
    0 18px 40px rgba(0,0,0,.55),
    0 3px 0 rgba(0,0,0,.30),
    inset 0 1px 0 rgba(255,255,255,.07);
  border-top: 1px solid rgba(255,255,255,.10);
}

/* tappable cards: raised, lift higher on hover */
.menu-btn, .game-card, .choice-card {
  box-shadow: 0 10px 22px rgba(0,0,0,.45), 0 2px 0 rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,.08);
  transition: transform .12s ease, box-shadow .15s ease, border-color .15s;
}
.menu-btn:hover, .game-card:hover, .choice-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 36px rgba(0,0,0,.55), 0 0 0 1px rgba(243,222,147,.3), inset 0 1px 0 rgba(255,255,255,.12);
}
.menu-btn:active, .game-card:active, .choice-card:active { transform: translateY(-1px); }

/* buttons: 3D press (raised edge → sinks on click) */
.btn {
  box-shadow: 0 3px 0 rgba(0,0,0,.35), 0 7px 14px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.14);
  transition: transform .07s ease, box-shadow .12s ease, filter .15s, background .15s;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.35), 0 3px 8px rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,.10); }
.btn.primary { box-shadow: 0 3px 0 #9c7a26, 0 8px 18px rgba(201,162,74,.4), inset 0 1px 0 rgba(255,255,255,.5); }
.btn.primary:active { transform: translateY(2px); box-shadow: 0 1px 0 #9c7a26, 0 3px 10px rgba(201,162,74,.35), inset 0 1px 0 rgba(255,255,255,.4); }

/* playing cards: thicker, raised, glossy */
.pcard {
  box-shadow:
    0 6px 14px rgba(0,0,0,.5),
    0 1px 0 rgba(0,0,0,.35),
    inset 0 2px 0 rgba(255,255,255,.9),
    inset 0 -4px 7px rgba(0,0,0,.07);
}

/* felt table: deeper bowl + raised gold rim */
.felt-table {
  box-shadow:
    inset 0 0 70px rgba(0,0,0,.6),
    inset 0 2px 0 rgba(255,255,255,.06),
    0 12px 34px rgba(0,0,0,.5);
}

/* coin: pops off the surface */
.coin-ico { filter: drop-shadow(0 1px 1.5px rgba(0,0,0,.45)); }
.coin-chip {
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.85),
    inset 0 -2px 4px rgba(0,0,0,.18),
    0 3px 8px rgba(0,0,0,.4);
}
.coin-chip:active { transform: translateY(1px); }

/* avatars: spherical sheen */
.ava { box-shadow: inset 0 2px 4px rgba(255,255,255,.45), inset 0 -4px 8px rgba(0,0,0,.3), 0 3px 8px rgba(0,0,0,.4); }

/* topbar + room bar: subtle elevation */
.topbar { box-shadow: 0 4px 16px rgba(0,0,0,.45); position: relative; z-index: 50; }

/* reveal boards: lifted panels */
.reveal-board { box-shadow: 0 6px 16px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.05); }

/* respect reduced-motion: keep depth, drop the movement */
@media (prefers-reduced-motion: reduce) {
  .menu-btn, .game-card, .choice-card, .btn, .coin-chip { transition: none; }
}

/* ============================================================
 * Avatar picker + vibrancy (less "dull")
 * ==========================================================*/
.avatar-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.avatar-opt {
  line-height: 0; padding: 4px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  transition: transform .08s, border-color .12s, box-shadow .12s;
}
.avatar-opt img { width: 100%; height: auto; display: block; border-radius: 9px; }
.avatar-opt:hover { transform: translateY(-2px); border-color: var(--gold-dim); }
.avatar-opt.sel  { border-color: var(--gold); background: rgba(243,222,147,.14); box-shadow: 0 0 0 2px rgba(243,222,147,.45); }

/* avatar image fills the lobby circle (img clips itself, so .ava can stay
   overflow:visible — otherwise the corner host buttons get cut off) */
.ava-img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.seat-beg, .seat-kick, .seat-crown, .seat-dot { z-index: 2; }
/* small avatar beside the name on the reveal board */
.rb-ava { width: 18px; height: 18px; border-radius: 50%; object-fit: cover; vertical-align: -4px; margin-right: 4px; }

/* vibrancy: faint coloured glows over the dark backdrop so it feels alive */
body {
  background:
    radial-gradient(60% 38% at 82% 8%,  rgba(47,127,196,.07), transparent 60%),
    radial-gradient(55% 38% at 8% 92%,  rgba(214,91,148,.06), transparent 60%),
    radial-gradient(80% 48% at 50% -6%, rgba(243,222,147,.12), transparent 60%),
    radial-gradient(130% 120% at 50% 0%, #21232c 0%, #131419 55%, #0a0b0e 100%) fixed;
}

/* ============ ป๊อปอัปยืนยันการซื้อ + ร้านเติมเหรียญในห้อง ============ */
/* ลอยทับห้อง/เกมเสมอ (สูงกว่า login gate 1000 / forgot 1100) ผู้ใช้ไม่หลุดออกจากห้อง */
.buy-modal { z-index: 1200; align-items: center; }

.buy-card { max-width: 340px; text-align: center; }
.buy-title { font-size: 17px; font-weight: 800; color: var(--gold); margin: 2px 0 4px; }
.buy-note  { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.buy-price {
  font-size: 34px; font-weight: 800; color: var(--text);
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin: 6px 0 2px;
}
.buy-price .coin-ico { font-size: 28px; }
.buy-balance { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.buy-warn {
  background: rgba(224,88,77,.12); border: 1px solid var(--danger);
  color: #ffb3ad; border-radius: 10px; padding: 8px 10px;
  font-size: 13px; margin: 2px 0 12px;
}

.buy-actions { display: flex; gap: 14px; justify-content: center; align-items: center; margin-top: 6px; }
.buy-btn {
  width: 64px; height: 64px; border-radius: 50%;
  font-size: 28px; font-weight: 800; cursor: pointer; border: 2px solid transparent;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .08s ease, filter .15s ease;
}
.buy-btn:active { transform: scale(.94); }
.buy-btn.no  { background: transparent; border-color: var(--danger); color: var(--danger); }
.buy-btn.no:hover  { background: rgba(224,88,77,.14); }
.buy-btn.yes { background: var(--ok); border-color: var(--ok); color: #06281a; box-shadow: 0 6px 18px rgba(57,192,127,.35); }
.buy-btn.yes:hover { filter: brightness(1.08); }
/* เมื่อเหรียญไม่พอ ปุ่มหลักกลายเป็น "เติมเหรียญ" (กว้าง + ทอง) */
.buy-btn.yes.topup {
  width: auto; height: 52px; border-radius: 26px; padding: 0 20px;
  font-size: 16px; background: var(--primary); border-color: var(--primary);
  color: #161310; box-shadow: 0 6px 18px rgba(201,162,74,.35);
}

.coinshop-card { max-width: 420px; }
.coinshop-card .shop-packages { margin: 6px 0; }
#coinShopMsg:empty { display: none; }

/* ============ ป๊อปอัปปลดล็อกเล่น (unlock-to-play) — สไตล์เกมพรีเมียม ============ */
.unlock-card {
  position: relative; max-width: 366px; text-align: center; overflow: hidden;
  padding: 28px 22px 20px;
  background:
    radial-gradient(125% 75% at 50% -8%, rgba(243,222,147,.18), transparent 62%),
    linear-gradient(180deg, #1d2030 0%, #131419 100%);
  border: 1px solid var(--gold-dim);
  box-shadow: 0 26px 70px rgba(0,0,0,.72), inset 0 1px 0 rgba(255,255,255,.05);
}
.unlock-x {
  position: absolute; top: 10px; right: 12px; z-index: 3;
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  background: rgba(255,255,255,.06); border: none; color: var(--muted); font-size: 14px;
}
.unlock-x:hover { background: rgba(255,255,255,.14); color: var(--text); }

.unlock-badge {
  width: 78px; height: 78px; margin: 2px auto 14px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 38px;
  background: radial-gradient(circle at 50% 34%, #2a2d3c, #15161e);
  border: 2px solid var(--gold);
  box-shadow: 0 0 0 6px rgba(243,222,147,.08), 0 0 30px rgba(243,222,147,.4);
  animation: unlockGlow 2.6s ease-in-out infinite;
}
@keyframes unlockGlow {
  0%,100% { box-shadow: 0 0 0 6px rgba(243,222,147,.08), 0 0 26px rgba(243,222,147,.32); }
  50%     { box-shadow: 0 0 0 6px rgba(243,222,147,.14), 0 0 40px rgba(243,222,147,.6); }
}

.unlock-title {
  margin: 0 0 4px; font-size: 22px; font-weight: 800; letter-spacing: .2px;
  background: linear-gradient(180deg, #fff3cf, var(--gold));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.unlock-sub { margin: 0 0 14px; font-size: 13px; color: var(--muted); }

.unlock-pricewrap { display: inline-flex; align-items: baseline; gap: 3px; }
.unlock-cur { font-size: 22px; font-weight: 700; color: var(--gold); }
.unlock-amt {
  font-size: 54px; font-weight: 900; line-height: 1; letter-spacing: -1.5px;
  background: linear-gradient(180deg, #fff7e0, #e7cd7c);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.unlock-once { margin: 4px 0 16px; font-size: 12px; color: var(--muted); letter-spacing: .4px; }

.unlock-perks {
  list-style: none; margin: 0 0 18px; padding: 8px 14px; text-align: left;
  background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.06); border-radius: 12px;
}
.unlock-perks li {
  display: flex; align-items: center; gap: 11px; font-size: 14px; color: var(--text); padding: 8px 0;
}
.unlock-perks li + li { border-top: 1px solid rgba(255,255,255,.05); }
.unlock-perks .pk-ic {
  flex: 0 0 28px; height: 28px; border-radius: 8px; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(243,222,147,.12);
}

.unlock-cta {
  width: 100%; padding: 15px; border: none; border-radius: 13px; cursor: pointer;
  font-size: 17px; font-weight: 800; color: #2a1d00;
  background: linear-gradient(180deg, #ffe9a8, var(--primary));
  box-shadow: 0 8px 22px rgba(201,162,74,.45), inset 0 1px 0 rgba(255,255,255,.5);
  animation: unlockPulse 2.2s ease-in-out infinite;
}
.unlock-cta:hover { filter: brightness(1.05); }
.unlock-cta:active { transform: translateY(1px); }
@keyframes unlockPulse {
  0%,100% { box-shadow: 0 8px 22px rgba(201,162,74,.42), inset 0 1px 0 rgba(255,255,255,.5); }
  50%     { box-shadow: 0 8px 32px rgba(243,222,147,.7), inset 0 1px 0 rgba(255,255,255,.5); }
}
.unlock-later {
  width: 100%; margin-top: 10px; background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 13px; padding: 6px;
}
.unlock-later:hover { color: var(--text); }

/* ============================================================
 * Button animations v5 — "แบนตอนปกติ เรืองใต้ปุ่มตอนจะกด"
 * (Berto อนุมัติ 2026-06-11) — ลบบล็อกนี้ทั้งก้อนเพื่อย้อนกลับ
 * ทับเฉพาะส่วน "ปุ่ม" ของ Depth v4 ด้านบน (การ์ด/โต๊ะ/ไพ่คงเดิม)
 * ปกติ: แบน เห็นแค่เส้นขอบ · hover/แตะ: แสงเรืองใต้ปุ่ม + ลอยขึ้น · กด: จมลง
 * ==========================================================*/
.btn, .menu-btn, .game-card, .choice-card {
  box-shadow: none;
  transform: translateY(0);
  transition: transform .18s ease, box-shadow .18s ease,
              background .15s, border-color .15s, filter .15s;
}

/* เดสก์ท็อป/เมาส์: ชี้ = ลอยขึ้น + แสงเรืองจากใต้ปุ่ม */
@media (hover: hover) {
  .btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 10px 16px -4px rgba(0,0,0,.55), 0 6px 14px -2px rgba(243,222,147,.35);
  }
  .btn.primary:hover:not(:disabled) {
    box-shadow: 0 10px 18px -4px rgba(0,0,0,.55), 0 6px 16px -2px rgba(243,222,147,.55);
  }
  .btn.danger:hover:not(:disabled) {
    box-shadow: 0 10px 16px -4px rgba(0,0,0,.55), 0 6px 14px -2px rgba(224,88,77,.4);
  }
  .menu-btn:hover, .game-card:hover, .choice-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 20px -4px rgba(0,0,0,.55), 0 6px 16px -2px rgba(243,222,147,.3);
  }
}

/* มือถือ/แท็บเล็ต + ตอนคลิกจริง: นิ้วแตะ = จมลงเล็กน้อย + แสงเรืองสั้น ๆ ใต้ปุ่ม */
.btn:active:not(:disabled) {
  transform: translateY(0) scale(.985);
  box-shadow: 0 2px 6px -2px rgba(243,222,147,.35);
}
.btn.danger:active:not(:disabled) {
  box-shadow: 0 2px 5px -2px rgba(224,88,77,.3);
}
.menu-btn:active, .game-card:active, .choice-card:active {
  transform: translateY(0) scale(.985);
  box-shadow: 0 2px 6px -2px rgba(243,222,147,.3);
}

/* ผู้ใช้ที่ตั้งค่า "ลดการเคลื่อนไหว" ในเครื่อง: ปิดอนิเมชันให้ */
@media (prefers-reduced-motion: reduce) {
  .btn, .menu-btn, .game-card, .choice-card { transition: none; }
}
/* ============ END Button animations v5 ============ */

