/* ============================================================
   Сборник игр — общее оформление (зелёное сукно, крупный текст)
   Базовый шрифт 18–22px, кнопки min-height 52px,
   карты --card-w (7 колонок Косынки) / --card-w10 (10 колонок Паука).
   ============================================================ */

:root {
  /* Сукно */
  --felt-dark: #073d23;
  --felt-mid: #0a4d2b;
  --felt-light: #0e5c33;

  /* Карты: 7 колонок (Косынка) и 10 колонок (Паук) */
  --card-w: min(calc((100vw - 56px) / 7), 78px);
  --card-w10: min(calc((100vw - 46px) / 10), 78px);
  --card-h: calc(var(--card-w) * 1.4);
  --card-h10: calc(var(--card-w10) * 1.4);
  --card-radius: max(6px, calc(var(--card-w) * 0.09));
  --card-rank-fs: clamp(14px, calc(var(--card-w) * 0.34), 26px);
  --card-rank-fs10: clamp(12px, calc(var(--card-w10) * 0.36), 22px);

  /* Цвета элементов */
  --ink: #1c1c1c;
  --red: #b3261e;
  --cream: #f4f1e6;
  --card-bg: #fdfaf1;
  --card-line: #a49c84;
  --gold: #ffd75e;
  --panel: rgba(4, 32, 18, 0.55);
  --panel-line: rgba(255, 255, 255, 0.28);
  --btn-ink: #14241b;

  --topbar-h: 60px;
  --max-w: 640px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  font-size: 19px; /* базовый 18–22px */
  line-height: 1.4;
  color: var(--cream);
  background-color: var(--felt-mid);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.07'/%3E%3C/svg%3E"),
    radial-gradient(130% 90% at 50% 10%, rgba(47, 140, 84, 0.55) 0%,
      rgba(20, 90, 52, 0.35) 45%, rgba(6, 36, 21, 0) 80%),
    radial-gradient(160% 130% at 50% 118%, rgba(3, 25, 14, 0.65) 0%,
      rgba(3, 25, 14, 0) 55%),
    linear-gradient(180deg, var(--felt-light) 0%, var(--felt-mid) 55%,
      var(--felt-dark) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

h1, h2, h3 { line-height: 1.2; margin: 0; }

button { font-family: inherit; }

/* ---------- Шапка (меню и игры) ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--topbar-h);
  padding: 8px 12px;
  padding-top: calc(8px + env(safe-area-inset-top));
  background: linear-gradient(180deg, rgba(4, 38, 21, 0.94) 0%,
    rgba(4, 38, 21, 0.78) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.topbar-title {
  flex: 1;
  min-width: 0;
  font-size: 23px;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.45);
}

/* ---------- Кнопки: крупные, контрастные ---------- */

/* Не даём элементам 52px проваливаться под липкую шапку (sticky topbar) */
.spacer {
  display: block;
  width: 100%;
  height: calc(var(--topbar-h) + 10px);
}

.btn {
  min-height: 52px;
  min-width: 52px;
  padding: 10px 18px;
  font-size: 19px;
  font-weight: 700;
  color: var(--btn-ink);
  background: linear-gradient(180deg, #fdf9ec 0%, #e9e0c7 100%);
  border: 2px solid #123f27;
  border-radius: 12px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  cursor: pointer;
  line-height: 1.2;
}

.btn:active {
  transform: translateY(1px);
  box-shadow: 0 0 0 rgba(0, 0, 0, 0);
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

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

.btn-primary {
  color: #fff;
  background: linear-gradient(180deg, #2f8f57 0%, #1d6b41 100%);
  border-color: #0d3b24;
}

.btn-danger {
  color: #fff;
  background: linear-gradient(180deg, #d9534a 0%, #b0352d 100%);
  border-color: #6e1f1a;
}

.btn-ghost {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.6);
}

.btn-icon {
  width: 52px;
  min-width: 52px;
  padding: 10px 0;
  font-size: 24px;
  text-align: center;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  padding: 12px;
}

/* ---------- Экран меню ---------- */

.menu {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 14px 14px calc(28px + env(safe-area-inset-bottom));
}

.menu-title {
  font-size: 36px;
  font-weight: 800;
  text-align: center;
  margin: 8px 0 2px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}

.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 148px;
  padding: 20px 10px;
  color: var(--cream);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.16) 0%,
    rgba(255, 255, 255, 0.05) 100%);
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 16px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  text-align: center;
}

.game-card:active {
  transform: translateY(1px);
}

.game-card:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.game-icon {
  font-size: 54px;
  line-height: 1;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.45));
}

.game-name {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
}

.game-sub {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.85);
}

.game-card.soon {
  opacity: 0.72;
  cursor: default;
  background: rgba(255, 255, 255, 0.06);
  border-style: dashed;
}

.soon-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 12px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #3a2a00;
  background: var(--gold);
  border-radius: 999px;
}

/* ---------- Стол игры ---------- */

.game-screen {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 10px 8px calc(18px + env(safe-area-inset-bottom));
}

.table-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 4px 14px;
}

.stock,
.foundations,
.towers,
.tower,
.deck {
  min-height: var(--card-h);
}

.stock,
.foundations {
  display: flex;
  gap: 5px;
  flex-wrap: nowrap;
}

.foundations {
  gap: 4px;
}

.foundations .card,
.stock .card,
.deck .card {
  width: var(--card-w);
  height: var(--card-h);
}

.towers {
  display: grid;
  grid-template-columns: repeat(7, var(--card-w));
  gap: 6px;
  justify-content: center;
}

.towers.towers-10 {
  grid-template-columns: repeat(10, var(--card-w10));
  gap: 3px;
}

.tower {
  position: relative;
  min-height: var(--card-h);
  border-radius: var(--card-radius);
}

.towers.towers-10 .tower {
  min-height: var(--card-h10);
}

.tower .card {
  position: absolute;
  left: 0;
  top: 0;
}

.tower.empty::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 3px dashed rgba(255, 255, 255, 0.35);
  border-radius: var(--card-radius);
}

/* ---------- Карты ---------- */

.card {
  position: relative;
  width: var(--card-w);
  height: var(--card-h);
  border-radius: var(--card-radius);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.card-face {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--card-bg);
  border: 1px solid var(--card-line);
  border-radius: var(--card-radius);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.38);
  color: var(--ink);
  overflow: hidden;
}

.card.red .card-face { color: var(--red); }
.card.black .card-face { color: var(--ink); }

.card .corner {
  position: absolute;
  top: 4%;
  left: 7%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  line-height: 1;
}

.card .corner-tr {
  top: auto;
  left: auto;
  right: 7%;
  bottom: 4%;
  transform: rotate(180deg);
}

.card .card-rank {
  font-size: var(--card-rank-fs);
  font-weight: 800;
}

.card .card-suit {
  font-size: calc(var(--card-rank-fs) * 0.92);
  line-height: 1;
}

.card .card-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--card-w) * 0.5);
  opacity: 0.9;
}

.towers.towers-10 .card {
  width: var(--card-w10);
  height: var(--card-h10);
}

.towers.towers-10 .card .card-rank {
  font-size: var(--card-rank-fs10);
}

.towers.towers-10 .card .card-suit {
  font-size: calc(var(--card-rank-fs10) * 0.92);
}

/* Рубашка. Прозрачность баг: раньше весь фон был одной shorthand-записью
   `background:` — если повторяющийся градиент не отрисовался (старые
   Chromium на Android), элемент оставался полностью прозрачным и под
   рубашкой видны карты. Поэтому база — отдельное НЕПРОЗРАЧНОЕ
   background-color, а узор — background-image (не влияет на базу). */
.card-back {
  display: block;
  width: 100%;
  height: 100%;
  border: 2px solid #1c5a36;
  border-radius: var(--card-radius);
  background-color: #12402a;
  background-image:
    repeating-linear-gradient(45deg,
      rgba(255, 255, 255, 0.10) 0, rgba(255, 255, 255, 0.10) 3px,
      transparent 3px, transparent 6px),
    linear-gradient(160deg, #14502f 0%, #0e3a22 100%);
  box-shadow:
    inset 0 0 0 3px rgba(255, 255, 255, 0.22),
    0 2px 5px rgba(0, 0, 0, 0.38);
}

/* Состояния карт */
.card.selected .card-face {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(255, 215, 94, 0.55),
    0 6px 14px rgba(0, 0, 0, 0.5);
}

.card.hint .card-face {
  animation: hint-pulse 0.9s ease-in-out infinite;
}

.card.dragging {
  z-index: 1000;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.55);
}

@keyframes hint-pulse {
  0%, 100% { box-shadow: 0 2px 5px rgba(0, 0, 0, 0.38); }
  50% { box-shadow: 0 0 0 4px rgba(255, 215, 94, 0.85), 0 2px 5px rgba(0, 0, 0, 0.38); }
}

/* ---------- HUD ---------- */

.hud {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 8px;
}

.hud-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 14px;
  font-size: 17px;
  color: #fff;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 10px;
}

.hud-item b {
  font-size: 21px;
  font-weight: 800;
}

/* ---------- Тосты и служебное ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: min(90vw, 440px);
  padding: 13px 22px;
  font-size: 18px;
  color: #fff;
  text-align: center;
  background: #10281c;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  z-index: 100;
  animation: toast-in 0.18s ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.loading {
  padding: 48px 20px;
  font-size: 19px;
  text-align: center;
  color: rgba(255, 255, 255, 0.9);
}

/* ---------- Адаптив ---------- */

/* Портретный смартфон ~360–400px (Galaxy A50): подгонка зазоров под 7/10 колонок */
@media (max-width: 420px) {
  body { font-size: 18px; }
  :root {
    --card-w: min(calc((100vw - 52px) / 7), 78px);
    --card-w10: min(calc((100vw - 42px) / 10), 78px);
    --topbar-h: 56px;
  }
  .menu-title { font-size: 32px; }
  .game-icon { font-size: 48px; }
  .towers { gap: 4px; }
  .foundations, .stock { gap: 3px; }
}

/* Планшеты и шире: фиксированные размеры карт, центрирование */
@media (min-width: 700px) {
  :root {
    --card-w: 78px;
    --card-w10: 66px;
  }
  body { font-size: 20px; }
  .menu { max-width: 720px; }
  .game-screen { max-width: 700px; }
}

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

/* ============================================================
   UI-слой (js/core/ui.js): HUD, панель действий, состояние карт,
   диалоги, экран победы, кучи (столбы) пасьянса.
   ============================================================ */

/* ---------- HUD (повторные объявления усиливают базовые стили выше) ---------- */

.hud {
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
}

.hud-item {
  flex-direction: row;
  align-items: baseline;
  gap: 8px;
}

.hud-label {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.72);
}

.hud-value {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
}

/* ---------- Панель действий ----------
   Над статистикой (HUD): иконки-кнопки (🔄 новая игра, 💡 подсказка,
   ↩ отмена, 🔊 звук). Кнопки широкие (64px) — крупные пальцем. */

.action-bar {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
}

.action-bar .btn {
  flex: 0 1 auto;
  width: 64px;
  min-width: 64px;
  min-height: 64px;
  padding: 0;
  font-size: 30px;
  line-height: 1;
}

/* Адаптив: на очень узких экранах кнопки чуть компактнее, но не меньше 56px. */
@media (max-width: 360px) {
  .action-bar .btn {
    width: 56px;
    min-width: 56px;
    min-height: 56px;
    font-size: 26px;
  }
}

/* Контраст к зелёному сукну: янтарно-красный, белый текст */
.btn-primary {
  color: #fff;
  background: linear-gradient(180deg, #d9772b 0%, #a03d17 100%);
  border-color: #5f2410;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

/* ---------- Состояния карт: выбрана / подсказка сброса ---------- */

.card.selected {
  outline: 3px solid #ffd54a;
  box-shadow: 0 0 10px rgba(255, 213, 74, 0.7);
  z-index: 5;
}

.card.drop-hint {
  outline: 3px dashed #fff;
  outline-offset: 2px;
}

/* Подсветка ЦЕЛЕВОЙ кучи (highlightTargets из drag.js кладёт класс
   на .pile, не на .card) — заметная рамка вокруг места сброса. */
.pile.drop-hint {
  outline: 3px dashed #ffd54a;
  outline-offset: 2px;
  background: rgba(255, 213, 74, 0.10);
}

/* ---------- Лицо карты (makeCardEl): лицо на самом .card.face-up,
   уголки, центр, цвета мастей ---------- */

.card.face-up {
  /* База — отдельное НЕПРОЗРАЧНОЕ background-color (не shorthand background:):
     на старом Chromium (Samsung A50) shorthand с градиентами отрисовывался
     сбоем и лицо карты становилось прозрачным (см. .card.face-back). */
  background-color: var(--card-bg);
  border: 1px solid var(--card-line);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.38);
  color: var(--ink);
  overflow: hidden;
}

.card.face-up.red {
  color: var(--red);
}

.card.face-up.black {
  color: var(--ink);
}

.card .card-corner {
  position: absolute;
  top: 4%;
  left: 7%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  line-height: 1;
  /* z-index НЕ даём: позиционированный элемент с z-index > 0 рисуется
     выше ВСЕХ не-позиционированных соседей — уголок (обычно нижний-правый)
     карты, лежащей ВНИЗУ веера столба, «просвечивал» поверх верхней карты
     (все .pile-card в куче — z-index auto, порядок решает DOM). */
}

/* Второй уголок — НИЖНИЙ-ПРАВЫЙ (как у стандартной карты: верхний-левый +
   нижний-правый, перевёрнут на 180°). */
.card .card-corner.bottom-right {
  top: auto;
  bottom: 4%;
  left: auto;
  right: 7%;
  transform: rotate(180deg);
}

/* Рубашка (face-back): как .card-back — непрозрачная база + узор.
   База отдельно (background-color), чтобы рубашка не стала прозрачной
   при сбое отрисовки градиента. */
.card.face-back {
  border: 2px solid #1c5a36;
  background-color: #12402a;
  background-image:
    repeating-linear-gradient(45deg,
      rgba(255, 255, 255, 0.10) 0, rgba(255, 255, 255, 0.10) 3px,
      transparent 3px, transparent 6px),
    linear-gradient(160deg, #14502f 0%, #0e3a22 100%);
  box-shadow:
    inset 0 0 0 3px rgba(255, 255, 255, 0.22),
    0 2px 5px rgba(0, 0, 0, 0.38);
}

/* ---------- Диалоги (модальные окна) ---------- */

body.modal-open {
  overflow: hidden; /* блокируем прокрутку под модальным окном */
}

.dialog-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.55);
  z-index: 100;
}

.dialog {
  width: 100%;
  max-width: 90vw;
  padding: 24px;
  font-size: 19px;
  color: #1c1c1c;
  background: #fdfaf1;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  text-align: left;
}

.dialog-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 10px;
}

.dialog-text {
  line-height: 1.5;
}

.dialog-buttons {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.dialog-buttons .btn {
  flex: 1;
}

.dialog .btn {
  min-height: 56px;
  font-size: 19px;
}

/* «Отмена» в диалоге: окно светлое (#fdfaf1), базовый .btn-ghost
   с белым текстом на нём не читается — делаем тёмный шрифт. */
.dialog .btn-ghost {
  color: #1c1c1c;
  background-color: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.35);
}

/* ---------- Экран победы ---------- */

.win-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 28px 16px;
  text-align: center;
}

.win-title {
  font-size: clamp(42px, 11vw, 54px);
  font-weight: 800;
  color: #ffd54a;
  text-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
}

.win-subtitle {
  font-size: 20px;
  color: rgba(255, 255, 255, 0.85);
}

.win-stats {
  font-size: 20px;
  line-height: 1.8;
  color: #fff;
}

.win-btn {
  width: 100%;
  max-width: 340px;
  min-height: 56px;
  font-size: 19px;
}

/* ---------- Кучи (столбы) пасьянса ---------- */

.pile {
  position: relative;
  min-height: var(--card-h);
  border-radius: var(--card-radius);
}

.pile-card {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--card-w);
  height: var(--card-h);
}

/* 7 колонок (Косынка): карты --card-w × --card-h */
.pile-7 .pile-card {
  width: var(--card-w);
  height: var(--card-h);
}

.pile-7 .card {
  width: var(--card-w);
  height: var(--card-h);
}

/* 10 колонок (Паук): карты --card-w10 × --card-h10 */
.pile-10 .pile-card {
  width: var(--card-w10);
  height: var(--card-h10);
}

.pile-10 .card {
  width: var(--card-w10);
  height: var(--card-h10);
}

.pile-10 .card .card-rank {
  font-size: var(--card-rank-fs10);
}

.pile-10 .card .card-suit {
  font-size: calc(var(--card-rank-fs10) * 0.92);
}

/* Плавное «посадочное» смещение обёртки карты (веер сдвигается после
   хода — top меняется). */
.pile-card {
  transition: top 0.18s ease-out;
}

/* Переворот карты: появляется из «кромки» (полуповорот вокруг Y).
   Класс .card-flip навешивают игры на свежеоткрытые карты (0.3 c). */
.card-flip {
  animation: card-flip 0.3s ease-in-out;
}

@keyframes card-flip {
  from { transform: rotateY(90deg); }
  to { transform: rotateY(0deg); }
}

/* Клон «летающей» карты (animateCardMove): перелёт к цели + fade-out.
   transform и opacity меняются из JS — здесь только кривая тайминга. */
.card-fly {
  transition: transform 0.26s cubic-bezier(0.22, 0.61, 0.36, 1),
    opacity 0.26s ease-out;
}

/* Разметка пустого фундамента (Косынка): знак масти — «куда собирать». */
.foundation-mark {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--card-w) * 0.5);
  color: rgba(255, 255, 255, 0.35);
  pointer-events: none;
}

.foundation-mark.red {
  color: rgba(255, 110, 100, 0.5);
}

/* ---------- Статистика в меню ---------- */

.menu-stats {
  margin-top: 18px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  padding: 14px 16px;
}

.menu-stats-title {
  margin: 0 0 10px;
  font-size: 22px;
  color: var(--gold);
  text-align: center;
}

.game-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.game-stats:last-child {
  border-bottom: none;
}

.game-stats-name {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}

.game-stats-info {
  text-align: right;
}

.game-stats-wins {
  font-size: 19px;
  color: #fff;
}

.game-stats-best {
  font-size: 17px;
  color: rgba(255, 255, 255, 0.8);
}

.game-stats-empty {
  font-size: 17px;
  color: rgba(255, 255, 255, 0.65);
}

/* ============================================================
   Косынка (js/games/klondike.js): раскладка поля.
   HUD и action-bar — из ui.js (.hud, .action-bar выше).
   ============================================================ */

.game-layout {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Верхний ряд: слева — рубашка и сброс, справа — 4 фундамента. */
.klondike-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

/* Левая группа: рубашка (stock) и сброс (waste) рядом. */
.klondike-deal {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

.klondike-top .pile.stock {
  width: var(--card-w);
  flex: 0 0 auto;
  cursor: pointer;
}

.klondike-top .pile.waste {
  width: var(--card-w);
  flex: 0 0 auto;
}

/* 4 фундамента в одном ряду. Карты и знак масти в куче абсолютные
   (из потока) — без явной ширины куча схлопывается в 0 и контура не видно. */
.klondike-top .pile.foundation {
  width: var(--card-w);
  flex: 0 0 auto;
}

/* 4 фундамента в одном ряду. */
.klondike-foundations {
  display: flex;
  gap: 6px;
}

/* 7 столбов. */
.klondike-table {
  display: grid;
  grid-template-columns: repeat(7, var(--card-w));
  gap: 6px;
  justify-content: center;
}

/* Пустые места: пунктир (как .tower.empty).
   :empty срабатывает только у куч без карт — конфликт слоёв нет. */
.klondike-top .pile:empty::after,
.klondike-table .pile:empty::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 3px dashed rgba(255, 255, 255, 0.35);
  border-radius: var(--card-radius);
  pointer-events: none;
}

/* Пустой фундамент: тот же пунктирный контур. :empty не сработает
   (внутри знак масти .foundation-mark) — класс .empty навешивает renderState. */
.klondike-top .pile.foundation.empty::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 3px dashed rgba(255, 255, 255, 0.35);
  border-radius: var(--card-radius);
  pointer-events: none;
}

/* Адаптив: зазоры под узкий экран. */
@media (max-width: 420px) {
  .klondike-top { gap: 6px; }
  .klondike-foundations { gap: 4px; }
  .klondike-table { gap: 4px; }
}

/* ---------- Выбор режима (сплошной оверлей) ---------- */

.klondike-mode-select {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(3, 25, 14, 0.72);
  backdrop-filter: blur(3px);
}

.klondike-mode-select[hidden] {
  display: none;
}

.klondike-mode-panel {
  width: 100%;
  max-width: 340px;
  background: rgba(4, 32, 18, 0.92);
  border: 1px solid var(--panel-line);
  border-radius: 18px;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}

.klondike-mode-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--gold);
}

.klondike-mode-sub {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.75);
}

.klondike-mode-btn {
  width: 100%;
  min-height: 52px;
}

/* ============================================================
   Паук (js/games/spider.js): раскладка поля.
   HUD и action-bar — из ui.js (.hud, .action-bar выше).
   ============================================================ */

.spider-layout {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Верхний ряд: рубашка слева, 8 мест готовых последовательностей справа. */
.spider-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.spider-top .pile.stock {
  width: var(--card-w10);
  flex: 0 0 auto;
  cursor: pointer;
}

/* 8 мест для готовых последовательностей K→A в одном ряду. */
.spider-runs {
  display: flex;
  gap: 4px;
}

.spider-runs .pile.run {
  width: var(--card-w10);
  flex: 0 0 auto;
}

/* Пустые места: пунктир (как .klondike-top .pile:empty::after).
   :empty срабатывает только у куч без карт — конфликт слоёв нет. */
.spider-runs .pile.run:empty::after,
.spider-top .pile:empty::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 3px dashed rgba(255, 255, 255, 0.35);
  border-radius: var(--card-radius);
  pointer-events: none;
}

/* Стол: 10 столбов. */
.spider-table {
  display: grid;
  grid-template-columns: repeat(10, var(--card-w10));
  gap: 6px;
  justify-content: center;
}

/* ---------- Выбор числа мастей (сплошной оверлей) ---------- */

.spider-suit-select {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(3, 25, 14, 0.72);
  backdrop-filter: blur(3px);
}

.spider-suit-select[hidden] {
  display: none;
}

.spider-suit-panel {
  width: 100%;
  max-width: 340px;
  background: rgba(4, 32, 18, 0.92);
  border: 1px solid var(--panel-line);
  border-radius: 18px;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}

.spider-suit-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--gold);
}

.spider-suit-sub {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.75);
}

.spider-suit-btn {
  width: 100%;
  min-height: 52px;
}

/* Адаптив: зазоры под узкий экран. */
@media (max-width: 420px) {
  .spider-top { gap: 6px; }
  .spider-runs { gap: 3px; }
  .spider-table { gap: 3px; }
}

/* ============================================================
   Вордли (ежедневный): сетка 6×5, экранная клавиатура.
   Цвета клеток — плоские (background-color), без градиентов
   и var() в shorthand background: — старый Chromium (A50).
   ============================================================ */

:root {
  /* Клетка: до 64px на широком экране, ~52px на узком. */
  --wordle-cell: clamp(46px, calc((100vw - 56px) / 5), 64px);
  --wordle-gap: clamp(4px, 1.2vw, 7px);
  --wordle-line: rgba(255, 255, 255, 0.32);
  --wordle-line-strong: rgba(255, 255, 255, 0.75);
  --wordle-green: #4c9a52;
  --wordle-yellow: #c9a63a;
  --wordle-gray: #3b4145;
}

.wordle-grid {
  display: flex;
  justify-content: center;
  margin: 18px 0 16px;
}

.wordle-board {
  display: flex;
  flex-direction: column;
  gap: var(--wordle-gap);
}

.wordle-row {
  display: flex;
  gap: var(--wordle-gap);
}

.wordle-cell {
  width: var(--wordle-cell);
  height: var(--wordle-cell);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--wordle-line);
  border-radius: 8px;
  background-color: rgba(255, 255, 255, 0.05);
}

.wordle-letter {
  font-size: clamp(22px, calc(var(--wordle-cell) * 0.46), 34px);
  font-weight: 800;
  color: #fff;
  line-height: 1;
}

/* Введённая буква (до проверки). */
.wordle-cell.filled {
  border-color: var(--wordle-line-strong);
  background-color: rgba(255, 255, 255, 0.12);
}

.wordle-cell.green {
  border-color: var(--wordle-green);
  background-color: var(--wordle-green);
}

.wordle-cell.yellow {
  border-color: var(--wordle-yellow);
  background-color: var(--wordle-yellow);
}

.wordle-cell.yellow .wordle-letter {
  color: #241d05;
}

.wordle-cell.gray {
  border-color: var(--wordle-gray);
  background-color: var(--wordle-gray);
}

/* Переворот буквы (клетка) при проверке строки. */
.wordle-cell.flip {
  animation: wordle-flip 0.4s ease-in-out;
}

@keyframes wordle-flip {
  0% { transform: rotateX(0deg); }
  50% { transform: rotateX(90deg); }
  100% { transform: rotateX(0deg); }
}

/* Тряска ряда: неверная длина / несуществующее слово. */
.wordle-row.shake {
  animation: wordle-shake 0.4s ease-in-out;
}

@keyframes wordle-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

/* ---------- Экранная клавиатура ---------- */

.wordle-keyboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 560px;
  margin: 0 auto;
  padding: 4px 8px;
}

.wordle-key-row {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.wordle-key {
  flex: 1 1 0;
  max-width: 40px;
  min-height: 56px;
  border: 2px solid var(--panel-line);
  border-radius: 8px;
  background-color: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.wordle-key:active {
  transform: translateY(1px);
}

/* Зелёная кнопка «Ок» (галочка) — слева в третьем ряду. */
.wordle-key.ok {
  background-color: var(--wordle-green);
  border-color: var(--wordle-green);
  color: #fff;
  font-size: 22px;
}

/* Цвета клавиш по проверенным буквам (приоритет green > yellow > gray). */
.wordle-key.green {
  background-color: var(--wordle-green);
  border-color: var(--wordle-green);
}

.wordle-key.yellow {
  background-color: var(--wordle-yellow);
  border-color: var(--wordle-yellow);
  color: #241d05;
}

.wordle-key.gray {
  background-color: var(--wordle-gray);
  border-color: var(--wordle-gray);
  opacity: 0.65;
}

/* ---------- Окно конца дня (всплывает поверх игры) ---------- */

.wordle-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background-color: rgba(0, 0, 0, 0.55);
  z-index: 110;
  animation: wordle-overlay-in 160ms ease-out;
}

@keyframes wordle-overlay-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.wordle-overlay .win-screen {
  width: 100%;
  max-width: 420px;
  background-color: #0c3f24; /* тёмная «суконная» панель, плоский цвет */
  border: 2px solid var(--panel-line);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
}

/* ============================================================
   Поиск слов (Words of Wonders / wordfinder)
   Клетчатая сетка кроссворда + круговое кольцо букв снизу.
   ============================================================ */

:root {
  --wf-line: rgba(255, 255, 255, 0.32);
  --wf-line-strong: rgba(255, 255, 255, 0.8);
  --wf-cell-bg: rgba(255, 255, 255, 0.06);
  --wf-typed-bg: rgba(255, 255, 255, 0.16);
  --wf-solved-bg: #4c9a52; /* решено — «вордли»-зелёный */
  --wf-solved-ink: #0d2412;
  --wf-tile-bg: rgba(255, 255, 255, 0.14);
  --wf-tile-active-bg: #ffd75e; /* активная плитка — золото */
  --wf-tile-active-ink: #241d05;
}

/* ---------- Сетка кроссворда ---------- */

.wf-grid {
  display: grid;
  gap: 5px;
  justify-content: center;
  margin: 18px auto 8px;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.wf-cell {
  width: var(--wf-cell);
  height: var(--wf-cell);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--wf-line);
  border-radius: 7px;
  background-color: var(--wf-cell-bg);
  touch-action: none;
}

/* Введённая буква, но слово ещё не решено. */
.wf-cell.typed {
  border-color: var(--wf-line-strong);
  background-color: var(--wf-typed-bg);
}

/* Клетка из решённого слова — зелёная. */
.wf-cell.solved {
  border-color: var(--wf-solved-bg);
  background-color: var(--wf-solved-bg);
}

.wf-letter {
  font-size: calc(var(--wf-cell) * 0.5);
  font-weight: 800;
  line-height: 1;
  color: #fff;
}

.wf-cell.solved .wf-letter {
  color: var(--wf-solved-ink);
}

/* Влетание буквы: короткий «пружинный» масштаб. */
.wf-letter.pop {
  animation: wf-pop 0.22s ease-out;
}

@keyframes wf-pop {
  0% { transform: scale(0.3); }
  60% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* ---------- Кольцо букв (обособленная зона ввода) ---------- */

.wf-ring {
  --wf-tile: clamp(44px, 13vw, 54px);
  /* Радиус окружности ЦЕНТРОВ плиток: 1.95×tile — плитки ПОЛНОСТЬЮ
     внутри окружности (диск 5.5×tile, самый дальний угол плитки
     в 1.95+0.71=2.66×tile < радиуса 2.75×tile). */
  --wf-ring-r: calc(var(--wf-tile) * 1.95);
  display: flex;
  justify-content: center;
  margin: 16px auto 28px;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Круг-таблица: плитки по краю, набранный штрих в центре, линии штриха
   (svg) под плитками. Отдельная область — кроссворд выше не касается
   пальцем. */
.wf-disc {
  position: relative;
  width: calc(var(--wf-tile) * 5.5);
  height: calc(var(--wf-tile) * 5.5);
  border: 2px dashed var(--panel-line);
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.035);
}

.wf-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Линия штриха — ломаная от буквы к букве (одна <path>). */
.wf-line {
  fill: none;
  stroke: var(--gold);
  stroke-opacity: 0.55;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Кончик линии у курсора — яркая точка (видно, куда ведём). */
.wf-line-cur {
  fill: var(--gold);
  fill-opacity: 0.95;
}

/* Набранный штрих в центре круга. */
.wf-stroke {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: 70%;
  text-align: center;
  font-weight: 800;
  letter-spacing: 2px;
  font-size: clamp(18px, 5vw, 26px);
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.2;
  word-break: break-all;
  pointer-events: none;
}

.wf-stroke-ch {
  color: rgba(255, 255, 255, 0.65);
}

/* Последняя буква штриха — золотом (пишется сейчас). */
.wf-stroke-ch.last {
  color: var(--gold);
}

/* Буква «улетает» в клетку: пока летит .wf-fly, буква в клетке скрыта
   (.wf-flying); класс снимает обработчик прилёта. */
.wf-letter.wf-flying {
  opacity: 0;
}

/* «Полёт» буквы из центра круга в клетку кроссворда (wordfinder). */
.wf-fly {
  position: fixed;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: var(--gold);
  pointer-events: none;
  transition: left 220ms cubic-bezier(0.2, 0.7, 0.3, 1),
    top 220ms cubic-bezier(0.2, 0.7, 0.3, 1), opacity 180ms ease;
}

.wf-tile {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--wf-tile);
  height: var(--wf-tile);
  margin-left: calc(var(--wf-tile) / -2);
  margin-top: calc(var(--wf-tile) / -2);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--panel-line);
  border-radius: 12px;
  background-color: var(--wf-tile-bg);
  color: #fff;
  font-size: calc(var(--wf-tile) * 0.44);
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: background-color 120ms ease, box-shadow 120ms ease,
    transform 120ms ease;
}

/* Плитка задействована в текущем штрихе. */
.wf-tile.picked {
  background-color: var(--wf-tile-active-bg);
  border-color: var(--wf-tile-active-bg);
  color: var(--wf-tile-active-ink);
  box-shadow: 0 0 0 3px rgba(255, 215, 94, 0.35);
}

.wf-tile:active {
  box-shadow: 0 0 0 3px rgba(255, 215, 94, 0.35);
}

/* ---------- Оверлей «Победа» ---------- */

.wf-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background-color: rgba(0, 0, 0, 0.55);
  z-index: 110;
  animation: wf-overlay-in 160ms ease-out;
}

@keyframes wf-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.wf-win {
  width: 100%;
  max-width: 420px;
  background-color: #0c3f24; /* тёмная «суконная» панель, плоский цвет */
  border: 2px solid var(--panel-line);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  padding: 26px 22px;
  text-align: center;
  animation: wf-win-in 220ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

@keyframes wf-win-in {
  from { transform: translateY(14px) scale(0.96); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.wf-win-title {
  font-size: 34px;
  font-weight: 800;
  margin: 0 0 6px;
  color: var(--gold);
}

.wf-win-sub {
  font-size: 18px;
  margin: 0 0 20px;
  color: var(--cream);
}

.wf-win-btn {
  width: 100%;
  margin-top: 10px;
}

/* ============================================================
   Рейтинг игроков (фаза 4, js/main.js):
   - диалог ввода ника при первом входе (.login-*);
   - блок «Моё табло» в меню (.my-board*);
   - ник в шапке меню (.topbar-login);
   - экран рейтинга #/rating (.rating-*).
   Стили гармоничны с тёмным сукном: текст --cream, панели
   --panel/--panel-line, акценты --gold. Мобильные: max-width 640px.
   ============================================================ */

/* ---------- Диалог ввода ника (блокирующий, только кнопки) ---------- */

/* Оверлей: как .dialog-overlay, но з-index выше тостов. Клик по фону
   и Escape НЕ закрывают (нет обработчиков в JS) — только кнопки. */
.login-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.62);
  z-index: 120;
}

/* Светлое окно как у .dialog (#fdfaf1, тёмный текст). */
.login-dialog {
  width: 100%;
  max-width: 420px;
  padding: 26px 22px;
  font-size: 19px;
  color: #1c1c1c;
  background: #fdfaf1;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  text-align: center;
}

.login-dialog .dialog-title {
  font-size: 23px;
}

.login-dialog .dialog-text {
  font-size: 17px;
  color: rgba(28, 28, 28, 0.75);
}

/* Поле ника: крупное, по центру. */
.login-input {
  width: 100%;
  min-height: 56px;
  margin-top: 16px;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.03em;
  color: #1c1c1c;
  background: #fff;
  border: 2px solid #123f27;
  border-radius: 12px;
  outline: none;
}

.login-input:focus {
  box-shadow: 0 0 0 3px rgba(255, 215, 94, 0.6);
}

.login-input::placeholder {
  color: rgba(28, 28, 28, 0.4);
  font-weight: 400;
}

/* Сообщение об ошибке под полем (красный текст).
   min-height резервирует место — кнопки не прыгают. */
.login-error {
  min-height: 26px;
  margin-top: 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--red);
}

/* Кнопки диалога: «Отмена» (.btn-ghost) на светлом фоне — тёмный шрифт
   (базовый .btn-ghost с белым текстом здесь не читается). */
.login-dialog .btn {
  min-height: 56px;
  font-size: 19px;
}

.login-dialog .btn-ghost {
  color: #1c1c1c;
  background-color: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.35);
}

/* ---------- Блок «Моё табло» в меню ---------- */

.my-board {
  margin-top: 18px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 14px;
  padding: 14px 16px;
}

/* Заголовок + кнопка «Рейтинг» в одном ряду. */
.my-board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.my-board-title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  color: var(--gold);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Компактная кнопка «Рейтинг» (меньше базовых 52px). */
.my-board-btn {
  min-height: 44px;
  min-width: auto;
  padding: 8px 16px;
  font-size: 16px;
}

/* Без ника: подсказка + кнопка «Выбрать ник». */
.my-board-nologin {
  margin-bottom: 12px;
  font-size: 17px;
  color: rgba(255, 255, 255, 0.75);
}

.my-board-pick {
  width: 100%;
}

/* С ником: ник крупно (клик — открыть рейтинг). */
.my-board-login {
  margin-bottom: 12px;
  font-size: 24px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

/* Строка из 4 статистик: Место · Игры · Побед · %. */
.my-board-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  text-align: center;
}

.my-board-stat {
  padding: 8px 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
}

.my-board-stat-value {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
}

.my-board-stat-label {
  margin-top: 2px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
}

/* ---------- Ник в шапке меню ---------- */

/* Мелкий золотой ник справа от заголовка, клик → #/rating. */
.topbar-login {
  flex: 0 0 auto;
  max-width: 40%;
  padding: 4px 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 8px;
  cursor: pointer;
}

.topbar-login:hover {
  text-decoration: underline;
}

/* ---------- Экран рейтинга (#/rating) ---------- */

.rating-screen {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 14px 14px calc(28px + env(safe-area-inset-bottom));
}

.rating-title {
  font-size: 30px;
  font-weight: 800;
  text-align: center;
  margin: 8px 0 16px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}

/* Табы: «Все» + по каждой активной игре. */
.rating-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
}

.rating-tab {
  min-height: 44px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  color: var(--cream);
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid var(--panel-line);
  border-radius: 999px;
  cursor: pointer;
}

.rating-tab:active {
  transform: translateY(1px);
}

.rating-tab:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

/* Активный таб — золотой. */
.rating-tab.active {
  color: #241d05;
  background: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

/* Таблица топ-20: панель в стиле сукна. */
.rating-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 14px;
  overflow: hidden;
}

.rating-th {
  padding: 12px 10px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: left;
  color: rgba(255, 255, 255, 0.75);
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

/* Числовые колонки (Место/Игры/Победы/%) — по центру. */
.rating-table .rating-th:nth-child(n + 3),
.rating-table td:nth-child(n + 3) {
  text-align: center;
}

.rating-cell {
  padding: 11px 10px;
  font-size: 17px;
  color: var(--cream);
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
}

.rating-table tbody tr:last-child .rating-cell {
  border-bottom: none;
}

.rating-place {
  font-weight: 700;
}

/* Ник: по левому краю, без переноса. */
.rating-login {
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

/* Моя строка: золотая подсветка + жирный ник. */
.rating-row-me .rating-cell {
  background: rgba(255, 215, 94, 0.18);
}

.rating-row-me .rating-login {
  font-weight: 800;
  color: var(--gold);
}

/* Служебные строки (загрузка / пусто / офлайн) — центрированный текст. */
.rating-status,
.rating-empty,
.rating-error {
  padding: 28px 16px;
  font-size: 17px;
  text-align: center;
  color: rgba(255, 255, 255, 0.7);
}

.rating-error {
  color: #ffb4a8;
}

/* Адаптив: под узкий экран — компактнее таблица и табы. */
@media (max-width: 420px) {
  .rating-title {
    font-size: 26px;
  }
  .rating-tab {
    min-height: 40px;
    padding: 7px 13px;
    font-size: 16px;
  }
  .rating-cell {
    padding: 9px 6px;
    font-size: 16px;
  }
  .my-board-stat-value {
    font-size: 18px;
  }
}
