:root {
  --ink: #f8fbff;
  --text: #f8fbff;
  --muted: #a9b9cc;
  --line: rgba(255, 255, 255, 0.16);
  --paper: #050b17;
  --panel: rgba(9, 20, 38, 0.88);
  --panel-solid: #0a1425;
  --gold: #f2c55f;
  --gold-deep: #a96d17;
  --red: #e0362f;
  --red-soft: rgba(224, 54, 47, 0.16);
  --blue: #37a7ff;
  --blue-soft: rgba(55, 167, 255, 0.16);
  --shadow: 0 18px 54px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 24% 0%, rgba(55, 167, 255, 0.22), transparent 34rem),
    radial-gradient(circle at 78% 14%, rgba(224, 54, 47, 0.18), transparent 30rem),
    linear-gradient(180deg, #020711 0%, #071224 45%, #040814 100%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.site-hero {
  position: relative;
  width: min(1440px, calc(100% - 32px));
  margin: 16px auto 0;
  overflow: hidden;
  background: #020711;
  border: 1px solid rgba(242, 197, 95, 0.38);
  border-bottom: 1px solid rgba(242, 197, 95, 0.38);
  border-radius: 8px;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.42);
}

.site-hero img {
  display: block;
  width: 100%;
  height: clamp(260px, 52vw, 720px);
  object-fit: cover;
  object-position: center;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 4.5rem);
  line-height: 0.96;
  max-width: 760px;
}

h2 {
  font-size: 1.25rem;
  color: var(--ink);
}

.eyebrow {
  color: var(--gold);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hero-actions,
.hero-refresh,
.dialog-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.hero-actions {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 2;
  justify-content: flex-end;
  max-width: calc(100% - 32px);
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(2, 7, 17, 0.7);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
}

.hero-refresh {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 2;
  max-width: calc(100% - 32px);
}

.hero-refresh-button {
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(2, 7, 17, 0.7);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
}

.hero-updated {
  color: rgba(248, 251, 255, 0.82);
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.25;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.86);
}

.primary-button,
.secondary-button,
.icon-button,
.tab,
.time-zone-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 42px;
  padding: 0 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
}

.primary-button,
.icon-button {
  border-color: rgba(242, 197, 95, 0.72);
  color: #071224;
  background: linear-gradient(180deg, #ffe08a, var(--gold));
  font-weight: 850;
}

.time-zone-toggle {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.time-zone-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.time-zone-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
  text-transform: uppercase;
}

.time-zone-button {
  min-height: 34px;
  padding: 0 10px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.time-zone-button.active {
  color: #071224;
  background: var(--gold);
}

main {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto 56px;
}

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

.feature-panel,
.leaderboard-section,
.side-panel,
.tabs-section,
.map-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.feature-panel {
  min-height: 210px;
  padding: clamp(18px, 3vw, 34px);
  min-width: 0;
}

.tournament-status-panel {
  display: grid;
  align-content: center;
  text-align: center;
}

.panel-label,
.muted,
.metric-label {
  color: var(--muted);
}

.panel-label {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

.next-match {
  display: grid;
  margin-top: 18px;
}

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

.owner-card {
  border-left: 5px solid var(--blue);
  padding: 14px 16px;
  background: var(--blue-soft);
  border-radius: 8px;
}

.owner-card.away {
  border-left-color: var(--red);
  background: var(--red-soft);
}

.flag-bg {
  background-image:
    linear-gradient(90deg, rgba(9, 20, 38, 0.92), rgba(9, 20, 38, 0.72), rgba(9, 20, 38, 0.92)),
    var(--flag-url);
  background-repeat: no-repeat;
  background-position: center, right center;
  background-size: auto, 8rem auto;
}

.owner-card.flag-bg,
.team-card.flag-bg {
  background-position: center, right 12px center;
  background-size: auto, 9rem auto;
}

.owner {
  font-size: 1.15rem;
  font-weight: 800;
}

.team-name {
  margin-top: 4px;
  color: var(--muted);
}

.vs-pill {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  color: #071224;
  background: var(--gold);
  font-weight: 900;
}

.match-meta {
  color: var(--muted);
  line-height: 1.5;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 30px;
}

.tournament-status-panel .status-grid {
  position: relative;
  align-items: stretch;
}

.tournament-status-panel .status-grid > div {
  display: grid;
  align-content: center;
  gap: 8px;
  min-height: 108px;
  padding: 14px 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.metric {
  display: block;
  font-size: clamp(2rem, 4vw, 3.5rem);
  font-weight: 900;
  line-height: 1;
}

.tournament-status-panel .metric {
  color: var(--ink);
  text-shadow: 0 0 20px rgba(55, 167, 255, 0.26);
}

.tournament-status-panel .metric-label {
  font-weight: 850;
  text-transform: uppercase;
}

.content-grid,
.tabs-section,
.map-section {
  margin-top: 18px;
}

.leaderboard-section,
.side-panel,
.tabs-section,
.map-section {
  padding: 20px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.section-heading.compact {
  align-items: start;
}

.leaderboard,
.fixture-list,
.teams-grid,
.knockout-grid {
  display: grid;
  gap: 10px;
}

.leader-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.rank {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: #071224;
  background: var(--gold);
  border-radius: 50%;
  font-weight: 900;
}

.leader-main {
  min-width: 0;
}

.leader-owner {
  font-weight: 900;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.78rem;
  white-space: nowrap;
}

.chip.flag-bg {
  background-image:
    linear-gradient(90deg, rgba(9, 20, 38, 0.88), rgba(9, 20, 38, 0.76)),
    var(--flag-url);
  background-position: center, right center;
  background-size: auto, 3.2rem auto;
}

.score {
  font-size: 1.8rem;
  font-weight: 900;
}

.fixture-card,
.team-card,
.stage-card,
.group-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.fixture-card {
  position: relative;
  padding: 12px;
}

.fixture-card.fixture-flags {
  background: rgba(9, 20, 38, 0.58);
}

.fixture-card.fixture-flags .fixture-teams {
  position: relative;
  z-index: 1;
  overflow: hidden;
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(9, 20, 38, 0.56), rgba(9, 20, 38, 0.86), rgba(9, 20, 38, 0.56));
}

.fixture-card.fixture-flags .fixture-teams::before,
.fixture-card.fixture-flags .fixture-teams::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: -1;
  width: 36%;
  opacity: 0.72;
  background-repeat: no-repeat;
  background-size: 120% auto;
  pointer-events: none;
}

.fixture-card.fixture-flags .fixture-teams::before {
  left: 0;
  background-image: var(--flag-home);
  background-position: left center;
  -webkit-mask-image: linear-gradient(90deg, #000 0%, #000 28%, transparent 92%);
  mask-image: linear-gradient(90deg, #000 0%, #000 28%, transparent 92%);
}

.fixture-card.fixture-flags .fixture-teams::after {
  right: 0;
  background-image: var(--flag-away);
  background-position: right center;
  -webkit-mask-image: linear-gradient(270deg, #000 0%, #000 28%, transparent 92%);
  mask-image: linear-gradient(270deg, #000 0%, #000 28%, transparent 92%);
}

.fixture-teams {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(118px, auto) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  font-weight: 850;
  min-height: 74px;
  padding: 8px 10px;
}

.fixture-side,
.fixture-center {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.fixture-side {
  max-width: 82%;
}

.fixture-side-home {
  justify-self: end;
  text-align: right;
}

.fixture-side-away {
  justify-self: start;
  text-align: left;
}

.fixture-owner,
.fixture-team,
.fixture-date,
.fixture-group {
  overflow-wrap: anywhere;
}

.fixture-owner {
  color: var(--ink);
  font-size: 1.08rem;
}

.fixture-team {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 750;
}

.fixture-center {
  justify-items: center;
  text-align: center;
  padding: 0 8px;
}

.fixture-score {
  display: inline-grid;
  place-items: center;
  min-width: 36px;
  height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  color: #071224;
  background: var(--gold);
  font-weight: 950;
  font-size: 1.04rem;
}

.fixture-date {
  color: var(--gold);
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.2;
}

.fixture-group {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  overflow-x: auto;
}

.tab.active {
  color: #071224;
  border-color: var(--gold);
  background: var(--gold);
  font-weight: 850;
}

.tab-view {
  display: none;
}

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

.groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}

.group-card {
  overflow: hidden;
}

.group-card h3,
.stage-card h3 {
  margin: 0;
  padding: 12px 14px;
  font-size: 0.98rem;
  color: var(--ink);
  background: linear-gradient(90deg, rgba(55, 167, 255, 0.2), rgba(242, 197, 95, 0.12));
}

tbody tr.flag-bg {
  background-image:
    linear-gradient(90deg, rgba(9, 20, 38, 0.92), rgba(9, 20, 38, 0.72), rgba(9, 20, 38, 0.92)),
    var(--flag-url);
  background-repeat: no-repeat;
  background-position: center, right 8px center;
  background-size: auto, 6.6rem auto;
}

table {
  width: 100%;
  min-width: 420px;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th,
td {
  padding: 9px 10px;
  border-top: 1px solid var(--line);
  text-align: right;
}

th:first-child,
td:first-child {
  text-align: left;
}

.owned-team {
  font-weight: 900;
  color: var(--gold);
}

.stage-card {
  overflow: hidden;
}

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

.team-card {
  padding: 12px;
}

.team-card .owner {
  font-size: 0.9rem;
  color: var(--gold);
}

.world-map {
  overflow: visible;
  padding-bottom: 4px;
}

.map-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1000 / 380;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 50%, rgba(55, 167, 255, 0.1), transparent 44%),
    linear-gradient(180deg, rgba(6, 17, 33, 0.96), rgba(9, 20, 38, 0.9));
}

.map-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 80px 80px;
  mask-image: radial-gradient(circle at center, #000 0%, transparent 78%);
}

.map-graticule {
  position: absolute;
  inset: 22px;
  border: 1px solid rgba(242, 197, 95, 0.16);
  border-radius: 50%;
  pointer-events: none;
}

.world-map-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.46;
  filter: drop-shadow(0 0 16px rgba(55, 167, 255, 0.26));
  pointer-events: none;
}

.map-land-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.world-map-svg.fallback path {
  fill: rgba(55, 167, 255, 0.2);
  stroke: rgba(242, 197, 95, 0.34);
  stroke-width: 1.8;
  vector-effect: non-scaling-stroke;
}

.world-map-svg.detailed {
  opacity: 0.62;
}

.world-ocean {
  fill: rgba(55, 167, 255, 0.035);
  stroke: rgba(242, 197, 95, 0.18);
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}

.world-land {
  fill: rgba(55, 167, 255, 0.22);
  stroke: rgba(242, 197, 95, 0.34);
  stroke-width: 0.85;
  vector-effect: non-scaling-stroke;
}

.map-marker {
  position: absolute;
  left: var(--map-x);
  top: var(--map-y);
  z-index: 1;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  grid-template-areas:
    "flag team"
    "flag meta";
  column-gap: 7px;
  align-items: center;
  width: 138px;
  min-height: 42px;
  padding: 5px 7px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(2, 7, 17, 0.76);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.32);
  transform: translate(-50%, -50%);
  backdrop-filter: blur(8px);
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.map-marker:hover,
.map-marker:focus-visible {
  z-index: 20;
  outline: none;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.48), 0 0 0 1px rgba(242, 197, 95, 0.42);
  transform: translate(-50%, -50%) scale(1.08);
}

.map-marker img {
  grid-area: flag;
  width: 28px;
  height: 20px;
  object-fit: cover;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.32);
}

.map-team {
  grid-area: team;
  min-width: 0;
  overflow: hidden;
  font-size: 0.72rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-meta {
  grid-area: meta;
  color: var(--gold);
  font-size: 0.66rem;
  font-weight: 750;
}

.settings-dialog {
  width: min(760px, calc(100% - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  background: var(--panel-solid);
  box-shadow: var(--shadow);
}

.settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.settings-dialog form {
  display: grid;
  gap: 12px;
  padding: 22px;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
}

.icon-only {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
}

label {
  margin-top: 8px;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
}

textarea {
  min-height: 260px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.9rem;
}

.empty {
  padding: 18px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

@media (max-width: 900px) {
  .hero-grid,
  .content-grid,
  .versus,
  .status-grid {
    grid-template-columns: 1fr;
  }

  .hero-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: min(300px, calc(100% - 20px));
    right: 10px;
    bottom: 10px;
  }

  .hero-refresh {
    left: 10px;
    bottom: 10px;
    max-width: min(320px, calc(100% - 20px));
  }

  .time-zone-toggle {
    grid-column: 1 / -1;
  }

  .time-zone-control {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    width: 100%;
  }

  .versus {
    justify-items: stretch;
  }

  .vs-pill {
    justify-self: center;
  }

  .section-heading {
    align-items: start;
    flex-direction: column;
  }

  .site-hero img {
    height: auto;
  }
}

@media (max-width: 560px) {
  .site-hero,
  main {
    width: min(100% - 20px, 1440px);
  }

  .site-hero {
    margin-top: 10px;
  }

  .site-hero img {
    height: auto;
    object-fit: contain;
  }

  .hero-actions,
  .hero-refresh {
    position: static;
    width: 100%;
    max-width: none;
    margin: 8px 0 0;
  }

  .site-hero {
    padding-bottom: 8px;
  }

  .feature-panel,
  .leaderboard-section,
  .side-panel,
  .tabs-section,
  .map-section {
    padding: 14px;
  }

  .status-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .tournament-status-panel .status-grid > div {
    min-height: 88px;
    padding: 10px 6px;
  }

  .metric {
    font-size: 1.75rem;
  }

  .metric-label {
    font-size: 0.78rem;
  }

  .leader-row {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: 9px;
    padding: 10px;
  }

  .rank {
    width: 30px;
    height: 30px;
  }

  .score {
    font-size: 1.35rem;
  }

  .chip {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .fixture-teams {
    grid-template-columns: minmax(0, 1fr) minmax(86px, auto) minmax(0, 1fr);
    gap: 4px;
    min-height: 82px;
    padding: 8px 6px;
  }

  .fixture-card.fixture-flags .fixture-teams::before,
  .fixture-card.fixture-flags .fixture-teams::after {
    width: 42%;
    background-size: 135% auto;
  }

  .fixture-side {
    max-width: 100%;
  }

  .fixture-owner {
    font-size: 0.9rem;
  }

  .fixture-team,
  .fixture-date {
    font-size: 0.74rem;
  }

  .fixture-group {
    font-size: 0.66rem;
  }

  .fixture-score {
    min-width: 30px;
    height: 26px;
    padding: 0 8px;
    font-size: 0.9rem;
  }

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

  .group-card {
    overflow-x: auto;
  }

  .stage-matches {
    grid-template-columns: 1fr;
    padding: 10px;
  }

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

  textarea {
    min-height: 220px;
  }
}
