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

:root {
    --bg: #0a0e17;
    --bg-card: #111827;
    --bg-card-hover: #1a2332;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --border: #1e293b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --green: #22c55e;
    --success-bg: #052e16;
    --bbc: #d62828;
    --itv: #1e3a8a;
    --gold: #f59e0b;
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

header {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    border-bottom: 1px solid var(--border);
    padding: 2rem 1rem;
    text-align: center;
}

.header-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(59,130,246,0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 50%, rgba(139,92,246,0.08) 0%, transparent 50%);
    pointer-events: none;
}

.header-content {
    position: relative;
    z-index: 1;
}

.header-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.logo-trophy {
    height: 4.5rem;
    width: auto;
    filter: drop-shadow(0 0 20px rgba(245,158,11,0.3));
    animation: trophy-glow 3s ease-in-out infinite;
}

@keyframes trophy-glow {
    0%, 100% { filter: drop-shadow(0 0 20px rgba(245,158,11,0.3)); }
    50% { filter: drop-shadow(0 0 30px rgba(245,158,11,0.5)); }
}

.logo-text h1 {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), #8b5cf6, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1rem;
    margin-top: 0.1rem;
}

nav.tabs {
    display: flex;
    gap: 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-btn {
    flex: 1;
    min-width: 100px;
    padding: 1rem 1.5rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text);
    background: rgba(255,255,255,0.03);
}

.tab-btn.active {
    color: var(--accent);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 1rem;
    right: 1rem;
    height: 3px;
    background: var(--accent);
    border-radius: 3px 3px 0 0;
}

main {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.5rem 1rem 4rem;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fade-in 0.2s ease;
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.tab-content h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text);
    font-weight: 700;
}

.match-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.match-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    transition: all 0.2s;
}

.match-card:hover {
    background: var(--bg-card-hover);
    border-color: #334155;
}

.match-stage {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.match-teams {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.team {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.team.home {
    text-align: right;
    align-items: flex-end;
}

.team.away {
    text-align: left;
    align-items: flex-start;
}

.team-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.team.winner .team-name {
    color: var(--green);
}

.team.loser {
    opacity: 0.5;
}

.team.loser .team-name {
    text-decoration: line-through;
    color: var(--text-muted);
}

.team.home .team-name {
    flex-direction: row-reverse;
}

.team-owner {
    font-size: 0.75rem;
    color: var(--owner-color, var(--text-muted));
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.score-preview {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
    flex-shrink: 0;
}

.score-final {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    font-size: 1.25rem;
    font-weight: 800;
}

.score {
    background: var(--bg);
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-sm);
    min-width: 2rem;
    text-align: center;
    color: var(--text);
}

.score-sep {
    color: var(--text-muted);
}

.match-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.match-tv {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
}

.match-tv.bbc {
    background: var(--bbc);
    color: white;
}

.match-tv.itv {
    background: var(--itv);
    color: white;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem 1rem;
    font-size: 0.95rem;
}

.standings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.group-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

.group-card h3 {
    font-size: 0.9rem;
    color: var(--accent);
    margin-bottom: 0.75rem;
    font-weight: 700;
}

.group-table {
    width: 100%;
    border-collapse: collapse;
}

.group-table th {
    text-align: center;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.25rem 0.2rem;
    font-weight: 600;
}

.group-table th:first-child, .group-table td:first-child {
    text-align: center;
    width: 1.2rem;
}

.group-table th:nth-child(2), .group-table td:nth-child(2) {
    text-align: left;
}

.group-table td {
    padding: 0.3rem 0.2rem;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    text-align: center;
    vertical-align: middle;
}

.group-table tr.eliminated {
    opacity: 0.45;
    text-decoration: line-through;
}

.group-table tr.eliminated td {
    text-decoration: line-through;
}

.team-cell {
    font-weight: 600;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.team-cell .flag,
.team-cell .flag-emoji {
    flex-shrink: 0;
}

.owner-indicator {
    display: inline-flex;
    align-items: center;
    margin-left: auto;
}

.owner-indicator .avatar-xs {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--owner-color);
    flex-shrink: 0;
}

.bracket-section {
    margin-bottom: 2rem;
}

.bracket-intro {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.bracket-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0.75rem;
}

.bracket-round {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

.bracket-round-title {
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 700;
    margin-bottom: 0.15rem;
}

.bracket-round-date {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 0.75rem;
}

.bracket-match {
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.bracket-match.done {
    border-color: var(--green);
}

.bracket-teams {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.bracket-team {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 600;
}

.bracket-team.loser {
    opacity: 0.5;
    text-decoration: line-through;
}

.bracket-score {
    background: var(--bg-card);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

.leaderboard {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.leaderboard-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    transition: all 0.2s;
}

.leaderboard-card:hover {
    background: var(--bg-card-hover);
}

.leaderboard-card:first-child {
    border-color: var(--gold);
    background: linear-gradient(135deg, #1a1508, #111827);
}

.lb-rank {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-muted);
    min-width: 2rem;
    text-align: center;
}

.leaderboard-card:first-child .lb-rank {
    color: var(--gold);
}

.lb-info {
    min-width: 120px;
}

.lb-info strong {
    display: block;
    font-size: 1rem;
}

.lb-count {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.lb-teams {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    flex: 1;
    justify-content: flex-end;
}

.lb-team-tag {
    font-size: 0.75rem;
    background: var(--bg);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.lb-team-tag.alive {
    border-color: var(--green);
    color: var(--green);
}

.lb-team-tag.eliminated {
    border-color: #ef4444;
    color: #ef4444;
    text-decoration: line-through;
    opacity: 0.6;
}

.teams-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.member-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all 0.2s;
}

.member-card:hover {
    border-color: #334155;
}

.member-header {
    padding: 1.25rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, color-mix(in srgb, var(--owner-color) 15%, transparent) 0%, transparent 100%);
}

.member-header h3 {
    font-size: 1.1rem;
    margin-top: 0.5rem;
    color: var(--owner-color, var(--text));
}

.team-count {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.member-teams {
    padding: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.member-team {
    font-size: 0.8rem;
    background: var(--bg);
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-sm);
    color: var(--text);
    border: 1px solid var(--border);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.flag {
    display: inline-block;
    width: 16px;
    height: 12px;
    vertical-align: middle;
    border-radius: 2px;
    flex-shrink: 0;
}

.flag-emoji {
    font-size: 1rem;
    line-height: 1;
    vertical-align: middle;
}

.avatar-sm {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.avatar-xs {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.avatar-md {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.avatar-lg {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--owner-color);
    flex-shrink: 0;
}

footer {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
}

.last-updated {
    font-size: 0.7rem;
    margin-top: 0.25rem;
    opacity: 0.7;
}

.footer-links {
    margin-top: 0.5rem;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.75rem;
}

.footer-links a:hover {
    color: var(--accent);
    text-decoration: underline;
}

@media (max-width: 600px) {
    .header-content h1 { font-size: 1.5rem; }
    .logo-trophy { height: 2.5rem; }
    .tab-btn { padding: 0.75rem 0.75rem; font-size: 0.8rem; min-width: 80px; }
    .match-teams { flex-direction: column; gap: 0.5rem; }
    .team.home, .team.away { text-align: center; align-items: center; }
    .team.home .team-name, .team.away .team-name { flex-direction: row; }
    .standings-grid { grid-template-columns: 1fr; }
    .teams-grid { grid-template-columns: 1fr; }
    .leaderboard-card { flex-wrap: wrap; }
    .lb-teams { justify-content: flex-start; margin-top: 0.5rem; }
}
