.mg-board {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  gap: 2px;
  position: relative;
  /* поле целиком на экране: не шире колонки и не выше окна за вычетом шапки и игроков */
  width: min(100%, 680px, max(320px, calc(100vh - 400px)));
  margin: 0 auto;
  aspect-ratio: 1;
}

.mg-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  font-size: clamp(0.45rem, 1.5vw, 0.66rem);
  line-height: 1.1;
  text-align: center;
}

.mg-cell.go,
.mg-cell.jail,
.mg-cell.park,
.mg-cell.gojail {
  background: color-mix(in srgb, var(--accent) 12%, var(--bg));
}

.mg-cell.offer {
  box-shadow: inset 0 0 0 3px var(--warning);
}

.mg-cell.can {
  box-shadow: inset 0 0 0 3px var(--success);
  cursor: pointer;
}

.mg-band {
  width: 100%;
  min-height: 22%;
  font-size: 0.8em;
}

.mg-icon {
  font-size: 1.5em;
}

.mg-name {
  padding: 1px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.mg-price {
  color: var(--muted);
}

.mg-owner {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 22%;
  aspect-ratio: 1;
  border: 1px solid #fff;
  border-radius: 3px;
}

.mg-dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border: 1.5px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.mg-dot {
  margin-right: 4px;
  vertical-align: -1px;
}

.mg-center {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  justify-content: center;
  grid-row: 2 / 8;
  grid-column: 2 / 8;
  padding: 8px;
  overflow: hidden;
}

.mg-dice {
  font-size: clamp(1.8rem, 6vw, 3rem);
  line-height: 1;
}

.mg-status {
  font-weight: 700;
}

.mg-round {
  font-size: 0.75rem;
  color: var(--muted);
}

.mg .pt-seat small {
  color: var(--muted);
  font-size: 0.7rem;
}

/* ---------- фишки: отдельный слой, переезжают по клеткам ---------- */

.mg-tokens {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.mg-tok {
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  place-items: center;
  width: clamp(18px, 3.4vw, 26px);
  height: clamp(18px, 3.4vw, 26px);
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--c);
  color: #fff;
  font-size: clamp(0.6rem, 1.4vw, 0.8rem);
  font-weight: 800;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  transition: left 0.16s var(--ease), top 0.16s var(--ease), transform 0.16s var(--ease);
}

.mg-tokens.still .mg-tok {
  transition: none;
}

.mg-tok.turn {
  z-index: 1;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 45%, transparent), 0 2px 6px rgba(0, 0, 0, 0.45);
}

.mg-tok.moving {
  z-index: 2;
  scale: 1.18;
}

/* клетка, куда пришёл последний ход: рамка цвета игрока */
.mg-cell.dest {
  outline: 3px solid var(--c, var(--accent));
  outline-offset: -2px;
}

/* клетка, куда только что встали: вспышка поверх постоянной рамки */
.mg-cell.landed {
  animation: mg-landed 1.2s var(--ease);
}

@keyframes mg-landed {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--c, var(--accent)) 70%, transparent);
  }
  100% {
    box-shadow: 0 0 0 10px transparent;
  }
}

/* аватарка игрока — та же буква и цвет, что у фишки */
.mg-ava {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--c, var(--accent));
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  vertical-align: -4px;
}

.mg-status {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mg-status .mg-ava {
  margin-right: 2px;
}

.mg-dice {
  display: flex;
  gap: 4px;
}

.mg-dice span {
  display: inline-block;
}

/* бросок: кубики один раз плавно прокручиваются и останавливаются, второй чуть медленнее первого */
.mg-dice.rolling span {
  animation: mg-roll 0.8s cubic-bezier(0.15, 0.6, 0.25, 1);
}

.mg-dice.rolling span + span {
  animation-name: mg-roll-2;
}

@keyframes mg-roll {
  0% {
    transform: translateY(-8px) rotate(-360deg);
  }
  75% {
    transform: translateY(1px) rotate(4deg);
  }
  100% {
    transform: none;
  }
}

@keyframes mg-roll-2 {
  0% {
    transform: translateY(-6px) rotate(420deg);
  }
  75% {
    transform: translateY(1px) rotate(-3deg);
  }
  100% {
    transform: none;
  }
}

/* всплывающая сумма у игрока */
.mg .pt-seat {
  position: relative;
  flex-direction: row;
  gap: 10px;
  min-width: 0;
  padding: 6px 12px;
}

.mg .pt-seats {
  margin-bottom: var(--sp-2);
}

.mg-delta {
  position: absolute;
  top: -6px;
  right: 6px;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
  pointer-events: none;
  animation: mg-delta 1.8s var(--ease) forwards;
}

.mg-delta.up {
  background: var(--success);
}

.mg-delta.down {
  background: var(--danger);
}

@keyframes mg-delta {
  0% {
    opacity: 0;
    transform: translateY(6px);
  }
  15% {
    opacity: 1;
    transform: translateY(0);
  }
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-14px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .mg-tok {
    transition: none;
  }

  .mg-dice.rolling span {
    animation: none;
  }
}

/* пока идёт ход (кубики, фишка), кнопки приглушены; нажатие запоминается и срабатывает, когда фишка встанет */
.tb-actions.mg-wait {
  opacity: 0.55;
  transition: opacity var(--dur) var(--ease);
}

.tb-actions .queued {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- телефон: игроки компактно, поле с кнопками хода — на одном экране ---------- */
@media (max-width: 640px) {
  .pt-panel.mg {
    gap: 6px;
    padding: 8px 6px;
  }

  /* игроки — плашками по 3–4 в ряд: имя сверху, деньги под ним */
  .mg .pt-seats {
    gap: 4px;
    width: 100%;
    margin-bottom: 0;
  }

  .mg .pt-seat {
    flex: 1 1 64px;
    flex-direction: column;
    gap: 0;
    padding: 3px 4px;
    font-size: 0.75rem;
  }

  .mg .pt-seat b {
    max-width: 100%;
    font-size: 0.8rem;
  }

  .mg .pt-seat .mg-ava {
    width: 16px;
    height: 16px;
    margin-right: 3px;
    font-size: 0.66rem;
    vertical-align: -3px;
  }

  .mg-board {
    width: 100%;
  }

  .mg-tok {
    font-size: 0.66rem;
  }

  .mg-center {
    gap: 4px;
    padding: 4px;
  }

  .mg-center .tb-actions {
    gap: 6px;
  }

  .mg-center .tb-actions .btn {
    padding: 8px 12px;
    font-size: 0.88rem;
  }

  .mg-center .pt-muted {
    margin: 0;
    font-size: 0.75rem;
  }
}

/* узкий экран: клетки ~40 px — название улицы не прочесть, оставляем цвет района, цену и значок
   (полное название — во всплывающей подсказке клетки, в кнопке «Купить…» и в ленте событий) */
@media (max-width: 480px) {
  .mg-cell {
    justify-content: space-between;
    font-size: 0.66rem;
    line-height: 1.15;
  }

  .mg-cell .mg-name {
    display: none;
  }

  .mg-band {
    min-height: 24%;
    font-size: 0.6rem;
    line-height: 1;
  }

  .mg-icon {
    margin-top: 2px;
    font-size: 1.35em;
    line-height: 1;
  }

  .mg-price {
    padding-bottom: 2px;
    color: var(--text);
    font-weight: 700;
  }

  /* на угловых и особых клетках без цены значок — по центру */
  .mg-cell:not(:has(.mg-price)) {
    justify-content: center;
  }

  .mg-cell:not(:has(.mg-price)) .mg-icon {
    margin-top: 0;
    font-size: 1.6em;
  }
}
