:root {
    --brand-slate: #55545d;
    --pitch-blue: #0077cc;
    --bg-canvas: #f6f8fa;
    --brand-slate-soft: rgba(85, 84, 93, 0.05);
}


/* 🟢 1. Prevent the entire page from wobbling/scrolling horizontally */
html, body {
    /*overflow-x: hidden;*/
    width: 100%;
}

html {
    scroll-behavior: smooth;
}

/* 🟢 1. Universal Box-Sizing (Fixes right-edge overflow) */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #ffffff;
    color: #333;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.footysim-stats-container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding-top: 0;
}

/* 🟢 Desktop Base Layout */
.table-scroll-wrapper {
    width: 100%;
    overflow-x: auto;
}

.global-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
}

.footysim-stats-header { margin-bottom: 30px; padding-top: 20px;}
/* 🟢 Desktop/Tablet Safe Zone for Header */
@media screen and (min-width: 769px) {
    .footysim-stats-header {
        padding-left: 20px;
        padding-right: 20px;
    }
}
.meta-header-box { text-align: center; margin-bottom: 40px; }
.main-title { font-size: 32px; font-weight: 800; margin: 0 0 5px 0; }
.subtitle { font-size: 15px; color: #555; margin: 0; }
.updated-timestamp-top { font-size: 11px; color: #999; text-transform: uppercase; margin: 0 0 8px 0; letter-spacing: 0.5px; }

.league-controls-container { display: flex; justify-content: flex-start; margin-bottom: 20px; }
.league-selector select { padding: 10px 14px; font-size: 14px; font-weight: 600; border: 1px solid #ccc; border-radius: 4px; background-color: #f9f9f9; cursor: pointer; min-width: 250px; }
/* 🟢 NEW: Season Switcher Dropdown (Matches league-selector style) */
.season-selector select {
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #f9f9f9;
    cursor: pointer;
    font-family: inherit;
    color: #555;
}
.league-info { display: flex; justify-content: space-between; align-items: flex-end; border-top: 1px solid #ddd; padding-top: 15px; margin-bottom: 20px; }
.league-title-box { display: flex; align-items: center; gap: 15px; }
.league-name { font-size: 16px; text-transform: uppercase; margin: 0; color: #111; font-weight: 700; }
.league-season { font-size: 14px; font-weight: normal; color: #666; margin: 3px 0 0 0; }

.forecast-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.meta-headers th { text-align: center !important; font-size: 11px; color: #333; padding-bottom: 5px; border-bottom: none !important; }
.meta-group-border { border-bottom: 1px solid #ccc !important; }

.forecast-table th {
    text-align: center;
    padding: 12px 18px 8px 8px;
    border-bottom: 2px solid #333;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    user-select: none;
    vertical-align: bottom;
    position: relative;
}

.forecast-table th.sortable { cursor: pointer; transition: background 0.1s; }
.forecast-table th.sortable:hover { background-color: #f4f4f4; color: #111; }

.forecast-table th.sortable::after {
    content: ' \25B4';
    opacity: 0.3;
    position: absolute;
    right: 4px;
    bottom: 8px;
}
.forecast-table th.sortable.desc::after { content: ' \25BE'; opacity: 0.3; }
.forecast-table th.sortable.active-sort::after { opacity: 1; color: #ff5e2f; }

.forecast-table th.team-col,
.forecast-table td.team-col {
    position: sticky;
    left: 0;
    z-index: 10;
    background-color: #fff;
    box-shadow: 2px 0 5px rgba(0,0,0,0.05);
    text-align: left;
}

.forecast-table th.team-col {
    padding-right: 8px;
    z-index: 11;
}

.forecast-table td.team-col {
    font-weight: bold;
    font-size: 15px;
    color: #111;
    white-space: nowrap;
}

.team-name-wrapper { display: flex; align-items: baseline; gap: 6px; }

.forecast-table td { padding: 8px; border-bottom: 1px solid #eee; text-align: center; vertical-align: middle; }
.dimmed-points { color: #999; font-size: 12px; font-weight: normal; }

.forecast-table tbody tr:nth-child(even) { background-color: #fcfcfc; }
.forecast-table tbody tr:nth-child(even) td.team-col { background-color: #fcfcfc; }

.team-eliminated { opacity: 0.4; filter: grayscale(100%); transition: opacity 0.2s; }
.dash-eliminated { color: #ccc; font-weight: normal; }
.check-mark { color: #111; font-weight: bold; }

.bg-90 { background-color: rgba(255, 94, 47, 0.85); color: white; }
.bg-75 { background-color: rgba(255, 133, 46, 0.65); color: #111; }
.bg-50 { background-color: rgba(255, 171, 52, 0.45); color: #111; }
.bg-25 { background-color: rgba(255, 205, 82, 0.30); color: #111; }
.bg-10 { background-color: rgba(255, 228, 133, 0.20); color: #111; }
.bg-1  { background-color: rgba(255, 243, 191, 0.10); color: #333; }
.bg-0  { background-color: transparent; color: #999; }

.pct-cell { width: 70px; min-width: 70px; text-align: center !important; font-weight: 600; font-size: 13px; }
.pct-cell-narrow { width: 45px; min-width: 45px; text-align: center !important; font-weight: 600; font-size: 13px; }

.forecast-table th.pts-col,
.forecast-table td.pts-col { width: 60px; min-width: 60px; max-width: 60px; text-align: center; }

.forecast-table th.gd-col,
.forecast-table td.gd-col { width: 75px; min-width: 75px; max-width: 75px; text-align: center; }

.position-dist-header { text-align: center; vertical-align: bottom; padding-bottom: 8px; width: 160px; min-width: 160px; cursor: default; }
.position-dist-cell { width: 160px; min-width: 160px; padding-right: 20px !important; padding-left: 20px !important; vertical-align: bottom; }

/* 🟢 UPDATED SPARKLINE ENGINE: Uses gap instead of margins for easy squishing */
.sparkline-container { width: 100%; height: 26px; position: relative; cursor: crosshair; }
.spark-bars {
    position: absolute; bottom: 0; left: 0; width: 100%; height: 15px;
    display: flex; gap: 1px; align-items: flex-end; border-bottom: 1px solid #ddd;
}
.sparkbar {
    flex: 1; min-width: 0; /* min-width 0 allows infinite squish */
    min-height: 1px; pointer-events: none; transition: background 0.1s, opacity 0.1s;
}
.sparkline-container:hover .sparkbar { background: #fcd5c5 !important; opacity: 1 !important; }
.sparkline-container .sparkbar.active { background: #ff5e2f !important; opacity: 1 !important; }
.spark-label { position: absolute; top: -2px; font-size: 10px; line-height: 1.1; color: #111; display: none; pointer-events: none; z-index: 5; width: 130px; }
.pos-header-labels { display: flex; justify-content: space-between; font-size: 9px; color: #999; margin-top: 5px; font-weight: normal; text-transform: none; padding: 0 10px; }

.divider-left { border-left: 2px solid #ddd !important; }
.divider-right { border-right: 2px solid #ddd !important; }
.thin-right { border-right: 1px solid #eee !important; }

.see-also-links { font-size: 13px; margin: 14px 0 18px 0; color: #666; }
.see-also-links a { color: #444; text-decoration: none; border-bottom: 1px solid #ccc; padding-bottom: 1px; transition: all 0.2s; }
.see-also-links a:hover { color: #000; border-bottom-color: #000; }
.see-also-links .tool-link { font-weight: 600; color: #0088cc; border-bottom-color: rgba(0, 136, 204, 0.3); }
.see-also-links .tool-link:hover { border-bottom-color: #0088cc; }
.see-also-links .link-divider { color: #ddd; margin: 0 10px; }

.footysim-site-footer { text-align: center; padding: 40px 20px 120px; margin-top: 60px; /*border-top: 1px solid #eee;*/ }
.footer-content { max-width: 800px; margin: 0 auto; }
.footysim-site-footer .copyright { color: #444; font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.footysim-site-footer .disclaimer { color: #999; font-size: 11px; line-height: 1.5; max-width: 600px; margin: 0 auto; }


/* 🟢 Desktop Group Column */
.forecast-table th.group-col,
.forecast-table td.group-col {
    width: 50px;
    min-width: 50px;
    max-width: 50px;
    text-align: center;
    padding-right: 12px; /* Adds breathing room on the right */
    color: #888;
    font-weight: 600;
    font-size: 13px;
}



/* 🟢 Mobile-Only Adjustments - Extreme 538 Fit */
@media screen and (max-width: 768px) {


    /* 1. Maximize screen real estate */
    body { padding: 5px 2px; }

    /* Give the top controls some breathing room away from the edge */
    .footysim-stats-header {
        padding: 20px 10px 0 10px; /* 🟢 Restores the 20px top padding! */
    }

    /* Kill horizontal scrolling */
    .table-scroll-wrapper {
        overflow-x: hidden !important;
        padding-bottom: 0 !important;
    }

    /* 2. Global table strictness */
    .forecast-table { font-size: 10px; table-layout: fixed; width: 100%; border-collapse: collapse; }

    /* Give all headers room at the bottom for the sort arrows */
    .forecast-table th { box-sizing: border-box; padding: 2px 0 10px 0 !important; overflow: hidden; }
    .forecast-table td { box-sizing: border-box; padding: 2px 0; overflow: hidden; }

    /* 3. Meta Headers (Shrunk to fit strict layout, no arrows needed so less padding) */
    .meta-headers { display: table-row; }
    .meta-headers th {
        font-size: 7.5px !important;
        line-height: 1.1;
        padding: 2px 1px !important;
        white-space: normal;
    }

    /* 4. Team Column - Stacked and Truncated */
    .forecast-table th.team-col,
    .forecast-table td.team-col,
    .forecast-table .meta-headers th:first-child {
        width: 70px; min-width: 70px; max-width: 70px;
        padding-left: 2px !important;
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
        box-shadow: none;
    }

    .forecast-table td.team-col { font-size: 11px; }
    .team-name-wrapper { display: flex; flex-direction: column; align-items: flex-start; gap: 0; }
    .dimmed-points { font-size: 7.5px; margin-left: 0; }

    /* 5. Points Column Squeezed */
    .forecast-table th.pts-col,
    .forecast-table td.pts-col {
        width: 18px; min-width: 18px; max-width: 18px;
        font-size: 8px;
    }
    .forecast-table td.pts-col { padding: 2px 0 !important; }

    /* 6. Goal Diff Column (CSS Text Replacement -> "GD") */
    .forecast-table th.gd-col {
        width: 18px; min-width: 18px; max-width: 18px;
        font-size: 0 !important; /* Hides original text */
    }
    .forecast-table th.gd-col::before {
        content: "GD";
        font-size: 8px;
        display: block;
    }
    .forecast-table td.gd-col {
        width: 18px; min-width: 18px; max-width: 18px;
        font-size: 8px; padding: 2px 0 !important;
    }

    /* 7. Sparkline Squeeze (CSS Text Replacement -> "POS") */
    .position-dist-header {
        width: 32px; min-width: 32px; max-width: 32px;
        font-size: 0 !important; height: auto; padding-bottom: 2px !important;
    }
    .position-dist-header::before {
        content: "POS";
        font-size: 8px;
        display: block;
    }
    .pos-header-labels { display: none; }

    .position-dist-cell {
        width: 32px; min-width: 32px; max-width: 32px;
        padding-left: 1px !important; padding-right: 1px !important;
    }

    /* 🟢 The Sparkline Auto-Squish Magic */
    .spark-bars:has(.sparkbar:nth-child(25)) { gap: 0; }

    /* 🟢 TOOLTIP FIX */
    .spark-label {
        width: 32px !important;
        font-size: 4.5px !important;
        line-height: 1.1 !important;
        top: 0 !important; left: 0 !important;
        transform: none !important;
        background: rgba(255, 255, 255, 0.9) !important;
        color: #000 !important; box-shadow: none !important;
        border-radius: 0 !important; padding: 1px 0 !important;
        text-align: center; white-space: normal !important;
        word-break: break-word !important; height: auto !important;
        display: none;
    }
    .spark-label::after { display: none !important; }

    /* 8. THE VERTICAL CLASS FIX */
    .forecast-table th.vert-mobile {
        writing-mode: vertical-rl;
        white-space: normal !important;
        line-height: 1.1 !important;
        height: 90px !important;
        width: 25px !important;
        min-width: 25px !important;
        max-width: 25px !important;
        padding: 2px 0 12px 0 !important;
        font-size: 7px !important;
        letter-spacing: -0.2px;
        text-align: right !important;
        vertical-align: middle !important;
        overflow: hidden;
    }

    /* 9. Probability Cell Widths */
    .pct-cell, .pct-cell-narrow {
        width: 25px; min-width: 25px; max-width: 25px;
        font-size: 8.5px;
        letter-spacing: -0.5px;
        padding: 4px 0 !important;
    }

    /* 10. The "Leftover" Horizontal Small Headers (e.g. Group Stages 1st, 2nd) */
    .forecast-table th.sortable:not(.vert-mobile):not(.team-col):not(.pts-col):not(.gd-col) {
        writing-mode: horizontal-tb !important;
        white-space: normal !important;
        font-size: 7.5px !important;
        line-height: 1.1 !important;
        padding: 2px 1px 12px 1px !important;
        width: 25px !important;
        min-width: 25px !important;
        max-width: 25px !important;
        text-align: center !important;
        vertical-align: bottom !important;
    }

    /* ==========================================================
       🟢 11. THE MASTER SORT ARROW STANDARDIZATION (MOBILE)
       ========================================================== */
    .forecast-table th.sortable::after {
        display: block !important;
        writing-mode: horizontal-tb !important;
        content: '\25B4';
        position: absolute;
        bottom: 1px;         /* Pins arrow to the very bottom */
        left: 0; right: 0;   /* Allows exact horizontal centering */
        margin: 0 auto;
        text-align: center;
        transform: none !important; /* Strips desktop float offsets */
        font-size: 8px !important;  /* Overrides GD font-size: 0 bug */
        opacity: 0.4;
    }

    /* Custom placement just for the Team column so it aligns right */
    .forecast-table th.team-col.sortable::after {
        left: auto;
        right: 2px;
    }

    .forecast-table th.sortable.desc::after { content: '\25BE'; }
    .forecast-table th.sortable.active-sort::after { opacity: 1; color: #ff5e2f; }

    /* 🟢 Mobile Group Column Logic */

    /* completely hide the dedicated group column on mobile */
    .forecast-table th.group-col,
    .forecast-table td.group-col {
        display: none !important;
    }

    /* Show the inline badge so the user still sees the group letter */
    .mobile-group-badge {
        display: inline !important;
    }

}

/* 🟢 Soft SPA Page Transition */
@keyframes softFadeIn {
    0% {
        opacity: 0;
        transform: translateY(12px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: softFadeIn 0.35s ease-out forwards;
}

/* 🟢 Header Philosophy Styling */
.engine-philosophy {
    font-size: 13px;
    color: #888;
    margin: 8px 0 20px 0 !important; /* Give it clear space below subtitle */
    display: flex;
    flex-direction: column; /* Stack on mobile, side-by-side on desktop */
    align-items: center;
    gap: 4px;
}

#diff-link {
    color: #0088cc;
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px dashed rgba(0, 136, 204, 0.4);
    transition: all 0.2s;
}

#diff-link:hover {
    color: #005580;
    border-bottom-color: #005580;
}

@media screen and (min-width: 768px) {
    .engine-philosophy {
        flex-direction: row;
        justify-content: center;
        gap: 10px;
    }
}

/* =========================================
   538-STYLE PILL TOGGLE
   ========================================= */
.view-toggle-container {
    display: flex;
    justify-content: center;
    margin-top: 15px;
    margin-bottom: 25px;
}

.view-toggle-pill {
    display: inline-flex;
    background: #e2e8f0; /* Crisp light gray */
    border-radius: 30px;
    padding: 4px;
}

.toggle-btn {
    background: transparent;
    border: none;
    padding: 8px 24px;
    font-size: 14px;
    font-weight: 600;
    color: #64748b;
    border-radius: 26px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.toggle-btn:hover {
    color: #1e293b;
}

.toggle-btn.active {
    background: #ffffff;
    color: #0f172a;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1); /* The popped-out look */
}

/* =========================================
   TAB SWITCHING LOGIC
   ========================================= */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Footer Legal Styling --- */
.footer-disclaimers {
    max-width: 800px;
    margin: 0 auto 20px auto;
}

.disclaimer-text {
    font-size: 11px;
    line-height: 1.6;
    color: #999;
    margin-bottom: 12px;
}

.responsible-gambling {
    color: #777; /* Slightly darker to differentiate the legal warning */
    border-top: 1px solid #eee;
    padding-top: 15px;
    margin-top: 15px;
}

.disclaimer-text a {
    color: #777;
    text-decoration: underline;
}

.disclaimer-text a:hover {
    color: #333;
}

/* ==========================================
   GLOBAL SEARCH MODAL
========================================== */
.global-search-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 100000;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 12vh;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.global-search-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.global-search-modal {
    background: #fff;
    width: 90%;
    max-width: 550px;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    overflow: hidden;
    transform: translateY(-20px);
    transition: transform 0.2s ease;
    display: flex;
    flex-direction: column;
}

.global-search-overlay.active .global-search-modal {
    transform: translateY(0);
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #f0f0f0;
}

.search-input-wrapper svg {
    color: #94a3b8;
    margin-right: 12px;
}

#team-search-input {
    flex-grow: 1;
    border: none;
    font-size: 18px;
    outline: none;
    background: transparent;
    color: #1e293b;
    font-weight: 500;
}

.search-results-container {
    max-height: 400px;
    overflow-y: auto;
    margin: 0;
    padding: 0;
    list-style: none;
}

.search-result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    text-decoration: none;
    color: #334155;
    border-bottom: 1px solid #f8fafc;
    transition: background 0.1s;
    cursor: pointer;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item.selected, .search-result-item:hover {
    background: #f1f5f9;
}

.search-result-name {
    font-weight: 600;
    font-size: 15px;
}

.search-shortcut-hint {
    font-size: 10px;
    color: #94a3b8;
    background: #f1f5f9;
    padding: 3px 6px;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
}

body.search-open {
    overflow: hidden;
}

/* Nav button styling */
.nav-search-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
}
.nav-search-btn:hover {
    background: #f1f5f9;
    color: #111827;
}