@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700;800&family=Inter:wght@400;500;600;700;800;900&family=Roboto+Mono:wght@500;700&display=swap');

:root {
  --gold: #d4af37;
  --gold-light: #f1c40f;
  --gold-dark: #8b6914;
  --felt: #0d5c2a;
  --felt-deep: #062818;
  --felt-darker: #021d10;
  --wood: #3e2723;
  --red: #c0392b;
  --red-light: #e74c3c;
  --red-dark: #8b1a0d;
  --green: #27ae60;
  --green-light: #2ecc71;
  --blue: #3498db;
  --blue-dark: #1f618d;
  --purple: #8e44ad;
  --purple-dark: #5b2c6f;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background:
    radial-gradient(ellipse at 50% 35%, rgba(46,141,73,0.5) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 100%, rgba(0,0,0,0.6) 0%, transparent 50%),
    linear-gradient(180deg, var(--felt) 0%, var(--felt-deep) 60%, var(--felt-darker) 100%);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: #f5f5f5;
  height: 100vh;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}
body::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,0.015) 1px, transparent 1.5px),
    radial-gradient(circle at 80% 70%, rgba(0,0,0,0.06) 1px, transparent 1.5px);
  background-size: 36px 36px, 28px 28px;
  pointer-events: none;
  z-index: 0;
}
body::after {
  content: '';
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(0,0,0,0.65) 100%);
  pointer-events: none;
  z-index: 0;
}

/* ============ HEADER ============ */
#header {
  background:
    linear-gradient(180deg, rgba(20,20,20,0.85) 0%, rgba(10,10,10,0.65) 100%);
  border-bottom: 2px solid var(--gold);
  padding: 8px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  position: relative;
  z-index: 10;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(0,0,0,0.55);
}
#header::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -4px;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(212,175,55,0.6), transparent);
  pointer-events: none;
}
#header h1 {
  font-family: 'Cinzel', 'Georgia', serif;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 2.5px;
  background: linear-gradient(180deg, #ffe896 0%, #d4af37 50%, #8b6914 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 2px 8px rgba(212,175,55,0.4);
  display: flex; align-items: center; gap: 10px;
}
#header h1::before { content: '\2660'; font-size: 16px; -webkit-text-fill-color: var(--gold); }
#header h1::after  { content: '\2663'; font-size: 16px; -webkit-text-fill-color: var(--gold); }

#header .right-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

#header button {
  background: linear-gradient(180deg, #c0392b 0%, #7c1b10 100%);
  color: white;
  border: 1px solid rgba(255,255,255,0.18);
  padding: 7px 16px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow:
    0 3px 8px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.25),
    inset 0 -2px 4px rgba(0,0,0,0.3);
  transition: all 0.15s ease;
}
#header button:hover {
  background: linear-gradient(180deg, #e74c3c 0%, #a02818 100%);
  transform: translateY(-2px);
  box-shadow:
    0 7px 16px rgba(0,0,0,0.6),
    0 0 14px rgba(231,76,60,0.4),
    inset 0 1px 0 rgba(255,255,255,0.35);
}
#header button:active { transform: translateY(0); }

.ai-toggle {
  display: flex; align-items: center; gap: 7px;
  cursor: pointer; user-select: none;
  font-size: 11px; font-weight: 700; letter-spacing: 0.4px;
  background: rgba(0,0,0,0.55);
  padding: 6px 12px; border-radius: 6px;
  border: 1px solid rgba(46,204,113,0.55);
  color: #ecf0f1;
  transition: all 0.2s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.05);
}
.ai-toggle input { width: 15px !important; height: 15px !important; }
.ai-toggle:hover { background: rgba(46,204,113,0.15); border-color: var(--green-light); transform: translateY(-1px); }
.ai-toggle input { width: 18px; height: 18px; cursor: pointer; accent-color: var(--green-light); }
.ai-toggle.off { border-color: rgba(127,140,141,0.6); color: #95a5a6; }
.ai-toggle.off:hover { background: rgba(0,0,0,0.55); }
.ai-status { font-size: 11px; opacity: 0.85; font-weight: 800; letter-spacing: 1px; }

/* ============ SCOREBOARD ============ */
#scoreboard {
  background: rgba(0,0,0,0.55);
  border-bottom: 1px solid rgba(212,175,55,0.25);
  padding: 5px 20px;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  position: relative;
  z-index: 5;
  flex-shrink: 0;
  box-shadow: 0 3px 8px rgba(0,0,0,0.4);
}
#scoreboard .bet-info {
  background: linear-gradient(180deg, rgba(255,255,255,0.05) 0%, rgba(0,0,0,0.4) 100%);
  border: 1px solid rgba(212,175,55,0.45);
  border-radius: 18px;
  padding: 4px 12px;
  display: flex; align-items: center; gap: 6px;
  font-size: 10.5px; font-weight: 700;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.85);
  text-transform: uppercase;
  box-shadow: 0 2px 5px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.1);
}
.bet-info .bet-label { color: rgba(255,255,255,0.7); }
.bet-info .bet-eq { color: var(--gold); font-weight: 900; }
.bet-info .bet-amount {
  font-family: 'Roboto Mono', 'Courier New', monospace;
  color: var(--gold-light);
  font-weight: 800;
  letter-spacing: 0.6px;
  text-shadow: 0 0 8px rgba(241,196,15,0.4);
}
.bet-divider { height: 18px; width: 1px; background: rgba(212,175,55,0.45); }

/* Per-player chip display (in player header) */
.player-chip-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: linear-gradient(180deg, rgba(255,215,0,0.12) 0%, rgba(0,0,0,0.5) 100%);
  border: 1px solid rgba(212,175,55,0.55);
  padding: 2px 8px;
  border-radius: 10px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.1);
  font-family: 'Roboto Mono', monospace;
  font-size: 11.5px; font-weight: 800;
  letter-spacing: 0.4px;
}
.player-chip-badge .chip-icon-sm { width: 12px; height: 12px; border-width: 2px; }
.player-meta { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }

.chip-icon {
  width: 22px; height: 22px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, #ffe896 0%, #f1c40f 35%, #d4af37 65%, #8b6914 100%);
  border: 3px dashed #fff;
  box-shadow:
    0 3px 8px rgba(0,0,0,0.6),
    inset 0 0 4px rgba(0,0,0,0.4);
  display: inline-block; vertical-align: middle;
  position: relative; flex-shrink: 0;
}
.chip-icon::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.4) 0%, transparent 60%);
  pointer-events: none;
}
.chip-icon-sm { width: 16px; height: 16px; border-width: 2px; }

.chip-amount {
  font-family: 'Roboto Mono', 'Courier New', monospace;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.8px;
}
.chip-amount.normal { color: var(--gold-light); text-shadow: 0 0 6px rgba(241,196,15,0.3); }
.chip-amount.low { color: var(--red-light); text-shadow: 0 0 8px rgba(231,76,60,0.55); }
.chip-amount.high { color: var(--green-light); text-shadow: 0 0 8px rgba(46,204,113,0.55); }

/* ============ RENAME MODAL ============ */
.rename-modal {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at center, rgba(0,10,5,0.88) 0%, rgba(0,0,0,0.96) 100%);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 240;
}
.rename-modal .rename-card {
  background: linear-gradient(180deg, #1f3328 0%, #0a1a12 100%);
  border: 2px solid rgba(212,175,55,0.6);
  border-radius: 14px;
  padding: 24px 32px;
  min-width: 360px; max-width: 92vw;
  box-shadow: 0 20px 50px rgba(0,0,0,0.85), 0 0 60px rgba(212,175,55,0.18);
}
.rename-modal h2 {
  font-family: 'Cinzel', serif;
  font-size: 24px; letter-spacing: 3px;
  background: linear-gradient(180deg, #ffe896 0%, #d4af37 50%, #8b6914 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 16px; text-align: center;
}
.rename-modal .rn-field {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
}
.rename-modal .rn-field label {
  flex: 0 0 130px; font-size: 13px; color: #d4af37; font-weight: 700;
  letter-spacing: 0.5px;
}
.rename-modal .rn-field input {
  flex: 1; background: rgba(0,0,0,0.5); border: 1px solid rgba(212,175,55,0.4);
  color: white; padding: 8px 12px; border-radius: 6px; font-size: 14px;
  font-family: 'Inter', sans-serif; outline: none;
}
.rename-modal .rn-field input:focus { border-color: #d4af37; box-shadow: 0 0 8px rgba(212,175,55,0.4); }
.rename-modal .rn-btn-row {
  display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap;
}
.rename-modal button {
  padding: 10px 22px; border: none; border-radius: 6px;
  font-weight: 700; letter-spacing: 1px; cursor: pointer; font-size: 13px;
}
.rename-modal button.primary {
  background: linear-gradient(180deg, #2ecc71 0%, #167a40 100%); color: white;
}
.rename-modal button.secondary {
  background: linear-gradient(180deg, #5d6d7e 0%, #34495e 100%); color: #ecf0f1;
}
.rename-modal button.warn {
  background: linear-gradient(180deg, #c0392b 0%, #6e1810 100%); color: white;
}

/* Highlight HUMAN player row in result tables */
table.score-table tr.human-row td {
  background: linear-gradient(90deg, rgba(46,204,113,0.22), rgba(46,204,113,0.08)) !important;
  color: #5dd690 !important;
  font-weight: 800 !important;
}
table.score-table tr.human-row td.name-col { color: #2ecc71 !important; }
table.score-table tr.human-row td.rank-col b { color: #2ecc71 !important; text-shadow: 0 0 8px rgba(46,204,113,0.45); }

/* ============ MESSAGE ============ */
/* Message hiện ở BOTTOM của play-area (cuối bàn cờ) thay vì top page.
   Không che bài, người chơi nhìn thấy ngay khi nhìn vào giữa bàn. */
#message {
  /* Absolute ở bottom-center của play-area (vì play-area có position: relative).
     Không ảnh hưởng layout cards giữa bàn. */
  position: absolute;
  bottom: 14px; left: 50%;
  transform: translateX(-50%);
  text-align: center;
  padding: 5px 22px;
  font-size: 13px;
  min-height: 26px;
  background: rgba(0,0,0,0.78);
  font-weight: 700;
  letter-spacing: 0.5px;
  color: rgba(255,255,255,0.96);
  z-index: 6;
  display: flex; align-items: center; justify-content: center;
  max-width: 88%;
  border-radius: 16px;
  border: 1px solid rgba(212,175,55,0.55);
  box-shadow: 0 2px 12px rgba(0,0,0,0.7), inset 0 1px 0 rgba(255,255,255,0.06);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#message:empty { display: none; }
#message.waiting {
  background: linear-gradient(90deg, rgba(231,76,60,0.7) 0%, rgba(192,57,43,0.85) 50%, rgba(231,76,60,0.7) 100%) !important;
  color: white;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 1.2px;
  border-color: rgba(255,180,170,0.7);
  animation: waitingFlash 0.9s ease-in-out infinite;
}
@keyframes waitingFlash {
  0%, 100% { box-shadow: 0 2px 12px rgba(231,76,60,0.5); }
  50%      { box-shadow: 0 2px 22px rgba(231,76,60,0.95); }
}

/* ============ SETUP BANNER ============ */
.setup-banner {
  display: none;
  text-align: center;
  padding: 7px;
  font-size: 12.5px; font-weight: 700;
  letter-spacing: 0.8px;
  background: linear-gradient(90deg, #5b2c6f, #8e44ad, #5b2c6f);
  background-size: 200% 100%;
  animation: bannerShift 3s linear infinite;
  border-bottom: 2px solid rgba(255,255,255,0.25);
  color: white;
  z-index: 5; position: relative;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(0,0,0,0.5);
}
.setup-banner.show { display: block; }
@keyframes bannerShift { 0% { background-position: 0% 50%; } 100% { background-position: 200% 50%; } }

/* ============ TABLE LAYOUT ============ */
.table {
  display: grid;
  grid-template-areas:
    ".    top    ."
    "left center right"
    ".    bottom .";
  grid-template-columns: minmax(200px,1fr) minmax(320px,2.2fr) minmax(200px,1fr);
  grid-template-rows: minmax(0,0.85fr) minmax(0,1fr) minmax(0,0.85fr);
  gap: 6px;
  padding: 8px;
  max-width: 1500px;
  margin: 0 auto;
  position: relative; z-index: 5;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow: hidden;
}

.p-top { grid-area: top; }
.p-left { grid-area: left; display: flex; flex-direction: column; justify-content: center; }
.p-right { grid-area: right; display: flex; flex-direction: column; justify-content: center; }
.p-bottom { grid-area: bottom; }

.p-left .cards-row, .p-right .cards-row { flex-wrap: wrap; padding-left: 20px; min-height: 64px; }

/* ============ PLAYER AREA ============ */
.player-area {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.05) 0%, rgba(0,0,0,0.35) 100%);
  border-radius: 10px;
  padding: 6px 10px;
  position: relative;
  border: 2px solid transparent;
  transition: all 0.3s ease;
  min-height: 0;
  box-shadow:
    0 4px 12px rgba(0,0,0,0.45),
    inset 0 1px 0 rgba(255,255,255,0.08);
}
.player-area.passed-round { overflow: hidden; }
.player-area.in-round {
  border-color: rgba(46,204,113,0.55);
  background: linear-gradient(180deg, rgba(46,204,113,0.07) 0%, rgba(0,0,0,0.35) 100%);
  box-shadow:
    0 6px 18px rgba(0,0,0,0.45),
    0 0 16px rgba(46,204,113,0.25),
    inset 0 1px 0 rgba(255,255,255,0.08);
}
.player-area.active {
  border-color: var(--gold) !important;
  background: linear-gradient(180deg, rgba(255,215,0,0.18) 0%, rgba(0,0,0,0.35) 100%) !important;
  animation: activePulse 1.8s ease-in-out infinite;
}
@keyframes activePulse {
  0%, 100% {
    box-shadow:
      0 0 25px rgba(255,215,0,0.55),
      inset 0 0 22px rgba(255,215,0,0.12),
      0 6px 18px rgba(0,0,0,0.45);
  }
  50% {
    box-shadow:
      0 0 45px rgba(255,215,0,0.85),
      inset 0 0 28px rgba(255,215,0,0.22),
      0 6px 18px rgba(0,0,0,0.45);
  }
}
.player-area.finished {
  opacity: 0.42;
  filter: grayscale(0.6);
  background: rgba(0,0,0,0.55);
}
.player-area.passed-round {
  background:
    repeating-linear-gradient(45deg, transparent, transparent 12px, rgba(231,76,60,0.06) 12px, rgba(231,76,60,0.06) 24px),
    rgba(35,18,18,0.65) !important;
  border: 2px dashed rgba(231,76,60,0.7) !important;
  box-shadow: 0 6px 18px rgba(0,0,0,0.45), inset 0 0 30px rgba(231,76,60,0.08);
}
.player-area.passed-round::after {
  content: 'ĐÃ BỎ LƯỢT';
  position: absolute;
  bottom: 10px; right: 14px;
  font-family: 'Cinzel', serif;
  font-size: 16px; font-weight: 900;
  color: rgba(231,76,60,0.85);
  letter-spacing: 4px;
  pointer-events: none;
  text-shadow: 0 2px 5px rgba(0,0,0,0.85), 0 0 8px rgba(231,76,60,0.4);
  transform: rotate(-8deg);
}
.player-area.passed-round .card { filter: grayscale(0.85) brightness(0.55) opacity(0.55); }
.player-area.passed-round .player-name {
  color: #888;
  text-decoration: line-through;
  text-decoration-color: rgba(231,76,60,0.6);
}

.player-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 4px; font-size: 12px; padding: 0 2px;
  gap: 6px;
}
/* Footer dưới cards: 2 hàng riêng biệt, đều căn giữa.
   Hàng 1: nickname + badges. Hàng 2: chip + card count. */
.player-footer {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; margin-top: 6px; padding: 4px 8px;
  font-size: 12px;
}
.player-footer .pf-row {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; flex-wrap: wrap;
}
.player-name {
  font-weight: 800; font-size: 13.5px; letter-spacing: 0.5px;
  color: white;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
  display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
}

.player-name .badge,
.player-name .badge-pass,
.player-name .badge-inround {
  border-radius: 10px;
  padding: 2px 7px;
  font-size: 9px; font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.3);
}
.player-name .badge {
  background: linear-gradient(180deg, #ffd966 0%, #d68910 100%);
  color: #1a1a1a;
  border: 1px solid rgba(255,255,255,0.35);
  text-shadow: none;
}
.player-name .badge-pass {
  background: linear-gradient(180deg, #e74c3c 0%, #a02818 100%);
  color: white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.3), 0 0 8px rgba(231,76,60,0.5);
}
.player-name .badge-inround {
  background: linear-gradient(180deg, #2ecc71 0%, #1e8449 100%);
  color: white;
}

.card-count {
  color: rgba(255,255,255,0.78);
  font-size: 11px; font-weight: 700;
  background: rgba(0,0,0,0.45);
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  font-family: 'Roboto Mono', monospace;
  letter-spacing: 0.5px;
}

/* ===== Big center turn timer (current player's main countdown) ===== */
.center-timer {
  position: absolute;
  top: 14px; left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 8px 18px;
  border-radius: 14px;
  font-family: 'Roboto Mono', monospace;
  font-size: 22px; font-weight: 900;
  letter-spacing: 1px;
  color: #fff;
  background: linear-gradient(180deg, rgba(46,204,113,0.40) 0%, rgba(0,0,0,0.75) 100%);
  border: 2px solid rgba(46,204,113,0.80);
  box-shadow:
    0 0 22px rgba(46,204,113,0.55),
    0 4px 14px rgba(0,0,0,0.55),
    inset 0 1px 0 rgba(255,255,255,0.15);
  text-shadow: 0 2px 4px rgba(0,0,0,0.7);
  white-space: nowrap;
  pointer-events: none;
}
.center-timer.hidden { display: none; }
.center-timer .ct-icon { font-size: 22px; }
.center-timer .ct-main {
  font-size: 30px; font-weight: 900;
  color: #fff;
  min-width: 50px; text-align: center;
}
.center-timer .ct-sep {
  width: 1px; height: 26px;
  background: rgba(255,255,255,0.35);
  margin: 0 4px;
}
.center-timer .ct-dp-label {
  font-size: 13px; font-weight: 700;
  color: rgba(255,255,255,0.78);
  letter-spacing: 0.6px;
}
.center-timer .ct-dp-val {
  font-size: 20px; font-weight: 900;
  color: #ffd966;
}
.center-timer.warn {
  background: linear-gradient(180deg, rgba(243,156,18,0.50) 0%, rgba(0,0,0,0.75) 100%);
  border-color: rgba(243,156,18,0.85);
  box-shadow: 0 0 26px rgba(243,156,18,0.65), 0 4px 14px rgba(0,0,0,0.55);
  animation: centerTimerPulse 0.55s ease-in-out infinite;
}
.center-timer.using-reserve {
  background: linear-gradient(180deg, rgba(231,76,60,0.55) 0%, rgba(0,0,0,0.75) 100%);
  border-color: rgba(231,76,60,0.95);
  box-shadow: 0 0 30px rgba(231,76,60,0.75), 0 4px 14px rgba(0,0,0,0.55);
  animation: centerTimerPulse 0.45s ease-in-out infinite;
}
.center-timer.using-reserve .ct-main { color: #fff; }
.center-timer.using-reserve .ct-dp-val { color: #fff; }
@keyframes centerTimerPulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.05); }
}

/* ===== Per-player reserve pill (each player owns their own DP) ===== */
.timer-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: 'Roboto Mono', monospace;
  font-size: 11px; font-weight: 800;
  padding: 2px 9px;
  border-radius: 10px;
  background: rgba(0,0,0,0.45);
  color: rgba(255,255,255,0.62);
  border: 1px solid rgba(255,255,255,0.10);
  letter-spacing: 0.4px;
  white-space: nowrap;
}
/* Player đang lượt: highlight DP để biết "đồng hồ này đang đếm" */
.timer-pill.timer-current {
  background: linear-gradient(180deg, rgba(46,204,113,0.28) 0%, rgba(0,0,0,0.55) 100%);
  color: #fff;
  border-color: rgba(46,204,113,0.65);
  box-shadow: 0 0 8px rgba(46,204,113,0.45);
}
.timer-pill.timer-current.using-reserve {
  background: linear-gradient(180deg, rgba(231,76,60,0.45) 0%, rgba(0,0,0,0.55) 100%);
  border-color: rgba(231,76,60,0.85);
  color: #fff;
  box-shadow: 0 0 10px rgba(231,76,60,0.65);
  animation: timerPulse 0.5s ease-in-out infinite;
}
@keyframes timerPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
.timer-reserve-label { opacity: 0.78; font-weight: 700; }
.timer-reserve-val { color: #ffd966; font-weight: 900; }
.timer-pill.timer-current.using-reserve .timer-reserve-val { color: #fff; }

.cards-row {
  display: flex; flex-wrap: wrap;
  align-items: flex-end;
  min-height: 92px;
  padding: 6px 0 4px 28px;
  position: relative;  /* để ranking-badge anchor vào cards-row, không đè footer */
}
/* Face-down 3-card display: căn giữa cho đẹp (không có info nên centered) */
.cards-row.face-down-row {
  justify-content: center;
  padding-left: 0; padding-right: 0;
}
.p-left .cards-row.face-down-row,
.p-right .cards-row.face-down-row {
  padding-left: 0;
  justify-content: center;
}

/* ============ POKER CARDS (classic Georgia serif, lifted from poker.html) ============ */
.card {
  width: 66px;
  height: 92px;
  background: linear-gradient(145deg, #ffffff 0%, #f4f4f4 100%);
  border-radius: 8px;
  border: 1px solid #bbb;
  margin-left: -26px;
  position: relative;
  font-weight: 900;
  font-family: 'Georgia', 'Times New Roman', serif;
  user-select: none;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 3px 4px 9px rgba(0,0,0,0.7), inset 0 0 0 1px rgba(0,0,0,0.06);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s;
}
.card:first-child { margin-left: 0; }
.card::before { display: none; }

.card .corner-tl, .card .corner-br {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 0.92;
  font-family: 'Georgia', 'Times New Roman', serif;
}
.card .corner-tl { top: 3px; left: 5px; }
.card .corner-br { bottom: 3px; right: 5px; transform: rotate(180deg); }
.card .corner-rank {
  font-size: 20px;
  letter-spacing: -1px;
  font-weight: 900;
  line-height: 0.92;
}
.card .corner-suit {
  font-size: 15px;
  margin-top: 1px;
  line-height: 1;
}

.card .center-suit {
  position: absolute;
  top: 52%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 46px;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(0,0,0,0.08);
  font-weight: normal;
}

.card.red  { color: #d11b1b; }
.card.black { color: #111; }
/* Card back (úp bài) - poker-style diagonal pattern + centered emblem */
.card.card-back {
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.06) 0 6px, transparent 6px 14px),
    linear-gradient(135deg, #2c5491 0%, #1a3a5c 50%, #0a2240 100%);
  border: 1px solid #4a7aac;
  box-shadow: 3px 4px 9px rgba(0,0,0,0.7), inset 0 0 0 2px rgba(255,255,255,0.08);
  cursor: default;
}
.card.card-back::after {
  content: '\2660';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 38px;
  color: rgba(212,175,55,0.45);
  font-family: serif;
  text-shadow: 0 0 12px rgba(212,175,55,0.35);
}
.card.card-back.small::after { font-size: 26px; }

.card.red { color: #c0392b; }
.card.black { color: #1a1a1a; }

.card.clickable, .card.cuop-clickable, .card.setup-clickable { cursor: pointer; }

.card.clickable:hover {
  transform: translateY(-12px);
  box-shadow:
    0 12px 22px rgba(0,0,0,0.6),
    0 0 0 2px var(--gold),
    0 0 18px rgba(255,215,0,0.7);
  /* không z-index để giữ stacking tự nhiên (lá kế tiếp vẫn đè 1 phần) */
}
.card.cuop-clickable:hover {
  transform: translateY(-12px);
  box-shadow:
    0 12px 22px rgba(0,0,0,0.6),
    0 0 0 2px var(--red),
    0 0 18px rgba(231,76,60,0.7);
}

.card.selected {
  transform: translateY(-26px) scale(1.06);
  box-shadow:
    0 16px 28px rgba(0,0,0,0.7),
    0 0 0 3px var(--gold),
    0 0 28px rgba(255,215,0,0.95),
    0 0 8px rgba(255,215,0,0.5);
  /* KHÔNG set z-index để giữ stacking tự nhiên: lá kế tiếp (right) vẫn đè lên 1 phần của
     lá đã chọn, đúng như stack bài tay thật. */
}
.card.selected::after {
  content: '\2713';
  position: absolute;
  top: -10px; right: -9px;
  width: 22px; height: 22px;
  background: linear-gradient(180deg, #FFD700 0%, #d4af37 100%);
  color: #1a1a1a;
  border: 2px solid #1a1a1a;
  border-radius: 50%;
  font-size: 13px; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 6px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.6);
  z-index: 3;
}

.card.cuop-selected {
  transform: translateY(-26px) scale(1.06);
  box-shadow:
    0 16px 28px rgba(0,0,0,0.7),
    0 0 0 3px var(--red),
    0 0 28px rgba(231,76,60,0.95);
  /* không z-index - giữ stacking tự nhiên */
}
.card.cuop-selected::after {
  content: '\2713';
  position: absolute;
  top: -10px; right: -9px;
  width: 22px; height: 22px;
  background: var(--red);
  color: white;
  border: 2px solid white;
  border-radius: 50%;
  font-size: 13px; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 6px rgba(0,0,0,0.55);
  z-index: 3;
}

.card.setup-clickable:hover {
  transform: translateY(-10px);
  box-shadow: 0 12px 22px rgba(0,0,0,0.6), 0 0 0 2px var(--purple), 0 0 18px rgba(155,89,182,0.7);
  /* không z-index - giữ stacking tự nhiên */
}
.card.setup-source {
  transform: translateY(-22px) scale(1.06);
  box-shadow: 0 16px 28px rgba(0,0,0,0.7), 0 0 0 3px var(--red-light), 0 0 28px rgba(231,76,60,1);
}

/* Small cards (side players) - Georgia serif style scaled down */
.card.small { width: 46px; height: 64px; margin-left: -19px; border-radius: 6px; }
.card.small:first-child { margin-left: 0; }
.card.small .corner-tl { top: 2px; left: 3px; }
.card.small .corner-br { bottom: 2px; right: 3px; transform: rotate(180deg); }
.card.small .corner-rank { font-size: 14px; letter-spacing: -0.7px; }
.card.small .corner-suit { font-size: 11px; margin-top: 0; }
.card.small .center-suit { font-size: 32px; }

/* ============ PLAY AREA (CENTER) ============ */
#play-area {
  grid-area: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at center, rgba(20,90,42,0.5) 0%, rgba(0,0,0,0.5) 80%);
  border-radius: 80px;
  border: 2px solid rgba(212,175,55,0.45);
  min-height: 0;
  padding: 8px;
  position: relative;
  box-shadow:
    inset 0 0 50px rgba(0,0,0,0.7),
    0 0 25px rgba(0,0,0,0.55);
}
#play-area::before {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1px dashed rgba(212,175,55,0.25);
  border-radius: 75px;
  pointer-events: none;
}
#play-area .label {
  font-family: 'Cinzel', serif;
  font-size: 11px;
  color: var(--gold);
  letter-spacing: 3px;
  margin-bottom: 6px;
  text-shadow: 0 0 12px rgba(212,175,55,0.6), 0 1px 2px rgba(0,0,0,0.7);
  text-transform: uppercase;
  font-weight: 700;
}
#play-area .played-cards {
  position: relative;
  width: 100%;
  min-height: 110px;
  display: block;
}

/* Each round-play is a "stack" tossed onto the table at an angle.
   Older stacks (lower z-index) peek out from under the latest. */
.played-stack {
  position: absolute;
  top: 50%; left: 50%;
  display: flex;
  align-items: center;
  padding-left: 26px;
  transform-origin: center center;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.45));
}
.played-stack:not(.latest) {
  opacity: 0.6;
}
.played-stack.latest {
  opacity: 1;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.65));
}
#play-area .play-info {
  font-size: 11px;
  color: rgba(255,255,255,0.92);
  margin-top: 7px;
  font-weight: 700;
  letter-spacing: 0.6px;
  background: rgba(0,0,0,0.55);
  padding: 3px 11px;
  border-radius: 11px;
  border: 1px solid rgba(212,175,55,0.4);
  box-shadow: 0 2px 5px rgba(0,0,0,0.4);
}
/* Tour timer badge inside play area */
#play-area .tour-table-timer {
  position: absolute;
  top: 14px; right: 18px;
  background: linear-gradient(180deg, rgba(0,0,0,0.85) 0%, rgba(20,40,30,0.85) 100%);
  border: 2px solid rgba(212,175,55,0.6);
  border-radius: 10px;
  padding: 6px 12px 6px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  z-index: 5;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5), inset 0 1px 0 rgba(212,175,55,0.3);
  min-width: 78px;
}
#play-area .tour-table-timer .lbl {
  font-family: 'Cinzel', serif; font-size: 9px;
  letter-spacing: 2px; color: #d4af37; font-weight: 700;
}
#play-area .tour-table-timer .clock {
  font-family: 'Roboto Mono', monospace; font-size: 22px;
  font-weight: 700; color: #2ecc71;
  text-shadow: 0 0 10px rgba(46,204,113,0.4);
  line-height: 1;
}
#play-area .tour-table-timer .clock.warn { color: #e67e22; text-shadow: 0 0 10px rgba(230,126,34,0.5); }
#play-area .tour-table-timer .clock.expired { color: #e74c3c; text-shadow: 0 0 10px rgba(231,76,60,0.5); font-size: 12px; }
#play-area .tour-table-timer .info {
  font-size: 9px; color: #95a5a6; letter-spacing: 1px;
  margin-top: 2px;
}

/* ============ ACTIONS (BUTTONS) ============ */
#actions {
  text-align: center;
  padding: 8px;
  background: linear-gradient(180deg, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0.78) 100%);
  border-top: 2px solid rgba(212,175,55,0.4);
  position: relative; z-index: 5;
  flex-shrink: 0;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.55);
}
#actions::before {
  content: '';
  position: absolute;
  top: -4px; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(212,175,55,0.6), transparent);
}
#actions button {
  padding: 8px 24px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 7px;
  cursor: pointer;
  margin: 0 4px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  transition: all 0.15s ease;
  box-shadow:
    0 3px 8px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.28),
    inset 0 -2px 4px rgba(0,0,0,0.25);
}
#actions button:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow:
    0 7px 16px rgba(0,0,0,0.6),
    inset 0 1px 0 rgba(255,255,255,0.4);
}
#actions button:not(:disabled):active { transform: translateY(0); }
#actions button:disabled {
  background: linear-gradient(180deg, #555 0%, #333 100%) !important;
  color: #888 !important;
  cursor: not-allowed !important;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3) !important;
  transform: none !important;
  border-color: rgba(255,255,255,0.05) !important;
}

/* btn-play & btn-pass: cả 2 đều xanh lá khi active để dễ phân biệt với trạng thái disabled (xám).
   btn-play màu xanh sáng, btn-pass xanh đậm hơn để phân biệt 2 nút. */
#btn-play { background: linear-gradient(180deg, #2ecc71 0%, #167a40 100%); color: white; }
#btn-play:not(:disabled):hover { background: linear-gradient(180deg, #58d68d 0%, #229954 100%); box-shadow: 0 7px 16px rgba(0,0,0,0.6), 0 0 12px rgba(46,204,113,0.5), inset 0 1px 0 rgba(255,255,255,0.4); }

#btn-pass { background: linear-gradient(180deg, #16a085 0%, #0e6655 100%); color: white; }
#btn-pass:not(:disabled):hover { background: linear-gradient(180deg, #1abc9c 0%, #117864 100%); box-shadow: 0 7px 16px rgba(0,0,0,0.6), 0 0 12px rgba(26,188,156,0.5), inset 0 1px 0 rgba(255,255,255,0.4); }

#btn-sort { background: linear-gradient(180deg, #3498db 0%, #1a5276 100%); color: white; }
#btn-sort:hover { background: linear-gradient(180deg, #5dade2 0%, #2874a6 100%); box-shadow: 0 7px 16px rgba(0,0,0,0.6), 0 0 12px rgba(52,152,219,0.5), inset 0 1px 0 rgba(255,255,255,0.4); }

#btn-cuop { background: linear-gradient(180deg, #e74c3c 0%, #7c1b10 100%); color: white; display: none; }
#btn-cuop.show { display: inline-block; }
#btn-cuop:hover { background: linear-gradient(180deg, #ec7063 0%, #a02818 100%); box-shadow: 0 7px 16px rgba(0,0,0,0.6), 0 0 14px rgba(231,76,60,0.7), inset 0 1px 0 rgba(255,255,255,0.4); }

#btn-start-game { background: linear-gradient(180deg, #af7ac5 0%, #5b2c6f 100%); color: white; }
#btn-start-game.hidden { display: none; }
#btn-start-game:hover { background: linear-gradient(180deg, #bb8fd6 0%, #76448a 100%); box-shadow: 0 7px 16px rgba(0,0,0,0.6), 0 0 14px rgba(155,89,182,0.6); }

/* ============ PLAYER CUOP BUTTON ============ */
.player-cuop-btn {
  position: absolute;
  top: 4px; right: 6px;
  background: linear-gradient(180deg, #ff6b5b 0%, #a02818 100%);
  color: white;
  border: 2px solid rgba(255,255,255,0.85);
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  cursor: pointer;
  z-index: 30;
  box-shadow:
    0 3px 8px rgba(0,0,0,0.55),
    0 0 14px rgba(231,76,60,0.95),
    inset 0 1px 0 rgba(255,255,255,0.3);
  animation: cuopBtnPulse 0.85s ease-in-out infinite;
  transition: transform 0.1s;
  font-family: 'Inter', sans-serif;
}
.player-cuop-btn:hover { transform: scale(1.12); }
@keyframes cuopBtnPulse {
  0%, 100% { box-shadow: 0 4px 12px rgba(0,0,0,0.55), 0 0 12px rgba(231,76,60,0.85), inset 0 1px 0 rgba(255,255,255,0.3); transform: scale(1); }
  50% { box-shadow: 0 4px 12px rgba(0,0,0,0.55), 0 0 28px rgba(231,76,60,1), inset 0 1px 0 rgba(255,255,255,0.5); transform: scale(1.07); }
}

/* ============ OVERLAYS ============ */
.overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(0,10,5,0.85) 0%, rgba(0,0,0,0.95) 100%);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 100;
  overflow-y: auto;
  padding: 20px;
}
/* Compact variant: modal nhỏ ở giữa màn hình (không backdrop blur) → vẫn nhìn được cards đối thủ xung quanh.
   Position fixed ở center để chắc chắn hiện ra, không phụ thuộc parent positioning. */
.overlay.compact {
  position: fixed !important;
  inset: auto !important;
  top: 50% !important; left: 50% !important;
  transform: translate(-50%, -50%) !important;
  width: auto !important;
  /* Kéo ngang ra rộng bằng bàn chơi (~table max-width 1500px), pad 95vw cho viewport nhỏ. */
  max-width: min(1280px, 95vw) !important;
  max-height: 80vh !important;
  overflow-y: auto;
  /* 30% transparency = 70% opaque background, để vẫn nhìn được cards và bàn phía dưới. */
  background: linear-gradient(180deg, rgba(20,40,28,0.7) 0%, rgba(8,18,12,0.72) 100%) !important;
  -webkit-backdrop-filter: blur(2px) !important; backdrop-filter: blur(2px) !important;
  padding: 16px 30px !important;
  border: 2px solid rgba(212,175,55,0.8) !important;
  border-radius: 14px !important;
  box-shadow:
    0 14px 40px rgba(0,0,0,0.85),
    0 0 50px rgba(212,175,55,0.25),
    inset 0 1px 0 rgba(255,255,255,0.08) !important;
  z-index: 150 !important;
}
.overlay.compact h2 {
  font-size: 24px !important;
  margin-bottom: 10px !important;
  letter-spacing: 3px !important;
  text-shadow: 0 0 18px rgba(212,175,55,0.5) !important;
}
.overlay.compact button {
  padding: 10px 28px !important;
  font-size: 13px !important;
  letter-spacing: 1.5px !important;
  margin-top: 6px;
}
.overlay.compact table.score-table {
  font-size: 13px;
  width: 100%;
}
.overlay.compact table.score-table th,
.overlay.compact table.score-table td {
  padding: 6px 12px;
  white-space: nowrap;
}
.overlay.compact table.score-table td.note-cell {
  white-space: normal;
  font-size: 12px;
  max-width: none;
}
.overlay h2 {
  font-family: 'Cinzel', serif;
  font-size: 44px;
  font-weight: 800;
  background: linear-gradient(180deg, #ffe896 0%, #d4af37 50%, #8b6914 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 18px;
  letter-spacing: 5px;
  text-shadow: 0 0 35px rgba(212,175,55,0.5);
  text-align: center;
}
.overlay p {
  font-size: 18px;
  margin-bottom: 14px;
  color: rgba(255,255,255,0.95);
  text-align: center;
}
.overlay button {
  padding: 14px 44px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  background: linear-gradient(180deg, #c0392b 0%, #6e1810 100%);
  color: white;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 10px;
  cursor: pointer;
  margin-top: 20px;
  box-shadow:
    0 6px 16px rgba(0,0,0,0.6),
    inset 0 1px 0 rgba(255,255,255,0.3);
  transition: all 0.15s;
}
.overlay button:hover {
  background: linear-gradient(180deg, #e74c3c 0%, #8b1a0d 100%);
  transform: translateY(-2px);
  box-shadow: 0 9px 22px rgba(0,0,0,0.7), 0 0 16px rgba(231,76,60,0.5), inset 0 1px 0 rgba(255,255,255,0.4);
}

/* ============ SCORE TABLE (game over) ============ */
.score-table {
  border-collapse: separate;
  border-spacing: 0;
  margin: 16px 0;
  font-size: 13.5px;
  min-width: 520px;
  background: rgba(0,0,0,0.55);
  border-radius: 12px;
  overflow: hidden;
  box-shadow:
    0 10px 30px rgba(0,0,0,0.6),
    0 0 25px rgba(212,175,55,0.15);
  border: 1px solid rgba(212,175,55,0.3);
}
.score-table th, .score-table td {
  padding: 10px 16px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.score-table th {
  background: linear-gradient(180deg, rgba(212,175,55,0.3) 0%, rgba(212,175,55,0.08) 100%);
  color: var(--gold);
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  border-bottom: 2px solid var(--gold);
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.score-table td.pos { color: var(--green-light); font-weight: 800; text-shadow: 0 0 6px rgba(46,204,113,0.4); }
.score-table td.neg { color: var(--red-light); font-weight: 800; text-shadow: 0 0 6px rgba(231,76,60,0.4); }
.score-table tr.total-row {
  background: rgba(212,175,55,0.1);
  font-weight: 800;
  font-size: 14px;
}
.score-table tr.total-row:last-child {
  background: linear-gradient(180deg, rgba(212,175,55,0.3) 0%, rgba(212,175,55,0.15) 100%) !important;
  font-size: 17px;
}
/* Game-over table: 5-column compact layout (Excel-style) */
.score-table.go-table {
  font-size: 14px;
  min-width: 0;
  width: auto;
  max-width: 900px;
}
.score-table.go-table th { padding: 10px 16px; font-size: 12px; letter-spacing: 1.2px; }
.score-table.go-table td { padding: 11px 16px; font-size: 14px; }
.score-table.go-table td.rank-col {
  font-family: 'Cinzel', serif; color: var(--gold);
  font-size: 15px; letter-spacing: 1.2px;
  min-width: 90px; text-align: center;
  white-space: nowrap;
}
.score-table.go-table td.name-col {
  color: #ecf0f1; font-size: 15px; letter-spacing: 0.5px;
  text-align: left; min-width: 110px;
}
.score-table.go-table td:nth-child(3),
.score-table.go-table td:nth-child(4) {
  font-family: 'Roboto Mono', monospace; text-align: right;
  font-size: 14px; letter-spacing: 0.3px;
}
.score-table.go-table .note-col { min-width: 240px; }
.score-table.go-table .note-cell {
  text-align: left;
  font-size: 12px;
  line-height: 1.5;
  color: #d4c89a;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  max-width: 360px;
  white-space: normal;
}
.score-table.go-table tr:hover { background: rgba(212,175,55,0.05); }

/* ============ RANKING BADGE (medal on player) ============ */
.ranking-badge {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 42px;
  font-weight: bold;
  color: var(--gold-light);
  text-shadow:
    0 0 18px rgba(0,0,0,0.95),
    0 0 32px rgba(212,175,55,0.65);
  z-index: 20;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.7));
}

/* ============ HANG FLASH NOTIFICATION ============ */
/* Đặt sát mép dưới bàn (trên action buttons), không đè cards giữa bàn. */
.hang-flash {
  position: fixed;
  bottom: 70px; left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #c0392b 0%, #6e1810 100%);
  color: white;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  z-index: 90;
  text-align: center;
  max-width: 80vw;
  box-shadow:
    0 6px 18px rgba(0,0,0,0.7),
    0 0 24px rgba(231,76,60,0.55),
    inset 0 1px 0 rgba(255,255,255,0.25);
  border: 1px solid rgba(255,255,255,0.25);
  letter-spacing: 0.3px;
  animation: flashIn 0.25s ease-out, flashOut 0.4s 1.9s ease-in forwards;
}
@keyframes flashIn { from { opacity: 0; transform: translateX(-50%) translateY(20px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
@keyframes flashOut { from { opacity: 1; } to { opacity: 0; transform: translateX(-50%) translateY(20px); } }

/* ============ CHIP DELTA ANIMATION ============ */
.chip-delta {
  position: absolute;
  top: 30%; left: 50%;
  transform: translate(-50%, 0);
  font-size: 24px;
  font-weight: 900;
  font-family: 'Roboto Mono', monospace;
  pointer-events: none;
  z-index: 80;
  text-shadow: 0 0 12px rgba(0,0,0,0.95), 2px 2px 5px rgba(0,0,0,0.9);
  animation: chipFloat 2.2s ease-out forwards;
  white-space: nowrap;
  letter-spacing: 1px;
}
.chip-delta.gain { color: #2ecc71; text-shadow: 0 0 12px rgba(0,0,0,0.95), 0 0 16px rgba(46,204,113,0.85), 2px 2px 4px rgba(0,0,0,0.9); }
.chip-delta.loss { color: #ff6b5b; text-shadow: 0 0 12px rgba(0,0,0,0.95), 0 0 16px rgba(231,76,60,0.85), 2px 2px 4px rgba(0,0,0,0.9); }
@keyframes chipFloat {
  0%   { transform: translate(-50%, 20px) scale(0.4); opacity: 0; }
  20%  { transform: translate(-50%, 0) scale(1.3); opacity: 1; }
  60%  { transform: translate(-50%, -35px) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -80px) scale(0.85); opacity: 0; }
}

/* ============ REFILL POPUP ============ */
.chip-refill-overlay {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(135deg, #ffe896 0%, #f1c40f 35%, #d4af37 70%, #8b6914 100%);
  color: #1a1a1a;
  padding: 36px 70px;
  border-radius: 24px;
  font-family: 'Cinzel', serif;
  font-size: 38px;
  font-weight: 900;
  letter-spacing: 5px;
  text-align: center;
  border: 4px solid var(--gold-light);
  box-shadow:
    0 0 90px rgba(255,215,0,1),
    0 14px 44px rgba(0,0,0,0.65),
    inset 0 0 35px rgba(255,255,255,0.45);
  z-index: 200;
  pointer-events: none;
  animation: refillPop 2.5s ease-out forwards;
  text-transform: uppercase;
}
.chip-refill-overlay .sub {
  font-size: 16px;
  font-weight: 700;
  margin-top: 12px;
  letter-spacing: 2px;
  font-family: 'Inter', sans-serif;
}
@keyframes refillPop {
  0%   { transform: translate(-50%,-50%) scale(0.2) rotate(-15deg); opacity: 0; }
  15%  { transform: translate(-50%,-50%) scale(1.45) rotate(8deg); opacity: 1; }
  30%  { transform: translate(-50%,-50%) scale(1) rotate(0); opacity: 1; }
  85%  { transform: translate(-50%,-50%) scale(1) rotate(0); opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(0.9); opacity: 0; }
}

/* ============ RULES PANEL ============ */
.overlay.rules-overlay { z-index: 230; }
.rules-panel {
  width: 95%; max-width: 1000px; max-height: 88vh;
  background: linear-gradient(180deg, #2c3e50 0%, #1a252f 100%);
  border: 2px solid #d4af37; border-radius: 14px;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7);
}
.rules-head {
  padding: 14px 22px; display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid rgba(212,175,55,0.3);
}
.rules-head h2 {
  margin: 0; font-family: 'Cinzel', serif; color: #d4af37;
  font-size: 22px; letter-spacing: 3px;
}
.overlay.rules-overlay button.rules-close {
  background: rgba(231,76,60,0.85); color: #fff; border: none;
  width: 34px; height: 34px; padding: 0;
  border-radius: 50%; cursor: pointer;
  font-size: 16px; font-weight: 700;
  margin: 0; letter-spacing: 0; text-transform: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
}
.overlay.rules-overlay button.rules-close:hover {
  background: #e74c3c;
  transform: none;
  box-shadow: 0 4px 12px rgba(231,76,60,0.5);
}
.rules-tabs {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(212,175,55,0.2);
  background: rgba(0,0,0,0.35);
}
/* High specificity to override .overlay button defaults */
.overlay.rules-overlay .rules-tabs button.rules-tab {
  background: rgba(255,255,255,0.04);
  color: #bdc3c7;
  border: 1px solid rgba(212,175,55,0.22);
  padding: 6px 12px;
  border-radius: 18px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: none;
  white-space: nowrap;
  margin: 0;
  font-family: 'Inter', sans-serif;
  box-shadow: none;
  transition: all 0.15s;
  display: inline-flex; align-items: center; gap: 4px;
  line-height: 1.2;
}
.overlay.rules-overlay .rules-tabs button.rules-tab:hover {
  background: rgba(212,175,55,0.13);
  color: #ecf0f1;
  border-color: rgba(212,175,55,0.5);
  transform: none;
  box-shadow: none;
}
.overlay.rules-overlay .rules-tabs button.rules-tab.active {
  background: linear-gradient(180deg, #d4af37 0%, #b88f25 100%);
  color: #1a1a1a;
  border-color: #d4af37;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(212,175,55,0.4);
}
.overlay.rules-overlay .rules-tabs button.rules-tab.active:hover {
  background: linear-gradient(180deg, #e3c14a 0%, #c9a02b 100%);
  color: #1a1a1a;
}
.rules-content {
  flex: 1; overflow-y: auto; padding: 18px 24px;
  font-size: 14px; line-height: 1.65; color: #ecf0f1;
  font-family: 'Inter', sans-serif;
}
.rules-content h3 {
  color: #d4af37; font-family: 'Cinzel', serif; font-size: 17px;
  margin: 20px 0 10px 0; padding-bottom: 4px;
  letter-spacing: 1.5px; border-bottom: 1px solid rgba(212,175,55,0.3);
}
.rules-content h3:first-child { margin-top: 0; }
.rules-content p { margin: 8px 0; color: #d5dbdb; }
.rules-content ul { list-style: none; padding: 0; margin: 8px 0; }
.rules-content ul li {
  padding: 5px 0 5px 22px; position: relative; color: #d5dbdb;
}
.rules-content ul li:before {
  content: '◆'; position: absolute; left: 0; color: #d4af37; font-size: 11px; top: 8px;
}
.rules-content ol { padding-left: 24px; margin: 8px 0; color: #d5dbdb; }
.rules-content ol li { padding: 4px 0; }
.rules-content b, .rules-content strong { color: #f1c40f; }
.rules-content .highlight {
  background: linear-gradient(90deg, rgba(212,175,55,0.18) 0%, rgba(212,175,55,0.05) 100%);
  padding: 12px 16px; border-left: 4px solid #d4af37;
  border-radius: 5px; margin: 12px 0;
}
.rules-content .warn {
  background: rgba(231,76,60,0.12); padding: 10px 14px;
  border-left: 4px solid #e74c3c; border-radius: 5px;
  margin: 12px 0; font-size: 13px;
}
.rules-content .ok {
  background: rgba(46,204,113,0.12); padding: 10px 14px;
  border-left: 4px solid #2ecc71; border-radius: 5px;
  margin: 12px 0; font-size: 13px;
}
.rules-content table {
  width: 100%; border-collapse: collapse; margin: 12px 0;
  background: rgba(0,0,0,0.35); border-radius: 8px; overflow: hidden;
  border: 1px solid rgba(212,175,55,0.2);
}
.rules-content th {
  background: linear-gradient(180deg, rgba(212,175,55,0.25) 0%, rgba(212,175,55,0.08) 100%);
  color: #d4af37; padding: 9px 12px; font-size: 12px;
  letter-spacing: 1.2px; text-align: left;
  border-bottom: 1px solid rgba(212,175,55,0.4);
  font-family: 'Cinzel', serif; text-transform: uppercase;
}
.rules-content td {
  padding: 9px 12px; font-size: 13px; color: #d5dbdb;
  border-top: 1px solid rgba(255,255,255,0.04);
  vertical-align: top;
}
.rules-content tr:hover td { background: rgba(212,175,55,0.04); }
.rules-content .pos { color: #2ecc71; font-weight: 700; }
.rules-content .neg { color: #e74c3c; font-weight: 700; }
.rules-content .neutral { color: #f1c40f; font-weight: 700; }
.rules-content .mini-card {
  display: inline-block; padding: 1px 6px; margin: 0 1px;
  background: #fafafa; color: #1a1a1a; border-radius: 3px;
  font-weight: 800; font-family: Georgia, serif; font-size: 12px;
  border: 1px solid #555; line-height: 1.3;
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.rules-content .mini-card.red { color: #d62828; }
/* Real card visual (rank top + suit bottom) for combo examples */
.rules-content .hand {
  display: inline-flex; flex-wrap: wrap; gap: 2px;
  vertical-align: middle; align-items: center;
}
.rules-content .pcard {
  display: inline-flex; flex-direction: column;
  align-items: center; justify-content: center;
  width: 26px; height: 36px; padding: 2px 0;
  background: linear-gradient(180deg, #fff 0%, #ececec 100%);
  color: #1a1a1a; border-radius: 4px;
  font-weight: 800; font-family: Georgia, serif;
  border: 1px solid #444; line-height: 1;
  box-shadow: 0 2px 5px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.7);
  vertical-align: middle;
}
.rules-content .pcard .r { font-size: 13px; letter-spacing: -0.5px; }
.rules-content .pcard .s { font-size: 11px; margin-top: 1px; }
.rules-content .pcard.red { color: #d62828; }
/* Stack đôi/xám gần lại 1 chút cho gọn */
.rules-content .hand.stack .pcard + .pcard { margin-left: -8px; }
.rules-content .hand .gap { width: 4px; display: inline-block; }
.rules-content .key { color: #58e89a; font-family: 'Roboto Mono', monospace; }

/* ============ HISTORY PANEL ============ */
.overlay.history-panel-overlay { z-index: 220; }  /* above mode-overlay(200) and tour-lb(180) */
.history-panel {
  max-width: 900px;
  width: 95%;
  max-height: 75vh;
  display: flex;
  flex-direction: column;
  background: rgba(0,0,0,0.55);
  border-radius: 16px;
  border: 1px solid rgba(212,175,55,0.4);
  padding: 20px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.7);
}
.history-list {
  flex: 1;
  overflow-y: auto;
  padding-right: 6px;
}
.history-row {
  display: grid;
  grid-template-columns: 44px 110px 130px 130px 1fr 90px;
  gap: 8px;
  align-items: center;
  padding: 9px 12px;
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  margin-bottom: 6px;
  border: 1px solid rgba(212,175,55,0.18);
  transition: all 0.15s;
}
.history-row .h-tour-badge {
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  padding: 4px 7px; border-radius: 5px;
  background: linear-gradient(180deg, rgba(212,175,55,0.25) 0%, rgba(139,105,20,0.25) 100%);
  color: #f1c40f; border: 1px solid rgba(212,175,55,0.35);
  text-align: center; font-family: 'Roboto Mono', monospace;
  white-space: nowrap;
}
.history-row .h-tour-badge.cash {
  background: linear-gradient(180deg, rgba(46,204,113,0.18) 0%, rgba(22,160,133,0.18) 100%);
  color: #2ecc71; border-color: rgba(46,204,113,0.4);
}
.history-filter-bar {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px;
  padding-bottom: 10px; border-bottom: 1px solid rgba(212,175,55,0.2);
  max-height: 90px; overflow-y: auto;
}
.history-filter-bar .hf-btn {
  background: rgba(0,0,0,0.4); color: #bdc3c7;
  border: 1px solid rgba(212,175,55,0.3);
  padding: 6px 10px; border-radius: 6px; cursor: pointer;
  font-size: 11px; font-weight: 700; letter-spacing: 1px;
  white-space: nowrap;
}
.history-filter-bar .hf-btn:hover { background: rgba(212,175,55,0.15); color: #ecf0f1; }
.history-filter-bar .hf-btn.active {
  background: linear-gradient(180deg, #d4af37 0%, #8b6914 100%);
  color: #1a1a1a; border-color: #d4af37;
}
.history-filter-bar .hf-btn.tour { font-size: 10px; }
.history-tour-header {
  background: linear-gradient(90deg, rgba(212,175,55,0.22) 0%, rgba(212,175,55,0.05) 100%);
  border: 1px solid rgba(212,175,55,0.35);
  padding: 9px 14px; border-radius: 7px; margin-bottom: 8px;
  color: #d4af37; font-weight: 700; letter-spacing: 1.5px; font-size: 13px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
}
.history-tour-header .hist-export-btn {
  background: linear-gradient(180deg, #2ecc71 0%, #16a085 100%);
  color: #fff; border: 1px solid rgba(255,255,255,0.25);
  padding: 6px 12px; border-radius: 5px; cursor: pointer;
  font-size: 11px; font-weight: 700; letter-spacing: 1px;
}
.history-tour-header .hist-export-btn:hover { filter: brightness(1.15); transform: translateY(-1px); }
.history-round-band {
  background: rgba(46,204,113,0.12);
  color: #2ecc71; padding: 5px 12px; border-radius: 5px;
  font-weight: 700; letter-spacing: 1.5px; font-size: 11px;
  margin: 8px 0 4px 0;
}
.history-row:hover {
  background: rgba(212,175,55,0.1);
  border-color: var(--gold);
}
.history-row .h-id { font-weight: 800; color: var(--gold); text-align: center; font-family: 'Roboto Mono', monospace; }
.history-row .h-time { font-size: 11px; color: #aaa; font-family: 'Roboto Mono', monospace; }
.history-row .h-result { font-weight: 700; }
.history-row .h-chips { font-family: 'Roboto Mono', monospace; font-size: 11px; display: flex; gap: 8px; flex-wrap: wrap; }
.history-row .h-chips span { padding: 2px 6px; border-radius: 4px; }
.history-row .h-chips .pos { background: rgba(46,204,113,0.2); color: #2ecc71; }
.history-row .h-chips .neg { background: rgba(231,76,60,0.2); color: #ff6b5b; }
.history-row .h-chips .zero { color: #aaa; }
.history-row button.h-replay {
  background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold-dark) 100%);
  color: #1a1a1a;
  border: 1px solid #fff;
  padding: 6px 14px;
  border-radius: 6px;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: 1px;
  font-size: 12px;
}
.history-row button.h-replay:hover { transform: translateY(-1px); box-shadow: 0 4px 8px rgba(0,0,0,0.4); }
.history-empty { text-align: center; padding: 40px; color: #888; font-size: 16px; }
.history-clear {
  background: linear-gradient(180deg, #c0392b 0%, #6e1810 100%);
  color: white; border: 1px solid rgba(255,255,255,0.2);
  padding: 8px 18px; border-radius: 7px;
  font-size: 12px; font-weight: 700; letter-spacing: 1px;
  cursor: pointer; text-transform: uppercase;
}
.history-clear:hover { background: linear-gradient(180deg, #e74c3c 0%, #8b1a0d 100%); }

/* ============ REPLAY OVERLAY ============ */
.replay-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.95);
  z-index: 250;
  display: none;
  flex-direction: column;
}
.replay-overlay.open { display: flex; }
.replay-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 20px;
  background: linear-gradient(180deg, rgba(20,20,20,0.9), rgba(0,0,0,0.7));
  border-bottom: 2px solid var(--gold);
  flex-shrink: 0;
}
.replay-title {
  color: var(--gold); font-weight: 800; font-size: 17px; letter-spacing: 1px;
  font-family: 'Cinzel', serif;
}
.replay-close {
  background: linear-gradient(180deg, #c0392b 0%, #7c1b10 100%);
  color: white; border: 1px solid rgba(255,255,255,0.3);
  width: 32px; height: 32px; border-radius: 50%;
  cursor: pointer; font-weight: 900; font-size: 14px;
}
.replay-table {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-areas: ".  rtop  ."  "rleft rcenter rright"  ".  rbot  .";
  grid-template-columns: minmax(180px,1fr) minmax(280px,2fr) minmax(180px,1fr);
  grid-template-rows: minmax(0,0.85fr) minmax(0,1fr) minmax(0,0.85fr);
  gap: 6px; padding: 10px;
  background:
    radial-gradient(ellipse at 50% 35%, rgba(46,141,73,0.5) 0%, transparent 60%),
    linear-gradient(180deg, var(--felt) 0%, var(--felt-deep) 100%);
}
.replay-seat {
  background: linear-gradient(180deg, rgba(255,255,255,0.05) 0%, rgba(0,0,0,0.35) 100%);
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 6px 10px;
  position: relative;
  transition: all 0.3s;
}
.replay-seat-top { grid-area: rtop; }
.replay-seat-bot { grid-area: rbot; }
.replay-seat-left { grid-area: rleft; display: flex; flex-direction: column; justify-content: center; }
.replay-seat-right { grid-area: rright; display: flex; flex-direction: column; justify-content: center; }
.replay-seat.acting {
  border-color: var(--gold);
  box-shadow: 0 0 18px rgba(255,215,0,0.5);
}
.replay-seat.passed {
  background: rgba(40,20,20,0.55) !important;
  border: 2px dashed rgba(231,76,60,0.6) !important;
  opacity: 0.7;
}
.replay-seat.finished {
  opacity: 0.45; filter: grayscale(0.6);
}
.replay-seat .replay-seat-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 4px; font-size: 12px;
}
.replay-seat-name { font-weight: 800; color: white; font-size: 13px; }
.replay-seat-rank-badge {
  background: linear-gradient(180deg, #ffd966, #d68910);
  color: #1a1a1a; border-radius: 10px; padding: 2px 8px;
  font-size: 10px; font-weight: 900; letter-spacing: 1px;
}
.replay-seat-cards-count {
  color: #ccc; font-size: 11px; font-family: 'Roboto Mono', monospace;
  background: rgba(0,0,0,0.5); padding: 2px 7px; border-radius: 8px;
}
.replay-seat-cards {
  display: flex; flex-wrap: wrap; align-items: flex-end;
  padding-left: 18px; min-height: 60px;
}

.replay-center {
  grid-area: rcenter;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(20,90,42,0.5) 0%, rgba(0,0,0,0.5) 80%);
  border-radius: 80px;
  border: 2px solid rgba(212,175,55,0.45);
  padding: 14px;
  position: relative;
  min-height: 0;
}
.replay-message {
  color: var(--gold); font-weight: 700; font-size: 14px;
  margin-bottom: 10px; letter-spacing: 0.5px; text-align: center;
  min-height: 22px;
  font-family: 'Cinzel', serif;
  text-shadow: 0 1px 2px rgba(0,0,0,0.7);
}
.replay-stacks {
  position: relative; width: 100%;
  min-height: 90px;
}

.replay-controls {
  display: flex; justify-content: center; align-items: center;
  gap: 10px; padding: 12px;
  background: linear-gradient(180deg, rgba(0,0,0,0.7), rgba(0,0,0,0.9));
  border-top: 2px solid rgba(212,175,55,0.4);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.replay-controls button {
  background: linear-gradient(180deg, #444 0%, #222 100%);
  color: white; border: 1px solid #666;
  padding: 8px 16px; border-radius: 7px;
  cursor: pointer; font-weight: 800; font-size: 13px;
  letter-spacing: 0.5px; min-width: 50px;
  transition: all 0.15s;
}
.replay-controls button:hover { border-color: var(--gold); transform: translateY(-1px); }
.replay-controls button.replay-play-btn {
  background: linear-gradient(180deg, #2ecc71 0%, #1e8449 100%);
  border-color: rgba(255,255,255,0.3); min-width: 100px;
}
.replay-controls button.replay-play-btn.playing {
  background: linear-gradient(180deg, #f39c12 0%, #d68910 100%);
}
.replay-step-indicator {
  color: var(--gold-light); font-family: 'Roboto Mono', monospace;
  font-weight: 700; font-size: 13px;
  background: rgba(0,0,0,0.6); padding: 6px 14px;
  border-radius: 6px; border: 1px solid rgba(212,175,55,0.3);
  letter-spacing: 1px;
}
.replay-controls select {
  background: #333; color: white;
  border: 1px solid #666; padding: 7px;
  border-radius: 6px; cursor: pointer;
  font-size: 12px; font-weight: 700;
}
.replay-game-nav {
  display: flex; gap: 6px; align-items: center;
  margin-left: 8px; padding-left: 14px;
  border-left: 1px solid rgba(212,175,55,0.3);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 600px) {
  #header h1 { font-size: 16px; letter-spacing: 1.5px; }
  .card { width: 50px; height: 70px; margin-left: -20px; border-radius: 6px; }
  .card .center-suit { font-size: 34px; }
  .card .corner-rank { font-size: 15px; }
  .card .corner-suit { font-size: 11px; }
  .card.small { width: 38px; height: 54px; margin-left: -15px; }
  .card.small .center-suit { font-size: 24px; }
  .table { grid-template-columns: minmax(120px,1fr) minmax(220px,2fr) minmax(120px,1fr); }
}
@media (max-height: 720px) {
  .card { width: 58px; height: 80px; margin-left: -23px; }
  .card .center-suit { font-size: 40px; }
  .card .corner-rank { font-size: 17px; }
  .card .corner-suit { font-size: 13px; }
  .card.small { width: 42px; height: 58px; margin-left: -17px; }
  .card.small .center-suit { font-size: 28px; }
  .cards-row { min-height: 80px; }
  .p-left .cards-row, .p-right .cards-row { min-height: 58px; }
  #play-area .played-cards { min-height: 84px; }
}
@media (max-height: 620px) {
  .card { width: 48px; height: 66px; margin-left: -19px; }
  .card .center-suit { font-size: 32px; }
  .card .corner-rank { font-size: 14px; }
  .card .corner-suit { font-size: 11px; }
  .card.small { width: 36px; height: 50px; margin-left: -14px; }
  .card.small .center-suit { font-size: 23px; }
  .cards-row { min-height: 66px; }
  .p-left .cards-row, .p-right .cards-row { min-height: 50px; }
  #play-area .played-cards { min-height: 68px; }
}

/* ============ MODE SELECT / TOURNAMENT OVERLAYS ============ */
.mode-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: radial-gradient(ellipse at center, #1a3a2a 0%, #0a1a14 80%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; overflow-y: auto;
}
.mode-card {
  background: linear-gradient(180deg, #2c3e50 0%, #1a252f 100%);
  border: 2px solid #d4af37; border-radius: 14px;
  padding: 26px 34px; max-width: 720px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7), inset 0 1px 0 rgba(255,255,255,0.08);
  color: #ecf0f1;
}
.mode-card h2 {
  margin: 0 0 18px 0; text-align: center; font-family: 'Cinzel', serif;
  font-size: 30px; color: #d4af37; letter-spacing: 4px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.7);
}
.mode-card h3 {
  margin: 4px 0 14px 0; text-align: center; color: #d4af37;
  font-size: 17px; letter-spacing: 2px; font-weight: 600;
}
.mode-options {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 14px;
}
.mode-option {
  background: rgba(0,0,0,0.35); border: 2px solid rgba(212,175,55,0.4);
  border-radius: 10px; padding: 22px 18px; cursor: pointer;
  transition: all 0.2s ease; text-align: center;
}
.mode-option:hover {
  border-color: #d4af37; background: rgba(212,175,55,0.15);
  transform: translateY(-3px); box-shadow: 0 10px 24px rgba(0,0,0,0.5);
}
.mode-option .icon { font-size: 42px; margin-bottom: 10px; }
.mode-option .title { font-size: 20px; font-weight: 700; color: #f1c40f; margin-bottom: 6px; letter-spacing: 1.5px; }
.mode-option .desc { font-size: 13px; color: #bdc3c7; line-height: 1.5; }
.tour-form {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 16px 0;
}
.tour-form .field { display: flex; flex-direction: column; }
.tour-form .field label { font-size: 12px; color: #bdc3c7; margin-bottom: 4px; letter-spacing: 1px; }
.tour-form .field input {
  background: rgba(0,0,0,0.4); border: 1.5px solid rgba(212,175,55,0.4);
  border-radius: 6px; padding: 9px 12px; color: #ecf0f1; font-size: 15px;
  font-family: 'Inter', sans-serif;
}
.tour-form .field input:focus { outline: none; border-color: #d4af37; }
.tour-form .field .hint { font-size: 11px; color: #95a5a6; margin-top: 3px; font-style: italic; }
.mode-card .btn-row {
  display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap;
}
.mode-card button {
  background: linear-gradient(180deg, #d4af37 0%, #8b6914 100%);
  color: #1a1a1a; border: none; padding: 11px 24px;
  border-radius: 7px; cursor: pointer; font-size: 15px; font-weight: 700;
  letter-spacing: 1.5px; transition: all 0.15s;
  box-shadow: 0 4px 10px rgba(0,0,0,0.4);
}
.mode-card button:hover { filter: brightness(1.15); transform: translateY(-1px); }
.mode-card button.secondary { background: linear-gradient(180deg, #5d6d7e 0%, #34495e 100%); color: #ecf0f1; }

/* ============ TOUR HUD (top bar during tour round) ============ */
.tour-hud {
  background: linear-gradient(180deg, #1a3a2a 0%, #0d2418 100%);
  border-bottom: 2px solid #d4af37; padding: 6px 14px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  font-size: 12px; color: #ecf0f1; letter-spacing: 1px;
}
.tour-hud .item { display: flex; align-items: center; gap: 5px; }
.tour-hud .label { color: #95a5a6; font-size: 11px; }
.tour-hud .val { color: #d4af37; font-weight: 700; font-size: 13px; }
.tour-hud .timer { color: #2ecc71; font-weight: 700; font-family: 'Roboto Mono', monospace; }
.tour-hud .timer.warn { color: #e67e22; }
.tour-hud .timer.expired { color: #e74c3c; }
.tour-hud button {
  background: rgba(212,175,55,0.85); color: #1a1a1a; border: none;
  padding: 4px 10px; border-radius: 4px; cursor: pointer; font-weight: 700;
  font-size: 11px; letter-spacing: 1px;
}
.tour-hud button:hover { filter: brightness(1.15); }

/* ============ TOUR LEADERBOARD ============ */
.tour-lb-overlay {
  position: fixed; inset: 0; z-index: 180;
  background: rgba(10,20,16,0.94);
  display: flex; align-items: center; justify-content: center; padding: 12px;
}
.tour-lb-card {
  background: linear-gradient(180deg, #2c3e50 0%, #1a252f 100%);
  border: 2px solid #d4af37; border-radius: 12px;
  width: 100%; max-width: 1100px; max-height: 92vh;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7);
  position: relative;
}
.tour-lb-head {
  padding: 14px 20px; border-bottom: 1px solid rgba(212,175,55,0.3);
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px;
}
.tour-lb-head h2 {
  margin: 0; font-family: 'Cinzel', serif; color: #d4af37;
  font-size: 22px; letter-spacing: 3px;
}
.tour-lb-head .info {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  font-size: 13px; color: #bdc3c7;
}
.tour-lb-head .info .round-badge {
  background: linear-gradient(180deg, #f1c40f 0%, #c9930b 100%);
  color: #1a1a1a; padding: 7px 14px; border-radius: 8px;
  font-family: 'Cinzel', serif; font-weight: 800; font-size: 17px;
  letter-spacing: 2px; border: 2px solid #fff;
  box-shadow: 0 4px 14px rgba(0,0,0,0.5), 0 0 18px rgba(241,196,15,0.6);
  display: inline-flex; align-items: center; gap: 6px;
  text-shadow: 0 1px 0 rgba(255,255,255,0.4);
}
.tour-lb-head .info .round-badge .lbl { font-size: 11px; letter-spacing: 1.5px; opacity: 0.7; font-family: 'Inter', sans-serif; }
.tour-lb-head .info .info-pill {
  background: rgba(0,0,0,0.4); border: 1px solid rgba(212,175,55,0.3);
  padding: 5px 10px; border-radius: 16px; font-size: 12px; color: #ecf0f1;
  white-space: nowrap;
}
.tour-lb-head .info .info-pill b { color: #d4af37; }
.tour-lb-body { flex: 1; overflow-y: auto; padding: 0 6px; }
.tour-lb-body .table-band {
  background: linear-gradient(90deg, rgba(212,175,55,0.16) 0%, rgba(212,175,55,0.06) 100%);
  padding: 4px 14px; font-size: 11px; letter-spacing: 2px;
  color: #d4af37; font-weight: 700; border-top: 1px solid rgba(212,175,55,0.25);
}
.tour-lb-body .table-band:first-child { border-top: none; }
.tour-lb-body table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tour-lb-body thead th {
  position: sticky; top: 0; background: #1a252f; z-index: 2;
  padding: 8px 10px; text-align: left; color: #d4af37; font-weight: 700;
  font-size: 11px; letter-spacing: 1.5px; border-bottom: 2px solid #d4af37;
}
.tour-lb-body td { padding: 7px 10px; border-bottom: 1px solid rgba(255,255,255,0.04); }
.tour-lb-body tr.human {
  background: linear-gradient(90deg, rgba(46,204,113,0.32) 0%, rgba(46,204,113,0.12) 100%);
  font-weight: 700;
  box-shadow: inset 4px 0 0 #2ecc71, inset 0 -1px 0 rgba(46,204,113,0.4);
}
.tour-lb-body tr.human td { color: #2ecc71; }
.tour-lb-body tr.human td.rank { color: #58e89a; text-shadow: 0 0 8px rgba(46,204,113,0.5); }
.tour-lb-body tr.human td.score { color: #58e89a; }
.tour-lb-body tr.human td.chips { color: #58e89a; }
.tour-lb-body tr.human td.opp { color: #2ecc71; }
.tour-lb-body tr.human td.reg { color: #2ecc71; opacity: 0.85; }
.tour-lb-body tr:hover { background: rgba(255,255,255,0.04); }
.tour-lb-body tr.human:hover { background: linear-gradient(90deg, rgba(46,204,113,0.42) 0%, rgba(46,204,113,0.18) 100%); }
.tour-lb-body td.rank { color: #d4af37; font-weight: 700; width: 50px; }
.tour-lb-body td.score { color: #2ecc71; font-weight: 700; text-align: right; width: 70px; }
.tour-lb-body td.chips { color: #f1c40f; text-align: right; font-family: 'Roboto Mono', monospace; width: 110px; font-size: 12px; }
.tour-lb-body td.opp { color: #95a5a6; text-align: right; width: 80px; }
.tour-lb-body td.reg { color: #7f8c8d; text-align: right; width: 60px; font-size: 11px; }
.tour-lb-body td.prize { text-align: right; width: 110px; font-family: 'Roboto Mono', monospace; font-weight: 700; font-size: 12px; }
.tour-lb-body td.prize .prize-amt { color: #2ecc71; }
.tour-lb-body td.prize .prize-zero { color: #5d6d7e; }
/* Highlight flash when scrolling to my row */
.tour-lb-body tr.human.flash-highlight {
  animation: humanRowFlash 1.6s ease-out;
}
@keyframes humanRowFlash {
  0%   { box-shadow: inset 4px 0 0 #2ecc71, 0 0 30px rgba(46,204,113,0.9); background: rgba(46,204,113,0.65); }
  40%  { box-shadow: inset 4px 0 0 #2ecc71, 0 0 20px rgba(46,204,113,0.7); background: rgba(46,204,113,0.5); }
  100% { box-shadow: inset 4px 0 0 #2ecc71, 0 0 0 transparent; background: rgba(46,204,113,0.18); }
}
/* Floating "Vi tri toi" button (sticky at bottom-right of leaderboard) */
.tour-lb-mypos-fab {
  position: absolute; right: 18px; bottom: 78px;
  background: linear-gradient(180deg, #f1c40f 0%, #c9930b 100%);
  color: #1a1a1a; border: 2px solid #fff;
  padding: 9px 16px; border-radius: 22px; font-weight: 700;
  letter-spacing: 1.5px; font-size: 12px; cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,0.5), 0 0 18px rgba(241,196,15,0.5);
  display: flex; align-items: center; gap: 6px;
  z-index: 10; transition: transform 0.15s, box-shadow 0.15s;
}
.tour-lb-mypos-fab:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0,0,0,0.6), 0 0 24px rgba(241,196,15,0.7); }
.tour-lb-mypos-fab .arrow { font-size: 16px; }
/* "Vi tri toi" button in tour HUD */
.tour-hud button.mypos-btn {
  background: linear-gradient(180deg, #f1c40f 0%, #c9930b 100%);
  color: #1a1a1a; font-weight: 700; padding: 4px 12px;
  box-shadow: 0 0 10px rgba(241,196,15,0.4);
}
/* ============ TOUR MODE: hide irrelevant chrome ============ */
body.tour-mode #scoreboard { display: none; }
/* Hide AI/auto-deal toggles in tour mode (irrelevant), but KEEP face-down toggle visible */
body.tour-mode .ai-toggle:not(.tour-visible) { display: none; }
body.tour-mode #header button[onclick="onClickNewGameBtn()"] { display: none; }
body.tour-mode #header h1 { font-size: 16px; letter-spacing: 2px; }
body.tour-mode #header { padding: 4px 14px; min-height: 0; }
body.tour-mode .tour-hud { padding: 5px 14px; gap: 12px; font-size: 11px; }
body.tour-mode .tour-hud .val { font-size: 12px; }
/* Tour-only buttons: hidden in cash mode, shown in tour mode */
.tour-only { display: none !important; }
body.tour-mode .tour-only { display: inline-flex !important; align-items: center; }
.tour-lb-foot {
  padding: 12px 20px; border-top: 1px solid rgba(212,175,55,0.3);
  display: flex; justify-content: center; gap: 10px; flex-wrap: wrap;
}
.tour-lb-foot button {
  background: linear-gradient(180deg, #d4af37 0%, #8b6914 100%);
  color: #1a1a1a; border: none; padding: 10px 22px; border-radius: 6px;
  cursor: pointer; font-weight: 700; letter-spacing: 1.5px; font-size: 14px;
}
.tour-lb-foot button.secondary { background: linear-gradient(180deg, #5d6d7e 0%, #34495e 100%); color: #ecf0f1; }
.tour-lb-foot button:hover { filter: brightness(1.15); }
/* Settings row in tour leaderboard footer (face-down toggle) */
.tour-lb-settings {
  display: flex; justify-content: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 20px 0; font-family: 'Inter', sans-serif;
}
.tour-lb-settings label.facedown-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border: 1.5px solid rgba(52,152,219,0.55);
  border-radius: 6px; cursor: pointer; user-select: none;
  font-size: 12px; letter-spacing: 1px; color: #ecf0f1;
  background: rgba(52,152,219,0.12);
}
.tour-lb-settings label.facedown-pill:hover { filter: brightness(1.2); }
.tour-lb-settings label.facedown-pill.on {
  background: rgba(52,152,219,0.35); border-color: rgba(52,152,219,0.9);
}
.tour-lb-settings label.facedown-pill input { accent-color: #3498db; }
.tour-lb-settings label.facedown-pill .status {
  font-weight: 700; color: #f39c12; font-family: 'Roboto Mono', monospace;
}
.tour-lb-settings label.facedown-pill.on .status { color: #2ecc71; }
.prize-tooltip {
  position: fixed; z-index: 250; background: #1a252f;
  border: 2px solid #d4af37; padding: 12px 16px; border-radius: 8px;
  color: #ecf0f1; font-size: 13px; max-width: 320px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.7);
}
.prize-tooltip .ttl { color: #d4af37; font-weight: 700; margin-bottom: 6px; letter-spacing: 1px; }
.prize-tooltip .row { display: flex; justify-content: space-between; padding: 2px 0; }
.prize-tooltip button.close { margin-top: 8px; width: 100%; background: rgba(212,175,55,0.6); color: #1a1a1a; border: none; padding: 4px; border-radius: 4px; cursor: pointer; font-weight: 700; }

/* ============ TOUR ROUND SUMMARY (per-round result) ============ */
.tour-round-summary {
  background: rgba(0,0,0,0.4); border: 1px solid rgba(212,175,55,0.3);
  border-radius: 8px; padding: 10px 14px; margin: 10px 16px;
}
.tour-round-summary .ttl { color: #d4af37; font-weight: 700; letter-spacing: 1.5px; font-size: 12px; margin-bottom: 6px; }
.tour-round-summary .row { display: flex; justify-content: space-between; font-size: 12px; padding: 2px 0; color: #ecf0f1; }
.tour-round-summary .row.win { color: #2ecc71; }
.tour-round-summary .row.lose { color: #e74c3c; }
