:root {
  --bg: #0a0f1e;
  --panel: #131c33;        /* card base */
  --panel-hi: #1a2542;     /* card top (for subtle vertical gradient) */
  --line: #2a3960;
  --line-hi: #3a517f;      /* hover/focus border */
  --text: #e7ecf6;
  --muted: #93a3c6;
  --accent: #34d399;       /* green text / borders / highlights */
  --accent-2: #2dd4bf;     /* teal, used in small accents */
  --btn: #12b981;          /* SOLID button green (no gradient) */
  --btn-text: #04241a;     /* dark text on green for contrast */
  --locked: #5a678a;
  --radius: 14px;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  line-height: 1.5;
  background:
    radial-gradient(1100px 520px at 50% -8%, rgba(45, 212, 191, 0.13), transparent 62%),
    radial-gradient(840px 440px at 88% 2%, rgba(56, 189, 248, 0.09), transparent 58%),
    radial-gradient(720px 520px at 8% 16%, rgba(99, 102, 241, 0.07), transparent 60%),
    linear-gradient(180deg, #0b1124 0%, #080d1b 100%);
  background-attachment: fixed;
}

/* ---- shared surfaces -------------------------------------------------- */
.panel,
.card,
.tabs,
.filterbar,
.stage-header {
  background: linear-gradient(180deg, var(--panel-hi), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

header {
  padding: 1.4rem 1.5rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  background: linear-gradient(180deg, rgba(26, 37, 66, 0.6), transparent);
}
header h1 { font-size: 1.35rem; margin: 0; letter-spacing: -0.01em; }
.who { color: var(--muted); font-size: 0.9rem; }
.who button { margin-left: 0.7rem; }

main { max-width: 1000px; margin: 0 auto; padding: 1.25rem; }

/* ---- buttons (solid, never gradient) ---------------------------------- */
button {
  background: var(--btn);
  color: var(--btn-text);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.6rem 1.15rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s ease, border-color 0.15s ease;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
  font-weight: 500;
  font-size: 0.82rem;
  padding: 0.4rem 0.7rem;
}
button.ghost:hover { color: var(--text); border-color: var(--line-hi); filter: none; }

/* ---- top tabs (Predictions / Leaderboard) ----------------------------- */
.tabs {
  display: flex;
  gap: 0.3rem;
  margin-bottom: 1.2rem;
  padding: 0.35rem;
}
.tabs button {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--muted);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font-weight: 600;
  position: relative;
}
.tabs button:hover { color: var(--text); filter: none; }
.tabs button.active { color: var(--accent); background: rgba(52, 211, 153, 0.06); }
.tabs button.active::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0.25rem;
  width: 55%;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

/* ---- inputs ----------------------------------------------------------- */
input {
  background: #0b1322;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 0.55rem 0.65rem;
  font-size: 1rem;
}
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.15);
}

.card { padding: 1.1rem 1.25rem; margin-bottom: 0.85rem; box-shadow: var(--shadow); }
.stage { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }

/* ---- single-row match ------------------------------------------------- */
.match { display: flex; align-items: center; gap: 0.7rem; }
.match .kickoff { flex: 0 0 auto; width: 8.5rem; display: flex; align-items: center; gap: 0.5rem; }
.match .kickoff .ic { color: var(--muted); }
.kt { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.kt .ktime { color: var(--muted); }
.match .team {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
}
.match .team.home { justify-content: flex-end; }
.match .team.away { justify-content: flex-start; }
.match .team .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match .score {
  flex: 0 0 auto;
  width: 3.3rem;
  height: 2.7rem;
  text-align: center;
  font-weight: 700;
  font-size: 1.05rem;
}
.vs { flex: 0 0 auto; color: var(--muted); font-weight: 600; padding: 0 0.15rem; }
.match .status { flex: 0 0 auto; margin-left: 0.5rem; text-align: right; }

/* circular team flag (or globe for unknown / placeholder teams) */
.flag {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
  background: #0b1322;
  box-shadow: 0 0 0 1px var(--line), 0 2px 6px rgba(0, 0, 0, 0.3);
}
.flag-globe { color: var(--muted); padding: 3px; }

.card-foot { display: flex; justify-content: flex-end; margin-top: 0.55rem; }

.kickoff { color: var(--muted); font-size: 0.85rem; }
.locked-tag { color: var(--locked); font-size: 0.85rem; }
.result-tag {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.25);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
}
.saved { color: var(--accent); font-size: 0.85rem; font-weight: 600; }

/* ---- leaderboard table ------------------------------------------------ */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.7rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
td.num, th.num { text-align: right; }
tr.me { background: rgba(52, 211, 153, 0.08); }

/* ---- sticky filter bar ------------------------------------------------ */
.filterbar {
  position: sticky;
  top: 0.5rem;
  z-index: 5;
  padding: 0.8rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.chips { display: flex; gap: 0.45rem; margin-bottom: 0.6rem; }
.chip {
  flex: 1;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}
.chip:hover { color: var(--text); border-color: var(--line-hi); filter: none; }
.chip.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(52, 211, 153, 0.09);
}

/* inline icons inherit text colour and scale with font size */
.ic { width: 1.1em; height: 1.1em; flex: 0 0 auto; }

/* stage dropdown: leading calendar icon + custom trailing chevron */
.select-wrap { position: relative; }
.select-wrap .lead-ic,
.select-wrap .trail-ic {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  display: flex;
}
.select-wrap .lead-ic { left: 0.85rem; }
.select-wrap .trail-ic { right: 0.85rem; }
#stageFilter {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: #0b1322;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.95rem;
  padding: 0.65rem 2.4rem;
}
#stageFilter:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.15); }
.empty { text-align: center; padding: 2.5rem 0; }

/* ---- collapsible stage section header --------------------------------- */
.stage-header {
  width: 100%;
  font-size: 1rem;
  font-weight: 700;
  margin: 1.2rem 0 0.6rem;
  padding: 0.9rem 1.15rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  cursor: pointer;
  color: var(--text);
}
.stage-header:hover { border-color: var(--line-hi); filter: none; }
.stage-name::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.6rem;
  color: var(--accent);
  transition: transform 0.15s ease;
}
.stage-header.open .stage-name::before { transform: rotate(90deg); }
.stage-header .count {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.8rem;
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.25);
  border-radius: 999px;
  padding: 0.12rem 0.65rem;
}

/* ---- compact match cards ---------------------------------------------- */
.match-card {
  padding: 0.85rem 1.15rem;
  margin-bottom: 0.55rem;
  border-radius: 12px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.match-card:hover { border-color: var(--line-hi); }
.match-card .team { font-size: 0.95rem; }
.match-card .kickoff { font-size: 0.8rem; line-height: 1.25; }
.weight {
  font-size: 0.72rem;
  color: var(--accent);
  border: 1px solid rgba(52, 211, 153, 0.3);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  font-weight: 600;
}
.picks { margin-top: 0.8rem; border-top: 1px solid var(--line); padding-top: 0.7rem; }
.pick-row {
  display: flex;
  justify-content: space-between;
  padding: 0.3rem 0;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(42, 57, 96, 0.5);
}

/* ---- admin: editable team / kickoff fields ---------------------------- */
.team-edit { font-weight: 600; font-size: 0.92rem; min-width: 0; padding: 0.4rem 0.5rem; }
.team-edit.home { text-align: right; }
.team-edit.away { text-align: left; }
.kickoff-edit {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  color: var(--muted);
  font-size: 0.72rem;
}
.kickoff-edit input { width: 14rem; max-width: 100%; padding: 0.35rem 0.5rem; }
.actions { display: flex; gap: 0.5rem; align-items: flex-end; }
.match .team-edit { flex: 1 1 0; }
.meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 0.7rem;
  flex-wrap: wrap;
}

.center { text-align: center; }
.error { color: #fca5a5; }
.hidden { display: none; }

/* ---- mobile: match row wraps into kickoff / teams+scores / action ----- */
@media (max-width: 680px) {
  header { padding: 1.1rem; }
  main { padding: 0.85rem; }
  .match { flex-wrap: wrap; justify-content: center; row-gap: 0.55rem; }
  .match .kickoff { order: -1; width: 100%; justify-content: center; }
  .match .team { flex: 1 1 30%; }
  .match .score { width: 2.7rem; }
  .match .status { width: 100%; margin-left: 0; text-align: center; order: 1; }
  .match .status button { width: 100%; }
  .flag { width: 24px; height: 24px; }
  .card-foot { justify-content: center; }
}

#login { max-width: 400px; margin: 4.5rem auto; }
#login .card > * { display: block; width: 100%; margin-bottom: 0.75rem; }
.note { color: var(--muted); font-size: 0.85rem; }
