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

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
    color: #111;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ROOT VARIABLES */
:root {
    --accent: #4a61ff;
    --accent-dark: #3a4fd9;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --text: #111;
    --text-muted: #666;
    --card-bg: #fff;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
    --radius: 16px;
}

/* HEADER */
header {
    background: linear-gradient(135deg, var(--accent) 0%, #6366f1 50%, #8b5cf6 100%);
    box-shadow: 0 4px 20px rgba(74, 97, 255, 0.3);
    color: #fff;
    padding: 24px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.header-left h1 {
    margin: 0;
    font-size: clamp(1.5rem, 4vw, 2.2rem);
    font-weight: 700;
    letter-spacing: 0.5px;
}

.header-left .subtitle {
    margin-top: 4px;
    font-size: 0.9rem;
    opacity: 0.85;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* SELECT DROPDOWN */
header select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;

    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 999px;
    padding: 10px 40px 10px 16px;

    font-size: 0.9rem;
    font-family: inherit;
    font-weight: 600;

    color: #fff;
    background-color: rgba(255, 255, 255, 0.15);

    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23fff' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;

    cursor: pointer;
    transition: all 0.25s ease;
}

header select:hover {
    border-color: rgba(255, 255, 255, 0.6);
    background-color: rgba(255, 255, 255, 0.25);
}

header select:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.8);
}

header select option {
    color: var(--text);
    background: var(--card-bg);
}

/* Admin Button */
.admin-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    text-decoration: none;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.9rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    transition: all 0.25s ease;
}

.admin-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
}

/* MAIN CONTENT */
main {
    flex: 1;
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* TEAM GRID */
#teamGrid {
    display: grid;
    gap: 24px;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

/* Loading State */
.loading-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top-color: var(--accent);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* TEAM CARD */
.team-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.team-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent), #8b5cf6);
}

.team-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.15);
}

.team-card h2 {
    margin: 12px 0 8px;
    font-size: 1.3rem;
    color: var(--text);
}

/* Badge (Male / Female) */
.pill {
    display: inline-block;
    padding: 6px 14px;
    font-size: 0.8rem;
    border-radius: 999px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pill.male {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    color: #1e40af;
}

.pill.female {
    background: linear-gradient(135deg, #fce7f3, #fbcfe8);
    color: #be185d;
}

/* TEAM META INFO */
.team-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.team-meta span {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* EMPTY STATE */
.empty-state {
    grid-column: 1 / -1;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 60px 40px;
    text-align: center;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.empty-state h3 {
    margin: 0 0 8px;
    font-size: 1.5rem;
    color: var(--text);
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 24px;
}

.btn-primary {
    display: inline-block;
    padding: 12px 28px;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    color: #fff;
    text-decoration: none;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.25s ease;
    border: none;
    cursor: pointer;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(74, 97, 255, 0.35);
}

/* FOOTER */
footer {
    background: #1f2937;
    color: #9ca3af;
    padding: 20px 24px;
    text-align: center;
}

.footer-content {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 0.9rem;
}

.footer-content strong {
    color: var(--accent);
}

/* ==================== SECTIONS ==================== */
.matches-section,
.teams-section {
    margin-bottom: 32px;
}

.section-title {
    margin-bottom: 20px;
}

.section-title h2 {
    margin: 0;
    font-size: 1.4rem;
    color: var(--text);
}

/* ==================== MATCH CAROUSEL ==================== */
.matches-carousel {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 12px;
    scroll-snap-type: x mandatory;
}

.matches-carousel::-webkit-scrollbar {
    height: 6px;
}

.matches-carousel::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.matches-carousel::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
}

.match-card {
    flex: 0 0 280px;
    background: #ffffff;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    scroll-snap-align: start;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.match-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent), #8b5cf6);
}

.match-card.featured {
    flex: 0 0 320px;
    background: linear-gradient(135deg, var(--accent) 0%, #6366f1 100%);
    border: 2px solid rgba(99, 102, 241, 0.5);
    color: #fff;
}

.match-card.featured::before {
    height: 6px;
    background: linear-gradient(90deg, #fbbf24, #f59e0b);
}

.match-card.featured .match-team {
    background: rgba(255, 255, 255, 0.15);
}

.match-card.featured .team-name {
    color: #fff;
}

.match-card.featured .match-vs {
    color: rgba(255, 255, 255, 0.8);
}

.match-card.featured .match-pool {
    color: rgba(255, 255, 255, 0.7);
    border-top-color: rgba(255, 255, 255, 0.2);
}

.match-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}

.match-number {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--accent);
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.match-card.featured .match-number {
    color: #fbbf24;
}

.match-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.match-team {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.team-emoji {
    font-size: 1.2rem;
}

.match-team .team-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
}

.match-vs {
    text-align: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    padding: 4px;
}

.match-pool {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

.no-matches {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.05);
    border-radius: var(--radius);
}

/* PAST MATCHES */
.past-matches-section {
    margin-top: 40px;
}

.past-matches-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.past-match-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.past-match-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}

.past-match-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.past-match-header .pool-badge {
    background: var(--accent);
    color: #fff;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.completed-badge {
    font-size: 0.75rem;
    color: var(--success);
    font-weight: 600;
}

.past-match-teams {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.past-match-team {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 10px;
    transition: all 0.2s ease;
}

.past-match-team.winner {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.1) 0%, rgba(34, 197, 94, 0.05) 100%);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.past-match-team .team-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
    flex: 1;
}

.past-match-team .team-score {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--accent);
    margin: 0 12px;
}

.past-match-team.winner .team-score {
    color: var(--success);
}

.winner-badge {
    font-size: 1.2rem;
}

/* RESPONSIVE */
@media (max-width: 640px) {
    header {
        padding: 16px;
        flex-direction: column;
        text-align: center;
    }
    
    .header-right {
        width: 100%;
        justify-content: center;
    }
    
    main {
        padding: 16px;
    }
    
    #teamGrid {
        grid-template-columns: 1fr;
    }
    
    .matches-carousel {
        gap: 12px;
    }
    
    .past-matches-grid {
        grid-template-columns: 1fr;
    }
    
    .match-card {
        flex: 0 0 260px;
    }
    
    .match-card.featured {
        flex: 0 0 280px;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 8px;
    }
    
    .footer-content span:nth-child(2),
    .footer-content span:nth-child(4) {
        display: none;
    }
}
