:root {
  --ink: #111827;
  --muted: #667085;
  --line: #d9dee8;
  --paper: #f6f8fb;
  --card: #ffffff;
  --red: #d52b3a;
  --green: #11845b;
  --blue: #1455d9;
  --gold: #c88a10;
  --shadow: 0 18px 50px rgba(16, 24, 40, .12);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

a { color: inherit; text-decoration: none; }

button, input { font: inherit; }

.hero {
  min-height: 92vh;
  color: #fff;
  background:
    linear-gradient(90deg, rgba(8, 14, 33, .92), rgba(12, 31, 54, .72) 46%, rgba(14, 21, 37, .45)),
    url("https://images.unsplash.com/photo-1522778119026-d647f0596c20?auto=format&fit=crop&w=1800&q=80") center/cover;
  display: flex;
  flex-direction: column;
}

.topbar {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand, .nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand { font-weight: 800; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #fff;
  color: var(--red);
  letter-spacing: 0;
}

.nav-actions a {
  padding: 10px 12px;
  color: rgba(255,255,255,.88);
  font-weight: 600;
}

.hero-grid {
  width: min(1180px, calc(100% - 32px));
  margin: auto auto 8vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 48px;
  align-items: end;
}

.hero-copy h1 {
  max-width: 820px;
  margin: 8px 0 20px;
  font-size: clamp(2.7rem, 6vw, 6.6rem);
  line-height: .96;
  letter-spacing: 0;
}

.lead {
  max-width: 670px;
  color: rgba(255,255,255,.88);
  font-size: 1.18rem;
  line-height: 1.65;
}

.eyebrow {
  margin: 0;
  color: var(--red);
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-size: .78rem;
}

.hero .eyebrow { color: #ffcc4d; }

.hero-actions {
  margin-top: 32px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.button {
  border: 0;
  border-radius: 8px;
  padding: 13px 18px;
  font-weight: 800;
  cursor: pointer;
}

.button.primary { background: #fff; color: var(--ink); }

.button.ghost {
  background: rgba(255,255,255,.13);
  color: #fff;
  border: 1px solid rgba(255,255,255,.35);
}

.status-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 8px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.22);
  backdrop-filter: blur(18px);
}

.metric { display: block; font-size: 2.2rem; font-weight: 800; }
.metric-label { color: rgba(255,255,255,.78); font-weight: 600; }
.tipper-field {
  display: grid;
  gap: 7px;
  color: rgba(255,255,255,.78);
  font-weight: 800;
}
.tipper-field input {
  width: 100%;
  height: 42px;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(255,255,255,.16);
  color: #fff;
  font-weight: 800;
}
.tipper-field input::placeholder { color: rgba(255,255,255,.62); }
.log-state { color: rgba(255,255,255,.74); font-size: .84rem; font-weight: 700; }

.section {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 58px 0;
}

.intro-band {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 24px;
  align-items: center;
}

.section-head { margin-bottom: 24px; }
.section-head h2 { margin: 8px 0 8px; font-size: clamp(1.9rem, 4vw, 3rem); letter-spacing: 0; }
.section-head p:not(.eyebrow) { color: var(--muted); line-height: 1.6; }
.section-head.compact { margin-bottom: 0; }
.title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.title-row h2 { margin-bottom: 0; }
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.info-help {
  position: relative;
  z-index: 3;
}
.info-help summary {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
  list-style: none;
}
.info-help summary::-webkit-details-marker { display: none; }
.info-help div {
  position: absolute;
  top: 40px;
  right: 0;
  width: min(330px, calc(100vw - 32px));
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #344054;
  box-shadow: var(--shadow);
  font-size: .9rem;
  line-height: 1.5;
  font-weight: 600;
}
.info-help:not(:hover):not([open]) div { display: none; }

.rules-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.rules-strip span, .pill {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 9px 11px;
  font-weight: 700;
  color: #344054;
}

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

.tab {
  min-width: 44px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 800;
  cursor: pointer;
}

.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.groups-root { display: grid; gap: 22px; }

.group-card, .table-shell, .third-note, .round-section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, .06);
}

.group-card { overflow: hidden; }

.group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.group-title { display: flex; align-items: center; gap: 10px; }
.group-title h3 { margin: 0; font-size: 1.3rem; }

.team-flags { display: flex; gap: 6px; align-items: center; }
.team-flags .flag-img { width: 28px; height: 20px; }

.group-content {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(420px, .85fr);
  gap: 0;
}

.matches {
  padding: 16px;
  display: grid;
  gap: 10px;
}

.match-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px 22px 58px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfe;
}

.team-name { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 700; }
.team-name.away { justify-content: flex-end; text-align: right; }
.flag-img {
  width: 32px;
  height: 24px;
  object-fit: cover;
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(17, 24, 39, .12);
  flex: 0 0 auto;
  background: #eef2f7;
}
.flag-img.fallback { display: inline-block; }
.name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-input {
  width: 58px;
  height: 42px;
  border: 1px solid #cbd3df;
  border-radius: 8px;
  text-align: center;
  font-weight: 800;
  background: #fff;
}
.dash { text-align: center; color: var(--muted); font-weight: 800; }

.standings { border-left: 1px solid var(--line); padding: 16px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; border-bottom: 1px solid #edf0f5; text-align: left; font-size: .9rem; }
th { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; }
tr.qualified td:first-child { border-left: 4px solid var(--green); }
tr.third td:first-child { border-left: 4px solid var(--gold); }
.team-cell { display: flex; gap: 8px; align-items: center; font-weight: 800; }

.third-band {
  width: 100%;
  padding-left: max(16px, calc((100% - 1180px) / 2));
  padding-right: max(16px, calc((100% - 1180px) / 2));
  background: #eaf1f8;
}

.third-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.table-shell, .third-note { overflow: hidden; }
.third-note { padding: 18px; }
.third-note h3 { margin: 0 0 8px; }
.third-note p { color: var(--muted); line-height: 1.55; }
.slot-list { display: grid; gap: 8px; margin-top: 16px; }
.slot-item { display: flex; justify-content: space-between; gap: 8px; padding: 10px; border-radius: 8px; background: #fff; border: 1px solid var(--line); font-weight: 700; }
.slot-item span:last-child { display: inline-flex; align-items: center; gap: 8px; }
.ok { color: var(--green); font-weight: 800; }
.wait { color: var(--muted); font-weight: 800; }

.bracket-root { display: grid; gap: 18px; }
.round-section { padding: 16px; }
.round-section h3 { margin: 0 0 14px; }
.bracket-scroll {
  overflow: auto;
  border: 1px solid #2d3746;
  border-radius: 8px;
  padding: 18px;
  background: #171a1f;
  box-shadow: 0 18px 42px rgba(16, 24, 40, .18);
}
.bracket-tree {
  --round-gap: 52px;
  --row-height: 76px;
  min-width: 1710px;
  display: grid;
  grid-template-columns: repeat(5, 300px);
  grid-template-rows: 32px repeat(32, var(--row-height));
  column-gap: var(--round-gap);
  position: relative;
}
.bracket-round-title {
  grid-row: 1;
  align-self: center;
  margin: 0;
  color: #fff;
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-align: center;
  text-transform: uppercase;
}
.bracket-slot {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}
.bracket-connector {
  position: absolute;
  left: calc(-1 * var(--round-gap));
  top: 0;
  bottom: 0;
  width: var(--round-gap);
  pointer-events: none;
}
.bracket-connector::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 25%;
  bottom: 25%;
  border-left: 2px solid #aeb8c6;
}
.bracket-connector::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 0;
  top: 50%;
  border-top: 2px solid #aeb8c6;
}
.bracket-connector i {
  position: absolute;
  left: 0;
  width: 14px;
  border-top: 2px solid #aeb8c6;
}
.bracket-connector i:first-child { top: 25%; }
.bracket-connector i:last-child { top: 75%; }
.ko-match {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
  box-shadow: 0 8px 22px rgba(16, 24, 40, .06);
}
.bracket-tree .ko-match {
  position: relative;
  z-index: 2;
  min-height: 96px;
  border-color: #66707d;
  background: #565d66;
  color: #fff;
  box-shadow: none;
}
.ko-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: .78rem; font-weight: 800; margin-bottom: 8px; gap: 8px; }
.bracket-tree .ko-meta { color: #d9e1ea; font-size: .68rem; }
.ko-meta > span:first-child {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.ko-versus {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}
.ko-side {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: .88rem;
  font-weight: 900;
}
.ko-side.away {
  justify-content: flex-end;
  text-align: right;
}
.ko-side.empty {
  justify-content: center;
  color: var(--muted);
}
.bracket-tree .ko-side.empty { color: #d1d7df; }
.ko-side.winner .name-text { color: var(--green); }
.bracket-tree .ko-side.winner .name-text { color: #d1fae5; }
.ko-side .flag-img {
  width: 24px;
  height: 17px;
  border-radius: 3px;
}
.bracket-tree .ko-side .flag-img {
  width: 20px;
  height: 14px;
  border-radius: 2px;
}
.ko-center-score {
  display: grid;
  grid-template-columns: 1fr 10px 1fr;
  align-items: center;
  gap: 2px;
}
.ko-center-score span {
  color: var(--muted);
  text-align: center;
  font-weight: 900;
}
.bracket-tree .ko-center-score span { color: #fff; }
.ko-score {
  width: 100%;
  height: 32px;
  border: 1px solid #cbd3df;
  border-radius: 5px;
  text-align: center;
  font-weight: 800;
  background: #fff;
}
.bracket-tree .ko-score {
  border-color: #d6dde8;
  background: #edf3fb;
  color: #122033;
}
.winner-choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}
.bracket-tree .winner-choice {
  gap: 6px;
  margin-top: 8px;
}
.ko-winner-choice {
  min-height: 36px;
  border: 1px solid #cbd3df;
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}
.bracket-tree .ko-winner-choice {
  min-height: 30px;
  border-color: #778293;
  background: #47515f;
  color: #fff;
  font-size: .74rem;
}
.ko-winner-choice.selected {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.placement-section {
  display: grid;
  grid-template-columns: minmax(0, .7fr) minmax(300px, 1fr);
  gap: 18px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  box-shadow: 0 8px 24px rgba(16, 24, 40, .06);
}
.placement-section h3 { margin: 6px 0 0; font-size: 1.4rem; }
.placement-card {
  max-width: 520px;
  width: 100%;
}

.footer {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 46px;
  color: var(--muted);
  font-size: .92rem;
}

@media (max-width: 980px) {
  .hero-grid, .intro-band, .group-content, .third-layout, .placement-section { grid-template-columns: 1fr; }
  .status-panel { max-width: 420px; }
  .standings { border-left: 0; border-top: 1px solid var(--line); }
  .rules-strip { justify-content: flex-start; }
}

@media (max-width: 680px) {
  .nav-actions { display: none; }
  .hero { min-height: 88vh; }
  .hero-grid { gap: 24px; }
  .match-row {
    grid-template-columns: minmax(0, 1fr) 48px 18px 48px minmax(0, 1fr);
  }
  .score-input { width: 48px; }
  .name-text { max-width: 100%; }
  .bracket-scroll {
    margin-inline: -16px;
    border-radius: 0;
    padding: 12px;
  }
}
