.ba-live-score-wrapper :where(.button, button, fieldset, input, select, textarea) {
    margin: 0 !important;
}

.ba-live-score-wrapper {
    font-family: "Lexend", 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #333;
    max-width: 1200px;
    margin: 20px auto;
    background: #fff;
    box-shadow: 0 0px 6px 2px rgba(0, 0, 0, .04);
}

/* Filter Section */
.ba-filters-container {
    padding: 24px;
    background: #edf2f7;
    border-bottom: 1px solid #eee;
}

.ba-search-league-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 20px;
}

.ba-search-box {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.ba-search-box input {
    width: 100%;
    padding: 12px 45px 12px 20px;
    border: 1.5px solid #e0e0e0;
    border-radius: 30px !important;
    font-size: 14px;
    background: #fff;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.ba-search-box input:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.1);
}

.ba-search-box i {
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 20px;
    transition: color 0.3s;
}

.ba-search-box input:focus+i {
    color: #3498db;
}

.ba-league-filter select,
.ba-provider-filter select {
    width: 100%;
    padding: 0 40px 0 20px;
    border: 1.5px solid #e0e0e0;
    border-radius: 20px;
    font-size: 14px;
    background: #fff;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 18px;
    transition: all 0.3s ease;
}

.ba-league-filter select:focus,
.ba-provider-filter select:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.1);
}

/* Date Tabs */
.ba-date-tabs {
    display: flex;
    gap: 10px;
    background: transparent;
    overflow-x: auto;
    padding: 5px 0;
    scrollbar-width: none;
}

.ba-date-tabs::-webkit-scrollbar {
    display: none;
}

.ba-date-tab {
    padding: 10px 24px;
    background: #fff;
    color: #666;
    border: 1.5px solid #eee;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ba-date-tab:hover {
    background: #f8f9fa;
    border-color: #ddd;
    transform: translateY(-1px);
}

.ba-date-tab.active {
    background: #436590;
    color: #fff;
    border-color: #4c9eea;
}

/* Table Design */
.ba-score-table-container {
    width: 100%;
    overflow-x: auto;
    background: #fff;
    position: relative;
    min-height: 200px;
}

.ba-score-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.ba-score-table th,
.ba-match-row td,
.ba-section-title,
.ba-toggle-cell,
.ba-h1-left-info,
.ba-load-more-container {
    border-right: none !important;
    border-top: none;
}

.ba-score-table th {
    background: #2c3e50;
    color: #fff;
    padding: 10px 8px;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: 1px solid #919eab;
    text-align: center;
}

.ba-score-table th.sub-th {
    background: #34495e;
    font-size: 11px;
    padding: 8px 10px;
}

.ba-score-table th:first-child,
.ba-score-table td:first-child:not(.ba-full-width-mobile) {
    padding-left: 24px !important;
}

.ba-score-table th:last-child,
.ba-score-table td:last-child:not(.ba-full-width-mobile) {
    padding-right: 24px !important;
}

.ba-score-table thead tr:first-child th:first-child {
    border-top-left-radius: 0px;
}

.ba-score-table thead tr:first-child th:last-child {
    border-top-right-radius: 0px;
}

.ba-title-row td,
.ba-league-group td {
    padding: 0 !important;
}

.ba-title-row td:first-child,
.ba-league-group td:first-child,
.ba-title-row td:last-child,
.ba-league-group td:last-child {
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* Section Title Row */
.ba-section-title {
    background: #1a252f;
    color: #fff;
    padding: 10px 20px;
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    text-align: center;
}

/* League Row */
.ba-league-header {
    background: #edf2f7;
    color: #2d3748;
    padding: 8px 20px;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    border-bottom: 2px solid #e2e8f0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ba-league-header img {
    width: 20px !important;
    height: 20px !important;
    margin-right: 12px;
    object-fit: contain;
}

/* Match Row */
.ba-match-row {
    border-bottom: 1px solid #edf2f7;
    background: #fff;
    transition: background 0.2s ease;
}

.ba-match-row:hover {
    background: #f8fafc;
}

.ba-match-row td {
    padding: 2px 4px;
    vertical-align: middle;
    text-align: center;
}

.ba-match-row.ba-is-live {
    background: #fff5f5;
}

.ba-match-row.ba-is-live:hover {
    background: #fff0f0;
}

/* Time & Score Cell */
.ba-time-cell {
    width: 110px;
}

.ba-score-val {
    display: block;
    font-weight: bold;
    font-size: 12px;
    margin-bottom: 6px;
    color: #333;
}

.ba-live-info,
.ba-finished-info,
.ba-upcoming-time {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    gap: 4px;
}

.ba-status-name.ft {
    background: #4a5568 !important;
    color: #fff !important;
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 4px;
}

.ba-live-status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    flex-direction: row;
    flex-wrap: nowrap;
}

.ba-elapsed-time,
.ba-status-name {
    white-space: nowrap;
}

.ba-live-time,
.ba-match-hour {
    color: #555;
    font-size: 13px;
    font-weight: 500;
}

.ba-elapsed-time {
    color: #c0392b;
    font-weight: bold;
    font-size: 13px;
}

.ba-match-date {
    font-size: 13px;
    color: #888;
}

.ba-status-name {
    font-size: 10px;
    text-transform: uppercase;
    color: #4a5568;
    background: #edf2f7;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* Match/Teams Cell */
.ba-match-cell {
    text-align: left !important;
    padding-left: 15px !important;
}

.ba-teams-names {
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: relative;
}

.ba-team-row {
    display: flex;
    align-items: center;
    gap: 5px;
    /* margin-bottom: 4px; */
}

.ba-team-logo {
    width: 20px !important;
    height: 20px !important;
    object-fit: contain;
    flex-shrink: 0;
}

.ba-team-name {
    font-size: 12px;
    font-weight: 500;
}

.ba-team-name.home {
    color: #c0392b;
}

.ba-draw-label {
    color: #333;
    font-size: 11px;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translate(-50%, -50%);
}

/* Odds Components */
.ba-odds-cell {
    min-width: 90px;
    border-left: 1px solid #e0e0e0;
    position: relative;
}

.ba-odds-flex {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

.ba-handicap-val {
    color: #c0392b;
    font-weight: bold;
    font-size: 13px;
    flex: 0 0 40px;
    text-align: right;
}

.ba-odds-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.ba-odds-val {
    font-size: 12px;
    color: #333;
    font-weight: 500;
}

.ba-eu-cell .ba-odds-stack {
    align-items: center;
}

/* Toggle Button (hidden on desktop, visible on mobile) */
.ba-toggle-cell {
    display: none;
    width: 40px;
    text-align: center;
    padding: 8px !important;
}

.ba-toggle-h1.active {
    color: #3498db;
}

/* Collapsible First Half Row (hidden by default) */
.ba-h1-collapsible {
    display: none;
}

.ba-h1-collapsible td {
    background: #FFF9E6;
    /* Beige/cream background */
    border-bottom: 1px solid #e2e8f0;
}

.ba-h1-left-info {
    padding: 8px 4px !important;
    text-align: center;
    vertical-align: middle;
}

.ba-h1-title {
    font-size: 11px;
    font-weight: 700;
    color: #4b5563;
    margin-bottom: 4px;
}

.ba-h1-close {
    background: none;
    border: 1px solid #919eab;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.ba-h1-close:hover {
    transform: scale(1.1);
}

/* Internal Toggle Styles */
.ba-mobile-toggle-wrapper {
    display: none;
    margin-top: 5px;
}

.ba-toggle-h1 {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    color: #4CAF50;
    /* Green color from image */
    cursor: pointer;
    transition: color 0.3s ease;
}

.ba-toggle-h1:hover {
    color: #3498db;
}

.ba-toggle-h1 svg {
    transition: transform 0.3s ease;
}

.ba-toggle-h1.active svg {
    transform: rotate(180deg);
}

.ba-toggle-h1 span {
    transform: none !important;
    display: inline-block;
}

/* Responsive */
@media screen and (max-width: 768px) {
    .ba-live-score-wrapper {
        margin: 0 auto;
        width: 100%;
        max-width: 100%;
        box-shadow: none;
    }

    .ba-draw-label {
        top: 145%
    }

    .ba-date-tab {
        padding: 0 14px;
        font-size: 12px
    }

    .ba-no-matches-row {
        height: 96px;
        font-size: 12px;
    }

    .ba-filters-container {
        padding: 15px;
    }

    .ba-search-league-row {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .ba-search-box {
        width: 100%;
        max-width: 100%;
    }

    /* Show internal toggle on mobile */
    .ba-mobile-toggle-wrapper {
        display: block;
    }

    /* Hide 1H header and columns on mobile */
    /* First header row: hide 4th the (Hiệp 1) */
    .ba-score-table thead tr:first-child th:nth-child(4),
    /* Second header row: hide 4th, 5th, 6th th (1H Tỷ Lệ, 1H Tài Xỉu, 1H 1x2) */
    .ba-score-table thead tr:last-child th:nth-child(4),
    .ba-score-table thead tr:last-child th:nth-child(5),
    .ba-score-table thead tr:last-child th:nth-child(6),
    /* Match rows: hide indices 5, 6, 7 (1H columns) */
    .ba-match-row td:nth-child(6),
    .ba-match-row td:nth-child(7),
    .ba-match-row td:nth-child(8) {
        display: none;
    }

    /* Adjust table for mobile - fit to screen */
    .ba-score-table {
        font-size: 11px;
        width: 100% !important;
        max-width: 100% !important;
        table-layout: auto;
        /* Changed from fixed to allow natural stretching */
        border-spacing: 0;
        display: table !important;
    }

    .ba-score-table th,
    .ba-score-table td {
        padding: 3px 3px !important;
        box-sizing: border-box;
    }

    /* Explicitly override the desktop side padding */
    .ba-score-table th:first-child,
    .ba-score-table td:first-child:not(.ba-full-width-mobile) {
        padding-left: 5px !important;
    }

    .ba-score-table th:last-child,
    .ba-score-table td:last-child:not(.ba-full-width-mobile) {
        padding-right: 5px !important;
    }

    /* Column widths for mobile */
    .ba-time-cell {
        width: 45px !important;
        /* Reduced for 320px */
        min-width: 45px;
    }

    .ba-h1-left-info {
        width: 45px !important;
        min-width: 45px;
    }

    .ba-match-cell {
        width: auto !important;
        min-width: 70px;
        /* Further reduced for 320px */
    }

    .ba-odds-cell {
        width: 58px !important;
        /* Reduced for 320px */
        min-width: 58px;
    }

    /* Ensure specific sub-headers also have widths */
    .ba-score-table thead th.sub-th {
        width: 58px !important;
        padding: 5px !important;
    }

    .ba-score-table thead th:nth-child(1) {
        width: 45px !important;
    }

    .ba-score-table thead th:nth-child(2) {
        width: auto !important;
    }

    /* Adjust odds display for mobile */
    .ba-handicap-val {
        font-size: 10px;
        flex: 0 0 22px;
        color: #8b0000;
        font-weight: 700;
    }

    .ba-odds-flex {
        gap: 8px !important;
    }

    .ba-score-table-container {
        padding: 0;
        margin: 0;
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden;
        display: block !important;
    }

    /* Force colspan cells to stretch */
    .ba-full-width-mobile {
        width: 100% !important;
        display: table-cell !important;
    }

    .ba-odds-val {
        font-size: 10px;
        padding: 1px 0;
    }

    .ba-team-row {
        gap: 5px;
        /* margin-bottom: 2px; */
    }

    .ba-team-logo {
        width: 14px !important;
        height: 14px !important;
    }

    /* Compact team names */
    .ba-team-name {
        font-size: 11px;
        display: block;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        color: #444;
        max-width: 80px;
    }

    .ba-team-name.away {
        color: #ff6b6b;
    }

    .ba-draw-label {
        font-size: 10px;
        color: #666;
        /* padding-left: 19px; */
    }

    /* Live info adjustments */
    .ba-live-time,
    .ba-elapsed-time,
    .ba-status-name {
        font-size: 9px;
    }

    .ba-score-val {
        font-size: 11px;
        font-weight: 700;
    }

    .ba-live-status-row {
        flex-direction: column;
        gap: 2px;
    }
}

/* Extra small screen tweaks */
@media screen and (max-width: 375px) {
    .ba-score-table {
        font-size: 10px;
    }

    .ba-odds-cell {
        width: 55px !important;
        min-width: 55px;
    }

    .ba-score-table thead th.sub-th {
        width: 55px !important;
    }

    .ba-match-cell {
        padding-left: 5px !important;
    }
}

/* Tablet adjustments */
@media screen and (min-width: 769px) {
    .ba-h1-collapsible {
        display: none !important;
        /* Always hide on desktop */
    }
}

/* Odds Change Indicators */
.ba-odds-up {
    color: #27ae60 !important;
    /* Green */
    transition: color 0.5s ease;
}

.ba-odds-down {
    color: #c0392b !important;
    /* Red */
    transition: color 0.5s ease;
}

/* MQTT Odds Flash Animation */
.ba-odds-flash {
    animation: ba-odds-flash-animation 0.5s ease;
}

@keyframes ba-odds-flash-animation {

    0%,
    100% {
        background-color: transparent;
    }

    50% {
        background-color: rgba(52, 152, 219, 0.1);
    }
}

/* Suspended/Closed Odds State */
.ba-odds-suspended {
    opacity: 0.6;
    position: relative;
    pointer-events: none;
}

/* Status Overlays (Lock/Maintenance) */
.ba-odds-status-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    background: #fff;
    backdrop-filter: blur(2px);
    border-radius: 4px;
}

/* Row-specific backgrounds for overlays to fully obscure data */
.ba-match-row.ba-is-live .ba-odds-status-overlay {
    background: #fff5f5;
}

.ba-h1-collapsible .ba-odds-status-overlay {
    background: #FFF9E6;
}

/* Hover consistency */
.ba-match-row:hover .ba-odds-status-overlay {
    background: #f8fafc;
}

.ba-match-row.ba-is-live:hover .ba-odds-status-overlay {
    background: #fff0f0;
}


.ba-odds-status-overlay.locked {
    color: #e74c3c;
}

.ba-odds-status-overlay.maint {
    color: #f39c12;
}

.ba-odds-status-overlay.empty {
    color: #95a5a6;
}

.ba-odds-icon {
    width: 20px !important;
    height: 20px !important;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

/* Ensure odds content is still semi-visible but muted under icons */
.ba-odds-suspended .ba-odds-flex,
.ba-odds-suspended .ba-odds-stack {
    filter: blur(0.5px);
}


/* Load More Button */
.ba-load-more-container {
    padding: 12px;
    text-align: center;
    background: #fcfcfc;
    border-top: 1px solid #eee;
}

.ba-load-more-btn {
    padding: 12px 40px;
    background: #2c3e50;
    color: #fff;
    border: 1px solid #919eab;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.ba-load-more-btn:hover {
    background: #34495e;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.ba-load-more-btn:active {
    transform: translateY(0);
}

.ba-load-more-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Loader Overlay */
.ba-loader-overlay {
    position: absolute;
    top: var(--ba-header-height, 0);
    left: 0;
    width: 100%;
    height: calc(100% - var(--ba-header-height, 0));
    background: rgba(255, 255, 255, 0.7);
    display: none;
    justify-content: center;
    align-items: flex-start;
    /* Position spinner at the top of the body area */
    padding-top: 50px;
    /* 50px from the top of the body */
    z-index: 100;
}

/* Spinner Animation */
.ba-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    animation: ba-spin 1s linear infinite;
}

@keyframes ba-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

td.ba-full-width-mobile {
    padding: 0px !important;
}