:root {
  --bg: #10151c;
  --panel: #1a222d;
  --line: #2a3542;
  --text: #e8edf2;
  --muted: #8a99a8;
  --felt: #17603f;
  --felt-edge: #0d3d27;
  --rail: #4a2f1c;
  --gold: #f2c14e;
  --red: #d64545;
  --blue: #3d8bfd;
  --card: #fdfdfb;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  min-height: 100vh;
}

header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
header h1 { font-size: 20px; margin: 0; }
header .meta { color: var(--muted); font-size: 14px; flex: 1; }

main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 16px;
}

/* ---------- table ---------- */
.table {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  min-height: 380px;
}
.felt {
  position: absolute;
  inset: 12% 8%;
  border-radius: 999px;
  background: radial-gradient(ellipse at center, #1f7a52 0%, var(--felt) 55%, var(--felt-edge) 100%);
  border: 14px solid var(--rail);
  box-shadow: inset 0 0 40px rgba(0,0,0,.5), 0 10px 30px rgba(0,0,0,.4);
  display: grid;
  place-items: center;
}
.center { text-align: center; display: grid; gap: 8px; justify-items: center; }
.pot {
  background: rgba(0,0,0,.35);
  padding: 4px 14px;
  border-radius: 999px;
  font-weight: 600;
  color: var(--gold);
}
.board { display: flex; gap: 6px; min-height: 74px; }
.message { min-height: 22px; font-size: 14px; color: #fff; text-shadow: 0 1px 2px #000; max-width: 360px; }

.seat {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 150px;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  text-align: center;
  transition: border-color .2s, opacity .2s, box-shadow .2s;
}
.seat.active { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(242,193,78,.25); }
.seat.folded { opacity: .45; }
.seat.out { opacity: .25; }
.seat.winner { border-color: #4ade80; box-shadow: 0 0 0 3px rgba(74,222,128,.3); }
.seat .name { font-weight: 600; font-size: 14px; display: flex; justify-content: center; gap: 6px; align-items: center; }
.seat .chips { color: var(--gold); font-size: 13px; }
.seat .hand { display: flex; justify-content: center; gap: 4px; margin: 6px 0 2px; min-height: 58px; }
.seat .action { font-size: 12px; color: var(--muted); min-height: 16px; }
.seat .bet {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.6);
  color: var(--gold);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.seat[data-pos="bottom"] .bet { top: -26px; }
.seat[data-pos="top"] .bet { bottom: -26px; }
.seat[data-pos="left"] .bet, .seat[data-pos="right"] .bet { bottom: -26px; }
.dealer {
  display: inline-grid; place-items: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; color: #000; font-size: 11px; font-weight: 700;
}

/* ---------- cards ---------- */
.card {
  width: 50px; height: 70px;
  border-radius: 6px;
  background: var(--card);
  color: #111;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 700; line-height: 1;
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
  animation: deal .25s ease-out;
}
.card .r { font-size: 20px; }
.card .s { font-size: 22px; }
.card.red { color: var(--red); }
.card.back {
  background: repeating-linear-gradient(45deg, #2b4c8c 0 6px, #335aa3 6px 12px);
  border: 3px solid #fff;
}
.seat .card { width: 40px; height: 56px; }
.seat .card .r { font-size: 16px; }
.seat .card .s { font-size: 17px; }
.card.hl { outline: 3px solid #4ade80; }
@keyframes deal { from { transform: translateY(-10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- controls ---------- */
.controls {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 10px;
}
.controls .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.controls .raise input[type=range] { flex: 1; min-width: 120px; accent-color: var(--gold); }
.controls .raise input[type=number] {
  width: 90px; padding: 8px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 15px;
}

button {
  font: inherit;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #2a3542;
  color: var(--text);
  cursor: pointer;
}
button:hover:not(:disabled) { filter: brightness(1.15); }
button:disabled { opacity: .4; cursor: not-allowed; }
button.primary { background: var(--blue); border-color: var(--blue); }
button.danger { background: #7a2a2a; border-color: #7a2a2a; }
button.warn { background: #8a5a12; border-color: #8a5a12; }
button.ghost { background: transparent; }
button.small { padding: 6px 10px; font-size: 13px; }
button.wide { flex: 1; }
.hidden { display: none !important; }

/* ---------- log ---------- */
.log { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.log h2 { font-size: 15px; margin: 0 0 8px; color: var(--muted); }
.log ol { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; font-size: 13px; display: grid; gap: 3px; }
.log li.hand { color: var(--gold); margin-top: 6px; }
.log li.win { color: #4ade80; }

@media (max-width: 640px) {
  header h1 { font-size: 17px; }
  .table { aspect-ratio: auto; height: 470px; }
  .felt { inset: 18% 4%; border-width: 8px; }
  .seat { width: 108px; padding: 6px; }
  .seat .card { width: 30px; height: 42px; }
  .seat .card .r { font-size: 12px; }
  .seat .card .s { font-size: 13px; }
  .seat .hand { min-height: 44px; }
  .card { width: 38px; height: 54px; }
  .card .r { font-size: 15px; }
  .card .s { font-size: 16px; }
  .board { min-height: 56px; gap: 4px; }
}
