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

:root {
    --accent: #1c3f6e;
    --accent-hover: #162f55;
    --accent-light: #eaeff6;
    --accent-text: #1c3f6e;
    --bg: #f4f3f1;
    --surface: #ffffff;
    --surface-2: #eeede9;
    --border: rgba(0,0,0,0.07);
    --border-med: rgba(0,0,0,0.11);
    --border-strong: rgba(0,0,0,0.16);
    --text: #181816;
    --text-muted: #6a6a65;
    --text-dim: #aeada7;
    --danger: #b43030;
    --danger-light: #f9ecec;
    --success: #25634a;
    --warning: #8a5c0a;
    --live-pulse: rgba(180, 48, 48, 0.15);
}

body {
    font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

/* ─── DARK MODE ─────────────────────────────────────────────────────────── */
body.dark {
    --bg: #101010;
    --surface: #1a1a18;
    --surface-2: #222220;
    --border: rgba(255,255,255,0.06);
    --border-med: rgba(255,255,255,0.10);
    --border-strong: rgba(255,255,255,0.15);
    --text: #eeece8;
    --text-muted: #888883;
    --text-dim: #515150;
    --accent-light: #1a2535;
    --accent-text: #7aaee8;
    --danger-light: rgba(180,48,48,0.12);
}

/* ─── NAV ───────────────────────────────────────────────────────────────── */
nav {
    background: var(--surface);
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-med);
    position: sticky;
    top: 0;
    z-index: 100;
    height: 54px;
}

.logo {
    font-family: "Boldonse", system-ui;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    flex-shrink: 0;
}

.nav-links {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 6px 13px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s, color 0.15s;
}
.nav-btn:hover { background: var(--surface-2); color: var(--text); }
.nav-btn.active { background: var(--accent-light); color: var(--accent-text); }

.live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--danger);
    display: inline-block;
    animation: livepulse 1.8s infinite;
}
@keyframes livepulse { 0%,100%{opacity:1} 50%{opacity:0.35} }

.theme-toggle {
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--text-muted);
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: border-color 0.15s, color 0.15s;
    margin-left: 10px;
}
.theme-toggle:hover { border-color: var(--text-muted); color: var(--text); }

/* ─── LAYOUT ────────────────────────────────────────────────────────────── */
.container {
    max-width: 880px;
    margin: 0 auto;
    padding: 32px 20px;
}

.page { display: none; }
.page.active { display: block; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.page-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ─── TYPOGRAPHY ────────────────────────────────────────────────────────── */
.section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
    margin-bottom: 20px;
}
.page-header .section-title { margin-bottom: 0; }

/* ─── SEARCH ────────────────────────────────────────────────────────────── */
.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}
.search-bar input {
    flex: 1;
    padding: 10px 16px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}
.search-bar input::placeholder { color: var(--text-dim); }
.search-bar input:focus { border-color: var(--accent); }
.search-bar button {
    padding: 10px 20px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
}
.search-bar button:hover { background: var(--accent-hover); }

/* ─── PILLS ─────────────────────────────────────────────────────────────── */
.liga-pills {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.pill {
    padding: 5px 13px;
    border-radius: 6px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 500;
    transition: all 0.15s;
    white-space: nowrap;
    user-select: none;
}
.pill:hover { border-color: var(--accent); color: var(--accent-text); }
.pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ─── MATCH CARD ────────────────────────────────────────────────────────── */
.match-card {
    background: var(--surface);
    border-radius: 8px;
    padding: 13px 18px;
    margin-bottom: 3px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: border-color 0.15s, background 0.15s;
}
.match-card:hover { background: var(--surface-2); border-color: var(--border-med); }
.match-card.live-card { border-color: rgba(180,48,48,0.22); background: var(--danger-light); }
.match-card.live-card:hover { border-color: rgba(180,48,48,0.35); }

.team-side { display: flex; align-items: center; gap: 8px; }
.team-home { justify-content: flex-end; text-align: right; }
.team-away { justify-content: flex-start; }
.team-name { font-size: 13px; font-weight: 500; }
.team-crest-sm { width: 20px; height: 20px; object-fit: contain; flex-shrink: 0; }

.score-box { text-align: center; min-width: 90px; }
.score {
    font-family: 'DM Mono', monospace;
    font-size: 18px;
    font-weight: 500;
    color: var(--text);
    letter-spacing: 0.04em;
}
.match-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.match-competition { font-size: 10px; color: var(--text-dim); margin-top: 2px; letter-spacing: 0.02em; }

.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.halftime-score { font-size: 10.5px; color: var(--text-dim); margin-top: 2px; }

.goals-wrapper { padding: 0 18px 10px; }
.goals-list { font-size: 11px; color: var(--text-muted); line-height: 1.8; }
.goal-item {
    display: inline-block;
    margin-right: 10px;
    padding: 1px 0;
}
.goal-item::before {
    content: '';
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-dim);
    margin-right: 5px;
    vertical-align: middle;
}

/* ─── REFRESH / BACK BUTTONS ────────────────────────────────────────────── */
.refresh-btn, .back-btn {
    background: none;
    border: 1px solid var(--border-strong);
    color: var(--text-muted);
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: border-color 0.15s, color 0.15s;
}
.refresh-btn:hover, .back-btn:hover {
    border-color: var(--text-muted);
    color: var(--text);
}
.back-btn { margin-bottom: 20px; }

.auto-refresh-badge {
    font-size: 11px;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

/* ─── STANDINGS ─────────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
.standings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.standings-table th {
    text-align: left;
    color: var(--text-muted);
    padding: 9px 12px;
    border-bottom: 1px solid var(--border-strong);
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    white-space: nowrap;
}
.standings-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.standings-table tr:last-child td { border-bottom: none; }
.standings-table tbody tr:hover td { background: var(--surface-2); }

.pos { color: var(--text-muted); width: 28px; font-weight: 500; font-size: 12px; }
.team-crest { width: 16px; height: 16px; object-fit: contain; margin-right: 9px; vertical-align: middle; }
.points { font-weight: 600; color: var(--accent-text); font-variant-numeric: tabular-nums; }

.cl-zone { border-left: 2px solid #1c6fbf; }
.el-zone { border-left: 2px solid #92620a; }
.rel-zone { border-left: 2px solid var(--danger); }

.form-cell { display: flex; gap: 3px; }
.form-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}
.form-W { background: var(--success); }
.form-D { background: var(--text-dim); }
.form-L { background: var(--danger); }

.table-legend {
    margin-top: 14px;
    display: flex;
    gap: 18px;
    font-size: 11px;
    color: var(--text-muted);
}
.legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 5px;
    vertical-align: middle;
}
.legend-dot.cl { background: #1c6fbf; }
.legend-dot.el { background: #92620a; }
.legend-dot.rel { background: var(--danger); }

/* ─── SCORERS ────────────────────────────────────────────────────────────── */
.scorer-card {
    background: var(--surface);
    border-radius: 8px;
    padding: 13px 16px;
    margin-bottom: 3px;
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1px solid var(--border);
}
.scorer-rank {
    font-family: 'DM Mono', monospace;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-dim);
    min-width: 22px;
}
.scorer-crest { width: 26px; height: 26px; object-fit: contain; flex-shrink: 0; }
.scorer-info { flex: 1; min-width: 0; }
.scorer-name { font-weight: 500; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scorer-team { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.scorer-goals {
    font-family: 'DM Mono', monospace;
    font-size: 20px;
    font-weight: 500;
    color: var(--text);
    line-height: 1;
}
.scorer-assists { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ─── TEAM CARD ──────────────────────────────────────────────────────────── */
.team-card {
    background: var(--surface);
    border-radius: 8px;
    padding: 15px 18px;
    margin-bottom: 3px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: border-color 0.15s, background 0.15s;
}
.team-card:hover { background: var(--surface-2); border-color: var(--border-med); }
.team-crest-big { width: 38px; height: 38px; object-fit: contain; flex-shrink: 0; }
.team-info { flex: 1; min-width: 0; }
.team-info h3 { font-size: 14px; font-weight: 500; margin-bottom: 3px; }
.team-info p { font-size: 12px; color: var(--text-muted); }
.team-card-arrow { color: var(--text-dim); flex-shrink: 0; }

/* ─── TEAM DETAIL ────────────────────────────────────────────────────────── */
.team-detail-header {
    display: flex;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 24px;
    background: var(--surface);
    border-radius: 10px;
    padding: 20px;
    border: 1px solid var(--border-med);
}
.team-detail-crest { width: 60px; height: 60px; object-fit: contain; flex-shrink: 0; margin-top: 2px; }
.team-detail-info h2 { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.team-detail-meta {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
}
.meta-item { display: inline-block; }

.fav-action-btn {
    background: none;
    border: 1px solid var(--border-strong);
    color: var(--text-muted);
    padding: 4px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.15s;
}
.fav-action-btn:hover { border-color: var(--accent); color: var(--accent-text); }
.fav-action-btn.is-fav { background: var(--accent-light); color: var(--accent-text); border-color: transparent; }

/* ─── SQUAD ──────────────────────────────────────────────────────────────── */
.squad-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
    gap: 4px;
    margin-top: 6px;
}
.player-card {
    background: var(--surface);
    border-radius: 7px;
    padding: 11px 14px;
    border: 1px solid var(--border);
}
.player-name { font-size: 13px; font-weight: 500; }
.player-pos { font-size: 11px; color: var(--accent-text); margin-top: 3px; font-weight: 500; }
.player-nat { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.position-group-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.09em;
    margin: 20px 0 8px;
}

/* ─── TABS ───────────────────────────────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-strong);
}
.tab {
    padding: 9px 16px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
    user-select: none;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent-text); border-bottom-color: var(--accent); }

/* ─── FAVORITES ──────────────────────────────────────────────────────────── */
.favorites-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.favorites-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.fav-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 500;
    transition: all 0.15s;
}
.fav-chip:hover { border-color: var(--accent); color: var(--accent-text); }
.fav-chip img { width: 14px; height: 14px; object-fit: contain; }
.fav-remove {
    color: var(--text-dim);
    margin-left: 2px;
    display: flex;
    align-items: center;
    transition: color 0.15s;
}
.fav-remove:hover { color: var(--danger); }

/* ─── MODAL ──────────────────────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--surface);
    border-radius: 12px;
    padding: 26px;
    width: 100%;
    max-width: 480px;
    border: 1px solid var(--border-med);
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
}
.modal-close {
    position: absolute;
    top: 18px;
    right: 18px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 4px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}
.modal-close:hover { color: var(--text); background: var(--surface-2); }

.modal-competition {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 16px;
    padding-right: 32px;
}
.modal-teams {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    gap: 8px;
}
.modal-team { text-align: center; flex: 1; min-width: 0; }
.modal-team img { width: 42px; height: 42px; object-fit: contain; display: block; margin: 0 auto 8px; }
.modal-team-name { font-size: 13px; font-weight: 500; }
.modal-score {
    font-family: 'DM Mono', monospace;
    font-size: 30px;
    font-weight: 500;
    color: var(--text);
    text-align: center;
    flex: 0 0 auto;
    padding: 0 12px;
    letter-spacing: 0.04em;
}
.modal-ht { text-align: center; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.modal-date { text-align: center; font-size: 12px; color: var(--text-muted); margin-bottom: 20px; }
.modal-section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.09em;
    margin: 0 0 10px;
}
.modal-empty { text-align: center; color: var(--text-dim); font-size: 13px; padding: 12px 0; }

.goal-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.goal-row:last-child { border-bottom: none; }
.goal-minute {
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    color: var(--text-muted);
    min-width: 32px;
    font-weight: 500;
    padding-top: 1px;
}
.goal-type { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* ─── SKELETON ───────────────────────────────────────────────────────────── */
.skeleton {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    height: 56px;
    margin-bottom: 3px;
    overflow: hidden;
    position: relative;
}
.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 25%, var(--surface-2) 50%, transparent 75%);
    background-size: 200% 100%;
    animation: shimmer 1.6s infinite;
}
@keyframes shimmer { 0%{background-position:200%} 100%{background-position:-200%} }

/* ─── UTILS ──────────────────────────────────────────────────────────────── */
.loading {
    text-align: center;
    padding: 48px;
    color: var(--text-muted);
    font-size: 13px;
}
.empty {
    text-align: center;
    padding: 48px;
    color: var(--text-dim);
    font-size: 13px;
}

/* ─── RESPONSIVE ─────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    nav { padding: 0 14px; height: 50px; }
    .nav-btn { padding: 5px 9px; font-size: 12px; }
    .container { padding: 20px 14px; }
    .team-name { font-size: 12px; }
    .score { font-size: 16px; }
    .match-card { padding: 11px 14px; }
    .standings-table th:nth-child(n+5),
    .standings-table td:nth-child(n+5) { display: none; }
    .modal { padding: 20px; }
    .modal-score { font-size: 24px; }
}
