:root {
  --bg: #ffffff;
  --card: #ffffff;
  --ink: #111111;
  --ink-soft: #777777;
  --line: #e5e5e5;
  --accent: #d97706;        /* amber */
  --accent-deep: #b45309;
  --accent-soft: #fdf1df;
  --shadow: 0 1px 2px rgba(17, 17, 17, .05);
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas,
          "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  letter-spacing: 0.02em;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-deep); text-decoration: underline; }

/* ---------- header ---------- */
.site-header {
  display: flex;
  align-items: center;
  gap: 22px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 24px 18px;
}
.logo { height: 72px; width: auto; flex: none; }
.btp-badge { margin-left: auto; flex: none; display: block; line-height: 0; }
.btp-badge img {
  height: 66px;
  width: auto;
  border-radius: 12px;
  transition: transform .15s, box-shadow .15s;
}
.btp-badge:hover img {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(17, 17, 17, .12);
}
.title-block h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}
.tagline { margin: 7px 0 0; color: var(--ink-soft); font-size: 13px; line-height: 1.5; }
.meta {
  margin: 9px 0 0;
  color: var(--ink-soft);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.meta b { color: var(--ink); font-weight: 700; }

/* ---------- tabs ---------- */
.tabs {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
}
.tab {
  appearance: none;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--ink); border-bottom-color: var(--accent); }

/* ---------- panels ---------- */
main { max-width: 1180px; margin: 0 auto; padding: 22px 24px 60px; }
.panel { display: none; }
.panel.is-active { display: block; }
.panel-intro {
  color: var(--ink-soft);
  font-size: 12.5px;
  max-width: 760px;
  margin: 0 0 22px;
  line-height: 1.6;
}

/* ---------- download buttons ---------- */
.panel-actions {
  display: flex;
  gap: 8px;
  margin: 0 0 18px;
}
.dl-btn {
  appearance: none;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 14px;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.dl-btn:hover {
  color: var(--accent-deep);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dl-btn:disabled { opacity: .55; cursor: default; }

/* ---------- group grid ---------- */
.group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 16px;
}
.group-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.group-card h3 {
  margin: 0;
  padding: 11px 16px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
  background: #fafafa;
}
.team-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--line);
}
.team-row:last-child { border-bottom: none; }
.team-row .flag { width: 40px; height: 30px; object-fit: contain; }
.team-name { font-size: 13.5px; font-weight: 700; }
.team-sub {
  font-size: 10.5px;
  color: var(--ink-soft);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}
.advance-cell { width: 128px; text-align: right; }
.bar {
  position: relative;
  height: 18px;
  background: #f0f0f0;
  border-radius: 3px;
  overflow: hidden;
}
.bar > span {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent));
  border-radius: 3px;
}
.bar > i {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 6px;
  font-size: 10.5px;
  font-style: normal;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* ---------- simulations (knockout) table ---------- */
.table-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}
.ko-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.ko-table thead th {
  position: sticky;
  top: 0;
  background: #fafafa;
  color: var(--ink-soft);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
  padding: 11px 10px;
  text-align: center;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.ko-table thead th:first-child,
.ko-table thead th:nth-child(2) { text-align: left; }
.ko-table thead th.sorted { color: var(--accent); }
.ko-table thead th .arrow { font-size: 9px; margin-left: 3px; }
.ko-table tbody td {
  padding: 0;
  text-align: center;
  border-bottom: 1px solid var(--line);
}
.ko-table tbody tr:hover { background: #fafafa; }
.cell-team {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  text-align: left;
  white-space: nowrap;
}
.cell-team .flag { width: 38px; height: 28px; object-fit: contain; }
.cell-team .nm { font-weight: 700; }
.cell-rank { color: var(--ink-soft); width: 28px; font-variant-numeric: tabular-nums; }
.cell-group, .cell-rating {
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  padding: 0 8px;
}
.cell-rating { color: var(--ink); font-weight: 700; }
.prob {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  padding: 9px 6px;
  min-width: 64px;
}
.prob.zero { color: #c7c7c7; font-weight: 400; }

/* ---------- matches ---------- */
.match-legend {
  display: flex;
  gap: 16px;
  margin-left: auto;
  align-items: center;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.match-legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 11px; height: 11px; border-radius: 2px; display: inline-block; }
.sw-a { background: var(--accent); }
.sw-d { background: #ddd6ca; }
.sw-b { background: #3f4651; }

.match-list { display: flex; flex-direction: column; gap: 8px; }
.match-date {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 18px 0 4px;
}
.match-date:first-child { margin-top: 0; }

.match-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 11px 16px;
}
.match-card.is-played { background: #fcfbf9; }
.match {
  display: grid;
  grid-template-columns: 1fr minmax(140px, 300px) 1fr;
  align-items: center;
  gap: 14px;
}
.m-team { display: flex; align-items: center; gap: 10px; min-width: 0; }
.m-team-a { justify-content: flex-end; text-align: right; }
.m-team-b { justify-content: flex-start; text-align: left; }
.m-team .flag { width: 34px; height: 26px; object-fit: contain; flex: none; }
.m-name-wrap { display: flex; flex-direction: column; min-width: 0; }
.m-team-a .m-name-wrap { align-items: flex-end; }
.m-team-b .m-name-wrap { align-items: flex-start; }
.m-name {
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.m-team:not(.win) .m-name { color: var(--ink-soft); }
.match-card:not(.is-played) .m-name { color: var(--ink); }
.m-xg {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.m-bar {
  display: flex;
  height: 22px;
  border-radius: 4px;
  overflow: hidden;
  background: #f0f0f0;
}
.seg {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  white-space: nowrap;
  min-width: 0;
}
.seg-a { background: var(--accent); }
.seg-d { background: #ddd6ca; color: #6b6253; }
.seg-b { background: #3f4651; }

.m-score {
  text-align: center;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}
.m-meta {
  margin-top: 7px;
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-align: center;
}

@media (max-width: 560px) {
  .match { grid-template-columns: 1fr; gap: 8px; }
  .m-team-a, .m-team-b { justify-content: flex-start; text-align: left; }
}

/* ---------- how this works ---------- */
.explainer {
  max-width: 720px;
  font-size: 14px;
  line-height: 1.7;
  color: #2a2a2a;
}
.explainer .lead {
  font-size: 15.5px;
  line-height: 1.65;
  color: var(--ink);
  border-left: 3px solid var(--accent);
  padding-left: 16px;
  margin: 0 0 30px;
}
.explainer h2 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-deep);
  margin: 30px 0 8px;
}
.explainer p { margin: 0 0 14px; }
.explainer strong { color: var(--ink); font-weight: 700; }
.explainer em { font-style: italic; color: var(--ink); }

/* ---------- footer ---------- */
.site-footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 8px 24px 44px;
  color: var(--ink-soft);
  font-size: 11px;
  letter-spacing: 0.04em;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}
.site-footer strong { color: var(--ink); }

@media (max-width: 620px) {
  .site-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .logo { height: 56px; }
}
