:root {
  --bg: #0b1220;
  --panel: #121a2e;
  --panel-alt: #182241;
  --border: #2a3557;
  --text: #e6ecff;
  --muted: #94a3c4;
  --accent: #ffcc33;
  --win: #2ecc71;
}

* { box-sizing: border-box; }

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

main#app {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  padding: 16px;
  align-items: stretch;
}

/* Each half is 4 columns of rounds (R32, R16, QF, SF). */
.half {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
/* The left half is laid out right-to-left so R32 sits on the outside
   (far-left edge) and SF sits inside (nearest the center column). The
   right half is plain ltr, which mirrors the visual result: SF nearest
   the center, R32 on the far-right edge. */
.half-left { direction: rtl; }
.half-left .round { direction: ltr; }  /* keep card contents ltr */

.round {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  gap: 8px;
  min-width: 170px;
}

.round-title {
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.match {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.match .team {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 13px;
}
/* Right half: mirror team rows so the flag is on the outer (right) edge
   and the name reads toward the center final. */
.half-right .match .team {
  grid-template-columns: auto 1fr 24px;
}
.half-right .match .team .name  { text-align: right; }
.half-right .match .team .score { text-align: left; }
.match .team + .team {
  border-top: 1px solid var(--border);
  background: var(--panel-alt);
}
.match .team.winner .name { color: var(--accent); font-weight: 600; }
.match .flag {
  width: 24px; height: 16px;
  background-size: cover; background-position: center;
  border-radius: 2px;
  background-color: #2a3557;
}
.match .name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.match .score {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-width: 1.5em;
  text-align: right;
}
.match .team.winner .score { color: var(--accent); }
.match.placeholder .team .name { color: var(--muted); font-style: italic; }

/* Center column */
.center {
  min-width: 220px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 0 8px;
}
.center-header {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}
.center-header .big {
  font-size: 56px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}
.center-header .stack {
  display: flex;
  flex-direction: column;
  font-size: 14px;
  letter-spacing: 0.1em;
}
.center-header .champ-label {
  color: var(--accent);
  font-weight: 700;
}
.champion {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 20px;
  border: 2px solid var(--accent);
  border-radius: 10px;
  min-width: 180px;
  background: rgba(255, 204, 51, 0.06);
}
.champion-flag {
  width: 64px; height: 40px;
  background-size: cover; background-position: center;
  border-radius: 3px;
  background-color: #2a3557;
}
.champion-name {
  font-weight: 700;
  letter-spacing: 0.08em;
  min-height: 1.2em;
}
.final-slot {
  width: 100%;
  max-width: 220px;
}

/* Footer */
#status {
  position: fixed;
  right: 12px; bottom: 12px;
  background: rgba(18, 26, 46, 0.9);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}
#status button {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
}
#status button:hover { background: var(--panel-alt); }

@media (max-width: 1100px) {
  main#app {
    grid-template-columns: 1fr;
  }
  .half { grid-template-columns: repeat(4, minmax(120px, 1fr)); overflow-x: auto; }
  .half-left { direction: ltr; }
}
