*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg:      #0a0a0f;
  --surface: #12121a;
  --surface2:#1a1a26;
  --border:  #2a2a3d;
  --text:    #e8e8ff;
  --muted:   #7a7a9a;
  --gold:    #ffd700;
  --gold2:   #ffb300;
  --green:   #22c55e;
  --red:     #ef4444;
  --accent:  #a78bfa;
  --mono: 'SFMono-Regular', Consolas, monospace;
}
html { scroll-behavior: smooth; }
body { background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 15px; line-height: 1.5; min-height: 100vh; display: flex; flex-direction: column; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
.gold { color: var(--gold); }
#main, main { flex: 1; }
.page { display: none; }
.page.active { display: block; }

/* Header (same as casino-v2 for a consistent ecosystem look) */
.header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; }
.hdr-inner { display: flex; align-items: center; gap: 16px; height: 58px; }
.logo-link { display: flex; align-items: center; gap: 9px; text-decoration: none; flex-shrink: 0; }
.logo-img { width: 34px; height: 34px; }
.logo-text { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.player-bar { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.btn-sm { background: var(--gold); color: #0a0a0f; border: none; padding: 5px 12px; border-radius: 6px; font-size: 0.78rem; font-weight: 700; cursor: pointer; }
.chip { background: var(--surface2); border: 1px solid var(--gold); color: var(--gold); padding: 4px 11px; border-radius: 999px; font-size: 0.8rem; font-weight: 700; white-space: nowrap; }
.wa { display: flex; gap: 6px; }
.btn-ghost { background: transparent; color: var(--gold); border: 1px solid var(--gold); }
.btn-ghost:hover { background: rgba(255,215,0,.1); }

/* Modal (shared shape with casino-v2's wallet.css) */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.modal[hidden] { display: none; }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 22px; width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 12px; }
.modal-box h3 { font-size: 1.15rem; }
.modal-info { font-size: 0.8rem; color: var(--muted); font-family: var(--mono); }
.modal-close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 0.85rem; padding: 4px; }
.modal-close:hover { color: var(--text); }
.field-label { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.bet-input { background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 9px 13px; border-radius: 7px; font-size: 1rem; outline: none; width: 100%; }
.bet-input:focus { border-color: var(--gold); }
.btn-play { background: linear-gradient(135deg, var(--gold2), var(--gold)); color: #0a0a0f; border: none; padding: 12px; border-radius: 8px; font-size: 1rem; font-weight: 700; cursor: pointer; transition: opacity .12s; }
.btn-play:hover { opacity: .88; }
.btn-play:disabled { opacity: .4; cursor: not-allowed; }

/* Sit-down modal — a little more presence than the plain generic modal shape above */
.sit-modal-box { background: linear-gradient(160deg, var(--surface) 0%, var(--surface2) 100%); border-color: rgba(255,215,0,.18); }
.sit-modal-header { display: flex; align-items: center; gap: 14px; }
.sit-modal-header h3 { margin: 0; }
.sit-modal-sub { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.sit-seat-badge {
  width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.05rem; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.5);
  box-shadow: 0 0 0 3px rgba(255,215,0,.2), 0 2px 8px rgba(0,0,0,.4);
}
.sit-info-row { display: flex; gap: 10px; }
.sit-info-chip { flex: 1; background: rgba(0,0,0,.2); border: 1px solid var(--border); border-radius: 9px; padding: 8px 11px; }
.sit-info-label { display: block; font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 2px; }
.sit-amount-row { position: relative; }
.sit-amount-input { padding-right: 52px; font-size: 1.15rem; font-weight: 700; }
.sit-amount-suffix { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 0.85rem; font-weight: 700; pointer-events: none; }
.sit-presets { display: flex; gap: 8px; margin-top: -4px; }
.sit-presets .btn-sm { flex: 1; }
.bet-status { font-size: 0.82rem; line-height: 1.55; white-space: pre-line; }
.bet-status.pending { color: var(--muted); }
.bet-status.win { color: var(--green); }
.bet-status.err { color: var(--red); }

.fair-box { background: rgba(167,139,250,.06); border: 1px solid rgba(167,139,250,.2); border-radius: 10px; padding: 18px 20px; margin: 24px 0 32px; }
.fair-box h4 { color: var(--accent); margin-bottom: 6px; font-size: 0.9rem; }
.fair-box p { font-size: 0.83rem; color: var(--muted); line-height: 1.6; }

/* ═══════════════════ Lobby ═══════════════════ */
.hero { background: linear-gradient(135deg, #0d2e1a 0%, #0a1a3e 55%, #1a1408 100%); padding: 40px 0 30px; border-bottom: 1px solid var(--border); }
.hero h1 { font-size: 2.1rem; font-weight: 800; margin-bottom: 6px; letter-spacing: -.01em; }
.hero p { color: rgba(255,255,255,.6); font-size: 0.95rem; }

.table-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; margin: 32px 0; }
.table-grid-empty { color: var(--muted); font-size: 0.9rem; margin: 32px 0; text-align: center; }
.table-card {
  position: relative; display: block; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.table-card:hover { border-color: var(--gold); transform: translateY(-4px); box-shadow: 0 10px 28px rgba(0,0,0,.45); }
.table-card-felt {
  height: 90px;
  background: radial-gradient(ellipse at 50% 35%, #0d3d1a 0%, #051509 85%);
  border-bottom: 1px solid var(--border);
  position: relative;
}
.table-card-felt::after {
  content: ''; position: absolute; inset: 10px; border: 3px solid #3a2417; border-radius: 50% / 60%;
  box-shadow: inset 0 0 18px rgba(0,0,0,.6);
}
.table-card-info { padding: 14px 16px 6px; }
.table-card-info h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 4px; }
.table-card-info p { font-size: 0.8rem; color: var(--muted); }
.table-card-badge { position: absolute; top: 10px; right: 10px; background: var(--gold); color: #0a0a0f; font-size: 0.72rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.table-card-live { margin: 2px 16px 14px; font-size: 0.75rem; color: var(--green); font-weight: 700; }

.back-link { display: inline-block; color: var(--muted); text-decoration: none; font-size: 0.85rem; margin: 18px 0 0; }
.back-link:hover { color: var(--gold); }

.footer { border-top: 1px solid var(--border); padding: 18px 0; font-size: 0.78rem; color: var(--muted); }

/* ═══════════════════ Poker table ═══════════════════ */
.table-wrap { padding: 24px 0 40px; display: flex; flex-direction: column; align-items: center; gap: 16px; }

.poker-table { position: relative; width: 100%; max-width: 900px; aspect-ratio: 16/9; }
.felt {
  position: absolute; inset: 6%;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(255,255,255,.06) 0%, rgba(255,255,255,0) 42%),
    radial-gradient(ellipse at 50% 42%, #0f4a20 0%, #0b351a 45%, #051509 80%, #030a04 100%);
  border: 12px solid #3a2417; border-radius: 50% / 40%;
  box-shadow:
    inset 0 0 70px rgba(0,0,0,.65),
    inset 0 0 0 4px rgba(255,215,0,.14),
    0 10px 30px rgba(0,0,0,.55),
    0 0 0 1px rgba(255,255,255,.03);
  overflow: hidden;
}
.felt::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; mix-blend-mode: overlay; opacity: .5;
  background-image: repeating-radial-gradient(circle at 50% 50%, rgba(255,255,255,.04) 0, rgba(255,255,255,.04) 1px, transparent 1px, transparent 3px);
}
.board { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; z-index: 2; }
.community { display: flex; gap: 8px; justify-content: center; margin-bottom: 10px; min-height: 90px; }
.pot { color: var(--gold); font-weight: 700; font-size: 1.02rem; text-shadow: 0 1px 4px rgba(0,0,0,.6); }
.pot::before { content: ''; display: inline-block; width: 14px; height: 14px; border-radius: 50%; margin-right: 7px; vertical-align: -2px;
  background: radial-gradient(circle at 35% 30%, #fff1b8, var(--gold2) 58%, #8a6d00 100%);
  box-shadow: 0 0 0 2px rgba(0,0,0,.45) inset, 0 1px 3px rgba(0,0,0,.5); }
.winner-banner { color: var(--gold); font-weight: 700; font-size: 0.88rem; margin-top: 6px; text-align: center; text-shadow: 0 1px 4px rgba(0,0,0,.6); }

/* ── custom vector card deck (no image assets) ──────────────────────────── */
.card {
  position: relative; width: 54px; height: 76px; flex-shrink: 0; border-radius: 7px; color: #17172a;
  background: linear-gradient(160deg, #ffffff 0%, #f0f0f0 100%);
  box-shadow: 0 3px 10px rgba(0,0,0,.5), inset 0 0 0 1px rgba(0,0,0,.08);
}
.card.red { color: #c0392b; }
.card-corner { position: absolute; display: flex; flex-direction: column; align-items: center; line-height: 1; font-weight: 800; }
.card-corner-tl { top: 4px; left: 5px; }
.card-corner-br { bottom: 4px; right: 5px; transform: rotate(180deg); }
.card-rank { font-size: .74rem; }
.card-suit { font-size: .82rem; margin-top: 1px; }
.card-pip { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 1.7rem; opacity: .92; }
.card.big { width: 70px; height: 98px; }
.card.big .card-rank { font-size: .86rem; }
.card.big .card-suit { font-size: .96rem; }
.card.big .card-pip { font-size: 2.2rem; }

.card.back {
  background: repeating-linear-gradient(45deg, #13173a 0px 7px, #1b2150 7px 14px);
  box-shadow: 0 3px 10px rgba(0,0,0,.5), inset 0 0 0 2px rgba(255,215,0,.4), inset 0 0 0 6px #0a0a12;
  display: flex; align-items: center; justify-content: center;
}
.card-back-logo { width: 56%; height: 56%; opacity: .95; }

/* one-shot animations — gated in table.js so these only fire on a real state change, not every poll */
.seat-cards.deal-in .card, .card.deal-in {
  animation: dealIn .35s cubic-bezier(.2,.7,.3,1.1) backwards;
}
@keyframes dealIn {
  0% { transform: translate(-50%, -140%) scale(.6) rotate(-8deg); opacity: 0; }
  100% { transform: translate(0, 0) scale(1) rotate(0); opacity: 1; }
}
.card.flip-reveal { animation: flipReveal .5s ease-in; }
@keyframes flipReveal {
  0% { transform: rotateY(180deg); }
  49% { transform: rotateY(180deg); filter: brightness(.6); }
  50% { transform: rotateY(0deg); filter: brightness(.6); }
  100% { transform: rotateY(0deg); }
}
.chip-fly {
  position: fixed; width: 14px; height: 14px; border-radius: 50%; z-index: 9999; pointer-events: none;
  background: radial-gradient(circle at 35% 30%, #fff1b8, var(--gold2) 58%, #8a6d00 100%);
  box-shadow: 0 0 0 2px rgba(0,0,0,.45) inset, 0 2px 6px rgba(0,0,0,.5);
  transition: transform .55s cubic-bezier(.3,.6,.3,1), opacity .55s ease-in .1s;
}
.confetti-piece {
  position: fixed; width: 7px; height: 11px; z-index: 9999; pointer-events: none;
  animation: confettiFall 1.1s cubic-bezier(.2,.7,.4,1) forwards;
}
@keyframes confettiFall {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; }
}

.seats { position: absolute; inset: 0; z-index: 3; }
.seat {
  position: absolute; width: 172px; transform: translate(-50%, -50%);
  background: linear-gradient(160deg, var(--surface) 0%, var(--surface2) 100%);
  border: 1px solid var(--border); border-radius: 13px;
  padding: 12px 10px; text-align: center; font-size: 0.85rem;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  box-shadow: 0 4px 12px rgba(0,0,0,.35);
  transition: border-color .15s, box-shadow .15s;
}
.seat.empty { background: rgba(255,255,255,.03); border-style: dashed; cursor: pointer; color: var(--muted); box-shadow: none; }
.seat.empty:hover { border-color: var(--gold); color: var(--gold); }
.seat.active-turn { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 18px rgba(255,215,0,.45); }
.seat.active-turn::after {
  content: ''; position: absolute; inset: -4px; border-radius: 15px; padding: 3px; pointer-events: none;
  background: conic-gradient(var(--gold) calc(var(--turn-pct, 100) * 1%), transparent 0);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  filter: drop-shadow(0 0 4px rgba(255,215,0,.6));
}
.seat.folded { opacity: .4; }
.seat.you { border-color: var(--accent); }
.seat.winner { border-color: var(--gold); animation: winnerPulse 1.6s ease-in-out infinite; }
@keyframes winnerPulse {
  0%, 100% { box-shadow: 0 0 0 1px var(--gold), 0 0 14px rgba(255,215,0,.4); }
  50% { box-shadow: 0 0 0 1px var(--gold), 0 0 30px rgba(255,215,0,.85); }
}
.seat-avatar {
  width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 800; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.5);
  box-shadow: 0 0 0 2px rgba(255,255,255,.1), 0 2px 6px rgba(0,0,0,.4);
}
.seat-number { color: var(--muted); font-size: 0.64rem; text-transform: uppercase; letter-spacing: .05em; }
.seat-category { color: var(--gold); font-size: 0.68rem; margin-top: 2px; }
.seat-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.seat-stack { color: var(--gold); font-size: 0.82rem; }
.seat-stack::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px;
  background: radial-gradient(circle at 35% 30%, #fff1b8, var(--gold2) 58%, #8a6d00 100%);
  box-shadow: 0 0 0 2px rgba(0,0,0,.45) inset; }
.seat-bet { color: var(--muted); font-size: 0.7rem; }
.seat-sitout { color: var(--muted); font-size: 0.7rem; font-style: italic; }
.seat-standup { color: var(--accent); font-size: 0.65rem; margin-top: 2px; text-decoration: underline; cursor: pointer; }
.seat-standup.disabled { color: var(--muted); text-decoration: none; cursor: default; }
.seat-cards { display: flex; gap: 4px; justify-content: center; margin-top: 5px; }
.seat-cards .card { width: 48px; height: 67px; border-radius: 6px; }
.seat-cards .card .card-rank { font-size: .68rem; }
.seat-cards .card .card-suit { font-size: .74rem; }
.seat-cards .card .card-pip { font-size: 1.5rem; }
.button-chip {
  position: absolute; width: 20px; height: 20px; border-radius: 50%; font-size: 0.62rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center; transform: translate(16px, -16px);
  background: radial-gradient(circle at 35% 30%, #fffbe6, var(--gold) 55%, var(--gold2) 100%); color: #0a0a0f;
  box-shadow: 0 2px 5px rgba(0,0,0,.5);
}

/* seat position table for up to 6 seats, oval layout */
.seat[data-seat="0"] { left: 50%; top: 94%; }
.seat[data-seat="1"] { left: 14%; top: 74%; }
.seat[data-seat="2"] { left: 6%; top: 28%; }
.seat[data-seat="3"] { left: 50%; top: 6%; }
.seat[data-seat="4"] { left: 94%; top: 28%; }
.seat[data-seat="5"] { left: 86%; top: 74%; }

/* turn timer — a subtle ring on the seat itself (visible to everyone), plus an explicit
   number badge and (when it's your own turn) a hard-to-miss bar + countdown in the action bar */
.turn-timer {
  position: absolute; top: -9px; left: -9px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--gold); color: #0a0a0f; font-size: 0.68rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.5), 0 0 0 2px var(--surface);
  z-index: 4;
}
.turn-countdown { margin-bottom: 2px; }
.turn-countdown-track { height: 7px; border-radius: 4px; background: var(--surface2); overflow: hidden; }
.turn-countdown-bar { height: 100%; width: 100%; background: linear-gradient(90deg, var(--gold2), var(--gold)); }
.turn-countdown-text { display: block; text-align: center; font-size: 0.8rem; font-weight: 700; color: var(--gold); margin-top: 4px; }

.action-bar { width: 100%; max-width: 560px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.ab-info { font-size: 0.82rem; color: var(--muted); text-align: center; }
.ab-controls { display: flex; gap: 8px; align-items: center; }
.btn-act { flex: 1; border: none; padding: 11px; border-radius: 8px; font-weight: 700; cursor: pointer; font-size: 0.9rem; }
.btn-fold { background: var(--surface2); color: var(--red); border: 1px solid var(--border); }
.btn-call { background: var(--surface2); color: var(--green); border: 1px solid var(--border); }
.btn-raise { background: linear-gradient(135deg, var(--gold2), var(--gold)); color: #0a0a0f; }
.raise-group { flex: 2; display: flex; gap: 6px; }
.raise-group .bet-input { width: 90px; }
.btn-act:disabled { opacity: .35; cursor: not-allowed; }

@media (max-width: 760px) {
  .hdr-inner { flex-wrap: wrap; height: auto; padding: 8px 20px; }
  .player-bar { width: 100%; justify-content: flex-end; flex-wrap: wrap; }
  .hero { padding: 28px 0 20px; }
  .hero h1 { font-size: 1.5rem; }
  .table-grid { grid-template-columns: 1fr; }

  .seat { width: 124px; font-size: 0.72rem; padding: 7px; }
  .seat-avatar { width: 26px; height: 26px; font-size: .58rem; }
  .button-chip { width: 16px; height: 16px; font-size: .5rem; transform: translate(12px, -12px); }

  .card { width: 36px; height: 50px; border-radius: 5px; }
  .card .card-rank { font-size: .54rem; }
  .card .card-suit { font-size: .6rem; }
  .card .card-pip { font-size: 1.1rem; }
  .card.big { width: 46px; height: 64px; }
  .card.big .card-rank { font-size: .6rem; }
  .card.big .card-suit { font-size: .68rem; }
  .card.big .card-pip { font-size: 1.4rem; }
  .community { min-height: 64px; }
  .seat-cards .card { width: 34px; height: 47px; border-radius: 5px; }
  .seat-cards .card .card-rank { font-size: .5rem; }
  .seat-cards .card .card-suit { font-size: .55rem; }
  .seat-cards .card .card-pip { font-size: 1.05rem; }
}
