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

:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-border: #2d333b;
  --text: #e6edf3;
  --muted: #8b949e;
  --felt: radial-gradient(ellipse at center, #1a6b3c 0%, #114a29 65%, #0c3a20 100%);
  --felt-border: #3d2b1f;
  --accent: #2ea043;
  --red: #e5534b;
  --gold: #d4a017;
  --card-red: #d64545;
  --card-black: #1b1f24;
}

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ---------- topbar ---------- */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--panel-border);
  z-index: 20;
}

.brand {
  font-weight: 700;
  font-size: 16px;
}

.table-info {
  color: var(--muted);
  font-size: 13px;
}

.topbar-right {
  display: flex;
  gap: 8px;
}

/* ---------- table ---------- */
#table-wrap {
  flex: 1;
  position: relative;
  min-height: 0;
}

#table {
  position: absolute;
  inset: 0;
  margin: 8px auto;
  max-width: 980px;
  width: 100%;
}

#felt {
  position: absolute;
  left: 12%;
  top: 14%;
  width: 76%;
  height: 68%;
  background: var(--felt);
  border-radius: 50% / 46%;
  border: 10px solid var(--felt-border);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, .45), 0 8px 30px rgba(0, 0, 0, .5);
}

#board {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.pot {
  background: rgba(0, 0, 0, .45);
  padding: 4px 14px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--gold);
}

.board-cards {
  display: flex;
  gap: 6px;
  min-height: 64px;
}

.table-message {
  color: rgba(230, 237, 243, .75);
  font-size: 14px;
  text-align: center;
  max-width: 70%;
}

/* ---------- cards ---------- */
.card {
  width: 44px;
  height: 62px;
  border-radius: 6px;
  background: #f5f2ea;
  color: var(--card-black);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
  line-height: 1;
  user-select: none;
}

.card .rank {
  font-size: 18px;
}

.card .suit {
  font-size: 16px;
}

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

.card.back {
  background: repeating-linear-gradient(45deg, #2b4a80, #2b4a80 4px, #203a66 4px, #203a66 8px);
  border: 2px solid #d9d9d9;
}

.card.small {
  width: 34px;
  height: 48px;
}

.card.small .rank {
  font-size: 14px;
}

.card.small .suit {
  font-size: 12px;
}

.card.win-combo {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

/* ---------- seats ---------- */
.seat {
  position: absolute;
  width: 150px;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  z-index: 5;
}

.seat .cards {
  display: flex;
  gap: 4px;
  min-height: 50px;
}

.seat .plate {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 6px 12px;
  text-align: center;
  min-width: 120px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .4);
}

.seat.turn .plate {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(46, 160, 67, .55);
}

.seat.folded {
  opacity: .45;
}

.seat.hero .plate {
  border-color: #58a6ff;
}

.seat .name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.seat .stack {
  font-size: 12px;
  color: var(--gold);
}

.seat .badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--gold);
  color: #222;
  font-size: 10px;
  font-weight: 700;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.seat .badge.sb {
  background: #58a6ff;
  right: 16px;
}

.seat .badge.bb {
  background: #bc8cff;
  right: 16px;
}

.seat .bet-chip {
  background: rgba(0, 0, 0, .55);
  border: 1px solid var(--gold);
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 12px;
}

.seat .combo {
  font-size: 11px;
  color: #8ddb9d;
}

.seat .win-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
}

.seat .timer {
  height: 4px;
  width: 100%;
  background: rgba(255, 255, 255, .12);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 4px;
}

.seat .timer .fill {
  height: 100%;
  background: var(--accent);
  transition: width 1s linear;
}

.seat .timer .fill.low {
  background: var(--red);
}

.seat.empty .plate {
  background: rgba(22, 27, 34, .5);
  border-style: dashed;
  color: var(--muted);
  cursor: default;
}

.seat .allin-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--red);
}

/* ---------- actions ---------- */
.actions {
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 20;
}

.action-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid var(--panel-border);
  background: #21262d;
  color: var(--text);
  border-radius: 8px;
  padding: 10px 22px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s;
}

.btn:hover {
  filter: brightness(1.2);
}

.btn:disabled {
  opacity: .4;
  cursor: default;
}

.btn.fold {
  background: #6e2b28;
}

.btn.check, .btn.call {
  background: #1f5130;
}

.btn.raise {
  background: #7a5a12;
}

.btn.allin {
  background: #6e2b6a;
}

.btn.start {
  background: var(--accent);
}

.btn.ghost {
  background: transparent;
}

.btn.small {
  padding: 6px 12px;
  font-size: 13px;
}

.raise-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 420px;
  margin: 0 auto;
  width: 100%;
}

.raise-row {
  display: flex;
  gap: 8px;
}

.raise-row input[type="number"] {
  flex: 1;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--gold);
}

input, select {
  background: #0d1117;
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
}

/* ---------- side panels ---------- */
.panel {
  position: absolute;
  top: 54px;
  right: 10px;
  width: 320px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 14px;
  z-index: 30;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}

.panel h3 {
  font-size: 14px;
  margin-bottom: 10px;
}

.panel h4 {
  font-size: 12px;
  color: var(--muted);
  margin: 8px 0 6px;
}

.panel label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.dev-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.dev-row input {
  width: 0;
  flex: 1;
  min-width: 40px;
}

.dev-block {
  border-top: 1px solid var(--panel-border);
  padding-top: 8px;
  margin-top: 8px;
}

.dev-players {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dev-players .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  gap: 6px;
}

.muted {
  color: var(--muted);
}

.small-text {
  font-size: 11px;
  margin-bottom: 8px;
}

.fair-content {
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  word-break: break-all;
}

.fair-content .kv b {
  display: block;
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
}

.fair-content code {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  color: #79c0ff;
}

.fair-ok {
  color: #56d364;
  font-weight: 700;
}

.fair-fail {
  color: var(--red);
  font-weight: 700;
}

.hidden {
  display: none !important;
}

/* ---------- mobile ---------- */
@media (max-width: 720px) {
  .seat {
    width: 104px;
  }

  .seat .plate {
    min-width: 86px;
    max-width: 104px;
    padding: 4px 8px;
  }

  .seat .name {
    font-size: 12px;
    max-width: 96px;
  }

  .card {
    width: 34px;
    height: 48px;
  }

  .card .rank {
    font-size: 14px;
  }

  .card .suit {
    font-size: 12px;
  }

  .card.small {
    width: 26px;
    height: 38px;
  }

  .panel {
    width: calc(100vw - 20px);
  }

  #felt {
    left: 8%;
    top: 15%;
    width: 84%;
    height: 66%;
    border-width: 7px;
    border-radius: 46% / 42%;
  }

  .btn {
    padding: 10px 16px;
    font-size: 14px;
  }

  .brand {
    display: none;
  }
}
