/* ═══════════════════════════════════════════════════════════════════════
   WORLD CUP 2026 PREDICTOR — "Night match under floodlights"
   Deep pitch green · chalk lines · scoreboard digits · gold for the real
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  --pitch-deep: #07130b;
  --pitch: #0c2113;
  --panel: #090e0a;
  --panel2: #0d1510;
  --chalk: rgba(238, 248, 238, 0.92);
  --line: rgba(220, 240, 225, 0.22);
  --line-strong: rgba(220, 240, 225, 0.38);
  --text: #eef5ee;
  --muted: #8fa996;
  --green: #46d97c;
  --green-soft: rgba(70, 217, 124, 0.18);
  --amber: #f0b43c;
  --amber-soft: rgba(240, 180, 60, 0.16);
  --gold: #ffd24a;
  --red: #ff6b5e;

  --font-display: "Anton", "Arial Narrow", sans-serif;
  --font-body: "Barlow Semi Condensed", "Helvetica Neue", sans-serif;
  --font-mono: "Chivo Mono", "Courier New", monospace;
}

* { box-sizing: border-box; }

html { overflow-x: clip; }

::selection { background: var(--green); color: var(--pitch-deep); }

body {
  margin: 0;
  color: var(--text);
  font: 500 15px/1.45 var(--font-body);
  background-color: var(--pitch-deep);
  /* floodlight glows over mowed-grass stripes */
  background-image:
    radial-gradient(900px 480px at 12% -6%, rgba(208, 255, 222, 0.10), transparent 60%),
    radial-gradient(900px 480px at 88% -6%, rgba(208, 255, 222, 0.08), transparent 60%),
    repeating-linear-gradient(90deg,
      rgba(255, 255, 255, 0.018) 0 90px,
      transparent 90px 180px),
    linear-gradient(180deg, var(--pitch) 0%, var(--pitch-deep) 70%);
  background-attachment: fixed;
}

/* chalk centre circle + halfway line, faint behind everything */
body::before {
  content: "";
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(72vw, 760px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(238, 248, 238, 0.045);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}
body::after {
  content: "";
  position: fixed;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(238, 248, 238, 0.035);
  pointer-events: none;
  z-index: 0;
}

header, main, footer { position: relative; z-index: 1; }

/* ────────────────────────────────────────────── header: scoreboard bar */

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(7, 19, 11, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--line-strong);
  padding: 14px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 22px;
}

header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 24px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: flex;
  align-items: baseline;
  gap: 10px;
  white-space: nowrap;
}
header h1 .ball {
  font-size: 20px;
  align-self: center;
  filter: drop-shadow(0 0 8px rgba(70, 217, 124, 0.5));
  animation: ball-spin 9s linear infinite;
}
@keyframes ball-spin {
  to { transform: rotate(360deg); }
}
header h1 .year {
  color: var(--green);
  text-shadow: 0 0 14px rgba(70, 217, 124, 0.55);
}
header h1 .word-predictor {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.34em;
  color: var(--pitch-deep);
  background: var(--chalk);
  padding: 3px 9px 3px 11px;
  border-radius: 3px;
  align-self: center;
}

.controls { display: flex; gap: 10px; align-items: center; }

button {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 8px 16px;
  cursor: pointer;
  background: transparent;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
button:hover:not(:disabled) { border-color: var(--chalk); background: rgba(238, 248, 238, 0.06); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: default; }
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

#refresh-btn {
  background: var(--green);
  border-color: var(--green);
  color: var(--pitch-deep);
  box-shadow: 0 0 18px rgba(70, 217, 124, 0.25);
}
#refresh-btn:hover:not(:disabled) {
  background: #5ce890;
  border-color: #5ce890;
  box-shadow: 0 0 24px rgba(70, 217, 124, 0.4);
}

#status { color: var(--muted); font-size: 13px; flex: 1 1 240px; }
#status.error { color: var(--red); }

/* ─────────────────────────────────────────────────────────────── layout */

main { padding: 26px 24px 60px; max-width: 1700px; margin: 0 auto; }

/* section headings as stadium signage with a chalk rule running off */
h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 21px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 44px 0 18px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 14px;
}
h2::before {
  content: "";
  width: 11px;
  height: 14px;
  background: var(--green);
  clip-path: polygon(0 0, 100% 0, 0 100%); /* corner-flag pennant */
  filter: drop-shadow(0 0 6px rgba(70, 217, 124, 0.5));
}
h2::after {
  content: "";
  flex: 1 1 60px;
  height: 1px;
  background: linear-gradient(90deg, var(--line-strong), transparent);
  min-width: 40px;
}
h2 .hint {
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--muted);
}

/* ─────────────────────────────────────────────────────────────── groups */

#groups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(390px, 1fr));
  gap: 18px;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

.group-card {
  background: linear-gradient(180deg, var(--panel2) 0%, var(--panel) 22%);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  transition: border-color 0.2s;
  animation: rise 0.45s ease backwards;
}
.group-card:hover { border-color: var(--line-strong); }
.group-card:nth-child(2)  { animation-delay: 0.04s; }
.group-card:nth-child(3)  { animation-delay: 0.08s; }
.group-card:nth-child(4)  { animation-delay: 0.12s; }
.group-card:nth-child(5)  { animation-delay: 0.16s; }
.group-card:nth-child(6)  { animation-delay: 0.20s; }
.group-card:nth-child(7)  { animation-delay: 0.24s; }
.group-card:nth-child(8)  { animation-delay: 0.28s; }
.group-card:nth-child(9)  { animation-delay: 0.32s; }
.group-card:nth-child(10) { animation-delay: 0.36s; }
.group-card:nth-child(11) { animation-delay: 0.40s; }
.group-card:nth-child(12) { animation-delay: 0.44s; }

.group-card h3 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 16px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--green);
  display: flex;
  align-items: center;
  gap: 10px;
}
.group-card h3::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(70, 217, 124, 0.35), transparent);
}

/* ─────────────────────────────────────────────────────────────── tables */

table { border-collapse: collapse; width: 100%; }
th, td { padding: 3px 6px; text-align: center; }
th {
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
td {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
td.team-cell {
  text-align: left;
  white-space: nowrap;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
}

.standings tbody tr.adv { background: var(--green-soft); }
.standings tbody tr.adv td:first-child { box-shadow: inset 3px 0 0 var(--green); }
.standings tbody tr.third { background: var(--amber-soft); }
.standings tbody tr.third td:first-child { box-shadow: inset 3px 0 0 var(--amber); }

tr.tentative td { opacity: 0.8; }

/* ───────────────────────────────────────────────────────────── fixtures */

.fixtures { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 9px; }

.fixture {
  display: grid;
  grid-template-columns: 90px 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  border-radius: 4px;
}
.fx-date {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
}
.fx-team {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}
.fx-team.home { text-align: right; }
.fx-score { display: flex; align-items: center; gap: 4px; }
.dash { color: var(--muted); }

/* scoreboard cells */
input.score {
  width: 42px;
  padding: 4px 2px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 5px;
  appearance: textfield;
  -moz-appearance: textfield;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input.score::-webkit-outer-spin-button,
input.score::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input.score:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 1px var(--green), 0 0 12px rgba(70, 217, 124, 0.3);
}
input.score:disabled { color: var(--muted); background: transparent; }

/* real results lock in gold — the official record */
.fixture.locked input.score,
.ko-row.locked input.score {
  background: var(--amber-soft);
  border-color: rgba(240, 180, 60, 0.6);
  color: var(--gold);
}
.fixture.locked .fx-date::before { content: "🔒 "; font-size: 9px; }

/* ─────────────────────────────────────────────────────────────── thirds */

#thirds-wrap {
  background: linear-gradient(180deg, var(--panel2) 0%, var(--panel) 22%);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  max-width: 720px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}
#thirds tbody tr.adv { background: var(--green-soft); }
#thirds tbody tr.adv td:first-child { box-shadow: inset 3px 0 0 var(--green); }
#thirds-note { color: var(--muted); font-size: 12.5px; margin: 10px 0 0; }

/* ────────────────────────────────────────────────────────────── bracket */

#bracket {
  display: flex;
  gap: 18px;
  overflow-x: auto;
  padding-bottom: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
#bracket::-webkit-scrollbar { height: 8px; }
#bracket::-webkit-scrollbar-track { background: transparent; }
#bracket::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }

.bk-col { flex: 0 0 215px; display: flex; flex-direction: column; }
.bk-col h4 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--chalk);
  text-align: center;
  display: flex;
  align-items: center;
  gap: 8px;
}
.bk-col h4::before,
.bk-col h4::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.bk-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  gap: 10px;
}
/* Split Final column into two equal halves so both matches meet at midpoint */
.bk-final-half {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.bk-final-half--top { justify-content: flex-end; padding-bottom: 5px; }
.bk-final-half--bot { justify-content: flex-start; padding-top: 5px; }

.ko-match {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ko-match:hover {
  border-color: var(--line-strong);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.55);
}
.ko-head {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.ko-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 2px 0;
}
.ko-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
  font-weight: 500;
}
.ko-name.tbd { color: var(--muted); font-style: italic; font-size: 12.5px; }
.ko-row.win .ko-name {
  color: var(--green);
  font-weight: 700;
  text-shadow: 0 0 10px rgba(70, 217, 124, 0.35);
}

.ko-pens {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px dashed var(--line);
}
.ko-pens.hidden { display: none; }
.pens-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.pen-btn { font-size: 11px; padding: 2px 9px; border-radius: 999px; letter-spacing: 0.04em; }
.pen-btn.sel {
  background: var(--green);
  border-color: var(--green);
  color: var(--pitch-deep);
  font-weight: 700;
}

/* ───────────────────────────────────────────────────────────── champion */

#champion {
  margin: 10px 0 20px;
  background: linear-gradient(180deg, var(--panel2) 0%, var(--panel) 30%);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 16px;
  transition: border-color 0.3s, box-shadow 0.3s;
}
#champion .trophy { font-size: 28px; filter: grayscale(1) opacity(0.4); transition: filter 0.3s; }
#champion-name { color: var(--muted); font-style: italic; }

#champion.crowned {
  border-color: rgba(255, 210, 74, 0.55);
  box-shadow: 0 0 0 1px rgba(255, 210, 74, 0.25), 0 0 32px rgba(255, 210, 74, 0.14);
}
#champion.crowned .trophy {
  filter: drop-shadow(0 0 12px rgba(255, 210, 74, 0.65));
  animation: trophy-lift 2.4s ease-in-out infinite;
}
@keyframes trophy-lift {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%      { transform: translateY(-3px) rotate(3deg); }
}
#champion.crowned #champion-name {
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 400;
  font-size: 26px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(255, 210, 74, 0.45);
}

/* ─────────────────────────────────────────────────────────────── footer */

footer {
  color: var(--muted);
  font-size: 12.5px;
  padding: 18px 24px 34px;
  max-width: 1700px;
  margin: 0 auto;
  border-top: 1px dashed var(--line);
}

/* ─────────────────────────────────────────────────────────── responsive */

@media (max-width: 480px) {
  html { overflow-x: clip; }
  header { padding: 10px 14px; }
  header h1 { font-size: 18px; white-space: normal; }
  header h1 .word-predictor { font-size: 10px; letter-spacing: 0.2em; }
  .controls { flex-wrap: wrap; }
  .controls button { flex: 1 1 auto; padding: 7px 10px; font-size: 12px; }
  main { padding: 20px 14px 60px; }
  #groups { grid-template-columns: 1fr; }
  .fixture { grid-template-columns: 82px 1fr auto 1fr; }
}

/* prevent iOS auto-zoom on input focus (triggered when font-size < 16px) */
@media (hover: none) and (pointer: coarse) {
  input.score { font-size: 16px; }
}

/* ─────────────────────────────────────────── mobile score navigation bar */

.score-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(7, 19, 11, 0.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line-strong);
  justify-content: flex-end;
}
.score-nav--hidden { display: none; }
.nav-btn { font-size: 13px; padding: 6px 14px; min-width: 72px; display: flex; align-items: center; gap: 7px; }
.nav-btn--done { color: var(--green); border-color: var(--green); }

.nav-btn--prev::before,
.nav-btn--next::after {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  flex-shrink: 0;
}
.nav-btn--prev::before {
  border-right: 6px solid currentColor;
}
.nav-btn--next::after {
  border-left: 6px solid currentColor;
}
.nav-btn--prev:disabled::before { border-right-color: currentColor; }
.nav-btn--next:disabled::after  { border-left-color: currentColor; }

/* ─────────────────────────────────────────── sim button + probability bars */

#sim-btn {
  border-color: rgba(150, 110, 255, 0.45);
  color: rgba(185, 155, 255, 0.92);
}
#sim-btn:hover:not(:disabled) {
  border-color: rgba(150, 110, 255, 0.8);
  background: rgba(150, 110, 255, 0.07);
}

/* fixture rows use a 4-col grid; the sim-bar is the 5th child and spans all */
.fixture {
  grid-template-rows: auto auto;
}
.fixture .sim-bar {
  grid-column: 1 / -1;
  margin-top: 1px;
  margin-bottom: 2px;
}

.sim-bar {
  display: none;
  height: 15px;
  border-radius: 2px;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.sim-bar:not(.hidden) { display: flex; }

.sim-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  white-space: nowrap;
  transition: width 0.35s ease;
}
.sim-seg.home { background: rgba(0, 229, 255, 0.20); color: #00e5ff; }
.sim-seg.draw { background: rgba(255, 229, 80, 0.16); color: #ffe550; }
.sim-seg.away { background: rgba(0, 168, 210, 0.22); color: #00a8d2; }

/* tighter variant inside knockout cells */
.ko-match .sim-bar {
  margin-top: 7px;
  border-top: 1px dashed var(--line);
  height: 14px;
  font-size: 9px;
}

@media (prefers-reduced-motion: reduce) {
  .group-card { animation: none; }
  header h1 .ball,
  #champion.crowned .trophy { animation: none; }
}
