/* Match page: big scoreboard + live Match centre tab (timeline, stats).
   Uses the site's --home-* palette so it sits in the dark match header. */

/* ---------------------------------------------------------------------
   Scoreboard
   ------------------------------------------------------------------- */
.match-scoreboard {
  --mb-red: #ff2e4c;
  --mb-muted: #9aa4ab;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(7.5rem, auto) minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  padding: 14px 10px 10px;
  color: var(--home-text, #edf4f8);
}

.match-scoreboard__team {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 0;
  text-align: center;
}

/* Logo sits straight on the header background (no tile). */
.match-scoreboard__crest {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 76px;
  height: 64px;
}

/* Two classes so it beats custom.css's 22px round .team-logo (loaded later). */
.match-scoreboard__crest .match-scoreboard__logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 6px;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.45));
}

/* Teams without a crest: coloured initial fills the tile. */
.match-scoreboard__crest .team-logo--fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  color: #fff;
  font-size: 1.5rem;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.match-scoreboard__name {
  max-width: 100%;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.match-scoreboard__centre {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding-top: 6px;
  text-align: center;
}

.match-scoreboard__date {
  color: var(--mb-muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.match-scoreboard__score {
  display: flex;
  align-items: center;
  gap: 0.3em;
  color: var(--mb-red);
  font-size: clamp(2.3rem, 6vw, 3.3rem);
  font-weight: 800;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.match-scoreboard__dash {
  font-weight: 700;
}

.match-scoreboard__score--vs {
  color: var(--home-text-soft, #bec9d1);
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  letter-spacing: 0.08em;
}

.match-scoreboard__status {
  color: var(--mb-red);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.match-scoreboard__status:empty {
  display: none;
}

/* Stadium under "VS" on pre-match pages. */
.match-scoreboard__venue {
  display: inline-flex;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  max-width: 14rem;
  margin-top: 4px;
  color: var(--mb-muted);
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
}

.match-scoreboard__venue i {
  flex: 0 0 auto;
  margin-top: 1px;
  color: hsl(var(--home-base, 146 72% 47%));
  font-size: 0.9rem;
}

/* "HT 1-0 · 2H 1-1": quiet context under the status. */
.match-scoreboard__periods {
  margin-top: 2px;
  color: var(--mb-muted);
  font-size: 0.74rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  line-height: 1.35;
}

.match-scoreboard__periods:empty {
  display: none;
}

/* ---------------------------------------------------------------------
   Live accent bar
   custom.css draws it as an inset box-shadow, which any child with a
   background (tab bar, scrollbar track) paints over. On the match page
   draw it as an overlay line instead so it runs the full height.
   ------------------------------------------------------------------- */
.home-page .match-detail.is-live {
  position: relative;
  box-shadow: none;
}

.home-page .match-detail.is-live::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  background: #e11d2e;
  z-index: 3;
  pointer-events: none;
}

/* ---------------------------------------------------------------------
   Market tab bar scrollbar: slim and quiet instead of the global 8px
   green bar with arrow buttons (.home-page *::-webkit-scrollbar).
   ------------------------------------------------------------------- */
.home-page .match-detail__tabs {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
  padding-bottom: 2px;
}

.home-page .match-detail__tabs::-webkit-scrollbar {
  display: block;
  height: 3px;
}

.home-page .match-detail__tabs::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 0;
}

.home-page .match-detail__tabs::-webkit-scrollbar-thumb {
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

.home-page .match-detail__tabs:hover::-webkit-scrollbar-thumb {
  background: hsl(var(--home-base, 146 72% 47%) / 0.7);
}

.home-page .match-detail__tabs::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

/* Touch screens scroll by swiping; no bar needed. */
@media (hover: none) {
  .home-page .match-detail__tabs {
    scrollbar-width: none;
  }

  .home-page .match-detail__tabs::-webkit-scrollbar {
    display: none;
  }
}

/* ---------------------------------------------------------------------
   Match centre tab button (in the market tab bar)
   ------------------------------------------------------------------- */
.match-detail__tab[hidden] {
  display: none;
}

.match-detail__tab--centre {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: hsl(var(--home-base, 146 72% 47%));
}

.match-detail__tab--centre i {
  font-size: 1rem;
}

/* ---------------------------------------------------------------------
   Match centre panel
   ------------------------------------------------------------------- */
.match-centre {
  --mc-home: hsl(var(--home-base, 146 72% 47%));
  --mc-away: #8fa3b3;
  --mc-track: rgba(255, 255, 255, 0.07);
  --mc-muted: var(--home-text-soft, #bec9d1);
  --mc-text: var(--home-text, #edf4f8);
  margin: 12px 8px 16px;
  padding: 14px;
  border: 1px solid var(--home-border, rgba(255, 255, 255, 0.08));
  border-radius: 12px;
  background: var(--home-panel, #121b20);
  color: var(--mc-text);
}

.match-centre[hidden] {
  display: none;
}

/* Timeline / Stats switch */
.match-centre__tabs {
  display: flex;
  gap: 4px;
  padding: 3px;
  margin-bottom: 14px;
  border-radius: 999px;
  background: var(--mc-track);
}

.match-centre__tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 999px;
  padding: 8px 10px;
  background: transparent;
  color: var(--mc-muted);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.match-centre__tab i {
  font-size: 1rem;
}

.match-centre__tab.is-active {
  background: var(--home-panel-2, #171f25);
  color: var(--mc-text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.match-centre__tab:focus-visible {
  outline: 2px solid var(--mc-home);
  outline-offset: -2px;
}

.match-centre__panel[hidden] {
  display: none;
}

.match-centre__empty {
  margin: 10px 0 4px;
  text-align: center;
  color: var(--mc-muted);
  font-size: 0.82rem;
}

/* Team legend above the stats */
.match-centre__teams {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.match-centre__teams span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.match-centre__teams span::before {
  content: "";
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mc-home);
}

.match-centre__teams span:last-child {
  flex-direction: row-reverse;
}

.match-centre__teams span:last-child::before {
  background: var(--mc-away);
}

/* Stat rows */
.match-centre__stats {
  display: grid;
  gap: 12px;
}

.mc-stat__head {
  display: grid;
  grid-template-columns: 3.2rem 1fr 3.2rem;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 5px;
}

.mc-stat__label {
  text-align: center;
  color: var(--mc-muted);
  font-size: 0.78rem;
  line-height: 1.2;
}

.mc-stat__val {
  font-weight: 700;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  color: var(--mc-muted);
}

.mc-stat__val:last-child {
  text-align: right;
}

.mc-stat__val.is-lead {
  color: var(--mc-text);
  font-weight: 800;
}

.mc-stat__bar {
  display: flex;
  gap: 3px;
  height: 6px;
}

.mc-stat__home,
.mc-stat__away {
  display: block;
  min-width: 3px;
  border-radius: 999px;
  opacity: 0.55;
  transition: width 0.5s ease;
}

.mc-stat__home {
  background: var(--mc-home);
}

.mc-stat__away {
  background: var(--mc-away);
}

.mc-stat__home.is-lead,
.mc-stat__away.is-lead {
  opacity: 1;
}

/* Timeline: home events left, away right, minute on the centre line.
   A full tab now, so no inner scroll box. */
.match-centre__events {
  position: relative;
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 2px 0;
  list-style: none;
}

.match-centre__events::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: var(--mc-track);
  transform: translateX(-50%);
}

.mc-event {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 3rem 1fr;
  align-items: center;
  min-height: 36px;
}

.mc-event__min {
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
  z-index: 1;
  min-width: 2.7rem;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--home-panel-2, #171f25);
  border: 1px solid var(--home-border, rgba(255, 255, 255, 0.08));
  color: var(--mc-muted);
  font-size: 0.74rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.mc-event__text {
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.mc-event--home .mc-event__text {
  grid-column: 1;
  justify-self: end;
  flex-direction: row-reverse;
  text-align: right;
  padding-right: 8px;
}

.mc-event--away .mc-event__text,
.mc-event--none .mc-event__text {
  grid-column: 3;
  justify-self: start;
  padding-left: 8px;
}

.mc-event--none .mc-event__text {
  opacity: 0.8;
}

.mc-event__words {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}

.mc-event__words strong {
  font-size: 0.82rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.mc-event__words small {
  color: var(--mc-muted);
  font-size: 0.72rem;
}

.mc-event__icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--mc-track);
  color: var(--mc-muted);
  font-size: 0.95rem;
}

.mc-event--goal .mc-event__icon {
  background: var(--mc-home);
  color: #06140c;
}

.mc-event--goal .mc-event__words strong {
  color: var(--mc-text);
}

.mc-event--own_goal .mc-event__icon {
  background: rgba(225, 29, 46, 0.2);
  color: #ff6b77;
}

.mc-event--miss .mc-event__icon {
  color: #ff6b77;
}

.mc-event--var .mc-event__icon {
  color: #7cc4ff;
}

.mc-card {
  display: block;
  width: 9px;
  height: 13px;
  border-radius: 2px;
}

.mc-card--yellow {
  background: #f5c518;
}

.mc-card--red {
  background: #e11d2e;
}

/* ---------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------- */
@media (min-width: 992px) {
  .match-scoreboard {
    padding: 18px 16px 12px;
    gap: 20px;
  }

  .match-scoreboard__crest {
    width: 92px;
    height: 76px;
  }

  .match-scoreboard__crest .team-logo--fallback {
    width: 70px;
    height: 70px;
    font-size: 1.7rem;
  }

  .match-scoreboard__name {
    font-size: 1rem;
  }

  .match-centre {
    margin: 12px 12px 18px;
    padding: 16px 18px;
  }
}

@media (max-width: 480px) {
  .match-scoreboard {
    grid-template-columns: minmax(0, 1fr) minmax(6rem, auto) minmax(0, 1fr);
    gap: 8px;
    padding: 10px 4px 8px;
  }

  .match-scoreboard__crest {
    width: 60px;
    height: 50px;
  }

  .match-scoreboard__crest .team-logo--fallback {
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
  }

  .match-scoreboard__name {
    font-size: 0.8rem;
  }

  .match-scoreboard__date {
    font-size: 0.72rem;
  }

  .match-scoreboard__status {
    font-size: 0.7rem;
  }

  .match-scoreboard__periods {
    font-size: 0.68rem;
  }

  .match-scoreboard__venue {
    max-width: 9rem;
    font-size: 0.68rem;
  }

  .match-centre {
    margin: 10px 4px 12px;
    padding: 12px 10px;
    border-radius: 10px;
  }

  .mc-stat__head {
    grid-template-columns: 2.7rem 1fr 2.7rem;
  }

  .mc-stat__label {
    font-size: 0.74rem;
  }

  .mc-event {
    grid-template-columns: 1fr 2.6rem 1fr;
  }

  .mc-event__min {
    min-width: 2.3rem;
    font-size: 0.7rem;
  }

  .mc-event__words strong {
    font-size: 0.78rem;
  }

  .mc-event__icon {
    width: 21px;
    height: 21px;
  }
}

@media (max-width: 360px) {
  .match-scoreboard__crest {
    width: 52px;
    height: 44px;
  }

  .match-scoreboard__crest .team-logo--fallback {
    width: 42px;
    height: 42px;
  }

  .match-scoreboard__score {
    font-size: 2rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mc-stat__home,
  .mc-stat__away,
  .match-centre__tab {
    transition: none;
  }
}

/* ---------------------------------------------------------------------
   Pre-match Stats tab (form, head-to-head, comparison, averages, lineups)
   Reuses the match-centre panel, bars and palette.
   ------------------------------------------------------------------- */
.match-insights .mi-section + .mi-section {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--home-border, rgba(255, 255, 255, 0.08));
}

.mi-section[hidden] {
  display: none;
}

.mi-title {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 10px;
  color: var(--mc-text);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.mi-title i {
  color: var(--mc-home);
  font-size: 1rem;
}

.mi-title small {
  margin-left: auto;
  color: var(--mc-muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.mi-advice {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.35;
}

.mi-note {
  margin: 4px 0 0;
  color: var(--mc-muted);
  font-size: 0.76rem;
}

.mi-note[hidden] {
  display: none;
}

/* Form badges */
.mi-form {
  display: grid;
  gap: 8px;
}

.mi-form__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.mi-form__team {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.84rem;
  font-weight: 600;
}

.mi-form__badges {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 4px;
}

.mi-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 800;
  color: #fff;
}

.mi-badge--w { background: var(--mc-home); color: #06140c; }
.mi-badge--d { background: #5b6770; }
.mi-badge--l { background: #e11d2e; }

/* Head to head */
.mi-h2h {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.mi-h2h__box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 6px;
  border-radius: 10px;
  background: var(--mc-track);
  text-align: center;
  min-width: 0;
}

.mi-h2h__box strong {
  font-size: 1.35rem;
  line-height: 1;
  color: var(--mc-home);
}

.mi-h2h__box--draw strong { color: var(--mc-muted); }
.mi-h2h__box--away strong { color: var(--mc-away); }

.mi-h2h__box span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--mc-muted);
  font-size: 0.72rem;
}

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

.mi-meeting {
  display: grid;
  grid-template-columns: 5.6rem 1fr;
  align-items: center;
  gap: 2px 10px;
  font-size: 0.8rem;
}

.mi-meeting__date {
  color: var(--mc-muted);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.mi-meeting__teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.mi-meeting__teams > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--mc-muted);
}

.mi-meeting__teams > span:first-child { text-align: right; }
.mi-meeting__teams > span.is-winner { color: var(--mc-text); font-weight: 700; }

.mi-meeting__score {
  min-width: 2.6rem;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--mc-track);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.mi-meeting__league {
  grid-column: 2;
  color: var(--mc-muted);
  font-size: 0.68rem;
  text-align: center;
}

/* Season averages */
.mi-averages {
  display: grid;
  gap: 6px;
}

.mi-avg {
  display: grid;
  grid-template-columns: 3.2rem 1fr 3.2rem;
  align-items: baseline;
  gap: 6px;
}

.mi-avg__label {
  text-align: center;
  color: var(--mc-muted);
  font-size: 0.78rem;
}

.mi-avg__val {
  font-weight: 700;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  color: var(--mc-muted);
}

.mi-avg__val:last-child { text-align: right; }
.mi-avg__val.is-lead { color: var(--mc-text); font-weight: 800; }

/* Lineups: two columns, stacked on phones */
.mi-lineups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.mi-lineup__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.84rem;
}

.mi-lineup__formation {
  color: var(--mc-home);
  font-size: 0.74rem;
  font-weight: 700;
}

.mi-lineup__players {
  display: grid;
  gap: 3px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.8rem;
}

.mi-lineup__players li {
  display: grid;
  grid-template-columns: 1.8rem 1fr auto;
  gap: 6px;
  align-items: baseline;
}

.mi-lineup__num {
  color: var(--mc-muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.mi-lineup__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mi-lineup__pos {
  color: var(--mc-muted);
  font-size: 0.7rem;
}

@media (max-width: 480px) {
  .mi-meeting {
    grid-template-columns: 1fr;
  }

  .mi-meeting__date,
  .mi-meeting__league {
    grid-column: 1;
    text-align: center;
  }

  .mi-lineups {
    grid-template-columns: 1fr;
  }

  .mi-badge {
    width: 22px;
    height: 22px;
  }
}
