:root {
  color-scheme: dark;
  --bg: #050505;
  --panel: #0c0f10;
  --panel-2: #121617;
  --panel-3: #1a2022;
  --border: #2a3032;
  --muted: #a4aaad;
  --text: #f7f7f7;
  --green: #bbff2a;
  --green-soft: rgba(187, 255, 42, 0.15);
  --blue: #64f1dc;
  --amber: #ffbe4d;
  --red: #ff3c5d;
}

.site-footer.site-legal-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin: 18px 0 0;
  padding: 24px 0 38px;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.site-footer.site-legal-footer a {
  color: inherit;
  font-size: inherit;
  font-weight: 750;
  text-decoration: none;
  text-transform: none;
}

.site-footer.site-legal-footer a:hover,
.site-footer.site-legal-footer a:focus-visible {
  color: var(--green);
  outline: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  min-height: 100vh;
  padding: 0 18px 18px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(260px, 1fr) auto;
  gap: 18px;
  align-items: center;
  min-height: 74px;
  margin: 0 -18px;
  padding: 10px 18px;
  border-bottom: 1px solid #202426;
  background: #000;
}

.brand,
.chart-controls,
.view-actions,
.result-bar,
.site-footer nav {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(187, 255, 42, 0.56);
  background: var(--green-soft);
  color: var(--green);
  font-size: 13px;
  font-weight: 950;
}

.brand-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.brand-copy strong,
.footer-brand strong {
  color: var(--text);
  font-size: 15px;
  font-weight: 950;
  line-height: 1.05;
  text-transform: uppercase;
}

.brand-copy small,
.footer-brand span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.chart-controls {
  gap: 10px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(100%, 560px);
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  background: #0b0d0e;
  color: var(--muted);
}

.search-box input,
.chart-controls select {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.search-box input {
  width: 100%;
  font-size: 14px;
}

.chart-controls select {
  height: 42px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--border);
  background: #0b0d0e;
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.home-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--border);
  background: #0b0d0e;
  color: var(--text);
  font-size: 12px;
  font-weight: 950;
  text-decoration: none;
  text-transform: uppercase;
}

.home-link:hover,
.site-footer a:hover {
  border-color: var(--green);
  color: var(--green);
}

.toolkit-menu {
  position: relative;
  justify-self: end;
  z-index: 40;
  display: grid;
  justify-items: end;
}

.toolkit-menu summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--border);
  background: #0b0d0e;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 950;
  list-style: none;
  text-decoration: none;
  text-transform: uppercase;
  user-select: none;
}

.toolkit-menu summary::-webkit-details-marker {
  display: none;
}

.toolkit-menu summary::after {
  content: "";
  width: 0;
  height: 0;
  margin-left: 8px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
}

.toolkit-menu[open] summary,
.toolkit-menu summary:hover,
.toolkit-menu summary:focus-visible {
  border-color: var(--green);
  color: var(--green);
  outline: none;
}

.toolkit-menu nav {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  gap: 2px;
  width: 260px;
  max-width: calc(100vw - 20px);
  padding: 8px;
  border: 1px solid var(--border);
  background: rgba(5, 5, 5, 0.96);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.36);
}

.toolkit-menu nav a {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
  text-transform: uppercase;
}

.toolkit-menu nav a:hover,
.toolkit-menu nav a:focus-visible,
.toolkit-menu nav a[aria-current="page"] {
  background: #111718;
  color: var(--text);
  outline: none;
}

.toolkit-menu nav a[href*="duellysorted.com"] {
  gap: 8px;
  color: var(--muted);
}

.toolkit-menu nav a[href*="duellysorted.com"]::before {
  content: "";
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  opacity: 0.95;
  background:
    linear-gradient(45deg, transparent 43%, currentColor 44% 55%, transparent 56%),
    linear-gradient(-45deg, transparent 43%, currentColor 44% 55%, transparent 56%);
}

.toolkit-menu nav a[href*="duellysorted.com"]:hover,
.toolkit-menu nav a[href*="duellysorted.com"]:focus-visible {
  background: #111718;
  color: var(--text);
}

.workspace {
  display: block;
  padding-top: 16px;
}

.library-panel {
  min-width: 0;
  border: 1px solid var(--border);
  background: rgba(12, 15, 16, 0.96);
}

.library-panel {
  min-height: calc(100vh - 130px);
  padding: 18px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.section-heading h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(30px, 3.4vw, 54px);
  font-weight: 950;
  line-height: 0.9;
  text-transform: uppercase;
}

.view-actions {
  align-self: start;
  gap: 7px;
  flex: 0 0 auto;
}

.platform-switcher {
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.platform-switcher-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid var(--border);
  background: #0b0d0e;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.icon-button:hover,
.icon-button.active {
  border-color: var(--green);
  background: #111718;
  color: var(--text);
}

.master-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 12px;
}

.master-summary[hidden] {
  display: none;
}

.master-source {
  display: grid;
  gap: 5px;
  min-width: 0;
  min-height: 78px;
  padding: 10px;
  border: 1px solid var(--border);
  background: #090b0c;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
}

.master-source:hover,
.master-source.active {
  border-color: var(--green);
  background: #111718;
  color: var(--text);
}

.master-source span {
  color: var(--green);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.master-source strong {
  color: var(--text);
  font-size: 28px;
  font-weight: 950;
  line-height: 1;
}

.master-source small {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-title span,
.detail-stats span,
.taxonomy h3 {
  color: var(--green);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.result-bar {
  justify-content: space-between;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.chart-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chart-item {
  border: 1px solid transparent;
  background: #090b0c;
}

.chart-item.expanded {
  border-color: var(--green);
  background: #0c1111;
}

.chart-row {
  display: grid;
  grid-template-columns: 54px 86px 64px minmax(0, 1fr) minmax(150px, auto) 96px;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 92px;
  padding: 8px;
  border: 1px solid var(--border);
  background: #090b0c;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.chart-row:hover,
.chart-row.selected {
  border-color: var(--green);
  background: #111718;
}

.chart-item.expanded .chart-row {
  border-color: transparent;
  border-bottom-color: var(--border);
}

.position {
  color: var(--text);
  font-size: 30px;
  font-weight: 950;
  text-align: center;
}

.movement,
.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 7px;
  font-size: 11px;
  font-weight: 950;
  white-space: nowrap;
}

.movement.up,
.status.up {
  color: #ecfff5;
  background: var(--green-soft);
}

.movement.down,
.status.down {
  color: #ffe5ea;
  background: rgba(255, 60, 93, 0.22);
}

.movement.new,
.status.new {
  color: #fff3cb;
  background: rgba(255, 190, 77, 0.2);
}

.movement.same,
.status.same {
  color: #dbe5ff;
  background: rgba(100, 241, 220, 0.18);
}

.row-artwork,
.artwork-placeholder {
  width: 54px;
  height: 74px;
  object-fit: cover;
  background: linear-gradient(135deg, #1b252b, #101518);
}

.app-artwork {
  object-fit: contain;
  padding: 6px;
  border: 1px solid #243034;
}

.artwork-placeholder {
  display: grid;
  place-items: center;
  border: 1px solid #243034;
  color: var(--green);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.game-copy {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.game-copy strong {
  overflow: hidden;
  color: var(--text);
  font-size: 17px;
  font-weight: 950;
  line-height: 1.16;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-copy small,
.previous {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.access-tags {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.access-tags em,
.taxonomy span {
  padding: 4px 7px;
  background: var(--panel-3);
  color: #d4dde0;
  font-size: 11px;
  font-style: normal;
  font-weight: 850;
}

.previous {
  text-align: right;
}

.inline-detail {
  padding: 16px;
  border-top: 1px solid rgba(187, 255, 42, 0.22);
  background: #080a0a;
}

.inline-detail-grid {
  display: grid;
  grid-template-columns: minmax(240px, 420px) 1fr;
  gap: 18px;
  align-items: stretch;
}

.hero-frame {
  position: relative;
  min-height: 280px;
  background: #090b0c;
}

.hero-frame img,
.hero-artwork {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-frame img.app-artwork,
.hero-artwork.app-artwork {
  object-fit: contain;
}

.hero-shadow {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 30%, rgba(5, 5, 5, 0.94));
}

.hero-frame .status {
  position: absolute;
  left: 14px;
  bottom: 14px;
}

.detail-body {
  min-width: 0;
  padding: 0;
}

.detail-title h2 {
  margin: 4px 0 14px;
  color: var(--text);
  font-size: 27px;
  line-height: 1.08;
}

.detail-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.detail-stats div {
  padding: 12px;
  border: 1px solid var(--border);
  background: #090b0c;
}

.detail-stats strong {
  display: block;
  margin-top: 5px;
  color: var(--text);
  font-size: 18px;
  line-height: 1.1;
}

.signal-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.signal-card {
  display: grid;
  gap: 6px;
  min-width: 0;
  min-height: 94px;
  padding: 10px;
  border: 1px solid var(--border);
  background: #090b0c;
  color: var(--text);
  text-decoration: none;
}

.signal-card:hover,
.signal-card:focus-visible {
  border-color: var(--green);
}

.signal-card-twitch {
  border: 1px solid color-mix(in srgb, #9146ff 54%, var(--border));
  background: color-mix(in srgb, #9146ff 12%, #090b0c);
}

.signal-heading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
  white-space: nowrap;
}

.signal-card > strong {
  overflow: hidden;
  color: var(--text);
  font-size: 18px;
  font-weight: 950;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.signal-card > small {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.signal-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}

.signal-metrics span {
  display: inline-flex;
  gap: 4px;
  min-width: 0;
  padding: 4px 6px;
  background: rgba(5, 5, 5, 0.34);
}

.signal-metrics em {
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
  text-transform: uppercase;
}

.signal-metrics b {
  overflow: hidden;
  color: var(--text);
  font-size: 10px;
  font-weight: 950;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.taxonomy {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.taxonomy div {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.regional-ranks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rank-pill {
  display: inline-grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  column-gap: 7px;
  row-gap: 0;
  align-items: center;
  min-width: 72px;
  min-height: 48px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  background: #090b0c;
  color: var(--text);
  font-weight: 900;
  text-decoration: none;
}

a.rank-pill:hover,
a.rank-pill:focus-visible {
  border-color: var(--green);
  background: #111718;
}

.rank-flag,
.rank-logo {
  grid-row: 1 / 3;
}

.rank-flag {
  font-size: 22px;
  line-height: 1;
}

.rank-logo {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid color-mix(in srgb, var(--logo-color, var(--green)) 72%, #000);
  background: color-mix(in srgb, var(--logo-color, var(--green)) 18%, #050505);
  color: #f8fff8;
  overflow: hidden;
}

.rank-logo::before,
.rank-logo::after {
  content: "";
  position: absolute;
  box-sizing: border-box;
}

.rank-logo::before {
  inset: 5px;
  background: currentColor;
  -webkit-mask: var(--platform-icon) center / contain no-repeat;
  mask: var(--platform-icon) center / contain no-repeat;
}

.rank-logo::after {
  display: none;
}

.rank-logo-xbox {
  --logo-color: #107c10;
  --platform-icon: url("assets/platform-icons/xbox.svg");
  border-radius: 50%;
}

.rank-logo-steam {
  --logo-color: #66c0f4;
  --platform-icon: url("assets/platform-icons/steam.svg");
  border-radius: 50%;
}

.rank-logo-playstation {
  --logo-color: #006fcd;
  --platform-icon: url("assets/platform-icons/playstation.svg");
  border-radius: 5px;
}

.rank-logo-nintendo {
  --logo-color: #e60012;
  --platform-icon: url("assets/platform-icons/nintendo.svg");
  gap: 3px;
  border-radius: 7px;
}

.rank-logo-twitch {
  --logo-color: #9146ff;
  --platform-icon: url("assets/platform-icons/twitch.svg");
  border-radius: 6px;
}

.rank-pill strong {
  color: var(--green);
  font-size: 18px;
  line-height: 1;
}

.rank-pill small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
}

.empty-state button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 13px;
  background: var(--green);
  color: #03120c;
  font-size: 13px;
  font-weight: 950;
  text-decoration: none;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 320px;
  padding: 30px;
  border: 1px dashed var(--border);
  color: var(--muted);
  text-align: center;
}

.empty-state[hidden] {
  display: none;
}

.empty-state h2 {
  margin: 12px 0 0;
  color: var(--text);
}

.site-footer {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 18px;
  align-items: center;
  margin: 18px -18px -18px;
  padding: 24px 18px;
  border-top: 1px solid #202426;
  background: #000;
}

.footer-brand {
  display: grid;
  gap: 4px;
}

.site-footer nav {
  justify-content: flex-end;
  gap: 18px;
  flex-wrap: wrap;
}

.site-footer a {
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
  text-transform: uppercase;
}

@media (max-width: 1180px) {
  .topbar {
    grid-template-columns: 190px 1fr auto;
  }

  .inline-detail-grid {
    grid-template-columns: 320px 1fr;
  }

  .detail-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .master-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .app-shell {
    padding: 0 10px 10px;
  }

  .topbar {
    position: static;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 10px;
    min-height: 68px;
    margin: 0 -10px;
    padding: 9px 10px;
  }

  .brand {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }

  .home-link {
    grid-column: 2;
    grid-row: 1;
    min-height: 40px;
    align-self: center;
  }

  .toolkit-menu {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
    justify-self: end;
  }

  .chart-controls {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(112px, 155px);
    gap: 8px;
    align-items: stretch;
  }

  .platform-switcher {
    flex-wrap: wrap;
    justify-content: flex-start;
    overflow-x: visible;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .platform-switcher::-webkit-scrollbar {
    display: none;
  }

  .platform-switcher-label {
    flex: 0 0 100%;
  }

  .platform-switcher .icon-button {
    flex: 1 1 calc(33.333% - 6px);
    min-width: 0;
    padding: 0 8px;
  }

  .master-summary {
    grid-template-columns: repeat(5, minmax(70px, 1fr));
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .master-summary::-webkit-scrollbar {
    display: none;
  }

  .master-source {
    min-height: 70px;
  }

  .master-source strong {
    font-size: 23px;
  }

  .master-source small {
    display: none;
  }

  .search-box,
  .chart-controls select {
    width: 100%;
  }

  .chart-controls select {
    padding: 0 28px 0 10px;
    font-size: 11px;
  }

  .workspace {
    padding-top: 12px;
  }

  .library-panel {
    min-height: 0;
    padding: 13px;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-heading h1 {
    font-size: 36px;
  }

  .view-actions {
    width: 100%;
    overflow-x: visible;
  }

  .chart-row {
    grid-template-columns: 44px 70px 50px minmax(0, 1fr);
    gap: 8px;
  }

  .inline-detail {
    padding: 12px;
  }

  .inline-detail-grid {
    grid-template-columns: 1fr;
  }

  .hero-frame {
    min-height: 220px;
  }

  .access-tags,
  .previous {
    grid-column: 4;
    justify-content: flex-start;
    text-align: left;
  }

  .position {
    font-size: 25px;
  }

  .game-copy strong {
    white-space: normal;
  }

  .row-artwork,
  .artwork-placeholder {
    width: 50px;
    height: 68px;
  }
}

@media (max-width: 540px) {
  .platform-switcher .icon-button {
    flex-basis: calc(50% - 5px);
    font-size: 11px;
  }

  .section-heading h1 {
    font-size: 31px;
  }

  .result-bar {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .chart-row {
    grid-template-columns: 38px 62px 44px minmax(0, 1fr);
  }

  .detail-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .detail-stats div {
    min-width: 0;
    padding: 8px 6px;
  }

  .detail-stats span {
    font-size: 8px;
    line-height: 1.15;
    overflow-wrap: anywhere;
  }

  .detail-stats strong {
    font-size: 15px;
    line-height: 1.05;
    overflow-wrap: anywhere;
  }

  .signal-grid {
    grid-template-columns: 1fr;
  }

  .signal-card {
    gap: 8px;
    padding: 8px;
  }

  .signal-heading {
    font-size: 11px;
  }

  .signal-metrics em,
  .signal-metrics b {
    font-size: 8px;
    line-height: 1.15;
  }

  .movement {
    min-height: 24px;
    padding: 3px 5px;
    font-size: 10px;
  }

  .site-footer {
    grid-template-columns: 1fr;
    margin: 12px -10px -10px;
  }

  .site-footer nav {
    justify-content: flex-start;
  }
}

.site-footer.site-legal-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin: 18px 0 0;
  padding: 24px 0 38px;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.site-footer.site-legal-footer a {
  color: inherit;
  font-size: inherit;
  font-weight: 750;
  text-decoration: none;
  text-transform: none;
}

.site-footer.site-legal-footer a:hover,
.site-footer.site-legal-footer a:focus-visible {
  color: var(--green);
  outline: none;
}
