/* ===========================
   CUSTOM PROPERTIES
   =========================== */
:root {
  --bg:          #0a0e1a;
  --bg-card:     #111827;
  --bg-hover:    #1a2235;
  --border:      #1e2d47;
  --border-hi:   #2d4060;
  --gold:        #f5c518;
  --green:       #00c853;
  --green-tint:  rgba(0, 200, 83, 0.10);
  --red:         #ff5252;
  --text:        #e8edf5;
  --muted:       #6b7fa3;
  --dim:         #3d5175;
  --radius:      10px;
}

/* ===========================
   RESET & BASE
   =========================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

/* Hide tab radio inputs — they stay in DOM for :checked selectors */
input[name="tabs"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* ===========================
   HEADER
   =========================== */
header {
  background: linear-gradient(160deg, #0d1527 0%, #0f1e38 50%, #0a0e1a 100%);
  border-bottom: 1px solid var(--border-hi);
  padding: 52px 24px 44px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

header::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 25% 60%, rgba(245,197,24,.07) 0%, transparent 55%),
    radial-gradient(ellipse at 75% 40%, rgba(26,86,219,.09) 0%, transparent 55%);
  pointer-events: none;
}

.header-inner {
  position: relative;
  z-index: 1;
  animation: fadeDown .6s ease both;
}

.host-line {
  font-size: .72rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
}

header h1 {
  font-size: clamp(2rem, 6vw, 3.6rem);
  font-weight: 800;
  letter-spacing: -.025em;
  line-height: 1.1;
  margin-bottom: 10px;
}

header h1 em {
  font-style: normal;
  color: var(--gold);
  animation: glow 3s ease-in-out infinite;
}

@keyframes glow {
  0%, 100% { text-shadow: 0 0 18px rgba(245,197,24,.3); }
  50%       { text-shadow: 0 0 40px rgba(245,197,24,.7), 0 0 70px rgba(245,197,24,.2); }
}

.sub {
  font-size: .9rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}

@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===========================
   GROUP NAV
   =========================== */
.group-nav {
  display: flex;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  overflow-x: auto;
  scrollbar-width: none;
}
.group-nav::-webkit-scrollbar { display: none; }

.group-nav label {
  flex: 0 0 auto;
  padding: 14px 20px;
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: color .15s, border-color .15s, background .15s;
  user-select: none;
  white-space: nowrap;
}
.group-nav label:hover {
  color: var(--text);
  background: var(--bg-hover);
}

/* Active tab */
#tab-a:checked ~ .group-nav label[for="tab-a"],
#tab-b:checked ~ .group-nav label[for="tab-b"],
#tab-c:checked ~ .group-nav label[for="tab-c"],
#tab-d:checked ~ .group-nav label[for="tab-d"],
#tab-e:checked ~ .group-nav label[for="tab-e"],
#tab-f:checked ~ .group-nav label[for="tab-f"],
#tab-g:checked ~ .group-nav label[for="tab-g"],
#tab-h:checked ~ .group-nav label[for="tab-h"],
#tab-i:checked ~ .group-nav label[for="tab-i"],
#tab-j:checked ~ .group-nav label[for="tab-j"],
#tab-k:checked ~ .group-nav label[for="tab-k"],
#tab-l:checked ~ .group-nav label[for="tab-l"] {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

/* ===========================
   MAIN
   =========================== */
main {
  max-width: 740px;
  margin: 0 auto;
  padding: 36px 16px 72px;
}

/* ===========================
   GROUP PANELS
   =========================== */
.group-panel { display: none; animation: fadeUp .22s ease both; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

#tab-a:checked ~ main #panel-a { display: block; }
#tab-b:checked ~ main #panel-b { display: block; }
#tab-c:checked ~ main #panel-c { display: block; }
#tab-d:checked ~ main #panel-d { display: block; }
#tab-e:checked ~ main #panel-e { display: block; }
#tab-f:checked ~ main #panel-f { display: block; }
#tab-g:checked ~ main #panel-g { display: block; }
#tab-h:checked ~ main #panel-h { display: block; }
#tab-i:checked ~ main #panel-i { display: block; }
#tab-j:checked ~ main #panel-j { display: block; }
#tab-k:checked ~ main #panel-k { display: block; }
#tab-l:checked ~ main #panel-l { display: block; }

/* ===========================
   PANEL HEADER
   =========================== */
.panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.panel-header h2 {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -.02em;
}

/* ===========================
   STANDINGS TABLE
   =========================== */
.standings {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Round corner cells (no overflow:hidden, so tooltips can escape) */
.standings thead th:first-child { border-top-left-radius: var(--radius); }
.standings thead th:last-child  { border-top-right-radius: var(--radius); }
.standings tbody tr:last-child td:first-child { border-bottom-left-radius: var(--radius); }
.standings tbody tr:last-child td:last-child  { border-bottom-right-radius: var(--radius); }

.standings thead tr { background: var(--bg-hover); }

.standings th {
  padding: 10px 12px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  position: relative;
  cursor: help;
}
.standings th.tcol { text-align: left; cursor: default; }

/* ---- Header tooltips (pure CSS, by column position) ---- */
.standings thead th::after {
  content: "";
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: #060912;
  color: var(--text);
  border: 1px solid var(--border-hi);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: none;
  text-align: left;
  white-space: pre;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s, transform .15s;
  z-index: 500;
  box-shadow: 0 6px 20px rgba(0,0,0,.5);
}
.standings thead th:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Tooltip text per column */
.standings thead th:nth-child(1)::after { content: "League position"; }
.standings thead th:nth-child(3)::after { content: "Played — matches played"; }
.standings thead th:nth-child(4)::after { content: "Won"; }
.standings thead th:nth-child(5)::after { content: "Drawn"; }
.standings thead th:nth-child(6)::after { content: "Lost"; }
.standings thead th:nth-child(7)::after { content: "Goal difference"; }
.standings thead th:nth-child(8)::after { content: "Points\00000AWin = 3\00000ADraw = 1\00000ALoss = 0"; }

/* Team column has no tooltip */
.standings thead th.tcol::after { content: none; }

/* Pts (last column): anchor tooltip to the right so it stays on-screen.
   Now that the table no longer clips, it floats cleanly on top. */
.standings thead th:nth-child(8)::after {
  left: auto;
  right: 0;
  transform: translateY(4px);
}
.standings thead th:nth-child(8):hover::after {
  transform: translateY(0);
}

.standings tbody tr { transition: background .12s; }
.standings tbody td { border-top: 1px solid var(--border); }
.standings tbody tr:hover { background: var(--bg-hover); }

.standings td {
  padding: 13px 12px;
  text-align: center;
  font-size: .9rem;
}
.standings td.tcol { text-align: left; }

.tname {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 150px;
  white-space: nowrap;
}
.tname span { font-size: 1.25rem; line-height: 1; }

.pts { font-weight: 700; font-size: 1rem; color: var(--gold); }

.gdpos { color: var(--green); font-weight: 600; }
.gdneg { color: var(--red);   font-weight: 600; }

/* Top-2 qualifying rows */
.adv { background: var(--green-tint) !important; }
.adv td:first-child { border-left: 3px solid var(--green); }

/* Separator below the qualification line (after 2nd place) */
.adv + tr:not(.adv) td { border-top: 2px solid var(--border-hi); }

/* ===========================
   FIXTURES (prediction inputs)
   =========================== */
.fixtures { margin-top: 22px; }

.fixtures-title {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}
.fixtures-title .hint {
  font-weight: 500;
  letter-spacing: .02em;
  text-transform: none;
  color: var(--dim);
}

.fixture {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 7px;
  font-size: .85rem;
}
.fixture.fx-set { border-color: var(--border-hi); }
.fixture.fx-played { background: var(--bg-card); opacity: .82; }
.fixture.fx-played .fx-goal {
  background: var(--bg-alt, var(--bg));
  border-color: var(--border);
  color: var(--dim);
  cursor: not-allowed;
  pointer-events: none;
}
.fixture.fx-played .fx-md::after {
  content: ' ✓';
  color: var(--green);
  display: inline-block; /* keeps underline from extending over the checkmark */
}

.fx-md {
  flex: 0 0 auto;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--dim);
  width: 48px;
  white-space: nowrap;
}
a.fx-date-link {
  text-decoration: none;
  border-radius: 4px;
  padding: 2px 3px;
  margin: -2px -3px;
  transition: color .15s, background .15s;
}
a.fx-date-link:hover {
  color: var(--gold);
  background: var(--bg-hover);
  text-decoration: underline;
}

.fx-team {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  overflow: hidden;
}
.fx-home { justify-content: flex-end; text-align: right; }
.fx-away { justify-content: flex-start; }

.fx-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.flag-img { display: inline-block; vertical-align: middle; border-radius: 1px; }

.fx-score {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
}
.fx-colon { color: var(--muted); }

.fx-goal {
  width: 38px;
  padding: 6px 4px;
  text-align: center;
  font-size: .9rem;
  font-weight: 700;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-hi);
  border-radius: 6px;
  -moz-appearance: textfield;
}
.fx-goal::-webkit-outer-spin-button,
.fx-goal::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.fx-goal:focus { outline: none; border-color: var(--gold); }

.fx-clear {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--dim);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: color .15s, background .15s;
}
.fx-clear:hover { color: var(--red); background: var(--bg-hover); }

/* ===========================
   KNOCKOUT BRACKET
   =========================== */
#bracket {
  max-width: 1240px;
  margin: 0 auto;
  padding: 8px 16px 64px;
}

.bracket-head { margin-bottom: 26px; }
.bracket-head h2 {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -.02em;
  margin-bottom: 8px;
}
.bracket-note {
  font-size: .85rem;
  color: var(--muted);
  max-width: 640px;
  margin-bottom: 16px;
}
#reset-btn {
  padding: 9px 16px;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border-hi);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
#reset-btn:hover { border-color: var(--gold); background: var(--bg-hover); }

/* ---- Champion + third-place summary ---- */
#bracket-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 32px;
  margin-bottom: 30px;
}
.champion {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(245,197,24,.06), transparent);
}
.champion.has-champ {
  border-color: var(--gold);
  box-shadow: 0 0 24px rgba(245,197,24,.18);
}
.champion-label {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--gold);
}
.champion-team { font-size: 1.25rem; font-weight: 800; }
.champion-team .flag-img { width: 28px; height: 21px; }

.thirdplace { display: flex; align-items: center; gap: 12px; }
.tp-label {
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.thirdplace .bkt-match { width: 200px; }

/* ---- Flowchart ---- */
.bracket-flow {
  --bkt-gap: 38px;
  display: flex;
  align-items: stretch;
  gap: var(--bkt-gap);
  overflow-x: auto;
  padding-bottom: 12px;
  scrollbar-width: thin;
}

.bkt-round {
  flex: 0 0 auto;
  min-width: 184px;
  display: flex;
  flex-direction: column;
}
.bkt-round-label {
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  padding-bottom: 10px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.bkt-col {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.bkt-match {
  position: relative;
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  min-height: 78px;
  padding: 6px 0;
}

/* Connector: horizontal line from each card to the next column */
.bkt-round:not([data-round="F"]) .bkt-match::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 100%;
  width: var(--bkt-gap);
  height: 2px;
  background: var(--border-hi);
}
/* Connector: vertical line joining each pair, at the next-column boundary */
.bkt-round:not([data-round="F"]) .bkt-match:nth-child(odd)::before {
  content: '';
  position: absolute;
  top: 50%;
  left: calc(100% + var(--bkt-gap) - 2px);
  width: 2px;
  height: 100%;
  background: var(--border-hi);
}

.bkt-slot {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .12s, border-color .12s, color .12s;
}
.bkt-slot:first-child { border-radius: 8px 8px 0 0; }
.bkt-slot:last-child  { border-radius: 0 0 8px 8px; border-top: none; }
.bkt-slot .flag-img { margin-right: 3px; }

.bkt-slot:not(.is-empty):hover { background: var(--bg-hover); border-color: var(--border-hi); }
.bkt-slot.is-winner {
  background: var(--green-tint);
  border-color: var(--green);
  color: #fff;
}
.bkt-slot.is-winner::after {
  content: '✓';
  float: right;
  color: var(--green);
  font-weight: 800;
}
.bkt-slot.is-loser { color: var(--dim); }
.bkt-slot.is-empty { cursor: default; }
.bkt-slot .muted { color: var(--dim); font-weight: 500; }

/* ===========================
   FOOTER
   =========================== */
footer {
  text-align: center;
  padding: 24px;
  font-size: .75rem;
  color: var(--dim);
  border-top: 1px solid var(--border);
  letter-spacing: .05em;
}
footer .credit {
  margin-top: 8px;
  color: var(--muted);
}
footer .credit a {
  color: var(--gold);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color .15s;
}
footer .credit a:hover { border-bottom-color: var(--gold); }

/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 480px) {
  header { padding: 36px 16px 30px; }

  .group-nav label { padding: 12px 15px; font-size: .8rem; }

  .tname { min-width: 90px; white-space: normal; }

  .standings td,
  .standings th { padding: 10px 8px; font-size: .82rem; }

  .fixture { gap: 6px; padding: 8px; font-size: .78rem; }
  .fx-md { width: 42px; font-size: .58rem; }
  .fx-goal { width: 32px; }

  #bracket { padding: 8px 12px 56px; }
  .bracket-flow { --bkt-gap: 26px; }
  .bkt-round { min-width: 158px; }
  .champion-team { font-size: 1.05rem; }
}
