.ranking-panel { margin-top: 24px; height: auto; }
.ranking-panel .card-body { padding: 20px; }
.ranking-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ranking-toolbar h2 { color: #ffaa33; margin-bottom: 6px; }
.ranking-toolbar p { margin: 0; opacity: .8; }
.ranking-toolbar label { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#ranking-search { min-height: 44px; box-sizing: border-box; padding: 10px 12px; border: 1px solid #996638; border-radius: 8px; background: rgba(0,0,0,.2); color: inherit; font: inherit; }
#ranking-refresh { min-height: 44px; }
.ranking-metadata { display: flex; flex-wrap: wrap; gap: 8px 24px; font-size: .9rem; opacity: .85; }
.ranking-metadata p { margin: 4px 0; overflow-wrap: anywhere; }
#ranking-status { padding: 12px 14px; border-left: 3px solid #ff6600; background: rgba(255,102,0,.07); overflow-wrap: anywhere; }
#ranking-status.status-error { color: #ffbc80; border-color: #ffaa33; }
.ranking-help { line-height: 1.6; opacity: .85; }
.ranking-table-container { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; border: 1px solid rgba(255,150,60,.2); border-radius: 10px; }
.ranking-table-container:focus-visible { outline: 2px solid #ff8c33; outline-offset: 3px; }
#ranking-table { width: 100%; min-width: 0; font-size: .875rem; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
#ranking-table caption { text-align: left; padding: 12px 16px; color: #ffaa33; }
#ranking-table th, #ranking-table td { padding: 8px 7px; text-align: left; border-bottom: 1px solid rgba(255,255,255,.08); white-space: nowrap; }
#ranking-table th { background: rgba(255,102,0,.08); white-space: normal; }
#ranking-table th button { min-height: 44px; padding: 8px 0; color: #ffaa33; background: transparent; border-radius: 0; font: inherit; font-weight: bold; width: 100%; text-align: inherit; white-space: normal; }
#ranking-table tbody tr:hover { background: rgba(255,102,0,.05); }
.ranking-account { display: flex; align-items: center; gap: 5px; min-height: 24px; }
.ranking-avatar { border-radius: 50%; object-fit: cover; background: #75411f; width: 24px; height: 24px; flex: 0 0 24px; }
.ranking-avatar-failed { visibility: hidden; }
#ranking-table .has-power-down { color: #dba66b; }
#ranking-table .is-enabled { color: #39ef70; }
#ranking-table .is-disabled { color: #ff6262; }
body.light #ranking-search { background: #fff; }
body.light #ranking-status.status-error, body.light #ranking-table th button { color: #a34000; }
body.light #ranking-table .has-power-down { color: #98591f; }
body.light #ranking-table .is-enabled { color: #00852b; }
body.light #ranking-table .is-disabled { color: #d51b29; }
body.light #ranking-table td { border-color: rgba(0,0,0,.1); }
@media (max-width: 600px) { .ranking-toolbar .controls, .ranking-toolbar label, #ranking-search { width: 100%; } .ranking-toolbar .controls { align-items: stretch; } #ranking-refresh { width: 100%; } }

/* Native scrolling is retained for mouse, keyboard and touch input. */
.ranking-scroll-top { max-width: 100%; height: 24px; overflow-x: auto; overflow-y: hidden; margin-bottom: 6px; border: 1px solid rgba(255,150,60,.2); border-radius: 6px; -webkit-overflow-scrolling: touch; }
#ranking-scroll-spacer { height: 1px; }
.ranking-scroll-top:focus-visible { outline: 2px solid #ff8c33; outline-offset: 3px; }
#ranking-table th:nth-child(1), #ranking-table td:nth-child(1) { position: sticky; left: 0; z-index: 2; background: #2a2a2a; }
#ranking-table th:nth-child(2), #ranking-table td:nth-child(2) { position: sticky; left: var(--ranking-rank-width, 80px); z-index: 2; background: #2a2a2a; }
#ranking-table th:nth-child(1), #ranking-table th:nth-child(2) { z-index: 3; background: #352e27; }
#ranking-table tbody tr:hover td:nth-child(1), #ranking-table tbody tr:hover td:nth-child(2) { background: #352d27; }
body.light #ranking-table td:nth-child(1), body.light #ranking-table td:nth-child(2) { background: #fff; }
body.light #ranking-table th:nth-child(1), body.light #ranking-table th:nth-child(2) { background: #fff0e5; }
body.light #ranking-table tbody tr:hover td:nth-child(1), body.light #ranking-table tbody tr:hover td:nth-child(2) { background: #fff7f0; }

/* Let intrinsic cell contents determine whether horizontal scrolling is needed. */
/* Keep identity and vote columns at their natural content width; other
   columns share the remaining space without altering cell padding. */
#ranking-table th:nth-child(-n+3), #ranking-table td:nth-child(-n+3) { width: 1%; }
#ranking-table th:nth-child(1), #ranking-table td:nth-child(1),
#ranking-table th:nth-child(3), #ranking-table td:nth-child(3),
#ranking-table th:nth-child(5), #ranking-table td:nth-child(5),
#ranking-table th:nth-child(6), #ranking-table td:nth-child(6),
#ranking-table th:nth-child(7), #ranking-table td:nth-child(7),
#ranking-table th:nth-child(9), #ranking-table td:nth-child(9),
#ranking-table th:nth-child(11), #ranking-table td:nth-child(11) { text-align: right; }
#ranking-table th:last-child button { max-width: 7rem; }
.ranking-scroll-top[hidden] { display: none; }

.ranking-mobile-sort, .ranking-mobile-instructions { display: none; }

/* Power Down's card pattern; desktop table and native scroll remain unchanged. */
@media (max-width: 600px) {
  .ranking-panel .card-body { padding: 12px; }
  .ranking-toolbar > *, .ranking-toolbar .controls > * { min-width: 0; max-width: 100%; }
  .ranking-toolbar .controls { display: flex; flex-direction: column; gap: 10px; }
  .ranking-toolbar label { align-items: stretch; flex-direction: column; }
  .ranking-mobile-sort {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    margin-block: 16px;
  }
  .ranking-mobile-sort select, .ranking-mobile-sort button {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    font: inherit;
  }
  .ranking-mobile-sort select {
    padding: 10px 12px;
    border: 1px solid #996638;
    border-radius: 8px;
    background: #252525;
    color: inherit;
  }
  body.light .ranking-mobile-sort select { background: #fff; }
  #ranking-scroll-hint, #ranking-scroll-top, .ranking-desktop-instructions { display: none; }
  .ranking-mobile-instructions { display: inline; }
  .ranking-table-container { border: 0; border-radius: 0; max-height: none; }
  #ranking-table, #ranking-table tbody { display: block; width: 100%; }
  #ranking-table thead { display: none; }
  #ranking-table caption { display: block; padding: 0 0 12px; white-space: normal; }
  #ranking-table tbody tr {
    display: block;
    margin-bottom: 14px;
    padding: 12px;
    border: 1px solid rgba(128,128,128,.2);
    border-radius: 12px;
    background: rgba(128,128,128,.04);
  }
  #ranking-table tbody td:nth-child(n) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
    align-items: baseline;
    gap: 12px;
    width: auto;
    padding: 9px 0;
    text-align: right;
    white-space: normal;
    overflow-wrap: anywhere;
    position: static;
    background: transparent;
  }
  #ranking-table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    text-align: left;
    color: #a3a3a3;
  }
  body.light #ranking-table tbody td::before { color: #555; }
  #ranking-table .ranking-cell-value, #ranking-table .ranking-account,
  #ranking-table .ranking-account span { min-width: 0; max-width: 100%; }
  #ranking-table .ranking-account { justify-content: flex-end; }
  #ranking-table tbody tr td:nth-child(-n+2) { background: transparent; }
  #ranking-table td:nth-child(1), #ranking-table td:nth-child(2) { font-weight: 700; }
}
