:root {
  color-scheme: light;
  --paper: #fff7e6;
  --paper-2: #fffdf2;
  --ink: #171717;
  --muted: #6f6758;
  --line: #231f20;
  --shadow: #d7c5a4;
  --red: #ef3f25;
  --blue: #1d74ff;
  --green: #18a760;
  --orange: #ff9f1c;
  --yellow: #ffd93d;
  --gray: #ece2cc;
  --radius: 8px;
  font-family: "Arial Black", "Microsoft YaHei", "PingFang SC", ui-sans-serif, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(35, 31, 32, 0.04) 1px, transparent 1px),
    linear-gradient(rgba(35, 31, 32, 0.04) 1px, transparent 1px),
    var(--paper);
  background-size: 16px 16px;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  border: 4px solid var(--line);
  background: var(--paper);
}

.side-rail {
  min-height: 100vh;
  padding: 28px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 17px;
  background: var(--paper-2);
  border-right: 4px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 4px solid var(--line);
  border-radius: var(--radius);
  background: var(--red);
  color: #fff;
  box-shadow: 4px 4px 0 var(--shadow);
  font-size: 28px;
  font-weight: 950;
}

.brand-name {
  display: flex;
  align-items: baseline;
  gap: 3px;
  font-size: 27px;
  font-weight: 950;
  line-height: 0.95;
}

.brand-name span:first-child {
  font-size: 34px;
}

.brand-subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.35;
}

.main-nav,
.meta-nav {
  display: grid;
  gap: 8px;
}

.nav-item,
.meta-nav a {
  min-height: 38px;
  border: 3px solid transparent;
  border-radius: 5px;
  padding: 8px 10px;
  font-weight: 900;
}

.nav-item.is-active,
.nav-item:hover,
.meta-nav a:hover {
  background: var(--red);
  border-color: var(--line);
  color: #fff;
  box-shadow: 4px 4px 0 var(--shadow);
}

.meta-nav {
  border-top: 2px solid #ddceb2;
  border-bottom: 2px solid #ddceb2;
  padding: 11px 0;
}

.controller-art {
  width: 190px;
  max-width: 100%;
  height: auto;
  display: block;
  margin: 24px auto 0 -6px;
  image-rendering: pixelated;
}

.privacy-box {
  margin-top: auto;
  border: 3px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
  background: var(--paper);
  box-shadow: 4px 4px 0 var(--shadow);
}

.privacy-title {
  margin-bottom: 8px;
  font-weight: 950;
}

.privacy-box p,
.season-board p,
.panel-heading p,
.side-card p,
.doc-card p,
.doc-card li {
  margin: 0;
  color: var(--muted);
  line-height: 1.58;
}

.privacy-box p {
  font-size: 12px;
}

.main-surface {
  min-width: 0;
  max-width: 100vw;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.1;
  font-weight: 950;
  text-shadow: 2px 2px 0 rgba(35, 31, 32, 0.12);
}

h2 {
  font-size: 16px;
  font-weight: 950;
}

h3 {
  font-size: 14px;
  font-weight: 950;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--red);
  font-size: 12px;
  font-weight: 950;
}

.season-board {
  display: grid;
  grid-template-columns: minmax(300px, 1.3fr) 220px 280px minmax(320px, 1fr);
  gap: 0;
  align-items: stretch;
  border: 4px solid var(--line);
  border-radius: 13px;
  background: var(--paper-2);
  box-shadow: inset 0 0 0 2px #fff7e7, 6px 6px 0 var(--shadow);
  min-height: 128px;
  overflow: hidden;
}

.season-intro,
.season-countdown,
.season-score {
  padding: 18px;
  position: relative;
}

.season-intro,
.countdown-content,
.season-score-actions,
.user-cell,
.tier-cell {
  display: flex;
  align-items: center;
}

.season-intro {
  gap: 12px;
}

.season-intro::after,
.season-countdown::after,
.season-score::after {
  content: "";
  position: absolute;
  right: 0;
  top: 14px;
  bottom: 14px;
  border-right: 3px dashed rgba(35, 31, 32, 0.28);
}

.season-score::after {
  display: none;
}

.season-trophy {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(4px 4px 0 rgba(35, 31, 32, 0.18));
}

.season-countdown > span,
.season-score > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
}

.countdown-content {
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.countdown-content strong,
.season-score strong {
  display: block;
  font-size: 34px;
  line-height: 1;
  font-weight: 950;
}

.countdown-content span,
.season-score small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.kart-asset {
  width: 82px;
  height: auto;
  image-rendering: pixelated;
}

.season-score-actions {
  gap: 10px;
  margin-top: 10px;
}

.top-sync-status {
  min-width: 106px;
  display: grid;
  grid-template-columns: 9px 1fr;
  column-gap: 7px;
  align-items: center;
}

.top-sync-status > span,
.sync-dot {
  width: 9px;
  height: 9px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--green);
}

.top-sync-status small {
  grid-column: 2;
}

.sync-button,
.apply-button,
.pager button {
  min-height: 36px;
  border: 3px solid var(--line);
  border-radius: var(--radius);
  background: var(--yellow);
  color: var(--ink);
  padding: 0 14px;
  cursor: pointer;
  font-weight: 950;
  box-shadow: 3px 3px 0 var(--shadow);
}

.sync-button:disabled,
.pager button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.tier-track {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  align-content: center;
  padding: 14px;
}

.tier-node {
  min-width: 0;
  min-height: 82px;
  border: 3px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 7px;
  text-align: center;
  box-shadow: 3px 3px 0 rgba(35, 31, 32, 0.1);
  opacity: 0.58;
}

.tier-node.is-cleared {
  opacity: 1;
}

.tier-node.is-active {
  background: #fff1bf;
  box-shadow: 4px 4px 0 var(--orange);
}

.tier-emblem,
.tier-mini {
  object-fit: contain;
  image-rendering: pixelated;
}

.tier-emblem {
  width: 28px;
  height: 28px;
}

.tier-node span,
.tier-node small {
  display: block;
  overflow-wrap: anywhere;
}

.tier-node span {
  margin-top: 2px;
  font-size: 11px;
  font-weight: 950;
}

.tier-node small {
  color: var(--muted);
  font-size: 10px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 4px solid var(--line);
  border-radius: 13px;
  background: var(--paper-2);
  box-shadow: 5px 5px 0 var(--shadow);
  padding: 12px;
}

.scope-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tab {
  min-height: 38px;
  border: 3px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 0 14px;
  cursor: pointer;
  font-weight: 950;
}

.tab.is-active {
  background: var(--red);
  color: #fff;
}

.region-fields {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.region-fields label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
}

.region-fields input {
  width: 136px;
  min-height: 36px;
  border: 3px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 0 9px;
  font-weight: 900;
}

.region-fields input:disabled {
  background: var(--gray);
  color: #958b78;
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric,
.leaderboard-panel,
.side-card,
.doc-card {
  border: 4px solid var(--line);
  border-radius: 13px;
  background: var(--paper-2);
  box-shadow: 5px 5px 0 var(--shadow);
}

.metric {
  min-height: 86px;
  padding: 14px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 24px;
  line-height: 1;
  font-weight: 950;
  overflow-wrap: anywhere;
}

.content-grid {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
  align-items: start;
}

.leaderboard-panel {
  min-width: 0;
  overflow: hidden;
}

.panel-heading {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 4px solid var(--line);
  background: #fff3d3;
}

.data-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
  white-space: nowrap;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 1160px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 2px solid #e3d5bb;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.rank {
  width: 58px;
}

.rank-medal {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 3px solid var(--line);
  border-radius: 50%;
  background: #fff;
}

.rank-medal img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  image-rendering: pixelated;
}

.rank-gold {
  background: #fff0a6;
}

.rank-silver {
  background: #f0f3f7;
}

.rank-bronze {
  background: #ffd3a7;
}

.user-cell {
  gap: 10px;
}

.avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: 3px solid var(--line);
  border-radius: 50%;
  background: #fff;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
}

.user-cell strong,
.tier-cell strong {
  display: block;
  font-size: 13px;
  font-weight: 950;
}

.user-cell small,
.tier-cell span,
.combo-mix small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.tier-cell {
  gap: 8px;
}

.tier-mini {
  width: 28px;
  height: 28px;
}

.agent-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 3px solid var(--line);
  border-radius: 999px;
  padding: 0 9px;
  background: #fff;
  font-size: 12px;
  font-weight: 950;
  white-space: nowrap;
}

.agent-badge.codex {
  background: #dff7e8;
}

.agent-badge.claude {
  background: #ffe4bf;
}

.agent-badge.multi {
  background: #dceaff;
}

.combo-mix {
  min-width: 132px;
}

.combo-bar {
  width: 100%;
  height: 18px;
  display: flex;
  overflow: hidden;
  border: 3px solid var(--line);
  border-radius: 999px;
  background: #fff;
}

.combo-segment {
  min-width: 4px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 10px;
  font-weight: 950;
}

.codex {
  background: var(--green);
}

.claude {
  background: var(--orange);
}

.multi {
  background: var(--blue);
}

.power-stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.power-stat i {
  width: 10px;
  height: 10px;
  border: 2px solid var(--line);
  background: var(--yellow);
  transform: rotate(45deg);
}

.sync-dot {
  display: inline-block;
  margin-right: 6px;
}

.empty-state {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  font-weight: 900;
}

.empty-state.compact {
  padding: 12px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 16px;
}

.pager span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
}

.insight-panel {
  display: grid;
  gap: 14px;
}

.side-card {
  padding: 16px;
}

.side-card h2,
.side-card h3 {
  margin-bottom: 10px;
}

.side-card small {
  color: var(--muted);
}

.agent-breakdown {
  display: grid;
  gap: 9px;
}

.donut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 2px solid #e3d5bb;
  font-size: 12px;
  font-weight: 900;
}

.donut-row:last-child {
  border-bottom: 0;
}

.donut-row span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.donut-row i {
  width: 12px;
  height: 12px;
  display: inline-block;
  border: 2px solid var(--line);
  border-radius: 50%;
}

.text-link {
  display: inline-flex;
  margin-top: 10px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 950;
}

.doc-shell {
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding: 32px 18px;
}

.doc-main {
  width: min(920px, 100%);
  display: grid;
  gap: 14px;
}

.doc-card {
  padding: 22px;
}

.doc-card h1 {
  margin-bottom: 10px;
}

.doc-card h2 {
  margin: 18px 0 8px;
}

.doc-card ul {
  margin: 0;
  padding-left: 20px;
}

.doc-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.doc-actions a {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  border: 3px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  background: var(--yellow);
  font-weight: 950;
  box-shadow: 3px 3px 0 var(--shadow);
}

@media (max-width: 1460px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-rail {
    min-height: auto;
    border-right: 0;
    border-bottom: 4px solid var(--line);
  }

  .controller-art,
  .privacy-box {
    display: none;
  }

  .season-board,
  .insight-panel {
    grid-template-columns: 1fr;
  }

  .season-intro::after,
  .season-countdown::after,
  .season-score::after {
    display: none;
  }

  .tier-track {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .main-surface {
    padding: 12px;
  }

  .brand-name {
    font-size: 24px;
  }

  h1 {
    font-size: 24px;
  }

  .toolbar,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

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

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

  .region-fields,
  .region-fields label,
  .region-fields input,
  .apply-button {
    width: 100%;
  }
}
