/* =========================================
   MATCHDAY SELECTOR
   ========================================= */
.matchday-selector-wrapper {
    text-align: center;
    margin: 25px 0 30px 0;
}

.matchday-selector-wrapper select {
    padding: 10px 36px 10px 20px;
    font-size: 14px;
    font-weight: 700;
    border-radius: 8px;
    border: 1px solid #ddd;
    cursor: pointer;
    background-color: #fff;
    color: #333;
    outline: none;
    min-width: 240px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.04);
    appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="%23888" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    transition: border-color 0.2s;
}

/* =========================================
   THE CARDS
   ========================================= */
.match-card {
    background: #fff;
    border: 1px solid #eaeaea;
    border-radius: 12px;
    max-width: 750px;
    margin: 0 auto 16px auto;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
    overflow: hidden;
}

.match-card-header {
    background: #f8f9fa;
    border-bottom: 1px solid #eaeaea;
    padding: 10px 15px;
    font-weight: 800;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #888;
    text-align: center;
}

/* =========================================
   MATCH ROWS & BARS
   ========================================= */
.match-row {
    padding: 14px 20px;
    border-bottom: 1px solid #f8f8f8;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.match-row:last-of-type {
    border-bottom: none;
}

.match-date {
    text-align: center;
    font-size: 9px;
    font-weight: 600;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.match-teams-bars {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
}

.m-team {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    color: #222;
    min-width: 0; /* Magic Bullet */
}

.m-team-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.m-home {
    text-align: right;
    justify-content: flex-end;
}

.m-away {
    text-align: left;
    justify-content: flex-start;
}

.m-score-box {
    flex: 1.8;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #111;
    font-size: 18px;
    font-weight: 900;
    letter-spacing: 4px;
    height: 24px;
}

.m-bar-container {
    flex: 1.8;
    display: flex;
    height: 24px;
    border-radius: 6px;
    overflow: hidden;
    background: #f0f0f0;
}

.m-seg {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 11px;
    font-weight: 700;
    transition: width 0.4s ease;
    padding: 0 2px;
}

.m-win  { background-color: #42C4D1; }
.m-draw { background-color: #A0AAB5; }
.m-loss { background-color: #F5A623; }

/* =========================================
   FLAGS (NEW)
   ========================================= */
.team-flag-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 12px;
    border-radius: 1px;
    overflow: hidden;
    background: #f0f0f0;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,0.08);
}

.flag-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.flag-fallback {
    font-size: 8px;
    font-weight: 800;
    color: #bbb;
    text-transform: uppercase;
}

/* =========================================
   KNOCKOUT ADVANCEMENT PILLS
   ========================================= */
.m-advancement {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px 20px;
    background: #fbfbfb;
    border-top: 1px solid #f0f0f0;
    gap: 8px;
}

.m-adv-t1, .m-adv-t2 {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0; /* Crucial: Allows container to shrink below content size */
}

.m-adv-t1 { justify-content: flex-end; text-align: right; }
.m-adv-t2 { justify-content: flex-start; text-align: left; }

.m-adv-center {
    flex: 0;
    white-space: nowrap;
    color: #bbb;
    font-weight: 700;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0 4px;
}

.adv-name {
    color: #888;
    font-weight: 500;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /*flex: 1; /* Take up all available space */
    min-width: 0; /* Enable ellipsis */
}

.adv-prob {
    color: #111;
    font-weight: 800;
    font-size: 14px;
    flex-shrink: 0; /* Probability numbers must never shrink or wrap */
    margin: 0 6px;
}

/* =========================================
   MOBILE RESPONSIVENESS
   ========================================= */
@media (max-width: 768px) {
    .match-card { margin: 0 10px 12px 10px; }
    .match-teams-bars { gap: 6px; }
    .m-team { font-size: 11px; gap: 5px; }
    .m-bar-container, .m-score-box { height: 20px; flex: 1.4; }
    .m-score-box { font-size: 14px; letter-spacing: 2px; }
    .m-seg { font-size: 8.5px; font-weight: 800; }
    .match-row { padding: 12px 10px; }
    .m-advancement { padding: 10px 8px; gap: 4px; }

    .adv-name { font-size: 10px; }
    .adv-prob { font-size: 12px; margin: 0 2px; }
    .m-adv-center { font-size: 7.5px; }

    .team-flag-icon { width: 15px; height: 10px; }


    .m-team-name {
        white-space: normal;
        word-break: break-word; /* Prevents long words from breaking the layout */
        line-height: 1.2;
    }

    /* 2. Pin the flags to the top so they don't float weirdly if the text wraps */
    .m-team {
        font-size: 11px;
        gap: 5px;
        align-items: center;
        flex: 1;
    }

    /* 3. Give the bar a massive flex boost so it steals the newly freed space */
    .m-bar-container, .m-score-box {
        height: 20px;
        flex: 2.5; /* Boosted from 1.4 to make the bar dominant */
    }

    .m-seg {
        font-size: 8.5px;
        font-weight: 800;
    }


}

.m-adv-t2 .adv-name {
    padding-left: 10px
}
.m-adv-t1 .adv-name {
    padding-right: 10px
}

/* =========================================
   TOP PREDICTED SCORES DRAWER
   ========================================= */
.top-scores-container {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.top-scores-toggle {
    background: none;
    border: none;
    color: #999;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    transition: color 0.2s;
}

.top-scores-toggle:hover {
    color: #666;
}

.top-scores-toggle .ts-arrow {
    font-size: 8px;
    transition: transform 0.3s ease;
}

.top-scores-toggle.active .ts-arrow {
    transform: rotate(180deg);
}

.top-scores-drawer {
    width: 100%;
    max-width: 240px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, margin-top 0.3s ease, opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 5px;
    opacity: 0;
}

.top-scores-drawer.open {
    max-height: fit-content;
    margin-top: 8px;
    margin-bottom: 4px;
    opacity: 1;
}

.ts-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 11px;
    color: #555;
}

.ts-score {
    font-weight: 800;
    width: 32px;
    text-align: center;
    color: #333;
}

.ts-bar-wrapper {
    flex: 1;
    height: 6px;
    background: #f0f0f0;
    border-radius: 3px;
    overflow: hidden;
}

.ts-bar {
    height: 100%;
    background: #A0AAB5; /* Matches your 'Draw' gray for a neutral data look */
    border-radius: 3px;
}

.ts-prob {
    font-weight: 700;
    width: 34px;
    text-align: right;
}

/* =========================================
   CLICKABLE MATCH ROWS
   ========================================= */
a.match-row {
    text-decoration: none !important;
    color: inherit !important;
    transition: background-color 0.15s ease;
    cursor: pointer;
    display: flex;
}

/* Force child elements to ignore default link styling */
a.match-row * {
    text-decoration: none !important;
}

@media (hover: hover) {
    a.match-row:hover {
        background-color: #f4f9ff;
    }
}

/* =========================================
   MATCH ROW CTA (Clickable Hint)
   ========================================= */
.match-row-cta {
    width: 100%;
    text-align: center !important;
    padding-top: 12px;
    margin-top: 12px;
    border-top: 1px dashed #e2e8f0;
    font-size: 10px;
    font-weight: 700;
    color: #0088cc;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color 0.2s ease;
}

@media (hover: hover) {
    a.match-row:hover .match-row-cta {
        color: #005580;
    }
}