:root {
  --bg: #1e1e2e;
  --panel: #2a2a3d;
  --cell: #313146;
  --cell-hover: #3a3a54;
  --text: #f2f2f7;
  --muted: #9a9ab0;
  --x-color: #ff6b6b;
  --o-color: #4dabf7;
  --win: #51cf66;
  --accent: #7c5cff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding: 16px;
}

.app {
  position: relative; /* кнопка «i» держится за правый верхний угол */
  background: var(--panel);
  border-radius: 20px;
  padding: 32px 28px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
  transition: max-width 0.15s ease;
}

.app.wide {
  max-width: 460px;
}

h1 {
  margin: 0 0 8px;
  font-size: 1.6rem;
}

.status {
  margin: 0 0 20px;
  font-size: 1.1rem;
  color: var(--muted);
  min-height: 1.4em;
}

.mark {
  font-weight: 700;
}

.mark-x {
  color: var(--x-color);
}

.mark-o {
  color: var(--o-color);
}

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 8px;
  margin: 0 auto 24px;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  transition: opacity 0.2s ease;
}

/* Онлайн: подсветка на своём ходу. Чужой ход ничем не затемняем — доска
   должна оставаться читаемой, пока соперник думает. */
.board.active {
  animation: turn-pulse 1.8s ease-in-out infinite;
}


/* Hotseat: both players share the board, so the ring shows whose mark is up. */
.board.turn-x {
  box-shadow: 0 0 0 3px var(--x-color);
}

.board.turn-o {
  box-shadow: 0 0 0 3px var(--o-color);
}

@media (prefers-reduced-motion: reduce) {
  .board.active {
    animation: none;
    box-shadow: 0 0 0 3px var(--win);
  }
}

.cell {
  background: var(--cell);
  border: none;
  border-radius: 12px;
  font-size: clamp(2rem, 8vw, 2.6rem);
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0;
  transition: background 0.15s ease, transform 0.1s ease;
}

.mark-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cell:hover:not(:disabled) {
  background: var(--cell-hover);
}

.cell:active:not(:disabled) {
  transform: scale(0.96);
}

.cell:disabled {
  cursor: default;
}

.cell.x {
  color: var(--x-color);
}

.cell.o {
  color: var(--o-color);
}

.cell.win {
  background: rgba(81, 207, 102, 0.25);
  color: var(--win);
}

.cell.win .mark-img {
  box-shadow: inset 0 0 0 3px var(--win);
}

.scoreboard {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 20px;
  font-size: 0.9rem;
  color: var(--muted);
}

.score {
  flex: 1;
  background: var(--cell);
  border-radius: 10px;
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.score-img {
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  max-width: 24px;
  max-height: 24px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
  flex-shrink: 0;
}

.score span:last-child {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}

.reset-btn {
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  padding: 12px 20px;
  border-radius: 12px;
  cursor: pointer;
  width: 100%;
  transition: filter 0.15s ease;
}

.reset-btn:hover {
  filter: brightness(1.1);
}

.reset-btn:active {
  filter: brightness(0.95);
}

.hidden {
  display: none !important;
}

.screen {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
}

.subtitle {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 1rem;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.you-are {
  margin: 0 0 4px;
  font-weight: 600;
  color: var(--muted);
}

.primary-btn,
.secondary-btn {
  border: none;
  font-size: 1rem;
  font-weight: 600;
  padding: 14px 20px;
  border-radius: 12px;
  cursor: pointer;
  width: 100%;
  transition: filter 0.15s ease, background 0.15s ease;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
}

.primary-btn:hover {
  filter: brightness(1.1);
}

.primary-btn:active {
  filter: brightness(0.95);
}

.primary-btn:disabled {
  opacity: 0.45;
  cursor: default;
  filter: none;
}

.secondary-btn {
  background: var(--cell);
  color: var(--text);
}

.secondary-btn:hover {
  background: var(--cell-hover);
}

.room-code {
  margin: 0;
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: 0.3rem;
  color: var(--accent);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.room-code-small {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.1rem;
}

.code-input {
  background: var(--cell);
  border: none;
  border-radius: 12px;
  padding: 14px;
  color: var(--text);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.3rem;
  text-align: center;
  text-transform: uppercase;
  width: 100%;
}

.code-input::placeholder {
  color: var(--muted);
  opacity: 0.5;
}

.name-input {
  background: var(--cell);
  border: none;
  border-radius: 12px;
  padding: 14px;
  color: var(--text);
  font-size: 1.1rem;
  text-align: center;
  width: 100%;
}

.name-input::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.you-name {
  color: var(--accent);
  font-weight: 700;
}

/* Под список игроков отведено постоянное место: сколько бы их ни было,
   кнопки под списком не прыгают, а лишние строки листаются внутри. */
.player-list {
  list-style: none;
  margin: 0 0 8px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: none;
  height: 178px;
  overflow-y: auto;
  text-align: left;
  background: rgba(0, 0, 0, 0.16);
  border-radius: 12px;
}

.player-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--cell);
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 0.9rem;
  width: 100%;
  color: var(--text);
  text-align: left;
}

.player-row.selectable {
  cursor: pointer;
}

.player-row.selectable:hover {
  background: var(--cell-hover);
}

.player-row.selected {
  border-color: var(--accent);
}

.player-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-tag {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--cell-hover);
  color: var(--muted);
  white-space: nowrap;
}

.player-tag.host {
  background: var(--accent);
  color: #fff;
}

.player-tag.you {
  background: var(--win);
  color: #10240f;
}

.btn-sub {
  display: block;
  font-size: 0.72rem;
  font-weight: 500;
  opacity: 0.8;
  margin-top: 2px;
}

.chat-notice {
  align-self: center;
  font-size: 0.75rem;
  color: var(--muted);
  padding: 2px 0;
}

.chat-author {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  margin-bottom: 2px;
}

.chat-msg.mine .chat-author {
  color: rgba(255, 255, 255, 0.75);
}

.chat-toggle {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 54px;
  height: 54px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  z-index: 20;
}

.chat-toggle:hover {
  filter: brightness(1.1);
}

.chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--x-color);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 20px;
}

.chat-panel {
  position: fixed;
  right: 16px;
  bottom: 82px;
  width: min(320px, calc(100vw - 32px));
  max-height: min(60vh, 460px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--panel);
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
  z-index: 20;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 0.9rem;
}

.chat-close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 6px;
}

.chat-close:hover {
  color: var(--text);
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-height: 70px;
  overflow-y: auto;
  background: var(--cell);
  border-radius: 10px;
  padding: 10px;
  text-align: left;
  font-size: 0.85rem;
}

.chat-msg {
  max-width: 85%;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--cell-hover);
  align-self: flex-start;
  word-break: break-word;
}

.chat-msg.mine {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
}

.chat-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.chat-chip {
  border: none;
  background: var(--cell);
  color: var(--text);
  font-size: 0.8rem;
  padding: 7px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.chat-chip:hover {
  background: var(--cell-hover);
}

.chat-row {
  display: flex;
  gap: 8px;
}

.chat-row input {
  flex: 1;
  min-width: 0;
  background: var(--cell);
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 0.9rem;
}

.chat-row input::placeholder {
  color: var(--muted);
}

.chat-row button {
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.15s ease;
}

.chat-row button:hover {
  filter: brightness(1.1);
}

.link-box {
  display: flex;
  gap: 8px;
}

.link-box input {
  flex: 1;
  min-width: 0;
  background: var(--cell);
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 0.85rem;
}

.link-box button {
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.15s ease;
}

.link-box button:hover {
  filter: brightness(1.1);
}

.game-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Игр больше, чем помещается на экран телефона: показываем три, остальные
   листаются в самом списке, а не уезжают вниз страницей. */
.game-list {
  max-height: 176px;
  overflow-y: auto;
  padding-right: 4px;
}

.game-list.with-sub {
  max-height: 224px;
}

/* Полоса прокрутки у этих списков тонкая: она подсказка, а не деталь. */
.player-list,
.game-list {
  scrollbar-width: thin;
  scrollbar-color: var(--cell-hover) transparent;
}

.player-list::-webkit-scrollbar,
.game-list::-webkit-scrollbar {
  width: 6px;
}

.player-list::-webkit-scrollbar-thumb,
.game-list::-webkit-scrollbar-thumb {
  background: var(--cell-hover);
  border-radius: 999px;
}

/* ---------- checkers / chess board ---------- */

.cb-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  aspect-ratio: 1 / 1;
  margin: 0 auto 20px;
  border-radius: 8px;
  overflow: hidden;
  transition: opacity 0.2s ease;
}

.cb-grid.active {
  animation: turn-pulse 1.8s ease-in-out infinite;
}


.cb-grid.turn-w {
  box-shadow: 0 0 0 3px #f2f2f7;
}

.cb-grid.turn-b {
  box-shadow: 0 0 0 3px #12121c;
}

@media (prefers-reduced-motion: reduce) {
  .cb-grid.active {
    animation: none;
    box-shadow: 0 0 0 3px var(--win);
  }
}

.cb-cell {
  border: none;
  padding: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.3rem, 6vw, 2.1rem);
  line-height: 1;
  cursor: default;
  background: #3c3c56;
}

.cb-cell.dark {
  background: #2b2b40;
}

.cb-cell.playable {
  cursor: pointer;
}

.cb-cell.selected {
  box-shadow: inset 0 0 0 3px var(--accent);
}

.cb-cell.last-move {
  box-shadow: inset 0 0 0 2px rgba(124, 92, 255, 0.55);
}

.cb-cell.target::after {
  content: "";
  position: absolute;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: var(--win);
  opacity: 0.85;
}

.cb-cell.target.capture::after {
  width: 76%;
  height: 76%;
  border-radius: 50%;
  background: transparent;
  border: 3px solid var(--x-color);
}

.cb-cell.check {
  background: rgba(255, 107, 107, 0.45);
}

.ck-piece {
  width: 72%;
  height: 72%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.45);
}

.ck-piece.w {
  background: #f0f0f5;
  color: #8a7300;
}

.ck-piece.b {
  background: #16161f;
  color: #ffd75e;
  border: 1px solid #40405a;
}

.ch-piece.w {
  color: #ffffff;
  text-shadow: 0 0 2px #000, 0 1px 2px rgba(0, 0, 0, 0.8);
}

.ch-piece.b {
  color: #15151f;
  text-shadow: 0 0 2px rgba(255, 255, 255, 0.55);
}

.mini-score {
  margin: -8px 0 14px;
  font-size: 0.85rem;
  color: var(--muted);
}

.reset-btn.danger {
  background: var(--x-color);
}

.bs-heading {
  margin: 4px 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.bs-heading.active {
  color: var(--win);
  font-weight: 700;
}

/* The turn indicator at the top scrolls out of view on phones, so the board
   you play on shows whose turn it is. */
@keyframes turn-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 3px var(--win), 0 0 14px rgba(81, 207, 102, 0.35);
  }
  50% {
    box-shadow: 0 0 0 3px var(--win), 0 0 24px rgba(81, 207, 102, 0.7);
  }
}

.bs-grid-attack {
  border-radius: 8px;
  transition: opacity 0.2s ease;
}

.bs-grid-attack.active {
  animation: turn-pulse 1.8s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .bs-grid-attack.active {
    animation: none;
    box-shadow: 0 0 0 3px var(--win);
  }
}

.bs-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
  gap: 2px;
  width: 100%;
  aspect-ratio: 1 / 1;
  margin: 0 0 16px;
}

.bs-cell {
  background: var(--cell);
  border: none;
  border-radius: 3px;
  padding: 0;
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bs-grid-attack .bs-cell,
.bs-grid-place .bs-cell {
  cursor: pointer;
}

.bs-grid-attack .bs-cell:hover:not(:disabled) {
  background: var(--cell-hover);
}

.bs-cell.preview {
  background: rgba(124, 92, 255, 0.55);
}

.bs-cell.preview-bad {
  background: rgba(255, 107, 107, 0.45);
}

.bs-cell.ship {
  background: var(--accent);
}

.bs-cell.miss::after {
  content: "";
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: var(--muted);
}

.bs-cell.hit {
  background: var(--x-color);
}

.bs-cell.hit::after {
  content: "×";
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
}

.bs-cell.sunk {
  background: #7a1f1f;
}













.modal {
  position: fixed;
  inset: 0;
  background: rgba(16, 16, 26, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 20;
}

.modal-box {
  background: var(--panel);
  border-radius: 18px;
  padding: 24px 22px;
  width: 100%;
  max-width: 320px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
}

.modal-box .subtitle {
  margin-top: 0;
}

.modal-box .hint {
  margin-bottom: 16px;
}

/* ---------- история игр ---------- */

.hist-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.hist-row {
  background: var(--cell);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hist-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.hist-game {
  font-weight: 700;
}

.hist-when {
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.hist-line {
  font-size: 0.85rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.hist-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.hist-outcome {
  font-size: 0.85rem;
  font-weight: 700;
}

.hist-outcome.won {
  color: var(--win);
}

.hist-outcome.lost {
  color: var(--x-color);
}

.hist-outcome.draw {
  color: var(--muted);
}

.hist-share {
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.hist-share:disabled {
  opacity: 0.6;
  cursor: default;
}

/* ---------- чужая победа по ссылке ---------- */

.win-card {
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.35), rgba(81, 207, 102, 0.2));
  border-radius: 16px;
  padding: 14px 16px;
  margin: 6px 0 16px;
}

.win-cup {
  margin: 0;
  font-size: 1.8rem;
  line-height: 1;
}

.win-title {
  margin: 8px 0 4px;
  font-weight: 700;
  font-size: 1.05rem;
}

.win-detail {
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: var(--text);
}

.win-invite {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.entry-block {
  background: var(--cell);
  border-radius: 14px;
  padding: 14px 14px 10px;
  margin-bottom: 12px;
}

.entry-block .name-input {
  margin-bottom: 8px;
}

.entry-title {
  margin: 0 0 10px;
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kick-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 6px;
  cursor: pointer;
}

.kick-btn:hover {
  background: var(--x-color);
  color: #fff;
}

/* ----- дурак ----- */

.dk-players {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.dk-player {
  background: var(--cell);
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.dk-player.attacker {
  border-color: var(--accent);
}

.dk-player.defender {
  border-color: var(--x-color);
}

.dk-player.out {
  opacity: 0.45;
}

.dk-player .dk-count {
  color: var(--muted);
}

.dk-middle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
  min-height: 96px;
}

.dk-deck {
  flex: 0 0 auto;
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
}

.dk-table {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.dk-pair {
  position: relative;
  width: 46px;
  height: 78px;
}

.dk-pair .dk-card {
  position: absolute;
  top: 0;
  left: 0;
}

.dk-pair .dk-card.defence {
  top: 16px;
  left: 12px;
}

.dk-hand {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-bottom: 14px;
}

.dk-card {
  width: 46px;
  height: 64px;
  border-radius: 8px;
  background: #f4f4fa;
  color: #14141f;
  border: 2px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.1;
  padding: 0;
  cursor: default;
}

.dk-card.red {
  color: #d63a3a;
}

.dk-card.back {
  background: linear-gradient(140deg, var(--accent), #4a34a8);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
}

.dk-card.playable {
  cursor: pointer;
  box-shadow: 0 0 0 2px var(--accent);
}

.dk-card.playable:hover {
  transform: translateY(-3px);
}

.dk-card.dim {
  opacity: 0.5;
}

.dk-card.chosen {
  border-color: var(--win);
}

.dk-trump {
  margin-top: 4px;
}

.dk-role {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.admin-room {
  background: var(--cell);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
  text-align: left;
}

.admin-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.admin-code {
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.admin-when {
  font-size: 0.75rem;
  color: var(--muted);
}

.admin-line {
  font-size: 0.85rem;
  margin: 2px 0;
}

.admin-line .muted {
  color: var(--muted);
}

.admin-chat {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  max-height: 140px;
  overflow-y: auto;
  font-size: 0.8rem;
}

.admin-chat div {
  margin-bottom: 3px;
}

.admin-chat .who {
  color: var(--accent);
  font-weight: 600;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: 90vw;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
  z-index: 30;
}

.admin-tools {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.admin-tools input {
  flex: 1;
  min-width: 0;
  background: var(--cell);
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 0.85rem;
}

.admin-tools .primary-btn {
  width: auto;
  padding: 10px 14px;
  margin: 0;
}

.admin-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.admin-tab {
  flex: 1;
  border: none;
  background: var(--cell);
  color: var(--muted);
  border-radius: 10px;
  padding: 8px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.admin-tab.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.admin-action {
  border: none;
  background: var(--cell-hover);
  color: var(--text);
  border-radius: 8px;
  padding: 5px 10px;
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}

.admin-action.danger {
  background: var(--x-color);
  color: #fff;
}

.admin-board {
  margin-top: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--text);
  /* Поля и доски короткие и в строку влезают всегда, а новости мафии и руки
     в дураке длинные — пусть переносятся, а не уезжают вбок. */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.admin-user {
  display: flex;
  flex-wrap: wrap; /* редактор титула встаёт отдельной строкой */
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--cell);
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 6px;
  font-size: 0.85rem;
}

.admin-user .muted {
  color: var(--muted);
  font-size: 0.78rem;
}

.msg-log {
  max-height: 260px;
  overflow-y: auto;
  text-align: left;
  margin-bottom: 12px;
}

.msg {
  background: var(--cell);
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.msg.from-admin {
  background: var(--accent);
  color: #fff;
}

.msg .when {
  display: block;
  font-size: 0.72rem;
  opacity: 0.7;
  margin-top: 3px;
}

#messageText,
.admin-reply textarea {
  width: 100%;
  background: var(--cell);
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  resize: vertical;
  margin-bottom: 10px;
}

#messageBadge,
#adminInboxBadge {
  display: inline-block;
  min-width: 18px;
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 9px;
  background: var(--x-color);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
}

.admin-thread {
  background: var(--cell);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
  text-align: left;
}

.admin-thread .msg {
  background: var(--panel);
}

.admin-reply {
  display: flex;
  gap: 6px;
  align-items: flex-start;
}

.admin-reply textarea {
  margin: 0;
}

.admin-reply .admin-action {
  white-space: nowrap;
}

/* ---------- мафия ---------- */

/* Карточка роли: цвет сразу говорит, за кого вы играете. */
.mf-card {
  background: var(--cell);
  border-left: 4px solid var(--muted);
  border-radius: 12px;
  padding: 12px 14px;
  text-align: left;
}

.mf-card.team-red {
  border-left-color: var(--win);
}

.mf-card.team-black {
  border-left-color: var(--x-color);
}

.mf-card.team-maniac {
  border-left-color: #ffa94d;
}

.mf-card.dead {
  opacity: 0.6;
}

.mf-role {
  margin: 0 0 6px;
  font-size: 1.1rem;
  font-weight: 700;
}

.mf-about {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.35;
}

.mf-news {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 132px;
  overflow-y: auto;
  text-align: left;
  scrollbar-width: thin;
  scrollbar-color: var(--cell-hover) transparent;
}

.mf-line {
  font-size: 0.85rem;
  color: var(--text);
  background: rgba(0, 0, 0, 0.16);
  border-radius: 8px;
  padding: 6px 10px;
}

/* Личное — то, что знаете только вы: проверка, лечение, подсмотренная роль. */
.mf-line.mine {
  color: #fff;
  background: rgba(124, 92, 255, 0.35);
}

.mf-list {
  height: auto;
  max-height: 270px;
  background: rgba(0, 0, 0, 0.16);
}

.mf-row.dead {
  opacity: 0.5;
}

.mf-row.dead .player-name {
  text-decoration: line-through;
}

.mf-row.ally {
  border-color: rgba(255, 107, 107, 0.5);
}

/* Ночной чат мафии и разговоры выбывших подписаны отдельно. */
.chat-msg.scope-mafia .chat-author {
  color: var(--x-color);
}

.chat-msg.scope-dead .chat-author {
  color: var(--muted);
}

/* Титул от владельца: золотая плашка рядом с ником, видна всем. */
.title-chip {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.3;
  padding: 1px 7px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffd43b, #fab005);
  color: #3b2a00;
  white-space: nowrap;
  vertical-align: middle;
}

.admin-search {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 2px solid transparent;
  background: var(--cell);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
}

.admin-search:focus {
  border-color: var(--accent);
}

.admin-title-edit {
  display: flex;
  gap: 6px;
  width: 100%;
  margin-top: 8px;
}

.admin-title-edit input {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  border-radius: 8px;
  border: none;
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
}

/* ---------- «i»: об играх и правила ---------- */

.info-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--cell-hover);
  background: transparent;
  color: var(--muted);
  font: italic 700 1rem Georgia, "Times New Roman", serif;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.info-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.info-box {
  max-width: 440px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  padding: 18px 16px 12px;
  text-align: left;
}

.info-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.info-head .subtitle {
  margin: 0;
  font-weight: 700;
  color: var(--text);
}

.info-close {
  border: none;
  background: var(--cell);
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.9rem;
}

.info-body {
  overflow-y: auto;
  font-size: 0.88rem;
  line-height: 1.45;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--cell-hover) transparent;
}

.info-body > p {
  margin: 0 0 12px;
  color: var(--muted);
}

.info-body details {
  background: var(--cell);
  border-radius: 12px;
  margin-bottom: 8px;
}

.info-body summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 14px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.info-body summary::-webkit-details-marker {
  display: none;
}

.info-body summary::after {
  content: "+";
  color: var(--muted);
  font-weight: 400;
  font-size: 1.2rem;
  line-height: 1;
}

.info-body details[open] summary::after {
  content: "−";
}

.info-body details p,
.info-body details ul {
  margin: 0 14px 10px;
}

.info-roles {
  padding-left: 18px;
}

.info-roles li {
  margin-bottom: 4px;
}
