/* ---------------------------------------------------------------------------
   Friends surface and the contiguous blocks that travel with it: the friends page's shared building blocks
   (the your-code / add-a-friend / sectioned-list bits the friends page and the invite picker both use), the
   groups shelf, the friend picker, the player profile page, and the match-history rows and replay dialog.
   Backed by FriendsPage.razor, Friends/FriendRow.razor, Friends/FriendPicker.razor, PlayerProfilePage.razor,
   GroupsShelf.razor, MatchHistoryRow.razor, MatchHistoryDialog.razor, MatchCard.razor.
   --------------------------------------------------------------------------- */

/* The friend code is case-sensitive base-59, so it must not inherit the meta line's uppercasing (that would
   corrupt a read-aloud or hand-typed code); monospace keeps the characters distinct. */
.friend-code {
    text-transform: none;
    letter-spacing: normal;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85rem;
    color: var(--text-primary);
}
.friends-section { margin-top: 0.9rem; }
.friends-section__label {
    margin: 0 0 0.4rem;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
}
/* A tight row pairing a text field with an inline action button — the share-link copy row and the add-by-code
   row. The field flexes to fill; the button is auto-sized beside it. */
.friends-field-row { display: flex; gap: 0.4rem; align-items: center; }
/* The link field: mono, single-line, faded tail. Kept visible (not clipped away) so it stays selectable for a
   manual copy when the async clipboard is unavailable — an insecure context such as an iOS PWA over http, or a
   permissions block. */
.friends-copy__field {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.45rem 0.6rem;
    border-radius: 0.6rem;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.app-btn.friends-copy__btn { padding: 0.45rem 0.85rem; font-size: 0.85rem; }
/* Inside these rows the add field flexes (overriding .name-input's full-width centre) and every button is
   auto-sized, with the full-width first-button spacing neutralised. */
.friends-field-row .name-input { flex: 1 1 auto; min-width: 0; width: auto; text-align: left; }
.friends-field-row .app-btn { margin-top: 0; width: auto; flex: 0 0 auto; }
/* A small sentence-case helper line (share hints, status feedback) — readable where the uppercase label style
   would shout a full sentence, and it pairs naturally with an inline code chip. */
.friends-note {
    margin: 0.45rem 0 0;
    font-size: 0.78rem;
    line-height: 1.45;
    color: var(--text-secondary);
}
.friend-row {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    min-height: 4.5rem;
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid color-mix(in srgb, var(--border-color) 75%, transparent);
    background: var(--bg-card);
}
.friend-row__avatar { --avatar-size: var(--avatar-md); }
.friend-row__name {
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.friend-row__actions { margin-left: auto; display: flex; align-items: center; gap: 0.4rem; }
.friend-row__status { font-size: 0.8rem; color: var(--text-muted); }
.app-btn.friend-row__btn { padding: 0.3rem 0.6rem; font-size: 0.8rem; }

/* The name + presence cluster: the dotted name on top, a muted status line beneath ("Online" / "Playing …" /
   "Your move in …" / "last seen …") — two lines so the richer states have room. */
.friend-row__who { display: flex; flex-direction: column; align-items: flex-start; gap: 0.1rem; min-width: 0; }
.friend-row__nameline { display: flex; align-items: center; gap: 0.45rem; min-width: 0; max-width: 100%; }
.friend-row__presence {
    max-width: 100%;
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.friend-row__presence--playing,
.friend-row__presence--yourmove,
.friend-row__presence--waiting {
    padding: 0.12rem 0.42rem;
    border-radius: 999px;
    font-weight: 650;
}
.friend-row__presence--playing { color: var(--text-status-positive); background: color-mix(in srgb, var(--accent-green) 12%, transparent); }
.friend-row__presence--yourmove { color: var(--text-status-attention); background: color-mix(in srgb, var(--accent-gold) 16%, transparent); }
.friend-row__presence--waiting { color: var(--accent-blue-ink); background: color-mix(in srgb, var(--accent-blue) 10%, transparent); }
.presence-dot {
    flex: none;
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 9999px;
}
.presence-dot--online {
    background: var(--accent-green);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-green) 22%, transparent);
}
.presence-dot--offline { background: color-mix(in srgb, var(--text-muted) 55%, transparent); }
/* Richer activity dots: a friend actively playing reads as a live green like online; "your move" pulses in the
   accent gold to pull the eye (it's the one actionable state); "waiting on them" is a calm blue. */
.presence-dot--playing {
    background: var(--accent-green);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-green) 22%, transparent);
}
.presence-dot--waiting { background: var(--accent-blue); }
.presence-dot--yourmove {
    position: relative;
    background: var(--accent-gold);
}
/* The expanding ring is a ::after disc scaled + faded; transform + opacity
   composite, so it animates without repainting. */
.presence-dot--yourmove::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--accent-gold);
    pointer-events: none;
    opacity: 0;
    animation: presence-pulse 1.8s ease-out infinite;
}
@keyframes presence-pulse {
    0%   { transform: scale(1); opacity: 0.55; }
    70%  { transform: scale(2.4); opacity: 0; }
    100% { transform: scale(2.4); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .presence-dot--yourmove::after { animation: none; }
}

/* ── Segmented tabs (friends page) ───────────────────────────────────────── */
.seg-tabs {
    display: flex;
    gap: 0.3rem;
    padding: 0.25rem;
    background: color-mix(in srgb, var(--text-muted) 10%, transparent);
    border-radius: 0.7rem;
    overflow-x: auto;
}
.seg-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.85rem;
    border: none;
    background: transparent;
    border-radius: 0.55rem;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
}
.seg-tab:hover { color: var(--text-primary); }
.seg-tab--active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm, 0 1px 3px -1px rgba(0,0,0,0.2));
}
.seg-tab__count {
    min-width: 1.15rem;
    padding: 0 0.3rem;
    border-radius: 9999px;
    background: var(--accent-red);
    color: var(--text-on-accent);
    font-size: 0.72rem;
    line-height: 1.15rem;
    text-align: center;
}

/* ── Friends page (routed /friends) ──────────────────────────────────────── */
.friends-page__body {
    /* A flex column that takes the height the shell gives it, so a section that wants to centre in the page
       (the log-in gate below) has a full-height box to centre in. The signed-in stack is unaffected: its rows
       are block-level and lay out in a column either way. */
    display: flex;
    flex: 1 0 auto;
    flex-direction: column;
    width: 100%;
    max-width: 40rem;
    margin: 0 auto;
    padding: 1rem 1.15rem 4rem;
}
.friends-page__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 0.5rem 0 1rem;
}
.friends-page__title { font-size: 1.5rem; font-weight: 700; }
/* The log-in gate is the whole page for a guest — a heading, a sentence, and one button. Sat at the top of a
   tall screen it is a paragraph adrift in a dark field; centred in the height it is given, it is a designed
   empty state. The column grows and never shrinks, so a short viewport scrolls instead of clipping the button. */
.friends-page__gate {
    display: flex;
    flex: 1 0 auto;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    text-align: center;
    padding: 2rem 1rem;
}
.friends-page__gate .friends-note { max-width: 34rem; margin: 0; }
/* What a friend list is for, in three lines — the gate's whole job is to be worth logging in for, and a
   heading plus a button says nothing about what the account buys. Left-aligned inside the centred column so
   the three read as a list rather than three stray sentences. */
.friends-page__sell {
    list-style: none;
    margin: 0.35rem 0 0.4rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    text-align: left;
    font-size: 0.95rem;
    color: var(--text-secondary);
}
.friends-page__sell li { display: flex; align-items: baseline; gap: 0.6rem; }
.friends-page__sell-art { flex: 0 0 auto; font-size: 0.9rem; }
.friends-page__list { margin-top: 0.75rem; }
.friends-search {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    flex: 1 1 12rem;
    max-width: 18rem;
    padding: 0.4rem 0.7rem;
    border: 1px solid var(--border-color);
    border-radius: 0.6rem;
    background: var(--bg-card);
}
.friends-search:focus-within { border-color: color-mix(in srgb, var(--accent-blue) 55%, var(--border-color)); }
.friends-search__icon { color: var(--text-muted); font-size: 0.9rem; }
/* The border tint is the always-on cue; the outline is the app's baseline ring, which the field does not
   suppress — a tint alone is 1.8:1 against its own resting colour. Cf. chrome.css's .app-input policy. */
.friends-search input { flex: 1; min-width: 0; min-height: 2.75rem; border: none; background: transparent; font: inherit; color: var(--text-primary); }
.friends-search input::placeholder { color: var(--text-muted); }
.friends-add { margin-bottom: 0.5rem; border: 1px solid var(--border-color); border-radius: 0.7rem; padding: 0.3rem 0.8rem; }

/* Compact social hub: the list leads, Add Friend becomes a focused dialog, and narrow screens use a local
   bottom navigation (the hub lives inside the shared app shell, under the top bar). */
.friends-page__body { padding: 1.2rem 1.15rem 5.5rem; }
.friends-page__head { flex-wrap: nowrap; margin: 0.35rem 0 0.9rem; }
.friends-page__eyebrow {
    margin: 0 0 0.15rem;
    color: var(--accent-blue-ink);
    font-size: 0.7rem;
    font-weight: 750;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}
.friends-page__title { margin: 0; font-size: 1.75rem; font-weight: 750; }
.app-btn.friends-page__add { width: auto; margin: 0; padding: 0.55rem 0.85rem; }
.friends-page__tools { display: flex; margin-bottom: 0.75rem; }
.friends-page__desktop-tabs { margin-bottom: 0.75rem; }
.friends-page__mobile-filters { display: none; margin-bottom: 0.75rem; }
.friends-page__list {
    /* The bordered list fills the body column no matter which tab's content it holds: rows, section headings,
       and the empty state are all full-width blocks, so the container does not reflow between tabs. */
    width: 100%;
    margin-top: 0;
    overflow: visible;
    border: 1px solid var(--border-color);
    border-radius: 0.9rem;
    background: var(--bg-card);
    box-shadow: 0 0.4rem 1.4rem color-mix(in srgb, var(--text-primary) 6%, transparent);
}
/* The list's ends are rounded on whatever child happens to sit there — a heading, a row, or the empty state,
   which interleave and change per tab. overflow stays visible (a row's overflow menu escapes the box), so the
   container's own radius cannot clip a square-cornered child; the child carries the same radius instead. */
.friends-page__list > :first-child { border-start-start-radius: 0.9rem; border-start-end-radius: 0.9rem; }
.friends-page__list > :last-child {
    border-end-start-radius: 0.9rem;
    border-end-end-radius: 0.9rem;
    border-bottom: none;
}
.friends-search { width: 100%; max-width: none; padding: 0 0.75rem; border-radius: 0.75rem; }
.friends-list__heading {
    margin: 0;
    padding: 0.65rem 0.8rem 0.4rem;
    color: var(--text-muted);
    background: color-mix(in srgb, var(--text-muted) 5%, transparent);
    font-size: 0.72rem;
    font-weight: 750;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
/* The friends tabs reserve a tall band so the panel does not collapse to a couple of lines when a list is
   empty; everything else is the shared .app-empty recipe. */
.friends-empty { min-height: 14rem; }
/* The add-a-friend panel: a PanelModal on the OverRoom tier, scrolling as a whole so a phone can reach the QR
   and the paste field alike. The cap is on the dynamic viewport — 100vh is the screen with the browser's
   toolbars hidden, so a card sized to it hides its own last row behind a toolbar with no page scroll to reach
   it. Compounded with the primitive's card class so these refinements win over the base recipe whatever the
   sheet order. */
.app-modal__panel.friends-add-dialog {
    max-width: 31rem;
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
    padding: 1.25rem;
}
.friends-add-dialog__divider {
    margin: 1rem 0 0.2rem;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
}
.friends-add-dialog__divider::before,
.friends-add-dialog__divider::after { content: ""; height: 1px; flex: 1; background: var(--border-color); }
.friends-add-dialog__feedback {
    margin: 0.65rem 0 0;
    padding: 0.55rem 0.7rem;
    border-radius: 0.6rem;
    color: var(--text-secondary);
    background: color-mix(in srgb, var(--accent-blue) 8%, transparent);
    font-size: 0.82rem;
}
.friends-mobile-nav {
    position: fixed;
    right: max(0.75rem, env(safe-area-inset-right));
    bottom: max(0.75rem, env(safe-area-inset-bottom));
    left: max(0.75rem, env(safe-area-inset-left));
    z-index: var(--z-mobile-nav);
    min-height: 4.25rem;
    padding: 0.35rem;
    display: grid;
    /* Two sections — Friends and Requests. Add friend is the header's top-right button at every width, so it
       is not a section here. */
    grid-template-columns: repeat(2, 1fr);
    gap: 0.25rem;
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    background: color-mix(in srgb, var(--bg-card) 94%, transparent);
    box-shadow: 0 0.8rem 2rem rgba(20, 29, 49, 0.16);
    backdrop-filter: blur(16px);
}
.friends-mobile-nav__item {
    position: relative;
    min-height: 3.5rem;
    padding: 0.35rem 0.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    border: none;
    border-radius: 0.75rem;
    color: var(--text-muted);
    background: transparent;
    font: inherit;
    font-size: 0.7rem;
    font-weight: 650;
    cursor: pointer;
}
.friends-mobile-nav__item--active { color: var(--accent-blue-ink); background: color-mix(in srgb, var(--accent-blue) 9%, transparent); }
.friends-mobile-nav__icon { font-size: 1.1rem; line-height: 1; }
.friends-mobile-nav__badge {
    position: absolute;
    top: 0.25rem;
    right: calc(50% - 1.45rem);
    min-width: 1rem;
    height: 1rem;
    padding: 0 0.2rem;
    display: grid;
    place-items: center;
    border-radius: 999px;
    color: var(--text-on-accent);
    background: var(--accent-red);
    font-size: 0.62rem;
}
@media (min-width: 40rem) {
    .friends-mobile-nav { display: none; }
    .friends-page__body { padding-bottom: 3rem; }
}
@media (max-width: 40rem) {
    .friends-page__desktop-tabs { display: none; }
    .friends-page__mobile-filters { display: block; }
    .friends-page__body { padding-inline: 0.75rem; }
    .friends-field-row { align-items: stretch; flex-direction: column; }
    .friends-field-row .app-btn { min-height: 2.75rem; }
    .friend-row__actions { gap: 0.2rem; }
    .app-btn.friend-row__btn { padding-inline: 0.5rem; }
}

/* The per-row overflow: a ⋯ button opening a small menu (native <details>, no JS). */
.friend-overflow { position: relative; }
.friend-overflow__btn {
    list-style: none;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    border-radius: 0.5rem;
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1;
}
.friend-overflow__btn::-webkit-details-marker { display: none; }
.friend-overflow__btn:hover { background: var(--bg-hover); color: var(--text-primary); }
/* Placement only — the surface, the column and the row recipe are .app-menu / .app-menu__item (chrome.css).
   A friends row sits in an overflow: visible list, so the menu hangs from the ⋯ button's right edge. */
.friend-overflow__menu {
    right: 0;
    top: 100%;
    margin-top: 0.25rem;
}


/* ── Groups shelf (home, front and centre) ──────────────────────────────
   A group tile (an overlapping member-avatar stack + name + status that opens the group page), the add-group card (a
   dashed placeholder with a big plus, which asks before replacing an existing group), and the groupless prompt. */
.groups-shelf__row { display: flex; flex-wrap: wrap; align-items: stretch; gap: 1rem; }

/* A group rendered as a proper card: a coloured banner (a per-group gradient with a monogram watermark and the
   overlapping member-avatar stack) above a body with the name, status, and badges. The card's hue rides in on a
   `--group-hue` custom property the component sets from the group's name. */
.group-shelf-card {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 17rem;
    max-width: 100%;
    padding: 0;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    overflow: hidden;
    text-align: left;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.group-shelf-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.14);
    border-color: color-mix(in srgb, hsl(var(--group-hue, 210) 60% 55%) 55%, var(--border-color));
}

/* The banner: a diagonal two-stop gradient in the group's own hue, with a big translucent monogram watermark and
   the avatar stack sitting along its lower edge. */
.group-shelf-card__banner {
    position: relative;
    display: flex;
    align-items: flex-end;
    height: 4.5rem;
    padding: 0.55rem 0.9rem;
    background: linear-gradient(135deg,
        hsl(var(--group-hue, 210) 62% 52%),
        hsl(calc(var(--group-hue, 210) + 42) 58% 42%));
    overflow: hidden;
}
.group-shelf-card__emblem {
    position: absolute;
    top: -1rem;
    right: 0.35rem;
    font-size: 4.75rem;
    font-weight: 800;
    line-height: 1;
    color: rgba(255, 255, 255, 0.16);
    pointer-events: none;
    user-select: none;
}
/* The avatars overlap into a stack; a ring in the banner's darker hue keeps each disc legible on the gradient. */
.group-shelf-card__avatars { position: relative; display: inline-flex; }
.group-shelf-card__avatars > * + * { margin-left: -0.5rem; }
.group-shelf-card__avatar { --avatar-size: var(--avatar-sm); border-radius: 9999px; box-shadow: 0 0 0 2px hsl(var(--group-hue, 210) 55% 38%); }
.group-shelf-card__more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--avatar-sm);
    height: var(--avatar-sm);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-on-accent);
    background: rgba(255, 255, 255, 0.22);
}

.group-shelf-card__body { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; padding: 0.7rem 0.9rem 0.85rem; }
.group-shelf-card__name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.group-shelf-card__meta { font-size: 0.82rem; color: var(--text-muted); }
/* The table-state badge — a dot + label for the group's coarse state: a game in play (Playing <game name>,
   green, pulsing), a forming gathering (Forming, amber), or a recently-finished game (Just played, muted). The
   playing state uses the base green + pulse; the creating and done modifiers recolour and stop the pulse. */
.group-shelf-card__badge { display: inline-flex; align-items: center; gap: 0.3rem; margin-top: 0.2rem; font-size: 0.75rem; font-weight: 600; color: var(--accent-green-ink); }
.group-shelf-card__badge-dot { width: 0.5rem; height: 0.5rem; border-radius: 9999px; background: currentColor; animation: group-pulse 1.8s ease-in-out infinite; }
.group-shelf-card__badge--creating { color: var(--accent-amber-ink); }
.group-shelf-card__badge--creating .group-shelf-card__badge-dot { animation: none; }
.group-shelf-card__badge--done { color: var(--text-muted); }
.group-shelf-card__badge--done .group-shelf-card__badge-dot { animation: none; }
/* The durable-unread bubble, in the card's top-right corner over the banner. */
.group-shelf-card__unread {
    position: absolute;
    top: 0.55rem;
    right: 0.6rem;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.35rem;
    border-radius: 9999px;
    background: var(--warn-ember);
    color: var(--text-on-accent);
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* The empty shelf. A bare sentence under a heading reads as a paragraph that lost its section — as a dashed
   placeholder in the shape of the card that will land here, it reads as a slot waiting to be filled, which is
   what it is. It stays inert (no button): the two ways to fill it are elsewhere on purpose, and the copy names
   both. */
.groups-shelf__empty {
    margin: 0;
    padding: 1.4rem 1.5rem;
    border: 1px dashed color-mix(in srgb, var(--text-primary) 20%, transparent);
    border-radius: 1rem;
    background: color-mix(in srgb, var(--bg-card) 45%, transparent);
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--text-secondary);
    max-width: 34rem;
}

@keyframes group-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .group-shelf-card__badge-dot { animation: none; } }

/* ── Friend picker (search box in the forming-table invite list) ─────────── */
.friend-picker__search { width: 100%; margin: 0.3rem 0 0.5rem; text-align: left; }

/* The linked part of a friend row (avatar + name) opening their profile; the row's action buttons sit outside it. */
.friend-row__link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1 1 auto;
    min-width: 0;
    text-decoration: none;
    color: inherit;
    border: none;
    background: transparent;
    cursor: pointer;
    font: inherit;
    text-align: left;
    padding: 0;
    border-radius: 0.5rem;
}
.friend-row__link:hover .friend-row__name { color: var(--accent-blue-ink); }
.friend-row__chevron {
    margin-left: auto;
    padding-left: 0.45rem;
    color: var(--text-muted);
    font-size: 1.35rem;
    line-height: 1;
}

/* ── A friend's profile page (Pages/PlayerProfilePage.razor) ───────────────────
   The friends-only public-profile read on its own route: a hero, the reachable actions, headline stats, and
   the friend's two game shelves. A hub surface — it sits in the shell's scrolling column and paints no
   background of its own — carrying only its own way back to the friends hub above the content. */
.player-page { display: flex; flex-direction: column; min-height: 100%; }
.player-page__topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: clamp(0.6rem, 2vw, 1rem) clamp(0.9rem, 3vw, 2.5rem) 0;
}
/* The reading column: bounded like the rest of the app's content, so a hero and two shelves don't stretch
   across a laptop just because the page has the width. */
.player-page__body {
    width: 100%;
    max-width: 48rem;
    margin: 0 auto;
    display: grid;
    gap: 1rem;
    padding: clamp(0.75rem, 3vw, 1.75rem) clamp(0.9rem, 3vw, 2.5rem) 2rem;
}
.player-page__title { margin: 0; }
/* A name is up to 20 characters and may be one unbroken token, so the text column has to be allowed to shrink
   and the name to break inside itself — otherwise the hero's min-content width exceeds both its hosts (a
   horizontal scrollbar in the profile dialog, a clip on the profile page). */
.profile-hero {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 0;
    min-width: 0;
}
.profile-hero__meta { min-width: 0; }
.profile-hero__avatar { --avatar-size: var(--avatar-xl); }
.profile-hero__name { font-size: 1.5rem; font-weight: 700; margin: 0; min-width: 0; overflow-wrap: anywhere; }
.profile-hero__status { display: inline-flex; align-items: center; gap: 0.45rem; color: var(--text-muted); font-size: 0.9rem; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.5rem; }
.profile-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}
.profile-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.7rem 0.4rem;
    background: color-mix(in srgb, var(--text-muted) 8%, transparent);
    border-radius: 0.7rem;
}
.profile-stat__value { font-size: 1.25rem; font-weight: 700; color: var(--text-primary); }
.profile-stat__label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
@media (max-width: 30rem) {
    .profile-stats { grid-template-columns: repeat(2, 1fr); }
}

/* The history panel: a PanelModal whose card is roomier than the primitive's default, with a heading that
   summarizes the record and a scrollable list of match rows. Compounded with the primitive's card class so
   these refinements win over the base recipe whatever the sheet order. */
.app-modal__panel.history-card {
    gap: 1rem;
    padding: 1.4rem 1.5rem 1.5rem;
}
/* A larger title than the primitive's default — the history panel leads with it. */
.app-modal__panel-title.history-card__title { font-size: 1.4rem; line-height: 1.1; }

/* Scroll region. Capped, with negative side margins so rows can breathe to the card edge while the
   scrollbar sits in the gutter and never overlaps a row. */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: min(60vh, 32rem);
    overflow-y: auto;
    margin: 0 -0.35rem;
    padding: 0.15rem 0.35rem;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-hover) transparent;
}
.history-list::-webkit-scrollbar { width: 8px; }
.history-list::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 9999px; }
.history-list::-webkit-scrollbar-track { background: transparent; }

/* One match: [ accent icon tile ] [ name + result, then meta ] [ watch action ]. The game's catalog
   accent arrives inline as --game-accent / --game-accent-deep. */
.history-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.85rem;
    padding: 0.6rem 0.7rem;
    border-radius: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    transition: border-color 0.15s ease, background-color 0.15s ease;
}
.history-row:hover {
    border-color: color-mix(in srgb, var(--game-accent) 45%, var(--border-color));
    background: var(--bg-hover);
}
/* A win reads at a glance: a gold edge bar and a faint gold wash. */
.history-row--win {
    border-color: color-mix(in srgb, var(--accent-gold) 38%, var(--border-color));
    background: color-mix(in srgb, var(--accent-gold) 7%, var(--bg-card));
    box-shadow: inset 3px 0 0 var(--accent-gold);
}
.history-row--win:hover {
    border-color: color-mix(in srgb, var(--accent-gold) 55%, var(--border-color));
    background: color-mix(in srgb, var(--accent-gold) 11%, var(--bg-card));
}
/* Per-game surfaces (the game-detail view) drop the leading game-icon tile — the game is obvious there — so the
   row is just [ result + meta ] [ watch ]. */
.history-row--nogame { grid-template-columns: 1fr auto; }

.history-row__art {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.7rem;
    height: 2.7rem;
    border-radius: 0.6rem;
    flex: 0 0 auto;
    background: var(--accent-tile-bg);
    box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--game-accent) 70%, black);
}
.history-row__emoji {
    font-size: 1.5rem;
    line-height: 1;
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.5));
}

.history-row__main { min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.history-row__line { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.history-row__game {
    font-size: 1rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Result badge: a neutral rank pill, or a glossy gold pill for a win. */
.history-row__result {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.66rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.12rem 0.5rem;
    border-radius: 9999px;
    color: var(--text-secondary);
    background: color-mix(in srgb, var(--text-muted) 20%, transparent);
    border: 1px solid var(--border-color);
}
.history-row__result.is-win {
    color: var(--text-on-accent-deep);
    background: linear-gradient(180deg, var(--accent-gold-pale) 0%, var(--accent-gold) 60%, var(--accent-gold-deep) 100%);
    border-color: transparent;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
}
.history-row__crown { font-size: 0.72rem; }

.history-row__meta {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.76rem;
    color: var(--text-muted);
    min-width: 0;
}
.history-row__dot { opacity: 0.5; flex: 0 0 auto; }
/* Score and time stay whole; the opponents label is the piece that gives if the row is tight. */
.history-row__meta > span { white-space: nowrap; }
.history-row__when { flex: 0 0 auto; }
.history-row__opp {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-row__side { flex: 0 0 auto; }

/* Watch action — the .app-action-chip recipe (chrome.css) carries the resting ghost and its blue hover; what
   is here is the glyph and the disabled twin (stale/absent replay), a dashed muted chip on the same footprint
   that the primitive has no state for. Every rule that restates one of the primitive's own properties is
   compounded with .app-action-chip: chrome.css loads after this sheet, so an uncompounded single-class rule
   ties on specificity and loses on order — a media block included, since a query adds none. */
.history-watch__glyph { font-size: 0.6rem; color: var(--accent-blue-ink); }
.history-watch:not(.history-watch--disabled):hover .history-watch__glyph { color: var(--text-on-accent); }

.history-watch--disabled.app-action-chip {
    cursor: default;
    color: var(--text-muted);
    background: transparent;
    border-style: dashed;
    border-color: color-mix(in srgb, var(--text-muted) 30%, transparent);
    font-weight: 500;
    font-size: 0.75rem;
}
.history-watch--disabled.app-action-chip:hover {
    background: transparent;
    border-color: color-mix(in srgb, var(--text-muted) 30%, transparent);
    color: var(--text-muted);
}
.history-watch--disabled .history-watch__glyph { color: var(--text-muted); }

/* On narrow screens, drop the label from both the Watch button and the disabled chip so each side column
   collapses to a single glyph and rows keep a matching footprint. */
@media (max-width: 24rem) {
    .history-watch__label { display: none; }
    .history-watch.app-action-chip { padding: 0.4rem 0.55rem; }
}

