/* «Rummikub» — оформление. Лобби и разделы — тёмный стиль Games (общие классы style.css),
   партия — яркая сцена: игровой стол с сукном, фарфоровые плитки, мраморная стойка (img/rummikub/).
   Из rummikub-экран.js идут только классы и data-атрибуты; числовые переменные --k/--a/--h (размеры по ширине),
   --x/--y (несомая плитка) и --dx/--dy (рука-указатель) выставляет код. Картинки — с запасной отрисовкой на случай, если файл не загрузился. */

body.rummikub {
  --кнопка-фон: var(--сб-акцент);
  --кнопка-текст: var(--сб-акцент-текст);
  --акцент: var(--сб-акцент);
  --золото-светлое: #FFE08A;
  --золото: #F4C54A;
  --стекло: rgba(14, 22, 40, .66);
  --стекло-край: rgba(255, 255, 255, .22);
  --текст-на-сцене: #f6f8ff;
  --сукно: #17407f;
  --сукно-тёмное: #0a2a55;
  --фарфор: #F4F6FA;
  --фарфор-низ: #DDE3EE;
  --рубин: #D7263D;
  --сапфир: #2A5FD8;
  --изумруд: #12A06B;
  --графит: #2B2F3A;
  --ошибка: #ff6f86;
  --ошибка-фон: rgba(255, 111, 134, .16);
}
.без-скриптов { padding: 24px; text-align: center; }

/* ---------- Лобби ---------- */
.плашка-возврата {
  min-height: 46px; margin: 6px 0; padding: 10px 16px; border-radius: 14px; border: 1px solid color-mix(in srgb, var(--сб-акцент) 50%, transparent);
  background: color-mix(in srgb, var(--сб-акцент) 12%, transparent); color: inherit; font: inherit; font-weight: 700; cursor: pointer;
}
.страница-rummikub .лобби__картинка { aspect-ratio: 16 / 8.2; }
.страница-rummikub .лобби__рисунок { width: 100%; height: 100%; object-fit: cover; }
.страница-rummikub .лобби__подпись {
  font-family: var(--шрифт); font-weight: 700; font-size: clamp(16px, 4.6vw, 20px);
  line-height: 1.25; color: #fff; text-shadow: 0 2px 10px rgba(0, 0, 0, .7);
}
.значок-бот, .значок-вместе { display: block; width: 100%; height: 100%; object-fit: contain; }
body.rummikub .карточка-входа__значок:has(.значок-бот),
body.rummikub .карточка-входа__значок:has(.значок-вместе) { padding: 0; }

/* ---------- Разделы: правила, рекорды, профиль ---------- */
.раздел { overflow-y: auto; gap: 10px; width: 100%; max-width: 520px; margin: 0 auto; padding-bottom: calc(24px + var(--отступ-снизу)); }
/* Нижняя полоса вкладок на «Рекордах» и «Профиле» (разметку ставит общий нижние-вкладки.js).
   Нижний отступ = высота полосы + запас + безопасная зона: последняя строка при прокрутке до конца целиком над полосой. */
.раздел:has(> .нижние-вкладки) {
  --вт-панель-низ: clamp(52px, 14.36vw, 64px);
  --вт-поверхность: var(--сб-поверхность);
  --вт-текст: var(--сб-текст);
  --вт-текст-тихий: var(--сб-текст-тихий);
  --вт-акцент: var(--сб-акцент);
  padding-bottom: calc(var(--вт-панель-низ) + 24px + var(--отступ-снизу));
  scroll-padding-bottom: calc(var(--вт-панель-низ) + 24px + var(--отступ-снизу));
}
.раздел > :not(.нижние-вкладки) { flex-shrink: 0; }
/* «‹» в разделах — кнопка 44×44 у левого края: общий style.css растягивает #кнопка-рекорды-назад на всю ширину (правило для витрины Games). */
:is(#кнопка-рекорды-назад, #кнопка-профиль-назад, #кнопка-правила-назад).верх-игры__кнопка { width: 44px; min-width: 44px; max-width: 64px; flex: 0 0 44px; margin: 0; }
.раздел__заголовок { margin: 4px 0; font-size: 26px; line-height: 1.15; }
.раздел__пояснение { margin: 0; opacity: .8; line-height: 1.35; }
.правила__карточки { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.карточка-правила { padding: 12px 14px; border-radius: 16px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .1); }
.карточка-правила__заголовок { margin: 6px 0 4px; font-size: 17px; }
.карточка-правила__текст { margin: 0; font-size: 15px; line-height: 1.35; opacity: .88; }
.схема { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 6px 0; }
.схема-пара { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px 12px; }
.схема__стрелка { width: 26px; height: 14px; background: linear-gradient(var(--сб-акцент), var(--сб-акцент)) left center / 100% 3px no-repeat; position: relative; }
.схема__стрелка::after { content: ""; position: absolute; right: 0; top: 0; width: 10px; height: 14px; background: var(--сб-акцент); clip-path: polygon(0 0, 100% 50%, 0 100%); }
.схема-кнопки { display: flex; gap: 8px; justify-content: center; }
.схема-кнопки__кнопка { padding: 8px 12px; border-radius: 12px; font-weight: 800; font-size: 14px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .22); }
.схема-кнопки__кнопка[data-главная] { background: var(--сб-акцент); color: var(--сб-акцент-текст); border-color: var(--сб-акцент); }

.рекорды { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.рекорды__строка, .сводка__строка {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 52px;
  padding: 10px 14px; border-radius: 14px; background: rgba(255, 255, 255, .06);
}
.рекорды__название { font-weight: 700; }
.рекорды__значение, .сводка__значение { margin: 0; text-align: right; font-size: 14px; line-height: 1.3; }
.сводка__значение { font-weight: 700; font-size: 16px; }
body.rummikub dl.сводка { display: flex; flex-direction: column; align-items: stretch; gap: 8px; min-height: 0; padding: 0; margin: 0; }
.сводка__название { margin: 0; }
.профиль-игрока { display: flex; align-items: center; gap: 14px; }
.профиль-игрока__имя { margin: 0; }
.профиль-игрока__аватар { width: 64px; height: 64px; flex: 0 0 auto; }

/* ---------- Листы ---------- */
body.rummikub .лист-ещё__лист { gap: 8px; }
.лист-выбора__пояснение { margin: 0; text-align: center; line-height: 1.35; opacity: .9; }
.лист-бот__сейчас { font-weight: 800; opacity: 1; color: var(--сб-акцент); }
.лист-бот__группа { margin: 6px 0 0; font-size: 13px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; opacity: .7; }
.лист-бот__кнопки { display: flex; flex-direction: column; gap: 8px; }
.лист-бот__кнопки--ряд { flex-direction: row; }
/* Листы выбора: всё содержимое не сжимается, лист прокручивается; «Играть» и «Закрыть» закреплены внизу одним блоком (не перекрывают друг друга и не уходят за край). */
.лист-выбора .лист-ещё__лист > * { flex-shrink: 0; }
.лист-выбора .лист-ещё__лист { overflow: hidden; }
.лист-выбора .лист-ещё__лист > .лист-бот__прокрутка { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 8px; }
.лист-бот__прокрутка > * { flex-shrink: 0; }
/* Знак «ниже есть ещё настройки»: светлая тень у нижнего края прокрутки; уходит, когда доскроллили до конца (приём с background-attachment: local). Только цвет, картинок нет. */
.лист-бот__прокрутка {
  background:
    linear-gradient(var(--вт-поверхность, #121826) 30%, transparent) center top / 100% 36px no-repeat local,
    linear-gradient(transparent, var(--вт-поверхность, #121826) 70%) center bottom / 100% 36px no-repeat local,
    radial-gradient(farthest-side at 50% 0, rgba(255, 255, 255, .22), transparent) center top / 100% 12px no-repeat scroll,
    radial-gradient(farthest-side at 50% 100%, rgba(210, 247, 107, .55), transparent) center bottom / 100% 22px no-repeat scroll;
}
/* «Время на ход» на узком экране: кнопки по ширине надписи, чтобы «Без ограничения» помещалось целиком (шрифт не уменьшаем). */
#лист-бот-время .кнопка.кнопка--выбор, #лист-вместе-время .кнопка.кнопка--выбор { flex: 1 1 auto; padding-left: 8px; padding-right: 8px; }
.лист-бот__низ { display: flex; flex-direction: row; gap: 8px; margin-top: 8px; padding-top: 0; }
.лист-бот__низ .кнопка { flex: 2 1 0; min-width: 0; min-height: 52px; }
.лист-бот__низ .лист-ещё__закрыть { position: static; flex: 1 1 0; width: auto; min-width: 0; min-height: 52px; margin-top: 0; padding: 0 8px; box-shadow: none; }
.лист-бот__кнопки .кнопка.кнопка--выбор {
  min-height: 52px; padding: 8px 14px; text-align: left; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px;
  color: var(--сб-текст, #fff); background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .22); box-shadow: none;
}
.лист-бот__кнопки:not(.лист-бот__кнопки--ряд) .кнопка.кнопка--выбор { flex: 0 0 auto; min-height: 64px; }
.лист-бот__кнопки--ряд .кнопка.кнопка--выбор { flex: 1 1 0; align-items: center; text-align: center; font-size: 14px; }
.кнопка--выбор__название { font-size: 16px; font-weight: 800; }
.кнопка--выбор__описание { font-size: 13px; font-weight: 500; opacity: .85; line-height: 1.25; }
.лист-бот__кнопки .кнопка.кнопка--выбор[aria-pressed="true"] { color: var(--сб-акцент-текст); background: var(--сб-акцент); border-color: var(--сб-акцент); }
.лист-бот__кнопки .кнопка.кнопка--выбор[aria-pressed="true"] .кнопка--выбор__описание { opacity: .9; }
.лист-ещё__строка[aria-pressed="true"] .лист-ещё__значение { color: var(--сб-акцент); font-weight: 800; }
.итог__кнопки { display: flex; gap: 10px; }
.итог__кнопки .кнопка { flex: 1 1 0; min-width: 0; }
.кнопка[aria-disabled="true"] { opacity: .55; }

/* ---------- Партия: сцена ---------- */
.партия {
  --k: 8; --a: 44px; --h: 57px; --ko: 13; --ao: 26px; --ho: 34px;
  /* Низ плашек «Пропустить показ» и тренировки: чуть выше ленты. Под лентой: действия, стойка (2 плитки + 4 зазор + 14 поля), промежутки, поле экрана; замер 320…430 — до ленты 2h+130…138 px. */
  --над-лентой: calc(var(--h) * 2 + 142px);
  gap: 5px; user-select: none; -webkit-user-select: none; overflow: hidden;
  background: #17304a url("../../img/rummikub/сцена.jpg") center / cover no-repeat;
  color: var(--текст-на-сцене); touch-action: manipulation; max-width: 480px; margin: 0 auto; width: 100%;
}
.партия__верх { display: flex; align-items: center; gap: 8px; min-height: 44px; flex: 0 0 auto; }
.партия__кнопка {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; flex: 0 0 auto;
  color: var(--текст-на-сцене); background: var(--стекло); border: 1px solid var(--стекло-край); border-radius: 14px; cursor: pointer;
}
.партия__кнопка svg { width: 22px; height: 22px; }
.партия__режим {
  flex: 1 1 auto; min-width: 0; margin: 0; padding: 0 12px; min-height: 36px; display: flex; align-items: center; justify-content: center; text-align: center;
  font-size: 15px; font-weight: 800; border-radius: 18px; background: var(--стекло); border: 1px solid var(--стекло-край);
}
@media (max-width: 340px) { .партия__режим { font-size: 13px; line-height: 1.15; padding: 0 8px; } }

/* ---------- Игроки ---------- */
.партия__игроки { display: flex; gap: 6px; flex: 0 0 auto; flex-wrap: nowrap; }
.чип {
  position: relative; flex: 1 1 0; min-width: 0; min-height: 40px; display: flex; align-items: center; gap: 5px; padding: 4px 8px;
  border-radius: 20px; background: var(--стекло); border: 2px solid var(--стекло-край); font-weight: 800; font-size: 13px; overflow: hidden;
}
.чип__имя { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.чип__число { font-size: 18px; font-variant-numeric: tabular-nums; }
.чип__точка { width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, .35); flex: 0 0 auto; }
.чип[data-ходит="да"] { border-color: var(--сб-акцент); box-shadow: 0 0 0 3px rgba(210, 247, 107, .28); }
.чип[data-ходит="да"] .чип__точка { background: var(--сб-акцент); }
.чип[data-мало="да"] .чип__число { color: var(--золото-светлое); }
.чип__замок { width: 12px; height: 12px; flex: 0 0 auto; border-radius: 3px; border: 2px solid rgba(255, 255, 255, .55); }
.чип[data-вышел="да"] .чип__замок { border-color: var(--сб-акцент); background: var(--сб-акцент); }
.чип--пул { flex: 0 0 auto; min-width: 64px; }
.чип__рубашка { width: 16px; height: 22px; border-radius: 3px; background: #2A5FD8 url("../../img/rummikub/плитка-рубашка.png") center / cover no-repeat; border: 1px solid rgba(255, 255, 255, .5); }
.чип__думает { display: none; gap: 3px; }
.чип__думает i { width: 5px; height: 5px; border-radius: 50%; background: var(--сб-акцент); animation: думает 1s infinite ease-in-out; }
.чип__думает i:nth-child(2) { animation-delay: .15s; }
.чип__думает i:nth-child(3) { animation-delay: .3s; }
.чип[data-ходит="да"] .чип__думает { display: inline-flex; }
.чип[data-таймер="да"] .чип__думает { display: none; }
/* Узкий экран (320): в полосе игроков имя «Вы» съедалось многоточием; ход и так виден по салатовой рамке, поэтому точка и три точки «думает» прячутся */
@media (max-width: 340px) { .чип { gap: 4px; padding: 4px 6px; } .чип__точка, .чип[data-ходит="да"] .чип__думает { display: none; } }
/* Четверо за столом (пять плашек с пулом): иначе имя сжималось до нуля и было не понять, кто где. Точка и «думает» уходят (ход виден по рамке),
   число меньше, пул уже. До 400 уходит ещё и замок: «вышел» тогда показывает салатовое имя. */
.партия__игроки:has(> .чип:nth-child(5)) .чип { gap: 3px; padding: 4px 5px; font-size: 12px; }
.партия__игроки:has(> .чип:nth-child(5)) .чип__число { font-size: 16px; }
.партия__игроки:has(> .чип:nth-child(5)) .чип__точка, .партия__игроки:has(> .чип:nth-child(5)) .чип[data-ходит="да"] .чип__думает { display: none; }
.партия__игроки:has(> .чип:nth-child(5)) .чип--пул { min-width: 54px; }
/* Узкий экран на четверых: имя целиком в первой строке чипа, число и пометки под ним — подписи соседних чипов не налезают друг на друга. */
@media (max-width: 340px) {
  .партия__игроки:has(> .чип:nth-child(5)) .чип:not(.чип--пул) { flex-wrap: wrap; justify-content: center; align-content: center; row-gap: 0; padding: 3px 3px; }
  .партия__игроки:has(> .чип:nth-child(5)) .чип:not(.чип--пул) .чип__имя { flex: 0 0 100%; text-align: center; font-size: 12px; line-height: 1.15; }
}
.партия__игроки:has(> .чип:nth-child(5)) .чип[data-вышел="да"] .чип__имя { color: var(--сб-акцент); }
@media (max-width: 400px) { .партия__игроки:has(> .чип:nth-child(5)) .чип__замок { display: none; } }
@keyframes думает { 0%, 100% { opacity: .25; transform: scale(.7); } 50% { opacity: 1; transform: scale(1.15); } }
.чип__полоса { position: absolute; left: 0; bottom: 0; height: 4px; width: 100%; background: var(--сб-акцент); transform-origin: left; }
.чип__полоса[data-доля="0"] { transform: scaleX(0); }
.чип__секунды:empty { display: none; }
.чип__секунды { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--ошибка); }
.чип[data-срочно="да"] { border-color: var(--ошибка); }
.чип[data-срочно="да"] .чип__полоса { background: var(--ошибка); }
.чип__полоса[data-доля="20"] { transform: none; }
.чип__полоса[data-доля="19"] { transform: scaleX(.95); } .чип__полоса[data-доля="18"] { transform: scaleX(.9); }
.чип__полоса[data-доля="17"] { transform: scaleX(.85); } .чип__полоса[data-доля="16"] { transform: scaleX(.8); }
.чип__полоса[data-доля="15"] { transform: scaleX(.75); } .чип__полоса[data-доля="14"] { transform: scaleX(.7); }
.чип__полоса[data-доля="13"] { transform: scaleX(.65); } .чип__полоса[data-доля="12"] { transform: scaleX(.6); }
.чип__полоса[data-доля="11"] { transform: scaleX(.55); } .чип__полоса[data-доля="10"] { transform: scaleX(.5); }
.чип__полоса[data-доля="9"] { transform: scaleX(.45); } .чип__полоса[data-доля="8"] { transform: scaleX(.4); }
.чип__полоса[data-доля="7"] { transform: scaleX(.35); } .чип__полоса[data-доля="6"] { transform: scaleX(.3); }
.чип__полоса[data-доля="5"] { transform: scaleX(.25); } .чип__полоса[data-доля="4"] { transform: scaleX(.2); }
.чип__полоса[data-доля="3"] { transform: scaleX(.15); } .чип__полоса[data-доля="2"] { transform: scaleX(.1); }
.чип__полоса[data-доля="1"] { transform: scaleX(.05); }

/* ---------- Плитка ---------- */
.плитка {
  position: relative; box-sizing: border-box; width: var(--a); height: var(--h); padding: 0; margin: 0; flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font: inherit; color: var(--графит); cursor: grab; touch-action: none; -webkit-tap-highlight-color: transparent;
  border-radius: 7px; border: 1px solid rgba(60, 70, 95, .45);
  background: url("../../img/rummikub/плитка-основа.png") center / 100% 100% no-repeat, linear-gradient(180deg, var(--фарфор), var(--фарфор-низ));
  box-shadow: 0 2px 0 #aab3c6, 0 3px 5px rgba(0, 10, 30, .4), inset 0 1px 0 rgba(255, 255, 255, .9);
}
.плитка__число { font-weight: 900; line-height: 1; font-size: max(24px, calc(var(--h) * .45)); font-variant-numeric: tabular-nums; }
.плитка__знак { display: none; width: 9px; height: 9px; background: currentColor; }
.плитка[data-цвет="0"] { color: var(--рубин); }
.плитка[data-цвет="1"] { color: var(--сапфир); }
.плитка[data-цвет="2"] { color: var(--изумруд); }
.плитка[data-цвет="3"] { color: var(--графит); }
.партия[data-знаки="да"] .плитка__знак { display: block; }
.плитка[data-цвет="0"] .плитка__знак { border-radius: 50%; }
.плитка[data-цвет="1"] .плитка__знак { border-radius: 1px; }
.плитка[data-цвет="2"] .плитка__знак { clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.плитка[data-цвет="3"] .плитка__знак { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.плитка[data-джокер] { background: url("../../img/rummikub/плитка-джокер.png") center / 100% 100% no-repeat, linear-gradient(180deg, #fff, #e6dcff); }
.плитка__кристалл {
  width: 46%; aspect-ratio: 1; background: linear-gradient(135deg, #7be4ff, #b58cff 55%, #ff9ad5);
  clip-path: polygon(50% 0, 100% 38%, 78% 100%, 22% 100%, 0 38%); filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .35));
}
.плитка__как { position: absolute; right: 3px; bottom: 2px; font-size: 12px; font-weight: 900; color: var(--графит); }
.плитка:focus-visible { outline: 3px solid var(--сб-акцент); outline-offset: 2px; z-index: 2; }
.плитка--выбрана { transform: translateY(-5px); box-shadow: 0 0 0 3px var(--сб-акцент), 0 6px 10px rgba(0, 10, 30, .5); z-index: 2; }
.плитка--подсказка { box-shadow: 0 0 0 3px var(--сб-акцент), 0 0 12px 3px color-mix(in srgb, var(--сб-акцент) 75%, transparent); animation: подсказка 1s infinite ease-in-out; }
@keyframes подсказка { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.12); } }
.плитка--новая { animation: новая .5s ease-out; box-shadow: 0 0 0 3px var(--сб-акцент), 0 0 10px 2px rgba(210, 247, 107, .7); }
@keyframes новая { from { transform: translateY(-14px) scale(1.1); opacity: .4; } to { transform: none; opacity: 1; } }
.плитка--тень { opacity: .3; filter: grayscale(.6); }
.плитка--несу {
  position: fixed; left: 0; top: 0; z-index: 20; pointer-events: none; transform: translate(var(--x, 0px), var(--y, 0px)) scale(1.12) rotate(-3deg);
  box-shadow: 0 10px 18px rgba(0, 10, 30, .55), 0 0 0 2px var(--сб-акцент); cursor: grabbing;
}
.плитка--мини { width: 30px; height: 40px; cursor: default; border-radius: 5px; touch-action: auto; }
.плитка--мини .плитка__число { font-size: 18px; }
.плитка--мини .плитка__знак { display: none; }

/* ---------- Стол ---------- */
.партия__столоболочка { position: relative; flex: 1 1 0; min-height: 96px; display: flex; flex-direction: column; }
.стол {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 8px 6px; border-radius: 16px; touch-action: pan-y;
  display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px 10px;
  background: url("../../img/rummikub/стол.jpg") center / cover no-repeat, radial-gradient(ellipse at 50% 30%, var(--сукно), var(--сукно-тёмное));
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, .25), inset 0 8px 18px rgba(0, 0, 0, .35);
}
.стол__пусто {
  position: absolute; left: 12px; right: 12px; top: 50%; transform: translateY(-50%); margin: 0; text-align: center; pointer-events: none;
  font-weight: 700; font-size: 15px; color: rgba(255, 255, 255, .8); text-shadow: 0 1px 4px rgba(0, 0, 0, .6);
}
.стол[data-пусто="нет"] + .стол__пусто { display: none; }
.набор {
  position: relative; display: flex; flex-wrap: wrap; gap: 4px 1px; padding: 3px; border-radius: 10px; flex: 0 0 auto; max-width: 100%;
  background: rgba(255, 255, 255, .08); border: 2px solid transparent;
}
.набор[data-моё="да"] { border-color: var(--сб-акцент); box-shadow: 0 0 10px 2px rgba(210, 247, 107, .55); }
.набор[data-заперт="да"] .плитка { cursor: default; filter: saturate(.85); }
.набор[data-ошибка="да"] { border: 2px dashed var(--ошибка); background: var(--ошибка-фон); padding-right: 22px; }
.набор__восклик {
  position: absolute; right: -4px; top: -12px; width: 32px; height: 32px; padding: 0; border-radius: 50%; border: 2px solid #fff;
  background: var(--ошибка); color: #fff; font-weight: 900; font-size: 18px; line-height: 1; cursor: pointer;
}
.набор__восклик::after { content: ""; position: absolute; inset: -9px; }
.зона-новый {
  margin-bottom: 8px; flex: 0 0 auto; min-width: calc(var(--a) * 2); min-height: var(--h); padding: 0 12px; border-radius: 10px; font: inherit; font-weight: 800; font-size: 14px;
  color: rgba(255, 255, 255, .85); background: rgba(255, 255, 255, .06); border: 2px dashed rgba(255, 255, 255, .45); cursor: pointer;
}
[data-цель="да"].зона-новый, .набор[data-цель="да"], .паз[data-цель="да"], .стойка[data-цель="да"], .стол[data-цель="да"] {
  outline: 3px solid var(--сб-акцент); outline-offset: 1px; background-color: rgba(210, 247, 107, .22);
}
[data-цель="нет"].зона-новый, .набор[data-цель="нет"], .паз[data-цель="нет"], .стойка[data-цель="нет"], .стол[data-цель="нет"] {
  outline: 3px solid var(--ошибка); outline-offset: 1px;
}
.цель-подпись {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); margin: 0; padding: 6px 12px; border-radius: 14px; max-width: 92%;
  font-size: 14px; font-weight: 800; text-align: center; background: var(--стекло); border: 1px solid var(--стекло-край); pointer-events: none; z-index: 6;
}
.цель-подпись[data-цель="нет"] { color: #ffd9de; border-color: var(--ошибка); }

/* Обзор: весь стол сразу, плитки ×0,6 */
.стол[data-обзор="да"] { gap: 6px 8px; }
.стол[data-обзор="да"] .плитка { width: var(--ao); height: var(--ho); border-radius: 4px; }
.стол[data-обзор="да"] .плитка__число { font-size: max(12px, calc(var(--ho) * .5)); }
.стол[data-обзор="да"] .плитка__знак { display: none; }
.стол[data-обзор="да"] .зона-новый { display: none; }
.стол[data-обзор="да"] .набор { padding: 2px; }

/* ---------- Лента ---------- */
.лента { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex: 0 0 auto; min-height: 44px; }
.лента__слева { flex: 1 1 auto; min-width: 0; }
.лента__счёт { display: flex; align-items: center; gap: 8px; min-width: 0; }
/* Выбраны плитки: счёт прячется, «Хвост»/«Снять» на месте; строка состояния показывается только для отказа и всплывает над лентой. */
.лента__счёт[data-выбор="да"] .пилюля { display: none; }
.лента__счёт[data-выбор="да"] .партия__статус:not([data-вид="отказ"]) { display: none; }
.лента__счёт[data-выбор="да"] .партия__статус {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 4px); z-index: 6; pointer-events: none; background: rgba(14, 22, 40, .94);
}
.пилюля {
  flex: 0 0 auto; padding: 6px 10px; min-height: 32px; display: inline-flex; align-items: center; border-radius: 16px;
  font-weight: 900; font-size: 14px; background: var(--стекло); border: 1px solid var(--стекло-край); font-variant-numeric: tabular-nums;
}
.пилюля[data-вид="хватает"], .пилюля[data-вид="вышел"] { background: var(--сб-акцент); color: var(--сб-акцент-текст); border-color: var(--сб-акцент); }
.партия__статус {
  flex: 1 1 auto; min-width: 0; margin: 0; padding: 4px 8px; min-height: 36px; display: flex; align-items: center; font-size: 13px; font-weight: 700; line-height: 1.2;
  border-radius: 12px; background: var(--стекло); border: 1px solid var(--стекло-край);
}
.партия__статус:empty { visibility: hidden; }
.партия__статус[data-вид="отказ"] { border-color: var(--ошибка); color: #ffd9de; }
.лента__выбор { display: flex; gap: 8px; }
.лента__малая {
  min-height: 44px; padding: 6px 12px; font: inherit; font-weight: 800; font-size: 14px; color: var(--текст-на-сцене); cursor: pointer;
  background: var(--стекло); border: 1px solid var(--стекло-край); border-radius: 14px;
}
.лента__кнопки { display: flex; gap: 8px; flex: 0 0 auto; }
.лента__значок {
  width: 44px; height: 44px; padding: 0; display: inline-flex; align-items: center; justify-content: center; font: inherit; cursor: pointer;
  color: var(--текст-на-сцене); background: var(--стекло); border: 1px solid var(--стекло-край); border-radius: 14px; box-shadow: none; min-height: 44px;
}
.лента__значок svg { width: 22px; height: 22px; }
.лента__значок.кнопка--выбор[aria-pressed="true"] { color: var(--сб-акцент-текст); background: var(--сб-акцент); border-color: var(--сб-акцент); }
.лента__надпись { font-weight: 900; font-size: 13px; letter-spacing: -.5px; }
.лента__цвета { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.лента__цвета i { width: 9px; height: 9px; border-radius: 50%; }
.лента__цвета i:nth-child(1) { background: var(--рубин); } .лента__цвета i:nth-child(2) { background: var(--сапфир); }
.лента__цвета i:nth-child(3) { background: var(--изумруд); } .лента__цвета i:nth-child(4) { background: #9aa3b8; }

/* ---------- Стойка ---------- */
.партия__стойкаоболочка {
  /* Ширина стойки по формуле ТЗ §3б = W − 12: рамка выходит на 2 px в поля экрана и без бокового отступа, иначе крайние плитки срезались на 6–7 px */
  position: relative; flex: 0 0 auto; margin: 0 -2px; padding: 6px 0 8px; border-radius: 12px;
  background: url("../../img/rummikub/стойка.jpg") center / cover no-repeat, linear-gradient(180deg, #dfe5ef, #c3ccdb);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .25), 0 3px 8px rgba(0, 0, 0, .4); overflow: hidden;
}
/* Пазы на картинке стойки (13 в ряду) не совпадают с нашей сеткой из k колонок. Размываем и приглушаем фон поверх картинки:
   остаётся мрамор с мягкими тенями без чёткой решётки, а настоящие ячейки рисуют .паз--пуст. */
.партия__стойкаоболочка::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(180deg, rgba(236, 240, 247, .55), rgba(208, 216, 230, .6));
  -webkit-backdrop-filter: blur(9px); backdrop-filter: blur(9px);
}
.стойка {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: repeat(var(--k), var(--a)); grid-auto-rows: var(--h); gap: 4px 0; justify-content: center;
  height: calc(var(--h) * 2 + 4px); overflow-y: auto; overflow-x: hidden; scroll-snap-type: y mandatory; scrollbar-width: none; touch-action: pan-y;
}
.стойка::-webkit-scrollbar { display: none; }
.стойка[data-закрыта="да"] { visibility: hidden; }
.паз { width: var(--a); height: var(--h); display: flex; align-items: center; justify-content: center; scroll-snap-align: start; box-sizing: border-box; padding: 0 1px; }
.паз .плитка { width: 100%; height: 100%; }
.паз--пуст { border-radius: 6px; background: rgba(0, 0, 0, .14); box-shadow: inset 0 1px 3px rgba(0, 0, 0, .4); margin: 0 1px; width: calc(var(--a) - 2px); }
.стойка__точки { z-index: 2; position: absolute; right: 2px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 4px; pointer-events: none; }
.стойка__точки i { width: 5px; height: 5px; border-radius: 50%; background: rgba(255, 255, 255, .4); }
.стойка__точки i.активна { background: #fff; }

/* ---------- Панель действий ---------- */
.партия__действия { flex: 0 0 auto; display: grid; grid-template-columns: repeat(3, 1fr) 1.5fr; gap: 8px; padding-bottom: 6px; }
.действие {
  min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 4px 4px;
  font: inherit; color: var(--текст-на-сцене); background: var(--стекло); border: 1px solid var(--стекло-край); border-radius: 14px; cursor: pointer;
}
.действие svg { width: 20px; height: 20px; }
.действие__подпись { font-size: 12px; font-weight: 800; line-height: 1.1; text-align: center; }
.действие:active { transform: translateY(2px); }
.действие[aria-disabled="true"] { opacity: .5; }
.действие--главная { color: var(--сб-акцент-текст); background: var(--сб-акцент); border-color: var(--сб-акцент); }
.действие--главная .действие__подпись { font-size: 15px; }
.действие--главная[data-вид="готово"] { box-shadow: 0 0 0 3px rgba(210, 247, 107, .35); }
.действие[data-мигает="да"] { animation: мигает 1s infinite ease-in-out; }
@keyframes мигает { 0%, 100% { box-shadow: none; } 50% { box-shadow: 0 0 0 3px var(--сб-акцент); } }

/* ---------- Подпись показа бота ---------- */
.показ-пропустить {
  position: absolute; left: 12px; right: 12px; bottom: var(--над-лентой); margin: 0; padding: 8px 12px; border-radius: 14px; text-align: center; z-index: 7;
  font-size: 14px; font-weight: 800; color: var(--сб-акцент-текст); background: var(--сб-акцент); box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
}

/* ---------- Тренировка ---------- */
/* Подсказка стоит в потоке между игроками и столом (стол при этом ниже, но не перекрыт). Порядок блоков партии задан явно. */
.партия > .партия__верх { order: 1; }
.партия > .партия__игроки { order: 2; }
.партия > .обучение { order: 3; }
.партия > .партия__столоболочка { order: 4; }
.партия > .лента { order: 5; }
.партия > .партия__стойкаоболочка { order: 6; }
.партия > .партия__действия { order: 7; }
.обучение {
  position: relative; flex: 0 0 auto; z-index: 8; display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 14px;
  background: rgba(10, 16, 30, .92); border: 2px solid var(--сб-акцент);
}
.обучение__текст { flex: 1 1 auto; margin: 0; font-size: 13px; font-weight: 700; line-height: 1.25; }
.обучение__пропуск { min-height: 44px; padding: 6px 12px; font: inherit; font-weight: 800; font-size: 13px; color: var(--текст-на-сцене); background: transparent; border: 1px solid var(--стекло-край); border-radius: 12px; cursor: pointer; }
.рука-указатель {
  position: absolute; left: 0; top: 0; width: 44px; height: 44px; z-index: 9; pointer-events: none; transform: translate(var(--dx, 0px), var(--dy, 0px));
  transition: transform .35s ease-out; animation: тап 1.1s infinite ease-in-out;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 3a2 2 0 0 1 4 0v7l2-.4a2 2 0 0 1 2.2 1.1l1.2-.3a2 2 0 0 1 2 .9 2 2 0 0 1 1.3 2.3l-.9 5.2A4 4 0 0 1 16.9 22H12a4 4 0 0 1-3.2-1.6L4.5 14.7a1.8 1.8 0 0 1 2.7-2.3L9 14Z' fill='%23fff' stroke='%23123' stroke-width='1.1' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .5));
}
@keyframes тап { 0%, 100% { margin: 0; } 50% { margin: -6px 0 0 -6px; } }

/* ---------- Шторка «Вместе» ---------- */
.шторка {
  position: absolute; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px; text-align: center;
  background: #0d1426 url("../../img/rummikub/шторка.jpg") center / cover no-repeat;
}
.шторка__заголовок { margin: 0; font-size: 24px; line-height: 1.2; text-shadow: 0 2px 10px rgba(0, 0, 0, .7); }
.шторка__кнопка { min-height: 56px; padding: 10px 22px; font-size: 18px; }

/* ---------- Подтверждение ---------- */
.окно-подтверждение { position: absolute; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; padding: 12px; background: rgba(5, 10, 20, .55); }
.окно-подтверждение__карточка { width: 100%; display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: 18px; background: #172036; border: 1px solid var(--стекло-край); }
.окно-подтверждение__заголовок { margin: 0; font-size: 18px; line-height: 1.25; text-align: center; }

/* ---------- Итог ---------- */
.окно-итог {
  position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 35; display: flex; flex-direction: column; gap: 8px; padding: 12px;
  border-radius: 18px; text-align: center; background: rgba(12, 18, 34, .94); border: 1px solid var(--стекло-край);
}
.окно-итог__заголовок { margin: 0; font-size: 22px; line-height: 1.1; color: var(--золото-светлое); }
.итог__таблица { width: 100%; border-collapse: collapse; font-size: 14px; }
.итог__таблица th, .итог__таблица td { padding: 5px 4px; text-align: center; border-bottom: 1px solid rgba(255, 255, 255, .12); }
.итог__таблица th:first-child, .итог__таблица td:first-child { text-align: left; }
.итог__таблица tr[data-победитель="да"] { color: var(--сб-акцент); font-weight: 800; }
.окно-итог__строка { margin: 0; font-size: 14px; font-weight: 700; line-height: 1.25; }
.окно-итог .итог__кнопки { flex-wrap: wrap; gap: 8px; }
.окно-итог .кнопка { min-width: 0; min-height: 48px; padding: 6px 8px; font-size: 14px; line-height: 1.15; }
.окно-итог .кнопка--главная { flex: 1.3 1 100%; font-size: 16px; }
.итог__вернуться { position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 35; }

/* ---------- Конфетти ---------- */
.конфетти { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
.конфетти i { position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px; animation: конфетти 1.8s ease-in forwards; }
.конфетти i:nth-child(5n+1) { background: var(--сб-акцент); left: 8%; --дрейф: 24px; }
.конфетти i:nth-child(5n+2) { background: var(--золото); left: 28%; --дрейф: -30px; }
.конфетти i:nth-child(5n+3) { background: #5fd4e3; left: 48%; --дрейф: 18px; }
.конфетти i:nth-child(5n+4) { background: #fff; left: 68%; --дрейф: -20px; }
.конфетти i:nth-child(5n) { background: #ff8fb8; left: 88%; --дрейф: 30px; }
.конфетти i:nth-child(3n) { margin-left: 14px; animation-delay: .12s; }
.конфетти i:nth-child(4n) { margin-left: -12px; animation-delay: .25s; }
@keyframes конфетти { to { transform: translate(var(--дрейф, 0), 110vh) rotate(540deg); opacity: .9; } }

/* ---------- Низкие экраны: подписи прячем, плотнее ---------- */
@media (max-height: 640px) {
  .действие__подпись { display: none; }
  .действие--главная .действие__подпись { display: block; }
  .действие { min-height: 44px; }
  .чип { min-height: 34px; }
}

/* ---------- Низкое окно (телефон на боку, высота до 500 px): кнопки действий — столбцом справа, всё помещается в окно ----------
   Плитки в этом режиме меньше (34×44, задаёт rummikub-экран.js по тому же условию). Запас: если что-то не влезло, экран партии прокручивается. */
@media (max-height: 500px) and (orientation: landscape) {
  .партия { --над-лентой: calc(var(--h) * 2 + 84px); max-width: 760px; overflow-y: auto; overscroll-behavior: contain; }
  .партия.экран--виден {
    display: grid; grid-template-columns: minmax(0, 1fr) 92px; grid-template-rows: auto auto auto minmax(64px, 1fr) auto auto;
    column-gap: 8px; row-gap: 4px; align-content: stretch;
  }
  .партия > .партия__верх { grid-column: 1; grid-row: 1; }
  .партия > .партия__игроки { grid-column: 1; grid-row: 2; }
  .партия > .обучение { grid-column: 1; grid-row: 3; }
  .партия > .партия__столоболочка { grid-column: 1; grid-row: 4; min-height: 64px; }
  .партия > .лента { grid-column: 1; grid-row: 5; }
  .партия > .партия__стойкаоболочка { grid-column: 1; grid-row: 6; }
  .партия > .партия__действия {
    grid-column: 2; grid-row: 1 / -1; display: flex; flex-direction: column; gap: 6px; padding-bottom: 0; justify-content: center; align-self: stretch;
  }
  .партия__действия .действие { flex: 1 1 0; min-height: 48px; max-height: 88px; }
  .партия__действия .действие--главная { flex-grow: 1.4; }
  .партия__действия .действие__подпись { display: block; }
  .показ-пропустить { right: 112px; }
  /* Рука больше двух строк (rummikub-013): стойка в три строки 22×28 той же высоты (3·28 + 2·4 = 92), цифра меньше, знак цвета скрыт */
  .стойка[data-рядов="3"] { height: calc(var(--h) * 3 + 8px); }
  .стойка[data-рядов="3"] .плитка__число { font-size: max(12px, calc(var(--h) * .5)); }
  .стойка[data-рядов="3"] .плитка__знак { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .партия *, .партия *::before, .партия *::after {
    animation-duration: .01ms !important; animation-delay: 0ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important;
  }
}
