/* CSS Variables */
:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-tertiary: #1a2332;
    --bg-card: #151d2b;
    --accent-primary: #00d4aa;
    --accent-secondary: #7c3aed;
    --accent-gold: #fbbf24;
    --accent-silver: #94a3b8;
    --accent-bronze: #cd7f32;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --profit: #10b981;
    --loss: #ef4444;
    --border: rgba(255, 255, 255, 0.08);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --font-primary: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --header-height: 72px;
    --nav-height: 56px;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Scroll Progress Bar */
.scroll-progress-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: none;
    border: none;
    z-index: 10000;
    pointer-events: none;
}

.scroll-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #00d4aa, #7c3aed, #00d4aa);
    background-size: 200% 100%;
    animation: gradientShift 3s ease infinite;
    border-radius: 0 2px 2px 0;
    transition: width 0.1s ease-out;
    box-shadow: 0 0 8px rgba(0, 212, 170, 0.4);
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Background Pattern */
.background-pattern {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    background: 
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(0, 212, 170, 0.15), transparent),
        radial-gradient(ellipse 60% 40% at 80% 60%, rgba(124, 58, 237, 0.1), transparent),
        linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

/* Header */
header {
    background: rgba(17, 24, 39, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 2rem;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.season-badge {
    background: var(--bg-tertiary);
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--accent-primary);
    border: 1px solid var(--border);
}

.season-selector {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-tertiary);
    padding: 0.25rem;
    border-radius: 2rem;
    border: 1px solid var(--border);
}

.season-btn {
    background: transparent;
    padding: 0.375rem 0.875rem;
    border-radius: 1.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-primary);
}

.season-btn:hover:not(.active) {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.season-btn.active {
    background: linear-gradient(135deg, var(--accent-primary), #00b894);
    color: var(--bg-primary);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 212, 170, 0.3);
}

.refresh-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, var(--accent-primary), #00b894);
    color: var(--bg-primary);
    border: none;
    padding: 0.625rem 1.25rem;
    border-radius: 0.5rem;
    font-family: var(--font-primary);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.refresh-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 212, 170, 0.3);
}

.refresh-btn:active {
    transform: translateY(0);
}

.refresh-icon {
    font-size: 1rem;
    transition: transform 0.3s ease;
}

.refresh-btn:hover .refresh-icon {
    transform: rotate(180deg);
}

/* Section Navigation */
.section-nav {
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: var(--header-height); /* Below header */
    z-index: 99;
    overflow: visible;
    padding-bottom: 0;
    /* Auto-hide transition */
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Mobile/Tablet: Hide header and auto-hide nav */
@media (max-width: 1024px) {
    /* Hide the main header on mobile to maximize space */
    header {
        display: none !important;
    }
    
    /* Nav should stick to top since header is hidden */
    .section-nav {
        top: 0;
        position: fixed;
        left: 0;
        right: 0;
        border-top: none;
    }
    
    /* Ensure scroll progress has no visible background on mobile */
    .scroll-progress-container {
        background: none !important;
        border: none !important;
        box-shadow: none !important;
    }
    
    /* Add padding to body content to account for fixed nav */
    body {
        padding-top: 60px; /* Fixed value for nav height on mobile */
    }
    
    /* Adjust scroll margin for sections (no header) */
    section[id],
    div.fun-stat-card[id],
    #profit-loss,
    #weekly-winners,
    #position-matrix,
    #prediction-stats,
    #fun-stats,
    #player-stats,
    #consistency-kings,
    #streaks,
    #form-guide,
    #matchday-perf,
    #scorelines,
    #prediction-masters,
    #outcome-distribution,
    #points-matrix {
        scroll-margin-top: calc(var(--nav-height) + 16px);
    }
    
    .section-nav.nav-hidden {
        transform: translateY(-100%);
        opacity: 0;
        pointer-events: none;
    }
    
    .section-nav.nav-visible {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    gap: 0.5rem;
    overflow: visible;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex-wrap: wrap;
}

.nav-container::-webkit-scrollbar {
    display: none;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    border-radius: 2rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.nav-item:hover {
    background: var(--bg-card);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(0, 212, 170, 0.3);
}

.nav-item:active {
    box-shadow: 0 0 0 1px rgba(0, 212, 170, 0.2);
}

/* Nav Dropdown */
.nav-dropdown {
    position: relative;
    display: inline-block;
    z-index: 200;
}

.nav-dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.dropdown-arrow {
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

.nav-dropdown:hover .dropdown-arrow {
    transform: rotate(180deg);
}

.nav-dropdown-content {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    border: 1px solid var(--accent-primary);
    border-radius: 0.75rem;
    padding: 0.5rem;
    padding-top: 0.75rem;
    min-width: max-content;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.2s ease;
    z-index: 9999;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* Invisible bridge to maintain hover when moving to dropdown */
.nav-dropdown-content::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 0;
    right: 0;
    height: 10px;
}

.nav-dropdown:hover .nav-dropdown-content {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.nav-dropdown-content a {
    display: block;
    padding: 0.5rem 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8125rem;
    border-radius: 0.5rem;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.nav-dropdown-content a:hover {
    background: rgba(0, 212, 170, 0.1);
    color: var(--accent-primary);
}

/* Scroll margin for anchor links (header + nav + buffer) */
section[id],
#consistency-kings,
#streaks,
#form-guide,
#matchday-perf,
#scorelines,
#prediction-masters,
#outcome-distribution,
#points-matrix {
    scroll-margin-top: calc(var(--header-height) + var(--nav-height) + 16px);
}

/* Main Content */
main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Section Titles */
.section-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.section-title .info-tooltip {
    margin-left: 0.25rem;
}

.section-title .info-icon {
    font-size: 1rem;
}

.title-icon {
    font-size: 1.25rem;
}

/* Summary Section */
.summary-section {
    margin-bottom: 2.5rem;
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.summary-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.summary-value {
    font-size: 1.75rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--accent-primary);
}

.summary-note {
    font-size: 0.6875rem;
    color: var(--text-tertiary);
    font-weight: 400;
}

.summary-note:empty {
    display: none;
}

/* Prize Structure Section (Collapsible) */
.prize-structure-section {
    margin-bottom: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    overflow: hidden;
}

/* .prize-structure-section[open] - no special styles needed */

.prize-structure-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
    list-style: none; /* Remove default arrow */
}

.prize-structure-header::-webkit-details-marker {
    display: none; /* Remove default arrow in WebKit */
}

.prize-structure-header:hover {
    background: var(--bg-tertiary);
}

.prize-structure-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.collapse-arrow {
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: transform 0.3s ease;
}

.prize-structure-section[open] .collapse-arrow {
    transform: rotate(0deg);
}

.prize-structure-section:not([open]) .collapse-arrow {
    transform: rotate(-90deg);
}

.prize-structure-content {
    padding: 0 1rem 1rem 1rem;
}

.prize-structure-content .summary-cards {
    margin-bottom: 1rem;
    gap: 0.75rem;
}

.prize-structure-content .summary-card {
    background: var(--bg-tertiary);
    padding: 0.875rem 1rem;
    border-radius: 0.5rem;
    gap: 0.25rem;
}

.prize-structure-content .summary-value {
    font-size: 1.25rem;
}

.prize-structure-content .summary-label {
    font-size: 0.75rem;
}

.prize-structure-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.prize-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.875rem 1rem;
}

.prize-card.weekly {
    border-left: 4px solid var(--accent-primary);
}

.prize-card.season {
    border-left: 4px solid var(--accent-gold);
}

.prize-card-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.prize-items {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.prize-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    background: var(--bg-tertiary);
    padding: 0.375rem 0.625rem;
    border-radius: 0.375rem;
    border: 1px solid var(--border);
}

.prize-item.gold {
    background: rgba(251, 191, 36, 0.1);
    border-color: var(--accent-gold);
}

.prize-item.silver {
    background: rgba(148, 163, 184, 0.1);
    border-color: var(--accent-silver);
}

.prize-item.bronze {
    background: rgba(205, 127, 50, 0.1);
    border-color: var(--accent-bronze);
}

.prize-position {
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.prize-item.gold .prize-position {
    color: var(--accent-gold);
}

.prize-item.silver .prize-position {
    color: var(--accent-silver);
}

.prize-item.bronze .prize-position {
    color: var(--accent-bronze);
}

.prize-amount {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-primary);
}

/* Prize Override Section (for gameweek exceptions) */
.prize-override-section {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border);
}

.prize-override-header {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* Season Complete Banner */
.season-complete-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    background: linear-gradient(135deg, var(--accent-gold), #d97706);
    color: var(--bg-primary);
    padding: 1rem 2rem;
    border-radius: 1rem;
    margin-bottom: 2rem;
    font-weight: 700;
    font-size: 1.125rem;
    animation: celebratePulse 2s ease-in-out infinite;
}

@keyframes celebratePulse {
    0%, 100% { transform: scale(1); box-shadow: 0 4px 20px rgba(251, 191, 36, 0.3); }
    50% { transform: scale(1.02); box-shadow: 0 8px 30px rgba(251, 191, 36, 0.5); }
}

.banner-icon {
    font-size: 1.5rem;
}

.banner-text {
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Weekly Winners */
.weekly-winners-section {
    margin-bottom: 2.5rem;
}

.weekly-winners-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.leg-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    overflow: hidden;
}

.leg-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    cursor: pointer;
    background: var(--bg-tertiary);
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

.leg-section[open] .leg-header {
    border-bottom-color: var(--border);
}

.leg-header:hover {
    background: rgba(0, 212, 170, 0.05);
}

.leg-header::marker,
.leg-header::-webkit-details-marker {
    display: none;
}

.leg-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.leg-title::before {
    content: '▶';
    font-size: 0.75rem;
    color: var(--accent-primary);
    transition: transform 0.2s ease;
}

.leg-section[open] .leg-title::before {
    transform: rotate(90deg);
}

.leg-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-card);
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
}

.leg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    padding: 1.5rem;
}

.weekly-winner-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    overflow: hidden;
    transition: all 0.2s ease;
}

.weekly-winner-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.week-header {
    background: linear-gradient(135deg, #00d4aa, #7c3aed);
    color: var(--bg-primary);
    font-weight: 700;
    font-size: 0.875rem;
    padding: 0.5rem;
    text-align: center;
}

.winners-content {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 80px;
}

.winner-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.5rem;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.03);
}

.winner-row.first-place {
    background: rgba(251, 191, 36, 0.1);
}

.winner-row.second-place {
    background: rgba(148, 163, 184, 0.1);
}

.winner-row.tie-for-first {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(148, 163, 184, 0.1));
    flex-wrap: wrap;
}

.winner-row.tie-for-second {
    flex-wrap: wrap;
}

.winner-row .medal {
    font-size: 1rem;
    flex-shrink: 0;
}

.winner-row .winner-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary);
}

.winner-row .winner-names {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.5rem;
}

.tie-badge {
    font-size: 0.625rem;
    font-weight: 700;
    background: var(--accent-gold);
    color: var(--bg-primary);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    margin-left: auto;
}

.no-winner {
    color: var(--text-muted);
    font-size: 0.875rem;
    text-align: center;
    padding: 1rem;
}

/* Leaderboard */
.leaderboard-section {
    margin-bottom: 2.5rem;
}

.leaderboard {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.leaderboard-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.25rem 1.5rem;
    display: grid;
    grid-template-columns: auto 1fr auto auto auto auto auto;
    align-items: center;
    gap: 1.25rem;
    transition: all 0.2s ease;
}

.leaderboard-item:hover {
    transform: translateX(4px);
    border-color: var(--accent-primary);
}

.leaderboard-item.profit {
    border-left: 4px solid var(--profit);
}

.leaderboard-item.loss {
    border-left: 4px solid var(--loss);
}

.leaderboard-item.has-final-prize {
    border-right: 4px solid var(--accent-gold);
}

.rank {
    font-size: 1.5rem;
    font-weight: 800;
    width: 2.5rem;
    text-align: center;
}

.rank.gold { color: var(--accent-gold); }
.rank.silver { color: var(--accent-silver); }
.rank.bronze { color: var(--accent-bronze); }

.player-name {
    font-size: 1.125rem;
    font-weight: 600;
}

.stat-group {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 1rem;
}

.stat-value.profit { color: var(--profit); }
.stat-value.loss { color: var(--loss); }

.net-profit {
    font-size: 1.25rem;
    font-weight: 700;
    font-family: var(--font-mono);
    min-width: 100px;
    text-align: right;
}

.net-profit.profit { color: var(--profit); }
.net-profit.loss { color: var(--loss); }

/* Leaderboard Points and Final Prize */
.points-group .stat-value {
    color: var(--accent-primary);
    font-weight: 700;
}

.points-value {
    color: var(--accent-primary);
    font-weight: 700;
}

.final-prize-group {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
    min-width: 100px;
}

.final-prize-group .stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.final-prize-group.active {
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { filter: drop-shadow(0 0 2px rgba(251, 191, 36, 0.3)); }
    to { filter: drop-shadow(0 0 8px rgba(251, 191, 36, 0.6)); }
}

.final-prize-badge {
    background: linear-gradient(135deg, var(--accent-gold), #d97706);
    color: var(--bg-primary);
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
    border-radius: 0.5rem;
}

.final-prize-badge.paid {
    background: linear-gradient(135deg, var(--profit), #059669);
    animation: none;
}

.final-prize-badge.paid::after {
    content: ' ✓';
}

.leaderboard-item.paid {
    border-right-color: var(--profit);
}

.no-prize {
    color: var(--text-muted);
}

/* ===== LEADERBOARD TABLE ===== */
.leaderboard-table-wrapper {
    overflow-x: auto;
    border-radius: 1rem;
    border: 1px solid var(--border);
    background: var(--bg-card);
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.leaderboard-table thead {
    background: var(--bg-tertiary);
    position: sticky;
    top: 0;
    z-index: 10;
}

.leaderboard-table th {
    padding: 1rem 1.25rem;
    text-align: center;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

/* Player column stays left-aligned */
.leaderboard-table th:nth-child(2) {
    text-align: left;
}

.leaderboard-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
}

.leaderboard-table th.sortable:hover {
    color: var(--accent-primary);
    background: rgba(168, 85, 247, 0.1);
}

.leaderboard-table th.sorted {
    color: var(--accent-primary);
    background: rgba(168, 85, 247, 0.1);
}

.leaderboard-table th.rank-col {
    width: 50px;
    text-align: center;
}

.leaderboard-table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    transition: background 0.2s;
    text-align: center;
}

/* Player column stays left-aligned */
.leaderboard-table .player-name-cell {
    text-align: left;
}

.leaderboard-table tbody tr:hover {
    background: rgba(168, 85, 247, 0.05);
}

.leaderboard-table tbody tr:last-child td {
    border-bottom: none;
}

.leaderboard-table .rank-col {
    text-align: center;
    font-weight: 700;
    color: var(--text-muted);
}

.leaderboard-table .player-name-cell {
    font-weight: 600;
    color: var(--text-primary);
}

.leaderboard-table .points-cell {
    font-weight: 700;
    color: var(--accent-primary);
}

.leaderboard-table .won-cell {
    color: var(--text-secondary);
}

.leaderboard-table .pl-cell {
    font-weight: 600;
}

.leaderboard-table .pl-cell.profit .pl-value {
    color: var(--profit);
}

.leaderboard-table .pl-cell.loss .pl-value {
    color: var(--loss);
}

.leaderboard-table .profit-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: var(--profit);
    color: white;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 700;
}

.leaderboard-table .roi-cell.profit {
    color: var(--profit);
}

.leaderboard-table .roi-cell.loss {
    color: var(--loss);
}

.leaderboard-table .prize-cell {
    text-align: center;
}

.leaderboard-table .prize-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.35rem 0.75rem;
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.2), rgba(245, 158, 11, 0.2));
    border: 1px solid var(--accent-gold);
    border-radius: 2rem;
    color: var(--accent-gold);
    font-weight: 600;
    font-size: 0.85rem;
}

.leaderboard-table .prize-badge.paid {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(5, 150, 105, 0.2));
    border-color: var(--profit);
    color: var(--profit);
}

/* Profit row highlight */
.leaderboard-table tbody tr.profit {
    background: rgba(16, 185, 129, 0.05);
}

.leaderboard-table tbody tr.profit:hover {
    background: rgba(16, 185, 129, 0.1);
}

/* Loss row styling */
.leaderboard-table tbody tr.loss {
    background: rgba(239, 68, 68, 0.03);
}

.leaderboard-table tbody tr.loss:hover {
    background: rgba(239, 68, 68, 0.08);
}

/* Prize row - no special rank highlight (prize column shows it) */

/* Mini Position Bars */
.pos-dist-header {
    text-align: center;
    padding: 0.75rem 0.5rem;
}

.pos-dist-cell {
    padding: 0.5rem;
}

.mini-position-bars {
    display: flex;
    gap: 2px;
    align-items: flex-end;
    height: 24px;
    justify-content: center;
}

.mini-bar {
    width: 8px;
    min-height: 2px;
    border-radius: 2px 2px 0 0;
    background: var(--text-muted);
    transition: transform 0.2s ease;
    cursor: pointer;
}

.mini-bar:hover {
    transform: scaleY(1.1);
    opacity: 0.9;
}

.mini-bar.pos-1 { background: var(--accent-gold); }
.mini-bar.pos-2 { background: #c0c0c0; }
.mini-bar.pos-3 { background: #cd7f32; }
.mini-bar.pos-4 { background: #cbd5e1; }
.mini-bar.pos-5 { background: #94a3b8; }
.mini-bar.pos-6 { background: #f87171; }
.mini-bar.pos-7 { background: #ef4444; }

/* Position Chart Wrapper */
.position-chart-wrapper {
    position: relative;
    display: inline-block;
}

/* Expanded Position Popup */
.position-popup {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    background: #1e2738;
    border: 1px solid #2d3a4f;
    border-radius: 12px;
    padding: 0.75rem 1.25rem 1rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    min-width: 220px;
    pointer-events: none;
}

.position-popup::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: #1e2738;
}

.position-chart-wrapper:hover .position-popup,
.position-chart-wrapper.expanded .position-popup {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) scale(1);
    pointer-events: auto;
}

.expanded-bars {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    justify-content: center;
    padding-top: 0.5rem;
}

.expanded-bar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.bar-count {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 3px;
}

.bar-wrapper {
    height: 55px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
}

.expanded-bar {
    width: 20px;
    min-height: 3px;
    border-radius: 3px 3px 0 0;
    transition: transform 0.2s ease;
}

.expanded-bar.pos-1 { background: linear-gradient(180deg, #fbbf24, #f59e0b); }
.expanded-bar.pos-2 { background: linear-gradient(180deg, #e5e7eb, #9ca3af); }
.expanded-bar.pos-3 { background: linear-gradient(180deg, #d97706, #b45309); }
.expanded-bar.pos-4 { background: #cbd5e1; }
.expanded-bar.pos-5 { background: #94a3b8; }
.expanded-bar.pos-6 { background: #f87171; }
.expanded-bar.pos-7 { background: #ef4444; }

.bar-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* First row popup - position below to avoid cutoff */
.leaderboard-table tbody tr:first-child .position-popup {
    bottom: auto;
    top: calc(100% + 10px);
}

.leaderboard-table tbody tr:first-child .position-popup::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: #1e2738;
}

/* Hide mobile dropdown portal globally - only shows on mobile/tablet when opened */
#mobile-dropdown-portal {
    display: none !important;
}

@media (max-width: 1024px) {
    #mobile-dropdown-portal {
        display: none !important;
    }
    
    #mobile-dropdown-portal.portal-open {
        display: block !important;
    }
}

.prize-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: var(--bg-tertiary);
    border-radius: 0.75rem;
    margin-top: 0.75rem;
    align-items: center;
}

.prize-legend.complete {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(5, 150, 105, 0.2));
    border: 1px solid var(--profit);
}

.prize-legend.complete .legend-item {
    color: var(--profit);
    background: rgba(16, 185, 129, 0.15);
}

.legend-title {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.legend-item {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--accent-gold);
    background: rgba(251, 191, 36, 0.1);
    padding: 0.25rem 0.75rem;
    border-radius: 0.5rem;
}

/* Charts Section */
.charts-section {
    margin-bottom: 2.5rem;
}

.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    min-height: 300px;
}

.chart-bar-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chart-bar-row {
    display: grid;
    grid-template-columns: 120px 1fr 100px;
    align-items: center;
    gap: 1rem;
}

.chart-player-name {
    font-weight: 600;
    font-size: 0.875rem;
}

.chart-bar-container {
    height: 32px;
    background: var(--bg-tertiary);
    border-radius: 0.5rem;
    overflow: hidden;
    position: relative;
}

.chart-bar {
    height: 100%;
    border-radius: 0.5rem;
    transition: width 0.6s ease;
    position: absolute;
    left: 50%;
}

.chart-bar.profit {
    background: linear-gradient(90deg, var(--profit), #34d399);
    transform: translateX(0);
}

.chart-bar.loss {
    background: linear-gradient(90deg, #f87171, var(--loss));
    transform: translateX(-100%);
}

.chart-value {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.875rem;
    text-align: right;
}

.chart-value.profit { color: var(--profit); }
.chart-value.loss { color: var(--loss); }

/* Player Cards */
.players-section {
    margin-bottom: 2.5rem;
}

.player-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.25rem;
}

.player-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    transition: all 0.2s ease;
}

.player-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
    border-color: var(--accent-secondary);
}

.player-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.player-card-name {
    font-size: 1.25rem;
    font-weight: 700;
}

.player-card-roi {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
    border-radius: 2rem;
}

.player-card-roi.profit {
    background: rgba(16, 185, 129, 0.15);
    color: var(--profit);
}

.player-card-roi.loss {
    background: rgba(239, 68, 68, 0.15);
    color: var(--loss);
}

.player-card-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.player-stat {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.player-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.player-stat-value {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 1rem;
}

.player-card-positions {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.positions-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.positions-bars {
    display: flex;
    gap: 0.25rem;
}

.position-bar {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.position-bar-fill {
    width: 100%;
    background: var(--bg-tertiary);
    border-radius: 0.25rem;
    height: 60px;
    display: flex;
    align-items: flex-end;
    overflow: hidden;
}

.position-bar-inner {
    width: 100%;
    background: linear-gradient(180deg, var(--accent-secondary), #6d28d9);
    border-radius: 0.25rem 0.25rem 0 0;
    transition: height 0.4s ease;
}

.position-bar-inner.first {
    background: linear-gradient(180deg, var(--accent-gold), #d97706);
}

.position-bar-inner.second {
    background: linear-gradient(180deg, var(--accent-silver), #64748b);
}

.position-bar-inner.third {
    background: linear-gradient(180deg, var(--accent-bronze), #a16207);
}

.position-bar-label {
    font-size: 0.625rem;
    color: var(--text-muted);
    font-weight: 500;
}

.position-bar-count {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Position Table */
.positions-section {
    margin-bottom: 2.5rem;
}

.position-table-wrapper {
    overflow-x: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
}

.position-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
}

.position-table th,
.position-table td {
    padding: 0.875rem 1rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.position-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.position-table th:first-child,
.position-table td:first-child {
    text-align: left;
    font-weight: 600;
}

.position-table td:first-child {
    font-family: var(--font-primary);
}

.position-table tr:last-child td {
    border-bottom: none;
}

.position-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.position-cell {
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    display: inline-block;
    min-width: 2rem;
}

/* Zero count - green (good to avoid positions) */
.position-cell.pos-zero { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; }

/* Paid positions (1st, 2nd) - green shades, higher count = more intense */
.position-cell.pos-paid-high { background: rgba(16, 185, 129, 0.35); color: #10b981; }
.position-cell.pos-paid-mid { background: rgba(16, 185, 129, 0.2); color: #10b981; }
.position-cell.pos-paid-low { background: rgba(16, 185, 129, 0.1); color: #6ee7b7; }

/* Middle positions (3rd-5th) - neutral gray, intensity by count */
.position-cell.pos-neutral-high { background: rgba(148, 163, 184, 0.35); color: #94a3b8; }
.position-cell.pos-neutral-mid { background: rgba(148, 163, 184, 0.2); color: #94a3b8; }
.position-cell.pos-neutral-low { background: rgba(148, 163, 184, 0.1); color: #cbd5e1; }

/* Bottom positions (6th, 7th) - red shades, higher count = more intense */
.position-cell.pos-bottom-high { background: rgba(239, 68, 68, 0.35); color: #ef4444; }
.position-cell.pos-bottom-mid { background: rgba(239, 68, 68, 0.2); color: #ef4444; }
.position-cell.pos-bottom-low { background: rgba(239, 68, 68, 0.1); color: #fca5a5; }

/* ===== Points Matrix Table ===== */
.points-matrix-section {
    margin-bottom: 2.5rem;
}

.points-matrix-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
}

.points-matrix-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
}

.points-matrix-table th,
.points-matrix-table td {
    padding: 0.75rem 0.5rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.points-matrix-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: all 0.15s ease;
}

.points-matrix-table th:hover {
    color: var(--accent-primary);
}

.points-matrix-table th.player-header {
    text-align: left;
    min-width: 100px;
}

.points-matrix-table th.total-header {
    background: rgba(251, 191, 36, 0.1);
    color: var(--accent-gold);
}

.points-matrix-table td.player-name-cell {
    text-align: left;
    font-family: var(--font-primary);
    font-weight: 600;
    color: var(--text-primary);
    position: sticky;
    left: 0;
    background: var(--bg-card);
    z-index: 1;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
}

.points-matrix-table tr:last-child td {
    border-bottom: none;
}

.points-matrix-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.points-matrix-table tbody tr:hover td.player-name-cell {
    background: var(--bg-secondary);
}

/* Points cell color coding */
.points-cell {
    font-weight: 500;
    font-size: 0.875rem;
}

.points-cell.points-high {
    color: #10b981;
    background: rgba(16, 185, 129, 0.15);
}

.points-cell.points-mid-high {
    color: #34d399;
    background: rgba(52, 211, 153, 0.1);
}

.points-cell.points-mid-low {
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.1);
}

.points-cell.points-low {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
}

.points-matrix-table td.total-cell {
    font-weight: 700;
    color: var(--accent-gold);
    background: rgba(251, 191, 36, 0.05);
}

/* Sortable headers */
.points-matrix-table th.sorted-asc::after {
    content: ' ▲';
    font-size: 0.6rem;
}

.points-matrix-table th.sorted-desc::after {
    content: ' ▼';
    font-size: 0.6rem;
}

/* View Toggle Buttons */
.view-toggle {
    display: flex;
    gap: 0.25rem;
    margin-left: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-bottom: 1px solid var(--bg-card);
    padding: 0.25rem;
    border-radius: 0.5rem 0.5rem 0 0;
    position: relative;
    top: calc(1.5rem + 1px);
    align-self: flex-end;
    z-index: 1;
}

.toggle-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    font-family: var(--font-primary);
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toggle-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.toggle-btn.active {
    color: var(--bg-primary);
    background: var(--accent-primary);
}

.toggle-btn span {
    font-size: 0.875rem;
}

/* Points Chart Container */
.points-chart-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    border-top-right-radius: 0;
    padding: 1.5rem;
    height: 400px;
}

.points-matrix-wrapper {
    border-top-right-radius: 0;
}

@media (max-width: 640px) {
    .points-chart-wrapper {
        height: 350px;
        padding: 1rem;
    }
    
    .outcome-chart-wrapper {
        padding: 1rem;
        height: 350px;
    }
    
    .view-toggle {
        margin-left: 0;
        margin-top: 0.5rem;
    }
    
    .toggle-btn {
        padding: 0.5rem 0.625rem;
        font-size: 0.6875rem;
    }
}

/* Sortable table headers */
.position-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

.position-table th.sortable:hover {
    color: var(--accent-primary);
    background: rgba(0, 212, 170, 0.1);
}

.position-table th.sortable::after {
    content: '↑↓';
    display: inline-block;
    margin-left: 0.375rem;
    opacity: 0.5;
    font-size: inherit;
    color: white;
    transition: opacity 0.15s ease;
}

.position-table th.sortable:hover::after {
    opacity: 1;
}

.position-table th.sortable.sorted-desc::after {
    content: '▼';
    opacity: 1;
    font-size: inherit;
    color: var(--accent-primary);
}

.position-table th.sortable.sorted-asc::after {
    content: '▲';
    opacity: 1;
    font-size: inherit;
    color: var(--accent-primary);
}

/* Loading State */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
    font-size: 1rem;
}

.loading::after {
    content: '';
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

/* Error State */
.error {
    text-align: center;
    padding: 3rem;
    color: var(--loss);
    background: rgba(239, 68, 68, 0.1);
    border-radius: 1rem;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

footer a {
    color: var(--accent-primary);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Prediction Stats Section (Combined Goal Diff + Exact Score) */
.prediction-stats-section {
    margin-bottom: 2.5rem;
}

.prediction-stats-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
}

.prediction-stats-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem 2rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
    align-items: flex-start;
}

.prediction-stats-summary .summary-stat {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 100px;
}

.prediction-stats-summary .summary-stat.with-percentage .stat-main {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.prediction-stats-summary .stat-number {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.prediction-stats-summary .stat-percentage {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-gold);
    background: rgba(251, 191, 36, 0.15);
    padding: 0.125rem 0.375rem;
    border-radius: 0.375rem;
}

.prediction-stats-summary .stat-text {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Summary stat groups for Goal Diff and Exact Score */
.summary-stat-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-radius: 0.75rem;
    border: 1px solid var(--border);
}

.summary-stat-header {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.summary-stat-header .info-tooltip {
    font-size: 0.8rem;
}

.summary-stat-header .info-tooltip .tooltip-content {
    min-width: 220px;
}

.summary-stat-group .summary-stat {
    min-width: auto;
}

.summary-stat-group .stat-number {
    font-size: 1.25rem;
}

/* Draw group styling */
.summary-stat-group.draw-group {
    border-left-color: #ec4899;
}

.summary-stat-group.draw-group .summary-stat-header {
    color: #ec4899;
}

/* Away group styling */
.summary-stat-group.away-group {
    border-left-color: #3b82f6;
}

.summary-stat-group.away-group .summary-stat-header {
    color: #3b82f6;
}

/* Home group styling */
.summary-stat-group.home-group {
    border-left-color: #cbd5e1;
}

.summary-stat-group.home-group .summary-stat-header {
    color: #e2e8f0;
}

/* Exact group styling */
.summary-stat-group.exact-group {
    border-left-color: var(--accent-secondary);
}

.summary-stat-group.exact-group .summary-stat-header {
    color: var(--accent-secondary);
}

/* Prediction Table */
.prediction-table-wrapper {
    overflow-x: auto;
    margin-top: 0.5rem;
}

.prediction-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-primary);
}

.prediction-table th,
.prediction-table td {
    padding: 0.875rem 1rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.prediction-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg-tertiary);
}

.prediction-table th:first-child {
    text-align: left;
}

.prediction-table td:first-child {
    text-align: left;
}

/* Zone headers (Goal Difference / Exact Score) */
.prediction-table .zone-headers th {
    border-bottom: none;
}

.prediction-table .zone-header {
    font-size: 0.85rem;
    font-weight: 700;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--border);
}

.prediction-table .zone-header.goal-diff-zone {
    background: linear-gradient(135deg, rgba(0, 212, 170, 0.15), rgba(0, 184, 148, 0.1));
    color: var(--accent-primary);
    border-left: 2px solid var(--accent-primary);
}

.prediction-table .zone-header.exact-zone {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.15), rgba(109, 40, 217, 0.1));
    color: var(--accent-secondary);
    border-left: 2px solid var(--accent-secondary);
}

.prediction-table .zone-header.tendency-zone {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.15), rgba(14, 165, 233, 0.1));
    color: #06b6d4;
    border-left: 2px solid #06b6d4;
}

.prediction-table .zone-header.draw-zone {
    background: linear-gradient(135deg, rgba(236, 72, 153, 0.15), rgba(219, 39, 119, 0.1));
    color: #ec4899;
    border-left: 2px solid #ec4899;
}

.prediction-table .zone-header.away-zone {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(37, 99, 235, 0.1));
    color: #3b82f6;
    border-left: 2px solid #3b82f6;
}

.prediction-table .zone-header.home-zone {
    background: linear-gradient(135deg, rgba(226, 232, 240, 0.15), rgba(203, 213, 225, 0.1));
    color: #e2e8f0;
    border-left: 2px solid #cbd5e1;
}

.prediction-table .zone-header.solo-zone {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(217, 119, 6, 0.1));
    color: var(--accent-gold);
    border-left: 2px solid var(--accent-gold);
}

/* Sub-headers */
.prediction-table .sub-headers th {
    font-size: 0.7rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-card);
}

/* Sortable headers */
.prediction-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    position: relative;
}

.prediction-table th.sortable:hover {
    color: var(--accent-primary);
    background: rgba(0, 212, 170, 0.1);
}

.prediction-table th.sortable::after {
    content: '↑↓';
    display: inline-block;
    margin-left: 0.375rem;
    opacity: 0.5;
    font-size: inherit;
    color: white;
    transition: opacity 0.2s ease;
}

.prediction-table th.sortable:hover::after {
    opacity: 1;
}

.prediction-table th.sortable.sorted-asc::after {
    content: '▲';
    opacity: 1;
    color: var(--accent-primary);
}

.prediction-table th.sortable.sorted-desc::after {
    content: '▼';
    opacity: 1;
    color: var(--accent-primary);
}

/* Table body */
.prediction-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.prediction-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.01);
}

.prediction-table tbody tr:nth-child(even):hover {
    background: rgba(255, 255, 255, 0.03);
}

.prediction-table .player-name-cell {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.prediction-table .count-cell {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 1rem;
}

.prediction-table .accuracy-cell {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Goal diff specific colors */
.prediction-table .count-cell.goal-diff,
.prediction-table .accuracy-cell.goal-diff {
    color: var(--accent-primary);
}

/* Exact score specific colors */
.prediction-table .count-cell.exact,
.prediction-table .accuracy-cell.exact {
    color: var(--accent-secondary);
}

/* Safe Winners (Tendency) specific colors */
.prediction-table .count-cell.tendency,
.prediction-table .accuracy-cell.tendency {
    color: #06b6d4;
}

/* Draw Master specific colors */
.prediction-table .count-cell.draw,
.prediction-table .accuracy-cell.draw {
    color: #ec4899;
}

/* Away Master specific colors */
.prediction-table .count-cell.away,
.prediction-table .accuracy-cell.away {
    color: #3b82f6;
}

/* Home Master specific colors */
.prediction-table .count-cell.home,
.prediction-table .accuracy-cell.home {
    color: #e2e8f0;
}

/* Solo Kings specific colors */
.prediction-table .count-cell.solo,
.prediction-table .accuracy-cell.solo {
    color: var(--accent-gold);
}

/* ===== Prediction Subsections ===== */
.prediction-subsection {
    margin-bottom: 2rem;
}

.subsection-title {
    font-family: var(--font-main);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ===== Breakdown Table Styles ===== */
.breakdown-title {
    font-family: var(--font-main);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.breakdown-title .info-tooltip {
    font-size: 0.9rem;
}

.breakdown-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    background: var(--bg-card);
    border-top-right-radius: 0;
}

/* Outcome Distribution Chart */
.outcome-chart-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    border-top-right-radius: 0;
    padding: 1.5rem;
    height: 400px;
    transition: height 0.3s ease;
}


.breakdown-table {
    width: 100%;
    min-width: 650px;
    border-collapse: collapse;
    font-family: var(--font-main);
}

.breakdown-table thead th {
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-card));
    padding: 0.875rem 1rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.breakdown-table thead th:first-child {
    text-align: left;
    padding-left: 1.25rem;
}

.breakdown-table thead th.sortable {
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

.breakdown-table thead th.sortable:hover {
    color: var(--accent-primary);
    background: rgba(0, 212, 170, 0.1);
}

.breakdown-table thead th.sortable::after {
    content: '↑↓';
    display: inline-block;
    margin-left: 0.375rem;
    opacity: 0.4;
    font-size: 0.7rem;
}

.breakdown-table thead th.sortable:hover::after {
    opacity: 1;
}

.breakdown-table thead th.sortable.sorted-asc::after {
    content: '▲';
    opacity: 1;
    color: var(--accent-primary);
}

.breakdown-table thead th.sortable.sorted-desc::after {
    content: '▼';
    opacity: 1;
    color: var(--accent-primary);
}

/* Column header colors */
.breakdown-table thead th.breakdown-wrong {
    color: #ef4444;
}

.breakdown-table thead th.breakdown-home {
    color: #e2e8f0;
}

.breakdown-table thead th.breakdown-away {
    color: #3b82f6;
}

.breakdown-table thead th.breakdown-draw {
    color: #ec4899;
}

.breakdown-table thead th.breakdown-gd {
    color: var(--accent-primary);
}

.breakdown-table thead th.breakdown-exact {
    color: var(--accent-secondary);
}

.breakdown-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.15s ease;
}

.breakdown-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.breakdown-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.01);
}

.breakdown-table tbody tr:nth-child(even):hover {
    background: rgba(255, 255, 255, 0.04);
}

.breakdown-table tbody td {
    padding: 0.75rem 1rem;
    text-align: center;
}

.breakdown-table tbody td:first-child {
    text-align: left;
    padding-left: 1.25rem;
}

.breakdown-table .player-name-cell {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

/* Breakdown cells */
.breakdown-cell {
    text-align: center;
    vertical-align: middle;
}

.breakdown-count {
    display: block;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 1rem;
}

.breakdown-pct {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    opacity: 0.7;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    background: rgba(255, 255, 255, 0.05);
    margin-top: 0.25rem;
}

/* Cell type colors */
.breakdown-cell.wrong .breakdown-count {
    color: #ef4444;
}

.breakdown-cell.wrong .breakdown-pct {
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.1);
}

.breakdown-cell.home .breakdown-count {
    color: #e2e8f0;
}

.breakdown-cell.home .breakdown-pct {
    color: #cbd5e1;
    background: rgba(226, 232, 240, 0.1);
}

.breakdown-cell.away .breakdown-count {
    color: #3b82f6;
}

.breakdown-cell.away .breakdown-pct {
    color: #93c5fd;
    background: rgba(59, 130, 246, 0.1);
}

.breakdown-cell.draw .breakdown-count {
    color: #ec4899;
}

.breakdown-cell.draw .breakdown-pct {
    color: #f9a8d4;
    background: rgba(236, 72, 153, 0.1);
}

.breakdown-cell.gd .breakdown-count {
    color: var(--accent-primary);
}

.breakdown-cell.gd .breakdown-pct {
    color: var(--accent-primary);
    background: rgba(0, 212, 170, 0.1);
}

.breakdown-cell.exact .breakdown-count {
    color: var(--accent-secondary);
}

.breakdown-cell.exact .breakdown-pct {
    color: var(--accent-secondary);
    background: rgba(139, 92, 246, 0.1);
}

/* Fun Stats Section */
.fun-stats-section {
    margin-bottom: 2.5rem;
}

.fun-stats-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.fun-stats-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

@media (max-width: 1024px) {
    .fun-stats-row {
        grid-template-columns: 1fr;
    }
    
    /* Tablet: Enable horizontal scroll on wide tables */
    .prediction-table-wrapper,
    .position-table-wrapper,
    .streaks-table-wrapper,
    .breakdown-table-wrapper,
    .points-matrix-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Table wrapper styling for horizontal scroll */
    .prediction-table-wrapper,
    .position-table-wrapper,
    .streaks-table-wrapper,
    .breakdown-table-wrapper,
    .points-matrix-wrapper {
        position: relative;
        overflow-x: auto;
        overflow-y: visible;
        -webkit-overflow-scrolling: touch;
    }
    
    /* ===== STICKY PLAYER COLUMN FOR ALL TABLES ===== */
    
    /* Position table - simple sticky (no rowspan) */
    .position-table td:first-child {
        position: sticky;
        left: 0;
        z-index: 5;
        background: #151d2b;
        box-shadow: -50px 0 0 0 #151d2b;
        border-right: 1px solid rgba(255, 255, 255, 0.08);
    }
    
    .position-table tbody tr:nth-child(even) td:first-child {
        background: #181f2e;
        box-shadow: -50px 0 0 0 #181f2e;
    }
    
    .position-table th:first-child {
        position: sticky;
        left: 0;
        z-index: 10;
        background: #1a2332;
        box-shadow: -50px 0 0 0 #1a2332;
        border-right: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .position-table tbody tr:hover td:first-child {
        background: #1c2536;
        box-shadow: -50px 0 0 0 #1c2536;
    }
    
    /* Prediction & Streaks tables - sticky with pseudo-element to cover gap */
    .prediction-table .player-name-cell,
    .streaks-table .player-name {
        position: sticky;
        left: 0;
        z-index: 5;
        background: #151d2b;
        box-shadow: -50px 0 0 0 #151d2b;
    }
    
    /* Pseudo-element extends the cell to the right to cover scrolling content */
    .prediction-table .player-name-cell::after,
    .streaks-table .player-name::after {
        content: '';
        position: absolute;
        top: 0;
        bottom: 0;
        right: -1px;
        width: 3px;
        background: linear-gradient(to right, #151d2b, transparent);
        z-index: 10;
    }
    
    .prediction-table tbody tr:nth-child(even) .player-name-cell,
    .streaks-table tbody tr:nth-child(even) .player-name {
        background: #181f2e;
        box-shadow: -50px 0 0 0 #181f2e;
    }
    
    .prediction-table tbody tr:nth-child(even) .player-name-cell::after,
    .streaks-table tbody tr:nth-child(even) .player-name::after {
        background: linear-gradient(to right, #181f2e, transparent);
    }
    
    .prediction-table tbody tr:hover .player-name-cell,
    .streaks-table tbody tr:hover .player-name {
        background: #1c2536;
        box-shadow: -50px 0 0 0 #1c2536;
    }
    
    .prediction-table tbody tr:hover .player-name-cell::after,
    .streaks-table tbody tr:hover .player-name::after {
        background: linear-gradient(to right, #1c2536, transparent);
    }
    
    /* Headers for rowspan tables */
    .prediction-table thead tr.zone-headers th:first-child,
    .streaks-table .name-header {
        position: sticky;
        left: 0;
        z-index: 15;
        background: #1a2332;
        box-shadow: -50px 0 0 0 #1a2332;
    }
    
    .prediction-table thead tr.zone-headers th:first-child::after,
    .streaks-table .name-header::after {
        content: '';
        position: absolute;
        top: 0;
        bottom: 0;
        right: -1px;
        width: 4px;
        background: linear-gradient(to right, #1a2332, transparent);
        z-index: 10;
    }
    
    /* Points Matrix table - sticky player column */
    .points-matrix-table td.player-name-cell {
        position: sticky;
        left: 0;
        z-index: 5;
        background: #151d2b;
        box-shadow: -50px 0 0 0 #151d2b;
    }
    
    .points-matrix-table tbody tr:nth-child(even) td.player-name-cell {
        background: #181f2e;
        box-shadow: -50px 0 0 0 #181f2e;
    }
    
    .points-matrix-table tbody tr:hover td.player-name-cell {
        background: #1c2536;
        box-shadow: -50px 0 0 0 #1c2536;
    }
    
    .points-matrix-table th.player-header {
        position: sticky;
        left: 0;
        z-index: 10;
        background: #1a2332;
        box-shadow: -50px 0 0 0 #1a2332;
    }
    
    /* Leaderboard table - sticky player column (2nd column after rank) */
    .leaderboard-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .leaderboard-table .rank-col {
        position: sticky;
        left: 0;
        z-index: 6;
        background: #151d2b;
        box-shadow: -50px 0 0 0 #151d2b;
    }
    
    .leaderboard-table .player-name-cell {
        position: sticky;
        left: 35px;
        z-index: 5;
        background: #151d2b;
        box-shadow: -35px 0 0 0 #151d2b;
    }
    
    .leaderboard-table .player-name-cell::after {
        content: '';
        position: absolute;
        top: 0;
        bottom: 0;
        right: -1px;
        width: 3px;
        background: linear-gradient(to right, #151d2b, transparent);
        z-index: 10;
    }
    
    .leaderboard-table thead th.rank-col {
        background: #1a2332;
        box-shadow: -50px 0 0 0 #1a2332;
        z-index: 11;
    }
    
    .leaderboard-table thead th:nth-child(2) {
        position: sticky;
        left: 35px;
        z-index: 10;
        background: #1a2332;
        box-shadow: -35px 0 0 0 #1a2332;
    }
    
    .leaderboard-table thead th:nth-child(2)::after {
        content: '';
        position: absolute;
        top: 0;
        bottom: 0;
        right: -1px;
        width: 3px;
        background: linear-gradient(to right, #1a2332, transparent);
        z-index: 10;
    }
    
    .leaderboard-table tbody tr:nth-child(even) .rank-col {
        background: #181f2e;
        box-shadow: -50px 0 0 0 #181f2e;
    }
    
    .leaderboard-table tbody tr:nth-child(even) .player-name-cell {
        background: #181f2e;
        box-shadow: -35px 0 0 0 #181f2e;
    }
    
    .leaderboard-table tbody tr:nth-child(even) .player-name-cell::after {
        background: linear-gradient(to right, #181f2e, transparent);
    }
    
    .leaderboard-table tbody tr:hover .rank-col {
        background: #1c2536;
        box-shadow: -50px 0 0 0 #1c2536;
    }
    
    .leaderboard-table tbody tr:hover .player-name-cell {
        background: #1c2536;
        box-shadow: -35px 0 0 0 #1c2536;
    }
    
    .leaderboard-table tbody tr:hover .player-name-cell::after {
        background: linear-gradient(to right, #1c2536, transparent);
    }
    
    /* Breakdown table - sticky player column */
    .breakdown-table .player-name-cell {
        position: sticky;
        left: 0;
        z-index: 5;
        background: #151d2b;
        box-shadow: -50px 0 0 0 #151d2b;
    }
    
    .breakdown-table .player-name-cell::after {
        content: '';
        position: absolute;
        top: 0;
        bottom: 0;
        right: -1px;
        width: 3px;
        background: linear-gradient(to right, #151d2b, transparent);
        z-index: 10;
    }
    
    .breakdown-table tbody tr:nth-child(even) .player-name-cell {
        background: #181f2e;
        box-shadow: -50px 0 0 0 #181f2e;
    }
    
    .breakdown-table tbody tr:nth-child(even) .player-name-cell::after {
        background: linear-gradient(to right, #181f2e, transparent);
    }
    
    .breakdown-table tbody tr:hover .player-name-cell {
        background: #1c2536;
        box-shadow: -50px 0 0 0 #1c2536;
    }
    
    .breakdown-table tbody tr:hover .player-name-cell::after {
        background: linear-gradient(to right, #1c2536, transparent);
    }
    
    .breakdown-table thead th:first-child {
        position: sticky;
        left: 0;
        z-index: 10;
        background: #1a2332;
        box-shadow: -50px 0 0 0 #1a2332;
    }
    
    .breakdown-table thead th:first-child::after {
        content: '';
        position: absolute;
        top: 0;
        bottom: 0;
        right: -1px;
        width: 3px;
        background: linear-gradient(to right, #1a2332, transparent);
        z-index: 10;
    }
}

.fun-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
}

.fun-stat-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Info Tooltip */
.info-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: help;
}

.info-icon {
    font-size: 0.875rem;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.info-tooltip:hover .info-icon {
    opacity: 1;
}

.tooltip-content {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    border: 1px solid var(--accent-primary);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    min-width: 280px;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.6;
    color: var(--text-secondary);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.2s ease;
    z-index: 9999;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    white-space: normal;
}

.tooltip-content::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid var(--accent-primary);
}

.info-tooltip:hover .tooltip-content {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.tooltip-content strong {
    color: var(--text-primary);
}

.tooltip-content em {
    color: var(--text-muted);
    font-style: italic;
}

.fun-stat-note {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    padding: 0.5rem 0.75rem;
    background: rgba(0, 212, 170, 0.05);
    border-left: 3px solid var(--accent-primary);
    border-radius: 0 0.375rem 0.375rem 0;
}

/* Consistency Kings */
.consistency-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.consistency-item {
    display: grid;
    grid-template-columns: 40px minmax(80px, 1fr) auto auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: var(--bg-tertiary);
    border-radius: 0.75rem;
    border-left: 4px solid var(--border);
    transition: all 0.2s ease;
}

.consistency-item:hover {
    transform: translateX(4px);
}

.consistency-item.gold {
    border-left-color: var(--accent-gold);
    background: rgba(251, 191, 36, 0.08);
}

.consistency-item.blue {
    border-left-color: #3b82f6;
    background: rgba(59, 130, 246, 0.08);
}

.consistency-item.gray {
    border-left-color: var(--text-muted);
    background: rgba(148, 163, 184, 0.08);
}

.consistency-item.purple {
    border-left-color: var(--accent-secondary);
    background: rgba(124, 58, 237, 0.08);
}

.consistency-item.orange {
    border-left-color: #f97316;
    background: rgba(249, 115, 22, 0.08);
}

.consistency-item.cyan {
    border-left-color: #06b6d4;
    background: rgba(6, 182, 212, 0.08);
}

.consistency-rank {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-muted);
    text-align: center;
}

.consistency-name {
    font-weight: 600;
    color: var(--text-primary);
}

.consistency-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    width: fit-content;
}

.consistency-badge.gold {
    background: rgba(251, 191, 36, 0.2);
    color: var(--accent-gold);
}

.consistency-badge.blue {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.consistency-badge.gray {
    background: rgba(148, 163, 184, 0.2);
    color: var(--text-muted);
}

.consistency-badge.purple {
    background: rgba(124, 58, 237, 0.2);
    color: var(--accent-secondary);
}

.consistency-badge.orange {
    background: rgba(249, 115, 22, 0.2);
    color: #fb923c;
}

.consistency-badge.cyan {
    background: rgba(6, 182, 212, 0.2);
    color: #22d3ee;
}

.consistency-stats {
    display: flex;
    gap: 0.5rem;
}

.stat-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg-card);
    padding: 0.375rem 0.625rem;
    border-radius: 0.5rem;
    min-width: 50px;
}

.stat-pill .stat-label {
    font-size: 0.625rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.stat-pill .stat-value {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Streaks Table */
.streaks-card {
    overflow: visible;
}

.streaks-table-wrapper {
    overflow-x: auto;
    margin-top: 0.5rem;
}

.streaks-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.875rem;
}

.streaks-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Zone Headers (Hot/Mid/Cold) */
.streaks-table .zone-header {
    padding: 0.75rem 0.5rem;
    font-weight: 700;
    font-size: 0.9rem;
    text-align: center;
    border-bottom: 2px solid;
}

.streaks-table .zone-header.hot {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border-color: #ef4444;
}

.streaks-table .zone-header.mid {
    background: rgba(148, 163, 184, 0.15);
    color: #94a3b8;
    border-color: #94a3b8;
}

.streaks-table .zone-header.cold {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border-color: #60a5fa;
}

.streaks-table .name-header {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 0.75rem;
    font-weight: 700;
    text-align: left;
    border-bottom: 2px solid var(--border);
    vertical-align: middle;
}

/* Sub Headers (Active/Longest/2+ Streaks) */
.streaks-table .sub-header {
    padding: 0.5rem 0.375rem;
    font-weight: 600;
    font-size: 0.7rem;
    text-align: center;
    white-space: nowrap;
    position: relative;
}

.streaks-table .sub-header.hot {
    background: rgba(239, 68, 68, 0.08);
    color: #ef4444;
    border-bottom: 1px solid rgba(239, 68, 68, 0.3);
}

.streaks-table .sub-header.mid {
    background: rgba(148, 163, 184, 0.08);
    color: #94a3b8;
    border-bottom: 1px solid rgba(148, 163, 184, 0.3);
}

.streaks-table .sub-header.cold {
    background: rgba(59, 130, 246, 0.08);
    color: #60a5fa;
    border-bottom: 1px solid rgba(59, 130, 246, 0.3);
}

/* Sortable Sub Headers */
.streaks-table .sub-header.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
}

.streaks-table .sub-header.sortable:hover {
    filter: brightness(1.3);
}

.streaks-table .sub-header.sortable::after {
    content: '↑↓';
    display: inline-block;
    margin-left: 0.375rem;
    opacity: 1;
    font-size: inherit;
    color: white;
    transition: opacity 0.15s ease;
}

.streaks-table .sub-header.sortable:hover::after {
    opacity: 1;
}

.streaks-table .sub-header.sortable.sorted-desc::after {
    content: '▼';
    opacity: 1;
    font-size: inherit;
    color: white;
}

.streaks-table .sub-header.sortable.sorted-asc::after {
    content: '▲';
    opacity: 1;
    font-size: inherit;
    color: white;
}

/* Table Body */
.streaks-table tbody tr {
    transition: background 0.15s ease;
}

.streaks-table tbody tr:hover {
    background: var(--bg-tertiary);
}

.streaks-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.streaks-table tbody tr:nth-child(even):hover {
    background: var(--bg-tertiary);
}

.streaks-table .player-name {
    padding: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.streaks-table .streak-cell {
    padding: 0.5rem;
    text-align: center;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    font-weight: 500;
}

.streaks-table .streak-cell.hot {
    background: rgba(239, 68, 68, 0.03);
}

.streaks-table .streak-cell.mid {
    background: rgba(148, 163, 184, 0.03);
}

.streaks-table .streak-cell.cold {
    background: rgba(59, 130, 246, 0.03);
}

/* Active Streak Badge */
.active-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    padding: 0.2rem 0.5rem;
    border-radius: 1rem;
    font-weight: 700;
    font-size: 0.8rem;
    background: rgba(239, 68, 68, 0.25);
    color: #ef4444;
    animation: pulse 2s infinite;
}

.active-badge.mid {
    background: rgba(148, 163, 184, 0.25);
    color: #94a3b8;
}

.active-badge.cold {
    background: rgba(59, 130, 246, 0.25);
    color: #60a5fa;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Form Guide */
.form-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.form-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-radius: 0.75rem;
}

.form-name {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 100px;
}

.form-circles {
    display: flex;
    gap: 0.5rem;
}

.form-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    transition: transform 0.2s ease;
}

.form-circle:hover {
    transform: scale(1.1);
}

.form-circle.first {
    background: linear-gradient(135deg, var(--accent-gold), #d97706);
    color: var(--bg-primary);
}

.form-circle.second {
    background: linear-gradient(135deg, var(--accent-silver), #64748b);
    color: var(--bg-primary);
}

.form-circle.third {
    background: linear-gradient(135deg, var(--accent-bronze), #a16207);
    color: var(--bg-primary);
}

.form-circle.mid {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.form-circle.bottom {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Matchday Performance */
.matchday-ranking-tables {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.ranking-table {
    background: var(--bg-tertiary);
    border-radius: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
}

.ranking-table.best {
    border-left: 3px solid var(--accent-gold);
}

.ranking-table.worst {
    border-left: 3px solid #ef4444;
}

.ranking-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.ranking-table table {
    width: 100%;
    border-collapse: collapse;
}

.ranking-table tr {
    transition: background 0.15s ease;
}

.ranking-table tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.ranking-table td {
    padding: 0.375rem 0.5rem;
    font-size: 0.8rem;
}

.ranking-table td.rank {
    font-weight: 700;
    color: var(--text-muted);
    width: 24px;
}

.ranking-table td.name {
    font-weight: 600;
    color: var(--text-primary);
}

.ranking-table td.gw {
    color: var(--text-secondary);
    text-align: center;
}

.ranking-table td.points {
    font-weight: 600;
    text-align: right;
}

.ranking-table.best td.points {
    color: var(--accent-gold);
}

.ranking-table.worst td.points {
    color: #ef4444;
}

@media (max-width: 600px) {
    .matchday-ranking-tables {
        grid-template-columns: 1fr;
    }
}

.performance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
}

.performance-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-radius: 0.75rem;
}

.performance-name {
    font-weight: 600;
    color: var(--text-primary);
}

.performance-stats {
    display: flex;
    gap: 0.5rem;
}

.perf-badge {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    background: var(--bg-card);
    color: var(--text-secondary);
}

.perf-badge.best {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.perf-badge.worst {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* Favorite Scorelines */
.scorelines-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
}

.scoreline-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-radius: 0.75rem;
}

.scoreline-name {
    font-weight: 600;
    color: var(--text-primary);
}

.scoreline-chips {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.scoreline-chip {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 0.25rem 0.625rem;
    border-radius: 0.375rem;
    background: var(--bg-card);
    color: var(--text-secondary);
}

.scoreline-chip.top {
    background: linear-gradient(135deg, var(--accent-primary), #059669);
    color: var(--bg-primary);
}

.scoreline-chip.empty {
    color: var(--text-muted);
    font-style: italic;
}

.scoreline-chip small {
    opacity: 0.75;
    font-weight: 400;
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    main {
        padding: 1rem;
    }
    
    .leaderboard-item {
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto;
        gap: 0.75rem 1rem;
    }
    
    .stat-group {
        align-items: flex-start;
    }
    
    .net-profit {
        grid-column: span 2;
        text-align: left;
    }
    
    .chart-bar-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .player-cards {
        grid-template-columns: 1fr;
    }
    
    .exact-score-item {
        grid-template-columns: 40px 1fr auto;
        gap: 0.75rem;
    }
    
    .exact-progress {
        display: none;
    }
    
    .exact-scores-summary {
        flex-direction: column;
        gap: 1rem;
    }
    
    .exact-scores-summary .summary-stat {
        min-width: auto;
    }
    
    .exact-scores-summary .summary-stat.with-percentage .stat-main {
        flex-wrap: wrap;
    }
    
    .goal-diff-item {
        grid-template-columns: 40px 1fr auto;
        gap: 0.75rem;
    }
    
    .goal-diff-progress {
        display: none;
    }
    
    .goal-diff-summary {
        flex-direction: column;
        gap: 1rem;
    }
    
    .goal-diff-summary .summary-stat {
        min-width: auto;
    }
    
    .goal-diff-summary .summary-stat.with-percentage .stat-main {
        flex-wrap: wrap;
    }
    
    .nav-container {
        padding: 0.75rem 1rem;
        gap: 0.375rem;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: visible;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
    }
    
    .nav-item {
        padding: 0.5rem 0.875rem;
        font-size: 0.75rem;
        min-height: 44px; /* Touch-friendly */
        scroll-snap-align: start;
    }
    
    /* Mobile dropdown - HIDE original dropdown, use portal instead */
    .nav-dropdown {
        position: static;
    }
    
    /* Hide the original dropdown content on mobile - portal will show it */
    .nav-dropdown-content {
        display: none !important;
    }
    
    /* Disable hover on mobile */
    .nav-dropdown:hover .nav-dropdown-content {
        display: none !important;
    }
    
    /* Arrow rotation when open */
    .nav-dropdown.dropdown-open .dropdown-arrow {
        transform: rotate(180deg);
    }
    
    /* ===== PORTAL STYLES - Rendered outside nav scroll container ===== */
    #mobile-dropdown-portal {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 99999;
        background: rgba(10, 15, 25, 0.85);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }
    
    #mobile-dropdown-portal.portal-open {
        display: block;
        animation: fadeIn 0.2s ease;
    }
    
    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
    
    @keyframes slideDown {
        from { 
            opacity: 0;
            transform: translateX(-50%) translateY(-10px);
        }
        to { 
            opacity: 1;
            transform: translateX(-50%) translateY(0);
        }
    }
    
    #mobile-dropdown-menu {
        position: fixed;
        top: 60px;
        left: 50%;
        transform: translateX(-50%);
        width: calc(100% - 2rem);
        max-width: 320px;
        background: linear-gradient(145deg, #1e293b, #0f172a);
        border: 1px solid rgba(0, 212, 170, 0.4);
        border-radius: 1rem;
        padding: 0.5rem;
        display: flex;
        flex-direction: column;
        gap: 0.375rem;
        box-shadow: 
            0 0 0 1px rgba(0, 212, 170, 0.1),
            0 20px 50px rgba(0, 0, 0, 0.5),
            0 0 30px rgba(0, 212, 170, 0.1);
        animation: slideDown 0.25s ease;
    }
    
    #mobile-dropdown-menu::before {
        display: none;
    }
    
    #mobile-dropdown-menu a {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.875rem 1rem;
        font-size: 0.9375rem;
        font-weight: 500;
        color: #e2e8f0;
        text-decoration: none;
        border-radius: 0.625rem;
        background: rgba(255, 255, 255, 0.03);
        min-height: 48px;
        box-sizing: border-box;
        transition: all 0.15s ease;
        border: 1px solid transparent;
        white-space: nowrap;
    }
    
    #mobile-dropdown-menu a:active {
        background: rgba(0, 212, 170, 0.15);
        border-color: rgba(0, 212, 170, 0.3);
        color: #00d4aa;
        transform: scale(0.98);
    }
    
    /* Tap hint at bottom */
    #mobile-dropdown-menu::after {
        content: 'Tap outside to close';
        display: block;
        text-align: center;
        font-size: 0.6875rem;
        color: rgba(255, 255, 255, 0.3);
        padding: 0.75rem 0 0.25rem;
        margin-top: 0.25rem;
    }
    
    /* Mobile table scroll containers */
    .prediction-table-wrapper,
    .position-table-wrapper,
    .streaks-table-wrapper,
    .breakdown-table-wrapper,
    .points-matrix-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem;
        padding: 0 1rem;
    }
    
    .prediction-table,
    .position-table,
    .streaks-table {
        min-width: 700px;
    }
    
    /* Weekly Winners - single column */
    .weekly-winners-grid {
        grid-template-columns: 1fr !important;
    }
    
    .week-card {
        padding: 0.75rem;
    }
    
    .week-header {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    /* Summary cards stack */
    .prediction-stats-summary {
        flex-direction: column;
        gap: 1rem;
    }
    
    .prediction-stats-summary .summary-stat-group {
        padding-left: 0;
        border-left: none;
        padding-top: 1rem;
        border-top: 1px solid var(--border);
        width: 100%;
    }
    
    /* Section titles smaller */
    .section-title {
        font-size: 1.25rem;
    }
    
    /* Info tooltips - tap to toggle on mobile */
    .info-tooltip .tooltip-content {
        display: none;
        position: fixed;
        left: 1rem;
        right: 1rem;
        top: 80px;
        width: auto;
        max-width: none;
        transform: none;
        z-index: 10001;
    }
    
    /* Disable hover on mobile */
    .info-tooltip:hover .tooltip-content {
        display: none;
        opacity: 0;
        visibility: hidden;
    }
    
    /* Show tooltip when .tooltip-active class is added (via JS) */
    .info-tooltip.tooltip-active .tooltip-content {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }
    
    /* Leaderboard adjustments */
    .leaderboard-item {
        padding: 1rem;
    }
    
    .stat-group {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .stat-label {
        font-size: 0.625rem;
    }
    
    .stat-value {
        font-size: 0.875rem;
    }
    
    /* Prediction stats container */
    .prediction-stats-container {
        padding: 1rem;
    }
    
    /* Fun stats cards */
    .fun-stat-card {
        padding: 1rem;
    }
    
    .fun-stat-title {
        font-size: 1rem;
    }
    
    /* Prize structure */
    .prize-structure-section {
        padding: 1rem;
    }
    
    .prize-cards {
        grid-template-columns: 1fr;
    }
    
    /* Collapsible leg sections */
    .leg-header {
        padding: 0.75rem 1rem;
    }
    
    .leg-content {
        padding: 1rem;
    }
}

/* Medium phones (640px and below) */
@media (max-width: 640px) {
    /* Summary grid adjustments */
    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Form guide - wrap badges */
    .form-item {
        flex-wrap: wrap;
    }
    
    .form-badges {
        flex-wrap: wrap;
        justify-content: flex-start;
    }
    
    /* Consistency grid adjustments */
    .consistency-item {
        grid-template-columns: 36px 1fr;
    }
    
    .consistency-badge {
        grid-column: span 2;
        justify-self: start;
        margin-top: 0.25rem;
    }
    
    /* Scorelines grid */
    .scorelines-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
    
    /* Performance grid */
    .performance-grid {
        grid-template-columns: 1fr;
    }
}

/* Small phones (480px and below) */
@media (max-width: 480px) {
    :root {
        --header-height: 60px;
        --nav-height: 48px;
    }
    
    /* Adjust body padding for smaller nav */
    body {
        padding-top: 52px;
    }
    
    /* Header compact (hidden on mobile anyway) */
    .header-content {
        padding: 0.75rem 1rem;
    }
    
    .logo h1 {
        font-size: 1rem;
    }
    
    .logo-icon {
        font-size: 1.5rem;
    }
    
    .season-badge {
        font-size: 0.625rem;
        padding: 0.25rem 0.5rem;
    }
    
    .season-selector {
        padding: 0.125rem;
        gap: 0.125rem;
    }
    
    .season-btn {
        font-size: 0.625rem;
        padding: 0.25rem 0.5rem;
    }
    
    .refresh-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
        min-height: 44px;
    }
    
    /* Nav even more compact */
    .nav-container {
        padding: 0.5rem 0.75rem;
        gap: 0.25rem;
    }
    
    .nav-item {
        padding: 0.375rem 0.625rem;
        font-size: 0.6875rem;
    }
    
    /* Dropdown portal position adjustment for smaller screens */
    #mobile-dropdown-menu {
        top: 52px;
        max-width: 280px;
    }
    
    #mobile-dropdown-menu a {
        padding: 0.75rem 0.875rem;
        font-size: 0.875rem;
    }
    
    /* Main content */
    main {
        padding: 0.75rem;
    }
    
    /* Section titles */
    .section-title {
        font-size: 1.125rem;
        gap: 0.5rem;
    }
    
    .title-icon {
        font-size: 1.25rem;
    }
    
    /* Summary cards */
    .summary-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .summary-card {
        padding: 1rem;
    }
    
    .summary-value {
        font-size: 1.5rem;
    }
    
    .summary-label {
        font-size: 0.6875rem;
    }
    
    /* Prediction stats banner */
    .prediction-stats-summary .stat-number {
        font-size: 1.25rem;
    }
    
    .prediction-stats-summary .summary-stat-header {
        font-size: 0.75rem;
    }
    
    /* Tables - even more compact */
    .prediction-table {
        min-width: 600px;
        font-size: 0.75rem;
    }
    
    .prediction-table thead .zone-headers th {
        padding: 0.5rem 0.5rem;
        font-size: 0.6875rem;
    }
    
    .prediction-table thead .sub-headers th {
        padding: 0.375rem 0.5rem;
        font-size: 0.625rem;
    }
    
    .prediction-table tbody td {
        padding: 0.5rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .prediction-table .player-name-cell {
        font-size: 0.75rem;
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Position table compact */
    .position-table {
        min-width: 500px;
    }
    
    .position-table th,
    .position-table td {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
    }
    
    /* Streaks table compact */
    .streaks-table {
        min-width: 550px;
    }
    
    .streaks-table th,
    .streaks-table td {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
    }
    
    /* Leaderboard table compact */
    .leaderboard-table {
        min-width: 600px;
    }
    
    .leaderboard-table th,
    .leaderboard-table td {
        padding: 0.5rem 0.625rem;
        font-size: 0.75rem;
    }
    
    .leaderboard-table .player-name-cell {
        font-size: 0.75rem;
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .leaderboard-table .rank-col {
        padding: 0.5rem 0.375rem;
        width: 35px;
    }
    
    /* Breakdown table (Outcome Distribution) compact */
    .breakdown-table {
        min-width: 550px;
    }
    
    .breakdown-table th,
    .breakdown-table td {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .breakdown-table .player-name-cell {
        font-size: 0.75rem;
        max-width: 70px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .breakdown-cell .breakdown-count {
        font-size: 0.75rem;
    }
    
    .breakdown-cell .breakdown-pct {
        font-size: 0.625rem;
        padding: 0.125rem 0.25rem;
    }
    
    /* Weekly winners */
    .week-header {
        font-size: 0.75rem;
        padding: 0.375rem 0.5rem;
    }
    
    .winner-name {
        font-size: 0.8125rem;
    }
    
    .prize-badge {
        font-size: 0.625rem;
        padding: 0.125rem 0.375rem;
    }
    
    /* Fun stats */
    .fun-stat-card {
        padding: 1rem;
    }
    
    .fun-stat-title {
        font-size: 1rem;
    }
    
    /* Consistency items */
    .consistency-item {
        grid-template-columns: 32px 1fr auto;
        gap: 0.5rem;
        padding: 0.5rem;
    }
    
    .consistency-rank {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }
    
    .consistency-name {
        font-size: 0.8125rem;
    }
    
    .consistency-stats {
        font-size: 0.6875rem;
    }
    
    .consistency-badge {
        font-size: 0.5625rem;
        padding: 0.125rem 0.375rem;
    }
    
    /* Form guide */
    .form-item {
        gap: 0.375rem;
        padding: 0.5rem;
    }
    
    .form-badges {
        gap: 0.25rem;
    }
    
    .form-badge {
        width: 24px;
        height: 24px;
        font-size: 0.625rem;
    }
    
    /* Best/Worst matchdays */
    .matchday-ranking-tables {
        gap: 0.75rem;
    }
    
    .ranking-table-card {
        padding: 0.75rem;
    }
    
    .ranking-table th,
    .ranking-table td {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
    }
    
    /* Performance grid */
    .performance-grid {
        grid-template-columns: 1fr;
    }
    
    .performance-item {
        padding: 0.75rem;
    }
    
    /* Scorelines */
    .scoreline-item {
        padding: 0.5rem;
    }
    
    .scoreline-badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
    
    /* Leaderboard */
    .leaderboard-item {
        padding: 0.75rem;
        gap: 0.5rem;
    }
    
    .player-rank {
        width: 32px;
        height: 32px;
        font-size: 0.875rem;
    }
    
    .player-name {
        font-size: 0.9375rem;
    }
    
    .final-prize-badge {
        font-size: 0.5625rem;
        padding: 0.125rem 0.375rem;
    }
    
    /* Prize structure */
    .prize-structure-section summary {
        padding: 0.75rem;
        font-size: 0.875rem;
    }
    
    .prize-cards {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .prize-card {
        padding: 0.75rem;
    }
    
    /* Player stats cards */
    .player-card {
        padding: 1rem;
    }
    
    .player-card-name {
        font-size: 1rem;
    }
    
    /* Collapsible sections */
    .leg-header {
        padding: 0.75rem;
        font-size: 0.875rem;
    }
    
    /* Info tooltips */
    .info-icon {
        font-size: 0.75rem;
    }
    
    .tooltip-content {
        font-size: 0.75rem;
        line-height: 1.5;
        max-height: 60vh;
        overflow-y: auto;
    }
}

/* Landscape phones */
@media (max-width: 640px) and (orientation: landscape) {
    :root {
        --header-height: 50px;
        --nav-height: 44px;
    }
    
    .header-content {
        flex-direction: row;
        padding: 0.5rem 1rem;
    }
    
    .logo h1 {
        font-size: 0.875rem;
    }
    
    .nav-container {
        padding: 0.375rem 0.75rem;
    }
    
    .nav-item {
        padding: 0.25rem 0.5rem;
        font-size: 0.625rem;
        min-height: 36px;
    }
    
    /* Dropdown portal position for landscape */
    #mobile-dropdown-menu {
        top: 48px;
        max-width: 260px;
    }
    
    main {
        padding: 0.5rem;
    }
    
    /* Two-column layout for some grids in landscape */
    .weekly-winners-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ===== AI CHAT ASSISTANT ===== */
#ai-chat-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: var(--font-primary);
}

/* Chat Toggle Button */
.chat-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(168, 85, 247, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.chat-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(168, 85, 247, 0.6);
}

.chat-toggle-btn:active {
    transform: scale(0.95);
}

.chat-icon,
.chat-icon-close {
    font-size: 1.5rem;
    transition: all 0.3s ease;
    position: absolute;
}

.chat-icon-close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
    font-size: 1.25rem;
    color: white;
}

#ai-chat-container.chat-open .chat-icon {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

#ai-chat-container.chat-open .chat-icon-close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

/* Chat Panel */
.chat-panel {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 500px;
    max-height: calc(100vh - 150px);
    background: var(--bg-secondary);
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

#ai-chat-container.chat-open .chat-panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Chat Resize Handle */
.chat-resize-handle {
    position: absolute;
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    cursor: nwse-resize;
    z-index: 10;
    background: linear-gradient(135deg, rgba(255,255,255,0.3) 0%, transparent 50%);
    border-top-left-radius: 16px;
}

.chat-resize-handle::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    width: 8px;
    height: 8px;
    border-left: 2px solid rgba(255,255,255,0.5);
    border-top: 2px solid rgba(255,255,255,0.5);
}

.chat-resize-handle:hover {
    background: linear-gradient(135deg, rgba(255,255,255,0.5) 0%, transparent 50%);
}

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    color: white;
}

.chat-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 0.95rem;
}

.chat-ai-icon {
    font-size: 1.1rem;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-size-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    width: 26px;
    height: 26px;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    transition: all 0.2s;
}

.chat-size-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}

.chat-size-btn.active {
    background: rgba(255, 255, 255, 0.35);
    color: white;
    border-color: rgba(255, 255, 255, 0.5);
}

.chat-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: background 0.2s;
    margin-left: 4px;
}

.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg-primary);
}

.chat-message {
    max-width: 85%;
    animation: messageSlide 0.3s ease-out;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.user-message {
    align-self: flex-end;
}

.chat-message.ai-message {
    align-self: flex-start;
}

.message-content {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.user-message .message-content {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-message .message-content {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border);
}

.error-message .message-content {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.message-content ul {
    margin: 8px 0 0 0;
    padding-left: 20px;
}

/* Chat Tables */
.chat-table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 0.85rem;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.chat-table thead {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
}

.chat-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: white;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chat-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.chat-table tbody tr {
    background: var(--bg-tertiary);
    transition: background 0.2s;
}

.chat-table tbody tr:nth-child(even) {
    background: var(--bg-secondary);
}

.chat-table tbody tr:hover {
    background: rgba(168, 85, 247, 0.1);
}

.chat-table tbody tr:last-child td {
    border-bottom: none;
}

.chat-table td strong {
    color: var(--accent-primary);
}

/* Chat Headers */
.chat-h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent-primary);
    margin: 16px 0 8px 0;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.chat-h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 12px 0 6px 0;
}

/* Chat Lists */
.chat-list {
    margin: 8px 0;
    padding-left: 20px;
}

.chat-list li {
    margin: 4px 0;
    color: var(--text-secondary);
}

.chat-list li::marker {
    color: var(--accent-primary);
}

.message-content li {
    margin: 4px 0;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typing 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* Chat Input Area */
.chat-input-area {
    display: flex;
    gap: 8px;
    padding: 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

#chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#chat-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.2);
}

#chat-input::placeholder {
    color: var(--text-muted);
}

#chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

#chat-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.4);
}

#chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#chat-send-btn svg {
    width: 18px;
    height: 18px;
}

/* Mobile Chat Styles */
@media (max-width: 640px) {
    #ai-chat-container {
        bottom: 16px;
        right: 16px;
    }
    
    .chat-toggle-btn {
        width: 52px;
        height: 52px;
    }
    
    .chat-icon {
        font-size: 1.3rem;
    }
    
    .chat-panel {
        position: fixed;
        bottom: 0;
        right: 0;
        width: 100% !important;
        max-width: 100% !important;
        height: calc(100vh - 60px) !important;
        max-height: calc(100vh - 60px) !important;
        border-radius: 20px 20px 0 0;
        border-bottom: none;
    }
    
    /* Hide resize controls on mobile - fullscreen mode */
    .chat-resize-handle,
    .chat-size-btn {
        display: none !important;
    }
    
    #ai-chat-container.chat-open .chat-toggle-btn {
        transform: translateY(100px);
        opacity: 0;
        pointer-events: none;
    }
    
    .chat-header {
        padding: 14px 16px;
    }
    
    .chat-messages {
        padding: 12px;
    }
    
    .chat-input-area {
        padding: 12px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
    
    #chat-input {
        padding: 10px 14px;
        font-size: 16px; /* Prevents iOS zoom */
    }
    
    #chat-send-btn {
        width: 40px;
        height: 40px;
    }
}

/* ===== FUN FACT GENERATOR ===== */

.fun-fact-btn {
    background: linear-gradient(135deg, #8b5cf6, #6366f1) !important;
    border: none !important;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #3ee610 !important;
}

/* Only apply hover on devices with a mouse */
@media (hover: hover) and (pointer: fine) {
    .fun-fact-btn:hover {
        background: linear-gradient(135deg, #7c3aed, #4f46e5) !important;
        transform: scale(1.05);
    }
}

.fun-fact-btn:active {
    transform: scale(0.98);
}

.fun-fact-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 15, 25, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 99999;
    justify-content: center;
    align-items: center;
}

.fun-fact-overlay.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.fun-fact-popup {
    background: linear-gradient(145deg, #1e293b, #0f172a);
    border: 2px solid rgba(139, 92, 246, 0.4);
    border-radius: 1.5rem;
    padding: 0;
    width: 90%;
    max-width: 420px;
    box-shadow: 
        0 0 0 1px rgba(139, 92, 246, 0.1),
        0 20px 50px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(139, 92, 246, 0.15);
    animation: popupAppear 0.25s ease-out;
    overflow: hidden;
}

@keyframes popupAppear {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.fun-fact-header {
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.fun-fact-icon {
    font-size: 1.5rem;
}

.fun-fact-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
}

.fun-fact-content {
    padding: 1.5rem;
}

.fun-fact-select-area label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.player-select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    margin-bottom: 1rem;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
}

.player-select:focus {
    outline: none;
    border-color: rgba(139, 92, 246, 0.5);
}

.player-select option {
    background: #1e293b;
    color: var(--text-primary);
}

.generate-fact-btn,
.another-fact-btn {
    width: 100%;
    padding: 0.875rem 1.5rem;
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    border: none;
    border-radius: 0.75rem;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

/* Only apply hover effects on devices with a mouse/pointer */
@media (hover: hover) and (pointer: fine) {
    .generate-fact-btn:hover:not(:disabled),
    .another-fact-btn:hover {
        background: linear-gradient(135deg, #7c3aed, #4f46e5);
        transform: translateY(-2px);
        box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
    }
}

/* Active state for touch devices */
.generate-fact-btn:active:not(:disabled),
.another-fact-btn:active {
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    transform: scale(0.98);
}

.generate-fact-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.rate-limit-info {
    margin-top: 0.75rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.rate-limit-info.exceeded {
    color: #f87171;
}

.fun-fact-result {
    text-align: center;
}

.fact-text {
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 1rem;
    padding: 1.5rem;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--text-primary);
}

.exit-hint {
    margin-top: 1rem;
    margin-bottom: 0;
    font-size: 0.8rem;
    color: var(--text-muted, #64748b);
    opacity: 0.7;
    font-style: italic;
    text-align: center;
}

.ai-disclaimer {
    margin: 0.75rem 0 0 0;
    padding: 0;
    font-size: 0.7rem;
    color: var(--text-muted, #64748b);
    opacity: 0.6;
    text-align: center;
    font-style: italic;
}

.joke-divider {
    border: none;
    border-top: 1px solid rgba(139, 92, 246, 0.3);
    margin: 1rem 0;
}

.pl-joke {
    margin: 0;
    font-size: 0.95rem;
    color: #94a3b8;
    text-align: center;
}

.another-fact-btn {
    background: transparent;
    border: 2px solid rgba(139, 92, 246, 0.5);
    color: #a78bfa;
}

.another-fact-btn:hover {
    background: rgba(139, 92, 246, 0.1);
    border-color: rgba(139, 92, 246, 0.8);
}

.fun-fact-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem;
}

.fun-fact-loading .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(139, 92, 246, 0.2);
    border-top-color: #8b5cf6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

