/*
 * «Двор» — стили на дизайн-токенах.
 * Каждая тема задаёт только переменные; компоненты пишутся один раз.
 * Темы: classic (по умолчанию), home, evening, y2k (косметика «нулевые»).
 * Шрифты только системные: без загрузки со сторонних серверов, кириллица везде.
 */

/* ---------- темы ---------- */

:root,
[data-theme="classic"] {
  /* Клуб: профессиональный карточный клуб — сукно, орех, латунь, бордо, слоновая кость (концепт 05) */
  --bg: #101f18;
  --bg-image: radial-gradient(ellipse at top, #1b3427 0%, transparent 65%);
  --surface: #172d22;
  --surface-2: #1f3a2c;
  --border: #4f5f3e;
  --text: #f1ead8;
  --muted: #bdb39a;
  --accent: #7d1f2c;
  --accent-hover: #922636;
  --accent-ink: #f8f0e0;
  --ok: #2f6a4b;
  --ok-ink: #f3ecdc;
  --warn: #8e2f22;
  --warn-ink: #f8eee6;
  --header-bg: #0c1912;
  --header-ink: #ece2c6;
  --header-border: #b89a5a;
  --rail: linear-gradient(#5b3a25, #3d2617);
  --felt: radial-gradient(ellipse at 50% 35%, #236246, #133d2b 75%);
  --felt-ink: rgba(241, 234, 216, .78);
  --card-face: #fbf6ea;
  --card-edge: #d8ccb6;
  --card-red: #9e2a2a;
  --card-black: #1b1714;
  --card-back: repeating-linear-gradient(45deg, #7d1f2c 0 4px, #8f2c37 4px 8px);
  --card-back-border: #efe3c8;
  --highlight: #c9a65c;
  --badge-attack: #3e3522; --badge-attack-ink: #f0d79c;
  --badge-defend: #1f3d2d; --badge-defend-ink: #bfe2c9;
  --badge-take: #4a2421; --badge-take-ink: #f3c2b9;
  --font-ui: "PT Sans", "Helvetica Neue", "Segoe UI", Arial, sans-serif;
  --font-display: "PT Serif", Georgia, "Times New Roman", serif;
  --font-card: "PT Serif", Georgia, serif;
  --radius-lg: 12px;
  --radius: 8px;
  --radius-sm: 6px;
  --btn-bg: transparent;
  --btn-shadow: inset 0 0 0 1px rgba(201, 166, 92, .35);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-card: 0 1px 1px rgba(0, 0, 0, .25), 0 3px 8px rgba(0, 0, 0, .35);
  --avatar-ink: #fff; --overlay: rgba(4, 10, 7, .62); --link: #e2c27a; --input-bg: #0f2219; --divider: #2c4636; --online: #6fbf8a;
  --bubble-mine: #2a4a35; --bubble-mine-ink: #f1ead8; --bubble-other: #1f3a2c; --bubble-other-ink: #f1ead8; --nav-bg: #0f2219; --nav-active: #e2c27a;
  color-scheme: dark;
  /* бренд-элементы темы (docs/brand.md) */
  --scene: url("/themes/classic/scene-wide.jpg");
  --scene-tall: url("/themes/classic/scene-tall.jpg");
  --scene-pos: 38% 60%;
  --scene-veil: linear-gradient(rgba(13, 29, 23, .12), rgba(13, 29, 23, .12));
  --scene-veil-game: linear-gradient(rgba(13, 29, 23, .46), rgba(13, 29, 23, .46)); /* подложка читаемости из дизайн-системы: цвет фона темы ~40% */
  --art-durak: url("/themes/classic/durak.jpg");
  --art-quiz: url("/themes/classic/quiz.jpg");
  --art-mafia: url("/themes/classic/mafia.jpg");
  --table-surface: url("/themes/classic/table.svg");
  --table-tint: linear-gradient(transparent, transparent);
  --table-light: rgba(255, 236, 190, .16);
  --header-glass: rgba(10, 22, 15, .78);
  --plate-bg: rgba(16, 32, 23, .88); --plate-ink: #f1e4c6;
  --ring: #7fd39a;
  --note-bg: #efe3cb; --note-ink: #2a2118; --note-pin: #a58656;
  --font-note: "PT Serif", Georgia, serif;
  --btn-primary-bg: linear-gradient(#7a1e2b, #5a1520);
  --btn-primary-shadow: inset 0 0 0 1px rgba(201, 166, 92, .55), 0 2px 6px rgba(0, 0, 0, .35);
}

[data-theme="home"] {
  /* Дом: тёплая гостиная — кремовая бумага, мёд, шалфей, терракота (концепт 03) */
  --bg: #f1e6d4;
  --bg-image: none;
  --surface: #fffaf1;
  --surface-2: #f4e9d6;
  --border: #e2d2b8;
  --text: #2f251c;
  --muted: #74675a;
  --accent: #b0502c;
  --accent-hover: #963f22;
  --accent-ink: #fffaf3;
  --ok: #557758;
  --ok-ink: #fbfdf9;
  --warn: #b24b33;
  --warn-ink: #fff8f4;
  --header-bg: #fffaf1;
  --header-ink: #2f251c;
  --header-border: #e2d2b8;
  --rail: linear-gradient(#b7834b, #93622f);
  --felt: radial-gradient(ellipse at 50% 35%, #c99358, #a66d34 80%);
  --felt-ink: rgba(255, 249, 238, .92);
  --card-face: #fffefb;
  --card-edge: #e3d8c9;
  --card-red: #c0453a;
  --card-black: #2f251c;
  --card-back: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, .22) 1.5px, transparent 2px) 0 0 / 8px 8px, #b9572f;
  --card-back-border: #fffaf1;
  --highlight: #d99a35;
  --badge-attack: #f8e3cf; --badge-attack-ink: #94461f;
  --badge-defend: #e2ebe2; --badge-defend-ink: #3e6143;
  --badge-take: #f6dcd4; --badge-take-ink: #9b3f2c;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: Georgia, "PT Serif", "Times New Roman", serif;
  --font-card: Georgia, "PT Serif", serif;
  --radius-lg: 20px;
  --radius: 14px;
  --radius-sm: 10px;
  --btn-bg: #fffaf1;
  --btn-shadow: inset 0 0 0 1px #d9c7aa;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 8px 24px rgba(60, 40, 20, .10);
  --shadow-card: 0 1px 2px rgba(60, 40, 20, .12), 0 4px 12px rgba(60, 40, 20, .12);
  --avatar-ink: #fff; --overlay: rgba(40, 28, 18, .42); --link: #a24a28; --input-bg: #fffdf8; --divider: #eadcc6; --online: #5d7f61;
  --bubble-mine: #f6dfcf; --bubble-mine-ink: #3a2a20; --bubble-other: #fffdf8; --bubble-other-ink: #2f251c; --nav-bg: #fffaf1; --nav-active: #b0502c;
  color-scheme: light;
  /* бренд-элементы темы (docs/brand.md) */
  --scene: url("/themes/home/scene-wide.jpg");
  --scene-tall: url("/themes/home/scene-tall.jpg");
  --scene-pos: 30% 70%;
  --scene-veil: linear-gradient(rgba(73, 56, 43, .06), rgba(73, 56, 43, .06));
  --scene-veil-game: linear-gradient(rgba(73, 56, 43, .36), rgba(73, 56, 43, .36)); /* подложка читаемости из дизайн-системы: цвет фона темы ~40% */
  --art-durak: url("/themes/home/durak.jpg");
  --art-quiz: url("/themes/home/quiz.jpg");
  --art-mafia: url("/themes/home/mafia.jpg");
  --table-surface: url("/themes/home/table.svg");
  --table-tint: linear-gradient(rgba(90, 50, 20, .10), rgba(90, 50, 20, .10));
  --table-light: rgba(255, 244, 220, .20);
  --header-glass: rgba(255, 249, 238, .82);
  --plate-bg: rgba(255, 249, 238, .92); --plate-ink: #2f251c;
  --ring: #c27a3a;
  --note-bg: #efdcbc; --note-ink: #2f251c; --note-pin: #b7834b;
  --font-note: "Noteworthy", "Bradley Hand", "Segoe Print", cursive;
  --btn-primary-bg: linear-gradient(#bd5a33, #a2462a);
  --btn-primary-shadow: 0 2px 0 #7f3720, 0 3px 8px rgba(120, 60, 30, .25);
}

[data-theme="evening"] {
  /* Ночь: ночной ламповый уют — дождь за окном, тёмное дерево, янтарный свет (концепт 04) */
  --bg: #141110;
  --bg-image: radial-gradient(ellipse at top, #2a2118 0%, transparent 65%);
  --surface: #211b17;
  --surface-2: #2b231e;
  --border: #3f342b;
  --text: #f2e7d5;
  --muted: #b8a891;
  --accent: #d99540;
  --accent-hover: #e6a654;
  --accent-ink: #1c140c;
  --ok: #7aa07d;
  --ok-ink: #121a12;
  --warn: #d77a5d;
  --warn-ink: #1f120e;
  --header-bg: #110e0c;
  --header-ink: #efdcbc;
  --header-border: #3f342b;
  --rail: linear-gradient(#3e2b1d, #24180f);
  --felt: radial-gradient(ellipse at 45% 25%, #4a3523, #22170f 78%);
  --felt-ink: rgba(242, 231, 213, .78);
  --card-face: #f6eee1;
  --card-edge: #cbbca5;
  --card-red: #b43a32;
  --card-black: #221d19;
  --card-back: repeating-linear-gradient(45deg, #5e2c25 0 4px, #6d352d 4px 8px);
  --card-back-border: #e8dcc8;
  --highlight: #f0b25b;
  --badge-attack: #4a3826; --badge-attack-ink: #f3c993;
  --badge-defend: #2d4236; --badge-defend-ink: #a9d3b2;
  --badge-take: #4d2c25; --badge-take-ink: #f2aa98;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "PT Serif", Georgia, serif;
  --font-card: "PT Serif", Georgia, serif;
  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 9px;
  --btn-bg: transparent;
  --btn-shadow: inset 0 0 0 1px #5a4a3b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-card: 0 2px 3px rgba(0, 0, 0, .35), 0 6px 14px rgba(0, 0, 0, .3);
  --avatar-ink: #fff; --overlay: rgba(0, 0, 0, .58); --link: #ebb066; --input-bg: #1a1512; --divider: #352c25; --online: #7aa07d;
  --bubble-mine: #43342a; --bubble-mine-ink: #f6eadb; --bubble-other: #2b231e; --bubble-other-ink: #f2e7d5; --nav-bg: #110e0c; --nav-active: #f0b25b;
  color-scheme: dark;
  /* бренд-элементы темы (docs/brand.md) */
  --scene: url("/themes/evening/scene-wide.jpg");
  --scene-tall: url("/themes/evening/scene-tall.jpg");
  --scene-pos: 30% 55%;
  --scene-veil: linear-gradient(rgba(20, 23, 28, .10), rgba(20, 23, 28, .10));
  --scene-veil-game: linear-gradient(rgba(20, 23, 28, .46), rgba(20, 23, 28, .46)); /* подложка читаемости из дизайн-системы: цвет фона темы ~40% */
  --art-durak: url("/themes/evening/durak.jpg");
  --art-quiz: url("/themes/evening/quiz.jpg");
  --art-mafia: url("/themes/evening/mafia.jpg");
  --table-surface: url("/themes/evening/table.svg");
  --table-tint: linear-gradient(transparent, transparent);
  --table-light: rgba(255, 190, 110, .24);
  --header-glass: rgba(17, 14, 12, .78);
  --plate-bg: rgba(26, 20, 17, .86); --plate-ink: #f3e3c8;
  --ring: #f0b25b;
  --note-bg: #e9d6b8; --note-ink: #241a12; --note-pin: #9c7a4a;
  --font-note: "Noteworthy", "Bradley Hand", "Segoe Print", cursive;
  --btn-primary-bg: linear-gradient(#e6a75a, #c97834);
  --btn-primary-shadow: 0 0 14px rgba(240, 178, 91, .35), inset 0 1px 0 rgba(255, 255, 255, .25);
}

[data-theme="y2k"] {
  /* Нулевые: компьютерный стол 2004-го — синий свет монитора, серебро, лайм (концепт 02) */
  --bg: #0d1630;
  --bg-image: radial-gradient(ellipse at top, #1c2f63 0%, transparent 65%);
  --surface: #17233f;
  --surface-2: #1f2f52;
  --border: #3c5384;
  --text: #eef3ff;
  --muted: #a8b6d4;
  --accent: #b6ef2e;
  --accent-hover: #c9ff4f;
  --accent-ink: #13210a;
  --ok: #3f8fe0;
  --ok-ink: #061426;
  --warn: #e45a4f;
  --warn-ink: #1a0705;
  --header-bg: linear-gradient(#1a2a55, #0e1a3a);
  --header-ink: #eef3ff;
  --header-border: #4a72d6;
  --rail: linear-gradient(#a3acbb, #6e7787);
  --felt: radial-gradient(ellipse at 50% 30%, #234a9c, #10275e 80%);
  --felt-ink: rgba(238, 243, 255, .8);
  --card-face: #f7f9ff;
  --card-edge: #b8c3d9;
  --card-red: #c62828;
  --card-black: #10131a;
  --card-back: repeating-linear-gradient(45deg, #1f4fbf 0 5px, #2b62d6 5px 10px);
  --card-back-border: #e9eefb;
  --highlight: #b6ef2e;
  --badge-attack: #3a3f1e; --badge-attack-ink: #dcf88e;
  --badge-defend: #1d3560; --badge-defend-ink: #b9d6ff;
  --badge-take: #4a2228; --badge-take-ink: #ffbdb6;
  --font-ui: Tahoma, Verdana, "Segoe UI", sans-serif; /* Tahoma уже Verdana: в Нулевых колонка игр не «падает» из-за лишних переносов */
  --font-display: "Trebuchet MS", Verdana, sans-serif;
  --font-card: Georgia, serif;
  --radius-lg: 14px;
  --radius: 10px;
  --radius-sm: 7px;
  --btn-bg: linear-gradient(#5a6c93, #3c4d73);
  --btn-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 rgba(0, 0, 0, .4);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-card: 1px 2px 4px rgba(0, 0, 0, .4);
  --avatar-ink: #fff; --overlay: rgba(4, 8, 20, .6); --link: #9fd0ff; --input-bg: #111b33; --divider: #2c3f68; --online: #b6ef2e;
  --bubble-mine: #284878; --bubble-mine-ink: #eef3ff; --bubble-other: #1f2f52; --bubble-other-ink: #eef3ff; --nav-bg: #111b33; --nav-active: #b6ef2e;
  color-scheme: dark;
  /* бренд-элементы темы (docs/brand.md) */
  --scene: url("/themes/y2k/scene-wide.jpg");
  --scene-tall: url("/themes/y2k/scene-tall.jpg");
  --scene-pos: 35% 55%;
  --scene-veil: linear-gradient(rgba(16, 29, 53, .10), rgba(16, 29, 53, .10));
  --scene-veil-game: linear-gradient(rgba(16, 29, 53, .46), rgba(16, 29, 53, .46)); /* подложка читаемости из дизайн-системы: цвет фона темы ~40% */
  --art-durak: url("/themes/y2k/durak.jpg");
  --art-quiz: url("/themes/y2k/quiz.jpg");
  --art-mafia: url("/themes/y2k/mafia.jpg");
  --table-surface: url("/themes/y2k/table.svg");
  --table-tint: linear-gradient(transparent, transparent);
  --table-light: rgba(120, 170, 255, .18);
  --header-glass: rgba(14, 24, 52, .78);
  --plate-bg: rgba(20, 32, 64, .84); --plate-ink: #ffffff;
  --ring: #bef73e;
  --note-bg: #f4f6fb; --note-ink: #1b2a55; --note-pin: #3f8fe0;
  --font-note: "Noteworthy", "Bradley Hand", "Segoe Print", cursive;
  --btn-primary-bg: linear-gradient(#d4ff6a, #a9e52b);
  --btn-primary-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 2px 8px rgba(190, 247, 62, .3);
}

[data-theme="nineties"] {
  /* Девяностые: обжитая квартира 94-го — бумага объявлений, бордо, бутылочное стекло, клеёнка (концепт 01) */
  --bg: #e6d6b8;
  --bg-image: none;
  --surface: #f5ead2;
  --surface-2: #eadbbd;
  --border: #c9b28b;
  --text: #2b1c15;
  --muted: #6a5543;
  --accent: #7b1d29;
  --accent-hover: #631620;
  --accent-ink: #fbf1e4;
  --ok: #2d5a3a;
  --ok-ink: #f4ecda;
  --warn: #973a1d;
  --warn-ink: #fbefe4;
  --header-bg: linear-gradient(#4a2620, #331a15);
  --header-ink: #f3e3c8;
  --header-border: #b07a3a;
  --rail: linear-gradient(#6b4128, #4a2a18);
  --felt: radial-gradient(ellipse at 50% 35%, #8f6343, #5d3a24 80%);
  --felt-ink: #4a2a1c;
  --card-face: #fffaf0;
  --card-edge: #c9b48f;
  --card-red: #b02828;
  --card-black: #1d1512;
  --card-back: repeating-linear-gradient(45deg, #a32a2a 0 4px, #f0e0c4 4px 6px, #a32a2a 6px 10px);
  --card-back-border: #f6ecd6;
  --highlight: #d2973a;
  --badge-attack: #f1dcb5; --badge-attack-ink: #7a4310;
  --badge-defend: #d9e4d6; --badge-defend-ink: #2b4f33;
  --badge-take: #f0d0c6; --badge-take-ink: #852b1d;
  --font-ui: "PT Sans", "Helvetica Neue", Arial, sans-serif;
  --font-display: "PT Sans Narrow", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --font-card: Georgia, serif;
  --radius-lg: 8px;
  --radius: 6px;
  --radius-sm: 4px;
  --btn-bg: #f5ead2;
  --btn-shadow: inset 0 0 0 1px #8f6a4a, 0 1px 0 rgba(0, 0, 0, .15);
  --shadow: 0 1px 2px rgba(50, 30, 15, .12), 0 6px 18px rgba(50, 30, 15, .16);
  --shadow-card: 0 1px 1px rgba(0, 0, 0, .2), 0 3px 8px rgba(0, 0, 0, .22);
  --avatar-ink: #fff; --overlay: rgba(30, 15, 8, .5); --link: #7b1d29; --input-bg: #fffaf0; --divider: #dccaa5; --online: #2d5a3a;
  --bubble-mine: #ead7b5; --bubble-mine-ink: #2b1c15; --bubble-other: #fffaf0; --bubble-other-ink: #2b1c15; --nav-bg: #f5ead2; --nav-active: #7b1d29;
  color-scheme: light;
  /* бренд-элементы темы (docs/brand.md) */
  --scene: url("/themes/nineties/scene-wide.jpg");
  --scene-tall: url("/themes/nineties/scene-tall.jpg");
  --scene-pos: 35% 60%;
  --scene-veil: linear-gradient(rgba(51, 43, 37, .06), rgba(51, 43, 37, .06));
  --scene-veil-game: linear-gradient(rgba(51, 43, 37, .40), rgba(51, 43, 37, .40)); /* подложка читаемости из дизайн-системы: цвет фона темы ~40% */
  --art-durak: url("/themes/nineties/durak.jpg");
  --art-quiz: url("/themes/nineties/quiz.jpg");
  --art-mafia: url("/themes/nineties/mafia.jpg");
  --table-surface: url("/themes/nineties/table.svg");
  --table-tint: linear-gradient(rgba(110, 45, 25, .08), rgba(110, 45, 25, .08));
  --table-light: rgba(255, 232, 190, .22);
  --header-glass: rgba(64, 31, 24, .86);
  --plate-bg: #efdfc4; --plate-ink: #5a1820;
  --ring: #f2b43c;
  --note-bg: #efe0c4; --note-ink: #1f2d5a; --note-pin: #b3242c;
  --font-note: "Noteworthy", "Bradley Hand", "Segoe Print", cursive;
  --btn-primary-bg: linear-gradient(#7d1f29, #63171f);
  --btn-primary-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 2px 0 #3d0e13;
}

/* ---------- основа ---------- */

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

body {
  margin: 0;
  min-height: 100vh;
  font: 15px/1.45 var(--font-ui);
  color: var(--text);
  /* фон рисует body::before (сцена темы); свой фон у body без background-attachment: fixed — иначе перерисовка всей страницы на каждом шаге прокрутки */
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* Фон темы — сцена из дизайн-системы (16:9 и 9:16, без обрезки смысла), на весь экран.
   На главной сцена почти без вуали; в лобби и за игрой — подложка читаемости ~40% цвета темы. */
/* Сцена и холст закреплены по «большой» высоте экрана (100lvh): когда на телефоне при прокрутке прячется
   адресная строка, они не пересчитываются и не дёргаются; отдельный слой — без перерисовки при прокрутке. */
body::before {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 100vh;
  height: 100lvh;
  transform: translateZ(0);
  z-index: -1;
  background: var(--scene-veil), var(--scene) center / cover no-repeat, var(--bg);
  pointer-events: none;
}
html[data-screen="game"] body::before,
html[data-screen="lobby"] body::before { background: var(--scene-veil-game), var(--scene) center / cover no-repeat, var(--bg); }
@media (max-aspect-ratio: 4/5) {
  body::before { background: var(--scene-veil), var(--scene-tall) center / cover no-repeat, var(--bg); }
  html[data-screen="game"] body::before,
  html[data-screen="lobby"] body::before { background: var(--scene-veil-game), var(--scene-tall) center / cover no-repeat, var(--bg); }
}
/* широкий экран: игры вертикальной колонкой справа, сцена видна слева и в центре */
@media (min-width: 1200px) and (min-aspect-ratio: 5/4) {
  main.screen.home { margin-left: auto; margin-right: 5vw; max-width: 680px; }
  /* лёгкий туман ~40% цвета темы вокруг колонки игр: сцена слева чистая, справа уходит в дымку */
  html[data-screen="home"] body::before {
    background:
      linear-gradient(to right, transparent calc(100% - 5vw - 680px - 220px), color-mix(in srgb, var(--bg) 40%, transparent) calc(100% - 5vw - 680px - 40px)),
      var(--scene-veil), var(--scene) center / cover no-repeat, var(--bg);
  }
}

:focus-visible { outline: 3px solid var(--highlight); outline-offset: 2px; }

/* ---------- шапка ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background: var(--header-bg);
  color: var(--header-ink);
  border-bottom: 1px solid var(--header-border);
}
[data-theme="y2k"] .topbar { border-bottom-width: 3px; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); }

.logo { font: 700 26px/1 var(--font-display); letter-spacing: .01em; }
[data-theme="y2k"] .logo { font-style: italic; text-shadow: 0 0 12px rgba(74, 114, 214, .8); }

.who-am-i { display: flex; align-items: center; gap: 10px; font-weight: 600; flex-wrap: wrap; justify-content: flex-end; }
.conn { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); }
.conn.on { background: var(--ok); }
.theme-pick { font: 13px var(--font-ui); padding: 4px 6px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); }

/* ---------- кнопки ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  font: 600 15px var(--font-ui);
  color: var(--text);
  background: var(--btn-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--btn-shadow);
  cursor: pointer;
  transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-ok { background: var(--ok); color: var(--ok-ink); border-color: transparent; }
.btn-warn { background: var(--warn); color: var(--warn-ink); border-color: transparent; }
.btn-small { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn-big { min-height: 52px; padding: 0 30px; font-size: 17px; margin-top: 14px; }

/* ---------- экраны и панели ---------- */

.screen { max-width: 620px; margin: 28px auto; padding: 0 16px; }
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  box-shadow: var(--shadow);
}
.panel h1 { margin: 0 0 6px; font: 700 28px/1.15 var(--font-display); }
.lead { margin: 0 0 20px; color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; margin-bottom: 18px; }
input, select { font: inherit; color: var(--text); }
.field input, .join input, .invite input {
  font-size: 16px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.create, .join {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface-2);
  margin-bottom: 12px;
}
.create label, .join label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--muted); }
.create select { min-height: 40px; padding: 0 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.create .check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; color: var(--text); min-height: 40px; }
.create .check input { width: 18px; height: 18px; accent-color: var(--accent); }
.join input { width: 130px; text-transform: uppercase; letter-spacing: 3px; }

#lobby-code { letter-spacing: 4px; color: var(--accent); }
.invite { display: flex; gap: 8px; margin-bottom: 18px; }
.invite input { flex: 1; min-width: 0; font-size: 14px; color: var(--muted); }

.seats { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.seats li {
  display: flex; align-items: center; gap: 12px;
  min-height: 52px; padding: 0 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}
.seats li.empty { color: var(--muted); background: transparent; border-style: dashed; }
.seats .tag { margin-left: auto; font-size: 12px; color: var(--muted); }

.avatar {
  width: 32px; height: 32px; flex: none;
  border-radius: 50%;
  display: inline-grid; place-items: center;
  color: var(--avatar-ink); font-weight: 700; font-size: 14px;
}

/* ---------- игровая комната ---------- */

.room {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 18px;
  max-width: 1200px;
  margin: 18px auto;
  padding: 0 16px;
}
@media (max-width: 900px) { .room { grid-template-columns: 1fr; } }

.table-wrap {
  background: var(--rail);
  border-radius: calc(var(--radius-lg) + 8px);
  padding: 14px;
  box-shadow: var(--shadow);
}

.opponents { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }

.opp {
  min-width: 132px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 2px solid transparent;
  text-align: center;
  color: var(--text);
  transition: border-color .2s, box-shadow .2s;
}
.opp.active { border-color: var(--highlight); box-shadow: 0 0 0 4px color-mix(in srgb, var(--highlight) 25%, transparent); }
.opp.out { opacity: .55; }
.opp .who { display: flex; align-items: center; gap: 8px; justify-content: center; font-weight: 600; }
.opp .bot-note { font-size: 11px; color: var(--muted); }
.opp .count { font-size: 13px; color: var(--muted); }

.badge { display: inline-block; margin-top: 4px; padding: 1px 9px; border-radius: 99px; font-size: 12px; background: var(--surface-2); color: var(--muted); }
.badge.attack { background: var(--badge-attack); color: var(--badge-attack-ink); }
.badge.defend { background: var(--badge-defend); color: var(--badge-defend-ink); }
.badge.take { background: var(--badge-take); color: var(--badge-take-ink); }

.backs { display: flex; justify-content: center; margin-top: 6px; height: 32px; }
.backs .back-mini {
  width: 21px; height: 30px; margin-left: -12px;
  border-radius: 3px;
  background: var(--card-back);
  border: 1.5px solid var(--card-back-border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
}
.backs .back-mini:first-child { margin-left: 0; }

.felt {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) 90px;
  align-items: center;
  gap: 10px;
  min-height: 230px;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: var(--felt);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, .35);
}

/* ---------- карты ---------- */

.card {
  --w: 70px;
  position: relative;
  width: var(--w);
  height: calc(var(--w) * 1.42);
  flex: none;
  border-radius: calc(var(--w) * .1);
  background: var(--card-face);
  border: 1px solid var(--card-edge);
  box-shadow: var(--shadow-card);
  font-family: var(--font-card);
  color: var(--card-black);
  user-select: none;
}
.card.red { color: var(--card-red); }
.card .corner {
  position: absolute; top: 5px; left: 6px;
  font-size: calc(var(--w) * .25); line-height: .95; font-weight: 700; text-align: center;
}
.card .corner small { display: block; font-size: calc(var(--w) * .21); }
.card .corner.br { top: auto; left: auto; bottom: 5px; right: 6px; transform: rotate(180deg); }
.card .pip { position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--w) * .46); }
.card.trumpy::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit;
  box-shadow: inset 0 0 0 2px var(--highlight);
  pointer-events: none;
}
.card.back { background: var(--card-back); border: 3px solid var(--card-back-border); }

.deck { position: relative; height: 112px; }
.deck .trump { position: absolute; left: 30px; top: 18px; transform: rotate(90deg); }
.deck .card.back { position: absolute; left: 0; top: 6px; }
.deck .count, .discard .count { position: absolute; bottom: -10px; left: 0; color: var(--felt-ink); font-size: 12px; white-space: nowrap; }
.deck .empty-trump { color: var(--felt-ink); font-size: 13px; text-align: center; }
.discard { position: relative; height: 112px; display: grid; place-items: center; }
.discard .card.back { transform: rotate(12deg); opacity: .85; }

.table-cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; min-height: 124px; }
.pair { position: relative; width: 90px; height: 124px; }
.pair .card:nth-child(2) { position: absolute; left: 18px; top: 22px; transform: rotate(8deg); }
.pair.target .card:first-child { outline: 3px solid var(--highlight); outline-offset: 2px; cursor: pointer; animation: pulse 1.1s infinite; }
@keyframes pulse { 50% { outline-color: transparent; } }
.table-empty { color: var(--felt-ink); font-style: italic; align-self: center; }

.status {
  display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap;
  margin: 12px 0 8px;
  padding: 10px 14px;
  min-height: 44px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  text-align: center;
  transition: background .2s, color .2s;
}
.status.my-turn { background: var(--accent); color: var(--accent-ink); }

.me { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.hand {
  display: flex; justify-content: center; flex-wrap: nowrap;
  max-width: 100%; overflow-x: auto;
  padding: 22px 12px 6px; min-height: 128px;
  scrollbar-width: none;
}
.hand .card { margin-left: -16px; cursor: default; transition: transform .12s; }
.hand .card:first-child { margin-left: 0; }
.hand .card.playable { cursor: pointer; }
.hand .card.dim { filter: saturate(.6) brightness(.86); }
.hand .card.selected { transform: translateY(-20px); outline: 3px solid var(--highlight); outline-offset: 1px; z-index: 3; }
.actions { display: flex; gap: 10px; min-height: 44px; }

.timer {
  display: inline-block; min-width: 26px; padding: 1px 7px;
  border-radius: 99px; font-size: 12px; font-weight: 700;
  background: var(--badge-attack); color: var(--badge-attack-ink);
}
.timer.low { background: var(--badge-take); color: var(--badge-take-ink); }
.status.my-turn .timer { background: var(--accent-ink); color: var(--accent); }

/* ---------- журнал ---------- */

.side {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  max-height: 640px;
  overflow: auto;
}
.side h2 { margin: 0 0 8px; font: 700 17px var(--font-display); }
.side h2 small { font: 12px var(--font-ui); color: var(--muted); letter-spacing: 1px; margin-left: 4px; }
.log { margin: 0; padding-left: 22px; font-size: 13px; line-height: 1.65; }
.log li.bout { color: var(--muted); list-style: none; margin-left: -22px; border-top: 1px dashed var(--border); margin-top: 4px; padding-top: 2px; }

/* ---------- окна ---------- */

.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: var(--overlay); padding: 16px; }
.dialog {
  max-width: 420px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px 30px;
  text-align: center;
  font: 21px/1.35 var(--font-display);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
}
.dialog .hint { font-family: var(--font-ui); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 11px 18px; border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
  font-size: 14px; z-index: 10; max-width: calc(100vw - 32px);
}

/* ---------- телефон ---------- */

@media (max-width: 600px) {
  .topbar { padding: 8px 12px; }
  .logo { font-size: 22px; }
  .screen { margin: 16px auto; }
  .panel { padding: 18px; }
  .room { padding: 0 8px; margin: 10px auto; }
  .table-wrap { padding: 10px; border-radius: var(--radius-lg); }
  .opp { min-width: 0; flex: 1 1 40%; padding: 8px; }
  .felt { grid-template-columns: 70px minmax(0, 1fr) 54px; min-height: 190px; padding: 12px 8px; gap: 6px; }
  .felt .card, .opp .card { --w: 52px; }
  .deck .trump { left: 18px; }
  .pair { width: 66px; height: 92px; }
  .pair .card { --w: 52px; }
  .pair .card:nth-child(2) { left: 12px; top: 16px; }
  .table-cards { gap: 8px; min-height: 96px; }
  .hand .card { --w: 58px; margin-left: -22px; }
  .hand .card:first-child { margin-left: 0; }
  .actions .btn { flex: 1; }
  .actions { width: 100%; }
}

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

/* ---------- телефон: компактные соперники и шапка ---------- */
.opp .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
@media (max-width: 600px) {
  .who-am-i { gap: 6px; flex-wrap: nowrap; }
  #me-name { display: none; }
  .btn .long { display: none; }
  .theme-pick { max-width: 96px; }
  .opponents { flex-wrap: nowrap; gap: 6px; margin-bottom: 8px; }
  .opp { flex: 1 1 0; min-width: 0; padding: 6px 4px; border-radius: var(--radius-sm); }
  .opp .who { flex-direction: column; gap: 3px; font-size: 13px; max-width: 100%; }
  .opp .who .nm { max-width: 100%; }
  .opp .avatar { width: 26px; height: 26px; font-size: 12px; }
  .opp .backs, .opp .bot-note { display: none; }
  .opp .count { font-size: 12px; }
  .opp .badge { font-size: 11px; padding: 0 6px; margin-top: 2px; }
}

/* =====================================================================
 * Общие компоненты для всех разделов (профиль, чаты, лента, клубы, настройки).
 * Только переменные тем — свои цвета здесь запрещены (проверяет тест тем).
 * ===================================================================== */

a { color: var(--link); }
.card-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.muted { color: var(--muted); }
.divider { height: 1px; background: var(--divider); border: 0; margin: 12px 0; }

.input {
  width: 100%; min-height: 44px; padding: 0 12px;
  font: 16px var(--font-ui); color: var(--text);
  background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.input::placeholder { color: var(--muted); }

.avatar-sm { width: 24px; height: 24px; font-size: 11px; }
.avatar-lg { width: 72px; height: 72px; font-size: 30px; border: 3px solid var(--surface); box-shadow: var(--shadow); }
.avatar-wrap { position: relative; display: inline-block; }
.online-dot { position: absolute; right: 0; bottom: 0; width: 11px; height: 11px; border-radius: 50%; background: var(--online); border: 2px solid var(--surface); }

.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 12px; border-radius: 99px; background: var(--surface-2); color: var(--text); font-size: 13px; border: 1px solid var(--border); }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

/* навигация: снизу на телефоне, сверху на компьютере */
.app-nav { display: flex; gap: 4px; background: var(--nav-bg); border-top: 1px solid var(--border); padding: 6px; }
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: 48px; justify-content: center; border-radius: var(--radius-sm);
  font-size: 12px; color: var(--muted); text-decoration: none;
}
.nav-item .ico { font-size: 18px; line-height: 1; }
.nav-item.active { color: var(--nav-active); background: var(--surface-2); font-weight: 700; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--divider); }
.tab { padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; cursor: pointer; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* списки: друзья, «играли вместе», чаты, участники клуба */
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 12px; border-bottom: 1px solid var(--divider); }
.list-item:last-child { border-bottom: 0; }
.list-item .main { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; }
.list-item .sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .meta { font-size: 12px; color: var(--muted); text-align: right; }
.unread { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700; }

/* профиль */
.profile-head { padding: 0 18px 16px; }
.profile-cover { height: 84px; margin: 0 -18px; background: var(--felt); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.profile-head .avatar-wrap { margin-top: -36px; }
.profile-name { font: 700 22px var(--font-display); margin: 6px 0 0; }
.profile-status { color: var(--muted); font-size: 14px; font-style: italic; }
.stats { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.stat { flex: 1; min-width: 80px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); text-align: center; }
.stat b { display: block; font: 700 18px var(--font-display); }
.stat span { font-size: 12px; color: var(--muted); }

/* чат */
.chat { display: flex; flex-direction: column; gap: 6px; padding: 12px; }
.msg { max-width: 78%; padding: 8px 12px; border-radius: var(--radius); font-size: 15px; line-height: 1.4; }
.msg.other { align-self: flex-start; background: var(--bubble-other); color: var(--bubble-other-ink); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.mine { align-self: flex-end; background: var(--bubble-mine); color: var(--bubble-mine-ink); border-bottom-right-radius: 4px; }
.msg .meta { display: block; font-size: 11px; opacity: .65; margin-top: 2px; text-align: right; }
.msg-author { font-size: 12px; font-weight: 700; color: var(--muted); margin: 6px 0 -2px 4px; }
.composer { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--divider); background: var(--surface); }

/* лента и публикации */
.post { padding: 14px 16px; }
.post-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.post-head .who { font-weight: 600; }
.post-head .when { font-size: 12px; color: var(--muted); }
.post-body { margin: 0 0 10px; }
.post-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.result-card { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--radius); background: var(--felt); color: var(--felt-ink); margin-bottom: 10px; }
.result-card b { color: var(--card-face); font-size: 16px; }

/* настройки: выбор темы */
.theme-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.theme-tile {
  display: flex; flex-direction: column; gap: 8px; padding: 10px; text-align: left;
  border-radius: var(--radius); border: 2px solid var(--border); cursor: pointer;
  background: var(--bg); color: var(--text); font: 600 14px var(--font-ui);
}
.theme-tile.on { border-color: var(--highlight); box-shadow: 0 0 0 3px color-mix(in srgb, var(--highlight) 30%, transparent); }
.theme-tile .swatches { display: flex; gap: 4px; }
.theme-tile .swatches i { width: 18px; height: 18px; border-radius: 5px; border: 1px solid var(--border); }
.theme-tile small { font-weight: 400; color: var(--muted); font-size: 12px; }

.settings-dialog { width: 100%; max-width: 560px; text-align: left; font: 15px/1.45 var(--font-ui); display: grid; gap: 12px; }
.settings-dialog h2 { margin: 0; font: 700 22px var(--font-display); }
.settings-dialog .hint { margin: 0; }
.settings-dialog > .btn { justify-self: end; }

/* =====================================================================
 * Режим «Семья»: просто и крупные цели для пальца (кнопки, карты), шрифт — обычный.
 * Размер текста — отдельная настройка (data-size). Модификатор поверх любой темы.
 * Включается в настройках или сам — за семейным столом.
 * ===================================================================== */

[data-family="on"] .side,
[data-family="on"] .opp .backs,
[data-family="on"] .opp .bot-note,
[data-family="on"] .deck .count,
[data-family="on"] .discard,
[data-family="on"] .create .advanced { display: none !important; }

[data-family="on"] .btn { min-height: 56px; padding: 0 22px; border-radius: var(--radius); }
[data-family="on"] .btn-small { min-height: 44px; }
[data-family="on"] .actions { width: 100%; max-width: 520px; }
[data-family="on"] .actions .btn { flex: 1; min-height: 64px; }

[data-family="on"] .room { grid-template-columns: 1fr; max-width: 820px; }
[data-family="on"] .felt { grid-template-columns: 96px minmax(0, 1fr); }
[data-family="on"] .card { --w: 92px; }
[data-family="on"] .pair { width: 118px; height: 160px; }
[data-family="on"] .pair .card:nth-child(2) { left: 22px; top: 28px; }
[data-family="on"] .hand { min-height: 170px; padding-top: 30px; }
[data-family="on"] .hand .card { margin-left: -14px; }
[data-family="on"] .hand .card:first-child { margin-left: 0; }
[data-family="on"] .hand .card.selected { transform: translateY(-28px); outline-width: 4px; }
[data-family="on"] .hand .card.dim { filter: saturate(.45) brightness(.78); }

[data-family="on"] .timer { min-width: 34px; padding: 2px 9px; }

[data-family="on"] .opp { min-width: 150px; padding: 12px; }
[data-family="on"] .opp .count { color: var(--text); }
[data-family="on"] .opp .badge { padding: 2px 10px; }
[data-family="on"] .avatar { width: 40px; height: 40px; }

/* старт и лобби: сначала «войти по коду», крупное поле */
[data-family="on"] .home .join { order: -1; flex-direction: column; align-items: stretch; }
[data-family="on"] .home .games { order: 0; }
[data-family="on"] .home { display: flex; flex-direction: column; }
[data-family="on"] .home-hero { order: -2; }
[data-family="on"] .home .join label { color: var(--text); }
[data-family="on"] .join input { width: 100%; min-height: 64px; text-align: center; letter-spacing: 8px; }
[data-family="on"] .field input { min-height: 56px; }
[data-family="on"] .seats li { min-height: 60px; }
[data-family="on"] #lobby-code { letter-spacing: 6px; }

@media (max-width: 600px) {
  [data-family="on"] .felt { grid-template-columns: 64px minmax(0, 1fr); padding: 12px 8px; }
  [data-family="on"] .felt .card, [data-family="on"] .pair .card { --w: 66px; }
  [data-family="on"] .pair { width: 84px; height: 116px; }
  [data-family="on"] .pair .card:nth-child(2) { left: 14px; top: 20px; }
  [data-family="on"] .hand .card { --w: 74px; margin-left: -24px; }
  [data-family="on"] .hand .card:first-child { margin-left: 0; }
  [data-family="on"] .opp { min-width: 0; padding: 8px 4px; }
  [data-family="on"] .avatar { width: 32px; height: 32px; }
  [data-family="on"] .actions .btn { min-height: 60px; }
}

/* переключатель в настройках */
.switch-row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); cursor: pointer; }
.switch-row .text { flex: 1; }
.switch-row .text b { display: block; }
.switch-row .text small { color: var(--muted); }
.switch { position: relative; width: 52px; height: 30px; flex: none; border-radius: 99px; background: var(--border); transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-card); transition: left .15s; }
.switch.on { background: var(--ok); }
.switch.on::after { left: 25px; }

/* ---------- телефон и нативная оболочка ----------
 * Наведение только там, где есть мышь: на телефоне :hover «залипает» после касания.
 * Вырезы и полосы экрана (safe area) учитываются в шапке, нижних полосах и окнах.
 * touch-action: manipulation убирает задержку и масштаб от двойного касания —
 * важно для режима «Семья», где карта кладётся вторым касанием.
 */
@media (hover: hover) {
  .btn:hover { filter: brightness(.98); }
  .btn-primary:hover { background: var(--accent-hover); filter: none; }
  .hand .card.playable:hover { transform: translateY(-10px); z-index: 2; }
}
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
/* без «резиновой» прокрутки: шапка и подвал не отрываются от краёв окна. Работает только на корневом элементе;
   фон html — цвет темы: там, где браузер всё же чуть тянет страницу, за краем не видно чужого цвета */
html, body { overscroll-behavior: none; }
html { background: var(--bg); }
button, .btn, .card, .pair, .switch-row, .theme-tile, .nav-item { touch-action: manipulation; }
.card, .hand, .table-cards, .opponents, .btn { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.topbar {
  padding-top: max(10px, env(safe-area-inset-top));
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
}
.screen, .room { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
body { padding-bottom: env(safe-area-inset-bottom); }
.toast { bottom: calc(24px + env(safe-area-inset-bottom)); }
.overlay { padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.app-nav { padding-bottom: max(6px, env(safe-area-inset-bottom)); }
@media (max-width: 600px) {
  .topbar { padding-top: max(8px, env(safe-area-inset-top)); padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .room { padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
  .invite { flex-wrap: wrap; }
  .invite input { flex-basis: 100%; }
  .invite .btn { flex: 1; }
}

/* ---------- главная, профиль, правила ---------- */

a.logo { color: inherit; text-decoration: none; }
.home { max-width: 760px; }
.home-hero { padding: 18px 20px; border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); }
.home-hero h1 { margin: 0 0 6px; font: 700 32px/1.15 var(--font-display); }
.home-hero .lead { margin-bottom: 18px; }
.games { display: grid; gap: 12px; margin-bottom: 16px; }
.game-card {
  display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; align-items: center; gap: 16px;
  padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.game-icon { width: 64px; height: 64px; display: grid; place-items: center; font-size: 34px; border-radius: var(--radius); background: var(--felt); }
.game-main h2 { margin: 0 0 2px; font: 700 22px var(--font-display); }
.game-main p { margin: 0; color: var(--muted); font-size: 14px; }
.game-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.soon-card .game-icon { filter: saturate(.5); }
.soon { margin-left: 6px; font-size: 11px; font-weight: 600; opacity: .85; }
.home .join { margin-bottom: 8px; }
.home-foot { text-align: center; font-size: 13px; color: var(--muted); }
.home-foot a, .rules a:not(.btn), .adult a { color: var(--link); }
.btn-back { margin-bottom: 12px; }

.profile-chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 2px 12px 2px 2px;
  border: 1px solid var(--header-border); border-radius: 99px; background: transparent; color: inherit;
  font: 600 14px var(--font-ui); cursor: pointer;
}
.avatar-emoji { background: var(--surface-2); border: 1px solid var(--border); font-size: 19px; line-height: 1; }
.avatar-emoji.avatar-lg { font-size: 40px; }
.profile-chip .avatar { width: 30px; height: 30px; font-size: 17px; }

.profile-dialog { width: 100%; max-width: 520px; max-height: calc(100dvh - 32px); overflow: auto; text-align: left; font: 15px/1.45 var(--font-ui); display: grid; gap: 14px; }
.profile-dialog h2 { margin: 0; font: 700 24px var(--font-display); }
.profile-dialog .hint { margin: 0; }
.profile-dialog .field { margin: 0; }
.profile-dialog fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.profile-dialog legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
.profile-dialog .check { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.profile-dialog .check input { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
.profile-dialog .adult { padding: 12px; border-radius: var(--radius); background: var(--surface-2); }
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px; }
.avatar-option {
  aspect-ratio: 1; display: grid; place-items: center; font-size: 28px; line-height: 1;
  border: 2px solid transparent; border-radius: var(--radius); background: var(--surface-2); cursor: pointer;
}
.avatar-option.on { border-color: var(--highlight); background: var(--surface); box-shadow: 0 0 0 3px color-mix(in srgb, var(--highlight) 30%, transparent); }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; }
.dialog-actions .btn { min-width: 120px; }

.settings-profile { width: 100%; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.settings-profile .go { font-size: 22px; color: var(--muted); }

.rules { max-width: 760px; }
.rules h2 { font: 700 20px var(--font-display); margin: 26px 0 8px; }
.rules table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 8px 0; }
.rules th, .rules td { text-align: left; padding: 8px; border-bottom: 1px solid var(--divider); vertical-align: top; }

@media (max-width: 600px) {
  .home-hero h1 { font-size: 26px; }
  .game-card { grid-template-columns: 52px minmax(0, 1fr); gap: 12px; padding: 14px; }
  .game-icon { width: 52px; height: 52px; font-size: 28px; }
  .game-actions { grid-column: 1 / -1; justify-content: stretch; }
  .game-actions .btn { flex: 1; }
  .profile-chip { padding-right: 2px; }
  .profile-chip #me-name { display: none; }
}

/* ---------- камера и микрофон за столом ---------- */

.media-bar {
  display: flex; justify-content: center; gap: 8px;
  padding: 6px max(12px, env(safe-area-inset-left));
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.media-toggle {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px;
  border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  font: 600 13px var(--font-ui); cursor: pointer;
}
.media-toggle .ico { filter: grayscale(1); opacity: .6; }
.media-toggle .state { font-weight: 400; }
.media-toggle.on { color: var(--ok-ink); background: var(--ok); border-color: transparent; }
.media-toggle.on .ico { filter: none; opacity: 1; }
[data-family="on"] .media-toggle { min-height: 48px; padding: 0 20px; }

/* ---------- подбор: «Собираем стол», кто сядет за стол ---------- */

.gather { display: grid; gap: 10px; margin: 4px 0 16px; padding: 16px; border-radius: var(--radius); background: var(--surface-2); }
.gather-count { display: flex; align-items: center; gap: 12px; font-size: 18px; }
.gather-count b { white-space: nowrap; }
.gather-bar { flex: 1; height: 10px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); overflow: hidden; }
.gather-bar i { display: block; height: 100%; background: var(--ok); transition: width .3s; }
.gather-status { margin: 0; color: var(--text); }
.btn-wide { width: 100%; margin-top: 0; }
.lobby-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.who-sits { flex-basis: 100%; border: 0; padding: 0; margin: 0; display: grid; gap: 6px; }
.who-sits legend { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; padding: 0; }
.create .who-sits .check { align-items: flex-start; min-height: 0; padding: 6px 0; }
.who-sits .check input { margin-top: 2px; flex: none; }
.who-sits small { display: block; color: var(--muted); font-size: 12px; }

/* ---------- чат стола, игрок, жалоба ---------- */

.chat-slot { margin-top: 14px; }
.table-chat { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.table-chat .chat { height: 240px; overflow-y: auto; overscroll-behavior: contain; }
.side .table-chat { border: 0; border-radius: 0; margin: 0 -16px -14px; }
.side .chat-slot { margin-top: 0; }
.side .table-chat .chat { height: 380px; }
.chat-empty { margin: auto; color: var(--muted); font-size: 13px; text-align: center; padding: 0 12px; }
.chat-note { margin: 0; padding: 6px 12px 0; font-size: 12px; }
button.msg-author { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; border: 0; background: none; padding: 0; cursor: pointer; font: 700 12px var(--font-ui); color: var(--muted); }
button.msg-author .avatar { width: 22px; height: 22px; font-size: 13px; }
.msg { overflow-wrap: anywhere; white-space: pre-wrap; }
.composer .input { flex: 1; min-width: 0; }
.side-tabs { margin: -6px -4px 10px; }
.side-tabs .tab { background: none; border-top: 0; border-left: 0; border-right: 0; font: 600 14px var(--font-ui); display: inline-flex; align-items: center; gap: 6px; }
.side-tabs .tab small { font-size: 11px; letter-spacing: 1px; font-weight: 400; }
.log-pane { max-height: 420px; overflow: auto; }
.side { max-height: none; }
.seats li.clickable, .opp .who[data-person] { cursor: pointer; }

.person-dialog { width: 100%; max-width: 380px; display: grid; gap: 10px; font: 15px/1.45 var(--font-ui); }
.person-head { display: flex; flex-direction: column; align-items: center; gap: 8px; font: 700 20px var(--font-display); margin-bottom: 6px; }
.person-head .avatar { width: 64px; height: 64px; }
.report-dialog { width: 100%; max-width: 520px; max-height: calc(100dvh - 32px); overflow: auto; text-align: left; font: 15px/1.45 var(--font-ui); display: grid; gap: 12px; }
.report-dialog h2 { margin: 0; font: 700 22px var(--font-display); }
.report-dialog fieldset { border: 0; padding: 0; margin: 0; }
.report-dialog legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
.report-dialog .hint { margin: 0; }
.report-dialog .field { margin: 0; }
.report-dialog textarea { min-height: 72px; padding: 10px 12px; resize: vertical; font: inherit; }
.report-reasons { display: grid; gap: 2px; }
.report-dialog .check { display: flex; align-items: flex-start; gap: 10px; min-height: 36px; padding: 4px 0; }
.report-dialog .check input { width: 18px; height: 18px; margin-top: 2px; flex: none; accent-color: var(--accent); }

[data-family="on"] .table-chat .chat { height: 280px; }
@media (max-width: 600px) {
  .table-chat .chat { height: 200px; }
  .side .table-chat .chat { height: 260px; }
}

/* ---------- счётчики на главной ---------- */
.game-main .game-stats { margin-top: 6px; font-size: 13px; color: var(--muted); }
.game-main .game-stats.live::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--online); vertical-align: 1px; }
.game-main .game-stats:empty { display: none; }

/* ---------- аватары-картинки ---------- */
img.avatar { display: inline-block; object-fit: cover; background: var(--surface-2); border: 1px solid var(--border); padding: 0; }
.avatar-option { padding: 3px; overflow: hidden; }
.avatar-option img { width: 100%; height: 100%; object-fit: cover; border-radius: calc(var(--radius) - 3px); display: block; }
.avatar-grid { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
.profile-chip img.avatar { width: 30px; height: 30px; }
button.msg-author img.avatar { width: 22px; height: 22px; }
.person-head img.avatar { width: 88px; height: 88px; }

/* ---------- квиз ---------- */

.quiz-wrap { display: grid; gap: 14px; align-content: start; }
.quiz-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 600; color: var(--muted); }
.quiz-top .timer { font-size: 15px; min-width: 40px; text-align: center; }
.quiz-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: 22px 22px 18px; display: grid; gap: 14px;
}
.quiz-kicker { margin: 0; font-size: 13px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.quiz-kicker:empty { display: none; }
.quiz-question { margin: 0; font: 700 24px/1.3 var(--font-display); }
.quiz-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quiz-option {
  display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 14px; text-align: left;
  border: 2px solid var(--border); border-radius: var(--radius); background: var(--surface-2); color: var(--text);
  font: 600 17px/1.25 var(--font-ui); cursor: pointer; transition: border-color .15s, background .15s;
}
.quiz-option b { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--surface); border: 1px solid var(--border); font-size: 14px; }
.quiz-option:disabled { cursor: default; }
.quiz-option.picked { border-color: var(--accent); background: var(--surface); }
.quiz-option.picked b { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.quiz-option.right { border-color: var(--ok); background: var(--ok); color: var(--ok-ink); }
.quiz-option.right b { background: var(--ok-ink); color: var(--ok); border-color: transparent; }
.quiz-option.wrong { border-color: var(--warn); opacity: .85; }
.quiz-option.wrong > span { text-decoration: line-through; }
@media (hover: hover) { .quiz-option:not(:disabled):hover { border-color: var(--highlight); } }
.quiz-text { display: flex; gap: 8px; }
.quiz-text .input { flex: 1; min-width: 0; min-height: 48px; font-size: 17px; }
.quiz-status { margin: 0; color: var(--muted); font-size: 14px; }
.quiz-status.reveal { color: var(--text); font-size: 16px; padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); }
.quiz-scores { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.quiz-scores li { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.quiz-scores li.mine { border-color: var(--highlight); }
.quiz-scores .nm { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.quiz-scores .nm small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quiz-scores .pts { font: 700 22px var(--font-display); min-width: 28px; text-align: right; }
.quiz-scores .tick { color: var(--ok); font-weight: 700; }
[data-family="on"] .quiz-option { min-height: 72px; }
[data-family="on"] .quiz-options { grid-template-columns: 1fr; }
@media (max-width: 600px) {
  .quiz-card { padding: 16px; }
  .quiz-question { font-size: 20px; }
  .quiz-options { grid-template-columns: 1fr; }
  .quiz-option { min-height: 54px; font-size: 16px; }
}

/* ---------- дурак: что произошло, закрытый бит, новые карты ---------- */

/* подсказка «что произошло» — вне стола, мелко, над ним */
.event { grid-column: 1 / -1; margin: 0 0 -8px; min-height: 20px; text-align: center; font-size: 13px; color: var(--muted); }
.event:empty { visibility: hidden; }
.event.flash { animation: event-in .8s ease-out; }
@keyframes event-in { from { color: var(--text); } }
.card.fresh { animation: card-in .6s ease-out; }
@keyframes card-in { from { transform: translateY(-14px) scale(1.06); box-shadow: 0 0 0 4px var(--highlight); } }
.pair .card.fresh:nth-child(2) { animation-name: card-in-def; }
@keyframes card-in-def { from { transform: rotate(8deg) translateY(-14px) scale(1.06); box-shadow: 0 0 0 4px var(--highlight); } }
.last-bout { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.last-bout-label { padding: 1px 10px; border-radius: 99px; background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 600; }
.last-bout.took .last-bout-label { background: var(--badge-take); color: var(--badge-take-ink); }
.last-bout-cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; animation: to-discard 2.5s ease-in forwards; }
.last-bout.took .last-bout-cards { animation-name: to-taker; }
/* первую секунду бит виден целиком (последняя карта легла), потом карты уезжают */
@keyframes to-discard { 0%, 45% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateX(45%) scale(.7) rotate(8deg); } }
@keyframes to-taker { 0%, 45% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-70%) scale(.7); } }
[data-family="on"] .event { color: var(--text); }

/* ---------- квиз: выбор уровня и формата, «на вылет» ---------- */
.choice-form { display: grid; gap: 18px; }
.choice-group { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.choice-group legend { font-weight: 700; margin-bottom: 6px; padding: 0; }
.choice { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 2px solid var(--border); border-radius: var(--radius); background: var(--surface-2); cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--surface); }
.choice input { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
.choice span { display: flex; flex-direction: column; }
.choice small { color: var(--muted); font-size: 13px; }
.quiz-scores li.out { opacity: .55; }
.quiz-scores li.out .nm { text-decoration: line-through; }
.quiz-scores .gone { font-size: 12px; color: var(--muted); }

/* ---------- стол не дёргается: у блоков постоянная высота ----------
 * Подсказки, статус, соперники и сукно меняют текст и число карт, но не размер:
 * длинный текст обрезается, пустые строки резервируют место.
 */
.event { height: 20px; line-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status { height: 64px; min-height: 0; overflow: hidden; line-height: 1.3; }
.opp .bot-note, .opp .count { height: 16px; line-height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opp .badge.empty { visibility: hidden; }
.opp .backs { height: 24px; overflow: hidden; }
.felt { height: 290px; min-height: 0; }
.table-cards { align-content: center; max-height: 100%; overflow: hidden; }
.hand { height: 150px; min-height: 0; align-items: flex-end; }
.actions { height: 44px; }
.dialog-actions.center { justify-content: center; flex-wrap: wrap; }
@media (max-width: 600px) {
  .felt { height: 232px; }
  .hand { height: 124px; }
  .status { height: 60px; font-size: 14px; }
}
[data-family="on"] .event { height: 26px; line-height: 26px; }
[data-family="on"] .status { height: 84px; }
[data-family="on"] .hand { height: 170px; }
[data-family="on"] .actions { height: 64px; }
@media (max-width: 600px) { [data-family="on"] .hand { height: 140px; } }

/* карта, закрывшая бит, светится, пока бит на столе */
.last-bout .card.fresh { animation: none; box-shadow: 0 0 0 3px var(--highlight), var(--shadow-card); }

/* ---------- размер текста (настройка) и окна поверх страницы ----------
 * Размер текста масштабирует всю страницу целиком (zoom): пропорции, отступы и
 * фиксированные высоты стола растут вместе с текстом, ничего не ломается.
 * Режим «Семья» шрифт не увеличивает — только кнопки, карты и простоту.
 */
[data-size="large"] body { zoom: 1.12; }
[data-size="xlarge"] body { zoom: 1.25; }
html.modal-open, html.modal-open body { overflow: hidden; }
.overlay { overflow-y: auto; overscroll-behavior: contain; align-items: start; }
.overlay > .dialog { margin: auto 0; }
.settings-dialog { max-height: none; }
.settings-section { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--divider); }
.settings-section h3 { margin: 0; font: 700 13px var(--font-ui); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.settings-foot { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.settings-foot a { color: var(--link); }
.segmented { display: flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
.segmented button { flex: 1; min-height: 44px; padding: 0 12px; border: 0; border-right: 1px solid var(--border); background: transparent; color: var(--text); font: 600 14px var(--font-ui); cursor: pointer; }
.segmented button:last-child { border-right: 0; }
.segmented button.on { background: var(--accent); color: var(--accent-ink); }

/* полировка: название и подпись в строке профиля — друг под другом, имя не слипается с подписью */
.settings-profile .main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.settings-profile .title { font-weight: 700; }
.settings-profile .sub { white-space: normal; }
.seats li .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-trump .trump-suit { font-size: 22px; }
.rules-lang a { color: var(--header-ink); font-size: 14px; }

/* темы в настройках — по две в ряд и на телефоне */
@media (max-width: 600px) { .theme-tiles { grid-template-columns: 1fr 1fr; } }

/* «Ошибка в вопросе?» — неприметно, внизу карточки */
.link-btn { justify-self: start; padding: 0; border: 0; background: none; color: var(--muted); font: 13px var(--font-ui); text-decoration: underline; cursor: pointer; }
.q-report { display: grid; gap: 8px; }
.q-report textarea { min-height: 56px; padding: 8px 10px; font: inherit; resize: vertical; }

/* ---------- мафия ---------- */

.mafia-wrap { display: grid; gap: 12px; align-content: start; }
.mafia-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mafia-phase { font: 700 20px var(--font-display); }
.mafia-role { display: grid; gap: 4px; padding: 12px 14px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.mafia-role b { font: 700 17px var(--font-display); }
.mafia-role small { color: var(--muted); font-size: 13px; line-height: 1.4; }
.mafia-role.role-mafia, .mafia-role.role-don { border-color: var(--warn); }
.mafia-role.role-sheriff, .mafia-role.role-doctor { border-color: var(--ok); }
.mafia-seats { list-style: none; margin: 0; padding: 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; border-radius: var(--radius-lg); background: var(--felt); box-shadow: inset 0 0 40px rgba(0, 0, 0, .35); }
.mafia-seat { position: relative; display: grid; grid-template-columns: auto auto 1fr; grid-template-rows: auto auto; align-items: center; column-gap: 8px; row-gap: 4px; min-height: 64px; padding: 8px 10px; border-radius: var(--radius); background: var(--surface); border: 2px solid transparent; color: var(--text); }
.mafia-seat .no { grid-row: 1 / 3; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); font: 700 13px var(--font-ui); }
.mafia-seat .avatar { grid-row: 1 / 3; width: 36px; height: 36px; }
.mafia-seat .nm { font-weight: 600; min-width: 0; line-height: 1.2; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.mafia-seat .tags { grid-column: 3; display: flex; flex-wrap: wrap; gap: 4px; min-height: 18px; }
.mafia-seat .tag { padding: 0 7px; border-radius: 99px; font-size: 11px; line-height: 18px; background: var(--surface-2); color: var(--muted); }
.mafia-seat .tag.speak { background: var(--accent); color: var(--accent-ink); }
.mafia-seat .tag.nom { background: var(--badge-attack); color: var(--badge-attack-ink); }
.mafia-seat .tag.shot { background: var(--badge-take); color: var(--badge-take-ink); }
.mafia-seat .tag.role-mafia, .mafia-seat .tag.role-don { background: var(--warn); color: var(--warn-ink); }
.mafia-seat .tag.role-sheriff, .mafia-seat .tag.role-doctor { background: var(--ok); color: var(--ok-ink); }
.mafia-seat.mine { border-color: var(--border); }
.mafia-seat.speaking { border-color: var(--highlight); box-shadow: 0 0 0 3px color-mix(in srgb, var(--highlight) 35%, transparent); }
.mafia-seat.out { opacity: .68; }
.mafia-seat.out .avatar { filter: grayscale(.7); }
.mafia-seat.out .nm { text-decoration: line-through; }
.mafia-seat.targetable { cursor: pointer; }
@media (hover: hover) { .mafia-seat.targetable:hover { border-color: var(--accent); } }
.mafia-seat.picked { border-color: var(--accent); background: var(--surface-2); }
.mafia-panel { display: grid; gap: 10px; min-height: 108px; padding: 12px 14px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); }
.mafia-prompt { margin: 0; font-weight: 600; min-height: 40px; }
.mafia-actions { display: flex; flex-wrap: wrap; gap: 8px; min-height: 44px; }
@media (max-width: 600px) {
  .mafia-seats { grid-template-columns: 1fr 1fr; padding: 8px; gap: 6px; }
  .mafia-seat { padding: 6px 8px; min-height: 58px; }
  .mafia-actions .btn { flex: 1; }
}

/* закрытый канал (ночная мафия) */
.msg-private { border: 1px dashed var(--warn); }
.msg-channel { display: block; font-size: 11px; font-weight: 700; color: var(--warn); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }

/* ===================================================================
   Бренд-элементы тем (docs/brand.md). Взяты из концептов «пять стилей»:
   сцена за интерфейсом, шапка-стекло, логотип и табличка заголовка,
   плитки игр с иллюстрациями, кнопки, записка с кодом стола, кольцо аватара.
   Цвета — только через токены темы; правила [data-theme] задают форму.
   =================================================================== */

/* шапка поверх сцены */
.topbar {
  background: var(--header-glass);
  -webkit-backdrop-filter: blur(12px) saturate(1.15);
  backdrop-filter: blur(12px) saturate(1.15);
}

/* логотип: везде прописными, характер — от темы */
.logo > .logo-name { display: inline-block; text-transform: uppercase; letter-spacing: .08em; }
[data-theme="classic"] .logo > .logo-name { font-weight: 400; letter-spacing: .16em; color: var(--plate-ink); }
[data-theme="classic"] .logo > .logo-name::before,
[data-theme="classic"] .logo > .logo-name::after { content: "♣"; font-size: .45em; vertical-align: .55em; margin: 0 .5em; color: var(--highlight); letter-spacing: 0; }
[data-theme="home"] .logo > .logo-name { letter-spacing: .06em; padding-bottom: 3px; background: linear-gradient(var(--highlight), var(--highlight)) 50% 100% / 70% 1.5px no-repeat; }
[data-theme="evening"] .logo > .logo-name { font-weight: 400; letter-spacing: .18em; }
[data-theme="y2k"] .logo > .logo-name { font-family: var(--font-ui); font-style: italic; font-weight: 800; letter-spacing: .02em; padding-bottom: 4px; background: linear-gradient(var(--accent), var(--accent)) 0 100% / 100% 3px no-repeat; text-shadow: none; }
[data-theme="y2k"] .logo { text-shadow: none; }
[data-theme="nineties"] .logo > .logo-name {
  padding: 3px 10px 2px; font-weight: 800; letter-spacing: .03em;
  background: var(--plate-bg); color: var(--plate-ink);
  transform: rotate(-2deg);
  clip-path: polygon(0 6%, 8% 0, 22% 5%, 40% 1%, 58% 6%, 76% 0, 92% 4%, 100% 0, 98% 52%, 100% 100%, 82% 95%, 64% 100%, 46% 94%, 28% 100%, 12% 95%, 0 100%, 2% 48%);
}

/* главная: сцена видна, заголовок — на табличке */
.home-hero { background: none; box-shadow: none; padding: 4vh 0 14px; text-align: center; }
.home-hero h1 {
  display: inline-block; margin: 0; padding: 8px 24px;
  background: var(--plate-bg); color: var(--plate-ink);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.home-hero .lead {
  display: block; width: fit-content; max-width: 100%; margin: 10px auto 0; padding: 6px 14px;
  background: var(--plate-bg); color: var(--plate-ink); border-radius: var(--radius); font-size: 14px;
}
[data-theme="classic"] .home-hero h1 { font-style: italic; font-weight: 400; border: 1px solid color-mix(in srgb, var(--highlight) 55%, transparent); }
[data-theme="home"] .home-hero h1 { border-radius: 99px; font-weight: 600; }
[data-theme="evening"] .home-hero h1 { font-weight: 400; }
[data-theme="y2k"] .home-hero h1 { font-family: var(--font-ui); font-weight: 800; background: linear-gradient(var(--accent), var(--accent)) 50% calc(100% - 4px) / 60% 3px no-repeat, var(--plate-bg); }
[data-theme="nineties"] .home-hero h1 {
  font-family: var(--font-ui); font-style: italic; font-weight: 700; border-radius: 0; transform: rotate(-1.5deg);
  clip-path: polygon(0 4%, 10% 0, 30% 4%, 52% 0, 74% 5%, 100% 0, 99% 50%, 100% 100%, 78% 96%, 55% 100%, 33% 95%, 12% 100%, 0 96%, 1% 50%);
}
[data-theme="nineties"] .home-hero .lead { border-radius: 0; }

/* плитки игр: иллюстрация слева, как в концептах */
.game-icon { width: 96px; height: 76px; font-size: 0; background: var(--felt) center / cover no-repeat; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); }
.game-icon[data-game="durak"] { background-image: var(--art-durak); }
.game-icon[data-game="quiz"] { background-image: var(--art-quiz); }
.game-icon[data-game="mafia"] { background-image: var(--art-mafia); }
.game-card { grid-template-columns: 96px minmax(0, 1fr) auto; }
[data-theme="classic"] .game-card { border-color: color-mix(in srgb, var(--highlight) 45%, transparent); box-shadow: inset 0 0 0 3px var(--surface), inset 0 0 0 4px color-mix(in srgb, var(--highlight) 18%, transparent), var(--shadow); }
[data-theme="evening"] .game-card,
[data-theme="y2k"] .game-card { background: color-mix(in srgb, var(--surface) 90%, transparent); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
[data-theme="y2k"] .game-card { border-color: color-mix(in srgb, var(--header-border) 55%, transparent); }
@media (max-width: 600px) {
  .game-card { grid-template-columns: 76px minmax(0, 1fr); }
  .game-icon { width: 76px; height: 62px; }
}

/* кнопки: основная — материал темы (бордо, терракота, янтарь, лайм) */
.btn-primary { background: var(--btn-primary-bg); box-shadow: var(--btn-primary-shadow); }
@media (hover: hover) { .btn-primary:hover { background: var(--btn-primary-bg); filter: brightness(1.07); } }
.btn-primary:focus-visible { outline-color: var(--ring); }

/* вход по коду — та же плотная панель, что и плитки */
.home .join { background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }

/* записка с кодом стола: бумажка на кнопке/булавке */
.table-note {
  position: relative; width: fit-content; min-width: 200px; margin: 6px auto 18px; padding: 16px 26px 12px;
  display: grid; justify-items: center; gap: 2px;
  background: var(--note-bg); color: var(--note-ink);
  border-radius: 3px; transform: rotate(-1.5deg);
  box-shadow: 0 1px 1px rgba(0, 0, 0, .15), 0 6px 14px rgba(0, 0, 0, .22);
}
.table-note::before {
  content: ""; position: absolute; top: -7px; left: 50%; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, color-mix(in srgb, var(--note-bg) 80%, transparent), transparent 45%), var(--note-pin);
  box-shadow: 0 2px 3px rgba(0, 0, 0, .35);
}
.table-note .note-label { font: 600 14px var(--font-ui); }
.table-note b { font: 400 36px/1.1 var(--font-note); letter-spacing: 3px; border-bottom: 2px solid currentColor; padding: 0 6px 2px; }
[data-theme="classic"] .table-note b { font-weight: 700; border-bottom-width: 1px; }
[data-family="on"] .table-note b { font-size: 44px; }

/* кольцо аватара: свой профиль и активный игрок */
.profile-chip .avatar, .profile-chip img.avatar { box-shadow: 0 0 0 2px var(--ring); }
.opp.active { border-color: var(--ring); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ring) 28%, transparent); }
.opp.active .avatar { box-shadow: 0 0 0 2px var(--ring), 0 0 10px var(--ring); }

/* ---------- игровой экран: стол из сцены темы ---------- */

/* стол — поверхность из сцены (сукно, дерево, клеёнка) в бортике темы; свет лампы и затемнение к краям */
.table-wrap { background: none; box-shadow: none; padding: 4px 0 0; }
.felt, .mafia-seats {
  border: 10px solid transparent;
  border-radius: calc(var(--radius-lg) + 14px);
  background:
    radial-gradient(ellipse at 50% 38%, var(--table-light), transparent 62%) padding-box,
    radial-gradient(ellipse at 50% 50%, transparent 52%, rgba(0, 0, 0, .42)) padding-box,
    var(--table-tint) padding-box,
    var(--table-surface) 0 0 / auto padding-box,
    var(--felt) padding-box,
    var(--rail) border-box;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .35), inset 0 6px 18px rgba(0, 0, 0, .35), var(--shadow);
}
[data-theme="classic"] .felt, [data-theme="classic"] .mafia-seats { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--highlight) 45%, transparent), inset 0 6px 18px rgba(0, 0, 0, .35), var(--shadow); }
.deck .count, .discard .count, .felt .empty, .deck .empty-trump { text-shadow: 0 1px 2px rgba(0, 0, 0, .7); }

/* соперники — таблички с портретом в кольце; число карт — фишка */
.opp { background: var(--plate-bg); color: var(--plate-ink); border: 1px solid var(--border); box-shadow: var(--shadow); }
.opp .avatar { width: 36px; height: 36px; box-shadow: 0 0 0 2px var(--border); }
.opp.active { border-color: var(--ring); }
.opp.active .avatar { box-shadow: 0 0 0 2px var(--ring), 0 0 12px var(--ring); }
.opp .bot-note, .opp .count { color: color-mix(in srgb, var(--plate-ink) 70%, transparent); }

/* строка хода — табличка; таймер — крупными цифрами */
.status { background: var(--plate-bg); color: var(--plate-ink); border: 1px solid var(--border); box-shadow: var(--shadow); }
.status.my-turn { background: var(--btn-primary-bg); color: var(--accent-ink); border-color: transparent; box-shadow: var(--btn-primary-shadow); }
.timer { min-width: 34px; padding: 2px 8px; font: 700 15px/1.2 var(--font-display); font-variant-numeric: tabular-nums; text-align: center; }
.status.my-turn .timer { background: var(--accent-ink); color: var(--accent); }

/* квиз: вопрос — карточка-табличка, очки — фишки */
.quiz-card { border-top: 4px solid var(--accent); }
.quiz-scores li { background: var(--plate-bg); color: var(--plate-ink); }
.quiz-scores li.mine { border-color: var(--ring); box-shadow: 0 0 0 2px color-mix(in srgb, var(--ring) 35%, transparent); }
.quiz-scores .avatar { box-shadow: 0 0 0 2px var(--border); }
.quiz-scores li.mine .avatar { box-shadow: 0 0 0 2px var(--ring); }
.quiz-scores .pts { min-width: 44px; padding: 2px 8px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); text-align: center; font-variant-numeric: tabular-nums; }
.quiz-scores .nm small { color: color-mix(in srgb, var(--plate-ink) 70%, transparent); }

/* мафия: места за общим столом, говорящий — в кольце */
.mafia-seats { padding: 14px; }
.mafia-seat { background: var(--plate-bg); color: var(--plate-ink); box-shadow: var(--shadow-card); }
.mafia-seat .avatar { box-shadow: 0 0 0 2px var(--border); }
.mafia-role { border-top: 4px solid var(--accent); }

/* полоса камеры и микрофона — то же стекло, что и шапка */
.media-bar { background: var(--header-glass); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-bottom-color: var(--header-border); }
.mafia-seat.speaking { border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 35%, transparent), var(--shadow-card); }
.mafia-seat.speaking .avatar { box-shadow: 0 0 0 2px var(--ring), 0 0 12px var(--ring); }
.btn-leave .long { margin-left: .3em; }

/* место в мафии: номер — значок на портрете, имени остаётся вся ширина (на телефоне имена не рвутся по буквам) */
.mafia-seat { grid-template-columns: auto minmax(0, 1fr); isolation: isolate; }
.mafia-seat .avatar { grid-column: 1; }
.mafia-seat .no { position: absolute; top: 4px; left: 4px; z-index: 1; width: 20px; height: 20px; font-size: 11px; border: 1px solid var(--border); }
.mafia-seat .nm, .mafia-seat .tags { grid-column: 2; }
.mafia-seat .nm { overflow-wrap: break-word; }

/* верхняя строка квиза и мафии — табличка, как строка хода в дураке */
.quiz-top, .mafia-top { padding: 8px 12px; border-radius: var(--radius); background: var(--plate-bg); color: var(--plate-ink); border: 1px solid var(--border); box-shadow: var(--shadow); }

/* квиз на телефоне: поле ответа во всю ширину, кнопка под ним — подсказка в поле не обрезается */
@media (max-width: 480px) {
  .quiz-text { flex-wrap: wrap; }
  .quiz-text .input { flex-basis: 100%; }
  .quiz-text .btn { flex: 1; }
}

/* кнопка-иконка (настройки): квадрат 40×40, иконка цвета текста шапки */
.btn-icon { width: 40px; min-width: 40px; height: 40px; min-height: 40px; padding: 0; border-radius: 50%; color: inherit; }
.topbar .btn-icon { color: var(--text); }
.btn-icon svg { display: block; }

/* закрыли окно итога — кнопка, чтобы вернуться к нему */
.result-chip { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20; box-shadow: var(--btn-primary-shadow), var(--shadow); }
[data-theme="nineties"] .deck .count, [data-theme="nineties"] .discard .count, [data-theme="nineties"] .felt .empty, [data-theme="nineties"] .deck .empty-trump { text-shadow: none; font-weight: 600; }

/* живая сцена — холст под интерфейсом (src/ui/scene-fx.ts) */
.scene-canvas { position: fixed; top: 0; left: 0; width: 100%; height: 100vh; height: 100lvh; transform: translateZ(0); z-index: -1; pointer-events: none; }

/* ---------- вход: Яндекс ID / VK ID (ADR 0004) ---------- */
.login-dialog { width: 100%; max-width: 460px; display: grid; gap: 12px; text-align: left; font: 15px/1.45 var(--font-ui); }
.login-dialog h2 { margin: 0; font: 700 24px var(--font-display); }
.login-dialog .hint { margin: 0; }
.login-consent { display: flex; align-items: flex-start; gap: 10px; padding: 12px; border-radius: var(--radius); background: var(--surface-2); cursor: pointer; }
.login-consent input { width: 20px; height: 20px; margin-top: 1px; flex: none; accent-color: var(--accent); }
.login-consent a, .login-dialog a { color: var(--link); }
.login-buttons { display: grid; gap: 8px; }
.btn-login { justify-content: flex-start; gap: 12px; min-height: 48px; padding: 0 16px; background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow-card); }
.btn-login svg { flex: none; border-radius: 6px; }
.btn-login:disabled { opacity: .45; }
.settings-account { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.settings-account .main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.settings-account .title { font-weight: 600; }
.settings-account .sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-login { margin: 0 12px 8px; }

/* ---------- видео за столом (ADR 0005) ---------- */
.video-strip {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: thin;
  padding: 8px max(12px, env(safe-area-inset-left)); justify-content: center;
  background: var(--header-glass); border-bottom: 1px solid var(--header-border);
}
.v-tile {
  position: relative; flex: none; width: 148px; aspect-ratio: 4 / 3; padding: 0; overflow: hidden;
  border: 2px solid var(--border); border-radius: var(--radius); background: var(--surface-2); color: var(--text);
  cursor: pointer; font: inherit;
}
.v-tile.mine { cursor: default; }
.v-tile.speaking { border-color: var(--ring); box-shadow: 0 0 0 2px var(--ring), 0 0 14px var(--ring); }
.v-tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.v-tile.mine video { transform: scaleX(-1); }
.v-face { position: absolute; inset: 0; display: grid; place-items: center; }
.v-face .avatar { width: 56px; height: 56px; font-size: 30px; }
.v-name, .v-state {
  position: absolute; max-width: calc(100% - 12px); padding: 1px 7px; border-radius: 99px;
  font-size: 12px; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: var(--plate-bg); color: var(--plate-ink);
}
.v-name { left: 6px; bottom: 6px; font-weight: 600; }
.v-state { right: 6px; top: 6px; }
.v-state:empty { display: none; }
.media-toggle.blocked { opacity: .55; }
@media (max-width: 600px) {
  .video-strip { justify-content: flex-start; }
  .v-tile { width: 112px; }
  .v-face .avatar { width: 44px; height: 44px; font-size: 24px; }
}

/* закреплённая панель стола: камера, микрофон и окошки игроков не уезжают при прокрутке */
.table-bar { position: sticky; top: 0; z-index: 15; -webkit-backdrop-filter: blur(14px) saturate(1.1); backdrop-filter: blur(14px) saturate(1.1); }
.table-bar .media-bar, .table-bar .video-strip { background: var(--header-glass); }
.table-bar:empty, .table-bar:has(> #media-bar[hidden]):has(> #video-strip[hidden]) { display: none; }

/* уровень микрофона: тонкая полоска внизу кнопки живёт от голоса */
#btn-mic { position: relative; overflow: hidden; }
.mic-level { position: absolute; left: 10px; right: 10px; bottom: 3px; height: 3px; border-radius: 2px; background: var(--ok); transform: scaleX(0); transform-origin: left; transition: transform .08s linear; pointer-events: none; }

/* чат справа от стола на широком экране — прилипает под полосу видео; на телефоне — внизу */
@media (min-width: 901px) {
  .room > .side { position: sticky; align-self: start; max-height: calc(100vh - 24px); overflow: auto; }
  #screen-lobby { max-width: 1100px; }
  #screen-lobby > .panel { display: grid; grid-template-columns: minmax(0, 1fr) 340px; column-gap: 28px; align-items: start; }
  #screen-lobby > .panel > * { grid-column: 1; }
  #screen-lobby > .panel > #chat-slot-lobby { grid-column: 2; grid-row: 1 / span 40; margin-top: 0; position: sticky; }
}

/* ---------- чат справа — под высоту окна (широкий экран) ---------- */
@media (min-width: 901px) {
  .room > .side { display: flex; flex-direction: column; overflow: hidden; max-height: none; }
  .room > .side .side-tabs { flex: none; }
  .room > .side .chat-slot { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  .room > .side .table-chat { flex: 1; min-height: 0; }
  .room > .side .table-chat .chat { flex: 1; height: auto; min-height: 120px; }
  .room > .side .log-pane { flex: 1; min-height: 0; overflow: auto; }
  #screen-lobby > .panel > #chat-slot-lobby { display: flex; flex-direction: column; max-height: 720px; }
  #chat-slot-lobby .table-chat { flex: 1; min-height: 0; }
  #chat-slot-lobby .table-chat .chat { flex: 1; height: auto; min-height: 160px; }
  /* полоса видео компактнее: стол важнее */
  .video-strip { padding-top: 6px; padding-bottom: 6px; }
  .v-tile { width: 128px; }
}

/* ---------- стол во весь экран ---------- */
.btn-full { display: none; }
@media (min-width: 901px) {
  html[data-screen="game"] .btn-full, html[data-screen="lobby"] .btn-full { display: inline-flex; }
  html.table-full .topbar { display: none; }
  html.table-full .table-bar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 200px; z-index: 15;
    display: flex; flex-direction: column; border-right: 1px solid var(--header-border);
    background: var(--header-glass);
  }
  html.table-full .media-bar { flex-direction: column; align-items: stretch; border-bottom: 1px solid var(--header-border); padding: 10px; }
  html.table-full .video-strip { flex: 1; flex-direction: column; align-items: center; justify-content: flex-start; overflow-y: auto; border-bottom: 0; }
  html.table-full .v-tile { width: 168px; }
  html.table-full main.room, html.table-full main#screen-lobby { margin: 12px 12px 12px 212px; max-width: none; }
  html.table-full main.room { grid-template-columns: minmax(0, 1fr) 340px; }
}

/* широкий экран без полноэкранки: стол держит свою ширину, чат забирает остаток до края (с отступом) */
@media (min-width: 901px) {
  html:not(.table-full) main.room { max-width: 1760px; padding: 0 24px; grid-template-columns: minmax(0, 980px) minmax(300px, 1fr); }
}

/* ===================================================================
   «Во весь экран» = стол во весь экран: сукно на всю площадь, бортик по краю,
   соперники у верхнего края, рука у нижнего, видео — панель у левого края, чат — у правого.
   Обычный режим (стол-«превью» в комнате) не меняется.
   =================================================================== */
@media (min-width: 901px) {
  html.table-full body::before { display: none; }
  html.table-full main.room,
  html.table-full main#screen-lobby {
    position: fixed; inset: 0; z-index: 1; margin: 0; max-width: none;
    border: 16px solid transparent;
    padding: 14px 18px 14px 208px;
    background:
      radial-gradient(ellipse at 45% 42%, var(--table-light), transparent 58%) padding-box,
      radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(0, 0, 0, .45)) padding-box,
      var(--table-tint) padding-box,
      var(--table-surface) 0 0 / auto padding-box,
      var(--felt) padding-box,
      var(--rail) border-box;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .4), inset 0 10px 30px rgba(0, 0, 0, .35);
    overflow: auto;
  }
  html.table-full main.room { display: grid; grid-template-columns: minmax(0, 1fr) clamp(300px, 24vw, 400px); gap: 18px; align-items: stretch; }
  html.table-full main#screen-lobby { display: block; }
  html.table-full main#screen-lobby > .panel { height: 100%; background: color-mix(in srgb, var(--surface) 82%, transparent); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }

  /* видео — панель на сукне у левого края */
  html.table-full .table-bar {
    left: 26px; top: 26px; bottom: 26px; width: 176px; z-index: 15;
    border: 1px solid color-mix(in srgb, var(--border) 70%, transparent); border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--surface) 55%, transparent);
    overflow: hidden;
  }
  html.table-full .table-bar .media-bar, html.table-full .table-bar .video-strip { background: none; }
  html.table-full .v-tile { width: 152px; }

  /* дурак: стол — весь экран; внутреннее сукно без своей рамки, карты лежат прямо на общем */
  html.table-full #durak-wrap { display: flex; flex-direction: column; min-height: 0; height: 100%; }
  html.table-full #durak-wrap .felt { flex: 1; min-height: 240px; background: none; border: 0; box-shadow: none; padding: 8px; }
  html.table-full #durak-wrap .opponents { margin-bottom: 4px; }
  html.table-full #durak-wrap .me { margin-top: auto; }
  html.table-full #durak-wrap .card { --w: 84px; }
  /* мафия: места игроков — прямо на сукне */
  html.table-full .mafia-seats { background: none; border: 0; box-shadow: none; padding: 0; }
  html.table-full .mafia-wrap, html.table-full .quiz-wrap { align-content: start; }

  /* чат — полупрозрачная панель на сукне у правого края */
  html.table-full main.room > .side {
    position: static; height: 100% !important; top: auto !important; align-self: stretch;
    background: color-mix(in srgb, var(--surface) 78%, transparent);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  }
}
@media (min-width: 901px) {
  html.table-full #durak-wrap .status { align-self: center; width: min(640px, 100%); }
  html.table-full #durak-wrap .deck, html.table-full #durak-wrap .discard { height: 150px; }
  html.table-full #durak-wrap .deck .count, html.table-full #durak-wrap .discard .count { bottom: -14px; }
  html.table-full #durak-wrap .felt { grid-template-columns: 140px minmax(0, 1fr) 120px; }
}
@media (min-width: 901px) {
  html.table-full #screen-lobby > .panel > #chat-slot-lobby { height: calc(100vh - 100px); max-height: none; top: auto; position: static; }
  html.table-full .mafia-wrap { align-content: center; }
  html.table-full .mafia-seats { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
  html.table-full .mafia-seat { min-height: 76px; }
  html.table-full .quiz-wrap { align-content: center; max-width: 980px; width: 100%; justify-self: center; }
}

/* ===================================================================
   Видео на местах игроков (полноэкранный стол, выбор игрока «на местах ⇄ сбоку»)
   =================================================================== */
.seat-video, .me-seat, .btn-vlayout, .chat-hide, .chat-show { display: none; }
@media (min-width: 901px) {
  html.table-full .btn-vlayout { display: inline-flex; }
  html.table-full .chat-hide { display: inline-grid; place-items: center; margin-left: auto; width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 50%; background: var(--surface-2); color: var(--text); font-size: 16px; cursor: pointer; }
  html.table-full .side-tabs { display: flex; align-items: center; }

  /* на местах: окошко — в табличке игрока вместо аватара, статистика под ним */
  html.video-seats .seat-video { display: block; }
  html.video-seats .seat-video:empty { display: none; }
  html.video-seats .seat-video video { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius-sm); }
  html.video-seats .seat-video video.mine { transform: scaleX(-1); }
  html.video-seats .opp.has-video { width: 200px; padding-top: 8px; }
  html.video-seats .opp .seat-video { width: 184px; aspect-ratio: 4 / 3; margin: 0 auto 6px; }
  html.video-seats .opp.has-video .who .avatar { display: none; }
  html.video-seats .has-video.v-speaking .seat-video video { box-shadow: 0 0 0 3px var(--ring), 0 0 16px var(--ring); }
  html.video-seats .has-video.v-mic-off .nm::after { content: " 🔇"; font-size: .85em; }
  /* своё место у руки */
  html.video-seats .me { position: relative; }
  html.video-seats .me-seat.has-video {
    display: grid; position: absolute; left: 0; bottom: 0; width: 176px; gap: 4px; justify-items: center;
    padding: 6px; border-radius: var(--radius); background: var(--plate-bg); color: var(--plate-ink); box-shadow: var(--shadow);
  }
  html.video-seats .me-seat .seat-video { width: 164px; aspect-ratio: 4 / 3; }
  html.video-seats .me-seat .nm { font-size: 12px; font-weight: 600; }
  /* мафия: окошко сверху места, номер и подписи — под ним */
  html.video-seats .mafia-seat.has-video { grid-template-columns: 1fr; grid-template-rows: auto auto auto; }
  html.video-seats .mafia-seat.has-video .seat-video { grid-column: 1; grid-row: 1; aspect-ratio: 4 / 3; width: 100%; }
  html.video-seats .mafia-seat.has-video .avatar { display: none; }
  html.video-seats .mafia-seat.has-video .nm, html.video-seats .mafia-seat.has-video .tags { grid-column: 1; }
  /* квиз: маленькое окошко вместо аватара в строке счёта */
  html.video-seats .quiz-scores li.has-video .seat-video { width: 72px; aspect-ratio: 4 / 3; flex: none; }
  html.video-seats .quiz-scores li.has-video .avatar { display: none; }

  /* левая панель при видео на местах — узкая полоса иконок */
  html.video-seats .video-strip { display: none; }
  html.video-seats .table-bar { width: 64px; }
  html.video-seats .table-bar .media-bar { padding: 8px 6px; gap: 8px; border-bottom: 0; }
  html.video-seats .table-bar .media-toggle { justify-content: center; padding: 0; min-height: 48px; }
  html.video-seats .table-bar .media-toggle .lbl, html.video-seats .table-bar .media-toggle .state { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  html.video-seats .table-bar .media-toggle .ico { font-size: 20px; }
  html.video-seats main.room, html.video-seats main#screen-lobby { padding-left: 96px; }

  /* чат свёрнут: стол шире, справа язычок «Чат» со счётчиком */
  html.chat-collapsed main.room { grid-template-columns: minmax(0, 1fr); }
  html.chat-collapsed main.room > .side { display: none; }
  html.chat-collapsed .chat-show {
    display: inline-flex; align-items: center; gap: 6px; position: fixed; right: 26px; top: 50%; z-index: 16;
    transform: translateY(-50%) rotate(-90deg); transform-origin: right center;
    padding: 8px 14px; border: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0;
    background: var(--surface); color: var(--text); font: 600 14px var(--font-ui); box-shadow: var(--shadow); cursor: pointer;
  }
}
@media (min-width: 901px) {
  /* чат — всегда правая колонка стола, всё остальное — левая (строка событий не должна занимать место чата) */
  html.table-full main.room > * { grid-column: 1; }
  html.table-full main.room > .side { grid-column: 2; grid-row: 1 / span 20; }
  html.chat-collapsed main.room > * { grid-column: 1; }
  html.video-seats .mafia-seats { align-items: start; }
}

/* правки полноэкранного стола: заметная «свернуть чат» (стрелка вниз), крупный язычок со счётчиком,
   строки дурака не сжимаются по высоте (строка хода больше не обрезается) */
@media (min-width: 901px) {
  html.table-full .chat-hide { width: 36px; height: 36px; border: 0; background: var(--btn-primary-bg); color: var(--accent-ink); box-shadow: var(--btn-primary-shadow); }
  html.table-full #durak-wrap > * { flex-shrink: 0; }
  html.table-full #durak-wrap > .felt { flex: 1 1 auto; }
  html.chat-collapsed .chat-show {
    transform: none; top: auto; bottom: 28px; right: 28px; border-radius: 99px;
    padding: 12px 20px; gap: 10px; font-size: 16px; min-height: 52px;
    background: var(--btn-primary-bg); color: var(--accent-ink); border: 0; box-shadow: var(--btn-primary-shadow), var(--shadow);
  }
  html.chat-collapsed .chat-show .ico { font-size: 20px; }
  .chat-show .chat-count { min-width: 24px; height: 24px; padding: 0 7px; border-radius: 99px; display: inline-grid; place-items: center; font: 700 13px var(--font-ui); background: var(--accent-ink); color: var(--accent); }
}

/* зрители: пометка в панели; у зрителя окошки игроков — размытый аватар (видео им не приходит) */
.watch-badge { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 99px; border: 1px dashed var(--border); color: var(--text); font: 600 13px var(--font-ui); background: var(--surface-2); }
.watch-badge[hidden] { display: none; }
.v-tile.blurred .v-face { filter: blur(6px) saturate(.7); }

/* =====================================================================
 * Профиль игрока (ТЗ §5.1): шапка, игры и рейтинги, достижения, правка анкеты.
 * ===================================================================== */
.card-dialog { width: 100%; max-width: 620px; max-height: calc(100dvh - 32px); overflow: auto; text-align: left; font: 15px/1.45 var(--font-ui); display: grid; gap: 14px; }
.card-actions { position: sticky; bottom: -26px; margin: 0 -30px -26px; padding: 12px 30px 18px; background: var(--surface); border-top: 1px solid var(--divider); display: flex; justify-content: flex-end; gap: 10px; }
#card-body { display: grid; gap: 14px; }
.pc-loading { margin: 24px 0; text-align: center; }
.pc-head { display: flex; gap: 16px; align-items: center; }
.pc-head > .avatar { width: 88px; height: 88px; flex: none; }
.pc-id { display: grid; gap: 4px; min-width: 0; }
.pc-id h2 { margin: 0; font: 700 24px/1.15 var(--font-display); overflow-wrap: anywhere; }
.pc-verified { justify-self: start; display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px 2px 7px; border-radius: 99px; background: var(--ok); color: var(--ok-ink); font: 600 12px var(--font-ui); }
.pc-status { margin: 0; font-style: italic; color: var(--text); overflow-wrap: anywhere; }
.pc-meta { margin: 0; color: var(--muted); font-size: 14px; }
.pc-about { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.pc-favs { display: flex; flex-wrap: wrap; gap: 6px; }
.pc-section { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--divider); }
.pc-section h3 { margin: 0; font: 700 13px var(--font-ui); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.pc-section h3 small { font-weight: 600; letter-spacing: 0; }
.pc-section .hint { margin: 0; font-size: 13px; }
.pc-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.pc-stat { display: grid; gap: 2px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.pc-stat.empty { opacity: .7; }
.pc-game { font: 700 16px var(--font-display); }
.pc-count { font-size: 13px; color: var(--muted); }
.pc-rate { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.pc-rate small { color: var(--muted); font-size: 12px; }
.pc-rating { color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }
.pc-recent { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.pc-recent li { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; font-size: 14px; }
.pc-when { color: var(--muted); min-width: 52px; font-variant-numeric: tabular-nums; }
.pc-res { color: var(--muted); }
.pc-res.won { color: var(--ok); font-weight: 600; }
.pc-recent small { color: var(--muted); font-size: 12px; border: 1px solid var(--border); border-radius: 99px; padding: 0 6px; }
.pc-with { display: flex; flex-wrap: wrap; gap: 8px; }
.pc-friend { display: grid; justify-items: center; gap: 2px; width: 84px; padding: 6px 4px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); color: var(--text); font: 600 13px var(--font-ui); cursor: pointer; }
.pc-friend:hover { border-color: var(--accent); }
.pc-friend:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.pc-friend .avatar { width: 44px; height: 44px; }
.pc-friend span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-friend small { color: var(--muted); font-weight: 400; font-size: 11px; }
.pc-form { display: grid; gap: 12px; }
.pc-form h2 { margin: 0; font: 700 22px var(--font-display); }
.pc-form .field { margin: 0; display: grid; gap: 4px; }
.pc-form .field > span { font-weight: 600; font-size: 14px; }
.pc-form textarea { resize: vertical; min-height: 72px; font: inherit; }
.pc-form select { min-height: 44px; }
.pc-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pc-chips { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; max-height: 150px; overflow: auto; }
.pc-chips legend { font-weight: 600; font-size: 14px; padding: 0; margin-bottom: 6px; width: 100%; }
.pc-chips legend small { color: var(--muted); font-weight: 400; }
.pc-chips .chip { cursor: pointer; font: inherit; font-size: 13px; }
.pc-form .hint { margin: 0; font-size: 13px; }
.pc-icon { width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-size: 18px; }
@media (max-width: 520px) {
  .card-dialog { padding: 20px 18px; }
  .card-actions { margin: 0 -18px -20px; padding: 12px 18px 16px; bottom: -20px; }
  .pc-head .avatar { width: 64px; height: 64px; }
  .pc-row { grid-template-columns: 1fr; }
}

/* ---------- достижения: группы и ровная сетка ---------- */
.pc-ach-group { display: grid; gap: 6px; }
.pc-ach-group + .pc-ach-group { margin-top: 6px; }
.pc-ach-group h4 { margin: 0; font: 700 14px var(--font-display); color: var(--text); }
.pc-ach { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); grid-auto-rows: 1fr; gap: 8px; }
.pc-ach-item {
  display: grid; grid-template-columns: 32px 1fr; grid-template-rows: auto 1fr auto; column-gap: 10px; row-gap: 2px;
  padding: 10px 12px; border-radius: var(--radius); border: 1px dashed var(--border); color: var(--muted); min-height: 96px;
}
.pc-ach-item.earned { border-style: solid; background: var(--surface-2); color: var(--text); }
.pc-medal { grid-row: 1 / span 2; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--border); }
.pc-ach-item.earned .pc-medal { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.pc-ach-item.earned .pc-medal .ic { fill: currentColor; }
.pc-ach-title { font-size: 14px; line-height: 1.25; align-self: center; }
.pc-ach-desc { font-size: 12px; line-height: 1.3; }
.pc-ach-foot { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; min-height: 18px; margin-top: 6px; font-size: 12px; }
.pc-ach-foot .pc-progress { flex: 1; margin: 0; }
.pc-ach-foot small { font-variant-numeric: tabular-nums; }
.pc-got { display: inline-flex; align-items: center; gap: 4px; color: var(--ok); font-weight: 600; }
.pc-progress { display: block; height: 5px; border-radius: 99px; background: var(--border); overflow: hidden; }
.pc-progress i { display: block; height: 100%; background: var(--accent); }

/* ---------- кнопки-иконки, вкладки, друзья ---------- */
.icon-btn { width: 44px; height: 44px; flex: none; display: inline-grid; place-items: center; border-radius: 50%; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; padding: 0; transition: transform .12s ease, border-color .12s ease; }
.icon-btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.icon-btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.icon-btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.icon-btn.pending { color: var(--muted); }
.icon-btn.danger:hover { border-color: var(--warn); color: var(--warn); }
.icon-btn.ghost { background: transparent; border-color: transparent; }
.pc-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.person-actions { justify-content: center; margin-bottom: 4px; }
.person-status { font: 400 14px var(--font-ui); color: var(--muted); font-style: italic; text-align: center; }
#person-avatar.clickable { cursor: pointer; }
#person-avatar.clickable .avatar { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 50%; }
.pc-badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pc-friends { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px 2px 8px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: 600 12px var(--font-ui); }
button.pc-friends { cursor: pointer; }
button.pc-friends:hover { border-color: var(--accent); }
.pc-rel { font: 600 12px var(--font-ui); color: var(--muted); }
.pc-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--divider); }
.pc-tabs button { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--muted); font: 600 15px var(--font-ui); cursor: pointer; }
.pc-tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.pc-tab-n { font-weight: 400; color: var(--muted); }
.count-badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font: 700 11px var(--font-ui); }
.btn-badged { position: relative; }
.btn-badged .count-badge { position: absolute; top: -4px; right: -4px; }
.pc-people { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.pc-person { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.pc-person-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: 0; background: none; color: var(--text); text-align: left; font: inherit; cursor: pointer; padding: 0; }
.pc-person-acts { display: flex; gap: 6px; flex: none; }
.pc-person-acts .icon-btn { width: 38px; height: 38px; }
.dm-ava { position: relative; flex: none; display: inline-block; line-height: 0; }
.dm-ava .avatar { width: 40px; height: 40px; }
.dm-ava.big .avatar { width: 88px; height: 88px; }
.dm-ava.online::after { content: ""; position: absolute; right: 1px; bottom: 1px; width: 11px; height: 11px; border-radius: 50%; background: var(--ok); border: 2px solid var(--surface); }
.dm-ava.big.online::after { width: 16px; height: 16px; right: 4px; bottom: 4px; }
.dm-main { display: grid; min-width: 0; }
.dm-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-main small { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- сообщения вне игры ---------- */
.messages-dialog { width: 100%; max-width: 560px; height: min(680px, calc(100dvh - 32px)); padding: 0; text-align: left; font: 15px/1.45 var(--font-ui); display: flex; flex-direction: column; overflow: hidden; }
.dm-top { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--divider); }
.dm-top h2 { margin: 0; flex: 1; font: 700 22px var(--font-display); }
.dm-panes { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.dm-list { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 6px 8px; }
.dm-conv { display: none; flex: 1; min-height: 0; flex-direction: column; }
#messages.in-thread .dm-list { display: none; }
#messages.in-thread .dm-conv { display: flex; }
.dm-row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 8px; border: 0; border-radius: var(--radius); background: none; color: var(--text); text-align: left; font: inherit; cursor: pointer; }
.dm-row:hover { background: var(--surface-2); }
.dm-row .dm-main { flex: 1; }
.dm-side { display: grid; justify-items: end; gap: 4px; color: var(--muted); font-size: 12px; }
.dm-sep { margin: 12px 8px 4px; font: 700 12px var(--font-ui); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.dm-thread-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--divider); }
.dm-peer { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: 0; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.dm-thread { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.dm-thread .msg { white-space: pre-wrap; overflow-wrap: anywhere; }
.dm-note { margin: 0; padding: 10px 16px; border-top: 1px solid var(--divider); }
.dm-rules { margin: 0; padding: 0 16px 10px; font-size: 12px; }
.hint.pad { padding: 16px; margin: 0; }
.hint.center { text-align: center; }
.empty-state { display: grid; justify-items: center; gap: 8px; padding: 40px 24px; color: var(--muted); text-align: center; }
.empty-state p { margin: 0; max-width: 320px; }
@media (max-width: 520px) {
  .messages-dialog { height: calc(100dvh - 16px); }
  .pc-ach { grid-template-columns: 1fr 1fr; }
  .pc-person-acts .icon-btn { width: 36px; height: 36px; }
}

/* окна поверх закреплённой полоски стола и плавающих кнопок; подсказка-тост — поверх окон */
.overlay { z-index: 30; }
.toast { z-index: 40; }
/* жалоба открывается и поверх окна сообщений */
#report { z-index: 35; }

/* ---------- единые настройки: я, аккаунт, приватность, документы ---------- */
.settings-section.first { border-top: 0; padding-top: 0; }
.set-identity { display: flex; align-items: flex-end; gap: 14px; }
.set-avatar { position: relative; flex: none; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 50%; line-height: 0; }
.set-avatar .avatar { width: 72px; height: 72px; }
.set-avatar:focus-visible { outline: 2px solid var(--ring); outline-offset: 3px; }
.set-avatar-edit { position: absolute; right: -2px; bottom: -2px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-size: 13px; line-height: 1; border: 2px solid var(--surface); }
.set-name { flex: 1; margin: 0; display: grid; gap: 4px; }
.set-name > span { font-weight: 600; font-size: 14px; }
#set-avatar-grid { max-height: 260px; overflow: auto; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius); }
.set-facts { margin: 0; display: grid; gap: 4px; font-size: 14px; }
.set-facts div { display: flex; gap: 8px; flex-wrap: wrap; }
.set-facts dt { color: var(--muted); }
.set-facts dt::after { content: ":"; }
.set-facts dd { margin: 0; }
.set-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.set-actions a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.btn-danger-text { color: var(--warn); border-color: var(--warn); }
.set-grid { display: grid; gap: 10px; }
.set-grid .field { margin: 0; display: grid; gap: 4px; }
.set-grid .field > span { font-weight: 600; font-size: 14px; }
.set-grid select { min-height: 44px; }
.set-docs { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.set-docs a { color: var(--link); }
#set-consents { font-size: 13px; }

/* аватары с прозрачным фоном (набор «двора») и свои фото: круг с подложкой, фото — по центру */
img.avatar-img { object-fit: cover; background: var(--surface-2); }

/* ---------- достижения иконками с подсказкой ---------- */
.ach-group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ach-group + .ach-group { margin-top: 2px; }
.ach-row li { line-height: 0; }
.ach-group-name { flex: 0 0 76px; font: 600 13px var(--font-ui); color: var(--muted); }
.ach-row { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.ach-icon { width: 56px; height: 56px; padding: 0; border: 0; border-radius: 14px; background: none; cursor: pointer; line-height: 0; transition: transform .12s ease; }
.ach-icon img { width: 56px; height: 56px; display: block; }
.ach-icon:not(.earned) img { filter: grayscale(1) brightness(.75); opacity: .45; }
.ach-icon:hover, .ach-icon:focus-visible { transform: translateY(-2px) scale(1.06); }
.ach-icon:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.card-dialog { position: relative; }
.ach-tip {
  position: absolute; z-index: 5; width: 230px; display: grid; gap: 4px; padding: 10px 12px;
  border-radius: var(--radius); background: var(--surface); color: var(--text); border: 1px solid var(--border);
  box-shadow: var(--shadow); font: 13px/1.35 var(--font-ui); pointer-events: none;
}
.ach-tip b { font-size: 14px; }
.ach-tip em { font-style: normal; color: var(--muted); font-size: 12px; }
.ach-tip em.got { color: var(--ok); font-weight: 600; }
@media (max-width: 520px) { .ach-group-name { flex-basis: 100%; } .ach-icon, .ach-icon img { width: 50px; height: 50px; } }

/* ---------- соперники ---------- */
.rivals-head { border-top: 0; padding-top: 0; }
.rivals-sort { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.rivals-sort select { flex: 1; min-height: 40px; }
.rivals { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rivals li { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.rival-rank { width: 22px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 700; }
.rival-score { flex: none; display: inline-flex; align-items: baseline; gap: 3px; font: 700 18px var(--font-display); font-variant-numeric: tabular-nums; }
.rival-score .lost, .rival-score .won { min-width: 30px; padding: 1px 8px; border-radius: 8px; text-align: center; font-size: 16px; }
.rival-score .lost { background: var(--warn); color: var(--warn-ink); }
.rival-score .won { background: var(--ok); color: var(--ok-ink); }
.rival-score .sep { color: var(--muted); }

/* ---------- своё фото, ограничения ---------- */
.set-photo { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.set-photo .hint { flex-basis: 100%; margin: 0; font-size: 13px; }
.set-photo .hint.warn, .set-restrictions { color: var(--warn); }
img.avatar-photo.pending { opacity: .55; outline: 2px dashed var(--muted); outline-offset: 2px; }
.set-restrictions { padding: 10px 12px; border: 1px solid var(--warn); border-radius: var(--radius); font-size: 14px; }
.set-restrictions ul { margin: 6px 0; padding-left: 18px; color: var(--text); }
.set-restrictions small { color: var(--muted); }

/* ---------- значки-счётчики в шапке и в чатах ---------- */
.profile-chip.btn-badged { position: relative; }
.btn-badged .count-badge { position: absolute; top: -5px; right: -5px; box-shadow: 0 0 0 2px var(--surface); }
.dm-row.unread .dm-main b { font-weight: 800; }
.dm-row.unread .dm-main small { color: var(--text); }
.dm-row.unread .dm-side small { color: var(--accent); font-weight: 600; }
.table-ava { width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--felt, var(--surface-2)); color: var(--text); line-height: 1; }

/* ---------- модерация ---------- */
.mod-dialog { width: 100%; max-width: 760px; height: min(760px, calc(100dvh - 32px)); padding: 0; text-align: left; font: 15px/1.45 var(--font-ui); display: flex; flex-direction: column; overflow: hidden; }
.mod-tabs { padding: 0 12px; }
.mod-body { flex: 1; overflow-y: auto; padding: 12px 16px; }
.mod-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); padding: 12px; display: grid; gap: 8px; }
.mod-photos { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.mod-photos img { width: 160px; height: 160px; border-radius: 50%; object-fit: cover; justify-self: center; background: var(--surface); }
.mod-reports { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.mod-report-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.mod-report-head small { color: var(--muted); }
.mod-report p, .mod-report blockquote { margin: 0; }
.mod-report blockquote { padding: 6px 10px; border-left: 3px solid var(--border); color: var(--muted); }
.prio { font: 700 11px var(--font-ui); padding: 1px 7px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); }
.prio-p0, .prio-p1 { background: var(--warn); color: var(--warn-ink); border-color: transparent; }
.mod-evidence { margin: 6px 0 0; padding-left: 18px; font-size: 14px; display: grid; gap: 2px; }
.mod-evidence .by-target { color: var(--text); font-weight: 600; }
.mod-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.mod-form { display: grid; gap: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.mod-form .field { margin: 0; display: grid; gap: 4px; }
.mod-form .field > span { font-weight: 600; font-size: 13px; }
.mod-log { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.mod-log small { color: var(--muted); }
.link-btn { border: 0; background: none; padding: 0; color: var(--link); font: inherit; cursor: pointer; text-align: center; }
.mod-shield { color: var(--muted); }
#mod { z-index: 32; }

/* своя камера закрыта правилом допуска (ADR 0010) */
.media-btn.locked, #btn-cam.locked { opacity: .7; }
#btn-cam.locked .state::before { content: "🔒 "; }
.cam-access { margin: 0; font-size: 13px; }

/* «Лампа Клуб» — две слова: логотип всегда в одну строку, на узком экране — мельче и плотнее */
.logo, .logo > .logo-name { white-space: nowrap; }
@media (max-width: 520px) {
  .logo { font-size: 17px; }
  .logo > .logo-name, [data-theme] .logo > .logo-name { letter-spacing: .04em; }
  [data-theme="classic"] .logo > .logo-name::before, [data-theme="classic"] .logo > .logo-name::after { margin: 0 .3em; }
}
@media (max-width: 380px) { .logo { font-size: 15px; } }

/* ---------- реклама: только вне игры, с пометкой, в размер места ---------- */
.ad-slot { margin: 12px 0; }
.ad-frame { position: relative; display: grid; gap: 4px; padding: 12px 14px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font: 14px/1.4 var(--font-ui); }
.ad-label { justify-self: start; font: 600 11px var(--font-ui); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ad-network .ad-box { min-height: 90px; }
/* над списком чатов — пластинка размером с чат */
.ad-row-slot { margin: 2px 0 8px; }
.ad-row-slot .ad-frame { padding: 8px 10px; grid-template-columns: 1fr auto; align-items: center; column-gap: 10px; }
.ad-row-slot .ad-label { grid-column: 1 / -1; }
.ad-row-slot .ad-network .ad-box { min-height: 60px; grid-column: 1 / -1; }
/* согласие на cookie Яндекса — плашка снизу на главной, не поверх игры */
.ads-consent { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 25; width: min(640px, calc(100vw - 24px)); display: grid; gap: 10px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow); font: 14px/1.45 var(--font-ui); }
.ads-consent p { margin: 0; }
.ads-consent a { color: var(--link); }
.ads-consent-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- «гость»: персонаж выглядывает из левого нижнего угла (справа — кнопка свёрнутого чата) ---------- */
.guest { position: fixed; left: 16px; bottom: 16px; z-index: 24; display: flex; align-items: flex-end; gap: 6px; max-width: min(420px, calc(100vw - 32px));
  transform: translateY(130%); opacity: 0; transition: transform .45s cubic-bezier(.2, .9, .3, 1.2), opacity .3s; pointer-events: none; }
.guest.in { transform: none; opacity: 1; pointer-events: auto; }
.guest-figure { flex: none; width: 96px; height: 96px; padding: 0; border: 0; background: none; cursor: pointer; line-height: 0; }
div.guest-figure { cursor: default; }
.guest-figure img, .guest-figure svg { width: 96px; height: 96px; display: block; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .35)); }
.guest-bubble { position: relative; display: grid; gap: 4px; margin-bottom: 40px; padding: 10px 14px 8px; border-radius: 16px 16px 16px 4px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow); font: 15px/1.35 var(--font-ui); }
.guest-bubble p { margin: 0; }
.guest-line { border: 0; background: none; padding: 0; color: var(--text); font: 600 15px/1.35 var(--font-ui); text-align: left; cursor: pointer; text-decoration: underline; text-decoration-color: var(--highlight); text-underline-offset: 3px; }
.guest-details { color: var(--muted); font-size: 12px; }
.guest-label { font: 600 11px var(--font-ui); color: var(--muted); letter-spacing: .02em; }
.guest-close { position: absolute; left: 78px; bottom: 82px; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 700 16px/1 var(--font-ui); cursor: pointer; box-shadow: var(--shadow); }
.guest-close:focus-visible, .guest-line:focus-visible, .guest-figure:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
@media (max-width: 520px) {
  .guest-figure, .guest-figure img, .guest-figure svg { width: 72px; height: 72px; }
  .guest-close { left: 56px; bottom: 60px; }
  .guest-bubble { margin-bottom: 30px; font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) { .guest { transition: none; } .lamp * { animation: none !important; } }

/* лампа клуба: 7 режимов-заглушек; цвета — из темы, свет ярче — радостнее */
.lamp { overflow: visible; }
.lamp-glow { fill: var(--highlight); opacity: .2; }
.lamp-g0 { stop-color: var(--plate-bg); }
.lamp-g1 { stop-color: var(--highlight); }
.lamp-glass { stroke: var(--plate-ink); stroke-width: 2; }
.lamp-shine { fill: none; stroke: var(--plate-bg); stroke-width: 3; stroke-linecap: round; opacity: .8; }
.lamp-filament { fill: none; stroke: var(--plate-ink); stroke-width: 1.6; stroke-linejoin: round; opacity: .45; }
.lamp-face { fill: var(--plate-ink); stroke: var(--plate-ink); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.lamp-face path { fill: none; }
.lamp-face .lamp-mouth-open { fill: var(--plate-ink); }
.lamp-cheek { fill: var(--accent); opacity: .35; }
.lamp-base { fill: var(--muted); }
.lamp-base2 { opacity: .8; }
.lamp-rays path { stroke: var(--highlight); stroke-width: 3; stroke-linecap: round; fill: none; }
.lamp-tear { fill: var(--link); }
.lamp-dots circle { fill: var(--muted); }
.lamp-z path { fill: none; stroke: var(--muted); stroke-width: 2; stroke-linejoin: round; }
.lamp-win .lamp-glow { opacity: .55; animation: lamp-pulse 1.6s ease-in-out infinite; }
.lamp-hello .lamp-glow { opacity: .38; }
.lamp-calm .lamp-glow { opacity: .24; }
.lamp-think .lamp-glow { opacity: .26; animation: lamp-flicker 2.4s steps(1) infinite; }
.lamp-thrill .lamp-g1, .lamp-thrill .lamp-glow { stop-color: var(--accent); fill: var(--accent); }
.lamp-thrill .lamp-glow { opacity: .38; }
.lamp-support .lamp-glass { opacity: .75; }
.lamp-support .lamp-glow { opacity: .1; }
.lamp-sleep .lamp-glass { opacity: .5; }
.lamp-sleep .lamp-glow { opacity: .03; }
.lamp-hello .lamp-rays { transform-origin: 86px 40px; animation: lamp-wave 1.2s ease-in-out 2; }
@keyframes lamp-pulse { 50% { opacity: .28; } }
@keyframes lamp-flicker { 0%, 100% { opacity: .26; } 40% { opacity: .12; } 45% { opacity: .32; } }
@keyframes lamp-wave { 50% { transform: rotate(18deg); } }

/* реплика «изо рта»: хвостик облачка указывает на рот лампы */
.guest-bubble.from-mouth { border-radius: 16px; }
.guest-bubble.from-mouth::before { content: ""; position: absolute; left: -9px; bottom: 6px; width: 16px; height: 16px; background: var(--surface); border-left: 1px solid var(--border); border-bottom: 1px solid var(--border); transform: rotate(45deg); }

/* промо-видео и переход */
.promo-dialog { width: 100%; max-width: 720px; display: grid; gap: 10px; text-align: left; }
.promo-dialog video { width: 100%; max-height: 70vh; border-radius: var(--radius); background: black; }
.leave-dialog { max-width: 460px; text-align: left; font: 15px/1.45 var(--font-ui); }
.leave-dialog h2 { margin: 0 0 8px; font: 700 20px var(--font-display); }
.leave-dialog a.btn { text-decoration: none; display: inline-flex; align-items: center; }
#promo, #leave { z-index: 33; }
.mod-ads-wrap { overflow-x: auto; }
.mod-ads { width: 100%; border-collapse: collapse; font-size: 14px; }
.mod-ads th, .mod-ads td { padding: 6px 8px; border-bottom: 1px solid var(--divider); text-align: right; white-space: nowrap; }
.mod-ads th:first-child, .mod-ads td:first-child { text-align: left; white-space: normal; }
.mod-ads td small { display: block; color: var(--muted); font-size: 12px; }
.mod-ads th { color: var(--muted); font-weight: 600; font-size: 12px; }

/* ---------- лист ожидания на главной ---------- */
.wait-bar { position: sticky; top: 8px; z-index: 5; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); }
.wait-text { flex: 1; min-width: 180px; display: grid; }
.wait-text small { color: var(--muted); font-size: 13px; }
.wait-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; animation: wait-pulse 1.4s ease-in-out infinite; }
.wait-bar.ready { border-color: var(--ok); }
.wait-bar.ready .wait-dot { background: var(--ok); }
@keyframes wait-pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .wait-dot { animation: none; } }
.guest-action { justify-self: start; margin: 2px 0; }

/* ---------- экскурсия с Лампой: затемнение с «окном» вокруг нужного места ---------- */
.tour { position: fixed; inset: 0; z-index: 28; }
.tour-spot { position: fixed; border-radius: var(--radius); box-shadow: 0 0 0 9999px rgba(0, 0, 0, .62); outline: 3px solid var(--highlight); outline-offset: 2px; transition: all .25s ease; pointer-events: none; }
.tour-spot-none { left: 50%; top: 50%; width: 0; height: 0; outline: none; }
.tour-lamp { position: fixed; display: flex; align-items: flex-end; gap: 6px; max-width: min(380px, calc(100vw - 16px)); }
.tour-lamp .guest-figure, .tour-lamp .guest-figure img, .tour-lamp .guest-figure svg { width: 88px; height: 88px; }
.tour-lamp .guest-bubble { margin-bottom: 34px; }
.tour-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.tour-count { color: var(--muted); font-size: 12px; margin-left: auto; }
#btn-tour { justify-self: start; }
@media (prefers-reduced-motion: reduce) { .tour-spot { transition: none; } }
/* ждёт на главной: полоса камеры и микрофона стола не нужна */
html[data-screen="home"] #table-bar { display: none; }
.push-kinds { display: grid; gap: 6px; padding: 4px 2px; }
.switch-row.disabled { opacity: .6; }

/* ---------- правовые страницы (/legal/) ---------- */
.legal-page .panel { max-width: 860px; }
.legal-facts { display: grid; gap: 8px; margin: 0 0 8px; }
.legal-facts div { display: grid; grid-template-columns: minmax(160px, 34%) 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--divider); }
.legal-facts dt { color: var(--muted); }
.legal-facts dd { margin: 0; font-weight: 600; }
.legal-docs { display: grid; gap: 6px; padding-left: 20px; }
.legal-table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 8px 0; }
.legal-table th, .legal-table td { padding: 8px; border: 1px solid var(--border); vertical-align: top; text-align: left; }
.legal-table th { background: var(--surface-2); }
.legal-missing { background: var(--warn); color: var(--warn-ink); padding: 0 4px; border-radius: 4px; }
@media (max-width: 600px) { .legal-facts div { grid-template-columns: 1fr; gap: 2px; } .legal-table { font-size: 13px; } }

/* ---------- подвал: только вне стола ---------- */
.site-footer { display: none; box-sizing: border-box; width: 100%; margin: 32px 0 0; padding: 26px max(20px, calc((100% - 1100px) / 2)) calc(18px + env(safe-area-inset-bottom)); border-top: 1px solid var(--divider); background: color-mix(in srgb, var(--bg) 60%, transparent); color: var(--text); font: 500 14px/1.5 var(--font-ui); }
html[data-screen="home"] .site-footer, html[data-screen="create"] .site-footer, html[data-screen="quiz-quick"] .site-footer, .legal-page ~ .site-footer, .rules ~ .site-footer { display: block; }
.foot-cols { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 24px; }
.foot-logo { font: 700 20px var(--font-display); }
.foot-brand p { margin: 6px 0 10px; color: var(--muted); }
.foot-badges { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.foot-badges li { padding: 2px 10px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface-2); font-size: 12px; }
.foot-col { display: grid; align-content: start; gap: 6px; }
.foot-col h2 { margin: 0 0 4px; font: 700 12px var(--font-ui); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.foot-col a, .foot-link { color: var(--link); text-decoration: none; }
.foot-col a:hover, .foot-link:hover { text-decoration: underline; }
.foot-link { justify-self: start; border: 0; background: none; padding: 0; font: inherit; cursor: pointer; text-align: left; }
.foot-bottom { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 18px 0 0; padding-top: 12px; border-top: 1px solid var(--divider); color: var(--muted); font-size: 13px; }
.foot-powered { color: var(--muted); text-decoration: none; }
.foot-powered b { color: var(--text); }
.foot-powered:hover b { color: var(--link); }
@media (max-width: 760px) { .foot-cols { grid-template-columns: 1fr 1fr; } .foot-brand { grid-column: 1 / -1; } }
@media (max-width: 420px) { .foot-cols { grid-template-columns: 1fr; } }

/* живая Лампа (ui/bulb.ts): холст квадратный, рот примерно на 47% высоты — к нему хвостик облачка */
.lamp-figure { width: auto !important; height: auto !important; line-height: 0; }
.lamp-figure .bulb-host { display: block; }
.guest .lamp-figure + .guest-bubble { margin-bottom: 66px; }
.tour-lamp .lamp-figure + .guest-bubble { margin-bottom: 80px; }
.guest:has(.lamp-figure) .guest-close { left: 6px; bottom: 148px; }
/* у холста поля по бокам под лучи и искры (~30% ширины): облачко подходит ко рту */
.guest .lamp-figure { margin-right: -46px; margin-left: -30px; }
.tour-lamp .lamp-figure { margin-right: -56px; }
@media (max-width: 520px) {
  .guest .lamp-figure + .guest-bubble { margin-bottom: 62px; }
  .guest:has(.lamp-figure) .guest-close { left: 2px; bottom: 112px; }
  .guest .lamp-figure { margin-right: -36px; margin-left: -22px; }
  .tour-lamp .lamp-figure { margin-right: -40px; }
  .tour-lamp .lamp-figure + .guest-bubble { margin-bottom: 70px; }
}
/* правило заглушки (размер img/svg в .guest-figure) не трогает слои живой Лампы */
.lamp-figure .dvb img, .lamp-figure .dvb svg { width: 100% !important; height: 100% !important; }
.lamp-figure .dvb .spark svg { width: 100% !important; height: 100% !important; }

/* ---------- реплики Лампы и «гостей» без подложки: контрастный текст на любом фоне ----------
 * Цвет текста темы и плотный ореол цвета фона темы: в тёмных темах — светлый текст с тёмным ореолом, в светлых — наоборот. */
.guest-bubble, .guest-bubble.from-mouth { background: none; border: 0; box-shadow: none; padding: 0; border-radius: 0; gap: 6px; }
.guest-bubble.from-mouth::before { content: none; }
.guest-bubble p, .guest-line, .guest-label, .guest-details {
  color: var(--text);
  text-shadow: 0 0 1px var(--bg), 1px 1px 0 var(--bg), -1px -1px 0 var(--bg), 1px -1px 0 var(--bg), -1px 1px 0 var(--bg),
    2px 0 0 var(--bg), -2px 0 0 var(--bg), 0 2px 0 var(--bg), 0 -2px 0 var(--bg), 0 0 6px var(--bg), 0 0 12px var(--bg);
}
.guest-bubble p, .guest-line { font: 700 17px/1.3 var(--font-ui); max-width: 300px; }
.guest-line { text-decoration-thickness: 2px; }
.guest-label { font-weight: 700; font-size: 12px; }
.guest-details { font-size: 13px; }
/* слова выходят изо рта: открываются слева направо */
.guest.in .guest-bubble p, .guest.in .guest-line, .tour-lamp .guest-bubble p { animation: lamp-say .55s ease-out both; }
@keyframes lamp-say { from { clip-path: inset(0 100% 0 0); opacity: .3; } to { clip-path: inset(0 0 0 0); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .guest.in .guest-bubble p, .guest.in .guest-line, .tour-lamp .guest-bubble p { animation: none; } }
@media (max-width: 520px) { .guest-bubble p, .guest-line { font-size: 16px; max-width: 220px; } }
/* Лампа и «гость» — над окном итогов партии и списком чатов (их места), но под настройками, жалобой и т. п. */
.guest { z-index: 31; }

/* Знак в логотипе — сама Лампа: при загрузке «включается» (моргает, как настоящая лампочка), при наведении подмигивает */
.logo { display: inline-flex; align-items: center; gap: 8px; }
.logo-mark { position: relative; flex: none; width: 56px; height: 56px; line-height: 0; margin: -14px -8px -14px -12px; }
.logo-mark img { position: absolute; inset: 0; width: 100%; height: 100%; transition: opacity .15s; }
.logo-mark img:first-child { filter: drop-shadow(0 0 6px color-mix(in srgb, var(--highlight) 55%, transparent)); animation: logo-on 1.4s .2s ease-out both; }
.logo-mark .logo-wink { opacity: 0; }
a.logo:hover .logo-wink, a.logo:focus-visible .logo-wink { opacity: 1; }
a.logo:hover .logo-mark img:first-child, a.logo:focus-visible .logo-mark img:first-child { opacity: 0; }
@keyframes logo-on {
  0% { filter: brightness(.45) saturate(.4); }
  12% { filter: brightness(1.15) drop-shadow(0 0 8px color-mix(in srgb, var(--highlight) 70%, transparent)); }
  18% { filter: brightness(.5) saturate(.5); }
  30% { filter: brightness(1.2) drop-shadow(0 0 10px color-mix(in srgb, var(--highlight) 80%, transparent)); }
  36% { filter: brightness(.7) saturate(.7); }
  100% { filter: brightness(1) drop-shadow(0 0 6px color-mix(in srgb, var(--highlight) 55%, transparent)); }
}
@media (max-width: 520px) { .logo-mark { width: 46px; height: 46px; margin: -12px -6px -12px -10px; } }
@media (prefers-reduced-motion: reduce) { .logo-mark img:first-child { animation: none; } }
/* своя Лампа не подписывается (подпись «Реклама · бренд» — только у гостей-рекламодателей) */
.guest:has(.lamp-figure) .guest-label { display: none; }
.tour-count { color: var(--text); text-shadow: 1px 1px 0 var(--bg), -1px -1px 0 var(--bg), 1px -1px 0 var(--bg), -1px 1px 0 var(--bg), 0 0 6px var(--bg); }

/* Футер полупрозрачный (фон темы просвечивает на 40%): весь текст — цвета темы с обводкой фоном, как реплики Лампы */
.site-footer, .site-footer a, .site-footer .foot-link, .site-footer h2, .site-footer p, .site-footer .foot-bottom, .site-footer .foot-powered {
  text-shadow: 1px 1px 0 var(--bg), -1px -1px 0 var(--bg), 1px -1px 0 var(--bg), -1px 1px 0 var(--bg), 0 0 6px var(--bg), 0 0 10px var(--bg);
}
.site-footer .foot-brand p, .site-footer .foot-col h2, .site-footer .foot-bottom, .site-footer .foot-powered { color: var(--text); }
.site-footer .foot-col h2 { opacity: .85; }
.site-footer .foot-col a, .site-footer .foot-link { font-weight: 600; }
.site-footer .foot-badges li { background: color-mix(in srgb, var(--bg) 70%, transparent); border-color: var(--text); text-shadow: none; }
/* светлые темы: светлая обводка на пёстром фоне слабее — текст плотнее и темнее, ссылки ближе к цвету текста, ореол шире */
[data-theme="home"] .site-footer, [data-theme="nineties"] .site-footer { font-weight: 600; }
[data-theme="home"] .site-footer *, [data-theme="nineties"] .site-footer * {
  text-shadow: 1px 1px 0 var(--bg), -1px -1px 0 var(--bg), 1px -1px 0 var(--bg), -1px 1px 0 var(--bg), 0 0 4px var(--bg), 0 0 8px var(--bg), 0 0 14px var(--bg), 0 0 20px var(--bg);
}
[data-theme="home"] .site-footer .foot-col a, [data-theme="home"] .site-footer .foot-link,
[data-theme="nineties"] .site-footer .foot-col a, [data-theme="nineties"] .site-footer .foot-link { color: color-mix(in srgb, var(--link) 55%, var(--text)); font-weight: 700; }
[data-theme="home"] .site-footer .foot-col h2, [data-theme="nineties"] .site-footer .foot-col h2 { opacity: 1; font-weight: 800; }
[data-theme="home"] .site-footer .foot-badges li, [data-theme="nineties"] .site-footer .foot-badges li { text-shadow: none; background: color-mix(in srgb, var(--bg) 85%, transparent); }

/* Шапка как подвал: фон темы просвечивает на 40%, без размытия; надписи — цвет темы с обводкой фоном */
html .topbar {
  background: color-mix(in srgb, var(--bg) 60%, transparent);
  -webkit-backdrop-filter: none; backdrop-filter: none;
  color: var(--text);
  border-bottom: 1px solid color-mix(in srgb, var(--text) 18%, transparent);
  box-shadow: none;
}
html .topbar .logo, html .topbar .who-am-i {
  text-shadow: 1px 1px 0 var(--bg), -1px -1px 0 var(--bg), 1px -1px 0 var(--bg), -1px 1px 0 var(--bg), 0 0 6px var(--bg), 0 0 10px var(--bg);
}
[data-theme="home"] .topbar .logo, [data-theme="nineties"] .topbar .logo,
[data-theme="home"] .topbar .who-am-i, [data-theme="nineties"] .topbar .who-am-i {
  text-shadow: 1px 1px 0 var(--bg), -1px -1px 0 var(--bg), 1px -1px 0 var(--bg), -1px 1px 0 var(--bg), 0 0 4px var(--bg), 0 0 8px var(--bg), 0 0 14px var(--bg), 0 0 20px var(--bg);
}
