/* © 2026 dezignet. Все права защищены. Копировать и использовать этот код без разрешения автора запрещено. */
/* ==========================================================
   ТОКЕНЫ: цвета, размеры и шрифты меняются только здесь
   ========================================================== */
:root {
  /* Поверхности: фон, панель, приподнятый элемент */
  --bg-main: #071a17;
  --surface-1: #0f2f29;
  --surface-2: #173f36;
  --surface-chip: rgba(7, 26, 23, 0.86);
  --surface-hover: #1f4c42;
  --avatar-bg: linear-gradient(145deg, #2b5a4e, #123229);
  --overlay-bg: rgba(4, 16, 13, 0.86);
  --screen-glow: rgba(43, 141, 110, 0.5);

  /* Стол: шум сукна общий для всех тем, цвет задаёт градиент */
  --felt-noise:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.95' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='.34'/%3E%3C/svg%3E");
  --felt: var(--felt-noise), radial-gradient(ellipse 72% 58% at 50% 43%, #2b8d6e 0%, #186450 48%, #0c4336 78%, #072c24 100%);
  --table-rim: #3a2413;
  --table-rim-light: #6b4524;

  /* Акцент и статусы: золото — главное действие, зелёный и красный — только смысл */
  --gold: #f2c75c;
  --gold-hover: #f7d680;
  --gold-deep: #a97a1f;
  --accent-rgb: 242, 199, 92;
  --danger: #8f1d31;
  --danger-hover: #a8263d;
  /* Пірік: синий, чтобы не путать с красными предупреждениями */
  --pirik-blue: #2f6bd8;
  --pirik-blue-glow: rgba(70, 140, 255, 0.85);
  --good: #6ee7a8;
  --bad: #ff8d7a;

  /* Текст */
  --text: #f3efe3;
  --text-muted: #b9cec5;
  --text-on-gold: #2a1c05;

  /* Линии */
  --line: rgba(243, 239, 227, 0.2);
  --line-focus: var(--gold);

  /* Карты */
  --card-face: #fffdf8;
  --suit-red: #c4192d;
  --suit-black: #17252b;
  --suit-red-dark: #ff9a8f;
  --card-w: 74px;
  --card-h: 108px;
  /* Карты в руке крупные: нижняя часть веера уходит за край экрана, значки видны сверху */
  --user-card-w: 151px;
  --user-card-h: 219px;
  --user-card-overlap: -65px;
  --avatar: 63px;
  --card-radius: 8px;
  /* Карты взятки в центре: в полтора раза крупнее, чтобы за ходами было легко следить */
  --table-card-w: min(calc(var(--card-w) * 1.5), 88px);
  --table-card-h: calc(var(--table-card-w) * 1.46);
  /* Козырь и Пірік на столе: на 15% крупнее обычной карты, чтобы козырь было легко разглядеть */
  --stack-card-w: calc(var(--card-w) * 1.15);
  --stack-card-h: calc(var(--card-h) * 1.15);

  /* Рубашка: мелкая синяя сетка с белой каймой, как у классической колоды */
  --card-back-color: #1c3f91;
  --card-back: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Crect width='12' height='12' fill='%231c3f91'/%3E%3Cpath d='M0 0l12 12M12 0L0 12' stroke='%23dfe8ff' stroke-width='.65'/%3E%3Ccircle cx='6' cy='0' r='1' fill='%23fff'/%3E%3Ccircle cx='6' cy='12' r='1' fill='%23fff'/%3E%3Ccircle cx='0' cy='6' r='1' fill='%23fff'/%3E%3Ccircle cx='12' cy='6' r='1' fill='%23fff'/%3E%3C/svg%3E");

  /* Типографика */
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-card: Georgia, "Times New Roman", serif;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 17px;

  /* Прочее */
  --tap: 44px;
  /* Скругления: плашки 6, кнопки и поля 10, окна 14 */
  --radius-chip: 6px;
  --radius-control: 10px;
  --radius-panel: 14px;
  --control-h: 40px;
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.5);
  --ease: cubic-bezier(0.2, 0.9, 0.4, 1);
  --header-height: 52px;
}

/* ==========================================================
   ТЕМЫ СТОЛА (выбираются в настройках и профиле)
   ========================================================== */
/* Бордо: винное сукно и шампанское */
html[data-theme="bordo"] {
  --bg-main: #19080b;
  --surface-1: #2d1015;
  --surface-2: #44171f;
  --surface-chip: rgba(25, 8, 11, 0.86);
  --surface-hover: #561e28;
  --avatar-bg: linear-gradient(145deg, #6b2b35, #2d0f15);
  --overlay-bg: rgba(18, 5, 8, 0.88);
  --screen-glow: rgba(160, 58, 69, 0.5);
  --felt: var(--felt-noise), radial-gradient(ellipse 72% 58% at 50% 43%, #a03a45 0%, #77202d 48%, #4b111b 78%, #2a060c 100%);
  --table-rim: #2b170d;
  --table-rim-light: #5e3b1f;
  --gold: #ecd09a;
  --gold-hover: #f4dfb5;
  --gold-deep: #a5803f;
  --accent-rgb: 236, 208, 154;
  --text-on-gold: #3a0d14;
  --text-muted: #dcc3c6;
  --danger: #b3263b;
  --danger-hover: #c93049;
}
/* Көк: тёмно-синее сукно и серебро */
html[data-theme="kok"] {
  --bg-main: #07111f;
  --surface-1: #0f1f36;
  --surface-2: #172c4a;
  --surface-chip: rgba(7, 17, 31, 0.86);
  --surface-hover: #1f3a60;
  --avatar-bg: linear-gradient(145deg, #2e5280, #10233f);
  --overlay-bg: rgba(4, 10, 20, 0.88);
  --screen-glow: rgba(50, 112, 176, 0.5);
  --felt: var(--felt-noise), radial-gradient(ellipse 72% 58% at 50% 43%, #3270b0 0%, #1f4e86 48%, #12325e 78%, #091c38 100%);
  --table-rim: #2a1c11;
  --table-rim-light: #5c4127;
  --gold: #e3e9f1;
  --gold-hover: #f3f6fa;
  --gold-deep: #8b97a8;
  --accent-rgb: 227, 233, 241;
  --text-on-gold: #0f1f36;
  --text-muted: #bccbdf;
  --pirik-blue: #4c95ff;
  --pirik-blue-glow: rgba(120, 180, 255, 0.95);
}
/* Графит: угольное сукно и янтарь */
html[data-theme="graphite"] {
  --bg-main: #0e1012;
  --surface-1: #1b1e22;
  --surface-2: #272b31;
  --surface-chip: rgba(14, 16, 18, 0.86);
  --surface-hover: #31363d;
  --avatar-bg: linear-gradient(145deg, #4c525a, #1e2226);
  --overlay-bg: rgba(8, 9, 11, 0.9);
  --screen-glow: rgba(120, 128, 140, 0.4);
  --felt: var(--felt-noise), radial-gradient(ellipse 72% 58% at 50% 43%, #5b6169 0%, #3e4349 48%, #272b30 78%, #15181b 100%);
  --table-rim: #1d1a17;
  --table-rim-light: #4a4239;
  --gold: #eaa65c;
  --gold-hover: #f2bb7f;
  --gold-deep: #9b6428;
  --accent-rgb: 234, 166, 92;
  --text-on-gold: #2a1606;
  --text-muted: #bcc2c9;
}

/* ==========================================================
   БАЗА
   ========================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-main);
  color: var(--text);
  font-family: var(--font-ui);
  display: flex;
  flex-direction: column;
  touch-action: manipulation;
}

button { font-family: inherit; }
button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ==========================================================
   КНОПКИ: одна форма, три роли
   ========================================================== */
.btn {
  height: var(--control-h);
  min-width: var(--control-h);
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 0 0 auto;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: none;
  color: var(--text);
  font-size: var(--fs-md);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.42; cursor: not-allowed; }

.btn-primary { background: var(--gold); color: var(--text-on-gold); }
.btn-primary:hover:not(:disabled) { background: var(--gold-hover); }
.btn-secondary { background: var(--surface-2); border-color: var(--line); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn-ghost:hover:not(:disabled) { background: rgba(243, 239, 227, 0.08); }
.btn-icon { width: var(--control-h); padding: 0; font-size: 18px; }
.btn-icon svg { width: 24px; height: 24px; display: block; }
.btn.is-active { border-color: var(--gold); color: var(--gold); }

.app-header .btn { --control-h: 40px; }
.app-header .btn:not(.btn-icon):not(.menu-item) { padding: 0 9px; font-size: var(--fs-sm); }
.app-menu .btn { --control-h: 44px; }
.action-bar .btn { --control-h: 44px; }

/* Общие плашки и подписи */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: var(--radius-chip);
  background: var(--surface-chip);
  color: var(--text);
  font-size: var(--fs-xs);
  font-weight: 700;
}
.chip-good { color: var(--good); }
.section-title { color: var(--gold); font-size: var(--fs-md); font-weight: 700; }
.option-title { color: var(--text); font-size: var(--fs-sm); font-weight: 700; }
.hint { color: var(--text-muted); font-size: var(--fs-xs); line-height: 1.35; }
.hint.note { display: block; margin-top: 8px; }
.row-between, .settings-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.settings-row { padding: 9px 10px; border-radius: var(--radius-control); background: var(--surface-chip); }
.row-inline { display: flex; align-items: center; gap: 5px; }
.volume-row { display: flex; align-items: center; gap: 8px; }
.volume-row input { flex: 1; accent-color: var(--gold); }
.stake-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.stake-options { display: flex; flex-wrap: wrap; gap: 4px; }
.player-select-btn.stake-option { min-height: var(--control-h); flex-direction: row; padding: 0 12px; }
#log-container-body { display: flex; flex-direction: column; gap: 4px; max-height: 55vh; }
.scoresheet-table-wrap.modal-table { max-height: 55vh; flex: 0 1 auto; }
.modal-body h3 { color: var(--gold); font-size: var(--fs-md); margin-top: 10px; }
.modal-body ul { padding-left: 16px; }
.modal-centered { text-align: center; }
.modal-centered .modal-header, .modal-centered .modal-footer { justify-content: center; }
#choice-footer, .modal-centered .modal-footer { flex-wrap: wrap; }

/* ==========================================================
   ШАПКА И МЕНЮ
   ========================================================== */
/* Название по центру, кон, банк и скорость слева, язык и меню справа */
.app-header {
  flex: 0 0 calc(var(--header-height) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 10px 0;
  background: var(--surface-1);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  column-gap: 8px;
  position: relative;
  z-index: 1000;
}

.header-left { justify-self: start; display: flex; align-items: center; gap: 5px; min-width: 0; }
.brand-box { justify-self: center; display: flex; align-items: center; gap: 5px; min-width: 0; }
.brand-box .brand-icon { font-size: 30px; color: var(--gold); }
.brand-box h1 {
  font-size: calc(var(--fs-lg) * 1.5);
  font-weight: 900;
  letter-spacing: 1px;
  line-height: 1;
  color: var(--gold);
}
.header-author-badge {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text-muted);
  margin-left: 4px;
  white-space: nowrap;
}

.header-status { gap: 6px; padding: 0 8px; }
.header-round-pill { color: var(--gold); }
.header-bank { color: var(--text); }

.header-actions { justify-self: end; display: flex; align-items: center; gap: 5px; flex-shrink: 0; }


.app-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 8px;
  width: 220px;
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-md);
}
.app-menu.open { display: flex; animation: menu-in 0.16s var(--ease); }
@keyframes menu-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.menu-author {
  padding: 6px 10px 8px;
  margin-bottom: 2px;
  border-bottom: 1px solid var(--line);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 700;
}

.menu-item { width: 100%; justify-content: flex-start; gap: 10px; padding: 0 10px; }
.menu-item-accent { color: var(--gold); }
.tab-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tab-icon.is-muted { opacity: 0.4; }
.tab-icon.is-live { color: var(--good); }

/* ==========================================================
   РАСКЛАДКА
   ========================================================== */
.main-screen-layout {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  display: flex;
  position: relative;
  overflow: hidden;
}

.scoreboard-sidebar {
  width: 270px;
  flex-shrink: 0;
  height: 100%;
  min-height: 0;
  background: var(--surface-1);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 8px;
  z-index: 20;
  overflow: hidden;
}

.sidebar-card {
  flex: 1 1 0;
  min-height: 0;
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  padding: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-card-title {
  flex-shrink: 0;
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--gold);
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
}

.round-indicator-pill {
  color: var(--gold);
  font-size: var(--fs-xs);
  font-weight: 700;
  white-space: nowrap;
}

.header-players-count {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  text-transform: none;
}

/* Таблица счёта */
.scoresheet-table-wrap {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-chip);
  background: var(--surface-chip);
}
.scoresheet-table-wrap::-webkit-scrollbar { width: 4px; height: 4px; }
.scoresheet-table-wrap::-webkit-scrollbar-thumb { background: var(--line); border-radius: var(--radius-chip); }

.scoresheet-table {
  width: 100%;
  border-collapse: collapse;
  text-align: center;
  font-size: var(--fs-xs);
  table-layout: fixed;
}
.scoresheet-table th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  color: var(--gold);
  padding: 5px 2px;
  font-weight: 700;
  border-bottom: 1px solid var(--line);
  z-index: 2;
}
.scoresheet-table th .th-player-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}
.scoresheet-table td {
  padding: 4px 1px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text);
}
.scoresheet-table tr:nth-child(even) { background: rgba(255, 255, 255, 0.025); }
.scoresheet-table .round-col {
  font-weight: 700;
  color: var(--text-muted);
  border-right: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
  width: 42px;
}
.scoresheet-table .total-row {
  position: sticky;
  bottom: 0;
  background: var(--surface-2);
  font-weight: 700;
  border-top: 2px solid var(--gold);
  color: var(--gold);
  font-size: var(--fs-sm);
}
.delta-val { font-size: var(--fs-xs); display: block; }
.delta-val.green { color: var(--good); }
.delta-val.red { color: var(--bad); }

/* ==========================================================
   СТОЛ
   ========================================================== */
.playfield-container {
  flex: 1 1 0;
  height: 100%;
  min-height: 0;
  width: 100%;
  position: relative;
  background: var(--felt);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: 0 6px 2px;
}

.felt-board {
  position: absolute;
  inset: 4px;
  border: 7px solid var(--table-rim);
  border-radius: 34px;
  box-shadow: inset 0 0 0 1px var(--table-rim-light), inset 0 8px 22px rgba(0, 0, 0, 0.5), inset 0 0 70px rgba(0, 0, 0, 0.42), 0 0 0 1px #1d1109;
  pointer-events: none;
  overflow: hidden;
}

.zone-1-top {
  flex: 0 0 auto;
  width: 100%;
  min-height: 52px;
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  padding: 14px 8px 0;
  z-index: 10;
  position: relative;
}

/* Отступы над верхними и под нижними игроками. Когда высоты мало, они сжимаются первыми */
.table-spacer { flex: 0 1 0; min-height: 0; }
.spacer-top { flex-basis: 12px; }
.spacer-bottom { flex-basis: 50px; }

.zone-2-center.cards-moving { z-index: 30; }

.zone-2-center {
  flex: 1 1 0;
  min-height: calc(var(--table-card-h) * 1.62 + 8px);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 15;
  position: relative;
}

/* Нижние игроки по краям, между ними банк и подсказка — на одном уровне с ними */
.zone-3-mid-lower {
  flex: 0 0 auto;
  width: 100%;
  min-height: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  margin-bottom: 18px;
  z-index: 10;
  position: relative;
}
.table-info {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  pointer-events: none;
}

.zone-4-bottom {
  flex: 0 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  z-index: 25;
  padding-bottom: max(4px, env(safe-area-inset-bottom, 0px));
  position: relative;
}

/* Центр: поле взятки */
.trick-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.arena-wrap { position: relative; flex: 0 0 auto; }

/* Подсказка: только обводка, чтобы не спорить с плашками имён. Ширина — до мест нижних игроков */
.user-notice-toast {
  position: relative;
  z-index: 35;
  max-width: 100%;
  min-height: 26px;
  padding: 4px 12px;
  border-radius: var(--radius-control);
  border: 1px solid rgba(243, 239, 227, 0.36);
  background: transparent;
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
  pointer-events: none;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.user-notice-toast:empty { display: none; }
.user-notice-toast.your-turn {
  border-color: var(--gold);
  color: var(--gold);
  animation: turn-glow 1.2s ease-in-out infinite alternate;
}
@keyframes turn-glow {
  from { box-shadow: 0 0 0 rgba(var(--accent-rgb), 0); }
  to { box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.55); }
}

.trick-arena {
  position: relative;
  width: calc(var(--table-card-w) * 2.6);
  height: calc(var(--table-card-h) * 1.62);
  pointer-events: none;
}

.trick-slot {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: all 0.3s ease;
}

/* Колода у раздающего: координаты центра задаёт showDeck */
#deck-source {
  position: fixed;
  width: var(--card-w);
  height: var(--card-h);
  margin: calc(var(--card-h) / -2) 0 0 calc(var(--card-w) / -2);
  pointer-events: none;
  z-index: 990;
  display: none;
}
#deck-source.visible { display: block; }
#deck-source .card { position: absolute; inset: 0; margin: 0; }
#deck-source.shuffling .riffle-left { animation: riffle-left var(--riffle-ms, 700ms) ease-in-out; }
#deck-source.shuffling .riffle-right { animation: riffle-right var(--riffle-ms, 700ms) ease-in-out; }
@keyframes riffle-left {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  30% { transform: translate(-58%, 3px) rotate(-11deg); }
  62% { transform: translate(-30%, 0) rotate(-5deg); }
}
@keyframes riffle-right {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  30% { transform: translate(58%, 3px) rotate(11deg); }
  62% { transform: translate(30%, 0) rotate(5deg); }
}

/* Банк стопкой монет */
.bank-stack {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 24px;
  color: var(--gold);
  font-size: var(--fs-sm);
  font-weight: 700;
}
.coin-pile { display: inline-flex; flex-direction: column-reverse; height: 22px; justify-content: flex-start; }
.coin-pile .coin {
  width: 22px;
  height: 7px;
  margin-top: -4px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffe08a, #c8912a);
  border: 1px solid #80591a;
  flex: 0 0 auto;
}

/* Стопки козыря и Піріка */
.side-stack-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  pointer-events: auto;
  flex-shrink: 0;
}
.stack-title-pill {
  padding: 1px 6px;
  border-radius: var(--radius-chip);
  background: var(--surface-chip);
  color: var(--text);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
}
.pirik-taken-placeholder {
  width: var(--stack-card-w);
  height: var(--stack-card-h);
  border: 1.5px dashed var(--line);
  border-radius: var(--card-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2px;
  font-weight: 700;
  font-size: var(--fs-xs);
  letter-spacing: -0.2px;
  color: var(--gold);
  background: rgba(0, 0, 0, 0.28);
  overflow: hidden;
  white-space: nowrap;
  line-height: 1.2;
}

.pirik-taken-placeholder span { display: inline-block; flex-shrink: 0; }

/* ==========================================================
   МЕСТА ИГРОКОВ
   ========================================================== */
.player-seat {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: opacity 0.3s ease, filter 0.3s ease;
}
.player-seat.passed-seat { opacity: 0.42 !important; filter: grayscale(70%) !important; }

.avatar-wrapper {
  position: relative;
  width: var(--avatar);
  height: var(--avatar);
  border-radius: var(--radius-panel);
  background: var(--avatar-bg);
  border: 2px solid var(--text-muted);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--avatar) * 0.46);
  color: #fff;
  font-weight: 700;
  z-index: 5;
  flex-shrink: 0;
}
/* Эмблема аватара: золотая линия на тёмной плашке */
.avatar-face { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.avatar-emblem {
  width: 64%;
  height: 64%;
  fill: none;
  stroke: var(--gold);
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.55));
}
.avatar-emoji { line-height: 1; }
.player-seat.active-turn .avatar-wrapper, .avatar-wrapper.is-turn {
  border-color: var(--gold);
  box-shadow: 0 0 14px rgba(var(--accent-rgb), 0.85);
  animation: turn-pulse 1.2s infinite alternate;
}
@keyframes turn-pulse {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

.avatar-wrapper.one-point-fire {
  border-color: #ff5a3c !important;
  box-shadow: 0 0 14px #ff5a3c, 0 0 24px #ff9500 !important;
  animation: fire-flame-pulse 0.7s infinite alternate !important;
}
.avatar-wrapper.one-point-fire::before {
  content: "🔥";
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: var(--fs-md);
  z-index: 30;
  animation: fire-flicker 0.6s infinite alternate;
}
@keyframes fire-flame-pulse {
  from { box-shadow: 0 0 12px #ff5a3c, 0 0 20px #ff9500; transform: scale(1); }
  to { box-shadow: 0 0 22px #ff5a3c, 0 0 34px #ff9500; transform: scale(1.06); }
}
@keyframes fire-flicker {
  from { transform: translateX(-50%) translateY(0) scale(0.9); }
  to { transform: translateX(-50%) translateY(-2px) scale(1.15); }
}

.avatar-dealer-chip {
  position: absolute;
  top: -6px;
  left: -6px;
  width: 21px;
  height: 21px;
  background: var(--gold);
  color: var(--text-on-gold);
  font-size: var(--fs-xs);
  font-weight: 700;
  border-radius: 50%;
  border: 1px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  z-index: 15;
}

.pirik-square-indicator {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 16px;
  height: 16px;
  background: var(--pirik-blue);
  border: 1.5px solid #fff;
  border-radius: var(--radius-chip);
  box-shadow: 0 0 10px var(--pirik-blue-glow);
  z-index: 20;
  animation: square-pulse 1.1s infinite alternate;
}
@keyframes square-pulse {
  from { transform: scale(0.95); }
  to { transform: scale(1.18); }
}

.pirik-taker-chip {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 21px;
  height: 21px;
  background: var(--pirik-blue);
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: 700;
  border-radius: 50%;
  border: 1.5px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  z-index: 22;
}

/* Плашка ПЯТАК внутри нижнего края аватара: не прячется за плашкой имени */
.avatar-pyatak-overlay {
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gold);
  color: var(--text-on-gold);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 1px 4px;
  border-radius: var(--radius-chip);
  border: 1px solid #fff;
  z-index: 25;
  white-space: nowrap;
}
/* Цвет плашки — цвет пары валетов */
.avatar-pyatak-overlay.is-red { background: var(--suit-red); color: #fff; }
.avatar-pyatak-overlay.is-black { background: #0e1518; color: #fff; }

.player-name-plate {
  margin-top: 3px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 118px;
  background: var(--surface-chip);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 2px 3px 2px 6px;
  border-radius: var(--radius-chip);
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  z-index: 5;
}
.player-name-plate .plate-name { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
/* Счёт крупный, его видно с одного взгляда: лидер золотом, близкие к победе зелёным, перебор красным */
.seat-score {
  min-width: 26px;
  padding: 1px 5px;
  border-radius: var(--radius-chip);
  background: rgba(243, 239, 227, 0.14);
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.seat-score.near-win { background: var(--good); color: #06281c; }
.seat-score.danger { background: var(--bad); color: #36100a; }
.seat-score.leader { background: var(--gold); color: var(--text-on-gold); box-shadow: 0 0 9px rgba(var(--accent-rgb), 0.65); }

/* Итог кона на аватаре: крупная цифра держится до начала следующего кона */
.round-delta {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  background: rgba(4, 16, 13, 0.88);
  font-size: calc(var(--avatar) * 0.42);
  font-weight: 800;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  animation: delta-in 0.35s var(--ease) both;
}
/* Пока виден итог кона, значок ПЯТАК не закрывает цифру */
.avatar-wrapper:has(> .round-delta) .avatar-pyatak-overlay { visibility: hidden; }
.round-delta.good { color: var(--good); }
.round-delta.bad { color: var(--bad); }
.round-delta.zero { color: var(--text-muted); }
@keyframes delta-in {
  from { opacity: 0; transform: scale(0.6); }
}

.trick-pips { display: flex; gap: 3px; height: 7px; margin-top: 3px; }
.trick-pips i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
}
.trick-pips i.won { background: var(--gold); border-color: var(--gold); }

.bot-card-fan {
  margin-top: 3px;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 4;
  height: 36px;
}
.bot-fan-card {
  width: 25px;
  height: 36px;
  background-color: var(--card-back-color);
  background-image: var(--card-back);
  background-size: 7px 7px;
  background-clip: padding-box;
  border: 1.5px solid #fff;
  border-radius: 3px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  margin-left: -16px;
  transform-origin: 50% 120%;
  /* Угол и дугу задаёт applyBotFan: веер симметричен при любом числе карт */
  transform: translateY(var(--arc, 0px)) rotate(var(--fan, 0deg));
  transition: transform 0.28s var(--ease), opacity 0.3s ease;
}
.bot-fan-card:first-child { margin-left: 0; }
.bot-fan-card.deal-pending, .user-card.deal-pending, .pirik-stack .card.deal-pending { visibility: hidden; }
.bot-fan-card.anim-land, .pirik-stack .card.anim-land { animation: card-land 0.18s ease-out; }
@keyframes card-land {
  from { scale: 1.12; }
}
.bot-fan-card.discarding {
  transform: translateY(-25px) scale(0.3) rotate(30deg) !important;
  opacity: 0 !important;
}

/* Место человека: аватар ровно по центру, слева сортировка и сброс, справа решения.
   Стороны делят ширину поровну; если справа кнопок больше, аватар чуть сдвигается, но строка не ломается */
.user-action-and-profile-row {
  width: 100%;
  max-width: 640px;
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 2px 14px;
  margin: 0 auto 4px;
}
.user-row-side { flex: 1 1 0; min-width: max-content; }
.user-row-side.side-left { justify-content: flex-end; }
.user-row-side.side-right { justify-content: flex-start; }
/* Место человека как у остальных: аватар, под ним имя со счётом и кружки взяток */
.user-seat-dock { display: flex; flex-direction: column; align-items: center; gap: 3px; flex: 0 0 auto; }
.user-avatar-column { display: flex; flex-direction: column; align-items: center; position: relative; }
.user-seat-labels { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.user-seat-labels .player-name-plate { margin-top: 0; max-width: 110px; }
.user-seat-labels .trick-pips { margin-top: 0; }

/* Набор кнопок всегда один и тот же: недоступные полупрозрачные, строка не прыгает */
.action-bar {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: nowrap;
}
.action-bar .btn:disabled { opacity: 0.36; }
.action-bar .btn-slot { min-width: 70px; }
.throw-wrap { position: relative; display: inline-flex; }
/* Подтверждение сброса: маленькие ✓ и ✕ над кнопкой, без отдельного окна */
.confirm-pop {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface-1);
  box-shadow: var(--shadow-md);
  white-space: nowrap;
  z-index: 60;
  animation: confirm-in 0.14s var(--ease);
}
.confirm-pop .btn { --control-h: 38px; width: 38px; min-width: 38px; padding: 0; font-size: 18px; }
.confirm-pop small { padding: 0 4px; color: var(--text-muted); font-size: var(--fs-xs); font-weight: 700; }
@keyframes confirm-in {
  from { opacity: 0; transform: translate(-50%, 6px); }
}
.throw-wrap.is-armed > .btn-danger { box-shadow: 0 0 0 2px #ffb3a6, 0 0 14px rgba(255, 110, 90, 0.7); }


/* ==========================================================
   РУКА И КАРТЫ
   ========================================================== */
/* Видна верхняя половина веера, нижняя уходит за край экрана */
.player-hand {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  height: calc(var(--user-card-h) * 0.62 + 12px);
  padding: 10px 8px 0;
  perspective: 900px;
  transition: opacity 0.3s ease, filter 0.3s ease;
}
.player-hand.passed-hand {
  opacity: 0.4 !important;
  filter: grayscale(85%) brightness(0.65) !important;
  pointer-events: none !important;
}

/* isolation держит рисунок карты внутри неё: сосед всегда закрывает её целиком */
.card {
  width: var(--card-w);
  height: var(--card-h);
  background-color: var(--card-face);
  background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(236, 229, 212, 0.34));
  border-radius: var(--card-radius);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.42), 0 0 0 0.5px rgba(40, 30, 10, 0.45);
  position: relative;
  isolation: isolate;
  flex: 0 0 auto;
  cursor: default;
  pointer-events: none;
  transition: transform 0.2s var(--ease), box-shadow 0.2s ease, filter 0.2s ease;
  margin-left: -14px;
}
.card:first-child { margin-left: 0; }
.card-face { display: block; width: 100%; height: 100%; border-radius: inherit; }

.user-card {
  width: var(--user-card-w);
  height: var(--user-card-h);
  margin-left: var(--user-card-overlap);
  border-radius: var(--radius-control);
  transform-origin: 50% 135%;
  transform: translateY(calc(var(--arc, 0px) + var(--lift, 0px))) rotate(var(--fan, 0deg));
}
.user-card:first-child { margin-left: 0; }

/* Козырь в руке мягко светится */
.user-card.is-trump::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: 0 0 0 1.5px #ffd66b, 0 0 15px 4px rgba(255, 190, 48, 0.82), inset 0 0 12px rgba(255, 196, 64, 0.34);
  animation: trump-glow 1.9s ease-in-out infinite alternate;
}
@keyframes trump-glow {
  from { opacity: 0.68; }
  to { opacity: 1; }
}

/* Пара валетов одного цвета (Пятак) светится этим цветом, вокруг выбранный эффект */
.pair-aura {
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  pointer-events: none;
  animation: pair-pulse 1.5s ease-in-out infinite alternate;
}
.pair-glow.red { --fx-c1: #ffd36b; --fx-c2: rgba(255, 64, 48, 0.95); }
.pair-glow.black { --fx-c1: #f4f8ff; --fx-c2: rgba(170, 196, 232, 0.95); }
.pair-glow.red .pair-aura { box-shadow: 0 0 0 2px #ff6a5a, 0 0 20px 7px rgba(232, 30, 44, 0.95), 0 0 42px 14px rgba(255, 86, 56, 0.45), inset 0 0 18px 3px rgba(232, 40, 50, 0.55); }
.pair-glow.black .pair-aura { box-shadow: 0 0 0 2px #eef3fa, 0 0 18px 8px rgba(4, 8, 12, 0.95), 0 0 40px 14px rgba(196, 216, 242, 0.5), inset 0 0 18px 3px rgba(60, 76, 100, 0.6); }
@keyframes pair-pulse {
  from { opacity: 0.65; }
  to { opacity: 1; }
}
.pair-fx { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.pair-fx i {
  position: absolute;
  left: var(--x);
  bottom: var(--y);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  opacity: 0;
  background: var(--fx-c1);
  box-shadow: 0 0 7px 3px var(--fx-c2);
  animation: fx-spark var(--dur) var(--d) linear infinite;
}
@keyframes fx-spark {
  0% { opacity: 0; transform: translate(0, 0) scale(1); }
  12% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), -92px) scale(0.3); }
}
html[data-jack-fx="embers"] .pair-fx i {
  width: 9px;
  height: 9px;
  background: radial-gradient(circle, var(--fx-c1) 0%, var(--fx-c2) 45%, transparent 72%);
  box-shadow: none;
  animation-name: fx-ember;
  animation-duration: calc(var(--dur) * 1.7);
  animation-timing-function: ease-in-out;
}
@keyframes fx-ember {
  0% { opacity: 0; transform: translate(0, 0); }
  25% { opacity: 0.95; }
  50% { opacity: 0.45; }
  75% { opacity: 0.9; }
  100% { opacity: 0; transform: translate(var(--dx), -50px); }
}
html[data-jack-fx="stars"] .pair-fx i {
  width: 12px;
  height: 12px;
  border-radius: 0;
  box-shadow: none;
  clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%);
  filter: drop-shadow(0 0 3px var(--fx-c2));
  animation-name: fx-star;
  animation-duration: calc(var(--dur) * 1.4);
  animation-timing-function: ease-in-out;
}
@keyframes fx-star {
  0%, 100% { opacity: 0; transform: scale(0) rotate(0deg); }
  50% { opacity: 1; transform: scale(1) rotate(60deg); }
}
html[data-jack-fx="none"] .pair-fx { display: none; }

.card.unplayable { filter: brightness(0.58) saturate(0.6); }
.card.unplayable.is-trump { filter: brightness(0.86) saturate(0.85); }
.card.playable {
  cursor: pointer;
  pointer-events: auto;
  touch-action: none;
  -webkit-touch-callout: none;
  --lift: -9px;
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.52), 0 0 0 0.5px rgba(40, 30, 10, 0.45);
}
/* Подъём при наведении только там, где есть мышь: на телефоне он «залипал» после касания */
@media (hover: hover) {
  .card.playable:hover { --lift: -24px; z-index: 50; box-shadow: 0 16px 24px rgba(0, 0, 0, 0.58); }
}
.card.disabled { cursor: default; pointer-events: none; }

/* Долгое нажатие: карта поднимается, а когда заряд набран — дрожит и светится */
.user-card.charging { --lift: -30px; z-index: 50; transition: transform 0.2s cubic-bezier(0.3, 0.7, 0.4, 1), box-shadow 0.2s ease; }
.user-card.charged {
  box-shadow: 0 0 0 2px #ffd66b, 0 0 22px 6px rgba(255, 190, 48, 0.85), 0 16px 24px rgba(0, 0, 0, 0.5);
  animation: card-charged 0.09s linear infinite alternate;
}
@keyframes card-charged {
  from { translate: -1.5px 0; }
  to { translate: 1.5px 0; }
}

/* Карта долетела до руки: переворот лицом и лёгкий отскок */
.user-card.anim-deal { animation: hand-card-in 0.26s var(--ease) backwards; }
@keyframes hand-card-in {
  from { transform: translateY(calc(var(--arc, 0px) - 10px)) rotate(var(--fan, 0deg)) rotateY(80deg) scale(0.95); }
}

/* Козырь и Пірік лежат на столе как обычные карты */
#trump-slot, #pirik-container {
  position: relative;
  width: var(--stack-card-w);
  height: var(--stack-card-h);
}
#trump-slot .card { width: 100%; height: 100%; margin: 0; transform: rotate(-4deg); }
#trump-slot .card.anim-flip { animation: trump-flip 0.48s ease-out backwards; }
@keyframes trump-flip {
  from { transform: perspective(500px) rotateY(180deg) rotate(-4deg) scale(1.12); }
}
.pirik-stack { position: relative; width: 100%; height: 100%; }
/* Стопка Піріка у игрока: лежит на столе перед тем, на кого смотрит, с синим отсветом, как у метки на аватаре */
#pirik-traveler {
  position: fixed;
  z-index: 950;
  pointer-events: none;
  will-change: transform;
}
#pirik-traveler .card { border-width: 2px; background-size: 8px 8px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4); }
#pirik-traveler .card:last-child { box-shadow: 0 0 0 1.5px var(--pirik-blue), 0 0 14px var(--pirik-blue-glow), 0 6px 12px rgba(0, 0, 0, 0.45); }
.pirik-taken-placeholder.pirik-empty { background: rgba(0, 0, 0, 0.18); }
.pirik-stack .card { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; }

.card-back, .card.card-back, .flying-card.card-back {
  background-color: var(--card-back-color);
  background-image: var(--card-back);
  background-size: 10px 10px;
  background-clip: padding-box;
  border: 3px solid #fff;
  border-radius: var(--card-radius);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.45), 0 0 0 0.5px rgba(40, 30, 10, 0.5);
  cursor: default;
}
.flying-card {
  position: fixed;
  width: var(--card-w);
  height: var(--card-h);
  border-radius: var(--card-radius);
  z-index: 999;
  pointer-events: none;
  will-change: transform;
}
.flying-card.card-back { box-shadow: 0 10px 22px rgba(0, 0, 0, 0.55); }
.flying-card.card-back.is-glowing { box-shadow: 0 0 18px rgba(255, 215, 0, 0.85), 0 10px 22px rgba(0, 0, 0, 0.5); }

/* Карты взятки в центре: крупнее обычных, каждая со стороны своего игрока */
.trick-slot { width: 0; height: 0; transition: none; display: block; }
.trick-slot > div { position: absolute; left: calc(var(--table-card-w) / -2); top: calc(var(--table-card-h) / -2); }
.card.table-card {
  width: var(--table-card-w);
  height: var(--table-card-h);
  margin: 0;
  border-radius: calc(var(--card-radius) * 1.25);
  box-shadow: 0 4px 9px rgba(0, 0, 0, 0.5), 0 0 0 0.5px rgba(40, 30, 10, 0.5);
}
.card.winning-trick-card { box-shadow: 0 0 0 2px #ffd66b, 0 0 18px 4px rgba(255, 196, 64, 0.85); }
.card.table-card.slammed { animation: card-slam 0.22s ease-out; }
@keyframes card-slam {
  0% { scale: 1.1; }
  45% { scale: 0.96; }
  100% { scale: 1; }
}
/* Круг на сукне от удара картой с размаху */
.slam-ring {
  position: fixed;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border-radius: 50%;
  border: 2px solid rgba(255, 223, 140, 0.85);
  pointer-events: none;
  z-index: 998;
  animation: slam-ring 0.45s ease-out forwards;
}
@keyframes slam-ring {
  from { transform: scale(0.6); opacity: 0.9; }
  to { transform: scale(7); opacity: 0; }
}

/* ==========================================================
   МОМЕНТЫ ИГРЫ
   ========================================================== */
/* Итоги кона: плашка в центре стола, подробная таблица — по кнопке */
.round-plaque {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 38;
  transform: translate(-50%, -50%);
  width: max-content;
  max-width: min(250px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 11px 12px 7px;
  border: 1px solid rgba(var(--accent-rgb), 0.45);
  border-radius: var(--radius-panel);
  background: color-mix(in srgb, var(--surface-1) 94%, transparent);
  box-shadow: var(--shadow-md);
  pointer-events: auto;
}
.round-plaque[hidden] { display: none; }
.round-plaque.is-in { animation: plaque-in 0.32s var(--ease) both; }
@keyframes plaque-in {
  from { opacity: 0; transform: translate(-50%, -42%) scale(0.94); }
}
.round-plaque-title {
  color: var(--gold);
  font-size: var(--fs-md);
  font-weight: 800;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  white-space: nowrap;
}
.round-plaque #btn-next-round { min-width: 168px; }
.round-plaque .round-plaque-more { --control-h: 34px; padding: 0 12px; color: var(--text-muted); font-size: var(--fs-sm); }

.moment-layer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 40;
}
.moment-toast {
  position: absolute;
  max-width: calc(100vw - 28px);
  padding: 7px 20px 8px;
  border-radius: var(--radius-panel);
  text-align: center;
  white-space: nowrap;
  background: linear-gradient(180deg, #ffe08a, var(--gold));
  color: var(--text-on-gold);
  border: 2px solid #fff;
  box-shadow: 0 0 30px rgba(var(--accent-rgb), 0.9), var(--shadow-md);
  animation: moment-pop 1.6s var(--ease) both;
}
.moment-who { font-size: var(--fs-md); font-weight: 700; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; }
.moment-title { font-size: 27px; font-weight: 900; letter-spacing: 1px; line-height: 1.12; }
/* Большие моменты: Пятак и 4 валета. Цвет — цвет пары валетов */
.moment-toast.grand { padding: 9px 26px 11px; animation-name: moment-grand; }
.moment-toast.grand .moment-title { font-size: 36px; letter-spacing: 2px; }
.moment-toast.grand.red {
  background: linear-gradient(180deg, #e2384f, #9e1426);
  color: #fff;
  box-shadow: 0 0 44px rgba(226, 56, 79, 0.85), var(--shadow-md);
}
.moment-toast.grand.black {
  background: linear-gradient(180deg, #2c3c42, #0b1215);
  color: var(--gold);
  box-shadow: 0 0 44px rgba(var(--accent-rgb), 0.6), var(--shadow-md);
}
@keyframes moment-grand {
  0% { opacity: 0; transform: scale(0.3) rotate(-8deg); }
  16% { opacity: 1; transform: scale(1.18) rotate(2deg); }
  28% { transform: scale(0.97) rotate(0); }
  36% { transform: scale(1); }
  82% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.08); }
}
/* Эмодзи разлетаются вокруг больших плашек: радость за Пятак, слёзы за Ұшты */
.moment-emoji {
  position: absolute;
  left: 50%;
  top: 50%;
  font-size: 26px;
  line-height: 1;
  pointer-events: none;
  z-index: 41;
  animation: emoji-burst var(--dur, 1.3s) cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
  animation-delay: var(--delay, 0s);
  opacity: 0;
}
@keyframes emoji-burst {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3) rotate(0deg); }
  18% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(var(--s, 1.1)) rotate(var(--r, 0deg)); }
}
.moment-toast.bad {
  background: linear-gradient(180deg, #b22c43, var(--danger));
  color: #fff;
  box-shadow: 0 0 30px rgba(255, 110, 90, 0.8), var(--shadow-md);
}
@keyframes moment-pop {
  0% { opacity: 0; transform: scale(0.4) rotate(-5deg); }
  16% { opacity: 1; transform: scale(1.12) rotate(1deg); }
  27% { transform: scale(1) rotate(0); }
  80% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.08) translateY(-10px); }
}

/* Реплика игрока: вылетает из центра его аватара и встаёт над ним, хвостик смотрит на аватар */
.seat-bubble {
  --rise: 24px;
  position: fixed;
  z-index: 997;
  pointer-events: none;
  padding: 5px 11px;
  border-radius: var(--radius-control);
  background: #fffdf6;
  color: #17252b;
  font-size: var(--fs-md);
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  transform-origin: 50% 100%;
  animation: bubble-pop 1.5s var(--ease) both;
}
.seat-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 10px;
  height: 10px;
  background: inherit;
  transform: translateX(-50%) rotate(45deg);
  border-radius: 2px;
}
@keyframes bubble-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.25); }
  16% { opacity: 1; transform: translate(-50%, calc(-100% - var(--rise))) scale(1.08); }
  26%, 82% { opacity: 1; transform: translate(-50%, calc(-100% - var(--rise))) scale(1); }
  100% { opacity: 0; transform: translate(-50%, calc(-100% - var(--rise) - 8px)) scale(0.96); }
}

.fx-float {
  position: fixed;
  z-index: 998;
  pointer-events: none;
  transform: translate(-50%, -50%);
  font-size: 22px;
  font-weight: 700;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
  animation: float-up 1s ease-out both;
}
.fx-float.good { color: var(--good); }
.fx-float.bad { color: var(--bad); }
@keyframes float-up {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.6); }
  20% { opacity: 1; transform: translate(-50%, -70%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -190%) scale(1); }
}

.coin-rain { position: fixed; inset: 0; z-index: 10001; pointer-events: none; overflow: hidden; }
.coin-rain i {
  position: absolute;
  top: -30px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff0b8, var(--gold) 45%, var(--gold-deep));
  border: 1px solid #80591a;
  animation: coin-fall 1.9s ease-in both;
}
@keyframes coin-fall {
  0% { transform: translateY(0) rotateY(0); opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translateY(108vh) rotateY(900deg); opacity: 0; }
}

/* ==========================================================
   ОКНА И КНОПКИ
   ========================================================== */
/* Без размытия фона: в Chrome оно ломает отрисовку окна поверх экранов меню */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal-card {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  width: 92%;
  max-width: 480px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.75);
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.22s ease;
}
.modal-overlay.active .modal-card { transform: scale(1); }

.modal-header {
  padding: 11px 14px;
  background: var(--surface-chip);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h2 { font-size: var(--fs-md); color: var(--gold); display: flex; align-items: center; gap: 6px; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  min-width: 32px;
  cursor: pointer;
  line-height: 1;
}
.modal-body {
  padding: 12px 14px;
  overflow-y: auto;
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--text);
}
.modal-footer {
  padding: 9px 14px;
  background: var(--surface-chip);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}


.log-msg-item {
  padding: 4px 7px;
  border-radius: var(--radius-chip);
  background: rgba(255, 255, 255, 0.04);
  border-left: 2.5px solid var(--text-muted);
  word-break: break-word;
  font-size: var(--fs-sm);
}
.log-msg-item.highlight { border-left-color: var(--gold); background: rgba(var(--accent-rgb), 0.1); }
.log-msg-item.danger { border-left-color: var(--bad); background: rgba(255, 141, 122, 0.1); }
.log-msg-item.success { border-left-color: var(--good); background: rgba(110, 231, 168, 0.08); }

.player-select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 6px;
  margin: 6px 0;
}
.player-select-btn {
  min-height: 58px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  padding: 8px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 2px;
  color: var(--text);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.player-select-btn:hover { background: var(--surface-hover); }
.player-select-btn.selected { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }

.radio-card-box {
  background: var(--surface-chip);
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}
.radio-channel-select {
  height: var(--control-h);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 0 8px;
  border-radius: var(--radius-chip);
  font-size: var(--fs-sm);
  font-weight: 700;
  outline: none;
  width: 100%;
}

/* ==========================================================
   АДАПТИВ
   ========================================================== */
@media (max-width: 860px) {
  .scoreboard-sidebar { display: none; }
  :root {
    --card-w: 52px;
    --card-h: 76px;
    --user-card-w: 116px;
    --user-card-h: 167px;
    --user-card-overlap: -65px;
    --avatar: 57px;
  }
  .moment-toast { padding: 5px 15px 6px; }
  .moment-toast.grand .moment-title { font-size: 30px; }
  .moment-title { font-size: 22px; }
  .moment-who { font-size: var(--fs-md); }
  .card-back, .card.card-back, .flying-card.card-back { border-width: 2.5px; background-size: 8px 8px; }
}

@media (max-width: 520px) {
  .header-author-badge { display: none; }
  .app-header { padding-left: 7px; padding-right: 7px; gap: 4px; }
  .header-left, .header-actions { gap: 3px; }
  /* Компактные кнопки: в сети справа четыре кнопки, а название должно остаться по центру */
  .app-header .btn { --control-h: 38px; }
  .app-header .btn:not(.btn-icon):not(.menu-item) { padding: 0 7px; }
}

@media (max-width: 440px) {
  :root {
    --card-w: 48px;
    --card-h: 70px;
    --user-card-w: 108px;
    --user-card-h: 157px;
    --user-card-overlap: -59px;
  }
  .brand-box .brand-icon { display: none; }
  .brand-box h1 { font-size: calc(var(--fs-md) * 1.5); letter-spacing: 0.4px; }
  .header-status { padding: 0 6px; gap: 4px; }
  .player-name-plate { max-width: 100px; }
  /* Строка человека на телефоне: компактные кнопки, чтобы всё влезло в одну строку */
  .user-action-and-profile-row { padding: 2px 8px; gap: 8px; }
  .user-seat-labels .player-name-plate { max-width: 88px; }
  .action-bar { gap: 4px; }
  .action-bar .btn { --control-h: 42px; font-size: 13px; }
  .action-bar .btn:not(.btn-icon) { padding: 0 8px; }
  .action-bar .btn-icon { width: 38px; min-width: 38px; }
  .action-bar .btn-slot { min-width: 62px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
