:root {
  --bg: #0b1712;
  --panel: #13261e;
  --panel-2: #1b3329;
  --line: #2a4a3c;
  --text: #eef5f1;
  --muted: #8fae9f;
  --accent: #f2b844;
  --accent-text: #2a1d00;
  --danger: #d9534f;
  --felt: #17603f;
  --felt-edge: #0e3d28;
  --rail: #3b2614;
  --card: #fbfbf8;
  --red: #d22f3a;
  --black: #16181d;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
}
.hidden { display: none !important; }

header#top {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
#title { flex: 1; font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.balance { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.chip-icon {
  width: 16px; height: 16px; border-radius: 50%;
  background: radial-gradient(circle, var(--accent) 35%, #fff 36%, #fff 48%, var(--accent) 49%);
  box-shadow: 0 0 0 1px #0004;
}
button.icon { background: none; border: 0; color: var(--text); font-size: 28px; line-height: 1; padding: 0 6px 2px; }

main { flex: 1; overflow-y: auto; position: relative; }
section { padding: 14px; }
.center-msg { text-align: center; color: var(--muted); padding-top: 30vh; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 2px 8px; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.fine { color: var(--muted); font-size: 12px; text-align: center; margin-top: 18px; }

.btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  border-radius: 12px; padding: 12px 10px; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; }
.btn.accent { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn.danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 7px 10px; font-size: 13px; border-radius: 10px; }

.note {
  display: block; width: 100%; margin-top: 12px; padding: 12px;
  background: #f2b84422; border: 1px solid var(--accent); color: var(--text);
  border-radius: 12px; font: inherit; text-align: left;
}

.table-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; margin-bottom: 8px; cursor: pointer;
}
.table-item .info { flex: 1; min-width: 0; }
.table-item .name { font-weight: 700; }
.table-item .meta { color: var(--muted); font-size: 13px; }
.level { margin-bottom: 8px; }
.level .table-item { margin-bottom: 0; }
.sublist { border: 1px solid var(--line); border-top: 0; border-radius: 0 0 14px 14px; margin: -6px 6px 0; padding: 8px 6px 4px; background: #0e1d16; }
.subrow { display: flex; justify-content: space-between; width: 100%; background: none; border: 0; color: var(--text); font: inherit; padding: 8px 8px; border-radius: 8px; cursor: pointer; }
.subrow:active { background: var(--panel-2); }
.subrow .count { color: var(--muted); font-variant-numeric: tabular-nums; }
.table-item .count { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.table-item .count b { color: var(--text); }

/* ---------- Стол ---------- */
#tableView { padding: 10px 10px 0; display: flex; flex-direction: column; height: 100%; }
#felt { position: relative; flex: 1; min-height: 340px; margin: 26px 18px 34px; }
.felt-inner {
  position: absolute; inset: 0; border-radius: 48% / 34%;
  background: radial-gradient(ellipse at 50% 40%, #1f7a51, var(--felt) 55%, var(--felt-edge));
  border: 10px solid var(--rail);
  box-shadow: inset 0 0 30px #0007, 0 6px 20px #0008;
}
#center {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px; width: 80%;
}
#pot { font-weight: 700; font-variant-numeric: tabular-nums; background: #0005; padding: 2px 10px; border-radius: 10px; min-height: 1em; }
#pot:empty { visibility: hidden; }
#board { display: flex; gap: 4px; min-height: 52px; }
#resultBanner {
  background: #000a; border: 1px solid var(--accent); border-radius: 10px;
  padding: 6px 10px; text-align: center; font-size: 13px;
}
#resultBanner b { color: var(--accent); }

.card {
  width: 36px; height: 52px; border-radius: 6px; background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 800; box-shadow: 0 2px 4px #0006; line-height: 1;
}
.card .r { font-size: 17px; }
.card .s { font-size: 16px; }
.card.red { color: var(--red); }
.card.black { color: var(--black); }
.card.back {
  background: repeating-linear-gradient(45deg, #8c1d2a 0 4px, #a8293a 4px 8px);
  border: 2px solid #fff;
}
.card.sm { width: 28px; height: 40px; border-radius: 5px; }
.card.sm .r { font-size: 14px; }
.card.sm .s { font-size: 12px; }
.card.win { outline: 2px solid var(--accent); }

.seat {
  position: absolute; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; width: 92px;
}
.seat .cards { display: flex; gap: 2px; height: 40px; margin-bottom: -10px; z-index: 1; }
.seat.me .cards { height: 52px; margin-bottom: -8px; }
.plate {
  position: relative; width: 100%; background: #0d1a14ee; border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 6px 5px; text-align: center; overflow: hidden;
}
.plate .name { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plate .stack { font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--accent); }
.bot-badge { position: absolute; left: 4px; top: 2px; font-size: 11px; line-height: 1; opacity: .85; }
.plate .timer { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); width: 0; }
.seat.active .plate { border-color: var(--accent); box-shadow: 0 0 0 2px #f2b84455, 0 0 14px #f2b84466; }
.seat.folded { opacity: .45; }
.seat.away .plate .name::after { content: " · нет"; color: var(--muted); }
.seat .act {
  position: absolute; top: -18px; font-size: 11px; font-weight: 700;
  background: #000b; padding: 1px 6px; border-radius: 6px; white-space: nowrap;
}
.seat .act:empty { display: none; }
.seat .hand-name { font-size: 11px; color: var(--accent); margin-top: 2px; white-space: nowrap; }
.dealer {
  position: absolute; right: -6px; top: 18px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; color: #000; font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 3px #0008;
}
.bet {
  position: absolute; transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
  background: #0007; padding: 1px 7px 1px 3px; border-radius: 10px;
}
.empty-seat {
  position: absolute; transform: translate(-50%, -50%);
  width: 64px; height: 44px; border-radius: 12px; border: 1px dashed #ffffff44;
  background: #0003; color: var(--muted); font: inherit; font-size: 12px;
}
button.empty-seat { color: var(--accent); border-color: var(--accent); cursor: pointer; font-weight: 700; }

#controls { padding: 8px 4px calc(10px + env(safe-area-inset-bottom)); }
#actionBar { display: flex; gap: 8px; }
#actionBar .btn { flex: 1; padding: 14px 6px; }
#raisePanel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px; margin-bottom: 8px; }
.presets { display: flex; gap: 6px; }
.presets .btn { flex: 1; }
.slider-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.slider-row input { flex: 1; accent-color: var(--accent); }
.slider-row b { min-width: 64px; text-align: right; font-variant-numeric: tabular-nums; }
#seatBar { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
#tableInfo { flex: 1; color: var(--muted); font-size: 12px; }

/* ---------- Модалка и тост ---------- */
#modal {
  position: fixed; inset: 0; background: #000a; display: flex; align-items: flex-end; z-index: 20;
}
.sheet {
  width: 100%; background: var(--panel); border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line);
}
.sheet h3 { margin: 0 0 12px; }
#modalBody { margin-bottom: 14px; color: var(--text); }
#modalBody .muted { color: var(--muted); font-size: 13px; }
#modalBody code { font-size: 11px; word-break: break-all; color: var(--muted); }
.pack {
  display: flex; justify-content: space-between; align-items: center; width: 100%;
  margin-bottom: 8px; text-align: left;
}
.big-value { font-size: 26px; font-weight: 800; text-align: center; margin: 8px 0; font-variant-numeric: tabular-nums; }
#modalBody input[type=range] { width: 100%; accent-color: var(--accent); }

#toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: #000d; border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px;
  z-index: 30; max-width: 90%; text-align: center;
}
