:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #1b1b1b);
  --hint: var(--tg-theme-hint-color, #8a8a8a);
  --card: var(--tg-theme-secondary-bg-color, #f2f2f5);
  --accent: var(--tg-theme-button-color, #2f7de1);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #e0473e);
  --light: #eed8b5;
  --dark: #b58863;
  --size: min(calc(100vw - 24px), 480px);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

main { max-width: 504px; margin: 0 auto; padding: 12px; }

header h1 { margin: 0; font-size: 20px; }
.status { margin: 4px 0 10px; color: var(--hint); min-height: 21px; }
.status.alert { color: var(--danger); font-weight: 600; }
.status.turn { color: var(--accent); font-weight: 600; }

.players { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.player {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 10px; background: var(--card);
}
.player .dot { width: 14px; height: 14px; border-radius: 50%; border: 1px solid #0006; flex: none; }
.player .dot.w { background: #fff; }
.player .dot.b { background: #222; }
.player .dot:not(.w):not(.b) { display: none; } /* без цвета (бура, ожидание) — кружок ни о чём */
.player.active { outline: 2px solid var(--accent); }
.player .you { margin-left: auto; color: var(--hint); font-size: 13px; }

.board {
  width: var(--size); height: var(--size);
  display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
  border-radius: 6px; overflow: hidden; margin: 0 auto;
  box-shadow: 0 2px 10px #0003;
}
.board:empty { display: none; }
.sq {
  position: relative; display: flex; align-items: center; justify-content: center;
  min-width: 0; min-height: 0; overflow: hidden;
  font-size: calc(var(--size) / 8 * 0.74); line-height: 1; cursor: pointer;
}
.sq.l { background: var(--light); }
.sq.d { background: var(--dark); }
.sq.last::before { content: ""; position: absolute; inset: 0; background: #f6eb5a66; }
.sq.sel::before { content: ""; position: absolute; inset: 0; background: #5ab0f6aa; }
.sq.check::before { content: ""; position: absolute; inset: 0; background: radial-gradient(#ff3b30, #ff3b3000 70%); }
.sq.target::after {
  content: ""; position: absolute; width: 30%; height: 30%; border-radius: 50%; background: #0000004d;
}
.sq.target.capture::after { width: 86%; height: 86%; background: none; border: 4px solid #0000004d; }
.sq .coord { position: absolute; font-size: 10px; opacity: .7; font-weight: 600; }
.sq .coord.file { right: 3px; bottom: 1px; }
.sq .coord.rank { left: 3px; top: 1px; }
.sq.l .coord { color: var(--dark); }
.sq.d .coord { color: var(--light); }
.piece { position: relative; z-index: 1; }
.piece.w { color: #fff; text-shadow: 0 0 1px #000, 0 0 1px #000, 0 0 2px #000, 0 1px 2px #0008; }
.piece.b { color: #111; text-shadow: 0 0 1px #fff8; }

.moves {
  margin-top: 10px; padding: 8px 10px; border-radius: 10px; background: var(--card);
  font-size: 13px; color: var(--hint); max-height: 72px; overflow-y: auto;
}
.moves:empty { display: none; }

footer { margin-top: 12px; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
button {
  border: 0; border-radius: 10px; padding: 10px 18px; font: inherit; font-weight: 600;
  background: var(--accent); color: var(--accent-text);
}
button.danger { background: var(--card); color: var(--danger); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #000c; color: #fff; padding: 8px 14px; border-radius: 10px; max-width: 90vw;
}

/* выбор: игра, сила бота, число ботов */
.choices { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 8px; }
.choices p { margin: 0; text-align: center; color: var(--hint); }
.player .note { margin-left: auto; color: var(--hint); font-size: 13px; }
.player .note + .you { margin-left: 8px; }

/* шашки */
.board.checkers .sq.d { cursor: pointer; }
.board.checkers .sq.l { cursor: default; }
.disc {
  position: relative; z-index: 1; width: 74%; height: 74%; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 -4px 0 #0003, inset 0 0 0 3px #0001, 0 2px 4px #0007;
}
.disc.w { background: radial-gradient(circle at 35% 30%, #ffffff, #e4dccc); }
.disc.b { background: radial-gradient(circle at 35% 30%, #5b5b5b, #121212); }
.disc.king::after { content: "♛"; font-size: calc(var(--size) / 8 * 0.42); line-height: 1; }
.disc.w.king::after { color: #b8860b; }
.disc.b.king::after { color: #f0c040; }
.disc.gone { opacity: .35; }
.sq.can .disc { outline: 3px solid #5ab0f6; outline-offset: 1px; }

/* бура */
.table:empty { display: none; }
.table { display: flex; flex-direction: column; gap: 10px; }
.table .info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--hint); }
.table .info .pts { margin-left: auto; color: var(--text); font-weight: 600; }
.table .label { color: var(--hint); font-size: 13px; }
.felt { background: #1f6b3d; border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.felt .label { color: #d7f0dd; }
.felt.quiet { background: var(--card); }
.felt.quiet .label { color: var(--hint); }
.cards { display: flex; gap: 6px; flex-wrap: wrap; }
.card {
  width: 46px; height: 66px; border-radius: 7px; background: #fff; color: #111;
  border: 1px solid #0003; box-shadow: 0 1px 3px #0004;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1;
}
.card .r { font-weight: 700; font-size: 17px; }
.card .s { font-size: 22px; }
.card.red { color: #d42020; }
.card.back { background: repeating-linear-gradient(45deg, #2f5fb3 0 6px, #3d72cc 6px 12px); border: 2px solid #fff; }
.card.mini { width: 32px; height: 44px; }
.card.mini .r { font-size: 13px; }
.card.mini .s { font-size: 15px; }
.hand { display: flex; gap: 10px; justify-content: center; padding: 6px 0 4px; }
.card.big { width: 84px; height: 120px; border-radius: 10px; cursor: pointer; transition: transform .12s; }
.card.big .r { font-size: 30px; }
.card.big .s { font-size: 40px; }
.card.big.picked { transform: translateY(-12px); outline: 3px solid var(--accent); }
.scores { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px; border-radius: 10px; background: var(--card); }
.scores .win { font-weight: 700; }

/* ---------- мафия ---------- */
.moves { white-space: pre-line; }
.role { border-radius: 12px; padding: 10px 12px; background: var(--card); }
.role.hunter { background: #4a1414; color: #ffd9d9; }
.role.citizen { background: #14334a; color: #d9ecff; }
.role .big { font-size: 18px; font-weight: 700; }
.role .hint { font-size: 13px; opacity: .85; margin-top: 2px; }
.seats { display: flex; flex-direction: column; gap: 6px; }
.seat { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 12px; border-radius: 10px;
  background: var(--card); color: var(--text); font-size: 15px; text-align: left; border: 2px solid transparent; }
button.seat { cursor: pointer; }
.seat.voted { border-color: var(--accent); }
.seat.dead { opacity: .5; }
.seat.me .nm { font-weight: 600; }
.seat .rl { font-size: 13px; color: var(--hint); }
.seat .vt { margin-left: auto; font-weight: 600; }
.seat { flex-wrap: wrap; }
.seat .by { flex-basis: 100%; font-size: 12px; color: var(--hint); }
