/* «Сукно» — портал настольных игр: типографика, градиенты, CSS-карты и доски. Без картинок. */

:root {
  color-scheme: dark;
  --felt: #12402f;
  --felt-deep: #0a2a1f;
  --felt-light: #1b5a42;
  --ink: #f3ede2;
  --ink-soft: rgba(243, 237, 226, 0.72);
  --ink-faint: rgba(243, 237, 226, 0.4);
  --line: rgba(243, 237, 226, 0.14);
  --gold: #e0b866;
  --gold-deep: #b98b35;
  --danger: #ff8a7a;
  --ok: #9fe0a8;
  --card: #fbf8f1;
  --card-edge: #e6dfd0;
  --suit-red: #c4122f;
  --suit-black: #1d1d1f;
  --back-a: #7a1f2b;
  --back-b: #5b1520;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --card-w: 76px;
  --card-h: 108px;
  --font-ui: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Playfair Display", Georgia, serif;
}

* { box-sizing: border-box; }
/* hidden прячет всегда — даже если у элемента свой display (кнопки, бейджи). */
[hidden] { display: none !important; }

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

body {
  background:
    radial-gradient(ellipse at 50% 35%, var(--felt-light) 0%, var(--felt) 45%, var(--felt-deep) 100%) fixed,
    var(--felt-deep);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* Playfair по умолчанию рисует старостильные цифры — 0 похож на «o». */
  font-variant-numeric: lining-nums tabular-nums;
}

button, input, select { font: inherit; color: inherit; }

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Общие элементы ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: background 0.15s, transform 0.1s, border-color 0.15s;
  white-space: nowrap;
}
.btn:hover { background: rgba(255, 255, 255, 0.12); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn:focus-visible, .card:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.btn-primary {
  background: linear-gradient(180deg, var(--gold), var(--gold-deep));
  border-color: transparent;
  color: #241a07;
}
.btn-primary:hover { background: linear-gradient(180deg, #ecc779, var(--gold)); }

.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); }
.btn-small { min-height: 34px; padding: 6px 14px; font-size: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--ink-soft); letter-spacing: 0.04em; text-transform: uppercase; }
.field input {
  min-height: 48px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  outline: none;
  font-size: 17px;
}
.captcha { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.captcha-img { flex: 1 1 200px; min-height: 64px; max-width: 280px; border-radius: 8px; overflow: hidden; color: var(--ink-soft); font-size: 14px; }
.captcha-img svg { display: block; width: 100%; height: auto; }
#captcha { text-transform: uppercase; letter-spacing: 0.1em; }
.field input:focus { border-color: var(--gold); }

.error { color: var(--danger); min-height: 1.5em; font-size: 14px; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }

.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 32px;
}
.topbar nav { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
  letter-spacing: 0.02em;
  color: var(--ink);
}
.logo:hover { text-decoration: none; }
.logo .suits { font-size: 0.6em; letter-spacing: 0.15em; vertical-align: 0.35em; margin-left: 8px; }

.suit-r { color: #ff6b7f; }

h1, h2 { font-family: var(--font-display); font-weight: 700; line-height: 1.15; margin: 0 0 16px; }
h1 { font-size: clamp(36px, 7vw, 64px); }
h2 { font-size: 26px; }

.panel {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.list { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  flex-wrap: wrap;
}
.list .meta { font-size: 14px; color: var(--ink-soft); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  max-width: calc(100% - 32px);
  padding: 12px 20px;
  border-radius: 12px;
  background: #2a1714;
  border: 1px solid rgba(255, 138, 122, 0.4);
  color: var(--ink);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.info { background: #14302a; border-color: var(--line); }

/* ---------- Вход ---------- */

.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.auth-box { width: 100%; max-width: 400px; }
.auth-hero { text-align: center; margin-bottom: 28px; }
.auth-hero h1 { margin-bottom: 4px; }
.auth-hero .suits-line { font-size: 28px; letter-spacing: 0.5em; margin-left: 0.5em; }
.auth-home { display: block; color: inherit; }
.auth-home:hover { text-decoration: none; }
.auth-switch { margin: 0; text-align: center; color: var(--ink-soft); font-size: 15px; }
.auth-back { margin: 20px 0 0; text-align: center; font-size: 15px; }
.auth-back a { color: var(--ink-soft); }
.auth-back a:hover { color: var(--gold); }
.form { display: flex; flex-direction: column; gap: 16px; }

/* ---------- Лобби ---------- */

.hero-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 40px; }
.hero-action {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s, border-color 0.15s;
}
.hero-action:hover { transform: translateY(-2px); border-color: var(--gold); }
.hero-action .title { font-family: var(--font-display); font-size: 24px; font-weight: 700; }
.hero-action .sub { color: var(--ink-soft); font-size: 15px; }
.hero-action .glyph { font-size: 32px; line-height: 1; }

.section { margin-bottom: 36px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h2 { margin: 0; font-size: 22px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 2px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); font-size: 13px; }
.chip.gold { background: rgba(224, 184, 102, 0.2); color: var(--gold); }

.invite {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
  font-family: ui-monospace, monospace;
  font-size: 14px;
  word-break: break-all;
}

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

.card {
  position: relative;
  flex: none;
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 9px;
  background: linear-gradient(160deg, #fffdf8, var(--card));
  border: 1px solid var(--card-edge);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  color: var(--suit-black);
  user-select: none;
}
.card.red { color: var(--suit-red); }
.card .corner {
  position: absolute;
  top: 6px;
  left: 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}
.card .corner.bottom { top: auto; left: auto; bottom: 6px; right: 7px; transform: rotate(180deg); }
.card .rank { font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: -0.04em; }
.card .suit-small { font-size: 15px; margin-top: 1px; }
.card .pip {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 40px;
  line-height: 1;
}
.card.face .pip { font-family: var(--font-display); font-size: 40px; font-weight: 700; }

.card.back {
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.07) 0 4px, transparent 4px 9px),
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.07) 0 4px, transparent 4px 9px),
    linear-gradient(160deg, var(--back-a), var(--back-b));
  border: 3px solid #f4ecdc;
}

.card.small { --card-w: 46px; --card-h: 66px; border-radius: 6px; }
.card.small.back { border-width: 2px; }

/* ---------- Игровой стол ---------- */

.table {
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(300px, 2.2fr) minmax(150px, 1fr);
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "hud hud hud"
    "left center right"
    "me me me";
  overflow: hidden;
}

.hud {
  grid-area: hud;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
  flex-wrap: wrap;
}
.hud-info { display: flex; gap: 20px; align-items: baseline; flex-wrap: wrap; }
.hud-item { display: flex; flex-direction: column; line-height: 1.2; }
.hud-item .k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-faint); }
.hud-item .v { font-weight: 700; font-size: 18px; }
.hud-item .v .trump { font-size: 22px; }
.hud-actions { display: flex; gap: 8px; align-items: center; }

.seat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  position: relative;
}
.seat-left { grid-area: left; }
.seat-right { grid-area: right; }

.player-tag {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 18px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.22);
  min-width: 140px;
  text-align: center;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.player-tag .name { font-weight: 700; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-tag .score { font-family: var(--font-display); font-size: 28px; font-weight: 700; line-height: 1.1; }
.player-tag .badges { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; min-height: 22px; }
.player-tag.turn {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(224, 184, 102, 0.25), 0 0 32px rgba(224, 184, 102, 0.25);
  animation: pulse 1.6s ease-in-out infinite;
}
.player-tag.passed { opacity: 0.6; }
.player-tag.declarer .name::before { content: "★ "; color: var(--gold); }
.player-tag.offline .name::after { content: " · не в сети"; font-weight: 400; color: var(--ink-faint); font-size: 13px; }

@keyframes pulse {
  50% { box-shadow: 0 0 0 6px rgba(224, 184, 102, 0.12), 0 0 40px rgba(224, 184, 102, 0.35); }
}

.backs { display: flex; justify-content: center; min-height: 66px; }
.backs .card + .card { margin-left: -32px; }

.bubble {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translate(-50%, -100%);
  padding: 6px 14px;
  border-radius: 12px;
  background: var(--ink);
  color: #1d1d1f;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: var(--shadow);
  animation: pop 0.25s ease-out;
  z-index: 5;
}
.bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--ink);
  border-bottom: 0;
}
.seat-me .bubble { top: -8px; }

@keyframes pop {
  from { transform: translate(-50%, -80%) scale(0.85); opacity: 0; }
}

.center {
  grid-area: center;
  position: relative;
  display: grid;
  place-items: center;
}
.center-note {
  position: absolute;
  top: 12px;
  left: 0;
  right: 0;
  text-align: center;
  color: var(--ink-soft);
  font-size: 15px;
  padding: 0 8px;
}

.trick { position: relative; width: 260px; height: 230px; }
.trick .slot { position: absolute; transition: transform 0.4s ease; }
.trick .slot-me { left: 50%; bottom: 0; transform: translateX(-50%) rotate(2deg); }
.trick .slot-left { left: 0; top: 40px; transform: rotate(-8deg); }
.trick .slot-right { right: 0; top: 40px; transform: rotate(7deg); }
.trick .slot .card { box-shadow: var(--shadow); }
.trick.collect-me .slot { transform: translate(0, 220px) scale(0.6) !important; opacity: 0; }
.trick.collect-left .slot { transform: translate(-260px, 0) scale(0.6) !important; opacity: 0; }
.trick.collect-right .slot { transform: translate(260px, 0) scale(0.6) !important; opacity: 0; }
.trick.collecting .slot { transition: transform 0.45s ease-in, opacity 0.45s ease-in; }

.talon { display: flex; gap: 10px; }
.talon .card { animation: flip-in 0.4s ease-out both; }
.talon .card:nth-child(2) { animation-delay: 0.08s; }
.talon .card:nth-child(3) { animation-delay: 0.16s; }

@keyframes flip-in {
  from { transform: rotateY(90deg) translateY(-10px); opacity: 0; }
}

.seat-me {
  grid-area: me;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 16px;
}
.me-row { display: flex; align-items: center; gap: 16px; }
.me-row .player-tag { min-width: 0; flex-direction: row; gap: 12px; padding: 6px 16px; }
.me-row .player-tag .score { font-size: 22px; }

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 48px;
}
.controls .hint { color: var(--ink-soft); font-size: 15px; text-align: center; }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.stepper button { width: 44px; min-height: 44px; border: 0; background: rgba(255, 255, 255, 0.06); cursor: pointer; font-size: 20px; }
.stepper button:hover { background: rgba(255, 255, 255, 0.14); }
.stepper button:disabled { opacity: 0.3; cursor: default; }
.stepper .val { min-width: 64px; text-align: center; font-family: var(--font-display); font-size: 22px; font-weight: 700; }

.hand {
  display: flex;
  justify-content: center;
  padding-top: 18px;
  min-height: calc(var(--card-h) + 22px);
}
.hand .card {
  margin-left: calc(var(--card-w) * -0.32);
  transition: transform 0.15s ease, box-shadow 0.15s, opacity 0.2s;
  transform-origin: 50% 120%;
}
.hand .card:first-child { margin-left: 0; }
.hand .card.playable { cursor: pointer; }
.hand .card.playable:hover, .hand .card.selected { transform: translateY(-16px); box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35); }
.hand.active .card:not(.playable) { filter: brightness(0.62) saturate(0.5); }
.hand .card.new::after {
  content: "";
  position: absolute;
  top: -7px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
}

.popover {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  padding: 16px 20px;
  border-radius: var(--radius);
  background: #10261e;
  border: 1px solid var(--gold);
  box-shadow: var(--shadow);
  z-index: 20;
  white-space: nowrap;
}
.popover .row { display: flex; gap: 8px; }

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(4, 16, 11, 0.7);
  backdrop-filter: blur(3px);
  z-index: 50;
  animation: fade 0.2s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%;
  max-width: 460px;
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 28px;
  border-radius: 20px;
  background: linear-gradient(170deg, #1a4a38, #0f3024);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: rise 0.25s ease-out;
  scrollbar-color: rgba(243, 237, 226, 0.25) transparent;
}
@keyframes rise { from { transform: translateY(16px); opacity: 0; } }
.modal h2 { margin-bottom: 8px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }

.result-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.result-table th, .result-table td { padding: 8px 6px; text-align: right; border-bottom: 1px solid var(--line); }
.result-table th:first-child, .result-table td:first-child { text-align: left; }
.result-table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); font-weight: 600; }
.result-table .plus, .balance .plus, .tile .plus, .board .plus, .recent .plus, .faint .plus { color: var(--ok); }
.result-table .minus, .balance .minus, .tile .minus, .board .minus, .recent .minus, .faint .minus { color: var(--danger); }
.board .rate.plus { color: var(--ok); }
.board .rate.minus { color: var(--danger); }
.tiles + .section { margin-top: 28px; }
.money-boards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.money-boards h3 { margin: 8px 0 4px; font-size: 16px; }
.rules-list { padding-left: 20px; line-height: 1.6; }
.result-table .total { font-family: var(--font-display); font-weight: 700; font-size: 20px; }

.last-trick { display: flex; gap: 8px; justify-content: center; margin: 12px 0; }

/* ---------- Адаптивность ---------- */

@media (max-width: 900px) {
  :root { --card-w: 64px; --card-h: 92px; }
  .trick { width: 220px; height: 200px; }
  .card .rank { font-size: 19px; }
  .card .pip { font-size: 32px; }
  .card.face .pip { font-size: 34px; }
}

@media (max-width: 640px) {
  :root { --card-w: 52px; --card-h: 76px; }
  .table {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto 1fr auto;
    grid-template-areas:
      "hud hud"
      "left right"
      "center center"
      "me me";
  }
  .seat { padding: 8px 4px; }
  .player-tag { min-width: 0; width: 100%; padding: 8px; }
  .player-tag .score { font-size: 22px; }
  .backs { min-height: 0; }
  .backs .card { display: none; }
  .trick { width: 190px; height: 180px; }
  .card .rank { font-size: 16px; }
  .card .suit-small { font-size: 12px; }
  .card .pip { font-size: 26px; }
  .card.face .pip { font-size: 26px; }
  .card .corner.bottom { display: none; }
  .hand .card { margin-left: calc(var(--card-w) * -0.45); }
  .hud { padding: 8px 12px; gap: 8px; flex-wrap: nowrap; }
  .hud-info { gap: 12px; flex-wrap: nowrap; min-width: 0; }
  .hud .logo { font-size: 20px; }
  .hud .logo .suits { display: none; }
  .hud-item .v { font-size: 15px; white-space: nowrap; }
  .hud-item .k { font-size: 10px; }
  .hud-actions .btn { padding: 6px 10px; }
  .hud-actions [data-action="last-trick"] { font-size: 0; }
  .hud-actions [data-action="last-trick"]::before { content: "Взятка"; font-size: 14px; }
}

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

/* Карта соперника влетает в центр со стороны его места. */
.card.enter { animation: enter-me 0.35s cubic-bezier(.2, .8, .3, 1) both; }
.card.enter-left { animation-name: enter-left; }
.card.enter-right { animation-name: enter-right; }
@keyframes enter-left { from { transform: translate(-180px, -20px) rotate(-20deg); opacity: 0; } }
@keyframes enter-right { from { transform: translate(180px, -20px) rotate(20deg); opacity: 0; } }
@keyframes enter-me { from { transform: translateY(120px); opacity: 0; } }

/* ---------- Статистика ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.tile {
  padding: 16px 18px;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
}
.tile .num { font-family: var(--font-display); font-weight: 700; font-size: 34px; line-height: 1.1; }
.tile .num small { font-family: var(--font-ui); font-size: 15px; font-weight: 600; color: var(--ink-soft); margin-left: 4px; }
.tile .label { color: var(--ink-soft); font-size: 14px; margin-top: 4px; }
.tile .sub { color: var(--ink-faint); font-size: 13px; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.stats-grid h3 { font-size: 15px; font-weight: 700; margin: 0 0 4px; }
.stats-grid .note { color: var(--ink-faint); font-size: 13px; margin: 0 0 14px; }

/* Однорядная горизонтальная диаграмма: подпись, полоса, значение. */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 84px 1fr auto; gap: 10px; align-items: center; font-size: 14px; }
.bar-row .name { color: var(--ink-soft); white-space: nowrap; }
.bar-row .name .s { font-size: 18px; }
.bar-track { height: 12px; border-radius: 0 4px 4px 0; position: relative; }
.bar-track::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 1px; background: var(--line); }
.bar-fill { height: 100%; min-width: 2px; background: var(--gold); border-radius: 0 4px 4px 0; transition: width 0.4s ease; }
.bar-row:hover .bar-fill { background: #f0cf86; }
.bar-row .val { min-width: 92px; text-align: right; white-space: nowrap; }
.bar-row .val .faint { font-size: 13px; }

.seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: rgba(0, 0, 0, 0.25); flex-wrap: wrap; }
.seg button { min-height: 34px; padding: 4px 14px; border: 0; border-radius: 999px; background: transparent; cursor: pointer; font-weight: 600; color: var(--ink-soft); font-size: 14px; }
.seg button[aria-pressed="true"] { background: rgba(255, 255, 255, 0.12); color: var(--ink); }
.seg a { min-height: 34px; padding: 6px 14px; border-radius: 999px; font-weight: 600; color: var(--ink-soft); font-size: 14px; text-decoration: none; display: inline-flex; align-items: center; }
.seg a[aria-pressed="true"] { background: rgba(255, 255, 255, 0.12); color: var(--ink); }
.ratings-tabs { margin: 8px 0 20px; border-radius: 20px; }

.board { width: 100%; border-collapse: collapse; }
.board th, .board td { padding: 10px 8px; text-align: right; border-bottom: 1px solid var(--line); }
.board th:nth-child(2), .board td:nth-child(2) { text-align: left; }
.board th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); font-weight: 600; }
.board td:first-child { font-family: var(--font-display); font-weight: 700; font-size: 18px; width: 48px; }
.board tr.me td { color: var(--gold); }
.board .rate { font-weight: 700; }

.recent .won { color: var(--ok); font-weight: 700; }
.recent .lost { color: var(--ink-soft); }

@media (max-width: 640px) {
  .bar-row { grid-template-columns: 70px 1fr auto; }
  .bar-row .val { min-width: 70px; }
  .tile .num { font-size: 28px; }
}

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; margin-bottom: 24px; }
  .topbar nav { width: 100%; justify-content: flex-start; }
}

/* ---------- Портал: каталог, страницы игр ---------- */

.page-title { font-size: clamp(32px, 6vw, 48px); margin-bottom: 8px; }
.crumbs { margin: 0 0 8px; font-size: 14px; }
.crumbs a { color: var(--ink-soft); }
.topbar .btn.current { background: rgba(255, 255, 255, 0.1); }
.user-link { color: inherit; font-weight: 600; }
.user-link:hover { color: var(--gold); }
.row-title { font-family: var(--font-display); font-weight: 700; font-size: 17px; margin-bottom: 4px; }

.intro { margin-bottom: 36px; }
.intro h1 { margin-bottom: 8px; }
.intro p { max-width: 560px; margin: 0; font-size: 17px; }

.catalog { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  transition: transform 0.15s, border-color 0.15s;
}
.game-card:not(.soon):hover { transform: translateY(-2px); border-color: var(--gold); }
.game-card .cover { position: absolute; inset: 0; border-radius: inherit; }
.game-card .cover:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.game-card h3 { font-family: var(--font-display); font-size: 24px; margin: 4px 0 0; line-height: 1.15; }
.game-card p { margin: 0; }
.game-card .players { color: var(--gold); font-size: 14px; font-weight: 600; }
.game-card .blurb { color: var(--ink-soft); font-size: 15px; flex: 1; }
.game-card .counts { color: var(--ink-faint); font-size: 13px; }
.game-card .actions { position: relative; display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.game-card.soon { opacity: 0.55; }
.game-card.soon .chip { align-self: flex-start; margin-top: 6px; }

/* Лендинг для гостя */
.landing-hero { text-align: center; padding: 40px 0 48px; }
.landing-hero .suits-line { font-size: 32px; letter-spacing: 0.5em; margin-left: 0.5em; margin-bottom: 8px; }
.landing-hero h1 { font-size: clamp(34px, 6.5vw, 60px); max-width: 820px; margin: 0 auto 16px; }
.landing-hero .lead { max-width: 620px; margin: 0 auto 28px; font-size: 19px; color: var(--ink-soft); }
.landing-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.features { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 48px; }
@media (max-width: 900px) { .features { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .features { grid-template-columns: 1fr; } }
.feature { padding: 20px; border-top: 1px solid var(--line); }
.feature .glyph { font-size: 28px; min-height: 32px; }
.feature h3 { font-family: var(--font-display); font-size: 19px; margin: 8px 0 6px; }
.feature p { margin: 0; font-size: 15px; }
.game-card h3 a { position: relative; color: inherit; }
.game-card h3 a:hover { color: var(--gold); text-decoration: none; }
.faq { max-width: 760px; }
.faq details { border-top: 1px solid var(--line); padding: 14px 0; }
.faq details:last-child { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; font-weight: 600; font-size: 17px; }
.faq summary::marker { color: var(--gold); }
.faq details p { margin: 10px 0 0; }
.landing-bottom { text-align: center; padding: 32px 0 56px; }
.landing-bottom h2 { margin-bottom: 8px; }
.landing-bottom p { margin: 0 0 20px; }

/* Значок игры: символы мастей, числа или CSS-шашки. */
.glyph {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 34px;
  line-height: 1;
  color: var(--ink);
}
.g-disc {
  display: inline-block;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fffdf8, var(--card) 55%, #cfc6b3);
  box-shadow: inset 0 0 0 4px rgba(0, 0, 0, 0.08), inset 0 0 0 7px rgba(255, 255, 255, 0.5), 0 2px 4px rgba(0, 0, 0, 0.35);
}
.g-disc.dark { background: radial-gradient(circle at 35% 30%, #a8343f, var(--back-a) 55%, var(--back-b)); }

.game-head { display: flex; gap: 20px; align-items: flex-start; margin-bottom: 28px; }
.game-head .glyph { font-size: 44px; min-width: 64px; justify-content: center; padding-top: 6px; }
.game-head p { margin: 0 0 6px; }
.game-head .links { font-weight: 600; }

/* ---------- Правила ---------- */

.prose { max-width: 720px; font-size: 16px; }
.prose h2 { font-size: 24px; margin: 32px 0 10px; }
.prose h3 { font-size: 18px; margin: 24px 0 8px; }
.prose p, .prose ul, .prose ol { margin: 0 0 12px; }
.prose ul, .prose ol { padding-left: 24px; }
.prose li { margin: 4px 0; }
.prose li > ul, .prose li > ol { margin: 4px 0; }
.prose code { font-family: ui-monospace, monospace; font-size: 0.9em; padding: 1px 6px; border-radius: 6px; background: rgba(0, 0, 0, 0.25); }
.prose blockquote { margin: 0 0 12px; padding: 4px 16px; border-left: 3px solid var(--gold); color: var(--ink-soft); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
.prose .table-wrap { overflow-x: auto; margin: 0 0 16px; }
.prose table { border-collapse: collapse; min-width: 50%; }
.prose th, .prose td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; }
.prose th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); font-weight: 600; }
.modal.wide { max-width: 760px; }
.modal .prose h2 { font-size: 20px; margin-top: 24px; }

/* ---------- Чат за столом ---------- */

.chat {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  background: linear-gradient(170deg, #163f30, #0c271d);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.25s ease, visibility 0s 0.25s;
  z-index: 40;
}
.chat.open { transform: none; visibility: visible; transition: transform 0.25s ease; }
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 12px 20px; border-bottom: 1px solid var(--line); }
.chat-head h2 { margin: 0; font-size: 20px; }
.chat-list { flex: 1; overflow-y: auto; margin: 0; padding: 12px 16px; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.chat-list li { max-width: 92%; }
.chat-list li.mine { align-self: flex-end; text-align: right; }
.chat-meta { font-size: 13px; color: var(--ink-faint); }
.chat-meta time { margin-left: 6px; }
.chat-text {
  display: inline-block;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-align: left;
}
.chat-list li.mine .chat-text { background: rgba(224, 184, 102, 0.18); }
.chat-empty { color: var(--ink-faint); text-align: center; margin: auto; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.chat-form textarea {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  outline: none;
  resize: vertical;
}
.chat-form textarea:focus { border-color: var(--gold); }
.chat-note { margin: 0; padding: 12px 16px; border-top: 1px solid var(--line); color: var(--ink-faint); font-size: 14px; }

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--gold);
  color: #241a07;
  font-size: 12px;
  font-weight: 800;
}
.badge[hidden] { display: none; }

@media (max-width: 640px) {
  .game-head { gap: 12px; }
  .game-head .glyph { font-size: 32px; min-width: 44px; }
  .hud-actions [data-shell] { padding: 6px 8px; }
}

@media (max-width: 640px) {
  /* В шапке стола кнопок больше, чем помещается в строку: они уходят на вторую. */
  .hud { flex-wrap: wrap; }
  .hud-actions { width: 100%; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
}

/* ---------- Статистика и рейтинг ---------- */

.rating-line { margin: 0 0 16px; }
.rating-line strong { color: var(--gold); }
.sub-head { margin: 28px 0 12px; font-size: 18px; }
.section-head h2 a { color: inherit; }

/* ---------- Настройки стола ---------- */

.table-options { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; margin: 0 0 16px; }
.seg-label { align-self: center; padding: 0 8px 0 10px; font-size: 13px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.06em; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--gold); }
.chip.danger { background: rgba(255, 138, 122, 0.2); color: var(--danger); }

/* ---------- Стол «Дурака» ---------- */

.durak {
  height: 100dvh;
  display: grid;
  grid-template-columns: 100%;
  grid-template-rows: auto auto 1fr auto;
  grid-template-areas: "hud" "opp" "center" "me";
  overflow: hidden;
}
.durak .opponents { grid-area: opp; }
.durak .durak-center { grid-area: center; }
.opponents {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 28px 12px 4px;
  flex-wrap: wrap;
}
.opponent { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
.opponent .player-tag { min-width: 130px; }
.player-tag .score small { font-family: var(--font-ui); font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.opponent .backs .card + .card { margin-left: -36px; }

.durak-center {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 36px;
  padding: 36px 16px 12px;
  min-height: 0;
}
.durak-center .center-note { top: 4px; }
.deck { position: relative; width: calc(var(--card-w) + 34px); height: var(--card-h); flex: none; }
.deck .trump-card { position: absolute; left: 30px; top: 0; transform: rotate(90deg); transform-origin: 50% 50%; }
.deck .deck-back { position: absolute; left: 0; top: 0; }
.deck-count {
  position: absolute;
  left: calc(var(--card-w) / 2);
  bottom: -26px;
  transform: translateX(-50%);
  font-weight: 700;
  color: var(--ink-soft);
}
.deck.empty { display: grid; place-items: center; width: auto; }
.trump-big { font-size: 48px; opacity: 0.6; }

.battle {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  justify-content: center;
  align-items: flex-start;
  max-width: calc((var(--card-w) + 44px) * 3);
  min-height: calc(var(--card-h) + 26px);
  transition: transform 0.6s ease-in, opacity 0.6s ease-in;
}
.battle .pair { position: relative; width: calc(var(--card-w) + 20px); height: calc(var(--card-h) + 24px); }
.battle .pair .card { position: absolute; left: 0; top: 0; box-shadow: var(--shadow); }
.battle .pair .card.defense { left: 18px; top: 22px; transform: rotate(8deg); }
.battle .pair.target { cursor: pointer; }
.battle .pair.target > .card:first-child { outline: 3px solid var(--gold); outline-offset: 2px; }
.battle.clear-beaten { transform: translateX(40vw) rotate(10deg); opacity: 0; }
.battle.clear-taken { transform: translateY(-30vh) scale(0.6); opacity: 0; }
.card.enter-pop { animation: pop-card 0.3s cubic-bezier(.2, .8, .3, 1) both; }
@keyframes pop-card { from { transform: translateY(-30px) scale(0.85); opacity: 0; } }
.battle .pair .card.defense.enter-pop { animation-name: pop-defense; }
@keyframes pop-defense { from { transform: translate(10px, 30px) rotate(20deg); opacity: 0; } }
.durak .seat-me { grid-area: me; }
/* Рука бывает большой: нахлёст растёт с числом карт, чтобы она всегда помещалась в ширину. */
.durak .hand .card {
  margin-left: min(calc(var(--card-w) * -0.32), calc((100vw - 40px - var(--card-w)) / max(var(--count) - 1, 1) - var(--card-w)));
}
.durak .hand .card:first-child { margin-left: 0; }

@media (max-width: 640px) {
  .opponents { gap: 8px; padding-top: 24px; }
  .opponent .player-tag { min-width: 0; width: auto; padding: 6px 10px; }
  .opponent .backs { display: none; }
  .durak-center { flex-direction: column; gap: 12px; padding-top: 28px; }
  .deck { transform: scale(0.8); height: calc(var(--card-h) * 0.8); }
  .battle { gap: 8px 14px; }
  .battle .pair .card.defense { left: 12px; top: 16px; }
  .battle .pair { width: calc(var(--card-w) + 14px); height: calc(var(--card-h) + 18px); }
}
@media (max-width: 640px) {
  .durak .hand .card {
    margin-left: min(calc(var(--card-w) * -0.45), calc((100vw - 24px - var(--card-w)) / max(var(--count) - 1, 1) - var(--card-w)));
  }
  .durak .hand .card:first-child { margin-left: 0; }
}

/* ---------- Стол «Шестидесяти шести» ---------- */

.sixtysix {
  height: 100dvh;
  display: grid;
  grid-template-columns: 100%;
  grid-template-rows: auto auto 1fr auto;
  grid-template-areas: "hud" "opp" "center" "me";
  overflow: hidden;
}
.sixtysix .opponents { grid-area: opp; }
.sixtysix .seat-me { grid-area: me; }
.ss-center {
  grid-area: center;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 48px;
  padding: 36px 16px 12px;
  min-height: 0;
}
.ss-center .center-note { top: 4px; }
.deck.closed .deck-back { filter: grayscale(0.6) brightness(0.8); }
.deck.closed .trump-card { transform: rotate(0deg); left: 8px; top: 8px; z-index: -1; opacity: 0.85; }
.ss-trick { position: relative; width: calc(var(--card-w) * 2 + 40px); height: calc(var(--card-h) * 1.5); }
.ss-slot { position: absolute; }
.ss-slot .card { box-shadow: var(--shadow); }
.ss-opp { left: 0; top: 0; transform: rotate(-6deg); }
.ss-me { right: 0; bottom: 0; transform: rotate(5deg); }
.ss-trick .ss-slot { transition: transform 0.45s ease-in, opacity 0.45s ease-in; }
.ss-trick.collect-me .ss-slot { transform: translateY(40vh) scale(0.6); opacity: 0; }
.ss-trick.collect-opp .ss-slot { transform: translateY(-40vh) scale(0.6); opacity: 0; }
.ss-marriages { position: absolute; bottom: 4px; left: 0; right: 0; justify-content: center; }

@media (max-width: 640px) {
  .ss-center { flex-direction: column; gap: 12px; padding-top: 28px; }
  .sixtysix .opponent .backs { display: none; }
  .ss-trick { height: calc(var(--card-h) * 1.35); }
}

/* ---------- Шашки ---------- */

.checkers {
  height: 100dvh;
  display: grid;
  grid-template-columns: 100%;
  grid-template-rows: auto auto 1fr auto;
  grid-template-areas: "hud" "top" "board" "bottom";
  overflow: hidden;
}
.ck-top { grid-area: top; }
.ck-bottom { grid-area: bottom; }
.ck-board-wrap { grid-area: board; display: grid; place-items: center; min-height: 0; padding: 8px; }
.ck-side { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px 12px; }
.ck-tag { flex-direction: row; gap: 10px; padding: 8px 16px; min-width: 0; flex-wrap: wrap; justify-content: center; }
.ck-dot { width: 18px; height: 18px; border-radius: 50%; display: inline-block; }
.ck-dot.w { background: radial-gradient(circle at 35% 30%, #fffdf8, #e5dcc8); }
.ck-dot.b { background: radial-gradient(circle at 35% 30%, #a8343f, var(--back-b)); }

.ck-board {
  --size: min(92vw, calc(100dvh - 290px), 600px);
  width: var(--size);
  height: var(--size);
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border: 6px solid #3b2a1a;
  border-radius: 6px;
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(0, 0, 0, 0.4);
}
.ck-sq { position: relative; display: grid; place-items: center; }
.ck-sq.light { background: #e8d9b5; }
.ck-sq.dark { background: #8b5a34; cursor: pointer; }
.ck-sq.last { background: #a7773f; }
.ck-sq.path { background: #b98b35; }
.ck-sq.target::after {
  content: "";
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: rgba(224, 184, 102, 0.85);
  box-shadow: 0 0 12px rgba(224, 184, 102, 0.8);
}
.ck-sq.finish::after {
  content: "";
  width: 46%;
  height: 46%;
  border-radius: 50%;
  border: 3px solid rgba(255, 217, 138, 0.9);
  box-shadow: 0 0 10px rgba(224, 184, 102, 0.7);
}
.ck-rank, .ck-file { position: absolute; font-size: 11px; font-weight: 700; color: rgba(255, 255, 255, 0.55); pointer-events: none; }
.ck-rank { top: 2px; left: 3px; }
.ck-file { bottom: 1px; right: 4px; }
.ck-sq.light .ck-rank, .ck-sq.light .ck-file { color: rgba(59, 42, 26, 0.55); }

.piece {
  width: 78%;
  height: 78%;
  border-radius: 50%;
  position: relative;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.3s;
}
.piece.w {
  background: radial-gradient(circle at 35% 30%, #fffdf8, #ece4d2 55%, #c9bea6);
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.06), inset 0 0 0 7px rgba(255, 255, 255, 0.55), 0 3px 5px rgba(0, 0, 0, 0.45);
}
.piece.b {
  background: radial-gradient(circle at 35% 30%, #b8404b, var(--back-a) 55%, var(--back-b));
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.15), inset 0 0 0 7px rgba(255, 255, 255, 0.12), 0 3px 5px rgba(0, 0, 0, 0.45);
}
/* Дамка — две шашки стопкой: нижняя — тень со смещением. */
.piece.king { transform: translateY(-4px); }
.piece.w.king { box-shadow: inset 0 0 0 7px rgba(255, 255, 255, 0.55), 0 6px 0 #b4a98f, 0 8px 6px rgba(0, 0, 0, 0.45); }
.piece.b.king { box-shadow: inset 0 0 0 7px rgba(255, 255, 255, 0.12), 0 6px 0 #3e0d14, 0 8px 6px rgba(0, 0, 0, 0.45); }
.piece.king::after {
  content: "";
  position: absolute;
  inset: 32%;
  border-radius: 50%;
  border: 2px solid currentColor;
  color: var(--gold);
}
.piece.movable { box-shadow: 0 0 0 3px rgba(224, 184, 102, 0.75), 0 3px 5px rgba(0, 0, 0, 0.45); }
.piece.selected { animation: ck-pulse 0.9s ease-in-out infinite alternate; z-index: 1; }
.piece.king.selected { animation-name: ck-pulse-king; }
@keyframes ck-pulse {
  from { transform: scale(1.04); box-shadow: 0 0 0 3px var(--gold), 0 0 6px 2px rgba(224, 184, 102, 0.5), 0 4px 10px rgba(0, 0, 0, 0.5); }
  to { transform: scale(1.14); box-shadow: 0 0 0 5px #ffd98a, 0 0 22px 8px rgba(255, 217, 138, 0.85), 0 8px 16px rgba(0, 0, 0, 0.5); }
}
@keyframes ck-pulse-king {
  from { transform: translateY(-4px) scale(1.04); box-shadow: 0 0 0 3px var(--gold), 0 0 6px 2px rgba(224, 184, 102, 0.5), 0 8px 6px rgba(0, 0, 0, 0.45); }
  to { transform: translateY(-4px) scale(1.14); box-shadow: 0 0 0 5px #ffd98a, 0 0 22px 8px rgba(255, 217, 138, 0.85), 0 8px 6px rgba(0, 0, 0, 0.45); }
}
@media (prefers-reduced-motion: reduce) {
  .piece.selected { animation: none; transform: scale(1.1); box-shadow: 0 0 0 5px #ffd98a, 0 0 18px 6px rgba(255, 217, 138, 0.8); }
}
.piece.dragging { opacity: 0.25; }
.ck-ghost { position: fixed; z-index: 50; pointer-events: none; transform: scale(1.12); box-shadow: 0 0 0 4px #ffd98a, 0 14px 24px rgba(0, 0, 0, 0.55) !important; }
.ck-sq .piece.movable { cursor: grab; }
.piece.moving { transform: scale(1.1); z-index: 2; } /* летит над соседними полями */
.piece.doomed { opacity: 0.35; }

@media (max-width: 640px) {
  .ck-board { --size: min(96vw, calc(100dvh - 300px)); border-width: 4px; }
  .ck-side { padding: 6px 8px; }
}

/* ---------- «Пьяница» ---------- */

.pyanitsa {
  height: 100dvh;
  display: grid;
  grid-template-columns: 100%;
  grid-template-rows: auto 1fr auto;
  grid-template-areas: "hud" "players" "controls";
  overflow: hidden;
}
.py-players {
  grid-area: players;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-content: center;
  justify-items: center;
  padding: 24px 16px;
  min-height: 0;
  overflow: auto;
}
.py-player { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 12px; border-radius: var(--radius); transition: background 0.3s; }
.py-player.mine { order: 10; }
.py-player.winner { background: rgba(224, 184, 102, 0.12); box-shadow: 0 0 0 2px rgba(224, 184, 102, 0.4); }
.py-row { display: flex; align-items: center; gap: 18px; }
.py-pile { position: relative; width: calc(var(--card-w) + 6px); height: calc(var(--card-h) + 6px); }
.py-pile .card { position: absolute; left: 0; top: 0; }
.py-pile .card.under { left: 4px; top: 4px; z-index: -1; }
.py-empty { border: 2px dashed var(--line); background: transparent; box-shadow: none; }
.py-table { display: flex; min-width: var(--card-w); min-height: var(--card-h); }
.py-table .card + .card { margin-left: calc(var(--card-w) * -0.55); }
.py-table .card.down { transform: rotate(-4deg); }
.py-controls { grid-area: controls; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 12px 16px 24px; }
.py-flip { min-width: 240px; min-height: 56px; font-size: 18px; }
/* Полоска: сколько осталось до автооткрытия. */
.py-timer { width: 240px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.py-timer span { display: block; height: 100%; background: var(--gold); transform-origin: left; animation: py-timer 10s linear forwards; }
@keyframes py-timer { from { transform: scaleX(var(--from)); } to { transform: scaleX(0); } }

@media (max-width: 640px) {
  .py-players { gap: 8px; padding: 12px 8px; }
  .py-row { gap: 8px; }
  .py-player { padding: 6px; }
}

/* ---------- «Очко» ---------- */

.ochko {
  height: 100dvh;
  display: grid;
  grid-template-columns: 100%;
  grid-template-rows: auto 1fr auto;
  grid-template-areas: "hud" "players" "controls";
  overflow: hidden;
}
.ok-players {
  grid-area: players;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  align-content: center;
  justify-items: center;
  padding: 28px 16px 12px;
  min-height: 0;
  overflow: auto;
}
.ok-player { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.ok-player.mine { order: 10; grid-column: 1 / -1; }
.ok-cards { display: flex; align-items: center; min-height: 66px; }
.ok-cards .card + .card { margin-left: -18px; }
.ok-player.mine .ok-cards .card { --card-w: 64px; --card-h: 92px; }
.ok-total {
  margin-left: 12px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
}
.ok-controls { grid-area: controls; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px 16px 24px; }
.row-controls { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; align-items: center; }

@media (max-width: 640px) {
  .ok-players { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 20px 8px 8px; }
}

/* ---------- «Русский пасьянс» ---------- */

.solitaire {
  --card-w: min(84px, calc((100vw - 56px) / 7.3));
  --card-h: calc(var(--card-w) * 1.42);
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 100%;
  grid-template-rows: auto auto 1fr;
  grid-template-areas: "hud" "top" "tableau";
}
.sol-top {
  grid-area: top;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px max(16px, calc((100vw - (var(--card-w) + 10px) * 7) / 2)) 8px;
}
.sol-foundations { display: flex; gap: 10px; }
.sol-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.sol-slot {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 9px;
  border: 2px dashed var(--line);
  display: grid;
  place-items: center;
  position: relative;
}
.sol-slot .card { position: absolute; left: -2px; top: -2px; }
.sol-slot.target { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(224, 184, 102, 0.3); }
.sol-suit { font-size: calc(var(--card-w) * 0.5); opacity: 0.35; }
.sol-tableau {
  grid-area: tableau;
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 8px 8px 32px;
  align-items: flex-start;
}
.sol-col { position: relative; width: var(--card-w); min-height: var(--card-h); border-radius: 9px; }
.sol-col.target { box-shadow: 0 0 0 3px var(--gold); }
.sol-col .sol-slot.empty { position: absolute; inset: 0 0 auto 0; }
.sol-card { position: absolute; left: 0; }
.sol-card.open { cursor: pointer; }
.sol-card.playable:hover { filter: brightness(1.04); }
.sol-card.dragging { visibility: hidden; }
.sol-ghost { position: fixed; z-index: 50; width: var(--card-w); pointer-events: none; filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.45)); }
.sol-ghost .card { position: absolute; left: 0; }
.sol-dragging, .sol-dragging * { cursor: grabbing !important; }
.sol-slot.target.drop-over, .sol-col.target.drop-over { box-shadow: 0 0 0 4px var(--gold), 0 0 18px rgba(224, 184, 102, 0.6); }
.sol-card.selected { box-shadow: 0 0 0 3px var(--gold), 0 6px 14px rgba(0, 0, 0, 0.4); }

@media (max-width: 640px) {
  .sol-tableau { gap: 4px; padding: 6px 4px 24px; }
  .sol-foundations { gap: 4px; }
  .sol-top { padding: 10px 8px 6px; }
  .solitaire .card .corner.bottom { display: none; }
  .solitaire .card .pip { font-size: calc(var(--card-w) * 0.45); }
}
/* В столбцах пасьянса видна только верхняя полоска карты — масть ставим рядом со значением. */
.solitaire .card .corner { flex-direction: row; align-items: baseline; gap: 2px; }
.solitaire .card .corner .suit-small { margin-top: 0; }
@media (max-width: 640px) {
  .solitaire .card .rank { font-size: calc(var(--card-w) * 0.3); }
  .solitaire .card .suit-small { font-size: calc(var(--card-w) * 0.24); }
  .solitaire .card .corner { top: 3px; left: 4px; }
}

/* ---------- Лото ---------- */

.loto { min-height: 100dvh; display: flex; flex-direction: column; }
.lt-barrel-row { display: flex; align-items: center; justify-content: center; gap: 24px; padding: 20px 16px 8px; flex-wrap: wrap; }
.lt-barrel {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 52px;
  color: #3b2a1a;
  background: radial-gradient(circle at 35% 30%, #fff6dc, #e6c88a 60%, #b98b35);
  box-shadow: inset 0 -6px 12px rgba(0, 0, 0, 0.18), var(--shadow);
}
.lt-barrel.pop { animation: barrel-pop 0.35s cubic-bezier(.2, .8, .3, 1.4); }
@keyframes barrel-pop { from { transform: translateY(-40px) scale(0.6) rotate(-30deg); opacity: 0; } }
.lt-barrel-info { display: flex; flex-direction: column; gap: 10px; min-width: 240px; }
.lt-call { font-family: var(--font-display); font-size: 22px; min-height: 1.3em; }
.lt-recent { display: flex; gap: 6px; flex-wrap: wrap; min-height: 32px; }
.lt-ball {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  color: #3b2a1a;
  background: radial-gradient(circle at 35% 30%, #fff6dc, #d9bb7e);
  opacity: 0.8;
}
.lt-mine { padding: 12px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.lt-mine-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: center; }
.lt-tag { flex-direction: row; gap: 10px; padding: 6px 14px; min-width: 0; }
.lt-cards { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.lt-card {
  --cell: min(44px, calc((100vw - 48px) / 9));
  padding: 6px;
  border-radius: 10px;
  background: linear-gradient(160deg, #fffdf8, var(--card));
  box-shadow: var(--shadow);
}
.lt-cards.small .lt-card { --cell: 24px; padding: 4px; border-radius: 6px; }
.lt-row { display: grid; grid-template-columns: repeat(9, var(--cell)); }
.lt-cell {
  height: var(--cell);
  display: grid;
  place-items: center;
  border: 1px solid #e3d9c4;
  color: #1d1d1f;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: calc(var(--cell) * 0.45);
  position: relative;
}
.lt-cell.blank { background: repeating-linear-gradient(45deg, #efe6d2 0 3px, #f7f1e3 3px 7px); }
.lt-cell[data-n] { cursor: pointer; }
.lt-cell.covered::after {
  content: "";
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #d4505b, var(--back-a));
  opacity: 0.6;
}
.lt-setup { max-width: 480px; margin: 32px auto; padding: 0 16px; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.lt-setup-list { width: 100%; text-align: left; }
.lt-others { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; padding: 12px 16px 32px; }
.lt-other { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.lt-row.paid { box-shadow: inset 0 0 0 2px var(--gold-deep); } /* за эту верхнюю строку уже доплатили */
.lt-tag .score { color: var(--ok); font-size: 18px; }
.lt-tag .score.minus { color: var(--danger); }
.lt-round-note { padding: 8px 14px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--gold); }

@media (max-width: 640px) {
  .lt-barrel { width: 84px; height: 84px; font-size: 38px; }
  .lt-barrel-row { gap: 14px; padding-top: 12px; }
  .lt-call { font-size: 18px; }
  .lt-cards.small .lt-card { --cell: 16px; }
}

/* ---------- «Деберц» ---------- */

.deberts {
  height: 100dvh;
  display: grid;
  grid-template-columns: 100%;
  grid-template-rows: auto auto 1fr auto;
  grid-template-areas: "hud" "opp" "center" "me";
  overflow: hidden;
}
.deberts .opponents { grid-area: opp; }
.deberts .seat-me { grid-area: me; }
.db-center { grid-area: center; position: relative; display: flex; align-items: center; justify-content: center; gap: 36px; padding: 36px 16px 32px; min-height: 0; }
.db-center .center-note { top: 4px; }
.db-shown { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; }
.db-trick { display: flex; gap: 14px; min-height: calc(var(--card-h) + 22px); align-items: flex-start; transition: transform 0.45s ease-in, opacity 0.45s ease-in; }
.db-trick.collect-me { transform: translateY(30vh) scale(0.6); opacity: 0; }
.db-trick.collect-opp { transform: translateY(-30vh) scale(0.6); opacity: 0; }
.db-play { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 13px; }
.db-combos { position: absolute; bottom: 4px; left: 0; right: 0; justify-content: center; }
.deberts .hand .card {
  margin-left: min(calc(var(--card-w) * -0.32), calc((100vw - 40px - var(--card-w)) / max(var(--count) - 1, 1) - var(--card-w)));
}
.deberts .hand .card:first-child { margin-left: 0; }

@media (max-width: 640px) {
  .db-center { flex-direction: column; gap: 10px; padding-top: 28px; }
  .deberts .opponent .backs { display: none; }
  .db-trick { gap: 6px; }
}

/* ---------- «Преферанс» ---------- */

.preferans {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 100%;
  grid-template-rows: auto auto 1fr auto;
  grid-template-areas: "hud" "opp" "center" "me";
}
.preferans .opponents { grid-area: opp; }
.preferans .seat-me { grid-area: me; }
.pf-center { grid-area: center; position: relative; display: flex; align-items: center; justify-content: center; gap: 32px; padding: 36px 16px 16px; min-height: 0; }
.pf-center .center-note { top: 4px; }
.pf-prikup { display: flex; gap: 6px; align-items: center; }
.pf-open { display: flex; flex-wrap: wrap; justify-content: center; max-width: 340px; }
.pf-open .card + .card { margin-left: -18px; }
.pf-open .card.playable { cursor: pointer; }
.pf-open .card.playable:hover { transform: translateY(-6px); }
.opponent.controlled .player-tag { border-color: var(--gold); }
.pf-grid { display: flex; flex-direction: column; gap: 4px; }
.pf-row { display: flex; gap: 4px; }
.pf-row .btn { min-width: 56px; padding: 4px 8px; }
.pf-sheet td, .pf-sheet th { text-align: center; }
.pf-entries { margin: 0 0 8px; padding-left: 20px; }
.pf-entries .card { display: inline-block; vertical-align: middle; }
.preferans .hand .card {
  margin-left: min(calc(var(--card-w) * -0.32), calc((100vw - 40px - var(--card-w)) / max(var(--count) - 1, 1) - var(--card-w)));
}
.preferans .hand .card:first-child { margin-left: 0; }
.preferans .controls { flex-direction: column; }

@media (max-width: 640px) {
  .pf-center { flex-direction: column; gap: 10px; padding-top: 28px; }
  .pf-row .btn { min-width: 0; flex: 1; padding: 4px; font-size: 13px; }
  .pf-open { max-width: 170px; }
}

/* ---------- «Чапаев» ---------- */

.cp-board {
  --size: min(92vw, calc(100dvh - 290px), 600px);
  position: relative;
  width: var(--size);
  height: var(--size);
  border: 6px solid #3b2a1a;
  border-radius: 6px;
  box-shadow: var(--shadow);
  background: conic-gradient(#e8d9b5 0 25%, #8b5a34 0 50%, #e8d9b5 0 75%, #8b5a34 0) 0 0 / 25% 25%;
  touch-action: none;
  overflow: visible;
}
.cp-piece {
  position: absolute;
  width: var(--r);
  height: var(--r);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: opacity 0.35s, transform 0.35s;
}
.cp-piece.w { background: radial-gradient(circle at 35% 30%, #fffdf8, #ece4d2 55%, #c9bea6); box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.55), 0 3px 5px rgba(0, 0, 0, 0.45); }
.cp-piece.b { background: radial-gradient(circle at 35% 30%, #b8404b, var(--back-a) 55%, var(--back-b)); box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.12), 0 3px 5px rgba(0, 0, 0, 0.45); }
.cp-piece.movable { cursor: grab; box-shadow: 0 0 0 3px rgba(224, 184, 102, 0.75), 0 3px 5px rgba(0, 0, 0, 0.45); }
.cp-piece.gone { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
.cp-aim { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.cp-aim line { stroke: var(--gold); stroke-width: 0.8; stroke-dasharray: 2 1.5; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.cp-aim line { stroke-width: 3; }
.cp-power {
  position: absolute;
  transform: translate(-50%, -190%);
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--ink);
  color: #1d1d1f;
  font-weight: 800;
  font-size: 13px;
  pointer-events: none;
}

/* ---------- Приложение (PWA) ---------- */

.offline-banner {
  position: fixed;
  left: 50%;
  top: calc(8px + env(safe-area-inset-top));
  transform: translateX(-50%);
  z-index: 90;
  padding: 8px 16px;
  border-radius: 999px;
  background: #2a1714;
  border: 1px solid rgba(255, 138, 122, 0.4);
  font-size: 14px;
  box-shadow: var(--shadow);
}
.offline-banner[hidden] { display: none; }
@media (display-mode: standalone) {
  /* Установленное приложение: отступ под вырез экрана. */
  body { padding-top: env(safe-area-inset-top); }
}
.row-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
