@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── Palette ── */
  --navy:       #5c6b8a;   /* base blue-slate */
  --navy-lt:    #a2b8d2;   /* light blue */
  --peach:      #f5c9a8;   /* warm peach */
  --orange:     #ffd452;   /* primary accent */
  --brick:      #ba4c40;   /* danger / live */

  /* ── Backgrounds (darker derivatives of navy) ── */
  --bg:         #2c3548;
  --bg2:        #384260;
  --bg3:        #475470;
  --bg4:        #5c6b8a;   /* = navy */

  /* ── Borders ── */
  --border:     rgba(162,184,210,0.12);
  --border2:    rgba(162,184,210,0.24);

  /* ── Text ── */
  --text:       #f5f0ec;
  --text-dim:   #c5d4e4;
  --text-muted: #8a9ab8;

  /* ── Glows ── */
  --orange-glow: rgba(255,212,82,0.22);
  --brick-glow:  rgba(186,76,64,0.22);

  /* ── Sizes ── */
  --hh:     72px;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.45);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', sans-serif;
  background: linear-gradient(160deg, var(--bg) 0%, #1e2636 100%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
}

::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 99px; }

/* ─── HEADER ──────────────────────────── */
.site-header {
  height: var(--hh);
  background: var(--bg3);
  border-bottom: 1px solid var(--border2);
  position: sticky; top: 0; z-index: 200;
  box-shadow: 0 2px 20px rgba(0,0,0,0.5);
}
.header-inner {
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.25rem; height: 100%;
  max-width: 1400px; margin: 0 auto;
}

.logo { display: flex; align-items: center; gap: 11px; flex-shrink: 0; }
.logo-emblem {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--bg4); border: 2px solid var(--orange);
  display: flex; align-items: center; justify-content: center; font-size: 20px;
  box-shadow: 0 0 14px var(--orange-glow);
}
.logo-text-wrap { line-height: 1.15; }
.logo-brand   { font-family:'Bebas Neue',sans-serif; font-size:24px; letter-spacing:3px; color:var(--orange); }
.logo-edition { font-size:10px; color:var(--text-dim); letter-spacing:2px; text-transform:uppercase; }

.stage-nav { display:flex; gap:4px; flex:1; justify-content:center; }
.snav {
  padding: 8px 22px; border: none; background: none;
  color: var(--text-dim); font-size: 14px; font-weight: 600;
  font-family: 'DM Sans', sans-serif; cursor: pointer;
  border-radius: 8px; transition: all 0.15s; letter-spacing: 0.5px;
  text-transform: uppercase;
}
.snav:hover  { color: var(--text); background: var(--bg4); }
.snav.active { color: var(--orange); background: var(--orange-glow); }

.header-status { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.refresh-info  { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.live-dot {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 700; color: var(--orange); letter-spacing: 1px;
}
.live-dot::before {
  content: ''; width: 9px; height: 9px; border-radius: 50%;
  background: var(--orange); animation: pulse 1.5s infinite;
  box-shadow: 0 0 8px rgba(255,212,82,0.7);
}
@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.5;transform:scale(0.85)} }

/* ─── HUB LAYOUT ──────────────────────── */
.hub {
  display: grid; grid-template-columns: 3fr 2fr;
  max-width: 1400px; margin: 0 auto;
  min-height: calc(100dvh - var(--hh)); align-items: start;
}
@media (max-width: 900px) { .hub { grid-template-columns: 1fr; } }

/* ─── LEFT: MATCHES ───────────────────── */
.matches-panel {
  padding: 1rem 1.25rem 2rem;
  border-right: 1px solid var(--border);
  min-height: calc(100dvh - var(--hh));
}
@media (max-width: 900px) { .matches-panel { border-right: none; padding: 0.75rem; } }

/* Controls row — [All Groups] [A][B]…[L] [Sort] */
.match-controls {
  display: flex; align-items: stretch; gap: 8px;
  margin-bottom: 1rem;
}

/* Shared style for the two flanking action buttons */
.ctrl-btn {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  padding: 0 20px; min-width: 110px;
  border: 1.5px solid var(--border2);
  background: var(--bg2); color: var(--text-dim);
  border-radius: 8px; font-size: 13px; font-weight: 600;
  font-family: 'DM Sans', sans-serif; cursor: pointer;
  transition: all 0.14s; white-space: nowrap; flex-shrink: 0;
}
.ctrl-btn:hover  { background: var(--bg3); color: var(--text); border-color: var(--orange); }
.ctrl-btn.active { background: var(--orange); color: #1a2030; border-color: var(--orange); }

/* Sort arrow flip */
.sort-btn.asc .sort-arrow { transform: rotate(180deg); }
.sort-arrow { display: inline-block; transition: transform 0.2s; font-style: normal; }

/* Group letter pills grid — 6 cols × 2 rows */
.group-filter-bar {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px; flex: 1;
}
.gpill {
  padding: 9px 6px; font-size: 12px; font-weight: 600;
  border-radius: 7px; border: 1.5px solid var(--border2);
  background: var(--bg2); color: var(--text-dim);
  cursor: pointer; font-family: 'DM Sans', sans-serif;
  transition: all 0.12s; text-align: center;
}
.gpill:hover  { border-color: var(--orange); color: var(--orange); }
.gpill.active { background: var(--orange); color: #1a2030; border-color: var(--orange); }

/* Day separator */
.day-label {
  font-size: 9px; font-weight: 700; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--text-muted);
  padding: 14px 0 8px; display: flex; align-items: center; gap: 8px;
}
.day-label::after { content:''; flex:1; height:1px; background:var(--border); }

/* ─── MATCH CARD ──────────────────────── */
.match-card {
  background: rgba(56,66,96,0.7);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px 11px;
  margin-bottom: 7px;
  position: relative; overflow: hidden;
  transition: border-color 0.15s, background 0.15s;
  backdrop-filter: blur(4px);
}
.match-card:hover { border-color: var(--border2); background: rgba(71,84,112,0.8); }

/* Status stripe */
.match-card::before {
  content: ''; position: absolute; left:0; top:0; bottom:0; width:3px;
}
.match-card.state-post::before { background: var(--navy-lt); opacity:0.5; }
.match-card.state-in::before   { background: var(--brick); }
.match-card.state-pre::before  { background: var(--border2); }

/* Top meta row */
.match-meta-row {
  display: flex; align-items: center; gap: 6px; margin-bottom: 10px;
}
.match-group-tag {
  font-size: 9px; font-weight: 700; letter-spacing: 1px;
  background: rgba(92,107,138,0.5); color: var(--navy-lt);
  padding: 2px 7px; border-radius: 4px; text-transform: uppercase;
}
.match-status-tag {
  font-size: 9px; font-weight: 700; padding: 2px 7px; border-radius: 4px; letter-spacing: 0.5px;
}
.match-status-tag.ft    { background: rgba(162,184,210,0.1); color: var(--text-muted); }
.match-status-tag.live  { background: rgba(186,76,64,0.2); color: var(--brick); animation: pulse 1.5s infinite; }
.match-status-tag.sched { background: rgba(240,120,56,0.15); color: var(--orange); }

/* Venue chip */
.match-venue-chip {
  margin-left: auto;
  display: flex; align-items: center; gap: 5px;
  background: rgba(92,107,138,0.3); border: 1px solid var(--border);
  border-radius: 6px; padding: 3px 8px;
  max-width: 200px; overflow: hidden;
}
.venue-stadium { font-size: 10px; font-weight: 500; color: var(--peach); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.venue-city    { font-size: 9px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Score row */
.score-row {
  display: grid; grid-template-columns: 1fr 90px 1fr;
  align-items: center; gap: 6px;
}
.team-side       { display: flex; align-items: center; gap: 10px; }
.team-side.away  { flex-direction: row-reverse; text-align: right; }
.team-flag       { font-size: 28px; line-height: 1; flex-shrink: 0; }
.team-info       { min-width: 0; }
.team-name       { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team-code       { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }

.score-center    { text-align: center; }
.score-digits    { font-family:'Bebas Neue',sans-serif; font-size:30px; letter-spacing:5px; line-height:1; color:var(--text); }
.score-digits.ft   { color: var(--peach); }
.score-digits.live { color: var(--brick); }
.score-clock     { font-size: 10px; color: var(--text-muted); margin-top: 1px; }

/* Venue detail strip (below score) */
.venue-detail {
  display: flex; align-items: center; gap: 6px;
  margin-top: 9px; padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 10px;
}
.venue-icon { font-size: 11px; opacity: 0.7; flex-shrink: 0; }
.venue-name { color: var(--peach); font-weight: 500; }
.venue-sep  { color: var(--border2); }
.venue-loc  { color: var(--text-muted); }

/* Goal scorers */
.goal-scorers {
  display: flex; flex-direction: column; gap: 2px;
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--border);
}
.scorer-line { display:flex; align-items:center; gap:6px; font-size:10px; color:var(--text-dim); }
.scorer-line .min { color: var(--orange); font-weight: 600; min-width: 24px; }

/* ─── RIGHT PANEL ─────────────────────── */
.right-panel {
  display: flex; flex-direction: column;
  position: sticky; top: var(--hh);
  height: calc(100dvh - var(--hh)); overflow-y: auto;
  border-left: 1px solid var(--border);
}
.right-panel::-webkit-scrollbar { width: 2px; }
@media (max-width: 900px) { .right-panel { position: static; height: auto; border-left: none; } }

/* ─── PANEL ───────────────────────────── */
.panel { border-bottom: 1px solid var(--border); }
.panel-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px 9px;
  background: var(--bg2); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.panel-title { font-family:'Bebas Neue',sans-serif; font-size:16px; letter-spacing:2.5px; color:var(--navy-lt); }
.panel-sub   { font-size: 10px; color: var(--text-muted); }

/* Group letter tabs */
.group-letter-nav { display: flex; gap: 3px; flex-wrap: wrap; }
.gltab {
  width: 26px; height: 26px; border-radius: 5px;
  border: 1px solid var(--border); background: var(--bg3);
  color: var(--text-muted); font-size: 12px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.1s; font-family: 'DM Sans', sans-serif;
}
.gltab:hover  { border-color: var(--orange); color: var(--orange); }
.gltab.active { background: var(--orange); color: #1a2030; border-color: var(--orange); }

/* ─── STANDINGS ───────────────────────── */
.std-table { width: 100%; border-collapse: collapse; }
.std-table th {
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--text-muted);
  padding: 8px 8px; text-align: center;
}
.std-table th:first-child { text-align: left; padding-left: 14px; }
.std-table td {
  padding: 9px 8px; text-align: center;
  font-size: 13px; color: var(--text-dim);
  border-top: 1px solid var(--border);
}
.std-table td:first-child { text-align: left; padding-left: 14px; }
.std-table tr:hover td { background: rgba(92,107,138,0.2); }

.std-team    { display: flex; align-items: center; gap: 8px; }
.std-rank    { font-size: 11px; width: 16px; flex-shrink: 0; color: var(--text-muted); }
.std-rank.adv  { color: var(--orange); }
.std-rank.best { color: var(--peach); }
.std-rank.elim { color: var(--text-muted); opacity: 0.5; }
.std-flag    { font-size: 20px; line-height: 1; }
.std-name    { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
.std-pts     { font-weight: 700; color: var(--text) !important; }
.std-gd-pos  { color: var(--orange) !important; }
.std-gd-neg  { color: var(--brick)  !important; }

.qual-note {
  font-size: 9px; padding: 5px 14px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 6px; color: var(--text-muted);
}
.qual-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }

/* ─── TOP SCORERS ─────────────────────── */
.scorer-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; border-top: 1px solid var(--border);
  transition: background 0.1s;
}
.scorer-row:hover { background: rgba(92,107,138,0.2); }
.scorer-rank       { font-family:'Bebas Neue',sans-serif; font-size:17px; color:var(--text-muted); width:18px; flex-shrink:0; }
.scorer-rank.top   { color: var(--orange); }
.scorer-info       { flex:1; min-width:0; }
.scorer-name       { font-size:13px; font-weight:600; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.scorer-team       { display:flex; align-items:center; gap:4px; font-size:10px; color:var(--text-muted); margin-top:1px; }
.scorer-goals      { font-family:'Bebas Neue',sans-serif; font-size:22px; color:var(--orange); display:flex; flex-direction:column; align-items:center; flex-shrink:0; }
.scorer-goals-sub  { font-family:'DM Sans',sans-serif; font-size:8px; color:var(--text-muted); line-height:1; }

/* ─── SKELETON / LOADING ──────────────── */
.skeleton-wrap { display: flex; flex-direction: column; gap: 7px; }
.skeleton-card {
  height: 90px; border-radius: var(--radius);
  background: linear-gradient(90deg, var(--bg2) 25%, var(--bg3) 50%, var(--bg2) 75%);
  background-size: 200% 100%; animation: shimmer 1.6s infinite;
  border: 1px solid var(--border);
}
@keyframes shimmer { to { background-position: -200% 0; } }

.loading-row { display:flex; justify-content:center; padding:1.5rem; }
.spinner {
  width:18px; height:18px; border-radius:50%;
  border: 2px solid var(--border2); border-top-color: var(--orange);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform:rotate(360deg); } }

.empty-msg { padding:2rem 1rem; text-align:center; font-size:13px; color:var(--text-muted); }

/* ─── TOAST ───────────────────────────── */
.toast {
  position: fixed; bottom: calc(60px + 1rem); left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--bg4); border: 1px solid var(--border2);
  color: var(--text); padding: 9px 20px; border-radius: 99px;
  font-size: 13px; font-weight: 500; pointer-events: none;
  z-index: 900; opacity: 0; transition: opacity 0.2s, transform 0.2s;
  white-space: nowrap; box-shadow: var(--shadow);
}
.toast.show { opacity:1; transform:translateX(-50%) translateY(0); }
@media (min-width: 800px) { .toast { bottom: 1.5rem; } }

/* ─── MOBILE GROUP BAR ────────────────── */
.mobile-group-bar {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg2); border-top: 1px solid var(--border);
  padding: 8px 12px; gap: 4px; overflow-x: auto; flex-wrap: nowrap;
  z-index: 100; box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
}
.mobile-group-bar::-webkit-scrollbar { display: none; }
/* mobile-group-bar hidden — groups accessible via standings panel at top */

/* ─── MOBILE SORT FAB ─────────────────── */
.mobile-sort-fab {
  display: none;
  position: fixed;
  bottom: 20px;   /* floats in corner, not stuck to edge */
  right: 16px;
  z-index: 150;
  align-items: center; gap: 6px;
  padding: 10px 18px;
  background: var(--bg3);
  border: 1.5px solid var(--border2);
  color: var(--text-dim);
  border-radius: 22px;
  font-size: 13px; font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  transition: all 0.14s;
  white-space: nowrap;
}
.mobile-sort-fab:hover { background: var(--bg4); color: var(--text); border-color: var(--orange); }
.mobile-sort-fab.asc .sort-arrow { transform: rotate(180deg); }

/* ─── RESPONSIVE ─────────────────────── */

@media (max-width: 800px) {
  body { overflow-x: hidden; }
  .hub { overflow-x: hidden; }
  .matches-panel { overflow-x: hidden; }

  /* Groups panel floats to the TOP on mobile */
  .right-panel { order: -1; }

  /* Hide scorers on mobile — they push matches off screen */
  #panel-scorers { display: none; }

  /* Hide entire desktop controls bar on mobile */
  .match-controls { display: none; }

  /* Show the floating sort FAB instead */
  .mobile-sort-fab { display: flex; }

  /* Match card score row: tighten center column */
  .score-row { grid-template-columns: 1fr 76px 1fr; gap: 4px; }
  .score-digits { font-size: 26px; letter-spacing: 4px; }
  .team-name { font-size: 13px; }
  .team-flag { font-size: 26px; }
}

@media (max-width: 600px) {
  .header-inner { padding: 0 1rem; }
  .logo-edition { display: none; }
  .stage-nav { gap: 0; }
  .snav { padding: 6px 12px; font-size: 12px; }
  .score-row { grid-template-columns: 1fr 70px 1fr; }
  .score-digits { font-size: 22px; letter-spacing: 3px; }
  .team-name { font-size: 12px; }
  .team-flag { font-size: 22px; }
}
