header {
    position: fixed;
    top: 20px;
    left: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    align-items: center;
    padding: 7px 25px;
    background-image: url('../images/header_background_blured3.webp');
    background-size: cover;
    background-position: center;
    border-radius: 25px;
    transition: all 0.3s ease-in-out;
}
header.header-active {
    top: 0;
    left: 0;
    right: 0;
    border-radius: 0;
}
header h1 {
    font-weight: normal;
}
header .title a {
    color: var(--white);
    font-size: 25px;
    margin-left: 20px;
    white-space: nowrap;
    text-decoration: none;
}
.nav-bar {
    margin-left: auto;
    margin-right: 20px;
}
.nav-bar ul {
    list-style: none;
    display: flex;
    border-bottom: 2px solid var(--white);
    padding: 0;
    margin: 0;
}
.nav-bar li a {
    display: block;
    color: var(--white);
    padding: 7px 20px;
    font-size: 18px;
    transition: background-color 0.3s ease;
    text-decoration: none;
}
.nav-bar li.active a {
    background-color: var(--white);
    color: var(--black);
}
header .fa-bars {
    display: none;
    color: var(--white);
    font-size: 30px;
    cursor: pointer;
    margin-left: auto;
    transition: transform 0.2s ease;
    background: transparent;
    border: none;
    padding: 0;
}
header .fa-bars.fa-times {
    transform: rotate(180deg);
}
.header-actions {
    position: absolute;
    bottom: -32px;
    right: 40px;
    display: flex;
    gap: 10px;
    transition: right 0.3s ease-in-out, bottom 0.3s ease-in-out;
}
header.header-active .header-actions {
    right: 25px;
}
.header-actions button {
    width: 60px;
    height: 30px;
    background-image: url('../images/background-button.webp');
    background-size: cover;
    background-position: center;
    color: var(--white);
    border: 2px solid var(--white);
    border-top: none;
    border-radius: 0 0 50px 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: opacity 0.3s ease-in-out, transform 0.4s ease-out, box-shadow 0.3s ease, filter 0.3s ease;
    padding-bottom: 4px;
    box-sizing: content-box;
}
.header-actions button.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
}
.nav-bar-mobile {
    position: fixed;
    top: 95px;
    z-index: 999;
    background-image: url('../images/header_background_blured3.webp');
    background-size: cover;
    border-radius: 25px;
    opacity: 0;
    transform: translateY(-120%);
    pointer-events: none;
    transition: transform 0.4s ease-out, opacity 0.3s ease-out, top 0.3s ease-in-out, right 0.3s ease-in-out, border-radius 0.3s ease-in-out;
    right: 20px;
    width: max-content;
    overflow: hidden;
    padding: 0;
}
header.header-active ~ .nav-bar-mobile {
    top: 56px;
    border-radius: 0;
    right: 0;
}
.nav-bar-mobile.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.nav-bar-mobile ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0;
}
.nav-bar-mobile li a {
    display: block;
    color: var(--white);
    padding: 10px 20px;
    font-size: 18px;
    transition: background-color 0.3s ease;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}
.nav-bar-mobile li:last-child a {
    border-bottom: none;
}
.no-results {
    text-align: center;
    color: var(--text-subtle);
    padding: 4rem 1rem;
}
.no-results p {
    position: relative;
    top: 15rem;
    font-size: 1.5rem;
    color: white;
}
main {
    transition: padding-top 0.4s ease-out;
}
footer {
    text-align: center;
    padding: 0 50px 20px;
}
footer img {
    width: 100px;
    vertical-align: middle;
    margin: 20px;
    filter: grayscale(1) opacity(0.5);
}
footer .footer-legal {
    max-width: 800px;
    width: 90%;
    margin: 0 auto;
    font-size: 0.7em;
    text-transform: uppercase;
    color: var(--light-grey);
    line-height: 1.5;
    font-weight: normal;
}
footer .footer-legal a {
    color: var(--light-grey);
}
@media (hover: hover) and (pointer: fine) {
    .nav-bar li:not(.active):hover a,
    .nav-bar-mobile li:not(.active):hover a {
        background-color: var(--light-grey);
    }
    header:not(.header-active) ~ .widget-panel .profile-options li:last-child a,
    header:not(.header-active) ~ .widget-panel .leaderboard-options li:last-child a {
        border-bottom-left-radius: 25px;
        border-bottom-right-radius: 25px;
    }
    .header-actions button:hover {
        transform: translateY(2px);
        box-shadow: 0 6px 16px rgba(0,0,0,0.3);
        filter: brightness(1.2);
    }
}
@media (max-width: 900px) {
    .nav-bar { display: none; }
    header .fa-bars { display: block; }
    .header-actions { right: 15px; gap: 8px; bottom: -27px; }
    .header-actions button { width: 45px; height: 25px; font-size: 16px; padding-bottom: 3px; }
    footer .footer-legal { width: 100%; }
    footer img { width: 70px; }
}

.widget-panel {
    position: fixed;
    top: 95px;
    z-index: 999;
    background-image: url('../images/header_background_blured3.webp');
    background-size: cover;
    background-position: center;
    border-radius: 25px;
    opacity: 0;
    transform: translateY(-120%);
    pointer-events: none;
    transition: transform 0.4s ease-out, opacity 0.3s ease-out, top 0.3s ease-in-out, left 0.3s ease-in-out, right 0.3s ease-in-out, border-radius 0.3s ease-in-out;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
    overflow: visible;
    padding: 0;
}
.widget-panel.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
header.header-active ~ .widget-panel {
    top: 56px;
    border-radius: 0;
}
.profile-panel, .leaderboard-panel {
    right: 20px;
    width: 260px;
    min-width: 220px;
}
.search-panel {
    left: 20px;
    right: 20px;
    padding: 15px 25px;
}
header.header-active ~ .profile-panel,
header.header-active ~ .leaderboard-panel {
    right: 0;
}
header.header-active ~ .search-panel {
    left: 0;
    right: 0;
}
.panel-icon {
    color: var(--white);
    font-size: 24px;
}
#close-leaderboard-btn, #close-profile-btn, #close-filter-btn {
    background: transparent;
    border: none;
    color: var(--white);
    font-size: 20px;
    cursor: pointer;
    margin-left: auto;
}
.profile-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}
.profile-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}
.profile-username {
    color: var(--white);
    font-weight: bold;
    margin-right: auto;
    flex-grow: 1;
}
.profile-options {
    list-style: none;
    padding: 0;
    margin: 0;
}
.profile-options li a {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    color: var(--white);
    text-decoration: none;
    transition: background-color 0.2s ease;
}
.leaderboard-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}
.leaderboard-content {
    overflow-y: auto;
    padding: 3px 0;
}
.leaderboard-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.leaderboard-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    background-color: rgba(255, 255, 255, 0.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    margin: 4px 8px;
    border-radius: 8px;
}
.leaderboard-item .rank {
    flex-basis: 35px;
    flex-shrink: 0;
    font-weight: bold;
    font-size: 0.95rem;
}
.leaderboard-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 10px;
    border: none;
}
.leaderboard-item .username {
    flex-grow: 1;
    text-align: left;
    color: var(--white);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.95rem;
}
.leaderboard-item .score {
    font-weight: bold;
    color: var(--white);
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: 8px;
    font-size: 0.95rem;
}
.leaderboard-item.podium-1 .rank, .leaderboard-item.podium-1 .score { color: var(--podium-gold); }
.leaderboard-item.podium-2 .rank, .leaderboard-item.podium-2 .score { color: var(--podium-silver); }
.leaderboard-item.podium-3 .rank, .leaderboard-item.podium-3 .score { color: var(--podium-bronze); }
.leaderboard-item.current-user-podium-border { border: 1px solid; box-shadow: 0 0 6px 2px rgba(255, 255, 255, 0.7); }
.leaderboard-item.podium-1.current-user-podium-border { border-color: var(--podium-gold); box-shadow: 0 0 5px 2px var(--podium-gold); }
.leaderboard-item.podium-2.current-user-podium-border { border-color: var(--podium-silver); box-shadow: 0 0 5px 2px var(--podium-silver); }
.leaderboard-item.podium-3.current-user-podium-border { border-color: var(--podium-bronze); box-shadow: 0 0 5px 2px var(--podium-bronze); }
.leaderboard-separator {
    height: 1px;
    background-color: rgba(255, 255, 255, 0.2);
    margin: 8px 12px;
}
.leaderboard-item.current-user {
    background-color: rgba(146, 22, 168, 0.2);
}
.leaderboard-options {
    list-style: none;
    padding: 0;
    margin: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}
.leaderboard-options li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px;
    color: var(--white);
    text-decoration: none;
    transition: background-color 0.2s ease;
}
#search-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
    display: none;
}
.search-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
    width: 100%;
}
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background-color: var(--card-bg);
    border-radius: 5px;
    flex-grow: 1;
    border: 1px solid #555;
    min-width: 150px;
}
#search-input {
    width: 100%;
    background-color: transparent;
    border: none;
    color: #fff;
    font-size: 1rem;
    outline: none;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
}
#clear-search-btn {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
#clear-search-btn.visible {
    opacity: 1;
    pointer-events: auto;
}
.custom-select-wrapper {
    position: relative;
    user-select: none;
    flex: 1 1 180px;
    min-width: 150px;
}
.custom-select {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--card-bg);
    border-radius: 5px;
    padding: 0.5rem 0.75rem;
    border: 1px solid #555;
    cursor: pointer;
}
.custom-select.open {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}
.custom-select-trigger {
    color: #fff;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.custom-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--card-bg);
    border: 1px solid #555;
    border-top: none;
    border-bottom-left-radius: 5px;
    border-bottom-right-radius: 5px;
    z-index: 10;
    display: none;
    max-height: 200px;
    overflow-y: auto;
}
.custom-options.open {
    display: block;
}
.custom-option {
    padding: 0.5rem 0.75rem;
    color: #fff;
    cursor: pointer;
    transition: background-color 0.2s;
}
@media (max-width: 768px) {
    .search-header {
        flex-direction: column;
        align-items: stretch;
    }
}
@media (hover: hover) and (pointer: fine) {
    .profile-options li a:hover,
    .leaderboard-options li a:hover {
        background-color: var(--light-grey);
    }
    .custom-option:hover {
        background-color: var(--light-grey);
    }
}