:root {
  --ink: #15122b;
  --surface: #1e1a3a;
  --surface-2: #29244f;
  --line: #3a3466;
  --text: #efecff;
  --muted: #a39dca;

  /* Цвета тиров по мотивам оценок osu!: SS/S, A, B, C, D */
  --g-top1: #ffc93c;
  --g-top4: #ff6fae;
  --g-top8: #8fdc3c;
  --g-top16: #4fb6ff;
  --g-pass: #b18cff;
  --g-fail: #ff5f6d;

  /* Медали */
  --gold: #ffc93c;
  --silver: #c9cfe6;
  --bronze: #e39a5f;

  --font-display: "Unbounded", "Segoe UI", system-ui, sans-serif;
  --font-body: "Onest", "Segoe UI", system-ui, sans-serif;
  --radius: 14px;

  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font: 400 1rem/1.5 var(--font-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img {
  display: block;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-color: currentColor;
}

:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 300;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--text);
  color: var(--ink);
  font-weight: 600;
}

.skip-link:focus {
  top: 12px;
}

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

.small {
  font-size: 0.875rem;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.loading {
  color: var(--muted);
  padding: 32px 24px;
  max-width: 1200px;
  margin: 0 auto;
}

.notice {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.9375rem;
}

/* ---------- Шапка сайта ---------- */

.sitebar {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 8px 24px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--ink) 92%, transparent);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.brand {
  font: 800 1.25rem/1 var(--font-display);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand span {
  color: var(--g-top4);
}

.nav {
  display: flex;
  gap: 4px;
}

.nav a {
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.nav a:hover {
  color: var(--text);
}

.nav a[aria-current="page"] {
  background: var(--surface-2);
  color: var(--text);
}

.finder {
  position: relative;
  margin-left: auto;
}

.finder input {
  width: 260px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

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

.finder__list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  width: min(360px, calc(100vw - 32px));
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgb(0 0 0 / 0.45);
}

.finder__item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.finder__item[aria-selected="true"],
.finder__item:hover {
  background: var(--surface-2);
}

.finder__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.finder__hint {
  color: var(--muted);
  font-size: 0.8125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.finder__empty {
  padding: 10px;
  color: var(--muted);
}

/* Аккаунт в шапке */
.account {
  display: flex;
  align-items: center;
  gap: 8px;
}

.account:empty {
  display: none;
}

.account__in {
  height: 36px;
}

.account__me {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 180px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.account__me span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.account__out {
  padding: 4px 8px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 0.875rem;
  cursor: pointer;
}

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

/* ---------- Страница ---------- */

main {
  flex: 1;
  outline: none;
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px 24px;
}

.page--wide {
  max-width: 1440px;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 32px;
  margin-bottom: 18px;
}

.page-title {
  margin: 0;
  font: 800 clamp(1.375rem, 1rem + 1.2vw, 2rem)/1.15 var(--font-display);
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.lead {
  margin: 8px 0 20px;
  color: var(--muted);
  max-width: 70ch;
}

.lead--tight {
  margin: 4px 0 0;
}

.block {
  margin-top: 40px;
}

.block--flush {
  margin-top: 0;
}

.block__title {
  margin: 0 0 12px;
  font: 700 1.125rem/1.3 var(--font-display);
}

.footer {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 24px 40px;
  color: var(--muted);
  font-size: 0.8125rem;
}

/* ---------- Кнопки и поля ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.search input {
  width: 220px;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--text);
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover {
  background: #fff;
}

.btn--quiet {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.btn--quiet:hover {
  background: var(--surface);
}

.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 16px;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface);
}

.seg__btn {
  height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
}

.seg__btn[aria-pressed="true"] {
  background: var(--surface-2);
  color: var(--text);
}

.field {
  display: grid;
  gap: 6px;
  font-size: 0.875rem;
  color: var(--muted);
}

.field select {
  min-width: 240px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}

/* ---------- Мелкие элементы ---------- */

.flag {
  width: 28px;
  height: 21px;
  border-radius: 4px;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgb(255 255 255 / 0.12);
  flex: none;
}

.country-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 500;
}

.country-link:hover span {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.country-link .flag + .flag {
  margin-left: -6px;
}

.captain {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--g-top1);
  color: var(--ink);
  font: 700 0.625rem/1 var(--font-display);
  text-decoration: none;
  vertical-align: 1px;
  cursor: help;
}

.result {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
}

.result--p1 { background: var(--gold); color: var(--ink); }
.result--p2 { background: var(--silver); color: var(--ink); }
.result--p3 { background: var(--bronze); color: var(--ink); }
.result--none { background: transparent; color: var(--muted); padding: 0; }

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  vertical-align: 1px;
}

.tag--live { border-color: var(--g-top8); color: var(--g-top8); }
.tag--new { border-color: var(--g-top8); color: var(--g-top8); margin-left: 6px; }
.tag--gone { border-color: var(--g-fail); color: var(--g-fail); margin-left: 6px; }
.tag--support { border-color: var(--g-top4); color: var(--g-top4); }

.medals {
  display: inline-flex;
  gap: 6px;
}

.medal {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border-radius: 999px;
  color: var(--ink);
  font: 700 0.75rem/1 var(--font-display);
}

.medal--p1 { background: var(--gold); }
.medal--p2 { background: var(--silver); }
.medal--p3 { background: var(--bronze); }

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: cover;
  flex: none;
  background: var(--surface-2);
}

.avatar--empty {
  display: inline-block;
}

.avatar--xl {
  width: 112px;
  height: 112px;
  border-radius: 24px;
  box-shadow: 0 0 0 3px var(--ink), 0 0 0 5px var(--line);
}

/* ---------- Таблицы ---------- */

.table-wrap {
  position: relative;
  overflow-x: auto;
  border-radius: var(--radius);
  background: var(--surface);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.table th,
.table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.table thead th {
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
}

.table tbody th {
  font-weight: 500;
}

.table tbody tr:last-child > * {
  border-bottom: 0;
}

.table tbody tr:hover {
  background: color-mix(in srgb, var(--surface-2) 55%, transparent);
}

.table tfoot th,
.table tfoot td {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.table thead th.num,
.table td.num {
  text-align: right;
}

.table--edition td:last-child {
  min-width: 320px;
}

.inline-list {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.podium-inline {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px 16px;
}

/* ---------- Сборная ---------- */

.team-head {
  display: flex;
  align-items: center;
  gap: 20px;
}

.team-head__flag {
  width: 96px;
  height: 72px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgb(255 255 255 / 0.12);
  flex: none;
}

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 40px;
  margin: 24px 0 0;
}

.facts__item dt {
  color: var(--muted);
  font-size: 0.8125rem;
}

.facts__item dd {
  margin: 4px 0 0;
  font-weight: 500;
}

.compare__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-bottom: 12px;
}

.compare__summary {
  margin: 0 0 16px;
}

.compare__summary:empty {
  display: none;
}

.compare__tables {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: 16px;
  align-items: start;
}

.roster-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 12px;
  margin-bottom: 10px;
}

.roster-card__head h3 {
  margin: 0;
  font: 700 1rem/1.3 var(--font-display);
}

/* Схема замен: [было] —линия— [стало]. Линия занимает среднюю колонку
   и упирается в обе карточки, поэтому читается как связь между ними. */
.lineup {
  --link-w: 150px;
}

.lineup__rows {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.lineup__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--link-w) minmax(0, 1fr);
  align-items: stretch;
}

.lineup__row--head {
  align-items: end;
  margin-bottom: 10px;
}

.lineup__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
}

.lineup__head h3 {
  margin: 0;
  font: 700 1rem/1.3 var(--font-display);
}

.lineup__arrow {
  align-self: center;
  color: var(--muted);
  text-align: center;
  font-size: 1.25rem;
}

.lineup__card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 56px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--surface);
}

.lineup__who {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.lineup__who a {
  font-weight: 500;
  text-decoration: none;
}

.lineup__who a:hover {
  text-decoration: underline;
}

.lineup__stat {
  display: grid;
  justify-items: end;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  white-space: nowrap;
}

.lineup__stat small {
  color: var(--muted);
  font-size: 0.75rem;
}

.lineup__empty {
  display: grid;
  place-items: center;
  min-height: 56px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-size: 0.8125rem;
}

.lineup__link {
  --c: var(--line);
  position: relative;
  display: grid;
  place-items: center;
}

/* сама линия */
.lineup__link::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  translate: 0 -50%;
  background: var(--c);
}

/* наконечник стрелки у правой карточки */
.lineup__link::after {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  translate: 0 -50%;
  border: 6px solid transparent;
  border-left: 9px solid var(--c);
  border-right: 0;
}

.lineup__label {
  position: relative;
  padding: 2px 10px;
  border: 1px solid var(--c);
  border-radius: 999px;
  background: var(--ink);
  color: var(--c);
  font-size: 0.8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.lineup__short {
  display: none;
}

.lineup__link--kept {
  --c: var(--muted);
}

.lineup__link--kept::before {
  height: 0;
  border-top: 2px dashed var(--line);
  background: none;
}

.lineup__link--kept::after {
  display: none;
}

.lineup__link--kept .lineup__label {
  border-color: var(--line);
  font-weight: 500;
}

.lineup__link--swap { --c: var(--g-top16); }
.lineup__link--up { --c: var(--g-top8); }
.lineup__link--down { --c: var(--g-fail); }
.lineup__link--added { --c: var(--g-top8); }

/* ушёл без замены: линия гаснет к правому краю, без стрелки */
.lineup__link--vacated {
  --c: var(--g-fail);
}

.lineup__link--vacated::before {
  background: linear-gradient(90deg, var(--c), transparent);
}

.lineup__link--vacated::after {
  display: none;
}

/* состав ещё не объявлен: пунктир без стрелки */
.lineup__link--pending {
  --c: var(--muted);
}

.lineup__link--pending::before {
  height: 0;
  border-top: 2px dotted var(--line);
  background: none;
}

.lineup__link--pending::after {
  display: none;
}

.lineup__link--pending .lineup__label {
  border-color: var(--line);
  font-weight: 500;
}

/* новое место: линия проявляется слева */
.lineup__link--added::before {
  background: linear-gradient(90deg, transparent, var(--c) 60%);
}

.lineup__row--foot {
  margin-top: 10px;
  align-items: center;
}

.lineup__row--foot .lineup__link::after {
  display: none;
}

.lineup__avg {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 0.875rem;
}

.lineup__avg b {
  color: var(--text);
  font-weight: 600;
}

.lineup__note {
  margin: 14px 0 0;
}

@media (max-width: 640px) {
  .lineup {
    --link-w: 52px;
  }

  .lineup__full {
    display: none;
  }

  .lineup__short {
    display: inline;
  }

  .lineup__label {
    padding: 1px 6px;
    font-size: 0.6875rem;
  }

  .lineup__link--kept .lineup__label {
    display: none;
  }

  .lineup__card {
    flex-wrap: wrap;
    gap: 2px 8px;
    padding: 8px 10px;
  }

  .lineup__card .avatar {
    display: none;
  }

  /* На телефоне ранг и o!TR идут одной строкой под ником; pp видно в таблице и профиле */
  .lineup__card {
    overflow: hidden;
  }

  .lineup__card .statmini {
    grid-template-columns: repeat(2, auto auto);
    justify-content: start;
    column-gap: 4px;
    width: 100%;
  }

  .lineup__card .statmini dd {
    margin-right: 6px;
  }

  .lineup__card .statmini dt:nth-of-type(3),
  .lineup__card .statmini dd:nth-of-type(3) {
    display: none;
  }

  .lineup__head {
    flex-direction: column;
    align-items: flex-start;
  }

  .lineup__avg {
    padding: 0 4px;
  }
}

.who {
  display: flex;
  align-items: center;
  gap: 10px;
}

.who__text {
  min-width: 0;
}

.who__old {
  display: block;
  font-weight: 400;
  font-size: 0.75rem;
}

/* Матрица «игрок × турнир» */
.matrix-wrap {
  position: relative; /* удерживает скрытые подписи внутри прокрутки */
  overflow: auto;
  max-height: 80vh;
  border-radius: var(--radius);
  background: var(--surface);
}

.matrix {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
}

.matrix th,
.matrix td {
  padding: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}

.matrix thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-weight: 500;
  font-size: 0.8125rem;
  text-align: left;
}

.matrix__player {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 180px;
  max-width: 220px;
  padding: 8px 14px !important;
  background: var(--surface);
  font-weight: 500;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.matrix thead .matrix__player {
  z-index: 3;
}

.matrix__rank {
  padding: 8px 12px !important;
  color: var(--muted);
}

.matrix tbody tr:hover > * {
  background: var(--surface-2);
}

.matrix__ed button {
  display: grid;
  justify-items: center;
  gap: 4px;
  width: 52px;
  padding: 10px 0 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.matrix__ed button:hover {
  color: var(--text);
}

.matrix__year {
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.matrix__res {
  display: grid;
  place-items: center;
  min-width: 26px;
  height: 20px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font: 600 0.6875rem/1 var(--font-body);
}

.matrix__res--p1 { background: var(--gold); color: var(--ink); }
.matrix__res--p2 { background: var(--silver); color: var(--ink); }
.matrix__res--p3 { background: var(--bronze); color: var(--ink); }

.matrix__cell {
  width: 52px;
  height: 38px;
  text-align: center;
}

.matrix .is-a {
  background: color-mix(in srgb, var(--g-top16) 12%, var(--surface));
}

.matrix .is-b {
  background: color-mix(in srgb, var(--g-pass) 12%, var(--surface));
}

.matrix thead .is-a button,
.matrix thead .is-b button {
  color: var(--text);
}

/* Отметка в матрице — маленький хит-круг */
.dot {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text);
  vertical-align: middle;
}

.dot--captain {
  width: 20px;
  height: 20px;
  background: var(--g-top1);
}

.dot--captain::after {
  content: "К";
  color: var(--ink);
  font: 700 0.5625rem/1 var(--font-display);
}

/* ---------- Игрок ---------- */

.player-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px 24px;
  padding: 28px;
  border-radius: var(--radius);
  background-color: var(--surface);
  background-size: cover;
  background-position: center;
}

.player-hero__text {
  flex: 1 1 280px;
  min-width: 0;
}

.player-hero__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin: 10px 0 0;
}

.player-hero .muted {
  margin: 8px 0 0;
}

.player-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 32px;
  margin-top: 32px;
  align-items: start;
}

.statgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  margin: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

/* Линии сетки — тенью внутри ячеек, чтобы пустой хвост последнего ряда не закрашивался */
.statgrid__item {
  padding: 12px 14px;
  box-shadow: inset -1px -1px 0 var(--line);
}

.statgrid__item dt {
  color: var(--muted);
  font-size: 0.8125rem;
}

.statgrid__item dd {
  margin: 4px 0 0;
  font: 700 1.0625rem/1.25 var(--font-display);
  font-variant-numeric: tabular-nums;
}

.statgrid__item small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font: 400 0.75rem/1.3 var(--font-body);
}

.grades {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.grade {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  background: var(--surface);
  font-variant-numeric: tabular-nums;
}

.grade b {
  display: grid;
  place-items: center;
  min-width: 34px;
  height: 26px;
  border-radius: 999px;
  color: var(--ink);
  font: 800 0.75rem/1 var(--font-display);
}

.grade--ss b { background: var(--silver); }
.grade--s b { background: var(--gold); }
.grade--a b { background: var(--g-top8); }

.rankchart {
  margin: 0 0 8px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface);
}

.rankchart figcaption {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.875rem;
}

.rankchart figcaption b {
  color: var(--text);
  font-weight: 600;
}

.rankchart .up { color: var(--g-top8); }
.rankchart .down { color: var(--g-fail); }

.rankchart__svg {
  display: block;
  width: 100%;
  height: 72px;
}

.rankchart__svg polyline {
  fill: none;
  stroke: var(--g-top4);
  stroke-width: 2;
  stroke-linejoin: round;
}

.timeline {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
  border-radius: var(--radius);
  background: var(--surface);
}

.timeline__item {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.timeline__item:last-child {
  border-bottom: 0;
}

.timeline__item .captain {
  margin-left: -6px;
}

.timeline__item:has(.captain) {
  grid-template-columns: 96px minmax(0, 1fr) auto auto;
}

.timeline__ed {
  color: var(--muted);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.badges img {
  width: 86px;
  height: 40px;
  border-radius: 4px;
}

/* ---------- Пик'ем ---------- */

.pk-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.pk-tab {
  display: grid;
  gap: 2px;
  min-width: 150px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  text-decoration: none;
}

.pk-tab span {
  font: 700 0.9375rem/1.2 var(--font-display);
}

.pk-tab small {
  color: var(--muted);
  font-size: 0.75rem;
}

.pk-tab:hover {
  background: var(--surface);
}

.pk-tab[aria-current="page"] {
  border-color: var(--g-top4);
  background: color-mix(in srgb, var(--g-top4) 12%, var(--surface));
}

.pk-login {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 16px;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: var(--surface);
}

.pk-login p {
  margin: 0;
  max-width: 60ch;
}

.pk-status {
  min-height: 1.5em;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.875rem;
}

.pk-rules {
  margin: 0 0 16px;
  max-width: 80ch;
}

.pk-total {
  margin: 0 0 16px;
  font: 700 1.0625rem/1.3 var(--font-display);
}

.pk-empty {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.pk-empty p {
  margin: 0;
  max-width: 70ch;
}

.pk-groups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.pk-group {
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface);
}

.pk-group__head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}

.pk-group__head h3 {
  margin: 0;
  font: 700 1rem/1.2 var(--font-display);
}

.pk-group__head .tag {
  margin-left: auto;
}

.pk-group__note {
  margin: 10px 0 0;
}

.pk-order {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pk-order__row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 4px 6px 4px 4px;
  border-radius: 10px;
  background: var(--surface-2);
}

.pk-order__row.is-hit {
  box-shadow: inset 3px 0 0 var(--g-top8);
}

.pk-order__row.is-miss {
  box-shadow: inset 3px 0 0 var(--g-fail);
}

/* Номер места — хит-круг, как в тир-листе */
.pk-order__pos {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border: 2px solid var(--line);
  border-radius: 50%;
  font: 700 0.75rem/1 var(--font-display);
  color: var(--muted);
}

.pk-order__row:nth-child(-n + 2) .pk-order__pos {
  border-color: var(--g-top8);
  color: var(--text);
}

.pk-order__team {
  display: inline-flex;
  flex: 1;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-weight: 500;
}

.pk-order__team > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pk-order__moves {
  display: flex;
  gap: 2px;
}

.pk-move {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.75rem;
  cursor: pointer;
}

.pk-move:hover:not(:disabled) {
  background: var(--surface);
  color: var(--text);
}

.pk-move:disabled {
  opacity: 0.3;
  cursor: default;
}

/* Квалификация: список слева, корзины справа, между ними пунктирные линии как в сетке */
.qf {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0 56px;
  align-items: start;
}

.qf-pool {
  position: relative;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
}

/* хвост линии из списка к корзинам */
.qf-pool::after {
  content: "";
  position: absolute;
  top: 36px;
  right: -28px;
  width: 28px;
  border-top: 2px dashed var(--line);
}

.qf-pool__head,
.qf-dest__head {
  display: grid;
  gap: 2px;
  margin-bottom: 10px;
  text-align: left;
}

.qf-pool__head b,
.qf-dest__head b {
  font: 700 1rem/1.2 var(--font-display);
}

.qf-pool__head small,
.qf-dest__head small {
  color: var(--muted);
  font-size: 0.75rem;
}

.qf-pool__teams,
.qf-dest__teams {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.qf-dests {
  position: relative;
  display: grid;
  gap: 12px;
}

/* вертикальная линия, от которой расходятся корзины */
.qf-dests::before {
  content: "";
  position: absolute;
  top: 36px;
  bottom: 30px;
  left: -28px;
  border-left: 2px dashed var(--line);
}

.qf-dest {
  position: relative;
  padding: 14px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--surface);
}

.qf-dest::before {
  content: "";
  position: absolute;
  top: 34px;
  left: -29px;
  width: 29px;
  border-top: 2px dashed var(--line);
}

.qf-dest.is-active {
  border-color: var(--g-top4);
}

.qf-dest[data-slot="legends"] .qf-dest__head b { color: var(--gold); }

button.qf-dest__head {
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.qf-dest--out {
  background: transparent;
  border: 1px dashed var(--line);
}

.qf-dest--out .qf-dest__head {
  margin: 0;
}

.qf-dests--plain::before,
.qf-dests--plain .qf-dest::before {
  display: none;
}

/* ---------- Сетка плей-офф ---------- */

.bk-scroll {
  overflow-x: auto;
  padding-bottom: 8px;
  border-radius: var(--radius);
}

.bk {
  --match-h: 64px;
  --match-gap: 14px;
  position: relative;
  display: grid;
  grid-template-columns: repeat(10, 188px);
  grid-template-rows: auto auto calc(8 * (var(--match-h) + var(--match-gap))) auto auto calc(8 * (var(--match-h) + var(--match-gap)));
  column-gap: 36px;
  width: max-content;
  padding: 4px 4px 4px 0;
}

.bk__lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

.bk__lines path {
  fill: none;
  stroke: var(--line);
  stroke-width: 2;
  stroke-dasharray: 4 4;
}

.bk__lines path.is-on {
  stroke: color-mix(in srgb, var(--g-top4) 70%, transparent);
  stroke-dasharray: none;
}

.bk__side {
  margin: 18px 0 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--line);
  font: 800 1.125rem/1.2 var(--font-display);
}

.bk__side:first-child,
.bk > .bk__side:nth-of-type(1) {
  margin-top: 0;
}

.bk__title {
  display: grid;
  gap: 2px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: none;
}

.bk__title small {
  font-weight: 400;
  opacity: 0.8;
}

.bk__col {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
}

/* Матч всегда ровно посередине колонки, подпись над ним, итог под ним — так оба матча гранд-финала на одной линии */
.bk__final {
  display: grid;
  grid-template-rows: 1fr auto 1fr;
}

.bk__final > .bk__title {
  align-self: end;
}

.bk__final > :nth-child(3) {
  align-self: start;
}

.bk__champion {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 10px 0 0;
  color: var(--gold);
  font-size: 0.875rem;
  font-weight: 600;
}

.bk__champion small {
  color: var(--g-top8);
  font-weight: 700;
}

.bk__champion.is-miss small {
  color: var(--muted);
}

.bk__champion-note {
  margin: 10px 0 0;
}

.bk-match {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: 1fr 1fr;
  height: var(--match-h);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.bk-match.is-hit {
  border-color: var(--g-top8);
}

.bk-match.is-miss {
  border-color: color-mix(in srgb, var(--g-fail) 70%, transparent);
}

.bk-match__no {
  position: absolute;
  top: -8px;
  left: 8px;
  padding: 0 5px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--muted);
  font: 600 0.625rem/16px var(--font-body);
}

.bk-match__pts {
  position: absolute;
  top: -8px;
  right: 8px;
  padding: 0 5px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--g-top8);
  font: 700 0.625rem/16px var(--font-body);
}

.bk-match.is-miss .bk-match__pts {
  color: var(--muted);
}

/* Сброс сетки, который по прогнозу не понадобится */
.bk-match--skip {
  grid-template-rows: 1fr;
  border-style: dashed;
  background: none;
}

.bk-match--skip .bk-team {
  white-space: normal;
  line-height: 1.3;
}

.bk-team {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 0 10px;
  border: 0;
  background: none;
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
}

.bk-team + .bk-team {
  border-top: 1px solid var(--line);
}

.bk-team .flag {
  width: 22px;
  height: 16px;
  border-radius: 3px;
}

.bk-team > span:not(.bk-team__real) {
  overflow: hidden;
  text-overflow: ellipsis;
}

button.bk-team {
  cursor: pointer;
}

button.bk-team:hover {
  background: var(--surface-2);
}

.bk-team:first-of-type {
  border-radius: 9px 9px 0 0;
}

.bk-team:last-of-type {
  border-radius: 0 0 9px 9px;
}

.bk-team.is-picked {
  background: color-mix(in srgb, var(--g-top4) 18%, var(--surface));
  box-shadow: inset 3px 0 0 var(--g-top4);
  font-weight: 700;
}

.bk-team.is-out {
  color: var(--muted);
}

.bk-team.is-out .flag {
  opacity: 0.5;
}

.bk-team--tbd {
  color: var(--muted);
  font-size: 0.75rem;
  font-style: italic;
  font-weight: 400;
}

.bk-team__real {
  margin-left: auto;
  color: var(--g-top8);
  font-weight: 700;
}

.pk-slots {
  display: grid;
  gap: 8px;
  margin-bottom: 24px;
}

.pk-slot {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: center;
  gap: 8px 16px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--surface);
}

.pk-slot.is-active {
  border-color: var(--g-top4);
}

.pk-slot__head {
  display: grid;
  gap: 2px;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}

.pk-slot__head:disabled {
  cursor: default;
}

.pk-slot__head b {
  font: 700 0.9375rem/1.2 var(--font-display);
}

.pk-slot__head small {
  color: var(--muted);
  font-size: 0.75rem;
}

.pk-slot__teams,
.pk-pool__teams {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pk-chip {
  cursor: pointer;
}

.pk-chip:disabled,
span.pk-chip {
  cursor: default;
}

.pk-chip.is-hit {
  border-color: var(--g-top8);
}

.pk-chip.is-miss {
  opacity: 0.6;
}

.pk-chip small {
  color: var(--muted);
  font-size: 0.75rem;
}

.pk-seed {
  min-width: 2.2em;
  font-variant-numeric: tabular-nums;
}

.pk-user {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px;
}

.pk-user .lead {
  display: flex;
  align-items: center;
  gap: 8px;
}

.table tr.is-me {
  background: color-mix(in srgb, var(--g-top4) 12%, transparent);
}

@media (max-width: 900px) {
  .qf {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }

  .qf-pool::after,
  .qf-dests::before,
  .qf-dest::before {
    display: none;
  }
}

@media (max-width: 640px) {
  .pk-tab {
    flex: 1 1 40%;
    min-width: 0;
    padding: 8px 10px;
  }

  .bk {
    grid-template-columns: repeat(9, 160px);
    column-gap: 28px;
  }

  .pk-slot {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- o!TR ---------- */

/* Цвета тиров o!TR */
.tier-tag {
  --t: var(--muted);
  display: block;
  width: fit-content;
  margin-top: 2px;
  padding: 0 7px;
  border: 1px solid color-mix(in srgb, var(--t) 55%, transparent);
  border-radius: 999px;
  color: var(--t);
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

/* Палитра тиров с самого o!TR (тёмная тема, apps/web/lib/kit/color/tiers.ts) */
.tier-tag[data-tier="bronze"] { --t: #c8732d; }
.tier-tag[data-tier="silver"] { --t: #b3b3b3; }
.tier-tag[data-tier="gold"] { --t: #ddb246; }
.tier-tag[data-tier="platinum"] { --t: #3691b5; }
.tier-tag[data-tier="emerald"] { --t: #2dd26f; }
.tier-tag[data-tier="diamond"] { --t: #b961e5; }
.tier-tag[data-tier="master"] { --t: #a467ff; }
.tier-tag[data-tier="grandmaster"] { --t: #f9433e; }
.tier-tag[data-tier="elitegrandmaster"] { --t: #4e93fc; }

.otr-credit {
  color: var(--muted);
}

.roster__credit {
  margin: 12px 0 0;
}

.player-side {
  display: grid;
  gap: 28px;
  align-content: start;
}

.loading--inline {
  padding: 0;
  margin: 0;
}

.otr-card {
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--surface);
}

.otr-card__main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}

.otr-card__main .tier-tag {
  margin: 0;
  font-size: 0.8125rem;
  padding: 2px 10px;
}

.otr-card__value {
  font: 800 2rem/1 var(--font-display);
  font-variant-numeric: tabular-nums;
}

.otr-card__facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px 16px;
  margin: 14px 0 0;
}

.otr-card__facts dt {
  color: var(--muted);
  font-size: 0.75rem;
}

.otr-card__facts dd {
  margin: 2px 0 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Мини-статистика игрока: ранг / o!TR / pp */
.statmini {
  display: grid;
  grid-template-columns: auto auto;
  column-gap: 8px;
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.statmini dt {
  color: var(--muted);
  font-size: 0.6875rem;
  text-align: right;
  align-self: center;
}

.statmini dd {
  margin: 0;
  text-align: right;
}

.statmini dd:nth-of-type(2) {
  color: var(--g-top1);
  font-weight: 600;
}

.plays {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.play {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto 80px 90px;
  align-items: center;
  gap: 14px;
  padding: 8px 14px 8px 8px;
  border-radius: 12px;
  background: var(--surface);
}

.play__cover {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-2);
}

.play__map {
  display: grid;
  min-width: 0;
}

.play__map a {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  text-decoration: none;
}

.play__map a:hover {
  text-decoration: underline;
}

.play__mods {
  display: flex;
  gap: 4px;
}

.mod {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  font: 700 0.6875rem/1.2 var(--font-display);
}

.play__acc {
  color: var(--muted);
}

.play__pp {
  font: 700 1rem/1 var(--font-display);
}

.pager {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  font-size: 0.875rem;
}

.pager a {
  color: var(--muted);
  text-decoration: none;
}

.pager a:hover {
  color: var(--text);
}

/* ---------- Тир-лист ---------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
}

.board {
  display: grid;
  gap: 20px;
  min-width: 0;
}

.tiers {
  display: grid;
  gap: 6px;
}

.tier {
  display: grid;
  grid-template-columns: 172px minmax(0, 1fr);
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}

.tier__label {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-content: center;
  column-gap: 16px;
  row-gap: 2px;
  min-height: 76px;
  padding: 12px 14px 12px 18px;
  background: color-mix(in srgb, var(--tier) 14%, var(--surface));
  border-right: 1px solid color-mix(in srgb, var(--tier) 35%, transparent);
}

/* Метка тира — хит-круг с approach-кольцом */
.tier__mark {
  position: relative;
  grid-row: 1 / 3;
  align-self: center;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 4px solid var(--tier);
  border-radius: 50%;
  background: color-mix(in srgb, var(--tier) 28%, var(--ink));
  font: 800 1.0625rem/1 var(--font-display);
  color: #fff;
}

.tier__mark svg {
  width: 22px;
  height: 22px;
}

.tier__ring {
  position: absolute;
  inset: -8px;
  border: 2px solid var(--tier);
  border-radius: 50%;
  opacity: 0.45;
  pointer-events: none;
}

.tier__name {
  align-self: end;
  font-weight: 600;
  font-size: 0.9375rem;
  line-height: 1.2;
  /* Колонка подписи узкая: длинное слово переносим, а не выпускаем на соседнюю зону */
  overflow-wrap: anywhere;
  hyphens: auto;
}

.tier__count {
  align-self: start;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

/* В тир положили больше сборных, чем в нём мест */
.tier__count.is-over {
  color: var(--g-fail);
  font-weight: 600;
}

.zone {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
  min-height: 76px;
  padding: 12px;
  transition: background-color 0.12s;
}

.zone:empty {
  align-content: center;
}

.zone:empty::before {
  content: attr(data-empty);
  align-self: center;
  color: var(--muted);
  font-size: 0.875rem;
  opacity: 0.7;
}

.zone.is-over {
  background: color-mix(in srgb, var(--tier, var(--text)) 12%, transparent);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px 0 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.9375rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: grab;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  transition: opacity 0.15s, border-color 0.15s;
}

.chip .flag {
  pointer-events: none;
}

.chip:hover {
  border-color: var(--muted);
}

.chip.is-selected {
  border-color: var(--text);
  box-shadow: 0 0 0 1px var(--text);
}

.chip.is-dim {
  opacity: 0.22;
}

.chip.is-placeholder {
  opacity: 0.35;
  border-style: dashed;
  border-color: var(--text);
}

.chip-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  margin: 0;
  pointer-events: none;
  cursor: grabbing;
  border-color: var(--text);
  box-shadow: 0 12px 28px rgb(0 0 0 / 0.45);
  will-change: transform;
}

body.is-dragging,
body.is-dragging * {
  cursor: grabbing !important;
}

.pool {
  background: var(--surface);
  border-radius: var(--radius);
}

.pool__title {
  margin: 0;
  padding: 16px 16px 0;
  font: 700 1rem/1.3 var(--font-display);
}

.pool__count {
  margin-left: 6px;
  color: var(--muted);
  font-weight: 500;
}

.zone--pool {
  min-height: 120px;
  padding: 12px 16px 16px;
}

/* Панель состава в тир-листе */
.roster {
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  padding: 24px;
  background: var(--surface);
  border-radius: var(--radius);
  outline: none;
}

.roster__empty p {
  margin: 0;
  color: var(--muted);
}

.roster__body {
  position: relative;
}

.roster__close {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.roster__close:hover {
  background: var(--surface-2);
  color: var(--text);
}

.roster__flags {
  display: flex;
  gap: 8px;
}

.roster__flag {
  width: 72px;
  height: 54px;
  border-radius: 6px;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgb(255 255 255 / 0.12);
}

.roster__name {
  margin: 14px 0 4px;
  font: 700 1.5rem/1.15 var(--font-display);
  overflow-wrap: anywhere;
}

.roster__status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.9375rem;
}

.roster__status::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--tier, var(--line));
}

.roster__history {
  display: inline-block;
  margin-bottom: 14px;
  font-size: 0.9375rem;
}

/* Номера игроков — маленькие хит-круги с комбо-номером */
.roster__players {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: slot;
}

.roster__players li {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  counter-increment: slot;
}

.roster__players li::before {
  content: counter(slot);
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border: 2px solid var(--line);
  border-radius: 50%;
  font: 700 0.75rem/1 var(--font-display);
  color: var(--muted);
}

.roster__who {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.roster__who a {
  font-weight: 500;
  text-decoration: none;
}

.roster__who a:hover {
  text-decoration: underline;
}

.roster__stat {
  display: grid;
  justify-items: end;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.roster__stat small {
  color: var(--muted);
  font-size: 0.75rem;
}

.roster__players .is-vacant {
  color: var(--muted);
  opacity: 0.6;
}

.roster__note {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.875rem;
}

.roster__subhead {
  margin: 24px 0 10px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
}

.roster__moves {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.move {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  font-size: 0.875rem;
  text-align: left;
  cursor: pointer;
}

.move::before {
  content: "";
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--tier, var(--muted));
}

.move:hover {
  background: var(--surface-2);
}

.move[aria-pressed="true"] {
  border-color: var(--tier, var(--text));
  background: color-mix(in srgb, var(--tier, var(--text)) 16%, transparent);
  cursor: default;
}

.move--wide {
  grid-column: 1 / -1;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 200;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--text);
  color: var(--ink);
  font-weight: 600;
  translate: -50% 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, translate 0.2s;
}

.toast.is-visible {
  opacity: 1;
  translate: -50% 0;
}

/* ---------- Узкие экраны ---------- */

/* Шапка: на средних экранах поиск уходит на вторую строку */
@media (max-width: 1080px) {
  .sitebar {
    flex-wrap: wrap;
  }

  .account {
    margin-left: auto;
  }

  .finder {
    order: 3;
    flex: 1 1 100%;
    margin-left: 0;
  }

  .finder input {
    width: 100%;
  }

  .finder__list {
    left: 0;
    right: auto;
    width: 100%;
  }
}

@media (max-width: 980px) {
  .layout,
  .player-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Состав в тир-листе превращается в нижнюю шторку */
  .roster {
    position: fixed;
    inset: auto 0 0 0;
    top: auto;
    z-index: 70;
    max-height: 78vh;
    padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -16px 40px rgb(0 0 0 / 0.5);
    transform: translateY(105%);
    visibility: hidden;
    transition: transform 0.25s ease, visibility 0s linear 0.25s;
  }

  .roster.is-open {
    transform: none;
    visibility: visible;
    transition: transform 0.25s ease;
  }

  .roster__empty {
    display: none;
  }

  .roster__close {
    top: -12px;
    right: -4px;
  }
}

@media (max-width: 760px) {
  .sitebar {
    padding: 10px 16px;
  }

  /* Телефон: логотип и аккаунт, ниже меню с прокруткой, ниже поиск */
  .account {
    order: 1;
  }

  .nav {
    order: 2;
    flex: 1 1 100%;
    margin: 0 -16px;
    padding: 0 12px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .account__me span {
    display: none;
  }

  .nav a {
    padding: 6px 10px;
    font-size: 0.875rem;
  }

  .sitebar {
    position: static;
  }

  .roster {
    top: auto;
  }

  .play {
    grid-template-columns: 48px minmax(0, 1fr) auto;
  }

  .play__cover {
    width: 48px;
    height: 48px;
  }

  .play__mods {
    display: none;
  }

  .play__acc {
    display: none;
  }
}

@media (max-width: 640px) {
  .page {
    padding: 20px 16px 16px;
  }

  .footer {
    padding: 16px 16px 32px;
  }

  .toolbar {
    width: 100%;
  }

  .search {
    flex: 1 1 100%;
  }

  .search input {
    width: 100%;
  }

  .toolbar .btn {
    flex: 1 1 auto;
    justify-content: center;
    padding: 0 14px;
  }

  .hide-sm {
    display: none;
  }

  .table th,
  .table td {
    padding: 10px;
  }

  .field select {
    min-width: 0;
    width: 100%;
  }

  .compare__controls .field {
    flex: 1 1 100%;
  }

  .team-head__flag {
    width: 64px;
    height: 48px;
  }

  .player-hero {
    padding: 20px;
  }

  .avatar--xl {
    width: 80px;
    height: 80px;
    border-radius: 18px;
  }

  .timeline__item,
  .timeline__item:has(.captain) {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .timeline__ed {
    grid-column: 1 / -1;
  }

  .matrix__player {
    min-width: 132px;
    max-width: 150px;
  }

  .tier {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .tier__label {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    row-gap: 4px;
    padding: 14px 4px 10px;
    text-align: center;
  }

  .tier__mark {
    grid-row: auto;
    margin-bottom: 6px;
    width: 42px;
    height: 42px;
    border-width: 3px;
    font-size: 0.9375rem;
  }

  .tier__mark svg {
    width: 18px;
    height: 18px;
  }

  .tier__ring {
    inset: -7px;
  }

  .tier__name,
  .tier__count {
    align-self: auto;
  }

  .tier__name {
    font-size: 0.8125rem;
  }

  .tier__count {
    font-size: 0.75rem;
  }

  .zone {
    min-height: 72px;
    padding: 10px;
    gap: 6px;
  }

  .chip {
    height: 34px;
    font-size: 0.875rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Матчи и статистика o!TR ---------- */

/* Шапка сайта липкая: разделы по якорю не должны прятаться под ней */
[id].block,
[id].table-wrap {
  scroll-margin-top: 130px;
}

.jump {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -8px 0 20px;
}

.jump a {
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.875rem;
  text-decoration: none;
}

.jump a:hover {
  color: var(--text);
  background: var(--surface);
}

.stage {
  margin-top: 10px;
  border-radius: var(--radius);
  background: var(--surface);
}

.stage > summary {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
}

.stage > summary::before {
  content: "▸";
  color: var(--muted);
}

.stage[open] > summary::before {
  content: "▾";
}

.stage[open] > summary {
  border-bottom: 1px solid var(--line);
}

.mlist {
  margin: 0;
  padding: 0;
  list-style: none;
}

.stage .mlist {
  padding: 4px 0;
}

.played-title {
  margin: 24px 0 8px;
  font-size: 1rem;
}

.played-summary {
  margin: 0 0 12px;
}

#played .mlist {
  border-radius: var(--radius);
  background: var(--surface);
  padding: 4px 0;
}

.mlist__row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 64px minmax(0, 1fr) 110px;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  color: inherit;
  text-decoration: none;
}

/* С точки зрения сборной — ещё колонка победы или поражения */
.mlist__row:has(.mlist__outcome) {
  grid-template-columns: 64px 28px minmax(0, 1fr) 64px minmax(0, 1fr) 110px;
}

a.mlist__row:hover {
  background: var(--surface-2);
}

.mlist__date {
  display: grid;
  color: var(--muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.mlist__date small {
  font-size: 0.6875rem;
}

.mlist__outcome {
  justify-self: center;
  min-width: 24px;
  padding: 1px 4px;
  border-radius: 6px;
  font: 700 0.6875rem/1.4 var(--font-display);
  text-align: center;
}

.mlist__outcome--win { background: color-mix(in srgb, var(--g-top8) 22%, transparent); color: var(--g-top8); }
.mlist__outcome--loss { background: color-mix(in srgb, var(--g-fail) 18%, transparent); color: var(--g-fail); }

.mlist__side {
  display: flex;
  justify-content: flex-end;
  min-width: 0;
  color: var(--muted);
}

.mlist__side--b {
  justify-content: flex-start;
}

.mlist__side.is-winner {
  color: var(--text);
  font-weight: 600;
}

.mlist__team {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.mlist__side:not(.mlist__side--b) .mlist__team {
  flex-direction: row-reverse;
}

.mlist__team > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mlist__team .flag {
  width: 24px;
  height: 18px;
  border-radius: 3px;
  flex: none;
}

.mlist__score {
  text-align: center;
  color: var(--muted);
}

.mlist__score b {
  font-weight: 500;
}

.mlist__score b.is-winner {
  color: var(--text);
  font-weight: 800;
}

.mlist__more {
  color: var(--muted);
  font-size: 0.8125rem;
  text-align: right;
}

a.mlist__row:hover .mlist__more {
  color: var(--text);
}

.table--stats tr.is-idle th a {
  color: var(--muted);
}

.cost {
  font-weight: 700;
}

.cost--high { color: var(--g-top8); }
.cost--low { color: var(--muted); font-weight: 500; }

.rating-change small {
  color: var(--muted);
}

.rating-change .up { color: var(--g-top8); }
.rating-change .down { color: var(--g-fail); }

.timeline__stats {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
}

/* ---------- Страница матча ---------- */

.match-head__meta {
  margin: 0 0 12px;
  color: var(--muted);
}

.match-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  margin: 0;
  font: 800 1.5rem/1.2 var(--font-display);
}

.match-head__team {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 0;
  color: var(--muted);
  text-decoration: none;
  text-align: right;
}

.match-head__team--b {
  flex-direction: row-reverse;
  text-align: left;
}

.match-head__team.is-winner {
  color: var(--text);
}

.match-head__flags {
  display: flex;
  gap: 4px;
  flex: none;
}

.match-head__flags .flag {
  width: 48px;
  height: 36px;
  border-radius: 6px;
}

.match-head__score {
  display: flex;
  gap: 10px;
  padding: 6px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: 2rem;
}

.match-head__score .is-winner {
  color: var(--text);
}

.match-head__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 16px 0 0;
}

.match-sides {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr));
  gap: 16px;
}

.match-sides__caption {
  padding: 12px 14px 4px;
  text-align: left;
  font-weight: 700;
}

.match-sides__caption .flag {
  display: inline-block;
  width: 24px;
  height: 18px;
  margin-right: 8px;
  border-radius: 3px;
  vertical-align: -3px;
}

.map-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.map-card {
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.map-card__head {
  display: grid;
  grid-template-columns: 28px auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.map-card__no {
  color: var(--muted);
  font: 700 0.875rem/1 var(--font-display);
  text-align: center;
}

.map-card__mods {
  display: flex;
  gap: 4px;
}

.mod--dt, .mod--nc { color: #c9a8ff; }
.mod--hr { color: #ff8f8f; }
.mod--hd { color: #ffd479; }
.mod--fm { color: #8fdc3c; }
.mod--ez, .mod--ht { color: #7cc8ff; }

.map-card__title {
  display: grid;
  min-width: 0;
}

.map-card__title > a,
.map-card__title > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.map-card__running {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  font-weight: 700;
}

.map-card__sides {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.map-side {
  padding: 10px 14px 12px;
  border-top: 3px solid transparent;
}

.map-side + .map-side {
  border-left: 1px solid var(--line);
}

.map-side.is-winner {
  border-top-color: var(--g-top8);
  background: color-mix(in srgb, var(--g-top8) 6%, transparent);
}

.map-side__total {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.875rem;
}

.map-side.is-winner .map-side__total b {
  color: var(--g-top8);
}

.scores {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.scores th,
.scores td {
  padding: 3px 0;
  text-align: left;
  font-weight: 400;
}

.scores td {
  padding-left: 10px;
  text-align: right;
}

.scores th a {
  text-decoration: none;
}

.scores th a:hover {
  text-decoration: underline;
}

.scores__mods {
  margin-left: 6px;
  color: var(--muted);
  font: 700 0.625rem/1 var(--font-display);
}

.scores__acc,
.scores__miss {
  color: var(--muted);
}

@media (max-width: 760px) {
  .mlist__row {
    grid-template-columns: 44px minmax(0, 1fr) 48px minmax(0, 1fr);
    gap: 8px;
    padding: 8px 10px;
  }

  .mlist__row:has(.mlist__outcome) {
    grid-template-columns: 44px 24px minmax(0, 1fr) 48px minmax(0, 1fr);
  }

  .mlist__more {
    display: none;
  }

  .match-head {
    font-size: 1.125rem;
    gap: 10px;
  }

  .match-head__team,
  .match-head__team--b {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .match-head__flags .flag {
    width: 40px;
    height: 30px;
  }

  .match-head__score {
    font-size: 1.5rem;
    padding: 4px 10px;
  }

  .map-card__head {
    grid-template-columns: 22px minmax(0, 1fr) auto;
  }

  .map-card__mods {
    grid-column: 2;
    grid-row: 2;
  }

  .map-card__sides {
    grid-template-columns: 1fr;
  }

  .map-side + .map-side {
    border-left: 0;
  }
}

@media (max-width: 480px) {
  .mlist__team .flag + span {
    font-size: 0.875rem;
  }

  .scores__acc {
    display: none;
  }
}

/* Средние экраны: в широких таблицах статистики прячем второстепенные колонки */
.table--stats tbody th {
  white-space: nowrap;
}

@media (max-width: 960px) {
  .hide-md {
    display: none;
  }
}
