:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef2f9;
  --text: #141b2e;
  --muted: #5a6784;
  --line: #e4e9f2;
  --accent: #3b5bff;
  --accent-dark: #2942c7;
  --nav: #161e36;
  --nav-item: #aeb8d4;
  --nav-active: #243252;
  --nav-accent: #4c6fff;
  --gp: #01875f;
  --as: #0a84ff;
  --danger: #b42318;
  --success: #087443;
  --r-card: 14px;
  --r-ctrl: 10px;
  --r-pill: 999px;
  --shadow: 0 1px 2px rgba(20, 27, 46, 0.06);
  --shadow-h: 0 6px 18px rgba(20, 27, 46, 0.10);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { min-height: 100vh; margin: 0; background: var(--bg); color: var(--text); }
button, select, input { font: inherit; }
h1, h2, h3, p { margin: 0; }
h2 { font-size: 20px; font-weight: 800; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

/* ===================== TOP BAR ===================== */
.topbar { background: var(--nav); position: sticky; top: 0; z-index: 20; box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15); }
.tb-inner { align-items: center; display: flex; gap: 20px; margin: 0 auto; max-width: 1320px; padding: 10px 28px; }
.tb-brand { align-items: center; color: #fff; display: flex; font-weight: 800; gap: 9px; letter-spacing: 0.01em; }
.tb-logo { width: 26px; height: 26px; border-radius: 7px; display: block; }
.tb-name { font-size: 16px; }
.tb-nav { display: flex; gap: 4px; }
.tb-tab { background: transparent; border: 0; border-radius: 9px; color: var(--nav-item); cursor: pointer; font-size: 14px; font-weight: 700; padding: 8px 14px; }
.tb-tab:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.tb-tab.active { background: var(--nav-active); color: #fff; box-shadow: inset 0 -2px 0 var(--nav-accent); }
.tb-right { align-items: center; display: flex; gap: 10px; margin-left: auto; }
.stale-badge { background: #fff3d6; border-radius: var(--r-pill); color: #7a4a00; font-size: 12px; font-weight: 800; padding: 4px 11px; white-space: nowrap; }
.info-wrap { position: relative; }
.info-btn { align-items: center; background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.28); border-radius: var(--r-pill); color: #fff; cursor: pointer; display: inline-flex; font-size: 13px; font-weight: 700; gap: 7px; height: 34px; justify-content: center; padding: 0 14px; }
.info-btn:hover { background: rgba(255, 255, 255, 0.14); }
.info-btn[aria-expanded="true"] { background: #fff; border-color: #fff; color: var(--nav); }
.info-glyph { align-items: center; border: 1.5px solid currentColor; border-radius: 50%; display: inline-flex; font-family: Georgia, serif; font-size: 11px; font-style: italic; font-weight: 700; height: 17px; justify-content: center; width: 17px; }
.info-legend { border-top: 1px solid var(--line); margin-top: 2px; padding-top: 8px; }
.info-legend-title { color: var(--text) !important; font-size: 14px !important; font-weight: 800; }
.info-legend ul { display: grid; gap: 6px; list-style: none; margin: 8px 0 0; padding: 0; }
.info-legend li { color: var(--muted); font-size: 12px; line-height: 1.35; }
.info-legend li strong { color: var(--text); font-weight: 700; }
.info-legend .lg-gp { color: var(--gp); font-weight: 800; }
.info-legend .lg-as { color: var(--as); font-weight: 800; }
.back-btn { align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-ctrl); color: var(--muted); cursor: pointer; display: inline-flex; font-size: 20px; height: 40px; justify-content: center; line-height: 1; width: 44px; }
.back-btn:hover { border-color: var(--accent); color: var(--accent); }
.info-pop { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-h); display: grid; gap: 6px; padding: 14px 16px; position: absolute; right: 0; top: 38px; width: 290px; z-index: 30; }
.info-title { font-weight: 800; }
.info-pop p { color: var(--text); font-size: 13px; line-height: 1.4; }
.info-updated { color: var(--muted) !important; }
.info-warn { background: #fff8e8; border-radius: 8px; color: #7a4a00 !important; font-weight: 700; padding: 6px 8px; }
.info-ok { color: var(--success) !important; font-weight: 700; }
.info-stats { border-top: 1px solid var(--line); display: grid; gap: 6px; margin: 2px 0; padding-top: 8px; }
.info-stat-row { align-items: baseline; color: var(--muted); display: flex; font-size: 13px; gap: 12px; justify-content: space-between; }
.info-stat-row strong { color: var(--text); font-size: 15px; font-weight: 800; }

/* ===================== SHELL ===================== */
.app-shell { margin: 0 auto; max-width: 1320px; padding: 20px 28px 40px; }
.workspace { display: grid; gap: 16px; min-width: 0; }

.primary-button { background: var(--accent); border: 0; border-radius: var(--r-ctrl); color: #fff; cursor: pointer; font-weight: 700; min-height: 40px; padding: 9px 16px; white-space: nowrap; }
.primary-button:hover { background: var(--accent-dark); }
.ghost-button { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-ctrl); color: var(--muted); cursor: pointer; font-weight: 700; min-height: 38px; padding: 8px 14px; white-space: nowrap; }
.ghost-button:hover { border-color: #c3cde2; color: var(--text); }
.filter-toggle { align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-ctrl); color: var(--text); cursor: pointer; display: inline-flex; font-weight: 700; gap: 7px; min-height: 40px; padding: 8px 14px; }
.filter-toggle:hover { border-color: #c3cde2; }
.filter-toggle[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.ft-count { background: var(--accent); border-radius: var(--r-pill); color: #fff; font-size: 11px; font-weight: 800; padding: 1px 7px; }

.status { border-radius: var(--r-ctrl); border: 1px solid #bdd2ff; background: #edf4ff; color: #183b82; padding: 12px 14px; }
.status[data-tone="error"] { background: #fff0ed; border-color: #ffc7bd; color: var(--danger); }
.status[data-tone="warning"] { background: #fff8e8; border-color: #f0cf84; color: #7a4a00; }

.view { display: none; }
.view.active { display: grid; gap: 16px; }

/* ===================== MARKET RADAR (kept) ===================== */
.filters, .report-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow); }
.filters { display: grid; gap: 14px; grid-template-columns: minmax(220px, 1.2fr) repeat(2, minmax(150px, 1fr)); padding: 16px; }
.field { display: grid; gap: 7px; }
.field > span { color: var(--muted); font-size: 13px; font-weight: 700; }
select { appearance: none; background: #fff; border: 1px solid #c4cde0; border-radius: var(--r-ctrl); color: var(--text); min-height: 42px; padding: 10px 12px; }
.segments { background: var(--surface-2); border-radius: var(--r-ctrl); display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; overflow: hidden; }
.segment { background: transparent; border: 0; color: var(--muted); cursor: pointer; font-weight: 700; min-height: 42px; padding: 10px 12px; }
.segment.active { background: var(--nav-active); color: #fff; }
.report-panel { display: grid; gap: 12px; padding: 16px 18px 18px; }
.split-lists-header { border-bottom: 1px solid var(--line); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.split-lists-header h3 { color: var(--muted); font-size: 16px; font-weight: 800; padding: 14px 10px; text-align: center; }
.split-lists { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.chart-column { min-width: 0; }
.game-list { display: grid; gap: 8px; }
.game-card { align-items: start; border: 1px solid var(--line); border-radius: var(--r-card); display: grid; gap: 12px; grid-template-columns: 34px 52px minmax(0, 1fr); min-height: 108px; padding: 12px 14px; }
.display-rank { font-size: 18px; font-weight: 800; text-align: center; color: var(--muted); }
.game-main { display: grid; gap: 4px; min-width: 0; }
.game-title { color: var(--text); font-weight: 800; overflow: hidden; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.publisher { color: var(--muted); }
.sensor-rank { display: grid; gap: 2px; grid-column: 3; color: var(--muted); }
.sensor-rank strong { font-size: 18px; color: var(--text); }
.sensor-link { color: var(--accent); font-weight: 700; grid-column: 3; text-decoration: none; }
.sensor-link:hover, a.game-title:hover { color: var(--accent-dark); text-decoration: underline; }
.empty-state { border: 1px solid var(--line); border-radius: var(--r-card); color: var(--muted); padding: 18px; }
.scan-state { display: grid; gap: 8px; }
.scan-state strong { color: var(--text); font-size: 18px; }

/* ---- icon with always-present fallback ---- */
.icon { align-items: center; background: var(--surface-2); border-radius: 12px; color: #526176; display: grid; height: 54px; overflow: hidden; position: relative; text-decoration: none; width: 54px; }
.icon-fallback { align-items: center; display: flex; font-weight: 800; height: 100%; justify-content: center; left: 0; position: absolute; top: 0; width: 100%; }
.icon img { display: block; height: 100%; object-fit: cover; position: relative; width: 100%; z-index: 1; }

/* ===================== COMPETITORS RADAR ===================== */
.cr-screen { display: grid; gap: 16px; }
.cr-screen[hidden] { display: none; }

.cr-actionbar { align-items: center; display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; }
.cr-actionbar-left { align-items: center; display: flex; gap: 10px; }
.cr-actionbar-right { align-items: center; display: flex; gap: 10px; }
.cr-screen-title { font-size: 20px; font-weight: 800; }
.cr-chip { background: var(--surface-2); border-radius: var(--r-pill); color: var(--muted); font-size: 14px; font-weight: 800; padding: 1px 10px; }

/* stat blocks */
.cr-statrow { display: grid; gap: 12px; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.cr-stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow); display: grid; gap: 6px; padding: 14px 16px; }
.cr-stat-label { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.cr-stat-value { color: var(--text); font-size: 24px; font-weight: 800; line-height: 1; }

/* filter panel (collapsible) */
.cr-filters { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow); display: flex; flex-wrap: wrap; gap: 12px; padding: 14px 16px; align-items: end; }
.cr-field { display: grid; gap: 6px; min-width: 150px; }
.cr-field > span { color: var(--muted); font-size: 12px; font-weight: 700; }
.cr-grow { flex: 1 1 220px; }
.cr-field input[type="search"] { background: #fff; border: 1px solid #c4cde0; border-radius: var(--r-ctrl); color: var(--text); min-height: 42px; padding: 10px 12px; width: 100%; }
.cr-field select { width: 100%; }
.cr-store .segment { min-height: 42px; padding: 8px 12px; font-size: 13px; }
.cr-reset { align-self: end; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-ctrl); color: var(--muted); cursor: pointer; font-weight: 700; min-height: 42px; padding: 8px 16px; }
.cr-reset:hover { color: var(--text); border-color: #c3cde2; }

/* tabs */
.cr-tabs { display: flex; gap: 4px; }
.cr-tab { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-ctrl); color: var(--muted); cursor: pointer; font-size: 14px; font-weight: 700; padding: 9px 16px; }
.cr-tab:hover { color: var(--text); }
.cr-tab.active { background: var(--nav-active); border-color: var(--nav-active); color: #fff; }
.cr-count { background: var(--surface-2); border-radius: var(--r-pill); font-size: 11px; font-weight: 800; margin-left: 6px; min-width: 18px; padding: 1px 6px; color: var(--muted); }
.cr-tab.active .cr-count { background: rgba(255, 255, 255, 0.25); color: #fff; }

/* card list */
.cr-cardlist { display: grid; gap: 10px; }
.cr-card { align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow); display: grid; gap: 14px; grid-template-columns: 30px 56px minmax(0, 1fr) auto; padding: 12px 16px; transition: box-shadow .15s, transform .15s; }
.cr-card:hover { box-shadow: var(--shadow-h); transform: translateY(-1px); }
.cr-card .icon { width: 56px; height: 56px; }
.cr-num { color: var(--muted); font-size: 14px; font-weight: 700; text-align: center; }
.cr-body { display: grid; gap: 5px; min-width: 0; }
.cr-title-row { align-items: center; display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.cr-title { color: var(--text); font-size: 16px; font-weight: 800; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
a.cr-title:hover { color: var(--accent-dark); text-decoration: underline; }
.cr-pub-link { color: var(--muted); font-weight: 700; text-decoration: none; }
.cr-pub-link:hover { color: var(--accent-dark); text-decoration: underline; }
.cr-meta { align-items: center; color: var(--muted); display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; }
.cr-badges { display: inline-flex; flex-wrap: wrap; gap: 8px; }
.cr-store-badge { align-items: center; border-radius: var(--r-pill); display: inline-flex; font-size: 12px; font-weight: 700; gap: 5px; padding: 4px 10px; text-decoration: none; }
.cr-store-badge.gp { background: rgba(1, 135, 95, 0.10); color: var(--gp); }
.cr-store-badge.as { background: rgba(10, 132, 255, 0.10); color: var(--as); }
.cr-store-badge:hover { filter: brightness(0.94); }
.cr-ext { font-size: 11px; opacity: 0.8; }
.cr-actions { display: flex; align-items: center; }
.cr-sensor { align-items: center; color: var(--muted); display: inline-flex; font-size: 13px; font-weight: 700; gap: 4px; text-decoration: none; white-space: nowrap; }
.cr-sensor:hover { color: var(--accent-dark); text-decoration: underline; }

/* status badge */
.cr-badge { border-radius: var(--r-pill); font-size: 11px; font-weight: 800; padding: 3px 9px; white-space: nowrap; }
.cr-badge.new { background: #dcfce7; color: #12805c; }
.cr-badge.active { background: #e0f2fe; color: #075985; }
.cr-badge.removed { background: #f1f5f9; color: #64748b; }
.cr-badge.archived { background: #eef1f6; color: #475569; }
.cr-badge.moved { background: #ede9fe; color: #6d28d9; }
.cr-badge.moved-untracked { background: #fef3c7; color: #92600a; }
.cr-badge-link { align-items: center; cursor: pointer; display: inline-flex; font-size: 12px; gap: 5px; padding: 4px 10px; text-decoration: none; }
.cr-badge-link:hover { filter: brightness(0.95); }
.cr-newacct { align-items: center; border-radius: var(--r-ctrl); display: inline-flex; font-size: 12px; font-weight: 700; gap: 5px; margin-top: 4px; padding: 5px 11px; text-decoration: none; width: fit-content; }
.cr-newacct.untracked { background: #fef3c7; color: #92600a; }
.cr-newacct.moved { background: #ede9fe; color: #6d28d9; }
.cr-newacct:hover { filter: brightness(0.96); text-decoration: none; }
.cr-newacct-ico { font-size: 11px; }
/* publisher-row project counts */
.cr-pub-projects { align-items: center; display: flex; flex-wrap: wrap; gap: 6px; }
.cr-pub-total { color: var(--text); font-size: 13px; font-weight: 800; }
.cr-pub-tracked { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.cr-pub-sep { color: var(--muted); font-size: 12.5px; }

/* pager */
.cr-pager { align-items: center; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; padding-top: 4px; }
.cr-page { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; color: var(--text); cursor: pointer; font-weight: 700; min-width: 36px; min-height: 36px; padding: 6px 10px; }
.cr-page:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.cr-page.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.cr-page:disabled { opacity: 0.4; cursor: default; }
.cr-page-dots { color: var(--muted); padding: 0 4px; }

/* empty states */
.cr-empty { align-items: center; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r-card); display: grid; gap: 8px; justify-items: center; padding: 40px 20px; text-align: center; }
.cr-empty-ico { color: var(--nav-accent); font-size: 26px; }
.cr-empty strong { color: var(--text); font-size: 17px; }
.cr-empty p { color: var(--muted); }

/* publishers list */
.cr-pub-list { display: grid; gap: 8px; }
.cr-pub-row { align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow); color: var(--text); display: grid; gap: 14px; grid-template-columns: minmax(0, 1.3fr) auto minmax(150px, 1.2fr) 96px 54px 24px; padding: 14px 16px; text-decoration: none; transition: box-shadow .15s, transform .15s; }
.cr-pub-row:hover { box-shadow: var(--shadow-h); transform: translateY(-1px); }
.cr-pub-name { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-pub-accs { display: inline-flex; gap: 6px; }
.cr-acc { border-radius: var(--r-pill); font-size: 12px; font-weight: 800; padding: 2px 9px; }
.cr-acc.gp { background: rgba(1, 135, 95, 0.10); color: var(--gp); }
.cr-acc.as { background: rgba(10, 132, 255, 0.10); color: var(--as); }
.cr-pub-active { color: var(--muted); font-size: 13px; font-weight: 700; }
.cr-pub-last { color: var(--muted); font-size: 13px; }
.cr-pub-presence { display: inline-flex; gap: 6px; }
.cr-dot { background: #d3dbe8; border-radius: 50%; height: 9px; width: 9px; }
.cr-dot.on.gp { background: var(--gp); }
.cr-dot.on.as { background: var(--as); }
.cr-pub-go { color: var(--muted); text-align: right; }
.cr-pub-row:hover .cr-pub-go { color: var(--accent); }

/* publisher details */
.cr-pd-name { font-size: 20px; font-weight: 800; }
#cr-pd-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cr-acc-cols { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cr-acc-block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow); display: grid; gap: 10px; padding: 14px 16px; align-content: start; }
.cr-acc-head { align-items: center; display: flex; gap: 8px; justify-content: space-between; }
.cr-acc-title { font-weight: 800; }
.cr-acc-title.gp { color: var(--gp); }
.cr-acc-title.as { color: var(--as); }
.cr-acc-n { background: var(--surface-2); border-radius: var(--r-pill); color: var(--muted); font-size: 12px; font-weight: 800; padding: 1px 9px; }
.cr-acc-filter { background: #fff; border: 1px solid #c4cde0; border-radius: var(--r-ctrl); min-height: 38px; padding: 8px 12px; width: 100%; }
.cr-acc-list { display: grid; gap: 4px; max-height: 520px; overflow: auto; }
.cr-acc-row { align-items: center; border: 1px solid var(--line); border-radius: var(--r-ctrl); color: var(--text); display: flex; gap: 8px; justify-content: space-between; padding: 9px 12px; text-decoration: none; }
.cr-acc-row:hover { border-color: var(--accent); color: var(--accent); }
.cr-acc-url { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-acc-empty { color: var(--muted); padding: 6px 2px; }

/* ===================== responsive ===================== */
@media (max-width: 1024px) {
  .cr-statrow { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #cr-pd-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .tb-inner { flex-wrap: wrap; gap: 12px; padding: 10px 16px; }
  .tb-right { order: 2; }
  .tb-nav { order: 3; width: 100%; }
  .tb-tab { flex: 1; text-align: center; }
  .app-shell { padding: 16px; }
  .filters { grid-template-columns: 1fr; }
  .split-lists-header, .split-lists { grid-template-columns: 1fr; }
  .game-card { grid-template-columns: 34px 52px minmax(0, 1fr); }
  .sensor-rank, .sensor-link { grid-column: 3; }
  .cr-acc-cols { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .cr-statrow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cr-actionbar-right { width: 100%; }
  .cr-actionbar-right .primary-button, .cr-actionbar-right .ghost-button { flex: 1; }
  .cr-card { grid-template-columns: 28px 48px minmax(0, 1fr); }
  .cr-card .icon { width: 48px; height: 48px; }
  .cr-actions { grid-column: 2 / -1; justify-content: flex-start; padding-left: 62px; }
  .cr-pub-row { grid-template-columns: 1fr auto; grid-auto-rows: auto; gap: 8px; }
  .cr-pub-active, .cr-pub-last { grid-column: 1 / -1; }
  .cr-pub-go { display: none; }
}

/* Rule 24: problems of the last collection run, shown above the feed. */

/* "Moved to: <new publisher>" — the account a moved game now belongs to. */
.cr-movedto { color: var(--muted); font-size: 13px; }
.cr-movedto-label { font-weight: 600; }
.cr-movedto-link { color: var(--accent); font-weight: 600; text-decoration: none; }
.cr-movedto-link:hover { text-decoration: underline; }
