/* ==========================================================================
   UNO ONLINE — design tokens
   Палитра рождена из фетра карточного стола + 4 базовых цвета колоды.
   Unbounded — заголовки/крупные цифры, Manrope — интерфейс, JetBrains Mono — данные.
   ========================================================================== */

:root {
  --ink: #14121A;
  --ink-soft: #1B1826;
  --panel: #211D2C;
  --felt-1: #234a37;
  --felt-2: #122419;

  --paper: #F5EFE0;
  --muted: #ACA6BA;
  --line: rgba(245, 239, 224, 0.12);
  --line-strong: rgba(245, 239, 224, 0.22);

  --red: #E4483C;
  --red-deep: #A82E22;
  --yellow: #F2B705;
  --yellow-deep: #A9790B;
  --green: #2FA84F;
  --green-deep: #1D7038;
  --blue: #2B6CE4;
  --blue-deep: #1D4CA8;
  --black-card: #221E2C;

  --font-display: 'Unbounded', system-ui, sans-serif;
  --font-body: 'Manrope', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --radius-lg: 24px;
  --radius-md: 14px;
  --radius-sm: 8px;
  --shadow-deep: 0 20px 50px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

/* Плавные переходы между состояниями стола (перелёт карты в сброс, уплотнение веера руки,
   перемещение подсветки хода между соперниками) — работает через нативный View Transitions API,
   для каждого элемента задаётся свой view-transition-name прямо в JS. */
::view-transition-group(*) {
  animation-duration: 0.32s;
  animation-timing-function: cubic-bezier(.22,.72,.2,1);
}
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*) { animation: none !important; }
}

html, body {
  height: 100%;
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input { font-family: inherit; }
button { cursor: pointer; }
input:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 2px;
}

/* Атмосферный фон стола: радиальный фетр + лёгкая виньетка */
.felt-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  /* Штриховка — обычный слой фона, а не отдельный элемент с mix-blend-mode:
     полноэкранный блендинг выбивал всю страницу с быстрого пути композитинга. */
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.007) 0 2px, transparent 2px 26px),
    radial-gradient(120% 90% at 50% -10%, rgba(255,255,255,0.06), transparent 55%),
    radial-gradient(140% 120% at 50% 110%, var(--felt-2), var(--ink) 70%),
    linear-gradient(160deg, var(--felt-1), var(--felt-2) 60%);
}

/* ==========================================================================
   Экраны
   ========================================================================== */

.screen {
  position: relative;
  z-index: 1;
  height: 100dvh;
  width: 100%;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.screen.active { display: flex; }

@keyframes dealIn {
  from { opacity: 0; transform: translateY(28px) rotate(-1.5deg) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) rotate(0) scale(1); }
}
.deal-in { animation: dealIn 0.55s cubic-bezier(.2,.8,.2,1) both; }

@media (prefers-reduced-motion: reduce) {
  .deal-in { animation: none; }
  * { scroll-behavior: auto !important; }
}

.field-label {
  display: block;
  font-size: 12px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 700;
}

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

.hud-tools {
  position: fixed;
  top: 14px; right: 14px;
  z-index: 95;
  display: flex;
  gap: 8px;
}
.hud-btn {
  position: relative;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: rgba(14, 12, 18, 0.82);
  border: 1px solid var(--line-strong);
  color: var(--paper);
  font-size: 17px;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease;
}
.hud-btn:hover { transform: scale(1.08); background: rgba(24, 21, 30, 0.95); }
.hud-btn.is-muted { color: var(--muted); }
.hud-btn-exit:hover { background: rgba(228, 72, 60, 0.55); }

/* Кнопка UNO в режиме рулетки: выскакивает в присланной сервером точке — каждое
   окно в новом месте. Своя пара кадров нужна потому, что обычная пульсация задаёт
   transform целиком и стёрла бы сдвиг к центру точки. */
#btn-uno.roaming {
  position: fixed;
  margin: 0;
  transform: translate(-50%, -50%);
  z-index: 58;
  animation: unoPulseRoam 1.1s ease-in-out infinite;
  box-shadow: 0 10px 28px rgba(0,0,0,0.55), 0 0 22px rgba(242,183,5,0.45);
}
#btn-uno.roaming.urgent {
  animation: unoPopRoam 0.24s cubic-bezier(.2,.9,.3,1.5) both, unoPulseRoam 1.1s ease-in-out 0.24s infinite;
}
#btn-uno.roaming.pressed { animation: none; transform: translate(-50%, -50%); }
#btn-uno.roaming:hover { transform: translate(-50%, -50%) scale(1.06); }
@keyframes unoPulseRoam {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.07); }
}
@keyframes unoPopRoam {
  from { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  to   { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  #btn-uno.roaming, #btn-uno.roaming.urgent { animation: none; }
}
/* Кнопки лога и чата нужны только за столом */
.hud-tools .game-only { display: none; }
body.in-game .hud-tools .game-only { display: flex; }

.hud-badge {
  position: absolute;
  top: -3px; right: -3px;
  min-width: 17px; height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--red);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--ink);
}
.hud-badge[hidden] { display: none; }

/* ==========================================================================
   Индикатор направления хода
   ========================================================================== */

.direction-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(0,0,0,0.22);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.direction-arrow-spin { display: inline-block; }
.direction-arrow { display: inline-block; font-size: 15px; color: var(--yellow); }
.direction-arrow.flash { animation: dirFlash 0.55s ease; }
@keyframes dirFlash {
  0% { transform: scale(1); }
  40% { transform: scale(1.6) rotate(180deg); color: var(--red); }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .direction-arrow.flash { animation: none; }
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 13px 22px;
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.01em;
  transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
  color: var(--paper);
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.08); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; filter: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--red), var(--red-deep));
  box-shadow: 0 10px 24px rgba(228, 72, 60, 0.35);
}
.btn-secondary {
  background: linear-gradient(135deg, var(--blue), var(--blue-deep));
  box-shadow: 0 10px 24px rgba(43, 108, 228, 0.35);
}
.btn-ghost {
  background: rgba(245,239,224,0.08);
  border: 1px solid var(--line-strong);
}
.btn-small { padding: 9px 14px; font-size: 13px; }
.btn-uno {
  background: linear-gradient(135deg, var(--yellow), var(--red));
  font-family: var(--font-display);
  font-size: 18px;
  padding: 14px 26px;
  animation: unoPulse 1.1s ease-in-out infinite;
  box-shadow: 0 0 22px rgba(242,183,5,0.45);
}
@keyframes unoPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}
@media (prefers-reduced-motion: reduce) { .btn-uno { animation: none; } }
/* Кнопка возникает мгновенно в момент, когда осталась одна карта, — даём ей заметное появление */
.btn-uno.urgent {
  animation: unoPop 0.24s cubic-bezier(.2,.9,.3,1.5) both, unoPulse 1.1s ease-in-out 0.24s infinite;
}
@keyframes unoPop {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { .btn-uno.urgent { animation: none; } }

.btn-uno.pressed {
  animation: none;
  background: linear-gradient(135deg, var(--green), var(--green-deep));
  box-shadow: 0 0 16px rgba(47,168,79,0.55);
}

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

.entry-card {
  width: min(440px, 100%);
  background: linear-gradient(165deg, var(--panel), var(--ink-soft));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-deep);
}

.logo {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 34px;
  margin: 0 0 6px;
  letter-spacing: 0.01em;
  background: linear-gradient(90deg, var(--red), var(--yellow), var(--green), var(--blue));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.logo-dot { color: var(--paper); -webkit-text-fill-color: var(--paper); }

.tagline { color: var(--muted); margin: 0 0 26px; font-size: 14.5px; line-height: 1.5; }

.field { display: block; margin-bottom: 20px; }
.field input[type="text"] {
  width: 100%;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  color: var(--paper);
  font-size: 15px;
}
.field input::placeholder { color: #6f6a7f; }

.avatar-picker { display: flex; flex-wrap: wrap; gap: 10px; }
.avatar-swatch {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.avatar-swatch:hover { transform: scale(1.1); }
.avatar-swatch.selected { border-color: var(--paper); transform: scale(1.14); }

.entry-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.join-row { display: flex; gap: 10px; }
.code-input {
  width: 96px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-family: var(--font-mono);
  font-weight: 700;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--paper);
  padding: 0 10px;
}
.join-row .btn { flex: 1; }

.entry-error {
  margin: 16px 0 0;
  color: var(--yellow);
  font-size: 13.5px;
  font-weight: 700;
  text-align: center;
}

/* ==========================================================================
   Лобби / комната ожидания
   ========================================================================== */

.lobby-wrap {
  width: min(720px, 100%);
  max-height: 92dvh;
  background: linear-gradient(165deg, var(--panel), var(--ink-soft));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-deep);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.lobby-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 26px;
  border-bottom: 1px solid var(--line);
}
.room-code {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 30px;
  letter-spacing: 0.16em;
  color: var(--yellow);
}

.lobby-body {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 0;
  min-height: 260px;
  max-height: 52dvh;
}

.player-list {
  padding: 18px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-right: 1px solid var(--line);
}

.player-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(245,239,224,0.04);
}
.dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.player-name { font-weight: 700; flex: 1; }
.crown { font-size: 13px; }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: #4dd06b; }
.conn-dot.off { background: #6b6578; }

/* Лог событий и чат разнесены: у каждого свой заголовок и своя лента */
.lobby-panels {
  display: grid;
  grid-template-rows: 1fr 1fr;
  min-height: 0;
}
.feed-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-bottom: 1px solid var(--line);
}
.feed-panel:last-child { border-bottom: none; }
.feed-title {
  margin: 0;
  padding: 10px 18px 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.log-feed {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.log-feed .log-line b { color: var(--paper); }

.chat-feed {
  flex: 1;
  overflow-y: auto;
  padding: 10px 18px 14px;
  font-size: 13.5px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-line {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: baseline;
  gap: 7px;
}
.chat-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  align-self: center;
}
.chat-author { font-weight: 800; font-size: 12.5px; color: var(--paper); }
.chat-text { color: var(--muted); overflow-wrap: anywhere; }
.chat-feed:empty::after {
  content: 'Пока тихо. Напишите первым.';
  color: #6f6a7f;
  font-size: 12.5px;
}

.chat-form { display: flex; border-top: 1px solid var(--line); }
.chat-form input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--paper);
  padding: 12px 14px;
  font-size: 13.5px;
}
.chat-form input::placeholder { color: #6f6a7f; }
.chat-form button { border-radius: 0; background: transparent; color: var(--yellow); font-size: 17px; padding: 0 16px; }

.lobby-footer {
  padding: 18px 26px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-top: 1px solid var(--line);
}
.lobby-hint { flex: 1; margin: 0; color: var(--muted); font-size: 13.5px; }

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

#screen-game { padding: 0; }
.table-wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.game-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  padding-right: 268px; /* место под фиксированный ряд кнопок справа */
}
.room-pill {
  font-size: 12.5px;
  color: var(--muted);
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--line);
  padding: 7px 12px;
  border-radius: 999px;
}
.room-pill b { color: var(--paper); font-family: var(--font-mono); letter-spacing: 0.08em; }
/* ==========================================================================
   Чей сейчас ход — отдельная заметная строка, а не подпись в углу
   ========================================================================== */

.turn-banner {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0 auto 4px;
  padding: 8px 20px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.34);
  border: 1px solid var(--line);
  font-weight: 800;
  font-size: 15px;
  color: var(--muted);
  transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}
.turn-who b { color: var(--paper); }
.turn-dot {
  width: 13px; height: 13px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.35);
}
.turn-banner.my-turn {
  color: var(--ink);
  background: linear-gradient(135deg, var(--yellow), #FFD87A);
  border-color: transparent;
  box-shadow: 0 6px 22px rgba(242, 183, 5, 0.45);
}
.turn-you { font-family: var(--font-display); font-size: 16px; letter-spacing: 0.02em; }
.turn-pulse {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--ink);
  animation: turnPulse 1.1s ease-in-out infinite;
}
@keyframes turnPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.5); opacity: 0.45; }
}

/* На своём ходу подсвечиваем края стола — видно даже боковым зрением */
body.my-turn .table-wrap::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  border-radius: 18px;
  box-shadow: inset 0 0 0 2px rgba(242, 183, 5, 0.5), inset 0 0 42px rgba(242, 183, 5, 0.16);
  opacity: 0.85;
}
@media (prefers-reduced-motion: reduce) {
  .turn-pulse { animation: none; }
}

/* Подпись «ходит» у места активного соперника */
.seat-turn-tag {
  position: absolute;
  top: -7px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--yellow);
  color: var(--ink);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: 0 3px 10px rgba(0,0,0,0.45);
}

/* Игроки сидят по кругу: колода и сброс в центре, места расставлены по эллипсу.
   Координаты каждого места считает JS — так порядок хода читается по кругу. */
/* Кольцо лампочек вокруг центра: показывает, в какую сторону идёт ход. Личная
   настройка игрока, комнату не трогает. */
/* Круг, а не овал: размер берём от высоты стола и держим соотношение 1:1, иначе
   кольцо растягивается по ширине экрана. Точки приглушённые — подсказка, а не
   светомузыка: подсвечивается одна, остальные едва видны. */
.dir-lights {
  position: absolute;
  left: 50%; top: 50%;
  height: min(78%, 340px);
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 1;
}
.dir-light {
  position: absolute;
  width: 6px; height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.16;
  animation: dirChase 3s linear infinite;
}
@keyframes dirChase {
  0%   { opacity: 0.16; transform: scale(1); }
  6%   { opacity: 0.7;  transform: scale(1.45); }
  20%  { opacity: 0.16; transform: scale(1); }
  100% { opacity: 0.16; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) { .dir-light { animation: none; opacity: 0.22; } }

.table-ring {
  position: relative;
  flex: 1;
  min-height: 320px;
  margin: 2px 6px 0;
}
.opponents-arc {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Место соперника: сверху веер его карт рубашкой вверх, снизу подпись */
.opp-seat {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  width: max-content;
  max-width: 168px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 5px 8px 7px;
  border-radius: 20px;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
.opp-seat.active-turn {
  background: rgba(242,183,5,0.09);
  box-shadow: 0 0 0 1px rgba(242,183,5,0.45), 0 0 24px rgba(242,183,5,0.18);
}
.opp-seat.disconnected { opacity: 0.45; }

.opp-fan {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 72px;
  padding-top: 8px;
}
.opp-fan .card-mini {
  transform: rotate(var(--rot, 0deg)) translateY(var(--lift, 0px));
  transform-origin: bottom center;
}
.opp-fan .card-mini.last-card {
  border-color: var(--yellow);
  box-shadow: 0 0 12px rgba(242,183,5,0.65);
}
.opp-fan-extra {
  align-self: center;
  margin-left: 7px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.opp-fan-empty {
  align-self: center;
  font-size: 11.5px;
  color: #6f6a7f;
}

.opp-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px 6px 6px;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.opp-seat.active-turn .opp-chip { border-color: var(--yellow); }
.opp-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: 12px;
  color: rgba(0,0,0,0.55);
  flex-shrink: 0;
}
.opp-meta { display: flex; flex-direction: column; line-height: 1.25; }
.opp-name { font-size: 12.5px; font-weight: 800; display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.opp-count { white-space: nowrap; }
.opp-count { font-size: 11px; color: var(--muted); font-family: var(--font-mono); }
.opp-flag { font-size: 10px; color: var(--yellow); font-weight: 800; }
.opp-flag.said { color: var(--green); }

/* Кнопка появляется только когда истекла секундная фора на выкрик UNO */
.btn-catch {
  border: none;
  background: var(--red);
  color: var(--paper);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.2px;
  border-radius: 999px;
  padding: 9px 18px;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0,0,0,0.5), 0 0 0 2px rgba(228,72,60,0.35);
  z-index: 6;
}
/* Обычный режим: кнопка стоит сбоку от места, а не под подписью — так её видно
   и не спутать с чипом игрока. Сторону выбирает JS: у правых мест — влево. */
.btn-catch:not(.roaming) {
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-left: 6px;
}
.opp-seat.catch-left .btn-catch:not(.roaming) {
  left: auto;
  right: 100%;
  margin-left: 0;
  margin-right: 6px;
}
.opponents-arc.compact .btn-catch:not(.roaming) { font-size: 12px; padding: 7px 13px; }
/* Кнопка живёт в разметке постоянно и просто скрывается, поэтому анимацию
   появления вешаем на отдельный класс — иначе она проигралась бы один раз.
   Сдвиг к центру приходится повторять в кадрах: transform задаётся целиком. */
.btn-catch:not(.roaming).pop { animation: catchPop 0.22s cubic-bezier(.2,.9,.3,1.4) both; }
.btn-catch[hidden] { display: none; }
@keyframes catchPop {
  from { transform: translateY(-50%) scale(0.6); opacity: 0; }
  to   { transform: translateY(-50%) scale(1); opacity: 1; }
}

/* Рулетка: ловля выскакивает в той же точке, что и кнопка «UNO!» у владельца
   карты. Место одно для всех, фора у него — полсекунды. */
.btn-catch.roaming {
  position: fixed;
  right: auto;
  margin: 0;
  transform: translate(-50%, -50%);
  z-index: 58;
  font-size: 16px;
  padding: 12px 24px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.55), 0 0 0 3px rgba(228,72,60,0.45);
}
.btn-catch.roaming:hover { transform: translate(-50%, -50%) scale(1.06); }
.btn-catch.roaming.pop { animation: catchPopRoam 0.22s cubic-bezier(.2,.9,.3,1.4) both; }
@keyframes catchPopRoam {
  from { transform: translate(-50%, -50%) scale(0.6); opacity: 0; }
  to   { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .btn-catch.pop, .btn-catch.roaming.pop { animation: none; }
}

.table-center {
  position: absolute;
  left: 50%;
  top: 52%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* Сброс должен лежать чуть левее середины стола, поэтому смещаем пару «колода —
   сброс» так, чтобы по центру оказалась не она целиком, а промежуток правее сброса. */
/* По центру стола лежит сброс, а колода стоит слева от него: пара сдвинута ровно
   на половину своей ширины плюс промежуток. */
.pile-group { display: flex; align-items: center; gap: 26px; transform: translateX(-59px); }

.bot-tag {
  font-size: 10px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 1px 6px;
}
.bot-kick {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 6px;
}
.bot-kick:hover { color: var(--red); background: rgba(228,72,60,0.14); }

.pile { position: relative; }
/* Когда с колоды берут не карту, а штраф, она подсвечивается красным */
#pile-draw.penalty .card-back {
  box-shadow: 0 0 0 3px var(--red), 0 0 24px rgba(228, 72, 60, 0.65);
  border-radius: 10px;
}

.draw-pile {
  border: none;
  background: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.card-back {
  width: 92px; height: 132px;
  border-radius: 10px;
  background:
    radial-gradient(60% 60% at 50% 50%, rgba(255,255,255,0.10), transparent 60%),
    linear-gradient(135deg, var(--red), var(--blue) 50%, var(--green));
  border: 3px solid var(--paper);
  box-shadow: 0 10px 22px rgba(0,0,0,0.4), 0 0 0 3px rgba(0,0,0,0.25) inset;
  position: relative;
}
.card-back::after {
  content: '';
  position: absolute; inset: 10px;
  border: 2px solid rgba(245,239,224,0.55);
  border-radius: 8px;
  transform: rotate(-18deg);
}
.draw-pile:hover .card-back { transform: translateY(-3px); }
.draw-pile.disabled .card-back { opacity: 0.5; }
.pile-count { font-family: var(--font-mono); font-weight: 700; font-size: 13px; color: var(--muted); }

.discard-pile { width: 92px; height: 132px; position: relative; }
/* Место каждой карты в сбросе задаёт JS и больше не меняет: карта, однажды
   положенная, лежит неподвижно, пока её место не займёт новая. */
.discard-pile .card { position: absolute; inset: 0; }

/* Код настроек: одна строка на всю ширину, кнопки не переносятся по одной */
.rules-code {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 14px;
}
.rules-code-row { display: flex; gap: 8px; flex-wrap: wrap; }
#rules-code-input {
  flex: 1 1 160px;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 15px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: rgba(0,0,0,0.28);
  color: var(--paper);
}
#rules-code-input:focus { outline: none; border-color: var(--blue); }
.rules-code-hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.rules-code-hint.bad { color: var(--red); }
.rules-code-hint.good { color: var(--green); }

.pending-banner {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--yellow);
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--line-strong);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
}

.action-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding-bottom: 6px;
}

.hand-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 14px;
}
.hand-bar[hidden] { display: none; }
.hand-count {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
}
.spectator-note {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.spectator-note[hidden] { display: none; }
body.spectating .my-hand { min-height: 0; }

/* overflow-x:auto заставляет браузер обрезать и по вертикали (overflow-y становится auto),
   поэтому запас под приподнятую карту даём именно внутренним отступом сверху. */
.my-hand-wrap {
  /* нижний отступ поднимает веер над всплывающими уведомлениями (они внизу по центру) */
  padding: 46px 10px 66px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}
.my-hand {
  display: flex;
  justify-content: center;
  min-height: 152px;
  padding: 0 20px;
}

/* Тянуть мышью по столу и выделять цифры как текст не нужно — это не документ.
   Ввод и переписку оставляем выделяемыми: оттуда текст копируют. */
body {
  -webkit-user-select: none;
  user-select: none;
}
input, textarea, .chat-line, .log-line, .rules-code-hint, #rules-code-input {
  -webkit-user-select: text;
  user-select: text;
}

/* ---------- Игральная карта ---------- */

.card {
  width: 92px; height: 132px;
  border-radius: 10px;
  border: 3px solid var(--paper);
  flex-shrink: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 16px rgba(0,0,0,0.4);
  transition: transform 0.18s ease, box-shadow 0.18s ease, margin 0.18s ease;
}
.my-hand .card {
  margin-left: -38px;
  transform: rotate(var(--rot, 0deg)) translateY(var(--lift, 0px));
  transform-origin: bottom center;
}
.my-hand .card:first-child { margin-left: 0; }
.my-hand .card.playable { cursor: pointer; }
.my-hand .card.playable:hover {
  transform: rotate(var(--rot, 0deg)) translateY(calc(var(--lift, 0px) - 22px)) scale(1.06);
  z-index: 5;
  box-shadow: 0 16px 28px rgba(0,0,0,0.55);
}
.my-hand .card.unplayable { filter: saturate(0.55) brightness(0.72); }

.card-red    { background: linear-gradient(160deg, var(--red), var(--red-deep)); color: var(--red); }
.card-yellow { background: linear-gradient(160deg, var(--yellow), var(--yellow-deep)); color: var(--yellow); }
.card-green  { background: linear-gradient(160deg, var(--green), var(--green-deep)); color: var(--green); }
.card-blue   { background: linear-gradient(160deg, var(--blue), var(--blue-deep)); color: var(--blue); }
.card-black  { background: linear-gradient(160deg, #38324a, var(--black-card)); color: var(--paper); }

.card-oval {
  width: 70%; height: 77%;
  background: var(--paper);
  border-radius: 50%;
  transform: rotate(-20deg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-symbol {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 32px;
  transform: rotate(20deg);
  line-height: 1;
}
.card-black .card-oval { background: linear-gradient(135deg, var(--red), var(--yellow), var(--green), var(--blue)); }
/* После выбора цвета центр чёрной карты закрашивается в него — видно, чем ходить */
.card-oval.wild-picked {
  box-shadow: inset 0 0 0 3px rgba(255,255,255,0.85), 0 0 14px rgba(0,0,0,0.35);
  animation: wildFill 0.34s ease-out both;
}
.card.wild-colored {
  box-shadow: 0 8px 16px rgba(0,0,0,0.4), 0 0 0 3px var(--picked, transparent), 0 0 22px var(--picked, transparent);
}
@keyframes wildFill {
  from { transform: rotate(-20deg) scale(0.72); opacity: 0.4; }
  to   { transform: rotate(-20deg) scale(1); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { .card-oval.wild-picked { animation: none; } }
.card-black .card-symbol { color: var(--paper); font-size: 15px; text-align: center; }

/* Угловая цифра лежит поверх овала и всегда читается: свой слой + тёмная обводка */
.card-corner {
  position: absolute;
  top: 5px; left: 7px;
  z-index: 2;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  line-height: 1;
  color: var(--paper);
  text-shadow: 0 1px 2px rgba(0,0,0,0.75), 0 0 4px rgba(0,0,0,0.55);
}
.card-corner-flip {
  top: auto; left: auto;
  bottom: 5px; right: 7px;
  transform: rotate(180deg);
}
.card-mini .card-corner { display: none; }

/* ---------- Рубашка карты (соперники, колода, летящие карты) ---------- */

.card-face-down {
  background:
    radial-gradient(60% 60% at 50% 50%, rgba(255,255,255,0.10), transparent 60%),
    linear-gradient(135deg, var(--red), var(--blue) 50%, var(--green));
  box-shadow: 0 6px 16px rgba(0,0,0,0.42);
}
.card-back-art {
  position: absolute;
  inset: 13%;
  border: 2px solid rgba(245,239,224,0.55);
  border-radius: 6px;
  transform: rotate(-18deg);
}
.card-mini {
  width: 46px; height: 66px;
  border-width: 2px;
  border-radius: 7px;
}
.card-mini .card-back-art { border-width: 1.5px; border-radius: 4px; }
/* Компактные места: на узком экране круг иначе не помещается — имя уходит под
   фишку, веер и подписи сжимаются, но порядок хода по кругу остаётся читаемым. */
.opponents-arc.compact .opp-seat { max-width: 82px; padding: 2px 3px 4px; }
.opponents-arc.compact .opp-chip {
  flex-direction: column;
  gap: 1px;
  padding: 3px 6px 4px;
  border-radius: 13px;
}
.opponents-arc.compact .opp-meta { align-items: center; text-align: center; }
.opponents-arc.compact .opp-avatar { width: 22px; height: 22px; font-size: 9px; }
.opponents-arc.compact .opp-name {
  font-size: 10px;
  max-width: 66px;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}
.opponents-arc.compact .opp-count { font-size: 9px; white-space: nowrap; }
.opponents-arc.compact .opp-chip { max-width: 82px; }
.opponents-arc.compact .crown { display: none; }
.opponents-arc.compact .opp-flag { font-size: 8.5px; }
.opponents-arc.compact .card-mini { width: 26px; height: 37px; border-width: 1.5px; border-radius: 5px; }
.opponents-arc.compact .opp-fan { min-height: 42px; padding-top: 2px; }
.opponents-arc.compact .seat-turn-tag { font-size: 8px; padding: 1px 6px; top: -5px; }
.opponents-arc.compact .btn-catch { font-size: 9px; padding: 3px 8px; bottom: -7px; }

.opponents-arc.crowded .card-mini { width: 34px; height: 49px; }
.opponents-arc.crowded .opp-seat { max-width: 132px; }
.opponents-arc.crowded .opp-chip { padding: 4px 9px 4px 4px; }
.opponents-arc.crowded .opp-avatar { width: 24px; height: 24px; font-size: 10px; }
.opponents-arc.crowded .opp-fan { min-height: 56px; }
.opponents-arc.crowded .opp-fan .card-mini { margin-left: -18px; }

/* ---------- Слой летящих карт ---------- */

.fly-layer {
  position: fixed;
  inset: 0;
  z-index: 55;
  pointer-events: none;
  overflow: hidden;
}
.card.in-flight {
  box-shadow: 0 18px 36px rgba(0,0,0,0.55);
  will-change: transform;
}

/* Полёт карты от руки к стопке сброса */
@keyframes cardFly {
  from { transform: translate(0,0) scale(1) rotate(0deg); opacity: 1; }
  to   { transform: translate(var(--fly-x,0), var(--fly-y,0)) scale(0.9) rotate(12deg); opacity: 0; }
}
.card.flying { animation: cardFly 0.38s ease-in forwards; z-index: 30; }
@media (prefers-reduced-motion: reduce) { .card.flying { animation: none; opacity: 0; } }

/* ---------- Боковые панели: лог событий и чат ----------
   Начинаются ниже ряда кнопок, поэтому кнопка-переключатель всегда остаётся
   доступной — панель можно закрыть и ею, и крестиком, и Esc, и кликом мимо. */

.side-panel {
  position: fixed;
  top: 66px; right: 0;
  width: min(340px, 88vw);
  height: calc(100dvh - 66px);
  background: var(--ink-soft);
  border-left: 1px solid var(--line);
  border-top: 1px solid var(--line);
  border-radius: 16px 0 0 0;
  box-shadow: -18px 0 44px rgba(0,0,0,0.5);
  z-index: 70;
  display: flex;
  flex-direction: column;
  transform: translateX(102%);
  transition: transform 0.26s cubic-bezier(.3,.8,.3,1);
}
.side-panel[hidden] { display: none; }
.side-panel.open { transform: translateX(0); }
.side-panel .log-feed,
.side-panel .chat-feed { flex: 1; }

.side-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 12px 11px 18px;
  border-bottom: 1px solid var(--line);
}
.side-panel-head h4 {
  margin: 0;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.side-close {
  width: 30px; height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(245,239,224,0.06);
  border: 1px solid var(--line);
  color: var(--paper);
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s ease;
}
.side-close:hover { background: rgba(245,239,224,0.16); }

/* ==========================================================================
   Модалки
   ========================================================================== */

.modal {
  position: fixed; inset: 0;
  z-index: 60;
  background: rgba(10, 9, 14, 0.72);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.modal[hidden] { display: none; }
/* Итог раунда показываем выше центра, чтобы карта, которой закончили партию,
   осталась на виду. Предельную высоту считает JS по реальному положению сброса:
   доли экрана тут не годятся — стол смещается вместе с размером окна. */
#modal-round-end { align-items: flex-start; padding-top: 12px; }
#modal-round-end .modal-card { overflow-y: auto; }
.modal.visible { opacity: 1; pointer-events: auto; }
.modal-card {
  width: min(420px, 100%);
  background: linear-gradient(165deg, var(--panel), var(--ink-soft));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px;
  text-align: center;
  box-shadow: var(--shadow-deep);
  position: relative;
  transform: scale(0.92) translateY(10px);
  transition: transform 0.22s cubic-bezier(.2,.8,.2,1);
}
.modal.visible .modal-card { transform: scale(1) translateY(0); }
@media (prefers-reduced-motion: reduce) {
  .modal, .modal-card { transition: none; }
}
.modal-card h3 { font-family: var(--font-display); margin: 0 0 18px; font-size: 18px; }

.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 30px; height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(245,239,224,0.08);
  color: var(--muted);
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: rgba(245,239,224,0.16); color: var(--paper); }
.modal-cancel-btn { width: 100%; margin-top: 16px; }

.color-swatches { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.swatch { height: 64px; border-radius: var(--radius-md); border: 3px solid var(--paper); }
.swatch-red { background: var(--red); }
.swatch-yellow { background: var(--yellow); }
.swatch-green { background: var(--green); }
.swatch-blue { background: var(--blue); }
.swatch:hover { transform: scale(1.04); }

.winner-name { font-family: var(--font-display); font-size: 28px; margin: 4px 0 6px; }
.winner-points { color: var(--yellow); font-weight: 800; margin: 0 0 18px; }
.breakdown-list { list-style: none; margin: 0 0 18px; padding: 0; text-align: left; }
.breakdown-list li {
  display: flex; justify-content: space-between;
  padding: 7px 0; border-bottom: 1px solid var(--line);
  font-size: 14px; color: var(--muted);
}
.scoreboard { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.score-row { display: flex; justify-content: space-between; font-size: 13.5px; }
.score-row b { font-family: var(--font-mono); color: var(--paper); }

/* ==========================================================================
   Тосты
   ========================================================================== */

.toast-stack {
  position: fixed;
  /* ниже нижней кромки веера: рука поднята, и уведомления её больше не закрывают */
  bottom: 8px; left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
  width: min(360px, 90vw);
}
.toast {
  background: var(--ink-soft);
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--yellow);
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  box-shadow: var(--shadow-deep);
  animation: toastIn 0.25s ease both;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity 0.2s ease, transform 0.2s ease; }

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


/* ==========================================================================
   Правила комнаты, выход из партии, обмен руками
   ========================================================================== */

.lobby-header-actions { display: flex; gap: 8px; flex-shrink: 0; }
.lobby-footer-info { flex: 1; min-width: 0; }
.rules-summary {
  margin: 5px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.rule-chip {
  font-size: 11px;
  font-weight: 700;
  color: var(--yellow);
  background: rgba(242, 183, 5, 0.12);
  border: 1px solid rgba(242, 183, 5, 0.3);
  border-radius: 999px;
  padding: 3px 9px;
}
.rule-chip.muted {
  color: var(--muted);
  background: rgba(245, 239, 224, 0.05);
  border-color: var(--line);
}

.rules-card { width: min(560px, 100%); max-height: 88dvh; display: flex; flex-direction: column; }
.rules-note { margin: 0 0 14px; font-size: 12.5px; color: var(--muted); line-height: 1.45; text-align: left; }
.rules-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 -6px;
  padding: 0 6px;
}
.rule-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--line);
}
.rule-row:last-child { border-bottom: none; }
.rule-row.readonly { opacity: 0.72; }
.rule-text { flex: 1; min-width: 0; text-align: left; }
.rule-title { font-weight: 800; font-size: 13.5px; margin-bottom: 3px; }
.rule-desc { font-size: 12px; color: var(--muted); line-height: 1.45; }

.rule-switch {
  flex-shrink: 0;
  width: 46px; height: 26px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(0,0,0,0.35);
  padding: 2px;
  display: flex;
  transition: background 0.18s ease, border-color 0.18s ease;
}
.rule-switch .rule-knob {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.18s cubic-bezier(.3,.8,.3,1), background 0.18s ease;
}
.rule-switch.on { background: rgba(47, 168, 79, 0.4); border-color: var(--green); }
.rule-switch.on .rule-knob { transform: translateX(20px); background: var(--paper); }
.rule-switch:disabled { cursor: default; }

.rule-choice { display: flex; gap: 5px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; max-width: 190px; }
.rule-opt {
  border: 1px solid var(--line-strong);
  background: rgba(0,0,0,0.3);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.rule-opt.selected { background: var(--yellow); border-color: var(--yellow); color: var(--ink); }
.rule-opt:disabled { cursor: default; }
.rules-actions { display: flex; justify-content: flex-end; padding-top: 14px; }

.exit-hint { margin: 0 0 18px; font-size: 13px; color: var(--muted); line-height: 1.5; text-align: left; }
.exit-actions { display: flex; flex-direction: column; gap: 10px; }

.swap-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.swap-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(245, 239, 224, 0.05);
  color: var(--paper);
  font-size: 13.5px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.swap-option:hover { background: rgba(245, 239, 224, 0.12); border-color: var(--line-strong); }
.swap-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.swap-name { flex: 1; text-align: left; font-weight: 700; }
.swap-count { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }


/* ==========================================================================
   Врывание и выбор дублей
   ========================================================================== */

/* Карта, которой можно врезаться вне очереди, светится отдельно от обычных ходов */
.my-hand .card.jump-in {
  box-shadow: 0 8px 16px rgba(0,0,0,0.4), 0 0 0 3px var(--yellow), 0 0 22px rgba(242,183,5,0.6);
}

.multi-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  max-height: 44dvh;
  overflow-y: auto;
}
.multi-option {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(245, 239, 224, 0.04);
  color: var(--paper);
  font-size: 13.5px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.multi-option:hover { background: rgba(245, 239, 224, 0.1); }
.multi-option.selected { border-color: var(--yellow); background: rgba(242, 183, 5, 0.12); }
.multi-option.locked { cursor: default; opacity: 0.9; }
.multi-card {
  width: 30px; height: 43px;
  border-width: 2px;
  border-radius: 6px;
  flex-shrink: 0;
  box-shadow: none;
}
.multi-face {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 14px;
  color: var(--paper);
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.multi-name { flex: 1; text-align: left; font-weight: 700; }
.multi-mark { color: var(--yellow); font-weight: 800; width: 14px; }

@media (max-width: 640px) {
  .lobby-body { grid-template-columns: 1fr; }
  .player-list { border-right: none; border-bottom: 1px solid var(--line); max-height: 160px; }
  .entry-card, .lobby-wrap { padding: 24px 20px; }
  .card { width: 62px; height: 90px; }
  .card-back, .discard-pile { width: 62px; height: 90px; }
  .card-symbol { font-size: 21px; }
  .my-hand .card { margin-left: -24px; }
  .logo { font-size: 26px; }

  /* На телефоне ряд кнопок ужимаем, иначе он съедает всю верхнюю строку */
  .hud-tools { top: 8px; right: 8px; gap: 5px; }
  .hud-btn { width: 34px; height: 34px; font-size: 14px; }
  .hud-badge { min-width: 15px; height: 15px; line-height: 15px; font-size: 9px; }
  /* пять кнопок по 34px с зазорами — под них и держим отступ */
  .game-topbar { padding: 8px 10px; padding-right: 196px; gap: 6px; }
  .room-pill { font-size: 11px; padding: 5px 9px; }
  .turn-banner { font-size: 13.5px; padding: 7px 16px; margin-bottom: 2px; }
  .turn-you { font-size: 14px; }
  .direction-pill { padding: 5px 8px; }
  #direction-label { display: none; }

  .multi-card { width: 26px; height: 37px; }
  .multi-list { max-height: 40dvh; }
  .rules-card { max-height: 90dvh; }
  .rule-row { flex-direction: column; align-items: stretch; gap: 9px; }
  .rule-choice { justify-content: flex-start; max-width: none; }
  .rule-switch { align-self: flex-start; }
  .lobby-header-actions { flex-direction: column; }

  .side-panel { top: 54px; height: calc(100dvh - 54px); width: min(340px, 92vw); }

  /* .card выше переопределяет размер, поэтому рубашки соперников задаём заново */
  .card-mini { width: 34px; height: 49px; }
  .table-ring { min-height: 300px; margin: 2px 2px 0; }
  .hand-bar { gap: 8px; }
  .hand-count { font-size: 11.5px; padding: 4px 10px; }
  .opp-fan { min-height: 56px; padding-top: 6px; }
  .opp-fan .card-mini { margin-left: -18px; }
  .opponents-arc { gap: 4px 10px; }
  .opponents-arc.crowded .card-mini { width: 28px; height: 40px; }
  .my-hand-wrap { padding-top: 38px; }
}
