:root {
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --secondary: #64748b;
    --accent: #10b981;
    --danger: #ef4444;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --font-sans: 'Inter', sans-serif;
    --font-display: 'Outfit', sans-serif;
    --radius: 12px;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-sans);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    padding-bottom: 60px;
}

/* Typography */
h1, h2, h3 { font-family: var(--font-display); }
h1 { font-size: 2rem; font-weight: 900; background: linear-gradient(to right, #3b82f6, #10b981); -webkit-background-clip: text; color: transparent; }
h2 { font-size: 1.5rem; margin-bottom: 1rem; }
h3 { font-size: 1.2rem; margin-bottom: 0.5rem; color: var(--text-muted); }

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

/* Header */
.app-header {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
    padding: 1rem;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

select {
    background: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 0.5rem;
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-weight: 600;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.third-status-banner {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--accent);
    color: var(--accent);
    border-radius: var(--radius);
    text-align: center;
    font-weight: 800;
    font-family: var(--font-display);
    font-size: 1.2rem;
}
.third-status-banner.error {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
    color: var(--danger);
}

/* Groups Grid */
.groups-section { margin-bottom: 2rem; }
.groups-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}
@media (min-width: 768px) {
    .groups-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
    .groups-grid { grid-template-columns: repeat(3, 1fr); }
}

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

.group-header {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.75rem 1rem;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
}

.team-row {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}
.team-row:last-child { border-bottom: none; }

.team-info {
    display: flex;
    align-items: center;
    flex: 1;
    gap: 0.75rem;
}
.flag {
    width: 24px; height: 18px; border-radius: 2px;
    object-fit: cover;
}

.team-actions {
    display: flex;
    gap: 0.25rem;
}
.pos-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.pos-btn:hover { background: rgba(255,255,255,0.1); }
.pos-btn.active-1 { background: #fbbf24; color: #000; border-color: #fbbf24; }
.pos-btn.active-2 { background: #9ca3af; color: #000; border-color: #9ca3af; }
.pos-btn.active-3 { background: #cd7f32; color: #fff; border-color: #cd7f32; }

/* Bracket */
.bracket-section { margin-bottom: 2rem; }
.bracket-round { margin-bottom: 2rem; }
.match-list { display: flex; flex-direction: column; gap: 1rem; }

@media (min-width: 768px) {
    .bracket-section {
        display: flex;
        gap: 1.5rem;
        overflow-x: auto;
        padding-bottom: 1rem;
    }
    .bracket-round { flex: 0 0 300px; }
}

.match-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
}

.match-team {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    transition: background 0.2s;
}
.match-team:last-child { border-bottom: none; }
.match-team:hover { background: rgba(255,255,255,0.1); }
.match-team.empty { cursor: not-allowed; opacity: 0.5; }
.match-team.winner { background: rgba(16, 185, 129, 0.2); border-left: 4px solid var(--accent); }

.match-team .flag { margin-right: 0.75rem; }
.match-team .name { font-weight: 600; flex: 1; }
.match-team .meta { font-size: 0.8rem; color: var(--text-muted); margin-left: 0.5rem; }

/* Champion */
.champion-section { text-align: center; }
.empty-champ {
    font-size: 3rem; color: var(--text-muted); font-weight: 900;
    padding: 2rem;
}
.champ-display {
    display: flex; flex-direction: column; align-items: center; gap: 1rem;
    padding: 2rem;
}
.champ-display .flag { width: 80px; height: 60px; border-radius: 8px; }
.champ-display .name { font-size: 2.5rem; font-weight: 900; color: #fbbf24; }

/* Buttons & Actions */
.actions-section {
    display: flex; flex-direction: column; gap: 1rem; margin-top: 2rem;
}
@media (min-width: 768px) {
    .actions-section { flex-direction: row; flex-wrap: wrap; justify-content: center; }
}
.btn {
    padding: 1rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    transition: opacity 0.2s, transform 0.1s;
    font-family: var(--font-sans);
}
.btn:hover { opacity: 0.9; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: var(--secondary); color: white; }
.btn-danger { background: var(--danger); color: white; }

.app-footer {
    margin-top: 4rem;
    text-align: center;
    padding: 2rem;
    border-top: 1px solid var(--border);
    display: flex; justify-content: center; gap: 1.5rem;
}
.app-footer a { color: var(--text-muted); text-decoration: none; font-size: 0.9rem; }
.app-footer a:hover { color: white; }
