/* Оболочка и общие элементы. Всё, что рисуется больше чем на одном экране, живёт здесь; игровые доски
   рисуют себя на <canvas> и в этот файл почти не заглядывают. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;   /* в игре «оттяните-чтобы-обновить» — это случайный выход из матча */
  /* Только прокрутка: ни двойной тап, ни щипок не должны увеличивать страницу — быстрые нажатия по кнопкам
     в мобильных браузерах иначе превращались в зум. Доски ставят себе touch-action: none сами. */
  touch-action: pan-x pan-y;
}

body {
  /* Это приложение, а не документ: перетаскивание пальцем — скролл и жесты, а не выделение текста.
     Без запрета долгий свайп на iOS вскидывает «Скопировать/Найти» посреди игры. Поля ввода — ниже. */
  -webkit-user-select: none;
  user-select: none;
  font-family: var(--font);
  color: var(--ink);
  /* Тёмный, а не сукно: основные экраны мобильного живут на почти чёрном фоне, сукно — вход и матчи. */
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  /* НЕ inset: 0. В Safari «100vh» — это высота С УБРАННОЙ панелью URL: пока панель видна, низ
     приложения (таббар, кнопки матча) лежит ПОД ней и его никак не достать. dvh меряет реально
     видимую область и сжимается вместе с появлением панели. Строка с vh — запасной вариант для
     браузеров без dvh, им хуже не становится. */
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  align-items: center;
}

/* Телефонная колонка — как _WebShell во Flutter-вебе (460px). Игра нарисована под телефон: доски по
   ширине, нижняя навигация; растянутая на монитор она превращается в кнопки по краям с пустотой
   посередине. Ограничение ширины — единственный способ показать ту же игру, а не испорченную. */
/* Экран лежит либо прямо в #app, либо в контейнере запуска роутера (display:contents). */
#app > .screen,
#app > div > .screen {
  width: 100%;
  max-width: 460px;
}
@media (min-width: 461px) {
  #app > .screen,
  #app > div > .screen {
    border-inline: 1px solid var(--line);
  }
}

/* Безопасные зоны iOS: без них нижняя навигация уезжает под полосу-жест. */
.safe-top { padding-top: env(safe-area-inset-top); }
.safe-bottom { padding-bottom: env(safe-area-inset-bottom); }

/* --- Типографика ------------------------------------------------------------------------------- */

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 26px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0 0 var(--sp-3); line-height: 1.45; }
.dim { color: var(--ink-dim); }
.faint { color: var(--ink-faint); }
.small { font-size: 13px; }
.tiny { font-size: 11px; }
.num { font-variant-numeric: tabular-nums; font-family: var(--font-num); }
.center { text-align: center; }
.grow { flex: 1 1 auto; min-height: 0; min-width: 0; }
.row { display: flex; align-items: center; gap: var(--sp-2); }
.col { display: flex; flex-direction: column; gap: var(--sp-2); }
.wrap { flex-wrap: wrap; }
.spacer { flex: 1 1 auto; }

/* --- Экран ------------------------------------------------------------------------------------- */

.screen {
  position: relative;   /* плавающие баннеры матча позиционируются от экрана */
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

/* Предложение ничьей — плавает над нижней зоной, ничего не раздвигая. */
.draw-float {
  position: absolute; left: 12px; right: 12px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 118px);
  z-index: 30;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: #23262C; border: 1px solid rgba(255, 255, 255, 0.10); border-radius: 16px;
  box-shadow: var(--shadow-3);
  font-size: 14px; font-weight: 600;
  animation: sheet-in var(--dur) var(--ease-out);
}

.scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.pad { padding: var(--sp-4); }

/* --- Верхняя панель ---------------------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  padding-top: calc(var(--sp-3) + env(safe-area-inset-top));
  background: rgba(0, 0, 0, 0.22);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  flex: 0 0 auto;
}

.topbar h2 { font-size: 18px; }

.back-btn {
  border: 0;
  background: none;
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  padding: var(--sp-1) var(--sp-2);
  cursor: pointer;
  border-radius: var(--r-sm);
}
.back-btn:hover { background: var(--surface); }

/* --- Нижняя навигация -------------------------------------------------------------------------- */

.tabbar {
  display: flex;
  flex: 0 0 auto;
  background: rgba(0, 0, 0, 0.34);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.tabbar button {
  flex: 1 1 0;
  border: 0;
  background: none;
  color: var(--ink-faint);
  padding: var(--sp-2) var(--sp-1) var(--sp-3);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: color var(--dur-fast) var(--ease-out);
  position: relative;
}

.tabbar button .ico {
  line-height: 1;
  padding: 3px 18px;
  border-radius: var(--r-pill);
  transition: background var(--dur-fast) var(--ease-out), opacity var(--dur-fast) var(--ease-out);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* Неактивная вкладка приглушается прозрачностью самой КАРТИНКИ: перекрасить <img> нечем. */
  opacity: 0.5;
}
.tabbar button.active .ico { opacity: 1; }
.tabbar button .ico .ico-img { display: block; }
/* Активная вкладка — пилюля вокруг иконки, как в Material 3 мобильного, а не просто синяя иконка. */
.tabbar button.active { color: var(--ink); }
.tabbar button.active .ico { background: rgba(83, 166, 255, 0.22); }
.tabbar button:hover { color: var(--ink-dim); }
.tabbar button.active:hover { color: var(--ink); }

/* Точка на вкладке — «есть что забрать» (ежедневный бонус, заявка в друзья, непрочитанное). */
.tabbar button .dot {
  position: absolute;
  top: 6px;
  right: calc(50% - 16px);
  width: 8px;
  height: 8px;
  border-radius: var(--r-pill);
  background: var(--gold);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35);
}

/* --- Иконки ------------------------------------------------------------------------------------ */

.ico-img {
  display: inline-block;
  vertical-align: -0.22em;
  object-fit: contain;
  flex: 0 0 auto;
  user-select: none;
}

/* Глиф-маска: сам знак — currentColor, поэтому он живёт в цвете окружающего текста. */
.ico-mask {
  display: inline-block;
  vertical-align: -0.22em;
  flex: 0 0 auto;
  background: currentColor;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}

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

.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--surface-strong);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out),
              opacity var(--dur-fast) var(--ease-out);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.16); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.42; cursor: default; }

.btn.primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  border-color: transparent;
  color: #04203C;
  box-shadow: var(--shadow-2);
}
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: linear-gradient(180deg, var(--accent), var(--accent-deep)); }

/* Деньги всегда золотые — покупка, ставка, забрать награду. */
.btn.gold {
  background: linear-gradient(180deg, var(--gold), var(--gold-deep));
  border-color: transparent;
  color: #3A2A05;
  box-shadow: var(--shadow-2);
}
.btn.gold:hover:not(:disabled) { filter: brightness(1.06); background: linear-gradient(180deg, var(--gold), var(--gold-deep)); }

.btn.danger { border-color: rgba(255, 107, 107, 0.5); color: var(--danger); }
.btn.danger:hover:not(:disabled) { background: rgba(255, 107, 107, 0.14); }

.btn.ghost { background: none; border-color: var(--line); }
.btn.block { width: 100%; }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn.link { background: none; border: 0; color: var(--accent); padding: var(--sp-2); font-weight: 500; }
.btn.link:hover { background: none; text-decoration: underline; }

/* --- Поля ввода -------------------------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12px; color: var(--ink-dim); padding-left: 2px; }

.input {
  appearance: none;
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--surface-sunken);
  color: var(--ink);
  font: inherit;
  padding: 12px 14px;
  border-radius: var(--r-md);
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
input, textarea, [contenteditable] {
  -webkit-user-select: text;
  user-select: text;
}

.input::placeholder { color: var(--ink-faint); }
.input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(0, 0, 0, 0.30);
}
.input.bad { border-color: var(--danger); }

select.input { cursor: pointer; }
select.input option { background: var(--felt-bottom); color: var(--ink); }

/* --- Карточки ---------------------------------------------------------------------------------- */

.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  box-shadow: var(--shadow-1);
}

.card.tap { cursor: pointer; transition: transform var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out); }
.card.tap:hover { background: var(--surface-strong); }
.card.tap:active { transform: scale(0.985); }

.list { display: flex; flex-direction: column; gap: var(--sp-2); }

.list-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

/* --- Аватар ------------------------------------------------------------------------------------ */

/* Общий аватар со шляпой используется и в чужом профиле, открытом напрямую. */
.hat-wrap { position: relative; flex: 0 0 auto; }
.hat-wrap .avatar { width: 100%; height: 100%; }
.hat-wrap.tap { cursor: pointer; }
.hat-img { position: absolute; pointer-events: none; object-fit: contain; }

.avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--r-pill);
  background: var(--surface-strong) center/cover no-repeat;
  border: 1px solid var(--line-strong);
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: var(--ink-dim);
  overflow: hidden;
  position: relative;
}
.avatar.lg { width: 84px; height: 84px; font-size: 30px; }
.avatar.sm { width: 32px; height: 32px; font-size: 13px; }

/* Онлайн-точка на аватаре друга. */
.avatar .online {
  position: absolute;
  right: 0; bottom: 0;
  width: 12px; height: 12px;
  border-radius: var(--r-pill);
  background: var(--success);
  border: 2px solid var(--felt-bottom);
}

/* --- Деньги ------------------------------------------------------------------------------------ */

.coins {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--gold);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
/* Монета — подготовленная иконка, не CSS-кружок; размер в em, чтобы расти вместе с цифрой. */
.coins::before {
  content: '';
  width: 1.05em; height: 1.05em;
  background: url('../assets/icons/color3d/coin.png') center / contain no-repeat;
  flex: 0 0 auto;
}

/* Шляпа на общем аватаре: круг остаётся круглым (фон режет border-radius), а шляпа свисает за него —
   поэтому у аватара со шляпой overflow снимается. Пропорции те же, что в мобильном (45/20 от лица). */
.avatar.has-hat { overflow: visible; }
.avatar .hat-on {
  position: absolute;
  width: 225%; height: 225%;
  left: -62.5%; top: -62.5%;
  object-fit: contain;
  pointer-events: none;
  z-index: 1;
}

.premium-star { display: inline-block; width: 18px; height: 18px; flex: 0 0 18px; vertical-align: -2px; overflow: hidden; color: transparent; background: linear-gradient(145deg,#79ccff,#2487ed 65%,#4369dc); mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m12 2 3.1 6.4 7.1 1-5.1 5 1.2 7.1-6.3-3.3-6.3 3.3 1.2-7.1-5.1-5 7.1-1Z' fill='black' stroke='black' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat; }

/* --- Плашки и уведомления ---------------------------------------------------------------------- */

.banner {
  padding: var(--sp-2) var(--sp-4);
  background: rgba(176, 58, 58, 0.92);
  color: #fff;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex: 0 0 auto;
}
.banner.warn { background: rgba(255, 196, 77, 0.92); color: #3A2A05; }
.banner .btn { padding: 4px 10px; font-size: 12px; border-radius: var(--r-sm); }

#toasts {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  z-index: 60;
  pointer-events: none;
  width: min(92vw, 460px);
}

.toast {
  background: rgba(10, 22, 38, 0.96);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-3);
  font-size: 14px;
  animation: toast-in var(--dur) var(--ease-out);
  max-width: 100%;
  text-align: center;
}
.toast.bad { border-color: rgba(255, 107, 107, 0.6); color: #FFD9D9; }
.toast.good { border-color: rgba(91, 217, 138, 0.6); color: #D8FFE6; }
.toast.gone { animation: toast-out var(--dur) var(--ease-out) forwards; }

@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); } }

/* --- Модальные окна ---------------------------------------------------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 10, 20, 0.66);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: var(--sp-4);
  animation: fade-in var(--dur-fast) var(--ease-out);
}

.sheet {
  width: min(100%, 460px);
  max-height: min(86vh, 720px);
  overflow-y: auto;
  /* Тёмная нейтральная поверхность, как у диалогов мобильного (M3 dark), — НЕ синий градиент. */
  background: #23262C;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  animation: sheet-in var(--dur) var(--ease-out);
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(18px) scale(0.98); } to { opacity: 1; transform: none; } }

/* Нижний лист — веб-двойник showModalBottomSheet: во всю ширину, скруглён только верх, ручка сверху,
   выезжает снизу. Класс вешает modal-обёртка конкретного окна. */
.overlay.from-bottom { place-items: end center; padding: 0; }
.sheet.bottom {
  width: 100%;
  max-width: 640px;
  border-radius: 20px 20px 0 0;
  border-bottom: 0;
  padding: 8px var(--sp-4) calc(var(--sp-4) + env(safe-area-inset-bottom, 0px));
  animation: sheet-up var(--dur) var(--ease-out);
}
.sheet.bottom::before {
  content: '';
  display: block;
  width: 36px; height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.28);
  margin: 2px auto 6px;
  flex: 0 0 auto;
}
@keyframes sheet-up { from { opacity: 0.4; transform: translateY(48px); } to { opacity: 1; transform: none; } }

/* --- Турнир в списке лобби — как _TournamentLobbyCard мобильного ------------------------------- */

.list-row.trn-lobby { cursor: pointer; background: linear-gradient(90deg, transparent, rgba(232, 196, 106, 0.10)); }
.list-row.trn-lobby:active { background: linear-gradient(90deg, transparent, rgba(232, 196, 106, 0.18)); }
.trn-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 6px;
  background: rgba(232, 196, 106, 0.18); border: 1px solid rgba(232, 196, 106, 0.5);
  color: var(--gold); font-size: 10px; font-weight: 900; letter-spacing: 0.5px; }
.trn-badge .ico-mask { background: var(--gold); }
.trn-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px;
  border: 1.5px solid rgba(232, 196, 106, 0.6); }
.trn-dot.on { background: var(--gold); border-color: var(--gold); }
.card.trn-wait { background: rgba(232, 196, 106, 0.14); border-color: rgba(232, 196, 106, 0.35); }
.card.trn-wait .ico-mask { background: var(--gold); }

/* --- Создание комнаты — нижний лист с шагами, как в мобильном ---------------------------------- */

.cr-title { font-size: 20px; font-weight: 800; margin: 2px 0 4px; }
.cr-back { background: none; border: 0; cursor: pointer; color: var(--ink); font-size: 22px; padding: 4px 10px 4px 2px; }
.cr-item { display: flex; align-items: center; gap: 12px; padding: 14px 8px; border-bottom: 1px solid var(--line);
  cursor: pointer; border-radius: 8px; }
.cr-item:last-child { border-bottom: 0; }
.cr-item:active { background: var(--surface); }
.cr-field { position: relative; border: 1px solid var(--line-strong); border-radius: 12px;
  padding: 12px 10px 10px; margin-top: 8px; }
.cr-label { position: absolute; top: -9px; left: 12px; padding: 0 6px; font-size: 12px;
  color: var(--ink-dim); background: #23262C; }
.cr-row { display: flex; align-items: center; gap: 6px; }
.cr-ico { flex: 0 0 auto; display: inline-flex; width: 28px; justify-content: center; }
.cr-arrow { background: none; border: 0; cursor: pointer; color: var(--ink-dim); font-size: 24px;
  padding: 0 12px; line-height: 1; }
.cr-arrow:active { color: var(--ink); }
.cr-val { flex: 1 1 auto; text-align: center; font-size: 17px; font-weight: 700; }
.cr-create { margin-top: 10px; padding: 14px; border-radius: var(--r-pill); font-size: 16px; font-weight: 800; }

/* --- Верхние баннеры-уведомления — веб-двойник ChatNotificationHost ---------------------------- */

.ntf-host {
  position: fixed; top: calc(env(safe-area-inset-top, 0px) + 8px); left: 10px; right: 10px;
  z-index: 90; display: flex; justify-content: center; pointer-events: none;
}
.ntf-card {
  pointer-events: auto; cursor: pointer;
  display: flex; align-items: center; gap: 12px;
  width: 100%; max-width: 560px;
  padding: 10px 12px;
  background: #1C1F24; border: 1px solid rgba(255, 255, 255, 0.10); border-radius: 18px;
  box-shadow: 0 9px 22px rgba(0, 0, 0, 0.45);
  animation: ntf-in 260ms var(--ease-out);
}
.ntf-card.out { animation: ntf-out 220ms var(--ease-out) both; }
@keyframes ntf-in { from { opacity: 0; transform: translateY(-160%); } to { opacity: 1; transform: none; } }
@keyframes ntf-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-160%); } }
.ntf-coin { flex: 0 0 auto; display: grid; place-items: center; width: 40px; height: 40px; }
.ntf-mid { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ntf-reason { font-size: 12px; font-weight: 700; color: var(--ink-dim); }
.ntf-gain { display: inline-flex; align-items: center; gap: 6px; font-size: 21px; font-weight: 900;
  letter-spacing: 0.3px; color: var(--ink); }
.ntf-bal { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 800;
  color: var(--ink-dim); transform-origin: left center; }
.ntf-title { display: inline-flex; align-items: center; gap: 5px; font-size: 14px; font-weight: 800;
  color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ntf-text { font-size: 13px; color: var(--ink-dim); overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ntf-x { flex: 0 0 auto; background: none; border: 0; color: var(--ink-dim); cursor: pointer;
  font-size: 15px; padding: 6px; }

/* --- «Премиум активирован» — веб-двойник PremiumCelebrationHost -------------------------------- */

.overlay.prem-cel { z-index: 95; }
.prem-panel {
  width: min(100%, 360px);
  padding: 28px 24px 20px;
  display: flex; flex-direction: column; align-items: center;
  background: #23262C;
  border: 1px solid rgba(83, 166, 255, 0.45);
  border-radius: 24px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  animation: sheet-in var(--dur) var(--ease-out);
}
.prem-badge {
  width: 84px; height: 84px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(83, 166, 255, 0.16);
  border: 1.5px solid rgba(83, 166, 255, 0.5);
  margin-bottom: 18px;
}
.prem-star-big { color: var(--accent); font-size: 46px; line-height: 1; }
.prem-star-sm { color: var(--accent); font-size: 18px; line-height: 1; }
.prem-perk { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink-dim); }
.prem-perk .ico-mask { background: var(--accent); flex: 0 0 auto; }
.prem-ok { margin-top: 22px; padding: 13px; border-radius: var(--r-md); font-weight: 800; font-size: 15px; }

/* --- Панель результата матча — веб-двойник GameResultOverlay ----------------------------------- */

.rslt {
  position: fixed; inset: 0; z-index: 40;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; overflow-y: auto;
  background: linear-gradient(180deg, rgba(14, 26, 40, 0.95), rgba(8, 12, 18, 0.96));
  animation: fade-in 450ms var(--ease-out);
}
.rslt-bubble {
  position: fixed; top: calc(env(safe-area-inset-top, 0px) + 64px); left: 50%; transform: translateX(-50%);
  z-index: 40; max-width: 320px;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 16px;
  background: rgba(16, 26, 38, 0.90); border: 1px solid rgba(255, 255, 255, 0.10);
  color: #fff; font-size: 15px; font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  animation: fade-in 240ms var(--ease-out);
}
.rslt-bubble .ico-mask { background: #E57373; }
.rslt-bubble.neutral { font-size: 17px; padding: 12px 22px; border-color: rgba(255, 255, 255, 0.18); }

/* Запрос «выгнать за бездействие»: цели — во весь экран, чтобы нельзя было не заметить; просителю — плашка. */
.kick-overlay.full { position: fixed; inset: 0; z-index: 45; display: grid; place-items: center; padding: 24px;
  background: rgba(120, 20, 20, 0.55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  animation: fade-in 200ms var(--ease-out); }
.kick-card { width: min(100%, 360px); display: flex; flex-direction: column; gap: 14px; padding: 26px 22px; text-align: center;
  background: var(--bg-elev); border: 1px solid rgba(229, 115, 115, 0.6); border-radius: var(--r-lg); box-shadow: var(--shadow-3); }
.kick-title { font-size: 22px; font-weight: 900; }
.kick-body { font-size: 14px; color: var(--ink-dim); }
.kick-stay { padding: 18px; border: 0; border-radius: var(--r-pill); cursor: pointer; font-size: 20px; font-weight: 900;
  background: var(--success); color: #062; animation: kick-pulse 1s var(--ease-in-out) infinite; }
/* Пульс — тенью, а не масштабом: кнопка не должна «ездить» под пальцем. */
@keyframes kick-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(91, 217, 138, 0.6); } 50% { box-shadow: 0 0 0 12px rgba(91, 217, 138, 0); } }
.kick-overlay.pill { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 64px); left: 50%; transform: translateX(-50%);
  z-index: 40; pointer-events: none; }
.kick-pill { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 16px;
  background: rgba(16, 26, 38, 0.92); border: 1px solid rgba(229, 115, 115, 0.5); color: #fff; font-size: 14px; font-weight: 700; }
.sheet.full { width: 100%; max-width: none; height: 100%; max-height: none; border-radius: 0; border: 0;
  justify-content: center; padding: var(--sp-5) var(--sp-4) calc(var(--sp-5) + env(safe-area-inset-bottom, 0px)); }
.overlay.full { padding: 0; }

.rslt-vs { display: flex; align-items: flex-start; justify-content: center; gap: 8px; }
.rslt-p { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 110px; }
.rslt-p.dimmed { opacity: 0.5; }
.rslt-p .avatar { width: 80px; height: 80px; font-size: 32px; }
.rslt-p .pname { max-width: 110px; text-align: center; font-size: 15px; font-weight: 800; color: #fff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rslt-pa { position: relative; }
/* Готовность к реваншу — двойник Icons.check_circle мобильного: зелёный кружок с белой галкой на
   тёмной подложке. Прежняя бледная галочка на тёмном фоне попросту терялась. */
.rslt-tick { position: absolute; left: -2px; top: -6px; width: 28px; height: 28px; border-radius: 50%;
  background: #101820; display: grid; place-items: center; opacity: 0; transform: scale(.65);
  transition: opacity 240ms ease, transform 320ms var(--ease-out); pointer-events: none; }
.rslt-tick.active { opacity: 1; transform: scale(1); }
.rslt-tick i { width: 22px; height: 22px; border-radius: 50%; background: #55C16A; color: #08130C;
  display: grid; place-items: center; font-style: normal; font-size: 14px; font-weight: 900; line-height: 1; }
.rslt-mid { display: flex; flex-direction: column; align-items: center; padding-top: 22px; }
.rslt-vslbl { color: rgba(255, 255, 255, 0.38); font-size: 17px; font-weight: 900; letter-spacing: 3px; }
.rslt-score { display: flex; align-items: baseline; gap: 7px; margin-top: 12px; }
.rslt-score b { font-size: 30px; font-weight: 900; color: #fff; }
.rslt-score b.off { color: rgba(255, 255, 255, 0.3); }
.rslt-score i { font-style: normal; color: rgba(255, 255, 255, 0.24); font-size: 22px; font-weight: 900; }
.rslt-serieslbl { margin-top: 2px; color: rgba(255, 255, 255, 0.38); font-size: 9.5px; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase; }
.rslt-emblem { width: 132px; height: 132px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid; box-shadow: 0 0 40px 4px; }
.rslt-emblem .avatar { width: 108px; height: 108px; font-size: 40px; }

.rslt-title { margin-top: 22px; font-size: 36px; font-weight: 900; letter-spacing: 0.5px; text-align: center; }
.rslt-sub { margin-top: 4px; font-size: 18px; font-weight: 700; }
.rslt-reason { margin-top: 8px; color: rgba(255, 255, 255, 0.7); font-size: 16px; text-align: center; }

.rslt-friend {
  margin-top: 14px; width: 250px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px; border-radius: var(--r-pill); background: transparent; cursor: pointer;
  color: #fff; border: 1px solid rgba(255, 255, 255, 0.5); font-weight: 600; font-size: 14px;
}
.rslt-friend:disabled { color: #81C784; border-color: rgba(129, 199, 132, 0.5); }

.rslt-card {
  margin-top: 30px; padding: 16px; width: min(100%, 320px);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  background: rgba(6, 10, 15, 0.9); border: 1px solid rgba(255, 255, 255, 0.09); border-radius: 22px;
}
.rslt-note { display: flex; align-items: center; gap: 8px; color: rgba(255, 255, 255, 0.54);
  font-size: 14px; font-weight: 600; text-align: center; }
.rslt-cd { color: rgba(255, 255, 255, 0.6); font-size: 13px; font-weight: 600; }
.rslt-votes { color: #43D97E; font-size: 15px; font-weight: 800; }
.rslt-err { color: #E57373; font-size: 13px; text-align: center; }
.rslt-rematch {
  width: 250px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px; border-radius: var(--r-pill); cursor: pointer;
  background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff; font-size: 16px; font-weight: 800;
  transition: background 260ms ease, border-color 260ms ease, color 260ms ease;
}
.rslt-rematch:disabled { background: rgba(255, 255, 255, 0.07); color: rgba(255, 255, 255, 0.54); cursor: default; }
.rslt-rematch-box { width: 100%; min-height: 82px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px; }
.rslt-rematch-status { min-height: 19px; text-align: center; color: rgba(255,255,255,.6); font-size: 13px; line-height: 19px; }
.rslt-rematch-status.error { color: #E57373; }
.rslt-rematch-spin { width: 18px; height: 18px; display: none; }
.rslt-rematch.waiting .rslt-rematch-spin { display: inline-block; }
.rslt-view { background: none; border: 0; cursor: pointer; color: rgba(255, 255, 255, 0.6);
  display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; padding: 4px 8px; }
.rslt-leave {
  width: 250px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px; border-radius: var(--r-pill); border: 0; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 16px; font-weight: 700;
}
.rslt-peek { position: fixed; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  display: flex; justify-content: center; z-index: 40; }
.rslt-back { background: rgba(16, 26, 38, 0.9); color: #fff; border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--r-pill); padding: 12px 22px; font-size: 15px; font-weight: 700; cursor: pointer; }

/* Планка турнирного матча — копия _TournamentMatchBar: стадия слева, «Сетка» справа. */
.tourn-bar {
  flex: 0 0 auto; display: flex; align-items: stretch;
  box-sizing: border-box; min-height: calc(50px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #4D5563; background: #12161D;
}
.tourn-bar > * { flex: 1 1 0; display: flex; align-items: center; justify-content: center; gap: 8px; }
.tourn-stage { color: rgba(255, 255, 255, 0.6); font-weight: 800; font-size: 13px; letter-spacing: 1.5px;
  text-transform: uppercase; }
.tourn-open { border: 0; background: none; color: #fff; font-weight: 700; font-size: 14px; cursor: pointer;
  border-left: 1px solid rgba(255, 255, 255, 0.12); }

/* --- Загрузка ---------------------------------------------------------------------------------- */

.spinner {
  width: 26px; height: 26px;
  border: 3px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: var(--r-pill);
  animation: spin 0.8s linear infinite;
}
.spinner.lg { width: 44px; height: 44px; border-width: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-box { display: grid; place-items: center; gap: var(--sp-3); padding: var(--sp-6); color: var(--ink-dim); }

.empty {
  display: grid;
  place-items: center;
  gap: var(--sp-2);
  padding: var(--sp-6) var(--sp-4);
  color: var(--ink-faint);
  text-align: center;
}

/* --- Экран входа ------------------------------------------------------------------------------- */

.auth-screen {
  flex: 1 1 auto;
  display: grid;
  place-items: center;
  padding: var(--sp-4);
  overflow-y: auto;
}

.auth-card {
  width: min(100%, 400px);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  background: rgba(0, 0, 0, 0.26);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-3);
}

.auth-logo {
  text-align: center;
  margin-bottom: var(--sp-2);
}
/* Вход по коду комнаты — главное на странице входа: крупное поле на 4 символа и золотая кнопка. */
.auth-codebox { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: var(--r-md);
  background: rgba(232, 196, 106, 0.08); border: 1px solid rgba(232, 196, 106, 0.35); }
.auth-codelabel { text-align: center; font-size: 12px; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; color: var(--gold); }
.auth-code { text-align: center; font-family: var(--font-num); font-size: 30px; font-weight: 800; letter-spacing: 10px;
  padding: 12px 8px 12px 18px; text-transform: uppercase; }
.auth-code::placeholder { letter-spacing: 6px; font-weight: 500; opacity: 0.35; }
.auth-or { display: flex; align-items: center; gap: 10px; color: var(--ink-faint); font-size: 12px; }
.auth-or::before, .auth-or::after { content: ''; flex: 1 1 auto; height: 1px; background: var(--line); }
.auth-logo .title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #FFF, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.auth-tabs { display: flex; gap: var(--sp-1); background: var(--surface-sunken); padding: 4px; border-radius: var(--r-md); }
.auth-tabs button {
  flex: 1 1 0;
  border: 0;
  background: none;
  color: var(--ink-dim);
  font: inherit;
  font-weight: 600;
  padding: 9px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.auth-tabs button.active { background: var(--surface-strong); color: var(--ink); }

/* Вход через Google: кнопку рисует сам GIS в своём iframe, поэтому оформляем только место вокруг. */
.auth-google { display: flex; flex-direction: column; gap: var(--sp-3); }
.auth-google.busy { opacity: 0.5; pointer-events: none; }
/* GIS рисует кнопку в своём iframe и РАСШИРЯЕТ его за наши границы (10 px по бокам, 2 px сверху и
   снизу) — место под фокусную рамку, залитое белым фоном своей страницы. На тёмной карточке это
   выглядит как белая рамка вокруг кнопки, поэтому лишнее просто срезаем. */
.g-btn { display: flex; justify-content: center; align-items: center; height: 40px; overflow: hidden;
  border-radius: var(--r-sm); }
/* Кнопка Apple — по правилам Apple: чёрная плашка, белый знак и надпись, высота не меньше 44. */
.apple-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 44px; padding: 0 16px;
  background: #000; color: #fff; border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--r-sm); cursor: pointer;
  font-family: inherit; font-size: 15px; font-weight: 600;
}
.apple-btn:hover { background: #111; }
.apple-btn svg { display: block; margin-top: -2px; }

/* Разделитель «или по почте» — черта, надпись, черта. */
.auth-or { display: flex; align-items: center; gap: 10px; color: var(--ink-faint); font-size: 12px; }
.auth-or i { flex: 1 1 0; height: 1px; background: var(--line); }

.form-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  padding-left: 2px;
}

/* --- Игровое поле ------------------------------------------------------------------------------ */

.board-wrap {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  /* Единственный трек — РОВНО в ширину контейнера. Авто-трек грида растёт по max-content содержимого:
     ряд кнопок монополии, посчитанный в одну строку, распирал колонну до 500+px, и доска уезжала за
     правый край экрана. minmax(0, 100%) запрещает треку быть шире самого контейнера. */
  grid-template-columns: minmax(0, 100%);
}

/* Канвас всегда вписан в контейнер и никогда не растягивает страницу вбок. */
.board-wrap canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  touch-action: none;   /* доска сама обрабатывает касания — браузерная прокрутка тут только мешает */
}

.match-hud {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
  flex: 0 0 auto;
  /* Четыре места в ширину телефона не помещаются никаким сжатием — ряд прокручивается вбок,
     а тесный режим ниже делает пилюли компактнее, чтобы прокрутка нужна была как можно реже.
     Запас сверху — под шляпу: прокрутка по X делает обрезающей и ось Y, и без него шляпа срезается. */
  padding-top: 18px;
  overflow-x: auto;
  scrollbar-width: none;
}
.match-hud::-webkit-scrollbar { display: none; }
.match-hud > * { flex: 0 0 auto; }

/* Тесный режим — экран матча включает его при 3+ местах. */
.match-hud.crowded { gap: 6px; padding: var(--sp-2) var(--sp-3); }
.match-hud.crowded .seat { padding: 4px 8px; gap: 5px; }
.match-hud.crowded .seat .name { max-width: 7ch; font-size: 12px; }
.match-hud.crowded .seat .clock { font-size: 12px; }
.match-hud.crowded .avatar.sm { width: 26px; height: 26px; font-size: 11px; }

.seat {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 6px 10px;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid transparent;
  transition: border-color var(--dur) var(--ease-out), background var(--dur) var(--ease-out);
}
.seat.on-clock { border-color: var(--accent); background: rgba(83, 166, 255, 0.14); }
.seat .name { font-size: 13px; font-weight: 600; max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat .clock { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--ink-dim); }
.seat.low .clock { color: var(--danger); }

.action-bar.no-safe { padding-bottom: var(--sp-3); }
.action-bar {
  display: flex;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  padding-bottom: calc(var(--sp-3) + env(safe-area-inset-bottom));
  flex: 0 0 auto;
  justify-content: center;
  flex-wrap: wrap;
}

/* Доска — СВОЙ контекст наложения: у дурака карты живут с z-index до сотен, и без изоляции они
   всплывали над кнопками рамки и даже над панелью результата. Хром рамки — поверх доски всегда. */
.board-wrap { position: relative; z-index: 0; }
.topbar, .match-hud, .action-bar, .tourn-bar { position: relative; z-index: 2; }

/* Кнопки в топ-баре матча: сдаться и предложить ничью — общие для всех игр. */
.top-act { background: none; border: 0; cursor: pointer; padding: 8px; display: inline-flex; }
.top-act.rs { color: #E57373; }

/* Банк матча — единственное место, где он показан: планка в самом низу, копия _MatchBankBar
   мобильного — шов сверху, нейтральный тёмный тон, 50px + сейф-зона. */
.pot-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  /* Сейф-зона входит В ВЫСОТУ, а не в паддинг: иначе в standalone-режиме текст прижат к верху полосы
     и выглядит смещённым. Центруем по всей видимой полосе. */
  box-sizing: border-box;
  min-height: calc(50px + env(safe-area-inset-bottom, 0px));
  padding: 0 12px;
  border-top: 1px solid #4D5563;
  background: #12161D;
  font-size: 14px;
  font-weight: 700;
}
.pot-bar .dim { color: rgba(255, 255, 255, 0.70); }
.pot-bar .coins { font-size: 16px; font-weight: 800; }

/* Цветная метка фишки игрока в пилюле места (монополия). */
.seat-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: var(--r-pill);
  margin-right: 5px;
  vertical-align: 0.05em;
}

/* --- Мелочи ------------------------------------------------------------------------------------ */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  background: var(--surface-strong);
  font-size: 12px;
  font-weight: 600;
}
.chip.gold { background: rgba(232, 196, 106, 0.18); color: var(--gold); }
.chip.accent { background: rgba(83, 166, 255, 0.18); color: var(--accent); }

.divider { height: 1px; background: var(--line); margin: var(--sp-2) 0; }

/* FAB «Создать игру» — как в мобильном лобби: плавает над списком справа внизу. */
.fab {
  position: absolute;
  right: var(--sp-4);
  bottom: var(--sp-4);
  z-index: 5;
  border-radius: var(--r-lg);
  padding: 14px 20px;
  box-shadow: var(--shadow-3);
}

/* Точка «есть что забрать» на иконке магазина в топ-баре. */
.topbar .dot-btn { position: relative; }
.topbar .dot-btn .dot {
  position: absolute;
  top: 2px; right: 2px;
  width: 9px; height: 9px;
  border-radius: var(--r-pill);
  background: #FF7A88;
  box-shadow: 0 0 0 2px var(--bg);
}

/* --- Полоса загрузки маршрута: пока едет модуль следующего экрана, прежний остаётся на месте ------ */
.route-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 70; pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 40% 100%; background-repeat: no-repeat;
  opacity: 0; transition: opacity var(--dur-fast) var(--ease-out);
}
.route-progress.on { opacity: 1; animation: route-progress 1s linear infinite; }
@keyframes route-progress { from { background-position: -40% 0; } to { background-position: 140% 0; } }
