:root {
  color-scheme: light;
  --navy: #111827;
  --navy-2: #172033;
  --red: #ef3340;
  --red-dark: #d82634;
  --cream: #f5f2ec;
  --surface: #fffdfa;
  --ink: #171a1f;
  --muted: #727780;
  --line: #e5e1db;
  --soft: #f0ede8;
  --shadow: 0 12px 32px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.hide-results .match-row.is-completed .score-value:not(.placeholder) {
  filter: blur(7px);
  user-select: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
p {
  margin: 0;
}

.hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fff;
  padding: 22px 22px 60px;
}

.hero-inner {
  max-width: 1180px;
  margin: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.mark {
  display: block;
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.brand h1 {
  font-size: 18px;
  margin: 0;
  letter-spacing: -0.01em;
}

.brand p {
  max-width: 780px;
  margin: 3px 0 0;
  color: #adb7c6;
  font-size: 13px;
  line-height: 1.35;
}

.refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 9px 14px;
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  white-space: nowrap;
}

.spinning .refresh-glyph {
  display: inline-block;
  animation: spin 0.65s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.shell {
  max-width: 1180px;
  margin: -30px auto 0;
  padding: 0 22px 36px;
}

.control-card {
  position: sticky;
  top: 0;
  z-index: 4;
  margin-bottom: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 16px 36px rgba(17, 24, 39, 0.13);
}

.control-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.tabs {
  display: flex;
  gap: 5px;
  padding: 4px;
  background: var(--soft);
  border-radius: 12px;
}

.tabs button {
  min-height: 36px;
  padding: 8px 16px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 9px;
  font-weight: 700;
}

.tabs button.active {
  color: #fff;
  background: var(--navy);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.14);
}

.right-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}

.switchline {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.switchline input {
  width: 16px;
  height: 16px;
  accent-color: var(--red);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.15fr) minmax(170px, 0.9fr) minmax(190px, 1fr) minmax(190px, 0.9fr);
  gap: 9px;
  align-items: start;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.select,
select,
input:not([type="checkbox"]) {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
}

.select:focus,
select:focus,
input:not([type="checkbox"]):focus {
  border-color: #a7adb6;
  box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.05);
}

.filter-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.filter-toggle::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-top: -3px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 140ms ease, margin-top 140ms ease;
}

.control-card.filters-open .filter-toggle::after {
  margin-top: 3px;
  transform: rotate(225deg);
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-chips:empty {
  display: none;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  min-height: 24px;
  padding: 3px 7px;
  color: #253445;
  background: #eef3f7;
  border: 1px solid #d5e0e8;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.1;
}

.filter-chip:hover {
  background: #e4edf4;
  border-color: #c5d4df;
}

.player-chip {
  color: #28325a;
  background: #eceffc;
  border-color: #d5daf4;
}

.country-chip {
  color: #2e3d31;
  background: #eaf4ec;
  border-color: #cfe2d3;
}

.chip-flag {
  font-size: 14px;
  line-height: 1;
}

.chip-remove {
  color: var(--muted);
  font-size: 11px;
}

.summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0 4px 12px;
  color: var(--muted);
  font-size: 12px;
}

.match-list {
  display: block;
}

.day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 24px 4px 12px;
}

.day-head h2 {
  margin: 0;
  color: var(--navy);
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.day-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.tournament {
  margin-bottom: 16px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.tournament-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 17px;
  background: #faf8f4;
  border-bottom: 1px solid var(--line);
}

.tournament-title {
  color: var(--navy);
  font-size: 14px;
  font-weight: 800;
}

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

.match-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) 24px;
  align-items: center;
  gap: 14px;
  min-height: 74px;
  padding: 13px 17px;
  border-bottom: 1px solid var(--line);
}

.match-row:last-child {
  border-bottom: 0;
}

.match-row.is-ongoing {
  box-shadow: inset 3px 0 0 var(--red);
}

.match-row.is-ongoing .time {
  color: var(--red-dark);
}

.time {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.match-content {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.players {
  display: grid;
  gap: 6px;
}

.player-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  color: #2d333c;
  font-size: 14px;
  font-weight: 650;
}

.player-line.winner {
  color: var(--navy);
  font-weight: 800;
}

.player-identity {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.player-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-value {
  margin-left: auto;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
  font-weight: 850;
}

.score-value.placeholder {
  color: #a2a7ae;
}

.game-score {
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.match-meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  min-height: 22px;
  padding: 3px 7px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.15;
  text-decoration: none;
}

.status {
  text-transform: uppercase;
}

.status.live {
  color: #196049;
  background: #e4f6ee;
  border-color: #b6e6d3;
}

.status.completed {
  color: #6e3641;
  background: #f8e8eb;
  border-color: #e8c7ce;
}

.now-pill {
  gap: 5px;
  color: #8f1f17;
  background: #fff0ee;
  border-color: #f3bbb5;
  text-transform: uppercase;
}

.now-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--red-dark);
  box-shadow: 0 0 0 3px rgba(239, 51, 64, 0.14);
}

.round-pill {
  color: #27405c;
  background: #e8f0f7;
  border-color: #cadae8;
}

.table-pill {
  color: #4b4527;
  background: #f2eddb;
  border-color: #ddd2aa;
}

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

.chev {
  color: #9ba1aa;
  font-size: 22px;
  line-height: 1;
  text-align: right;
}

.flags {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
}

.flag {
  position: relative;
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  font-size: 17px;
  line-height: 1;
  cursor: default;
}

.flag::before,
.flag::after {
  position: absolute;
  left: 50%;
  z-index: 8;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(2px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.flag::before {
  content: "";
  top: calc(100% + 1px);
  border-right: 5px solid transparent;
  border-bottom: 5px solid var(--navy);
  border-left: 5px solid transparent;
}

.flag::after {
  content: attr(data-country);
  top: calc(100% + 6px);
  padding: 4px 7px;
  color: #fff;
  background: var(--navy);
  border-radius: 4px;
  box-shadow: 0 6px 16px rgba(17, 24, 39, 0.18);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.flag:hover::before,
.flag:hover::after {
  opacity: 1;
  transform: translateX(-50%);
}

.empty,
.error {
  padding: 28px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.error {
  color: var(--red-dark);
}

@media (max-width: 860px) {
  .control-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .right-controls {
    justify-content: space-between;
    width: 100%;
    flex-wrap: wrap;
  }

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

@media (max-width: 640px) {
  .hero {
    padding: 16px 14px 54px;
  }

  .brand {
    align-items: flex-start;
  }

  .brand p {
    display: none;
  }

  .refresh-btn {
    padding: 8px 10px;
  }

  .shell {
    padding: 0 12px 28px;
  }

  .control-card {
    padding: 12px;
    border-radius: 16px;
  }

  .control-top {
    gap: 10px;
    margin-bottom: 0;
  }

  .tabs {
    width: 100%;
  }

  .tabs button {
    flex: 1;
    padding-inline: 10px;
  }

  .right-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
  }

  .filter-toggle {
    display: inline-flex;
  }

  .toolbar {
    display: none;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
  }

  .control-card.filters-open .toolbar {
    display: grid;
  }

  .summary {
    display: grid;
  }

  .day-head {
    margin-top: 22px;
  }

  .tournament-head {
    align-items: flex-start;
  }

  .tournament-meta {
    max-width: 46%;
  }

  .match-row {
    grid-template-columns: 58px minmax(0, 1fr) 18px;
    gap: 10px;
    padding: 12px;
  }

  .player-line {
    gap: 9px;
    font-size: 13px;
  }
}

@media (max-width: 420px) {
  .mark {
    width: 42px;
    height: 42px;
  }

  .brand h1 {
    font-size: 16px;
  }

  .refresh-label {
    display: none;
  }

  .match-row {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .chev {
    display: none;
  }
}
