:root {
  --bg: #ffffff;
  --text: #161616;
  --muted: #6f6f6f;
  --line: #e6e6e6;
  --soft: #f7f7f7;
  --accent: #111111;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

button {
  font: inherit;
}

.arena {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.marquee {
  padding: 8px 0 18px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.75rem, 5vw, 3rem);
  font-weight: 750;
  letter-spacing: -0.03em;
}

h2 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 0.95rem;
  font-weight: 700;
}

.view-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.view-tabs button {
  padding: 10px 12px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

.view-tabs button.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.view-panel {
  display: none;
}

.view-panel.active {
  display: block;
}

.money-board,
.world-board,
.knockout-board {
  margin-bottom: 22px;
}

.board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

td {
  color: var(--text);
}

td:nth-child(3),
th:nth-child(3),
.contender-table th:first-child,
.contender-table td:first-child,
.contender-table th:nth-child(2),
.contender-table td:nth-child(2),
.group-table th:first-child,
.group-table td:first-child,
.group-table th:nth-child(2),
.group-table td:nth-child(2) {
  text-align: left;
}

.contender-row th {
  color: var(--text);
  font-size: 0.92rem;
  letter-spacing: 0;
  text-transform: none;
}

.contender-row strong {
  font-weight: 750;
}

.gambler-name {
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 700;
}

.contender-table table,
.group-table table {
  background: var(--bg);
}

.contender-table th:first-child,
.contender-table td:first-child {
  width: 34px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.contender-table th:nth-child(2),
.contender-table td:nth-child(2) {
  width: 110px;
}

.contender-table th:last-child,
.contender-table td:last-child {
  width: 38px;
}

.group-table th:first-child,
.group-table td:first-child {
  width: 72px;
}

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

.team-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  color: var(--muted);
  line-height: 1;
}

.team-flag img,
.table-flag {
  display: block;
  width: 30px;
  height: 20px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.team-flag small {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.team-flag.eliminated,
tr.eliminated .table-flag {
  opacity: 0.32;
  filter: grayscale(1);
}

.group-stage {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(460px, 1fr));
  gap: 18px;
}

.group-table {
  border: 0;
  border-radius: 0;
  overflow: hidden;
}

.card-context {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.card-context h3 {
  min-width: 0;
  overflow: visible;
  text-overflow: ellipsis;
  line-height: 1.35;
  white-space: nowrap;
}

.group-table table {
  table-layout: fixed;
  font-size: 0.84rem;
}

.group-table th:first-child,
.group-table td:first-child {
  width: 74px;
}

.group-table th:nth-child(n + 3),
.group-table td:nth-child(n + 3) {
  width: 38px;
}

.team-cell {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 28px;
}

.team-cell > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-table .gambler-name {
  display: block;
  font-size: inherit;
  white-space: nowrap;
}

tr.selected {
  background: #fbfbfb;
}

tr.eliminated {
  color: var(--muted);
}

.contender-row.eliminated .gambler-name {
  color: var(--muted);
  opacity: 0.45;
}

.knockout-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.round-column {
  display: grid;
  align-content: start;
  gap: 9px;
}

.round-column h3 {
  position: sticky;
  top: 0;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  width: fit-content;
  max-width: 100%;
  margin: 0 0 2px;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.match-card {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

.match-card.empty {
  color: var(--muted);
  text-align: center;
}

.match-card .fixture-team {
  display: grid;
}

.match-card .fixture-gambler:empty,
.match-card .fixture-team > strong:empty {
  display: none;
}

.match-card .fixture-team:has(.fixture-gambler:empty) {
  grid-template-columns: 30px minmax(0, 1fr) 24px;
}

.match-card .fixture-team:has(.fixture-gambler:empty):has(strong:empty) {
  grid-template-columns: 30px minmax(0, 1fr);
}

.match-card .fixture-team.placeholder .team-name {
  white-space: normal;
}

.match-card .fixture-team.eliminated .table-flag,
.match-card .fixture-team.eliminated .team-name,
.match-card .fixture-team.eliminated > strong {
  opacity: 0.42;
  filter: grayscale(1);
}

.match-card b,
.match-card strong {
  font-weight: 750;
}

.match-card span,
.match-card time {
  color: var(--muted);
  font-size: 0.82rem;
}

.fixture-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(440px, 100%), 1fr));
  align-items: start;
  gap: 8px 16px;
}

.fixture-day {
  grid-column: 1 / -1;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  width: fit-content;
  max-width: 100%;
  margin: 0 0 2px;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.fixture {
  display: grid;
  gap: 5px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

.fixture .card-context,
.match-card .card-context {
  padding: 2px 0 4px;
  background: transparent;
  border-bottom: 0;
}

.match-card .match-context {
  justify-content: space-between;
  min-height: 20px;
  padding-bottom: 0;
}

.fixture .card-context h3,
.match-card .card-context h3 {
  color: var(--accent);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.fixture-team {
  display: grid;
  grid-template-columns: 72px 30px minmax(0, 1fr) 24px;
  gap: 10px;
  align-items: center;
}

.fixture-gambler {
  overflow: hidden;
}

.fixture-team .gambler-name {
  display: block;
  font-size: 0.84rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fixture-team .team-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 0.9rem;
}

.fixture-team.placeholder .team-name {
  color: var(--muted);
  font-style: italic;
}

.fixture-team > strong {
  font-weight: 750;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.fixture-team.eliminated .table-flag,
.fixture-team.eliminated .team-name,
.fixture-team.eliminated > strong {
  opacity: 0.4;
  filter: grayscale(1);
}

.fixture-team .gambler-name.eliminated {
  color: var(--muted);
  opacity: 0.45;
}

.table-flag.placeholder {
  background: repeating-linear-gradient(
    -45deg,
    var(--soft),
    var(--soft) 4px,
    var(--bg) 4px,
    var(--bg) 8px
  );
  border-style: dashed;
}

.fixture-foot {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 3px;
  margin-top: 1px;
  border-top: 1px solid var(--line);
}

.fixture-stage {
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.fixture-foot-end {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.fixture-share {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

.fixture-share:hover,
.fixture-share:focus-visible {
  color: var(--accent);
  background: rgba(17, 17, 17, 0.06);
}

.fixture-share.copied::after {
  content: "Copied!";
  position: absolute;
  bottom: calc(100% + 4px);
  right: 0;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--ink, #1b1b1b);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  pointer-events: none;
}

.fixture-foot time,
.fixture-foot .fixture-ft {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.fixture-foot .fixture-live {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 750;
}

.fixture-foot .fixture-live::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #e5342b;
}

.fixture.next {
  border-color: var(--accent);
  background: var(--soft);
}

.fixture.next .fixture-foot time {
  color: var(--accent);
}

.fixture.next .card-context time {
  color: var(--accent);
}

.deep-linked {
  outline: 0;
  box-shadow: inset 0 0 0 4px var(--accent);
  scroll-margin-top: 14px;
}

.card-context .fixture-share {
  order: 3;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 720px) {
  .arena {
    padding: 16px 12px;
  }

  .view-tabs {
    gap: 2px;
    overflow-x: visible;
  }

  .view-tabs button {
    flex: 1 1 0;
    min-width: 0;
    padding: 10px 4px;
    font-size: 0.82rem;
    text-align: center;
    white-space: nowrap;
  }

  th,
  td {
    padding: 8px 5px;
  }

  .contender-row th {
    width: auto;
  }

  .contender-table th:first-child,
  .contender-table td:first-child {
    width: 22px;
  }

  .contender-table th:nth-child(2),
  .contender-table td:nth-child(2) {
    width: 62px;
  }

  .contender-table th,
  .contender-table td {
    padding-right: 2px;
    padding-left: 2px;
    font-size: 0.74rem;
  }

  .contender-table th:nth-child(n + 4),
  .contender-table td:nth-child(n + 4) {
    width: 21px;
  }

  .contender-table th:last-child,
  .contender-table td:last-child {
    width: 36px;
    padding-right: 8px;
  }

  .group-table th:first-child,
  .group-table td:first-child {
    width: 64px;
  }

  .group-table th:first-child {
    font-size: 0.72rem;
  }

  .group-table th:nth-child(2),
  .group-table td:nth-child(2) {
    padding-left: 8px;
  }

  .flag-strip {
    flex-wrap: nowrap;
    gap: 5px;
  }

  .contender-table .flag-strip {
    flex-wrap: nowrap;
    gap: 3px;
  }

  .contender-table .team-flag {
    width: clamp(22px, calc((100vw - 228px) / 4), 30px);
  }

  .contender-table .team-flag img {
    width: clamp(22px, calc((100vw - 228px) / 4), 30px);
    height: clamp(15px, calc((100vw - 228px) / 6), 20px);
  }

  .team-flag img {
    width: 25px;
    height: 17px;
  }

  .team-flag small {
    display: none;
  }

  .group-stage,
  .knockout-grid {
    grid-template-columns: 1fr;
    overflow-x: visible;
  }

  .group-table {
    overflow: hidden;
  }

  .group-table table {
    min-width: 0;
    font-size: 0.74rem;
  }

  .group-table th,
  .group-table td {
    padding-right: 3px;
    padding-left: 3px;
  }

  .group-table th:nth-child(n + 3),
  .group-table td:nth-child(n + 3) {
    width: 24px;
  }

  .group-table th:last-child,
  .group-table td:last-child {
    width: 34px;
    padding-right: 8px;
  }

  .team-cell {
    grid-template-columns: 23px minmax(0, 1fr);
    gap: 5px;
  }

  .table-flag {
    display: block;
    width: 23px;
    height: 16px;
  }

  .fixture {
    padding: 9px 10px;
  }

  .fixture-team {
    grid-template-columns: 62px 23px minmax(0, 1fr) 22px;
    gap: 8px;
  }

  .fixture-team .team-name {
    font-size: 0.86rem;
  }
}
