:root {
    --primary: #1d4ed8;
    --secondary: #f59e0b;
    --bg: #f6f7f9;
    --card: #ffffff;
    --text: #16181d;
    --muted: #667085;
    --border: #e4e7ec;
    --win: #067647;
    --loss: #b42318;
    color-scheme: light;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.wrap { max-width: 920px; margin: 0 auto; padding: 0 16px; }

/* Club logo repeated, light grey and spaced, behind everything. */
.tiles {
    position: fixed;
    inset: -40px;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}
.tile-row { display: flex; height: 190px; align-items: center; }
/* Every other row shifted by half a cell: a quincunx, never two side by side. */
.tile-row:nth-child(even) { margin-left: 140px; }
.tiles img {
    flex: none;
    width: 84px;
    height: 84px;
    margin: 0 98px;
    object-fit: contain;
    filter: grayscale(1);
    opacity: .14;
}

.site-header {
    background: var(--primary);
    color: #fff;
    border-bottom: 4px solid var(--secondary);
}
.site-header .wrap {
    position: relative;
    min-height: 112px;
    padding-right: 210px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding-top: 20px;
    padding-bottom: 20px;
}
.site-header h1 { margin: 0; font-size: clamp(1.4rem, 4vw, 2rem); line-height: 1.15; }
.eyebrow { margin: 0 0 4px; font-size: .85rem; opacity: .85; text-transform: uppercase; letter-spacing: .06em; }
/* Club logo straddles the header and the page, without a background. */
.club-logo {
    position: absolute;
    right: 16px;
    bottom: -84px;
    z-index: 2;
    width: 184px;
    height: 184px;
    object-fit: contain;
    /* Thick shadow that follows the logo's contour (transparent background). */
    filter:
        drop-shadow(0 0 1px rgba(0, 0, 0, .55))
        drop-shadow(0 0 4px rgba(0, 0, 0, .45))
        drop-shadow(0 6px 14px rgba(0, 0, 0, .40));
}

.filters-panel { margin: 100px 0 20px; }
.filters-panel > summary { display: none; }
.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    padding: 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.filters label span { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 4px; }
.filters select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    font: inherit;
}
.filter-actions { display: flex; align-items: end; gap: 12px; }
.filter-actions a { color: var(--primary); font-size: .9rem; padding-bottom: 8px; }
.apply { padding: 8px 14px; border: 0; border-radius: 8px; background: var(--primary); color: #fff; font: inherit; }

.group { margin: 28px 0; }
.group h2 {
    margin: 0;
    font-size: 1.15rem;
    padding-left: 10px;
    border-left: 4px solid var(--primary);
}
.day { margin: 18px 0 0; font-size: 1rem; color: var(--text); }
.subtitle { margin: 4px 0 0 14px; color: var(--muted); font-size: .9rem; }

.matches { display: grid; gap: 10px; margin-top: 12px; }
.layout-cards .matches { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.match {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
}
.meta { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; color: var(--muted); }

.pill { font-size: .9rem; font-weight: 700; padding: 4px 14px; border-radius: 999px; background: var(--bg); }
.pill.win { background: #dcfae6; color: var(--win); }
.pill.loss { background: #fee4e2; color: var(--loss); }
.pill.upcoming { background: color-mix(in srgb, var(--secondary) 20%, #fff); color: var(--text); }

.teams {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 10px;
    margin: 10px 0 8px;
}
.team { display: flex; align-items: center; gap: 8px; min-width: 0; }
.team.away { justify-content: flex-end; text-align: right; }
.team img, .badge { width: 68px; height: 68px; object-fit: contain; flex: none; }
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #475467;
    color: #fff;
    font-weight: 800;
    font-size: 1.35rem;
    letter-spacing: .02em;
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .35);
    /* Slightly smaller than the logo box, like a logo with its margins. */
    transform: scale(.85);
}
.badge[hidden] { display: none; }
.badge.is-club { background: var(--primary); }
.name { font-size: .95rem; overflow-wrap: break-word; min-width: 0; }
.is-club .name { font-weight: 700; color: var(--primary); }

.score {
    display: flex;
    gap: 6px;
    font-size: 1.35rem;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    padding: 4px 10px;
    border-radius: 8px;
    background: var(--bg);
}
.score .sep { color: var(--muted); }
.score .winner { font-weight: 800; }
.score.upcoming {
    background: color-mix(in srgb, var(--secondary) 35%, #fff);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--secondary) 60%, #fff);
}
.score .time { font-size: 1.05rem; font-weight: 700; color: var(--text); }

.level { font-size: .82rem; color: var(--muted); }

/* Compact cards: stack teams vertically. */
.layout-cards .teams { grid-template-columns: 1fr auto; }
.layout-cards .team.away { grid-column: 1; grid-row: 2; justify-content: flex-end; flex-direction: row-reverse; text-align: left; }
.layout-cards .team.home { grid-column: 1; grid-row: 1; }
.layout-cards .score { grid-column: 2; grid-row: 1 / span 2; flex-direction: column; align-items: center; gap: 2px; }
.layout-cards .score .sep { display: none; }

.empty { padding: 40px 0; text-align: center; color: var(--muted); }
.site-footer { padding: 24px 16px 40px; color: var(--muted); font-size: .85rem; text-align: center; }

@media (max-width: 520px) {
    .name { font-size: .85rem; }
    .team img, .badge { width: 52px; height: 52px; }
    .badge { font-size: 1.05rem; }
    /* Logo above the name so long club names have the full column. */
    body:not(.layout-cards) .team { flex-direction: column; justify-content: flex-start; text-align: center; gap: 4px; }
    body:not(.layout-cards) .team.away { flex-direction: column-reverse; justify-content: flex-end; }
    .name { font-size: .82rem; }
    .score { font-size: 1.1rem; }
    .site-header .wrap { min-height: 92px; padding-right: 128px; }
    .club-logo { width: 116px; height: 116px; bottom: -50px; }
    .filters-panel { margin-top: 64px; }
    /* Filters folded behind a button on phones. */
    .filters-panel > summary {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px 14px;
        background: var(--card);
        border: 1px solid var(--border);
        border-radius: 12px;
        font-weight: 600;
        cursor: pointer;
        list-style: none;
    }
    .filters-panel > summary::-webkit-details-marker { display: none; }
    .filters-panel > summary::after { content: "▾"; color: var(--muted); }
    .filters-panel[open] > summary { border-radius: 12px 12px 0 0; border-bottom: 0; }
    .filters-panel[open] > summary::after { content: "▴"; }
    .filters-panel[open] .filters { border-radius: 0 0 12px 12px; }
    .filters-count { color: var(--primary); }
    .pill { font-size: .8rem; padding: 3px 10px; }
}
