/* ═══════════════════════════════════════════════════════════════════════════
   Poker Island — дизайн-система
   Слои: 1) токены  2) база  3) примитивы  4) компоненты  5) экраны  6) адаптив
   Правила, которым подчинён весь файл:
   • один акцент — латунь; всё остальное держится на оттенках чернил и волосяных
     линиях. Никаких вторых-третьих «фирменных» цветов;
   • у элемента максимум одна тень; свечения нет вообще;
   • размеры берутся только из шкалы отступов и радиусов;
   • элементы, которые появляются и исчезают, не двигают соседей: им заранее
     отведено место.
   ═════════════════════════════════════════════════════════════════════════ */

/* ── 1. Токены ──────────────────────────────────────────────────────────── */

:root {
  color-scheme: dark;

  /* Пространство: шаг 4. Между значениями ничего нет. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  /* Радиусы: три ступени и пилюля. */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  /* Чернила: фон, панель, поднятый элемент. Больше уровней не нужно. */
  --ink-900: #060b08;
  --ink-800: #0b1310;
  --ink-700: #101b16;
  --ink-600: #16241d;

  /* Линии: волосяная и заметная. */
  --line: #1d2c25;
  --line-strong: #2b4034;

  /* Текст: основной, приглушённый, служебный. */
  --text: #e7ede9;
  --text-muted: #90a49a;
  --text-faint: #61756b;

  /* Акцент — латунь. Деньги, активный ход, главное действие. */
  --brass: #d8b36a;
  --brass-soft: rgba(216, 179, 106, 0.16);
  --brass-line: rgba(216, 179, 106, 0.34);

  /* Служебные значения: отказ и успех. Только для текста и бейджей. */
  --danger: #d97066;
  --success: #6fce9b;

  /* Сукно и борт. */
  --felt: #14795a;
  --felt-deep: #0a4630;
  --rail: #4a2d1a;

  /* Типографика */
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --text-xs: 11px;
  --text-sm: 13px;
  --text-md: 15px;
  --text-lg: 18px;
  --text-xl: 22px;

  /* Тени: ровно две. */
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 12px 32px rgba(0, 0, 0, 0.45);

  /* Движение: две длительности и одна кривая. */
  --dur-1: 120ms;
  --dur-2: 200ms;
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);

  /* Размеры управляющих элементов */
  --control-h: 42px;
  --control-h-sm: 32px;

  --safe-b: env(safe-area-inset-bottom, 0px);
}

/* ── 2. База ────────────────────────────────────────────────────────────── */

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink-900);
  color: var(--text);
  font: 400 var(--text-md) / 1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body { display: flex; flex-direction: column; }

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: var(--text-xl); }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-lg); }

/* Деньги везде набираются моноширинными цифрами — колонки не пляшут. */
.bankroll, .chips__v, .seat__stack, .hero__stack, .actions__amount,
.table-card__blinds, .actions__clock { font-variant-numeric: tabular-nums; }

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::selection { background: var(--brass-soft); }

/* ── 3. Примитивы ───────────────────────────────────────────────────────── */

/* Кнопка. Вариантов ровно столько, сколько ролей: нейтральная, главная,
   бесшумная, отказ. Размеров два. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--control-h); padding: 0 var(--space-4);
  font: 600 var(--text-sm) / 1 var(--font);
  color: var(--text); background: var(--ink-700);
  border: 1px solid var(--line-strong); border-radius: var(--radius-md);
  cursor: pointer; white-space: nowrap; touch-action: manipulation;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease),
              color var(--dur-1) var(--ease), opacity var(--dur-1) var(--ease);
}
.btn:hover:not(:disabled) { background: var(--ink-600); border-color: #35513f; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.34; cursor: default; }

.btn--primary {
  background: var(--brass); border-color: var(--brass); color: #171104;
}
.btn--primary:hover:not(:disabled) { background: #e4c17c; border-color: #e4c17c; }

.btn--ghost { background: transparent; border-color: var(--line); color: var(--text-muted); }
.btn--ghost:hover:not(:disabled) { background: var(--ink-800); color: var(--text); }

.btn--tiny { min-height: var(--control-h-sm); padding: 0 var(--space-3); font-size: var(--text-xs); }

/* Панель — единственный контейнер в интерфейсе. */
.panel, .side, .actions, .hero, .table-card {
  background: var(--ink-800); border: 1px solid var(--line); border-radius: var(--radius-lg);
}

/* Поле ввода. */
.field, .dlg input, .dlg select, .chat input {
  min-height: var(--control-h); width: 100%;
  padding: 0 var(--space-3);
  background: var(--ink-900); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-md);
  font: 400 var(--text-sm) var(--font);
  transition: border-color var(--dur-1) var(--ease);
}
.field:focus, .dlg input:focus, .dlg select:focus, .chat input:focus { outline: none; border-color: var(--brass-line); }

/* Микро-подпись: единственное место, где используется разрядка. */
.pot__label, .actions__turn {
  font-size: var(--text-xs); letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-faint);
}

/* ── 4. Компоненты ──────────────────────────────────────────────────────── */

/* Шапка */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  padding-top: calc(var(--space-3) + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--line);
  background: var(--ink-900);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: var(--space-2); font-weight: 650; }
.brand__mark { color: var(--brass); font-size: var(--text-lg); }
.brand__name { letter-spacing: -0.01em; }
.topbar__right { display: flex; align-items: center; gap: var(--space-2); }

.chip-name {
  max-width: 140px; overflow: hidden; text-overflow: ellipsis;
  min-height: var(--control-h-sm); padding: 0 var(--space-3);
  background: transparent; color: var(--text); border: 1px solid var(--line);
  border-radius: var(--radius-pill); font: 500 var(--text-sm) var(--font); cursor: pointer;
}
.bankroll {
  min-height: var(--control-h-sm); display: inline-flex; align-items: center;
  padding: 0 var(--space-3); border-radius: var(--radius-pill);
  color: var(--brass); font-weight: 650; font-size: var(--text-sm);
  border: 1px solid var(--brass-line); background: var(--brass-soft);
}
.conn { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); flex: none; }
.conn[data-state="on"] { background: var(--success); }

/* Карта */
.card {
  width: 46px; height: 64px; border-radius: var(--radius-sm);
  background: #f5f3ec; color: #14161a;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font: 700 var(--text-lg) / 1 var(--font); box-shadow: var(--shadow-1);
}
.card--red { color: #b8352f; }
.card--back {
  background:
    repeating-linear-gradient(45deg, #1b3f66 0 5px, #16324f 5px 10px);
  border: 1px solid #0d2136; color: transparent;
}
.card__rank { font-size: var(--text-lg); }
.card__suit { font-size: var(--text-sm); opacity: 0.9; }
.card--sm { width: 30px; height: 42px; border-radius: 6px; }
.card--sm .card__rank { font-size: var(--text-sm); }
.card--sm .card__suit { font-size: 10px; }

/* Лобби */
main { flex: 1; min-height: 0; display: flex; }
.lobby { flex: 1; width: 100%; max-width: 880px; margin: 0 auto; padding: var(--space-5) var(--space-4) var(--space-6); }
.lobby__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-4); }
.lobby__list { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); }
.lobby__note { margin-top: var(--space-5); color: var(--text-faint); font-size: var(--text-sm); max-width: 62ch; }

.table-card {
  display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-4); text-align: left; color: inherit; font: inherit; cursor: pointer;
  transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
.table-card:hover { border-color: var(--line-strong); background: var(--ink-700); }
.table-card__top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); }
.table-card__name { font-weight: 650; }
.table-card__blinds { color: var(--brass); font-size: var(--text-sm); }
.table-card__meta { display: flex; flex-wrap: wrap; gap: var(--space-3); color: var(--text-faint); font-size: var(--text-sm); }

/* Экран стола */
.table-screen {
  flex: 1; min-height: 0; display: grid; gap: var(--space-3); padding: var(--space-3);
  grid-template-columns: minmax(0, 1fr) 300px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "head side" "felt side" "actions side";
}
.table-screen__head { grid-area: head; display: flex; align-items: center; gap: var(--space-3); }
.table-screen__head h2 {
  flex: 1; min-width: 0; font-size: var(--text-md); font-weight: 500; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.table-screen__tools { display: flex; gap: var(--space-2); align-items: center; }
.table-capacity {
  min-height: var(--control-h-sm); display: inline-flex; align-items: center;
  padding: 0 var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-pill);
  color: var(--brass); background: rgba(3, 10, 7, 0.48); font-size: var(--text-xs);
  white-space: nowrap;
}

/* Стол */
.table-stage {
  --floor-texture: url('/floors/casino-carpet-seamless.png');
  --scene-wall:
    radial-gradient(ellipse at 50% 16%, rgba(125, 33, 38, 0.34), transparent 42%),
    linear-gradient(180deg, #260b10, #0b0708 74%);
  --scene-decor:
    repeating-linear-gradient(90deg, transparent 0 12%, rgba(217, 164, 74, 0.07) 12.2%, transparent 12.4% 25%),
    radial-gradient(circle at 50% 35%, rgba(236, 186, 85, 0.2), transparent 26%);
  grid-area: felt; container-type: size;
  display: grid; place-items: center;
  position: relative; min-height: 360px; height: 100%; overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--scene-wall);
}
body[data-floor="parquet"] .table-stage {
  --floor-texture: url('/floors/walnut-parquet-seamless.png');
  --scene-wall:
    radial-gradient(circle at 50% 12%, rgba(38, 86, 60, 0.46), transparent 34%),
    linear-gradient(180deg, #10271c, #07120d 72%);
  --scene-decor:
    radial-gradient(circle at 17% 31%, rgba(255, 211, 105, 0.74) 0 2px, rgba(255, 190, 74, 0.18) 3px, transparent 54px),
    radial-gradient(circle at 83% 31%, rgba(255, 211, 105, 0.74) 0 2px, rgba(255, 190, 74, 0.18) 3px, transparent 54px),
    repeating-linear-gradient(90deg, transparent 0 14.8%, rgba(201, 162, 39, 0.07) 15%, transparent 15.2% 30%);
}
body[data-floor="slate"] .table-stage {
  --floor-texture: url('/floors/graphite-slate-seamless.png');
  --scene-wall:
    radial-gradient(ellipse at 50% 22%, rgba(24, 95, 136, 0.5), transparent 40%),
    linear-gradient(180deg, #071521, #040a10 72%);
  --scene-decor:
    linear-gradient(104deg, transparent 18%, rgba(88, 195, 255, 0.14) 18.3%, transparent 19.1%),
    linear-gradient(76deg, transparent 80%, rgba(88, 195, 255, 0.14) 80.3%, transparent 81.1%),
    radial-gradient(ellipse at 50% 72%, rgba(36, 142, 194, 0.22), transparent 38%);
}
.table-stage::before {
  content: ''; position: absolute; z-index: 0; inset: 0 0 45%; pointer-events: none;
  background: var(--scene-decor);
  box-shadow: inset 0 -1px rgba(220, 193, 119, 0.12);
}
.table-stage::after {
  content: ''; position: absolute; z-index: 0; left: -10%; right: -10%; top: 51%; bottom: -24%;
  pointer-events: none;
  background-image: linear-gradient(180deg, rgba(3, 8, 6, 0.08), rgba(3, 8, 6, 0.7)), var(--floor-texture);
  background-repeat: no-repeat, repeat;
  background-size: 100% 100%, 310px 310px;
  transform: perspective(520px) rotateX(47deg) scale(1.22); transform-origin: top center;
  filter: saturate(0.72) brightness(0.6);
}
/* Все слои живут на одном холсте 1536 × 1024. Меняется только общий масштаб:
   перспектива изображения и координаты DOM никогда не растягиваются раздельно. */
.table-canvas {
  position: relative; z-index: 1; container-type: inline-size;
  width: 100%;
  width: min(100cqw, 150cqh); aspect-ratio: 3 / 2;
  /* Переменные крупье живут здесь же: их читает и CSS, и плеер спрайта. */
  --dealer-width: 12.5cqw;
  /* Пропорции кадра из /dealer-v6/manifest.json: высота ÷ ширина. */
  --dealer-aspect: 2.079;
  /* Доля фигуры выше борта: она уходит за стол, ниже — руки поверх сукна. */
  --dealer-rail: 0.45;
  --dealer-top: 2.6cqw;
  --dealer-height: calc(var(--dealer-width) * var(--dealer-aspect));
}
.table-scene__image {
  position: absolute; z-index: 2; inset: 0;
  display: block; width: 100%; height: 100%; object-fit: contain;
  pointer-events: none; user-select: none;
  filter: drop-shadow(0 18px 24px rgba(0, 0, 0, 0.38));
}
.table-scene__image[hidden] { display: none; }
.felt {
  --dealer-y: 10%; --pot-y: 44%; --board-y: 52%;
  position: absolute; z-index: 3; inset: 0; width: 100%; height: 100%; min-height: 0;
  border: 0; border-radius: 0; background: none; box-shadow: none;
}
.felt::before, .felt::after { content: ''; position: absolute; pointer-events: none; }
/* Ворс сукна. */
.felt::before {
  display: none;
}
/* Линия ставок. */
.felt::after {
  display: none;
}

.felt__brand {
  position: absolute; left: 50%; top: 55%; transform: translate(-50%, -50%); z-index: 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: rgba(255, 255, 255, 0.06); pointer-events: none; user-select: none;
}
.felt__brand span:first-child { font-size: 64px; line-height: 1; }
.felt__brand span:last-child { font-size: var(--text-xs); letter-spacing: 0.4em; text-transform: uppercase; }

.dealer, .pot, .board, .seats, .fx { z-index: 1; }
.pot, .board, .dealer { position: absolute; left: 50%; transform: translate(-50%, -50%); }

.pot {
  top: var(--pot-y); display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  background: rgba(3, 10, 7, 0.55); border: 1px solid var(--line); border-radius: var(--radius-pill);
  color: var(--brass); font-weight: 650; font-size: var(--text-sm); white-space: nowrap;
}
.board { top: var(--board-y); display: flex; gap: var(--space-1); }
/* Борд чуть мельче карманных карт: между лотком крупье и нижним местом
   вертикали ровно столько, сколько нужно банку и пяти картам. */
.board .card { width: 40px; height: 56px; }
.board .card__rank { font-size: var(--text-md); }

/* Крупье: два окна одного спрайта. Верх уходит под столешницу,
   низ ложится поверх сукна — линия реза совпадает с бортом стола. */
.dealer-back {
  position: absolute; z-index: 3; left: 50%; top: var(--dealer-top);
  width: var(--dealer-width);
  height: calc(var(--dealer-height) * var(--dealer-rail));
  overflow: hidden; pointer-events: none;
  transform: translateX(-50%);
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.35));
}
.dealer {
  position: absolute; z-index: 3; left: 50%;
  top: calc(var(--dealer-top) + var(--dealer-height) * var(--dealer-rail));
  width: var(--dealer-width);
  height: calc(var(--dealer-height) * (1 - var(--dealer-rail)));
  overflow: hidden; pointer-events: none;
  transform: translateX(-50%);
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.3));
}
/* Кадр рисует canvas: он сам берёт из спрайта нужную половину,
   поэтому слою не нужно ни смещение, ни обрезка. */
.dealer__layer, .dealer__layer canvas {
  display: block; width: 100%; height: 100%;
}

/* Слой пролёта фишек и карт */
.fx { position: absolute; inset: 0; pointer-events: none; overflow: visible; z-index: 5; }

/* Место */
.seats { position: absolute; inset: 0; }
.seat {
  position: absolute; transform: translate(-50%, -50%); width: 132px;
  display: flex; flex-direction: column; align-items: center; gap: var(--space-1);
}
/* Место под карты держится всегда — иначе бокс подпрыгивал бы к раздаче. */
.seat__cards { display: flex; gap: 3px; min-height: 42px; }
.seat__box {
  width: 100%; padding: var(--space-2); text-align: center;
  background: rgba(4, 11, 8, 0.82); border: 1px solid var(--line);
  border-radius: var(--radius-md);
  transition: border-color var(--dur-2) var(--ease);
}
.seat--active .seat__box { border-color: var(--brass-line); background: rgba(9, 18, 13, 0.9); }
.seat--folded { opacity: 0.4; }
.seat--offline .seat__name::after { content: ' ·'; color: var(--danger); }
.seat__name {
  font-size: var(--text-sm); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.seat__stack { font-size: var(--text-sm); color: var(--brass); }
.seat__label {
  min-height: 15px; font-size: var(--text-xs); color: var(--text-faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.seat__label--win { color: var(--success); font-weight: 650; }

.seat__bet {
  position: absolute; top: -30px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: var(--space-1);
  padding: 2px var(--space-2) 2px var(--space-1);
  background: rgba(3, 10, 7, 0.6); border: 1px solid var(--brass-line);
  border-radius: var(--radius-pill); color: var(--brass);
}
.seat__bet.is-empty, .hero__bet.is-empty { visibility: hidden; }
.seat--upper .seat__bet { top: auto; bottom: -30px; }
.seat--left .seat__bet { top: 50%; left: auto; right: -6px; transform: translate(100%, -50%); }
.seat--right .seat__bet { top: 50%; left: -6px; right: auto; transform: translate(-100%, -50%); }
.seat__dealer {
  position: absolute; right: -4px; top: 50%; width: 22px; height: 22px;
  display: grid; place-items: center; border-radius: 50%;
  background: #efece1; color: #14201a; font-size: var(--text-xs); font-weight: 700;
  box-shadow: var(--shadow-1);
}
.seat--empty .seat__box {
  border-style: dashed; color: var(--text-faint); cursor: pointer;
  font: 500 var(--text-sm) var(--font);
}
.seat--empty .seat__box:disabled { cursor: default; }

/* Своё место на узком экране — верхняя строка панели действий. */
.hero {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 0 0 var(--space-2); min-height: 56px;
  background: none; border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
}
.hero__cards { display: flex; gap: var(--space-1); min-width: 96px; }
.hero__info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.hero__name { font-weight: 650; font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero__stack { color: var(--brass); font-weight: 650; }
.hero__label {
  min-height: 16px; font-size: var(--text-xs); color: var(--text-faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hero__bet {
  margin-left: auto; display: inline-flex; align-items: center; gap: var(--space-1);
  padding: var(--space-1) var(--space-3) var(--space-1) var(--space-2);
  background: rgba(3, 10, 7, 0.55); border: 1px solid var(--brass-line);
  border-radius: var(--radius-pill); color: var(--brass);
}

/* Панель действий: всегда на экране, недоступна вне своего хода. */
.actions {
  grid-area: actions; display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-3); padding-bottom: calc(var(--space-3) + var(--safe-b));
}
.actions__head { display: flex; align-items: center; justify-content: space-between; min-height: 16px; }
.actions--live .actions__turn { color: var(--brass); }
.actions__clock { font-size: var(--text-xs); color: var(--text-faint); }
.actions__timer { height: 2px; background: var(--line); border-radius: var(--radius-pill); overflow: hidden; }
.actions__timer span {
  display: block; height: 100%; width: 100%; background: var(--brass);
  transform-origin: left; transition: width var(--dur-2) linear;
}
.actions--idle .actions__timer span { background: var(--line-strong); }
.actions__row { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-2); }

.btn--fold { background: transparent; border-color: var(--line); color: var(--danger); }
.btn--fold:hover:not(:disabled) { background: rgba(217, 112, 102, 0.1); border-color: rgba(217, 112, 102, 0.4); }
.btn--check, .btn--call { background: var(--ink-700); }
.btn--raise { background: var(--brass); border-color: var(--brass); color: #171104; }
.btn--raise:hover:not(:disabled) { background: #e4c17c; border-color: #e4c17c; }

.actions__bet { display: flex; flex-direction: column; gap: var(--space-2); }
.actions__bet-controls { display: flex; align-items: center; gap: var(--space-3); }
.actions__amount { min-width: 72px; font-weight: 650; color: var(--brass); }
.actions__presets { display: flex; gap: var(--space-2); flex-wrap: wrap; }

#bet-slider {
  width: 100%; height: 24px; accent-color: var(--brass); cursor: pointer;
}
#bet-slider:disabled { cursor: default; opacity: 0.4; }

/* Лог и чат */
.side { grid-area: side; display: flex; flex-direction: column; gap: var(--space-2); min-height: 0; padding: var(--space-3); }
.log { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; font-size: var(--text-sm); }
.log__line { color: var(--text-faint); word-break: break-word; }
.log__line--system { color: var(--text-muted); }
.log__line--showdown { color: var(--brass); }
.log__line--chat { color: var(--text); }
.log__author { font-weight: 650; color: var(--text-muted); }
.chat { display: flex; gap: var(--space-2); }
.chat input { flex: 1; min-width: 0; }
.chat .btn { padding: 0 var(--space-3); }

/* Диалоги */
dialog {
  max-width: min(420px, 92vw); padding: 0; color: var(--text);
  background: var(--ink-800); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.62); }
.dlg { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-5); }
.dlg--wide { max-width: 92vw; }
.dlg label { display: flex; flex-direction: column; gap: var(--space-1); font-size: var(--text-sm); color: var(--text-muted); }
.dlg menu { display: flex; justify-content: flex-end; gap: var(--space-2); margin: 0; padding: 0; }
.dlg__hint { margin: 0; color: var(--text-faint); font-size: var(--text-sm); }
.fair {
  margin: 0; padding: var(--space-3); max-height: 46vh; overflow: auto;
  background: var(--ink-900); border: 1px solid var(--line); border-radius: var(--radius-md);
  font-size: var(--text-xs); white-space: pre-wrap; word-break: break-all; color: var(--text-muted);
}

/* Уведомление */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--space-5) + var(--safe-b));
  transform: translateX(-50%) translateY(8px);
  padding: var(--space-2) var(--space-4); max-width: 90vw; text-align: center;
  background: var(--ink-700); border: 1px solid var(--brass-line); border-radius: var(--radius-pill);
  color: var(--brass); font-size: var(--text-sm);
  opacity: 0; pointer-events: none; z-index: 50;
  transition: opacity var(--dur-2) var(--ease), transform var(--dur-2) var(--ease);
}
.toast--show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Фишки: одна геометрия, цвет номинала приходит из переменных внутрь <use>. */
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.chips { display: inline-flex; align-items: center; gap: var(--space-2); }
.chip-stack { display: inline-flex; align-items: center; }
.chip {
  --chip-body: #7a8a80;
  --chip-edge: #f3efe4;
  --chip-inlay: #f3efe4;
  --chip-ink: var(--chip-body);
  width: var(--chip-size, 20px); height: var(--chip-size, 20px);
  flex: none; display: block; filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.5));
}
.chip + .chip { margin-left: calc(var(--chip-size, 20px) * -0.42); }
.chip svg { display: block; width: 100%; height: 100%; }
.chips__v { font-weight: 650; font-size: var(--text-sm); }

/* Казино: канонический код номиналов. */
[data-chips="casino"] .chip[data-v="5"]    { --chip-body: #c8362c; }
[data-chips="casino"] .chip[data-v="25"]   { --chip-body: #2f9d5b; }
[data-chips="casino"] .chip[data-v="100"]  { --chip-body: #1b1d23; }
[data-chips="casino"] .chip[data-v="500"]  { --chip-body: #6f45a5; }
[data-chips="casino"] .chip[data-v="1000"] { --chip-body: #d7a521; --chip-edge: #3d2f09; --chip-ink: #6d5210; }
[data-chips="casino"] .chip[data-v="5000"] { --chip-body: #d4671d; }

/* Остров: палитра выведена из бренда, в центре пальма из иконки. */
[data-chips="island"] .chip[data-v="5"]    { --chip-body: #e3d4b0; --chip-edge: #8a7647; --chip-ink: #6d5a2e; }
[data-chips="island"] .chip[data-v="25"]   { --chip-body: #2a9c8c; }
[data-chips="island"] .chip[data-v="100"]  { --chip-body: #d2593a; }
[data-chips="island"] .chip[data-v="500"]  { --chip-body: #2f5aa8; }
[data-chips="island"] .chip[data-v="1000"] { --chip-body: #e8c46a; --chip-edge: #4a3a10; --chip-ink: #5f4a12; }
[data-chips="island"] .chip[data-v="5000"] { --chip-body: #191b21; --chip-edge: #e8c46a; --chip-ink: #e8c46a; }

/* Размер фишки по месту: банк крупнее ставок, ставки крупнее мест. */
.pot .chip { --chip-size: 22px; }
.hero__bet .chip { --chip-size: 20px; }
.seat__bet .chip { --chip-size: 16px; }

/* Индикатор выбранной стилистики в кнопке. */
.chip-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #c8362c; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25) inset;
}
[data-chips="island"] .chip-dot { background: #2a9c8c; }

/* ── 6. Адаптив ─────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .table-screen {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(220px, 1fr) auto auto;
    grid-template-areas: "head" "felt" "actions" "side";
    padding: var(--space-2); gap: var(--space-2); overflow-y: auto;
  }
  .table-stage {
    min-height: 220px;
  }
  .felt {
    min-height: 0;
  }
  .felt__brand span:first-child { font-size: 40px; }

  /* Карточка места на телефоне: только имя, стек и ставка — подпись действия
     всё равно дублируется в логе, а высота места здесь на вес золота. */
  .seat { width: 68px; }
  .seat__box { padding: var(--space-1) 5px; }
  .seat__cards { min-height: 34px; }
  .seat .card--sm { width: 24px; height: 34px; }
  .seat__label { display: none; }
  .seat__name, .seat__stack { font-size: var(--text-xs); }
  .seat__dealer { width: 18px; height: 18px; right: -2px; }

  /* Ставка встаёт под боксом в самой колонке места: строка под неё
     зарезервирована всегда, поэтому бокс не сдвигается, когда ставка есть. */
  .seat__bet {
    position: static; transform: none; margin-top: 2px;
    min-height: 18px; padding: 0 var(--space-2) 0 var(--space-1);
  }
  .seat__bet .chip { --chip-size: 12px; }
  .seat__bet .chips { gap: var(--space-1); }
  .seat__bet .chips__v { font-size: var(--text-xs); }

  .board { gap: 3px; }
  .board .card { width: 24px; height: 34px; }
  .board .card__rank { font-size: var(--text-xs); }
  .board .card__suit { font-size: 9px; }

  .actions { padding: var(--space-2); padding-bottom: calc(var(--space-2) + var(--safe-b)); }
  /* Слайдер и пресеты в одной строке — панель ниже, столу больше высоты. */
  .actions__bet-controls { gap: var(--space-2); }
  .hero__cards { min-width: 0; }
  .hero { min-height: 48px; }
  .side { max-height: 16vh; }
  .brand__name { display: none; }
}

@media (max-width: 560px) {
  .table-screen__head h2 { display: none; }
  .table-screen__head .btn { padding: 0 var(--space-3); font-size: var(--text-xs); min-height: 36px; }
  .seat { width: 74px; }
  .seat__name, .seat__stack { font-size: var(--text-xs); }
  .lobby__list { grid-template-columns: 1fr; }
  .actions__row { gap: 6px; }
  .actions__row .btn { padding: 0 var(--space-1); }
  .actions__presets [data-size="0.75"] { display: none; }
  /* На узком столе подпись банка лишняя: фишки и сумма говорят сами за себя. */
  .pot__label { display: none; }
  .pot { padding: var(--space-1) var(--space-2); }
  .side { max-height: 15vh; }
}

/* Альбомный телефон: лог убираем, стол занимает экран. */
@media (max-height: 480px) and (orientation: landscape) {
  .side { display: none; }
  .topbar { padding: var(--space-1) var(--space-3); }
  .seat__cards { min-height: 30px; }
  .card--sm { width: 24px; height: 33px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Стол и контролы: плотность
   Размеры мест и карт зависят от ширины самого стола, а координаты кресел
   остаются фиксированными в процентах холста. Плотность выставляет JS
   (ResizeObserver → data-density).
   ═════════════════════════════════════════════════════════════════════════ */

.felt[data-density] {
  --seat-w: 132px;
  --seat-avatar: 34px;
  --seat-card-w: 30px;
  --seat-card-h: 42px;
  --board-card-w: 40px;
  --board-card-h: 56px;
}
.felt[data-density="regular"] {
  --seat-w: 108px; --seat-avatar: 28px;
  --seat-card-w: 26px; --seat-card-h: 36px;
  --board-card-w: 32px; --board-card-h: 45px;
}
.felt[data-density="compact"] {
  --seat-w: 76px; --seat-avatar: 0px;
  --seat-card-w: 22px; --seat-card-h: 31px;
  --board-card-w: 26px; --board-card-h: 36px;
}

/* ── Место ──────────────────────────────────────────────────────────────── */

.seat { width: var(--seat-w); gap: 3px; }
.seat__cards { min-height: var(--seat-card-h); gap: 2px; }
.seat .card--sm { width: var(--seat-card-w); height: var(--seat-card-h); }
.seat .card--sm .card__rank { font-size: 12px; }
.seat .card--sm .card__suit { font-size: 9px; }

/* Карты смотрят к центру: у нижних мест лежат над карточкой, у верхних — под. */
.seat--upper { flex-direction: column-reverse; }
.seat--left:not(.seat--empty), .seat--right:not(.seat--empty) {
  width: calc(var(--seat-w) + var(--seat-card-w) + var(--seat-card-w) + 8px);
}
.seat--left:not(.seat--empty) {
  flex-direction: row-reverse;
  transform: translate(calc(-50% + var(--seat-card-w) + 1px), -50%);
}
.seat--right:not(.seat--empty) {
  flex-direction: row;
  transform: translate(calc(-50% - var(--seat-card-w) - 1px), -50%);
}
.seat--left:not(.seat--empty) .seat__box,
.seat--right:not(.seat--empty) .seat__box { flex: none; width: var(--seat-w); }
.seat--left:not(.seat--empty) .seat__cards,
.seat--right:not(.seat--empty) .seat__cards {
  flex: none; min-width: calc(var(--seat-card-w) + var(--seat-card-w) + 2px); min-height: 0;
}

.seat__box {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: var(--space-2);
  width: 100%; padding: 5px var(--space-2); text-align: left;
  background: linear-gradient(180deg, rgba(14, 26, 20, 0.94), rgba(6, 13, 10, 0.94));
  border: 1px solid var(--line); border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
}
.seat--active .seat__box { border-color: var(--brass-line); }

.seat__avatar {
  flex: none; width: var(--seat-avatar); height: var(--seat-avatar);
  display: grid; place-items: center; border-radius: 50%;
  background: hsl(var(--avatar-hue, 150) 32% 26%);
  border: 1px solid hsl(var(--avatar-hue, 150) 34% 42%);
  color: #f2efe6; font-size: var(--text-sm); font-weight: 650;
}
.felt[data-density="compact"] .seat__avatar { display: none; }

.seat__info { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.seat__name {
  font-size: var(--text-sm); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.seat__stack { font-size: var(--text-sm); color: var(--brass); font-weight: 650; }
.seat__label {
  min-height: 14px; font-size: var(--text-xs); color: var(--text-faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.seat__label--win { color: var(--success); font-weight: 650; }
.felt[data-density="compact"] .seat__name,
.felt[data-density="compact"] .seat__stack { font-size: var(--text-xs); }
.felt[data-density="compact"] .seat__label { display: none; }

/* Время хода видно прямо на месте. */
.seat__turn {
  position: absolute; left: 0; bottom: 0; height: 2px; width: 0;
  background: var(--brass); transition: width var(--dur-2) linear;
}

.seat__dealer {
  width: 20px; height: 20px; right: -6px; top: 50%;
  background: #f0ede2; color: #131d18; font-size: 11px;
}
.seat--right .seat__dealer { right: auto; left: -6px; }

.seat--empty .seat__box {
  justify-content: center; min-height: 44px;
  background: rgba(4, 11, 8, 0.5); border-style: dashed;
  color: var(--text-faint); font: 500 var(--text-sm) var(--font);
}

/* ── Ставка ─────────────────────────────────────────────────────────────── */

.seat__bet {
  position: absolute; z-index: 2; display: flex; align-items: center; gap: var(--space-1);
  padding: 1px var(--space-2) 1px var(--space-1); white-space: nowrap;
  background: rgba(3, 10, 7, 0.72); border: 1px solid var(--brass-line);
  border-radius: var(--radius-pill); color: var(--brass);
}
.seat__bet .chip { --chip-size: 14px; }
.seat__bet .chips__v { font-size: var(--text-xs); }
/* Фишки всегда между игроком и банком. */
.seat--lower .seat__bet { top: -12px; bottom: auto; left: 50%; right: auto; transform: translate(-50%, -100%); }
.seat--upper .seat__bet { top: auto; bottom: -12px; left: 50%; right: auto; transform: translate(-50%, 100%); }
.seat--left .seat__bet { top: 50%; bottom: auto; left: auto; right: -8px; transform: translate(100%, -50%); }
.seat--right .seat__bet { top: 50%; bottom: auto; left: -8px; right: auto; transform: translate(-100%, -50%); }
.felt[data-density="compact"] .seat--left .seat__bet,
.felt[data-density="compact"] .seat--right .seat__bet {
  top: auto; bottom: -10px; left: 50%; right: auto; transform: translate(-50%, 100%);
}

/* ── Борд ───────────────────────────────────────────────────────────────── */

.board .card { width: var(--board-card-w); height: var(--board-card-h); }
.board .card__rank { font-size: var(--text-md); }
.felt[data-density="compact"] .board .card__rank { font-size: var(--text-xs); }
.felt[data-density="compact"] .board .card__suit { font-size: 9px; }

/* ═══════════════════════════════════════════════════════════════════════════
   Панель действий
   Сначала размер ставки, потом кнопки: кнопки внизу — ближе к большому пальцу.
   ═════════════════════════════════════════════════════════════════════════ */

.actions[data-density] { --action-h: 46px; }
.actions[data-density="compact"] { --action-h: 48px; }

.actions__sizing { display: flex; flex-direction: column; gap: var(--space-2); }
.actions__presets { display: flex; gap: var(--space-2); }
.preset {
  flex: 1; min-height: var(--control-h-sm); padding: 0 var(--space-2);
  font: 500 var(--text-xs) var(--font); color: var(--text-muted);
  background: transparent; border: 1px solid var(--line); border-radius: var(--radius-sm);
  cursor: pointer; white-space: nowrap;
  transition: color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.preset:hover:not(:disabled) { color: var(--text); border-color: var(--line-strong); }
.preset:disabled { opacity: 0.32; cursor: default; }

.actions__amount-row { display: flex; align-items: center; gap: var(--space-3); }
.actions__input {
  flex: none; width: 104px; min-height: var(--control-h-sm); padding: 0 var(--space-2);
  background: var(--ink-900); color: var(--brass); border: 1px solid var(--line);
  border-radius: var(--radius-sm); font: 650 var(--text-sm) var(--font);
  font-variant-numeric: tabular-nums; text-align: center;
}
.actions__input:focus { outline: none; border-color: var(--brass-line); }
.actions__input:disabled { color: var(--text-faint); }
.actions__slider { flex: 1; min-width: 0; height: 24px; accent-color: var(--brass); cursor: pointer; }
.actions__slider:disabled { cursor: default; opacity: 0.4; }

.actions__row { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-2); }
.actions__row .btn { min-height: var(--action-h); position: relative; }

/* Горячая клавиша подписана на кнопке — но не мешает читать саму подпись. */
.btn__key {
  position: absolute; top: 4px; right: 6px;
  font: 500 9px/1 var(--font); color: currentColor; opacity: 0.42;
}
.actions[data-density="compact"] .btn__key { display: none; }
.actions[data-density="compact"] .preset { font-size: 10px; padding: 0 var(--space-1); }
.actions[data-density="compact"] .actions__input { width: 84px; }

/* Контролы не растягиваются на всю ширину монитора: рука работает в пределах
   одного блока, а не через весь экран. */
.actions__sizing, .actions__row { width: 100%; max-width: 620px; margin-left: auto; }
.actions[data-density="compact"] .actions__sizing,
.actions[data-density="compact"] .actions__row { max-width: none; }

/* Полоса времени идёт над самими кнопками, а не через всю панель: взгляд
   связывает её с тем, на что она влияет. */
.actions__timer { width: 100%; max-width: 620px; margin-left: auto; }
.actions[data-density="compact"] .actions__timer { max-width: none; }

/* ═══════════════════════════════════════════════════════════════════════════
   Раскладка экрана стола
   Стол занимает всю площадь; действия и лог лежат поверх него по углам, как в
   покерных клиентах. Лог свёрнут до нескольких строк и разворачивается по
   клику — он справочный, а не главный элемент экрана.
   ═════════════════════════════════════════════════════════════════════════ */

@media (min-width: 901px) {
  .table-screen {
    display: flex; flex-direction: column; position: relative;
    gap: var(--space-2); padding: var(--space-3);
  }
  .table-screen__head { flex: none; }
  /* Нижний отступ равен высоте наложений: стол под ними не прячется. */
  .table-stage { flex: 1; min-height: 0; padding-bottom: 138px; }

  .side, .actions {
    position: absolute; bottom: var(--space-3); z-index: 6;
    background: rgba(5, 12, 9, 0.82);
    backdrop-filter: blur(10px);
  }
  .side { left: var(--space-3); width: 320px; }
  .actions { right: var(--space-3); width: min(560px, 46vw); }
  .actions__sizing, .actions__row, .actions__timer { max-width: none; margin-left: 0; }
}

/* ── Лог и чат ──────────────────────────────────────────────────────────── */

.side { padding: var(--space-2); gap: var(--space-2); }
.side__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  background: none; border: 0; padding: 0 var(--space-1); cursor: pointer;
  color: var(--text-faint); font: 500 var(--text-xs) var(--font);
  letter-spacing: 0.08em; text-transform: uppercase;
}
.side__head:hover { color: var(--text-muted); }
.side__chevron { transition: transform var(--dur-2) var(--ease); }
.side--expanded .side__chevron { transform: rotate(180deg); }

.log {
  max-height: 132px; font-size: var(--text-xs); line-height: 1.5;
  scrollbar-width: thin;
}
.side--expanded .log { max-height: 46vh; }
.chat input { min-height: var(--control-h-sm); font-size: var(--text-xs); }
.chat .btn { min-height: var(--control-h-sm); }

@media (max-width: 900px) {
  .side { max-height: none; }
  .log { max-height: 96px; }
  .side--expanded .log { max-height: 40vh; }
}

/* Панель действий — главный элемент управления, поэтому она заметнее прочих
   наложений: выше кнопки, чёткая рамка, собственная тень. */
@media (min-width: 901px) {
  .actions { --action-h: 52px; border-color: var(--line-strong); box-shadow: var(--shadow-2); }
  .actions--live { border-color: var(--brass-line); }
  .side { border-color: var(--line); }
}

/* На телефоне игра важнее переписки: лог свёрнут до трёх строк, поле ввода
   появляется только когда лог развёрнут, панель действий подобрана плотнее. */
@media (max-width: 900px) {
  .side { padding: var(--space-1) var(--space-2); gap: var(--space-1); }
  .log { max-height: 52px; }
  .side:not(.side--expanded) .chat { display: none; }
  .side--expanded .log { max-height: 34vh; }

  .actions { gap: 6px; padding: 6px var(--space-2); padding-bottom: calc(6px + var(--safe-b)); }
  .hero { min-height: 44px; padding-bottom: 6px; }
  .actions__sizing { gap: 6px; }
  .actions__amount-row { gap: var(--space-2); }
}
