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

:root {
    --bg-primary: #0a1628;
    --bg-secondary: #0f1f38;
    --bg-card: #152240;
    --bg-card-hover: #1a2d52;
    --green: #00a859;
    --green-light: #00d474;
    --gold: #f5a623;
    --gold-light: #ffc107;
    --text-primary: #e8edf2;
    --text-secondary: #8a9bb5;
    --text-muted: #5a6d85;
    --border: #1e3050;
    --win: #00d474;
    --lose: #e74c3c;
    --draw: #f5a623;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

html { font-size: 16px; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    background-image:
        radial-gradient(ellipse at 50% 0%, rgba(0,168,89,0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 100%, rgba(245,166,35,0.05) 0%, transparent 50%);
}

/* ── Header ── */
.header {
    background: linear-gradient(180deg, var(--bg-secondary) 0%, rgba(15,31,56,0.95) 100%);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}
.header-top {
    padding: 16px 20px 10px;
    text-align: center;
}
.logo {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--gold-light), var(--green-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.header-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ── Countdown Banner ── */
.countdown-banner {
    background: linear-gradient(135deg, rgba(0,168,89,0.12), rgba(245,166,35,0.08));
    border-bottom: 1px solid var(--border);
    padding: 7px 16px;
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-secondary);
    animation: fadeInDown 0.3s ease-out;
}
.countdown-banner strong {
    color: var(--text-primary);
}
.countdown-banner .countdown-flag {
    width: 20px;
    height: 14px;
    vertical-align: middle;
    border-radius: 2px;
    object-fit: cover;
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
    margin: 0 2px;
}
.countdown-banner .countdown-time {
    color: var(--gold-light);
    font-weight: 700;
}
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Tabs ── */
.team-select-wrapper {
    padding: 6px 12px 4px;
}
.team-select {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238a9bb5' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}
.team-select:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 2px rgba(0,168,89,0.2);
}
.team-select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

.tabs {
    display: flex;
    gap: 0;
    padding: 0 12px;
}
.tab {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    padding: 12px 8px;
    cursor: pointer;
    position: relative;
    transition: color 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tab:hover { color: var(--text-primary); }
.tab.active {
    color: var(--green-light);
}
.tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20%;
    right: 20%;
    height: 3px;
    background: var(--green);
    border-radius: 3px 3px 0 0;
}

/* ── Content ── */
.main-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px 12px 40px;
}

.hidden { display: none !important; }

/* ── Loader ── */
.loader {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
}
.spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--border);
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error ── */
.error {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}
.error button {
    margin-top: 16px;
    background: var(--green);
    color: #fff;
    border: none;
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
}

/* ── Section Headers ── */
.section-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--gold);
    padding: 20px 4px 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    scroll-margin-top: 150px;
}
.section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}
.section-title.highlight {
    animation: titleHighlightPulse 1.5s ease-in-out 2;
}
@keyframes titleHighlightPulse {
    0%, 100% { color: var(--gold); text-shadow: none; }
    50% { color: var(--gold-light); text-shadow: 0 0 16px rgba(245,166,35,0.6); }
}

/* ── Match Card ── */
.match-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    transition: background 0.2s;
}
.match-card:hover { background: var(--bg-card-hover); }
.match-card.live {
    border-color: var(--green);
    box-shadow: 0 0 12px rgba(0,168,89,0.15);
}
.match-card.finished {
    opacity: 0.85;
}
.match-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.match-group {
    background: rgba(0,168,89,0.15);
    color: var(--green-light);
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.match-status {
    font-weight: 600;
}
.match-status.live {
    color: var(--green-light);
    animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
.match-status.finished {
    color: var(--text-muted);
}

.match-body {
    display: flex;
    align-items: center;
    gap: 8px;
}
.match-team {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
    flex: 1;
    min-width: 0;
}
.match-team.match-right {
    justify-content: flex-end;
}
.match-team img {
    width: 26px;
    height: 18px;
    border-radius: 2px;
    object-fit: cover;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.match-team-name {
    font-size: 0.9rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.match-team.winner .match-team-name {
    color: var(--text-primary);
}
.match-team.loser .match-team-name {
    color: var(--text-muted);
}
.match-team-code {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-left: 4px;
}
.match-score {
    text-align: center;
    min-width: 56px;
    flex-shrink: 0;
}
.match-score .score {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 2px;
}
.match-score .score.half {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 1px;
    margin-top: 2px;
}
.match-vs {
    text-align: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    min-width: 56px;
    flex-shrink: 0;
}

/* ── Goals ── */
.goals-list {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-secondary);
}
.goal-entry {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
}
.goal-minute {
    background: var(--bg-secondary);
    padding: 1px 5px;
    border-radius: 3px;
    font-weight: 700;
    font-size: 0.7rem;
    min-width: 26px;
    text-align: center;
}
.goal-icon {
    font-size: 0.65rem;
}
.goals-columns {
    display: flex;
    gap: 8px;
}
.goals-col {
    flex: 1;
    min-width: 0;
}
.goals-col-center {
    min-width: 56px;
    flex-shrink: 0;
}
.goals-col-right .goal-entry {
    flex-direction: row-reverse;
}

/* ── Standings ── */
.standings-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}
@media (min-width: 700px) {
    .standings-grid {
        grid-template-columns: 1fr 1fr;
    }
}
@media (min-width: 1024px) {
    .standings-grid {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

.group-table-container {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}
.group-table-title {
    background: linear-gradient(135deg, rgba(0,168,89,0.2), rgba(0,168,89,0.05));
    padding: 10px 14px;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--green-light);
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}
.group-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}
.group-table th {
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 4px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}
.group-table th:first-child { text-align: left; padding-left: 14px; }
.group-table th:nth-child(2) { width: 24px; }
.group-table td {
    padding: 5px 4px;
    text-align: center;
    border-bottom: 1px solid rgba(30,48,80,0.5);
}
.group-table td:first-child { text-align: left; padding-left: 14px; }
.group-table td:nth-child(2) { width: 24px; color: var(--text-muted); font-size: 0.7rem; }
.group-table .team-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}
.group-table .team-cell img {
    width: 22px;
    height: 15px;
    border-radius: 2px;
    object-fit: cover;
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.group-table .team-name {
    font-weight: 500;
}
.group-table .pts {
    font-weight: 700;
    color: var(--text-primary);
}
.qualify-zone {
    border-left: 3px solid var(--green);
}

.group-table-container.highlight {
    animation: highlightPulse 1.5s ease-in-out 2;
}
@keyframes highlightPulse {
    0%, 100% { border-color: var(--border); box-shadow: none; }
    50% { border-color: var(--gold); box-shadow: 0 0 18px rgba(245,166,35,0.4); }
}

/* ── No Results ── */
.no-data {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ── Footer ── */
.footer {
    text-align: center;
    padding: 20px;
    font-size: 0.7rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}
.footer a {
    color: var(--green-light);
    text-decoration: none;
}

/* ── Responsive ── */
@media (max-width: 480px) {
    .header-top { padding: 12px 16px 8px; }
    .logo { font-size: 1.25rem; }
    .countdown-banner { font-size: 0.7rem; padding: 6px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .main-content { padding: 12px 8px 32px; }
    .match-team-name { font-size: 0.82rem; }
    .match-score .score { font-size: 1.1rem; }
}
