:root {
  color-scheme: dark;
  --bg: #07110f;
  --panel: #0d1c19;
  --panel-2: #122621;
  --line: rgba(255, 255, 255, 0.13);
  --text: #f4f7f1;
  --muted: #9db2aa;
  --gold: #e7c46a;
  --green: #3bd18f;
  --red: #f36868;
  --blue: #66b6ff;
  --card-w: 280px;
  --card-h: 162px;
  --col-gap: 76px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(231, 196, 106, 0.12), transparent 34%),
    radial-gradient(circle at 82% 12%, rgba(102, 182, 255, 0.13), transparent 24rem),
    linear-gradient(180deg, #07110f 0%, #0b171a 55%, #07110f 100%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

button {
  font: inherit;
}

.shell {
  width: min(100%, 1760px);
  margin: 0 auto;
  padding: 32px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  min-height: 140px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 78px);
  line-height: 0.98;
  letter-spacing: 0;
}

.status-panel {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 28, 25, 0.78);
  color: var(--muted);
  font-size: 14px;
}

.status-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 18px rgba(231, 196, 106, 0.7);
}

.status-dot.ok {
  background: var(--green);
  box-shadow: 0 0 18px rgba(59, 209, 143, 0.7);
}

.status-dot.error {
  background: var(--red);
  box-shadow: 0 0 18px rgba(243, 104, 104, 0.7);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 22px 0;
}

.summary-grid article {
  min-height: 82px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(18, 38, 33, 0.72);
}

.summary-grid span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.summary-grid strong {
  font-size: 18px;
  line-height: 1.25;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 10px 0 18px;
}

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

.tab,
.refresh {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 28, 25, 0.9);
  color: var(--text);
  cursor: pointer;
}

.tab {
  padding: 0 14px;
}

.tab.active,
.tab:hover,
.refresh:hover {
  border-color: rgba(231, 196, 106, 0.76);
  background: rgba(231, 196, 106, 0.15);
}

.refresh {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
}

.refresh span {
  font-size: 20px;
  line-height: 1;
}

.bracket-wrap {
  overflow-x: auto;
  padding: 8px 0 28px;
}

.bracket {
  min-width: calc(var(--card-w) * 5 + var(--col-gap) * 4);
}

.bracket.diagram {
  position: relative;
  display: block;
}

.bracket.filtered {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  min-width: 0;
}

.round-list {
  display: grid;
  gap: 14px;
  align-content: start;
}

.round-title {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 12px 2px 10px;
  background: linear-gradient(180deg, rgba(7, 17, 15, 0.95), rgba(7, 17, 15, 0));
}

.round-title h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.round-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.round-lane-title {
  position: absolute;
  top: 0;
  width: var(--card-w);
  height: 44px;
  z-index: 3;
  padding: 0 2px;
}

.round-lane-title h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.round-lane-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.connector-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.connector-layer path {
  fill: none;
  stroke: rgba(231, 196, 106, 0.42);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.match-card {
  position: relative;
  min-height: 162px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(18, 38, 33, 0.98), rgba(11, 25, 28, 0.96));
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.24);
}

.diagram-card {
  position: absolute;
  z-index: 2;
  width: var(--card-w);
  height: var(--card-h);
  min-height: var(--card-h);
}

.match-head,
.match-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.match-number {
  color: var(--gold);
  font-weight: 800;
}

.team-row {
  display: grid;
  grid-template-columns: 42px 30px 1fr minmax(22px, auto);
  align-items: center;
  gap: 8px;
  min-height: 38px;
  margin-top: 10px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.team-row.winner {
  background: rgba(59, 209, 143, 0.14);
  box-shadow: inset 3px 0 0 var(--green);
}

.seed {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.flag {
  width: 28px;
  height: 20px;
  overflow: hidden;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.12);
}

.flag img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.team-name {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score {
  color: var(--text);
  font-size: 18px;
}

.match-meta {
  margin-top: 12px;
  line-height: 1.3;
}

.empty {
  grid-column: 1 / -1;
  padding: 40px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 820px) {
  .shell {
    padding: 20px;
  }

  .topbar,
  .controls {
    align-items: stretch;
    flex-direction: column;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .bracket {
    display: grid;
    grid-template-columns: 1fr;
    min-width: 0;
    width: auto !important;
    height: auto !important;
  }

  .bracket.diagram {
    position: static;
    gap: 14px;
  }

  .round-lane-title,
  .connector-layer {
    display: none;
  }

  .diagram-card {
    position: relative;
    left: auto !important;
    top: auto !important;
    width: 100%;
    height: auto;
    min-height: var(--card-h);
  }

  .match-card::after {
    display: none;
  }
}
