:root {
  --bg: #0b0f14;
  --panel: #131a22;
  --panel-2: #1b242e;
  --line: #263241;
  --felt: #14663f;
  --felt-edge: #0c3b24;
  --text: #e8eef4;
  --muted: #93a4b5;
  --gold: #e7c15a;
  --accent: #2f9e6a;
  --red: #e5484d;
  --blue: #3b82f6;
  --chip: #f4d35e;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 800px at 50% -10%, #16202b 0%, var(--bg) 60%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow-x: hidden;
}
.hidden { display: none !important; }

/* ---- topbar ---- */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #10161d, #0d1218);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; letter-spacing: .5px; color: var(--gold); }
.top-right { display: flex; align-items: center; gap: 12px; }
.me-name { color: var(--text); font-weight: 600; cursor: pointer; border-bottom: 1px dashed var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red); box-shadow: 0 0 8px var(--red); }
.dot.on { background: var(--accent); box-shadow: 0 0 8px var(--accent); }

/* ---- buttons ---- */
.btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: 9px 16px; border-radius: 10px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: filter .12s, transform .05s;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: #2b8f60; color: #06120c; }
.btn-ghost { background: transparent; }
.btn-fold { background: #3a2226; border-color: #5a2a2f; color: #ffb4b6; }
.btn-call { background: #123a2a; border-color: #1f6647; color: #b6f0d1; }
.btn-raise { background: #3a3018; border-color: #6a5726; color: var(--gold); }

/* ---- modal ---- */
.modal { position: fixed; inset: 0; background: rgba(4,7,10,.82); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; width: min(92vw, 380px); text-align: center; }
.modal-card h2 { margin: 0 0 6px; color: var(--gold); }
.modal-card .sub { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.modal-card input { width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-size: 16px; margin-bottom: 14px; }
.modal-card .btn { width: 100%; }

/* ---- lobby ---- */
#lobby { max-width: 780px; margin: 0 auto; padding: 22px 16px 60px; }
.lobby-head { display: flex; align-items: center; justify-content: space-between; }
.lobby-head h1 { font-size: 22px; margin: 0; }
.table-list { margin-top: 16px; display: grid; gap: 12px; }
.table-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
}
.table-row .tr-main { display: flex; flex-direction: column; gap: 3px; }
.table-row .tr-name { font-weight: 700; }
.table-row .tr-sub { color: var(--muted); font-size: 13px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.badge.live { color: #7ef0b6; border-color: #1f6647; }
.create-form { margin-top: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.create-form h3 { margin: 0 0 12px; }
.create-form label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 5px; flex: 1; }
.create-form input { padding: 9px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-size: 14px; }
.create-form .row { display: flex; gap: 12px; margin-top: 12px; align-items: flex-end; }

/* ---- table view ---- */
#tableView { max-width: 1000px; margin: 0 auto; padding: 10px 12px 40px; }
.table-meta { display: flex; align-items: center; gap: 12px; padding: 4px 4px 10px; }
.t-name { font-weight: 700; }
.t-blinds { color: var(--muted); font-size: 13px; }
.table-meta .btn { margin-left: auto; padding: 6px 12px; font-size: 13px; }

#feltWrap { width: 100%; }
#felt {
  position: relative; width: 100%; aspect-ratio: 16/10; max-height: 62vh;
  margin: 0 auto;
  background:
    radial-gradient(120% 120% at 50% 40%, #1c8a56 0%, var(--felt) 45%, var(--felt-edge) 100%);
  border: 14px solid #201a12;
  border-radius: 44% / 46%;
  box-shadow: inset 0 0 60px rgba(0,0,0,.55), 0 18px 40px rgba(0,0,0,.5);
}
#board { position: absolute; top: 38%; left: 50%; transform: translate(-50%,-50%); display: flex; gap: 6px; }
#potBox { position: absolute; top: 55%; left: 50%; transform: translate(-50%,-50%); text-align: center; color: var(--gold); font-weight: 700; }
.pot-label { display: block; font-size: 10px; letter-spacing: 2px; color: #d9c98f; opacity: .8; }
#potAmt { font-size: 20px; }
#phaseTag { position: absolute; top: 66%; left: 50%; transform: translateX(-50%); font-size: 11px; letter-spacing: 2px; color: #cfe8db; text-transform: uppercase; opacity: .75; }

/* cards */
.card {
  width: var(--cw, 40px); height: calc(var(--cw, 40px) * 1.42);
  border-radius: 6px; background: #f7f7f2; color: #111; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 800; box-shadow: 0 2px 6px rgba(0,0,0,.4); line-height: 1;
}
.card .r { font-size: calc(var(--cw,40px) * .48); }
.card .s { font-size: calc(var(--cw,40px) * .42); }
.card.red { color: #d31d2b; }
.card.back {
  background: repeating-linear-gradient(45deg, #7b1c26, #7b1c26 5px, #5f141c 5px, #5f141c 10px);
  border: 2px solid #e7c15a44;
}
.card.back .r, .card.back .s { display: none; }
#board .card { --cw: 46px; }

/* seats */
.seat { position: absolute; width: 112px; transform: translate(-50%,-50%); text-align: center; }
.seat .pod {
  background: rgba(9,14,19,.86); border: 1px solid var(--line); border-radius: 12px;
  padding: 7px 8px 8px; position: relative;
}
.seat.acting .pod { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(231,193,90,.5), 0 0 18px rgba(231,193,90,.35); }
.seat.folded .pod { opacity: .45; }
.seat .pname { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat .pstack { font-size: 12px; color: var(--gold); }
.seat.me .pod { border-color: #2f9e6a; }
.seat .pcards { display: flex; gap: 3px; justify-content: center; margin-top: 4px; min-height: 40px; }
.seat .pcards .card { --cw: 28px; }
.seat .lastact { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); font-size: 10px; text-transform: uppercase; letter-spacing: 1px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; color: var(--muted); white-space: nowrap; }
.seat .lastact.fold { color: #ff9ea1; }
.seat .lastact.allin { color: var(--gold); border-color: #6a5726; }
.seat .bet { position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); font-size: 12px; color: var(--chip); font-weight: 700; white-space: nowrap; }
.seat .bet::before { content: "🪙 "; }
.badge-dealer, .badge-blind { position: absolute; width: 20px; height: 20px; border-radius: 50%; font-size: 10px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.badge-dealer { background: #f7f7f2; color: #111; top: -6px; right: -6px; border: 1px solid #999; }
.badge-blind { top: 16px; right: -8px; background: var(--blue); color: #fff; }
.seat .tag-out { font-size: 10px; color: var(--muted); }
.seat .disc { color: var(--red); font-size: 10px; }
.timer-ring { position: absolute; left: -4px; top: -4px; right: -4px; bottom: -4px; border-radius: 14px; pointer-events: none; }

/* empty seat */
.seat.empty .pod { background: rgba(9,14,19,.5); border-style: dashed; }
.seat.empty .sit-btn { background: var(--accent); color: #06120c; border: none; padding: 8px 12px; border-radius: 9px; font-weight: 700; cursor: pointer; width: 100%; }

/* winner glow */
.seat.winner .pod { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold), 0 0 24px rgba(231,193,90,.6); }

/* ---- action bar ---- */
#actionBar { position: sticky; bottom: 0; margin-top: 16px; background: linear-gradient(180deg, rgba(11,15,20,.2), var(--bg) 40%); padding-top: 10px; z-index: 15; }
.act-row { display: flex; gap: 10px; justify-content: center; }
.act-row .btn { flex: 1; max-width: 200px; padding: 14px; font-size: 15px; }
.raise-controls { max-width: 640px; margin: 12px auto 0; display: flex; flex-direction: column; gap: 10px; }
.presets { display: flex; gap: 8px; justify-content: center; }
.chip-btn { flex: 1; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); padding: 8px; border-radius: 8px; font-weight: 600; cursor: pointer; }
#raiseSlider { width: 100%; accent-color: var(--gold); }
.raise-confirm { display: flex; gap: 10px; }
.raise-confirm input { width: 120px; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-size: 16px; font-weight: 700; text-align: center; }
.raise-confirm .btn { flex: 1; }

.side-controls { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }

/* ---- lower panels ---- */
#lowerPanels { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
#logPanel, #chatPanel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
#logPanel h4, #chatPanel h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
#log, #chatMsgs { height: 140px; overflow-y: auto; font-size: 13px; display: flex; flex-direction: column; gap: 3px; }
#log div { color: var(--muted); }
#chatMsgs .cm b { color: var(--gold); }
#chatForm { display: flex; gap: 8px; margin-top: 8px; }
#chatForm input { flex: 1; padding: 9px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); }

/* ---- toast ---- */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line); color: var(--text); padding: 10px 18px; border-radius: 10px; z-index: 200; box-shadow: 0 6px 20px rgba(0,0,0,.4); }

/* ---- mobile ---- */
@media (max-width: 720px) {
  #felt { aspect-ratio: 3/4; max-height: 56vh; border-width: 10px; }
  #board .card { --cw: 34px; }
  .seat { width: 92px; }
  .seat .pcards .card { --cw: 22px; }
  .seat .pname { font-size: 11px; }
  #lowerPanels { grid-template-columns: 1fr; }
  .act-row .btn { padding: 16px 10px; }
  .create-form .row { flex-direction: column; align-items: stretch; }
}
