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

:root {
  --felt: #1a5c38;
  --felt-dark: #0f3d24;
  --felt-border: #8b6914;
  --gold: #d4a843;
  --card-white: #faf8f5;
  --red: #c0392b;
  --black: #1a1a2e;
  --bg: #0d1117;
  --surface: #161b22;
  --text: #e6edf3;
  --muted: #8b949e;
}

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.app {
  display: grid;
  grid-template-columns: 1fr 260px;
  grid-template-rows: auto 1fr auto auto;
  gap: 1rem;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem;
  min-height: 100vh;
}

header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 1rem;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold);
}

.phase-badge {
  background: var(--surface);
  border: 1px solid #30363d;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--muted);
}

.display-mode {
  display: inline-flex;
  border: 1px solid #30363d;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.display-mode:not(.hidden) {
  margin-left: auto;
}

.display-mode.hidden { display: none; }

.display-mode-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.display-mode-btn:hover {
  color: var(--text);
}

.display-mode-btn.active {
  background: var(--gold);
  color: var(--black);
}

.btn-stop-replay {
  margin-left: auto;
  background: #3d1f1f;
  color: #f85149;
  border: 1px solid #f8514966;
  font-size: 0.85rem;
  padding: 0.35rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
}

.btn-stop-replay.hidden { display: none; }

.table-area {
  grid-column: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.table {
  position: relative;
  width: 100%;
  max-width: 700px;
  aspect-ratio: 16 / 10;
}

.table-felt {
  position: absolute;
  inset: 10% 5%;
  background: radial-gradient(ellipse at center, var(--felt) 0%, var(--felt-dark) 100%);
  border-radius: 50%;
  border: 6px solid var(--felt-border);
  box-shadow:
    inset 0 0 60px rgba(0, 0, 0, 0.4),
    0 8px 32px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.pot {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  min-height: 1.5rem;
}

.community {
  display: flex;
  gap: 0.4rem;
}

.seats {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.player-seat {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: auto;
}

.player-seat.has-hud {
  cursor: help;
}

.player-hud-tooltip {
  position: absolute;
  bottom: calc(100% + 0.4rem);
  left: 50%;
  transform: translateX(-50%);
  min-width: 9.5rem;
  padding: 0.55rem 0.65rem;
  background: rgba(12, 16, 22, 0.96);
  border: 1px solid #3d4654;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  z-index: 30;
  text-align: left;
}

.player-seat.has-hud:hover .player-hud-tooltip,
.player-seat.has-hud:focus-within .player-hud-tooltip {
  opacity: 1;
  visibility: visible;
}

.player-hud-title {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.player-hud-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem 0.65rem;
  margin: 0;
}

.player-hud-grid div {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.78rem;
}

.player-hud-grid dt {
  margin: 0;
  color: var(--muted);
  font-weight: 500;
}

.player-hud-grid dd {
  margin: 0;
  font-weight: 600;
  color: var(--text);
}

.player-hud-note {
  margin: 0.4rem 0 0;
  font-size: 0.65rem;
  color: var(--muted);
  text-align: center;
}

.player-seat.folded {
  opacity: 0.45;
}

.player-seat.folded.peek-cards:hover {
  opacity: 0.9;
}

.player-seat.active .player-info {
  border-color: var(--gold);
  box-shadow: 0 0 12px rgba(212, 168, 67, 0.5);
}

.dealer-button {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  background: white;
  color: var(--black);
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ccc;
  z-index: 2;
}

.player-cards {
  display: flex;
  gap: 0.25rem;
}

.player-seat.peek-cards .player-cards {
  cursor: pointer;
}

.card-slot {
  position: relative;
  width: 52px;
  height: 74px;
  flex-shrink: 0;
}

.card-slot .card {
  position: absolute;
  top: 0;
  left: 0;
}

.card-peek .card-peek-face {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.card-peek .card-peek-back {
  transition: opacity 0.15s ease;
}

.player-seat.peek-cards .player-cards:hover .card-peek-face,
.player-seat.peek-cards .player-cards:focus-within .card-peek-face {
  opacity: 1;
}

.player-seat.peek-cards .player-cards:hover .card-peek-back,
.player-seat.peek-cards .player-cards:focus-within .card-peek-back {
  opacity: 0;
}

.player-info {
  background: var(--surface);
  border: 2px solid #30363d;
  border-radius: 8px;
  padding: 0.3rem 0.6rem;
  text-align: center;
  min-width: 90px;
  position: relative;
}

.player-name {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
}

.player-chips {
  display: block;
  font-size: 0.8rem;
  color: var(--gold);
}

.player-bet {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
}

.player-status {
  display: block;
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.player-status.allin {
  color: var(--red);
  font-weight: 600;
}

.card {
  width: 52px;
  height: 74px;
  background: var(--card-white);
  border-radius: 6px;
  border: 1px solid #ccc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  line-height: 1;
  gap: 2px;
}

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

.card-rank { font-size: 1rem; }
.card-suit { font-size: 1.2rem; }

.card-back {
  background: linear-gradient(135deg, #1e3a5f 25%, #2a5298 50%, #1e3a5f 75%);
  border: 2px solid #4a7ab5;
}

.card-back-pattern {
  width: 70%;
  height: 80%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.card-empty {
  background: transparent;
  border: 2px dashed rgba(255, 255, 255, 0.15);
  box-shadow: none;
}

.message-bar {
  grid-column: 1;
  text-align: center;
  padding: 0.5rem;
  font-size: 0.95rem;
  color: var(--gold);
  min-height: 2rem;
}

.controls {
  grid-column: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  padding: 0.5rem;
}

.controls.hidden { display: none; }

.action-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.raise-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  max-width: 520px;
}

.pot-presets {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem;
}

.btn-preset {
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  border: 1px solid #30363d;
  background: var(--surface);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.btn-preset:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.btn-preset.active {
  background: #3d2e1f;
  border-color: var(--gold);
  color: var(--gold);
}

.raise-adjust {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  width: 100%;
}

.raise-input-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.raise-input {
  width: 5.5rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
}

.raise-input:focus {
  outline: none;
  border-color: var(--gold);
}

.raise-hint {
  font-size: 0.78rem;
  color: var(--muted);
  min-height: 1rem;
}

#raise-slider {
  flex: 1;
  min-width: 100px;
  max-width: 180px;
  accent-color: var(--gold);
}

.btn {
  padding: 0.55rem 1.2rem;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
}

.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.hidden { display: none; }

.btn-fold { background: #3d1f1f; color: #f85149; border: 1px solid #f8514966; }
.btn-check { background: #1f2d3d; color: #58a6ff; border: 1px solid #58a6ff66; }
.btn-call { background: #1f3d2a; color: #3fb950; border: 1px solid #3fb95066; }
.btn-raise { background: #3d2e1f; color: var(--gold); border: 1px solid var(--gold); }
.btn-allin { background: #3d1f2a; color: #f778ba; border: 1px solid #f778ba66; }
.btn-deal {
  grid-column: 1;
  justify-self: center;
  background: var(--gold);
  color: var(--black);
  font-size: 1rem;
  padding: 0.7rem 2rem;
}

.btn-deal.hidden { display: none; }

.btn-replay {
  background: var(--surface);
  color: var(--gold);
  border: 1px solid var(--gold);
  font-size: 0.95rem;
  padding: 0.7rem 1.25rem;
}

.btn-replay:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-reset-solo {
  background: transparent;
  color: #f85149;
  border: 1px solid #f8514966;
  font-size: 0.9rem;
  padding: 0.65rem 1.1rem;
}

.btn-reset-solo.hidden { display: none; }

.message-bar {
  grid-column: 1;
  justify-self: center;
  text-align: center;
  font-size: 0.95rem;
  color: var(--gold);
  min-height: 1.4rem;
  order: 5;
}

.online-toolbar {
  grid-column: 1;
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  order: 6;
}

.online-toolbar.hidden { display: none; }

.btn-table-details {
  background: #1f2d3d;
  color: #58a6ff;
  border: 1px solid #58a6ff66;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
}

.btn-table-details:hover {
  border-color: #58a6ff;
}

.btn-rebuy {
  background: #1f3d2a;
  color: var(--gold);
  border: 1px solid var(--gold);
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
}

.btn-rebuy:hover:not(:disabled) {
  background: #264a34;
}

.btn-rebuy.hidden { display: none; }

.btn-rebuy:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.max-rebuys-wrap.hidden { display: none; }

.table-details-panel {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  order: 7;
  max-width: 520px;
  justify-self: center;
  width: 100%;
}

.table-details-panel.hidden { display: none; }

.table-details-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.table-details-header h2 {
  font-size: 1rem;
  color: var(--gold);
  margin: 0;
}

.btn-close-details {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
}

.btn-close-details:hover { color: var(--text); }

.setup-bar {
  grid-column: 1;
  justify-self: center;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  order: 11;
}

.setup-bar.hidden { display: none; }

.setup-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.setup-select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font-family: inherit;
  font-size: 0.9rem;
}

.setup-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.bot-stepper {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-stepper {
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  border: 1px solid #30363d;
  background: var(--surface);
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
}

.btn-stepper:hover:not(:disabled) {
  border-color: var(--gold);
  color: var(--gold);
}

.btn-stepper:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.bot-count {
  min-width: 1.5rem;
  text-align: center;
  font-weight: 600;
}

.setup-hint {
  font-size: 0.8rem;
  color: var(--muted);
}

.setup-option {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.setup-option input { accent-color: var(--gold); }

.multiplayer-panel {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  order: 10;
}

.multiplayer-panel.hidden { display: none; }

.multiplayer-title {
  font-size: 1rem;
  color: var(--gold);
  margin: 0 0 1rem;
}

.public-rooms-sub,
.private-room-sub {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

.public-player-name {
  max-width: 16rem;
  margin-bottom: 0.75rem;
}

.public-rooms-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.65rem;
}

.public-room-card {
  background: var(--bg);
  border: 1px solid #30363d;
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.public-room-card.is-full {
  opacity: 0.72;
}

.public-room-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.public-room-name {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--gold);
}

.public-room-count {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

.public-room-meta {
  font-size: 0.75rem;
  color: var(--muted);
}

.public-room-status {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: capitalize;
}

.public-room-status.in-hand {
  color: #f0a04b;
}

.btn-join-public {
  margin-top: 0.15rem;
  width: 100%;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  border: none;
  background: var(--gold);
  color: var(--black);
  font-weight: 600;
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.btn-join-public:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.multiplayer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.multiplayer-header h2 {
  font-size: 1rem;
  color: var(--gold);
}

.lobby-entry {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.lobby-input {
  background: var(--bg);
  border: 1px solid #30363d;
  border-radius: 8px;
  color: var(--text);
  padding: 0.5rem 0.75rem;
  font-family: inherit;
  min-width: 140px;
}

.lobby-code-input {
  min-width: 100px;
  max-width: 120px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.btn-multiplayer {
  background: var(--gold);
  color: var(--black);
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn-multiplayer-outline {
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn-open-tables,
.btn-private-room {
  font-size: 0.95rem;
  padding: 0.7rem 1rem;
}

.btn-open-tables {
  background: #1f2d3d;
  color: var(--gold);
  border: 1px solid #d4a84366;
}

.btn-private-room {
  background: #1f2d3d;
  color: #58a6ff;
  border: 1px solid #58a6ff66;
}

.btn-open-tables.active,
.btn-private-room.active {
  box-shadow: inset 0 0 0 1px currentColor;
}

.btn-open-tables.hidden,
.btn-private-room.hidden {
  display: none;
}

.btn-leave {
  background: transparent;
  color: var(--muted);
  border: 1px solid #30363d;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
}

.btn-leave.hidden { display: none; }

.lobby-active.hidden { display: none; }

.lobby-hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.lobby-table-settings {
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.lobby-code {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.invite-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.invite-link {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid #30363d;
  border-radius: 8px;
  color: var(--text);
  padding: 0.45rem 0.6rem;
  font-family: inherit;
  font-size: 16px;
  -webkit-user-select: all;
  user-select: all;
}

.btn-copy,
.btn-share {
  background: var(--surface);
  color: var(--gold);
  border: 1px solid var(--gold);
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-share.hidden { display: none; }

.lobby-players {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.lobby-player {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg);
  border-radius: 8px;
  padding: 0.4rem 0.65rem;
  font-size: 0.85rem;
}

.lobby-player-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.btn-make-host {
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 6px;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn-make-host:hover:not(:disabled) {
  background: rgba(212, 168, 83, 0.12);
}

.btn-make-host:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-kick-player {
  background: transparent;
  color: #e57373;
  border: 1px solid #e57373;
  border-radius: 6px;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn-kick-player:hover:not(:disabled) {
  background: rgba(229, 115, 115, 0.12);
}

.btn-kick-player:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.lobby-seat {
  color: var(--muted);
  font-size: 0.8rem;
}

.join-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}

.join-modal.hidden { display: none; }

.join-modal-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--gold);
  border-radius: 14px;
  padding: 1.5rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.join-modal-card h2 {
  font-size: 1.25rem;
  color: var(--gold);
  margin-bottom: 0.35rem;
}

.join-modal-sub {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.join-modal-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin: -0.35rem 0 0.75rem;
  line-height: 1.35;
}

.join-modal-hint.hidden {
  display: none;
}

.join-modal-room {
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.join-modal-label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.join-modal-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid #30363d;
  border-radius: 8px;
  color: var(--text);
  padding: 0.6rem 0.75rem;
  font-family: inherit;
  font-size: 1rem;
  margin-bottom: 0.75rem;
}

.join-modal-input:focus {
  outline: none;
  border-color: var(--gold);
}

.join-modal-code {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

.join-modal-input[readonly] {
  opacity: 0.85;
  cursor: default;
}

.join-modal-error {
  color: #f85149;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.join-modal-error.hidden { display: none; }

.join-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.btn-join-modal {
  background: var(--gold);
  color: var(--black);
  border: none;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  font-family: inherit;
}

.btn-join-modal:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-join-modal-cancel {
  background: transparent;
  color: var(--muted);
  border: 1px solid #30363d;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
}

body.modal-open { overflow: hidden; }

body.invite-join-pending .setup-bar,
body.invite-join-pending .multiplayer-panel {
  display: none;
}

.skip-bar {
  grid-column: 1;
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.skip-bar.hidden { display: none; }

.skip-auto {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
}

.skip-auto input { accent-color: var(--gold); }

.btn-skip {
  background: #1f2d3d;
  color: #58a6ff;
  border: 1px solid #58a6ff66;
}

.btn-skip:disabled { opacity: 0.5; }

.sidebar {
  grid-column: 2;
  grid-row: 2 / 5;
  background: var(--surface);
  border: 1px solid #30363d;
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar h2 {
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
}

.log {
  flex: 1;
  overflow-y: auto;
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--muted);
}

.log-entry {
  padding: 0.15rem 0;
  border-bottom: 1px solid #21262d;
}

@media (max-width: 768px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto auto;
  }

  .sidebar {
    grid-column: 1;
    grid-row: auto;
    max-height: 160px;
  }
}

/* Portrait phones: tighter table so side seats stay on screen */
@media (orientation: portrait) and (max-width: 900px) {
  .app {
    padding: 0.5rem;
    gap: 0.5rem;
  }

  header h1 {
    font-size: 1.15rem;
  }

  .table-area {
    padding: 0 0.1rem;
    align-items: flex-start;
    overflow: visible;
  }

  .table {
    max-width: min(94vw, 360px);
    aspect-ratio: 4 / 5;
    margin: 0 auto;
  }

  .table-felt {
    inset: 10% 10%;
    gap: 0.35rem;
    border-width: 4px;
  }

  .pot {
    font-size: 0.85rem;
    min-height: 1.1rem;
  }

  .community {
    gap: 0.15rem;
    transform: scale(0.88);
    transform-origin: center;
  }

  .card,
  .card-slot {
    width: 32px;
    height: 46px;
  }

  .card-rank { font-size: 0.62rem; }
  .card-suit { font-size: 0.72rem; }

  .card-back {
    border-width: 1px;
  }

  .player-seat {
    gap: 0.15rem;
  }

  .player-cards {
    gap: 0.12rem;
  }

  .player-info {
    min-width: 62px;
    max-width: 88px;
    padding: 0.18rem 0.35rem;
    border-radius: 6px;
    border-width: 1px;
  }

  .player-name {
    font-size: 0.68rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 80px;
  }

  .player-chips {
    font-size: 0.62rem;
  }

  .player-bet,
  .player-status {
    font-size: 0.55rem;
  }

  .dealer-button {
    width: 15px;
    height: 15px;
    font-size: 0.5rem;
    top: -5px;
    right: -5px;
  }

  .message-bar {
    font-size: 0.85rem;
    min-height: 1.2rem;
    padding: 0.35rem;
  }

  .setup-bar {
    gap: 0.4rem;
    justify-content: center;
  }

  .setup-label {
    font-size: 0.75rem;
  }

  .setup-select,
  .btn-stepper {
    font-size: 0.8rem;
  }

  .btn-deal,
  .btn-open-tables,
  .btn-private-room {
    font-size: 0.85rem;
    padding: 0.55rem 0.75rem;
  }

  .controls {
    padding: 0.25rem;
    gap: 0.45rem;
  }

  .action-row {
    gap: 0.35rem;
  }

  .action-row .btn {
    font-size: 0.8rem;
    padding: 0.5rem 0.65rem;
  }

  .raise-panel {
    width: 100%;
    max-width: 100%;
  }

  .online-toolbar {
    flex-wrap: wrap;
    justify-content: center;
  }

  .table-details-panel {
    max-width: 100%;
    padding: 0.75rem 1rem;
  }
}

/* Very narrow portrait */
@media (orientation: portrait) and (max-width: 380px) {
  .table {
    max-width: 96vw;
    aspect-ratio: 3 / 4;
  }

  .card,
  .card-slot {
    width: 28px;
    height: 40px;
  }

  .card-rank { font-size: 0.55rem; }
  .card-suit { font-size: 0.65rem; }

  .player-info {
    min-width: 54px;
    max-width: 72px;
  }

  .player-name {
    font-size: 0.62rem;
    max-width: 66px;
  }
}

.account-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.account-bar.hidden {
  display: none;
}

.account-user {
  font-size: 0.85rem;
  color: var(--muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  cursor: pointer;
}

.account-user:hover {
  color: var(--gold);
  text-decoration: underline;
}

.btn-account,
.btn-account-outline {
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  font-family: inherit;
  cursor: pointer;
}

.btn-account {
  background: var(--gold);
  color: var(--black);
  border: none;
  font-weight: 600;
}

.btn-account-outline {
  background: transparent;
  color: var(--muted);
  border: 1px solid #30363d;
}

.btn-account:hover,
.btn-account-outline:hover {
  filter: brightness(1.08);
}

.display-mode:not(.hidden) {
  margin-left: 0;
}

.auth-modal-card {
  max-width: 380px;
}

.auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.auth-tab {
  flex: 1;
  padding: 0.45rem;
  border-radius: 8px;
  border: 1px solid #30363d;
  background: var(--bg);
  color: var(--muted);
  font-family: inherit;
  cursor: pointer;
  font-size: 0.85rem;
}

.auth-tab.active {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(212, 168, 83, 0.08);
}

.auth-forgot-wrap {
  margin: -0.15rem 0 0.65rem;
  text-align: right;
}

.auth-reset-unavailable {
  display: block;
  text-align: left;
  margin: 0;
}

.auth-forgot-wrap.hidden {
  display: none;
}

.btn-auth-link {
  color: var(--gold);
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: underline;
}

.btn-auth-link:hover {
  filter: brightness(1.1);
}

.join-modal-success {
  color: #3fb950;
  font-size: 0.85rem;
  margin: 0 0 0.75rem;
}

.join-modal-success.hidden {
  display: none;
}

.stats-panel {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #30363d;
}

.stats-panel.hidden {
  display: none;
}

.stats-panel h2 {
  font-size: 0.95rem;
  margin-bottom: 0.65rem;
  color: var(--gold);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 0.75rem;
}

.stats-grid div {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.stats-grid dt {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stats-grid dd {
  font-size: 0.9rem;
  font-weight: 600;
}

#stat-profit.positive { color: #3fb950; }
#stat-profit.negative { color: #f85149; }
