/* Night Court — Cumulative leaderboard (page overrides) */

body.ds[data-page="cumulative"] {
  overflow-x: hidden;
}

/* Control region: search + sticky segment */
.ds-cum-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 -16px 16px;
  padding: 0 16px;
}

@media (min-width: 1024px) {
  .ds-cum-controls {
    position: sticky;
    top: var(--topbar-h);
    z-index: 35;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    margin-left: 0;
    margin-right: 0;
    padding: 12px 16px;
    background: color-mix(in srgb, var(--ds-bg) 88%, transparent);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    border: 1px solid var(--ds-line);
    margin-bottom: 20px;
  }
}

/* Mobile: only segment bar is sticky (44px) */
.ds-cum-sticky-bar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 35;
  display: flex;
  align-items: center;
  height: 44px;
  margin: 0 -16px;
  padding: 0 16px;
  box-sizing: border-box;
  background: color-mix(in srgb, var(--ds-bg) 88%, transparent);
  backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 var(--ds-line);
}

@media (min-width: 1024px) {
  .ds-cum-sticky-bar {
    position: static;
    margin: 0;
    padding: 0;
    background: transparent;
    backdrop-filter: none;
    border-bottom: none;
    flex-shrink: 0;
    flex: 0 0 auto;
    width: auto;
  }
}

.ds-cum-search {
  position: relative;
  flex: 1;
  min-width: 0;
}

.ds-cum-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--ds-ink-3);
  pointer-events: none;
}

.ds-cum-search-icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.ds-cum-search input {
  width: 100%;
  min-height: 44px;
  padding: 0 44px 0 42px;
  border-radius: 999px;
  border: 1px solid var(--ds-line-strong);
  background: var(--ds-surface);
  color: var(--ds-ink);
  font-family: var(--ds-font-body);
  font-size: 14px;
  font-weight: 700;
  transition: border-color var(--ds-t-fast) var(--ds-ease), box-shadow var(--ds-t-fast) var(--ds-ease);
}

.ds-cum-search input:focus-visible {
  outline: none;
  border-color: var(--ds-volt);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ds-volt) 40%, transparent);
}

.ds-cum-search input::placeholder {
  color: var(--ds-ink-3);
}

.ds-cum-search-hint {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  min-width: 22px;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--ds-line-strong);
  background: var(--ds-surface-2);
  color: var(--ds-ink-3);
  font-family: var(--ds-font-mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.2;
}

@media (min-width: 768px) {
  .ds-cum-search-hint {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* Segment control — 44px total on mobile sticky bar */
.ds-segment.view-toggle {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  width: 100%;
  height: 44px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--ds-line-strong);
  background: var(--ds-surface);
  box-sizing: border-box;
}

@media (min-width: 1024px) {
  .ds-segment.view-toggle {
    width: 280px;
    min-width: 280px;
  }
}

.ds-segment.view-toggle .ds-segment-thumb {
  position: absolute;
  top: 4px;
  left: 4px;
  height: calc(100% - 8px);
  border-radius: 999px;
  background: var(--ds-volt);
  z-index: 0;
  transition: transform 420ms cubic-bezier(0.34, 1.56, 0.64, 1), width var(--ds-t-fast) var(--ds-ease);
  pointer-events: none;
}

.ds-segment.view-toggle button {
  position: relative;
  z-index: 1;
  min-height: 0;
  height: 100%;
  white-space: nowrap;
  padding: 0 8px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--ds-ink-2);
  font-family: var(--ds-font-body);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: color var(--ds-t-fast) var(--ds-ease);
}

.ds-segment.view-toggle button.active {
  color: var(--ds-bg);
}

.ds-segment.view-toggle button:focus-visible {
  outline: 2px solid var(--ds-volt);
  outline-offset: 2px;
}

/* Meta chips — single row scroll on mobile */
.cumulative-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  margin-bottom: 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.cumulative-chips::-webkit-scrollbar {
  display: none;
}

@media (min-width: 768px) {
  .cumulative-chips {
    flex-wrap: wrap;
    overflow-x: visible;
  }
}

body.ds[data-page="cumulative"] .cumulative-note,
body.ds[data-page="cumulative"] .cumulative-meta {
  flex-shrink: 0;
  margin: 0;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--ds-line-strong);
  background: var(--ds-surface);
  font-family: var(--ds-font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--ds-ink-2);
  line-height: 1.4;
  white-space: nowrap;
}

body.ds[data-page="cumulative"] .stats-team-title {
  margin-bottom: 10px;
}

body.ds[data-page="cumulative"] #cumulativeTable {
  margin-bottom: 24px;
}

/* Category accent colors */
body.ds[data-page="cumulative"] {
  --cum-pts: #c8ff3d;
  --cum-fg2: #8aa4ff;
  --cum-fg3: #4cc9f0;
  --cum-ast: #5eead4;
  --cum-or: #c4a1ff;
  --cum-st: #ffb86b;
  --cum-bs: #ff8fa3;
  --cum-lost: #ff6b6b;
  --cum-wld: #9aa79f;
  --cum-game: #9aa79f;
  --cum-meta: #9aa79f;
  --cum-name: #9aa79f;
  --heat-pts: linear-gradient(90deg, rgb(200 255 61) 0%, rgb(200 255 61 / 0) 100%);
  --heat-fg2: linear-gradient(90deg, rgb(138 164 255) 0%, rgb(138 164 255 / 0) 100%);
  --heat-fg3: linear-gradient(90deg, rgb(76 201 240) 0%, rgb(76 201 240 / 0) 100%);
  --heat-ast: linear-gradient(90deg, rgb(94 234 212) 0%, rgb(94 234 212 / 0) 100%);
  --heat-or: linear-gradient(90deg, rgb(196 161 255) 0%, rgb(196 161 255 / 0) 100%);
  --heat-st: linear-gradient(90deg, rgb(255 184 107) 0%, rgb(255 184 107 / 0) 100%);
  --heat-bs: linear-gradient(90deg, rgb(255 143 163) 0%, rgb(255 143 163 / 0) 100%);
  --heat-lost: linear-gradient(90deg, rgb(255 107 107) 0%, rgb(255 107 107 / 0) 100%);
  --heat-wld: linear-gradient(90deg, rgb(154 167 159) 0%, rgb(154 167 159 / 0) 100%);
}

/* Table scroll container — vertical sticky headers inside wrap */
body.ds[data-page="cumulative"] .stats-table-wrap {
  max-height: calc(100dvh - var(--topbar-h) - var(--sticky-bar-h, 0px) - 112px);
  overflow: auto;
  margin-bottom: 24px;
}

body.ds[data-page="cumulative"] .stats-table--cumulative th,
body.ds[data-page="cumulative"] .stats-table--cumulative td {
  background: var(--ds-surface);
  border-left: none;
  border-right: none;
}

body.ds[data-page="cumulative"] .stats-table--cumulative thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  padding-top: 10px;
  font-family: var(--ds-font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: none;
  color: var(--ds-ink-2);
  box-shadow: inset 0 3px 0 var(--cum-meta);
}

body.ds[data-page="cumulative"] .stats-table--cumulative thead th.cat-pts {
  box-shadow: inset 0 3px 0 var(--cum-pts);
}
body.ds[data-page="cumulative"] .stats-table--cumulative thead th.cat-fg2 {
  box-shadow: inset 0 3px 0 var(--cum-fg2);
}
body.ds[data-page="cumulative"] .stats-table--cumulative thead th.cat-fg3 {
  box-shadow: inset 0 3px 0 var(--cum-fg3);
}
body.ds[data-page="cumulative"] .stats-table--cumulative thead th.cat-ast {
  box-shadow: inset 0 3px 0 var(--cum-ast);
}
body.ds[data-page="cumulative"] .stats-table--cumulative thead th.cat-or {
  box-shadow: inset 0 3px 0 var(--cum-or);
}
body.ds[data-page="cumulative"] .stats-table--cumulative thead th.cat-st {
  box-shadow: inset 0 3px 0 var(--cum-st);
}
body.ds[data-page="cumulative"] .stats-table--cumulative thead th.cat-bs {
  box-shadow: inset 0 3px 0 var(--cum-bs);
}
body.ds[data-page="cumulative"] .stats-table--cumulative thead th.cat-lost {
  box-shadow: inset 0 3px 0 var(--cum-lost);
}
body.ds[data-page="cumulative"] .stats-table--cumulative thead th.cat-wld,
body.ds[data-page="cumulative"] .stats-table--cumulative thead th.cat-game {
  box-shadow: inset 0 3px 0 var(--cum-wld);
}
body.ds[data-page="cumulative"] .stats-table--cumulative thead th.cat-meta,
body.ds[data-page="cumulative"] .stats-table--cumulative thead th.cat-name {
  box-shadow: inset 0 3px 0 var(--cum-meta);
}

body.ds[data-page="cumulative"] .stats-table--cumulative th.sortable {
  cursor: pointer;
}

body.ds[data-page="cumulative"] .stats-table--cumulative th.sortable:hover {
  color: var(--ds-ink);
}

body.ds[data-page="cumulative"] .stats-table--cumulative .sort-arrow {
  color: var(--ds-volt);
  font-weight: 700;
}

body.ds[data-page="cumulative"] .stats-table--cumulative td.is-sorted {
  background: rgba(200, 255, 61, 0.05);
}

body.ds[data-page="cumulative"] .stats-table--cumulative thead th.sort-active {
  background: var(--ds-surface);
  background-image: linear-gradient(rgba(200, 255, 61, 0.05), rgba(200, 255, 61, 0.05));
}

/* Sticky rank + name */
body.ds[data-page="cumulative"] .stats-table--cumulative {
  --cum-rank-w: 52px;
  border-collapse: separate;
  border-spacing: 0;
}

body.ds[data-page="cumulative"] .stats-table--cumulative .col-rank {
  position: sticky;
  left: 0;
  z-index: 3;
  min-width: var(--cum-rank-w);
  max-width: var(--cum-rank-w);
  background: var(--ds-surface);
}

body.ds[data-page="cumulative"] .stats-table--cumulative .col-name {
  position: sticky;
  left: var(--cum-rank-w);
  z-index: 2;
  min-width: 8.5rem;
  max-width: 11rem;
  background: var(--ds-surface);
  box-shadow: 4px 0 12px rgba(0, 0, 0, 0.25);
}

body.ds[data-page="cumulative"] .stats-table--cumulative thead th.col-rank {
  z-index: 7;
}

body.ds[data-page="cumulative"] .stats-table--cumulative thead th.col-name {
  z-index: 6;
  text-align: left;
}

body.ds[data-page="cumulative"] .stats-table--cumulative tbody td.col-rank.is-sorted,
body.ds[data-page="cumulative"] .stats-table--cumulative tbody td.col-name.is-sorted {
  background: color-mix(in srgb, var(--ds-surface) 95%, rgba(200, 255, 61, 0.05));
}

/* Rank */
body.ds[data-page="cumulative"] .stats-table--cumulative td.col-rank {
  font-family: var(--ds-font-display);
  font-weight: 900;
  font-size: 24px;
  line-height: 1;
  color: var(--ds-ink-3);
}

body.ds[data-page="cumulative"] .stats-table--cumulative td.col-rank.rank-top1 {
  color: var(--ds-bg);
  background: var(--ds-volt);
}

body.ds[data-page="cumulative"] .stats-table--cumulative td.col-rank.rank-top1.is-sorted {
  background: var(--ds-volt);
}

body.ds[data-page="cumulative"] .stats-table--cumulative td.col-rank.rank-top2,
body.ds[data-page="cumulative"] .stats-table--cumulative td.col-rank.rank-top3 {
  color: var(--ds-ink);
}

/* Name */
body.ds[data-page="cumulative"] .stats-table--cumulative td.col-name {
  text-align: left;
  vertical-align: middle;
  font-weight: 700;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Numeric cells — no ds.css col-pts bar on cumulative */
body.ds[data-page="cumulative"] .stats-table--cumulative td.col-num {
  position: relative;
  font-family: var(--ds-font-mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  padding-bottom: 8px;
}

body.ds[data-page="cumulative"] .stats-table--cumulative td.col-pts::after {
  display: none;
}

body.ds[data-page="cumulative"] .stats-table--cumulative td.col-num.has-heat::before {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 4px;
  height: 2px;
  border-radius: 999px;
  transform: scaleX(var(--heat, 0));
  transform-origin: left center;
  opacity: 0.9;
  pointer-events: none;
}

body.ds[data-page="cumulative"] .stats-table--cumulative td.col-num.cat-pts.has-heat::before {
  background: var(--heat-pts);
}
body.ds[data-page="cumulative"] .stats-table--cumulative td.col-num.cat-fg2.has-heat::before {
  background: var(--heat-fg2);
}
body.ds[data-page="cumulative"] .stats-table--cumulative td.col-num.cat-fg3.has-heat::before {
  background: var(--heat-fg3);
}
body.ds[data-page="cumulative"] .stats-table--cumulative td.col-num.cat-ast.has-heat::before {
  background: var(--heat-ast);
}
body.ds[data-page="cumulative"] .stats-table--cumulative td.col-num.cat-or.has-heat::before {
  background: var(--heat-or);
}
body.ds[data-page="cumulative"] .stats-table--cumulative td.col-num.cat-st.has-heat::before {
  background: var(--heat-st);
}
body.ds[data-page="cumulative"] .stats-table--cumulative td.col-num.cat-bs.has-heat::before {
  background: var(--heat-bs);
}
body.ds[data-page="cumulative"] .stats-table--cumulative td.col-num.cat-lost.has-heat::before {
  background: var(--heat-lost);
}
body.ds[data-page="cumulative"] .stats-table--cumulative td.col-num.cat-wld.has-heat::before,
body.ds[data-page="cumulative"] .stats-table--cumulative td.col-num.cat-game.has-heat::before {
  background: var(--heat-wld);
}

body.ds[data-page="cumulative"] .stats-table--cumulative td.cat-pts.col-num {
  font-family: var(--ds-font-display);
  font-weight: 700;
  font-size: 18px;
}

body.ds[data-page="cumulative"] .stats-table--cumulative .cumulative-unit {
  margin-left: 3px;
  font-family: var(--ds-font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--ds-ink-3);
  text-transform: lowercase;
}

body.ds[data-page="cumulative"] .stats-table--cumulative .cumulative-fga-suffix {
  display: block;
  margin-top: 2px;
  font-family: var(--ds-font-mono);
  font-size: 10px;
  color: var(--ds-ink-3);
}

body.ds[data-page="cumulative"] .stats-table--cumulative .cumulative-max-game {
  font-family: var(--ds-font-mono);
  font-size: 10px;
  color: var(--ds-ink-3);
}

body.ds[data-page="cumulative"] .stats-table--cumulative td.cumulative-na {
  color: var(--ds-ink-3);
}

body.ds[data-page="cumulative"] .stats-table--cumulative td.cumulative-empty {
  padding: 24px 16px;
  color: var(--ds-ink-2);
  font-family: var(--ds-font-body);
}

/* スマホ: 表の中で縦に滑らせず、項目と数値を詰めて多く見せる */
@media (max-width: 767px) {
  body.ds[data-page="cumulative"] .stats-table-wrap {
    max-height: none;
    height: auto;
    overflow-x: auto;
    overflow-y: clip;
    overscroll-behavior-x: none;
    overscroll-behavior-y: auto;
    touch-action: pan-x pan-y;
    -webkit-overflow-scrolling: auto;
  }

  body.ds[data-page="cumulative"] .stats-table--cumulative {
    --cum-rank-w: 22px;
  }

  body.ds[data-page="cumulative"] .stats-table--cumulative tbody tr {
    height: 22px;
  }

  body.ds[data-page="cumulative"] .stats-table--cumulative th,
  body.ds[data-page="cumulative"] .stats-table--cumulative td {
    padding: 0 2px;
  }

  body.ds[data-page="cumulative"] .stats-table--cumulative thead th {
    top: 0;
    height: 18px;
    padding-top: 0;
    font-size: 8px;
    letter-spacing: 0;
    line-height: 1;
  }

  body.ds[data-page="cumulative"] .stats-table--cumulative .col-name {
    min-width: 3.4rem;
    max-width: 4.4rem;
    box-shadow: 2px 0 6px rgba(0, 0, 0, 0.2);
  }

  body.ds[data-page="cumulative"] .stats-table--cumulative td.col-rank {
    font-size: 11px;
  }

  body.ds[data-page="cumulative"] .stats-table--cumulative td.col-name {
    font-size: 10px;
  }

  body.ds[data-page="cumulative"] .stats-table--cumulative td.col-num {
    font-size: 9px;
    padding-bottom: 0;
    line-height: 1.1;
  }

  body.ds[data-page="cumulative"] .stats-table--cumulative td.cat-pts.col-num {
    font-size: 10px;
  }

  body.ds[data-page="cumulative"] .stats-table--cumulative .cumulative-unit,
  body.ds[data-page="cumulative"] .stats-table--cumulative .cumulative-fga-suffix,
  body.ds[data-page="cumulative"] .stats-table--cumulative .cumulative-max-game {
    display: inline;
    margin: 0 0 0 1px;
    font-size: 7px;
  }

  body.ds[data-page="cumulative"] .stats-table--cumulative td.col-num.has-heat::before {
    left: 2px;
    right: 2px;
    bottom: 0;
    height: 1px;
  }
}
