:root {
    --performance-header-height: 100px;
    --z-index-grid-hover: 1;
    --z-index-metric-badge: 2;
    --z-index-podium-count: 3;
    --z-index-grid-player-cell: 9;

}

#performance {
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-height: 0;
    padding: 0;
    padding-top: var(--title-bar-height);
}

#performance-content {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    width: 100vw;
    max-width: 100vw;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: auto;
    /* Allow horizontal scrolling */
    padding: 0;
    box-sizing: border-box;
}

/* Hide horizontal scrollbars on mobile/touch devices for performance content */
@media (hover: none) and (pointer: coarse) {
    #performance-content {
        scrollbar-width: none;
        /* Firefox */
        -ms-overflow-style: none;
        /* IE/Edge */
    }

    #performance-content::-webkit-scrollbar {
        display: none;
        /* Chrome/Safari/Webkit */
    }
}

.section-header {
    padding: 16px 20px;
    background: var(--surface-color, #f8f9fa);
    border-bottom: 1px solid var(--border-color, #e9ecef);
}

.section-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary, #212529);
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-header h3 i {
    color: var(--primary-color, #007bff);
}

.section-content {
    padding: 4px;
}

/* Statistics Grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.stat-card {
    display: flex;
    align-items: center;
    padding: 20px;
    background: var(--surface-color, #f8f9fa);
    border-radius: 8px;
    border: 1px solid var(--border-color, #e9ecef);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.stat-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color, #007bff);
    color: white;
    border-radius: 50%;
    margin-right: 16px;
    font-size: 20px;
}

.stat-content {
    flex: 1;
    min-width: 0;
}

.stat-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted, #6c757d);
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary, #212529);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-detail {
    font-size: 13px;
    color: var(--text-secondary, #495057);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Special styling for ranking information */
.stat-detail.ranking {
    font-weight: 600;
    color: var(--primary-color, #007bff);
}


/* No Data and Error Messages */
.no-data-message,
.error-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted, #6c757d);
}

.no-data-message i,
.error-message i {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
    opacity: 0.5;
}

.no-data-message p,
.error-message p {
    margin: 0;
    font-size: 16px;
}

.error-message {
    color: var(--danger-color, #dc3545);
}

.error-message i {
    color: var(--danger-color, #dc3545);
}

/* Compact no-data message for smaller sections */
.no-data-message-compact {
    text-align: center;
    padding: 16px 12px;
    color: var(--text-muted, #6c757d);
    font-style: italic;
    background: var(--surface-light, #f8f9fa);
    border-radius: 6px;
    border: 1px solid var(--border-light, #e9ecef);
}

.no-data-message-compact i {
    margin-right: 6px;
    color: var(--text-light, #adb5bd);
}

.no-data-message-compact p {
    margin: 0;
    font-size: 13px;
}

/* Chart styles for the performance page */
.chart-card {
    min-height: 200px;
}

.chart-container {
    margin-top: 8px;
    padding: 8px;
}

.mini-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 80px;
    margin-bottom: 8px;
    padding: 4px;
    background: var(--surface-color, #f8f9fa);
    border-radius: 4px;
    gap: 2px;
}

.chart-bin {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.chart-bar {
    width: 100%;
    min-height: 4px;
    background: var(--secondary-color, #6c757d);
    border-radius: 2px 2px 0 0;
    transition: all 0.3s ease;
    opacity: 0.7;
}

.chart-bar.current-player {
    background: var(--primary-color, #007bff);
    opacity: 1;
    box-shadow: 0 0 4px rgba(0, 123, 255, 0.4);
}

.chart-bar:hover {
    opacity: 1;
}

.chart-label {
    font-size: 10px;
    color: var(--text-muted, #6c757d);
    margin-top: 2px;
    text-align: center;
    word-break: break-all;
    line-height: 1.2;
}

.chart-summary {
    font-size: 11px;
    color: var(--text-secondary, #495057);
    text-align: center;
    margin-top: 4px;
}

.chart-no-data {
    text-align: center;
    color: var(--text-muted, #6c757d);
    font-style: italic;
    padding: 20px;
}

/* Compact chart styles for embedding in stat cards */
.chart-container {
    margin-top: 12px;
    padding: 8px 0;
}

.mini-chart-compact {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 50px;
    margin-bottom: 6px;
    padding: 2px;
    background: var(--surface-color, #f8f9fa);
    border-radius: 3px;
    gap: 1px;
}

.chart-bin-compact {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.chart-bar-compact {
    width: 100%;
    min-height: 3px;
    background: var(--secondary-color, #6c757d);
    border-radius: 1px 1px 0 0;
    transition: all 0.3s ease;
    opacity: 0.6;
}

.chart-bar-compact.current-player {
    background: var(--primary-color, #007bff);
    opacity: 1;
    box-shadow: 0 0 3px rgba(0, 123, 255, 0.4);
}

.chart-bar-compact:hover {
    opacity: 1;
}

.chart-label-compact {
    font-size: 9px;
    color: var(--text-muted, #6c757d);
    margin-top: 1px;
    text-align: center;
    word-break: break-all;
    line-height: 1.1;
}

.chart-summary-compact {
    font-size: 10px;
    color: var(--text-secondary, #495057);
    text-align: center;
    margin-top: 2px;
    font-style: italic;
}

.chart-no-data-compact {
    text-align: center;
    color: var(--text-muted, #6c757d);
    font-style: italic;
    font-size: 10px;
    padding: 8px;
}

/* Unified card styles for single comprehensive view */
.unified-card {
    min-height: 250px;
    align-items: flex-start;
}

.unified-content {
    width: 100%;
}

.performance-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 16px 0;
}

.perf-section {
    background: var(--surface-color, #f8f9fa);
    padding: 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color, #e9ecef);
}

.perf-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #212529);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.perf-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-color, #007bff);
    margin-bottom: 4px;
}

.perf-detail {
    font-size: 12px;
    color: var(--text-secondary, #495057);
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.perf-detail.ranking {
    font-weight: 600;
    color: var(--primary-color, #007bff);
}

.unified-chart {
    margin-top: 16px;
    padding: 12px;
    background: var(--surface-color, #f8f9fa);
    border-radius: 6px;
    border: 1px solid var(--border-color, #e9ecef);
}

.chart-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #212529);
    margin-bottom: 8px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* CanvasJS chart container styles */
.canvasjs-chart-container {
    min-height: 400px;
    max-height: 800px;
    margin: 8px 0 20px 0;
    border-radius: 6px;
    overflow-y: auto;
    overflow-x: hidden;
    border: 1px solid var(--border-color, #e9ecef);
    background: white;
}

.canvasjs-chart-container canvas {
    border-radius: 6px;
}

/* Ensure chart fits properly in unified card */
.unified-chart .canvasjs-chart-container {
    min-height: 380px;
    max-height: 800px;
    margin: 6px 0 20px 0;
}

/* Chart.js chart container styles */
.chartjs-chart-container {
    width: 100% !important;
    max-width: 800px !important;
    height: 400px !important;
    min-height: 300px !important;
    margin: 8px 0 20px 0;
    border-radius: 6px;
    border: 1px solid var(--border-color, #e9ecef);
    background: white;
    display: block;
}

/* Ensure chart fits properly in unified card */
.unified-chart .chartjs-chart-container {
    width: 100% !important;
    max-width: 800px !important;
    height: 400px !important;
    min-height: 300px !important;
}

/* Chart loading state */
.canvasjs-chart-container.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted, #6c757d);
    font-size: 14px;
}

.canvasjs-chart-container.loading::before {
    content: "Loading chart...";
}

/* Chart error states */
.chart-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted, #6c757d);
    font-size: 14px;
    background: var(--surface-color, #f8f9fa);
    border: 1px dashed var(--border-color, #dee2e6);
    border-radius: 4px;
}

.chart-error::before {
    content: "⚠ ";
    margin-right: 8px;
}

/* Performance Grid Styles */
.performance-grid-container {
    background: white;
    border-radius: 8px;
    border: 1px solid var(--border-color, #e9ecef);
    overflow: hidden;
    /* keep rounded corners; inner scroll element will handle scrolling */
    max-width: var(--app-max-width);
}

.performance-grid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    /* tightened */
    background: var(--section-header-bg, #f8f9fa);
    border-bottom: 1px solid var(--border-color, #e9ecef);
    position: sticky;
    top: 0;
    z-index: var(--z-index-performance-header);
    /* above table headers (10/11) */
    /* backdrop-filter removed - doesn't work consistently on iPhone */
}

/* Optional subtle shadow when stuck */
.performance-grid-header.is-stuck {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.performance-grid-header h3 {
    margin: 0;
    color: var(--text-primary, #333);
    font-size: 1.1em;
}

.performance-grid-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    padding: 0;
}

.performance-filter-panel {
    display: none;
    width: 100%;
    padding: 12px 15px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
    border-radius: 0;
    /* Remove inner radius */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 15px;
    animation: slideDown 0.2s ease-out;
    box-sizing: border-box;
}

/* Performance Summary Stats */
.performance-summary-stats {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    padding: 12px 16px;
    background: var(--surface-light, #fdfdfe);
    border-bottom: 1px solid var(--border-light, #f1f3f4);
    font-size: 14px;
    flex-wrap: wrap;
}

.summary-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.summary-label {
    color: var(--text-secondary, #6c757d);
    font-weight: 500;
}

.summary-value {
    color: var(--text-primary, #212529);
    font-weight: 600;
    padding: 2px 8px;
    background: var(--accent-light, #e7f3ff);
    border-radius: 4px;
    min-width: 24px;
    text-align: center;
}

.date-filter-info .summary-value {
    background: var(--warning-light, #fff3cd);
    color: var(--warning-dark, #856404);
    font-size: 13px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Removed @media (max-width: 768px) - sizing handled by clamp() */

.performance-filter-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* Min events filter */
.min-events-filter {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--badge-bg, #eef2f6);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.85em;
}

.min-events-filter .filter-label {
    font-weight: 600;
}

.min-events-input {
    background: var(--input-bg, #fff);
    border: 1px solid var(--border-color, #d0d7de);
    padding: 4px 6px;
    width: 50px;
    text-align: center;
    font-weight: 600;
    font-size: 0.9em;
    border-radius: 4px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.min-events-input:focus {
    outline: none;
    border-color: var(--accent-color, #0366d6);
    box-shadow: 0 0 0 2px rgba(3, 102, 214, 0.15);
}

.date-filter {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--badge-bg, #eef2f6);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.85em;
}

.date-filter .filter-label {
    font-weight: 600;
}

.date-input {
    background: var(--input-bg, #fff);
    border: 1px solid var(--border-color, #d0d7de);
    padding: 4px 6px;
    width: 120px;
    text-align: center;
    font-weight: 600;
    font-size: 0.9em;
    border-radius: 4px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.date-input:focus {
    outline: none;
    border-color: var(--accent-color, #0366d6);
    box-shadow: 0 0 0 2px rgba(3, 102, 214, 0.15);
}

.date-separator {
    font-weight: 600;
    color: var(--text-secondary, #656d76);
    margin: 0 2px;
}

/* Minimum events filter */
.min-events-filter {
    display: inline-flex;
    align-items: center;
    background: var(--badge-bg, #eef2f6);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.85em;
    gap: 6px;
}

.min-events-filter .min-events-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    user-select: none;
}

.min-events-filter .min-events-text {
    font-weight: 600;
    white-space: nowrap;
    color: var(--text-primary, #333);
}

.min-events-filter .min-events-input {
    width: 50px;
    padding: 2px 6px;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 4px;
    font-size: 0.85em;
    text-align: center;
    background: white;
}

.min-events-filter .min-events-input:focus {
    outline: none;
    border-color: var(--primary-color, #007bff);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.grid-filter-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.grid-filter-container label {
    font-size: 0.85em;
    font-weight: 600;
    color: var(--text-primary, #333);
    white-space: nowrap;
}

.grid-filter-container .custom-dropdown {
    min-width: 150px;
    font-size: var(--font-size-s);
}

.grid-filter-container .dropdown-selected {
    padding: 6px 10px;
    border: 1px solid var(--border-color, #ced4da);
    border-radius: 4px;
    background: white;
    cursor: pointer;
    position: relative;
}

.grid-filter-container .dropdown-selected:after {
    content: '▼';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: var(--text-muted, #6c757d);
}

.performance-grid-wrapper {
    /* structural wrapper */
    position: relative;
}

/* Dedicated scroll area so sticky header stays visible */
.performance-grid-scroll {
    /* Allow both horizontal and vertical scrolling for tables */
    max-height: calc(100vh - 300px);
    /* Reserve space for headers, filters, and summary stats */
    min-height: 200px;
    /* Minimum height to ensure scrollability */
    overflow-x: auto;
    overflow-y: auto;
    /* Enable vertical scrolling */
    position: relative;

    /* Mobile scroll behavior: prevent bounce but allow scrolling */
    overscroll-behavior: none;
    /* Prevent bounce/rubber-band on iOS/Android */
    -webkit-overflow-scrolling: touch;
    /* Smooth momentum scrolling */

    /* Allow scrolling but prevent page bounce */
    touch-action: auto;
    /* Changed from pan-x pan-y to allow normal scrolling */

    /* Prevent grid from being draggable as an image/element */
    -webkit-user-drag: none;
    margin-top: 10px;
}

/* Prevent grid content from being draggable */
.performance-grid-scroll * {
    overscroll-behavior: none;
    /* No bounce on child elements */
    -webkit-user-drag: none;
    /* Removed user-select: none - was preventing scrolling */
}

/* Allow text selection in player names */
.grid-player-cell {
    user-select: text !important;
}

/* Performance grid responsive height - linear scaling */
.performance-grid-scroll {
    max-height: clamp(calc(100vh - 200px), calc(100vh - 225px), calc(100vh - 250px));
}

/* Mobile/touch device scrollbar hiding */
@media (hover: none) and (pointer: coarse) {
    .performance-grid-scroll {
        scrollbar-width: none;
        /* Firefox */
        -ms-overflow-style: none;
        /* IE/Edge */
    }

    .performance-grid-scroll::-webkit-scrollbar {
        display: none;
        /* Chrome/Safari/Webkit */
    }
}

/* Performance Grid Layout - Responsive */
.performance-grid-layout {
    display: grid !important;
    grid-template-columns:
        clamp(80px, 15vw, 110px) repeat(5, minmax(clamp(60px, 10vw, 80px), 1fr));
    gap: 4px;
    /* Removed touch-action: none - was blocking scrolling */
}

/* Grid rows are now just wrappers for their cells (subgrid would be ideal but not widely supported) */
.grid-header-row,
.grid-row {
    /* Each row spans all 6 columns and contains 6 cells as direct children of the grid */
    display: contents;
    /* Makes children act as direct grid items */
}

/* All grid cells get default styling with responsive padding and borders */
.grid-header-row>div,
.grid-row>div {
    padding: 2px 3px;
    /* Reduced horizontal padding from 4px to 3px for more space */
    border-bottom: 1px solid #e9ecef;
    border-right: 1px solid #e9ecef;
    box-sizing: border-box;
    font-size: clamp(0.65rem, 2.7vw, 0.875rem);
    /* Linear scaling: perfect at 524px viewport */
}

/* Make all header cells sticky */
.grid-header-row>div {
    position: sticky;
    top: 0;
    z-index: 10;
    background: white;
    font-weight: 600;
}

/* Player column sticky */
.grid-player-header,
.grid-player-cell {
    position: sticky;
    left: 0;
    background: white;
    z-index: 5;
    border-right: 2px solid #dee2e6 !important;
}

.grid-player-header {
    z-index: 15;
}

/* Column headers - minimal styling */
.grid-column-header {
    cursor: pointer;
}

/* Remove right border from last column */
.grid-header-row>div:last-child,
.grid-row>div:last-child {
    border-right: none;
}

.grid-player-header {
    position: sticky;
    left: 0;
    background: var(--section-header-bg, #f8f9fa);
    border-right: 2px solid var(--border-color, #e9ecef) !important;
    z-index: var(--z-index-grid-player-header);
    top: 0;
    font-weight: 600;
    color: var(--text-primary, #333);
    display: flex;
    align-items: center;
    /* Force header to match player column width exactly */
    min-width: 0;
    /* Allow shrinking */
    max-width: clamp(80px, 15vw, 110px);
    /* Match grid column exactly */
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
}

.grid-column-header {
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* Removed width: 100% - let grid control width naturally */
    min-width: 0;
    /* Allow flex children to shrink */
}

.grid-column-header:hover {
    background: var(--hover-bg, #dee2e6);
}

.grid-column-header.sortable {
    user-select: none;
}

/* Header label text */
.grid-column-header .header-label {
    flex: 1;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Remove all sort arrows - use color instead */
.grid-column-header .sort-arrow {
    display: none;
    /* Hide arrows completely */
}

/* Use background color to indicate sort direction */
.grid-column-header.sorted-asc {
    background: rgba(34, 139, 34, 0.15) !important;
    /* Muted green for ascending */
}

.grid-column-header.sorted-desc {
    background: rgba(220, 53, 69, 0.15) !important;
    /* Muted red for descending */
}

/* Hover state */
.grid-column-header:hover {
    background: var(--hover-bg, #dee2e6);
}

/* Sorted headers keep their color on hover */
.grid-column-header.sorted-asc:hover {
    background: rgba(34, 139, 34, 0.25) !important;
    /* Slightly darker green on hover */
}

.grid-column-header.sorted-desc:hover {
    background: rgba(220, 53, 69, 0.25) !important;
    /* Slightly darker red on hover */
}

/* Player cell - sticky on left with responsive sizing */
.grid-player-cell {
    position: sticky;
    left: 0;
    background: white;
    border-right: 2px solid var(--border-color, #e9ecef) !important;
    z-index: var(--z-index-grid-player-cell);
    max-width: clamp(60px, 15vw, 140px);
    /* Match player column width */
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Data cells with responsive sizing */
.grid-data-cell {
    background: white;
    text-align: center;
    cursor: default;
    transition: transform 0.1s;
    position: relative;
    overflow: visible;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Center badge and content */
    justify-content: flex-start;
    padding-top: 4px;
    /* Small top padding instead of 22px */
}

.grid-row:nth-child(even) .grid-player-cell,
.grid-row:nth-child(even) .grid-data-cell {
    background-color: var(--row-even-bg, #f8f9fa);
}

.grid-row:nth-child(odd) .grid-player-cell,
.grid-row:nth-child(odd) .grid-data-cell {
    background-color: white;
}

/* Current player row highlighting */
.grid-row.current-player .grid-player-cell {
    background: var(--current-player-bg, #e3f2fd) !important;
    font-weight: 600;
}

/* Synthetic Average Player Row Styling */
.grid-row.synthetic-average>* {
    background: var(--average-cell-bg, #f8f9fa) !important;
    border-top: 2px solid var(--average-border, #007bff);
    border-bottom: 2px solid var(--average-border, #007bff);
    font-weight: 500;
}

.grid-row.synthetic-average .grid-player-cell {
    background: var(--average-player-bg, #e7f3ff) !important;
    font-weight: 600;
    color: var(--average-text, #0056b3);
    border-right: 2px solid var(--average-border, #007bff);
}

/* Column filter dialog (initial stub) */
.grid-filter-dialog {
    background: #fff;
    border: 1px solid var(--border-color, #ced4da);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    width: 380px;
    min-height: 300px;
    font-size: 1rem;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.grid-filter-dialog .gfd-header {
    font-weight: 600;
    font-size: 1.2rem;
    margin-bottom: 8px;
}

.grid-filter-dialog .gfd-desc {
    font-size: 0.95rem;
    line-height: 1.4;
    color: var(--text-secondary, #555);
    margin-bottom: 10px;
}

.grid-filter-dialog .gfd-section {
    border-top: 1px solid var(--border-color, #e9ecef);
    padding-top: 12px;
}

.grid-filter-dialog .gfd-subheader {
    font-weight: 500;
    font-size: 1.05rem;
    margin-bottom: 8px;
}

.grid-filter-dialog button {
    background: var(--button-bg, #f1f3f5);
    border: 1px solid var(--border-color, #ced4da);
    border-radius: 3px;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
}

.grid-filter-dialog button:hover {
    background: var(--button-hover-bg, #e2e6ea);
}

.grid-filter-dialog .gfd-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    border-top: 1px solid var(--border-color, #e9ecef);
    padding-top: 12px;
    margin-top: 8px;
}

.grid-info-icon {
    color: var(--info-color, #17a2b8);
    margin-right: 8px;
    cursor: help;
    font-size: var(--font-size-icon-small);
}

.grid-info-icon:hover {
    color: var(--info-hover, #138496);
}

.grid-sort-icon {
    margin-left: 8px;
    opacity: 0.5;
    font-size: var(--font-size-l)
}

.grid-column-header.sorted-asc .grid-sort-icon::before {
    content: '\f0de';
    /* fa-sort-up */
    opacity: 1;
}

/* Filter icon - prevent focus and keyboard appearance */
#performance-filter-icon {
    outline: none !important;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    pointer-events: auto !important;
    cursor: pointer !important;
}

#performance-filter-icon:focus {
    outline: none !important;
}

#performance-filter-icon:active {
    outline: none !important;
}

.filter-toggle-stat {
    pointer-events: none !important;
}

#performance-filter-icon i {
    pointer-events: auto !important;
    cursor: pointer !important;
}

.performance-summary-stats {
    -webkit-user-select: none;
    user-select: none;
}

.grid-column-header.sorted-desc .grid-sort-icon::before {
    content: '\f0dd';
    /* fa-sort-down */
    opacity: 1;
}

.player-info {
    display: flex;
    flex-direction: column;
    gap: clamp(2px, 0.3vw, 4px);
}

.player-name {
    font-weight: 500;
    color: var(--text-primary, #333);
    font-size: clamp(0.75rem, 0.5rem + 0.5vw, 0.9rem);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-activity {
    font-size: clamp(0.65rem, 0.4rem + 0.4vw, 0.75rem);
    color: var(--text-secondary, #666);
    line-height: 1.2;
}

.grid-current-indicator {
    color: var(--primary-color, #007bff);
    margin-left: 8px;
    font-size: 0.9em;
    align-self: flex-start;
}

.grid-data-cell {
    text-align: center;
    cursor: default;
    transition: transform 0.1s;
    position: relative;
    /* Contain absolutely positioned podium counts */
    overflow: visible;
    /* Allow podium counts to extend slightly beyond cell */
}

.grid-data-cell:hover {
    transform: scale(1.02);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: var(--z-index-grid-hover);
    position: relative;
}

.metric-rank-badge {
    --border: #222;
    --fill: white;
    --size: 14px;
    /* Even tighter size */
    display: inline-flex;
    /* Changed from absolute positioning to inline */
    width: var(--size);
    height: var(--size);
    font-size: 8px;
    font-weight: 700;
    color: black;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border-radius: 50%;
    /* Circle shape */
    position: relative;
    /* For pseudo-elements */
    margin-bottom: 2px;
    /* Small gap below badge */
    z-index: 1;
    /* Ensure text is above pseudo-elements */
}

/* outer border */
.metric-rank-badge::before {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 50%;
    /* Circle instead of pentagon */
    z-index: -2;
    /* negative values kept literal for stacking below */
}

/* inner fill */
.metric-rank-badge::after {
    content: "";
    position: absolute;
    inset: 1px;
    /* border thickness */
    background: var(--fill);
    border-radius: 50%;
    /* Circle instead of pentagon */
    background-image:
        linear-gradient(to bottom, rgba(255, 255, 255, .25), rgba(0, 0, 0, .08));
    z-index: -1;
    /* negative values kept literal for stacking below */
}

/* Slightly smaller on mobile */
.metric-rank-badge {
    width: 15px;
    height: 15px;
    /* font-size: 10px; */
    /* top: 3px; */
    /* right: 3px; */
}

.cell-key-value {
    display: block;
    font-weight: 600;
    font-size: 1em;
    color: var(--text-primary, #333);
    margin-top: 2px;
    /* Small gap from top */
}

.cell-detail {
    display: block;
    font-size: 0.75em;
    color: var(--text-secondary, #666);
    margin-top: 4px;
    /* Gap between value and detail */
}

.performance-grid-no-data {
    padding: 30px;
    text-align: center;
    color: var(--text-secondary, #666);
    font-style: italic;
}

/* Podium Icons Styles */
.cell-podium-icons {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    justify-content: center;
    align-items: center;
}

.podium-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: transform 0.2s ease;
    z-index: var(--z-index-metric-badge);
    /* Icon stays in front */
}

.podium-icon:hover {
    transform: scale(1.1);
}

.podium-count {
    position: absolute;
    top: -10px;
    right: -10px;
    color: black;
    font-size: 14px;
    font-weight: normal;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    text-shadow: 0 0 3px rgba(255, 255, 255, 0.8), 0 0 6px rgba(255, 255, 255, 0.6);
    z-index: var(--z-index-podium-count);
    /* Number stays on top */
}

/* Trophy (1st place) - Gold */
.trophy-gold {
    color: #FFD700;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Medal (2nd place) - Silver */
.medal-silver {
    color: #C0C0C0;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Ribbon (3rd place) - Bronze */
.ribbon-bronze {
    color: #CD7F32;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* No podium message */
.no-podium {
    font-size: 0.75em;
    color: var(--text-muted, #999);
    font-style: italic;
}

/* Mobile responsive adjustments */
/* Removed @media (max-width: 768px) - sizing handled by clamp() and responsive design */

/* Performance text filter controls */
.text-filter {
    display: flex;
    align-items: center;
    gap: 8px;
}

.text-filter .filter-input-wrapper {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.text-filter-input {
    width: 100%;
    padding: 6px 65px 6px 8px;
    /* Make room for both help and clear buttons */
    border: 1px solid var(--border-color, #d0d7de);
    border-radius: 0;
    /* Remove radius */
    font-size: 0.9em;
    background-color: var(--input-bg, #fff);
    color: var(--text-primary, #333);
    box-sizing: border-box;
}

.text-filter-input:focus {
    outline: none;
    border-color: var(--accent-color, #0366d6);
    box-shadow: 0 0 0 2px rgba(3, 102, 214, 0.15);
}

.text-filter .filter-help-toggle {
    position: absolute;
    right: 35px;
    /* Position to the left of the clear button */
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: var(--secondary-bg-color, #f6f8fa);
    border: 1px solid var(--border-color, #d0d7de);
    font-size: 12px;
    color: var(--secondary-color, #656d76);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: all 0.2s ease;
}

.text-filter .filter-help-toggle:hover {
    background-color: var(--accent-color, #0366d6);
    color: white;
    border-color: var(--accent-color, #0366d6);
}

.text-filter .clear-filter-btn {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    font-size: 16px;
    color: var(--secondary-color, #656d76);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 50%;
    display: none;
    /* Hidden by default, shown when there's text */
    line-height: 1;
    transition: all 0.2s ease;
}

.text-filter .clear-filter-btn:hover {
    background-color: var(--secondary-bg-color, #f6f8fa);
    color: var(--primary-color, #24292f);
}

.text-filter .clear-filter-btn.visible {
    display: block;
}

.apply-filter-btn {
    padding: 6px 12px;
    background-color: var(--primary-color, #0366d6);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.9em;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.2s ease;
}

.apply-filter-btn:hover {
    background-color: var(--primary-hover, #0256c4);
}

.apply-filter-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(3, 102, 214, 0.3);
}

/* Make filter controls responsive inside the panel */
.performance-filter-panel .performance-filter-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

/* FORCE: Normalize header styling to avoid duplicate/conflicting rules
   Headers now contain label only (arrows removed).
   Key: NO gap, NO width, minimal padding - let grid control width naturally. */
.grid-column-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 2px 3px !important;
    /* Reduced from 4px 6px for more space */
    box-sizing: border-box !important;
    margin: 0 !important;
    gap: 0 !important;
    /* CRITICAL: no gap or width expands */
    cursor: pointer !important;
}

.grid-column-header .header-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Hide arrow element in override section too */
.grid-column-header .sort-arrow {
    display: none !important;
}

/* Removed duplicate @media (max-width: 768px) for filter panel - redundant with clamp() */