/* ==========================================================================
   UAEERF Live Results – mobile-first stylesheet (no framework)
   ========================================================================== */
/* Theme: graphite gray (dark → light) with gold lines */
:root {
    --bg: #eceded;
    --bg-grad: linear-gradient(180deg, #c9cbce 0, #e2e3e5 220px, #f2f2f3 520px);
    --surface: #ffffff;
    --surface-2: #f4f4f5;
    --border: #dcdde0;
    --line: #c9a54a; /* gold line */
    --line-soft: rgba(201, 165, 74, .45); /* gold border */
    --text: #1f2124;
    --muted: #63666c;
    --primary: #2f3237; /* graphite */
    --primary-ink: #f1d78a; /* gold text on graphite */
    --primary-soft: #f3ecd9;
    --brand-dark: #26282c;
    --bar-grad: linear-gradient(90deg, #1c1d20 0%, #34373b 55%, #55585e 100%);
    --gold: #9a7622;
    --gold-bright: #d4af4f;
    --gold-soft: #f7f0dc;
    --live: #e11d48;
    --live-soft: #ffe4ea;
    --fault: #c2410c;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(20, 20, 22, .06), 0 4px 14px rgba(20, 20, 22, .06);
    --tabbar-h: 64px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #17181a;
        --bg-grad: linear-gradient(180deg, #0f1012 0, #1a1b1e 260px, #222427 600px);
        --surface: #232528;
        --surface-2: #2a2c30;
        --border: #36383c;
        --line: #d4af4f;
        --line-soft: rgba(212, 175, 79, .35);
        --text: #ececee;
        --muted: #a3a6ab;
        --primary: #d4af4f;
        --primary-ink: #1c1d20;
        --primary-soft: #3a3221;
        --brand-dark: #111214;
        --bar-grad: linear-gradient(90deg, #0b0c0d 0%, #222427 55%, #3a3c40 100%);
        --gold: #dcbc62;
        --gold-bright: #e2c068;
        --gold-soft: #2e2919;
        --live: #ff4d6d;
        --live-soft: #3a1520;
        --fault: #fb923c;
        --shadow: 0 1px 2px rgba(0,0,0,.45);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #17181a;
    --bg-grad: linear-gradient(180deg, #0f1012 0, #1a1b1e 260px, #222427 600px);
    --surface: #232528;
    --surface-2: #2a2c30;
    --border: #36383c;
    --line: #d4af4f;
    --line-soft: rgba(212, 175, 79, .35);
    --text: #ececee;
    --muted: #a3a6ab;
    --primary: #d4af4f;
    --primary-ink: #1c1d20;
    --primary-soft: #3a3221;
    --brand-dark: #111214;
    --bar-grad: linear-gradient(90deg, #0b0c0d 0%, #222427 55%, #3a3c40 100%);
    --gold: #dcbc62;
    --gold-bright: #e2c068;
    --gold-soft: #2e2919;
    --live: #ff4d6d;
    --live-soft: #3a1520;
    --fault: #fb923c;
    --shadow: 0 1px 2px rgba(0,0,0,.45);
    color-scheme: dark;
}

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: 120px;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
}

h1, h2, h3 {
    line-height: 1.2;
    margin: 0;
    letter-spacing: -.01em;
}

p {
    margin: 0;
}

small {
    font-size: .78rem;
}

[hidden] {
    display: none !important;
}

.muted {
    color: var(--muted);
}

.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px;
}

.skip-link {
    position: absolute;
    left: -999px;
    top: 8px;
    background: var(--surface);
    padding: 8px 12px;
    border-radius: 8px;
    z-index: 100;
}

    .skip-link:focus {
        left: 8px;
    }

:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent);
    outline-offset: 2px;
    border-radius: 6px;
}

/* ---------- App bar ---------- */
.appbar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--brand-dark);
    color: #fff;
    padding-top: env(safe-area-inset-top);
    box-shadow: 0 2px 10px rgba(0,0,0,.12);
}

.appbar__inner {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 58px;
}

.appbar__back {
    color: #fff;
    font-size: 1.35rem;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    margin-left: -8px;
}

    .appbar__back:active {
        background: rgba(255,255,255,.12);
    }

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    min-width: 0;
}

.brand__logo {
    height: 36px;
    width: auto;
}

.brand__text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    min-width: 0;
}

    .brand__text strong {
        font-size: 1.05rem;
        letter-spacing: .06em;
    }

    .brand__text small {
        opacity: .75;
        font-size: .72rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

.topnav {
    display: none;
    margin-left: auto;
    gap: 4px;
}

    .topnav a {
        color: rgba(255,255,255,.85);
        padding: 8px 14px;
        border-radius: 999px;
        font-weight: 500;
        font-size: .92rem;
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }

        .topnav a:hover, .topnav a.is-active {
            background: rgba(255,255,255,.12);
            color: #fff;
        }

.theme-toggle {
    margin-left: auto;
    background: transparent;
    border: 0;
    color: #fff;
    font-size: 1.1rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
}

    .theme-toggle:hover {
        background: rgba(255,255,255,.12);
    }

/* ---------- Breadcrumbs ---------- */
.crumbs {
    padding-top: 12px;
}

    .crumbs ol {
        list-style: none;
        margin: 0;
        padding: 0;
        display: flex;
        gap: 6px;
        font-size: .82rem;
        color: var(--muted);
        overflow-x: auto;
        white-space: nowrap;
        scrollbar-width: none;
    }

        .crumbs ol::-webkit-scrollbar {
            display: none;
        }

    .crumbs li + li::before {
        content: "›";
        margin-right: 6px;
        opacity: .6;
    }

    .crumbs a {
        color: var(--muted);
    }

        .crumbs a:hover {
            color: var(--primary);
        }

    .crumbs [aria-current] {
        color: var(--text);
        font-weight: 600;
    }

.main {
    padding-top: 16px;
    padding-bottom: 32px;
    min-height: 60vh;
}

/* ---------- Headings ---------- */
.hero {
    padding: 6px 0 16px;
}

    .hero h1 {
        font-size: 1.75rem;
        font-weight: 800;
    }

    .hero p {
        color: var(--muted);
        margin-top: 4px;
    }

.page-head {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 16px;
}

    .page-head h1 {
        font-size: 1.4rem;
        font-weight: 800;
    }

    .page-head .muted {
        margin-top: 6px;
        font-size: .9rem;
    }

.eyebrow {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    color: var(--gold);
    font-weight: 700;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: 6px;
}

.block {
    margin-top: 20px;
}

.block__title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.day-head {
    position: sticky;
    top: calc(58px + env(safe-area-inset-top) + 50px);
    z-index: 5;
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    background: var(--bg);
    padding: 8px 0;
    margin-bottom: 4px;
}

.count {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: .72rem;
    font-weight: 700;
}

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.list {
    display: grid;
    gap: 10px;
}

.show-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    color: var(--text);
    transition: transform .12s, border-color .12s;
}

    .show-card:hover {
        border-color: var(--primary);
    }

    .show-card:active {
        transform: scale(.99);
    }

.show-card__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.show-card__name {
    font-weight: 700;
    font-size: 1rem;
}

.show-card__meta {
    color: var(--muted);
    font-size: .86rem;
}

.chev {
    color: var(--muted);
    font-size: 1.1rem;
}

.datebadge {
    flex: none;
    width: 54px;
    height: 58px;
    border-radius: 12px;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

    .datebadge small {
        font-size: .68rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .06em;
    }

    .datebadge strong {
        font-size: 1.45rem;
        font-weight: 800;
        margin-top: 3px;
    }

.class-card {
    margin-bottom: 10px;
    overflow: hidden;
}

    .class-card.is-live {
        border-color: var(--live);
        box-shadow: 0 0 0 3px var(--live-soft);
    }

.class-card__main {
    display: flex;
    gap: 14px;
    padding: 14px;
    color: var(--text);
}

.class-card__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.class-card__name {
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.class-card__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 0 14px 14px;
}

.codebadge {
    flex: none;
    min-width: 54px;
    height: 58px;
    padding: 0 6px;
    border-radius: 12px;
    background: var(--gold-soft);
    color: var(--gold);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

    .codebadge small {
        font-size: .62rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .06em;
    }

    .codebadge strong {
        font-size: 1.25rem;
        font-weight: 800;
        margin-top: 4px;
        color: var(--text);
    }

.facts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

    .facts > span {
        display: inline-flex;
        align-items: center;
        gap: 5px;
        font-size: .78rem;
        color: var(--muted);
        background: var(--surface-2);
        border: 1px solid var(--border);
        padding: 3px 9px;
        border-radius: 999px;
    }

    .facts i {
        color: var(--primary);
    }

    .facts .facts__prize {
        color: var(--gold);
        border-color: color-mix(in srgb, var(--gold) 35%, var(--border));
        background: var(--gold-soft);
    }

        .facts .facts__prize i {
            color: var(--gold);
        }

.facts--lg {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
}

    .facts--lg > span {
        display: grid;
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto;
        column-gap: 8px;
        align-items: center;
        border-radius: var(--radius-sm);
        padding: 8px 12px;
        font-size: .95rem;
        font-weight: 700;
        color: var(--text);
        background: var(--surface);
    }

        .facts--lg > span i {
            grid-row: span 2;
            font-size: 1.15rem;
        }

        .facts--lg > span small {
            color: var(--muted);
            font-weight: 500;
            font-size: .7rem;
            text-transform: uppercase;
            letter-spacing: .05em;
        }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 16px;
    border-radius: 12px;
    font: inherit;
    font-weight: 600;
    font-size: .92rem;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}

    .btn:hover {
        border-color: var(--primary);
    }

.btn--sm {
    min-height: 40px;
    font-size: .85rem;
    padding: 0 12px;
}

.btn--primary {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-ink);
}

.btn--live {
    background: var(--live);
    border-color: var(--live);
    color: #fff;
}

/* ---------- Tabs / segmented ---------- */
.tabs, .segmented {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 4px;
    padding: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    margin-bottom: 14px;
    box-shadow: var(--shadow);
}

    .tabs a, .segmented a {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        min-height: 42px;
        border-radius: 10px;
        color: var(--muted);
        font-weight: 600;
        font-size: .9rem;
        text-align: center;
        padding: 0 6px;
    }

        .tabs a[aria-selected="true"], .segmented a[aria-selected="true"] {
            background: var(--primary);
            color: var(--primary-ink);
        }

            .tabs a[aria-selected="true"] .count {
                background: rgba(255,255,255,.22);
                color: inherit;
            }

        .segmented a i {
            font-size: 1rem;
        }

/* ---------- Chips ---------- */
.block + .chips {
    margin-top: 12px;
}

.chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0 10px;
    margin: 0 -16px;
    padding-left: 16px;
    padding-right: 16px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

    .chips::-webkit-scrollbar {
        display: none;
    }

.chips--sticky {
    position: sticky;
    top: calc(58px + env(safe-area-inset-top));
    z-index: 6;
    background: var(--bg);
    padding-top: 8px;
}

.chip {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    font-size: .85rem;
    white-space: nowrap;
}

    .chip.is-active {
        background: var(--primary);
        border-color: var(--primary);
        color: var(--primary-ink);
    }

/* ---------- Search ---------- */
.search {
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

    .search > i {
        position: absolute;
        left: 14px;
        color: var(--muted);
        pointer-events: none;
    }

    .search input {
        width: 100%;
        min-height: 46px;
        padding: 0 44px 0 40px;
        border-radius: 12px;
        border: 1px solid var(--border);
        background: var(--surface);
        color: var(--text);
        font: inherit;
        font-size: 16px; /* prevents iOS zoom */
    }

        .search input:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px var(--primary-soft);
        }

        .search input::-webkit-search-cancel-button {
            display: none;
        }

.search__clear {
    position: absolute;
    right: 6px;
    width: 36px;
    height: 36px;
    border: 0;
    background: none;
    color: var(--muted);
    cursor: pointer;
    display: none;
}

.search.has-value .search__clear {
    display: block;
}

.empty {
    color: var(--muted);
    text-align: center;
    padding: 20px 0;
}

/* ---------- Pills / dots ---------- */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .08em;
    padding: 3px 9px;
    border-radius: 999px;
}

.pill--live {
    background: var(--live-soft);
    color: var(--live);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex: none;
}

.dot--live {
    background: var(--live);
    box-shadow: 0 0 0 0 var(--live);
    animation: pulse 1.6s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 60%, transparent);
    }

    70% {
        box-shadow: 0 0 0 8px transparent;
    }

    100% {
        box-shadow: 0 0 0 0 transparent;
    }
}

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

    html {
        scroll-behavior: auto;
    }
}

.live-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    margin-bottom: 14px;
    border-radius: var(--radius);
    background: var(--live-soft);
    color: var(--text);
    border: 1px solid color-mix(in srgb, var(--live) 35%, transparent);
}

    .live-banner span:nth-child(2) {
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    .live-banner small {
        color: var(--muted);
    }

    .live-banner .dot {
        width: 12px;
        height: 12px;
    }

/* ---------- Documents ---------- */
.docs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
}

.doc {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    font-size: .88rem;
    min-height: 48px;
}

    .doc i {
        color: #dc2626;
        font-size: 1.25rem;
    }

    .doc span {
        display: flex;
        flex-direction: column;
        line-height: 1.2;
    }

    .doc small {
        color: var(--muted);
        font-weight: 500;
        font-size: .7rem;
    }

.doc--off {
    opacity: .55;
}

    .doc--off i {
        color: var(--muted);
    }

.docs-drawer {
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

    .docs-drawer summary {
        list-style: none;
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 12px 14px;
        cursor: pointer;
        font-weight: 600;
        font-size: .92rem;
        min-height: 48px;
    }

        .docs-drawer summary::-webkit-details-marker {
            display: none;
        }

        .docs-drawer summary small {
            color: var(--muted);
            font-weight: 400;
            flex: 1;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .docs-drawer summary .bi-chevron-down {
            transition: transform .2s;
        }

    .docs-drawer[open] summary .bi-chevron-down {
        transform: rotate(180deg);
    }

    .docs-drawer .docs {
        padding: 0 14px 14px;
    }

/* ---------- Results toolbar & stats ---------- */
.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: 14px 0 6px;
}

.updated {
    font-size: .8rem;
    margin-right: auto;
}

.switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

    .switch input {
        position: absolute;
        opacity: 0;
    }

.switch__track {
    width: 40px;
    height: 24px;
    border-radius: 999px;
    background: var(--border);
    position: relative;
    transition: background .2s;
}

    .switch__track::after {
        content: "";
        position: absolute;
        top: 3px;
        left: 3px;
        width: 18px;
        height: 18px;
        border-radius: 50%;
        background: #fff;
        transition: transform .2s;
        box-shadow: 0 1px 2px rgba(0,0,0,.2);
    }

.switch input:checked + .switch__track {
    background: var(--primary);
}

    .switch input:checked + .switch__track::after {
        transform: translateX(16px);
    }

.switch input:focus-visible + .switch__track {
    outline: 3px solid var(--primary-soft);
}

.switch small {
    color: var(--muted);
    font-weight: 500;
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 10px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    text-align: center;
}

    .stat small {
        display: block;
        color: var(--muted);
        font-size: .68rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: .05em;
    }

    .stat strong {
        font-size: 1.5rem;
        font-weight: 800;
    }

.progress {
    grid-column: 1 / -1;
    height: 6px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}

    .progress span {
        display: block;
        height: 100%;
        background: linear-gradient(90deg, var(--primary), var(--gold));
        border-radius: inherit;
    }

.arena {
    display: grid;
    gap: 8px;
}

.arena__item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--gold-soft);
    border: 1px solid color-mix(in srgb, var(--gold) 30%, transparent);
    font-size: .9rem;
}

    .arena__item small {
        color: var(--gold);
        font-weight: 800;
        letter-spacing: .06em;
        font-size: .68rem;
    }

/* ---------- Results list ---------- */
.results, .startlist {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 10px;
}

.result {
    display: grid;
    grid-template-columns: 62px 1fr;
    gap: 0;
    overflow: hidden;
}

.place {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    border-right: 1px solid var(--border);
    padding: 10px 4px;
    line-height: 1;
}

    .place small {
        font-size: .6rem;
        text-transform: uppercase;
        letter-spacing: .08em;
        color: var(--muted);
        font-weight: 700;
    }

    .place strong {
        font-size: 1.6rem;
        font-weight: 800;
        margin-top: 4px;
    }

.place--gold {
    background: linear-gradient(160deg, #fde68a, #f5c542);
    color: #4a3500;
}

.place--silver {
    background: linear-gradient(160deg, #eef0f3, #c9ced6);
    color: #2c3440;
}

.place--bronze {
    background: linear-gradient(160deg, #f6d1b0, #d99a63);
    color: #4a2408;
}

    .place--gold small, .place--silver small, .place--bronze small {
        color: inherit;
        opacity: .75;
    }

.result__body {
    padding: 12px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pair {
    display: grid;
    gap: 8px;
}

.pair__item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    min-width: 0;
}

    .pair__item > i {
        color: var(--primary);
        margin-top: 2px;
    }

    .pair__item span {
        display: flex;
        flex-direction: column;
        min-width: 0;
    }

    .pair__item strong {
        font-weight: 700;
        overflow-wrap: anywhere;
    }

    .pair__item small {
        color: var(--gold);
        font-weight: 600;
        font-size: .8rem;
    }

.horse-ico {
    opacity: .7;
    margin-top: 2px;
    flex: none;
}

:root[data-theme="dark"] .horse-ico {
    filter: invert(1);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .horse-ico {
        filter: invert(1);
    }
}

.rounds {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 6px;
}

.round {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 8px;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    font-size: .92rem;
}

    .round small {
        grid-column: 1 / -1;
        font-size: .65rem;
        text-transform: uppercase;
        letter-spacing: .08em;
        color: var(--muted);
    }

    .round em {
        display: block;
        font-style: normal;
        font-size: .65rem;
        font-weight: 500;
        color: var(--muted);
    }

    .round .has-faults {
        color: var(--fault);
    }

.prize {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--gold-soft);
    border-top: 1px solid var(--border);
    color: var(--gold);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

    .prize small {
        color: var(--muted);
        font-weight: 600;
        margin-right: 4px;
        text-transform: uppercase;
        font-size: .65rem;
        letter-spacing: .06em;
    }

.start {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px;
}

.startno {
    flex: none;
    width: 54px;
    height: 54px;
    border-radius: 12px;
    background: var(--gold-soft);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

    .startno small {
        font-size: .6rem;
        color: var(--gold);
        font-weight: 700;
        text-transform: uppercase;
    }

    .startno strong {
        font-size: 1.3rem;
        font-weight: 800;
        margin-top: 3px;
    }

.start .pair {
    flex: 1;
    min-width: 0;
}

/* ---------- States ---------- */
.state {
    text-align: center;
    padding: 48px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

    .state > i {
        font-size: 2.6rem;
        color: var(--primary);
    }

    .state h1 {
        font-size: 1.35rem;
    }

    .state p {
        color: var(--muted);
        max-width: 420px;
    }

.state__actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 8px;
}

.state--small {
    padding: 28px 16px;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

    .state--small > i {
        font-size: 1.8rem;
        color: var(--muted);
    }

    .state--small p {
        color: var(--text);
        font-weight: 600;
    }

/* ---------- Footer ---------- */
.footer {
    background: var(--brand-dark);
    color: rgba(255,255,255,.8);
    font-size: .88rem;
    padding: 28px 0 18px;
}

    .footer strong {
        color: #fff;
    }

    .footer p {
        margin-top: 6px;
    }

.footer__inner {
    display: grid;
    gap: 18px;
}

.footer__links {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.footer a {
    color: rgba(255,255,255,.9);
}

.social {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

    .social a {
        width: 40px;
        height: 40px;
        display: grid;
        place-items: center;
        border-radius: 50%;
        background: rgba(255,255,255,.1);
        font-size: 1.05rem;
    }

.footer__copy {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid rgba(255,255,255,.12);
    font-size: .78rem;
    opacity: .7;
}

/* ---------- Bottom tab bar (mobile) ---------- */
.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: flex;
    justify-content: space-around;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-top: 1px solid var(--border);
}

    .tabbar a, .tabbar button {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        color: var(--muted);
        font: inherit;
        font-size: .7rem;
        font-weight: 600;
        background: none;
        border: 0;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .tabbar i {
        font-size: 1.3rem;
    }

    .tabbar .is-active {
        color: var(--primary);
    }

        .tabbar .is-active i {
            transform: translateY(-1px);
        }

/* ---------- Larger screens ---------- */
@media (min-width: 640px) {
    .pair {
        grid-template-columns: 1fr 1fr;
    }

    .result {
        grid-template-columns: 76px 1fr;
    }

    .footer__inner {
        grid-template-columns: 2fr 1fr;
    }

    .arena {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}

@media (min-width: 900px) {
    body {
        padding-bottom: 0;
    }

    .tabbar {
        display: none;
    }

    .topnav {
        display: flex;
    }

    .theme-toggle {
        margin-left: 4px;
    }

    .hero h1 {
        font-size: 2.2rem;
    }

    .page-head {
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-start;
    }

        .page-head h1 {
            font-size: 1.8rem;
        }

        .page-head .docs {
            min-width: 340px;
        }

    .page-head--class {
        flex-direction: column;
        align-items: stretch;
    }

    .list {
        grid-template-columns: 1fr 1fr;
    }

    .tabs, .segmented {
        max-width: 560px;
    }

    .class-card {
        display: flex;
        align-items: center;
    }

    .class-card__main {
        flex: 1;
    }

    .class-card__actions {
        padding: 14px;
        grid-template-columns: 140px 140px;
    }

    .result {
        grid-template-columns: 84px 1fr 200px;
    }

    .prize {
        grid-column: auto;
        flex-direction: column;
        justify-content: center;
        border-top: 0;
        border-left: 1px solid var(--border);
        text-align: center;
    }

        .prize i {
            font-size: 1.4rem;
        }

    .day-head {
        top: calc(58px + 54px);
    }
}
/* ---------- Graphite & gold accents ---------- */
body {
    background: var(--bg-grad), var(--bg);
    background-repeat: no-repeat;
}

a:hover {
    color: var(--gold);
}

.appbar {
    background: var(--bar-grad);
    border-bottom: 2px solid var(--gold-bright);
}

.topnav a.is-active {
    box-shadow: inset 0 -2px 0 var(--gold-bright);
}

.brand__text strong {
    color: #f1d78a;
}

.footer {
    background: var(--bar-grad);
    border-top: 2px solid var(--gold-bright);
}

.social a {
    background: rgba(212, 175, 79, .14);
    border: 1px solid rgba(212, 175, 79, .4);
    color: #f1d78a;
}

.footer__copy {
    border-top-color: rgba(212, 175, 79, .3);
}

.card, .tabs, .segmented, .docs-drawer, .doc, .stat, .search input, .chip, .facts--lg > span, .btn {
    border-color: var(--line-soft);
}

    .card:hover, .show-card:hover, .btn:hover, .chip:hover {
        border-color: var(--line);
    }

.hero h1::after {
    content: "";
    display: block;
    width: 64px;
    height: 3px;
    margin-top: 10px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--gold-bright), transparent);
}

.block__title::after {
    content: "";
    flex: 1;
    height: 1px;
    margin-left: 6px;
    background: linear-gradient(90deg, var(--line), transparent);
}

.day-head {
    color: var(--gold);
    border-bottom: 1px solid var(--line-soft);
}

.tabs a[aria-selected="true"], .segmented a[aria-selected="true"], .chip.is-active, .btn--primary {
    background: linear-gradient(180deg, #3d4045, #26282c);
    color: #f1d78a;
    border-color: var(--gold-bright);
    box-shadow: inset 0 -2px 0 var(--gold-bright);
}

    .tabs a[aria-selected="true"] .count {
        background: rgba(212, 175, 79, .25);
        color: #f1d78a;
    }

.count {
    background: var(--gold-soft);
    color: var(--gold);
}

.datebadge {
    background: linear-gradient(160deg, #3d4045, #1f2124);
    color: #f1d78a;
    border: 1px solid var(--gold-bright);
}

.codebadge {
    border: 1px solid var(--line-soft);
}

.facts i, .pair__item > i, .state > i {
    color: var(--gold);
}

.search > i {
    color: var(--gold);
}

.search input:focus {
    border-color: var(--line);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.switch input:checked + .switch__track {
    background: var(--gold-bright);
}

.progress span {
    background: linear-gradient(90deg, #8c6a1d, var(--gold-bright), #f1d78a);
}

.place {
    border-right-color: var(--line-soft);
}

.result {
    border-left: 3px solid var(--line);
}

.prize {
    border-color: var(--line-soft);
}

.tabbar {
    border-top: 1px solid var(--gold-bright);
}

    .tabbar .is-active {
        color: var(--gold);
    }

        .tabbar .is-active i {
            filter: drop-shadow(0 0 6px rgba(212, 175, 79, .35));
        }

.chips--sticky, .day-head {
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

:focus-visible {
    outline-color: var(--gold-bright);
}

/* ---------- Compact results list ---------- */
.rlist {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.rrow {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    column-gap: 12px;
    row-gap: 4px;
    grid-template-areas: "pos who score" ". meta meta";
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

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

    .rrow:nth-child(even) {
        background: var(--surface-2);
    }

.rpos {
    grid-area: pos;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: .95rem;
    font-variant-numeric: tabular-nums;
    background: var(--surface-2);
    border: 1px solid var(--line-soft);
    color: var(--text);
}

    .rpos.place--gold {
        background: linear-gradient(160deg, #fde68a, #f5c542);
        color: #4a3500;
        border-color: #d4af4f;
    }

    .rpos.place--silver {
        background: linear-gradient(160deg, #eef0f3, #c9ced6);
        color: #2c3440;
        border-color: #b8bec7;
    }

    .rpos.place--bronze {
        background: linear-gradient(160deg, #f6d1b0, #d99a63);
        color: #4a2408;
        border-color: #c98a55;
    }

.rwho {
    grid-area: who;
    min-width: 0;
    line-height: 1.25;
}

.rrider {
    display: block;
    font-weight: 700;
    font-size: .95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rsub {
    display: block;
    font-size: .8rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rhorse {
    color: var(--text);
    font-weight: 500;
}

.rscore {
    grid-area: score;
    text-align: right;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

    .rscore strong {
        display: block;
        font-size: 1rem;
        font-weight: 800;
    }

        .rscore strong.is-clear {
            color: var(--gold);
        }

    .rscore span {
        font-size: .8rem;
        color: var(--muted);
    }

    .rscore small {
        font-size: .65rem;
        font-weight: 600;
        color: var(--muted);
    }

.rmeta {
    grid-area: meta;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    font-size: .74rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

    .rmeta:empty {
        display: none;
    }

.rr b {
    color: var(--gold);
    font-weight: 700;
    margin-right: 2px;
}

.rr .has-faults, .rscore .has-faults {
    color: var(--fault);
}

.rno {
    opacity: .8;
}

.rprize {
    margin-left: auto;
    color: var(--gold);
    font-weight: 700;
    white-space: nowrap;
}

@media (min-width: 900px) {
    .rrow {
        grid-template-columns: 40px minmax(220px, 1.2fr) minmax(0, 1.4fr) 110px;
        grid-template-areas: "pos who meta score";
        padding: 10px 16px;
    }

    .rpos {
        width: 36px;
        height: 36px;
    }

    .rmeta {
        font-size: .8rem;
    }
}

@media print {
    .appbar, .tabbar, .footer, .toolbar, .search, .segmented, .docs-drawer, .chips {
        display: none !important;
    }

    body {
        background: #fff;
        padding: 0;
    }

    .card {
        box-shadow: none;
        break-inside: avoid;
    }
}
