/* Pirly design tokens. Want blue instead of orange? Change --accent and --accent-soft (both themes). */
:root {
    --bg: #F3F5F8;
    --surface: #FFFFFF;
    --surface-2: #EBEFF4;
    --ink: #111722;
    --muted: #5A6578;
    --line: #DAE0E8;
    --accent: #D9581A;
    --accent-soft: rgba(217, 88, 26, .12);
    --on-accent: #FFFFFF;
    --live: #E0353A;
    --good: #1E8F50;
    --warn: #B07800;
    --bad: #C93C3C;
    --shadow: 0 1px 2px rgba(17, 23, 34, .06), 0 8px 24px rgba(17, 23, 34, .06);
    --font-display: "Barlow Condensed", "Arial Narrow", sans-serif;
    --font-body: "Figtree", "Segoe UI", system-ui, sans-serif;
    --gutter: max(16px, env(safe-area-inset-left, 0px));
    color-scheme: light;
}

/* Dark colours. Used when someone picks "Dark", or picks "Auto" and their device is in dark mode.
   The theme button sets data-theme="dark" or "light" on <html>; "Auto" removes it. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0C1118;
        --surface: #141B25;
        --surface-2: #1B2431;
        --ink: #E8EDF4;
        --muted: #8B97AA;
        --line: #253142;
        --accent: #FF8A3D;
        --accent-soft: rgba(255, 138, 61, .14);
        --on-accent: #1A0E05;
        --live: #FF5257;
        --good: #3DD68C;
        --warn: #F2B84B;
        --bad: #FF6B6B;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #0C1118;
    --surface: #141B25;
    --surface-2: #1B2431;
    --ink: #E8EDF4;
    --muted: #8B97AA;
    --line: #253142;
    --accent: #FF8A3D;
    --accent-soft: rgba(255, 138, 61, .14);
    --on-accent: #1A0E05;
    --live: #FF5257;
    --good: #3DD68C;
    --warn: #F2B84B;
    --bad: #FF6B6B;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
    color-scheme: dark;
}

* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body {
    background: var(--surface);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.num { font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

/* ---------- App shell: top bar, scrolling screen, bottom tabs ---------- */
.shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 560px;
    margin: 0 auto;
    background: var(--bg);
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (min-width: 600px) {
    body { background: var(--surface-2); }
    .shell { border-inline: 1px solid var(--line); }
}

.appbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 12px var(--gutter) 10px;
}
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; }
.brand svg { width: 26px; height: 26px; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 23px; line-height: 1; }
.brand-name b { color: var(--accent); }

.theme-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}
.theme-button:hover { color: var(--ink); }
.theme-button svg { width: 16px; height: 16px; }

.screen {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 14px var(--gutter) 28px;
}
.screen > * { flex-shrink: 0; }   /* never squash content to fit: the screen scrolls instead */

.tabbar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding: 6px var(--gutter) 8px;
}
.tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 2px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 10px;
}
.tab svg { width: 23px; height: 23px; }
.tab.active { color: var(--accent); }

/* ---------- Building blocks ---------- */
.h1 { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 30px; line-height: 1; }
h1:focus { outline: none; }   /* Blazor focuses the page heading after navigation, for screen readers */
.eyebrow {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
}
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.credit { font-size: 11.5px; color: var(--muted); text-align: center; margin: 0; }

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    white-space: nowrap;
}
.pill.live { background: color-mix(in srgb, var(--live) 14%, transparent); color: var(--live); }
.pill.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--live); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border-radius: 11px; padding: 3px; gap: 3px; }
.seg button { padding: 7px 4px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }

.empty { text-align: center; padding: 32px 18px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.btn { display: inline-block; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 13px; padding: 8px 14px; border-radius: 999px; text-decoration: none; }
.skeleton { background: var(--surface-2); border-radius: 12px; animation: shimmer 1.2s ease-in-out infinite; }
@keyframes shimmer { 50% { opacity: .55; } }

/* ---------- Games ---------- */
.round-stepper { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 8px; }
.round-stepper a, .round-stepper span.disabled {
    display: grid;
    place-items: center;
    height: 40px;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    text-decoration: none;
    font-size: 18px;
}
.round-stepper span.disabled { opacity: .35; }
.round-stepper .label { text-align: center; }
.round-stepper .label b { display: block; font-family: var(--font-display); font-size: 22px; line-height: 1.1; }
.round-stepper .label small { color: var(--muted); font-size: 12px; }

.glist { display: flex; flex-direction: column; overflow: hidden; }
.grow { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); text-decoration: none; }
.grow:first-child { border-top: 0; }
a.grow[href]:hover { background: var(--surface-2); }
.gteams { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.gt { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 8px; }
.gt .code { font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: .04em; color: var(--muted); }
.gt .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.gt .sc { font-family: var(--font-display); font-weight: 600; font-size: 20px; font-variant-numeric: tabular-nums; color: var(--muted); }
.gt.win .code, .gt.win .nm, .gt.win .sc { color: var(--ink); font-weight: 700; }
.gmeta { align-self: center; text-align: right; font-size: 12px; color: var(--muted); border-left: 1px solid var(--line); padding-left: 12px; min-width: 70px; }
.gmeta b { display: block; color: var(--ink); font-weight: 600; font-size: 13px; }

/* ---------- Live ---------- */
.livecard { display: flex; flex-direction: column; gap: 12px; padding: 14px; text-decoration: none; box-shadow: var(--shadow); }
.livecard:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.lc-top { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; }
.leaders { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.leader { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; min-width: 0; }
.leader .who { min-width: 0; }
.leader .who div:first-child { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leader .who div:last-child { font-size: 11.5px; color: var(--muted); }
.pirv { font-family: var(--font-display); font-weight: 700; font-size: 24px; line-height: 1; font-variant-numeric: tabular-nums; display: flex; flex-direction: column; align-items: flex-end; }
.pirv small { font-family: var(--font-body); font-size: 9.5px; font-weight: 700; letter-spacing: .08em; color: var(--muted); }

/* ---------- Players ---------- */
.section { display: flex; flex-direction: column; gap: 10px; }
.search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; }
.search svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 16px; padding: 11px 0; outline: none; }
.search:focus-within { border-color: var(--accent); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 12px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.plist { display: flex; flex-direction: column; overflow: hidden; }
.prow, .lrow { display: grid; align-items: center; gap: 12px; padding: 11px 14px; border-top: 1px solid var(--line); text-decoration: none; }
.prow { grid-template-columns: 1fr auto; }
.lrow { grid-template-columns: 22px 1fr auto; }
.prow:first-child, .lrow:first-child { border-top: 0; }
.prow:hover, .lrow:hover { background: var(--surface-2); }
.pname { font-weight: 700; font-size: 15px; line-height: 1.2; }
.psub { font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.rank { font-family: var(--font-display); font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.lbar { height: 4px; border-radius: 2px; background: var(--surface-2); margin-top: 6px; overflow: hidden; }
.lbar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.lval { font-family: var(--font-display); font-weight: 700; font-size: 22px; font-variant-numeric: tabular-nums; }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }
.status i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status.good { color: var(--good); }
.status.warn { color: var(--warn); }
.status.bad { color: var(--bad); }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.tile .num { font-family: var(--font-display); font-size: 26px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.tile .lbl { font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--muted); margin-top: 4px; }
.tile.key { background: var(--accent-soft); border-color: transparent; }
.tile.key .num { color: var(--accent); }
.chart { width: 100%; height: auto; display: block; }
.chart text { font-family: var(--font-display); font-size: 11px; fill: var(--muted); }
.chart text.value { fill: var(--ink); font-weight: 600; font-size: 12px; }

.prow { padding-right: 6px; }
.prow-link { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; text-decoration: none; min-width: 0; }
.player-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }

/* ---------- Favourites ---------- */
.star { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); flex: none; }
.star:hover { background: var(--surface-2); }
.star svg { width: 22px; height: 22px; }
.star[aria-pressed="true"] { color: var(--accent); }
.star[aria-pressed="true"] svg path { fill: currentColor; }

.tab { position: relative; }
.tab .badge {
    position: absolute;
    top: 2px;
    left: calc(50% + 6px);
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 9px;
    background: var(--accent);
    color: var(--on-accent);
    font-size: 10.5px;
    font-weight: 700;
    display: grid;
    place-items: center;
}

.fav { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.fav.is-live { border-color: color-mix(in srgb, var(--live) 40%, var(--line)); box-shadow: var(--shadow); }
.fav-head { display: grid; grid-template-columns: 1fr auto auto; align-items: start; gap: 10px; }
.fav-name { text-decoration: none; min-width: 0; }
.fav-head .star { margin: -6px -8px 0 0; }
.big-pir { font-family: var(--font-display); font-weight: 700; font-size: 38px; line-height: .9; font-variant-numeric: tabular-nums; text-align: right; }
.big-pir small { display: block; font-family: var(--font-body); font-size: 9.5px; font-weight: 700; letter-spacing: .08em; color: var(--muted); margin-top: 3px; }
.fav-line { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; }
.fav-line b { font-family: var(--font-display); font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; margin-right: 3px; }
.fav-mid { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.fav-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding-top: 10px; font-size: 12.5px; color: var(--muted); text-decoration: none; }
.spark { width: 84px; height: 28px; flex: none; }
.empty-star { width: 34px; height: 34px; color: var(--accent); }

.account { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.account-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.account-line { margin: 0; font-size: 13px; color: var(--muted); text-align: center; }
.btn.ghost { background: var(--surface-2); color: var(--ink); }
button.link { color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.small { font-size: 12.5px; }

/* ---------- News ---------- */
.nlist { display: flex; flex-direction: column; overflow: hidden; }
.news { padding: 12px 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 7px; }
.news:first-child { border-top: 0; }
.news-title { color: var(--ink); font-weight: 600; font-size: 15px; line-height: 1.3; text-decoration: none; text-wrap: pretty; }
.news-title:hover { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }
.news-title::after { content: " ↗"; color: var(--muted); font-weight: 500; }
.news-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.pill.injury { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); text-decoration: none; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--ink); text-decoration: none; }
.tag.team { font-family: var(--font-display); font-size: 13px; letter-spacing: .04em; color: var(--muted); padding: 3px 9px; }
.tag.favourite { background: var(--accent-soft); color: var(--accent); }

/* ---------- Box score ---------- */
.back { color: var(--accent); font-weight: 600; text-decoration: none; font-size: 14px; }
.scoreline { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.scoreline .team { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.scoreline .team.right { text-align: right; align-items: flex-end; }
.scoreline .code { font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: .04em; color: var(--muted); }
.scoreline .name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.scoreline .nums { display: flex; align-items: baseline; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 46px; line-height: .95; font-variant-numeric: tabular-nums; }
.scoreline .nums .dash { color: var(--muted); font-size: 28px; font-weight: 500; }
.scoreline .nums .lead { color: var(--accent); }

.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table.box { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
table.box th, table.box td { padding: 8px 7px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
table.box tr:last-child td { border-bottom: 0; }
table.box th { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; color: var(--muted); background: var(--surface); }
table.box th:first-child, table.box td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    text-align: left;
    background: var(--surface);
    border-right: 1px solid var(--line);
}
table.box td:first-child { font-weight: 600; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
table.box td.pir { font-family: var(--font-display); font-weight: 700; font-size: 15px; color: var(--accent); }
table.box td a { text-decoration: none; }
table.box td a:hover { text-decoration: underline; text-decoration-color: var(--accent); }
table.box tr.dnp td { color: var(--muted); }
table.box .starter { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: middle; }
table.box .bench { display: inline-block; width: 5px; margin-right: 6px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; color: var(--muted); margin: 0; }
.check b { color: var(--good); }
.check.off b { color: var(--bad); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Blazor template: loading screen and error banner ---------- */
#blazor-error-ui {
    background: var(--bad);
    color: #fff;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui a { color: #fff; font-weight: 700; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

.loading-progress { position: absolute; display: block; width: 6rem; height: 6rem; inset: 30vh 0 auto 0; margin: 0 auto; }
.loading-progress circle { fill: none; stroke: var(--line); stroke-width: 0.6rem; transform-origin: 50% 50%; transform: rotate(-90deg); }
.loading-progress circle:last-child {
    stroke: var(--accent);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}
.loading-progress-text { position: absolute; text-align: center; font-weight: 700; color: var(--muted); inset: calc(30vh + 2.4rem) 0 auto 0.2rem; }
.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Loading"); }
