:root {
  --afc-red: #d90d1b;
  --afc-red-dark: #ab0914;
  --afc-dark: #15161c;
  --afc-grey: #667085;
  --afc-bg: #f4f5f7;
  --afc-card: #ffffff;
  --border: #d9dde5;
  --focus: #2563eb;
  --success: #14743a;
  --danger: #b42318;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 280px;
  margin: 0;
  background: var(--afc-bg);
  color: var(--afc-dark);
}

button,
a {
  font: inherit;
}

button {
  min-height: 44px;
}

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

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 1000;
  padding: 10px 14px;
  border-radius: 6px;
  background: #fff;
  color: var(--afc-dark);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  background: linear-gradient(135deg, var(--afc-red), #bf0713);
  color: #fff;
  padding: 28px 20px;
  text-align: center;
}

.site-header h1 {
  margin: 0 0 6px;
  font-size: clamp(1.45rem, 4vw, 1.9rem);
  line-height: 1.2;
}

.subtitle,
.freshness-warning {
  margin: 0;
  font-size: 0.9rem;
}

.subtitle {
  opacity: 0.9;
}

.freshness-warning {
  max-width: 720px;
  margin: 12px auto 0;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  background: rgba(87, 0, 6, 0.28);
}

.sticky-next-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--afc-dark);
  border-bottom: 2px solid var(--afc-red);
  box-shadow: 0 2px 8px rgb(0 0 0 / 24%);
}

.sticky-next-bar[hidden],
#hero-next-match[hidden],
.freshness-warning[hidden] {
  display: none;
}

.sticky-next-button {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
}

.sticky-next-button:hover {
  background: #20222b;
}

.sticky-next-button .label {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #ff4a55;
}

.sticky-next-button .matchup {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
  font-weight: 700;
}

.sticky-next-button .countdown {
  margin-left: auto;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgb(255 255 255 / 12%);
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
}

main {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 24px 20px;
}

.hero-next-match {
  overflow: hidden;
  margin-bottom: 28px;
  border-top: 3px solid var(--afc-red);
  border-radius: 16px;
  background: linear-gradient(145deg, #17181f, #22242e);
  color: #fff;
  box-shadow: 0 6px 18px rgb(16 24 40 / 20%);
}

.hero-main-button {
  width: 100%;
  padding: 22px 22px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.hero-main-button:hover {
  background: rgb(255 255 255 / 3%);
}

.hero-label,
.eyebrow {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.hero-label {
  color: #ff4450;
}

.hero-teams {
  width: 100%;
  margin: 16px 0 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.hero-team {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.hero-team:first-child {
  flex-direction: row;
}

.hero-team:last-child {
  flex-direction: row-reverse;
}

.hero-team-name {
  min-width: 0;
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.hero-vs {
  opacity: 0.68;
  font-size: 0.85rem;
}

.hero-meta {
  margin-top: 3px;
  color: #e4e7ec;
  font-size: 0.9rem;
}

.hero-countdown {
  margin-top: 14px;
  padding: 8px 20px;
  border-radius: 999px;
  background: var(--afc-red);
  font-weight: 800;
}

.hero-jump-hint {
  margin-top: 9px;
  color: #b9c0cc;
  font-size: 0.75rem;
}

.primary-button,
.secondary-button {
  padding: 9px 16px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}

.primary-button {
  border: 1px solid var(--afc-red);
  background: var(--afc-red);
  color: #fff;
}

.primary-button:hover {
  background: var(--afc-red-dark);
}

.secondary-button {
  border: 1px solid #c9ced8;
  background: #fff;
  color: var(--afc-dark);
}

.secondary-button:hover {
  background: #f8f9fb;
}

.schedule-controls {
  margin-bottom: 22px;
}

.section-heading {
  margin-bottom: 14px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--afc-red-dark);
}

.section-heading h2 {
  margin: 0;
  font-size: 1.35rem;
}

.visible-count {
  color: var(--afc-grey);
  font-size: 0.85rem;
  white-space: nowrap;
}

.view-switcher {
  width: 100%;
  padding: 4px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  border-radius: 10px;
  background: #e2e5ea;
}

.view-button {
  padding: 8px 16px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #4b5565;
  font-weight: 700;
  cursor: pointer;
}

.view-button[aria-pressed="true"] {
  background: #fff;
  color: var(--afc-dark);
  box-shadow: 0 1px 4px rgb(16 24 40 / 12%);
}

.filter-group {
  margin-top: 16px;
}

.filter-label {
  display: block;
  margin-bottom: 8px;
  color: var(--afc-grey);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filters button {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--afc-dark);
  font-size: 0.85rem;
  cursor: pointer;
}

.filters button[aria-pressed="true"] {
  border-color: var(--afc-red);
  background: var(--afc-red);
  color: #fff;
}

.month-group {
  margin-top: 28px;
}

.month-heading {
  margin: 0 0 10px;
  color: var(--afc-grey);
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

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

.match-list li + li {
  margin-top: 10px;
}

.match-card {
  padding: 14px 16px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "badge teams when";
  align-items: center;
  column-gap: 14px;
  row-gap: 10px;
  border: 1px solid #eaecf0;
  border-radius: 11px;
  background: var(--afc-card);
  box-shadow: 0 1px 3px rgb(16 24 40 / 8%);
}

.match-card.completed {
  border-left: 3px solid #98a2b3;
}

.match-card.result-pending {
  border-left: 3px solid #f79009;
}

.match-card:focus {
  outline: none;
}

.match-card.highlight {
  animation: highlight-pulse 1.6s ease;
}

@keyframes highlight-pulse {
  0% { box-shadow: 0 0 0 0 rgb(217 13 27 / 60%); }
  25% { box-shadow: 0 0 0 6px rgb(217 13 27 / 22%); }
  100% { box-shadow: 0 1px 3px rgb(16 24 40 / 8%); }
}

.badge {
  grid-area: badge;
  justify-self: start;
  padding: 4px 8px;
  border-radius: 5px;
  color: #fff;
  font-size: 0.67rem;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge.home { background: var(--success); }
.badge.away { background: #475467; }
.badge.neutral { background: #667085; }
.badge.completed { background: #e4e7ec; color: #344054; }
.badge.result-pending { background: #fef0c7; color: #7a2e0e; }

.match-teams {
  grid-area: teams;
  min-width: 0;
}

.teams {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  font-size: 1rem;
  font-weight: 700;
}

.team {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}

.team-name {
  overflow-wrap: anywhere;
}

.vs-sep {
  color: var(--afc-grey);
  font-size: 0.82rem;
  font-weight: 400;
}

.meta {
  margin-top: 3px;
  color: var(--afc-grey);
  font-size: 0.8rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.match-when {
  grid-area: when;
  text-align: right;
  font-size: 0.85rem;
  white-space: nowrap;
}

.date,
.score {
  font-weight: 800;
}

.time {
  color: var(--afc-grey);
}

.score {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 7px;
  font-size: 1.12rem;
}

.result {
  min-width: 25px;
  padding: 3px 6px;
  border-radius: 5px;
  color: #fff;
  font-size: 0.68rem;
  text-align: center;
}

.result-w { background: var(--success); }
.result-d { background: #667085; }
.result-l { background: var(--danger); }

.crest-shell {
  position: relative;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: #eceff3;
  color: #475467;
  font-weight: 800;
}

.crest-shell img,
.crest-fallback {
  grid-area: 1 / 1;
}

.crest-shell img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.crest-shell:not(.crest-loaded) img {
  visibility: hidden;
}

.crest-loaded .crest-fallback {
  visibility: hidden;
}

.crest {
  width: 28px;
  height: 28px;
  font-size: 0.55rem;
}

.hero-crest {
  width: 54px;
  height: 54px;
  font-size: 0.8rem;
}

.empty-state,
.error-state {
  margin-top: 28px;
  padding: 42px 22px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--afc-grey);
  text-align: center;
}

.empty-state h3,
.error-state h2 {
  margin: 0 0 8px;
  color: var(--afc-dark);
}

.empty-state p,
.error-state p {
  margin: 0 0 18px;
}

.site-footer {
  max-width: 760px;
  margin: 0 auto;
  padding: 30px 20px 42px;
  color: var(--afc-grey);
  font-size: 0.8rem;
  text-align: center;
}

.site-footer a {
  color: var(--afc-red-dark);
}

@media (max-width: 520px) {
  .site-header {
    padding: 22px 14px;
  }

  main {
    padding: 18px 12px;
  }

  .sticky-next-button {
    padding-inline: 12px;
    gap: 8px;
  }

  .hero-main-button {
    padding: 20px 12px 14px;
  }

  .hero-teams {
    gap: 8px;
  }

  .hero-team {
    flex-direction: column !important;
    gap: 7px;
  }

  .hero-team-name {
    font-size: 1rem;
  }

  .hero-crest {
    width: 44px;
    height: 44px;
  }

  .hero-meta {
    font-size: 0.82rem;
  }

  .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 3px 3px 8px;
    scrollbar-width: thin;
  }

  .filters button {
    flex: 0 0 auto;
  }

  .match-card {
    padding: 13px 14px;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "badge when"
      "teams teams";
  }

  .teams {
    font-size: 0.95rem;
  }
}

@media (max-width: 340px) {
  .sticky-next-button .label {
    display: none;
  }

  .section-heading {
    align-items: start;
    flex-direction: column;
    gap: 4px;
  }

  .match-card {
    padding-inline: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
