/* ── Base Typography ── */
html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
    min-height: 100%;
}

/* Skip link: visible on focus for keyboard users */
.skip-link {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
    z-index: 9999;
    padding: 0.5rem 1rem;
    background: var(--brand-primary);
    color: #fff;
    font-weight: var(--font-weight-semibold);
    text-decoration: none;
    border-radius: var(--radius-sm);
}

.skip-link:focus {
    left: 0.75rem;
    top: 0.75rem;
    width: auto;
    height: auto;
    overflow: visible;
    outline: 2px solid #fff;
    outline-offset: 2px;
}

body {
    font-family: var(--font-family-base);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-normal);
    line-height: var(--line-height-normal);
    color: var(--text-primary);
    overflow-x: auto;
    background-color: var(--surface-page);
    margin-bottom: 80px;
}

/* Default link color inside primary content */
main a:not(.btn):not(.nav-link):not(.profile-nav-item):not(.profile-box):not(.live-stream-badge):not(.live-badge-link) {
    color: var(--link-color);
}

main a:not(.btn):not(.nav-link):not(.profile-nav-item):not(.profile-box):not(.live-stream-badge):hover {
    color: var(--link-hover-color);
}

/* ── Heading Hierarchy ── */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-family-heading);
    font-weight: var(--font-weight-semibold);
    line-height: var(--heading-line-height);
    letter-spacing: var(--heading-letter-spacing);
    color: var(--text-primary);
    margin-top: 0;
}

h1 {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
}

h2 {
    font-size: var(--font-size-xl);
}

h3 {
    font-size: var(--font-size-lg);
}

h4 {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
}

/* Slightly larger headings on desktop */
@media (min-width: 768px) {
    h1 {
        font-size: var(--font-size-3xl);
    }

    h2 {
        font-size: var(--font-size-2xl);
    }

    h3 {
        font-size: var(--font-size-xl);
    }
}

/* ── Breadcrumbs: subtle styling ── */
.breadcrumb {
    font-size: 0.8rem;
    --bs-breadcrumb-divider-color: var(--border-strong);
    --bs-breadcrumb-item-active-color: var(--text-muted);
    padding: 0.25rem 0.75rem;
    background: var(--surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}

.breadcrumb-item a {
    color: var(--text-muted);
    text-decoration: none;
}

.breadcrumb-item a:hover {
    color: var(--text-secondary);
}

/* Reduce space between breadcrumb and main content */
.app-main {
    margin-top: 0.25rem;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 var(--focus-ring-offset) #fff, 0 0 0 calc(var(--focus-ring-offset) + var(--focus-ring-width)) var(--focus-ring-color);
}

/* High-quality focus-visible for keyboard users (modern, token-driven) */
:focus-visible {
    outline: none;
    box-shadow: 0 0 0 var(--focus-ring-offset) #fff, 0 0 0 calc(var(--focus-ring-offset) + var(--focus-ring-width)) var(--focus-ring-color);
    border-radius: var(--radius-sm);
}

.profile-nav-item:focus-visible,
.rating-chip:focus-visible,
.report-issue-link:focus-visible,
.live-stream-badge:focus-visible {
    box-shadow: 0 0 0 var(--focus-ring-offset) #fff, 0 0 0 calc(var(--focus-ring-offset) + var(--focus-ring-width)) var(--focus-ring-color);
    transform: none; /* prevent conflicting hover lifts */
}

@media (max-width: 575.98px) {
    body {
        margin-bottom: 100px;
    }
}

body.chat-layout {
    margin-bottom: 0;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}


.live-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: #e00;
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
}  


/*------------------------------------------*/
.player-profile {
    max-width: 900px;
    margin: auto;
    padding: 20px;
}

.profile-content {
    margin: 0 auto;
    max-width: 900px;
}

@media (max-width: 600px) {
    .profile-content {
        max-width: 100%;
    }
}

.header {
    display: flex;
    align-items: center;
    background: #f3f3f3;
    padding: 15px;
    border-radius: 8px;
    gap: 20px;
}

.avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 3px solid #ddd;
}

.player-info {
    flex-grow: 1;
}

    .player-info h1 {
        font-size: var(--font-size-2xl);
        font-weight: var(--font-weight-bold);
        margin: 0 0 0.5rem;
        letter-spacing: var(--heading-letter-spacing);
    }

    .player-info p {
        margin: 5px 0;
        font-size: 16px;
    }

.bio, .stats {
    margin-top: 10px;
    background: #fff;
    padding: 5px;
    border-radius: 8px;
    border: 1px solid #ddd;
}

    .stats ul {
        list-style: none;
        padding: 0;
    }

    .stats li {
        padding: 5px 0;
    }

@media (max-width: 600px) {
    .header {
        flex-direction: column;
        text-align: center;
    }

    .avatar {
        width: 100px;
        height: 100px;
    }
}


/* ── Profile Navigation (clean tab bar) ── */
.profile-nav {
    display: flex;
    gap: 0.25rem;
    margin: 0.75rem 0 1rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -ms-overflow-style: none;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 0.25rem;
}

/* Hide scrollbar visually while preserving horizontal scroll on mobile */
.profile-nav::-webkit-scrollbar {
    display: none;
}

.profile-nav-item {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.9rem;
    font-size: 0.875rem;
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    scroll-snap-align: start;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.profile-nav-item:hover {
    color: var(--brand-primary);
    background-color: var(--surface-muted);
    text-decoration: none;
}

.profile-nav-item:focus-visible {
    color: var(--brand-primary);
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--focus-ring-color);
}

.profile-nav-item.active {
    color: var(--brand-primary);
    font-weight: var(--font-weight-semibold);
    border-bottom: 3px solid var(--brand-primary);
    margin-bottom: -3px; /* visually aligns with container border */
    border-radius: 0;
}

.profile-nav-item i {
    font-size: 1rem;
    color: var(--brand-accent);
}

.profile-nav-item.active i {
    color: var(--brand-primary);
}

/* Mobile: stack items instead of horizontal scroll on small screens */
@media (max-width: 575.98px) {
    .profile-nav {
        flex-wrap: wrap;
        overflow-x: visible;
        scroll-snap-type: none;
        -webkit-overflow-scrolling: auto;
        border-bottom: none;
        padding-bottom: 0;
        gap: 0.125rem;
        margin: 0.5rem 0 0.75rem;
    }

    .profile-nav-item {
        padding: 0.35rem 0.6rem;
        font-size: 0.8rem;
        flex: 1 1 auto;
        justify-content: center;
    }

    .profile-nav-item.active {
        margin-bottom: 0;
        border-bottom: none;
        border-radius: var(--radius-sm);
        background-color: var(--brand-primary);
        color: #fff;
    }

    .profile-nav-item.active i {
        color: #fff;
    }
}

.coach-badge-dot {
    width: 10px;
    height: 10px;
    background: var(--status-loss);
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px #fff;
}

.profile-nav-item.active .coach-badge-dot {
    background: #fff;
}



/* Bio and Coach sections — editorial reading column */
#bio {
    margin: 0;
    padding: 0.5rem 0.25rem;
    font-family: var(--font-family-serif);
    font-size: 1.15rem;
    line-height: var(--line-height-relaxed);
    color: var(--text-primary);
    max-width: 68ch;
    margin: 0 auto;
}

#bio p {
    margin: 0 0 1rem;
}

/* Drop cap on the opening paragraph */
#bio > p:first-of-type::first-letter,
#bio > div:first-of-type > p:first-of-type::first-letter {
    float: left;
    font-family: var(--font-family-serif);
    font-size: 3.6rem;
    line-height: 0.9;
    font-weight: var(--font-weight-semibold);
    color: var(--accent-editorial);
    padding: 0.35rem 0.6rem 0 0;
}

#bio h2, #bio h3 {
    font-family: var(--font-family-base);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--accent-editorial);
    margin: 1.75rem 0 0.5rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border-subtle);
}

#bio h2:first-child, #bio h3:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

#bio ul, #bio ol {
    padding-left: 1.25rem;
    margin: 0 0 1rem;
}

#coach {
    margin: 0;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background-color: var(--surface-muted);
    padding: 0.85rem;
}

/* ── Content Table of Contents (shared by bio, coach, term) ── */
.content-toc {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.content-toc-toggle {
    display: contents;
    background: none;
    border: none;
    padding: 0;
    cursor: default;
    width: 100%;
    text-align: left;
}

.content-toc-chevron {
    display: none;
}

.content-toc-title {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.content-toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
}

.content-toc-list li {
    margin: 0;
}

.content-toc-list a {
    display: inline-block;
    padding: 0.2rem 0;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 1px dotted var(--text-light);
    transition: color 0.15s ease, border-color 0.15s ease;
}

.content-toc-list a:hover {
    color: var(--text-primary);
    border-bottom-color: var(--text-primary);
}

.content-toc-list .content-toc-h3 {
    padding-left: 1rem;
    font-size: var(--font-size-xs);
}

/* ── Content Section Styles (shared by bio, coach, term) ── */
#bio .section,
#bio > div > .section,
#coach .section,
#term-definition .section {
    margin-bottom: 0.25rem;
}

#coach h2, #term-definition h2 {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    margin-top: 1.75rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e2e8f0;
    scroll-margin-top: 1rem;
}

#coach h2:first-child,
#term-definition h2:first-child {
    margin-top: 0;
}

#coach h3, #term-definition h3 {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
    padding-left: 0.75rem;
    border-left: 3px solid #e2e8f0;
    scroll-margin-top: 1rem;
}

#bio h4 {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
    margin-top: 1rem;
    margin-bottom: 0.35rem;
}

#bio p, #coach p, #term-definition p {
    margin-bottom: 0.75rem;
    line-height: var(--line-height-relaxed);
}

#bio ul, #bio ol,
#coach ul, #coach ol,
#term-definition ul, #term-definition ol {
    margin-bottom: 0.75rem;
    padding-left: 1.25rem;
}

#bio li, #coach li, #term-definition li {
    margin-bottom: 0.35rem;
    line-height: var(--line-height-normal);
}

@media (max-width: 575.98px) {
    #bio, #coach {
        padding: 0.5rem;
    }

    .content-toc {
        padding: 0.75rem 1rem;
    }

    .content-toc-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .content-toc-title {
        margin-bottom: 0;
    }

    .content-toc-chevron {
        display: block;
        font-size: var(--font-size-sm);
        color: var(--text-muted);
        transition: transform 0.25s ease;
    }

    .content-toc-expanded .content-toc-chevron {
        transform: rotate(180deg);
    }

    .content-toc-list {
        flex-direction: column;
        gap: 0.15rem;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease, margin-top 0.3s ease;
        margin-top: 0;
    }

    .content-toc-expanded .content-toc-list {
        max-height: 500px;
        margin-top: 0.5rem;
    }

    #coach h2, #term-definition h2 {
        font-size: var(--font-size-lg);
        margin-top: 1.25rem;
    }

    #coach h3, #term-definition h3 {
        font-size: var(--font-size-base);
        margin-top: 1rem;
    }
}

@media (min-width: 768px) {
    #bio, #coach {
        padding: 1.25rem;
    }

    #coach h2, #term-definition h2 {
        font-size: var(--font-size-2xl);
    }

    #coach h3, #term-definition h3 {
        font-size: var(--font-size-xl);
    }
}

.chart-container {
    background: var(--surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.75rem 0.5rem;
    margin-bottom: 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.chart-container:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
}

.chart-container svg {
    width: 100%;
    height: auto;
    min-width: 220px;
    font-family: var(--font-family-base);
}

.chart-container svg text {
    user-select: none;
}

/* Donut charts */
.donut-chart-item {
    width: 140px;
    flex-shrink: 0;
}

.donut-svg {
    width: 100%;
    height: auto;
    font-family: var(--font-family-base);
}

.donut-legend-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Mobile: smaller donuts and tighter layout */
@media (max-width: 575.98px) {
    .donut-chart-item {
        width: 110px;
    }

    .chart-container {
        padding: 8px 4px;
    }

    .chart-container svg {
        min-width: 280px;
    }
}

/* Simple chessboard using Unicode pieces */
.simple-chessboard {
    position: relative;
    display: grid;
    grid-template-columns: 20px repeat(8, 40px);
    grid-template-rows: repeat(8, 40px) 20px;
    border: 1px solid #333;
    width: 340px;
}

    .simple-chessboard .square {
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
    }

        .simple-chessboard .square .piece {
            width: 100%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
        }

            .simple-chessboard .square .piece svg {
                width: 100%;
                height: 100%;
                
                align-items: center;
                justify-content: center;
                filter: drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.5));
            }

    .simple-chessboard .coord {
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 12px;
        user-select: none;
    }

    .simple-chessboard .light {
        background-color: var(--board-light-color);
    }

    .simple-chessboard .dark {
        background-color: var(--board-dark-color);
    }

    .simple-chessboard .highlight {
        background-color: var(--board-highlight-color);
        box-shadow: inset 0 0 8px 2px var(--board-highlight-border);
        position: relative;
    }
    
        .simple-chessboard .highlight::after {
            content: '';
            position: absolute;
            inset: 0;
            border: 2px solid var(--board-highlight-border);
            pointer-events: none;
            border-radius: 2px;
        }

.arrow-overlay {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.chess-viewer {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

    .chess-viewer .move-panel {
        max-height: 340px;
        overflow-y: auto;
    }

    .chess-viewer .move-list {
        list-style: decimal;
        padding-left: 1.2rem;
    }

    .chess-viewer .move-list button {
        background: none;
        border: none;
        padding: 0;
        cursor: pointer;
    }

    .chess-viewer .move-list button.current {
        font-weight: bold;
    }

    .chess-viewer .viewer-controls {
        margin-top: 0.5rem;
        display: flex;
        gap: 0.5rem;
    }

.arrow-overlay .arrow-line {
    stroke: var(--arrow-color);
    stroke-width: var(--arrow-stroke-width, 5);
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
}

.arrow-overlay .arrow-head {
    fill: var(--arrow-color);    
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
}


.chat-window {
    height: 60vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    border: 1px solid var(--border-subtle);
    background: var(--surface-elevated);
    border-radius: var(--radius-md);
}

.chat-bubble {
    margin-bottom: 0.75rem;
    max-width: 80%;
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-md);
}

    .chat-bubble.user {
        background-color: var(--status-win-soft);
        color: var(--text-primary);
        margin-left: auto;
    }

    .chat-bubble.assistant {
        background-color: var(--surface-muted);
        color: var(--text-primary);
        margin-right: auto;
    }

    .chat-bubble.with-avatar {
        display: flex;
        align-items: flex-start;
    }

        .chat-bubble.with-avatar .avatar {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            margin-right: .5rem;
        }

        .chat-bubble.with-avatar.user {
            flex-direction: row-reverse;
        }

            .chat-bubble.with-avatar.user .avatar {
                margin-right: 0;
                margin-left: .5rem;
            }

        .chat-bubble.with-avatar .content-wrapper {
            max-width: 100%;
        }

    .chat-bubble .timestamp {
        font-size: 0.7rem;
        color: var(--text-muted);
        display: flex;
        justify-content: space-between;
        margin-top: 0.25rem;
    }

    .chat-bubble .status {
        margin-left: 0.5rem;
    }

    .chat-bubble .content {
        overflow-wrap: anywhere;
    }

.chat-header {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--surface-elevated);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.chat-header .coach-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    margin-right: 0.5rem;
    border: 1px solid var(--border-subtle);
}

.chat-header .coach-name {
    font-weight: 600;
    margin-right: auto;
    color: var(--text-primary);
}

.chat-header .new-session {
    font-size: 0.85rem;
    color: var(--brand-primary);
}

.loading {
    margin-top: .5rem;
}

.typing-indicator {
    font-style: italic;
    color: var(--text-muted);
    margin-top: 0.5rem;
    margin-right: auto;
    max-width: 80%;
    font-size: 0.85rem;
}

.options-container {
    margin-bottom: .5rem;
}

#chatForm textarea,
#chatForm #sendBtn {
    height: 3.125rem;
}

.online-indicator {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 6px;
    background-color: var(--status-win);
    border-radius: 50%;
}

.coach-intro {
    margin-bottom: 1rem;
}

.coach-portrait {
    max-width: 96px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-sm);
}

.live-streamer-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.4rem;
    margin-left: 0.25rem;
    vertical-align: middle;
}

/* ── Profile Header: Compact Modern Design ── */
.profile-header-compact {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.profile-header-top {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.profile-header-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 2px solid var(--border-subtle);
    object-fit: cover;
    flex-shrink: 0;
}

.profile-header-info {
    flex: 1;
    min-width: 0;
}

.profile-eyebrow {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--accent-editorial);
    margin-bottom: 0.25rem;
}

.profile-header-name {
    font-family: var(--font-family-serif);
    font-size: var(--font-size-3xl);
    font-weight: var(--font-weight-semibold);
    letter-spacing: -0.015em;
    margin: 0 0 0.35rem;
    line-height: 1.1;
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.5rem;
    overflow-wrap: anywhere;
}

.profile-header-title-badge {
    display: inline-block;
    background: var(--surface-muted);
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    line-height: 1;
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    border: 1px solid var(--border-subtle);
}

.profile-header-title-badge:hover {
    background: var(--brand-accent-soft);
    color: var(--brand-primary-hover);
    border-color: var(--brand-accent);
}

.profile-header-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-bottom: 0.2rem;
}

.profile-header-meta > *:not(:last-child)::after {
    content: '\00b7';
    margin: 0 0.35rem;
    color: var(--text-light);
}

.profile-header-meta a {
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 1px dotted var(--text-light);
}

.profile-header-meta a:hover {
    color: var(--text-primary);
}

.profile-header-wow {
    font-size: 0.65rem;
    color: var(--status-win);
}


.profile-header-record-detail {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
}

.profile-record-wins {
    color: var(--status-win);
}

.profile-record-losses {
    color: var(--status-loss);
}

.profile-record-draws {
    color: var(--status-draw);
}

.profile-header-ratings {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.25rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border-subtle);
}

.rating-chip {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    background: var(--surface-elevated);
    border: 1px solid var(--border-subtle);
    border-top: 3px solid var(--chip-accent, var(--border-strong));
    border-radius: var(--radius-md);
    padding: 0.45rem 0.65rem;
    min-width: 120px;
    flex: 1 1 120px;
    max-width: 170px;
    box-shadow: var(--shadow-sm);
}

.rating-chip-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.rating-chip-top .rating-chip-value {
    font-size: 1.05rem;
    font-weight: var(--font-weight-bold);
    text-align: right;
    white-space: nowrap;
    line-height: 1.1;
    color: var(--text-primary);
}

.rating-chip-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.rating-chip-icon {
    font-size: var(--font-size-sm);
    color: var(--chip-accent, var(--text-secondary));
}

.rating-chip-label {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-wide);
}

.rating-chip-value {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    line-height: var(--line-height-tight);
}

.rating-chip-record {
    display: inline-flex;
    gap: 0.35rem;
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    white-space: nowrap;
    font-weight: var(--font-weight-semibold);
}

.rating-chip-record-win {
    color: var(--status-win);
}

.rating-chip-record-loss {
    color: var(--status-loss);
}

.rating-chip-record-draw {
    color: var(--status-draw);
}

.rating-chip-bullet {
    --chip-accent: var(--rating-chip-bullet);
    background: linear-gradient(180deg, var(--rating-chip-bullet-soft), transparent 38%), var(--surface-elevated);
}

.rating-chip-blitz {
    --chip-accent: var(--rating-chip-blitz);
    background: linear-gradient(180deg, var(--rating-chip-blitz-soft), transparent 38%), var(--surface-elevated);
}

.rating-chip-rapid {
    --chip-accent: var(--rating-chip-rapid);
    background: linear-gradient(180deg, var(--rating-chip-rapid-soft), transparent 38%), var(--surface-elevated);
}

.rating-chip-daily {
    --chip-accent: var(--rating-chip-daily);
    background: linear-gradient(180deg, var(--rating-chip-daily-soft), transparent 38%), var(--surface-elevated);
}

@media (max-width: 575.98px) {
    .profile-header-top {
        flex-wrap: wrap;
    }

    .profile-header-avatar {
        width: 48px;
        height: 48px;
    }

    .profile-header-name {
        font-size: 1.6rem;
    }

    .profile-header-record {
        flex-direction: row;
        gap: 0.5rem;
        width: 100%;
        margin-left: 0;
        margin-top: 0.5rem;
        padding: 0.4rem 0.6rem;
        min-width: unset;
    }

    .profile-header-record-percentage {
        font-size: 1.1rem;
    }

    .profile-header-ratings {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .rating-chip {
        max-width: none;
        min-width: 0;
        padding: 0.4rem 0.55rem;
        gap: 0.2rem;
    }

    .rating-chip-value {
        font-size: var(--font-size-base);
    }

    .rating-chip-top {
        gap: 0.35rem;
    }
}

/* ── Year filter buttons (profile rating page) ── */
.year-filter-container {
    margin-bottom: 0.75rem;
}

.year-filter-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.year-filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.year-filter-btn {
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
    border: 1px solid var(--border-subtle);
    background: var(--surface-elevated);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.year-filter-btn:hover {
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.year-filter-btn.active {
    background: var(--brand-primary);
    color: #fff;
    border-color: var(--brand-primary);
}

/* ── Live Stream Badge ── */
.live-stream-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, var(--status-live), #9f1239);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.45rem 1rem;
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--status-live) 30%, transparent);
}

.live-stream-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px color-mix(in srgb, var(--status-live) 45%, transparent);
    color: #fff;
    text-decoration: none;
}

.live-stream-badge:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(220, 53, 69, 0.3);
}

.live-stream-dot {
    width: 8px;
    height: 8px;
    background: #fff;
    border-radius: 50%;
    flex-shrink: 0;
    animation: live-pulse 1.5s ease-in-out infinite;
}

@keyframes live-pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.6); }
    50% { opacity: 0.4; box-shadow: 0 0 0 4px rgba(255, 255, 255, 0); }
}

.live-stream-label {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    line-height: 1;
}

.live-stream-text {
    font-weight: 500;
}

.live-stream-icon {
    font-size: 0.7rem;
    opacity: 0.7;
}

/* ── Report Issue (subtle secondary action) ── */
.report-issue-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: color 0.15s ease, background-color 0.15s ease;
    margin-top: 0.5rem;
}

.report-issue-link:hover,
.report-issue-link:focus-visible {
    color: var(--status-loss);
    background-color: var(--status-loss-soft);
    text-decoration: none;
}

.report-issue-link i {
    font-size: 0.85em;
}

/* ── Ratings Overview Section (Peak + Trends combined) ── */
.ratings-overview-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
}

.rating-overview-card {
    background: var(--surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    min-width: 180px;
    flex: 1 1 200px;
    max-width: 260px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    position: relative;
    overflow: hidden;
}

.rating-overview-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--accent-color);
    opacity: 0.65;
}

.rating-overview-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
}

.rating-overview-card.elite {
    border-color: #d97706;
    border-width: 2px;
    background: linear-gradient(160deg, #fffaf0 0%, var(--surface-elevated) 60%);
}

.rating-overview-card.advanced {
    border-color: #2563eb;
    border-width: 2px;
    background: linear-gradient(160deg, #eff6ff 0%, var(--surface-elevated) 60%);
}

.rating-overview-card.intermediate {
    border-color: var(--status-win);
    border-width: 2px;
    background: linear-gradient(160deg, #f0fdf4 0%, var(--surface-elevated) 60%);
}

.rating-overview-card.beginner {
    border-color: var(--status-draw);
    border-width: 1.5px;
}

.rating-overview-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.rating-overview-icon {
    font-size: 1.5rem;
    color: var(--accent-color);
    opacity: 0.9;
}

.rating-overview-label {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-wide);
}

.rating-overview-body {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
}

.rating-overview-current,
.rating-overview-peak {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.rating-overview-current-label,
.rating-overview-peak-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: var(--font-weight-medium);
}

.rating-overview-current-value {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    line-height: 1.2;
}

.rating-overview-peak-value {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    line-height: 1.2;
}

.rating-overview-peak-date {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.rating-overview-trends {
    display: flex;
    gap: 1rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-subtle);
}

.rating-change-item {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.change-period {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: var(--font-weight-medium);
}

.change-value {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    display: flex;
    align-items: center;
    gap: 0.15rem;
}

.change-value.positive {
    color: var(--status-win);
}

.change-value.negative {
    color: var(--status-loss);
}

.change-value i {
    font-size: 0.75rem;
}

@media (max-width: 575.98px) {
    .ratings-overview-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    .rating-overview-card {
        max-width: none;
        min-width: 0;
        padding: 0.75rem 1rem;
    }

    .rating-overview-icon {
        font-size: 1.25rem;
    }

    .rating-overview-current-value {
        font-size: 1.25rem;
    }

    .rating-overview-peak-value {
        font-size: 1.1rem;
    }
}

/* ── Monthly Rating Charts ── */
.monthly-chart-container {
    margin-bottom: 0.75rem;
}

.monthly-chart-container:last-child {
    margin-bottom: 0;
}

.monthly-rating-chart {
    min-width: 400px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-subtle);
    background: var(--surface-elevated);
    transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.monthly-rating-chart:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

/* ── Win/Loss/Draw Donut Charts ── */
.donut-charts-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: flex-start;
    margin-top: 1rem;
    padding: 1rem;
    background: var(--surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.donut-chart-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 130px;
}

.donut-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem;
    margin-top: 0.25rem;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.donut-legend-item {
    display: flex;
    align-items: center;
    gap: 0.2rem;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

@media (max-width: 575.98px) {
    .donut-charts-row {
        gap: 1rem;
        padding: 0.75rem;
        justify-content: center;
    }

    .donut-chart-item {
        width: 100px;
    }

    .donut-legend {
        font-size: 0.65rem;
    }
}

/* ── Games Activity Chart ── */
.activity-chart-container {
    margin-top: 1rem;
}

.activity-chart {
    min-width: 320px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-subtle);
    background: var(--surface-elevated);
    transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.activity-chart:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

/* ── Peak / Multi-line Rating Chart (used in trends) ── */
.rating-chart {
    min-width: 420px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-subtle);
    background: var(--surface-elevated);
    transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.rating-chart:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

/* Chart SVG internal text & lines for crisper, consistent visuals */
.monthly-rating-chart text,
.activity-chart text,
.rating-chart text {
    font-family: var(--font-family-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.monthly-rating-chart line,
.activity-chart line,
.rating-chart line {
    shape-rendering: crispEdges;
}

/* ── Section Headers with Icons ── */
#rating h2 i,
#peak-ratings h2 i,
#rating-trends h2 i,
#monthly-rating h2 i,
#win-loss-draw h2 i,
#games-activity h2 i {
    margin-right: 0.5rem;
    color: var(--text-muted);
}

/* ── Openings Performance Table ── */
.openings-win {
    color: var(--status-win);
}

.openings-loss {
    color: var(--status-loss);
}

.openings-draw {
    color: var(--status-draw);
}

.openings-progress {
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--surface-muted);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
}

.openings-progress > div {
    height: 100%;
    transition: width 0.25s ease;
}

.openings-progress-win {
    background: var(--status-win);
}

.openings-progress-draw {
    background: var(--status-draw);
}

.openings-progress-loss {
    background: var(--status-loss);
}

.openings-name-cell {
    max-width: 180px;
}

/* Better visual feedback when hovering opening rows with progress charts */
.table-hover tbody tr:hover .openings-progress {
    box-shadow: 0 0 0 1px var(--border-strong);
    transition: box-shadow 0.1s ease;
}

/* Insights Page Styling */
.insight-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.25rem;
    align-items: start;
}

.insight-card {
    background: var(--surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.insight-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
}

.insight-card h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-subtle);
    letter-spacing: -0.01em;
}

.insight-card ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.insight-card li {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.9rem;
    gap: 1rem;
}

.insight-card li:last-child {
    border-bottom: none;
}

.insight-card li strong {
    color: var(--text-primary);
    flex-shrink: 0;
}

.insight-metric {
    font-weight: 700;
    color: var(--brand-primary);
    background: var(--surface-muted);
    padding: 0.1rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    white-space: nowrap;
}

.insight-metric.positive {
    color: var(--status-win);
    background: var(--status-win-soft);
}

.insight-metric.negative {
    color: var(--status-loss);
    background: var(--status-loss-soft);
}

.insight-page-header {
    margin-bottom: 1.5rem;
}

.insight-page-header h1 {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.insight-page-header p {
    max-width: 60ch;
    margin-left: auto;
    margin-right: auto;
}

@media (max-width: 767.98px) {
    .insight-grid {
        grid-template-columns: 1fr;
    }

    .insight-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

.insight-table {
    width: 100%;
    border-collapse: collapse;
}

.insight-table th,
.insight-table td {
    padding: 0.45rem 0.6rem;
    border-bottom: 1px solid var(--border-subtle);
    text-align: left;
    font-size: 0.85rem;
}

.insight-table th {
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--surface-muted);
}

.insight-table tbody tr:nth-child(even) {
    background: var(--surface-muted);
}

.insight-table tbody tr:hover {
    background: var(--brand-accent-soft);
}

/* ── Profile bio shell (stats / bio column) ── */
.interim-stats-container h1 {
    color: var(--text-primary);
    text-align: center;
}

.interim-stats-container .section {
    margin-bottom: 1.25rem;
}

.interim-stats-container p {
    font-size: var(--font-size-base);
    line-height: var(--line-height-relaxed);
    color: var(--text-primary);
    max-width: 70ch;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 0.9rem;
}

.interim-stats-container h2 {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--brand-primary);
    margin: 1.1rem 0 0.5rem;
    letter-spacing: -0.01em;
}

.interim-stats-container ul {
    list-style: none;
    max-width: 70ch;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1.1rem;
    margin-bottom: 0.9rem;
}

.interim-stats-container li {
    margin-bottom: 0.4rem;
    line-height: var(--line-height-relaxed);
}

.profile-bio-shell {
    padding: 1.25rem 1rem;
}

@media (min-width: 768px) {
    .profile-bio-shell {
        padding: 1.5rem 1.75rem;
    }
}

.profile-page-container {
    max-width: 1000px;
}

.profile-page-container.profile-page-wide {
    max-width: 1200px;
}

.profile-header-section {
    padding: 0.875rem;
    margin-bottom: 0.75rem;
}

.profile-content-shell {
    padding: 0.625rem;
}

.profile-bio-shell {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    background: var(--surface-elevated);
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.profile-bio-shell:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
}

.profile-header-card {
    position: relative;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    background: var(--surface-elevated);
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.profile-header-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Editorial accent rule across the top of the profile header */
.profile-header-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: var(--accent-editorial);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

@media (max-width: 575.98px) {
    .profile-header-section {
        padding: 0.75rem;
    }

    .profile-content-shell {
        padding: 0.5rem;
    }
}

/* ── Floating share (used by _ShareButtonPartial) ── */
.floating-share-btn {
    position: fixed;
    top: 5.5rem;
    right: 1rem;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background-color: var(--brand-primary);
    color: #fff;
    border: none;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1040;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.floating-share-btn:hover {
    background-color: var(--brand-primary-hover);
    box-shadow: var(--shadow-lg);
    transform: scale(1.04);
    color: #fff;
}

.floating-share-btn:active {
    transform: scale(0.97);
}

.floating-share-btn:focus-visible {
    outline: 2px solid var(--brand-accent);
    outline-offset: 3px;
}

@media (max-width: 768px) {
    .floating-share-btn {
        top: 4.75rem;
        right: 0.75rem;
        width: 2.875rem;
        height: 2.875rem;
    }
}

/* ── Admin horizontal nav: scroll on small screens ── */
.admin-pill-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.25rem;
    margin-bottom: 0.5rem;
    scrollbar-width: thin;
}

.admin-pill-nav .nav {
    flex-wrap: nowrap;
    min-width: min-content;
}

.admin-pill-nav .nav-link {
    white-space: nowrap;
    border-radius: var(--radius-md);
}
