:root {
  --felt: #0f5c3a;
  --felt-deep: #0a3d28;
  --rail: #3a2416;
  --rail-light: #6b4428;
  --ink: #f3efe6;
  --muted: #b7c4b8;
  --gold: #e2b85c;
  --gold-deep: #b8872e;
  --danger: #e05a4f;
  --ok: #5ecf8e;
  --panel: #121814;
  --chip: #1a2420;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font: "Instrument Sans", system-ui, sans-serif;
  --display: "Syne", "Instrument Sans", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 50% -10%, #1c3328 0%, transparent 60%),
    linear-gradient(160deg, #0b100e 0%, #151c18 45%, #0d1210 100%);
  color: var(--ink);
  font-family: var(--font);
}

button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

#app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 16px 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background:
    linear-gradient(135deg, var(--gold) 0%, var(--gold-deep) 100%);
  box-shadow: 0 0 0 3px rgba(226, 184, 92, 0.18);
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 2px solid rgba(20, 18, 12, 0.55);
  border-radius: 50%;
}

.brand h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.35rem;
  letter-spacing: 0.04em;
  line-height: 1.1;
}
.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.admin-link {
  color: var(--gold);
  text-decoration: none;
  font-size: 0.85rem;
  border: 1px solid rgba(226,184,92,0.35);
  padding: 8px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.top-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.stat {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 8px 12px;
  min-width: 88px;
}
.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.stat strong {
  font-size: 1rem;
  color: var(--gold);
}

.stage {
  display: grid;
  grid-template-columns: 1.55fr 0.9fr;
  gap: 16px;
  align-items: stretch;
}

.table-wrap {
  min-height: 560px;
}

.table {
  position: relative;
  height: 100%;
  min-height: 560px;
  border-radius: 48% / 42%;
  background:
    radial-gradient(ellipse at center, #147a4c 0%, var(--felt) 48%, var(--felt-deep) 100%);
  box-shadow:
    inset 0 0 0 14px var(--rail),
    inset 0 0 0 18px var(--rail-light),
    var(--shadow);
  overflow: hidden;
}

.felt-glow {
  position: absolute;
  inset: 18%;
  background: radial-gradient(circle, rgba(255,255,255,0.08), transparent 65%);
  pointer-events: none;
  animation: breathe 5s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 0.45; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.04); }
}

.seats {
  position: absolute;
  inset: 0;
}

.seat {
  position: absolute;
  width: 150px;
  transform: translate(-50%, -50%);
  text-align: center;
  transition: filter 0.2s ease, transform 0.25s ease;
}
.seat.active {
  filter: drop-shadow(0 0 12px rgba(226, 184, 92, 0.55));
  z-index: 3;
}
.seat.folded { opacity: 0.42; }
.seat.busted { opacity: 0.25; }
.seat.winner .avatar {
  box-shadow: 0 0 0 3px var(--gold), 0 8px 24px rgba(0,0,0,0.35);
}

.seat[data-pos="0"] { left: 50%; top: 86%; }
.seat[data-pos="1"] { left: 12%; top: 62%; }
.seat[data-pos="2"] { left: 18%; top: 24%; }
.seat[data-pos="3"] { left: 82%; top: 24%; }
.seat[data-pos="4"] { left: 88%; top: 62%; }

.avatar {
  width: 54px;
  height: 54px;
  margin: 0 auto 6px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.05rem;
  color: #1a140c;
  background: linear-gradient(145deg, #f0d38a, #c8963a);
  box-shadow: 0 8px 18px rgba(0,0,0,0.3);
}
.seat.you .avatar {
  background: linear-gradient(145deg, #8fd4ff, #3f8fd8);
  color: #07121c;
}
.seat-name {
  font-weight: 600;
  font-size: 0.92rem;
}
.seat-meta {
  font-size: 0.78rem;
  color: var(--muted);
}
.seat-chips {
  margin-top: 2px;
  color: var(--gold);
  font-weight: 700;
  font-size: 0.9rem;
}
.seat-bet {
  min-height: 1.1em;
  margin-top: 4px;
  font-size: 0.78rem;
  color: #d7ffe8;
}
.dealer-chip {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #111;
  color: var(--gold);
  font-size: 0.65rem;
  font-weight: 700;
  vertical-align: middle;
}

.hole {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-top: 6px;
  min-height: 62px;
}

.card {
  width: 44px;
  height: 62px;
  border-radius: 7px;
  background: #f7f4ec;
  color: #1a1a1a;
  border: 1px solid rgba(0,0,0,0.12);
  box-shadow: 0 6px 14px rgba(0,0,0,0.28);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 4px 5px;
  font-weight: 700;
  font-size: 0.78rem;
  line-height: 1;
  animation: dealIn 0.35s ease both;
}
.card .suit { font-size: 1rem; align-self: flex-end; }
.card.red { color: #c62828; }
.card.black { color: #1b1b1b; }
.card.back {
  background:
    repeating-linear-gradient(45deg, #1e3a5f 0 6px, #254a78 6px 12px);
  border-color: #0d2138;
  color: transparent;
}
.card.back .suit,
.card.back .rank { display: none; }

@keyframes dealIn {
  from { opacity: 0; transform: translateY(-18px) scale(0.9); }
  to { opacity: 1; transform: none; }
}

.board-area {
  position: absolute;
  left: 50%;
  top: 48%;
  transform: translate(-50%, -50%);
  width: min(420px, 78%);
  text-align: center;
  z-index: 2;
}

.pot-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(226,184,92,0.35);
  margin-bottom: 10px;
  animation: potPulse 2.4s ease-in-out infinite;
}
.pot-badge span { color: var(--muted); font-size: 0.78rem; }
.pot-badge strong { color: var(--gold); font-size: 1.05rem; }

@keyframes potPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

.board {
  display: flex;
  justify-content: center;
  gap: 8px;
  min-height: 72px;
}
.board .card {
  width: 52px;
  height: 74px;
  font-size: 0.9rem;
}

.street-label {
  margin: 10px 0 0;
  color: #d7ffe8;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.panel {
  position: relative;
  background: linear-gradient(180deg, #18201c 0%, var(--panel) 100%);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 20px;
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 560px;
}

.log-box {
  flex: 1;
  min-height: 180px;
  display: flex;
  flex-direction: column;
}
.log-box h2 {
  margin: 0 0 8px;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
#actionLog {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  max-height: 240px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#actionLog li {
  font-size: 0.86rem;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  border-left: 3px solid rgba(226,184,92,0.45);
  animation: fadeSlide 0.3s ease;
}
@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.controls { display: flex; flex-direction: column; gap: 10px; }
.raise-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}
#raiseSlider {
  width: 100%;
  accent-color: var(--gold);
}
.raise-meta {
  text-align: right;
  min-width: 84px;
}
.raise-meta span {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
}
.raise-meta strong {
  color: var(--gold);
  font-size: 1rem;
}

.btn-row, .preset-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.preset-row { grid-template-columns: repeat(3, 1fr); }

.btn, .preset-row button {
  border: 0;
  border-radius: 12px;
  padding: 12px 10px;
  font-weight: 700;
  color: #102018;
  transition: transform 0.12s ease, filter 0.12s ease, opacity 0.12s ease;
}
.btn:hover:not(:disabled),
.preset-row button:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.05);
}
.btn:disabled, .preset-row button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}
.btn.fold { background: #8f4a45; color: #fff; }
.btn.call { background: #4f8f72; color: #fff; }
.btn.raise { background: linear-gradient(135deg, var(--gold), var(--gold-deep)); }
.btn.allin { background: #2b2b2b; color: #fff; border: 1px solid rgba(255,255,255,0.15); }
.btn.primary {
  width: 100%;
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  padding: 14px;
  font-size: 1rem;
}
.preset-row button {
  background: rgba(255,255,255,0.08);
  color: var(--ink);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 8px;
  font-size: 0.82rem;
}

.start-box p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.overlay-card {
  position: absolute;
  inset: 16px;
  background: rgba(10, 16, 13, 0.94);
  border: 1px solid rgba(226,184,92,0.35);
  border-radius: 18px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  z-index: 5;
  animation: fadeSlide 0.28s ease;
}
.overlay-card h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.4rem;
  color: var(--gold);
}
.overlay-card p {
  margin: 0;
  color: var(--ink);
  line-height: 1.5;
  white-space: pre-line;
}

@media (max-width: 960px) {
  .stage { grid-template-columns: 1fr; }
  .table-wrap { min-height: 520px; }
  .table, .panel { min-height: 520px; }
  .seat { width: 118px; }
  .seat .card { width: 36px; height: 52px; font-size: 0.68rem; }
  .board .card { width: 44px; height: 62px; }
  .btn-row { grid-template-columns: repeat(2, 1fr); }
  .seat-meta { display: none; }
}

@media (max-width: 560px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .table-wrap { min-height: 560px; }
  .table {
    border-radius: 28px;
    min-height: 560px;
    overflow: visible;
  }
  .felt-glow { inset: 10%; }
  .seat[data-pos="0"] { left: 50%; top: 90%; }
  .seat[data-pos="1"] { left: 14%; top: 62%; }
  .seat[data-pos="2"] { left: 22%; top: 16%; }
  .seat[data-pos="3"] { left: 78%; top: 16%; }
  .seat[data-pos="4"] { left: 86%; top: 62%; }
  .avatar { width: 40px; height: 40px; font-size: 0.85rem; }
  .board-area { top: 46%; width: min(340px, 86%); }
  .hole { min-height: 52px; }
}
