:root {
    --bg-primary: #0f111a; /* Darker, more neutral navy for a professional look */
    --bg-secondary: #1a1c28; /* Slightly lighter for contrast */
    --bg-card: #252736; /* Subtle differentiation for cards */
    --text-primary: #f5f6fa; /* Crisp white for readability */
    --text-secondary: #b8bfd3; /* Softer secondary text for hierarchy */
    --accent-primary: #8b5cf6; /* Refined purple for primary actions */
    --accent-secondary: #facc15; /* Warmer gold for better harmony */
    --accent-live: #f87171; /* Softer red for live indicators */
    --border-color: #3f4657; /* Neutral border for subtle separation */
    --gradient-primary: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    --gradient-accent: linear-gradient(135deg, #facc15 0%, #eab308 100%);
    --shadow-primary: 0 4px 16px rgba(0, 0, 0, 0.3); /* Subtler shadow */
    --shadow-glow: 0 0 8px rgba(139, 92, 246, 0.2); /* Refined glow */
    --shadow-glow-accent: 0 0 8px rgba(250, 204, 21, 0.3); /* Matching accent glow */
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
}

#goalstream-livestream {
    max-width: 1280px; /* Slightly tighter for better alignment */
    margin: 0 auto;
    padding: 1.5rem;
    min-height: 100vh;
}

.header-section {
    text-align: center;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-primary);
}

.header-section h1 {
    font-size: 2.25rem; /* Slightly smaller for balance */
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

.branding {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--accent-secondary);
    margin-top: 0.5rem;
    animation: subtle-glow 2s ease-in-out infinite alternate;
}

@keyframes subtle-glow {
    from { text-shadow: 0 0 4px rgba(250, 204, 21, 0.3); }
    to { text-shadow: 0 0 8px rgba(250, 204, 21, 0.5); }
}

#search-container {
    margin: 1.5rem 0;
    text-align: center;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-primary);
}

#event-search {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: var(--bg-card);
    color: var(--text-primary);
    width: 100%;
    max-width: 24rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#event-search:focus {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

#event-search::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

#search-btn {
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--gradient-primary);
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    margin-left: 0.5rem;
    box-shadow: var(--shadow-primary);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#search-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

#events h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    background: var(--bg-secondary);
    padding: 1rem;
    margin: 2rem 0 1rem;
    text-align: center;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-primary);
}

.match-card-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
    gap: 1.25rem;
    padding: 0 0.5rem;
}

.match-card {
    background: var(--bg-card);
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: var(--shadow-primary);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    border: 1px solid var(--border-color);
}

.match-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-glow);
}

.match-card.live .match-card-header {
    background: var(--accent-live);
}

.match-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
}

.event-time {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.live-indicator {
    background: var(--accent-live);
    color: var(--text-primary);
    padding: 0.25rem 0.5rem;
    border-radius: 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    animation: subtle-pulse 2s ease infinite;
}

@keyframes subtle-pulse {
    0% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.5); }
    70% { box-shadow: 0 0 0 6px rgba(248, 113, 113, 0); }
    100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0); }
}

.match-card-body {
    padding: 1rem;
    text-align: center;
}

.event-details {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.event-flag {
    width: 1.75rem;
    vertical-align: middle;
    margin: 0 0.5rem;
}

.soon-indicator {
    font-size: 0.75rem;
    color: var(--accent-secondary);
    margin-top: 0.5rem;
    font-weight: 500;
}

.match-card-footer {
    padding: 0.75rem 1rem;
    text-align: center;
}

.watch-btn {
    width: 100%;
    background: var(--gradient-primary);
    color: var(--text-primary);
    border: none;
    padding: 0.75rem 1.25rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.watch-btn:hover {
    transform: scale(1.03);
    box-shadow: var(--shadow-glow);
}

.dropdown {
    display: none;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.75rem;
    margin: 0.5rem 0;
    z-index: 10;
    box-shadow: var(--shadow-primary);
}

.dropdown ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.dropdown li {
    margin: 0.5rem 0;
}

.dropdown a {
    display: block;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    background: var(--gradient-accent);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.dropdown a:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-glow-accent);
}

#backToTop {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--gradient-primary);
    color: var(--text-primary);
    border: none;
    border-radius: 2rem;
    cursor: pointer;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    font-size: 0.875rem;
    font-weight: 600;
}

#backToTop.visible {
    display: block;
    opacity: 1;
}

#backToTop:hover {
    transform: scale(1.1);
}

p {
    color: var(--text-primary);
    text-align: center;
    font-size: 1rem;
    margin: 1.5rem 0;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(1rem); }
    to { opacity: 1; transform: translateY(0); }
}

.match-card {
    animation: fadeInUp 0.4s ease forwards;
}

.match-card:nth-child(1) { animation-delay: 0.1s; }
.match-card:nth-child(2) { animation-delay: 0.15s; }
.match-card:nth-child(3) { animation-delay: 0.2s; }
.match-card:nth-child(4) { animation-delay: 0.25s; }

@media (max-width: 768px) {
    .match-card-container {
        grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
        gap: 1rem;
    }

    .header-section h1 {
        font-size: 1.75rem;
    }

    #event-search {
        max-width: 20rem;
        font-size: 0.875rem;
    }

    #search-btn {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }

    .match-card-header {
        padding: 0.625rem 0.75rem;
    }

    .event-time {
        font-size: 0.875rem;
    }

    .live-indicator {
        font-size: 0.625rem;
        padding: 0.2rem 0.4rem;
    }

    .event-details {
        font-size: 1rem;
    }

    .watch-btn {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }

    #events h2 {
        font-size: 1.5rem;
        padding: 0.75rem;
    }

    .dropdown a {
        font-size: 0.875rem;
        padding: 0.625rem 0.75rem;
    }
}

@media (max-width: 480px) {
    .match-card-container {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .header-section {
        padding: 1rem;
    }

    .header-section h1 {
        font-size: 1.25rem;
    }

    #events h2 {
        font-size: 1.25rem;
        padding: 0.625rem;
    }

    #event-search {
        max-width: 100%;
        font-size: 0.875rem;
        padding: 0.625rem;
    }

    #search-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    .dropdown a {
        font-size: 0.75rem;
        padding: 0.5rem 0.625rem;
    }
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-secondary);
}