/* ============================================================
   FIFA World Cup 2026 — modern minimal styles
   Single accent color, generous whitespace, system font stack.
   ============================================================ */

:root {
  --accent: #0F7A3D;          /* football-pitch green */
  --accent-ink: #0a5a2c;      /* darker, for hover */
  --accent-soft: #e7f4ec;     /* tint background */
  --ink: #0e1116;             /* near-black */
  --ink-2: #4a5260;           /* secondary text */
  --ink-3: #8a93a3;           /* tertiary / muted */
  --line: #ececf1;            /* hairlines */
  --line-2: #f4f4f7;          /* softer background blocks */
  --bg: #ffffff;
  --bg-elev: #ffffff;
  --shadow: 0 1px 2px rgba(14, 17, 22, .04), 0 4px 18px rgba(14, 17, 22, .04);
  --radius: 14px;
  --radius-sm: 8px;
  --max: 1120px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f1f3f7;
    --ink-2: #b8c0cc;
    --ink-3: #7d8694;
    --line: #232733;
    --line-2: #181b22;
    --bg: #0d1015;
    --bg-elev: #14171f;
    --accent-soft: #143524;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-ink); text-decoration: underline; }

button { font: inherit; color: inherit; cursor: pointer; }

/* ---- Top bar ----------------------------------------------------- */

.topbar {
  max-width: var(--max);
  margin: 0 auto;
  padding: 28px 28px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 14px; }
.trophy { font-size: 36px; line-height: 1; }
.brand-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand-sub {
  font-size: 13px;
  color: var(--ink-3);
  margin-top: 2px;
}

.topbar-right { display: flex; align-items: center; gap: 12px; }

.countdown {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-variant-numeric: tabular-nums;
  background: var(--accent-soft);
  color: var(--accent-ink);
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13px;
}
@media (prefers-color-scheme: dark) {
  .countdown { color: #6dd49b; }
}
.cd-num { font-size: 16px; font-weight: 700; }
.cd-label { color: var(--ink-3); margin-right: 4px; }
.cd-until { margin-left: 6px; color: var(--ink-3); font-weight: 500; }

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--line);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--ink-2);
  transition: background .15s, border-color .15s, color .15s;
}
.ghost-btn:hover { background: var(--line-2); color: var(--ink); }
.ghost-btn.is-busy svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Tabs -------------------------------------------------------- */

.tabs {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  background: transparent;
  border: 0;
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
  position: relative;
  white-space: nowrap;
  border-radius: 8px 8px 0 0;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--ink); font-weight: 600; }
.tab.is-active::after {
  content: '';
  position: absolute;
  left: 12px; right: 12px; bottom: -1px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}

/* ---- Content ----------------------------------------------------- */

.content {
  max-width: var(--max);
  margin: 0 auto;
  padding: 28px;
}

.tab-pane[hidden] { display: none; }
.tab-pane.is-active { display: block; }

.section-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}
.section-sub {
  margin: 0 0 22px;
  color: var(--ink-3);
  font-size: 14px;
}

/* ---- Match cards ------------------------------------------------- */

.match-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 720px) {
  .match-list { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1024px) {
  .match-list { grid-template-columns: 1fr 1fr 1fr; }
  #upcoming-list.match-list { grid-template-columns: 1fr 1fr; }
}

.match-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform .15s ease, box-shadow .15s ease;
}
.match-card:hover { transform: translateY(-1px); box-shadow: 0 1px 2px rgba(14,17,22,.06), 0 12px 28px rgba(14,17,22,.06); }

.match-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--ink-3);
}
.match-stage-pill {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: .02em;
  text-transform: uppercase;
}
@media (prefers-color-scheme: dark) {
  .match-stage-pill { color: #6dd49b; }
}

.match-teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
}
.match-team {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.match-team.away { flex-direction: row-reverse; text-align: right; }
.match-team .flag {
  width: 32px; height: 22px;
  border-radius: 3px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: var(--line-2);
  flex: 0 0 auto;
}
.match-team .name {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.match-team .fifa {
  display: block;
  font-size: 11px;
  color: var(--ink-3);
  font-weight: 500;
  letter-spacing: .04em;
  margin-top: 1px;
}
.match-vs {
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 600;
  letter-spacing: .04em;
  padding: 0 4px;
}
.match-score {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
  padding: 0 8px;
}

.match-when-where {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--ink-2);
  border-top: 1px dashed var(--line);
  padding-top: 12px;
}
.match-when-where .where { color: var(--ink-3); font-size: 12px; }
.match-when-where .when { font-weight: 500; }

/* ---- Match stats block (head-to-head, recent form) ---------- */

.match-stats {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: var(--line-2);
  border-radius: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
}
.stats-line {
  display: grid;
  grid-template-columns: 18px auto 1fr;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--ink-2);
}
.stats-line .stats-icon {
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.stats-line .stats-icon .stats-flag {
  width: 16px;
  height: 11px;
  object-fit: cover;
  border-radius: 2px;
  border: 1px solid var(--line);
}
.stats-line .stats-label {
  font-weight: 600;
  color: var(--ink);
  font-size: 12px;
  letter-spacing: .01em;
  white-space: nowrap;
}
.stats-line .stats-text {
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats-form {
  grid-template-columns: 18px auto 1fr;
}
.stats-form-strip {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.form-cell {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: 32px;
  padding: 2px 4px 1px;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
  font-size: 10.5px;
  line-height: 1.1;
  border: 1px solid transparent;
  background: var(--bg-elev);
  color: var(--ink-2);
  cursor: default;
}
.form-cell .form-r { font-weight: 700; font-size: 11px; }
.form-cell .form-s { color: var(--ink-3); font-size: 10px; margin-top: 1px; }
.form-w { background: rgba(15, 122, 61, 0.10); border-color: rgba(15, 122, 61, 0.20); color: var(--accent-ink); }
.form-w .form-r { color: var(--accent-ink); }
.form-d { background: rgba(122, 122, 130, 0.08); border-color: rgba(122, 122, 130, 0.18); }
.form-l { background: rgba(190, 49, 68, 0.08); border-color: rgba(190, 49, 68, 0.20); color: #8a2530; }
.form-l .form-r { color: #8a2530; }
@media (prefers-color-scheme: dark) {
  .form-w { color: #6dd49b; }
  .form-l { color: #f08487; }
  .form-l .form-r { color: #f08487; }
}

/* ---- Filter row ------------------------------------------------- */

.filter-row {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.search, .select {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  min-width: 0;
}
.search { flex: 1 1 240px; }
.select { flex: 0 0 auto; }
.search:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---- Groups ----------------------------------------------------- */

.groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.group-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.group-card h3 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.group-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: 14px;
  font-weight: 700;
}
.group-team-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.group-team {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s;
  text-align: left;
  background: transparent;
  border: 0;
  width: 100%;
  color: inherit;
}
.group-team:hover { background: var(--line-2); }
.group-team img.flag {
  width: 22px; height: 14px;
  object-fit: cover;
  border-radius: 2px;
  border: 1px solid var(--line);
  flex: 0 0 auto;
}
.group-team .gt-name { font-weight: 500; font-size: 14px; }
.group-team .gt-fifa { font-size: 11px; color: var(--ink-3); margin-left: 6px; letter-spacing: .04em; }

/* ---- Teams grid ------------------------------------------------- */

.teams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.team-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-align: left;
  transition: background .15s, transform .1s, border-color .15s;
}
.team-card:hover { background: var(--accent-soft); border-color: var(--accent); }
.team-card:active { transform: scale(.98); }
.team-card img.flag {
  width: 28px; height: 18px;
  object-fit: cover;
  border-radius: 2px;
  border: 1px solid var(--line);
  flex: 0 0 auto;
}
.team-card .tc-name { font-size: 14px; font-weight: 500; }
.team-card .tc-fifa { font-size: 11px; color: var(--ink-3); margin-top: 2px; letter-spacing: .04em; }

/* ---- Stadiums grid --------------------------------------------- */

.stadiums-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 8px;
}
.stadium-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.stadium-card .name { font-weight: 600; font-size: 15px; }
.stadium-card .fifa-name { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.stadium-card .city {
  margin-top: 12px;
  font-size: 13px;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 6px;
}
.stadium-card .meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-3);
}
.stadium-card .cap {
  font-weight: 600;
  color: var(--ink-2);
}

/* ---- Loading & error ------------------------------------------- */

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 60px 20px;
  color: var(--ink-3);
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
.error-state {
  text-align: center;
  padding: 60px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.error-title { font-size: 18px; font-weight: 600; }
.error-msg { color: var(--ink-3); font-size: 14px; max-width: 460px; }
.primary-btn {
  background: var(--accent);
  color: white;
  border: 0;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  margin-top: 8px;
}
.primary-btn:hover { background: var(--accent-ink); }

/* ---- Modal ----------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--bg);
  border-radius: 16px;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  animation: pop .2s ease;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-close {
  position: absolute;
  top: 8px; right: 12px;
  background: transparent;
  border: 0;
  font-size: 28px;
  line-height: 1;
  color: var(--ink-3);
  padding: 4px 10px;
  border-radius: 8px;
}
.modal-close:hover { background: var(--line-2); color: var(--ink); }

.modal-body { padding: 32px 28px 28px; }
.modal-body .m-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.modal-body .m-flag {
  width: 56px; height: 38px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--line);
}
.modal-body h2 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.modal-body .m-fifa {
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: .06em;
  font-weight: 600;
}
.modal-body .m-thumb {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  background: var(--line-2);
  border-radius: 10px;
  margin-bottom: 18px;
}
.modal-body .m-extract {
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  white-space: pre-line;
}
.modal-body .m-meta {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--ink-3);
}
.modal-body .m-meta a { color: var(--accent); font-weight: 500; }

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

.footer {
  max-width: var(--max);
  margin: 24px auto 40px;
  padding: 16px 28px 0;
  font-size: 12px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.footer .dot { color: var(--ink-3); }
#cache-status { color: var(--ink-3); }
#cache-status.is-online { color: var(--accent); }

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

[hidden] { display: none !important; }
