:root {
  color-scheme: dark;
  --bg: #11151b;
  --bg-soft: #171d25;
  --card: #1e252f;
  --card-soft: #242d39;
  --line: #303b4a;
  --text: #e9eef6;
  --muted: #97a4b6;
  --accent: #e3b45f;
  --accent-strong: #f2c877;
  --accent-text: #221a09;
  --danger: #ff8f80;
  --ok: #6fe3a5;
  --panel: rgba(17, 21, 27, 0.55);
  --panel-soft: rgba(17, 21, 27, 0.45);
  --panel-strong: rgba(17, 21, 27, 0.68);
  --panel-deep: rgba(17, 21, 27, 0.5);
  --radius: 14px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 500px at 15% -10%, rgba(227, 180, 95, 0.12), transparent 70%),
    radial-gradient(900px 500px at 100% 0%, rgba(111, 227, 165, 0.08), transparent 65%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

h1,
h2,
p,
dl,
dd,
ul {
  margin: 0;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: center;
  justify-content: space-between;
  max-width: 880px;
  margin: 0 auto;
  padding: 28px 20px 12px;
}

.topbar__title {
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.topbar__actions {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-left: auto;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--text);
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease, background-color 120ms ease;
}

.icon-button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.icon-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.icon-button[data-muted="true"] {
  color: var(--muted);
}

.icon-button__icon {
  display: inline-flex;
  width: 20px;
  height: 20px;
}

.icon-button__icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button__icon--sound-off {
  display: none;
}

.icon-button[data-muted="true"] .icon-button__icon--sound-on {
  display: none;
}

.icon-button[data-muted="true"] .icon-button__icon--sound-off {
  display: inline-flex;
}

.connection {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.connection__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 4px rgba(151, 164, 182, 0.12);
}

.connection[data-state="open"] {
  color: var(--ok);
}

.connection[data-state="open"] .connection__dot {
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(111, 227, 165, 0.15);
}

.connection[data-state="closed"] {
  color: var(--danger);
}

.connection[data-state="closed"] .connection__dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(255, 143, 128, 0.15);
}

.layout {
  display: grid;
  gap: 18px;
  max-width: 880px;
  margin: 0 auto;
  padding: 8px 20px 24px;
}

/* Версия сборки внизу страницы. Значение — хардкод в index.html;
   при смене версии его правят вместе с package.json. */
.footer {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 20px 26px;
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.02em;
  text-align: center;
}

.footer__version {
  font-variant-numeric: tabular-nums;
}

.card {
  background: linear-gradient(180deg, var(--card-soft), var(--card));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.card__title {
  font-size: 1.02rem;
  font-weight: 620;
  letter-spacing: 0.01em;
  margin-bottom: 14px;
}

.form {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field__label,
.label {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.field__control {
  width: 100%;
  padding: 11px 13px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
}

.field__control:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.field__control--code {
  text-transform: uppercase;
  letter-spacing: 0.28em;
  font-variant-numeric: tabular-nums;
}

select.field__control {
  cursor: pointer;
}

.button {
  justify-self: start;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  color: var(--accent-text);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  transition: filter 120ms ease, transform 120ms ease;
}

.button:hover:not(:disabled) {
  filter: brightness(1.06);
}

.button:active:not(:disabled) {
  transform: translateY(1px);
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.button--secondary {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent-strong);
}

.button--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
}

/* Лобби: игры — кнопки-плитки из games_list. */
.games {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  /* Все строки сетки одной высоты: плитки с разным набором тегов
     не делают соседнюю строку ниже. */
  grid-auto-rows: 1fr;
  gap: 12px;
}

.game-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 112px;
  padding: 14px 16px;
  overflow: hidden;
  overflow-wrap: anywhere;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease, transform 120ms ease;
}

/* Логотип игры — полупрозрачный фон в правом нижнем углу. Это SVG,
   поэтому он масштабируется без мыла и не перехватывает клики. */
.game-tile__logo {
  position: absolute;
  right: -10px;
  bottom: -14px;
  display: block;
  width: 108px;
  height: 108px;
  color: var(--accent);
  opacity: 0.16;
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
}

.game-tile__content {
  position: relative;
  z-index: 1;
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.game-tile:hover:not(:disabled) {
  background: rgba(227, 180, 95, 0.09);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.game-tile:hover:not(:disabled) .game-tile__logo {
  opacity: 0.24;
  transform: translateY(-2px) scale(1.03);
}

.game-tile:active:not(:disabled) {
  transform: translateY(0);
}

.game-tile:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.game-tile__name {
  font-size: 1.08rem;
  font-weight: 650;
  line-height: 1.25;
}

.game-tile__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Иконка-тег: иконка + короткая подпись, полный текст — в title/aria-label. */
.game-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px 3px 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 550;
  line-height: 1.2;
  white-space: nowrap;
}

.game-tag__icon {
  width: 13px;
  height: 13px;
  flex: none;
}

.game-tag__text {
  display: block;
}

.game-setup {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.game-setup__title {
  font-weight: 600;
}

.game-setup__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.mode-switch__button {
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease, color 120ms ease;
}

.mode-switch__button:hover {
  border-color: var(--accent);
}

.mode-switch__button--active {
  background: rgba(227, 180, 95, 0.14);
  border-color: var(--accent);
  color: var(--accent-strong);
  font-weight: 650;
}

/* Шапка комнаты: игра и правила слева, статус по центру, старт справа. */
.room__bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  margin-bottom: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.room__game {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.room__game-title {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 0;
  min-width: 0;
  font-weight: 650;
}

.room__game-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room__status {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  text-align: center;
}

.room__start {
  justify-self: end;
  margin: 0;
  white-space: nowrap;
}

.divider {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 20px 0;
}

.room__head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
}

.room__head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.room__menu {
  align-self: flex-start;
  white-space: nowrap;
}

/* Иконка правил: только presentation, текст приходит с сервера. */
.room__rules {
  display: inline-flex;
  flex: 0 0 32px;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.room__rules:hover {
  background: rgba(227, 180, 95, 0.12);
  border-color: rgba(227, 180, 95, 0.35);
  color: var(--accent-strong);
}

.room__rules:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.room__rules-icon {
  width: 18px;
  height: 18px;
}

.room__code {
  display: inline-block;
  margin: -2px -8px;
  padding: 2px 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  font: inherit;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.18em;
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.room__code:hover {
  background: rgba(227, 180, 95, 0.12);
  border-color: rgba(227, 180, 95, 0.35);
}

.room__code:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.room__code--copied {
  font-size: 1rem;
  line-height: 2.4;
  letter-spacing: 0.04em;
  color: var(--ok);
}

.room__bot {
  display: block;
  margin-bottom: 24px;
}

.room__bot-difficulty {
  max-width: 260px;
  margin-bottom: 10px;
}

.room__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.board {
  margin-bottom: 24px;
}

/* Поле нужно как система координат для SVG-линии победы. */
.board__field {
  position: relative;
  width: min(480px, 100%);
  margin: 0 auto;
  aspect-ratio: 1 / 1;
}

.board__grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: 10px;
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
}

.board__grid--tiles {
  gap: 2px;
  padding: 2px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.board__grid--tiles .cell {
  border: 0;
  border-radius: 4px;
  background: #3a4655;
}

.board__grid--tiles .cell--dark {
  background: #232c37;
}

/* Линия рисуется поверх клеток и не перехватывает клики. */
.board__win-line {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.board__win-line line {
  stroke: var(--accent-strong);
  stroke-width: 8;
  stroke-linecap: round;
  filter: drop-shadow(0 0 6px rgba(242, 200, 119, 0.6));
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 1;
  min-width: 0;
  min-height: 0;
  padding: 0;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  font-size: clamp(1.8rem, 7vw, 2.8rem);
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.cell:hover:not(:disabled) {
  background: rgba(227, 180, 95, 0.09);
  border-color: var(--accent);
}

.cell:active:not(:disabled) {
  transform: scale(0.97);
}

.cell:disabled {
  cursor: default;
}

.cell--x,
.cell--o {
  text-transform: uppercase;
}

.cell--x {
  color: #8fc7ff;
}

.cell--o {
  color: var(--accent-strong);
}

/* Шашки: внешность задаётся токеном, текст клетки остаётся для доступности. */
.cell--w,
.cell--b,
.cell--W,
.cell--B {
  color: transparent;
}

.cell--w::before,
.cell--b::before,
.cell--W::before,
.cell--B::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  width: 64%;
  aspect-ratio: 1;
  margin: 0;
  line-height: 0;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
}

.cell--w::before,
.cell--W::before {
  background: radial-gradient(circle at 32% 28%, #ffffff, #c9d2de 72%);
  border: 2px solid #8d99aa;
}

.cell--b::before,
.cell--B::before {
  background: radial-gradient(circle at 32% 28%, #4c5765, #10151c 72%);
  border: 2px solid #05080c;
}

.cell--W::before,
.cell--B::before {
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.35),
    inset 0 0 0 3px rgba(242, 200, 119, 0.9);
}

.cell--target {
  box-shadow: inset 0 0 0 2px var(--accent-strong);
}

/* Превью недопустимой расстановки: пересечение или касание. */
.cell--invalid {
  box-shadow: inset 0 0 0 2px var(--danger);
}

.board__grid--tiles .cell--invalid {
  background: rgba(255, 143, 128, 0.18);
}

.cell--selected {
  outline: 2px solid var(--accent-strong);
  outline-offset: -3px;
}

/* После правил клеток/шашек, чтобы подсветка победы не перебивалась фоном. */
.board__grid .cell--winning {
  background: rgba(242, 200, 119, 0.3);
}

.board__hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Кнопка передачи хода под доской, по центру. */
.board__pass {
  display: block;
  margin: 12px auto 0;
}

/* Морской бой: две доски рядом. display:grid перебивает [hidden],
   поэтому скрытие задано явно. */
.boards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.boards[hidden] {
  display: none;
}

.boards__hint {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.board--side {
  min-width: 0;
  margin-bottom: 0;
}

.board--side .board__field {
  width: 100%;
}

.board__title {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: center;
  text-transform: uppercase;
}

/* Панель расстановки флота: локальный черновик, сервер её не видит. */
.placement {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.placement[hidden] {
  display: none;
}

.placement__text {
  color: var(--muted);
}

.placement__ships {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.fleet-chip {
  display: grid;
  place-items: center;
  min-width: 40px;
  height: 32px;
  padding: 0 10px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 650;
}

.fleet-chip--placed {
  background: var(--bg-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.placement__hint {
  color: var(--accent-strong);
  font-size: 0.9rem;
}

.placement__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Морской бой: текст токена нужен только скринридеру, вид рисует CSS. */
.board__grid--tiles .cell {
  font-size: 0;
}

.cell--s::before {
  content: '';
  position: absolute;
  inset: 12%;
  border-radius: 3px;
  background: #3b6f9e;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.cell--h::before {
  content: '';
  position: absolute;
  top: 26%;
  left: 26%;
  width: 48%;
  height: 48%;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 6px rgba(255, 143, 128, 0.6);
}

.cell--m::before {
  content: '';
  position: absolute;
  top: 38%;
  left: 38%;
  width: 24%;
  height: 24%;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.75;
}

.board__grid--tiles .cell--k {
  background: rgba(255, 143, 128, 0.18);
  border-color: rgba(255, 143, 128, 0.45);
}

.board__grid--tiles .cell--s {
  background: #2e5a80;
}

.cell--k::before {
  content: '';
  position: absolute;
  inset: 12%;
  background:
    linear-gradient(
      45deg,
      transparent 46%,
      var(--danger) 46% 54%,
      transparent 54%
    ),
    linear-gradient(
      -45deg,
      transparent 46%,
      var(--danger) 46% 54%,
      transparent 54%
    );
}

/* Судоку: доска 9×9 с линиями квадратов, панель цифр и лидерборд. */
.sudoku {
  display: grid;
  grid-template-columns: minmax(0, 480px) minmax(0, 220px);
  gap: 20px;
  align-items: start;
  margin-bottom: 24px;
}

.sudoku[hidden] {
  display: none;
}

.sudoku__board {
  min-width: 0;
}

.sudoku__board .board__field {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

/* Перебиваем плиточный вид: у судоку клетки сомкнуты и разделены линиями. */
.board__grid--sudoku {
  gap: 0;
  padding: 0;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.board__grid--sudoku .cell {
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--bg-soft);
  color: var(--text);
  font-size: clamp(1rem, 4.2vw, 1.6rem);
  font-weight: 500;
}

.board__grid--sudoku .cell--box-alt {
  background: #1a2129;
}

.board__grid--sudoku .cell--given {
  background: #222b35;
  color: var(--text);
  font-weight: 700;
}

.board__grid--sudoku .cell--player {
  color: var(--accent-strong);
  font-weight: 650;
}

.board__grid--sudoku .cell--box-right {
  border-right: 2px solid #4b5a6d;
}

.board__grid--sudoku .cell--box-bottom {
  border-bottom: 2px solid #4b5a6d;
}

.board__grid--sudoku .cell--sudoku-peer {
  background: rgba(227, 180, 95, 0.08);
}

.board__grid--sudoku .cell--sudoku-same {
  background: rgba(111, 227, 165, 0.14);
}

.board__grid--sudoku .cell--selected {
  position: relative;
  z-index: 1;
  background: rgba(227, 180, 95, 0.22);
  outline: 2px solid var(--accent-strong);
  outline-offset: -2px;
}

.board__grid--sudoku .cell:disabled {
  cursor: default;
}

.sudoku__side {
  display: grid;
  gap: 12px;
}

.sudoku__hint {
  min-height: 2.7em;
  color: var(--muted);
  font-size: 0.9rem;
}

.sudoku__pad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.sudoku__key {
  padding: 12px 0;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  font: inherit;
  font-size: 1.1rem;
  font-weight: 650;
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.sudoku__key:hover:not(:disabled) {
  background: rgba(227, 180, 95, 0.09);
  border-color: var(--accent);
}

.sudoku__key:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.sudoku__key--erase {
  grid-column: 1 / -1;
  font-size: 0.9rem;
}

.sudoku__leaders-title {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sudoku__leaders {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sudoku__leader {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.sudoku__place {
  display: grid;
  flex: none;
  place-items: center;
  width: 24px;
  height: 24px;
  background: rgba(227, 180, 95, 0.16);
  border-radius: 50%;
  color: var(--accent-strong);
  font-size: 0.8rem;
  font-weight: 700;
}

.sudoku__leader-name {
  font-weight: 550;
}

.sudoku__leader--empty {
  color: var(--muted);
  border-style: dashed;
  font-size: 0.9rem;
}

/* Сапёр: поле 9×9 с цифрами, флажками и минами, сбоку — подсказки. */
.minesweeper {
  display: grid;
  grid-template-columns: minmax(0, 480px) minmax(0, 220px);
  gap: 20px;
  align-items: start;
  margin-bottom: 24px;
}

.minesweeper[hidden] {
  display: none;
}

.minesweeper__board {
  min-width: 0;
}

.minesweeper__board .board__field {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

.minesweeper__side {
  display: grid;
  gap: 12px;
  align-content: start;
}

.minesweeper__hint {
  color: var(--muted);
  font-size: 0.95rem;
}

.minesweeper__counter {
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 550;
}

.minesweeper__flag {
  justify-self: start;
}

.minesweeper__flag--active {
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  border-color: var(--accent);
  color: var(--accent-text);
}

/* Плотная сетка: закрытые клетки — плитки, открытые — тёмный фон. */
.board__grid--minesweeper {
  gap: 2px;
  padding: 6px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.board__grid--minesweeper .cell {
  border: 0;
  border-radius: 4px;
  background: #3a4655;
  font-size: clamp(0.95rem, 3.6vw, 1.35rem);
}

.board__grid--minesweeper .cell--closed:hover:not(:disabled) {
  background: #46556a;
}

.board__grid--minesweeper .cell--open {
  background: var(--bg-soft);
  color: var(--muted);
  cursor: default;
}

.board__grid--minesweeper .cell--open-number {
  color: var(--text);
  font-weight: 700;
}

.board__grid--minesweeper .cell--n1 { color: #8fc7ff; }
.board__grid--minesweeper .cell--n2 { color: #6fe3a5; }
.board__grid--minesweeper .cell--n3 { color: #ff9f9f; }
.board__grid--minesweeper .cell--n4 { color: #c7a8ff; }
.board__grid--minesweeper .cell--n5 { color: #e3b45f; }
.board__grid--minesweeper .cell--n6 { color: #7fe0e0; }
.board__grid--minesweeper .cell--n7 { color: #e9eef6; }
.board__grid--minesweeper .cell--n8 { color: #97a4b6; }

.board__grid--minesweeper .cell--flagged {
  background: #3a4655;
  color: var(--accent-strong);
}

.board__grid--minesweeper .cell--mine {
  background: #3a2020;
  color: var(--danger);
}

.board__grid--minesweeper .cell--exploded {
  background: var(--danger);
  color: #221009;
}

/* Волна открытия: клетки раскрытой области появляются слоями от нажатой.
   Задержку и длительность задаёт render/minesweeper.js CSS-переменными.
   backwards держит стартовый кадр во время задержки, иначе клетка успела бы
   показаться до начала анимации. */
.board__grid--minesweeper .cell--wave {
  animation: mine-reveal var(--mine-wave-duration, 200ms) cubic-bezier(0.22, 0.61, 0.36, 1)
    var(--mine-wave-delay, 0ms) backwards;
}

@keyframes mine-reveal {
  from {
    opacity: 0.25;
    transform: scale(0.72);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .board__grid--minesweeper .cell--wave {
    animation: none;
  }
}

/* Быстрые реакции: ряд кнопок в комнате и всплывающий пузырь над карточкой.
   Пузырь — presentation: он ничего не меняет в комнате и сам исчезает. */
.reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.reaction-button {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 120ms ease, transform 120ms ease;
}

.reaction-button:hover:not(:disabled),
.reaction-button:focus-visible {
  border-color: var(--accent);
}

.reaction-button:active:not(:disabled) {
  transform: scale(0.94);
}

.reaction-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.reaction-layer {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.reaction-bubble {
  position: fixed;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 1.35rem;
  line-height: 1;
  transform: translate(-50%, 0);
  animation: reaction-pop 2s ease-out forwards;
}

@keyframes reaction-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, 8px) scale(0.7);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
  75% {
    opacity: 1;
    transform: translate(-50%, -6px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -14px) scale(0.95);
  }
}

/* Текст для скринридера: имя игрока и его реакция. */
.reaction-live {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .reaction-button {
    transition: none;
  }

  .reaction-bubble {
    animation: none;
    transform: translate(-50%, 0);
  }
}

.players {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
  padding: 0;
  list-style: none;
}

.player {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.player__name {
  font-weight: 550;
}

.player__side {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.player__remove {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  /* Крестик рисуем линиями: глиф «×» сидит на baseline и выглядит смещённым. */
  font-size: 0;
  line-height: 1;
  cursor: pointer;
}

.player__remove::before,
.player__remove::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transform: translate(-50%, -50%) rotate(45deg);
}

.player__remove::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.player__remove:hover,
.player__remove:focus-visible {
  border-color: rgba(255, 143, 128, 0.55);
  color: #ff8f80;
}

.player__remove:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.player--empty {
  color: var(--muted);
  border-style: dashed;
}

.badge {
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(227, 180, 95, 0.16);
  color: var(--accent-strong);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.alert {
  padding: 12px 14px;
  border: 1px solid rgba(255, 143, 128, 0.45);
  border-radius: 10px;
  background: rgba(255, 143, 128, 0.1);
  color: var(--danger);
}

/* Модальное окно подтверждения выхода: перекрывает страницу, но не ломает её layout. */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
}

.modal[hidden] {
  display: none;
}

.modal__content {
  display: grid;
  gap: 18px;
  width: min(420px, 100%);
  padding: 24px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

/* Модалка правил: шире подтверждения выхода, тело прокручивается. */
.modal__content--rules {
  width: min(640px, 100%);
  max-height: min(86vh, 720px);
  padding: 0;
  gap: 0;
  overflow: hidden;
}

.rules__head {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.rules__title {
  font-size: 1.2rem;
  font-weight: 700;
}

.rules__close {
  flex: 0 0 auto;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  font-size: 1.4rem;
  line-height: 1;
}

.rules__body {
  display: grid;
  gap: 12px;
  padding: 18px 22px 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.rules__body p {
  color: var(--text);
  line-height: 1.55;
}

.rules__list {
  display: grid;
  gap: 8px;
  padding-left: 20px;
}

.rules__list li {
  line-height: 1.5;
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(9, 12, 16, 0.75);
  backdrop-filter: blur(4px);
  z-index: 10;
}

.overlay__card {
  display: grid;
  gap: 12px;
  width: min(420px, 100%);
  padding: 26px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}

.overlay__text {
  color: var(--muted);
}

.overlay__card .button {
  justify-self: center;
}

/* Празднование победы: конфетти на весь экран и поздравление.
   Пока показывается — перехватывает клики, чтобы случайное нажатие не
   сработало под анимацией; после исчезновения не мешает управлению. */
.celebration {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(9, 12, 16, 0.55);
  backdrop-filter: blur(2px);
  opacity: 1;
  transition: opacity 220ms ease;
}

.celebration[hidden] {
  display: none;
}

.celebration--closing {
  opacity: 0;
}

/* При prefers-reduced-motion: только текст, без затемнения и блокировки. */
.celebration--passive {
  background: transparent;
  backdrop-filter: none;
  pointer-events: none;
  transition: none;
}

.celebration__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.celebration__card {
  position: relative;
  display: grid;
  gap: 8px;
  padding: 28px 40px;
  background: rgba(22, 27, 34, 0.94);
  border: 1px solid var(--accent);
  border-radius: 18px;
  box-shadow: var(--shadow);
  text-align: center;
  animation: celebration-pop 320ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.celebration__title {
  margin: 0;
  color: var(--accent-strong);
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-weight: 750;
  line-height: 1.15;
}

.celebration__subtitle {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
}

@keyframes celebration-pop {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

body.is-celebrating {
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .celebration,
  .celebration__card {
    transition: none;
    animation: none;
  }
}

:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .topbar {
    padding-top: 20px;
  }

  .card {
    padding: 18px;
  }

  .room__code {
    font-size: 1.7rem;
  }

  /* Шапка комнаты: на узком экране игра, статус и старт идут друг под другом. */
  .room__head-actions {
    width: 100%;
  }

  .room__head-actions .room__menu {
    flex: 1 1 auto;
    width: auto;
  }

  .room__bar {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .room__status {
    text-align: left;
  }

  .room__start {
    justify-self: stretch;
  }

  .room__code--copied {
    font-size: 1rem;
    line-height: 2.04;
  }

  .button {
    width: 100%;
    justify-self: stretch;
  }

  /* Две доски морского боя на узком экране — друг под другом. */
  .boards {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .games {
    grid-template-columns: 1fr;
  }

  .game-tile__logo {
    width: 96px;
    height: 96px;
  }

  .sudoku {
    grid-template-columns: 1fr;
  }

  .minesweeper {
    grid-template-columns: 1fr;
  }

  .sudoku__pad {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  /* Модалка правил на телефоне — почти на весь экран, тело прокручивается. */
  .modal--rules {
    padding: 8px;
  }

  .modal__content--rules {
    width: 100%;
    height: calc(100dvh - 16px);
    max-height: calc(100dvh - 16px);
  }

  .rules__head {
    padding: 14px 16px;
  }

  .rules__body {
    padding: 16px 16px 20px;
  }

  /* .button на мобильном растягивается на всю ширину — крестику это не нужно. */
  .rules__close {
    width: 40px;
    min-width: 40px;
  }
}

/* Слой эффектов над доской: призраки фишек и волны выстрелов.
   Клики не перехватывает, раскладку не меняет. */
.board__fx {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}

.board__fx-piece {
  position: absolute;
  pointer-events: none;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  will-change: transform, opacity;
}

.board__fx-ring {
  position: absolute;
  border: 2px solid var(--muted);
  border-radius: 50%;
  pointer-events: none;
  will-change: transform, opacity;
}

.board__fx-ring--hit,
.board__fx-ring--sunk {
  border-color: var(--danger);
}

/* Клетка, которую анимация временно прячет: фон остаётся, фишка/символ — нет. */
.cell--fx-hidden {
  color: transparent;
}

.cell--fx-hidden::before {
  visibility: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .board__fx {
    display: none;
  }
}

/* Шахматы: глиф фигуры — текст клетки, цвет задаёт сторона. Призрак живёт
   в слое эффектов вне сетки, поэтому ему нужен тот же размер отдельно. */
.board__grid--tiles .cell--chess,
.board__fx-piece.cell--chess {
  /* Текстовый символьный шрифт, а не эмодзи: пешка U+265F есть в
     emoji-наборе и иначе может рисоваться своим цветом вопреки color. */
  font-family: 'Segoe UI Symbol', 'Apple Symbols', 'Noto Sans Symbols 2',
    'DejaVu Sans', system-ui, sans-serif;
  font-size: clamp(1.5rem, 5.4vw, 2.5rem);
  font-weight: 400;
  line-height: 1;
}

.cell--chess.cell--piece-light {
  color: #f5f8fc;
  text-shadow:
    0 0 1px #0b0f14,
    0 1px 2px rgba(0, 0, 0, 0.65);
}

.cell--chess.cell--piece-dark {
  color: #0d131a;
  text-shadow:
    1px 0 0 #eaf1fb,
    -1px 0 0 #eaf1fb,
    0 1px 0 #eaf1fb,
    0 -1px 0 #eaf1fb,
    0 2px 4px rgba(0, 0, 0, 0.55);
}

/* Скрытая клетка не должна оставлять тень глифа под призраком. */
.cell--fx-hidden.cell--chess {
  text-shadow: none;
}

/* Шах подсвечивается только потому, что сервер прислал check: true. */
.board__grid--tiles .cell--check {
  background: rgba(255, 143, 128, 0.28);
  box-shadow: inset 0 0 0 2px var(--danger);
}

/* Панель превращения пешки: выбор отправляет элемент legalMoves с promote. */
.promotion {
  display: grid;
  gap: 10px;
  max-width: 480px;
  margin: 14px auto 0;
  padding: 12px 16px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-align: center;
}

.promotion[hidden] {
  display: none;
}

.promotion__text {
  color: var(--muted);
  font-size: 0.9rem;
}

.promotion__choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.promotion__choice {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  padding: 0;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.promotion__choice:hover {
  background: rgba(227, 180, 95, 0.09);
  border-color: var(--accent);
}

.promotion__choice:active {
  transform: scale(0.97);
}


/* Куоридор: клетки 9×9, широкие щели под стены и SVG-слой поверх сетки. */
.board__grid.board__grid--quoridor {
  gap: 2.2%;
  padding: 0;
  background: #1b222c;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.board__grid--quoridor .cell {
  border: 1px solid #1c2530;
  border-radius: 6px;
  background: #303b49;
  font-size: 0;
}

.board__grid--quoridor .cell:hover:not(:disabled) {
  background: #3a4655;
  border-color: var(--accent);
}

/* Финишная линия текущего игрока: цвет зависит от стороны (game.you),
   правила не меняются. Белые идут вверх — светлая подсветка, чёрные вниз —
   тёмная. Значения по умолчанию нужны, только если сторона не определена. */
.board__grid--quoridor {
  --q-goal-rgb: 160, 175, 195;
  --q-goal-strong: 0.22;
  --q-goal-soft: 0.07;
  --q-goal-border: 0.42;
  --q-goal-rim: rgba(160, 175, 195, 0.8);
}

.board__grid--quoridor.board__grid--goal-white {
  --q-goal-rgb: 244, 247, 251;
  --q-goal-strong: 0.24;
  --q-goal-soft: 0.08;
  --q-goal-border: 0.45;
  --q-goal-rim: rgba(244, 247, 251, 0.85);
}

.board__grid--quoridor.board__grid--goal-black {
  --q-goal-rgb: 8, 11, 15;
  --q-goal-strong: 0.55;
  --q-goal-soft: 0.22;
  --q-goal-border: 0.8;
  --q-goal-rim: rgba(4, 6, 9, 0.95);
}

.board__grid--quoridor .cell--q-goal {
  background: linear-gradient(
    180deg,
    rgba(var(--q-goal-rgb), var(--q-goal-strong)),
    rgba(var(--q-goal-rgb), var(--q-goal-soft))
  );
  border-color: rgba(var(--q-goal-rgb), var(--q-goal-border));
}

/* Кант на внешнем краю доски показывает, куда идти. */
.board__grid--quoridor.board__grid--goal-top {
  box-shadow: inset 0 3px 0 var(--q-goal-rim);
}

.board__grid--quoridor.board__grid--goal-bottom {
  box-shadow: inset 0 -3px 0 var(--q-goal-rim);
}

/* Фишки Куоридора: белая и чёрная, крупнее шашечных и с ободком. */
.cell--quoridor.cell--q-w,
.cell--quoridor.cell--q-b {
  color: transparent;
}

.cell--quoridor.cell--q-w::before,
.cell--quoridor.cell--q-b::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 58%;
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.cell--quoridor.cell--q-w::before {
  background: radial-gradient(circle at 32% 28%, #ffffff, #c9d2de 72%);
  border: 2px solid #8d99aa;
}

.cell--quoridor.cell--q-b::before {
  background: radial-gradient(circle at 32% 28%, #4c5765, #10151c 72%);
  border: 2px solid #05080c;
}

/* SVG-слой не перехватывает клики по клеткам; щели стен включают pointer-events сами. */
.board__quoridor-walls {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

/* Направляющие щели: пунктир от края до края поля (вид сверху). */
.q-wall-guide {
  stroke: rgba(242, 200, 119, 0.34);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  stroke-linecap: round;
  pointer-events: none;
}

.q-wall {
  fill: #f2c877;
  stroke: #8a6420;
  stroke-width: 1.5;
  pointer-events: none;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.45));
}

/* Невидимая зона клика: подсветку рисует соседний призрак. */
.q-wall-slot {
  fill: transparent;
  stroke: none;
  pointer-events: all;
  cursor: pointer;
  outline: none;
  /* Тап по щели не должен зумить/скроллить страницу. */
  touch-action: manipulation;
}

/* Призрак будущей стены: полупрозрачный прямоугольник на две клетки. */
.q-wall-ghost {
  fill: rgba(242, 200, 119, 0.38);
  stroke: var(--accent-strong);
  stroke-width: 1.5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 120ms ease;
}

.q-wall-slot:hover + .q-wall-ghost,
.q-wall-slot:focus-visible + .q-wall-ghost {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .q-wall-ghost {
    transition: none;
  }
}

/* Куоридор на touch: выбранный режим и подтверждение стены.
   Панели появляются только на грубом указателе/узком экране — это решает
   renderQuoridor, CSS задаёт вид и размеры. */
.quoridor-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.quoridor-actions[hidden],
.quoridor-confirm[hidden] {
  display: none;
}

.quoridor-actions__group {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
}

.quoridor-actions__button {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.quoridor-actions__button[aria-pressed='true'] {
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  border-color: var(--accent-strong);
  color: #12161c;
}

.quoridor-actions__button:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.quoridor-confirm {
  display: grid;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
}

.quoridor-confirm__text {
  margin: 0;
  font-size: 0.9rem;
  opacity: 0.82;
}

.quoridor-confirm__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quoridor-confirm__actions .button {
  flex: 1 1 140px;
  min-height: 44px;
}

/* В режиме стены призраки видны у всех легальных щелей: на touch нет
   hover, а тонкая пунктирная линия слишком мелкая цель. */
.board__quoridor-walls--wall .q-wall-guide {
  stroke: rgba(242, 200, 119, 0.62);
  stroke-width: 1.6;
}

.board__quoridor-walls--wall .q-wall-ghost {
  opacity: 0.3;
}

.q-wall-slot--selected {
  fill: rgba(242, 200, 119, 0.16);
}

.q-wall-slot--selected + .q-wall-ghost {
  opacity: 1;
}

/* Лобби: обобщённые правила комнаты (чекбоксы startOptions). */
.start-options {
  display: grid;
  gap: 8px;
}

.field--checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
}

.field--checkbox:hover {
  border-color: var(--accent);
}

.field__check {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.field--checkbox .field__label {
  color: var(--text);
  font-size: 0.92rem;
  text-transform: none;
  letter-spacing: 0;
}

/* Правило комнаты с вариантами (вид карточек у Кодовых имён). */
.start-option {
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 9px;
}

.start-option .field__label {
  color: var(--text);
  font-size: 0.92rem;
  text-transform: none;
  letter-spacing: 0;
}

.start-option__choices {
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
}

/* Дурак: карточный стол, рубашки соперников и открытая своя рука. */
.durak {
  position: relative;
  display: grid;
  gap: 14px;
}

/* Слой перелётов карт: абсолютный, внутри .durak, клики не перехватывает. */
.durak__fx {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}

.durak__fx-card {
  position: absolute;
  margin: 0;
  pointer-events: none;
  will-change: transform, opacity;
}

/* Чужая карта: контейнер с двумя гранями. В кадре всегда видна ровно одна
   сторона, поэтому рубашка на старте и лицо после переворота не смешиваются. */
.durak__fx-card--flip {
  transform-style: preserve-3d;
  transform-origin: center;
}

.durak__fx-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.durak__fx-face--back {
  transform: rotateY(0deg);
}

.durak__fx-face--front {
  transform: rotateY(180deg);
}

.durak__fx-face--back .durak__back {
  display: block;
  width: 100%;
  height: 100%;
}

.durak__fx-face--front .durak-card {
  width: 100%;
  height: 100%;
}

/* Карта-цель ждёт, пока долетит клон. WAAPI-анимация имеет приоритет выше
   обычного правила, поэтому проявление поверх этого класса работает. */
.durak-card--fx-hidden {
  opacity: 0;
}

.durak__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.durak__meta-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.durak__meta-label {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.durak__counter {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.durak__trump-value {
  display: inline-flex;
  align-items: center;
}

.durak__trump-value .durak-card {
  width: 44px;
  height: 62px;
  padding: 5px 6px;
}

.durak__trump-value .durak-card__suit {
  font-size: 1rem;
}

.durak__trump-suit {
  color: var(--accent-strong);
  font-size: 1.5rem;
  line-height: 1;
}

.durak__opponents {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.durak__opponent {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.durak__opponent--out {
  opacity: 0.55;
}

.durak__opponent-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.durak__opponent-name {
  font-weight: 600;
}

.durak__role {
  padding: 2px 8px;
  border: 1px solid rgba(227, 180, 95, 0.45);
  border-radius: 999px;
  color: var(--accent-strong);
  font-size: 0.72rem;
  white-space: nowrap;
}

.durak__opponent-hand {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-height: 34px;
}

.durak__back {
  width: 18px;
  height: 28px;
  border: 1px solid #5a4a2c;
  border-radius: 5px;
  background: repeating-linear-gradient(
    135deg,
    #2a3442 0 4px,
    #222a35 4px 8px
  );
  box-shadow: inset 0 0 0 2px rgba(227, 180, 95, 0.12);
}

.durak__opponent-count {
  margin-left: 4px;
  color: var(--muted);
  font-weight: 650;
}

.durak__out {
  color: var(--muted);
  font-size: 0.85rem;
}

.durak__table {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-height: 150px;
  padding: 18px;
  background:
    radial-gradient(circle at 50% 40%, rgba(111, 227, 165, 0.08), transparent 65%),
    var(--panel-deep);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.durak__pair {
  position: relative;
  width: 84px;
  height: 112px;
  flex: none;
}

.durak-card {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  width: 64px;
  height: 92px;
  padding: 8px 9px;
  background: #f6f1e5;
  color: #1a1d22;
  border: 1px solid rgba(0, 0, 0, 0.25);
  border-radius: 9px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.3);
  font-weight: 700;
  line-height: 1;
}

.durak-card--red {
  color: #b3261e;
}

.durak-card__rank {
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}

.durak-card__suit {
  align-self: flex-end;
  font-size: 1.35rem;
}

.durak-card--trump {
  box-shadow:
    0 0 0 2px var(--accent),
    0 6px 14px rgba(0, 0, 0, 0.3);
}

.durak-card--attack {
  position: absolute;
  left: 0;
  top: 0;
}

.durak-card--beat {
  position: absolute;
  left: 14px;
  top: 14px;
  transform: rotate(6deg);
}

.durak__hole {
  position: absolute;
  left: 14px;
  top: 14px;
  width: 64px;
  height: 92px;
  border: 1px dashed rgba(151, 164, 182, 0.45);
  border-radius: 9px;
}

.durak__status {
  min-height: 1.5em;
  color: var(--muted);
  text-align: center;
}

.durak__hand {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  min-height: 100px;
  padding: 10px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.durak__card {
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 9px;
  cursor: default;
  transition: transform 120ms ease, opacity 120ms ease;
}

.durak__card:disabled {
  opacity: 0.45;
}

.durak__card--playable {
  cursor: pointer;
}

.durak__card--playable:hover .durak-card,
.durak__card--playable:focus-visible .durak-card {
  border-color: var(--accent);
  transform: translateY(-4px);
}

.durak__card--transfer .durak-card {
  box-shadow:
    0 0 0 2px var(--ok),
    0 6px 14px rgba(0, 0, 0, 0.3);
}

.durak__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.durak__actions .button[aria-pressed="true"] {
  background: rgba(227, 180, 95, 0.16);
  border-color: var(--accent-strong);
  color: var(--accent-strong);
}

.durak__empty {
  width: 100%;
  margin: auto;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 640px) {
  .durak__pair {
    width: 72px;
    height: 98px;
  }

  .durak-card {
    width: 56px;
    height: 82px;
    padding: 6px 7px;
  }

  .durak__hole {
    width: 56px;
    height: 82px;
  }

  .durak-card--beat {
    left: 12px;
    top: 12px;
  }

  .durak__hand {
    gap: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .durak__card,
  .durak__card--playable:hover .durak-card,
  .durak__card--playable:focus-visible .durak-card {
    transition: none;
    transform: none;
  }
}

/* Места в лобби (Кодовые имена): сетка команд и ролей. */
.seats {
  margin-bottom: 18px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.seats__head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.seats__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.seats__team {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.seats__team--red {
  border-top: 3px solid #c4544a;
}

.seats__team--blue {
  border-top: 3px solid #4f7fd1;
}

.seats__team-title {
  font-weight: 650;
}

.seats__team--red .seats__team-title {
  color: #ff9d92;
}

.seats__team--blue .seats__team-title {
  color: #9dbdff;
}

.seats__role {
  display: grid;
  gap: 6px;
}

.seats__role-name {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.seats__slots {
  display: grid;
  gap: 6px;
}

.seats__seat {
  padding: 8px 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  text-align: left;
}

.seats__seat--free {
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease;
}

.seats__seat--free:hover,
.seats__seat--free:focus-visible {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.seats__seat--taken {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  border-style: solid;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.seats__seat--self {
  border-color: var(--accent);
  background: rgba(227, 180, 95, 0.14);
  color: var(--accent-strong);
}

.seats__seat-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seats__seat-badge {
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
}

.seats__hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Уно: своя рука, счётчики соперников, верх сброса и выбор цвета. */
.uno {
  --uno-r: #d64545;
  --uno-y: #e0b23c;
  --uno-g: #3f9e57;
  --uno-b: #3d78c8;
  position: relative;
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

/* Слой перелётов карт: абсолютный, внутри .uno, клики не перехватывает. */
.uno__fx {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}

.uno__fx-card {
  position: absolute;
  margin: 0;
  pointer-events: none;
  will-change: transform, opacity;
}

/* Чужая карта: контейнер с двумя гранями. В кадре всегда видна ровно одна
   сторона, поэтому рубашка на старте и лицо после переворота не смешиваются. */
.uno__fx-card--flip {
  transform-style: preserve-3d;
  transform-origin: center;
}

.uno__fx-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.uno__fx-face--back {
  transform: rotateY(0deg);
}

.uno__fx-face--front {
  transform: rotateY(180deg);
}

.uno__fx-face--back .uno__back {
  display: block;
  width: 100%;
  height: 100%;
}

.uno__fx-face--back .uno__pile-back {
  display: block;
  width: 100%;
  height: 100%;
}

.uno__fx-face--back .uno-card,
.uno__fx-face--front .uno-card {
  width: 100%;
  height: 100%;
}

/* Карта-цель ждёт, пока долетит клон. WAAPI-анимация имеет приоритет выше
   обычного правила, поэтому проявление поверх этого класса работает. */
.uno-card--fx-hidden {
  opacity: 0;
}

.uno__empty {
  color: var(--muted);
}

/* Порядок хода: карточки мест и стрелки направления между ними. */
.uno__opponents {
  display: flex;
  align-items: stretch;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 4px;
}

.uno__seat {
  display: grid;
  flex: 0 0 auto;
  gap: 8px;
  min-width: 140px;
  padding: 10px 12px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.uno__seat--turn {
  border-color: var(--accent);
  background: rgba(227, 180, 95, 0.1);
}

.uno__self {
  border-style: dashed;
}

.uno__seat-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.uno__seat-name {
  font-weight: 600;
}

.uno__turn-badge {
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--accent-strong);
  font-size: 0.7rem;
  text-transform: uppercase;
}

.uno__seat-hand {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-height: 24px;
}

.uno__back {
  width: 16px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: linear-gradient(150deg, #2a3644, #1b222c);
}

.uno__seat-count {
  margin-left: 4px;
  color: var(--muted);
  font-size: 0.85rem;
}

.uno__dir-arrow {
  align-self: center;
  flex: 0 0 auto;
  color: var(--accent-strong);
  font-size: 1.35rem;
  line-height: 1;
  user-select: none;
}

/* Стол: крупная колода и сброс, рамка которого показывает текущий цвет. */
.uno__table {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 18px 12px;
  background:
    radial-gradient(circle at 50% 40%, rgba(227, 180, 95, 0.08), transparent 70%),
    var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.uno__pile {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.uno__pile--discard {
  padding: 6px;
  border: 3px solid var(--line);
  border-radius: 16px;
  transition: border-color 160ms ease;
}

.uno__pile--r {
  border-color: var(--uno-r);
}

.uno__pile--y {
  border-color: var(--uno-y);
}

.uno__pile--g {
  border-color: var(--uno-g);
}

.uno__pile--b {
  border-color: var(--uno-b);
}

.uno__pile-back {
  width: 82px;
  height: 122px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  background: repeating-linear-gradient(135deg, #2a3644 0 6px, #1b222c 6px 12px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.uno__pile-top {
  display: grid;
  place-items: center;
  min-width: 82px;
  min-height: 122px;
}

.uno__pile-top .uno-card {
  width: 82px;
  height: 122px;
}

.uno__pile-top .uno-card__rank {
  font-size: 1.05rem;
}

.uno__pile-top .uno-card__mark {
  width: 52px;
  height: 72px;
  font-size: 1.35rem;
}

.uno__pile-note {
  color: var(--muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.uno__pile-count {
  color: var(--text);
  font-weight: 650;
}

.uno__color-value {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.uno__color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.uno__color-dot--r {
  background: var(--uno-r);
}

.uno__color-dot--y {
  background: var(--uno-y);
}

.uno__color-dot--g {
  background: var(--uno-g);
}

.uno__color-dot--b {
  background: var(--uno-b);
}

.uno__status {
  min-height: 1.5em;
  color: var(--muted);
  text-align: center;
}

.uno__hand {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  min-height: 118px;
  padding: 10px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.uno__card {
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 10px;
  cursor: default;
  transition: transform 120ms ease, opacity 120ms ease;
}

.uno__card:disabled {
  opacity: 0.45;
}

.uno__card--playable {
  cursor: pointer;
}

.uno__card--playable:hover .uno-card,
.uno__card--playable:focus-visible .uno-card {
  border-color: var(--accent);
  transform: translateY(-6px);
}

.uno__card--active .uno-card {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 2px rgba(227, 180, 95, 0.5);
}

/* Сама карта: цветной прямоугольник с крупным «лицом» по центру. */
.uno-card {
  position: relative;
  display: grid;
  place-items: center;
  width: 68px;
  height: 102px;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  background: #1e2630;
  color: #fff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
  transition: border-color 120ms ease, transform 120ms ease;
}

.uno-card--r {
  background: var(--uno-r);
}

.uno-card--y {
  background: var(--uno-y);
  color: #2a2205;
}

.uno-card--g {
  background: var(--uno-g);
}

.uno-card--b {
  background: var(--uno-b);
}

/* Wild: четыре цвета по углам, лицо читается на тёмной основе. */
.uno-card--wild {
  background:
    conic-gradient(
      from 45deg,
      var(--uno-r) 0 25%,
      var(--uno-y) 0 50%,
      var(--uno-g) 0 75%,
      var(--uno-b) 0 100%
    );
}

.uno-card--w4 {
  border-color: rgba(255, 255, 255, 0.4);
}

.uno-card__rank {
  position: absolute;
  top: 6px;
  left: 8px;
  font-weight: 700;
  font-size: 0.95rem;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.uno-card__mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 56px;
  border-radius: 8px;
  background: rgba(17, 21, 27, 0.35);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.uno-card--y .uno-card__mark {
  background: rgba(255, 255, 255, 0.45);
}

.uno__colors {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 12px;
}

.uno__color {
  width: 52px;
  height: 52px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease;
}

.uno__color:hover,
.uno__color:focus-visible {
  transform: scale(1.08);
  border-color: #fff;
}

.uno__color--r {
  background: var(--uno-r);
}

.uno__color--y {
  background: var(--uno-y);
}

.uno__color--g {
  background: var(--uno-g);
}

.uno__color--b {
  background: var(--uno-b);
}

.uno__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

@media (max-width: 640px) {
  .uno-card {
    width: 56px;
    height: 86px;
  }

  .uno-card__mark {
    width: 34px;
    height: 46px;
    font-size: 0.95rem;
  }

  .uno__hand {
    gap: 6px;
    min-height: 100px;
  }

  .uno__color {
    width: 44px;
    height: 44px;
  }

  .uno__table {
    gap: 18px;
    padding: 14px 8px;
  }

  .uno__pile-back,
  .uno__pile-top .uno-card {
    width: 72px;
    height: 106px;
  }

  .uno__pile-top {
    min-width: 72px;
    min-height: 106px;
  }

  .uno__pile-top .uno-card__mark {
    width: 44px;
    height: 62px;
    font-size: 1.15rem;
  }

  .uno__seat {
    min-width: 108px;
    padding: 8px 10px;
  }

  .uno__seat-hand {
    gap: 2px;
  }

  .uno__back {
    width: 12px;
    height: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .uno__card,
  .uno__card--playable:hover .uno-card,
  .uno__card--playable:focus-visible .uno-card,
  .uno__color,
  .uno__pile--discard {
    transition: none;
    transform: none;
  }
}

/* Кодовые имена: команды, подсказка и сетка слов 5×5. */
.codenames {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.codenames__teams {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.codenames__team {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.codenames__team--active {
  border-color: var(--accent);
}

.codenames__team--self {
  background: rgba(227, 180, 95, 0.08);
}

.codenames__team--red .codenames__team-title {
  color: #ff9d92;
}

.codenames__team--blue .codenames__team-title {
  color: #9dbdff;
}

.codenames__team-title {
  display: flex;
  gap: 8px;
  align-items: baseline;
  justify-content: space-between;
  font-weight: 650;
}

.codenames__remaining {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.codenames__members {
  display: grid;
  gap: 3px;
  padding: 0;
  margin: 0;
  list-style: none;
  font-size: 0.9rem;
}

.codenames__members li {
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.codenames__role {
  color: var(--muted);
  font-size: 0.8rem;
}

.codenames__clue {
  padding: 12px 14px;
  background: var(--card-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 600;
}

/* Вид карточек: локальный переключатель игрока, не настройка партии. */
.codenames__view-switch {
  grid-template-columns: repeat(2, minmax(0, 150px));
  justify-self: start;
}

.codenames__grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.codenames__card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  justify-content: center;
  min-height: 76px;
  padding: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-align: center;
  cursor: default;
  overflow-wrap: anywhere;
  transition: filter 120ms ease, border-color 120ms ease;
}

.codenames__card--known {
  border-style: dashed;
}

.codenames__card--red.codenames__card--known {
  background: rgba(196, 84, 74, 0.3);
  border-color: #c4544a;
}

.codenames__card--blue.codenames__card--known {
  background: rgba(79, 127, 209, 0.3);
  border-color: #4f7fd1;
}

.codenames__card--neutral.codenames__card--known {
  background: rgba(140, 148, 160, 0.18);
}

.codenames__card--assassin.codenames__card--known {
  background: rgba(30, 30, 30, 0.85);
  border-color: #c4544a;
}

.codenames__card--revealed {
  opacity: 0.85;
}

.codenames__card--red.codenames__card--revealed {
  background: #7b2f2a;
  border-color: #c4544a;
}

.codenames__card--blue.codenames__card--revealed {
  background: #2b4570;
  border-color: #4f7fd1;
}

.codenames__card--neutral.codenames__card--revealed {
  background: #464b54;
}

.codenames__card--assassin.codenames__card--revealed {
  background: #161616;
  border-color: #c4544a;
}

.codenames__card--target {
  border-color: var(--accent);
  cursor: pointer;
}

.codenames__card--target:hover:not(:disabled),
.codenames__card--target:focus-visible {
  filter: brightness(1.2);
}

.codenames__word {
  line-height: 1.25;
}

/* Иконка Tabler: единый размер, цвет наследуется от карточки. */
.codenames__icon {
  flex: none;
  width: 48px;
  height: 48px;
  color: currentColor;
}

.codenames__card--icons {
  min-height: 92px;
  padding: 10px 8px;
}

.codenames__mark {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.codenames__clue-form {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(90px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.codenames__field--number {
  max-width: 120px;
}

.codenames__hint {
  color: var(--muted);
  font-size: 0.9rem;
}

.codenames__stop {
  justify-self: start;
}

@media (max-width: 640px) {
  .seats__grid,
  .codenames__teams {
    grid-template-columns: 1fr;
  }

  .codenames__grid {
    gap: 5px;
  }

  .codenames__card {
    min-height: 62px;
    padding: 5px;
    font-size: 0.85rem;
  }

  .codenames__card--icons {
    min-height: 72px;
  }

  .codenames__icon {
    width: 38px;
    height: 38px;
  }

  .codenames__view-switch {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .codenames__clue-form {
    grid-template-columns: 1fr;
  }

  .codenames__field--number {
    max-width: none;
  }

  .codenames__clue-form .button {
    justify-self: stretch;
  }
}

.domino {
  position: relative;
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

/* Слой перелётов костей: абсолютный, внутри .domino, клики не перехватывает. */
.domino__fx {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}

.domino__fx-tile {
  position: absolute;
  margin: 0;
  pointer-events: none;
  will-change: transform, opacity;
}

/* Чужая кость: контейнер с двумя гранями. В кадре всегда видна ровно одна
   сторона, поэтому рубашка на старте и лицо после переворота не смешиваются. */
.domino__fx-tile--flip {
  transform-style: preserve-3d;
  transform-origin: center;
}

.domino__fx-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.domino__fx-face--back {
  transform: rotateY(0deg);
}

.domino__fx-face--front {
  transform: rotateY(180deg);
}

.domino__fx-face--back .domino__back {
  display: block;
  width: 100%;
  height: 100%;
}

/* Кость-цель ждёт, пока долетит клон. WAAPI-анимация имеет приоритет выше
   обычного правила, поэтому проявление поверх этого класса работает. */
.domino-tile--fx-hidden {
  opacity: 0;
}

.domino__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.domino__meta-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.domino__meta-label {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.domino__counter {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.domino__empty {
  color: var(--muted);
}

.domino__opponents {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.domino__opponent {
  display: grid;
  gap: 8px;
  min-width: 160px;
  padding: 10px 12px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.domino__opponent--turn {
  border-color: var(--accent);
  background: rgba(227, 180, 95, 0.1);
}

.domino__opponent-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.domino__opponent-name {
  font-weight: 600;
}

.domino__turn-badge {
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--accent-strong);
  font-size: 0.7rem;
  text-transform: uppercase;
}

.domino__opponent-hand {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.domino__back {
  width: 12px;
  height: 24px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: linear-gradient(150deg, #2a3644, #1b222c);
}

.domino__opponent-count {
  margin-left: 4px;
  color: var(--muted);
  font-size: 0.85rem;
}

.domino__opponent-pips {
  color: var(--muted);
  font-size: 0.8rem;
}

.domino__table {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 96px;
  padding: 12px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow-x: auto;
}

.domino__status {
  min-height: 1.5em;
  color: var(--muted);
  text-align: center;
}

.domino__hand {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 80px;
  padding: 10px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
}

/* Кость: две половины. Дубль рисуется вертикально, остальные горизонтально. */
.domino__tile {
  --domino-half: 34px;
  display: inline-flex;
  flex-direction: row;
  flex: none;
  padding: 0;
  overflow: hidden;
  background: #f1e6cc;
  color: #20242e;
  border: 1px solid rgba(0, 0, 0, 0.4);
  border-radius: 8px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}

.domino__tile--double {
  flex-direction: column;
}

.domino__half {
  display: grid;
  place-items: center;
  width: var(--domino-half);
  height: var(--domino-half);
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.domino__half + .domino__half {
  border-left: 1px solid rgba(32, 36, 46, 0.35);
}

.domino__tile--double .domino__half + .domino__half {
  border-left: 0;
  border-top: 1px solid rgba(32, 36, 46, 0.35);
}

.domino__tile--button {
  cursor: default;
  transition: transform 120ms ease, opacity 120ms ease, border-color 120ms ease;
}

.domino__tile--button:disabled {
  opacity: 0.45;
}

.domino__tile--playable {
  cursor: pointer;
}

.domino__tile--playable:hover,
.domino__tile--playable:focus-visible {
  border-color: var(--accent);
  transform: translateY(-4px);
}

.domino__tile--active {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 2px rgba(227, 180, 95, 0.5);
}

/* Подсветка концов, к которым есть ход, — только presentation по legalMoves. */
.domino__chain-tile--left {
  box-shadow: -3px 0 0 0 var(--accent-strong), 0 2px 0 rgba(0, 0, 0, 0.25);
}

.domino__chain-tile--right {
  box-shadow: 3px 0 0 0 var(--accent-strong), 0 2px 0 rgba(0, 0, 0, 0.25);
}

.domino__ends-choice {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.domino__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

@media (max-width: 640px) {
  .domino__tile {
    --domino-half: 28px;
  }

  .domino__half {
    font-size: 0.95rem;
  }

  .domino__table {
    gap: 4px;
    min-height: 80px;
    padding: 8px;
  }

  .domino__ends-choice .button {
    flex: 1 1 auto;
  }
}
