@font-face {
    font-family: 'MosesText';
    src: url('../assets/fonts/MosesText_Inter-VF.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
}

@font-face {
    font-family: 'MosesText';
    src: url('../assets/fonts/MosesText_Inter-Light.otf?v=c4168ce4') format('opentype');
    font-weight: 300;
    font-style: normal;
}

@font-face {
    font-family: 'MosesText';
    src: url('../assets/fonts/MosesText_Inter-Regular.otf?v=9275aca6') format('opentype');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'MosesText';
    src: url('../assets/fonts/MosesText_Inter-Medium.otf?v=22fa8d06') format('opentype');
    font-weight: 500;
    font-style: normal;
}

@font-face {
    font-family: 'MosesText';
    src: url('../assets/fonts/MosesText_Inter-Bold.otf?v=770b9b85') format('opentype');
    font-weight: 700;
    font-style: normal;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    background-color: #EEF2FB;
}

body {
    font-family: 'MosesText', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #EEF2FB;
    color: #333;
    direction: rtl;
    font-weight: 300;
    min-height: 100vh;
    max-width: 1240px;
    margin: auto;
}

/* ── Header ─────────────────────────────────────────────── */

.page-header {
    background-color: #EEF2FB;
    user-select: none;
    padding: 0;
    position: relative;
}

.header-inner {
    position: relative;
    max-width: 1280px;
    margin: 0 auto;
    height: 95px;
    border-radius: 8px 8px 0 0;
    background-color: #00182F;
    background-image: url('../assets/images/Teams_bg.png?v=c2059735');
    background-size: cover;
    background-position: center;
    clip-path: inset(0 0 -200px 0);
    overflow: visible;
}

.header-bg-waves {
    display: none;
}

/* Decorative tab — top half (salmon) */
.header-inner::before {
    content: '';
    position: absolute;
    right: -53px;
    top: 0;
    width: 97px;
    height: 47.5px;
    background: #F48474;
    border-radius: 10000px 0 0 0;
    pointer-events: none;
    z-index: 2;
}

/* Decorative tab — bottom half (hot pink) */
.header-inner::after {
    content: '';
    position: absolute;
    right: -53px;
    bottom: 0;
    width: 97px;
    height: 47.5px;
    background: #F13E79;
    border-radius: 10000px 0 0 0;
    pointer-events: none;
    z-index: 2;
}

.header-content {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 50px;
    direction: rtl;
}

.header-title {
    font-size: 3.9rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.01em;
    line-height: 1;
    text-shadow: 0 1px 4px rgba(0,0,0,0.4);
    padding-right: 10px;
}

.header-trophy {
    position: absolute;
    bottom: -45px;
    left: 20px;
    height: 88px;
    width: auto;
    object-fit: contain;
    z-index: 10;
}

/* ── Search bar ─────────────────────────────────────────── */

.search-bar-wrapper {
    background: #EEF2FB;
    padding: 25px 20px;
    max-width: 1280px;
    margin: 0 auto;
    border-radius: 0 0 8px 8px;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 15px;
    background: #fff;
    border: 2px solid #689ABF;
    border-radius: 50px;
    padding: 0 16px;
    max-width: 610px;
    height: 50px;
    transition: border-color 0.2s;
}

.search-bar:focus-within {
    border-color: #689ABF;
}

.search-icon {
    color: #404040;
    flex-shrink: 0;
}

#search-input {
    flex: 1;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 14px;
    color: #1a1a2e;
    background: transparent;
    text-align: right;
    direction: rtl;
}

#search-input::placeholder {
    color: #A5ACBB;
}

/* ── Main content ───────────────────────────────────────── */

.main-content {
    max-width: 1280px;
    margin: 0 auto;
    padding: 20px 20px 40px;
}

.standings-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    max-width: 1260px;
    margin: 0 auto;
}

@media (max-width: 1200px) {
    .standings-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Hidden on desktop; shown only on mobile via media query below */
.group-header__chevron {
    display: none;
}

@media (max-width: 768px) {
    .standings-grid {
        grid-template-columns: 1fr;
    }

    .page-header {
        padding: 0;
    }

    .header-inner {
        height: 78px;
        border-radius: 0;
        overflow: hidden;
        clip-path: none;
    }

    /* Hide desktop tab decorations */
    .header-inner::before,
    .header-inner::after {
        display: none;
    }

    /* Mobile top half — salmon */
    .header-inner::before {
        display: block;
        content: '';
        position: absolute;
        right: -42px;
        top: 0;
        width: 79px;
        height: 39px;
        border-radius: 10000px 0 0 0;
        background: #F48474;
        pointer-events: none;
        z-index: 2;
    }

    /* Mobile bottom half — hot pink */
    .header-inner::after {
        display: block;
        content: '';
        position: absolute;
        right: -42px;
        top: 39px;
        width: 79px;
        height: 39px;
        border-radius: 10000px 0 0 0;
        background: #F13E79;
        pointer-events: none;
        z-index: 2;
    }

    /* Hide desktop stripes on mobile */
    .header-content::before {
        display: none;
    }

    .header-content {
        padding: 0 55px;
        z-index: 1;
    }

    .header-title {
        font-size: 1.6rem;
    }

    .header-trophy {
        height: 65px;
        bottom: 3px;
        left: 12px;
    }

    .search-bar-wrapper {
        padding: 10px 8px;
        border-radius: 0;
        max-width: 100%;
    }

    /* Show chevron on mobile */
    .group-header {
        cursor: pointer;
    }

    .group-header__chevron {
        display: block;
    }

    .main-content {
        padding: 12px 8px 32px;
    }
}

.group-card {
    background: #fff;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
}

.group-header {
    background: #00182F url('../assets/images/group_bg.png?v=0504b434') no-repeat left center;
    background-size: cover;
    color: #fff;
    padding: 14px 20px;
    font-size: 1.05em;
    font-weight: 400;
    text-align: right;
    direction: rtl;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.group-header__name {
    flex: 1;
}

.group-header__chevron {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    transition: transform 0.25s ease;
}

/* Collapsed state — rotates chevron 180° and hides table */
.group-card--collapsed .group-header__chevron {
    transform: rotate(180deg);
}

.group-card--collapsed .standings-table {
    display: none;
}

.standings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
    table-layout: fixed;
}

.standings-table th, .standings-table td {
    padding: 8px 5px;
    text-align: center;
}

.standings-table td {
    font-size: 0.95em;
}

.standings-table th {
    background-color: transparent;
    color: #fff;
    font-weight: 400;
    font-size: 0.85em;
    border: none;
    padding: 8px 5px;
}

.header-label {
    display: inline-block;
    background-color: #0a1e3a;
    padding: 6px 4px;
    border-radius: 2px;
}

.standings-table tbody tr {
    border-bottom: 1px solid #eee;
}

.standings-table tbody tr:last-child {
    border-bottom: none;
}

.standings-table tbody tr:hover {
    background-color: #f9f9f9;
}

.team-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: right !important;
    justify-content: flex-start;
    padding-right: 10px;
    direction: rtl;
    border-right: 4px solid transparent;
}

.team-rank {
    min-width: 20px;
    font-weight: 400;
    color: #333;
    text-align: center;
    font-size: 0.95em;
}

.team-flag {
    width: 30px;
    height: 23px;
    object-fit: cover;
    border-radius: 2px;
    border: none;
}

.team-name {
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #333;
}

/* Qualification borders on team-cell (design token source: fcds/green and fcds/medium-blue) */
.qualified-top2 {
    border-right: 4px solid #00B140;
}

/* Applied to 3rd-place teams that are confirmed to advance to Round of 32.
   During the group stage, shown for all 3rd-place teams (markThird = true).
   Once all R32 slots are assigned, shown only for the 8 best 3rd-place teams. */
.qualified-third {
    border-right: 4px solid #0070DF;
}

/* Column widths */
.col-team { width: 45%; text-align: right; }
.col-stat { width: 9%; text-align: center; }
.standings-table th.col-header { text-align: center; padding: 4px 0; }

.col-points {
    font-weight: bold;
    color: #0a1e3a;
}

/* ── Legend (מקרא) ─────────────────────────────────────── */

.legend {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    padding: 10px 0;
    direction: rtl;
    margin-top: 50px;
}

.legend__title {
    font-family: 'MosesText', sans-serif;
    font-size: 16px;
    font-weight: 700;
    line-height: 19px;
    color: #000;
    padding: 0 10px;
    width: 100%;
    text-align: right;
}

.legend__items {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 0 10px;
    width: 100%;
}

.legend__item {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 5px;
    padding-right: 10px;
    border-right: 3px solid transparent;
    width: 100%;
}

.legend__item--green {
    border-right-color: #00B140;
}

.legend__item--blue {
    border-right-color: #0070DF;
}

.legend__color-label {
    font-family: 'MosesText', sans-serif;
    font-size: 14px;
    font-weight: 700;
    line-height: 16px;
}

.legend__item--green .legend__color-label {
    color: #00B140;
}

.legend__item--blue .legend__color-label {
    color: #0070DF;
}

.legend__text {
    font-family: 'MosesText', sans-serif;
    font-size: 14px;
    font-weight: 400;
    line-height: 23px;
    color: #03122b;
}

/* Goal difference styling */
.goal-diff-positive {
    color: #28a745;
}

.goal-diff-negative {
    color: #dc3545;
}

.goal-diff-zero {
    color: #666;
}

/* ── Legend mobile overrides ─────────────────────────────── */
@media (max-width: 768px) {
    .legend {
        margin-top: 20px;
        gap: 5px;
    }

    .legend__title {
        font-size: 12px;
        line-height: 16px;
    }

    .legend__items {
        gap: 5px;
    }

    .legend__text {
        font-size: 12px;
        line-height: 17px;
    }

    .legend__color-label {
        display: none;
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .main-header h1 {
        font-size: 1.8em;
    }
    
    .main-header h2 {
        font-size: 1.3em;
    }
    
    .standings-table {
        font-size: 0.85em;
    }
    
    .team-name {
        font-size: 0.9em;
    }
    
    .col-team {
        width: 42%;
    }
}

/* ── Dark mode (mobile) ─────────────────────────────────── */
@media (max-width: 768px) and (prefers-color-scheme: dark) {
    body {
        background-color: #0a0a0a;
        color: #e4e8f0;
    }

    .page-header {
        background-color: #0a0a0a;
    }

    .search-bar-wrapper {
        background: #1e1e1e;
    }

    .search-bar {
        background: #2a2a2a;
        border-color: #3a3a3a;
    }

    #search-input {
        color: #fff;
    }

    #search-input::placeholder {
        color: #666;
    }

    .search-icon {
        color: #666;
    }

    .group-card {
        background: #1e1e1e;
    }

    .standings-table tbody tr {
        border-bottom-color: #2e2e2e;
    }

    .standings-table tbody tr:hover {
        background-color: #2a2a2a;
    }

    .standings-table td {
        color: #e4e8f0;
    }

    .team-name {
        color: #e4e8f0;
    }

    .team-rank {
        color: #a5acbb;
    }

    .col-points {
        color: #ffffff;
    }

    .goal-diff-zero {
        color: #a5acbb;
    }
}