:root {
  --bg: #0f1412;
  --panel: #1a211e;
  --panel-2: #222b27;
  --line: #34413b;
  --text: #e8efe9;
  --muted: #9aaba2;
  --accent: #f2c14e;
  --danger: #e05a4f;
  --ok: #4fbf7a;
  --felt: #1f6b47;
  --felt-edge: #5a3a22;
  --card: #fbfbf7;
  --red: #c8312a;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); }
a { color: var(--accent); }
.hidden { display: none !important; }
button, input, select { font: inherit; }
button {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 14px; cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: var(--accent); color: #1b1b1b; border-color: var(--accent); font-weight: 600; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.small { padding: 4px 10px; font-size: 0.85rem; }
input[type=text], input[type=password], input[type=number], select, textarea {
  background: #0c100e; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px;
}
label { display: block; color: var(--muted); font-size: 0.9rem; margin: 10px 0 4px; }
.error { color: var(--danger); min-height: 1.2em; margin-top: 8px; }
.muted { color: var(--muted); }

/* ---------- dashboard ---------- */
.page { max-width: 760px; margin: 40px auto; padding: 0 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px 24px; margin-bottom: 18px; }
.card h1, .card h2 { margin-top: 0; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.row > div { flex: 1 1 140px; }
.link-box { display: flex; gap: 8px; }
.link-box input { flex: 1; }
table.levels { border-collapse: collapse; margin-top: 6px; }
table.levels td, table.levels th { padding: 3px 6px; text-align: left; }
table.levels input { width: 100px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }

/* ---------- game: overlays ---------- */
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(5, 8, 7, 0.85); z-index: 50; }
.overlay .card { width: min(440px, 92vw); }
.preview { width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 8px; object-fit: cover; transform: scaleX(-1); }
.standings { width: 100%; border-collapse: collapse; }
.standings td, .standings th { padding: 6px; border-bottom: 1px solid var(--line); text-align: right; }
.standings td:first-child, .standings th:first-child { text-align: left; }
.pos { color: var(--ok); }
.neg { color: var(--danger); }

/* ---------- game layout ---------- */
.game { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto 1fr auto; height: 100vh; }
.infobar { grid-column: 1 / -1; display: flex; gap: 18px; align-items: center; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); font-size: 0.95rem; }
.infobar .spacer { flex: 1; }
.infobar .warn { color: var(--accent); font-weight: 600; }
.stage { position: relative; overflow: hidden; }
.side { width: 290px; background: var(--panel); border-left: 1px solid var(--line); padding: 12px; overflow-y: auto; grid-row: 2 / 4; grid-column: 2; }
.side.collapsed { display: none; }
.side h3 { margin: 14px 0 6px; font-size: 0.95rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.side .item { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.side .item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side textarea { width: 100%; min-height: 70px; }

/* ---------- the table ---------- */
.table-wrap { position: absolute; inset: 20px 30px 10px; }
.felt {
  position: absolute; left: 12%; right: 12%; top: 16%; bottom: 16%;
  border-radius: 50% / 50%;
  background: radial-gradient(ellipse at center, #2a8a5c 0%, var(--felt) 60%, #154d33 100%);
  border: 14px solid var(--felt-edge);
  box-shadow: 0 0 0 3px #2b1b10, inset 0 0 40px rgba(0, 0, 0, 0.45), 0 20px 50px rgba(0, 0, 0, 0.5);
}
.center { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center; }
.board { display: flex; gap: 6px; justify-content: center; min-height: 64px; }
.pot { margin-top: 8px; font-weight: 600; font-size: 1.05rem; text-shadow: 0 1px 2px #000; }
.message { margin-top: 6px; color: var(--accent); font-weight: 600; text-shadow: 0 1px 2px #000; max-width: 360px; }

.seat {
  position: absolute; width: 150px; transform: translate(-50%, -50%);
  background: rgba(16, 21, 19, 0.92); border: 2px solid var(--line); border-radius: 12px; padding: 5px;
  transition: border-color 0.2s, box-shadow 0.2s, opacity 0.2s;
}
.seat.turn { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(242, 193, 78, 0.35), 0 0 22px rgba(242, 193, 78, 0.45); }
.seat.folded, .seat.out { opacity: 0.55; }
.seat.empty { background: transparent; border: 2px dashed rgba(255, 255, 255, 0.12); height: 60px; }
.seat.you { border-color: #6fa8dc; }
.seat.you.turn { border-color: var(--accent); }
.seat .video { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #0a0d0c; border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 1.6rem; font-weight: 700; }
.seat .video video { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.seat .video video.mirror { transform: scaleX(-1); }
.seat .quality { position: absolute; top: 4px; right: 4px; width: 9px; height: 9px; border-radius: 50%; background: #666; z-index: 2; }
.seat .quality.excellent { background: var(--ok); }
.seat .quality.good { background: #b8d34b; }
.seat .quality.poor { background: var(--danger); }
.seat .muted-mic { position: absolute; bottom: 4px; left: 4px; font-size: 0.7rem; background: rgba(0,0,0,0.6); padding: 1px 4px; border-radius: 4px; z-index: 2; }
.seat .vol { position: absolute; bottom: 4px; right: 4px; width: 60%; z-index: 2; opacity: 0; transition: opacity 0.2s; }
.seat:hover .vol, .seat .vol:focus { opacity: 1; }
.seat .meta { display: flex; justify-content: space-between; gap: 4px; margin-top: 4px; font-size: 0.85rem; }
.seat .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat .stk { color: var(--accent); font-variant-numeric: tabular-nums; }
.seat .act { font-size: 0.78rem; color: var(--muted); min-height: 1em; text-transform: capitalize; }
.seat .cards { position: absolute; top: -18px; right: -10px; display: flex; gap: 2px; z-index: 3; }
.seat .cards .cardface { width: 30px; height: 42px; font-size: 0.85rem; }
.seat .timer { height: 4px; background: var(--accent); border-radius: 2px; margin-top: 4px; width: 0; }
.seat .dealer {
  position: absolute; left: -12px; top: -12px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; color: #111; font-weight: 800; font-size: 0.8rem; display: flex; align-items: center; justify-content: center; z-index: 3;
  box-shadow: 0 1px 4px #000;
}
.seat .tag { font-size: 0.7rem; color: var(--muted); }
.bet {
  position: absolute; transform: translate(-50%, -50%); background: rgba(0, 0, 0, 0.55); border: 1px solid var(--accent);
  color: var(--accent); border-radius: 12px; padding: 1px 9px; font-weight: 700; font-size: 0.85rem; font-variant-numeric: tabular-nums;
}

.cardface {
  width: 44px; height: 62px; border-radius: 6px; background: var(--card); color: #111;
  display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 800; font-size: 1.05rem; line-height: 1;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}
.cardface.red { color: var(--red); }
.cardface.back { background: repeating-linear-gradient(45deg, #8b1d1d 0 6px, #a32a2a 6px 12px); border: 2px solid #fff; }
.cardface .s { font-size: 1.1em; }

/* ---------- action bar ---------- */
.actions { grid-column: 1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 14px; background: var(--panel); border-top: 1px solid var(--line); min-height: 64px; }
.actions .group { display: flex; gap: 6px; align-items: center; }
.actions .spacer { flex: 1; }
.actions input[type=range] { width: 160px; }
.actions input[type=number] { width: 90px; }
.actions .big { font-size: 1.05rem; padding: 10px 18px; min-width: 96px; }
.actions .pre label { display: inline-flex; gap: 4px; margin: 0 8px 0 0; align-items: center; color: var(--text); }

.banner { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: var(--accent); color: #1b1b1b; padding: 6px 14px; border-radius: 8px; font-weight: 600; z-index: 10; cursor: pointer; }
.toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); background: var(--danger); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 60; }

@media (max-width: 900px) {
  .side { position: fixed; right: 0; top: 42px; bottom: 0; z-index: 40; }
  .seat { width: 110px; }
}
