/* styles — part 3 of 6 (css/3-lists-badges-league.css). The site's one stylesheet, split in its
   original order: the parts are loaded in this order (partials/head.html,
   admin/index.html) and must stay so — later rules win ties. */

/* Dark mode: the league card like the other dark tiles; its hairline
   light, the calendar sheets and the next event's red a shade lighter. */
:root[data-theme="dark"] .ev-slot {
  border-color: rgba(255, 255, 255, 0.1);
}

:root[data-theme="dark"] .ev-chev {
  background: rgba(255, 110, 110, 0.14);
  color: #ff9a9d;
}

:root[data-theme="dark"] .ev-cal {
  background: rgba(255, 110, 110, 0.14);
  color: #ff9a9d;
}

:root[data-theme="dark"] .ev-slot.is-next .ev-cal {
  background: var(--brand-red);
  color: #fff;
}

:root[data-theme="dark"] :is(.ev-slot.is-next .ev-tile-k, .ev-slot-time) {
  color: #ff8a8d;
}

:root[data-theme="dark"] .ev-archive .ev-tile {
  background: rgba(255, 255, 255, 0.035);
}

:root[data-theme="dark"] .ev-tag {
  background: rgba(255, 110, 110, 0.14);
  color: #ff9a9d;
}

:root[data-theme="dark"] .ev-archive .is-kind-league .ev-tile-k {
  color: #ff8a8d;
}

:root[data-theme="dark"] .ev-archive .is-kind-series .ev-tag {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

:root[data-theme="dark"] .ev-archive .is-kind-online :is(.ev-tile-k, .ev-tag) {
  color: var(--endstep-gold);
}

:root[data-theme="dark"] .ev-list-row {
  border-color: rgba(255, 255, 255, 0.12);
}

:root[data-theme="dark"] .ev-list-row:hover {
  background: rgba(255, 255, 255, 0.05);
}

:root[data-theme="dark"] .ev-list-date {
  color: #ff9a9d;
}

/* An online league (migration 034 — option A2 of a mockup, js/events-page.js):
   the card light like the live one's, its label and ring in endstep's gold,
   its next event's side light too (since 2026-11-04 — it was endstep-dark),
   gold its accents: the calendar sheet, the label and the time;
   the Serie online's row its label gold too, endstep's mark before it (the
   dark block on its left, .ev-online-cap, dropped 2026-11-03). Here, after the dark theme's rules above, and with a
   :root where those would win: the same in both themes. */
.ev-tile.is-online .ev-tile-k {
  color: var(--endstep-gold-deep);
}

.ev-league.is-online .league-ring-track {
  stroke: color-mix(in oklch, var(--endstep-gold) 22%, transparent);
}

.ev-league.is-online .league-ring-fill {
  stroke: var(--endstep-gold);
}

.ev-league.is-online .ev-slot {
  border-left-color: color-mix(in oklch, var(--endstep-gold) 30%, transparent);
}

.ev-league.is-online .ev-slot.is-next .ev-tile-k,
.ev-league.is-online .ev-slot.is-next .ev-slot-time {
  color: var(--endstep-gold-deep);
}

:root[data-theme="dark"] .ev-league.is-online .ev-slot.is-next .ev-tile-k,
:root[data-theme="dark"] .ev-league.is-online .ev-slot.is-next .ev-slot-time {
  color: var(--endstep-gold);
}

:root .ev-league.is-online .ev-slot.is-next .ev-cal {
  background: var(--endstep-gold);
  color: var(--endstep-ink);
}

:root .ev-minor.is-online .ev-chev {
  background: color-mix(in oklch, var(--endstep-gold) 18%, transparent);
  color: var(--endstep-gold-deep);
}

/* Round red position chip (the old Bacheca standings preview's look),
   one color for every position; min-width + padding only so a 3-digit
   rank would stretch it into a pill instead of overflowing. */
.rank-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  box-sizing: border-box;
  border-radius: var(--radius-pill);
  background: rgba(220, 24, 28, 0.18);
  color: var(--brand-red-deep);
  font-size: 0.82rem;
  font-weight: 800;
}

/* "Tu" (js/me-highlight.js): the signed-in account's own player — a small
   brand-red pill after its name wherever it's linked, and its table rows
   tinted more than a top-8 row (after those rules, same weight, so a top-8
   row of yours takes this one; dark mode: below, with the others). */
.me-pill {
  display: inline-flex;
  align-items: center;
  margin-left: 2px;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--brand-red);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.5;
  vertical-align: 0.12em;
  white-space: nowrap;
}

a.is-me {
  font-weight: 800;
}

/* Small inline icon with a hover/focus tooltip — player badges (Giocatori
   tab) and the banned-commander warning icon (Comandanti tab) both use
   this. data-tooltip feeds the tooltip text, shown by the site-wide
   js/floating-tooltip.js (wired in js/layout.js; .floating-tooltip below) —
   no native `title` involved, since no browser lets that be restyled. */
/* player.html's title: the player's badges as one unit that never splits —
   beside the name while they fit, otherwise all of them on the next line
   (js/player-detail.js). */
.badge-group {
  display: inline-block;
  white-space: nowrap;
}

/* No left margin on the first badge: on the next line it would indent the
   group. The space beside the name is .detail-hero-title-wrap's gap. */
#player-title-badges .badge-group > .icon-badge:first-child {
  margin-left: 0;
}

.icon-badge {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-left: 6px;
  font-size: 1rem;
  cursor: default;
}

/* The commander's badges after the name in commander.html's title (js/ui.js
   commanderBadgesHtml): the size of player.html's title badges
   (#player-title-badges, below) — from the same fixed base,
   .detail-hero-title-badges' clamp(2rem, 4.5vw, 3rem): ¾ of it on phones,
   ½ on a computer, a 3px / 2px ring, 12px from the name — not from the
   title's own size, which js/page-title-fit.js shrinks to fit a long name.
   Centred on the name's line like the player's (flex-centred beside it):
   their wrapper is one line tall (1lh, the title's own line height — it
   keeps the title's font), from the line's top, the discs centred in it. */
#commander-title .commander-title-badges {
  display: inline-flex;
  align-items: center;
  height: 1lh;
  margin-left: 12px;
  vertical-align: top;
}

#commander-title .icon-badge {
  font-size: calc(clamp(2rem, 4.5vw, 3rem) * 0.75);
  margin-left: 0;
}

#commander-title .icon-badge + .icon-badge {
  margin-left: 5px;
}

#commander-title .badge-disc {
  border-width: 3px;
}

@media (min-width: 821px) {
  #commander-title .icon-badge {
    font-size: calc(clamp(2rem, 4.5vw, 3rem) * 0.5);
  }

  #commander-title .icon-badge + .icon-badge {
    margin-left: 10px;
  }

  #commander-title .badge-disc {
    border-width: 2px;
  }
}

/* Same reasoning for the badges after the name in player.html's hero
   (#player-title-badges, beside the <h1>, not in it): in em of the name's
   own base size (.detail-hero-title-badges), so they keep their size when
   a long name is shrunk to fit its line. */
#player-title-badges .icon-badge {
  font-size: 0.75em;
  margin-left: 12px;
}

#player-title-badges .icon-badge + .icon-badge {
  margin-left: 5px;
}

#player-title-badges .badge-disc {
  border-width: 3px;
}

/* Desktop only (wider than 820px, the name up to 3rem): smaller — half
   the name's size, a disc ≈ 38px — with the thinner ring. */
@media (min-width: 821px) {
  #player-title-badges .icon-badge {
    font-size: 0.5em;
    margin-left: 10px;
  }

  #player-title-badges .badge-disc {
    border-width: 2px;
  }
}

/* A badge's icon in a disc (js/ui.js's badgeDiscHtml) — the one
   look for a badge everywhere: next to player names, the player page title,
   the admin lists (badges.html's big .badge-card-icon is the same disc at
   its own size). Sized in em from the surrounding text, so it follows each
   spot's own font size. The glyph — an <img> (uploaded/custom icon) or an
   emoji as text — sits in a same-size self-centering box: an emoji left as
   plain text sits wherever the font's glyph metrics place it, which won't
   line up with a flex-centered <img>. */
/* White with a brand-red ring (border-box: the ring is inside the 1.6em,
   so the size doesn't change) — on white every icon keeps its own colours
   at full contrast, which a tinted fill didn't for some of them. The ring
   is a whole number of px (2px; 3px on the bigger player-title discs): a
   fractional width — what an em-based one came to — renders blurry. */
.badge-disc {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-sizing: border-box;
  width: 1.6em;
  height: 1.6em;
  vertical-align: middle;
  /* The brand red, softened (half see-through over the white page). */
  border: 2px solid rgba(220, 24, 28, 0.45);
  border-radius: 50%;
  background: #fff;
  line-height: 1;
}

.badge-disc-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  height: 1em;
  font-size: 0.95em;
  line-height: 1;
}

img.badge-disc-glyph {
  object-fit: contain;
}

/* Side by side (admin player list's two badges, a name's several). */
.badge-disc + .badge-disc,
.icon-badge + .icon-badge {
  margin-left: 4px;
}

/* Badges: archetypes, color identity pips, provisional notice */

.badge-archetype {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 11px;
  border-radius: var(--radius-pill);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: capitalize;
  color: #fff;
}

/* A badge leading to its archetype's page (js/ui.js archetypeBadge,
   js/layout.js): a pointer, a touch brighter on hover, a ring on focus. */
.badge-archetype[data-archetype] {
  cursor: pointer;
  transition: filter 150ms ease, transform 150ms ease;
}

.badge-archetype[data-archetype]:hover {
  filter: brightness(1.15);
}

.badge-archetype[data-archetype]:focus-visible {
  outline: 2px solid var(--brand-red);
  outline-offset: 2px;
}

.badge-archetype-aggro { background: var(--accent-aggro); }
.badge-archetype-control { background: var(--accent-control); }
.badge-archetype-combo { background: var(--accent-combo); }
.badge-archetype-tempo { background: var(--accent-tempo); }
.badge-archetype-midrange { background: var(--accent-midrange); }

/* Its icon before the name (js/archetype-icons.js), in the badge's white. */
.badge-archetype-icon {
  flex: none;
  width: 1.2em;
  height: 1.2em;
  margin: 0 5px 0 -3px;
}

/* archetype.html: the icon in a disc of the archetype's colour before the
   name (js/archetype-detail.js puts it before the <h1>). */
.archetype-hero .profile-hero-heading {
  display: flex;
  align-items: center;
  gap: 14px;
}

.archetype-hero .profile-hero-name {
  flex: 1 1 auto;
  min-width: 0;
}

.archetype-hero-icon {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.85);
  color: #fff;
}

.archetype-hero-icon svg {
  width: 28px;
  height: 28px;
}

/* From 820px down the hero's text is centred: the icon and the name centred
   together, the icon right beside the name (user, 2026-11-19 — the name
   stretched over the row, centred in it, left the icon at its left edge). */
@media (max-width: 820px) {
  .archetype-hero .profile-hero-heading {
    justify-content: center;
  }

  .archetype-hero .profile-hero-name {
    flex: 0 1 auto;
  }
}

@media (max-width: 640px) {
  .archetype-hero-icon {
    width: 42px;
    height: 42px;
  }

  .archetype-hero-icon svg {
    width: 22px;
    height: 22px;
  }
}

.badge-status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 11px;
  border-radius: var(--radius-pill);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fff;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-status-open { background: var(--brand-red); }
.badge-status-closed { background: var(--text-muted); }

/* A league's status (js/ui.js leagueStatusBadge: "In corso" / "Conclusa"),
   wherever it shows — the Leghe & Eventi list, league.html's hero: a
   status, not a button — a small tinted chip, no shadow, small uppercase
   letters, a dot before them: "In corso" green with a soft pulse (live),
   "Conclusa" grey and still. (The admin's open/close toggles keep the
   solid .badge-status look: those are buttons.) */
.badge-status.status-chip {
  gap: 7px;
  min-height: 26px;
  box-sizing: border-box;
  margin-left: 0;
  padding: 0 11px;
  border: 1px solid transparent;
  box-shadow: none;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.badge-status.status-chip::before {
  content: "";
  flex-shrink: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.badge-status-open.status-chip {
  border-color: rgba(22, 163, 74, 0.32);
  background: rgba(22, 163, 74, 0.1);
  color: #15803d;
}

.badge-status-open.status-chip::before {
  background: #22c55e;
}

/* "In corso"'s dot pulsing: a ring over it (where the dot sits: the chip's
   11px padding, centred) growing and fading — transform + opacity, the
   GPU's, not a box-shadow repainted every frame. */
.badge-status-open.status-chip {
  position: relative;
}

.badge-status-open.status-chip::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 11px;
  width: 7px;
  height: 7px;
  margin-top: -3.5px;
  border-radius: 50%;
  background: rgba(34, 197, 94, 0.6);
  pointer-events: none;
  animation: status-live 2s ease-out infinite;
}

.badge-status-closed.status-chip {
  border-color: rgba(110, 100, 102, 0.28);
  background: rgba(110, 100, 102, 0.08);
  color: var(--text-muted);
}

.badge-status-closed.status-chip::before {
  opacity: 0.7;
}

@keyframes status-live {
  70%,
  100% {
    opacity: 0;
    transform: scale(2.7);
  }
}

@media (prefers-reduced-motion: reduce) {
  .badge-status-open.status-chip::after {
    display: none;
  }
}

:root[data-theme="dark"] .badge-status-open.status-chip {
  border-color: rgba(74, 222, 128, 0.35);
  background: rgba(74, 222, 128, 0.12);
  color: #4ade80;
}

:root[data-theme="dark"] .badge-status-open.status-chip::before {
  background: #4ade80;
}

:root[data-theme="dark"] .badge-status-closed.status-chip {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
}

/* The admin's clickable variant (see statusToggleButton in
   admin/js/crud-ui.js) — same pill look as the read-only badge above, just
   reset as an actual <button> and given hover feedback since it's also the
   open/close action now, not just a status display. */
.badge-status-toggle {
  border: none;
  font: inherit;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: filter 150ms ease, transform 150ms ease;
}

.badge-status-toggle:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.color-identity {
  display: inline-flex;
  gap: 4px;
}

/* Pips right after a commander's name in a table cell (js/ui.js's
   commanderPairWithColors), instead of a column of their own — a touch
   smaller than the standalone 18px ones so they sit on the text line. */
.color-identity-inline {
  display: inline-flex;
  margin-left: 8px;
  vertical-align: -2px;
  white-space: nowrap;
}

/* The real mana symbols (js/mana-icons.js, Scryfall's — everywhere a
   colour is shown, since 2026-11-10): each symbol is the whole disc; a faint
   ring round the small ones, as the plain pips had, so white's pale one
   still shows on the light page. */
.mana-symbol {
  display: block;
  flex: none;
  border-radius: 50%;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

/* A deck's colours (js/ui.js colorIdentityPips): the plain pips' sizes and
   spacing (.color-identity's 4px gap) — 18px, 14px after a name. Their
   name on hover (the title's on the image). */
.color-identity .mana-symbol,
.evo-colour-top .mana-symbol,
.pie-legend-swatch.has-symbol .mana-symbol,
.bar-chart-icon .mana-symbol {
  width: 18px;
  height: 18px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.22);
}

.color-identity-inline .mana-symbol {
  width: 14px;
  height: 14px;
}

.color-identity .mana-symbol[title] {
  pointer-events: auto;
}

/* The colour pickers (Comandanti's filter, the admin's colour identity, the
   player card's favourite colours): the symbol fills the disc, inside its
   ring; a picked one shows by its ring and swell (.color-swatch /
   .pc-mana's :has(input:checked)), no ✓ over the symbol. */
.color-swatch .mana-symbol,
.pc-mana .mana-symbol {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Comandanti's "Colori più giocati" bars and the colour bubbles' legend:
   the symbol is the disc (the bars' icon disc otherwise takes the row's
   colour, inline). */
.bar-chart-icon:has(.mana-symbol) {
  background: none !important;
}

.bar-chart-icon .mana-symbol,
.pie-legend-swatch.has-symbol .mana-symbol {
  width: 100%;
  height: 100%;
}

.pie-legend-swatch.has-symbol {
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: none;
}

/* A colour bubble (js/metagame-chart.js): its symbol over the %, the
   bubble filled with the symbol's own pale disc colour — the symbol's disc
   melting into it (no ring), just its glyph showing — so the % is dark
   (white wouldn't show on it), with no shadow. */
.bubble-label .mana-symbol {
  width: max(16px, 34cqw);
  height: max(16px, 34cqw);
  margin-bottom: 3cqw;
}

.bubble-label:has(.mana-symbol) {
  color: #1f1b18;
  text-shadow: none;
}

/* Comandanti's list on touch screens (user, 2026-10-30) — and archetype.html's
   commanders, the same markup (user, 2026-11-19): the colour identity at the
   row's right end, on the name's first line whatever its length — the name
   (and its banned / new badges) on the left, wrapping under itself. A
   computer keeps the pips right after the name. */
html.nav-mobile .commanders-row-title {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

html.nav-mobile .commanders-row-title .commanders-row-name {
  flex: 1;
  min-width: 0;
}

html.nav-mobile .commanders-row-title .color-identity-inline {
  flex-shrink: 0;
  margin-left: auto;
  /* Centred on the name's first line. */
  margin-top: calc((1lh - 16px) / 2);
}

/* Giocatori's list, the same (user, 2026-10-30): the badges at the row's
   right end, on the name's first line, the name wrapping under itself on
   the left. Their group (.players-row-badges) adds nothing on a computer
   (display: contents — the badges right after the name, as before). */
.players-row-badges {
  display: contents;
}

html.nav-mobile .players-row-title {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

/* The name only as wide as it needs (still free to wrap): "Tu"
   (js/me-highlight.js, inserted right after it) stays beside it, the
   badges pushed to the end (their margin-left: auto). */
html.nav-mobile .players-row-title .history-name {
  flex: 0 1 auto;
  min-width: 0;
}

/* On the name's first line (it's about a line tall), the usual small gap
   after the name (the row's 10px gap pulled in). */
html.nav-mobile .players-row-title .me-pill {
  flex-shrink: 0;
  align-self: flex-start;
  margin-left: -4px;
}

html.nav-mobile .players-row-badges {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  /* Centred on the name's first line (a badge's disc: 1.6rem). */
  margin-top: calc((1lh - 1.6rem) / 2);
}

html.nav-mobile .players-row-badges:empty {
  display: none;
}

/* (Their spacing the group's gap, not each badge's own left margin.) */
html.nav-mobile .players-row-badges .icon-badge {
  margin-left: 0;
}

/* Buttons/links reused across new pages */

.btn-primary,
.btn-secondary,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-pill);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease, background 180ms ease;
}

/* Its glow in its own colour (--brand-red: the site's red, or a hero page's
   colour — grey before it arrives), not a fixed red. */
.btn-primary {
  background: var(--brand-red);
  color: #fff;
  box-shadow: 0 10px 20px color-mix(in srgb, var(--brand-red) 24%, transparent);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 26px color-mix(in srgb, var(--brand-red) 30%, transparent);
}

.btn-secondary {
  background: #ffffff;
  color: var(--brand-red-deep);
  border-color: var(--hairline);
}

.btn-secondary:hover {
  transform: translateY(-1px);
  border-color: var(--hairline-hover-strong);
  background: #fff7f4;
}

/* A link styled as a button (Bacheca's "Tutti gli eventi") — the global
   a:hover underline would otherwise win on specificity. */
a.btn-secondary:hover {
  text-decoration: none;
}

.btn-danger {
  background: #ffffff;
  color: #b3261e;
  border-color: rgba(179, 38, 30, 0.28);
}

.btn-danger:hover {
  background: #fff1ef;
  border-color: rgba(179, 38, 30, 0.42);
}

/* Two half-width cards side by side from 880px (the album's own
   breakpoint), stacked on phones (js/history-list.js): player.html's
   "Album comandanti" + "Storico partite", commander.html's "Giocatori" +
   "Storico partite". A list is a card (.history-panel) holding sub-cards
   that scroll inside — no pagination — its top/bottom edge fading while
   there's more that way (.can-scroll-up/-down); 70vh at most, or capped by
   js (capScrollToItems: commander.html's matches, at 8 rounds;
   capScrollToHeightOf: its players, never taller than the matches). A
   column is as tall as its own list (align-self: start), except on desktop
   a `.fills-row` one: no height of its own (`contain: size`), so the other
   column alone sets the row's height and this one stretches to it,
   scrolling inside — player.html's matches, following the album. */
.history-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 28px 22px;
  margin-top: 28px;
}

.history-col,
.album-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.history-col > h2,
.album-col > h2 {
  margin-top: 0;
}

.history-col:not(.fills-row) {
  align-self: start;
}

/* The list (not a header wrapper, .history-col-head on event.html). */
.history-col > div:not(.history-col-head) {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

@media (min-width: 880px) {
  .history-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* A floor for when the album is short (no commanders recorded). */
  .history-col.fills-row {
    contain: size;
    min-height: 320px;
  }

  .history-col.fills-row .history-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .history-col.fills-row .history-scroll {
    flex: 1;
    min-height: 0;
    max-height: none;
  }
}

/* commander.html's Giocatori / Storico partite and player.html's Album
   comandanti / Storico partite (side by side on a computer — player.html's
   since 2026-11-19, user) and league.html's Eventi / Classifica (one under
   the other): on phones
   and touch screens (html.app-header) one at a time behind tabs
   (account.html's .profile-tabs, js/tabs.js — hidden on a computer) — no
   titles (the tab names it), each list whole rather than capped and
   scrolling inside (the caps are inline styles from js/history-list.js,
   hence !important). A Topdeck series has no Classifica: no tabs at all
   ([hidden], over .profile-tabs' own display on touch screens). */
html:not(.app-header) :is(.commander-tabs, .player-tabs) {
  display: none;
}

html.app-header .commander-tabs {
  margin-top: 28px;
}

html.app-header :is(.commander-lists, .player-lists) {
  grid-template-columns: minmax(0, 1fr);
  margin-top: 0;
}

html.app-header .commander-lists > .history-col:not(.is-current),
html.app-header .commander-lists > .history-col > h2,
html.app-header .player-lists > :is(.album-col, .history-col):not(.is-current),
html.app-header .player-lists > .history-col > h2 {
  display: none;
}

/* player.html on touch screens: the tabs 16px under what's above them (the
   rivals', the recap's 26px bottom margin), like commander.html's; the
   album's title gone like the others' — but its "?" (how the special cards
   are earned) kept, in its box's top right corner. */
html.app-header .player-tabs {
  margin-top: -10px;
}

html.app-header .player-lists > .album-col {
  position: relative;
}

html.app-header .player-lists > .album-col > h2 {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  margin: 0;
  font-size: 0;
}

/* league.html: Eventi / Classifica / Meta one at a time behind tabs on
   every screen, like event.html's (a Topdeck series: no Classifica tab). */
.league-lists > section:not(.is-current) {
  display: none;
}

html.app-header .commander-lists .history-scroll,
.league-lists .history-scroll {
  max-height: none !important;
}

/* player.html's Storico partite, the same on phones and touch screens while
   it's under the album (below 880px): the whole list, no scrolling inside.
   From 880px it's beside the album and scrolls in its height (.fills-row). */
@media (max-width: 879px) {
  html.app-header #player-matches .history-scroll {
    max-height: none;
  }
}

/* league.html's events as a timeline (js/league-detail.js timelineHtml):
   a vertical line, one round node per event (its day and month), its card
   beside it — the stretch already played red, the next event solid red
   with a halo, the later ones hollow; one awaiting its results dashed red
   (no date: "?").
   Laid out by the list's own width (a size container — half the row beside
   Classifica, the whole of it alone): from 620px the full date on the
   left of the line, the card's extra (players / time) on its right. */
#league-events {
  container-type: inline-size;
}

.league-timeline {
  --tl-node: 52px;
  --tl-gap: 14px;
  --tl-line: var(--hairline-hover);
  --tl-node-bg: #fffdf8;
  margin: 0;
  padding: 0;
  list-style: none;
}

:root[data-theme="dark"] .league-timeline {
  --tl-line: rgba(255, 255, 255, 0.14);
  --tl-node-bg: #120d0e;
}

.league-tl-item {
  position: relative;
  display: grid;
  grid-template-columns: var(--tl-node) minmax(0, 1fr);
  gap: var(--tl-gap);
  padding-bottom: 12px;
}

/* The line: through every node, from the first one's centre to the last
   one's; red up to the next event's node (half red, half grey there). */
.league-tl-item::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--tl-node) / 2 - 1px);
  width: 2px;
  background: var(--tl-line);
}

.league-tl-item:first-child::before {
  top: calc(var(--tl-node) / 2);
}

.league-tl-item:last-child::before {
  bottom: auto;
  height: calc(var(--tl-node) / 2);
}

.league-tl-item:only-child::before {
  display: none;
}

.league-tl-item:is(.is-played, .is-pending)::before {
  background: var(--brand-red);
}

.league-tl-item.is-next::before {
  background: linear-gradient(var(--brand-red) 50%, var(--tl-line) 50%);
}

.league-tl-date {
  display: none;
}

.league-tl-node {
  position: relative;
  z-index: 1;
  display: grid;
  place-content: center;
  width: var(--tl-node);
  height: var(--tl-node);
  box-sizing: border-box;
  border: 2px solid var(--tl-line);
  border-radius: 50%;
  background: var(--tl-node-bg);
  line-height: 1;
  text-align: center;
}

.league-tl-node b {
  color: var(--text-title);
  font-size: 1.05rem;
}

.league-tl-node span {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
}

.is-played > .league-tl-node {
  border-color: var(--brand-red);
}

.is-next > .league-tl-node {
  border-color: var(--brand-red);
  background: var(--brand-red);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--brand-red) 20%, transparent);
}

.is-next > .league-tl-node b,
.is-next > .league-tl-node span {
  color: #fff;
}

.is-pending > .league-tl-node {
  border-style: dashed;
  border-color: var(--brand-red);
}

.league-tl-card {
  display: grid;
  gap: 4px;
  align-content: center;
  min-height: var(--tl-node);
  box-sizing: border-box;
  padding: 10px 16px;
  border: 1px solid var(--hairline);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow-card);
  color: inherit;
  text-decoration: none;
  transition: border-color 150ms ease, transform 150ms ease;
}

:root[data-theme="dark"] .league-tl-card {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
}

a.league-tl-card:hover {
  border-color: var(--hairline-hover);
  color: inherit;
  text-decoration: none;
}

.league-tl-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.league-tl-k {
  color: var(--text-muted);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.league-tl-t {
  overflow: hidden;
  color: var(--text-title);
  font-size: 1.02rem;
  font-style: italic;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.league-tl-side {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.league-tl-side svg {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
}

.is-next > .league-tl-card,
:root[data-theme="dark"] .is-next > .league-tl-card {
  border-color: transparent;
  background: var(--brand-red);
}

.is-next > .league-tl-card :is(.league-tl-k, .league-tl-t, .league-tl-side) {
  color: #fff;
}

:is(.is-future, .is-pending) > .league-tl-card,
:root[data-theme="dark"] :is(.is-future, .is-pending) > .league-tl-card {
  background: transparent;
  box-shadow: none;
}

.is-pending > .league-tl-card {
  border-style: dashed;
}

:is(.is-future, .is-pending) .league-tl-t {
  color: var(--text-muted);
}

@container (min-width: 620px) {
  .league-tl-item {
    grid-template-columns: 110px var(--tl-node) minmax(0, 1fr);
  }

  .league-tl-item::before {
    left: calc(110px + var(--tl-gap) + var(--tl-node) / 2 - 1px);
  }

  .league-tl-date {
    display: block;
    align-self: center;
    color: var(--text-title);
    font-size: 0.95rem;
    font-weight: 800;
    text-align: right;
  }

  .league-tl-date small {
    display: block;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
  }

  .league-tl-card {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
  }
}

.history-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  box-sizing: border-box;
  margin-left: 4px;
  border-radius: var(--radius-pill);
  background: rgba(220, 24, 28, 0.12);
  color: var(--brand-red-deep);
  font-size: 0.78rem;
  font-weight: 800;
  vertical-align: 0.2em;
}

.history-count:empty {
  display: none;
}

.history-panel {
  flex: 1;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card-sm);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-card);
  padding: 8px;
  animation: entrance-fade-up 380ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

/* The lists without a box round them — Giocatori, Comandanti, event.html's
   Iscritti / Partite / Classifica, player.html's and commander.html's
   Storico partite: just the sub-cards on the page (a scrolling list keeps
   its scroll and top / bottom fades, now fading into the page). Scoped with
   :root in dark mode too, to outrank the panels' dark background. */
:is(#players-list, #commanders-table, #event-entries, #event-matches, #event-leaderboard, #player-matches, #commander-matches, #commander-players, #archetypes-table, #league-leaderboard, #archetype-commanders, #decks) .history-panel,
:root[data-theme="dark"] :is(#players-list, #commanders-table, #event-entries, #event-matches, #event-leaderboard, #player-matches, #commander-matches, #commander-players, #archetypes-table, #league-leaderboard, #archetype-commanders, #decks) .history-panel {
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

/* Their sub-cards, straight on the page now: more contrast — solid white
   (light) / a brighter glass (dark), a firmer edge and a soft shadow; the
   top-8 / "Tu" tints made solid on that white (no red edge on the left). The ids outrank the base
   variants (.is-top8, .is-me-row), so each is restated here. */
:is(#players-list, #commanders-table, #event-entries, #event-matches, #event-leaderboard, #player-matches, #commander-matches, #commander-players, #archetypes-table, #league-leaderboard, #archetype-commanders, #decks) .history-item {
  border-color: rgba(154, 28, 32, 0.2);
  background: #fff;
  box-shadow: 0 2px 8px rgba(80, 10, 14, 0.07);
}

:is(#players-list, #commanders-table, #event-entries, #event-matches, #event-leaderboard, #player-matches, #commander-matches, #commander-players, #archetypes-table, #league-leaderboard, #archetype-commanders, #decks) a.history-item:hover {
  border-color: rgba(154, 28, 32, 0.34);
  background: color-mix(in srgb, #dc181c 4%, #fff);
}

:is(#players-list, #commanders-table, #event-entries, #event-matches, #event-leaderboard, #player-matches, #commander-matches, #commander-players, #archetypes-table, #league-leaderboard, #archetype-commanders, #decks) .history-item.is-top8 {
  background: color-mix(in srgb, #dc181c 8.5%, #fff);
  box-shadow: 0 2px 8px rgba(80, 10, 14, 0.07);
}

:is(#players-list, #commanders-table, #event-entries, #event-matches, #event-leaderboard, #player-matches, #commander-matches, #commander-players, #archetypes-table, #league-leaderboard, #archetype-commanders, #decks) a.history-item.is-top8:hover {
  background: color-mix(in srgb, #dc181c 12%, #fff);
}

:is(#players-list, #commanders-table, #event-entries, #event-matches, #event-leaderboard, #player-matches, #commander-matches, #commander-players, #archetypes-table, #league-leaderboard, #archetype-commanders, #decks) .history-item.is-me-row {
  border-color: rgba(154, 28, 32, 0.3);
  background: color-mix(in srgb, #dc181c 12%, #fff);
}

:is(#players-list, #commanders-table, #event-entries, #event-matches, #event-leaderboard, #player-matches, #commander-matches, #commander-players, #archetypes-table, #league-leaderboard, #archetype-commanders, #decks) a.history-item.is-me-row:hover {
  border-color: rgba(154, 28, 32, 0.38);
  background: color-mix(in srgb, #dc181c 16%, #fff);
}

:root[data-theme="dark"] :is(#players-list, #commanders-table, #event-entries, #event-matches, #event-leaderboard, #player-matches, #commander-matches, #commander-players, #archetypes-table, #league-leaderboard, #archetype-commanders, #decks) .history-item {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

:root[data-theme="dark"] :is(#players-list, #commanders-table, #event-entries, #event-matches, #event-leaderboard, #player-matches, #commander-matches, #commander-players, #archetypes-table, #league-leaderboard, #archetype-commanders, #decks) a.history-item:hover {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 110, 110, 0.12);
}

:root[data-theme="dark"] :is(#players-list, #commanders-table, #event-entries, #event-matches, #event-leaderboard, #player-matches, #commander-matches, #commander-players, #archetypes-table, #league-leaderboard, #archetype-commanders, #decks) .history-item.is-top8 {
  background: rgba(255, 110, 110, 0.11);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

:root[data-theme="dark"] :is(#players-list, #commanders-table, #event-entries, #event-matches, #event-leaderboard, #player-matches, #commander-matches, #commander-players, #archetypes-table, #league-leaderboard, #archetype-commanders, #decks) a.history-item.is-top8:hover {
  background: rgba(255, 110, 110, 0.15);
}

:root[data-theme="dark"] :is(#players-list, #commanders-table, #event-entries, #event-matches, #event-leaderboard, #player-matches, #commander-matches, #commander-players, #archetypes-table, #league-leaderboard, #archetype-commanders, #decks) .history-item.is-me-row {
  border-color: rgba(255, 110, 110, 0.3);
  background: rgba(255, 110, 110, 0.17);
}

:root[data-theme="dark"] :is(#players-list, #commanders-table, #event-entries, #event-matches, #event-leaderboard, #player-matches, #commander-matches, #commander-players, #archetypes-table, #league-leaderboard, #archetype-commanders, #decks) a.history-item.is-me-row:hover {
  border-color: rgba(255, 110, 110, 0.36);
  background: rgba(255, 110, 110, 0.21);
}

.history-scroll {
  --fade-top: 0px;
  --fade-bottom: 0px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 70vh;
  overflow-y: auto;
  padding: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(220, 24, 28, 0.3) transparent;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 var(--fade-top), #000 calc(100% - var(--fade-bottom)), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 var(--fade-top), #000 calc(100% - var(--fade-bottom)), transparent 100%);
}

.history-scroll.can-scroll-up {
  --fade-top: 28px;
}

.history-scroll.can-scroll-down {
  --fade-bottom: 28px;
}

/* On phones / touch screens no visible scrollbar: the list scrolls with
   the finger and the top/bottom fades show there's more. */
@media (max-width: 640px) {
  .history-scroll {
    scrollbar-width: none;
  }

  .history-scroll::-webkit-scrollbar {
    display: none;
  }
}

html.nav-mobile .history-scroll {
  scrollbar-width: none;
}

html.nav-mobile .history-scroll::-webkit-scrollbar {
  display: none;
}

.history-item {
  flex-shrink: 0;
  border: 1px solid rgba(154, 28, 32, 0.14);
  border-radius: 14px;
  background: rgba(220, 24, 28, 0.055);
  padding: 12px 14px;
  font-variant-numeric: tabular-nums;
  transition: background 150ms ease, border-color 150ms ease;
}

a.history-item:hover {
  background: rgba(220, 24, 28, 0.09);
  border-color: rgba(154, 28, 32, 0.26);
}

.history-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.history-title {
  font-weight: 800;
  color: var(--text-title);
  transition: color 150ms ease;
}

/* A sub-card that is a link as a whole (to the event / player / commander
   page; the names inside it are plain text, js/ui.js `{ link: false }`):
   no underline, its title turning red on hover, a focus ring drawn inside
   (the scrolling list would clip one outside). No font-weight change for
   "Tu" (a.is-me): only the pill and the tint. */
a.history-item {
  color: inherit;
  text-decoration: none;
}

a.history-item:hover {
  text-decoration: none;
}

a.history-item:hover .history-title {
  color: var(--brand-red-deep);
}

a.history-item:focus-visible {
  outline: 2px solid var(--brand-red);
  outline-offset: -2px;
}

a.history-item.is-me {
  font-weight: inherit;
}

.history-meta {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.history-deck {
  color: var(--text-muted-2);
  font-size: 0.88rem;
}

.history-muted {
  color: var(--text-muted);
  font-style: italic;
}

/* commander.html's Giocatori: name + last match | events played. */
.history-player {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.history-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
}

.history-stat-value {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--brand-red-deep);
}

.history-stat-label {
  color: var(--text-muted);
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* The Comandanti / Giocatori pages' lists: name (+ a second line) | the
   numbers (js/history-list.js historyStatsHtml), in fixed-width columns so
   they line up down the list like a table's; the winrate in red. Phones:
   the numbers on their own row below, sharing its width. */
.history-ranked {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}

.history-stats {
  display: grid;
  grid-template-columns: repeat(var(--stat-count), 88px);
  gap: 6px;
}

.history-stats .history-stat {
  align-items: center;
}

.history-stats .history-stat-value {
  color: var(--text-value);
  white-space: nowrap;
}

.history-stats .history-stat.is-main .history-stat-value {
  color: var(--brand-red-deep);
}

/* A winrate on too few matches to count (Comandanti — js/commanders-page.js
   MIN_PLAYED_RATIO): greyed, "Pochi dati" on hover. */
.history-stats .history-stat.is-main .history-stat-value .wr-few {
  color: var(--text-muted);
}

/* A number's trend since the latest event — the winrate, Comandanti's
   metashare (js/history-list.js winrateTrendHtml): a trend arrow in a small
   disc tinted in its colour — ↗ green, ↘ red, → grey — hanging just after
   the number, outside its box, so the number stays centred in its column
   like the others. */
.history-stats .history-stat-value:has(.wr-trend) {
  position: relative;
}

.wr-trend {
  --trend: var(--text-muted);
  position: absolute;
  top: 50%;
  left: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35em;
  height: 1.35em;
  margin-left: 5px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--trend) 14%, transparent);
  color: var(--trend);
  font-size: 0.65em;
  line-height: 1;
  transform: translateY(-50%);
}

.wr-trend svg {
  width: 0.95em;
  height: 0.95em;
}

.wr-trend.is-up {
  --trend: #1a9a5c;
}

.wr-trend.is-down {
  --trend: var(--brand-red);
}

:root[data-theme="dark"] .wr-trend.is-up {
  --trend: #4cd38f;
}

:root[data-theme="dark"] .wr-trend.is-down {
  --trend: #ff6b6e;
}

/* In the Comandanti / Giocatori lists (a stat marked .has-trend): the arrow
   as tall as the number and its label together, beside both — the pair and
   the arrow centred in their column as one. Its room is part of the stat
   (padding), so a column holding one is widened when needed (88px is less
   than "METASHARE" + the arrow); every row has the same stats (.has-trend
   even without an arrow), so the columns still line up down the list. */
.history-ranked .history-stats:has(.has-trend) {
  grid-template-columns: repeat(var(--stat-count), minmax(88px, auto));
}

.history-stats .history-stat.has-trend {
  position: relative;
  justify-self: center;
  padding-right: 29px;
}

.history-stats .history-stat.has-trend .history-stat-value {
  position: static;
}

.history-stats .has-trend .wr-trend {
  left: auto;
  right: 0;
  width: 25px;
  height: 25px;
  margin: 0;
  font-size: 16px;
}

/* Classifica (league.html, event.html): Punti — what the order is by —
   stands out from the other numbers: a size up, on a soft pill in the
   accent (the page's hero colour, or the brand red). */
:is(#league-leaderboard, #event-leaderboard) .history-stats .history-stat.is-main {
  align-items: center;
  justify-self: center;
  padding: 4px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--brand-red) 11%, transparent);
}

:root[data-theme="dark"] :is(#league-leaderboard, #event-leaderboard) .history-stats .history-stat.is-main {
  background: color-mix(in srgb, var(--brand-red) 22%, transparent);
}

:is(#league-leaderboard, #event-leaderboard) .history-stats .history-stat.is-main .history-stat-value {
  font-size: 1.3rem;
  line-height: 1.1;
}

:is(#league-leaderboard, #event-leaderboard) .history-stats .history-stat.is-main .history-stat-label {
  color: var(--brand-red-deep);
}

/* The rest of the row lined up with it: every number given the pill's
   vertical padding and the row aligned to its bottom, so all the labels
   sit on one line (Punti's bigger number rising above its own). */
:is(#league-leaderboard, #event-leaderboard) .history-stats {
  align-items: end;
}

:is(#league-leaderboard, #event-leaderboard) .history-stats .history-stat {
  padding-block: 4px;
}

@media (max-width: 640px) {
  .history-ranked {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .history-ranked .history-stats {
    grid-template-columns: repeat(var(--stat-count), minmax(0, 1fr));
    padding-top: 10px;
    border-top: 1px solid var(--table-row-line);
  }

  /* The room for a trend arrow (below) widens its column over the others
     when needed — "METASHARE" alone nearly fills a quarter of the row. */
  .history-ranked .history-stats:has(.has-trend) {
    grid-template-columns: repeat(var(--stat-count), minmax(min-content, 1fr));
  }
}

/* Pull to refresh, installed app only (js/pull-refresh.js): a white disc
   with a red refresh arrow, hidden above the top edge, sliding down with
   the pull (--ptr-y); its red ring fills as it goes (--ptr-p, 0–1) and the arrow turns with it. Armed (.is-armed): the ring
   full, a little pop. Refreshing: held there, a red arc spinning round.
   Above the header (25) and the nav (20). */
.ptr {
  --ptr-y: 0px;
  --ptr-p: 0;
  position: fixed;
  top: env(safe-area-inset-top);
  left: 50%;
  z-index: 40;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 8px + var(--ptr-y)));
  transition: transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.ptr.is-pulling {
  transition: none;
}

.ptr-disc {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 3px solid transparent;
  border-radius: 50%;
  background:
    linear-gradient(#fff, #fff) padding-box,
    conic-gradient(var(--brand-red) calc(var(--ptr-p) * 360deg), color-mix(in srgb, var(--brand-red) 14%, #fff) 0) border-box;
  box-shadow: var(--shadow-card-hover);
  opacity: min(1, calc(var(--ptr-p) * 2.5));
  transition: scale 160ms ease, opacity 160ms ease;
}

.ptr.is-refreshing .ptr-disc {
  opacity: 1;
}

.ptr-disc svg {
  width: 22px;
  height: 22px;
  color: var(--brand-red);
  rotate: calc(var(--ptr-p) * 300deg);
}

.ptr.is-armed .ptr-disc {
  scale: 1.1;
}

.ptr.is-refreshing .ptr-disc {
  scale: 1;
  background:
    linear-gradient(#fff, #fff) padding-box,
    conic-gradient(var(--brand-red) 0 90deg, color-mix(in srgb, var(--brand-red) 14%, #fff) 0) border-box;
  animation: ptr-spin 800ms linear infinite;
}

.ptr.is-refreshing .ptr-disc svg {
  animation: ptr-spin 800ms linear infinite reverse;
}

@keyframes ptr-spin {
  to {
    rotate: 1turn;
  }
}

/* On a hero page, the page's accent (applyHeroTone sets --hero-accent on
   <body>, the disc's parent) instead of the red — dark mode its light
   shade, like the page's own red text there. Before the colour arrives, the
   neutral grey <body> already gives every page with a hero. */
body.has-hero-accent .ptr {
  --brand-red: var(--hero-accent);
}

:root[data-theme="dark"] body.has-hero-accent .ptr {
  --brand-red: var(--hero-accent-light);
}

:root[data-theme="dark"] .ptr-disc {
  background:
    linear-gradient(#241c1e, #241c1e) padding-box,
    conic-gradient(var(--brand-red) calc(var(--ptr-p) * 360deg), rgba(255, 255, 255, 0.12) 0) border-box;
}

:root[data-theme="dark"] .ptr.is-refreshing .ptr-disc {
  background:
    linear-gradient(#241c1e, #241c1e) padding-box,
    conic-gradient(var(--brand-red) 0 90deg, rgba(255, 255, 255, 0.12) 0) border-box;
}

@media (prefers-reduced-motion: reduce) {
  .ptr,
  .ptr-disc {
    transition: none;
  }

  .ptr.is-refreshing .ptr-disc,
  .ptr.is-refreshing .ptr-disc svg {
    animation: none;
  }
}

/* "Torna all'inizio" (js/back-to-top.js, Comandanti / Giocatori): a round
   button styled like the touch tab bar — a solid white disc (dark mode the
   bar's near-black) with the bar's faint edge and lifted shadow, the arrow
   in the body text colour; the same on every screen, and never in a hero's
   colour. Fixed bottom-right, fading/rising in once the page is scrolled
   down — visibility too, so while hidden it's neither clickable nor
   tabbable. On touch screens just above the tab bar, on the right (the "Tab
   bar" rules). */
.back-to-top {
  position: fixed;
  right: 24px;
  /* Lifted above the footer once it's in view (js/back-to-top.js), clear of
     its theme switch in the same corner — desktop; the touch rules below
     set their own bottom. */
  bottom: calc(24px + env(safe-area-inset-bottom) + var(--back-to-top-lift, 0px));
  z-index: 15;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  padding: 0;
  border: 1px solid rgba(154, 28, 32, 0.12);
  border-radius: 50%;
  background: #fff;
  color: var(--text-body);
  box-shadow: 0 -2px 10px rgba(40, 6, 9, 0.14), 0 4px 12px rgba(40, 6, 9, 0.2), 0 1px 3px rgba(40, 6, 9, 0.16);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.9);
  transition: opacity 200ms ease, transform 200ms ease, visibility 0s linear 200ms;
  -webkit-tap-highlight-color: transparent;
}

.back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 200ms ease, transform 200ms ease, visibility 0s;
}

.back-to-top:focus-visible {
  outline: 2px solid var(--brand-red);
  outline-offset: 3px;
}

:root[data-theme="dark"] .back-to-top {
  border-color: rgba(255, 255, 255, 0.1);
  background: #1e1517;
  color: rgba(255, 255, 255, 0.88);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.45), 0 4px 14px rgba(0, 0, 0, 0.55), 0 1px 3px rgba(0, 0, 0, 0.45);
}

.back-to-top svg {
  width: 22px;
  height: 22px;
}

/* (Lifted above the footer here too, like the desktop's: otherwise, at the
   page's bottom, it lies on the footer's theme switch.) */

@media (prefers-reduced-motion: reduce) {
  .back-to-top,
  .back-to-top.is-visible {
    transform: none;
    transition: none;
  }
}

/* An archetype badge as a card's title (Archetipi): its own size, not
   stretched across .history-main's column like a text line. */
.history-main > .badge-archetype {
  align-self: flex-start;
}

/* Two parts on one line at every width: the name (+ deck) | the archetype. */
.history-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

/* archetype.html's "Contro gli altri archetipi" (js/archetype-detail.js
   vsChartHtml): a diverging bar chart — per other archetype, its badge, a
   track with the 50% axis marked in the middle and a bar from it (right and
   green: it wins more often than not; left and red: it loses more; a short
   yellow tick: even), then the winrate over the number of matches. Each
   row a link to that archetype's page. The bars grow out of the axis.
   Fixed win / loss / even colours — the losing side stays red on the
   page's hero-coloured accent (not --brand-red, which it redefines). */
.vs-chart {
  --vs-label-w: 96px;
  --vs-value-w: 78px;
  --vs-win: #1fa45a;
  --vs-loss: #dc181c;
  --vs-even: #f5b300;
  --vs-win-text: #0e6e37;
  --vs-loss-text: #8d1d22;
  --vs-even-text: #7d5300;
  --vs-track-loss: rgba(220, 24, 28, 0.09);
  --vs-track-win: rgba(31, 164, 90, 0.11);
  padding: 12px;
}

:root[data-theme="dark"] .vs-chart {
  --vs-win: #4fdc8c;
  --vs-loss: #ff5a5f;
  --vs-even: #ffcc33;
  --vs-win-text: #7cf0ae;
  --vs-loss-text: #ff9a9d;
  --vs-even-text: #ffe07a;
  --vs-track-loss: rgba(255, 90, 95, 0.13);
  --vs-track-win: rgba(79, 220, 140, 0.13);
}

.vs-rows {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.vs-row {
  display: grid;
  grid-template-columns: var(--vs-label-w) minmax(0, 1fr) var(--vs-value-w);
  align-items: center;
  gap: 14px;
  padding: 8px;
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
  transition: background 150ms ease;
}

.vs-row:hover {
  background: rgba(220, 24, 28, 0.06);
  text-decoration: none;
}

:root[data-theme="dark"] .vs-row:hover {
  background: rgba(255, 255, 255, 0.06);
}

.vs-row:focus-visible {
  outline: 2px solid var(--brand-red);
  outline-offset: -2px;
}

/* The track in two halves, no axis line: the losing half (left) faintly
   red, the winning half (right) faintly green, meeting at 50% — the bars
   fill out from that edge in the stronger colour of their half. */
.vs-track {
  position: relative;
  height: 14px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--vs-track-loss) 50%, var(--vs-track-win) 50%);
}

.vs-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  width: var(--vs-len);
  animation: vs-grow 700ms cubic-bezier(0.2, 0.8, 0.2, 1) 150ms both;
}

.vs-bar.is-win {
  left: 50%;
  border-radius: 0 var(--radius-pill) var(--radius-pill) 0;
  background: var(--vs-win);
  transform-origin: left center;
}

.vs-bar.is-loss {
  right: 50%;
  border-radius: var(--radius-pill) 0 0 var(--radius-pill);
  background: var(--vs-loss);
  transform-origin: right center;
}

.vs-bar.is-even {
  left: 50%;
  width: 6px;
  margin-left: -3px;
  border-radius: 3px;
  background: var(--vs-even);
}

@keyframes vs-grow {
  from {
    transform: scaleX(0);
  }
}

.vs-value {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.vs-value strong {
  color: var(--text-title);
  font-size: 1.05rem;
  font-weight: 800;
}

.vs-value.is-win strong {
  color: var(--vs-win-text);
}

.vs-value.is-loss strong {
  color: var(--vs-loss-text);
}

.vs-value.is-even strong {
  color: var(--vs-even-text);
}

.vs-value small {
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
}

/* 0% / 50% / 100% under the tracks, lined up with them. */
.vs-axis {
  display: flex;
  justify-content: space-between;
  margin: 2px calc(var(--vs-value-w) + 22px) 0 calc(var(--vs-label-w) + 22px);
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 700;
}

@media (max-width: 640px) {
  .vs-chart {
    --vs-label-w: 78px;
    --vs-value-w: 62px;
    padding: 8px;
  }

  .vs-row {
    gap: 10px;
  }

  .vs-axis {
    margin: 2px calc(var(--vs-value-w) + 18px) 0 calc(var(--vs-label-w) + 18px);
  }
}

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

/* The position chip, then the name (Classifica). */
.history-lead {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

/* Partite: each round's matches as a grid of small cards (two side by side
   on desktop) — Giocatore 1 · score · Giocatore 2, the winner in bold. */
.event-match-grid .history-scroll {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.event-match {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

/* Each side: the name, its deck under it (.history-deck, as in Giocatori,
   without the pips; in its normal weight even for the winner) — each on one
   line, cut with "…" when too long. */
.event-match-player {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  color: var(--text-muted-2);
  font-weight: 600;
}

.event-match-player:last-child {
  text-align: right;
}

.event-match-name,
.event-match-player .history-deck {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.event-match-player .history-deck {
  font-weight: 400;
}

.event-match-player.is-winner {
  color: var(--text-title);
  font-weight: 800;
}

.event-match-player a:hover {
  color: var(--brand-red-deep);
  text-decoration: none;
}

.event-match-score {
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: rgba(220, 24, 28, 0.1);
  color: var(--brand-red-deep);
  font-size: 0.85rem;
  font-weight: 800;
  white-space: nowrap;
}

.event-match-score.is-special {
  background: rgba(111, 90, 94, 0.12);
  color: var(--text-muted-2);
}

:root[data-theme="dark"] .event-match-score {
  background: rgba(255, 110, 110, 0.14);
}

:root[data-theme="dark"] .event-match-score.is-special {
  background: rgba(255, 255, 255, 0.08);
}

/* A hero-coloured event page (main.has-hero-accent): the score chips' tint
   in its colour (the text already is — --brand-red-deep). */
main.has-hero-accent .event-match-score:not(.is-special) {
  background: color-mix(in srgb, var(--hero-accent) 12%, transparent);
}

:root[data-theme="dark"] main.has-hero-accent .event-match-score:not(.is-special) {
  background: color-mix(in srgb, var(--hero-accent-light) 16%, transparent);
}

/* league.html's Classifica: the top 8 (js/league-detail.js
   LEAGUE_TOP_HIGHLIGHT) with a faint red tint — no edge on the left ("Tu",
   below, still wins the tint). */
.history-item.is-top8 {
  background: rgba(220, 24, 28, 0.085);
}

a.history-item.is-top8:hover {
  background: rgba(220, 24, 28, 0.12);
}

/* Redrawn on every keystroke of a search box: no entrance replay. */
.history-panel.no-entrance-anim {
  animation: none;
}

/* As tall as its content, never scrolling (the Comandanti / Giocatori
   pages' lists). */
.history-panel.no-scroll .history-scroll {
  max-height: none;
  overflow: visible;
  -webkit-mask-image: none;
  mask-image: none;
}

/* "Tu" (js/me-highlight.js): the signed-in account's own player's card,
   tinted like its table rows. */
.history-item.is-me-row {
  border-color: rgba(154, 28, 32, 0.22);
  background: rgba(220, 24, 28, 0.12);
}

a.history-item.is-me-row:hover {
  border-color: rgba(154, 28, 32, 0.3);
  background: rgba(220, 24, 28, 0.16);
}

/* One sub-card per event, its rounds as rows. On top: event + deck on the
   left, the final position's chip on the right (filled red for 1st). */
.history-match-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--table-row-line);
}

.history-pos {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 6px;
  box-sizing: border-box;
  border-radius: var(--radius-pill);
  background: rgba(220, 24, 28, 0.14);
  color: var(--brand-red-deep);
  font-size: 0.85rem;
  font-weight: 800;
}

.history-pos.is-first {
  background: var(--brand-red);
  color: #fff;
}

/* League standings (league.html, the Bacheca) while the league runs: the
   change since its latest event as a small badge on the position chip's
   bottom-right corner, like a notification count (js/history-list.js
   leaguePosHtml) — solid, the trend arrows' icons (.wr-trend's): ↗ N green,
   ↘ N red, → grey unchanged, + grey for a newcomer. One fixed size whatever
   it holds, so every row's badge is the same. Instead of a ring in the
   card's colour (the rows have many: top 8, "Tu", hover, the hero's tints)
   the chip is cut out round it — a 2px gap the row shows through (a mask:
   the badge's pill shape, 2px larger, subtracted; the badge is the chip's
   sibling, or the mask would cut it too). The chip keeps its width, so the
   names line up; pushed off the name by the badge's overhang. Fixed green /
   red, never the hero's colour. */
.pos-with-change {
  position: relative;
  display: inline-flex;
  flex: none;
  margin-right: 20px;
}

.history-pos.has-change {
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='36' height='21'%3E%3Crect width='36' height='21' rx='10.5'/%3E%3C/svg%3E") right -21px bottom -4px / 36px 21px no-repeat, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='36' height='21'%3E%3Crect width='36' height='21' rx='10.5'/%3E%3C/svg%3E") right -21px bottom -4px / 36px 21px no-repeat, linear-gradient(#000 0 0);
  mask-composite: exclude;
}

.pos-badge {
  --trend: var(--text-muted);
  position: absolute;
  right: -19px;
  bottom: -2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: 32px;
  height: 17px;
  border-radius: var(--radius-pill);
  background: var(--trend);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.pos-badge svg {
  flex: none;
  width: 9px;
  height: 9px;
}

.pos-badge.is-up {
  --trend: #1a9a5c;
}

.pos-badge.is-down {
  --trend: #dc181c;
}

:root[data-theme="dark"] .pos-badge {
  color: #1a1214;
}

:root[data-theme="dark"] .pos-badge.is-up {
  --trend: #4cd38f;
}

:root[data-theme="dark"] .pos-badge.is-down {
  --trend: #ff6b6e;
}

.history-match-head .history-deck {
  margin-top: 4px;
}

.history-rounds {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history-round {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}

.history-round + .history-round {
  border-top: 1px solid var(--table-row-line);
}

.history-round:last-child {
  padding-bottom: 0;
}

.history-round-no {
  min-width: 22px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.history-opp-name {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.history-round .history-deck {
  font-size: 0.82rem;
}

/* The round's score, coloured by its outcome (no separate result icon). */
.history-score {
  font-weight: 800;
  color: var(--text-value);
}

.history-score.is-win {
  color: var(--accent-green-2);
}

.history-score.is-loss {
  color: var(--brand-red-deep);
}

.history-score.is-draw,
.history-score.is-drop {
  color: var(--text-muted);
}

/* Compact round Modifica/Elimina buttons for admin list rows — an SVG icon
   (see EDIT_ICON_SVG/DELETE_ICON_SVG in admin/js/crud-ui.js) instead of a
   labeled pill, since a row can otherwise get crowded once it also has a
   status toggle and a "Gestisci" button. Elimina is filled red-on-red from
   the start (not just on hover) so its destructive weight reads at a
   glance, same reasoning .btn-primary is solid brand-red while
   .btn-secondary stays an outline. */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.icon-btn:hover {
  transform: translateY(-1px);
}

.icon-btn-edit {
  color: var(--brand-red-deep);
  background: #fff;
  border-color: var(--hairline);
}

.icon-btn-edit:hover {
  background: #fff7f4;
  border-color: var(--hairline-hover-strong);
}

/* No resting box-shadow — a table row's own border-bottom sits right below
   the row's normal content height, and a shadow reaching past that (like
   this button briefly had) visually bled across the divider line into the
   next row, making it look bent/misaligned right where these buttons sit. */
.icon-btn-delete {
  color: #fff;
  background: #c8362b;
}

.icon-btn-delete:hover {
  background: #b3261e;
  box-shadow: 0 3px 8px rgba(179, 38, 30, 0.32);
}

/* Forms (public filters + admin CRUD) */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

/* .field's own `display: flex` above has the same specificity as the
   browser's default `[hidden] { display: none; }` rule, and — being an
   author rule — wins the tie regardless of source order, so a plain
   `hidden` attribute silently does nothing on a .field element without
   this. Higher-specificity rule needed to actually make it work. */
.field[hidden] {
  display: none;
}

.field label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.checkbox-field {
  margin-bottom: 14px;
}

.checkbox-field-row {
  display: flex;
  gap: 20px;
  margin-bottom: 14px;
}

.checkbox-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-body);
  cursor: pointer;
}

/* .checkbox-inline's own display:flex above beats the browser's default
   [hidden] { display: none; } rule at equal specificity (author rules win
   ties regardless of source order) — without this, a plain `hidden`
   attribute silently does nothing (same bug pattern as .field[hidden]
   above). */
.checkbox-inline[hidden] {
  display: none;
}

.checkbox-inline input {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: var(--brand-red);
}

.field input,
.field select,
.field textarea,
.cs-trigger {
  font: inherit;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--hairline);
  background: #fff;
  color: var(--text-body);
}

/* Search boxes (admin list filters) sit outside .admin-form-card/.card, so
   they don't get either one's own entrance animation for free — give them
   their own. Excludes #site-search-input: that's the header's site-wide
   search box on every public page (desktop pill and mobile overlay alike),
   which shouldn't play a generic fade-up on load — desktop has no entrance
   chrome around it at all, and mobile already has its own dedicated
   search-content-in animation on .site-search-field (below), which this
   would otherwise double up on. */
input[type="search"]:not(#site-search-input) {
  animation: entrance-fade-up 380ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.cs-trigger:focus-visible {
  outline: none;
  border-color: var(--hairline-hover-strong);
}

/* Custom-styled <select>: the native element stays in the DOM (hidden) as
   the single source of truth for .value/change/options (see
   js/custom-select.js) — this is purely the skin around it, a trigger
   button + popup list matching the site's rounded/card language, since no
   browser lets you reliably restyle the *native* popup itself. */

.cs-native {
  display: none;
}

/* No entrance animation here (removed — it kept skipping its own "from"
frame in a way that wasn't worth chasing further). */
.cs-wrap {
  position: relative;
  display: block;
  width: 100%;
}

/* Only promoted to its own stacking context while actually open — giving
   every closed trigger a permanent z-index made it paint in front of the
   sticky nav/admin-tabs bar (z-index 20) whenever it scrolled near/under
   it, which looked broken. Scoped to .is-open, it only needs to outrank
   anything else when the popup itself is showing (e.g. a later sibling
   like a data table that ends up in its own stacking context) — matches
   .cs-menu's own z-index so the whole wrapper is capped consistently. */
.cs-wrap.is-open {
  z-index: 30;
}

.cs-trigger {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  /* Not space-between: with no icon, that empty .cs-trigger-icon span still
     counts as a flex item, so the leftover space gets split before AND
     after the label — pushing it away from the left edge instead of
     leaving it flush. margin-left: auto on the arrow (below) pushes just
     that to the right instead, so icon+label always sit naturally at the
     start. */
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  appearance: none;
  cursor: pointer;
  text-align: left;
  transition: border-color 180ms ease;
}

.cs-trigger-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.cs-trigger-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.cs-trigger-arrow {
  flex-shrink: 0;
  margin-left: auto;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--brand-red);
  transition: transform 180ms ease;
}

.cs-wrap.is-open .cs-trigger-arrow {
  transform: rotate(180deg);
}

.cs-wrap.is-disabled .cs-trigger {
  opacity: 0.55;
  cursor: not-allowed;
}

.cs-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0;
  /* At least as wide as the trigger, but free to grow beyond it (capped)
     for options with a long two-line label (see .cs-option-label) that
     wouldn't otherwise fit inside a narrow field's own width. */
  min-width: 100%;
  width: max-content;
  max-width: min(360px, 90vw);
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-card-hover);
  padding: 6px;
  display: none;
}

.cs-wrap.is-open .cs-menu {
  display: block;
  animation: cs-menu-in 140ms ease both;
}

/* Set by js/custom-select.js when there isn't enough room below the
   trigger in the current viewport — anchors the menu above it instead,
   same mechanism as .cd-wrap.cd-open-upward for the date popup. */
.cs-wrap.cs-open-upward .cs-menu {
  top: auto;
  bottom: calc(100% + 6px);
}

/* Set by js/custom-select.js when the menu, wider than its trigger, would
   pass the screen's right edge: lined up with the trigger's right edge. */
.cs-wrap.cs-align-right .cs-menu {
  left: auto;
  right: 0;
}

@keyframes cs-menu-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.cs-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text-body);
}

/* An option can carry a data-icon (e.g. a custom-uploaded badge image) —
   shown here and in the closed trigger's own label (.cs-trigger-label). A
   flex container centers it reliably; vertical-align doesn't line up an
   <img> the same way it does inline text. */
.cs-option-icon {
  width: 1.1em;
  height: 1.1em;
  flex-shrink: 0;
}

/* An option can instead carry a data-label/data-sublabel pair (e.g. the
   event filter's own "event name" + "league name") for a two-line row —
   same "bold name, muted smaller line below" convention as event rows
   elsewhere on the site. */
.cs-option-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.cs-option-label,
.cs-option-sublabel {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cs-option-label {
  font-weight: 700;
  font-size: 0.85rem;
}

.cs-option-sublabel {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

img.cs-option-icon {
  object-fit: contain;
  border-radius: 3px;
}

/* An emoji left as plain inline text sits wherever the font's own glyph
   metrics happen to place it — flex-centering it inside a box the same
   size as the image icon above gives both the same vertical anchor. */
.cs-option-icon-text {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.cs-option:hover,
.cs-option:focus {
  outline: none;
  background: var(--hairline-hover);
}

/* data-searchable selects (js/custom-select.js): the menu becomes a column
   — the search field fixed at the top, only the option list below it
   scrolling, so the field never scrolls out of view. */
.cs-wrap.is-open .cs-menu.cs-menu-searchable {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cs-search {
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 6px;
  padding: 8px 12px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: #fff;
  color: var(--text-body);
  font: inherit;
  font-size: 0.92rem;
}

.cs-search:focus {
  outline: none;
  border-color: var(--hairline-hover-strong);
}

.cs-options {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

/* .cs-option's display: flex would otherwise override the hidden attribute
   the search filter sets on non-matching options. */
.cs-option[hidden] {
  display: none;
}

.cs-empty {
  padding: 9px 12px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-style: italic;
}

:root[data-theme="dark"] .cs-search {
  background: rgba(255, 255, 255, 0.06);
}

.cs-option[aria-selected="true"] {
  background: var(--brand-red);
  color: #fff;
}

/* Custom-styled <input type="date">: unlike <select>, no browser exposes
   any CSS hook into the native calendar popup at all, so this fully
   replaces it with a month-grid built in js/custom-date.js — same contract
   as the select skin above, the native input stays hidden as the source of
   truth for .value/change. */

.cd-native {
  display: none;
}

.cd-wrap {
  position: relative;
  display: block;
  width: 100%;
}

/* Same stacking fix as .cs-wrap.is-open above, scoped the same way —
   only promoted while the calendar popup is actually showing, so a closed
   date field doesn't paint in front of the sticky nav/admin-tabs bar. */
.cd-wrap.is-open {
  z-index: 30;
}

.cd-trigger {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--hairline);
  background: #fff;
  color: var(--text-body);
  appearance: none;
  cursor: pointer;
  text-align: left;
  transition: border-color 180ms ease;
}

.cd-trigger:focus-visible {
  outline: none;
  border-color: var(--hairline-hover-strong);
}

.cd-trigger-label.is-placeholder {
  color: var(--text-muted);
}

.cd-trigger-arrow {
  flex-shrink: 0;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--brand-red);
  transition: transform 180ms ease;
}

.cd-wrap.is-open .cd-trigger-arrow {
  transform: rotate(180deg);
}

.cd-wrap.is-disabled .cd-trigger {
  opacity: 0.55;
  cursor: not-allowed;
}

.cd-popup {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0;
  width: 268px;
  border: 1px solid var(--hairline);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow-card-hover);
  padding: 12px;
  display: none;
}

.cd-wrap.is-open .cd-popup {
  display: block;
  animation: cd-popup-in 140ms ease both;
}

/* Set by js/custom-date.js when there isn't enough room below the trigger
   in the current viewport — anchors the popup above it instead. */
.cd-wrap.cd-open-upward .cd-popup {
  top: auto;
  bottom: calc(100% + 6px);
}

@keyframes cd-popup-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.cd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.cd-month-label {
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--text-title);
  text-transform: capitalize;
}

.cd-nav {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: #fff;
  color: var(--brand-red-darker);
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
}

.cd-nav:hover {
  background: #fff7f4;
  border-color: var(--hairline-hover);
}

.cd-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 4px;
}

.cd-weekdays span {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.cd-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cd-day {
  aspect-ratio: 1;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-body);
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}

.cd-day:hover,
.cd-day:focus {
  outline: none;
  background: var(--hairline-hover);
}

.cd-day.is-outside {
  color: var(--text-muted);
  opacity: 0.55;
}

.cd-day.is-today {
  font-weight: 800;
  color: var(--brand-red);
}

.cd-day.is-selected {
  background: var(--brand-red);
  color: #fff;
  font-weight: 800;
}

.cd-day.is-selected.is-today {
  color: #fff;
}

.cd-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--hairline);
}

.cd-footer-btn {
  flex: 1;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  background: #fff;
  color: var(--brand-red-deep);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 7px 10px;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
}

.cd-footer-btn:hover {
  background: #fff7f4;
  border-color: var(--hairline-hover);
}

/* Commander color-identity picker: a round WUBRG-colored swatch per option
   instead of a checkbox + color name, sized as a comfortable touch target. */

.color-swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Admin's commander form (the non-compact row): all six swatches (WUBRG +
   colorless) always on one line — each shrinks evenly from its 38px when
   the form is too narrow for the full size, staying round (aspect-ratio),
   rather than one or two wrapping onto a second line. */
.color-swatch-row:not(.color-swatch-row-compact) {
  flex-wrap: nowrap;
  gap: 6px;
}

.color-swatch-row:not(.color-swatch-row-compact) > .color-swatch {
  flex: 0 1 38px;
  width: auto;
  height: auto;
  min-width: 0;
  aspect-ratio: 1;
}

.color-swatch {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.15);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}

.color-swatch:hover {
  transform: translateY(-2px);
}

.color-swatch input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.color-swatch:has(input:checked) {
  border-color: var(--brand-red);
  box-shadow: 0 0 0 3px rgba(220, 24, 28, 0.25);
  transform: scale(1.08);
}


/* Smaller variant so a 5-color filter row fits on the same line as the
   other filter fields instead of the full-size 38px picker used for
   actually editing a commander's color identity in admin. */
.color-swatch-row-compact {
  gap: 6px;
}

.color-swatch-row-compact .color-swatch {
  width: 26px;
  height: 26px;
  border-width: 1px;
}

#badges-admin-icon-preview img {
  display: block;
  width: 44px;
  height: 44px;
  object-fit: contain;
  margin-top: 10px;
  border-radius: 12px;
  border: 2px solid var(--hairline);
  background: #fff;
}

/* The file input's own "Scegli file" part is a browser-rendered button
   pseudo-element (::file-selector-button, ::-webkit-file-upload-button for
   older WebKit) — styled to match .btn-secondary. The input's own box is
   left bare (no border/background/padding) so only that pill button shows;
   without a width cap it'd also size itself to fit the button plus the
   browser's own "Nessun file selezionato" filename text and overflow the
   form card sideways, so both a width cap and (since that text can't be
   removed from the DOM — the browser draws it as part of the control)
   color: transparent are needed too. The button keeps its own color below
   since ::file-selector-button is a separate box color:transparent here
   doesn't reach. */
#badges-admin-icon-file {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  font: inherit;
  border: none;
  background: none;
  padding: 0;
  color: transparent;
  cursor: pointer;
}

#badges-admin-icon-file::file-selector-button,
#badges-admin-icon-file::-webkit-file-upload-button {
  font: inherit;
  font-weight: 800;
  padding: 0 14px;
  height: 36px;
  margin-right: 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--hairline);
  background: #fff;
  color: var(--brand-red-deep);
  cursor: pointer;
  transition: background 180ms ease, border-color 180ms ease;
}

#badges-admin-icon-file:hover::file-selector-button,
#badges-admin-icon-file:hover::-webkit-file-upload-button {
  background: #fff7f4;
  border-color: var(--hairline-hover);
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

/* A form's result line (admin forms, account.html) — js sets is-error /
   is-ok, or clears the text. */
.form-message {
  min-height: 20px;
  font-weight: 700;
  font-size: 0.85rem;
  margin-top: 4px;
}

.form-message.is-error {
  color: #b3261e;
}

.form-message.is-ok {
  color: var(--accent-green-2);
}

/* account.html ("Profilo") — js/account-page.js shows one [data-view] at a
   time: signed out, the narrow "Accedi" card; signed in, the profile. */
.account-card {
  max-width: 420px;
}

.account-card h2 {
  margin: 0 0 6px;
  font-size: 1.2rem;
  color: var(--text-title);
}

.account-hint {
  margin: 0 0 18px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.profile-card a {
  color: var(--brand-red-deep);
  font-weight: 800;
}

.profile-card h3 {
  margin: 0 0 14px;
  font-size: 1.1rem;
  color: var(--text-title);
}

/* overflow-wrap: a long email in the Account card wraps instead of
   overflowing on a phone. */
.profile-card p {
  margin: 0 0 12px;
  overflow-wrap: anywhere;
}

/* "Il tuo giocatore" while the account isn't linked yet: at the top of the
   page, tinted in the brand red as an invitation to claim the player first. */
.card.profile-claim {
  border-color: rgba(220, 24, 28, 0.35);
  background: linear-gradient(135deg, rgba(220, 24, 28, 0.08), rgba(255, 255, 255, 0.9) 60%);
}

/* Its entrance animation makes the card a stacking context (gotcha #10), so
   the player list's dropdown painted under the player card and the Account
   card below it. Lifted above them while the list is open. */
.card.profile-claim:has(.cs-wrap.is-open) {
  position: relative;
  z-index: 30;
}
