@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Syne:wght@400;600;700;800&display=swap');

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

:root {
  --bg: #0e1117;
  --bg2: #151820;
  --felt: #0d3320;
  --felt2: #0a2a1a;
  --rail: #1a4a2e;
  --rail2: #0f3020;
  --gold: #f0c040;
  --gold2: #d4a520;
  --text: #c8d0d8;
  --text2: #7a8898;
  --border: #1e2838;
  --card-bg: #f5f0e8;
  --red: #c0392b;
  --font-mono: 'Share Tech Mono', monospace;
  --font-head: 'Syne', sans-serif;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

/* ─── Scrollbar ────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ─── Header ───────────────────────────────────────────────────── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #fff;
}
.logo span { color: var(--gold); }

.tagline {
  font-size: 11px;
  color: var(--text2);
  letter-spacing: 3px;
  text-transform: uppercase;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.spectator-count {
  font-size: 12px;
  color: var(--text2);
}
.spectator-count strong { color: var(--gold); }

.nav-links {
  display: flex;
  gap: 10px;
  font-size: 12px;
  align-items: center;
}
.nav-links a {
  color: var(--text2);
  transition: color 0.2s;
}
.nav-links a:hover, .nav-links a.active { color: #fff; }
.nav-links a[href="/leaderboard.html"] {
  margin-left: 6px;
  padding-left: 10px;
  border-left: 1px solid #1e3a2a;
}

/* ─── Live pulse ───────────────────────────────────────────────── */
.live-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #ff4040;
  display: inline-block;
  animation: pulse-red 1.4s ease-in-out infinite;
}
@keyframes pulse-red {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(255,64,64,0.6); }
  50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(255,64,64,0); }
}

/* ─── LOBBY ────────────────────────────────────────────────────── */
.lobby-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}

.lobby-hero {
  text-align: center;
  margin-bottom: 40px;
}
.lobby-hero h1 {
  font-family: var(--font-head);
  font-size: 36px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 8px;
}
.lobby-hero p {
  color: var(--text2);
  font-size: 13px;
  letter-spacing: 1px;
}

.table-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 48px;
}

.table-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
  position: relative;
  overflow: hidden;
}
.table-card:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
}

.table-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.table-name {
  font-family: var(--font-head);
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}
.table-number {
  font-size: 11px;
  color: var(--text2);
  margin-top: 2px;
}

.phase-pill {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}
.phase-pill.preflop { background: #1a3a5a; color: #6ab0ff; }
.phase-pill.flop { background: #1a3a1a; color: #6aff8a; }
.phase-pill.turn { background: #3a2a00; color: #ffd060; }
.phase-pill.river { background: #3a1a1a; color: #ff8080; }
.phase-pill.showdown { background: #2a1a3a; color: #d088ff; }
.phase-pill.waiting { background: #1e2838; color: #7a8898; }

.agent-avatars {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.agent-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 700;
  color: var(--bg);
  flex-shrink: 0;
}

.table-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.pot-display {
  color: var(--gold);
  font-size: 14px;
}
.pot-display small { color: var(--text2); font-size: 10px; margin-right: 4px; }

.hand-num { color: var(--text2); font-size: 11px; }

/* ─── Mini leaderboard strip ───────────────────────────────────── */
.mini-leaderboard {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}
.mini-leaderboard h3 {
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 16px;
}
.mini-lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.mini-lb-row:last-child { border-bottom: none; }
.mini-lb-rank { color: var(--gold); font-size: 13px; width: 20px; }
.mini-lb-name { font-family: var(--font-head); font-size: 14px; font-weight: 700; flex: 1; }
.mini-lb-stat { color: var(--text2); font-size: 12px; }

/* ─── TABLE VIEW ───────────────────────────────────────────────── */
.table-page {
  display: grid;
  grid-template-columns: 1fr 360px;
  height: calc(100vh - 53px);
  overflow: hidden;
}

/* Left: poker table panel */
.table-panel {
  display: flex;
  flex-direction: column;
  padding: 24px;
  overflow: hidden;
  background: var(--bg);
}

.table-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-shrink: 0;
}

.table-title {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}

.hand-info {
  font-size: 12px;
  color: var(--text2);
  display: flex;
  gap: 16px;
}

/* Phase bar */
.phase-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  flex-shrink: 0;
}
.phase-step {
  flex: 1;
  text-align: center;
  padding: 5px;
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: all 0.3s;
}
.phase-step.active {
  color: var(--gold);
  border-color: var(--gold);
  background: rgba(240,192,64,0.08);
}
.phase-step.done {
  color: #fff;
  border-color: var(--rail);
  background: var(--rail2);
}

/* Felt table container */
.felt-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 0;
}

.felt-table {
  position: relative;
  width: min(680px, 100%);
  aspect-ratio: 16/9;
  background: radial-gradient(ellipse at 50% 40%, #0f4028 0%, var(--felt) 55%, var(--felt2) 100%);
  border: 8px solid var(--rail);
  border-radius: 50%;
  box-shadow: 0 0 60px rgba(0,0,0,0.8), inset 0 0 40px rgba(0,0,0,0.4);
  overflow: visible;
}

/* CRT scanline overlay */
.felt-table::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: inherit;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.04) 2px,
    rgba(0,0,0,0.04) 4px
  );
  pointer-events: none;
  z-index: 5;
}

/* Community cards in center */
.community-area {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 2;
}

.community-cards {
  display: flex;
  gap: 6px;
}

.pot-badge {
  background: rgba(240,192,64,0.15);
  border: 1px solid var(--gold2);
  color: var(--gold);
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: 1px;
}

/* Agent seats */
.seat {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 10;
  transition: opacity 0.3s;
}

.seat.folded { opacity: 0.35; }

.seat.thinking .seat-card {
  animation: thinking-pulse 0.8s ease-in-out infinite;
}

@keyframes thinking-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,255,255,0.2); }
  50% { box-shadow: 0 0 0 8px rgba(255,255,255,0); }
}

/* Seat positions (for 4 players) — seats extend outside the oval */
.seat[data-pos="0"] { top: 4%; left: 23%; transform: translateX(-50%); }
.seat[data-pos="1"] { top: 4%; left: 77%; transform: translateX(-50%); }
.seat[data-pos="2"] { top: 50%; left: 101%; transform: translateY(-50%); }
/* pos 3: anchor right edge at left:0 so it extends LEFT of the table */
.seat[data-pos="3"] { top: 50%; left: 0%; transform: translate(-100%, -50%); }

/* 3 players */
.seat[data-pos="0"].three { top: 4%; left: 25%; transform: translateX(-50%); }
.seat[data-pos="1"].three { top: 4%; left: 75%; transform: translateX(-50%); }
.seat[data-pos="2"].three { top: 68%; left: 50%; transform: translateX(-50%); }

/* 2 players (heads up) */
.seat[data-pos="0"].two { top: 6%; left: 50%; transform: translateX(-50%); }
.seat[data-pos="1"].two { top: auto; bottom: 6%; left: 50%; transform: translateX(-50%); }

.seat-card {
  background: var(--bg2);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  min-width: 120px;
  text-align: center;
  transition: border-color 0.3s;
}
.seat.active .seat-card { border-color: var(--gold); }

.seat-model { font-size: 9px; color: var(--text2); letter-spacing: 1px; margin-bottom: 2px; }
.seat-name { font-family: var(--font-head); font-size: 15px; font-weight: 700; }
.seat-chips { font-size: 11px; color: var(--text2); margin-top: 2px; }

.action-badge {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 8px;
  font-weight: 600;
  letter-spacing: 1px;
  margin-top: 4px;
  display: inline-block;
}
.action-badge.fold { background: #3a1a1a; color: #ff6060; }
.action-badge.call { background: #1a3a1a; color: #60ff80; }
.action-badge.raise { background: #3a2a00; color: #ffc040; }
.action-badge.check { background: #1a2a3a; color: #60c0ff; }
.action-badge.allin { background: #3a0a3a; color: #ff60ff; animation: allin-flash 0.5s 4; }
@keyframes allin-flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.seat-reasoning {
  font-size: 10px;
  color: var(--text2);
  font-style: italic;
  max-width: 130px;
  text-align: center;
  line-height: 1.4;
  opacity: 0;
  animation: fade-in-out 3s ease forwards;
}
@keyframes fade-in-out {
  0% { opacity: 0; }
  10% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; }
}

.hole-cards {
  display: flex;
  gap: 4px;
}

/* ─── Playing cards ────────────────────────────────────────────── */
.card {
  width: 34px; height: 46px;
  background: var(--card-bg);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-mono);
  box-shadow: 1px 2px 6px rgba(0,0,0,0.5);
  position: relative;
  color: #1a1a1a;
  flex-shrink: 0;
  animation: card-deal 0.3s ease;
}
@keyframes card-deal {
  from { transform: rotateY(90deg) scale(0.8); opacity: 0; }
  to { transform: rotateY(0deg) scale(1); opacity: 1; }
}

.card.red { color: var(--red); }

.card-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}
.card-rank { font-size: 15px; font-weight: 800; }
.card-suit { font-size: 13px; }

.card.back {
  background: #1a4a8a;
  background-image: repeating-linear-gradient(
    45deg, rgba(255,255,255,0.05), rgba(255,255,255,0.05) 1px,
    transparent 1px, transparent 8px
  );
}

.card.empty {
  background: rgba(255,255,255,0.05);
  border: 1px dashed rgba(255,255,255,0.1);
  box-shadow: none;
}

/* Community card sizing */
.community-cards .card {
  width: 44px; height: 60px;
}
.community-cards .card .card-rank { font-size: 18px; }
.community-cards .card .card-suit { font-size: 16px; }

/* ─── Analysis panel (right) ───────────────────────────────────── */
.analysis-panel {
  background: var(--bg2);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-section h3 {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text2);
  margin-bottom: 12px;
}

/* Equity bars */
.equity-bar-wrap {
  margin-bottom: 8px;
}
.equity-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  margin-bottom: 3px;
}
.equity-bar-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.equity-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s ease;
}

/* GT stats grid */
.gt-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.gt-stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
}
.gt-stat-label { font-size: 9px; color: var(--text2); text-transform: uppercase; letter-spacing: 1px; }
.gt-stat-value { font-size: 13px; color: var(--text); margin-top: 2px; }
.gt-stat-value.highlight { color: var(--gold); }

.gt-observation {
  background: var(--bg);
  border-left: 2px solid var(--gold2);
  padding: 8px 10px;
  font-size: 11px;
  color: var(--text2);
  font-style: italic;
  line-height: 1.5;
  border-radius: 0 4px 4px 0;
  animation: obs-fade 0.5s ease;
}
@keyframes obs-fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Session leaderboard */
.session-lb {
  font-size: 12px;
}
.session-lb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.session-lb-row:last-child { border-bottom: none; }
.session-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.session-name { font-family: var(--font-head); font-weight: 600; flex: 1; font-size: 12px; }
.session-chips { color: var(--gold); }
.session-wr { color: var(--text2); font-size: 10px; margin-left: auto; }

/* Commentary feed */
.commentary-box {
  padding: 12px 16px;
  border-bottom: 1px solid #0a2218;
}
.commentary-box h3 {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--gold);
  margin-bottom: 8px;
}
#commentary-feed {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 100px;
  overflow: hidden;
}
.commentary-line {
  font-size: 11px;
  color: var(--text2);
  line-height: 1.45;
  padding: 4px 0;
  border-bottom: 1px solid #0d2a1a;
  animation: commentFadeIn 0.5s ease;
}
.commentary-line:first-child {
  color: var(--text);
  font-style: italic;
}
.commentary-line:last-child { border-bottom: none; }
@keyframes commentFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Action log */
.action-log {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}
.action-log h3 {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text2);
  margin-bottom: 8px;
}
.log-entry {
  font-size: 11px;
  color: var(--text2);
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  display: flex;
  gap: 8px;
}
.log-time { color: #3a4858; flex-shrink: 0; }
.log-text { flex: 1; }

/* ─── LEADERBOARD PAGE ────────────────────────────────────────── */
.lb-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px;
}

.lb-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}
.lb-header h1 {
  font-family: var(--font-head);
  font-size: 28px;
  font-weight: 800;
  color: #fff;
}

.lb-controls {
  display: flex;
  gap: 12px;
}
.lb-search {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 6px;
  outline: none;
}
.lb-search:focus { border-color: var(--gold); }

.lb-table-wrap {
  overflow-x: auto;
}
table.lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.lb-table th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text2);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
}
table.lb-table th:hover { color: #fff; }
table.lb-table th.sorted { color: var(--gold); }

table.lb-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
table.lb-table tr:hover td { background: rgba(255,255,255,0.02); }

.lb-rank { color: var(--text2); }
.lb-rank.top1 { color: #ffd700; }
.lb-rank.top2 { color: #c0c0c0; }
.lb-rank.top3 { color: #cd7f32; }

.lb-agent-name {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 14px;
}
.lb-model-name { font-size: 10px; color: var(--text2); }
.lb-win-rate { color: var(--gold); font-weight: 600; }

/* ─── Winner announcement ──────────────────────────────────────── */
.winner-banner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg2);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 12px 24px;
  font-family: var(--font-head);
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  z-index: 200;
  animation: banner-in 0.4s ease, banner-out 0.4s ease 4s forwards;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.6);
}
@keyframes banner-in {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes banner-out {
  from { opacity: 1; }
  to { opacity: 0; pointer-events: none; }
}

/* ─── Responsive ───────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .table-page {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: auto;
    overflow: auto;
  }
  .analysis-panel {
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 600px;
  }
  .table-panel { height: 60vh; min-height: 480px; }
}

@media (max-width: 768px) {
  .table-grid { grid-template-columns: repeat(2, 1fr); }
  .felt-table { aspect-ratio: 4/3; }
  .site-header .tagline { display: none; }
}
@media (max-width: 480px) {
  .table-grid { grid-template-columns: 1fr; }
}
