html {
    scrollbar-width: none;
}

body {
    -ms-overflow-style: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
    width: 0;
    height: 0;
}

/* Hide native scrollbars on containers that use the floating scrollbar */
[data-floating-scrollbar] {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE 10+ */
}

[data-floating-scrollbar]::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.floating-scrollbar {
    position: fixed;
    right: 10px;
    top: 84px;
    bottom: 14px;
    width: 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(8px);
    z-index: 140;
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.floating-scrollbar-thumb {
    position: absolute;
    left: 1px;
    right: 1px;
    top: 0;
    min-height: 36px;
    border-radius: 999px;
    background: linear-gradient(180deg, #79afff, #5a94ef);
    border: 1px solid #6ea8fe;
    cursor: grab;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.floating-scrollbar.visible {
    opacity: 1;
    pointer-events: auto;
}

.floating-scrollbar-thumb:active,
.floating-scrollbar.is-dragging .floating-scrollbar-thumb {
    cursor: grabbing;
    box-shadow: 0 0 0 4px rgba(0,0,0,0.08);
}

.floating-scrollbar.is-static .floating-scrollbar-thumb {
    border-color: var(--border);
    background: rgba(255, 255, 255, 0.12);
}

@media (max-width: 768px) {
    .floating-scrollbar {
        right: 6px;
        width: 8px;
    }
}

.quick-nav {
    flex-wrap: nowrap;
    overflow: visible;
    align-items: center;
    isolation: isolate;
}

.quick-nav > .quick-nav-btn,
.quick-nav > .quick-nav-more,
.quick-nav > .quick-nav-account {
    flex: 0 0 auto;
}

.quick-nav-account {
    margin-left: auto;
}

.quick-nav-more {
    position: relative;
    display: none;
    z-index: 1000;
}

.quick-nav-more-toggle {
    white-space: nowrap;
}

.quick-nav-more-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 180px;
    max-width: min(70vw, 260px);
    border: 1px solid var(--border);
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(18, 23, 32, 0.98), rgba(18, 23, 32, 0.92));
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(10px);
    padding: 8px;
    display: grid;
    gap: 6px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-2px);
    transition: opacity 0.28s ease, transform 0.28s ease, visibility 0s linear 0.28s;
    z-index: 1100;
}

.quick-nav-more.open .quick-nav-more-menu,
.quick-nav-more:hover .quick-nav-more-menu,
.quick-nav-more:focus-within .quick-nav-more-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
    transition-delay: 0s;
}

.quick-nav-more-menu .quick-nav-btn {
    width: 100%;
    justify-content: flex-start;
}

/* When the menu is portaled to <body> we use these helpers. */
.quick-nav-more-menu.portal {
    position: fixed;
    top: auto;
    left: auto;
    right: auto;
    transform: translateY(0);
    max-height: calc(100vh - 32px);
    overflow-y: auto;
}

.quick-nav-more-menu.portal-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
    transition-delay: 0s;
}

.password-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(5, 7, 11, 0.74);
    padding: 16px;
}

.password-content {
    width: min(560px, 100%);
    padding: 22px;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(18, 23, 32, 0.98), rgba(18, 23, 32, 0.94));
    box-shadow: 0 22px 44px rgba(0, 0, 0, 0.45);
    color: var(--text);
}

.password-content h2 {
    margin-bottom: 10px;
}

.password-buttons {
    margin-top: 10px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.password-btn {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px 12px;
    background: #1b2232;
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
}

.password-input {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.95rem;
    outline: none;
}

.password-input:focus {
    border-color: var(--primary, #6ea8fe);
}

.password-field-wrap {
    position: relative;
}

.password-field-wrap .password-input {
    padding-right: 44px;
}

.password-toggle-btn {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 999px;
    background: rgba(157, 196, 255, 0.12);
    color: #9dc4ff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.16s ease, color 0.16s ease;
}

.password-toggle-btn:hover {
    background: rgba(157, 196, 255, 0.24);
    color: #d6e6ff;
}

.password-toggle-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.password-generator-wrap {
    margin-top: 8px;
    display: flex;
    justify-content: flex-end;
}

.auth-mode-toggle-btn {
    border: none;
    background: transparent;
    color: #9dc4ff;
    font-size: 0.86rem;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}

.auth-mode-toggle-btn:hover {
    color: #c8dcff;
}

.user-profile-actions {
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.user-profile-actions .user-profile-logout-btn {
    margin-right: 0;
}

.user-profile-actions .password-btn {
    width: auto;
    min-width: 86px;
}

.cancel-btn {
    background: #1b2232;
    border: 1px solid var(--border);
    color: var(--text);
}

.user-profile-logout-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    background: linear-gradient(180deg, #ff9a9a, #ff7d7d);
    color: #230505;
    border-color: #ff7d7d;
}

.user-profile-content {
    width: min(980px, 100%);
    max-height: 92vh;
    overflow: auto;
    text-align: left;
}

/* Match bracket page scrollbar theme for profile modal containers on all pages */
.user-profile-content,
.user-profile-body,
.global-profile-modal-content,
.global-profile-modal-body {
    scrollbar-width: thin;
    scrollbar-color: rgba(110,168,254,0.72) transparent;
}

.user-profile-content::-webkit-scrollbar,
.user-profile-body::-webkit-scrollbar,
.global-profile-modal-content::-webkit-scrollbar,
.global-profile-modal-body::-webkit-scrollbar {
    width: 10px;
}

.user-profile-content::-webkit-scrollbar-track,
.user-profile-body::-webkit-scrollbar-track,
.global-profile-modal-content::-webkit-scrollbar-track,
.global-profile-modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.user-profile-content::-webkit-scrollbar-thumb,
.user-profile-body::-webkit-scrollbar-thumb,
.global-profile-modal-content::-webkit-scrollbar-thumb,
.global-profile-modal-body::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #79afff, #5a94ef);
    border-radius: 999px;
    border: 2px solid rgba(0,0,0,0.08);
}

.user-profile-body {
    margin-top: 8px;
}

.user-profile-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.user-profile-head-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-width: 0;
    text-align: left;
}

.user-profile-handle-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    width: 100%;
}

.user-profile-avatar {
    width: 44px;
    height: 44px;
    border-radius: 999px;
    border: 1px solid var(--border);
    object-fit: cover;
}

.user-profile-handle {
    font-size: 1.05rem;
    font-weight: 700;
    text-align: left;
}

.user-profile-rank {
    color: var(--muted);
    font-size: 0.9rem;
}

.user-presence {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    margin-top: 2px;
}

.presence-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    display: inline-block;
    background: #8a8f99;
}

.user-presence.status-active {
    color: #5acb8a;
}

.user-presence.status-active .presence-dot {
    background: #5acb8a;
}

.user-presence.status-offline {
    color: var(--muted);
}

.user-profile-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 8px;
}

.user-profile-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #141b27;
    padding: 8px 10px;
}

.user-profile-item span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    margin-bottom: 4px;
}

.user-profile-item strong {
    font-size: 0.95rem;
}

.user-profile-links {
    margin-top: 10px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.user-profile-links a {
    color: #9dc4ff;
    text-decoration: none;
    font-weight: 600;
}

.user-profile-links a:hover {
    text-decoration: underline;
}

.user-profile-site {
    margin-top: 10px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
}

.user-profile-site h4 {
    font-size: 0.9rem;
    margin-bottom: 8px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.user-stats-handle {
    color: #9dc4ff;
    text-decoration: none;
    font-weight: 600;
}

.user-stats-handle:hover {
    text-decoration: underline;
}

.user-recent-wrap {
    margin-top: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px;
    background: #141b27;
}

.user-recent-title {
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: 6px;
}

.user-recent-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.user-recent-item {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 8px;
    align-items: center;
    font-size: 0.86rem;
}

.user-recent-outcome {
    min-width: 22px;
    text-align: center;
    border-radius: 999px;
    padding: 1px 6px;
    border: 1px solid var(--border);
    font-weight: 700;
}

.user-recent-outcome.win {
    color: #5acb8a;
}

.user-recent-outcome.loss {
    color: #ff7d7d;
}

.user-recent-outcome.tie {
    color: #9dc4ff;
}

.user-recent-opponent {
    color: var(--text);
}

.user-recent-score {
    color: var(--muted);
}

.user-recent-link {
    color: #9dc4ff;
    text-decoration: none;
}

.user-recent-empty {
    color: var(--muted);
    font-size: 0.85rem;
}

.global-profile-modal {
    position: fixed;
    inset: 0;
    background: rgba(8, 11, 18, 0.72);
    backdrop-filter: blur(4px);
    z-index: 1200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 14px;
}

.global-profile-modal-content {
    width: min(780px, 100%);
    max-height: 90vh;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(18, 23, 32, 0.98), rgba(18, 23, 32, 0.94));
    box-shadow: 0 22px 44px rgba(0, 0, 0, 0.45);
    color: var(--text);
    padding: 14px;
}

/* Keep About page profile modal width aligned with the slimmer modal used elsewhere */
.about-page .global-profile-modal-content {
    width: min(560px, 100%);
}

.about-page .global-profile-modal-actions {
    justify-content: flex-end;
    gap: 10px;
}

.global-profile-modal-body {
    margin-top: 8px;
}

.global-profile-modal-actions {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.global-profile-modal-close {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    background: #1b2232;
    color: var(--text);
    cursor: pointer;
}

.global-profile-modal-logout {
    border: 1px solid #ff7d7d;
    border-radius: 10px;
    padding: 8px 12px;
    background: linear-gradient(180deg, #ff9a9a, #ff7d7d);
    color: #230505;
    cursor: pointer;
    font-weight: 700;
}

.global-profile-head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.global-profile-avatar {
    width: 54px;
    height: 54px;
    border-radius: 999px;
    border: 1px solid var(--border);
    object-fit: cover;
}

.global-profile-handle {
    font-size: 1.1rem;
    font-weight: 700;
}

.global-profile-rank,
.global-profile-presence {
    color: var(--muted);
    font-size: 0.88rem;
}

.global-profile-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(120px, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.global-profile-grid div {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.global-profile-grid span {
    color: var(--muted);
    font-size: 0.8rem;
}

.global-profile-links {
    margin-top: 10px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.global-profile-links a {
    color: #9dc4ff;
    text-decoration: none;
    font-weight: 600;
}

.global-profile-recent-wrap {
    margin-top: 10px;
}

.global-profile-recent-title {
    color: var(--muted);
    font-size: 0.84rem;
    margin-bottom: 6px;
}

.global-profile-recent-wrap ul {
    list-style: none;
    display: grid;
    gap: 6px;
}

.global-profile-recent-item,
.global-profile-recent-empty {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 8px;
    font-size: 0.84rem;
    color: var(--muted);
}

/* Unified profile modal visuals: force Arena modal look on every page. */
#userProfileModal.password-modal,
.global-profile-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(5, 7, 11, 0.74);
    padding: 16px;
}

#userProfileModal .password-content.user-profile-content,
.global-profile-modal .global-profile-modal-content {
    width: min(560px, 100%);
    max-height: min(90vh, 720px);
    padding: 22px;
    text-align: left;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0));
    backdrop-filter: blur(10px);
    border-radius: var(--radius, 16px);
    box-shadow: var(--shadow, 0 20px 40px rgba(0, 0, 0, 0.35));
    color: var(--text);
    overflow-y: auto;
}

#userProfileModal .user-profile-body,
.global-profile-modal .global-profile-modal-body {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel);
    padding: 12px;
    margin-top: 10px;
    max-height: min(62vh, 560px);
    overflow-y: auto;
}

#userProfileModal .password-buttons.user-profile-actions,
.global-profile-modal .password-buttons.user-profile-actions,
.global-profile-modal .global-profile-modal-actions {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Strong centering guard for profile modal on non-arena pages with local modal overrides. */
body > #userProfileModal.password-modal,
body > .global-profile-modal {
    position: fixed !important;
    inset: 0 !important;
    display: none;
    align-items: center !important;
    justify-content: center !important;
    padding: 16px !important;
}

body > #userProfileModal.password-modal > .password-content.user-profile-content,
body > .global-profile-modal > .global-profile-modal-content {
    width: min(560px, 100%) !important;
    max-height: min(90vh, 720px) !important;
    margin: 0 auto !important;
}

@media (max-width: 860px) {
    body > #userProfileModal.password-modal,
    body > .global-profile-modal {
        align-items: center !important;
        justify-content: center !important;
        padding: 10px !important;
    }
}
