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

:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --panel: #0f3460;
  --accent: #e94560;
  --accent2: #f5a623;
  --green: #4caf50;
  --text: #eaeaea;
  --muted: #888;
  --card-w: 64px;
  --card-h: 90px;
  --radius: 8px;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ─── Screens ─────────────────────────────────────────────────────────────── */

.screen { display: none; width: 100%; max-width: 960px; padding: 24px 16px; }
.screen.active { display: flex; flex-direction: column; align-items: center; gap: 20px; }

h1 { font-size: 2.4rem; color: var(--accent); letter-spacing: 2px; text-align: center; }
h2 { font-size: 1.4rem; color: var(--accent2); text-align: center; }
h3 { font-size: 1.1rem; color: var(--muted); }

/* ─── Forms ───────────────────────────────────────────────────────────────── */

.panel {
  background: var(--surface);
  border: 1px solid var(--panel);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 420px;
}

.form-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
label { font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
input[type="text"] {
  background: var(--bg);
  border: 1px solid var(--panel);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.2s;
}
input[type="text"]:focus { border-color: var(--accent); }
input[type="text"].code-input { text-transform: uppercase; letter-spacing: 4px; font-size: 1.2rem; }

.divider { border: none; border-top: 1px solid var(--panel); margin: 20px 0; }

/* ─── Buttons ─────────────────────────────────────────────────────────────── */

button {
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  padding: 10px 20px;
  transition: opacity 0.15s, transform 0.1s;
}
button:hover:not(:disabled) { opacity: 0.9; transform: translateY(-1px); }
button:active:not(:disabled) { transform: translateY(0); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; width: 100%; padding: 12px; }
.btn-secondary { background: var(--panel); color: var(--text); }
.btn-action { background: var(--accent2); color: #111; min-width: 80px; }
.btn-danger  { background: #c0392b; color: #fff; min-width: 80px; }
.btn-green   { background: var(--green); color: #fff; }
.btn-large   { font-size: 1.2rem; padding: 14px 32px; }

/* ─── Lobby ───────────────────────────────────────────────────────────────── */

.game-code-display {
  background: var(--panel);
  border-radius: var(--radius);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 8px;
  padding: 16px 32px;
  color: var(--accent2);
  text-align: center;
  user-select: all;
}

.player-list {
  list-style: none;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-item {
  background: var(--surface);
  border: 1px solid var(--panel);
  border-radius: 6px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.player-item .crown { color: var(--accent2); }
.player-item .you-badge { font-size: 0.75rem; color: var(--accent); margin-left: auto; }
.player-item.disconnected { opacity: 0.5; }

/* ─── Round header ────────────────────────────────────────────────────────── */

.round-header {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 10px 24px;
  display: flex;
  gap: 32px;
  align-items: center;
  font-size: 1rem;
  width: 100%;
}
.round-header .label { color: var(--muted); font-size: 0.8rem; }
.round-header .value { font-weight: 700; font-size: 1.2rem; color: var(--accent2); }

/* ─── Player strip (chips + bet info) ────────────────────────────────────── */

.player-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  justify-content: center;
}

.player-chip {
  background: var(--surface);
  border: 2px solid var(--panel);
  border-radius: var(--radius);
  padding: 8px 14px;
  min-width: 120px;
  font-size: 0.85rem;
  transition: border-color 0.2s;
}
.player-chip.active-turn { border-color: var(--accent2); }
.player-chip.is-me { border-color: var(--accent); }
.player-chip .player-name { font-weight: 600; margin-bottom: 2px; display: block; }
.player-chip .chip-count { color: var(--accent2); }
.player-chip .bet-amount { color: var(--muted); font-size: 0.8rem; }
.player-chip.folded { opacity: 0.4; }
.player-chip.eliminated { opacity: 0.25; text-decoration: line-through; }

/* ─── Card deck / selection ───────────────────────────────────────────────── */

.deck-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 100%;
}

.card {
  width: var(--card-w);
  height: var(--card-h);
  border: 2px solid #555;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 4px 5px;
  font-weight: 800;
  font-size: 14px;
  position: relative;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  user-select: none;
}
.card:hover { transform: translateY(-4px); box-shadow: 0 4px 12px rgba(0,0,0,0.4); }
.card.selected {
  border-color: #2196f3;
  background: #e3f2fd;
  transform: translateY(-10px);
  box-shadow: 0 6px 16px rgba(33,150,243,0.5);
}
.card.hearts, .card.diamonds { color: #d32f2f; }
.card.spades, .card.clubs { color: #1a1a1a; }
.card .rank-top { line-height: 1; }
.card .suit-center { text-align: center; font-size: 22px; line-height: 1; }
.card .rank-bottom { line-height: 1; align-self: flex-end; transform: rotate(180deg); }
.card.static { cursor: default; }
.card.static:hover { transform: none; box-shadow: none; }
.card.winner-card { border-color: gold; box-shadow: 0 0 12px gold; }

/* Face-down card */
.card.face-down {
  background: linear-gradient(135deg, #1a3c6e 25%, #0d2b50 25%);
  border-color: #2a5298;
  cursor: default;
}
.card.face-down:hover { transform: none; }

/* ─── Hand display (showdown) ────────────────────────────────────────────── */

.hand-row {
  background: var(--surface);
  border: 1px solid var(--panel);
  border-radius: var(--radius);
  padding: 12px 16px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hand-row.winner { border-color: gold; background: #1a1a00; }
.hand-row .hand-label { font-size: 0.85rem; color: var(--muted); }
.hand-row .hand-rank { font-weight: 700; color: var(--accent2); }
.hand-row .hand-cards { display: flex; gap: 6px; flex-wrap: wrap; }

/* ─── Betting actions ─────────────────────────────────────────────────────── */

.bet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--panel);
  border-radius: var(--radius);
  padding: 16px;
  width: 100%;
}
.bet-actions.inactive { opacity: 0.35; pointer-events: none; }
.raise-group { display: flex; align-items: center; gap: 8px; }
.raise-group input[type="number"] {
  background: var(--bg);
  border: 1px solid var(--panel);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
  padding: 8px 12px;
  width: 100px;
  outline: none;
}
.raise-group input:focus { border-color: var(--accent); }

/* ─── Pot / status bar ────────────────────────────────────────────────────── */

.status-bar {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 12px 24px;
  display: flex;
  gap: 40px;
  justify-content: center;
  width: 100%;
  font-size: 1rem;
}
.status-bar .item { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.status-bar .item .s-label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.status-bar .item .s-value { font-size: 1.3rem; font-weight: 700; color: var(--accent2); }

/* ─── Game log ────────────────────────────────────────────────────────────── */

.game-log {
  background: var(--surface);
  border: 1px solid var(--panel);
  border-radius: var(--radius);
  padding: 10px 14px;
  width: 100%;
  max-height: 120px;
  overflow-y: auto;
  font-size: 0.82rem;
  color: var(--muted);
}
.game-log p { margin: 2px 0; }
.game-log p.important { color: var(--accent2); }

/* ─── Tie-breaker ─────────────────────────────────────────────────────────── */

.tie-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1rem;
}
.tie-row .tie-name { min-width: 120px; font-weight: 600; }

/* ─── Standings ───────────────────────────────────────────────────────────── */

.standings-list {
  list-style: none;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.standing-item {
  background: var(--surface);
  border: 1px solid var(--panel);
  border-radius: 6px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.standing-item .rank-badge {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--panel);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.standing-item:first-child .rank-badge { background: gold; color: #111; }
.standing-item:nth-child(2) .rank-badge { background: silver; color: #111; }
.standing-item:nth-child(3) .rank-badge { background: #cd7f32; color: #111; }
.standing-item .s-chips { margin-left: auto; font-weight: 700; color: var(--accent2); }

/* ─── Selection info ──────────────────────────────────────────────────────── */

.selection-count {
  font-size: 1.1rem;
  text-align: center;
  padding: 8px;
  color: var(--accent2);
}
.selection-waiting { font-size: 0.85rem; color: var(--muted); text-align: center; }

/* ─── Toast / error ───────────────────────────────────────────────────────── */

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  padding: 10px 24px;
  border-radius: 24px;
  font-size: 0.95rem;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 999;
}
#toast.visible { opacity: 1; }

/* ─── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  :root { --card-w: 52px; --card-h: 74px; }
  .card .suit-center { font-size: 16px; }
  h1 { font-size: 1.8rem; }
}
