:root {
    /* -- CORE COLORS (HSL) -- */
    --hue: 28;
    /* Orange */
    --sat: 95%;
    --lig: 50%;

    /* Derived Colors */
    --primary: hsl(var(--hue), var(--sat), var(--lig));
    --primary-dark: hsl(var(--hue), var(--sat), 40%);
    --primary-light: hsl(var(--hue), var(--sat), 75%);
    --bg-app: #F0EEE9;
    --bg-card: hsl(0, 0%, 100%);
    --text-main: hsl(220, 30%, 15%);
    --text-muted: hsl(220, 10%, 55%);
    --border-color: hsl(220, 15%, 90%);

    /* Semantic */
    --success: hsl(150, 70%, 45%);
    --warning: hsl(35, 90%, 50%);
    --danger: hsl(0, 75%, 55%);

    /* UI Layout */
    --header-height: 60px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 2px 8px -2px rgba(0, 0, 0, 0.05);
    --shadow-glass: 0 8px 32px 0 rgba(31, 38, 135, 0.07);

}

[data-theme="dark"] {
    --bg-app: hsl(220, 20%, 10%);
    --bg-card: hsl(220, 15%, 16%);
    --text-main: hsl(220, 20%, 95%);
    --text-muted: hsl(220, 10%, 65%);
    --border-color: hsl(220, 15%, 25%);
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* RESET & BASE */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* UTILS */
.glass-panel {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
}

[data-theme="dark"] .glass-panel {
    background: rgba(30, 35, 45, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.hidden {
    display: none !important;
}

.desktop-only {
    display: none !important;
}

/* Hidden by default on small screens if we go mobile first? No, we have base desktop styles usually? 
Actually, let's reverse. Base = Desktop? Or Base = Mobile?
Project seems mixed. 
Let's add: */

@media (min-width: 769px) {
    .desktop-only {
        display: table-cell !important;
    }
}

@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }
}

.padding-20 {
    padding: 20px;
}

.full-height-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* LAYOUT */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    padding-bottom: 40px;
    /* Space for mobile nav */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* HEADER - Unified for Mobile + Desktop */
.app-header {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 30px 20px;
    gap: 16px;
}


.header-actions {
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(0, 0, 0, 0.25);
    padding: 6px 10px;
    border-radius: 24px;
}

[data-theme="light"] .icon-toolbar {
    background: rgba(0, 0, 0, 0.08);
}

.icon-toolbar .icon-btn {
    width: 32px;
    height: 32px;
    font-size: 1.1rem;
}

.header-title-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.league-badge {
    font-size: clamp(0.7rem, 1.5vw, 0.85rem);
    font-weight: 800;
    color: white;
    background: var(--primary);
    border: none;
    border-radius: 10px;
    padding: 4px 12px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    white-space: nowrap;
    line-height: 1.2;
    box-shadow: 0 0 15px hsla(var(--hue), 70%, 50%, 0.3);
}

.logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.logo h1 {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    margin: 0;
    line-height: 1;
    font-weight: 800;
    color: var(--text-main);
}

.logo-icon {
    font-size: clamp(2rem, 5vw, 3rem);
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background-color: rgba(127, 127, 127, 0.1);
}

/* MAIN GRID */
.main-content {
    display: grid;
    /* Left: Flexible but wider for Table+Stats. Right: Slightly narrower for matches. */
    grid-template-columns: 1.4fr 1fr;
    gap: 32px;
    align-items: start;
}

/* COLUMNS */
.col-left {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.col-right {
    display: block;
}

/* VIEW SELECTOR (In Card Header) */
.view-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-left: auto;
    /* Push to right of header */
}

.nav-pill {
    flex: 0 0 auto;
    border: none;
    background: none;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    background-color: rgba(127, 127, 127, 0.05);
}

.nav-pill:hover {
    background-color: rgba(127, 127, 127, 0.1);
}

.nav-pill.active {
    background-color: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .nav-pill.active {
    background-color: var(--primary);
    color: white;
}

/* INSIGHTS STATS */
.insight-block {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.insight-row {
    font-size: 0.9rem;
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.insight-row .label {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.insight-row .value {
    font-weight: 600;
    color: var(--text-main);
    text-align: right;
}

.insight-row .value-multiline {
    font-weight: 500;
    line-height: 1.4;
    font-size: 0.9rem;
    text-align: right;
}

.insight-row .highlight {
    color: var(--primary);
    font-weight: 700;
}

.menu-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.menu-card {
    display: flex;
    flex-direction: row;
    /* Horizontal icons */
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    border: none;
    cursor: pointer;
    color: var(--text-main);
    font-weight: 600;
    transition: transform 0.2s;
}

.menu-card:hover {
    transform: translateY(-2px);
}

.menu-card .icon {
    font-size: 1.25rem;
    color: var(--primary);
}

/* CONTENT CARDS */
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    /* responsive wrap */
    gap: 10px;
    background: rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] .card-header {
    background: rgba(0, 0, 0, 0.15);
}

/* Compact Card Header (Tabelle) */
.card-header-compact {
    padding: 14px 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
}

/* Inline Card Header (Spielplan - title and controls in one row) */
.card-header-inline {
    padding: 14px 16px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.header-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-title-row h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}

/* Info Tooltip */
.info-tooltip-wrapper {
    position: relative;
    display: inline-flex;
}

.info-icon-btn {
    background: rgba(127, 127, 127, 0.08);
    border: 1px solid var(--border-color);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Inter', sans-serif;
}

.info-icon-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: hsla(var(--hue), 70%, 50%, 0.1);
}

/* Compact Search Bar */
.search-bar-compact {
    display: flex;
    align-items: center;
    background: rgba(127, 127, 127, 0.08);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2px 10px;
    flex: 1;
    max-width: 200px;
}

.search-bar-compact .search-icon {
    font-size: 0.9rem;
    margin-right: 6px;
    opacity: 0.6;
}

.search-bar-compact .search-select {
    flex: 1;
    padding: 6px 0;
    font-size: 0.85rem;
    border: none;
    background: transparent;
    color: var(--text-main);
    outline: none;
}

.info-tooltip {
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 14px;
    min-width: 280px;
    max-width: 320px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
}

[data-theme="dark"] .info-tooltip {
    background: hsl(220, 18%, 20%);
    border-color: hsl(220, 15%, 30%);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.info-tooltip-wrapper:hover .info-tooltip,
.info-tooltip-wrapper:focus-within .info-tooltip {
    opacity: 1;
    visibility: visible;
}

.tooltip-line {
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-main);
}

.tooltip-line+.tooltip-line {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--border-color);
}

/* Filters Row */
.filters-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

/* Segmented Control */
.segmented-control {
    display: inline-flex;
    background: rgba(127, 127, 127, 0.1);
    border-radius: 10px;
    padding: 3px;
    gap: 2px;
}

[data-theme="dark"] .segmented-control {
    background: rgba(0, 0, 0, 0.3);
}

.segment {
    border: none;
    background: transparent;
    padding: 5px 10px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.segment:hover:not(.active) {
    color: var(--text-main);
    background: rgba(127, 127, 127, 0.1);
}

.segment.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Season Dropdown */
.season-dropdown-wrapper {
    display: flex;
    align-items: center;
}

.season-dropdown {
    appearance: none;
    -webkit-appearance: none;
    background: rgba(127, 127, 127, 0.15);
    border: none;
    border-radius: 8px;
    padding: 8px 28px 8px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: all 0.2s;
}

[data-theme="dark"] .season-dropdown {
    background: rgba(0, 0, 0, 0.3);
}

.season-dropdown:hover {
    background: rgba(127, 127, 127, 0.25);
}

[data-theme="dark"] .season-dropdown:hover {
    background: rgba(0, 0, 0, 0.4);
}

.season-dropdown:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px hsla(var(--hue), 70%, 50%, 0.2);
}

[data-theme="dark"] .season-dropdown {
    background-color: rgba(0, 0, 0, 0.2);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23aaa' d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E");
}

/* Mobile Table Font Size Adjustment */
@media (max-width: 768px) {

    #standings-table td,
    #standings-table th {
        font-size: 0.9rem;
        /* Slightly smaller on mobile if needed */
        padding: 10px 4px;
        /* Tighten padding */
    }

    .team-cell {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 8px;
        /* Space between logo and name */
        justify-content: flex-start;
        /* Align left */
        text-align: left;
    }
}

/* Team Logo Base Styles */
.team-logo {
    width: 24px !important;
    height: 24px !important;
    max-width: 24px !important;
    max-height: 24px !important;
    min-width: 24px;
    object-fit: contain;
    flex-shrink: 0;
    /* Optional: fallback styling if image fails (though handled by onerror usually) */
    background-color: transparent;
}

/* Ensure desktop also aligns nicely */
@media (min-width: 769px) {
    .team-cell {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .team-logo {
        width: 28px;
        height: 28px;
    }
}

/* Mobile Responsive for Filters */
@media (max-width: 480px) {
    .info-tooltip {
        left: 0;
        top: calc(100% + 8px);
        transform: none;
        min-width: 240px;
    }

    .filters-row {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
    }

    .segmented-control {
        flex: 0 1 auto;
        padding: 2px;
    }

    .segment {
        flex: 0 0 auto;
        text-align: center;
        padding: 4px 8px;
        font-size: 0.75rem;
    }

    .season-dropdown-wrapper {
        flex: 0 0 auto;
    }

    .season-dropdown {
        padding: 4px 24px 4px 8px;
        font-size: 0.75rem;
    }
}

.sticky-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: inherit;
    border-radius: inherit;
    /* match top corners */
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    backdrop-filter: blur(12px);
}

/* TABLE STYLES */
.table-responsive {
    overflow-x: auto;
}

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

th,
td {
    padding: 12px 16px;
    text-align: left;
}

th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

tr:not(:last-child) td {
    border-bottom: 1px solid var(--border-color);
}

.col-pos {
    width: 40px;
    text-align: center;
    font-weight: 700;
    color: var(--text-muted);
}

.col-team {
    min-width: 150px;
}

.col-form {
    text-align: center;
    width: 60px;
    /* Adjust as needed */
    white-space: nowrap;
}

.col-games {
    text-align: center;
}

.col-diff {
    text-align: center;
}

.col-points {
    text-align: right;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

/* .team-cell is now handled in the Team Logo section above */
/* Previously:
.team-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
*/

.trend-mini {
    display: flex;
    gap: 2px;
    height: 6px;
    align-items: center;
}

/* MATCHES LIST */
.matches-container {
    padding: 0 20px 20px 20px;
    overflow-y: auto;
    max-height: 80vh;
    /* Scrollable list */
}

.match-group-header {
    padding: 12px 0 6px 0;
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    background: inherit;
}

.match-row {
    display: grid;
    grid-template-columns: 45px 1fr auto 1fr;
    gap: 12px;
    padding: 12px 0;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.match-time {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: right;
    line-height: 1.2;
}

.team-home {
    text-align: right;
    font-weight: 500;
    font-size: 0.95rem;
    white-space: normal;
    word-break: break-word;
    line-height: 1.3;
}

.team-guest {
    text-align: left;
    font-weight: 500;
    font-size: 0.95rem;
    white-space: normal;
    word-break: break-word;
    line-height: 1.3;
}

.match-score {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
}

.score-input {
    width: 36px;
    height: 30px;
    text-align: center;
    border: 1px solid var(--border-color);
    background: rgba(127, 127, 127, 0.05);
    border-radius: 6px;
    font-weight: 700;
    color: var(--text-main);
    font-size: 0.9rem;
    appearance: textfield;
}

.score-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-card);
}

/* MOBILE BOTTOM BAR */
.mobile-bottom-bar {
    display: none !important;
    /* Desktop default */
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    height: 64px;
    border-radius: 20px;
    padding: 0 20px;
    /* display: flex removed */
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.3);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

[data-theme="dark"] .mobile-bottom-bar {
    background: rgba(30, 30, 30, 0.9);
}

.bottom-nav-item {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    width: 60px;
}

.bottom-nav-item .icon {
    font-size: 1.4rem;
}

.bottom-nav-item.active {
    color: var(--primary);
    transform: translateY(-2px);
}


/* DESKTOP HEADER - Modern Dark Mode */
.desktop-header-row {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 80px 20px 40px 20px;
    margin: -20px -20px 24px -20px;
}

/* SEARCH */
.search-bar {
    margin-bottom: 20px;
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(127, 127, 127, 0.1);
    border-radius: var(--radius-md);
    padding: 2px 12px;
}

.search-icon {
    font-size: 1.1rem;
    margin-right: 8px;
    opacity: 0.6;
}

.search-select {
    width: 100%;
    padding: 12px 0;
    font-size: 1rem;
    border: none;
    background: transparent;
    color: var(--text-main);
    outline: none;
    /* -webkit-appearance: none; // Keep default arrow for dropdown indication */
}

/* Match Inputs */
.match-input {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    min-width: 80px;
}

.desktop-title {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 800;
    color: var(--text-main);
    margin: 0;
    text-align: center;
    text-shadow: 0 0 30px hsla(var(--hue), 70%, 50%, 0.4);
}

.desktop-controls {
    position: fixed;
    top: calc(16px + env(safe-area-inset-top, 0px));
    right: calc(16px + env(safe-area-inset-right, 0px));
    display: flex;
    gap: 8px;
    z-index: 10000;
    background: rgba(30, 41, 59, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50px;
    padding: 8px 14px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

@media (max-width: 600px) {
    .desktop-controls {
        display: none;
        /* Mobile uses .header-actions in .app-header instead */
    }

    .desktop-header-row {
        padding-top: 55px;
        /* Reduced padding on mobile since controls are smaller */
        padding-bottom: 30px;
    }

    .app-container {
        padding-left: 10px;
        padding-right: 10px;
    }
}

.desktop-only-flex {
    display: flex !important;
}

@media (max-width: 768px) {
    .desktop-only-flex {
        display: none !important;
    }

    /* On mobile, title inside main content is removed? 
       No, we use app-header on mobile. 
       desktop-title is inside desktop-header-row which is hidden.
    */
}

/* FOOTER & IMPRESSUM */
.app-footer {
    text-align: center;
    padding: 16px;
    margin-top: 16px;
    border-top: 1px solid var(--border-color);
}

#open-impressum {
    background: none;
    border: none;
    color: var(--text-muted);
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.9rem;
}

#open-impressum:hover {
    color: var(--primary);
}

.close-modal-imp {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}



.hint-text {
    width: 100%;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 8px;
    font-style: italic;
    flex-shrink: 0;
}

/* RESPONSIVE */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app-container {
        padding: 10px;
        padding-bottom: 20px;
    }

    .main-content {
        display: block;
    }

    .mobile-bottom-bar {
        display: flex !important;
    }

    .col-left,
    .col-right {
        display: none;
    }

    .col-left.mobile-visible {
        display: flex;
    }

    .col-right.mobile-visible {
        display: block;
    }

    /* New Helper for JS toggling */
    .mobile-hidden {
        display: none !important;
    }

    .view-selector {
        width: 100%;
        margin: 10px 0 0 0;
    }

    .match-row {
        grid-template-columns: 40px 1fr auto 1fr;
        gap: 8px;
        font-size: 0.8rem;
        padding: 10px 0;
    }

    .team-home,
    .team-guest {
        font-size: 0.75rem;
        white-space: normal;
        line-height: 1.3;
        word-break: break-word;
        hyphens: auto;
    }

    .match-time {
        font-size: 0.7rem;
    }

    .score-input {
        width: 30px;
        height: 26px;
        font-size: 0.8rem;
    }

    .app-header {
        display: flex !important;
    }

    /* Ensure visible on mobile */
}


/* MODAL */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* SETTINGS MODAL STYLES */
.settings-section {
    margin-bottom: 32px;
}

.settings-section h4 {
    margin-bottom: 20px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

.color-picker-grid {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.color-option {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.active {
    border-color: var(--text-main);
    transform: scale(1.15);
    box-shadow: 0 0 15px var(--primary);
}

.close-modal-settings {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

/* FAVORITE TEAM HIGHLIGHT */
.fw-bold {
    font-weight: 800 !important;
    color: var(--primary) !important;
    text-shadow: 0px 0px 1px currentColor;
}



.modal {
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.highlight-value {
    color: var(--primary) !important;
    font-weight: 800 !important;
}



.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

/* HIGHLIGHT INTERACTION */
.match-row.highlight-team {
    background-color: rgba(255, 165, 0, 0.1) !important;
    border-left: 3px solid var(--primary);
    margin-left: -3px;
}

tr.selected-team td {
    background-color: rgba(255, 165, 0, 0.1);
    /* Highlight in table */
    color: var(--primary-dark);
    font-weight: 600;
}


/* INSIGHTS STATS REDESIGN */
.insights-header-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    border-left: 4px solid var(--primary);
    padding-left: 12px;
}

.insights-header-row h3 {
    margin: 0;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 12px;
}

.full-width-rows {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stat-card {
    background-color: rgba(127, 127, 127, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 85px;
    transition: transform 0.2s, box-shadow 0.2s;
}

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

/* Primary highlighted card */
.stat-card-primary {
    border: 2px solid var(--primary);
    background: linear-gradient(135deg, rgba(var(--primary-rgb, 248, 153, 29), 0.08) 0%, transparent 100%);
}

.stat-card-wide {
    background-color: rgba(127, 127, 127, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* Label: small, uppercase, above value */
.stat-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    order: 1;
}

/* Value: Hero element - big and bold */
.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.1;
    margin-bottom: 4px;
    word-break: break-word;
    order: 2;
}

/* For cards where team name IS the value */
.stat-value-team {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
    order: 2;
}

.stat-sub {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    order: 3;
}

.stat-team {
    font-size: 0.85rem;
    color: var(--text-main);
    font-weight: 600;
    line-height: 1.3;
    margin-top: 2px;
    order: 3;
}

[data-theme="dark"] .stat-card,
[data-theme="dark"] .stat-card-wide {
    background-color: rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] .stat-card-primary {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, transparent 100%);
}

@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 500px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

#matches-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* Layout Reordering */
.col-left {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

@media (min-width: 1025px) {
    .section-standings {
        order: 1;
    }

    .menu-grid {
        order: 2;
    }

    .section-stats {
        order: 3;
    }
}

/* Desktop Header Adjustments */
.desktop-title-stack {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.desktop-badge {
    font-size: 0.9rem;
    padding: 2px 12px;
}

/* MATRIX VIEW */
.matrix-scroll-container {
    overflow-x: auto;
    max-height: 80vh;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-card);
}

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

.matrix-table th,
.matrix-table td {
    border: 1px solid var(--border-color);
    padding: 6px;
    text-align: center;
    white-space: nowrap;
}

/* Sticky Headers */
.matrix-corner {
    position: sticky;
    top: 0;
    left: 0;
    z-index: 3;
    background: var(--bg-card);
    border-bottom: 2px solid var(--border-color);
    border-right: 2px solid var(--border-color);
}

.matrix-header-col {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg-card);
    border-bottom: 2px solid var(--border-color);
    border-top: 4px solid hsl(350, 80%, 60%);
    /* Red Indicator (Guest) */
    height: 100px;
    vertical-align: bottom;
}

.matrix-header-col span {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    white-space: normal;
    word-break: normal;
    hyphens: auto;
    display: block;
    padding: 3px;
    max-height: 120px;
    overflow: hidden;
    font-size: 0.65rem;
    line-height: 1.1;
    color: hsl(350, 70%, 65%);
}

.matrix-row-header {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--bg-card);
    border-right: 2px solid var(--border-color);
    border-left: 4px solid hsl(142, 70%, 45%);
    /* Green Indicator (Home) */
    text-align: right;
    font-weight: 600;
    color: hsl(142, 60%, 55%);
    padding-right: 8px;

    /* Multiline Support */
    white-space: normal !important;
    font-size: 0.75rem;
    line-height: 1.1;
    min-width: 80px;
    max-width: 100px;
}

/* Cells */
.matrix-cell {
    min-width: 40px;
    height: 32px;
    color: var(--text-main);
    font-weight: 600;
}

.cell-self {
    background: repeating-linear-gradient(45deg,
            rgba(0, 0, 0, 0.05),
            rgba(0, 0, 0, 0.05) 5px,
            rgba(0, 0, 0, 0.1) 5px,
            rgba(0, 0, 0, 0.1) 10px);
}

.cell-win {
    background: hsl(142, 70%, 45%);
    /* Green */
    color: #fff;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

.cell-loss {
    background: hsl(350, 80%, 60%);
    /* Red */
    color: #fff;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

.cell-draw {
    background: hsl(210, 10%, 60%);
    /* Grey */
    color: #fff;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

.cell-pending {
    background: hsla(210, 30%, 50%, 0.2);
    color: var(--text-muted);
    font-size: 0.7rem;
    cursor: help;
}

/* Legend */
.matrix-legend {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.dot.win {
    background: hsl(142, 70%, 45%);
}

.dot.loss {
    background: hsl(350, 80%, 60%);
}

.dot.draw {
    background: hsl(210, 10%, 60%);
}

/* Modal Variants */
.modal-wide {
    max-width: 1200px;
    width: 95%;
}

@media (max-width: 768px) {

    /* Matrix Optimization for Mobile */
    /* Matrix Optimization for Mobile */
    .matrix-row-header {
        min-width: 90px;
        max-width: 100px;
        white-space: normal !important;
        word-break: break-word;
        font-size: 0.65rem;
        padding-right: 4px;
        line-height: 1.15;
    }

    .matrix-header-col {
        height: 90px;
    }

    .matrix-header-col span {
        max-height: 110px;
        font-size: 0.65rem;
        white-space: normal;
        word-break: break-word;
    }

}

/* FEVER CHART */
.chart-wrapper {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-top: 16px;
    min-height: 300px;
}

.fever-layout {
    display: flex;
    position: relative;
    border-bottom: 1px solid var(--border-color);
    overflow: hidden;
    /* Prevent spill */
}

.fever-fixed-axis {
    width: 40px;
    flex-shrink: 0;
    border-right: 1px solid var(--border-color);
    background: var(--bg-card);
    z-index: 2;
    position: sticky;
    left: 0;
}

.fever-scroll-area {
    flex-grow: 1;
    overflow-x: auto;
    position: relative;
}

.chart-svg-content {
    /* Fixed height matches axis */
    height: 400px;
    width: auto;
    /* Scales proportionally */
    min-width: 600px;
    /* Ensure logical minimum */
    display: block;
}

.chart-svg-axis {
    width: 100%;
    height: 400px;
    /* MUST MATCH Content Height */
    display: block;
}

/* H2H Button Visibility */
.h2h-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
    margin-left: 8px;
    /* Force spacing */
    opacity: 1 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-main);
}

.h2h-btn:hover {
    transform: scale(1.1);
    background-color: var(--bg-hover);
    border-radius: 50%;
}

.chart-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.chart-controls label {
    font-weight: 600;
    color: var(--text-main);
}

/* Fix for Mobile Navigation (Ensure Layout Hiding Overrides Global Styles) */
@media (max-width: 768px) {

    .col-left:not(.mobile-visible),
    .col-right:not(.mobile-visible) {
        display: none !important;
    }

    .col-left.mobile-visible {
        display: flex !important;
    }

    .col-right.mobile-visible {
        display: block !important;
    }
}

/* Table Animation */
.match-row,
tr {
    will-change: transform;
}

.animating-move {
    transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Toggle Switch */
.switch .slider {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15);
}

.switch input:checked+.slider {
    background-color: var(--primary);
    border-color: var(--primary);
}

.switch input:focus+.slider {
    box-shadow: 0 0 1px var(--primary);
}

.switch .slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

.switch input:checked+.slider:before {
    transform: translateX(22px);
}

/* Locked Input Style */
.score-input:disabled {
    background-color: rgba(127, 127, 127, 0.1);
    color: var(--text-muted);
    border: 1px solid transparent;
    cursor: not-allowed;
    opacity: 0.7;
}

[data-theme="dark"] .score-input:disabled {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Prediction Bar */
.prediction-bar-container {
    padding: 2px 8px 4px 8px;
}

/* Winner/Loser Highlighting */
.team-winner {
    background: rgba(34, 197, 94, 0.15);
    border-radius: 4px;
    padding: 2px 6px;
    margin: -2px -6px;
}

.team-loser {
    background: rgba(239, 68, 68, 0.15);
    border-radius: 4px;
    padding: 2px 6px;
    margin: -2px -6px;
}

.team-draw {
    background: rgba(234, 179, 8, 0.1);
    border-radius: 4px;
    padding: 2px 6px;
    margin: -2px -6px;
}

/* Favorite Team Highlighting */
.fav-team-match {
    background: linear-gradient(90deg, hsla(var(--hue, 28), 70%, 50%, 0.08), transparent);
    border-left: 3px solid var(--primary);
    margin-left: -3px;
    padding-left: 3px;
}

.fav-team-text {
    font-weight: 700 !important;
    color: var(--primary) !important;
}

/* Table Position Markers */
.pos-first {
    background: linear-gradient(90deg, rgba(34, 197, 94, 0.15), transparent);
    border-left: 3px solid var(--success);
}

.pos-last {
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.15), transparent);
    border-left: 3px solid var(--danger);
}

.prediction-bar {
    display: flex;
    height: 18px;
    border-radius: 9px;
    overflow: hidden;
    background: var(--border-color);
}

.prediction-home {
    background: linear-gradient(90deg, var(--success), hsl(120, 50%, 50%));
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-left: 6px;
    min-width: 30px;
}

.prediction-away {
    background: linear-gradient(90deg, hsl(0, 50%, 50%), var(--danger));
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 6px;
    min-width: 30px;
}

.prediction-pct {
    font-size: 11px;
    font-weight: 700;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
    line-height: 1;
}

.prediction-toggle.active {
    background: hsla(var(--hue), 70%, 50%, 0.2);
    color: var(--primary);
}

/* Modal Buttons */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-secondary {
    background: var(--bg-main);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: var(--bg-card);
}

/* Credits Footer */
.credits-footer {
    text-align: center;
    padding: 10px 20px;
    margin-top: 0;
    padding-bottom: 20px;
    /* Space for mobile bottom nav handled in media query */
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

@media (max-width: 768px) {
    .credits-footer {
        padding-bottom: 100px;
    }
}

.credits-footer:hover {
    color: var(--text-main);
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.footer-content .separator {
    opacity: 0.5;
}

.link-btn {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: inherit;
    text-decoration: underline;
}

.link-btn:hover {
    opacity: 0.8;
}

/* Kempa Easter Egg Animation */
.kempa-stage {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.kempa-player {
    position: absolute;
    font-size: 5rem;
    left: -150px;
    bottom: 50px;
    animation: kPlayer 2.5s ease-out forwards;
}

.kempa-ball {
    position: absolute;
    font-size: 2.5rem;
    right: -100px;
    bottom: 400px;
    animation: kBall 2.5s linear forwards;
}

@keyframes kPlayer {
    0% {
        transform: translateX(0);
        bottom: 50px;
    }

    35% {
        transform: translateX(45vw);
        bottom: 50px;
    }

    50% {
        transform: translateX(50vw) translateY(-150px);
    }

    55% {
        transform: translateX(52vw) translateY(-150px);
    }

    75% {
        transform: translateX(60vw) translateY(0);
        opacity: 1;
    }

    100% {
        transform: translateX(65vw);
        opacity: 0;
    }
}

@keyframes kBall {
    0% {
        right: -100px;
        bottom: 600px;
    }

    50% {
        right: 46%;
        bottom: 250px;
    }

    55% {
        right: 46%;
        bottom: 250px;
    }

    75% {
        right: -200px;
        bottom: 250px;
    }

    100% {
        right: -200px;
        opacity: 0;
    }
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    z-index: 9997;
    pointer-events: none;
    right: 0;
    animation: confettiExplode 2s ease-out forwards;
}

@keyframes confettiExplode {
    0% {
        transform: translateX(0) translateY(0) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateX(-60vw) translateY(30vh) rotate(720deg);
        opacity: 0;
    }
}