:root {
  --bg: #0f1218;
  --surface: #171c26;
  --text: #e8eaef;
  --muted: #8b93a7;
  --accent: #6ea8fe;
  --border: #2a3142;
  --font: "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.site-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 200;
}

.site-header-top {
  display: contents;
}

.site-header-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0.35rem;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}

.site-header-menu-btn:hover {
  border-color: var(--muted);
  color: var(--accent);
}

.site-header-menu-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.site-header-menu-icon {
  display: block;
}

.site-header-start {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-left: auto;
}

@media (max-width: 52rem) {
  .site-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.65rem 1rem 0.75rem;
  }

  .site-header-top {
    display: flex;
    align-items: center;
    gap: 0.5rem 0.65rem;
    width: 100%;
  }

  .site-header-menu-btn {
    display: inline-flex;
    margin-left: auto;
  }

  .site-header-season ~ .site-header-menu-btn {
    margin-left: 0;
  }

  .brand {
    font-size: 0.95rem;
    min-width: 0;
  }

  .brand-title {
    display: none;
  }

  .site-header-season {
    flex: 1 1 auto;
    min-width: 0;
    align-self: center;
  }

  .site-header .season-picker-wrap {
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  .site-header .season-picker-select {
    min-width: 0;
    width: 100%;
  }

  .header-updated--under-season {
    max-width: none;
  }

  .site-nav {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin-left: 0;
    margin-top: 0.65rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--border);
  }

  .site-header--nav-open .site-nav {
    display: flex;
  }

  .site-nav a {
    padding: 0.55rem 0;
    font-size: 1rem;
    border-radius: 4px;
  }

  .site-nav a:active {
    background: rgba(110, 168, 254, 0.08);
  }
}

@media (min-width: 52.0625rem) {
  .site-header-menu-btn {
    display: none !important;
  }
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
}

.site-nav a:hover {
  color: var(--accent);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
  min-width: 0;
  max-width: 100%;
}

.brand:hover {
  color: var(--accent);
}

.brand-logo {
  width: 2.35rem;
  height: 2.35rem;
  flex-shrink: 0;
  object-fit: contain;
  display: block;
}

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

.header-updated {
  color: var(--muted);
}

.header-updated--under-season {
  font-size: 0.62rem;
  line-height: 1.25;
  color: var(--muted);
  opacity: 0.88;
  max-width: 11.5rem;
}

.tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

.main {
  padding: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
}

.main:has(.home-layout) {
  max-width: 1320px;
}

/* Leaderboard home: primary column + optional right sidebar (info boxes) */
.home-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(13.5rem, 17.5rem);
  gap: 1.25rem 1.5rem;
  align-items: start;
}

.home-layout--main-only {
  grid-template-columns: minmax(0, 1fr);
}

.home-layout__main {
  min-width: 0;
}

.home-layout__aside {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

@media (min-width: 60rem) {
  /* Sit below sticky .site-header; --site-header-sticky-offset set by site-header.js */
  .home-layout__aside {
    position: sticky;
    top: calc(var(--site-header-sticky-offset, 5.75rem) + 0.35rem);
  }
}

@media (max-width: 52rem) {
  .home-layout:not(.home-layout--main-only) {
    grid-template-columns: 1fr;
  }

  .home-layout__aside {
    position: static;
    order: -1;
  }
}

.info-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 0.75rem 0.85rem;
}

.info-box__title {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 0.55rem;
}

/* Long-form explainer (how Elo works) */
.explain {
  max-width: 42rem;
}

.explain h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 1.75rem 0 0.5rem;
  color: var(--text);
}

.explain h2:first-of-type {
  margin-top: 1.25rem;
}

.explain-subhead {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.25rem 0 0.5rem;
  color: var(--text);
}

.explain-table {
  margin: 0.35rem 0 1.25rem;
  max-width: 36rem;
}

table.store-locator-table {
  min-width: 14rem;
}

table.store-locator-table th.store-locator-events-col,
table.store-locator-table td.store-locator-events-col {
  width: 5.5rem;
  white-space: nowrap;
}

table.skip-ids-table {
  max-width: 22rem;
}

table.skip-ids-table td {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88rem;
}

.explain-table-wide {
  max-width: min(52rem, 100%);
}

table.skip-detail-table td.tabular {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88rem;
  white-space: nowrap;
}

.explain p,
.explain li {
  color: var(--muted);
  font-size: 0.95rem;
}

.explain p {
  margin: 0 0 0.75rem;
}

.explain ul {
  margin: 0 0 0.75rem;
  padding-left: 1.25rem;
}

.explain li {
  margin-bottom: 0.35rem;
}

.explain strong {
  color: var(--text);
  font-weight: 600;
}

.formula-block {
  margin: 0.5rem 0 1rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text);
  overflow-x: auto;
}

.explain-note {
  font-size: 0.88rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.lede, .merged-note {
  color: var(--muted);
  margin: 0 0 1.25rem;
  max-width: 52rem;
}

.player-overview {
  margin: 0 0 1rem;
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(110, 168, 254, 0.06);
  max-width: 28rem;
}

.player-top-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  max-width: 52rem;
  width: 100%;
  gap: 0.65rem;
  margin: 0 0 1rem;
}

.player-dashboard-cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.65rem;
  align-items: start;
  width: 100%;
}

/* Left: Elo overview + chart stacked; right: win rates by legend only. */
.player-dashboard-main {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  align-items: stretch;
  min-width: 0;
}

.player-dashboard-main .elo-chart-panel-compact:not(.player-legend-panel) {
  margin: 0;
  width: 100%;
  max-width: none;
}

.player-legend-panel {
  min-width: 0;
}

.player-top-row .player-overview {
  margin: 0;
  max-width: none;
  width: 100%;
}

/* Same structure as .elo-chart-panel + .elo-chart-canvas-wrap, scaled down. */
.player-legend-panel .elo-chart-heading {
  font-size: 0.88rem;
  margin: 0 0 0.28rem;
}

.player-legend-panel__inner {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 0;
  /* Box height = rows only; no extra space below the last row. */
}

.player-legend-panel__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.3rem 0.6rem;
  align-items: center;
  box-sizing: border-box;
  min-height: 3.35rem;
  height: 3.35rem;
  padding: 1px 0.45rem;
  border-top: 1px solid var(--border);
  font-size: 0.76rem;
  line-height: 1.35;
  color: var(--muted);
}

.player-legend-panel__row:first-child {
  border-top: none;
}

.player-legend-panel__legend {
  min-width: 0;
  display: flex;
  align-items: center;
}

.player-legend-panel__legend .legend-icon-only {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  line-height: 0;
}

.player-legend-panel__legend .legend-icon-sm {
  width: 2.5rem;
  height: 2.5rem;
  display: block;
}

.player-legend-panel__metrics {
  display: flex;
  flex-wrap: nowrap;
  align-items: baseline;
  justify-content: flex-end;
  gap: 0.15rem 0.28rem;
  text-align: right;
  white-space: nowrap;
}

.player-legend-panel__metrics .player-stat-label {
  font-size: 0.58rem;
}

.player-legend-panel__empty {
  margin: 0;
  padding: 1px 0.45rem;
  box-sizing: border-box;
  min-height: 3.35rem;
  height: 3.35rem;
  display: flex;
  align-items: center;
  font-size: 0.76rem;
  line-height: 1.35;
}

.player-overview-elo {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 0.75rem;
}

.player-overview-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.player-overview-stats {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.35rem;
  font-size: 0.82rem;
  line-height: 1.35;
  color: var(--muted);
}

.player-overview-merged {
  margin-top: 0.55rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.5rem;
}

.player-overview-merged .player-overview-label {
  margin: 0;
}

.merged-ids-line {
  font-size: 0.68rem;
  line-height: 1.35;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.merged-ids-fallback {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.5rem;
}

.merged-ids-fallback .player-overview-label {
  margin: 0;
}

.event-deck-col {
  width: 14rem;
  min-width: 10.5rem;
}

.event-deck-cell {
  vertical-align: middle;
  overflow: visible;
}

.event-deck-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.legend-with-label {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  max-width: 6rem;
  text-align: center;
}

.legend-with-label--row .legend-name {
  max-width: 6.5rem;
}

.legend-name {
  font-size: 0.6rem;
  font-weight: 500;
  line-height: 1.15;
  color: var(--muted);
  max-width: 100%;
  overflow: hidden;
  word-break: break-word;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.legend-icon-sm {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  vertical-align: middle;
}

body.legend-picker-modal-open {
  overflow: hidden;
}

/* Avoid ghost “selection” at the trigger under the dimmed overlay (focus ring / tap highlight). */
body.legend-picker-modal-open .legend-picker-trigger {
  pointer-events: none;
  -webkit-tap-highlight-color: transparent;
}

body.legend-picker-modal-open .legend-picker-trigger:focus,
body.legend-picker-modal-open .legend-picker-trigger:focus-visible {
  outline: none;
  box-shadow: none;
}

.legend-picker-trigger {
  appearance: none;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  color: var(--muted);
  text-align: inherit;
  border-radius: 6px;
  max-width: 100%;
  -webkit-tap-highlight-color: transparent;
}

.legend-picker-trigger:hover {
  color: var(--text);
}

.legend-picker-trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.legend-picker-trigger__inner {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
}

.legend-picker-trigger--compact .legend-picker-trigger__inner {
  min-height: 2.5rem;
  min-width: 2.5rem;
  justify-content: center;
}

.legend-picker-none {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  min-height: 2.5rem;
  text-align: center;
}

/* Shared centered modal (all viewports) */
.legend-picker-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(0.75rem, env(safe-area-inset-top, 0px)) max(0.75rem, env(safe-area-inset-right, 0px))
    max(0.75rem, env(safe-area-inset-bottom, 0px)) max(0.75rem, env(safe-area-inset-left, 0px));
  box-sizing: border-box;
}

.legend-picker-modal[hidden] {
  display: none !important;
}

.legend-picker-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  -webkit-tap-highlight-color: transparent;
}

.legend-picker-modal__dialog {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(24rem, calc(100vw - 1.5rem));
  max-height: min(28rem, calc(100vh - 2rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
  background: var(--panel, #1a1d24);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, 0.45);
  overflow: hidden;
  box-sizing: border-box;
}

.legend-picker-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.legend-picker-modal__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.legend-picker-modal__close {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.legend-picker-modal__close:hover {
  background: rgba(255, 255, 255, 0.12);
}

.legend-picker-modal__close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.legend-picker-modal__body {
  padding: 0.65rem 0.75rem 0.85rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.legend-picker-modal__clear {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.38rem;
  width: 100%;
  margin: 0 0 0.5rem;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  border: 1px dashed rgba(255, 255, 255, 0.38);
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
}

.legend-picker-modal__clear:hover {
  border-color: rgba(255, 180, 160, 0.55);
  background: rgba(255, 120, 100, 0.12);
}

.legend-picker-modal__clear:focus-visible {
  outline: 2px solid rgba(100, 180, 255, 0.75);
  outline-offset: 2px;
}

.legend-picker-modal__clear-icon {
  position: relative;
  flex-shrink: 0;
  width: 1.35rem;
  height: 1.35rem;
  box-sizing: border-box;
  border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, 0.45);
  background: rgba(0, 0, 0, 0.15);
}

.legend-picker-modal__clear-icon::before,
.legend-picker-modal__clear-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52%;
  height: 2px;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.72);
}

.legend-picker-modal__clear-icon::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.legend-picker-modal__clear-icon::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.legend-picker-modal__grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.28rem 0.2rem;
}

.legend-picker-modal__tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  margin: 0;
  padding: 0.25rem 0.1rem 0.2rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  min-width: 0;
  line-height: 1.1;
}

.legend-picker-modal__tile:hover {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.04);
}

.legend-picker-modal__choice.is-active {
  border-color: rgba(100, 180, 255, 0.65);
  background: rgba(100, 180, 255, 0.1);
}

.legend-picker-modal__tile-img {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.legend-picker-modal__tile-name {
  font-size: 0.58rem;
  font-weight: 500;
  color: var(--muted);
  margin-top: 0.12rem;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  word-break: break-word;
}

.deck-label,
.deck-unset {
  font-size: 0.72rem;
  color: var(--muted);
}

.player-stat {
  display: inline-flex;
  align-items: baseline;
  gap: 0.28rem;
}

.player-stat-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.85;
}

.player-stat-value.tabular,
.tabular {
  font-variant-numeric: tabular-nums;
}

.player-stat-sep {
  opacity: 0.35;
  user-select: none;
}

.current-elo-value {
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1.1;
}

/* —— Event overview (draft in-site bracket) —— */
.event-overview {
  max-width: 56rem;
}

/* Fixed layout: name | legend | vs | legend | name */
table.event-overview-table {
  table-layout: fixed;
  width: 100%;
}

table.event-overview-table th.event-overview-name-col,
table.event-overview-table td.event-overview-name-col {
  width: calc((100% - 4.25rem - 14rem) / 2);
  box-sizing: border-box;
  word-wrap: break-word;
  overflow-wrap: break-word;
  vertical-align: middle;
}

table.event-overview-table th.event-overview-name-col:nth-child(1),
table.event-overview-table td.event-overview-name-col:nth-child(1) {
  text-align: left;
}

table.event-overview-table th.event-overview-name-col:nth-child(5),
table.event-overview-table td.event-overview-name-col:nth-child(5) {
  text-align: right;
}

table.event-overview-table th.event-overview-legend-col,
table.event-overview-table td.event-overview-legend-col {
  width: 7rem;
  min-width: 6.25rem;
  max-width: 9rem;
  text-align: center;
  vertical-align: middle;
  padding-left: 0.4rem;
  padding-right: 0.4rem;
  overflow: visible;
}

table.event-overview-table thead th.event-overview-vs-col,
table.event-overview-table tbody td.event-overview-vs-col {
  width: 4.25rem;
}

table.event-overview-table .event-overview-legend-wrap {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

table.event-overview-table .event-overview-legend-col .legend-picker-trigger__inner {
  justify-content: center;
}

table.event-overview-table .event-overview-legend-col .legend-with-label {
  max-width: none;
}

table.event-overview-table .event-overview-legend-col .legend-picker-trigger {
  max-width: none;
}

table.event-overview-table .event-overview-legend-col img.legend-icon-sm {
  display: block;
  width: 2.5rem;
  height: 2.5rem;
  max-width: none;
  flex-shrink: 0;
}

.event-overview__title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  line-height: 1.2;
}

.event-overview__meta {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.5rem 1.25rem;
  margin: 0 0 0.75rem;
  padding: 0.75rem 0 0;
  border-top: 1px solid var(--border, rgba(255, 255, 255, 0.08));
}

.event-overview__meta div {
  margin: 0;
}

.event-overview__meta dt {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.65;
  margin: 0 0 0.15rem;
}

.event-overview__meta dd {
  margin: 0;
  font-size: 0.95rem;
}

.event-overview__stats {
  margin: 0 0 0.75rem;
}

.event-overview__external {
  margin: 0 0 1.5rem;
}

.event-overview__standings {
  margin: 0 0 1.75rem;
}

.event-overview__standings-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

table.event-standings-table {
  width: 100%;
  table-layout: auto;
}

table.event-standings-table th.event-standings-rank-col,
table.event-standings-table td.event-standings-rank-col {
  width: 2.5rem;
  text-align: right;
  padding-right: 0.55rem;
  padding-left: 0.15rem;
  border-right: 1px solid var(--border);
  vertical-align: middle;
}

table.event-standings-table td.event-standings-rank-col.event-standings-rank--gold {
  color: #e8c84a;
  font-weight: 700;
  text-shadow: 0 0 12px rgba(232, 200, 74, 0.22);
}

table.event-standings-table td.event-standings-rank-col.event-standings-rank--silver {
  color: #c9ced9;
  font-weight: 700;
  text-shadow: 0 0 10px rgba(201, 206, 217, 0.18);
}

table.event-standings-table td.event-standings-rank-col.event-standings-rank--bronze {
  color: #c9935a;
  font-weight: 700;
  text-shadow: 0 0 10px rgba(201, 147, 90, 0.2);
}

table.event-standings-table th.event-standings-player-col,
table.event-standings-table td.event-standings-player-col {
  text-align: left;
  min-width: 8rem;
  padding-left: 0.35rem;
  vertical-align: middle;
}

table.event-standings-table .event-standings-dropped {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.68rem;
  line-height: 1.15;
  color: var(--muted);
  text-transform: lowercase;
}

table.event-standings-table th.event-standings-num-col,
table.event-standings-table td.event-standings-num-col {
  text-align: right;
  white-space: nowrap;
  vertical-align: middle;
}

table.event-standings-table th.event-standings-record-col,
table.event-standings-table td.event-standings-record-col {
  text-align: right;
  white-space: nowrap;
  vertical-align: middle;
  padding-right: 1rem;
}

table.event-standings-table th.event-standings-pct-col,
table.event-standings-table td.event-standings-pct-col {
  text-align: right;
  white-space: nowrap;
  padding-left: 0.35rem;
  vertical-align: middle;
}

table.event-standings-table th.event-standings-legend-col,
table.event-standings-table td.event-standings-legend-col {
  width: 2.65rem;
  min-width: 2.35rem;
  max-width: 3rem;
  text-align: center;
  vertical-align: middle;
  padding-left: 0.72rem;
  padding-right: 0.55rem;
}

table.event-standings-table .event-standings-legend-col .event-overview-legend-wrap {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

table.event-standings-table .event-standings-legend-col .legend-picker-trigger__inner {
  justify-content: center;
}

table.event-standings-table .event-standings-legend-col .legend-with-label {
  max-width: none;
}

table.event-standings-table .event-standings-legend-col .legend-picker-trigger {
  max-width: none;
}

table.event-standings-table .event-standings-legend-col img.legend-icon-sm {
  display: block;
  width: 2.25rem;
  height: 2.25rem;
  max-width: none;
  flex-shrink: 0;
}

a.button-link {
  display: inline-block;
  padding: 0.45rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 0.35rem;
}

a.button-link:hover {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.event-overview__round {
  margin: 0 0 1.75rem;
}

.event-overview__round-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.event-overview-vs-col {
  text-align: center;
  vertical-align: middle;
  color: var(--muted, rgba(255, 255, 255, 0.45));
  padding-left: 0.35rem;
  padding-right: 0.35rem;
  background: transparent;
}

.event-overview-vs__word {
  display: block;
  font-size: 0.8rem;
  text-transform: lowercase;
  line-height: 1.2;
}

.event-overview-match-id {
  display: block;
  font-size: 0.6rem;
  margin-top: 0.35rem;
  line-height: 1.15;
}

/* Seat cells: same tints as match history (win / loss / tie) */
table.event-overview-table td.event-overview-seat--win {
  background: rgba(72, 191, 145, 0.2);
}

table.event-overview-table td.event-overview-seat--loss {
  background: rgba(224, 92, 121, 0.2);
}

table.event-overview-table td.event-overview-seat--tie {
  background: rgba(141, 151, 173, 0.2);
}

.back {
  margin: 0 0 0.75rem;
}

.back a {
  color: var(--accent);
  text-decoration: none;
}

.back a:hover {
  text-decoration: underline;
}

.elo-chart-panel {
  margin: 0 0 1.5rem;
  max-width: 52rem;
}

.elo-chart-panel-compact {
  margin: 0;
  width: 100%;
  max-width: none;
}

.elo-chart-heading {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
  color: var(--text);
}

.elo-chart-note {
  margin: 0 0 0.75rem !important;
}

.elo-chart-canvas-wrap {
  position: relative;
  height: min(16rem, 42vw);
  min-height: 11rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 0.35rem 0.25rem 0.15rem;
}

.elo-chart-canvas-wrap-compact {
  height: 9.5rem;
  min-height: 9.5rem;
}

.elo-chart-canvas-wrap canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* Sidebar “Recent events” (home page aside) */
.recent-events--sidebar .recent-events__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.recent-events--sidebar .recent-events__item {
  margin: 0;
  border-top: 1px solid var(--border);
}

.recent-events--sidebar .recent-events__item:first-child {
  border-top: none;
}

.recent-events--sidebar .recent-events__link {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  padding: 0.42rem 0.2rem;
  margin: 0 -0.2rem;
  border-radius: 4px;
  text-decoration: none;
  color: var(--text);
  transition: background 0.12s ease, color 0.12s ease;
}

.recent-events--sidebar .recent-events__link:hover {
  background: rgba(110, 168, 254, 0.08);
}

.recent-events--sidebar .recent-events__name {
  font-size: 0.84rem;
  font-weight: 500;
  line-height: 1.3;
}

.recent-events--sidebar .recent-events__link:hover .recent-events__name {
  color: var(--accent);
}

.recent-events--sidebar .recent-events__meta {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.3;
}

.season-picker-wrap {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0 0 1.1rem;
  flex-wrap: wrap;
}

.site-header-season {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.15rem;
  flex-shrink: 0;
  align-self: center;
  min-width: 0;
}

.site-header .season-picker-wrap {
  margin: 0;
  flex-shrink: 0;
  width: min(100%, 11.5rem);
}

.site-header .season-picker-select {
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.32rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  width: 100%;
  min-width: 9.25rem;
  max-width: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}

.site-header .season-picker-select:hover {
  border-color: var(--muted);
}

.site-header .season-picker-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(110, 168, 254, 0.22);
}

.season-picker-select {
  font: inherit;
  font-size: 0.92rem;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  max-width: 100%;
}

.leaderboard-view-shell {
  margin: 0;
  position: relative;
}

.leaderboard-view-shell__state {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/*
 * View switcher: full-width “toggle rail” with sliding accent thumb (radios + :has on shell).
 */
.leaderboard-view-shell__tabs {
  --view-pad: 6px;
  --view-gap: 8px;
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
  gap: var(--view-gap);
  width: 100%;
  margin: 0 0 1rem;
  padding: var(--view-pad);
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #141922;
  background: color-mix(in srgb, var(--surface) 48%, var(--bg));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 6px 24px rgba(0, 0, 0, 0.22);
}

.leaderboard-view-shell__tabs::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: var(--view-pad);
  bottom: var(--view-pad);
  left: var(--view-pad);
  width: calc((100% - 2 * var(--view-pad) - var(--view-gap)) / 2);
  border-radius: 10px;
  background: linear-gradient(
    165deg,
    rgba(110, 168, 254, 0.22) 0%,
    rgba(110, 168, 254, 0.07) 55%,
    rgba(110, 168, 254, 0.04) 100%
  );
  border: 1px solid rgba(110, 168, 254, 0.32);
  box-shadow:
    0 0 20px rgba(110, 168, 254, 0.12),
    0 3px 14px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition: transform 0.24s cubic-bezier(0.34, 1.22, 0.64, 1);
  pointer-events: none;
}

.leaderboard-view-shell:has(#leaderboard-main-legends:checked) .leaderboard-view-shell__tabs::before,
.leaderboard-view-shell:has(#event-main-rounds:checked) .leaderboard-view-shell__tabs::before,
.leaderboard-view-shell:has(#player-main-event:checked) .leaderboard-view-shell__tabs::before {
  transform: translateX(calc(100% + var(--view-gap)));
}

.leaderboard-view-shell__tab {
  cursor: pointer;
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 2.55rem;
  padding: 0.45rem 0.65rem;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 550;
  letter-spacing: 0.02em;
  user-select: none;
  text-decoration: none;
  transition: color 0.18s ease;
}

.leaderboard-view-shell__tab:hover {
  color: var(--text);
  color: color-mix(in srgb, var(--text) 82%, var(--muted));
}

.leaderboard-view-shell__tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  z-index: 2;
}

#leaderboard-main-standings:checked ~ .leaderboard-view-shell__tabs label:first-of-type,
#leaderboard-main-legends:checked ~ .leaderboard-view-shell__tabs label:last-of-type,
#event-main-standings:checked ~ .leaderboard-view-shell__tabs label:first-of-type,
#event-main-rounds:checked ~ .leaderboard-view-shell__tabs label:last-of-type,
#player-main-match:checked ~ .leaderboard-view-shell__tabs label:first-of-type,
#player-main-event:checked ~ .leaderboard-view-shell__tabs label:last-of-type {
  color: var(--text);
  font-weight: 650;
  text-shadow: 0 0 18px rgba(110, 168, 254, 0.18);
}

@media (prefers-reduced-motion: reduce) {
  .leaderboard-view-shell__tabs::before {
    transition: none;
  }
}

.leaderboard-view-shell__panel {
  display: none;
}

#leaderboard-main-standings:checked ~ .leaderboard-view-shell__panel--standings,
#event-main-standings:checked ~ .leaderboard-view-shell__panel--standings {
  display: block;
}

#leaderboard-main-legends:checked ~ .leaderboard-view-shell__panel--legends {
  display: block;
}

#event-main-rounds:checked ~ .leaderboard-view-shell__panel--event-rounds {
  display: block;
}

#player-main-match:checked ~ .leaderboard-view-shell__panel--player-dash-match,
#player-main-match:checked ~ .leaderboard-view-shell__panel--player-table-match,
#player-main-event:checked ~ .leaderboard-view-shell__panel--player-dash-event,
#player-main-event:checked ~ .leaderboard-view-shell__panel--player-table-event {
  display: block;
}

.leaderboard-legend-usage {
  margin: 0 0 1.5rem;
  max-width: 36rem;
}

.leaderboard-legend-usage--embedded {
  margin-bottom: 0;
  max-width: none;
}

.leaderboard-legend-usage__wrap {
  max-width: 100%;
}

.leaderboard-legend-usage-table th:first-child,
.leaderboard-legend-usage-table td.leaderboard-legend-usage-table__legend-cell {
  text-align: left;
}

.leaderboard-legend-usage__row {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.leaderboard-legend-usage__img {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.leaderboard-legend-usage__name {
  font-size: 0.9rem;
  font-weight: 500;
  min-width: 0;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.data th,
table.data td {
  padding: 0.55rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

table.data thead th {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

table.data tbody tr:last-child td {
  border-bottom: none;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Match + event history: three-column layout; context under primary / stack under Δ Elo */
table.history-compact tbody td {
  vertical-align: middle;
}

table.history-compact .cell-context {
  vertical-align: top;
  min-width: 12rem;
  max-width: 36rem;
}

/* Match history: wider opponent column; vertically center all cells (overrides .cell-context top). */
table.history-compact.history-match-table thead tr > th:first-child,
table.history-compact.history-match-table td.cell-context {
  min-width: 15rem;
  max-width: 30rem;
  width: auto;
  vertical-align: middle;
}

table.history-compact.history-match-table thead th,
table.history-compact.history-match-table tbody td {
  vertical-align: middle;
}

/* Legend columns: center header, cell, and icon/picker in column. */
table.history-compact.history-match-table th.event-deck-col,
table.history-compact.history-match-table td.event-deck-cell {
  text-align: center;
}

table.history-compact.history-match-table .event-deck-inline {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

table.history-compact.history-match-table th.event-deck-col {
  width: 7.5rem;
  min-width: 6.25rem;
  max-width: 9rem;
}

/* Narrowest column: outcome. */
table.history-compact.history-match-table .history-match-outcome-col {
  width: 0.01%;
  max-width: 4.75rem;
  padding-left: 0.4rem;
  padding-right: 0.4rem;
  text-align: center;
}

/* Δ Elo: override table.data td { text-align: left } */
table.data.history-compact.history-match-table th.history-match-elo-col,
table.data.history-compact.history-match-table td.history-match-elo-col {
  text-align: right;
}

.context-primary {
  font-size: 0.95rem;
  line-height: 1.3;
}

.match-meta {
  margin-top: 0.28rem;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--muted);
}

.match-meta-event a.event-locator {
  font-weight: 400;
}

table.history-compact .cell-outcome {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  vertical-align: middle;
}

table.history-compact.history-event-table th.history-event-elo-col,
table.history-compact.history-event-table td.history-event-elo-col {
  text-align: right;
  vertical-align: middle;
}

table.history-compact.history-event-table td.history-event-elo-col .elo-stack {
  align-items: flex-end;
}

table.history-compact.history-event-table th.history-event-place-col,
table.history-compact.history-event-table td.history-event-place-col {
  width: 2.85rem;
  text-align: right;
  padding-left: 0.5rem;
  padding-right: 1.1rem;
  vertical-align: middle;
}

table.history-compact.history-event-table td.history-event-place-col.event-standings-rank--gold {
  color: #e8c84a;
  font-weight: 700;
  text-shadow: 0 0 12px rgba(232, 200, 74, 0.22);
}

table.history-compact.history-event-table td.history-event-place-col.event-standings-rank--silver {
  color: #c9ced9;
  font-weight: 700;
  text-shadow: 0 0 10px rgba(201, 206, 217, 0.18);
}

table.history-compact.history-event-table td.history-event-place-col.event-standings-rank--bronze {
  color: #c9935a;
  font-weight: 700;
  text-shadow: 0 0 10px rgba(201, 147, 90, 0.2);
}

.cell-elo {
  vertical-align: middle;
  width: 6.5rem;
}

.elo-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 0.18rem;
}

.elo-delta-main {
  line-height: 1.1;
}

.elo-after {
  font-size: 0.72rem;
  line-height: 1.2;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  cursor: default;
}

/* R / M ids under rating (match history only) */
.compact-ids {
  display: inline-flex;
  align-items: baseline;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 0.35rem;
  font-size: 0.72rem;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--muted);
  user-select: text;
}

.compact-ids-stacked {
  margin-top: 0.1rem;
  font-size: 0.64rem;
  gap: 0.28rem;
}

.compact-ids .id-label {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.65;
  margin-right: 0.12rem;
}

.compact-ids .id-dot {
  opacity: 0.35;
  user-select: none;
  font-weight: 300;
}

.compact-ids .id-pair {
  white-space: nowrap;
  display: inline-flex;
  align-items: baseline;
}

table.data a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

table.data a:hover {
  text-decoration: underline;
}

/* Keep leaderboard geometry stable across filters/toggles.
   Column order: #, Player, Legends, Win%, G, W-L-T, Elo
   (narrow: Win%, G, W-L-T, and inline player id hidden) */
table.leaderboard-table {
  table-layout: fixed;
}

table.leaderboard-table thead th,
table.leaderboard-table tbody td {
  padding-top: 0.22rem;
  padding-bottom: 0.22rem;
  padding-left: 0.6rem;
  padding-right: 0.6rem;
  vertical-align: middle;
}

/* Icons 2.1rem + 2px border (~2.23rem); height includes vertical padding (border-box). */
table.leaderboard-table tbody td {
  height: 2.7rem;
  box-sizing: border-box;
}

table.leaderboard-table .col-rank {
  width: 3.25rem;
}

/* Stemless rank delta (▲/▼) after player id; colors share .elo-delta-* rules below. */
table.leaderboard-table .leaderboard-rank-move {
  display: inline-block;
  margin-left: 0.45em;
  font-size: 1em;
  line-height: 1;
  vertical-align: middle;
  font-weight: 600;
}

table.leaderboard-table .col-legends {
  width: 5.35rem;
  padding-left: 0.3rem;
  padding-right: 0.3rem;
  vertical-align: middle;
}

.leaderboard-legend-stack {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  position: relative;
  min-height: 2.1rem;
  height: 100%;
}

.leaderboard-legend-stack__img {
  /* 20% up from 1.75rem baseline */
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--surface);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
  /* Overlap grows left → right: each next icon tucks under the right edge of the previous. */
  margin-left: -0.78rem;
  flex-shrink: 0;
  position: relative;
}

.leaderboard-legend-stack__img:first-child {
  margin-left: 0;
}

/* Left = most-played (--depth-1) on top; icons to the right sit behind and read darker. */
.leaderboard-legend-stack__img--depth-1 {
  z-index: 3;
  filter: brightness(1);
}

.leaderboard-legend-stack__img--depth-2 {
  z-index: 2;
  filter: brightness(0.78);
}

.leaderboard-legend-stack__img--depth-3 {
  z-index: 1;
  filter: brightness(0.56);
}

.leaderboard-legend-stack--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  min-height: 2.1rem;
  text-align: center;
}

table.leaderboard-table .col-winpct {
  width: 5.25rem;
}

table.leaderboard-table .col-g {
  width: 3rem;
}

table.leaderboard-table .col-wlt {
  width: 5.75rem;
}

table.leaderboard-table .col-elo {
  width: 5.5rem;
}

table.leaderboard-table .col-player {
  width: auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Legend usage: match leaderboard-table row density, padding, and fixed layout */
table.leaderboard-legend-usage-table {
  table-layout: fixed;
}

table.leaderboard-legend-usage-table thead th,
table.leaderboard-legend-usage-table tbody td {
  padding-top: 0.22rem;
  padding-bottom: 0.22rem;
  padding-left: 0.6rem;
  padding-right: 0.6rem;
  vertical-align: middle;
}

table.leaderboard-legend-usage-table tbody td {
  height: 2.7rem;
  box-sizing: border-box;
}

table.leaderboard-legend-usage-table th:nth-child(2),
table.leaderboard-legend-usage-table td:nth-child(2) {
  width: 5.75rem;
}

table.leaderboard-legend-usage-table th:nth-child(3),
table.leaderboard-legend-usage-table td:nth-child(3) {
  width: 5.25rem;
}

table.leaderboard-legend-usage-table th:nth-child(4),
table.leaderboard-legend-usage-table td:nth-child(4) {
  width: 5.5rem;
}

/* Desktop: wrapper is transparent so name → id → ▲/▼ stay one inline run. */
table.leaderboard-table .leaderboard-player-cell {
  display: contents;
}

table.leaderboard-table .leaderboard-player-cell__main {
  display: inline;
}

@media (max-width: 42rem) {
  /* Legend usage: icon only in the first column (name stays in img alt / title). */
  .leaderboard-legend-usage__name {
    display: none;
  }

  table.leaderboard-table .col-winpct {
    display: none;
  }

  table.leaderboard-table .leaderboard-player-id {
    display: none;
  }

  table.leaderboard-table .col-g,
  table.leaderboard-table .col-wlt {
    display: none;
  }

  /* Event final standings: rank | legend | player | record on small screens; tiebreakers + Pts hidden. */
  table.event-standings-table th.event-standings-num-col,
  table.event-standings-table td.event-standings-num-col,
  table.event-standings-table th.event-standings-pct-col,
  table.event-standings-table td.event-standings-pct-col {
    display: none;
  }

  .event-overview__standings .table-wrap {
    overflow-x: visible;
  }

  table.event-standings-table {
    table-layout: fixed;
    width: 100%;
    max-width: 100%;
  }

  table.event-standings-table th,
  table.event-standings-table td {
    padding: 0.18rem 0.22rem;
  }

  table.event-standings-table th.event-standings-rank-col,
  table.event-standings-table td.event-standings-rank-col {
    width: 1.6rem;
    max-width: 1.6rem;
    padding-left: 0;
    padding-right: 0.32rem;
    border-right: 1px solid var(--border);
  }

  table.event-standings-table td.event-standings-rank-col.event-standings-rank--gold,
  table.event-standings-table td.event-standings-rank-col.event-standings-rank--silver,
  table.event-standings-table td.event-standings-rank-col.event-standings-rank--bronze {
    text-shadow: none;
  }

  table.event-standings-table th.event-standings-player-col,
  table.event-standings-table td.event-standings-player-col {
    min-width: 0;
    width: auto;
    padding-left: 0.28rem;
    word-break: break-word;
  }

  table.event-standings-table .event-overview-raw-id {
    display: none;
  }

  /*
   * Record column: border-box so fixed width includes padding; width fits “RECORD” at default thead size.
   */
  table.event-standings-table th.event-standings-record-col,
  table.event-standings-table td.event-standings-record-col {
    box-sizing: border-box;
    min-width: 0;
    width: 5rem;
    max-width: 5rem;
  }

  table.event-standings-table td.event-standings-record-col {
    padding-left: 0.12rem;
    padding-right: 0.55rem;
    white-space: nowrap;
    text-align: right;
  }

  table.event-standings-table th.event-standings-record-col {
    text-align: center;
    padding: 0.2rem 0.45rem;
    white-space: nowrap;
    overflow: hidden;
  }

  table.event-standings-table th.event-standings-legend-col,
  table.event-standings-table td.event-standings-legend-col {
    width: 2rem;
    min-width: 2rem;
    max-width: 2.2rem;
    padding-left: 0.52rem;
    padding-right: 0.3rem;
    text-align: center;
  }

  table.event-standings-table .event-standings-legend-col img.legend-icon-sm {
    width: 1.85rem;
    height: 1.85rem;
  }

  table.leaderboard-table .col-player {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    word-break: break-word;
    vertical-align: middle;
  }

  /* Name + ▲/▼ as one row, vertically centered in the table cell (equal space top/bottom). */
  table.leaderboard-table .leaderboard-player-cell {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.45em;
    box-sizing: border-box;
    min-height: 100%;
    height: 100%;
  }

  table.leaderboard-table .leaderboard-player-cell__main {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
  }

  table.leaderboard-table .col-player .leaderboard-rank-move {
    margin-left: 0;
    flex-shrink: 0;
    line-height: 1.15;
  }

  table.leaderboard-table .col-rank {
    vertical-align: middle;
  }

  table.leaderboard-table thead th,
  table.leaderboard-table tbody td {
    padding-top: 0.22rem;
    padding-bottom: 0.22rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  /* Wrapped player names need variable row height.
     Legend column always reserves icon height so rows match when tags are empty (td min-height is flaky on some mobile engines). */
  table.leaderboard-table tbody td {
    height: auto;
    min-height: 2.7rem;
  }

  table.leaderboard-table .col-legends {
    vertical-align: middle;
    /* Floor matches stacked icons (2.1rem) + default td vertical padding (~0.44rem). */
    min-height: calc(2.1rem + 0.44rem);
  }

  table.leaderboard-legend-usage-table thead th,
  table.leaderboard-legend-usage-table tbody td {
    padding-top: 0.22rem;
    padding-bottom: 0.22rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  table.leaderboard-legend-usage-table tbody td {
    height: auto;
    min-height: 2.7rem;
  }

  .main {
    padding: 1rem 1rem;
  }

  .leaderboard-view-shell__tabs {
    max-width: none;
  }

  .player-dashboard-cols {
    grid-template-columns: 1fr;
  }

  /* Player history: card rows instead of a wide table */
  .table-wrap:has(table.history-match-table),
  .table-wrap:has(table.history-event-table),
  .table-wrap:has(table.event-overview-table) {
    overflow-x: visible;
    border: none;
    background: transparent;
    border-radius: 0;
  }

  table.history-match-table,
  table.history-match-table tbody,
  table.history-match-table tr,
  table.history-match-table th,
  table.history-match-table td {
    display: block;
  }

  table.history-match-table thead {
    display: block;
    border: 0;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    white-space: nowrap;
  }

  table.history-compact.history-match-table thead tr > th:first-child,
  table.history-compact.history-match-table td.cell-context {
    min-width: 0;
    max-width: none;
    width: auto;
  }

  table.history-match-table tbody tr {
    display: grid;
    column-gap: 0.75rem;
    row-gap: 0.55rem;
    align-items: start;
    padding: 0.75rem 0.85rem;
    margin-bottom: 0.7rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
  }

  /* One tint on the whole card (grid gaps no longer show a different color). */
  table.data.history-match-table tbody tr.outcome-win {
    background: rgba(72, 191, 145, 0.2);
  }

  table.data.history-match-table tbody tr.outcome-loss {
    background: rgba(224, 92, 121, 0.2);
  }

  table.data.history-match-table tbody tr.outcome-tie {
    background: rgba(141, 151, 173, 0.2);
  }

  table.data.history-match-table tbody tr.outcome-win td,
  table.data.history-match-table tbody tr.outcome-loss td,
  table.data.history-match-table tbody tr.outcome-tie td {
    background: transparent;
  }

  /* Row 1: opponent (left) + Δ Elo (right). Row 2: equal-width legend columns. Outcome hidden. */
  table.history-match-table tbody tr:has(.history-match-opp-legend-col) {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "opp elo"
      "legthem legyou";
  }

  table.history-match-table tbody tr:not(:has(.history-match-opp-legend-col)) {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "opp elo";
  }

  table.history-match-table .compact-ids .id-dot {
    display: none;
  }

  table.history-match-table thead .history-match-outcome-col,
  table.history-match-table tbody td.history-match-outcome-col {
    display: none;
  }

  table.history-match-table tbody td {
    border: none;
    padding: 0.2rem 0.4rem;
    min-width: 0;
  }

  table.history-match-table tbody td[data-mobile-label]::before,
  table.history-event-table tbody td[data-mobile-label]::before {
    content: attr(data-mobile-label);
    display: block;
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 0.22rem;
    line-height: 1.2;
  }

  table.history-match-table tbody td.cell-context {
    grid-area: opp;
    text-align: left;
  }

  table.history-match-table tbody td.cell-context .context-primary,
  table.history-match-table tbody td.cell-context .match-meta,
  table.history-match-table tbody td.cell-context .match-meta-event {
    text-align: left;
  }

  table.history-match-table tbody td.history-match-opp-legend-col {
    grid-area: legthem;
    position: relative;
    z-index: 2;
  }

  table.history-match-table tbody td.history-match-your-legend-col {
    grid-area: legyou;
    position: relative;
    z-index: 2;
  }

  /*
   * Row 1: Elo cell fills the grid column; stack uses full width with right-aligned lines.
   * align-self:end keeps the block at the bottom when the opponent cell is taller.
   */
  table.history-match-table tbody td.history-match-elo-col {
    grid-area: elo;
    align-self: end;
    position: relative;
    z-index: 0;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding-top: 0;
    text-align: right;
  }

  table.history-match-table tbody td.history-match-elo-col .elo-stack {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    width: 100%;
    max-width: 100%;
  }

  table.history-match-table tbody td.history-match-elo-col .elo-stack > .elo-delta-main,
  table.history-match-table tbody td.history-match-elo-col .elo-stack > .elo-after {
    width: 100%;
    text-align: right;
  }

  table.history-match-table tbody td.history-match-elo-col .elo-stack > .compact-ids {
    display: flex;
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  /* Δ Elo sits beside the name; no duplicate heading. */
  table.history-match-table tbody td.history-match-elo-col[data-mobile-label]::before {
    content: none;
    display: none;
    margin: 0;
  }

  table.history-match-table tbody td.event-deck-cell {
    text-align: center;
  }

  table.history-match-table tbody td .event-deck-inline {
    justify-content: center;
  }

  /* Event history cards */
  table.history-event-table,
  table.history-event-table tbody,
  table.history-event-table tr,
  table.history-event-table th,
  table.history-event-table td {
    display: block;
  }

  table.history-event-table thead {
    display: block;
    border: 0;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    white-space: nowrap;
  }

  table.history-compact.history-event-table .cell-context {
    min-width: 0;
    max-width: none;
  }

  table.history-event-table tbody tr {
    display: grid;
    /* One gap value: equal space between row 1 cells and between the 3 stats columns */
    gap: 0.75rem;
    padding: 0.75rem 0.85rem;
    margin-bottom: 0.7rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    align-items: start;
    justify-items: stretch;
  }

  table.data.history-event-table tbody tr.elo-up {
    background: rgba(72, 191, 145, 0.2);
  }

  table.data.history-event-table tbody tr.elo-down {
    background: rgba(224, 92, 121, 0.2);
  }

  table.data.history-event-table tbody tr.elo-flat {
    background: rgba(141, 151, 173, 0.2);
  }

  table.data.history-event-table tbody tr.elo-up td,
  table.data.history-event-table tbody tr.elo-down td,
  table.data.history-event-table tbody tr.elo-flat td {
    background: transparent;
  }

  /*
   * Event history (mobile): 3 equal-width columns (repeat(3, 1fr)).
   * Row 1: event spans cols 1–2, legend col 3. Row 2: W-L-T | Δ Elo | Place (one cell per column).
   */
  table.history-event-table tbody tr:has(.event-deck-cell) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas:
      "evt evt leg"
      "wlt elo plc";
  }

  table.history-event-table tbody tr:not(:has(.event-deck-cell)) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas:
      "evt evt evt"
      "wlt elo plc";
  }

  table.history-event-table tbody td {
    border: none;
    padding: 0;
    min-width: 0;
  }

  table.history-event-table tbody td.cell-context {
    grid-area: evt;
    text-align: left;
  }

  table.history-event-table tbody td.cell-context .context-primary,
  table.history-event-table tbody td.cell-context .match-meta {
    text-align: left;
  }

  table.history-event-table tbody td.event-deck-cell {
    grid-area: leg;
    text-align: right;
    position: relative;
    z-index: 2;
  }

  table.history-event-table tbody td.event-deck-cell[data-mobile-label]::before {
    text-align: right;
  }

  /*
   * Stats row: each cell is a full-width column (flex stretch). Label + value use the whole
   * cell width with everything centered.
   */
  table.history-event-table tbody td.cell-outcome,
  table.history-event-table tbody td.history-event-elo-col,
  table.history-event-table tbody td.history-event-place-col {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    text-align: center;
    font-variant-numeric: tabular-nums;
    padding-top: 0.15rem;
  }

  table.history-event-table tbody td.cell-outcome.num,
  table.history-event-table tbody td.history-event-elo-col.num,
  table.history-event-table tbody td.history-event-place-col.num {
    text-align: center;
  }

  table.history-event-table tbody td.cell-outcome[data-mobile-label]::before,
  table.history-event-table tbody td.history-event-elo-col[data-mobile-label]::before,
  table.history-event-table tbody td.history-event-place-col[data-mobile-label]::before {
    width: 100%;
    text-align: center;
    flex-shrink: 0;
    box-sizing: border-box;
  }

  table.history-event-table tbody td.history-event-place-col.event-standings-rank--gold,
  table.history-event-table tbody td.history-event-place-col.event-standings-rank--silver,
  table.history-event-table tbody td.history-event-place-col.event-standings-rank--bronze {
    text-shadow: none;
  }

  table.history-event-table tbody td.cell-outcome {
    grid-area: wlt;
  }

  table.history-event-table tbody td.history-event-place-col {
    grid-area: plc;
  }

  /*
   * Place column: desktop compact rules use width: 2.85rem + side padding with selector
   * specificity (0,3,2), which beats the generic mobile tbody td rules (0,2,3). That leaves
   * a narrow cell inside the third grid track — override with history-compact + tbody (0,3,3).
   */
  table.history-compact.history-event-table tbody td.history-event-place-col {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding-left: 0;
    padding-right: 0;
    text-align: center;
    align-items: center;
  }

  table.history-compact.history-event-table tbody td.history-event-place-col[data-mobile-label]::before {
    align-self: stretch;
    width: 100%;
    text-align: center;
  }

  table.history-compact.history-event-table tbody td.history-event-place-col .history-event-place-value {
    display: block;
    width: 100%;
    text-align: center;
    box-sizing: border-box;
  }

  table.history-event-table tbody td.cell-elo {
    grid-area: elo;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    position: relative;
    z-index: 0;
  }

  table.history-event-table tbody td.history-event-elo-col .elo-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    max-width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    box-sizing: border-box;
  }

  table.history-event-table tbody td.history-event-elo-col .elo-delta-main,
  table.history-event-table tbody td.history-event-elo-col .elo-after {
    display: block;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
  }

  table.history-event-table tbody td .event-deck-inline {
    justify-content: flex-end;
    width: 100%;
  }

  /* Event overview: one match = card; row 1 names + vs, row 2 legends */
  table.event-overview-table {
    display: block;
    width: 100%;
    table-layout: auto;
    border-collapse: separate;
    border-spacing: 0;
  }

  table.event-overview-table thead {
    display: block;
    border: 0;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    white-space: nowrap;
  }

  table.event-overview-table tbody {
    display: block;
  }

  table.event-overview-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) min-content minmax(0, 1fr);
    grid-template-rows: auto auto;
    column-gap: 0.5rem;
    row-gap: 0;
    align-items: stretch;
    padding: 0.75rem 0.85rem;
    margin-bottom: 0.7rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    width: 100%;
    box-sizing: border-box;
  }

  table.event-overview-table .event-overview-raw-id {
    display: none;
  }

  table.event-overview-table tbody tr td {
    display: block;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    border-bottom: none;
    padding: 0.3rem 0.45rem;
    vertical-align: middle;
  }

  table.event-overview-table tbody tr td:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
    text-align: center;
    padding-bottom: 0;
  }

  table.event-overview-table tbody tr td:nth-child(5) {
    grid-column: 3;
    grid-row: 1;
    text-align: center;
    padding-bottom: 0;
  }

  table.event-overview-table tbody tr td:nth-child(3) {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
    justify-self: center;
    padding: 0.2rem 0.35rem;
  }

  /* Reserve height for icon + label / picker so rows don’t jump when a legend is set */
  table.event-overview-table tbody tr td:nth-child(2),
  table.event-overview-table tbody tr td:nth-child(4) {
    text-align: center;
    padding-top: 0;
    min-height: 5.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
  }

  table.event-overview-table tbody tr td:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
  }

  table.event-overview-table tbody tr td:nth-child(4) {
    grid-column: 3;
    grid-row: 2;
  }

  table.event-overview-table tbody tr td .event-overview-legend-wrap {
    width: 100%;
    justify-content: center;
    align-items: center;
  }

  .compact-ids-stacked {
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 100%;
  }

  .legend-picker-modal__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .legend-picker-modal__tile-img {
    width: 2.35rem;
    height: 2.35rem;
  }
}

.subtle {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.85em;
}

.empty {
  color: var(--muted);
  padding: 1rem 0;
}

/* Match-history outcome tinting */
table.data tbody tr.outcome-win td {
  background: rgba(72, 191, 145, 0.2);
}

table.data tbody tr.outcome-loss td {
  background: rgba(224, 92, 121, 0.2);
}

table.data tbody tr.outcome-tie td {
  background: rgba(141, 151, 173, 0.2);
}

/* Event-history tinting by net Δ Elo for the event */
table.data tbody tr.elo-up td {
  background: rgba(72, 191, 145, 0.2);
}

table.data tbody tr.elo-down td {
  background: rgba(224, 92, 121, 0.2);
}

table.data tbody tr.elo-flat td {
  background: rgba(141, 151, 173, 0.2);
}

/* Δ Elo — neon gain / loss (event table: td; match table: .elo-delta-main; leaderboard ▲▼) */
td.elo-delta-pos,
.elo-delta-main.elo-delta-pos,
.leaderboard-rank-move--up {
  color: #39ff14;
  font-weight: 600;
  text-shadow:
    0 0 6px rgba(57, 255, 20, 0.55),
    0 0 16px rgba(57, 255, 20, 0.28);
}

td.elo-delta-neg,
.elo-delta-main.elo-delta-neg,
.leaderboard-rank-move--down {
  color: #ff2a6d;
  font-weight: 600;
  text-shadow:
    0 0 6px rgba(255, 42, 109, 0.55),
    0 0 16px rgba(255, 42, 109, 0.28);
}

td.elo-delta-zero,
.elo-delta-main.elo-delta-zero {
  color: #9aa3b8;
  font-weight: 500;
}
