.matches {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.matches .card {
  border-radius: var(--br-12);
  overflow: hidden;
}

/* --- shared bits --- */

.matches__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem 0.6rem;
  min-width: 0;
}

.matches__meta-part {
  font-size: var(--font-size-xs);
  color: var(--text-custom);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.matches__meta-part--right {
  margin-left: auto;
}

.matches__series {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-7);
  color: var(--span);
  background-color: var(--span-10);
  border: 1px solid var(--span-10);
  border-radius: var(--br-6);
  padding: 0.05rem 0.4rem;
  white-space: nowrap;
}

.matches__score--win {
  color: var(--green);
}

.matches__live {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-7);
  color: var(--red);
  background-color: var(--red-10);
  border: 1px solid var(--red-20);
  border-radius: var(--br-6);
  padding: 0.05rem 0.4rem;
  white-space: nowrap;
}

.matches__live i {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: var(--br-50);
  background-color: var(--red);
  animation: matches-pulse 1.6s ease-in-out infinite;
}

.matches__live--ended {
  color: var(--text-custom);
  background-color: var(--transparent-3-w);
  border-color: var(--transparent-10-w);
}

.matches__live--ended i {
  display: none;
}

@keyframes matches-pulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.25;
  }
}

/* --- loaders --- */

@keyframes matches-spin {
  to {
    transform: rotate(360deg);
  }
}

.matches__item--loading {
  opacity: 0.65;
  pointer-events: none;
}

.matches__item--loading::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 0.9rem;
  margin-top: -0.5rem;
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--transparent-10-w);
  border-top-color: var(--span);
  border-radius: var(--br-50);
  animation: matches-spin 0.7s linear infinite;
}

.matches__filter--loading {
  opacity: 0.6;
  pointer-events: none;
}

.matches__list-header--loading::after {
  content: "";
  width: 1rem;
  height: 1rem;
  margin-left: 0.5rem;
  border: 2px solid var(--transparent-10-w);
  border-top-color: var(--span);
  border-radius: var(--br-50);
  animation: matches-spin 0.7s linear infinite;
  flex: none;
}

.matches__back--loading::after {
  content: "";
  display: inline-block;
  width: 0.8rem;
  height: 0.8rem;
  margin-left: 0.35rem;
  border: 2px solid var(--transparent-10-w);
  border-top-color: var(--span);
  border-radius: var(--br-50);
  animation: matches-spin 0.7s linear infinite;
  vertical-align: middle;
}

.matches--nav-loading .matches__list,
.matches--nav-loading .pagination {
  opacity: 0.5;
  pointer-events: none;
}

/* --- match list --- */

.matches__list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.matches__controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  width: 100%;
}

.matches__filter {
  font-size: var(--font-size-s);
  color: var(--text-custom);
  background-color: var(--input-form);
  border: 1px solid var(--transparent-10-w);
  border-radius: var(--br-8);
  padding: 0.35rem 0.6rem;
  max-width: 100%;
  cursor: pointer;
}

.matches__filter:focus {
  outline: 1px solid var(--span-half);
}

.matches__search {
  display: flex;
  align-items: center;
  flex: 1 1 14rem;
  min-width: 0;
  background-color: var(--input-form);
  border: 1px solid var(--transparent-10-w);
  border-radius: var(--br-8);
  overflow: hidden;
}

.matches__search:focus-within {
  border-color: var(--span-half);
}

.matches__search-input {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--font-size-s);
  color: var(--text-default);
  background: none;
  border: none;
  outline: none;
  padding: 0.35rem 0.6rem;
}

.matches__search-input::placeholder {
  color: var(--text-custom);
  opacity: 0.6;
}

.matches__search-clear {
  flex: none;
  color: var(--text-custom);
  font-size: var(--font-size-m);
  line-height: 1;
  padding: 0.2rem 0.4rem;
}

.matches__search-clear:hover {
  color: var(--red);
}

.matches__search-btn {
  flex: none;
  font-size: var(--font-size-s);
  color: var(--text-custom);
  background-color: var(--transparent-3-w);
  border: none;
  border-left: 1px solid var(--transparent-10-w);
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  transition: 0.2s;
  white-space: nowrap;
}

.matches__search-btn:hover {
  color: var(--text-default);
}

.matches__search-btn--loading {
  color: transparent;
  position: relative;
  pointer-events: none;
}

.matches__search-btn--loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  margin: -0.4rem 0 0 -0.4rem;
  width: 0.8rem;
  height: 0.8rem;
  border: 2px solid var(--transparent-10-w);
  border-top-color: var(--span);
  border-radius: var(--br-50);
  animation: matches-spin 0.7s linear infinite;
}

.matches__chip {
  flex: none;
  font-size: var(--font-size-s);
  color: var(--text-custom);
  background-color: var(--input-form);
  border: 1px solid var(--transparent-10-w);
  border-radius: var(--br-8);
  padding: 0.35rem 0.7rem;
  white-space: nowrap;
  transition: 0.2s;
}

.matches__chip:hover {
  color: var(--text-default);
  border-color: var(--span-half);
}

.matches__chip--active {
  color: var(--span);
  background-color: var(--span-10);
  border-color: var(--span-half);
  font-weight: var(--font-weight-6);
}

.matches__chip--loading {
  opacity: 0.6;
  pointer-events: none;
}

.matches__list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.matches__item {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--br-10);
  background-color: var(--input-form);
  border: 1px solid var(--transparent-3-w);
  color: var(--text-default);
  transition: 0.2s;
}

.matches__item:hover {
  border-color: var(--span-half);
  background-color: var(--transparent-5-w);
}

.matches__item--live {
  border-color: var(--red-20);
}

.matches__item--live:hover {
  border-color: var(--red);
}

/* "Вы играли" - цветное ребро, чтобы свои матчи находились одним взглядом. */
.matches__item--mine {
  box-shadow: inset 3px 0 0 var(--span);
}

.matches__item-main {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.6rem;
}

.matches__item-team {
  font-size: var(--font-size-m);
  font-weight: var(--font-weight-6);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.matches__item-team--win {
  color: var(--text-default);
}

.matches__item-team--right {
  text-align: right;
}

.matches__item-score {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: var(--font-size-l);
  font-weight: var(--font-weight-7);
}

.matches__item-score i,
.matches__scoreline-result i,
.matches__map-score i {
  font-style: normal;
  color: var(--text-custom);
  opacity: 0.5;
}

.matches__item-sub {
  display: flex;
  gap: 0.6rem;
  font-size: var(--font-size-xs);
  color: var(--text-custom);
  opacity: 0.7;
}

/* --- match header --- */

.matches__header-top {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.matches__header-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.6rem;
  min-width: 0;
}

.matches__back {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  align-self: flex-start;
  font-size: var(--font-size-s);
  color: var(--span);
}

.matches__back svg {
  width: 0.9rem;
  height: 0.9rem;
  fill: var(--span);
}

.matches__share {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: var(--font-size-s);
  color: var(--text-custom);
  background-color: var(--transparent-3-w);
  border: 1px solid var(--transparent-10-w);
  border-radius: var(--br-8);
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  transition: 0.2s;
  white-space: nowrap;
}

.matches__share:hover {
  color: var(--text-default);
  border-color: var(--span-half);
}

.matches__share svg {
  width: 0.9rem;
  height: 0.9rem;
  fill: currentColor;
}

.matches__scoreline {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem;
  border-radius: var(--br-10);
  background-color: var(--transparent-3-w);
  border: 1px solid var(--transparent-3-w);
}

.matches__scoreline-team {
  font-size: var(--font-size-l);
  font-weight: var(--font-weight-7);
  color: var(--text-secondary);
  min-width: 0;
  overflow-wrap: anywhere;
}

.matches__scoreline-team--win {
  color: var(--text-default);
}

.matches__scoreline-team--right {
  text-align: right;
}

.matches__scoreline-result {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: var(--font-size-xxl);
  font-weight: var(--font-weight-7);
}

/* --- map cards --- */

.matches__map-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.9rem 1.2rem 0.4rem;
}

.matches__map-title {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  min-width: 0;
}

.matches__map-name {
  font-size: var(--font-size-l);
  font-weight: var(--font-weight-7);
  color: var(--text-default);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.matches__map-score {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  font-size: var(--font-size-m);
  font-weight: var(--font-weight-7);
  color: var(--text-secondary);
}

.matches__toggle {
  font-size: var(--font-size-s);
  color: var(--text-custom);
  background-color: var(--transparent-3-w);
  border: 1px solid var(--transparent-10-w);
  border-radius: var(--br-8);
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  transition: 0.2s;
}

.matches__toggle:hover {
  color: var(--text-default);
  border-color: var(--span-half);
}

/* --- team blocks: two hues so the eye separates teams without headers --- */

.matches__team-block {
  padding: 0.4rem 1.2rem 0.8rem;
  --matches-team-rgb: 158, 158, 158;
}

.matches__team-block--team1 {
  --matches-team-rgb: 204, 169, 102; /* --t */
}

.matches__team-block--team2 {
  --matches-team-rgb: 102, 170, 204; /* --ct */
}

.matches__team-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--font-size-s);
  font-weight: var(--font-weight-6);
  color: var(--text-custom);
  margin-bottom: 0.4rem;
  min-width: 0;
}

.matches__team-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: var(--br-50);
  background-color: rgb(var(--matches-team-rgb));
  flex: none;
}

.matches__team-name-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.matches__team-rounds {
  font-size: var(--font-size-s);
  font-weight: var(--font-weight-7);
  color: var(--text-default);
  background-color: var(--transparent-3-w);
  border: 1px solid var(--transparent-3-w);
  border-radius: var(--br-6);
  padding: 0 0.45rem;
  flex: none;
}

.matches__team-name--win {
  color: var(--green);
}

.matches__team-name--win .matches__team-name-text {
  font-weight: var(--font-weight-7);
}

.matches__team-name--win .matches__team-rounds {
  color: var(--green);
}

.matches__empty-team {
  font-size: var(--font-size-s);
  color: var(--text-custom);
  opacity: 0.6;
  padding: 0.3rem 0;
}

/* --- scoreboard --- */

.matches__table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--transparent-5-w);
  border-radius: var(--br-10);
}

.matches__table {
  border-radius: 0;
  /* глобальные table-стили ломают sticky-колонку: overflow hidden + collapse */
  overflow: visible;
  border-collapse: separate;
  border-spacing: 0;
}

.matches__table thead th,
.matches__table tbody td {
  padding: 0 0.6rem;
  text-align: center;
}

.matches__table tbody td {
  height: 40px;
  font-size: var(--font-size-s);
}

.matches__table thead th {
  font-size: var(--font-size-s);
  height: 34px;
}

/* Ховер: мгновенная смена фона, никакой анимации остальных свойств
   ( глобальный transition: .25s на tr анимирует всё подряд ). */
.matches__table tbody tr {
  transition: background-color 0.12s ease;
  background-color: rgba(var(--matches-team-rgb), 0.05);
}

.matches__table tbody tr:hover {
  color: inherit;
  transform: none;
  background-color: rgba(var(--matches-team-rgb), 0.14);
}

.matches__table thead th:first-child,
.matches__table tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  text-align: left;
  background-color: var(--card);
  box-shadow: 8px 0 8px -8px var(--transparent-20-b);
}

/* Липкая колонка непрозрачна, поэтому тон команды и цветное левое ребро - поверх. */
.matches__table tbody td:first-child {
  background-image: linear-gradient(rgba(var(--matches-team-rgb), 0.05), rgba(var(--matches-team-rgb), 0.05));
  box-shadow: inset 3px 0 0 rgba(var(--matches-team-rgb), 0.75), 8px 0 8px -8px var(--transparent-20-b);
  transition: background-image 0s, background-color 0.12s ease;
}

.matches__table tbody tr:hover td:first-child {
  background-image: linear-gradient(rgba(var(--matches-team-rgb), 0.14), rgba(var(--matches-team-rgb), 0.14));
}

.matches__team-block tbody tr.matches__row--me {
  background-color: var(--span-low);
}

.matches__team-block tbody tr.matches__row--me td:first-child {
  background-image: linear-gradient(var(--span-low), var(--span-low));
  box-shadow: inset 3px 0 0 var(--span), 8px 0 8px -8px var(--transparent-20-b);
}

.matches__cell-player {
  min-width: 8rem;
  max-width: 10rem;
}

.matches__player-link {
  display: inline-block;
  max-width: 9rem;
  color: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.matches__cell-strong {
  font-weight: var(--font-weight-7);
}

.matches__you {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-7);
  color: var(--span);
  background-color: var(--span-10);
  border-radius: var(--br-6);
  padding: 0.05rem 0.35rem;
  margin-left: 0.3rem;
  vertical-align: middle;
}

.matches__diff--pos {
  color: var(--green);
}

.matches__diff--neg {
  color: var(--red);
}

.matches__zero {
  opacity: 0.35;
}

/* Подсказки на заголовках: короткие KD/HS/CL непонятны без расшифровки. */
.matches__table thead th[title] {
  cursor: help;
  position: relative;
}

.matches__table thead th[title]:hover::after {
  content: attr(title);
  position: absolute;
  top: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--tooltip);
  color: var(--text-default);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-4);
  padding: 0.3rem 0.55rem;
  border-radius: var(--br-6);
  white-space: nowrap;
  z-index: 40;
  pointer-events: none;
  box-shadow: 0 6px 16px var(--transparent-20-b);
}

/* Группы колонок:
   ext  - K/D, K/R, HS, HS%, мультикиллы: на десктопе видны всегда, на мобильном за тумблером.
   ext2 - клатчи, входы, урон гранатами, точность: всегда за тумблером. */
.matches__ext,
.matches__ext2 {
  display: none;
}

.matches__map-card--full .matches__ext,
.matches__map-card--full .matches__ext2 {
  display: table-cell;
}

@media (min-width: 768px) {
  .matches__ext {
    display: table-cell;
  }

  .matches__header-top {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .matches__scoreline {
    padding: 1.2rem;
  }

  .matches__item {
    padding: 0.8rem 1.2rem;
  }
}
