:root {
    --bg: #f0f1f3;
    --surface: #fff;
    --text: #1c1e21;
    --text2: #6f7680;
    --accent: #00985f;
    --accent-hover: #007c4e;
    --live: #e1054d;
    --divider: #eceef0;
    --row-h: 64px;
    --pad: 16px;
    --row-pad: 20px;
    --card-gap: 24px;
    --card-pad: 24px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

a {
    color: inherit;
    text-decoration: none;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

h1 {
    font-size: 20px;
    line-height: 1.3;
    margin: 0 0 4px;
}

/* ---- Site header ---- */
.site-header {
    height: 48px;
    display: flex;
    align-items: center;
    background: var(--surface);
    border-bottom: 1px solid var(--divider);
}

/* Contenu du header aligné sur .layout (pleine largeur en fond). */
.site-header-inner {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 var(--pad);
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.tagline {
    font-size: 12px;
    color: var(--text2);
}

@media (max-width: 599px) {
    .tagline {
        display: none;
    }
}

/* ---- Layout ---- */
.layout {
    max-width: 1100px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: var(--pad);
    padding: var(--pad);
    align-items: start;
}

.content {
    min-width: 0;
}

/* ---- Sidebar (liste des tournois) ---- */
.sidebar {
    position: sticky;
    top: var(--pad);
    background: var(--surface);
}

.side-row {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 44px;
    padding: 0 12px;
    border-left: 3px solid transparent;
    transition: background-color 0.12s;
}

.side-row:hover {
    background: var(--bg);
}

.side-row.active {
    border-left-color: var(--accent);
    color: var(--accent);
}

.side-row .t-name {
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.side-row .t-dates {
    font-size: 11px;
    color: var(--text2);
    line-height: 1.2;
    white-space: nowrap;
}

/* ---- Strip mobile (cachée sur desktop) ---- */
.tournament-strip {
    display: none;
}

/* ---- Cartes ---- */
.card {
    background: var(--surface);
    margin: 0 0 var(--card-gap);
}

.card-head {
    display: block;
    margin: 0;
    height: 48px;
    line-height: 48px;
    padding: 0 var(--row-pad);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text2);
    border-bottom: 1px solid var(--divider);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.page-head {
    padding: var(--card-pad);
}

.intro {
    margin: 0;
    color: var(--text2);
    line-height: 1.6;
}

.welcome {
    padding: var(--pad);
}

.welcome p {
    margin: 0;
    color: var(--text2);
}

/* ---- Bloc ICS ---- */
.ics-block {
    padding: var(--card-pad);
}

.ics-block p {
    margin: 0;
}

.ics-cta {
    display: inline-flex;
    align-items: center;
    height: 32px;
    padding: 0 14px;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    transition: background-color 0.12s;
}

.ics-cta:hover,
.ics-cta:focus-visible {
    background: var(--accent-hover);
    color: #fff;
}

.ics-note {
    margin-top: 8px !important;
    font-size: 12px;
    color: var(--text2);
}

/* ---- Barre de filtres ---- */
.filter-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg);
    padding: 14px 0;
    margin: 0 0 var(--card-gap);
}

.chips {
    display: flex;
    gap: 10px;
    overflow-x: auto;
}

.chip {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    background: var(--surface);
    color: var(--text);
    border: 0;
    font: inherit;
    font-size: 13px;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.12s;
}

.chip:hover {
    background: var(--divider);
}

.chip[aria-pressed="true"] {
    background: var(--accent);
    color: #fff;
}

/* ---- Toggles de filtre (sous les chips équipes) ---- */
.filters {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 14px;
}

.ftog {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.ftog-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    background: transparent;
    border: 0;
    font: inherit;
    color: var(--text);
    cursor: pointer;
}

.ftog-box {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: var(--surface);
    border: 1px solid #c4c9cf;
}

.ftog-btn[aria-checked="true"] .ftog-box {
    background: var(--accent);
    border-color: var(--accent);
}

.ftog-btn[aria-checked="true"] .ftog-box::after {
    content: "✓";
    color: #fff;
    font-size: 11px;
    line-height: 1;
}

.ftog-main {
    font-weight: 600;
}

.ftog-sub {
    font-size: 12px;
    color: var(--text2);
}

.filter-foot {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 14px;
}

.f-reset {
    padding: 6px 10px;
    background: var(--surface);
    border: 0;
    font: inherit;
    font-size: 12px;
    color: var(--text2);
    cursor: pointer;
    transition: background-color 0.12s;
}

.f-reset:hover {
    background: var(--divider);
}

.filter-count {
    margin: 0;
    font-size: 12px;
    color: var(--text2);
}

.empty-state {
    padding: 24px var(--row-pad);
    text-align: center;
    color: var(--text2);
}

/* ---- Bannière prochain match ---- */
.next-up {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
    background: var(--surface);
    border-left: 3px solid var(--accent);
    padding: 16px 20px;
    margin: 0 0 var(--card-gap);
}

.next-up.is-live {
    border-left-color: var(--live);
}

.nu-prefix {
    font-weight: 700;
}

.next-up.is-live .nu-prefix {
    color: var(--live);
}

.nu-teams {
    font-weight: 600;
}

.nu-countdown {
    color: var(--text2);
    font-variant-numeric: tabular-nums;
}

/* ---- Lignes de match ---- */
.grp ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.match {
    height: var(--row-h);
    display: grid;
    grid-template-columns: 64px 1fr 150px 88px;
    column-gap: 12px;
    align-items: center;
    padding: 0 var(--row-pad);
    border-bottom: 1px solid var(--divider);
    transition: background-color 0.12s;
}

.match[hidden] {
    display: none;
}

.match[data-choc="1"] {
    border-left: 3px solid var(--live);
    padding-left: calc(var(--row-pad) - 3px);
}

.match:hover {
    background: #f7f8f9;
}

.match:last-child {
    border-bottom: 0;
}

.m-time {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    font-variant-numeric: tabular-nums;
}

.m-day {
    font-size: 11px;
    color: var(--text2);
    white-space: nowrap;
}

.m-hour {
    font-weight: 600;
}

.nuit {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text2);
}

.m-teams {
    display: grid;
    grid-template-columns: 1fr 56px 1fr;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.m-tags {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    min-width: 0;
}

.tag {
    display: inline-flex;
    align-items: center;
    height: 18px;
    padding: 0 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1;
}

.tag-choc {
    color: var(--live);
    background: rgba(225, 5, 77, 0.1);
}

.tag-live {
    color: #fff;
    background: var(--live);
    animation: tag-pulse 1.2s ease-in-out infinite;
}

.tag-next {
    color: #fff;
    background: var(--accent);
}

@keyframes tag-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

@media (prefers-reduced-motion: reduce) {
    .tag-live { animation: none; }
}

.team {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.team.t1 {
    justify-content: flex-end;
    text-align: right;
}

.team.t2 {
    justify-content: flex-start;
    text-align: left;
}

.t-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.team.fav {
    font-weight: 600;
}

.team.ph {
    color: var(--text2);
}

.flag {
    flex: 0 0 auto;
}

.m-action {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.m-add {
    display: inline-flex;
    align-items: center;
    height: 28px;
    padding: 0 8px;
    color: var(--text2);
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
    transition: background-color 0.12s, color 0.12s;
}

.m-add:hover,
.m-add:focus-visible {
    color: var(--accent);
    background: var(--bg);
}

.m-score {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    text-align: center;
    color: var(--text);
}

.m-score.live {
    color: var(--live);
}

.m-vs {
    color: var(--text2);
    font-weight: 400;
}

/* ---- WhatsApp ---- */
.whatsapp {
    padding: var(--pad);
}

.whatsapp p {
    margin: 0;
}

.whatsapp .join-btn {
    display: inline-flex;
    align-items: center;
    height: 32px;
    padding: 0 14px;
    margin-left: 4px;
    background: #25d366;
    color: #000;
    font-weight: 600;
    transition: background-color 0.12s;
}

.whatsapp .join-btn:hover {
    background: #1fb858;
}

/* ---- Footer ---- */
footer.note {
    font-size: 12px;
    color: var(--text2);
    padding: 0 var(--pad) 24px;
}

footer.note a {
    text-decoration: underline;
}

/* ---- Mobile < 900px ---- */
@media (max-width: 899px) {
    .sidebar {
        display: none;
    }

    .tournament-strip {
        display: flex;
        overflow-x: auto;
        background: var(--surface);
        border-bottom: 1px solid var(--divider);
    }

    .strip-row {
        flex: 0 0 auto;
        display: flex;
        flex-direction: column;
        justify-content: center;
        height: 48px;
        padding: 0 14px;
        border-bottom: 3px solid transparent;
        transition: background-color 0.12s;
    }

    .strip-row.active {
        border-bottom-color: var(--accent);
        color: var(--accent);
    }

    .strip-row .t-name {
        font-size: 13px;
        font-weight: 600;
        line-height: 1.2;
        white-space: nowrap;
    }

    .strip-row .t-dates {
        font-size: 10px;
        color: var(--text2);
        line-height: 1.2;
        white-space: nowrap;
    }

    .layout {
        display: block;
        padding: 0;
    }

    /* Cartes bord à bord */
    .card {
        margin: 0 0 12px;
    }

    .filter-bar {
        padding: 12px var(--pad);
        margin: 0 0 12px;
    }

    .next-up {
        margin: 0 0 12px;
    }

    /* Colonne tags repliée (auto) ; tags sous les équipes, sans toucher
       la hauteur des autres colonnes quand elle est vide. */
    .match {
        grid-template-columns: 64px 1fr auto;
        grid-template-areas:
            "time teams action"
            "time tags  action";
        height: auto;
        min-height: var(--row-h);
        padding-top: 6px;
        padding-bottom: 6px;
    }

    .m-time {
        grid-area: time;
    }

    .m-teams {
        grid-area: teams;
    }

    .m-tags {
        grid-area: tags;
        justify-content: flex-start;
        font-size: 10px;
    }

    .m-tags:empty {
        display: none;
    }

    .m-action {
        grid-area: action;
    }
}

/* ---- Thème bleu testable (?theme=blue) ---- */
html[data-theme="blue"] {
    --accent: #1a56db;
    --accent-hover: #1648b8;
}
