:root {
  --bg: #06231e;
  --bg-2: #082a24;
  --panel: #0b3129;
  --panel-2: #113a31;
  --line: rgba(243, 235, 211, 0.14);
  --line-2: rgba(243, 235, 211, 0.24);
  --felt: #0e4a3f;
  --felt-deep: #073329;
  --gold: #d9a62e;
  --gold-2: #f0c45a;
  --gold-ink: #3a2a05;
  --cream: #f3ebd3;
  --text: #e9f1ed;
  --muted: #9ab8ad;
  --card: #fbfaf6;
  --card-ink: #15161a;
  --card-red: #c8102e;
  --back: #8e1b2c;
  --win: #46c485;
  --lose: #e86a55;
  --hit: #2f9e6b;
  --stand: #c8463a;
  --split: #3e7cc4;
  --off-bg: #17302a;
  --off-ink: #4f6b62;
  --sans: "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
  --slab: "Roboto Slab", Rockwell, Georgia, serif;
  --r: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.num { font-family: var(--slab); font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- верхняя полоса ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10; background: rgba(6, 35, 30, 0.94);
  backdrop-filter: blur(6px);
}
.brand { font: 800 18px/1.1 var(--slab); color: var(--gold); letter-spacing: 0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 14px; color: var(--muted); white-space: nowrap; }
.who { color: var(--cream); }
.back-link {
  justify-self: start;
  background: none; border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px 5px 10px;
  color: var(--cream); text-decoration: none; font-size: 14px; font-weight: 600; white-space: nowrap;
}
.back-link::before { content: "‹ "; }
.link { background: none; border: 0; padding: 0; color: var(--cream); text-decoration: underline; text-underline-offset: 3px; font-size: 14px; }
.me-balance { font: 800 16px/1 var(--slab); color: var(--cream); }
.conn { background: var(--lose); color: #fff; border-radius: 999px; padding: 2px 10px; font-weight: 700; font-size: 12px; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 10px; border: 0;
  font-weight: 700; font-size: 15px; text-decoration: none; color: var(--text); text-align: center;
  transition: transform 0.08s ease, filter 0.15s ease, background-color 0.15s ease;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.38; cursor: not-allowed; }
.btn[data-busy] { opacity: 0.6; }
.btn-gold { background: var(--gold); color: var(--gold-ink); }
.btn-gold:hover:not(:disabled) { filter: brightness(1.06); }
.btn-ghost { background: transparent; border: 1px solid var(--line-2); }
.btn-danger { background: transparent; border: 1px solid rgba(232, 106, 85, 0.5); color: var(--lose); }
.btn-wide { width: 100%; }
.btn-big { min-height: 56px; font-size: 18px; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 8px; }

/* ---------- формы ---------- */
label.field, .field, .panel label, .auth-card label, .modal label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); justify-items: stretch; }
.field .seg { justify-self: start; }
input[type="text"], input[type="password"], input[type="number"], input:not([type]), select, textarea {
  min-height: 44px; padding: 0 12px; border-radius: 10px; width: 100%;
  border: 1px solid var(--line-2); background: var(--bg); color: var(--text); font-size: 16px;
}
textarea { padding: 10px 12px; resize: vertical; min-height: 44px; }
.input-num { font: 800 17px var(--slab) !important; }
.form-error { color: var(--lose) !important; margin: 0; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; }
.seg button { min-height: 42px; padding: 0 16px; border: 0; background: transparent; font-weight: 700; color: var(--text); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--gold); color: var(--gold-ink); }
.seg button:disabled { opacity: 0.4; }

/* ---------- вход ---------- */
.page-auth { display: grid; place-items: center; padding: 20px; background: radial-gradient(90% 70% at 50% 0%, #0f4a3e 0%, var(--bg) 70%); }
.auth-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 24px; display: grid; gap: 14px; }
.auth-card h1 { margin: 0; font: 800 26px/1.15 var(--slab); color: var(--gold); }
.auth-card p { margin: 0; color: var(--muted); }
.auth-form { display: grid; gap: 12px; }
.auth-card input { font-size: 17px; min-height: 48px; }

/* ---------- тост и окно ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: #2a0f0b; color: #ffd9d2; border: 1px solid rgba(232, 106, 85, 0.5);
  padding: 12px 16px; border-radius: 10px; max-width: calc(100% - 32px); font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.good { background: #0c3524; color: #c8f2dc; border-color: rgba(70, 196, 133, 0.5); }

dialog.modal {
  width: min(560px, calc(100% - 24px)); max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain;
  padding: 0; border: 1px solid var(--line-2); border-radius: 16px; background: var(--panel); color: var(--text);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
dialog.modal.wide { width: min(760px, calc(100% - 24px)); }
dialog.modal::backdrop { background: rgba(2, 18, 15, 0.78); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.modal-head h2 { margin: 0; font: 800 20px/1.2 var(--slab); color: var(--cream); flex: 1; }
.modal-x { background: none; border: 0; color: var(--muted); font-size: 26px; line-height: 1; padding: 4px 8px; }
.modal-body { padding: 18px; display: grid; gap: 14px; }
@media (prefers-reduced-motion: no-preference) {
  dialog.modal[open] { animation: pop-in 0.18s ease-out; }
  @keyframes pop-in { from { transform: translateY(10px) scale(0.98); opacity: 0; } }
}

/* ================= ЛОББИ ================= */
.lobby { max-width: 1080px; margin: 0 auto; padding: 18px 16px 40px; display: grid; gap: 22px; }
.section-title { margin: 0 0 12px; font: 800 20px/1.2 var(--slab); color: var(--cream); }

.wallet {
  display: grid; gap: 16px; padding: 20px; border-radius: 18px;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(217, 166, 46, 0.16), transparent 55%),
    linear-gradient(160deg, #0f4438, var(--panel));
  border: 1px solid var(--line);
}
.wallet-top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.wallet-label { font-size: 14px; color: var(--muted); }
.wallet-balance { font: 800 clamp(38px, 9vw, 58px)/1 var(--slab); color: var(--cream); letter-spacing: -0.01em; }
.wallet-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.wager { display: grid; gap: 8px; }
.wager-line { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; color: var(--muted); flex-wrap: wrap; }
.wager-line b { color: var(--cream); font-family: var(--slab); }
.bar { height: 10px; border-radius: 99px; background: rgba(243, 235, 211, 0.1); overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-2)); border-radius: inherit; transition: width 0.6s ease; }
.wallet-note { font-size: 13px; color: var(--muted); margin: 0; }

.seated-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 16px; border-radius: 14px; border: 1px solid rgba(217, 166, 46, 0.5); background: rgba(217, 166, 46, 0.08);
}
.seated-banner p { margin: 0; color: var(--cream); font-weight: 600; }

.table-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.tcard {
  display: grid; gap: 12px; padding: 16px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line);
  align-content: start;
}
.tcard.mine { border-color: rgba(217, 166, 46, 0.55); }
.tcard-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.tcard h3 { margin: 0; font: 800 19px/1.2 var(--slab); color: var(--cream); word-break: break-word; }
.tcard-sub { font-size: 13px; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; background: rgba(243, 235, 211, 0.1); color: var(--cream); }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.live { color: var(--win); background: rgba(70, 196, 133, 0.12); }
.pill.wait { color: var(--gold-2); background: rgba(217, 166, 46, 0.12); }
.pill.off { color: var(--lose); background: rgba(232, 106, 85, 0.12); }
.seat-row { display: flex; flex-direction: row-reverse; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.seat-dot { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; font-size: 13px; border: 1px dashed var(--line-2); color: var(--muted); }
.seat-dot.taken { border-style: solid; color: var(--cream); background: rgba(243, 235, 211, 0.06); }
.seat-dot b { font-family: var(--slab); color: var(--gold); }
.tcard-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.tcard-meta b { color: var(--cream); font-family: var(--slab); }
.empty-note { padding: 26px 18px; border-radius: 16px; border: 1px dashed var(--line-2); color: var(--muted); text-align: center; }
.empty-note b { color: var(--cream); }

/* ================= СУКНО ================= */
.felt-wrap { width: 100%; }
.felt {
  --cw: clamp(34px, 10.5cqw, 92px);
  --ch: calc(var(--cw) * 1.4);
  position: relative; overflow: hidden;
  aspect-ratio: 1000 / 690;
  container-type: inline-size;
  background: radial-gradient(120% 90% at 50% 0%, #135a4c 0%, var(--felt) 45%, var(--felt-deep) 100%);
}
.felt.seats-2 { --cw: clamp(32px, 9.2cqw, 84px); }
.felt.seats-3 { --cw: clamp(28px, 7.8cqw, 72px); }
@media (max-width: 600px) {
  .felt { aspect-ratio: 1000 / 860; --cw: clamp(34px, 11.5cqw, 92px); }
  .felt.seats-2 { --cw: clamp(30px, 9.6cqw, 84px); }
  .felt.seats-3 { aspect-ratio: 1000 / 900; --cw: clamp(26px, 8cqw, 72px); }
}

.felt-print { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.felt-print .band { fill: none; stroke: var(--gold); stroke-width: 50; opacity: 0.95; }
.felt-print .t-bj { fill: var(--gold); font: 800 34px var(--slab); letter-spacing: 3px; }
.felt-print .t-rule { fill: var(--felt-deep); font: 800 21px var(--slab); letter-spacing: 1.5px; }
.felt-print .t-ins { fill: rgba(243, 235, 211, 0.55); font: 800 17px var(--slab); letter-spacing: 3px; }

.zone-dealer {
  --fx: 26cqw; --fy: -4cqw;
  position: absolute; top: 3.5%; left: 0; right: 0;
  display: flex; justify-content: center; align-items: flex-start; gap: 10px;
}
.zone-boxes {
  --fx: 30cqw; --fy: -46cqw;
  position: absolute; left: 0; right: 0; bottom: 2%;
  display: flex; flex-direction: row-reverse; justify-content: space-evenly; align-items: flex-end;
  padding: 0 2%;
}
.felt-msg {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%);
  padding: 8px 16px; border-radius: 12px; background: rgba(4, 30, 25, 0.78); color: var(--cream);
  font: 700 clamp(13px, 2.4cqw, 18px)/1.3 var(--sans); text-align: center; pointer-events: none; max-width: 80%;
}

.box { display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; position: relative; }
.hands { display: flex; flex-direction: row-reverse; justify-content: center; align-items: flex-end; gap: calc(var(--cw) * 0.28); min-height: var(--ch); }
.hand-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; position: relative; }

.hand {
  --n: 1;
  position: relative;
  width: calc(var(--cw) * (1 + (var(--n) - 1) * 0.3));
  height: calc(var(--ch) * (1 + (var(--n) - 1) * 0.12));
}
.hand.empty { width: var(--cw); height: var(--ch); }
.hand.dealer-row { width: calc(var(--cw) * (1 + (var(--n) - 1) * 0.72)); height: var(--ch); }

/* ---------- карта ---------- */
.card {
  position: absolute;
  left: calc(var(--i) * var(--cw) * 0.3);
  bottom: calc(var(--i) * var(--ch) * 0.12);
  width: var(--cw); height: var(--ch);
  background: var(--card); color: var(--card-ink);
  border-radius: calc(var(--cw) * 0.08);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25), 0 calc(var(--cw) * 0.05) calc(var(--cw) * 0.12) rgba(0, 0, 0, 0.3);
  font-family: var(--slab);
  user-select: none;
}
.dealer-row .card { bottom: 0; left: calc(var(--i) * var(--cw) * 0.72); }
.card.red { color: var(--card-red); }
.card .ix { position: absolute; top: 5%; left: 7%; display: flex; flex-direction: column; align-items: center; font-size: calc(var(--cw) * 0.29); line-height: 0.95; }
.card .ix b { font-weight: 800; letter-spacing: -0.05em; }
.card .ix i { font-style: normal; font-size: 0.82em; }
.card .ix-b { top: auto; left: auto; bottom: 5%; right: 7%; transform: rotate(180deg); }
.card .pip { position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--cw) * 0.56); padding-top: 6%; }
.card.back, .card.fresh::after {
  background:
    repeating-linear-gradient(45deg, transparent 0 5px, rgba(255, 255, 255, 0.09) 5px 6px),
    repeating-linear-gradient(-45deg, transparent 0 5px, rgba(255, 255, 255, 0.09) 5px 6px),
    var(--back);
}
.card.back { border: calc(var(--cw) * 0.06) solid var(--card); }
.card.fresh::after { content: ""; position: absolute; inset: 0; border-radius: inherit; border: calc(var(--cw) * 0.06) solid var(--card); opacity: 0; pointer-events: none; }

@media (prefers-reduced-motion: no-preference) {
  /* карта вылетает из шуза рубашкой вверх и переворачивается на месте */
  .card.fresh { animation: deal-fly 0.62s cubic-bezier(0.22, 0.8, 0.25, 1) both; }
  .card.fresh::after { animation: deal-back 0.62s linear both; animation-delay: inherit; }
  @keyframes deal-fly {
    0% { transform: translate(var(--fx), var(--fy)) rotate(22deg) scale(0.92); opacity: 0; }
    12% { opacity: 1; }
    58% { transform: translate(0, 0) rotate(0) scaleX(1); }
    72% { transform: scaleX(0.04); }
    100% { transform: scaleX(1); }
  }
  @keyframes deal-back { 0%, 71% { opacity: 1; } 72%, 100% { opacity: 0; } }
  .card.back.fresh { animation: deal-fly-back 0.45s cubic-bezier(0.22, 0.8, 0.25, 1) both; }
  .card.back.fresh::after { display: none; }
  @keyframes deal-fly-back {
    from { transform: translate(var(--fx), var(--fy)) rotate(22deg) scale(0.92); opacity: 0; }
    to { transform: none; opacity: 1; }
  }
}

/* ---------- суммы, итоги ---------- */
.badge {
  min-width: calc(var(--cw) * 0.62); padding: 0 calc(var(--cw) * 0.12);
  height: calc(var(--cw) * 0.36);
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; background: #fff; color: var(--card-ink);
  font: 800 calc(var(--cw) * 0.22) / 1 var(--slab);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
}
.badge.active { background: var(--gold); color: var(--gold-ink); }
.badge.bust { background: var(--lose); color: #fff; }
.badge.bj { background: var(--gold); color: var(--gold-ink); }
.zone-dealer .badge { margin-top: calc(var(--ch) * 0.3); }
.hand-wrap.active .hand::after {
  content: ""; position: absolute; left: -8%; right: -8%; bottom: -9%; height: 5%;
  border-radius: 99px; background: var(--gold);
}
.tag {
  font: 800 calc(var(--cw) * 0.19) / 1 var(--slab);
  padding: 4px 8px; border-radius: 6px; background: rgba(0, 0, 0, 0.4); white-space: nowrap; color: var(--cream);
}
.tag.win, .tag.blackjack { color: var(--win); }
.tag.lose, .tag.bust { color: var(--lose); }
.tag.ins { color: var(--gold-2); }
@media (prefers-reduced-motion: no-preference) {
  .tag.pop { animation: tag-pop 0.35s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
  @keyframes tag-pop { from { transform: scale(0.4); opacity: 0; } }
}

/* ---------- бокс, фишки, имя ---------- */
.spot {
  position: relative;
  width: calc(var(--cw) * 1.05); aspect-ratio: 1; border-radius: 50%;
  border: 2px solid rgba(243, 235, 211, 0.5);
  display: grid; place-items: center;
  font: 700 calc(var(--cw) * 0.16) / 1.1 var(--sans); color: var(--cream); text-align: center;
}
.spot.free { border-style: dashed; }
button.spot { background: rgba(217, 166, 46, 0.12); border-color: var(--gold); color: var(--gold-2); font-size: calc(var(--cw) * 0.2); }
button.spot:hover { background: rgba(217, 166, 46, 0.22); }
.box.turn .spot { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(217, 166, 46, 0.25); }
.box.me .spot { border-color: var(--cream); }
.chip {
  --c: #c8302e; --t: #fff;
  width: calc(var(--cw) * 0.82); aspect-ratio: 1; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--c); color: var(--t);
  border: calc(var(--cw) * 0.075) dashed rgba(255, 255, 255, 0.88);
  box-shadow: inset 0 0 0 calc(var(--cw) * 0.06) var(--c), 0 3px 0 rgba(0, 0, 0, 0.35);
  font: 800 calc(var(--cw) * 0.2) / 1 var(--slab); letter-spacing: -0.03em;
  grid-area: 1 / 1;
}
.chip.c1 { --c: #ecebe4; --t: #1d2a26; border-color: #3e7cc4; }
.chip.c5 { --c: #c8302e; }
.chip.c25 { --c: #2e8b57; }
.chip.c100 { --c: #1c1c1c; }
.chip.c500 { --c: #6b3fa0; }
.chip.pay { transform: translate(28%, -22%); }
@media (prefers-reduced-motion: no-preference) {
  .chip.drop { animation: chip-drop 0.32s cubic-bezier(0.3, 1.4, 0.5, 1) both; }
  @keyframes chip-drop { from { transform: translateY(-60%) scale(1.25); opacity: 0; } }
  .chip.pay.fly { animation: chip-pay 0.7s cubic-bezier(0.22, 0.8, 0.25, 1) both; }
  @keyframes chip-pay { from { transform: translate(0, -340%) scale(0.8); opacity: 0; } 30% { opacity: 1; } }
  .chip.take { animation: chip-take 0.7s cubic-bezier(0.55, 0, 0.7, 0.3) both; }
  @keyframes chip-take { to { transform: translate(0, -340%) scale(0.7); opacity: 0; } }
}
.spot.lost .chip:not(.take) { opacity: 0; }
.seat-name { display: flex; align-items: baseline; gap: 6px; font-size: clamp(11px, 2cqw, 16px); color: var(--cream); max-width: calc(var(--cw) * 2.6); white-space: nowrap; }
.seat-name b { font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.seat-name .bal { font-family: var(--slab); font-weight: 800; color: var(--gold); }
.ready-mark { font: 700 clamp(10px, 1.6cqw, 13px)/1 var(--sans); color: var(--win); }
.box-timer { width: calc(var(--cw) * 1.4); height: 5px; border-radius: 99px; background: rgba(0, 0, 0, 0.35); overflow: hidden; }

/* ---------- полоса таймера ---------- */
.timer { height: 8px; border-radius: 99px; background: rgba(243, 235, 211, 0.12); overflow: hidden; }
.timer i, .box-timer i {
  display: block; height: 100%; width: 100%; border-radius: inherit; background: var(--gold);
  transform-origin: left center;
  animation: drain linear forwards;
}
@keyframes drain {
  from { transform: scaleX(1); background: var(--gold); }
  65% { background: var(--gold); }
  to { transform: scaleX(0); background: var(--lose); }
}

/* ================= СТОЛ ИГРОКА ================= */
.table-layout { max-width: 1280px; margin: 0 auto; display: grid; gap: 0; grid-template-columns: 1fr; }
@media (min-width: 980px) {
  .table-layout { grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; padding: 16px; }
  .table-layout .felt { border-radius: var(--r); border: 1px solid var(--line); aspect-ratio: 1000 / 590; }
  .table-layout .felt.seats-3 { aspect-ratio: 1000 / 620; }
  .table-side { position: sticky; top: 70px; align-self: start; }
}
.table-side { padding: 0 16px 20px; }
@media (min-width: 980px) { .table-side { padding: 0; } }
.console { padding: 14px 16px 18px; display: grid; gap: 14px; }
@media (min-width: 980px) { .console { padding: 16px 0 0; } }
.status { font: 700 19px/1.3 var(--sans); color: var(--cream); margin: 0; }
.status small { display: block; font-weight: 400; font-size: 14px; color: var(--muted); margin-top: 2px; }
.status.win { color: var(--gold); }
.bet-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.bet-sum { font: 800 28px/1 var(--slab); color: var(--cream); }
.bet-sum small { display: block; font: 400 13px/1.4 var(--sans); color: var(--muted); margin-top: 4px; }
.bet-tools { display: flex; gap: 8px; }
.chip-rack { display: flex; gap: 10px; flex-wrap: wrap; }
.chip-btn { --cw: 64px; background: none; border: 0; padding: 0; border-radius: 50%; }
.chip-btn .chip { width: 56px; border-width: 5px; box-shadow: inset 0 0 0 4px var(--c), 0 3px 0 rgba(0, 0, 0, 0.35); font-size: 15px; transition: transform 0.12s; }
.chip-btn:hover:not(:disabled) .chip { transform: translateY(-3px); }
.chip-btn:disabled { opacity: 0.28; cursor: not-allowed; }
.actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 560px) { .actions { grid-template-columns: repeat(4, 1fr); } }
.actions.two { grid-template-columns: 1fr 1fr; }
.act { min-height: 60px; border-radius: 12px; border: 0; font-weight: 800; font-size: 17px; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.2; transition: background-color 0.15s, color 0.15s, transform 0.08s; }
.act:active:not(:disabled) { transform: scale(0.98); }
.act small { font-size: 12px; font-weight: 600; opacity: 0.85; }
.act:disabled { background: var(--off-bg) !important; color: var(--off-ink) !important; cursor: not-allowed; box-shadow: none; }
.act-hit { background: var(--hit); }
.act-stand { background: var(--stand); }
.act-double { background: var(--gold); color: var(--gold-ink); }
.act-split { background: var(--split); }
.act-ins { background: var(--gold); color: var(--gold-ink); }
.act-noins { background: transparent; border: 1px solid var(--line-2); }
.hint { margin: 0; font-size: 13px; color: var(--muted); }
.console-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.others { display: flex; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.others span { padding: 3px 10px; border-radius: 999px; background: rgba(243, 235, 211, 0.07); color: var(--muted); }
.others span.ok { color: var(--win); }

/* ---------- чат ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: grid; gap: 12px; align-content: start; }
.panel h2 { margin: 0; font: 700 15px/1.3 var(--sans); color: var(--cream); display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.panel h2 small { font-weight: 400; color: var(--muted); font-size: 13px; }
.chat { gap: 10px; }
.chat-list { list-style: none; margin: 0; padding: 0 2px 0 0; display: grid; gap: 8px; max-height: 340px; min-height: 120px; overflow-y: auto; align-content: start; overscroll-behavior: contain; }
.chat-list li { font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; white-space: pre-wrap; }
.chat-list .who { font-weight: 800; margin-right: 6px; }
.chat-list .dealer .who { color: var(--gold); }
.chat-list .me .who { color: var(--win); }
.chat-list time { color: var(--muted); font-size: 12px; margin-right: 6px; font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: no-preference) {
  .chat-list li.new { animation: msg-in 0.25s ease-out; }
  @keyframes msg-in { from { opacity: 0; transform: translateY(6px); } }
}
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; min-width: 0; }
.chat-empty { color: var(--muted); font-size: 14px; }

/* ================= ИСТОРИЯ ================= */
.hist-day { margin: 6px 0 2px; font: 700 13px/1.3 var(--sans); color: var(--muted); text-transform: none; }
.hist-list { display: grid; gap: 6px; }
.hist-item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; text-align: left;
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2); color: var(--text); width: 100%;
}
.hist-item:hover { border-color: var(--line-2); }
.hist-item time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }
.hist-item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-item .t small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.hist-item .n { font: 800 15px var(--slab); text-align: right; }
.hist-item .n small { display: block; font: 400 12px var(--sans); color: var(--muted); }
.pos { color: var(--win); }
.neg { color: var(--lose); }
.hd-felt { --cw: 46px; --ch: calc(var(--cw) * 1.4); display: grid; gap: 14px; padding: 16px; border-radius: 12px; background: radial-gradient(120% 90% at 50% 0%, #135a4c 0%, var(--felt) 50%, var(--felt-deep) 100%); }
.hd-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hd-row .lbl { width: 78px; color: var(--cream); font-weight: 700; font-size: 14px; }
.hd-hands { display: flex; flex-direction: row-reverse; justify-content: flex-end; gap: 16px; flex-wrap: wrap; }
.hd-cards { display: flex; gap: 4px; align-items: center; }
.hd-cards .card { position: relative; left: auto; bottom: auto; animation: none !important; }
.hd-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.hd-table td { padding: 7px 0; border-bottom: 1px solid var(--line); }
.hd-table td:last-child { text-align: right; font-family: var(--slab); font-weight: 800; }
.hd-log { margin: 0; padding-left: 20px; display: grid; gap: 3px; color: var(--muted); font-size: 14px; }

/* ================= ПАНЕЛЬ ДИЛЕРА ================= */
.dealer-layout {
  display: grid; gap: 16px; padding: 14px;
  grid-template-columns: 1fr;
  grid-template-areas: "table" "cards" "side";
}
@media (min-width: 960px) {
  .dealer-layout {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    grid-template-areas: "table cards" "side side";
    align-items: start;
  }
}
@media (min-width: 1480px) {
  .dealer-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 360px; grid-template-areas: "table cards side"; }
}
.d-table { grid-area: table; display: grid; gap: 12px; }
.d-table .felt { border-radius: var(--r); border: 1px solid var(--line); }
.d-cards { grid-area: cards; display: grid; gap: 10px; align-content: start; }
.d-side { grid-area: side; display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }
.d-flow { display: grid; gap: 10px; }
.d-flow .row { display: flex; gap: 10px; flex-wrap: wrap; }
.d-flow .row .btn { flex: 1 1 150px; white-space: nowrap; }
.d-flow .row .btn-big { flex: 2 1 220px; }

.target { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 46px; font-weight: 700; color: var(--cream); }
.picker { display: grid; grid-template-columns: repeat(13, minmax(0, 1fr)); gap: 5px; }
.picker.off { opacity: 0.32; pointer-events: none; }
.pk {
  aspect-ratio: 5 / 7; border: 0; border-radius: 6px; background: var(--card); color: var(--card-ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-family: var(--slab); line-height: 1; padding: 0;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}
.pk b { font-weight: 800; font-size: clamp(12px, 1.5vw, 22px); letter-spacing: -0.04em; }
.pk i { font-style: normal; font-size: clamp(12px, 1.4vw, 20px); }
.pk.red { color: var(--card-red); }
.pk:active, .pk.hit { background: var(--gold); }
.pk.sel { outline: 3px solid var(--gold); outline-offset: 1px; }
.picker.ranks { grid-template-columns: repeat(5, 1fr); }
.picker.ranks .pk { aspect-ratio: 4 / 3; }
.picker.ranks .pk b { font-size: 24px; }
.picker.suits { grid-template-columns: repeat(4, 1fr); }
.picker.suits .pk b { font-size: 28px; }
.picker.suits .pk i { font-size: 30px; }
.picker .back-btn { grid-column: 1 / -1; }
@media (pointer: coarse) { .kbd-hint { display: none; } }

.seat-card { display: grid; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); }
.seat-card.vacant { color: var(--muted); border-style: dashed; }
.seat-card-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.seat-card-head b { font-size: 16px; }
.seat-card-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.seat-card-meta b { color: var(--cream); font-family: var(--slab); }
.online { font-size: 13px; color: var(--muted); white-space: nowrap; }
.online::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--lose); margin-right: 6px; }
.online.on::before { background: var(--win); }
.events { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 14px; max-height: 260px; overflow: auto; }
.events time { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 8px; }
.panel .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- лобби дилера ---------- */
.create-form { display: grid; gap: 14px; }
.create-form .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .create-form .grid2 { grid-template-columns: 1fr; } }
.names { display: flex; gap: 6px; flex-wrap: wrap; font-size: 13px; }
.names span { padding: 3px 10px; border-radius: 999px; background: rgba(70, 196, 133, 0.12); color: var(--win); }
.names span.bad { background: rgba(232, 106, 85, 0.12); color: var(--lose); }
.mytable { display: grid; gap: 14px; padding: 20px; border-radius: 18px; border: 1px solid rgba(217, 166, 46, 0.5); background: linear-gradient(160deg, #0f4438, var(--panel)); }
.mytable h2 { margin: 0; font: 800 24px/1.2 var(--slab); color: var(--cream); }
.mytable .btns { display: flex; gap: 10px; flex-wrap: wrap; }

/* ================= АДМИНКА ================= */
.tabs { display: flex; gap: 4px; padding: 10px 16px 0; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: 0; padding: 10px 14px; color: var(--muted); font-weight: 700; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--cream); border-bottom-color: var(--gold); }
.admin { max-width: 1240px; margin: 0 auto; padding: 18px 16px 40px; display: grid; gap: 18px; }
.admin-form { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); align-items: end; }
.data-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-weight: 700; color: var(--muted); font-size: 12px; padding: 9px 12px; background: var(--panel-2); white-space: nowrap; }
table.data td { padding: 9px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
table.data td.n { font-family: var(--slab); font-weight: 800; text-align: right; white-space: nowrap; }
table.data tr.off td { color: var(--muted); }
table.data .act-cell { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
code.code { font: 800 14px var(--slab); color: var(--gold-2); letter-spacing: 0.04em; }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.row-btns .btn { flex: 1 1 160px; }

/* ================= ТРАНСЛЯЦИЯ ================= */
.pills { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.pill.rec { color: #fff; background: #c8263a; }
.pill.rec::before { background: #fff; }
@media (prefers-reduced-motion: no-preference) {
  .pill.rec::before, .stream-live::before { animation: rec-blink 1.6s ease-in-out infinite; }
  @keyframes rec-blink { 50% { opacity: 0.25; } }
}

.stream { position: relative; }
.stream-box {
  position: relative; overflow: hidden; background: #020c0a;
  aspect-ratio: 16 / 9; width: 100%;
  touch-action: manipulation;
}
.stream video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #020c0a; display: block; }
.stream.mode-big .stream-box { max-height: 62vh; }
@media (min-width: 980px) {
  .stream.mode-big { margin-bottom: 14px; }
  .stream.mode-big .stream-box { border-radius: var(--r); border: 1px solid var(--line); max-height: 58vh; }
}

/* маленькое окно поверх страницы, утаскивается в любой угол */
.stream.mode-mini .stream-box {
  position: fixed; z-index: 45; width: min(46vw, 360px); max-height: none;
  border-radius: 12px; border: 1px solid var(--line-2);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
  cursor: grab; transition: transform 0.18s ease;
}
.stream.mode-mini .stream-box.dragging { transition: none; cursor: grabbing; opacity: 0.92; }
.stream.mode-mini .stream-box[data-corner="br"] { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
.stream.mode-mini .stream-box[data-corner="bl"] { left: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
.stream.mode-mini .stream-box[data-corner="tr"] { right: 12px; top: 64px; }
.stream.mode-mini .stream-box[data-corner="tl"] { left: 12px; top: 64px; }
.stream.mode-panel .stream-box { border-radius: 10px; border: 1px solid var(--line); }

.stream-top {
  position: absolute; top: 8px; left: 8px; display: flex; gap: 8px; align-items: center; pointer-events: none;
  font: 700 12px/1 var(--sans); color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}
.stream-live { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 6px; background: #c8263a; letter-spacing: 0.02em; }
.stream-live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #fff; }
.stream:not(.st-playing) .stream-live { display: none; }
.stream-msg {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; text-align: center;
  color: var(--cream); font: 600 clamp(13px, 2.4vw, 16px)/1.4 var(--sans); background: rgba(2, 12, 10, 0.55);
}
.stream.st-offair .stream-msg { background: radial-gradient(80% 80% at 50% 40%, #0d3b31, #020c0a); }
.stream-cta {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  border: 0; border-radius: 999px; padding: 12px 20px; background: var(--gold); color: var(--gold-ink);
  font: 800 15px/1 var(--sans); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}
.stream-ctl {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 4px;
  padding: 18px 8px 8px; background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
  opacity: 0; transition: opacity 0.2s; pointer-events: none;
}
.stream-box:hover .stream-ctl, .stream-box.ctl-on .stream-ctl, .stream:not(.st-playing) .stream-ctl { opacity: 1; pointer-events: auto; }
@media (hover: none) { .stream-box:hover .stream-ctl { opacity: 0; pointer-events: none; } .stream-box.ctl-on .stream-ctl { opacity: 1; pointer-events: auto; } }
.stream-ctl button {
  width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 8px;
  background: rgba(255, 255, 255, 0.12); color: #fff; padding: 0;
}
.stream-ctl button:hover { background: rgba(255, 255, 255, 0.24); }
.stream-ctl svg { width: 22px; height: 22px; }
.stream-ctl .grow { flex: 1; }
.stream-vol { width: 90px; accent-color: var(--gold); }
@media (hover: none) { .stream-vol { display: none; } }
.stream.mode-mini .stream-vol, .stream.mode-mini [data-s="pip"] { display: none; }
.stream-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px; font-size: 14px; color: var(--muted); border-bottom: 1px solid var(--line); background: var(--bg-2);
}
@media (min-width: 980px) { .stream-bar { border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 14px; } }
.stream-box:fullscreen { max-height: none; border-radius: 0; }

/* панель дилера */
.stream-panel .stream-box { margin-bottom: 2px; }
.stream-body { display: grid; gap: 10px; }
.stream-meta { font-size: 13px; }
.pill.live { color: var(--win); background: rgba(70, 196, 133, 0.12); }
.qr { background: #fff; border-radius: 12px; padding: 10px; width: min(300px, 100%); justify-self: center; }
.qr svg { display: block; width: 100%; height: auto; }
.copy-row { display: flex; gap: 6px; }
.copy-row input { flex: 1; min-width: 0; font-size: 14px; }
.howto { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.howto summary { cursor: pointer; font-weight: 700; color: var(--cream); }
.howto p { margin: 8px 0 0; font-size: 14px; color: var(--muted); }

/* галочка в форме */
.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: 12px; cursor: pointer; }
.check input { width: 22px; height: 22px; min-height: 0; margin: 2px 0 0; accent-color: var(--gold); flex: none; }
.check b { display: block; color: var(--cream); font-size: 15px; }
.check small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.check:has(input:disabled) { opacity: 0.6; cursor: not-allowed; }

/* ================= СТРАНИЦА КАМЕРЫ ================= */
.page-cam { background: #020c0a; }
.cam { max-width: 720px; margin: 0 auto; display: grid; gap: 0; min-height: 100dvh; align-content: start; }
.cam-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); }
.cam-head .pill.live { color: #fff; background: #c8263a; }
.cam-head .pill.wait { color: var(--gold-2); background: rgba(217, 166, 46, 0.14); }
.cam-view { position: relative; aspect-ratio: 16 / 9; background: #000; }
.cam-view video { width: 100%; height: 100%; object-fit: contain; display: block; }
.cam-stats { position: absolute; left: 8px; bottom: 8px; font: 700 12px/1.3 var(--sans); color: #fff; text-shadow: 0 1px 3px #000; }
.cam-msg { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; text-align: center; color: var(--cream); background: rgba(2, 12, 10, 0.78); font-weight: 600; }
.cam-ctl { display: grid; gap: 12px; padding: 16px; }
.cam-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 420px) { .cam-row { grid-template-columns: 1fr; } }
@media (orientation: landscape) and (max-height: 520px) {
  .cam { grid-template-columns: 1.4fr 1fr; max-width: none; }
  .cam-head { grid-column: 1 / -1; }
  .cam-view { aspect-ratio: auto; height: calc(100dvh - 56px); }
  .cam-ctl { overflow-y: auto; max-height: calc(100dvh - 56px); }
}

.stream.st-offair .stream-ctl, .stream.st-offair .stream-top { display: none; }

.stream-live { white-space: nowrap; }
.stream-lat { white-space: nowrap; }
.stream.mode-mini .stream-lat { display: none; }

/* широкий экран: видео слева во всю высоту, справа стол, ставки и чат */
@media (min-width: 1100px) {
  .table-layout.with-video {
    max-width: 1720px;
    grid-template-columns: minmax(0, 1.75fr) minmax(380px, 1fr);
    grid-template-areas: "video felt" "video console" "video chat";
    grid-template-rows: auto auto 1fr;
    align-items: start;
  }
  .table-layout.with-video .table-main { display: contents; }
  .table-layout.with-video #stream { grid-area: video; position: sticky; top: 70px; margin: 0; }
  .table-layout.with-video #table { grid-area: felt; }
  .table-layout.with-video #console { grid-area: console; padding-top: 0; }
  .table-layout.with-video .table-side { grid-area: chat; position: static; }
  .table-layout.with-video .stream.mode-big .stream-box { max-height: calc(100vh - 100px); }
  .table-layout.with-video .felt { aspect-ratio: 1000 / 640; }
}
