/* ============================================================
   InArena — Black · White · Taupe Design System
   Black and white carry the interface; taupe is the single accent.
   Light & Dark Modes · Inter (Headings) & Roboto (Body)
   Over the board: hard 2px corners, solid petrol shadows, paper grain · Vast Negative Space
   Every colour lives in the tokens below: components never hard-code one
   (test/design.test.js checks contrast and guards against hard-coded colours).
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800;900&family=Roboto:wght@400;500;700&display=swap');

:root {
    --font-heading: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-body: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    /* Taupe scale (same in both themes) */
    --taupe-50: #f7f4f0;
    --taupe-100: #ece6df;
    --taupe-200: #ddd3c8;
    --taupe-300: #c7b9a9;
    --taupe-400: #b5a38e;
    --taupe-500: #8c7b67;
    --taupe-600: #716253;
    --taupe-700: #574b40;
    --taupe-800: #3b332c;
    --taupe-900: #221e1a;

    /* Default: Light Mode (pure white, warm black text, taupe accent) */
    --bg: #ffffff;
    --bg-soft: #ece6df;
    --card: #f7f4f0;
    --card-hover: #efe9e2;
    --text: #0c0b0a;
    --muted: #6b5f53;
    --line: #e7e1da;
    --line-strong: #d3c9be;

    /* Accent roles:
       --accent       borders, lines, large marks (not for small text on white)
       --accent-fill  backgrounds that carry text (--on-accent on top)
       --accent-text  small accent text on light surfaces
       --accent-weak  tinted surfaces */
    --accent: #8c7b67;
    --accent-fill: #716253;
    --on-accent: #ffffff;
    --accent-text: #574b40;
    --accent-weak: #ece6df;

    /* Activity feed accents: petrol blue marks a Giant Slayer upset, warm sepia / brown a
       kudos. --petrol and --sepia-text are safe for small text; --sepia is for marks only. */
    --petrol: #1f5c63;
    --petrol-weak: #e2ecec;
    --sepia: #9a6a3c;
    --sepia-text: #6e4a2b;
    --sepia-weak: #f3e9dd;

    --primary: #0c0b0a;
    --primary-btn: #0c0b0a;
    --primary-btn-hover: #221e1a;
    --primary-dark: #0c0b0a;
    --primary-weak: rgba(12, 11, 10, 0.06);

    /* Legacy semantic names, kept for compatibility (monochrome + taupe values) */
    --green: #0c0b0a;
    --green-weak: #f7f4f0;
    --red: #6b5f53;
    --red-weak: #f7f4f0;
    --amber: #574b40;
    --amber-weak: #ece6df;
    --blue: #0c0b0a;
    --blue-weak: #f7f4f0;

    /* Heavily Rounded Corners & Zero Heavy Shadows */
    /* Hard edges: 2px at most, just enough to take the razor off the corner */
    --radius-xl: 2px;
    --radius: 2px;
    --radius-sm: 2px;
    --radius-pill: 2px;
    /* Solid, offset shadows instead of soft blur: a card is a slab of card stock on the table */
    --shadow-hard: 4px 4px 0 var(--petrol);
    --shadow-hard-sm: 2px 2px 0 var(--petrol);
    --shadow-hard-lg: 6px 6px 0 var(--petrol); /* overlays that sit on top of the page (the topbar menu) */
    /* Paper grain: SVG fractal noise (feTurbulence), greyscale, 6% alpha, tiled. No colour
       literal: the grain is the noise itself. Decoded source:
       <svg xmlns="http://www.w3.org/2000/svg" width="160" height="160"><filter id="n"><feTurbulence
       type="fractalNoise" baseFrequency=".85" numOctaves="3" stitchTiles="stitch"/><feColorMatrix
       type="saturate" values="0"/><feComponentTransfer><feFuncA type="linear" slope=".06"/>
       </feComponentTransfer></filter><rect width="100%" height="100%" filter="url(#n)"/></svg> */
    --paper-grain: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNjAiIGhlaWdodD0iMTYwIj48ZmlsdGVyIGlkPSJuIj48ZmVUdXJidWxlbmNlIHR5cGU9ImZyYWN0YWxOb2lzZSIgYmFzZUZyZXF1ZW5jeT0iLjg1IiBudW1PY3RhdmVzPSIzIiBzdGl0Y2hUaWxlcz0ic3RpdGNoIi8+PGZlQ29sb3JNYXRyaXggdHlwZT0ic2F0dXJhdGUiIHZhbHVlcz0iMCIvPjxmZUNvbXBvbmVudFRyYW5zZmVyPjxmZUZ1bmNBIHR5cGU9ImxpbmVhciIgc2xvcGU9Ii4wNiIvPjwvZmVDb21wb25lbnRUcmFuc2Zlcj48L2ZpbHRlcj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWx0ZXI9InVybCgjbikiLz48L3N2Zz4=");
    --shadow: none;

    --topbar-bg: rgba(255, 255, 255, 0.9);
    --tabbar-bg: rgba(247, 244, 240, 0.94);
    --inv-text: #ffffff;
    --map-tiles: light;

    /* Safe areas: keep the UI clear of the notch / status bar and of Android's gesture or
       button navigation bar (non-zero only with viewport-fit=cover, e.g. installed edge-to-edge) */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);

    /* Wide layout: one content width for the header and the page, fluid gutters and spacing
       that grow with the screen (phones keep the compact values, see the 760px rules) */
    --layout-max: 1280px;
    --layout-gutter: clamp(1rem, 4vw, 3rem);
    --layout-gap: clamp(1.35rem, 2.4vw, 2.25rem);
    --card-pad-y: clamp(1.2rem, 2.2vw, 2rem);
    --card-pad-x: clamp(1.25rem, 2.6vw, 2.25rem);

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0c0b0a;
        --bg-soft: #211d19;
        --card: #181512;
        --card-hover: #1f1b17;
        --text: #f7f4f0;
        --muted: #a89a8a;
        --line: #2a2520;
        --line-strong: #3d362f;

        --accent: #b5a38e;
        --accent-fill: #b5a38e;
        --on-accent: #0c0b0a;
        --accent-text: #b5a38e;
        --accent-weak: #2b2520;

        --petrol: #6fa9b0;
        --petrol-weak: #14262a;
        --sepia: #c99a69;
        --sepia-text: #d4aa7f;
        --sepia-weak: #2a2018;

        --primary: #f7f4f0;
        --primary-btn: #f7f4f0;
        --primary-btn-hover: #ece6df;
        --primary-dark: #ddd3c8;
        --primary-weak: rgba(247, 244, 240, 0.08);

        --green: #f7f4f0;
        --green-weak: #211d19;
        --red: #a89a8a;
        --red-weak: #181512;
        --amber: #b5a38e;
        --amber-weak: #2b2520;
        --blue: #f7f4f0;
        --blue-weak: #211d19;

        --topbar-bg: rgba(12, 11, 10, 0.88);
        --tabbar-bg: rgba(24, 21, 18, 0.94);
        --inv-text: #0c0b0a;
        --map-tiles: dark;

        color-scheme: dark;
    }
}

html[data-theme="dark"] {
    --bg: #0c0b0a;
    --bg-soft: #211d19;
    --card: #181512;
    --card-hover: #1f1b17;
    --text: #f7f4f0;
    --muted: #a89a8a;
    --line: #2a2520;
    --line-strong: #3d362f;

    --accent: #b5a38e;
    --accent-fill: #b5a38e;
    --on-accent: #0c0b0a;
    --accent-text: #b5a38e;
    --accent-weak: #2b2520;

    --petrol: #6fa9b0;
    --petrol-weak: #14262a;
    --sepia: #c99a69;
    --sepia-text: #d4aa7f;
    --sepia-weak: #2a2018;

    --primary: #f7f4f0;
    --primary-btn: #f7f4f0;
    --primary-btn-hover: #ece6df;
    --primary-dark: #ddd3c8;
    --primary-weak: rgba(247, 244, 240, 0.08);

    --green: #f7f4f0;
    --green-weak: #211d19;
    --red: #a89a8a;
    --red-weak: #181512;
    --amber: #b5a38e;
    --amber-weak: #2b2520;
    --blue: #f7f4f0;
    --blue-weak: #211d19;

    --topbar-bg: rgba(12, 11, 10, 0.88);
    --tabbar-bg: rgba(24, 21, 18, 0.94);
    --inv-text: #0c0b0a;
    --map-tiles: dark;

    color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font-body);
    background: var(--paper-grain) repeat, var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 0.96rem;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    transition: background-color .2s ease, color .2s ease;
}

a { color: var(--text); text-decoration: none; transition: opacity .15s; }
a:hover { opacity: 0.72; }

/* Interlinks (core.js playerLink / entityLink, class="arena-link ..."): every player and league
   name, in every view. Brutalist and quiet: the text keeps its container's colour and weight, a
   hairline underline says "link" at rest (phones have no hover, and a link must not rely on hover
   alone), and hover / focus turns it into a hard 2px petrol rule. A border on an inline box doesn't
   move the line, so a name sits exactly where the plain text did.
   .player-link (a player: global profile or league sheet) and .entity-link (a league or a
   tournament) stay on the markup as hooks for the routers and the tests; the look is this one. */
.arena-link {
    color: inherit;
    font-weight: inherit;
    text-decoration: none;
    border-bottom: 1px solid color-mix(in srgb, currentColor 40%, transparent);
    cursor: pointer;
    transition: border-color .12s linear, background-color .12s linear;
}
.arena-link:hover,
.arena-link:focus-visible {
    border-bottom: 2px solid var(--petrol);
    opacity: 1;
}
.arena-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Pressed: a tactile flash */
.arena-link:active { background: var(--petrol-weak); }
/* A league being fetched before the view transition (player app) */
.arena-link[aria-busy="true"] { cursor: progress; background: var(--petrol-weak); }
/* Inverted bands (background: var(--text)): petrol has no contrast there in either theme, the rule takes the band's own text colour */
.t-champion .arena-link:hover,
.t-champion .arena-link:focus-visible { border-bottom-color: currentColor; }
@media (prefers-reduced-motion: reduce) {
    .arena-link { transition: none; }
}
::selection { background: var(--accent-weak); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

h1, h2, h3, h4, .display-title {
    font-family: var(--font-heading);
    color: var(--text);
    font-weight: 800;
    letter-spacing: -0.035em;
    line-height: 1.08;
}
h1 { font-size: clamp(2rem, 5vw, 3.25rem); font-weight: 900; letter-spacing: -0.04em; }
h2 { font-size: clamp(1.35rem, 2.8vw, 1.85rem); margin-bottom: .35rem; }
h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: .25rem; }

code {
    font-family: var(--font-mono);
    font-size: .84em;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    color: var(--text);
    padding: .18rem .52rem;
    border-radius: var(--radius-pill);
}

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.xs { font-size: .76rem; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }
.mt { margin-top: 1.25rem; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.row-flex { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }

/* ---------- Vast Negative Space & Responsive Layout ---------- */
.container {
    width: 100%;
    max-width: var(--layout-max);
    margin: 0 auto;
    padding: clamp(1.5rem, 3vw, 2.75rem) var(--layout-gutter) 5rem;
    display: flex;
    flex-direction: column;
    gap: var(--layout-gap);
}
/* Running text keeps a readable line length even on a wide page */
.container > p { max-width: 75ch; }
.container > p.center { margin-inline: auto; }
.container.with-tabs { padding-bottom: calc(7.5rem + var(--safe-bottom)); }
.container-wide { max-width: 1440px; margin: 0 auto; padding: clamp(1.5rem, 3vw, 2.75rem) var(--layout-gutter) 5rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }

/* Chart tables for screen readers (chart.js): a <table> ignores its width:1px and keeps its
   content width, so on a 320px phone it widened the page. Their box becomes the containing
   block and clips them: still read by screen readers, no horizontal scroll. */
[data-gchart-sr], [data-gdist-sr], [data-grd-sr], [data-gheat-sr] { position: relative; overflow: hidden; }

/* ---------- Wide layout: two columns from 1024px ----------
   Phones and tablets keep one column in source order. On wide screens:
     .home-split  league Home: standings + tournaments (left) | new game (right)
     .home-duo    league Home: invitation | latest games
     .chart-pair  player profiles: rating history | rating deviation
     .lb-board    global leaderboard: podium (left, sticky) | ranking
   minmax(0, ...) and min-width: 0 let charts and long names shrink instead of overflowing. */
.home-split, .home-duo, .chart-pair, .lb-board {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--layout-gap);
}
.home-split > *, .home-duo > *, .chart-pair > *, .lb-board > * { min-width: 0; }
/* An empty slot (no chart script, no invitation card, no tournaments) takes no row */
.home-split > :not(:has(> *)), .home-duo:not(:has(> *)), .home-split-chart:empty, #playerTournaments:empty { display: none; }
.home-split-main, .lb-board-top { display: flex; flex-direction: column; gap: clamp(1rem, 1.6vw, 1.35rem); }
/* The standings column decides its own card columns: two only when it is wide enough */
.home-split-main { container-type: inline-size; }
.home-split .player-cards-grid.cols-desktop { grid-template-columns: minmax(0, 1fr); }
@container (min-width: 46rem) {
    .home-split .player-cards-grid.cols-desktop { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
    .home-split {
        grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
        grid-template-areas: "main side";
        align-items: start;
    }
    .home-split-main { grid-area: main; }
    .home-split-side { grid-area: side; position: sticky; top: calc(5.5rem + var(--safe-top)); }
    .home-duo { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
    .home-duo > :only-child { grid-column: 1 / -1; }
    .chart-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
    .lb-board.has-list { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); align-items: start; }
    .lb-board.has-list .lb-board-top { position: sticky; top: calc(5.5rem + var(--safe-top)); }
}

@media (max-width: 760px) {
    .container { padding: 1.25rem 1rem 4.5rem; gap: 1.35rem; }
    .container.with-tabs { padding-bottom: calc(7rem + var(--safe-bottom)); }
    .grid-2, .grid-3 { grid-template-columns: 1fr; gap: .9rem; }
}

/* ---------- Ultra-Minimalist Leaderboard Hero Header ---------- */
.lb-header {
    display: flex;
    flex-direction: column;
    gap: .55rem;
    padding: .5rem 0 .25rem;
}
.lb-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.lb-kicker {
    font-family: var(--font-heading);
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    gap: .5rem;
}
.lb-kicker::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    display: inline-block;
}
.lb-title {
    font-family: var(--font-heading);
    font-size: clamp(2.5rem, 7vw, 4.75rem);
    font-weight: 900;
    letter-spacing: -0.045em;
    line-height: 0.96;
    color: var(--text);
    text-transform: uppercase;
}
.lb-subtitle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: .35rem;
}

/* ---------- Tab Navigation Pill (Global, Friends, Regional) ---------- */
.pill-tabs-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.pill-tabs {
    display: inline-flex;
    align-items: center;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    padding: .32rem;
    gap: .25rem;
    max-width: 100%;
    overflow-x: auto;
}
.pill-tab {
    border: none;
    background: transparent;
    color: var(--muted);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: .88rem;
    letter-spacing: -0.01em;
    padding: .62rem 1.35rem;
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: background-color .16s ease, color .16s ease;
    white-space: nowrap;
}
.pill-tab:hover {
    color: var(--text);
}
.pill-tab.active, .pill-tab.on {
    background: var(--accent-fill);
    color: var(--on-accent);
}

/* ---------- Floating Player Cards Grid & List ---------- */
.player-cards-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr); /* minmax(0, …): a long name can't push the card past the screen */
    gap: .85rem;
}
@media (min-width: 900px) {
    .player-cards-grid.cols-desktop {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1.1rem;
    }
}
.player-card {
    background: var(--card);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hard-sm);
    padding: clamp(1.1rem, 1.6vw, 1.4rem) clamp(1.25rem, 2vw, 1.75rem);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.1rem;
    transition: border-color .16s ease, background-color .16s ease, transform .12s ease;
}
.player-card:hover {
    background: var(--card-hover);
    border-color: var(--line-strong);
}
.player-card.is-me {
    border-width: 2px;
    border-color: var(--accent);
}
.player-card-left {
    display: flex;
    align-items: center;
    gap: 1.1rem;
    min-width: 0;
    flex: 1;
}
.player-rank-badge {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 900;
    letter-spacing: -0.04em;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: var(--radius-sm);
    background: var(--bg);
    border: 1px solid var(--line-strong);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}
.player-card.rank-1 .player-rank-badge {
    background: var(--text);
    color: var(--inv-text);
    border-color: var(--text);
}
.player-card.rank-2 .player-rank-badge,
.player-card.rank-3 .player-rank-badge {
    background: var(--accent-weak);
    color: var(--accent-text);
    border-color: var(--accent);
}
.player-info {
    min-width: 0;
    flex: 1;
}
.player-name {
    font-family: var(--font-heading);
    font-size: 1.18rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}
.player-meta {
    font-family: var(--font-body);
    font-size: .8rem;
    color: var(--muted);
    margin-top: .2rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}
.player-card-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: .28rem;
    flex-shrink: 0;
}
.player-rating {
    font-family: var(--font-heading);
    font-size: clamp(1.55rem, 3vw, 2rem);
    font-weight: 900;
    letter-spacing: -0.04em;
    line-height: 1;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.player-delta {
    font-family: var(--font-heading);
    font-size: .78rem;
    font-weight: 700;
    padding: .2rem .65rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--line-strong);
    background: var(--bg);
    color: var(--text);
    font-variant-numeric: tabular-nums;
    letter-spacing: .01em;
}
.player-delta.up {
    background: var(--text);
    color: var(--inv-text);
    border-color: var(--text);
}
.player-delta.down {
    background: transparent;
    color: var(--muted);
    border-color: var(--line-strong);
}
.player-delta.flat {
    background: var(--bg-soft);
    color: var(--muted);
    border-color: var(--line);
}

/* ---------- Brand & Minimalist Topbar ---------- */
.brand {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    font-family: var(--font-heading);
    font-weight: 800;
    color: var(--text);
    text-decoration: none;
    font-size: 1rem;
    letter-spacing: -0.02em;
}
/* Brand emblem (apps/shared/brand/logo-96.png, shown at 34px): a thin taupe ring separates
   the black outer edge from the warm-black background in the dark theme. */
.brand-logo {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    display: block;
    border-radius: 50%;
    object-fit: contain;
    box-shadow: 0 0 0 1.5px var(--accent);
}
.brand:hover .brand-logo { box-shadow: 0 0 0 2px var(--accent-fill); }
@media (max-width: 380px) { .brand-name { display: none; } }
.brand-tag {
    font-family: var(--font-heading);
    font-size: .68rem;
    font-weight: 700;
    color: var(--text);
    background: var(--bg-soft);
    border: 1px solid var(--line-strong);
    padding: .2rem .65rem;
    border-radius: var(--radius-pill);
    text-transform: uppercase;
    letter-spacing: .08em;
}
.topbar {
    position: sticky;
    top: 0;
    z-index: 25;
    background: var(--topbar-bg);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--line);
    padding: var(--safe-top) var(--safe-right) 0 var(--safe-left);
}
.topbar-inner {
    max-width: var(--layout-max);
    margin: 0 auto;
    padding: .85rem var(--layout-gutter);
    display: flex;
    align-items: center;
    gap: .75rem;
}
@media (max-width: 760px) {
    .topbar-inner { padding: .75rem 1rem; }
}
/* Phones: header buttons wrap to a second row instead of pushing the page sideways */
@media (max-width: 600px) {
    .topbar-inner { flex-wrap: wrap; row-gap: .5rem; }
}
.topbar-title {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: -0.02em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.topbar-sub { font-size: .78rem; color: var(--muted); }

/* ---------- Compact topbar menu (G.renderTopbarMenu / bindTopbarMenu) ----------
   Above 600px the secondary actions sit in the bar; at 600px and below the bar keeps the brand
   and the title on one row, and the actions move into a native <dialog id="mobile-menu">. */
.topbar-actions { display: flex; align-items: center; gap: .75rem; flex-shrink: 0; }
/* Two classes: .btn (display: inline-flex, declared further down) must not show it on wide screens */
.topbar-inner .topbar-menu-btn { display: none; }
.topbar-menu-btn svg { display: block; }
@media (max-width: 600px) {
    .topbar-inner.has-menu { flex-wrap: nowrap; }
    .topbar-inner.has-menu .topbar-actions { display: none; }
    .topbar-inner.has-menu .topbar-menu-btn { display: inline-flex; flex-shrink: 0; padding-inline: .8rem; }
    /* The title gets the room: it shortens with an ellipsis, the tag never covers it */
    .topbar-inner.has-menu .topbar-league { flex-wrap: nowrap; min-width: 0; }
    .topbar-inner.has-menu .topbar-league > :not(.topbar-title) { flex-shrink: 0; }
    .topbar-inner.has-menu .topbar-title { min-width: 0; }
    .topbar-inner.has-menu .topbar-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
/* Narrow phones (360px): the hamburger alone, its label stays for screen readers (aria-label) */
@media (max-width: 380px) {
    .topbar-inner.has-menu .topbar-menu-btn { padding-inline: .7rem; }
    .topbar-menu-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
.mobile-menu {
    width: min(22rem, calc(100vw - 2rem - 6px));
    max-height: calc(100dvh - 2rem);
    margin: calc(var(--safe-top) + .75rem) auto auto;
    padding: 0;
    overflow: auto;
    border: 2px solid var(--petrol);
    border-radius: 0;
    box-shadow: var(--shadow-hard-lg);
    background: var(--card);
    color: var(--text);
}
.mobile-menu::backdrop { background: color-mix(in srgb, var(--taupe-900) 90%, transparent); }
.mobile-menu-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .7rem .7rem .7rem 1rem;
    border-bottom: 2px solid var(--petrol);
}
.mobile-menu-head strong {
    font-family: var(--font-heading);
    font-size: .78rem;
    font-weight: 900;
    letter-spacing: .1em;
    text-transform: uppercase;
}
.mobile-menu-close {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 2px solid var(--text);
    border-radius: 0;
    background: transparent;
    color: var(--text);
    cursor: pointer;
}
.mobile-menu-close:hover,
.mobile-menu-close:focus-visible { background: var(--text); color: var(--inv-text); }
.mobile-menu-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mobile-menu-list { display: flex; flex-direction: column; gap: .6rem; padding: 1rem; }
.mobile-menu-list > .btn,
.mobile-menu-list > .theme-toggle { width: 100%; min-height: 46px; justify-content: flex-start; border-radius: 0; }
.mobile-menu-list > .theme-toggle { height: auto; padding: .62rem 1.25rem; font-size: .86rem; box-shadow: var(--shadow-hard-sm); }
.mobile-menu-field { display: flex; flex-direction: column; gap: .3rem; font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.mobile-menu-field .input { width: 100%; }
/* The page behind does not scroll while the menu is open */
html:has(dialog.mobile-menu[open]) { overflow: hidden; }
@media (prefers-reduced-motion: no-preference) {
    .mobile-menu[open] { animation: mobile-menu-in .14s ease-out; }
}
@keyframes mobile-menu-in { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

.icon-btn, .theme-toggle {
    border: 1px solid var(--line-strong);
    background: var(--card);
    height: 38px;
    padding: 0 .85rem;
    border-radius: var(--radius-pill);
    font-family: var(--font-heading);
    font-size: .78rem;
    font-weight: 700;
    cursor: pointer;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    flex-shrink: 0;
    transition: background-color .15s, border-color .15s;
}
.icon-btn:hover, .theme-toggle:hover {
    background: var(--card-hover);
    border-color: var(--accent);
}
.theme-toggle svg { width: 15px; height: 15px; }

/* ---------- Floating Container Cards ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hard);
    padding: var(--card-pad-y) var(--card-pad-x);
}
.card.stack { gap: clamp(1rem, 1.6vw, 1.4rem); }
@media (max-width: 760px) {
    .card { padding: 1.2rem 1.25rem; }
}
.card-slim {
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: .9rem 1.1rem;
}
.card-click {
    width: 100%;
    text-align: left;
    cursor: pointer;
    font: inherit;
    color: inherit;
    transition: border-color .15s, background-color .15s;
}
.card-click:hover { border-color: var(--text); background: var(--card-hover); }
.card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    margin-bottom: .75rem;
    flex-wrap: wrap;
}
.section-title {
    font-family: var(--font-heading);
    font-size: .74rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .14em;
    color: var(--muted);
    margin: .5rem .15rem -.35rem;
}
.notice {
    background: var(--bg-soft);
    border: 1px solid var(--line-strong);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: .85rem 1.1rem;
    font-size: .86rem;
}

/* ---------- Heavily Rounded Monochromatic Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-hard-sm);
    padding: .62rem 1.25rem;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: .86rem;
    letter-spacing: -0.01em;
    cursor: pointer;
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease, opacity .15s ease, transform .08s ease, box-shadow .08s ease;
    white-space: nowrap;
    background: var(--card);
    color: var(--text);
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary {
    background: var(--text);
    border-color: var(--text);
    color: var(--inv-text);
}
.btn-primary:hover:not(:disabled) {
    opacity: 0.86;
    color: var(--inv-text);
}
.btn-ghost {
    background: transparent;
    border-color: var(--line-strong);
    color: var(--text);
}
.btn-ghost:hover:not(:disabled) {
    background: var(--card-hover);
    border-color: var(--text);
}
.btn-danger {
    background: transparent;
    color: var(--text);
    border-color: var(--line-strong);
}
.btn-danger:hover:not(:disabled) {
    background: var(--text);
    color: var(--inv-text);
    border-color: var(--text);
}
.btn-whatsapp {
    background: var(--bg-soft);
    border-color: var(--line-strong);
    color: var(--text);
}
.btn-whatsapp:hover:not(:disabled) {
    background: var(--text);
    color: var(--inv-text);
    border-color: var(--text);
}
.btn-block { width: 100%; }
.btn-lg { padding: .82rem 1.5rem; font-size: .95rem; }
.btn-sm { padding: .42rem .9rem; font-size: .78rem; }

/* Social Auth Buttons */
.social-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .6rem;
}
.btn-social {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .65rem .9rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--line-strong);
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-heading);
    font-size: .84rem;
    font-weight: 700;
    cursor: pointer;
    transition: border-color .15s, background-color .15s;
}
.btn-social:hover {
    background: var(--card-hover);
    border-color: var(--text);
}
.btn-social svg { width: 16px; height: 16px; flex-shrink: 0; filter: grayscale(100%); }

.divider {
    display: flex;
    align-items: center;
    gap: .75rem;
    color: var(--muted);
    font-family: var(--font-heading);
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    margin: .35rem 0;
}
.divider::before, .divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--line);
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--line-strong);
    border-top-color: currentColor;
    border-radius: var(--radius-sm);
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms & Search Inputs ---------- */
.form { display: flex; flex-direction: column; gap: .9rem; }
.field { display: flex; flex-direction: column; gap: .35rem; }
.field > span {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: .8rem;
    letter-spacing: -0.01em;
    color: var(--text);
}
.field em { font-weight: 400; color: var(--muted); font-style: normal; }
.field .hint { font-size: .75rem; color: var(--muted); }
.field .field-error { color: var(--red); font-weight: 700; }
.field[hidden] { display: none; }
.quick-join-form { flex-basis: 100%; width: 100%; margin-top: .25rem; }
.btn[data-quick-join-id][hidden] { display: none; }
.input {
    width: 100%;
    font-family: var(--font-body);
    font-size: .94rem;
    padding: .72rem 1.05rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    transition: border-color .15s;
}
.input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-weak);
}
.input-pill {
    border-radius: var(--radius-pill);
    padding: .82rem 1.35rem;
}
.input-code { text-transform: uppercase; letter-spacing: .1em; font-weight: 700; font-family: var(--font-mono); }
.input-sm { padding: .45rem .85rem; font-size: .82rem; border-radius: var(--radius-pill); width: auto; max-width: 240px; }
.form-actions { display: flex; justify-content: flex-end; gap: .6rem; flex-wrap: wrap; }

/* Segmented tabs */
.seg {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    padding: 4px;
    gap: 4px;
}
.seg button {
    border: none;
    background: transparent;
    padding: .55rem .75rem;
    border-radius: var(--radius-pill);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: .82rem;
    color: var(--muted);
    cursor: pointer;
    transition: all .15s;
}
.seg button.on {
    background: var(--accent-fill);
    color: var(--on-accent);
}

/* Radio choices */
.choices { display: grid; gap: .6rem; }
.choices.c2 { grid-template-columns: 1fr 1fr; }
.choices.c3 { grid-template-columns: repeat(3, 1fr); }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice > span {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .2rem;
    padding: .75rem .6rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--bg);
    cursor: pointer;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: .86rem;
    text-align: center;
    min-height: 62px;
    transition: all .14s;
    color: var(--muted);
}
.choice input:checked + span {
    border-color: var(--accent-fill);
    background: var(--accent-fill);
    color: var(--on-accent);
}
.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Lists & Legacy Row Compatibility ---------- */
.list { display: flex; flex-direction: column; gap: .65rem; }
.row {
    display: flex;
    align-items: center;
    gap: .9rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    background: var(--card);
    border: 1px solid var(--line);
}
.row-me {
    border-width: 2px;
    border-color: var(--accent);
}
.rank {
    width: 2.2rem;
    height: 2.2rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-strong);
    background: var(--bg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: .92rem;
    flex-shrink: 0;
    color: var(--text);
}
.avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--accent-weak) !important;
    color: var(--accent-text) !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: .78rem;
    flex-shrink: 0;
    border: 1px solid var(--accent);
}
.avatar-lg { width: 52px; height: 52px; font-size: 1.05rem; }
.name {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.score {
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: 1.35rem;
    letter-spacing: -0.03em;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.score small { display: block; font-size: .75rem; font-weight: 700; margin-top: .1rem; }

/* Monochromatic Tags & Badges */
.tag {
    font-family: var(--font-heading);
    font-size: .66rem;
    font-weight: 800;
    background: var(--bg-soft);
    color: var(--text);
    border: 1px solid var(--line-strong);
    padding: .14rem .55rem;
    border-radius: var(--radius-pill);
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: .06em;
}
.tag-org { background: var(--accent-fill); color: var(--on-accent); border-color: var(--accent-fill); }
.tag-queue { background: var(--accent-weak); color: var(--accent-text); border-color: var(--accent); }
.tag-public { background: var(--bg-soft); color: var(--text); border-color: var(--line-strong); }
.tag-private { background: transparent; color: var(--muted); border-color: var(--line-strong); }

.up { color: var(--text); font-weight: 700; }
.down { color: var(--muted); }
.flat { color: var(--muted); }
.rel {
    font-family: var(--font-heading);
    font-size: .68rem;
    font-weight: 700;
    padding: .14rem .55rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--line-strong);
    background: var(--bg);
    color: var(--text);
    white-space: nowrap;
}
.rel-high { background: var(--text); color: var(--inv-text); border-color: var(--text); }
.rel-mid { background: var(--accent-weak); color: var(--accent-text); border-color: var(--accent); }
.rel-low { background: transparent; color: var(--muted); }

/* Match rows */
.match {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .85rem 1.1rem;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}
.match-players { flex: 1; min-width: 0; font-size: .9rem; }
.match-players .vs { color: var(--muted); font-size: .76rem; margin: 0 .35rem; }
.result-pill {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: .78rem;
    padding: .25rem .7rem;
    border-radius: var(--radius-pill);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    border: 1px solid var(--line-strong);
}
.res-win { background: var(--text); color: var(--inv-text); border-color: var(--text); }
.res-draw { background: var(--accent-weak); color: var(--accent-text); border-color: var(--accent); }
.res-loss { background: transparent; color: var(--muted); }

/* ---------- Floating Pill Bottom Navigation Bar (Search, Home, Profile) ---------- */
.tabbar {
    position: fixed;
    bottom: 1.15rem;
    left: 0;
    right: 0;
    z-index: 40;
    display: flex;
    justify-content: center;
    padding: 0 calc(1rem + var(--safe-right)) var(--safe-bottom) calc(1rem + var(--safe-left));
    pointer-events: none;
}
.tabbar-inner {
    pointer-events: auto;
    width: 100%;
    max-width: 420px;
    background: var(--tabbar-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-hard);
    padding: .38rem;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr); /* three or four tabs, equal widths */
    gap: .25rem;
}
.tabbar button {
    border: none;
    background: transparent;
    font-family: var(--font-heading);
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--muted);
    padding: .58rem .5rem;
    border-radius: var(--radius-pill);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .22rem;
    cursor: pointer;
    transition: background-color .16s ease, color .16s ease;
}
.tabbar button svg {
    width: 19px;
    height: 19px;
    stroke-width: 2.1;
}
.tabbar button:hover { color: var(--text); }
.tabbar button.on {
    background: var(--accent-fill);
    color: var(--on-accent);
}

/* ---------- Stats & Charts ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(.85rem, 1.4vw, 1.15rem); }
@media (max-width: 680px) { .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.rating-tracks { gap: .85rem; }
.stat {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: clamp(1rem, 1.4vw, 1.25rem) clamp(1.1rem, 1.6vw, 1.4rem);
}
.stat-label {
    font-family: var(--font-heading);
    font-size: .68rem;
    color: var(--muted);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .1em;
}
.stat-value {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: -0.03em;
    margin-top: .2rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.stat-sub { font-size: .76rem; color: var(--muted); margin-top: .15rem; }
.stat-value-sm { font-size: 1.05rem; line-height: 1.45; }
.hero { display: flex; align-items: center; gap: 1rem; }
.score-lg {
    font-family: var(--font-heading);
    font-size: clamp(2rem, 4vw, 2.75rem);
    font-weight: 900;
    letter-spacing: -0.04em;
    text-align: right;
    line-height: 1;
    color: var(--text);
}

/* Time-Ratings Plot */
.plot-box {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: clamp(1rem, 1.4vw, 1.25rem) clamp(1.1rem, 1.6vw, 1.4rem);
}
.spark { width: 100%; height: auto; display: block; margin-top: .4rem; }
.spark-legend {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem 1.1rem;
    margin-top: .65rem;
    font-size: .78rem;
    color: var(--muted);
}
.legend-item {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--text);
}
.legend-dot {
    width: 9px;
    height: 9px;
    border-radius: var(--radius-sm);
    display: inline-block;
    border: 1px solid currentColor;
}

/* Invitation Code & Link Banner */
.invite-strip {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.25rem 1.4rem;
    display: flex;
    flex-direction: column;
    gap: .85rem;
}
.invite-items {
    display: grid;
    grid-template-columns: 1fr 1.4fr;
    gap: .75rem;
}
@media (max-width: 680px) {
    .invite-items { grid-template-columns: 1fr; }
}
.invite-pill {
    background: var(--bg);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    padding: .65rem .95rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .65rem;
    min-width: 0;
}
.invite-val {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: .88rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.invite-strip-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: .85rem;
    align-items: center;
}
@media (min-width: 760px) {
    .invite-strip-body.has-qr {
        grid-template-columns: minmax(0, 1fr) auto;
    }
}
.invite-opponent-card {
    text-align: center;
}
.invite-opponent-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    width: 100%;
}
.invite-opponent-copy {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .55rem;
    min-width: 0;
    flex: 1 1 auto;
}
.invite-opponent-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .45rem;
    margin-top: .2rem;
}
@media (min-width: 560px) {
    .invite-opponent-body.has-qr {
        flex-direction: row;
        justify-content: space-between;
        text-align: left;
        gap: 1.25rem;
    }
    .invite-opponent-body.has-qr .invite-opponent-copy {
        align-items: flex-start;
    }
    .invite-opponent-body.has-qr .invite-opponent-actions {
        justify-content: flex-start;
    }
}
.invite-qr-wrap {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: .35rem;
    padding: .65rem;
    background: var(--bg);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    margin: 0 auto;
}
.invite-qr-box {
    width: 148px;
    height: 148px;
    padding: .35rem;
    background: var(--taupe-50);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    line-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.invite-strip .invite-qr-box {
    width: 112px;
    height: 112px;
}
.invite-qr-img,
.invite-qr-box svg,
.invite-qr-box canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.invite-qr-caption {
    text-align: center;
    line-height: 1.2;
}

/* Prediction preview */
.preview {
    background: var(--bg);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    padding: .9rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: .55rem;
}
.bar { height: 8px; background: var(--line); border-radius: var(--radius-pill); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: var(--radius-pill); }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip {
    font-family: var(--font-heading);
    font-size: .76rem;
    font-weight: 700;
    background: var(--bg-soft);
    border: 1px solid var(--line-strong);
    padding: .25rem .65rem;
    border-radius: var(--radius-pill);
}
.chip.good { background: var(--text); color: var(--inv-text); border-color: var(--text); }
.chip.bad { color: var(--muted); }

/* Empty states */
.empty { text-align: center; padding: 2.2rem 1.25rem; }
.empty p { margin: .35rem auto 1rem; max-width: 360px; }

/* ---------- Auth ---------- */
.auth-wrap {
    max-width: 460px;
    margin: 0 auto;
    padding: 2rem 1rem 3rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}
.auth-wrap.auth-embedded { padding: 0; max-width: 100%; }
/* Embedded on a page with its own h1: an h2 that keeps the h1 look */
.auth-card h2.auth-title { font-size: clamp(2rem, 5vw, 3.25rem); font-weight: 900; letter-spacing: -0.04em; margin-bottom: 0; }
.auth-card { display: flex; flex-direction: column; gap: 1rem; padding: 1.65rem; }
.eyebrow {
    font-family: var(--font-heading);
    font-size: .72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .14em;
    color: var(--muted);
}
.auth-foot { text-align: center; font-size: .84rem; }

/* Stand-alone sign-in shell: header, (scene), card column */
.auth-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.auth-main { display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }
/* The scene exists only on the wide split screen */
.auth-side { display: none; }

/* ---------- Sign-in split screen (>= 1024px) ----------
   Column 1: the rook spiral loop, framed beside the card and vertically centered.
   Column 2: the glass card. The loop lives INSIDE column 1's grid cell, so it can never cover the
   form, whatever the window size or the render's framing. */
.auth-stage { --auth-card-w: 440px; --auth-gutter: clamp(1.25rem, 4vw, 3rem); --auth-gap: 2.5rem; --auth-pad-bottom: 2rem; }
@media (min-width: 1024px) {
    .auth-wrap.auth-stage {
        max-width: none; min-height: 100dvh; margin: 0;
        padding: 1.5rem var(--auth-gutter) var(--auth-pad-bottom);
        display: grid; grid-template-columns: minmax(0, 1fr) var(--auth-card-w); grid-template-rows: auto 1fr;
        column-gap: var(--auth-gap); row-gap: 1.5rem;
        position: relative; isolation: isolate;
    }
    .auth-stage::before {
        content: ""; position: absolute; inset: 0; z-index: -2; pointer-events: none;
        background:
            radial-gradient(40% 55% at 22% 78%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 72%),
            radial-gradient(35% 50% at 80% 45%, color-mix(in srgb, var(--accent) 11%, transparent), transparent 72%);
    }
    .auth-stage > .auth-top { grid-column: 1 / -1; grid-row: 1; }
    .auth-stage > .auth-side {
        display: block; grid-column: 1; grid-row: 2; align-self: center; justify-self: center;
        position: relative; overflow: hidden; pointer-events: none;
        width: 100%; max-width: 520px; aspect-ratio: 1 / 1;
    }
    .auth-scene-video { position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 300%; max-width: none; height: auto; }
    .auth-stage > .auth-main { grid-column: 2; grid-row: 2; align-self: center; width: var(--auth-card-w); }
    .auth-stage .auth-card {
        border: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
        background: color-mix(in srgb, var(--card) 55%, transparent);
        -webkit-backdrop-filter: blur(18px) saturate(150%);
        backdrop-filter: blur(18px) saturate(150%);
        box-shadow: var(--shadow-hard);
    }
}
/* ---------- Card with the scene beside it (embedded, scene: 'side') ----------
   From 860px: the rook spiral loop in column 1, the card in column 2, on one row; the loop never
   overlaps the card. The render keeps the circular vignette inside the left third (640x640 at 1080p),
   so a square window with the video at 300% width and vertically centered frames the board cleanly.
   Narrower: the card alone (bindAuthScene doesn't download the loop there). */
.auth-beside { --auth-card-w: 460px; }
.auth-beside > .auth-main { width: 100%; max-width: var(--auth-card-w); margin-inline: auto; }
@media (min-width: 860px) {
    .auth-wrap.auth-beside:has(> .auth-side) {
        display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, var(--auth-card-w));
        column-gap: clamp(1.5rem, 4vw, 3rem); align-items: center;
    }
    .auth-beside > .auth-side {
        display: block; grid-column: 1; grid-row: 1; justify-self: center;
        position: relative; overflow: hidden; pointer-events: none;
        width: 100%; max-width: 480px; aspect-ratio: 1 / 1;
    }
    .auth-beside .auth-scene-video { position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 300%; max-width: none; height: auto; }
    .auth-beside > .auth-main { grid-column: 2; grid-row: 1; }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    @media (min-width: 1024px) { .auth-stage .auth-card { background: color-mix(in srgb, var(--card) 92%, transparent); } }
}
@media (forced-colors: active) { .auth-stage .auth-card { border-color: CanvasText; } }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -.2rem; }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th {
    text-align: left;
    font-family: var(--font-heading);
    font-size: .7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    padding: .65rem .6rem;
    border-bottom: 1px solid var(--line-strong);
    white-space: nowrap;
}
.table td { padding: .75rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr.annulled td { opacity: .4; text-decoration: line-through; }

/* ---------- Organizer Nav Pills ---------- */
.org-nav { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .2rem; }
.org-nav button {
    border: 1px solid var(--line-strong);
    background: var(--bg);
    padding: .55rem 1.1rem;
    border-radius: var(--radius-pill);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: .82rem;
    cursor: pointer;
    color: var(--muted);
    white-space: nowrap;
    transition: all .15s;
}
.org-nav button:hover { color: var(--text); border-color: var(--accent); }
.org-nav button.on {
    background: var(--accent-fill);
    border-color: var(--accent-fill);
    color: var(--on-accent);
}

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(5.8rem + var(--safe-bottom));
    transform: translateX(-50%) translateY(20px);
    background: var(--text);
    border: 1px solid var(--text);
    color: var(--inv-text);
    padding: .7rem 1.35rem;
    border-radius: var(--radius-pill);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: .85rem;
    opacity: 0;
    pointer-events: none;
    transition: all .2s;
    z-index: 100;
    max-width: min(92vw, 440px);
    text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Optional Meeting Point & Interactive Map ---------- */
.map-shell {
    width: 100%;
    height: 290px;
    border-radius: var(--radius);
    border: 1px solid var(--line-strong);
    background: var(--bg-soft);
    overflow: hidden;
    position: relative;
    z-index: 1;
}
.map-shell.map-sm { height: 220px; }
.taupe-map-pin {
    width: 28px;
    height: 28px;
    border-radius: 50% 50% 50% 4px;
    transform: rotate(-45deg);
    background: var(--accent-fill);
    color: var(--on-accent);
    border: 2px solid var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
}
.taupe-map-pin span {
    transform: rotate(45deg);
    font-size: .8rem;
    line-height: 1;
}
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
    background: var(--bg) !important;
    color: var(--text) !important;
    border: 1px solid var(--line-strong);
    box-shadow: none !important;
    border-radius: var(--radius-sm) !important;
}
.leaflet-popup-content {
    margin: .65rem .85rem !important;
    font-family: var(--font-body) !important;
    font-size: .82rem !important;
    line-height: 1.4 !important;
}
.leaflet-container a.leaflet-popup-close-button {
    color: var(--muted) !important;
}
.map-popup { min-width: 170px; }
.map-popup-title { font-weight: 700; color: var(--text); margin-bottom: .15rem; }
.map-popup-loc { color: var(--accent-text); font-weight: 600; }
.map-popup-meta { color: var(--muted); font-size: .73rem; }
.map-popup-gap { margin-top: .25rem; }
.map-popup-actions { display: flex; gap: .35rem; margin-top: .4rem; }
.map-popup-actions .btn { padding: .2rem .5rem; font-size: .72rem; }
/* Leaflet colours every link in the map: keep the button colours */
.leaflet-container a.btn { color: var(--text); }
.leaflet-container a.btn-primary { color: var(--inv-text); }
.leaflet-container .leaflet-control-attribution { background: var(--topbar-bg); color: var(--muted); }
.leaflet-container .leaflet-control-attribution a { color: var(--accent-text); }
/* ---------- Search & scopes (Task 7) ---------- */
.hub-search { display: flex; flex-direction: column; gap: .75rem; }
.search-results {
    display: flex;
    flex-direction: column;
    gap: .65rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem 1.15rem;
}
.search-hit { display: block; color: inherit; }
.search-hit:hover { opacity: 1; }
.search-hit:hover .player-card { border-color: var(--accent); }
.league-row-card { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; }
.distance-badge {
    font-family: var(--font-heading);
    font-size: .72rem;
    font-weight: 800;
    color: var(--on-accent);
    background: var(--accent-fill);
    padding: .16rem .6rem;
    border-radius: var(--radius-pill);
    font-variant-numeric: tabular-nums;
}
.radius-chips { display: inline-flex; gap: .3rem; flex-wrap: wrap; }
.chip-btn {
    font-family: var(--font-heading);
    font-size: .74rem;
    font-weight: 700;
    color: var(--muted);
    background: var(--bg);
    border: 1px solid var(--line-strong);
    padding: .3rem .7rem;
    border-radius: var(--radius-pill);
    cursor: pointer;
}
.chip-btn:hover { color: var(--text); border-color: var(--accent); }
.chip-btn.on { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--on-accent); }
a.meeting-badge:hover { opacity: 1; border-color: var(--accent-text); }

/* ---------- Tournaments (Task 10) ---------- */
.t-list-item { display: block; }
.t-champion {
    display: flex;
    align-items: baseline;
    gap: .75rem;
    flex-wrap: wrap;
    background: var(--text);
    color: var(--inv-text);
    border-radius: var(--radius-sm);
    padding: .9rem 1.15rem;
}
.t-champion .eyebrow { color: var(--accent); }
.t-champion strong { font-family: var(--font-heading); font-size: 1.35rem; font-weight: 900; letter-spacing: -0.02em; }
.bracket-wrap { overflow-x: auto; margin: 0 -.2rem; padding-bottom: .3rem; }
.bracket { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 1rem; min-width: min-content; }
.bracket-round { display: flex; flex-direction: column; gap: .6rem; }
.bracket-games { display: flex; flex-direction: column; justify-content: space-around; gap: .75rem; flex: 1; }
/* Confirmation dialog (GTournaments.confirmDialog): native <dialog>, theme tokens only */
.confirm-dialog {
    width: min(440px, calc(100vw - 2rem));
    margin: auto;
    padding: 1.4rem 1.5rem;
    border: 1px solid var(--text);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-hard);
    background: var(--card);
    color: var(--text);
}
.confirm-dialog::backdrop { background: color-mix(in srgb, var(--taupe-900) 65%, transparent); backdrop-filter: blur(4px); }
.confirm-dialog h3 { margin: 0; }
.confirm-dialog p { margin: 0; }
.confirm-dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .6rem; }
.feedback-dialog textarea { resize: vertical; min-height: 7.5rem; line-height: 1.45; }
.feedback-dialog .feedback-error { color: var(--red); font-weight: 700; }

/* Discreet footer of the signed-in apps (Send feedback) */
.app-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: .45rem;
    margin-top: .5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--line);
    font-size: .75rem;
    color: var(--muted);
}
.app-footer-link {
    padding: .3rem .15rem;
    border: 0;
    background: none;
    font: inherit;
    color: var(--muted);
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}
.app-footer-link:hover, .app-footer-link:focus-visible { color: var(--text); }

/* League avatars (Step 4): image, or the league's initials when there is none */
.league-avatar {
    --avatar-size: 2.25rem;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--avatar-size);
    height: var(--avatar-size);
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--bg-soft);
    object-fit: cover;
    vertical-align: middle;
}
.league-avatar-sm { --avatar-size: 1.6rem; }
.league-avatar-md { --avatar-size: 2.25rem; }
.league-avatar-lg { --avatar-size: 3.25rem; }
.league-avatar-xl { --avatar-size: 6rem; }
.league-avatar-mono {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: calc(var(--avatar-size) * .38);
    letter-spacing: -0.02em;
    line-height: 1;
    color: var(--accent-text);
    user-select: none;
}
/* Media settings cards (avatar, banner, cover: apps/shared/media.js) */
.media-settings { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.media-settings-preview { display: flex; max-width: 100%; }
.media-preview-banner,
.media-preview-cover {
    display: block;
    width: min(100%, 360px);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--bg-soft);
    object-fit: cover;
}
.media-preview-banner { aspect-ratio: 3 / 1; }
.media-preview-cover { aspect-ratio: 1200 / 630; }
.media-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    border-style: dashed;
    font-size: .8rem;
    color: var(--muted);
}

/* League banner (Step 4b): 3:1 above the league header */
.league-banner {
    aspect-ratio: 3 / 1;
    width: 100%;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg-soft);
}
.league-banner img,
.t-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* League hero (core.js leagueBanner(l, { title: true }) + bindLeagueHero): the league's name on
   its banner. Light text on a warm-black scrim, the same in both themes because it sits on a
   photo, not on the page. */
/* 3:1 like any banner, but never shorter than its caption: the photo is out of flow and the
   caption in flow, and overflow: clip (not hidden) keeps the automatic minimum height, so a long
   name on a narrow phone grows the hero instead of being cut. */
.league-hero {
    position: relative;
    isolation: isolate;
    display: flex;
    align-items: flex-end;
    overflow: clip;
}
.league-hero > img { position: absolute; inset: 0; z-index: -1; }
.league-hero-caption {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: .25rem;
    padding: clamp(2.5rem, 7vw, 5rem) var(--card-pad-x) var(--card-pad-y);
    background: linear-gradient(to top, color-mix(in srgb, var(--taupe-900) 82%, transparent), transparent);
    color: var(--taupe-50);
    pointer-events: none;
}
.league-hero-kicker { font-size: .7rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; opacity: .85; }
.league-hero-title {
    font-size: clamp(1.6rem, 4.6vw, 3.25rem);
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -.02em;
    overflow-wrap: anywhere;
    text-wrap: balance;
}

/* ---------- Fade on scroll (core.js G.bindScrollFade) ----------
   Shared by the league banner and the landing page's animation: an element marked
   data-scroll-fade fades from 1 to 0 while it leaves the viewport at the top, below
   --scroll-fade-top (a sticky bar's height, set by bindScrollFade), and is hidden once fully
   gone (visibility: hidden: no clicks on an invisible element). A scroll-driven animation run by
   the compositor; browsers without it get the same curve from bindScrollFade's
   IntersectionObserver, through --scroll-opacity and data-scroll-faded. */
[data-scroll-fade] { opacity: var(--scroll-opacity, 1); }
[data-scroll-fade][data-scroll-faded] { visibility: hidden; pointer-events: none; }
@keyframes scroll-fade-out { to { opacity: 0; visibility: hidden; } }
@supports (animation-timeline: view()) {
    [data-scroll-fade] {
        view-timeline: --scroll-fade block;
        view-timeline-inset: var(--scroll-fade-top, 0px) 0px;
        animation: scroll-fade-out linear both;
        animation-timeline: --scroll-fade;
        animation-range: exit 0% exit 100%;
    }
}

/* League banner: the fade starts under the top bar (until bindScrollFade measures it), and its
   image drifts down a little on the same timeline, a slow parallax. */
.league-banner { --scroll-fade-top: var(--topbar-h, 4.5rem); }
@keyframes league-banner-drift { to { transform: translateY(18%) scale(1.06); } }
@supports (animation-timeline: view()) {
    .league-banner img {
        animation: league-banner-drift linear both;
        animation-timeline: --scroll-fade;
        animation-range: exit 0% exit 100%;
    }
}

/* The league name in the top bar steps aside while the hero shows it, and slides back in as the
   hero's name goes under the bar: the name is always on screen, once. */
.topbar-league { transition: opacity .2s ease, transform .2s ease, visibility 0s; }
.topbar.is-hero-covered .topbar-league {
    opacity: 0;
    transform: translateY(.45rem);
    visibility: hidden;
    transition: opacity .2s ease, transform .2s ease, visibility 0s .2s;
}

/* Reduced motion: the fade stays (no movement), the parallax and the slide go */
@media (prefers-reduced-motion: reduce) {
    .league-banner img { animation: none; }
    .topbar-league,
    .topbar.is-hero-covered .topbar-league { transform: none; transition: none; }
}

/* Tournament cover in the vanilla tournament view (players; organizers get the cover card) */
.t-cover {
    aspect-ratio: 1200 / 630;
    max-height: 320px;
    overflow: hidden;
    border-radius: var(--radius-sm);
    background: var(--bg-soft);
}
.topbar-title-row { display: flex; align-items: center; gap: .55rem; min-width: 0; }
.t-rounds { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.t-round { display: flex; flex-direction: column; gap: .55rem; }
.t-game {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: .55rem .7rem;
    display: flex;
    flex-direction: column;
    gap: .2rem;
}
.t-game.is-mine { border: 2px solid var(--accent); }
.t-player { display: flex; align-items: center; gap: .5rem; font-size: .88rem; padding: .15rem .3rem; border-left: 3px solid transparent; border-radius: var(--radius-sm); }
.t-player.is-winner { font-weight: 800; border-left-color: var(--accent); background: var(--accent-weak); color: var(--text); }
.t-player.is-loser { color: var(--muted); }
.t-seed { font-family: var(--font-heading); font-size: .7rem; font-weight: 800; color: var(--muted); min-width: 1.3rem; text-align: right; font-variant-numeric: tabular-nums; }
.t-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-colour { font-family: var(--font-heading); font-size: .64rem; font-weight: 800; color: var(--muted); border: 1px solid var(--line-strong); border-radius: var(--radius-pill); padding: 0 .38rem; }
.t-game-foot { display: flex; gap: .35rem; padding: 0 .3rem; }
.t-actions { display: flex; flex-wrap: wrap; gap: .3rem; padding-top: .3rem; border-top: 1px solid var(--line); margin-top: .2rem; }
.table tr.t-row-me td { background: var(--accent-weak); }

.meeting-badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-family: var(--font-heading);
    font-size: .72rem;
    font-weight: 700;
    color: var(--accent-text);
    background: var(--accent-weak);
    border: 1px solid var(--accent);
    padding: .2rem .65rem;
    border-radius: var(--radius-pill);
}

/* ---------- Global leaderboard (Task 12): podium + ranked list ---------- */
.podium {
    display: grid;
    grid-template-columns: 1fr 1.15fr 1fr;
    align-items: end;
    gap: 1rem;
}
.podium-step {
    background: var(--card);
    border: 2px solid var(--accent);
    border-radius: var(--radius);
    padding: 1.25rem 1rem 1.1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: .35rem;
    min-width: 0;
}
.podium-step.place-1 {
    background: var(--accent-fill);
    border-color: var(--accent-fill);
    color: var(--on-accent);
    padding-top: 1.9rem;
    padding-bottom: 1.6rem;
}
.podium-step.place-1 .muted,
.podium-step.place-1 .podium-handle { color: var(--on-accent); opacity: .85; }
.podium-step.place-1 .avatar { background: var(--on-accent) !important; color: var(--accent-fill) !important; }
.podium-place {
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: .78rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--accent-text);
}
.podium-step.place-1 .podium-place { color: var(--on-accent); }
.podium-name {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.02rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.podium-handle { font-size: .74rem; color: var(--muted); }
.podium-rating {
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: 1.9rem;
    letter-spacing: -0.03em;
    line-height: 1;
    margin-top: .2rem;
}
.podium-step.place-1 .podium-rating { font-size: 2.4rem; }
.podium-step.is-me { outline: 3px solid var(--text); outline-offset: 3px; }
@media (max-width: 680px) {
    .podium { grid-template-columns: 1fr; }
    .podium-step.place-1 { order: -1; }
}

.topbar-wrap { flex-wrap: wrap; row-gap: .5rem; }
/* Profile title: a handle (up to 32 characters) instead of one short word */
.lb-title-player { font-size: clamp(2rem, 6vw, 3.5rem); overflow-wrap: anywhere; }
.gl-list { display: flex; flex-direction: column; gap: .55rem; }
.gl-row {
    display: grid;
    grid-template-columns: 3rem auto 1fr auto;
    align-items: center;
    gap: .85rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: clamp(.7rem, 1vw, .9rem) clamp(1rem, 1.4vw, 1.3rem);
}
.gl-row.is-me { border-color: var(--accent); background: var(--accent-weak); }
.gl-rank { font-family: var(--font-heading); font-weight: 900; font-size: 1rem; color: var(--muted); }
.gl-who { min-width: 0; }
.gl-who strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gl-rating { font-family: var(--font-heading); font-weight: 900; font-size: 1.25rem; text-align: right; }

/* Provisional global rating (RD above the calibration threshold): "1650?" in sepia, the colour
   of uncertainty; calibrated ratings keep the standard text colour. --sepia-text is the sepia
   that is safe for text in both themes (--sepia is for marks only). */
.rating-provisional { color: var(--sepia-text); white-space: nowrap; }
.podium-step.place-1 .rating-provisional { color: inherit; } /* on the filled first-place step */
/* Thin taupe separator between the calibrated block and the provisional one */
.gl-divider { display: flex; align-items: center; gap: .65rem; margin: .35rem 0 .1rem; color: var(--accent-text);
    font-family: var(--font-heading); font-size: .68rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.gl-divider::before, .gl-divider::after { content: ""; flex: 1; height: 1px; background: var(--line-strong); }
.gl-prov-note { margin: 0; }

/* Profile trophies: plain text tags, thin taupe border, the value in petrol. No box shadow,
   no icon font: the emoji is decoration (aria-hidden) and the words carry the meaning. */
.trophies { display: flex; flex-wrap: wrap; gap: .45rem; margin: 0; padding: 0; list-style: none; }
.trophy { display: inline-flex; align-items: baseline; gap: .3rem; padding: .22rem .65rem; border: 1px solid var(--accent);
    border-radius: var(--radius-pill); font-size: .8rem; color: var(--muted); background: transparent; white-space: nowrap; }
.trophy b { color: var(--petrol); font-weight: 800; font-variant-numeric: tabular-nums; }
.gl-me-strip {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
    border: 2px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: .75rem 1rem;
    background: var(--accent-weak);
}

/* Address autocomplete (Task B3) */
.addr-ac { position: relative; }
.addr-ac-pop { position: absolute; left: 0; right: 0; top: 100%; z-index: 30; margin-top: .25rem;
    background: var(--card); border: 1px solid var(--text); border-radius: var(--radius); box-shadow: var(--shadow-hard); overflow: hidden; }
.addr-ac-pop[hidden] { display: none; }
.addr-ac-pop ul { list-style: none; margin: 0; padding: 0; max-height: 18rem; overflow: auto; }
.addr-ac-pop li { padding: .5rem .75rem; cursor: pointer; border-left: 3px solid transparent; transition: background-color .15s ease, border-color .15s ease; }
/* Hover and keyboard highlight: petrol tint with a petrol edge (both themes via tokens) */
.addr-ac-pop li:hover, .addr-ac-pop li[aria-selected="true"] { background: var(--petrol-weak); border-left-color: var(--petrol); }
.addr-ac-pop li:hover strong, .addr-ac-pop li[aria-selected="true"] strong { color: var(--petrol); }
@media (prefers-reduced-motion: reduce) { .addr-ac-pop li { transition: none; } }
.btn[data-loc-clear][hidden] { display: none; }
.addr-ac-pop li strong { display: block; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.addr-ac-pop li span { display: block; font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.addr-ac-attr { font-size: .7rem; color: var(--muted); padding: .25rem .75rem; border-top: 1px solid var(--line); }
.addr-ac-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }


/* ---------- Activity feed & kudos (apps/shared/feed.js) ---------- */
.feed-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.activity-list { display: flex; flex-direction: column; gap: .75rem; }
.activity-card {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 1rem 1.1rem .7rem;
    display: flex;
    flex-direction: column;
    gap: .55rem;
    min-width: 0;
}
/* Giant Slayer: petrol blue border with a thicker leading edge */
.activity-card.is-upset { border-color: var(--petrol); box-shadow: inset 3px 0 0 var(--petrol); }
.activity-head { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.activity-icon {
    flex: none;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-soft);
    color: var(--accent-text);
}
.activity-icon svg { width: 1.05rem; height: 1.05rem; }
.is-upset .activity-icon { background: var(--petrol-weak); color: var(--petrol); }
.activity-kicker {
    font-family: var(--font-heading);
    font-size: .7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--muted);
}
.is-upset .activity-kicker { color: var(--petrol); }
.activity-head time { display: block; }
.activity-line { overflow-wrap: anywhere; }
.activity-note { font-size: .82rem; color: var(--petrol); }
.activity-deltas { display: flex; flex-wrap: wrap; gap: .4rem; }
.activity-deltas:empty { display: none; }
.activity-delta {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .8rem;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    padding: .15rem .6rem;
}
.activity-delta b { font-family: var(--font-heading); font-weight: 800; color: var(--text); }
.activity-delta.down b { color: var(--muted); }
.activity-foot { display: flex; justify-content: flex-end; border-top: 1px solid var(--line); padding-top: .55rem; }

.kudos-btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    min-height: 2.75rem;
    padding: .35rem .95rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--muted);
    font-family: var(--font-heading);
    font-size: .85rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color .16s ease, border-color .16s ease, color .16s ease;
}
.kudos-btn svg { width: 1.1rem; height: 1.1rem; transition: fill .16s ease; }
.kudos-btn:hover { color: var(--text); border-color: var(--sepia); }
.kudos-btn.on { background: var(--sepia-weak); border-color: var(--sepia); color: var(--sepia-text); }
.kudos-btn.on svg { fill: var(--sepia); stroke: var(--sepia); }
.kudos-btn[aria-busy="true"] { cursor: progress; }
.kudos-btn.pop svg { animation: kudos-pop .32s ease-out; }
@keyframes kudos-pop {
    0% { transform: scale(1); }
    45% { transform: scale(1.28); }
    100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
    .kudos-btn, .kudos-btn svg { transition: none; }
    .kudos-btn.pop svg { animation: none; }
}

/* ============================================================
   Native-app feel (Android PWA / TWA)
   ============================================================ */

/* ---------- Touch UX ---------- */
/* No blue flash on tap: the pressed state below gives the feedback instead */
html { -webkit-tap-highlight-color: transparent; }
/* Installed (standalone / TWA): no elastic bounce or scroll chaining at the page edges.
   In a normal browser tab the overscroll stays, so pull-to-refresh keeps working there. */
@media (display-mode: standalone), (display-mode: fullscreen) {
    html, body { overscroll-behavior-y: none; }
}
/* Horizontal strips scroll on their own without triggering the back gesture */
.org-nav { overscroll-behavior-x: contain; }
/* No double-tap zoom delay on controls */
a, button, .btn, input, select, textarea, label, summary { touch-action: manipulation; }
/* Interface chrome is not text: a long press or a quick double tap must not select it.
   Content (names, ratings, game rows, feed, forms) stays selectable. */
.topbar, .tabbar, .org-nav, .brand, .btn, button, .tag, .eyebrow, .lb-kicker,
.section-title, .stat-label, label, summary, [role="tab"] {
    -webkit-user-select: none;
    user-select: none;
}
.brand, .brand-logo, .tabbar, .btn, button { -webkit-touch-callout: none; }
input, textarea, select, [contenteditable="true"], .selectable {
    -webkit-user-select: text;
    user-select: text;
}
/* Pressed state (replaces the tap highlight) */
.btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--petrol); }
.tabbar button:active, .org-nav button:active { transform: scale(.96); }
@media (prefers-reduced-motion: reduce) {
    .btn:active:not(:disabled) { transform: none; }
    .tabbar button:active, .org-nav button:active { transform: none; }
}

/* ---------- View transitions (G.viewTransition in apps/shared/core.js) ----------
   html[data-vt] is set only while a view change runs:
     forward  the new view enters from the end side (open a profile, a tab to the right)
     back     the new view enters from the start side (Back, a tab to the left)
     fade     cross-fade
   Motion follows Material's "shared axis X": the old view fades out quickly while sliding a
   short distance, the new one fades in behind it. The app bars are captured on their own,
   so they stay put while the content moves. */
html[data-vt] .topbar { view-transition-name: app-topbar; }
/* On the inner pill, not on .tabbar: a name on the parent would cut off the pill's backdrop blur */
html[data-vt] .tabbar-inner { view-transition-name: app-tabbar; }

@keyframes vt-fade-out { to { opacity: 0; } }
@keyframes vt-fade-in { from { opacity: 0; } }
@keyframes vt-to-start { to { transform: translateX(-2.25rem); } }
@keyframes vt-from-end { from { transform: translateX(2.25rem); } }
@keyframes vt-to-end { to { transform: translateX(2.25rem); } }
@keyframes vt-from-start { from { transform: translateX(-2.25rem); } }

html[data-vt]::view-transition-group(*) {
    animation-duration: 300ms;
    animation-timing-function: cubic-bezier(.2, 0, 0, 1);
}
html[data-vt="forward"]::view-transition-old(root) {
    animation: 105ms cubic-bezier(.4, 0, 1, 1) both vt-fade-out, 300ms cubic-bezier(.2, 0, 0, 1) both vt-to-start;
}
html[data-vt="forward"]::view-transition-new(root) {
    animation: 195ms cubic-bezier(0, 0, .2, 1) 105ms both vt-fade-in, 300ms cubic-bezier(.2, 0, 0, 1) both vt-from-end;
}
html[data-vt="back"]::view-transition-old(root) {
    animation: 105ms cubic-bezier(.4, 0, 1, 1) both vt-fade-out, 300ms cubic-bezier(.2, 0, 0, 1) both vt-to-end;
}
html[data-vt="back"]::view-transition-new(root) {
    animation: 195ms cubic-bezier(0, 0, .2, 1) 105ms both vt-fade-in, 300ms cubic-bezier(.2, 0, 0, 1) both vt-from-start;
}
html[data-vt="fade"]::view-transition-old(root) { animation: 120ms cubic-bezier(.4, 0, 1, 1) both vt-fade-out; }
html[data-vt="fade"]::view-transition-new(root) { animation: 200ms cubic-bezier(0, 0, .2, 1) 60ms both vt-fade-in; }

/* Reduced motion: core.js already skips the transition; this is the CSS safety net */
@media (prefers-reduced-motion: reduce) {
    ::view-transition-group(*),
    ::view-transition-old(*),
    ::view-transition-new(*) { animation: none !important; }
}


/* ============================================================
   Scoresheet QR handshake (player app)
   B shows a QR of the deep link; A lands on a one-tap report view. Same hard edges and solid
   shadows as every slab; the QR keeps its own white square in both themes (scanners need dark
   modules on light).
   ============================================================ */
.report-qr-cta { display: grid; gap: .35rem; margin-top: .9rem; text-align: center; }
.report-qr-dialog { width: min(420px, calc(100vw - 2rem)); }
.report-qr-box {
    width: min(100%, 300px);
    margin: 0 auto;
    border: 2px solid var(--text);
    box-shadow: var(--shadow-hard);
    line-height: 0;
}
.report-qr-box svg { display: block; width: 100%; height: auto; }
.report-qr-url { text-align: center; overflow-wrap: anywhere; }
.report-qr-url code { user-select: all; -webkit-user-select: all; }

/* One-tap report: nothing but the two players and three huge buttons */
.report-view { max-width: 40rem; }
.report-card { gap: clamp(1rem, 3vw, 1.5rem); }
.report-title {
    font-family: var(--font-heading);
    font-size: clamp(2rem, 8vw, 3.4rem);
    font-weight: 900;
    line-height: 1.02;
    letter-spacing: -0.04em;
    overflow-wrap: anywhere;
}
.report-vs { color: var(--muted); font-weight: 700; font-size: .5em; vertical-align: middle; margin: 0 .2em; }
.report-colors { display: flex; flex-wrap: wrap; gap: .5rem; }
.report-piece {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .3rem .6rem; border: 1px solid var(--text); border-radius: var(--radius-sm);
    font-size: .82rem; font-weight: 700;
}
.report-piece::before { content: ""; width: .8rem; height: .8rem; border: 1.5px solid var(--text); }
/* A piece is white or black whatever the theme: fixed palette tones, not --bg / --text (they swap) */
.report-piece.is-white::before { background: var(--taupe-50); }
.report-piece.is-black::before { background: var(--taupe-900); }
.report-actions { display: grid; gap: 1rem; }
.report-btn {
    width: 100%;
    min-height: 4.75rem;
    font-size: clamp(1.4rem, 5vw, 1.9rem);
    font-weight: 900;
    letter-spacing: .04em;
    text-transform: uppercase;
    border: 2px solid var(--text);
    box-shadow: var(--shadow-hard);
}
.report-btn:active:not(:disabled) { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--petrol); }
.report-win { background: var(--petrol); color: var(--bg); border-color: var(--petrol); }
.report-draw { background: var(--card); color: var(--text); }
.report-loss { background: var(--text); color: var(--inv-text); }
.report-btn:disabled { opacity: .55; cursor: progress; }
.report-btn[aria-busy="true"] { opacity: 1; outline: 3px solid var(--accent); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) {
    .report-btn:active:not(:disabled) { transform: none; }
}

/* ============================================================
   Online games import (player app, scoresheet card)
   A hard-edged button and a till-receipt list: dashed rules, one game per line, the date on
   the left, the platform on the right. Tokens only.
   ============================================================ */
.online-import { display: grid; gap: .75rem; margin-top: .9rem; }
.online-import-btn {
    border: 2px solid var(--text);
    box-shadow: var(--shadow-hard);
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}
.receipt {
    background: var(--bg);
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-sm);
    padding: .75rem .9rem;
    display: grid;
    gap: .5rem;
}
.receipt-head, .receipt-foot, .receipt-empty { font-size: .78rem; color: var(--muted); }
.receipt-head { display: flex; justify-content: space-between; text-transform: uppercase; letter-spacing: .12em; font-weight: 700; padding-bottom: .4rem; border-bottom: 1px dashed var(--line-strong); }
.receipt-list { list-style: none; display: grid; }
.receipt-list li + li { border-top: 1px dashed var(--line); }
.receipt-row {
    width: 100%;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: baseline;
    gap: .75rem;
    padding: .6rem .2rem;
    background: transparent;
    border: 0;
    color: var(--text);
    font: inherit;
    font-size: .88rem;
    text-align: left;
    cursor: pointer;
}
.receipt-row:hover:not(:disabled), .receipt-row:focus-visible { background: var(--petrol-weak); }
.receipt-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.receipt-row:disabled { cursor: progress; opacity: .6; }
.receipt-when { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.receipt-what { min-width: 0; overflow-wrap: anywhere; }
.receipt-src { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.receipt-win { color: var(--petrol); }
.receipt-loss { color: var(--text); }
.receipt-draw { color: var(--accent-text); }

/* Slim choices (.choices--slim): the scoresheet's Colour and Outcome toggles stay quiet next to
   its submit button. One hairline, transparent while unselected, no shadow, a compact height
   that still clears a 24px touch target (WCAG 2.5.8); selected = a solid taupe fill with the
   same 1px edge, distinct from the primary (black / inverted) submit button. */
.choices.choices--slim { gap: .4rem; }
.choices--slim .choice > span {
    min-height: 0;
    padding: .4rem .55rem;
    border: 1px solid var(--line-strong);
    background: transparent;
    box-shadow: none;
    font-size: .82rem;
    font-weight: 600;
    line-height: 1.3;
}
/* A second label (the organizer's "1 - 0") sits on the same line, so the toggle stays one line */
.choices--slim .choice > span { flex-direction: row; flex-wrap: wrap; column-gap: .35rem; row-gap: 0; }
.choices--slim .choice small { font-size: .74rem; font-weight: 500; opacity: .85; font-variant-numeric: tabular-nums; }
.choices--slim .choice > span:hover { border-color: var(--text); color: var(--text); }
.choices--slim .choice input:checked + span {
    border-color: var(--accent-fill);
    background: var(--accent-fill);
    color: var(--on-accent);
}
