:root {
    --bg:        #0a0e1a;
    --surface:   #111827;
    --surface2:  #1a2234;
    --border:    #1e2d45;
    --accent:    #00e5a0;
    --accent2:   #0099ff;
    --danger:    #ff4d6d;
    --warn:      #ffb830;
    --text:      #e8edf5;
    --muted:     #6b7a99;
    --cl:        #f0c040; /* Champions League gold */
    --el:        #e87020; /* Europa League orange */
    --ecl:       #38c080; /* Conference League green */
    --rel:       #ff4d6d; /* Relegation red */
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Barlow', sans-serif;
    min-height: 100vh;
    background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(0,229,160,0.07) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 80%, rgba(0,153,255,0.05) 0%, transparent 60%);
}

/* ─── Header ─── */
header {
    padding: 2.5rem 2rem 2rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}
header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0,229,160,0.04) 0%, transparent 100%);
    pointer-events: none;
}
.header-eyebrow {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.5rem;
}
h1 {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1;
    color: var(--text);
}
h1 span { color: var(--accent); }
.header-sub {
    margin-top: 0.75rem;
    color: var(--muted);
    font-size: 0.9rem;
}

/* ─── League Nav ─── */
.league-nav {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 1.25rem 2rem;
    overflow-x: auto;
    scrollbar-width: none;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.league-nav::-webkit-scrollbar { display: none; }

.league-tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}
.league-tab:hover {
    border-color: var(--accent);
    color: var(--text);
}
.league-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #0a0e1a;
}
.league-tab .flag { font-size: 1rem; }

/* ─── Main Layout ─── */
main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem;
}

/* ─── League Header ─── */
.league-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    animation: fadeIn 0.3s ease;
}
.league-logo-wrap {
    width: 56px;
    height: 56px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}
.league-title { flex: 1; }
.league-title h2 {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 1.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.league-title p { color: var(--muted); font-size: 0.85rem; }
.updated-badge {
    font-size: 0.75rem;
    color: var(--muted);
    background: var(--surface2);
    border: 1px solid var(--border);
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
}

/* ─── Standings Table ─── */
.standings-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    animation: slideUp 0.35s ease;
}

.standings-table {
    width: 100%;
    border-collapse: collapse;
}
.standings-table thead th {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 0.85rem 1rem;
    text-align: center;
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
}
.standings-table thead th:nth-child(2) { text-align: left; }

.standings-table tbody tr {
    border-bottom: 1px solid rgba(30,45,69,0.6);
    transition: background 0.15s;
    animation: fadeInRow 0.3s ease both;
}
.standings-table tbody tr:hover { background: var(--surface2); }
.standings-table tbody tr:last-child { border-bottom: none; }

.standings-table td {
    padding: 0.75rem 1rem;
    text-align: center;
    font-size: 0.9rem;
}
.standings-table td:nth-child(2) { text-align: left; }

/* Position cell */
.pos-cell {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    width: 40px;
    position: relative;
}
.pos-indicator {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    border-radius: 0 2px 2px 0;
}
.zone-cl   .pos-indicator { background: var(--cl); }
.zone-el   .pos-indicator { background: var(--el); }
.zone-ecl  .pos-indicator { background: var(--ecl); }
.zone-rel  .pos-indicator { background: var(--rel); }

/* Team cell */
.team-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.team-crest {
    width: 28px;
    height: 28px;
    object-fit: contain;
    flex-shrink: 0;
}
.team-crest-placeholder {
    width: 28px;
    height: 28px;
    background: var(--surface2);
    border-radius: 4px;
    flex-shrink: 0;
}
.team-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}
.team-name-short { display: none; }

/* Stats cells */
.stat-pts {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--text);
}
.stat-gd {
    font-weight: 600;
    color: var(--muted);
}
.stat-gd.positive { color: var(--accent); }
.stat-gd.negative { color: var(--rel); }

/* Form pills */
.form-wrap {
    display: flex;
    gap: 3px;
    justify-content: center;
}
.form-pill {
    width: 18px;
    height: 18px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Barlow Condensed', sans-serif;
}
.form-W { background: rgba(0,229,160,0.2); color: var(--accent); }
.form-D { background: rgba(255,184,48,0.2); color: var(--warn); }
.form-L { background: rgba(255,77,109,0.15); color: var(--rel); }

/* Legend */
.legend {
    display: flex;
    gap: 1.5rem;
    padding: 1rem 1.25rem;
    background: var(--surface2);
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    color: var(--muted);
}
.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* ─── Loading / Error ─── */
.state-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5rem 2rem;
    gap: 1rem;
    color: var(--muted);
    text-align: center;
}
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.error-icon { font-size: 2.5rem; }
.error-msg { max-width: 400px; font-size: 0.9rem; line-height: 1.6; }
.retry-btn {
    margin-top: 0.5rem;
    padding: 0.5rem 1.5rem;
    border-radius: 999px;
    border: 1px solid var(--accent);
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 0.9rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    transition: all 0.2s;
}
.retry-btn:hover { background: var(--accent); color: #0a0e1a; }

/* ─── Animations ─── */
@keyframes fadeIn  { from { opacity:0 } to { opacity:1 } }
@keyframes slideUp { from { opacity:0; transform:translateY(12px) } to { opacity:1; transform:none } }
@keyframes spin    { to { transform: rotate(360deg) } }
@keyframes fadeInRow {
    from { opacity:0; transform: translateX(-6px) }
    to   { opacity:1; transform: none }
}

/* ─── Responsive ─── */
@media (max-width: 700px) {
    main { padding: 1rem; }
    .standings-table .hide-mobile { display: none; }
    .team-name { max-width: 130px; }
}

/* ─── Footer ─── */
footer {
  text-align: center;
  padding: 2rem;
  margin-top: 2rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.8;
}
footer a {
  color: var(--accent);
  text-decoration: none;
}
footer a:hover {
  text-decoration: underline;
}