/* v284/v299: fitted compact avatars and a minimal store-like virtual ranking. */

#ranking-modal {
  container: ranking-v284 / size;
}

#ranking-modal.modal > .ranking-content.dialog-card {
  position: relative;
  box-sizing: border-box;
  display: grid;
  width: min(calc(100vw - 16px), 520px);
  max-width: 520px;
  height: min(780px, calc(100dvh - max(12px, env(safe-area-inset-top)) - max(8px, env(safe-area-inset-bottom))));
  max-height: none !important;
  grid-template-rows: auto auto auto minmax(132px, 1fr) auto;
  gap: 8px;
  align-content: stretch;
  padding: 12px;
  overflow: hidden;
  text-align: left;
  background: #f2f4f6 !important;
}

#ranking-modal .ranking-content::before {
  position: absolute;
  z-index: 2;
  top: 6px;
  left: 50%;
  margin: 0;
  transform: translateX(-50%);
}

#ranking-modal .ranking-header {
  min-width: 0;
  padding: 6px 2px 0;
}

#ranking-modal .ranking-header .dialog-title {
  margin: 0 0 2px;
  color: #191f28;
  font-size: 22px;
  line-height: 28px;
  text-align: left;
}

#ranking-modal .ranking-intro,
#ranking-modal .ranking-intro > span {
  margin: 0;
  color: #4e5968;
  font-size: 12.5px;
  font-weight: 650;
  line-height: 17px;
  text-align: left;
  word-break: keep-all;
}

#ranking-modal .ranking-overview {
  box-sizing: border-box;
  display: grid;
  min-width: 0;
  min-height: 100px;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: stretch;
  gap: 8px;
  padding: 7px;
  border: 1px solid #e5e8eb;
  border-radius: 8px;
  background: #fff;
}

#ranking-modal .ranking-feature-visual {
  position: relative;
  display: block;
  width: 92px;
  height: 92px;
  min-height: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid #e5e8eb;
  border-radius: 8px;
  background: #f2f4f6;
  box-shadow: none;
}

#ranking-modal .ranking-feature-visual .feature-hero-img {
  display: none;
}

#ranking-modal .ranking-feature-visual .feature-character-avatar {
  left: 50%;
  width: 88px;
  height: 100%;
  max-height: 100%;
  bottom: 0;
  transform: translateX(-50%) !important;
  transform-origin: bottom center;
}

#ranking-modal .ranking-player-summary.dialog-summary {
  box-sizing: border-box;
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr) 88px;
  grid-template-areas:
    "rank action"
    "record record";
  align-content: center;
  align-items: center;
  gap: 5px 7px;
  margin: 0;
  padding: 3px 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

#ranking-modal .ranking-player-rank,
#ranking-modal .ranking-player-record {
  display: grid;
  min-width: 0;
  gap: 1px;
}

#ranking-modal .ranking-player-rank {
  grid-area: rank;
}

#ranking-modal .ranking-player-record {
  grid-area: record;
}

#ranking-modal .ranking-player-rank > span,
#ranking-modal .ranking-player-record > span {
  color: #6b7684;
  font-size: 11px;
  font-weight: 700;
  line-height: 15px;
}

#ranking-modal .ranking-player-rank > strong {
  color: #1769e5;
  font-size: 22px;
  font-weight: 900;
  line-height: 25px;
  white-space: nowrap;
}

#ranking-modal .ranking-player-rank small {
  color: #6b7684;
  font-size: 10.5px;
  font-weight: 700;
}

#ranking-modal .ranking-player-record > strong {
  overflow: hidden;
  color: #191f28;
  font-size: 12.5px;
  font-weight: 800;
  line-height: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#ranking-modal .ranking-player-record b {
  color: #333d4b;
  font-weight: 850;
}

#ranking-modal #nickname-btn {
  grid-area: action;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: 0 7px;
  border: 1px solid #d1d6db;
  border-radius: 8px;
  color: #4e5968;
  background: #fff;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

#ranking-modal .rival-challenge {
  box-sizing: border-box;
  min-width: 0;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid #e5e8eb;
  border-radius: 8px;
  background: #fff;
}

#ranking-modal .rival-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

#ranking-modal .rival-head > div,
#ranking-modal .rival-head > em {
  display: grid;
  gap: 0;
}

#ranking-modal .rival-head span {
  color: #6b7684;
  font-size: 10px;
  font-weight: 750;
  line-height: 13px;
}

#ranking-modal .rival-head > div > strong {
  color: #191f28;
  font-size: 14px;
  font-weight: 850;
  line-height: 18px;
}

#ranking-modal .rival-head > em {
  flex: 0 0 auto;
  text-align: right;
  font-style: normal;
}

#ranking-modal .rival-head > em > strong {
  color: #1769e5;
  font-size: 13px;
  font-weight: 850;
  line-height: 17px;
}

#ranking-modal .rival-preview {
  display: grid;
  min-width: 0;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 1px 7px;
  margin-top: 4px;
}

#ranking-modal .rival-label {
  color: #6b7684;
  font-size: 10.5px;
  font-weight: 750;
  line-height: 14px;
}

#ranking-modal .rival-opponent {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
}

#ranking-modal .rival-opponent > strong {
  overflow: hidden;
  color: #191f28;
  font-size: 13.5px;
  font-weight: 850;
  line-height: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#ranking-modal .rival-opponent > small {
  flex: 0 0 auto;
  padding: 1px 6px;
  border-radius: 999px;
  color: #1769e5;
  background: #edf5ff;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 15px;
}

#ranking-modal .rival-rule,
#ranking-modal .rival-rule > span {
  grid-column: 1 / -1;
  margin: 0;
  color: #4e5968;
  font-size: 11px;
  font-weight: 650;
  line-height: 15px;
  text-align: left;
}

#ranking-modal #rival-start-btn {
  width: 100%;
  min-height: 40px;
  margin-top: 5px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: #3182f6;
  font-size: 14px;
  font-weight: 850;
}

#ranking-modal .rival-score {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 5px;
}

#ranking-modal .rival-score > span {
  display: grid;
  gap: 1px;
}

#ranking-modal .rival-score > span:last-child {
  text-align: right;
}

#ranking-modal .rival-score small {
  overflow: hidden;
  color: #6b7684;
  font-size: 10px;
  font-weight: 700;
  line-height: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#ranking-modal .rival-score b {
  color: #191f28;
  font-size: 13px;
  font-weight: 850;
  line-height: 17px;
}

#ranking-modal .rival-progress {
  height: 5px;
  margin-top: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #dce8f2;
}

#ranking-modal .rival-progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #3182f6;
}

#ranking-modal .rival-live-status {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-top: 3px;
}

#ranking-modal .rival-live-status > span,
#ranking-modal .rival-time {
  margin: 0;
  color: #4e5968;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 14px;
}

#ranking-modal .rival-time {
  flex: 0 0 auto;
  color: #1769e5;
}

#ranking-modal .rival-result {
  display: grid;
  gap: 1px;
  margin-top: 5px;
  padding: 6px 7px;
  border-radius: 7px;
  color: #526779;
  background: #f2f4f6;
  font-size: 10.5px;
}

#ranking-modal .rival-result.won {
  color: #286847;
  background: #eaf8ef;
}

#ranking-modal .rival-benefits {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-top: 4px;
  color: #6b7684;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 13px;
}

#ranking-modal .rival-benefits b {
  color: #1769e5;
  font-weight: 850;
}

#ranking-modal .ranking-board {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid #e5e8eb;
  border-radius: 8px;
  background: #fff;
}

#ranking-modal .ranking-board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px 5px;
}

#ranking-modal .ranking-board-head > div {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 6px;
}

#ranking-modal .ranking-board-head h3 {
  margin: 0;
  color: #191f28;
  font-size: 14px;
  font-weight: 850;
  line-height: 18px;
}

#ranking-modal .ranking-board-head p,
#ranking-modal .ranking-board-head > span {
  margin: 0;
  color: #6b7684;
  font-size: 10px;
  font-weight: 650;
  line-height: 14px;
}

#ranking-modal .ranking-board-head > span {
  flex: 0 0 auto;
}

#ranking-modal .ranking-columns,
#ranking-modal .ranking-row {
  display: grid;
  min-width: 0;
  grid-template-columns: 40px minmax(0, 1fr) minmax(74px, auto);
  align-items: center;
  column-gap: 5px;
}

#ranking-modal .ranking-columns {
  padding: 4px 8px;
  border-block: 1px solid #eef1f4;
  color: #8b95a1;
  background: #f7f8fa;
  font-size: 10px;
  font-weight: 750;
  line-height: 13px;
}

#ranking-modal .ranking-columns > span:last-child {
  text-align: right;
}

#ranking-modal #ranking-list {
  min-height: 0;
  margin: 0;
  padding: 0 5px 4px;
  overflow-y: auto;
  border: 0;
  border-radius: 0;
  background: #fff;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

#ranking-modal .ranking-row {
  min-height: 40px;
  padding: 3px;
  border-bottom: 1px solid #f0f2f5;
  color: #4e5968;
  background: #fff;
  font-size: 12px;
}

#ranking-modal .ranking-row:last-child {
  border-bottom: 0;
}

#ranking-modal .ranking-row.me {
  border: 1px solid #b8d8ff;
  border-radius: 7px;
  background: #edf5ff;
}

#ranking-modal .ranking-rank {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 1px;
  color: #6b7684;
}

#ranking-modal .ranking-rank b {
  font-size: 13px;
  font-weight: 900;
}

#ranking-modal .ranking-rank small {
  font-size: 9.5px;
  font-weight: 750;
}

#ranking-modal .ranking-row.podium .ranking-rank {
  color: #1769e5;
}

#ranking-modal .ranking-name {
  display: grid;
  min-width: 0;
  gap: 0;
}

#ranking-modal .ranking-name > strong {
  overflow: hidden;
  color: #333d4b;
  font-size: 12px;
  font-weight: 800;
  line-height: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#ranking-modal .ranking-name > small {
  color: #8b95a1;
  font-size: 9px;
  font-weight: 650;
  line-height: 12px;
}

#ranking-modal .ranking-row.me .ranking-name > small {
  color: #1769e5;
}

#ranking-modal .ranking-worth {
  overflow: hidden;
  color: #333d4b;
  font-size: 11.5px;
  font-weight: 850;
  line-height: 16px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#ranking-modal .dialog-actions {
  margin: 0;
}

#ranking-modal #ranking-close-btn {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: #3182f6;
  font-size: 16px;
  font-weight: 850;
}

/* Snapshot ids are namespaced; data markers keep fitted attachments visible. */
:is(
  [data-character-render="approved-b-raster"],
  [data-character-render^="tier-raster-"]
) [data-attachment-id="watch"]:not(.hidden)[data-rig-compatible="true"] {
  display: block !important;
}

.cosmetic-back-layer:not(.hidden)[data-rig-compatible="true"] {
  display: block !important;
}

:is(
  [data-feature-scene="upgrade"],
  [data-feature-scene="marketNews"],
  [data-feature-scene="share"]
) .feature-character-avatar {
  width: max(var(--fa-w, 38%), 64px);
  height: 82%;
  max-height: 82%;
  bottom: 0;
}

.feature-character-avatar .cosmetic:not(.hidden) {
  filter: drop-shadow(0 0.7px 0.45px rgb(25 31 40 / 28%));
}

@container ranking-v284 (max-width: 380px) {
  #ranking-modal.modal > .ranking-content.dialog-card {
    width: 100vw;
    height: calc(100dvh - max(4px, env(safe-area-inset-top)));
    gap: 6px;
    padding: 10px !important;
    border-radius: 14px 14px 0 0;
  }

  #ranking-modal .ranking-header {
    padding-top: 5px;
  }

  #ranking-modal .ranking-overview {
    min-height: 92px;
    grid-template-columns: 84px minmax(0, 1fr);
    padding: 6px;
  }

  #ranking-modal .ranking-feature-visual {
    width: 84px;
    height: 84px;
  }

  #ranking-modal .ranking-feature-visual .feature-character-avatar {
    width: 82px;
  }

  #ranking-modal .ranking-player-summary.dialog-summary {
    grid-template-columns: minmax(0, 1fr) 78px;
    gap: 3px 5px;
  }

  #ranking-modal #nickname-btn {
    min-height: 40px;
    padding-inline: 5px;
  }

  #ranking-modal .rival-challenge {
    padding: 7px 9px;
  }
}

@container ranking-v284 (max-height: 680px) {
  #ranking-modal.modal > .ranking-content.dialog-card {
    grid-template-rows: auto auto auto minmax(92px, 1fr) auto;
    gap: 5px;
    padding-top: 9px;
  }

  #ranking-modal .ranking-header .dialog-title {
    font-size: 20px;
    line-height: 24px;
  }

  #ranking-modal .ranking-intro {
    font-size: 11.5px;
    line-height: 15px;
  }

  #ranking-modal .ranking-overview {
    min-height: 86px;
    grid-template-columns: 84px minmax(0, 1fr);
    padding: 5px;
  }

  #ranking-modal .ranking-feature-visual {
    width: 84px;
    height: 84px;
  }

  #ranking-modal .ranking-feature-visual .feature-character-avatar {
    width: 82px;
  }

  #ranking-modal .ranking-player-summary.dialog-summary {
    grid-template-columns: minmax(0, 1fr) 78px;
  }

  #ranking-modal .ranking-player-rank > strong {
    font-size: 20px;
    line-height: 23px;
  }

  #ranking-modal #nickname-btn {
    min-height: 36px;
  }

  #ranking-modal .rival-rule,
  #ranking-modal .rival-benefits {
    display: none;
  }

  #ranking-modal #rival-start-btn {
    min-height: 36px;
  }

  #ranking-modal .ranking-board-head {
    padding-block: 5px 4px;
  }

  #ranking-modal .ranking-row {
    min-height: 36px;
  }
}

@container ranking-v284 (max-height: 500px) {
  #ranking-modal.modal > .ranking-content.dialog-card {
    height: calc(100dvh - max(4px, env(safe-area-inset-top)) - max(0px, env(safe-area-inset-bottom)));
    grid-template-rows: auto auto minmax(76px, 1fr) auto;
    gap: 4px;
    padding: 8px !important;
  }

  #ranking-modal .ranking-intro,
  #ranking-modal .ranking-overview {
    display: none;
  }

  #ranking-modal .rival-challenge {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 124px;
    align-items: center;
    gap: 3px 8px;
  }

  #ranking-modal .rival-head,
  #ranking-modal .rival-benefits {
    display: none;
  }

  #ranking-modal .rival-preview,
  #ranking-modal #rival-start-btn {
    margin: 0;
  }

  #ranking-modal .ranking-board {
    grid-template-rows: auto minmax(0, 1fr);
  }

  #ranking-modal .ranking-board-head {
    display: none;
  }
}
