:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --row-a: #1b2a4a;
  --row-b: #162040;
  --accent: #e94560;
  --gold: #f0c040;
  --text: #eee;
  --muted: #888;
  --green: #2ecc71;
  --red: #e74c3c;
}

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

body {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  background: var(--bg);
  color: var(--text);
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 12px;
}

.hidden { display: none !important; }

/* ── Header ─────────────────────────────── */

header {
  background: var(--surface);
  padding: 6px 10px;
  border-bottom: 2px solid var(--accent);
}

#header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  font-size: 1.2rem;
  letter-spacing: 4px;
  color: var(--gold);
}

#connect-wallet {
  background: var(--accent);
  color: white;
  border: none;
  padding: 4px 12px;
  border-radius: 3px;
  font-family: inherit;
  font-size: 0.65rem;
  cursor: pointer;
}

#wallet-connected { font-size: 0.7rem; }
#wallet-balance { color: var(--gold); font-weight: bold; }

#status-bar {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 3px;
}

/* ── Main ───────────────────────────────── */

main {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

section {
  background: var(--surface);
  border-radius: 4px;
}

/* ── My Bets (pinned) ───────────────────── */

#my-bets {
  padding: 6px;
  border: 1px solid var(--green);
}

#my-bets h3 {
  font-size: 0.6rem;
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.my-bet-row {
  display: grid;
  grid-template-columns: 20px repeat(6, 1fr);
  gap: 2px;
  margin-bottom: 2px;
  cursor: pointer;
}

.my-bet-row:hover { background: var(--row-a); }

/* ── Grid ───────────────────────────────── */

#grid-section {
  padding: 0;
  overflow: hidden;
}

#grid-header {
  display: grid;
  grid-template-columns: 20px repeat(6, 1fr);
  gap: 1px;
  padding: 4px 2px 2px;
  background: var(--surface);
}

.gh-label { }
.gh-seat {
  text-align: center;
  font-size: 0.55rem;
  color: var(--muted);
  text-transform: uppercase;
}

#grid-body {
  max-height: 55vh;
  overflow-y: auto;
}

.grid-row {
  display: grid;
  grid-template-columns: 20px repeat(6, 1fr);
  gap: 1px;
  padding: 1px 2px;
  cursor: pointer;
  border-left: 2px solid transparent;
}

.grid-row:nth-child(odd) { background: var(--row-a); }
.grid-row:nth-child(even) { background: var(--row-b); }
.grid-row.selected { border-left-color: var(--gold); background: #1f3055; }
.grid-row.has-bet { border-left-color: var(--green); }
.grid-row.selected.has-bet { border-left-color: var(--gold); }

.grid-label {
  font-weight: bold;
  color: var(--muted);
  font-size: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.grid-cell {
  text-align: center;
  padding: 3px 1px;
  font-size: 0.55rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 2px;
  min-height: 28px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.grid-cell.empty { opacity: 0.15; }
.grid-cell.eliminated { opacity: 0.15; }
.grid-cell.has-bet-cell { background: rgba(46, 204, 113, 0.1); }

.gc-name {
  font-weight: bold;
  color: var(--gold);
  font-size: 0.55rem;
}

.gc-stack {
  color: var(--green);
  font-size: 0.5rem;
}

.gc-cards {
  display: flex;
  gap: 1px;
  justify-content: center;
}

/* ── Cards ──────────────────────────────── */

.card {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: white;
  color: #333;
  font-weight: bold;
  box-shadow: 0 1px 1px rgba(0,0,0,0.2);
  flex-shrink: 0;
}

.card.lg { width: 32px; height: 44px; font-size: 0.8rem; border-radius: 3px; }
.card.sm { width: 18px; height: 24px; font-size: 0.45rem; border-radius: 2px; }
.card.mini { width: 100%; height: 22px; font-size: 0.45rem; border-radius: 2px; }
.card.red { color: #c0392b; }
.card.folded-card { opacity: 0.25; background: #999; color: #666; }

/* ── Detail panel ───────────────────────── */

#detail-panel { overflow: hidden; }

#detail-tabs {
  display: flex;
  border-bottom: 1px solid var(--row-b);
}

.dtab {
  flex: 1;
  padding: 6px 0;
  background: var(--row-b);
  color: var(--muted);
  border: none;
  font-family: inherit;
  font-size: 0.65rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
}

.dtab:hover { color: var(--text); }
.dtab.selected { background: var(--surface); color: var(--gold); border-bottom: 2px solid var(--gold); }

#detail-content { padding: 6px; }
.dtab-page { max-height: 240px; overflow-y: auto; }
.dtab-page.hidden { display: none; }

/* Detail board */
#detail-board {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px;
  background: #0d4b2e;
  border-radius: 4px;
  margin-bottom: 6px;
}

#detail-board .board-cards { display: flex; gap: 3px; }
#detail-board .pot { color: var(--gold); font-weight: bold; font-size: 0.75rem; }

/* Detail players */
.dp-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px;
  font-size: 0.65rem;
}

.dp-row:nth-child(odd) { background: var(--row-a); }
.dp-row:nth-child(even) { background: var(--row-b); }

.dp-name { font-weight: bold; color: var(--gold); min-width: 60px; }
.dp-cards { display: flex; gap: 2px; }
.dp-stack { color: var(--green); min-width: 45px; text-align: right; }
.dp-action { min-width: 55px; text-align: right; font-size: 0.6rem; }
.dp-bet-btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 2px;
  padding: 1px 6px;
  font-size: 0.55rem;
  font-family: inherit;
  cursor: pointer;
}
.dp-bet-btn.is-bet { background: var(--green); }

.act-fold { color: var(--red); }
.act-raise { color: var(--gold); }
.act-call { color: var(--green); }
.act-check { color: var(--muted); }
.act-allin { color: var(--accent); font-weight: bold; }
.act-winner { color: var(--gold); font-weight: bold; }

/* Hand log in detail */
#detail-hand-log { font-size: 0.6rem; margin-top: 6px; }
.log-entry { padding: 2px 0; color: var(--muted); border-bottom: 1px solid rgba(255,255,255,0.03); }
.log-entry .action-fold { color: var(--red); }
.log-entry .action-raise { color: var(--gold); }
.log-entry .action-call { color: var(--green); }
.log-entry .action-allin { color: var(--accent); font-weight: bold; }
.log-entry .winner { color: var(--gold); font-weight: bold; }

/* Tournament log */
#tournament-log { font-size: 0.6rem; }
.tlog-entry { padding: 2px 4px; border-bottom: 1px solid rgba(255,255,255,0.03); }
.tlog-entry:nth-child(odd) { background: var(--row-a); }
.tlog-entry:nth-child(even) { background: var(--row-b); }
.log-hand { color: var(--muted); margin-right: 4px; }
.log-elim { color: var(--red); }
.log-move, .log-shift { color: var(--muted); }
.log-win { color: var(--gold); }
.log-blinds { color: var(--accent); font-weight: bold; }
.log-consolidate { color: var(--accent); }
.log-seat { color: var(--muted); opacity: 0.6; }

/* ── Footer ─────────────────────────────── */

footer {
  background: var(--surface);
  padding: 6px 10px;
  border-top: 2px solid var(--accent);
}

#controls { display: flex; gap: 4px; justify-content: center; }
#controls button {
  background: var(--row-b);
  color: var(--text);
  border: 1px solid var(--muted);
  border-radius: 3px;
  padding: 6px 10px;
  font-family: inherit;
  font-size: 0.65rem;
  cursor: pointer;
}
#controls button:hover { border-color: var(--gold); }
#controls button.active { border-color: var(--accent); background: var(--accent); }

#tournament-config {
  margin-top: 4px;
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
}
#tournament-config input {
  background: var(--row-b);
  color: var(--text);
  border: 1px solid var(--muted);
  border-radius: 3px;
  padding: 2px 4px;
  width: 50px;
  font-family: inherit;
  font-size: 0.6rem;
}
#tournament-config button {
  background: var(--green);
  color: white;
  border: none;
  border-radius: 3px;
  padding: 4px 10px;
  font-family: inherit;
  cursor: pointer;
}

/* ── Winner ─────────────────────────────── */

#winner-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  z-index: 100;
}
#winner-overlay h2 { color: var(--gold); font-size: 1.5rem; margin-bottom: 8px; }
#winner-overlay p { font-size: 0.9rem; }
#winner-overlay button {
  margin-top: 12px; background: var(--accent); color: white; border: none;
  padding: 6px 18px; border-radius: 3px; font-family: inherit; cursor: pointer;
}

/* ── Scrollbar ──────────────────────────── */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--muted); border-radius: 2px; }

@media (min-width: 768px) {
  body { max-width: 600px; font-size: 13px; }
  .card.lg { width: 40px; height: 54px; font-size: 0.9rem; }
}
