.score_jungs {
    background-color: var(--herren-bg);
}

.score_damen {
    background-color: var(--damen-bg);
}

.table-wrap {
    position: relative;
    z-index: 1;
    overflow-x: auto;
    overflow-y: hidden;
    width: auto;
    padding: 0 0 5px 0 !important;
    margin: 0 20px !important;
    clip-path: inset(0);
    -webkit-overflow-scrolling: touch;
}

/* Custom Scrollbar for Tables */
.table-wrap::-webkit-scrollbar {
    height: 40px; /* Matches a standard row height */
}

.table-wrap::-webkit-scrollbar-track {
    background: var(--surface); /* Light gray like a row */
    border-radius: 0;
    margin: 0;
}

.table-wrap::-webkit-scrollbar-thumb {
    background: var(--border-hi); /* Solid medium gray handler */
    border-radius: 4px;
    border: 4px solid transparent; /* Subtle border for spacing */
    background-clip: padding-box;
}

.table-wrap::-webkit-scrollbar-thumb:hover {
    background: rgba(60, 70, 90, 1.0);
    background-clip: padding-box;
    cursor: grab;
}

.table-wrap::-webkit-scrollbar-thumb:active {
    background: rgba(30, 40, 60, 1.0);
    background-clip: padding-box;
    cursor: grabbing;
}

/* Firefox Support & Desktop Drag Styles */
.table-wrap {
    scrollbar-width: auto;
    scrollbar-color: rgba(80, 90, 110, 0.6) rgba(0, 0, 0, 0.1);
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.table-wrap:active,
.table-wrap.active_drag {
    cursor: grabbing;
}

table {
    display: table;
    font-family: 'Inter', sans-serif;
    font-size: 10pt;
    color: var(--text);
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
    border: 0;
    margin: 0 !important;
    padding: 0 !important;
    z-index: 10;
}

th {
    background-color: var(--table-cell);
    color: var(--muted);
    font-weight: 700;
    padding-bottom: 8px;
    padding-top: 10px;
    padding-left: 0px;
    padding-right: 0px;
}

td {
    text-align: center;
    background-color: var(--table-cell);
    font-weight: 400;
    text-decoration: none;
    font-family: 'Inter', sans-serif;
    font-style: normal;
    padding: 0px;
}

th,
td {
    border: 1px solid var(--border-table);
}

.Punkte td:first-child,
th:first-child {
    position: sticky;
    left: 0px;
    z-index: 99;
    background-color: var(--sticky-bg) !important;
}

.Punkte td:nth-child(2),
th:nth-child(2) {
    position: sticky;
    left: 28px;
    z-index: 98;
    background-color: var(--sticky-bg) !important;
}

.Punkte td:nth-child(3),
th:nth-child(3) {
    position: sticky;
    left: 88px;
    z-index: 97;
    background-color: var(--sticky-bg) !important;
    /* Visual separation between sticky Part 1 and scrolling Part 2 */
    box-shadow: 3px 0 5px -2px rgba(0, 0, 0, 0.3);
}

.Datum td:first-child {
    position: sticky;
    left: 0px;
    z-index: 99;
    background-color: var(--sticky-bg) !important;
}

.Datum td:nth-child(2) {
    position: sticky;
    left: 28px;
    z-index: 98;
    background-color: var(--sticky-bg) !important;
}

.Datum td:nth-child(3) {
    position: sticky;
    left: 88px;
    z-index: 97;
    background-color: var(--sticky-bg) !important;
    box-shadow: 3px 0 5px -2px rgba(0, 0, 0, 0.3);
}

.Top5 {
    background-color: var(--table-highlight) !important;
    color: var(--table-text-hi) !important;
    font-weight: 800;
}

.notTop5 {
    background-color: var(--table-cell) !important;
    color: var(--muted) !important;
    font-weight: 400;
}

.table_pos {
    min-width: 28px;
    max-width: 28px;
}

.table_name {
    min-width: 180px;
    max-width: 180px;
}

.table_gesamt {
    min-width: 60px;
    max-width: 60px;
}

.table_runde {
    min-width: 70px;
    max-width: 70px;
}

/* .Top5 defined above at line 125 – duplicate removed */

.notTop5 {
    background-color: transparent;
    color: var(--dim);
}


/* Date Row */

.Datum {
    display: none;
    background-color: var(--surface);
}


/* pretend colspan = 3 
    set Background to first 3 Col
    remove inner Borders    */

.Datum td:first-child,
.Datum td:nth-child(2),
.Datum td:nth-child(3) {
    background-color: var(--surface);
}

.Datum td:first-child,
.Datum td:nth-child(2) {
    border-right: none;
}

.Datum td:nth-child(3) {
    border-left: none;
}

.Punkte, .Punkte td {
    cursor: pointer;
}

.score_damen .Punkte:hover td,
.score_damen .mobile-detail-row:hover td {
    background-color: var(--border-hi) !important; /* Solid grey highlight */
}

.score_jungs .Punkte:hover td,
.score_jungs .mobile-detail-row:hover td {
    background-color: var(--border-hi) !important; /* Solid grey highlight */
}

@media (max-width: 1023px) {
    .table-wrap {
        cursor: default !important; /* Disable grab-scroll cursor on mobile */
    }
    /* TABLE STRUCTURE */
    table, thead, tbody, tr {
        display: block !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    thead tr, .Punkte {
        display: flex !important;
        flex-direction: row !important;
        align-items: stretch !important;
        width: 100% !important;
    }

    /* Reset Desktop Sticky Positioning */
    th, td {
        position: static !important;
        left: auto !important;
        z-index: 1 !important;
    }

    /* COLUMN WIDTHS - Consistently apply to both th and td via classes */
    .table_pos { 
        min-width: 45px !important; 
        max-width: 45px !important;
        flex-shrink: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .table_gesamt { 
        min-width: 75px !important; 
        max-width: 75px !important; 
        flex-shrink: 0 !important;
        border-left: none !important;
        border-right: none !important;
        font-size: 0.9rem !important;
        padding: 4px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        /* background-color: #f0f0f0 !important; -- Removed to match row background */
    }

    .table_name { 
        flex-grow: 1 !important; 
        min-width: 0 !important;
        max-width: none !important;
        text-align: left !important;
        padding-left: 10px !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: flex !important;
        align-items: center !important;
    }

    /* Hide all round columns and headers */
    th:nth-child(n+4), 
    td.table_runde,
    .table_runde {
        display: none !important;
    }

    /* MOBILE DETAIL ROWS */
    .mobile-detail-row {
        display: block !important;
        width: 100% !important;
        border-bottom: 1px solid var(--border);
        background: var(--card-alt);
    }

    .mobile-detail-container {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 10px;
        padding: 12px 14px !important;
        width: 100% !important;
        box-sizing: border-box;
        background: transparent !important;
        border: none !important;
    }

    .mobile-detail-container .detail-content {
        padding: 8px 12px !important;
        border: 1px solid var(--border) !important;
        border-radius: 8px;
        line-height: 1.3 !important;
        min-width: 65px !important;
        text-align: center;
        background: var(--card) !important;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }

    .detail-date {
        font-size: 0.65rem;
        color: var(--muted);
        font-weight: 500;
        margin-bottom: 4px;
    }

    .detail-score {
        font-size: 0.95rem;
        font-weight: 800;
        color: var(--text);
    }

    .mobile-detail-container .detail-content.Top5 {
        background-color: var(--table-highlight) !important;
        border-color: var(--table-highlight) !important;
        color: var(--table-text-hi) !important;
    }
    .mobile-detail-container .detail-content.Top5 .detail-score {
        color: var(--table-text-hi) !important;
        font-weight: 800 !important;
    }
    .mobile-detail-container .detail-content.notTop5 {
        background-color: var(--table-cell) !important;
    }
    .mobile-detail-container .detail-content.notTop5 .detail-score {
        color: var(--muted) !important;
    }

    .clickable-name {
        cursor: pointer;
        color: #1a56db;
        text-decoration: underline dotted;
    }

    .Datum {
        display: none !important;
    }
}
