:root {
  --bg: #0f1419;
  --panel: #1a2129;
  --panel-2: #232c36;
  --felt: #14694a;
  --felt-edge: #0c3d2c;
  --accent: #f5a623;
  --accent-2: #4a90d9;
  --text: #e8edf2;
  --muted: #8b97a4;
  --good: #4caf76;
  --bad: #d9534f;
  --card-red: #d23b3b;
  --card-black: #1c2833;
  --card-blue: #1f6fd6;
  --card-green: #1f9d57;
  --radius: 12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

.screen { height: 100vh; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- Join screen ---------- */
#join-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 30%, #1b2a25, var(--bg));
}
.join-card {
  background: var(--panel);
  padding: 36px;
  border-radius: var(--radius);
  width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  border: 1px solid #2a3540;
}
.join-card h1 { font-size: 32px; margin-bottom: 4px; }
.tagline { color: var(--muted); margin-bottom: 24px; }
.join-card label, .modal-card label {
  display: block;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--muted);
}
.join-card input, .modal-card input[type=text], .modal-card input[type=number] {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 11px 12px;
  background: var(--panel-2);
  border: 1px solid #313c47;
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
}
.hint { color: var(--muted); font-size: 12px; margin-top: 14px; text-align: center; }

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  transition: transform .05s, filter .15s;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: .4; cursor: not-allowed; }
.primary { background: var(--accent); color: #1a1206; padding: 10px 16px; }
.primary:hover { filter: brightness(1.08); }
.ghost { background: var(--panel-2); color: var(--text); padding: 8px 14px; }
.ghost:hover { background: #2c3742; }
.big { width: 100%; padding: 14px; font-size: 16px; margin-top: 8px; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid #2a3540;
  flex: 0 0 auto;
  height: 56px;          /* fixed so it never reflows and shifts the table */
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
}
.topbar-right { flex-wrap: nowrap; justify-content: flex-end; flex-shrink: 0; }
.brand { font-weight: 700; font-size: 18px; }
.room-info { display: flex; align-items: center; gap: 12px; }
#room-label { font-family: monospace; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.packcount {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-2);
  border: 1px solid #313c47;
  border-radius: 8px;
  padding: 3px 6px 3px 10px;
}
#pack-label { font-size: 13px; font-weight: 700; white-space: nowrap; }
.pack-btn {
  background: var(--panel);
  color: var(--text);
  width: 24px;
  height: 24px;
  border-radius: 6px;
  font-size: 18px;
  line-height: 1;
  padding: 0;
}
.pack-btn:hover:not(:disabled) { background: #2c3742; }
.pack-btn:disabled { opacity: .3; cursor: not-allowed; }

/* The Smash status indicator */
.smash-status {
  font-size: 13px;
  font-weight: 800;
  padding: 5px 10px;
  border-radius: 8px;
  white-space: nowrap;
  cursor: default;
}
.smash-status.locked { background: var(--panel-2); color: var(--muted); border: 1px solid #313c47; }
.smash-status.unlocked {
  background: linear-gradient(90deg, #ff3bd2, #f5a623);
  color: #2a1206;
  box-shadow: 0 0 14px rgba(255,59,210,.7);
  animation: smashGlow 1s ease-in-out infinite alternate;
}
@keyframes smashGlow { from { filter: brightness(1); } to { filter: brightness(1.3); } }
.afterdark-status {
  font-size: 13px;
  font-weight: 800;
  padding: 5px 10px;
  border-radius: 8px;
  white-space: nowrap;
  cursor: default;
  color: #dfe7ff;
  background: linear-gradient(90deg, #2a2350, #3a2f6e);
  border: 1px solid #4a3f7e;
  box-shadow: 0 0 12px rgba(120,100,230,.55);
}
.aceslose-status {
  font-size: 13px;
  font-weight: 800;
  padding: 5px 10px;
  border-radius: 8px;
  white-space: nowrap;
  cursor: default;
  color: #fff;
  background: linear-gradient(90deg, #5a1f1f, #7a2a2a);
  border: 1px solid #8a3a3a;
  box-shadow: 0 0 12px rgba(217,83,79,.6);
}

/* Smash honor-vote prompt */
.smash-prompt {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--panel);
  border: 3px solid #ff3bd2;
  border-radius: var(--radius);
  padding: 24px 28px;
  text-align: center;
  z-index: 60;
  box-shadow: 0 10px 50px rgba(0,0,0,.7), 0 0 40px rgba(255,59,210,.5);
  max-width: 440px;
}
.smash-prompt h2 { font-size: 28px; margin-bottom: 8px; animation: smashShake .4s infinite; }
.smash-cards { display: flex; gap: 8px; justify-content: center; margin: 12px 0; }
.smash-buttons { display: flex; gap: 10px; justify-content: center; margin: 14px 0; }
#smash-honor { background: var(--good); color: #fff; padding: 12px 22px; font-size: 16px; }

/* Full-screen smash celebration overlay */
.smash-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: rgba(0,0,0,.2);
}
.smash-overlay.go { animation: smashFlash .5s steps(2) 6; }
.smash-overlay-text {
  font-size: 64px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 20px #ff3bd2, 0 0 40px #f5a623, 3px 3px 0 #000;
  animation: smashShake .25s infinite, smashZoom .5s ease-out;
  text-align: center;
}
@keyframes smashFlash {
  0% { background: rgba(255,59,210,.45); }
  100% { background: rgba(245,166,35,.45); }
}
@keyframes smashShake {
  0%,100% { transform: rotate(-2deg) translateX(-4px); }
  50% { transform: rotate(2deg) translateX(4px); }
}
@keyframes smashZoom {
  from { transform: scale(.3); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ---------- All-in suspense + lead-change popup ---------- */
.suspense-banner {
  position: fixed;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 480;
  pointer-events: none;
  background: rgba(0,0,0,.78);
  color: #ffd54a;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: .5px;
  padding: 12px 26px;
  border-radius: 14px;
  border: 2px solid #ffd54a;
  box-shadow: 0 0 26px rgba(255,213,74,.6);
  text-shadow: 0 2px 4px #000;
  animation: suspensePulse .9s ease-in-out infinite;
}
@keyframes suspensePulse {
  0%,100% { transform: translateX(-50%) scale(1); opacity: .85; }
  50%     { transform: translateX(-50%) scale(1.08); opacity: 1; }
}
.lc-overlay {
  position: fixed;
  inset: 0;
  z-index: 510;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: rgba(0,0,0,.3);
}
.lc-overlay.go { animation: lcFlash .4s steps(2) 5; }
.lc-text {
  font-size: 60px;
  font-weight: 900;
  color: #fff;
  text-align: center;
  white-space: pre-line;
  line-height: 1.1;
  text-shadow: 0 0 20px #4a90d9, 0 0 44px #ffd54a, 3px 3px 0 #000;
  animation: lcShake .25s infinite, smashZoom .5s ease-out;
}
@keyframes lcFlash {
  0%   { background: rgba(74,144,217,.45); }
  100% { background: rgba(255,213,74,.40); }
}
@keyframes lcShake {
  0%,100% { transform: rotate(-2deg) translateX(-5px); }
  50%     { transform: rotate(2deg) translateX(5px); }
}

/* ---------- Hand-winner celebration ---------- */
.win-overlay {
  position: fixed;
  inset: 0;
  z-index: 505;
  display: flex;
  align-items: flex-start;          /* sit in the upper area, not over the board */
  justify-content: center;
  padding-top: 9%;
  pointer-events: none;
}
.win-overlay.go .win-card { animation: winPop .5s cubic-bezier(.2,1.3,.4,1); }
.win-overlay.go::before, .win-overlay.go::after {
  content: '🎉';
  position: absolute;
  top: 10%;
  font-size: 34px;
  animation: winBurst 1.1s ease-out forwards;
}
.win-overlay.go::before { left: 36%; }
.win-overlay.go::after  { right: 36%; content: '🎊'; animation-delay: .08s; }
.win-card {
  text-align: center;
  max-width: 70%;
  background: linear-gradient(160deg, rgba(40,30,6,.94), rgba(20,15,4,.94));
  border: 2px solid #ffd86b;
  border-radius: 14px;
  padding: 12px 22px;
  box-shadow: 0 0 26px rgba(255,200,70,.5), 0 8px 26px rgba(0,0,0,.55);
}
.win-trophy {
  font-size: 34px;
  line-height: 1;
  animation: winTrophy 1s ease-in-out infinite;
}
.win-title {
  font-size: 26px;
  font-weight: 900;
  color: #ffe9b0;
  text-shadow: 0 0 14px rgba(245,166,35,.8), 1px 1px 0 #000;
  margin-top: 4px;
  white-space: nowrap;
}
.win-sub { font-size: 15px; font-weight: 700; color: #ffd479; margin-top: 3px; }
.win-quip { font-size: 13px; font-style: italic; color: #e7d6a8; margin-top: 5px; max-width: 320px; }
@keyframes winPop {
  0%   { transform: scale(.3) rotate(-6deg); opacity: 0; }
  60%  { transform: scale(1.08) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes winTrophy {
  0%,100% { transform: translateY(0) rotate(-5deg); }
  50%     { transform: translateY(-7px) rotate(5deg); }
}
@keyframes winBurst {
  0%   { transform: translateY(0) scale(.6); opacity: 0; }
  25%  { opacity: 1; }
  100% { transform: translateY(-120px) scale(1.4); opacity: 0; }
}

/* ---------- Layout ---------- */
#game-screen { display: flex; flex-direction: column; position: relative; }
.layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  flex: 1 1 auto;
  min-height: 0;
}
/* Banners overlay the top of the table — they never resize the layout. */
.banners { position: absolute; top: 56px; left: 0; right: 0; z-index: 40; }

/* Collapsible side panel — collapse it to give the table the full width. */
.sidebar-toggle {
  position: absolute; top: 50%; transform: translateY(-50%);
  right: 320px; z-index: 46;
  width: 22px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel-2); color: var(--text);
  border: 1px solid #2a3540; border-right: none;
  border-radius: 8px 0 0 8px;
  cursor: pointer; font-size: 18px; line-height: 1;
}
.sidebar-toggle:hover { background: #2c3742; }
#game-screen.sidebar-collapsed .sidebar { display: none; }
#game-screen.sidebar-collapsed .layout { grid-template-columns: 1fr; }
#game-screen.sidebar-collapsed .sidebar-toggle { right: 0; }
.table-area {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px;
  overflow: hidden;
  height: 100%;
}
/* The table sits in a flex-grow stage; the action dock below has a reserved
   height so showing/hiding controls between hands never moves the table. */
.table-stage {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.action-dock {
  flex: 0 0 auto;
  width: 100%;
  height: 196px;          /* fixed so showing/hiding the action bar never moves the table */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  overflow: visible;
}

/* ---------- Poker table ---------- */
/* Fixed design size; scaleTable() in JS scales it (and all seats) to fit. */
.poker-table {
  position: relative;
  width: 900px;
  height: 562px;
  flex: 0 0 auto;
  transform-origin: center center;
}
.table-felt {
  position: absolute;
  inset: 8%;
  background: radial-gradient(ellipse at center, var(--felt), var(--felt-edge));
  border-radius: 50%;
  border: 10px solid #5a3d28;
  box-shadow: inset 0 0 60px rgba(0,0,0,.5), 0 10px 40px rgba(0,0,0,.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.community { display: flex; gap: 8px; min-height: 106px; align-items: center; }
.winner-banner {
  position: absolute;
  top: 7%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  font-size: 20px;
  font-weight: 800;
  color: #2a1d04;
  background: linear-gradient(90deg, #ffd86b, #f5a623);
  padding: 7px 22px;
  border-radius: 24px;
  box-shadow: 0 4px 16px rgba(245,166,35,.5);
  text-align: center;
  max-width: 80%;
  white-space: nowrap;
}
.winner-banner.multi { white-space: normal; max-width: 94%; font-size: 15px; }
.pot-display {
  font-size: 23px;
  font-weight: 800;
  color: #ffe9b0;
  background: rgba(0,0,0,.3);
  padding: 5px 18px;
  border-radius: 20px;
  min-height: 36px;
  display: flex;
  align-items: center;
}
.pot-display:empty { background: transparent; }
.status-line { color: #cfe9dd; font-size: 16px; height: 22px; }
.multi-board { display: flex; flex-direction: column; gap: 6px; }
.multi-board .board-row { display: flex; gap: 5px; align-items: center; padding: 3px 6px; border-radius: 8px; transition: background .3s; }
.multi-board .board-row.active-run { background: rgba(245,166,35,.16); box-shadow: 0 0 0 1px rgba(245,166,35,.4) inset; }
.multi-board .run-label { font-size: 11px; color: #cfe9dd; width: 54px; }

/* ---------- Cards ---------- */
.card {
  width: 74px;
  height: 104px;
  border-radius: 9px;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(0,0,0,.5);
  position: relative;
  user-select: none;
}
.card.small { width: 56px; height: 78px; font-size: 18px; }
.card .rank { font-size: 44px; line-height: 1; }
.card.small .rank { font-size: 31px; }
.card .suit { font-size: 38px; line-height: 1; }
.card.small .suit { font-size: 26px; }
.card.red { color: var(--card-red); }
.card.black { color: var(--card-black); }
/* Four-color deck (personal toggle): diamonds → blue, clubs → green.
   Spades stay black and hearts stay red via the rules above. */
body.four-color .card.suit-d { color: var(--card-blue); }
body.four-color .card.suit-c { color: var(--card-green); }
.card.back {
  background: repeating-linear-gradient(45deg, #2b4c8c, #2b4c8c 6px, #24407a 6px, #24407a 12px);
  border: 2px solid #1a2d57;
}
.card.win { outline: 3px solid var(--accent); box-shadow: 0 0 14px var(--accent); }
.card.muck { opacity: .4; }
.card.rabbit { opacity: .72; outline: 2px dashed var(--accent-2); outline-offset: -3px; filter: grayscale(.25); }

/* ---------- Seats ---------- */
.seat {
  position: absolute;
  width: 172px;
  transform: translate(-50%, -50%);
  text-align: center;
}
.seat-inner {
  background: var(--panel);
  border: 2px solid #2a3540;
  border-radius: 11px;
  padding: 8px 11px 12px;
  position: relative;
  transition: border-color .2s, box-shadow .2s;
}
/* Active player: bright pulsing ring + ACTING tag */
.seat.current .seat-inner {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245,166,35,.35), 0 0 22px rgba(245,166,35,.75);
  animation: actingPulse 1.1s ease-in-out infinite;
}
@keyframes actingPulse {
  50% { box-shadow: 0 0 0 4px rgba(245,166,35,.55), 0 0 30px rgba(245,166,35,.95); }
}
.acting-tag {
  position: absolute;
  top: -11px; left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #1a1206;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .5px;
  padding: 2px 9px;
  border-radius: 10px;
  white-space: nowrap;
}
.seat.folded .seat-inner { opacity: .45; }
.seat.me .seat-inner { border-color: var(--accent-2); }
/* Winner: gold glow + badge */
.seat.winner .seat-inner {
  border-color: #ffd700;
  box-shadow: 0 0 0 3px rgba(255,215,0,.45), 0 0 26px rgba(255,215,0,.85);
  animation: winnerGlow 1s ease-in-out infinite alternate;
}
@keyframes winnerGlow {
  from { box-shadow: 0 0 0 3px rgba(255,215,0,.35), 0 0 16px rgba(255,215,0,.6); }
  to { box-shadow: 0 0 0 4px rgba(255,215,0,.6), 0 0 32px rgba(255,215,0,1); }
}
.win-badge {
  position: absolute;
  top: -13px; left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(90deg, #ffd86b, #f5a623);
  color: #2a1d04;
  font-size: 12px;
  font-weight: 800;
  padding: 3px 11px;
  border-radius: 10px;
  white-space: nowrap;
  z-index: 5;
  box-shadow: 0 2px 10px rgba(245,166,35,.7);
  transform-origin: center bottom;
  animation: winBadgePop .6s cubic-bezier(.2,1.4,.4,1) both, winBadgeBob 1.4s ease-in-out .6s infinite;
}
@keyframes winBadgePop {
  0%   { transform: translateX(-50%) scale(0) translateY(8px); }
  70%  { transform: translateX(-50%) scale(1.25) translateY(0); }
  100% { transform: translateX(-50%) scale(1); }
}
@keyframes winBadgeBob {
  0%,100% { transform: translateX(-50%) translateY(0); }
  50%     { transform: translateX(-50%) translateY(-3px); }
}
.win-hand { font-size: 12px; color: #ffd479; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Prominent countdown progress bar directly under the active seat */
.seat-progress {
  position: absolute;
  top: 100%; left: 0; right: 0;   /* sits just below the seat box */
  margin-top: 6px;
  height: 14px;
  background: rgba(0,0,0,.65);
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,.5);
  box-shadow: 0 2px 10px rgba(0,0,0,.5);
}
.seat-progress-bar {
  height: 100%;
  width: 100%;
  background: var(--good);
  border-radius: 7px;
  transition: width .25s linear, background .3s;
}
/* Idle bar for players not currently on the clock: dim and neutral. */
.seat-progress-bar.idle { background: #3a4654; box-shadow: none; transition: none; }
.seat:not(.current) .seat-progress { height: 8px; margin-top: 4px; opacity: .7; }
/* Big, obvious per-player countdown number */
.seat-countdown {
  position: absolute;
  top: -16px; right: -12px;
  min-width: 34px; height: 34px;
  padding: 0 6px;
  background: var(--accent);
  color: #1a1206;
  border: 2px solid #fff3;
  border-radius: 17px;
  font-size: 18px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 14px rgba(245,166,35,.85);
  z-index: 8;
}
.seat-countdown.low {
  background: var(--bad);
  color: #fff;
  box-shadow: 0 0 16px rgba(217,83,79,.95);
  animation: cdPulse .5s ease-in-out infinite;
}
@keyframes cdPulse { 50% { transform: scale(1.18); } }
/* Community card deal-in animation */
.card.dealing { animation: dealIn .35s ease; }
@keyframes dealIn {
  from { opacity: 0; transform: translateY(-14px) scale(.85); }
  to { opacity: 1; transform: none; }
}
.seat-handstrength {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.15;
  margin: 1px 2px 3px;
}
.seat-name { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-wins {
  display: inline-block;
  background: var(--accent);
  color: #1a1206;
  font-size: 10px;
  font-weight: 800;
  padding: 0 5px;
  border-radius: 8px;
  vertical-align: middle;
}
.seat-stack { font-size: 19px; font-weight: 700; color: var(--good); }
.seat-cards { display: flex; justify-content: center; gap: 5px; margin-bottom: 4px; min-height: 88px; }
/* Slightly bigger hole cards in the seats. */
.seat-cards .card.small { width: 64px; height: 88px; }
.seat-cards .card.small .rank { font-size: 35px; }
.seat-cards .card.small .suit { font-size: 29px; }
.seat-equity {
  position: absolute;
  top: -14px; left: 50%;
  transform: translateX(-50%);
  background: var(--accent-2);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  padding: 2px 9px;
  border-radius: 12px;
  box-shadow: 0 0 12px rgba(74,144,217,.8);
  z-index: 7;
}
.seat-bet {
  position: absolute;
  top: -44px;              /* sits clear above the ACTING tag / dealer chip */
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.6);
  color: var(--accent);
  font-size: 14px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 10px;
  white-space: nowrap;
  z-index: 8;
}
.dealer-btn {
  position: absolute;
  bottom: -12px;
  right: -12px;
  width: 28px;
  height: 28px;
  background: radial-gradient(circle at 35% 30%, #fff, #e8e2d0);
  color: #1a1206;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--accent);
  box-shadow: 0 0 10px rgba(245,166,35,.7);
  z-index: 6;
}
.seat-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
}
.seat-badge.allin { background: var(--bad); color: #fff; }
.empty-seat {
  background: rgba(255,255,255,.04);
  border: 2px dashed #3a4550;
  color: var(--muted);
  border-radius: 10px;
  padding: 14px 8px;
  font-size: 12px;
  cursor: pointer;
  width: 100%;
}
.empty-seat:hover { background: rgba(255,255,255,.08); }

/* ---------- Action bar ---------- */
.action-bar {
  position: relative;
  width: 100%;
  max-width: 720px;
  background: var(--panel);
  border: 1px solid #2a3540;
  border-radius: var(--radius);
  padding: 12px;
  margin-top: 8px;
}
.big-bet-warning {
  background: var(--bad);
  color: #fff;
  font-weight: 800;
  text-align: center;
  padding: 7px;
  border-radius: 8px;
  margin-bottom: 8px;
  animation: bigBetPulse .7s ease-in-out infinite;
}
@keyframes bigBetPulse { 50% { filter: brightness(1.25); } }
.seat-bet.big { background: var(--bad); color: #fff; box-shadow: 0 0 10px var(--bad); animation: bigBetPulse .7s ease-in-out infinite; }
.action-info { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 15px; }
.hand-strength { color: var(--accent); font-weight: 600; }
.to-call { color: var(--muted); }
.action-extra { display: flex; margin-bottom: 8px; }
.act.random { background: linear-gradient(90deg, #8e44ad, #e67e22); padding: 10px; font-size: 14px; }
.action-buttons { display: flex; gap: 10px; }
.act { flex: 1; padding: 14px; font-size: 15px; color: #fff; }
.act.fold { background: var(--bad); }
.act.call { background: var(--good); }
.act.call.allin-call { background: linear-gradient(90deg, #d9534f, #e67e22); animation: bigBetPulse .7s ease-in-out infinite; }
.act.check { background: #2a9d8f; }
.act.raise { background: var(--accent-2); }
.act.min { background: #6b5bd9; }
.act:disabled { opacity: .4; cursor: not-allowed; }
.bet-dollar-prefix { font-size: 18px; font-weight: 700; color: var(--muted); align-self: center; }
/* The raise dialog floats above the action bar so opening it never shifts the layout. */
.bet-controls {
  position: absolute;
  left: 0; right: 0;
  bottom: 100%;
  margin-bottom: 8px;
  background: var(--panel);
  border: 1px solid #2a3540;
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: 0 -6px 24px rgba(0,0,0,.55);
  z-index: 30;
}
.bet-context {
  font-size: 13px;
  color: var(--muted);
  background: var(--panel-2);
  border-radius: 8px;
  padding: 6px 10px;
  margin-bottom: 10px;
  text-align: center;
}
.bet-context b { color: var(--accent); font-variant-numeric: tabular-nums; }
.bet-eq { color: var(--good); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; align-self: center; }
.quick-bets { display: flex; gap: 8px; margin-bottom: 10px; }
.chip-btn { flex: 1; background: var(--panel-2); color: var(--text); padding: 8px; }
.chip-btn:hover { background: #2c3742; }
.chip-btn.random { background: #6b5bd9; color: #fff; font-weight: 700; }
.chip-btn.random:hover { background: #7d6ee6; }
#bet-slider { width: 100%; margin: 8px 0; accent-color: var(--accent); }
.bet-amount-row { display: flex; gap: 8px; align-items: center; }
.bet-amount-row input { flex: 1; padding: 10px; background: var(--panel-2); border: 1px solid #313c47; border-radius: 8px; color: var(--text); font-size: 15px; }

.table-controls { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; justify-content: center; }
.busted-cta { animation: ctaPulse 1.1s ease-in-out infinite; }
@keyframes ctaPulse { 50% { filter: brightness(1.25); transform: scale(1.05); } }
.bet-dollars { font-weight: 700; color: var(--accent); white-space: nowrap; align-self: center; }
.bet-hint { margin-top: 8px; }

/* ---------- Run it twice prompt ---------- */
.run-prompt {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  z-index: 50;
  box-shadow: 0 10px 40px rgba(0,0,0,.6);
}
.run-buttons { display: flex; gap: 10px; margin: 14px 0; }
.run-btn { background: var(--accent-2); color: #fff; padding: 12px 20px; }
.run-btn.selected { background: var(--accent); color: #1a1206; }
.run-votes { font-size: 12px; color: var(--muted); }

/* ---------- Sidebar / chat ---------- */
.sidebar {
  background: var(--panel);
  border-left: 1px solid #2a3540;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.chat-panel { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-tabs { display: flex; border-bottom: 1px solid #2a3540; }
.tab {
  flex: 1;
  background: none;
  color: var(--muted);
  padding: 12px;
  border-radius: 0;
}
.tab.active { color: var(--text); border-bottom: 2px solid var(--accent); }
.chat-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.msg-time { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; margin-right: 4px; }
.chat-msg { font-size: 13px; line-height: 1.4; word-wrap: break-word; }
.chat-msg .who { font-weight: 700; color: var(--accent-2); }
.chat-msg.system { color: var(--muted); font-style: italic; font-size: 12px; }
.reactions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 10px 0;
  justify-content: center;
}
.react-btn {
  background: var(--panel-2);
  font-size: 18px;
  line-height: 1;
  padding: 5px 7px;
  border-radius: 8px;
}
.react-btn:hover { background: #2c3742; transform: scale(1.15); }
/* Floating reaction that rises off a seat */
.reaction-float {
  position: absolute;
  left: 50%;
  top: -14px;
  font-size: 34px;
  pointer-events: none;
  z-index: 25;
  animation: reactionFloat 2s ease-out forwards;
}
.reaction-float.reaction-spectator { top: 62%; }
@keyframes reactionFloat {
  0% { opacity: 0; transform: translate(-50%, 12px) scale(.4); }
  18% { opacity: 1; transform: translate(-50%, 0) scale(1.25); }
  100% { opacity: 0; transform: translate(-50%, -70px) scale(1); }
}
.chat-input-row { display: flex; gap: 6px; padding: 10px; border-top: 1px solid #2a3540; }
.chat-input-row input { flex: 1; padding: 9px; background: var(--panel-2); border: 1px solid #313c47; border-radius: 8px; color: var(--text); }

/* ---------- Modals ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-card {
  background: var(--panel);
  padding: 28px;
  border-radius: var(--radius);
  width: 360px;
  max-width: 92vw;
  max-height: 90vh;
  overflow-y: auto;        /* scroll when the contents are taller than the window */
  border: 1px solid #2a3540;
}
.modal-card h2 { margin-bottom: 16px; }
.modal-card label.checkbox { display: flex; align-items: center; gap: 8px; color: var(--text); }
.modal-card label.checkbox input { width: auto; margin: 0; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions button { flex: 1; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 8px;
  z-index: 200;
  box-shadow: 0 6px 20px rgba(0,0,0,.5);
}

/* ---------- New: timer, pre-actions, reveal, bots, callouts ---------- */
kbd {
  background: rgba(0,0,0,.35);
  border-radius: 4px;
  padding: 0 5px;
  font-size: 10px;
  font-family: monospace;
  margin-left: 4px;
  vertical-align: middle;
  opacity: .8;
}
.turn-timer { font-weight: 700; font-variant-numeric: tabular-nums; }
.turn-timer.warn { color: var(--bad); animation: pulse .8s infinite; }
@keyframes pulse { 50% { opacity: .45; } }

/* timer ring on the active seat */
.seat .timer-ring {
  position: absolute;
  top: -3px; left: -3px; right: -3px; bottom: -3px;
  border-radius: 12px;
  pointer-events: none;
}

.pause-banner {
  background: var(--bad);
  color: #fff;
  text-align: center;
  padding: 6px;
  font-weight: 700;
}
.buyin-banner {
  background: #2a3d2a;
  border-bottom: 1px solid #3a5a3a;
  color: var(--text);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
}
.buyin-banner .bi-title { font-weight: 700; }
.buyin-banner .bi-req {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,.25);
  padding: 4px 8px;
  border-radius: 8px;
}
.buyin-banner .bi-approve { background: var(--good); color: #fff; padding: 3px 10px; border-radius: 6px; }
.buyin-banner .bi-deny { background: var(--bad); color: #fff; padding: 3px 10px; border-radius: 6px; }

.preaction-bar, .reveal-bar {
  width: 100%;
  max-width: 720px;
  background: var(--panel);
  border: 1px solid #2a3540;
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-top: 8px;
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}
.pre-check { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--text); cursor: pointer; }
/* Reveal feedback */
.reveal-status { font-size: 13px; font-weight: 700; color: var(--muted); margin-left: auto; }
.reveal-status.shown { color: var(--good); }
.reveal-note {
  font-size: 11px;
  font-weight: 700;
  margin-top: 3px;
  color: var(--muted);
}
.reveal-note.shown { color: var(--good); }
/* A revealed hole card glows; a still-hidden one is dashed so you can tell which are public. */
.seat-cards .card.shown-public {
  box-shadow: 0 0 0 2px var(--good), 0 0 12px rgba(76,175,118,.8);
}
.seat-cards .card.still-hidden { outline: 2px dashed #5a6573; outline-offset: 1px; opacity: .9; }
.pre-check input { width: auto; }

.seat.away .seat-inner { opacity: .5; }
.seat-badge.away { background: #5a4a2a; color: #ffd479; }
.seat-badge.bot { background: #2a3d5a; color: #9ec5ff; }
.seat-number {
  position: absolute;
  top: -9px; left: -9px;
  width: 20px; height: 20px;
  background: var(--panel-2);
  border: 1px solid #3a4550;
  color: var(--muted);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  z-index: 3;
}
.bot-remove {
  position: absolute;
  top: -8px; right: -8px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--bad);
  color: #fff;
  font-size: 11px;
  line-height: 16px;
  padding: 0;
}

.hands-panel, .callouts-panel, .players-panel, .stats-panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
}

/* Stats tab */
.stats-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  background: var(--panel-2);
  border-radius: 8px;
  padding: 9px 11px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--muted);
}
.stats-summary b { color: var(--text, #fff); font-variant-numeric: tabular-nums; }
.stats-player {
  background: var(--panel-2);
  border-radius: 8px;
  padding: 8px 11px;
  margin-bottom: 7px;
}
.stats-head { display: flex; align-items: center; justify-content: space-between; }
.stats-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats-wins { color: #ffd479; font-weight: 800; font-variant-numeric: tabular-nums; margin-left: 8px; }
.stats-sub { font-size: 11px; color: var(--muted); margin-top: 3px; }
.stats-types { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.stat-chip {
  font-size: 11px;
  background: #243140;
  color: #cfe3ff;
  border: 1px solid #34465a;
  border-radius: 10px;
  padding: 2px 8px;
}

/* Players roster */
.roster-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  margin: 8px 2px 4px;
}
.roster-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-2);
  border-radius: 8px;
  padding: 7px 10px;
  margin-bottom: 5px;
  font-size: 13px;
}
.roster-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.roster-you { font-size: 10px; background: var(--accent-2); color: #fff; padding: 0 5px; border-radius: 6px; }
.roster-stack { color: var(--good); font-variant-numeric: tabular-nums; }
.roster-status { font-size: 10px; padding: 2px 7px; border-radius: 8px; background: #2a3540; color: var(--muted); }
.roster-status.st-in { background: #1f4a36; color: #7fe0ad; }
.roster-status.st-allin { background: var(--bad); color: #fff; }
.roster-status.st-folded { background: #3a2a2a; color: #c79a9a; }
.roster-status.st-away { background: #5a4a2a; color: #ffd479; }
.roster-status.st-out { background: #2a3540; color: var(--muted); }
.roster-status.st-busted { background: #4a1f1f; color: #ff9a9a; }
.roster-status.st-wait { background: #2a3540; color: #9ec5ff; }
.roster-status.st-spec { background: #2a3d5a; color: #9ec5ff; }
.roster-host { background: var(--accent-2); color: #fff; padding: 3px 8px; border-radius: 6px; font-size: 11px; margin-left: 4px; }
/* Player rows: two lines (name/stack/status, then net + host actions) */
.roster-row-player { flex-direction: column; align-items: stretch; gap: 4px; }
.roster-line { display: flex; align-items: center; gap: 8px; }
.roster-sub { font-size: 11px; }
.roster-rebuy { font-size: 11px; color: #ffd479; }
.roster-net { font-weight: 800; font-variant-numeric: tabular-nums; }
.roster-net.net-up { color: var(--good); }
.roster-net.net-down { color: #ff8a8a; }
.roster-net.net-even { color: var(--muted); }
.roster-invested { color: var(--muted); flex: 1; }
.roster-actions { display: flex; gap: 4px; }
.roster-btn { background: #2a3540; color: var(--text); padding: 3px 8px; border-radius: 6px; font-size: 11px; border: 1px solid #3a4654; }
.roster-btn.roster-host { background: var(--accent-2); color: #fff; border: none; }
.roster-btn.roster-kick { background: #4a1f1f; color: #ff9a9a; border-color: #5a2a2a; }
.roster-btn.roster-poke { background: #3a2f4a; color: #d9c7ff; border-color: #4a3d5e; }
.seat-badge.busted { background: #4a1f1f; color: #ff9a9a; }
/* Seat: disconnected + rebuy badge */
.seat.disconnected .seat-inner { opacity: .6; border-style: dashed; border-color: #6a7280; }
.conn-tag {
  position: absolute; top: -11px; left: 50%; transform: translateX(-50%);
  background: #5a4a2a; color: #ffd479; font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: 10px; white-space: nowrap; z-index: 6;
}
.rebuy-badge {
  position: absolute; bottom: -10px; right: -6px;
  background: #2a3d5a; color: #cfe3ff; font-size: 11px; font-weight: 800;
  padding: 1px 7px; border-radius: 10px; z-index: 6;
}
.hand-entry {
  background: var(--panel-2);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
  font-size: 12px;
}
.hand-entry .hand-head { display: flex; justify-content: space-between; color: var(--muted); margin-bottom: 5px; }
.hand-entry .mini-board { display: flex; gap: 3px; margin-bottom: 6px; flex-wrap: wrap; align-items: center; }
.hand-entry .mini-board .run-tag { font-size: 10px; color: var(--muted); margin-right: 4px; }
.hand-entry .hand-player { display: flex; align-items: center; gap: 6px; margin: 3px 0; }
.hand-entry .hand-player .cards { display: flex; gap: 2px; }
/* Shrink history cards so a full 5-card board fits on one row at panel width. */
.hand-entry .mini-board { flex-wrap: nowrap; }
.hand-entry .card.small { width: 44px; height: 62px; font-size: 15px; }
.hand-entry .card.small .rank { font-size: 24px; }
.hand-entry .card.small .suit { font-size: 19px; }
.hand-entry .won { color: var(--good); margin-left: auto; }
.hand-entry .muck { color: var(--muted); font-style: italic; }
.hand-entry .actions-toggle { color: var(--accent-2); cursor: pointer; font-size: 11px; }
.hand-entry .actions-list { margin-top: 5px; color: var(--muted); line-height: 1.5; display: none; }
.hand-entry.expanded .actions-list { display: block; }

.callout-entry {
  background: var(--panel-2);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 6px;
  font-size: 13px;
}
.callout-entry .cn { font-weight: 700; color: var(--accent); }
.callout-entry.sev2 { border-left-color: #ff9d3c; }
.callout-entry.sev3 { border-left-color: #ff6b6b; }
.callout-entry.sev4 { border-left-color: #ff3bd2; }
.mcg-checklist { border-left-color: var(--accent-2); }
.mcg-checklist .cn { color: var(--accent-2); display: block; margin-bottom: 5px; }
.mcg-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
  opacity: .5;
}
.mcg-row.got { opacity: 1; }
.mcg-check { width: 18px; text-align: center; }
.mcg-suit { font-size: 15px; }
.mcg-suit.red { color: #e8536b; }
.mcg-suit.black { color: #d6deea; }
.mcg-name { font-weight: 600; }
.mcg-row.got .mcg-name { color: var(--good); }
.callout-toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(90deg, #f5a623, #ff6b6b);
  color: #1a1206;
  font-weight: 800;
  font-size: 20px;
  padding: 12px 28px;
  border-radius: 30px;
  z-index: 300;
  box-shadow: 0 8px 30px rgba(0,0,0,.6);
  animation: calloutPop 2.6s ease;
}
@keyframes calloutPop {
  0% { transform: translate(-50%, -20px); opacity: 0; }
  12%, 80% { transform: translate(-50%, 0); opacity: 1; }
  100% { transform: translate(-50%, -10px); opacity: 0; }
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  margin: 12px 0;
  max-height: 220px;
  overflow-y: auto;
}
.emoji-grid button {
  background: var(--panel-2);
  font-size: 22px;
  padding: 6px;
  border-radius: 6px;
}
.emoji-grid button:hover { background: #2c3742; }
.seat-emoji { margin-right: 3px; }

@media (max-width: 820px) {
  /* Table takes the full width; the side panel slides in as an overlay. */
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: absolute; top: 0; bottom: 0; right: 0;
    width: min(340px, 88vw); z-index: 44;
    box-shadow: -8px 0 24px rgba(0,0,0,.6);
  }
  .sidebar-toggle { right: min(340px, 88vw); }
  #game-screen.sidebar-collapsed .sidebar-toggle { right: 0; }
}
@media (max-width: 640px) {
  /* The table itself scales via scaleTable(); only tweak the chrome here. */
  .table-area { padding: 6px; }
  .action-dock { height: 200px; }
  .action-bar, .preaction-bar, .reveal-bar { padding: 8px; }
  .act { padding: 11px 4px; font-size: 13px; }
  .act kbd, .chip-btn kbd { display: none; }
  .brand { font-size: 15px; }
  .topbar .ghost { padding: 6px 8px; font-size: 12px; }
  .quick-bets { flex-wrap: wrap; }
}
