:root {
  color-scheme: light;
  --bg: #fafafa; --surface: #fff; --surface-subtle: #fcfcfc; --hover: #f7f7f8;
  --ink: #202024; --muted: #85858e; --line: #e8e8ec; --selected: #f0f0f3;
  --focus: #7c9ef5; --blue: #4c78df; --green: #29aa72; --yellow: #d6a235; --red: #dc5d5d;
  --scroll-thumb: #20202424; --scroll-hover: #20202440;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
:root[data-theme=dark] {
  color-scheme: dark;
  --bg: #161617; --surface: #1b1b1e; --surface-subtle: #1e1e21; --hover: #232326;
  --ink: #e8e8ec; --muted: #82828c; --line: #2c2c31; --selected: #303035;
  --focus: #829ff5; --green: #58c992; --yellow: #dab66a; --red: #e67b7b;
  --scroll-thumb: #e8e8ec24; --scroll-hover: #e8e8ec40;
}
* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-hover); }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 13px; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button, a, input, summary { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: wait; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.shell { max-width: 1100px; padding: 0 40px; margin: auto; }
.icon-definitions { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.topbar { height: 88px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { font-size: 16px; font-weight: 650; letter-spacing: -.45px; }
.header-actions, .dialog-actions { display: flex; align-items: center; gap: 4px; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 7px; background: transparent; color: var(--muted); transition: background .15s, color .15s; }
.icon-button:hover { background: var(--hover); color: var(--ink); }
.heading { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin: 40px 0 23px; position: relative; }
.heading-label { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
h1 { font-size: 24px; font-weight: 600; letter-spacing: -.7px; margin: 0; }
.as-of { display: flex; align-items: center; gap: 6px; font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.status-dot { width: 5px; height: 5px; background: var(--green); border-radius: 50%; flex-shrink: 0; }
.status-dot.stale { background: var(--yellow); }
.status-dot.unavailable { background: var(--muted); }
.notice { padding: 10px 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; font-size: 12px; color: var(--muted); margin-bottom: 14px; line-height: 1.7; }
.notice.error, .error { color: var(--red); }
.ranking { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.toolbar { display: flex; align-items: center; gap: 24px; min-width: 0; }
.tabs { display: flex; align-items: center; gap: 2px; padding: 3px; background: var(--selected); border-radius: 7px; flex-shrink: 0; }
.tabs button { border: 0; border-radius: 5px; padding: 6px 13px; background: transparent; color: var(--muted); font-size: 12px; line-height: 18px; white-space: nowrap; }
.tabs button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px #0000000b; }
.tabs button:hover { color: var(--ink); }
.tools { display: flex; align-items: center; gap: 10px; min-width: 0; }
.search { display: flex; align-items: center; gap: 8px; width: 158px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); }
.search .icon { width: 14px; height: 14px; }
.search input { width: 100%; min-width: 0; border: 0; outline: none; background: transparent; color: var(--ink); font-size: 12px; }
.search input::placeholder { color: var(--muted); }
.search:focus-within { border-color: var(--focus); }
.author-filter { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.author-filter .icon { width: 14px; height: 14px; }
.author-filter select { border: 0; background: var(--bg); color: var(--muted); font-size: 12px; max-width: 120px; padding: 5px 0; cursor: pointer; }
.table-wrap { overflow-x: auto; overscroll-behavior-x: contain; }
table { border-collapse: collapse; width: 100%; text-align: left; white-space: nowrap; }
thead { background: var(--surface-subtle); }
th { font-weight: 400; font-size: 11px; color: var(--muted); height: 42px; padding: 0 18px; border-bottom: 1px solid var(--line); }
th.selected { color: var(--ink); }
td { padding: 20px 18px; border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: var(--hover); }
.game-row { cursor: pointer; }
.rank-column { width: 46px; padding-left: 22px; padding-right: 8px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.game-column { min-width: 185px; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.sort-button { display: inline-flex; align-items: center; justify-content: flex-end; gap: 4px; width: 100%; min-height: 42px; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; }
.sort-button:hover { color: var(--ink); }
.sort-arrow { width: 12px; height: 12px; visibility: hidden; }
.selected .sort-arrow { visibility: visible; }
td.numeric { font-size: 12px; color: var(--muted); font-weight: 450; letter-spacing: -.1px; }
td.numeric.selected { color: var(--ink); font-weight: 600; }
td.numeric:last-child, th.numeric:last-child { padding-right: 22px; }
.game-cell { display: flex; align-items: center; gap: 11px; min-width: 0; }
.game-logo, .avatar { position: relative; display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; background: var(--selected); color: var(--muted); }
.game-logo { width: 39px; height: 39px; border-radius: 10px; font-size: 15px; }
.game-logo img, .avatar img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; }
.game-text { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.game-name { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 550; line-height: 1.4; }
.game-open { max-width: 205px; padding: 0; border: 0; font: inherit; color: inherit; background: transparent; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.game-open:hover { color: var(--muted); }
.game-name .status-dot { margin-left: 1px; }
.row-author { display: inline-flex; align-items: center; gap: 7px; max-width: 155px; font-size: 11px; color: var(--muted); vertical-align: middle; line-height: 1.5; }
.row-author:hover { color: var(--ink); }
.row-author .author-name { max-width: 118px; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 22px; height: 22px; border-radius: 50%; font-size: 10px; }
.authors-inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mobile-authors { display: none; }
.value-missing { color: var(--muted) !important; font-weight: 400 !important; }
.ranking-footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 48px; border-top: 1px solid var(--line); padding: 0 22px; color: var(--muted); font-size: 10px; }
.ranking-footer > div { display: flex; align-items: center; gap: 10px; }
.footer-separator { height: 10px; width: 1px; background: var(--line); }
.sum-mark { font-size: 13px; }
.ranking-footer strong { color: var(--ink); font-weight: 500; font-size: 11px; font-variant-numeric: tabular-nums; }
.updated { display: flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; }
.updated .icon { width: 12px; height: 12px; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); font-size: 12px; }
.refreshing .icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.manage-entry { position: fixed; right: max(24px, env(safe-area-inset-right)); bottom: max(22px, env(safe-area-inset-bottom)); width: 32px; height: 32px; border: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: transparent; color: var(--muted); opacity: .28; transition: opacity .2s, background .2s; }
.manage-entry:hover, .manage-entry:focus-visible { opacity: 1; background: var(--selected); }
dialog { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; padding: 24px; max-height: calc(100dvh - 48px); overflow-y: auto; box-shadow: 0 20px 100px #00000018; }
dialog::backdrop { background: #00000032; backdrop-filter: blur(3px); }
.detail-dialog { width: min(780px, calc(100vw - 36px)); }
.admin-dialog { width: min(530px, calc(100vw - 36px)); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
h2 { font-size: 17px; font-weight: 600; margin: 0; line-height: 1.5; }
.detail-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.detail-title .game-logo { width: 43px; height: 43px; }
.detail-heading { min-width: 0; }
.detail-heading h2 { overflow-wrap: anywhere; }
.detail-heading .authors-inline { margin-top: 5px; }
.detail-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; padding: 0 0 27px; border-bottom: 1px solid var(--line); }
.detail-metric { display: flex; flex-direction: column; align-items: flex-start; gap: 9px; }
.detail-metric > span { color: var(--muted); font-size: 11px; }
.detail-metric strong { font-size: 22px; font-weight: 550; font-variant-numeric: tabular-nums; letter-spacing: -.6px; }
.detail-metric small { font-size: 10px; color: var(--muted); margin-top: -3px; }
.detail-metric .positive { color: var(--green); }
.detail-metric .negative { color: var(--red); }
.positive { color: var(--green); }
.negative { color: var(--red); }
.revenue-growth { display: block; margin-top: 7px; font-size: 10px; font-weight: 400; letter-spacing: 0; }
.rank-movement { display: block; font-size: 9px; margin-top: 6px; }
.export-dialog { width: min(550px, calc(100vw - 36px)); }
.export-dialog .dialog-header { margin-bottom: 18px; }
.export-preview { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; }
.export-status { color: var(--muted); font-size: 11px; line-height: 1.6; margin: 12px 0 0; }
.export-status:empty { display: none; }
.export-status.error { color: var(--red); }
.export-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.export-tabs { margin-bottom: 18px; width: fit-content; }
.asset-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.asset-tile { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.asset-tile img { width: 100%; height: 210px; display: block; object-fit: contain; background: var(--hover); }
.asset-tile.logo img { padding: 38px; }
.asset-controls { display: flex; align-items: center; padding: 5px 8px; gap: 2px; }
.asset-controls > span { flex: 1; font-size: 11px; color: var(--muted); }
.chart-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 23px 0 8px; }
.chart-toolbar .tabs button { font-size: 11px; padding: 4px 12px; }
.chart-ranges { display: flex; gap: 4px; }
.chart-ranges button { background: transparent; border: 0; border-radius: 5px; color: var(--muted); font-size: 11px; padding: 5px 8px; }
.chart-ranges button.active { color: var(--ink); background: var(--hover); }
.chart { position: relative; min-height: 180px; }
.chart > svg { width: 100%; display: block; touch-action: pan-y; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-label { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart-line { stroke: var(--blue); stroke-width: 2; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.chart-point { fill: var(--blue); stroke: var(--surface); stroke-width: 1.5; }
.chart-cross { stroke: var(--muted); stroke-dasharray: 4 4; opacity: .4; }
.chart-empty { height: 180px; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.chart-tooltip { position: absolute; top: 12px; display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 3px 16px #0000000a; border-radius: 7px; padding: 10px 12px; transform: translateX(-50%); pointer-events: none; color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.chart-tooltip strong { color: var(--ink); font-size: 12px; font-weight: 500; }
.detail-footer { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 10px; border-top: 1px solid var(--line); padding-top: 18px; margin-top: 6px; }
.primary-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 12px; border-radius: 6px; padding: 8px 13px; line-height: 18px; }
.primary-button { border: 1px solid var(--ink); color: var(--surface); background: var(--ink); }
.secondary-button { border: 1px solid var(--line); color: var(--ink); background: transparent; }
.secondary-button:hover { background: var(--hover); }
.secondary-button .icon { width: 13px; height: 13px; }
.login-form { display: flex; flex-direction: column; gap: 18px; }
.login-form .primary-button { align-self: flex-end; }
.form-field { display: flex; flex-direction: column; gap: 9px; font-size: 11px; color: var(--muted); min-width: 0; }
.form-field input, .bindings select { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 10px 11px; background: var(--surface); color: var(--ink); font-size: 12px; min-width: 0; }
.form-field input:disabled { color: var(--muted); background: var(--hover); }
.form-field input::placeholder { color: var(--muted); }
.admin-message { font-size: 11px; color: var(--muted); line-height: 1.7; margin: 14px 0 0; }
.admin-message.error { color: var(--red); }
.admin-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.admin-toolbar .tabs button { padding: 4px 15px; }
.admin-collection { display: flex; align-items: center; gap: 6px; margin-top: 12px; font-size: 11px; color: var(--muted); }
.admin-collection.error { color: var(--red); }
.admin-collection .icon-button { width: 24px; height: 24px; }
.admin-collection .icon { width: 12px; height: 12px; }
.collecting .icon { animation: collect-spin 1.5s linear infinite; }
@keyframes collect-spin { to { transform: rotate(360deg); } }
.admin-list { max-height: 400px; overflow-y: auto; }
.admin-row { display: flex; align-items: center; gap: 12px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.admin-row:last-child { border-bottom: 0; }
.admin-row .game-logo { width: 33px; height: 33px; border-radius: 8px; }
.admin-row .avatar { width: 28px; height: 28px; }
.admin-row-text { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.admin-row-text strong { font-size: 12px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-row-text > span { font-size: 10px; color: var(--muted); }
.form-fields { display: grid; gap: 19px; }
.lookup-field { position: relative; }
.lookup-field input { padding-right: 43px; }
.lookup-field .icon-button { position: absolute; right: 4px; bottom: 3px; }
.bindings { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.bindings legend { padding: 0; margin-bottom: 10px; font-size: 11px; color: var(--muted); }
.binding-option { display: flex; align-items: center; gap: 8px; font-size: 12px; cursor: pointer; }
.binding-option input { accent-color: var(--ink); }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 24px; }
@media(max-width: 1000px) {
  .heading-label { gap: 10px; }
  .toolbar { gap: 12px; }
  .search { width: 136px; }
  td, th { padding-left: 12px; padding-right: 12px; }
  .author-column { max-width: 135px; }
  .row-author { max-width: 130px; }
  .row-author .author-name { max-width: 90px; }
  .game-open { max-width: 165px; }
}
@media(max-width: 850px) { .heading .as-of { display: none; } }
@media(max-width: 700px) {
  .shell { padding: 0 18px; }
  .topbar { height: 72px; }
  .heading { margin: 30px 0 20px; gap: 10px; }
  h1 { font-size: 21px; white-space: nowrap; }
  .heading-tools { gap: 8px; }
  .tools { gap: 4px; }
  .search { width: 30px; height: 30px; border-color: transparent; padding: 7px; gap: 0; cursor: pointer; }
  .search input { width: 0; opacity: 0; }
  .search:focus-within { position: absolute; left: 0; right: 33px; width: auto; background: var(--surface); border-color: var(--focus); z-index: 2; gap: 8px; }
  .search:focus-within input { width: 100%; opacity: 1; }
  .tools > .icon-button { width: 27px; }
  .author-filter { position: absolute; right: 0; top: 41px; }
  .heading:has(.author-filter:not([hidden])) { margin-bottom: 51px; }
  .author-filter select { font-size: 11px; }
  .author-column { display: none; }
  .mobile-authors { display: flex; gap: 7px; flex-wrap: wrap; max-width: 150px; }
  .mobile-authors .row-author { font-size: 10px; gap: 5px; max-width: 165px; }
  .mobile-authors .avatar { width: 16px; height: 16px; font-size: 8px; }
  .mobile-authors .author-name { max-width: 135px; }
  .table-wrap table { min-width: 520px; }
  th { height: 38px; font-size: 10px; }
  .sort-button { min-height: 38px; }
  td { padding-top: 17px; padding-bottom: 17px; }
  .rank-column { width: 27px; padding-left: 14px; padding-right: 4px; }
  .game-column { min-width: 0; }
  .game-cell { gap: 9px; }
  .game-logo { width: 35px; height: 35px; border-radius: 9px; }
  .game-name { font-size: 12px; }
  .game-open { max-width: 150px; }
  .game-text { gap: 5px; }
  td.numeric { font-size: 11px; white-space: nowrap; }
  td.numeric, th.numeric { min-width: 100px; padding-left: 10px; padding-right: 10px; }
  td.numeric:last-child, th.numeric:last-child { padding-right: 14px; }
  .ranking-footer { padding: 0 14px; gap: 10px; font-size: 9px; }
  .ranking-footer > div { gap: 7px; }
  .ranking-footer strong { font-size: 10px; }
  .updated .icon { width: 11px; height: 11px; }
  dialog { padding: 20px; max-height: calc(100dvh - 32px); }
  .dialog-header { margin-bottom: 23px; gap: 6px; }
  .detail-title { gap: 10px; }
  .detail-heading h2 { font-size: 15px; }
  .detail-metrics { gap: 14px; padding-bottom: 23px; }
  .detail-metric { gap: 9px; }
  .detail-metric strong { font-size: 16px; letter-spacing: -.5px; }
  .detail-metric small { font-size: 9px; }
  .revenue-growth { font-size: 9px; margin-top: 6px; }
  .asset-tile img { height: 158px; }
  .asset-tile.logo img { padding: 25px; }
  .asset-controls { padding-left: 6px; padding-right: 4px; }
  .asset-controls .icon-button { width: 25px; }
  .detail-heading { flex: 1; }
  .detail-title { flex: 1; }
  .detail-heading h2 { font-size: 14px; }
  .dialog-actions { gap: 0; }
  .dialog-actions .icon-button { width: 27px; }
  .chart { min-height: 170px; margin-left: -10px; margin-right: -10px; }
  .chart-toolbar { padding-top: 19px; }
  .chart-ranges button { padding: 5px 6px; }
  .detail-footer { padding-top: 15px; }
}
@media(max-width: 370px) {
  .shell { padding: 0 12px; }
  h1 { font-size: 20px; }
  .game-open { max-width: 124px; }
  .mobile-authors { max-width: 124px; }
  .mobile-authors .author-name { max-width: 100px; }
  .updated .icon { display: none; }
  .detail-metric strong { font-size: 14px; }
  .detail-dialog { padding: 17px; }
}
@media(prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
