/* Base Styles */
:root {
    --primary-color: #1e88e5;
    --secondary-color: #ff5722;
    --dark-color: #212121;
    --light-color: #f5f5f5;
    --winner-color: #4caf50;
    --loser-color: #f44336;
    --overlay-bg: rgba(0, 0, 0, 0.7);
    --overlay-light: rgba(255, 255, 255, 0.15);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--light-color);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    padding-bottom: 200px; /* Reduced padding for more compact featured sadness */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    position: relative;
    z-index: 10;
}

/* Fullscreen Background Image */
.fullscreen-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    overflow: hidden;
}

.fullscreen-bg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    transition: opacity 0.5s ease;
}

/* Header Styles */
header {
    background-color: rgba(30, 136, 229, 0.8);
    color: white;
    padding: 10px 0;
    position: relative;
    z-index: 10;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

header h1 {
    font-size: 2.5rem;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

/* Main Content */
main {
    padding: 30px 0;
    position: relative;
    z-index: 5;
}

section {
    margin-bottom: 40px;
    background-color: var(--overlay-bg);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
}

section h2 {
    color: var(--light-color);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--overlay-light);
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}

/* Navigation Toggle Button */
.nav-toggle-btn {
    position: fixed;
    top: 20px; /* Adjusted position since header is hidden */
    right: 20px;
    z-index: 100;
    background-color: var(--secondary-color);
    color: white;
    padding: 10px 15px;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    transition: all 0.3s;
    border: none; /* Ensure default button styles are removed */
    font-family: inherit; /* Use the same font as the rest of the site */
    font-size: 1rem;
}

.nav-toggle-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.nav-toggle-btn:hover {
    background-color: #e64a19;
    transform: translateY(-2px);
}

.nav-toggle-btn i {
    margin-right: 8px;
    animation: spin 6s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Navigation Overlay */
.nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 99999; /* Just below the navigator but above everything else */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none; /* Don't capture clicks when invisible */
    /* Force a new stacking context */
    will-change: opacity;
}

.nav-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto; /* Capture clicks when active */
}

/* Featured Sadness - now at bottom */
#featured-sadness {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50; /* Lower than tournament navigator and overlay */
    margin: 0 auto;
    max-width: 800px;
    padding: 0 20px 10px 20px;
}

.game-info {
    margin-bottom: 1px;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.8);
    border-radius: 6px 6px 0 0;
    backdrop-filter: blur(10px);
}

.teams {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.team {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    border-radius: 4px;
    flex: 1;
    max-width: 47%;
}

.team-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
}

.winner {
    background-color: rgba(76, 175, 80, 0.3);
    border-left: 3px solid var(--winner-color);
}

.loser {
    background-color: rgba(244, 67, 54, 0.3);
    border-left: 3px solid var(--loser-color);
}

.vs {
    font-weight: bold;
    padding: 0 8px;
    font-size: 0.9rem;
}

.score {
    font-weight: bold;
    font-size: 1.3rem;
}

.game-date {
    text-align: center;
    font-style: italic;
    color: var(--light-color);
    opacity: 0.8;
    font-size: 0.9rem;
    margin-top: -2px;
}

.sadness-text {
    background-color: rgba(0, 0, 0, 0.8);
    padding: 15px;
    border-radius: 0;
    backdrop-filter: blur(10px);
}

.sadness-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.sadness-text h3 {
    color: var(--secondary-color);
    font-size: 1.6rem;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.7);
    margin: 0;
    flex-grow: 1;
    padding-right: 10px;
}

.share-btn {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.share-btn:hover {
    background-color: #e64a19;
    transform: scale(1.1);
}

.share-btn i {
    font-size: 1rem;
}

.sadness-text p {
    font-size: 1rem;
    line-height: 1.6;
}

/* Tournament Navigator - now slides in */
#tournament-navigator {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 90%;
    max-width: 500px;
    background-color: #000000;
    z-index: 100000; /* Ultra high z-index to ensure it's on top */
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.4s ease-in-out;
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.8);
    padding: 20px;
    /* Force a new stacking context */
    will-change: transform;
    isolation: isolate;
}

#tournament-navigator.visible {
    transform: translateX(0);
    pointer-events: auto; /* Ensure it can be interacted with */
}

#tournament-navigator.hidden {
    transform: translateX(100%);
    pointer-events: none; /* Prevent interactions when hidden */
}

/* Generic hidden class for other elements */
.hidden {
    display: none !important;
}

.nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--overlay-light);
    padding-bottom: 15px;
}

.close-nav-btn {
    background: var(--overlay-light);
    color: white;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
}

.close-nav-btn:hover {
    background-color: var(--secondary-color);
}

.rounds-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.round-btn {
    padding: 8px 15px;
    background-color: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--light-color);
}

.round-btn:hover {
    background-color: rgba(255, 255, 255, 0.25);
}

.round-btn.active {
    background-color: var(--primary-color);
    color: white;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
    max-height: 700px;
    overflow-y: auto;
    padding-right: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--overlay-light) transparent;
}

/* Styling for WebKit scrollbar */
.games-grid::-webkit-scrollbar {
    width: 8px;
}

.games-grid::-webkit-scrollbar-track {
    background: transparent;
}

.games-grid::-webkit-scrollbar-thumb {
    background-color: var(--overlay-light);
    border-radius: 4px;
}

.games-grid::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.round-info {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--light-color);
    padding-bottom: 10px;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--overlay-light);
}

.round-info h3 {
    font-size: 1.3rem;
    margin: 0;
    color: var(--secondary-color);
}

.round-info .game-count {
    background-color: var(--overlay-light);
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 0.85rem;
}

.date-header {
    grid-column: 1 / -1;
    color: var(--light-color);
    font-weight: bold;
    margin-top: 15px;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--overlay-light);
    font-size: 1.1rem;
}

.game-card {
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s, border-color 0.3s;
    background-color: rgba(0, 0, 0, 0.5);
    position: relative;
}

.game-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.game-card.active-card {
    border-color: var(--secondary-color);
    box-shadow: 0 0 15px var(--secondary-color);
    transform: translateY(-5px);
}

.game-card.active-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background-color: var(--secondary-color);
    z-index: 1;
}

.game-card-header {
    padding: 8px 10px;
    background-color: rgba(30, 136, 229, 0.7);
    color: white;
    text-align: center;
    font-size: 0.9rem;
}

.game-card-header h3 {
    font-size: 0.95rem;
    margin: 0;
}

.game-card-body {
    padding: 10px 15px;
}

.mini-team {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.95rem;
}

.mini-team:last-child {
    border-bottom: none;
}

.mini-loser {
    color: var(--loser-color);
}

.mini-team .team-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
}

.mini-team .score {
    font-weight: bold;
    min-width: 30px;
    text-align: right;
}

.view-sadness-btn {
    display: block;
    width: 100%;
    padding: 6px;
    margin-top: 8px;
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
    text-align: center;
    text-decoration: none;
    font-size: 0.9rem;
}

.view-sadness-btn:hover {
    background-color: #e64a19;
}

/* Footer removed */

/* Pre-Tournament State */
#pre-tournament-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 30px;
}

.coming-soon-section {
    background-color: rgba(0, 0, 0, 0.8);
    padding: 20px 30px;
    border-radius: 6px;
    backdrop-filter: blur(5px);
    border-left: 4px solid var(--secondary-color);
    max-width: 500px;
}

.coming-soon-title {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--secondary-color);
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
    letter-spacing: 1px;
}

.countdown-text {
    font-size: 1.2rem;
    color: var(--light-color);
    opacity: 0.9;
}

#countdown-days {
    font-weight: bold;
    font-size: 1.4rem;
    color: var(--light-color);
}

.slideshow-controls {
    display: flex;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.8);
    padding: 10px 15px;
    border-radius: 30px;
    backdrop-filter: blur(5px);
}

.slideshow-btn {
    background-color: var(--secondary-color);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    margin: 0 10px;
    transition: transform 0.2s, background-color 0.2s;
}

.slideshow-btn:hover {
    background-color: #e64a19;
    transform: scale(1.1);
}

.slideshow-caption {
    color: var(--light-color);
    padding: 0 15px;
    max-width: 300px;
    text-align: center;
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    #pre-tournament-container {
        flex-direction: column;
        align-items: center;
        padding: 20px;
        gap: 20px;
    }
    
    .coming-soon-section {
        width: 100%;
        max-width: none;
        padding: 15px 20px;
    }
    
    .coming-soon-title {
        font-size: 1.8rem;
    }
    
    .slideshow-controls {
        width: 100%;
        justify-content: center;
    }
    
    .teams {
        flex-direction: row; /* Keep horizontal layout even on mobile */
        gap: 5px;
    }
    
    .team {
        max-width: 45%;
    }
    
    .vs {
        margin: 0;
        padding: 0 5px;
        font-size: 0.8rem;
    }
    
    .team-name {
        font-size: 0.9rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 65%;
    }
    
    .score {
        font-size: 1.1rem;
    }
    
    .sadness-text h3 {
        font-size: 1.4rem;
    }
    
    .sadness-text p {
        font-size: 0.95rem;
    }
    
    .rounds-selector {
        justify-content: center;
    }
}