:root {
  --bg: #f4f1ea;
  --ink: #20242a;
  --muted: #69717c;
  --panel: #fffdf8;
  --line: #dad4c8;
  --red: #b8453d;
  --teal: #167579;
  --gold: #b98219;
  --green: #4b7d43;
  --shadow: 0 18px 42px rgba(49, 42, 31, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 12% 0%, rgba(184, 69, 61, 0.14), transparent 30rem),
    linear-gradient(135deg, rgba(22, 117, 121, 0.12), transparent 32rem),
    var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--ink);
  color: white;
  cursor: pointer;
}

button:hover {
  background: #343a42;
}

.shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(32px, 6vw, 72px);
  line-height: 0.95;
}

h2 {
  font-size: 18px;
}

.source {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  text-align: right;
}

.source button {
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 21px;
}

.controls {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) minmax(170px, 1fr) minmax(170px, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 253, 248, 0.85);
  color: var(--ink);
}

input,
select {
  height: 42px;
  padding: 0 12px;
}

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

.metrics article,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.88);
  box-shadow: var(--shadow);
}

.metrics article {
  min-height: 104px;
  padding: 18px;
  display: grid;
  align-content: space-between;
}

.metrics span,
.panelHead span {
  color: var(--muted);
  font-size: 13px;
}

.metrics strong {
  font-size: clamp(26px, 4vw, 44px);
  line-height: 1;
}

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

.panel {
  min-width: 0;
  padding: 18px;
}

.wide {
  grid-column: 1 / -1;
}

.panelHead {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panelHead > div:first-child {
  display: grid;
  gap: 3px;
}

.sortGroup {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.sortBtn {
  min-width: 58px;
  height: 30px;
  padding: 0 10px;
  border-color: #c9c1b3;
  background: #ece5d9;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.sortBtn:hover,
.sortBtn.active {
  border-color: var(--teal);
  background: var(--teal);
  color: white;
}

.sortBtn.active::after {
  content: " ↓";
}

.sortBtn.active[data-direction="asc"]::after {
  content: " ↑";
}

.timeline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
  align-items: stretch;
  gap: 10px;
  min-height: 210px;
  padding-top: 4px;
}

.bar {
  display: grid;
  grid-template-rows: 24px 142px 22px;
  align-items: end;
  gap: 6px;
  min-width: 0;
  height: 194px;
}

.barFill {
  align-self: end;
  width: 100%;
  min-height: 6px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, var(--teal), var(--green));
}

.bar b,
.bar span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.bar b {
  align-self: end;
  line-height: 1;
}

.bar span {
  align-self: start;
  color: var(--muted);
}

.table {
  display: grid;
  gap: 8px;
}

.scrollList {
  max-height: 430px;
  overflow: auto;
  padding-right: 4px;
}

.scrollList .header {
  position: sticky;
  top: 0;
  z-index: 1;
  min-height: 28px;
  background: rgba(255, 253, 248, 0.96);
  border-bottom: 1px solid var(--line);
}

.row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 56px 56px 72px;
  align-items: center;
  gap: 10px;
  min-height: 40px;
}

.row.header {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

.pill {
  justify-self: start;
  min-width: 60px;
  border-radius: 999px;
  padding: 5px 8px;
  background: rgba(184, 69, 61, 0.1);
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.matches {
  display: grid;
  gap: 10px;
  max-height: 456px;
  overflow: auto;
  padding-right: 4px;
}

.match {
  display: grid;
  gap: 7px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.match:first-child {
  border-top: 0;
  padding-top: 0;
}

.teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
}

.team {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.team.win {
  color: var(--teal);
}

.score {
  min-width: 54px;
  border-radius: 6px;
  padding: 6px 8px;
  background: #ece5d9;
  font-weight: 900;
  text-align: center;
}

.meta {
  color: var(--muted);
  font-size: 12px;
}

.empty {
  color: var(--muted);
  padding: 18px 0;
}

@media (max-width: 840px) {
  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .source {
    width: 100%;
    justify-content: space-between;
    text-align: left;
  }

  .controls,
  .metrics,
  .grid {
    grid-template-columns: 1fr;
  }

  .panelHead {
    flex-direction: column;
  }

  .sortGroup {
    justify-content: flex-start;
  }

  .row {
    grid-template-columns: minmax(100px, 1fr) 44px 44px 64px;
    gap: 8px;
  }

  .panel {
    padding: 14px;
  }

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

  .score {
    width: 58px;
  }
}
