:root {
  --navy: #0B1426;
  --navy-2: #0f1c33;
  --slate: #1E2D45;
  --slate-2: #25375480;
  --gold: #C9A84C;
  --green: #22C55E;
  --text: #F2F5FA;
  --muted: #8DA0BC;
  --line: #2a3b58;
  --red: #ef4444;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--navy);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
h1, h2, h3, .display, .score, .badge { font-family: 'Barlow Condensed', sans-serif; }
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- Login ---------- */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(900px 500px at 50% -10%, #16264388, transparent),
    var(--navy);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--slate);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: 0 20px 60px #00000066;
}
.login-card .crest {
  font-size: 40px;
  text-align: center;
  margin-bottom: 8px;
}
.login-card h1 {
  font-size: 28px;
  letter-spacing: 0.5px;
  text-align: center;
  text-transform: uppercase;
}
.login-card .sub {
  text-align: center;
  color: var(--muted);
  margin-bottom: 24px;
  font-size: 13px;
}
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 11px 13px;
  background: var(--navy);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus { border-color: var(--gold); }
.btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 9px;
  background: var(--gold);
  color: #1a1300;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.3px;
  transition: filter 0.15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.6; cursor: default; }
.login-error {
  color: var(--red);
  font-size: 13px;
  text-align: center;
  margin-top: 14px;
  min-height: 18px;
}

/* ---------- App shell ---------- */
#app { display: none; flex-direction: column; min-height: 100vh; }
#app.active { display: flex; }

/* Live bar (persistent top bar) */
#live-bar {
  background: linear-gradient(90deg, #0c1a30, #112744);
  border-bottom: 1px solid var(--line);
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 46px;
  font-size: 14px;
}
#live-bar.idle { color: var(--muted); }
.pulse-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 #22C55E99;
  animation: pulse 1.6s infinite;
  flex: 0 0 auto;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 #22C55Ecc; }
  70% { box-shadow: 0 0 0 9px #22C55E00; }
  100% { box-shadow: 0 0 0 0 #22C55E00; }
}
#live-bar .lb-match { font-weight: 600; }
#live-bar .lb-score { font-family: 'Barlow Condensed'; font-size: 18px; color: var(--gold); font-weight: 700; }
#live-bar .lb-phase {
  font-family: 'Barlow Condensed';
  background: var(--green);
  color: #042611;
  padding: 1px 8px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
}

/* Header */
header.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  gap: 16px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { font-size: 24px; }
.brand h1 {
  font-size: 22px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.brand h1 .y { color: var(--gold); }
nav.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
nav.tabs button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
  transition: all 0.15s;
}
nav.tabs button:hover { color: var(--text); background: var(--slate-2); }
nav.tabs button.active {
  color: var(--gold);
  background: var(--slate);
  border-color: var(--line);
}
.logout-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}
.logout-btn:hover { color: var(--text); border-color: var(--muted); }
.topnav-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--muted); }
.icon-btn .icon-exit { display: none; }
.icon-btn.is-fullscreen .icon-enter { display: none; }
.icon-btn.is-fullscreen .icon-exit { display: block; }

/* Main */
main { flex: 1; padding: 24px 20px 60px; max-width: 1200px; margin: 0 auto; width: 100%; }
.tab-panel { animation: fade 0.3s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.section-title {
  font-size: 22px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
  color: var(--text);
}
.muted { color: var(--muted); }
.empty {
  color: var(--muted);
  text-align: center;
  padding: 40px 20px;
  border: 1px dashed var(--line);
  border-radius: 12px;
}

/* Next-match card (shown when nothing is live) */
.empty.next-match { border-style: solid; }
.next-match__label {
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 12px;
  margin-bottom: 10px;
}
.next-match__teams {
  font-family: 'Barlow Condensed';
  font-size: 30px;
  font-weight: 700;
}
.next-match__vs { font-size: 20px; }
.next-match__meta { margin: 8px 0; }
.next-match__countdown { font-size: 26px; }

/* Filters */
.filters { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.filters select {
  background: var(--slate);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.filters select:focus { border-color: var(--gold); }

/* Match cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}
.match-card {
  background: var(--slate);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  transition: border-color 0.15s, transform 0.15s;
}
.match-card:hover { border-color: #3a517a; transform: translateY(-2px); }
.match-card.live { border-color: var(--green); box-shadow: 0 0 0 1px #22C55E33 inset; }
.mc-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 10px;
}
.status-chip {
  padding: 1px 8px;
  border-radius: 6px;
  font-family: 'Barlow Condensed';
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.5px;
}
.status-chip.scheduled { background: var(--slate-2); color: var(--muted); }
.status-chip.live { background: var(--green); color: #042611; }
.status-chip.finished { background: #33405a; color: var(--text); }
.mc-teams { display: flex; flex-direction: column; gap: 8px; }
.mc-team {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.mc-team .name { display: flex; align-items: center; gap: 9px; font-weight: 600; }
.mc-team .flag { font-size: 22px; line-height: 1; }
.mc-team .goals {
  font-family: 'Barlow Condensed';
  font-size: 22px;
  font-weight: 700;
  min-width: 22px;
  text-align: right;
}
.mc-team .goals.win { color: var(--gold); }
.mc-bottom {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.countdown { color: var(--gold); font-weight: 600; font-family: 'Barlow Condensed'; font-size: 15px; }

/* Standings */
.group-block { margin-bottom: 26px; }
.group-block h3 {
  font-size: 17px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  color: var(--gold);
}
table.standings {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  background: var(--slate);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  font-size: 14px;
}
table.standings th, table.standings td {
  padding: 9px 10px;
  text-align: center;
}
table.standings th {
  background: var(--navy-2);
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
table.standings td.team-cell, table.standings th.team-cell { text-align: left; }
/* Fixed layout: numeric columns share one width so Pts etc. line up across every group table. */
table.standings th:not(.team-cell), table.standings td:not(.team-cell) { width: 40px; }
table.standings td.team-cell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.standings tbody tr { border-top: 1px solid var(--line); }
table.standings td.pts { font-weight: 700; color: var(--text); }
table.standings tr.qualify { background: #14331f; }
table.standings tr.qualify td:first-child { box-shadow: inset 3px 0 0 var(--green); }
table.standings tr.third-best { background: #33300f; }
table.standings tr.third-best td:first-child { box-shadow: inset 3px 0 0 var(--gold); }
.pos { color: var(--muted); font-weight: 600; }

/* Teams grid */
.teams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.team-card {
  background: var(--slate);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 12px;
  text-align: center;
  transition: transform 0.15s, border-color 0.15s;
}
.team-card:hover { transform: translateY(-2px); border-color: #3a517a; }
.team-card .flag { font-size: 38px; line-height: 1; }
.team-card .tname { font-weight: 600; margin-top: 8px; }
.team-card .tgroup {
  margin-top: 4px;
  font-size: 12px;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.swatch.green { background: var(--green); }
.swatch.gold { background: var(--gold); }

/* ---------- Focus view ---------- */
.focus-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 22px;
  align-items: start;
}
@media (max-width: 860px) { .focus-grid { grid-template-columns: 1fr; } }
.focus-sub {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 17px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gold);
  margin: 22px 0 10px;
}
.focus-ticker {
  background: linear-gradient(120deg, #0c1a30, #122a4a);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
}
.focus-ticker.live { border-color: var(--green); box-shadow: 0 0 0 1px #22C55E33 inset; }
.ft-tag {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700; letter-spacing: 1px;
  font-size: 13px; text-transform: uppercase; color: var(--green);
  margin-bottom: 14px;
}
.ft-tag.muted { color: var(--muted); }
.ft-score { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; }
.ft-team {
  font-family: 'Barlow Condensed', sans-serif; font-size: 22px; font-weight: 600;
  display: flex; align-items: center; gap: 8px; min-width: 0;
}
.ft-team .ft-flag { font-size: 26px; line-height: 1; }
.ft-team.right { justify-content: flex-end; }
.ft-nums {
  font-family: 'Barlow Condensed', sans-serif; font-size: 34px; font-weight: 700;
  color: var(--gold); text-align: center; white-space: nowrap;
}
.ft-nums.vs { font-size: 20px; color: var(--muted); }
.ft-dash { color: var(--muted); }
.ft-meta { color: var(--muted); font-size: 12px; margin-top: 10px; text-align: center; }
.focus-cd { text-align: center; font-size: 24px; margin-top: 10px; }
table.standings tr.focus-row td { background: #243a5e; }
table.standings tr.focus-row td.team-cell { color: var(--gold); font-weight: 700; }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--red); color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 13px; opacity: 0; transition: opacity 0.3s; pointer-events: none; z-index: 50;
}
.toast.show { opacity: 0.96; }

@media (max-width: 560px) {
  .brand h1 { font-size: 18px; }
  main { padding: 18px 14px 50px; }
}
