:root {
  --bg: #0b1118;
  --card-bg: #151d28;
  --border: #243040;
  --text: #e7edf3;
  --muted: #7a8fa3;
  --accent: #34d399;
  --accent-dark: #059669;
  --warn: #f87171;
  --gold: #fbbf24;
  --gold-dim: rgba(251, 191, 36, 0.12);
  --pitch: #1f6f43;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* ---- Header ---- */

.page-header {
  text-align: center;
  padding: 3rem 1rem 2rem;
  background: linear-gradient(180deg, #0d2137 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.header-trophy {
  font-size: 2.8rem;
  line-height: 1;
  margin-bottom: 0.4rem;
}

.page-header h1 {
  margin: 0 0 0.3rem;
  font-size: 2rem;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--muted);
  margin: 0;
  font-size: 0.95rem;
}

/* ---- Layout ---- */

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
}

.card h2 {
  margin-top: 0;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 700;
}

.hint {
  color: var(--muted);
  font-size: 0.92rem;
}

/* ---- Countdown ---- */

.countdown-card {
  text-align: center;
  padding: 2rem 1.5rem;
  background: linear-gradient(135deg, #0d2137 0%, var(--card-bg) 100%);
}

.countdown-label {
  margin: 0 0 1.25rem;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.countdown-blocks {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
}

.countdown-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  min-width: 4rem;
}

.countdown-block span:first-child {
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.cd-unit {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.countdown-sep {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--border);
  line-height: 1;
  margin-bottom: 1.2rem;
}

.countdown-when {
  margin: 1.25rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ---- Info card ---- */

.info-card {
  line-height: 1.7;
  font-size: 0.95rem;
}

.info-card p { margin: 0 0 1rem; }
.info-card p:last-child { margin-bottom: 0; }

.info-subheading {
  font-weight: 600;
  color: var(--text);
}

.info-list {
  margin: 0.25rem 0 1rem 0;
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.info-list li { list-style: none; padding-left: 0; margin-left: -1.25rem; }

.pay-btn {
  display: inline-block;
  margin: 0.25rem 0 1.25rem;
  padding: 0.75rem 1.75rem;
  border-radius: 10px;
  background: var(--accent);
  color: #06281d;
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.pay-btn:hover { opacity: 0.85; }

.info-footer {
  color: var(--muted);
  font-size: 0.88rem;
}

/* ---- Fixtures ---- */

.fixtures-card { padding-bottom: 0.5rem; }

.fixtures-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}

.fixtures-timezone {
  font-size: 0.78rem;
  color: var(--muted);
}

.fixtures-list {
  max-height: 440px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.fixture-day {
  border-top: 1px solid var(--border);
  padding: 0.4rem 0 0.6rem;
}

.fixture-day:first-child { border-top: none; }

.fixture-day.past { opacity: 0.45; }

.fixture-day.today .fixture-day-header { color: var(--accent); }

.fixture-day-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.2rem 0 0.35rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.today-pill {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 20px;
  background: var(--accent);
  color: #06281d;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.fixture-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 0.1rem;
  border-radius: 6px;
  transition: background 0.1s;
}

.fixture-row:hover { background: rgba(255,255,255,0.03); }

.fixture-time {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  min-width: 3.2rem;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.fixture-teams {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  font-size: 0.9rem;
  min-width: 0;
}

.fixture-team {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.fixture-vs {
  color: var(--muted);
  font-size: 0.75rem;
  flex-shrink: 0;
}

.fixture-tbd {
  color: var(--muted);
  font-size: 0.88rem;
  font-style: italic;
}

.owner-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: rgba(52, 211, 153, 0.15);
  color: var(--accent);
  margin-left: 0.2rem;
  white-space: nowrap;
}

.fixture-stage {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stage-gs   { background: rgba(59,130,246,0.15); color: #60a5fa; }
.stage-r32  { background: rgba(20,184,166,0.15); color: #2dd4bf; }
.stage-r16  { background: rgba(52,211,153,0.15); color: var(--accent); }
.stage-qf   { background: rgba(251,146,60,0.15); color: #fb923c; }
.stage-sf   { background: rgba(248,113,113,0.15); color: #f87171; }
.stage-final{ background: rgba(251,191,36,0.2);  color: var(--gold); }

/* ---- Entrant cards ---- */

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.entrant-card {
  background: #0f1b26;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  transition: border-color 0.2s ease;
}

.entrant-card:hover {
  border-color: #354d66;
}

.entrant-card h3 {
  margin: 0 0 0.7rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
}

.entrant-card .remaining {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.entrant-card .remaining.alive { color: var(--accent); }

/* ---- Team rows ---- */

.team-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.38rem 0;
  border-bottom: 1px dashed var(--border);
}

.team-row:last-child { border-bottom: none; }

.team-name {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.team-flag {
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
}

.team-row.eliminated .team-name {
  color: var(--muted);
  text-decoration: line-through;
}

/* Legacy dot (tracker only — coloured by confederation) */
.flag-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pitch);
  flex-shrink: 0;
}

.dot-concacaf { background: #3b82f6; }
.dot-conmebol { background: #10b981; }
.dot-uefa     { background: #eab308; }
.dot-caf      { background: #ef4444; }
.dot-afc      { background: #a855f7; }
.dot-ofc      { background: #f97316; }

.team-row.eliminated .flag-dot { background: var(--warn); }

/* ---- Elimination controls ---- */

.elim-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.elim-controls select {
  padding: 0.25rem 0.4rem;
  font-size: 0.82rem;
}

/* ---- Forms & inputs ---- */

.inline-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 1rem 0;
}

.inline-form input[type="text"] { flex: 2; min-width: 160px; }
.inline-form input[type="number"] { flex: 1; min-width: 100px; }

input, select, button {
  font-size: 1rem;
  font-family: inherit;
}

input[type="text"], input[type="number"], select {
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0b1520;
  color: var(--text);
}

input:focus, select:focus, button:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button {
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #06281d;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

button:hover:not(:disabled) { opacity: 0.85; }

button:disabled {
  background: #243040;
  color: var(--muted);
  cursor: not-allowed;
}

button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

button.danger {
  background: transparent;
  color: var(--warn);
  border: 1px solid var(--warn);
}

button.small {
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
  border-radius: 6px;
}

/* ---- Table ---- */

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
}

th, td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody tr:hover { background: rgba(255, 255, 255, 0.025); }

/* ---- Progress bar ---- */

.totals-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0;
  font-size: 0.95rem;
}

#totals-text {
  white-space: nowrap;
  min-width: 200px;
}

.progress-track {
  flex: 1;
  height: 10px;
  border-radius: 6px;
  background: #0b1520;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-dark), var(--accent));
  transition: width 0.25s ease, background 0.25s ease;
}

.progress-fill.complete { background: var(--accent); }
.progress-fill.over { background: var(--warn); }

/* ---- Misc ---- */

.actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.error {
  color: var(--warn);
  font-size: 0.9rem;
  margin: 0.5rem 0 0;
}

/* ---- Footer ---- */

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  padding: 1.5rem;
}

.footer-link {
  color: var(--muted);
  text-decoration: none;
}

.footer-link:hover { color: var(--text); }

/* ---- Responsive ---- */

@media (max-width: 540px) {
  .totals-row { flex-direction: column; align-items: stretch; }
  #totals-text { min-width: 0; }
  .standings-bar-track { width: 60px; }
  .page-header h1 { font-size: 1.5rem; }
}
