:root {
  color-scheme: dark;
  --bg: #050505;
  --panel: #0c0f10;
  --panel-2: #121617;
  --panel-3: #1a2022;
  --border: #2a3032;
  --muted: #a4aaad;
  --text: #f7f7f7;
  --green: #00ba74;
  --green-soft: rgba(0, 186, 116, 0.16);
  --blue: #4c76ff;
  --amber: #ffbc00;
  --red: #ff3c5d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: linear-gradient(180deg, rgba(0, 186, 116, 0.1), transparent 340px), 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,
.content-actions,
.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(0, 186, 116, 0.52);
  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);
}

.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;
}

.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);
}

.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, 188, 0, 0.2);
}

.movement.same,
.status.same {
  color: #dbe5ff;
  background: rgba(76, 118, 255, 0.2);
}

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

.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(0, 186, 116, 0.22);
  background: linear-gradient(180deg, rgba(0, 186, 116, 0.08), transparent 70%), #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-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;
}

.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;
}

.rank-flag {
  grid-row: 1 / 3;
  font-size: 22px;
  line-height: 1;
}

.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;
}

.content-actions {
  gap: 8px;
  margin-top: 16px;
}

.content-actions a,
.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));
  }
}

@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;
  }

  .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;
  }

  .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: auto;
  }

  .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) {
  .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;
  }

  .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;
  }
}
