header {
    background-color: var(--header-bg-rgba); 
    padding: 8px 15px;
    position: fixed;
    top: 0;
    left: 50%; 
    transform: translateX(-50%); 
    z-index: 1000;
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.15); 
    border-bottom: none; 
    border-radius: 25px;
    backdrop-filter: blur(10px); 
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    width: calc(100% - 20px); /* Adjust width to prevent overflow */
    max-width: 95%;
    display: flex;
    align-items: center;
    min-height: 40px;
}

header .container {
    display: flex;
    justify-content: space-between; /* Distributes items along the main axis */
    align-items: center; /* Ensures vertical centering inside container */
    flex-wrap: wrap; /* Allows wrapping on smaller screens */
    padding: 0; 
    max-width: none; 
    width: 100%; 
    gap: 8px; /* Reduced gap for mobile */
}

header h1 {
    margin: 0;
    color: var(--text-dark); /* Changed to use var(--text-dark) for dark theme adaptability */
    font-size: 1.1em; /* Smaller for mobile */
    text-align: left;
}

header nav {
    flex-grow: 1; /* Nav will take available space between h1 and button */
    display: flex; /* Make nav a flex container */
    justify-content: flex-end; /* Align nav links to the right within the nav area */
    min-width: 0; /* Allows nav to shrink if necessary */
}

header nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap; 
    align-items: center; /* Align items vertically in the ul */
}

header nav ul li {
    margin-left: 15px; /* Reduced margin for mobile */
    margin-bottom: 0; /* Remove bottom margin */
}

header nav ul li a {
    color: var(--text-dark); /* Changed to new variable */
    text-decoration: none;
    font-weight: bold;
    font-size: 0.8em; /* Smaller for mobile */
    transition: color 0.3s ease;
}

header nav ul li a:hover {
    color: var(--accent-gold); /* Changed to new variable */
}

/* Mobile-first responsive adjustments */
@media (max-width: 768px) {
    header {
        top: 0; /* Adjusted */
        padding: 6px 12px; /* Even smaller for small screens */
        border-radius: 20px;
        width: calc(100% - 10px);
        min-height: 35px; /* Even smaller for small screens */
    }

    header .container {
        flex-direction: column; /* Stack items vertically */
        text-align: center;
        gap: 5px; /* Reduced gap */
    }

    header h1 {
        text-align: center; /* Center h1 when stacked */
        width: 100%; /* Take full width */
        font-size: 1em; /* Even smaller for small screens */
    }

    header nav {
        flex-grow: unset; /* Remove flex-grow when stacking */
        width: 100%; /* Take full width */
        justify-content: center; /* Center nav links */
        margin: 0; /* Remove horizontal margins */
    }

    header nav ul {
        justify-content: center; /* Center ul items */
        margin-top: 5px; /* Reduced margin */
    }

    header nav ul li {
        margin: 0 5px; /* Reduced margins */
        font-size: 0.75em; /* Even smaller for small screens */
    }
    
    .theme-toggle-btn {
        margin-left: 0; /* Remove left margin when stacked */
        margin-top: 8px; /* Reduced margin */
        width: 35px; /* Smaller button */
        height: 35px; /* Smaller button */
        font-size: 1em; /* Smaller icon */
    }
}