:root {
  color-scheme: dark;
  --bg: #202329;
  --panel: #2d2e35;
  --panel-border: #454850;
  --text: #f2f2f4;
  --muted: #aaaab0;
  --accent: #d9ff2f;
  --line: #50535b;
  --line-active: #d9ff2f;
  --inactive: #868890;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background:
    radial-gradient(circle at 74% 2%, rgba(217, 255, 47, 0.09), transparent 24rem),
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 18rem),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

.page-shell {
  width: min(1360px, 100%);
  margin: 0 auto;
  padding: 12px 18px 24px;
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 10px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 3.6vw, 46px);
  line-height: 1;
  letter-spacing: 0;
}

.json-link {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  text-decoration: none;
  font-size: 12px;
  font-weight: 800;
}

.bracket-wrap {
  overflow-x: auto;
  padding: 2px 0 12px;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.bracket {
  display: grid;
  grid-template-columns: repeat(4, 276px);
  gap: 48px;
  min-width: 1248px;
  align-items: start;
}

.stage {
  position: relative;
}

.stage-title {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
}

.match-list {
  position: relative;
  height: 430px;
}

.match {
  position: absolute;
  left: 0;
  right: 0;
  display: grid;
  align-content: center;
  min-height: 88px;
  padding: 10px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent),
    var(--panel);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.035),
    0 14px 30px rgba(0, 0, 0, 0.12);
}

.stage[data-stage-index="0"] .match:nth-child(1) {
  top: 0;
}

.stage[data-stage-index="0"] .match:nth-child(2) {
  top: 110px;
}

.stage[data-stage-index="0"] .match:nth-child(3) {
  top: 220px;
}

.stage[data-stage-index="0"] .match:nth-child(4) {
  top: 330px;
}

.stage[data-stage-index="1"] .match:nth-child(1) {
  top: 55px;
}

.stage[data-stage-index="1"] .match:nth-child(2) {
  top: 275px;
}

.stage[data-stage-index="2"] .match,
.stage[data-stage-index="3"] .match {
  top: 165px;
}

.stage[data-stage-index="0"] .match::after,
.stage[data-stage-index="1"] .match::after,
.stage[data-stage-index="2"] .match::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -25px;
  width: 25px;
  height: 1px;
  background:
    linear-gradient(90deg, transparent, rgba(217, 255, 47, 0.95), transparent) 0 0 / 25px 1px
      no-repeat,
    var(--line);
  animation: line-flow 1.8s linear infinite;
}

.stage[data-stage-index="0"] .match:nth-child(1)::before,
.stage[data-stage-index="0"] .match:nth-child(3)::before,
.stage[data-stage-index="1"] .match:nth-child(1)::before {
  content: "";
  position: absolute;
  right: -25px;
  top: 50%;
  width: 1px;
  height: 110px;
  background:
    linear-gradient(180deg, transparent, rgba(217, 255, 47, 0.75), transparent) 0 0 / 1px 42px
      no-repeat,
    var(--line);
  animation: line-flow-y 1.8s linear infinite;
}

.stage[data-stage-index="0"] .match:nth-child(2)::before,
.stage[data-stage-index="0"] .match:nth-child(4)::before,
.stage[data-stage-index="1"] .match:nth-child(2)::before {
  content: "";
  position: absolute;
  right: -25px;
  bottom: 50%;
  width: 1px;
  height: 110px;
  background:
    linear-gradient(0deg, transparent, rgba(217, 255, 47, 0.75), transparent) 0 0 / 1px 42px
      no-repeat,
    var(--line);
  animation: line-flow-y-reverse 1.8s linear infinite;
}

.stage[data-stage-index="0"] .match:nth-child(1)::before,
.stage[data-stage-index="0"] .match:nth-child(3)::before {
  height: 55px;
}

.stage[data-stage-index="0"] .match:nth-child(2)::before,
.stage[data-stage-index="0"] .match:nth-child(4)::before {
  height: 55px;
}

.stage[data-stage-index="1"] .match .match-date::before,
.stage[data-stage-index="2"] .match .match-date::before,
.stage[data-stage-index="3"] .match .match-date::before {
  content: "";
  position: absolute;
  left: -25px;
  top: 50%;
  width: 25px;
  height: 1px;
  background:
    linear-gradient(90deg, transparent, rgba(217, 255, 47, 0.95), transparent) 0 0 / 25px 1px
      no-repeat,
    var(--line);
  animation: line-flow 1.8s linear infinite;
  pointer-events: none;
}

.stage[data-stage-index="1"] .match .match-date::after,
.stage[data-stage-index="2"] .match .match-date::after,
.stage[data-stage-index="3"] .match .match-date::after {
  content: "";
  position: absolute;
  left: -6px;
  top: calc(50% - 4px);
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 6px solid var(--line-active);
  opacity: 0.9;
  pointer-events: none;
}

.match-date {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.team {
  display: grid;
  position: relative;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 26px;
  color: var(--inactive);
  font-size: 16px;
  font-weight: 900;
}

.team + .team {
  margin-top: 5px;
}

.team.is-active {
  color: var(--text);
}

.team-logo {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  object-fit: cover;
  background: #a8aab0;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
}

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

.team-metric {
  min-width: 22px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.team-metric--score {
  color: currentColor;
}

.team-metric--odds {
  min-width: 42px;
  color: #fff000;
  font-weight: 950;
  text-shadow: 0 0 18px rgba(255, 240, 0, 0.18);
}

.team-placeholder {
  width: 24px;
  height: 24px;
  border-radius: 50% 50% 44% 44%;
  background: #a8aab0;
  clip-path: polygon(50% 0, 92% 18%, 92% 58%, 50% 100%, 8% 58%, 8% 18%);
}

.load-error {
  padding: 24px;
  border: 1px solid #ba4d4d;
  border-radius: 8px;
  background: rgba(186, 77, 77, 0.12);
  color: #ffd4d4;
}

.data-warning {
  max-width: 760px;
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid rgba(214, 253, 67, 0.35);
  border-radius: 8px;
  background: rgba(214, 253, 67, 0.09);
  color: #edfbb0;
  font-size: 14px;
  font-weight: 700;
}

@media (max-width: 720px) {
  .page-shell {
    padding: 12px 14px 24px;
  }

  .hero {
    align-items: start;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 10px;
  }

  .bracket {
    grid-template-columns: repeat(4, 252px);
    min-width: 1098px;
    gap: 30px;
  }

  .stage[data-stage-index="0"] .match::after,
  .stage[data-stage-index="1"] .match::after,
  .stage[data-stage-index="2"] .match::after {
    right: -16px;
    width: 16px;
  }

  .stage[data-stage-index="0"] .match:nth-child(1)::before,
  .stage[data-stage-index="0"] .match:nth-child(2)::before,
  .stage[data-stage-index="0"] .match:nth-child(3)::before,
  .stage[data-stage-index="0"] .match:nth-child(4)::before,
  .stage[data-stage-index="1"] .match:nth-child(1)::before,
  .stage[data-stage-index="1"] .match:nth-child(2)::before {
    right: -16px;
  }

  .stage[data-stage-index="1"] .match .match-date::before,
  .stage[data-stage-index="2"] .match .match-date::before,
  .stage[data-stage-index="3"] .match .match-date::before {
    left: -16px;
    width: 16px;
  }
}

@keyframes line-flow {
  from {
    background-position: -42px 0, 0 0;
  }

  to {
    background-position: 49px 0, 0 0;
  }
}

@keyframes line-flow-y {
  from {
    background-position: 0 -42px, 0 0;
  }

  to {
    background-position: 0 110px, 0 0;
  }
}

@keyframes line-flow-y-reverse {
  from {
    background-position: 0 110px, 0 0;
  }

  to {
    background-position: 0 -42px, 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stage[data-stage-index="0"] .match::after,
  .stage[data-stage-index="1"] .match::after,
  .stage[data-stage-index="2"] .match::after,
  .stage[data-stage-index="0"] .match::before,
  .stage[data-stage-index="1"] .match::before {
    animation: none;
  }
}
