@import url('https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@500;600;700&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* ---------------------------------------------------------------- tokens -- */

:root {
    --bg: #0A0F1E;
    --surface: #111830;
    --surface-2: #18203D;
    --border: rgba(148, 163, 210, 0.14);
    --border-strong: rgba(148, 163, 210, 0.22);
    --hairline: rgba(148, 163, 210, 0.08);
    --hover: rgba(148, 163, 210, 0.07);

    --text: #E8ECF8;
    --muted: #A3ADCB;
    --dim: #6B7699;
    --faint: #3C4566;

    --accent: #4FD1A5;
    --accent-bright: #7FE6C2;
    --accent-ink: #062A1E;
    --accent-wash: rgba(79, 209, 165, 0.12);
    --gold: #E9B44C;
    --gold-wash: rgba(233, 180, 76, 0.14);
    --loss: #F08A83;
    --loss-wash: rgba(217, 72, 63, 0.16);

    --font-display: 'Chakra Petch', 'Trebuchet MS', sans-serif;
    --font-body: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', monospace;

    --page: 1440px;
    --gutter: 40px;
}

/* ------------------------------------------------------------------ base -- */

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    background-color: var(--bg);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='97' viewBox='0 0 56 97'%3E%3Cg fill='none' stroke='%23A3ADCB' stroke-opacity='0.07'%3E%3Cpath d='M28 1 55 16.5v31L28 63 1 47.5v-31z'/%3E%3Cpath d='M28 63 55 78.5v31L28 125 1 109.5v-31z'/%3E%3C/g%3E%3C/svg%3E");
    color: var(--text);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-bright); }

h1, h2, h3 { font-family: var(--font-display); margin: 0; line-height: 1.1; }
h1 { font-size: 40px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 600; letter-spacing: 0.04em; }

.num {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

.display { font-family: var(--font-display); }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.gold { color: var(--gold); }
.loss { color: var(--loss); }
.right { text-align: right; }
.grow { flex-grow: 1; }

.eyebrow {
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--dim);
    font-weight: 600;
}

.eyebrow-lg {
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--dim);
    font-weight: 600;
}

.footnote {
    padding: 12px 20px;
    font-size: 12px;
    color: var(--dim);
    border-top: 1px solid var(--hairline);
}

.empty {
    padding: 48px 20px;
    text-align: center;
    color: var(--dim);
}

/* --------------------------------------------------------------- chrome --- */

.topbar {
    display: flex;
    align-items: center;
    gap: 28px;
    height: 64px;
    padding: 0 var(--gutter);
    border-bottom: 1px solid var(--border);
    background: rgba(10, 15, 30, 0.92);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
}

.brand-name {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.nav { display: flex; gap: 4px; font-size: 14px; font-weight: 500; }

.nav a {
    padding: 8px 14px;
    border-radius: 8px;
    color: var(--muted);
}

.nav a:hover { background: var(--hover); color: var(--text); }
.nav a.active { background: var(--accent-wash); color: var(--accent); }

.page {
    max-width: var(--page);
    margin: 0 auto;
    padding: 0 var(--gutter) 56px;
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
    padding: 36px 0 0;
}

/* -------------------------------------------------------------- surfaces -- */

.card {
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    overflow: hidden;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
}

.card-head + .table-head,
.card-head + .rows { border-top: 1px solid var(--border); }

.card-body { padding: 16px 20px 20px; }

.stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 16px;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
}

.stat-value {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 26px;
    font-weight: 600;
}

.stat-value small { font-size: 13px; color: var(--dim); font-weight: 400; }

.stat-grid { display: grid; gap: 12px; }
.stat-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.split { display: grid; gap: 24px; padding-top: 28px; align-items: start; }
.split.wide-left { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
.split.wide-left-narrow { grid-template-columns: minmax(0, 1fr) 420px; }
.split.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.stack { display: flex; flex-direction: column; gap: 24px; }

/* ---------------------------------------------------------------- tables -- */

.table-head,
.row {
    display: grid;
    gap: 12px;
    align-items: center;
    padding: 10px 20px;
}

.table-head {
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--dim);
    font-weight: 600;
}

.row {
    padding: 11px 20px;
    border-top: 1px solid var(--hairline);
    color: inherit;
}

a.row:hover, .row.clickable:hover { background: var(--hover); color: inherit; }
.row.selected { background: var(--accent-wash); }
.row.winner { background: rgba(233, 180, 76, 0.06); }

.bar-track {
    flex-grow: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--bg);
    overflow: hidden;
}

.bar-fill { height: 100%; border-radius: 3px; background: var(--accent); }

/* ---------------------------------------------------------------- pieces -- */

.avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}

.avatar.sm { width: 28px; height: 28px; font-size: 12px; }

.tag {
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
    white-space: nowrap;
}

.tag.good { background: var(--accent-wash); color: var(--accent); }
.tag.bad { background: var(--loss-wash); color: var(--loss); }
.tag.gold { background: var(--gold-wash); color: var(--gold); }

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: transparent;
    color: var(--muted);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.pill:hover { border-color: var(--muted); color: var(--text); }
.pill.on { border-color: var(--accent); background: var(--accent-wash); color: var(--accent); }
.pill.ghost { border-style: dashed; cursor: default; }
.pill.ghost:hover { border-color: var(--border-strong); color: var(--muted); }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

.segmented {
    display: flex;
    gap: 2px;
    padding: 3px;
    border-radius: 9px;
    background: var(--bg);
    font-size: 12px;
    font-weight: 500;
}

.segmented button {
    padding: 6px 12px;
    border-radius: 7px;
    border: none;
    background: transparent;
    color: var(--dim);
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    cursor: pointer;
}

.segmented button:hover { color: var(--text); }
.segmented button.on { background: var(--surface-2); color: var(--text); }

.tabs {
    display: flex;
    gap: 2px;
    padding: 12px 20px 0;
    border-bottom: 1px solid var(--border);
}

.tabs button {
    padding: 10px 16px 12px;
    margin-bottom: -1px;
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--dim);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.tabs button:hover { color: var(--muted); }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 18px;
    border-radius: 10px;
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-bright); }
.btn.ghost { background: transparent; border-color: var(--border-strong); color: var(--muted); font-weight: 500; }
.btn.ghost:hover { border-color: var(--muted); color: var(--text); }
.btn.lg { height: 44px; padding: 0 20px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ----------------------------------------------------------------- forms -- */

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
}

input, select {
    height: 44px;
    width: 100%;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--border-strong);
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    outline: none;
}

input:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 209, 165, 0.18);
}

input.num {
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 600;
    text-align: right;
}

.validation {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--loss-wash);
    color: var(--loss);
    font-size: 13px;
}

/* ------------------------------------------------------------- faction art */

.hex { display: block; flex-shrink: 0; }

.hex-art {
    position: relative;
    flex-shrink: 0;
    display: grid;
    place-items: center;
}

.hex-art > * { grid-area: 1 / 1; }

/*
 * The portraits are circles. A hexagon of side s inscribed in its box has an inradius of about
 * 0.447 of the box, against 0.5 for the circle, so the portrait is inset to 86% to sit inside the
 * plate's edges instead of poking through them.
 */
.hex-portrait {
    display: block;
    width: 86%;
    height: 86%;
    object-fit: contain;
}

.faction-strip {
    display: flex;
    gap: 6px;
    justify-content: space-between;
    padding-top: 24px;
    flex-wrap: wrap;
}

.faction-strip-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 68px;
    padding: 4px 0;
    border: none;
    border-radius: 10px;
    background: none;
    color: var(--dim);
    font-family: inherit;
    font-size: 10px;
    cursor: pointer;
    transition: transform .12s;
}

.faction-strip-item:hover { transform: translateY(-3px); color: var(--muted); }
.faction-strip-item.on { color: var(--text); }

.coverage {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
}

.coverage-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px 6px;
    border-radius: 10px;
    color: inherit;
    min-width: 0;
}

.coverage-cell.played { background: rgba(148, 163, 210, 0.06); }
.coverage-cell:hover { background: var(--hover); }

.coverage-cell span {
    font-size: 11px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------------------------------------------------------------- charts -- */

.chart { position: relative; }
.chart .gridline { position: absolute; left: 0; right: 0; border-top: 1px solid var(--border); }
.chart .gridlabel { position: absolute; right: 2px; font-size: 10px; color: var(--dim); }

.bars {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.bars > button {
    position: relative;
    flex: 1 1 0;
    max-width: 48px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
}

.bars .bar { width: 100%; border-radius: 4px 4px 0 0; transition: opacity .12s; }
.bars .bar-label { font-size: 11px; font-weight: 600; height: 15px; }
.bars .bar-x { position: absolute; top: 100%; margin-top: 6px; font-size: 10px; color: var(--dim); }

.dot {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 2px solid var(--surface);
}

/* -------------------------------------------------------------- responsive */

@media (max-width: 1200px) {
    .split.wide-left,
    .split.wide-left-narrow,
    .split.even { grid-template-columns: minmax(0, 1fr); }
    .stat-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
    :root { --gutter: 16px; }

    h1 { font-size: 30px; }

    /* The header wraps onto two rows rather than scrolling the nav out of reach. */
    .topbar {
        position: static;
        height: auto;
        gap: 10px 14px;
        padding: 12px var(--gutter);
        flex-wrap: wrap;
    }

    .topbar .grow { display: none; }
    .nav { order: 3; width: 100%; gap: 2px; }
    .nav a { flex: 1 1 0; text-align: center; padding: 8px 6px; }
    .topbar .btn { margin-left: auto; }

    .page-head { padding-top: 24px; }
    .page-head > div:first-child { width: 100%; }

    .stat-grid.cols-3, .stat-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    /* Stacked so a long value and its caption stop colliding. */
    .stat-value { display: flex; flex-direction: column; align-items: flex-start; font-size: 22px; }
    .stat-value small { font-size: 12px; }

    .coverage { grid-template-columns: repeat(3, minmax(0, 1fr)); }

    /* Wide tables scroll inside their card instead of squashing the name column. */
    .scroll-x { overflow-x: auto; }
    .scroll-x > * { min-width: 720px; }

    .profile-head { gap: 16px; }
    .profile-hex { width: 72px; height: 72px; }
    .profile-hex svg { width: 72px; height: 72px; }
    .profile-hex .initial { font-size: 28px; }

    .faction-strip { justify-content: flex-start; gap: 4px; }
    .faction-strip-item { width: 58px; }

    .log-seat-row { grid-template-columns: 48px minmax(0, 1fr) minmax(0, 1fr) 70px 84px; }
}

/* ----------------------------------------------------- blazor error strip -- */

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 12px 20px;
    background: var(--loss-wash);
    color: var(--loss);
    border-top: 1px solid var(--loss);
}

#blazor-error-ui .dismiss { cursor: pointer; float: right; }

/* ------------------------------------------------------------ page grids -- */

.season-picker {
    height: 32px;
    width: auto;
    padding: 0 8px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: transparent;
    color: var(--muted);
    font-size: 12px;
}

.standings-row { grid-template-columns: 36px minmax(0, 1fr) 48px 48px 72px 150px 92px; }
.player-games-row { grid-template-columns: 44px minmax(0, 1fr) 60px 56px 70px minmax(0, 1.6fr); }
.opponents-row { grid-template-columns: minmax(0, 1fr) 70px 180px 64px; }
.faction-table-row { grid-template-columns: 40px minmax(0, 1.4fr) minmax(0, 1fr) 44px 86px 68px 76px 72px; }
.played-by-row { grid-template-columns: minmax(0, 1fr) 56px 64px 72px; }
.games-row { grid-template-columns: 52px 52px minmax(0, 1fr) 96px; }
.seat-row { grid-template-columns: 44px minmax(0, 1fr) minmax(0, 1fr) 60px 64px 72px; }
.log-seat-row { grid-template-columns: 64px minmax(0, 1fr) minmax(0, 1fr) 84px 104px; }
.log-meta { display: grid; grid-template-columns: 110px 170px minmax(0, 1fr) 170px; gap: 14px; }

.seat-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 0;
    min-width: 0;
    padding: 6px 8px;
    border-radius: 8px;
    background: var(--bg);
    border: 1px solid var(--hairline);
    color: inherit;
}

.seat-chip.winner { border-color: rgba(233, 180, 76, 0.5); }
.seat-chip .name { font-size: 12px; font-weight: 500; white-space: nowrap; }
.seat-chip .faction { font-size: 11px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-chip .vp { margin-left: auto; font-size: 13px; font-weight: 600; }

.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

.profile-head { display: flex; align-items: center; gap: 28px; padding-top: 28px; flex-wrap: wrap; }

.profile-hex {
    position: relative;
    width: 112px;
    height: 112px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
}

.profile-hex svg { grid-area: 1 / 1; }

.profile-hex .initial {
    grid-area: 1 / 1;
    font-family: var(--font-display);
    font-size: 44px;
    font-weight: 700;
}

@media (max-width: 760px) {
    .log-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.faction-line {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 0;
    margin-top: 10px;
    border-top: 1px solid var(--hairline);
    color: inherit;
}

.faction-line:hover { color: inherit; }
.faction-line:hover .truncate { color: var(--accent); }

/* The picker turns accent-coloured when it is showing all-time figures rather than one season. */
.season-picker.aggregate {
    border-color: var(--accent);
    color: var(--accent);
}

.seasons-row { grid-template-columns: 64px minmax(0, 1fr) 110px 150px 88px 96px; }

.banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: 10px;
    background: var(--accent-wash);
    border: 1px solid rgba(79, 209, 165, 0.3);
    color: var(--accent);
    font-size: 13px;
}

.roster-row { grid-template-columns: minmax(0, 1fr) 130px 210px; }

@media (max-width: 860px) {
    .roster-row { grid-template-columns: minmax(0, 1fr); gap: 8px; }
}

/* Folding casual games into the figures is a mode, so the control stays visible while it is on. */
.casual-toggle { height: 32px; padding: 0 12px; font-size: 12px; }
.casual-toggle.on { border-color: var(--gold); background: var(--gold-wash); color: var(--gold); }

.tag.casual { background: rgba(148, 163, 210, 0.16); color: var(--muted); }

.casual-check {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg);
    cursor: pointer;
}

.casual-check:hover { border-color: var(--border-strong); }
.casual-check.on { border-color: var(--gold); background: var(--gold-wash); }
.casual-check.on .dim { color: var(--muted); }
.casual-check input { width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--gold); }
