:root {
  color-scheme: light dark;
  --primary: #1e40af;
  --primary-2: #2563eb;
  --accent: #b45309;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef3fb;
  --text: #172554;
  --muted: #526078;
  --border: #d9e2f2;
  --success: #0f766e;
  --danger: #b91c1c;
  --ring: #1d4ed8;
  --shadow: 0 12px 35px rgba(30, 64, 175, .08);
  --radius: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button, a, select { touch-action: manipulation; }
button, select { cursor: pointer; }
button:active, a:active { opacity: .76; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid var(--ring); outline-offset: 3px; }
a { color: inherit; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 10; padding: 10px 14px; color: white; background: var(--primary); border-radius: 8px; }
.skip-link:focus { top: 12px; }

.topbar { min-height: 76px; padding: 12px max(20px, calc((100vw - 1280px) / 2)); display: flex; align-items: center; justify-content: space-between; gap: 20px; background: color-mix(in srgb, var(--surface) 92%, transparent); border-bottom: 1px solid var(--border); backdrop-filter: blur(14px); position: sticky; top: 0; z-index: 5; }
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; color: var(--primary); }
.brand svg { width: 42px; height: 42px; flex: none; }
.brand span { display: grid; line-height: 1.15; }
.brand strong { font-size: 17px; letter-spacing: -.02em; }
.brand small { margin-top: 4px; color: var(--muted); font-size: 12px; }
.freshness { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: #16a34a; box-shadow: 0 0 0 5px color-mix(in srgb, #16a34a 15%, transparent); }

.shell { width: min(1280px, calc(100% - 40px)); margin: 0 auto; }
.intro { padding: 52px 0 28px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 420px); align-items: end; gap: 40px; }
.eyebrow { margin: 0 0 8px; color: var(--primary-2); font: 700 11px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .12em; }
h1 { max-width: 800px; margin: 0; font-size: clamp(32px, 5vw, 58px); line-height: 1.06; letter-spacing: -.045em; text-wrap: balance; }
.intro p:not(.eyebrow) { max-width: 690px; margin: 18px 0 0; color: var(--muted); font-size: 17px; line-height: 1.65; }
.search { display: grid; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 650; }
.search input { min-height: 48px; width: 100%; padding: 0 15px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.search input::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }

.metrics { display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.metrics article { min-height: 90px; padding: 18px 22px; display: grid; align-content: center; gap: 5px; border-right: 1px solid var(--border); }
.metrics article:last-child { border-right: 0; }
.metrics span { color: var(--muted); font-size: 12px; }
.metrics strong { font: 700 26px/1.1 ui-monospace, SFMono-Regular, Consolas, monospace; }

.tabs { margin-top: 28px; display: flex; gap: 5px; border-bottom: 1px solid var(--border); }
.tabs button { min-height: 48px; padding: 0 15px; display: inline-flex; align-items: center; gap: 8px; color: var(--muted); background: none; border: 0; border-bottom: 3px solid transparent; font-weight: 700; transition: color .18s ease, border-color .18s ease, background .18s ease; }
.tabs button:hover { color: var(--text); background: var(--surface-2); }
.tabs button[aria-selected="true"] { color: var(--primary); border-color: var(--primary); }
.tabs svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.workspace { padding: 24px 0 64px; display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 24px; align-items: start; }
.workspace.games-view { grid-template-columns: minmax(0, 1fr); }
.filters { padding: 18px; display: grid; gap: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); position: sticky; top: 100px; }
.filter-heading { display: flex; align-items: center; justify-content: space-between; }
.filter-heading button { min-height: 36px; padding: 0 9px; color: var(--primary); background: transparent; border: 0; border-radius: 8px; font-weight: 650; }
.filter-heading button:hover { background: var(--surface-2); }
.filters label:not(.check) { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 650; }
.filters select { min-height: 44px; width: 100%; padding: 0 10px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 9px; }
.check { min-height: 44px; display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 13px; line-height: 1.35; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.filter-note, .panel-note { color: var(--muted); font-size: 12px; line-height: 1.6; }
.filter-note { margin: 0; padding-top: 12px; border-top: 1px solid var(--border); }

.results { min-width: 0; }
.signal-shortcuts { margin-bottom: 18px; padding: 14px 16px; display: grid; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.shortcut-group { min-width: 0; display: grid; grid-template-columns: 42px minmax(0, 1fr); align-items: center; gap: 10px; }
.shortcut-group > strong { color: var(--muted); font-size: 12px; }
.chip-strip { min-width: 0; display: flex; gap: 7px; overflow-x: auto; scrollbar-width: thin; }
.filter-chip { min-width: 44px; min-height: 44px; flex: none; padding: 0 12px; color: var(--muted); background: var(--surface-2); border: 1px solid transparent; border-radius: 999px; font-weight: 650; }
.filter-chip:hover { color: var(--text); border-color: var(--border); }
.filter-chip[aria-pressed="true"] { color: white; background: var(--primary); }
.signal-shortcuts > p { margin: 0 0 0 52px; color: var(--muted); font-size: 11px; }
.section-title { min-height: 58px; display: flex; justify-content: space-between; align-items: start; gap: 20px; }
.section-title h2 { margin: 0; font-size: 25px; letter-spacing: -.025em; }
.count { padding: 7px 10px; color: var(--muted); background: var(--surface-2); border-radius: 999px; font: 600 12px/1 ui-monospace, SFMono-Regular, Consolas, monospace; }
.panel-note { margin: -2px 0 18px; }
.signal-list { display: grid; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.signal-head, .signal-row { display: grid; grid-template-columns: minmax(220px, 2fr) minmax(110px, .8fr) minmax(100px, .7fr) 100px 100px 68px; align-items: center; gap: 14px; }
.signal-head { min-height: 42px; padding: 0 18px; color: var(--muted); background: var(--surface-2); font-size: 11px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.signal-row { min-height: 74px; padding: 12px 18px; border-top: 1px solid var(--border); transition: background .16s ease; }
.signal-row:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.term { min-width: 0; display: grid; gap: 3px; }
.term strong { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.term small, .meta { color: var(--muted); font-size: 12px; }
.term small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.term > .tag { justify-self: start; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { padding: 4px 7px; color: var(--muted); background: var(--surface-2); border-radius: 6px; font-size: 11px; line-height: 1; white-space: nowrap; }
.tag.new { color: #fff; background: var(--primary); }
.tag.confirmed { color: var(--success); border: 1px solid color-mix(in srgb, var(--success) 35%, var(--border)); }
.tag.cooling, .tag.stale { color: var(--muted); border: 1px solid var(--border); }
.tag.stale { opacity: .72; }
.tag.noise { color: var(--accent); background: color-mix(in srgb, #f59e0b 14%, var(--surface)); }
.number { font: 650 13px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; text-align: right; }
.growth { color: var(--success); }
.growth.down { color: var(--danger); }
.growth.hot { color: var(--danger); }
.open-link { min-width: 58px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 3px; color: var(--primary); border-radius: 9px; font-size: 12px; font-weight: 700; }
.open-link:hover { background: var(--surface-2); }
.open-link svg { width: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.game-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.game-card { min-width: 0; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.game-card header { display: flex; justify-content: space-between; gap: 14px; }
.game-card h3 { min-width: 0; margin: 0; overflow: hidden; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.score { color: var(--accent); font: 700 12px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: nowrap; }
.game-card .meta { margin-top: 7px; line-height: 1.5; }
.spark { width: 100%; height: 78px; margin-top: 16px; display: block; overflow: visible; }
.spark .area { fill: color-mix(in srgb, var(--primary-2) 14%, transparent); }
.spark .line { fill: none; stroke: var(--primary-2); stroke-width: 2.3; vector-effect: non-scaling-stroke; }
.chart-note { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.no-chart { min-height: 78px; margin: 16px 0 0; display: grid; place-items: center; color: var(--muted); background: var(--surface-2); border-radius: 10px; font-size: 12px; }
.game-footer { margin-top: 10px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.game-footer a { min-height: 40px; padding: 0 10px; display: inline-flex; align-items: center; color: var(--primary); border-radius: 8px; font-size: 13px; font-weight: 700; text-decoration: none; }
.game-footer a:hover { background: var(--surface-2); }
.sources { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comparison-metrics { margin-bottom: 18px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.comparison-metrics article { min-width: 0; padding: 17px; display: grid; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 13px; box-shadow: var(--shadow); }
.comparison-metrics span, .comparison-metrics small { color: var(--muted); font-size: 11px; line-height: 1.4; }
.comparison-metrics strong { font: 700 24px/1 ui-monospace, SFMono-Regular, Consolas, monospace; }
.compare-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.compare-card { min-width: 0; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.compare-card > header { min-height: 42px; display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.compare-card h3 { margin: 0; font-size: 16px; letter-spacing: -.015em; }
.compare-card header > a { min-height: 44px; padding: 0 10px; display: inline-flex; align-items: center; color: var(--primary); border-radius: 8px; font-size: 13px; font-weight: 700; text-decoration: none; }
.compare-card header > a:hover { background: var(--surface-2); }
.difference-list { margin-top: 10px; border-top: 1px solid var(--border); }
.difference-row { min-height: 58px; padding: 10px 2px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); }
.difference-row:last-child { border-bottom: 0; }
.difference-row .number { min-width: 64px; }
.empty.compact { padding: 28px 12px; }
.algorithm-card { margin-top: 14px; }
.algorithm-list { margin: 12px 0 0; padding: 0; display: grid; list-style: none; counter-reset: pipeline; }
.algorithm-list li { padding: 15px 2px 15px 40px; position: relative; border-top: 1px solid var(--border); counter-increment: pipeline; }
.algorithm-list li::before { content: counter(pipeline); width: 26px; height: 26px; display: grid; place-items: center; position: absolute; left: 2px; top: 14px; color: var(--primary); background: var(--surface-2); border-radius: 50%; font: 700 12px/1 ui-monospace, SFMono-Regular, Consolas, monospace; }
.algorithm-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.stage, .confidence { padding: 3px 6px; border-radius: 5px; font-size: 10px; font-weight: 750; }
.stage { color: var(--primary); background: var(--surface-2); }
.confidence { color: var(--success); border: 1px solid color-mix(in srgb, var(--success) 35%, var(--border)); }
.algorithm-list p { margin: 7px 0 4px; color: var(--text); font-size: 13px; line-height: 1.55; }
.algorithm-list small { display: block; color: var(--muted); font-size: 11px; line-height: 1.55; }
.method-note { margin: 14px 2px 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.source-health { margin: 0 0 14px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.source-state { min-height: 54px; padding: 10px 12px; display: grid; align-content: center; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--muted); border-radius: 10px; }
.source-state.ok, .source-state.cached { border-left-color: var(--success); }
.source-state.partial { border-left-color: var(--accent); }
.source-state.error { border-left-color: var(--danger); }
.source-state strong { font-size: 12px; }
.source-state span { color: var(--muted); font-size: 11px; }
.web-head, .web-row { display: grid; grid-template-columns: minmax(220px, 2fr) minmax(130px, .9fr) minmax(100px, .8fr) 84px 100px 48px; align-items: center; gap: 14px; }
.web-head { min-height: 42px; padding: 0 18px; color: var(--muted); background: var(--surface-2); font-size: 11px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.web-row { min-height: 74px; padding: 12px 18px; border-top: 1px solid var(--border); }
.score-number { color: var(--primary); font-size: 15px; }
.empty { padding: 50px 20px; color: var(--muted); text-align: center; }
.more { min-height: 46px; width: 100%; margin-top: 14px; color: var(--primary); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; font-weight: 700; }
.more:hover { background: var(--surface-2); }

footer { width: min(1280px, calc(100% - 40px)); margin: 0 auto; padding: 24px 0 34px; display: flex; justify-content: space-between; gap: 20px; color: var(--muted); border-top: 1px solid var(--border); font-size: 12px; }
.status { position: fixed; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 900px) {
  .intro { grid-template-columns: 1fr; gap: 24px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metrics article { border-bottom: 1px solid var(--border); }
  .metrics article:nth-child(even), .metrics article:last-child { border-right: 0; }
  .metrics article:last-child { border-bottom: 0; }
  .workspace { grid-template-columns: 1fr; }
  .filters { grid-template-columns: repeat(3, 1fr); position: static; }
  .filter-heading, .check, .filter-note { grid-column: 1 / -1; }
  .signal-head { display: none; }
  .signal-row { grid-template-columns: minmax(0, 1fr) auto 64px; }
  .signal-row > :nth-child(1) { grid-column: 1; grid-row: 1; }
  .signal-row > :nth-child(2) { grid-column: 1; grid-row: 2; }
  .signal-row > :nth-child(3) { grid-column: 1 / -1; grid-row: 3; }
  .signal-row > :nth-child(4) { grid-column: 2; grid-row: 1; }
  .signal-row > :nth-child(5) { grid-column: 2 / -1; grid-row: 2; }
  .signal-row > :nth-child(6) { grid-column: 3; grid-row: 1 / 3; align-self: center; }
  .signal-row [data-label]::before { content: attr(data-label) " "; color: var(--muted); font: 600 10px/1.2 system-ui, sans-serif; }
  .game-grid { grid-template-columns: 1fr; }
  .comparison-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .source-health { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .web-head { display: none; }
  .web-row { grid-template-columns: minmax(0, 1fr) auto 44px; }
  .web-row > :nth-child(1) { grid-column: 1; grid-row: 1; }
  .web-row > :nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .web-row > :nth-child(3) { grid-column: 1 / -1; grid-row: 3; }
  .web-row > :nth-child(4) { grid-column: 2; grid-row: 1; }
  .web-row > :nth-child(5) { grid-column: 1 / -1; grid-row: 4; }
  .web-row > :nth-child(6) { grid-column: 3; grid-row: 1; }
}

@media (max-width: 600px) {
  .topbar { min-height: 68px; padding-inline: 16px; }
  .freshness { max-width: 130px; text-align: right; }
  .shell, footer { width: min(100% - 28px, 1280px); }
  .intro { padding-top: 36px; }
  .metrics article { padding: 16px; }
  .tabs { overflow-x: auto; scrollbar-width: none; }
  .tabs button { flex: none; }
  .filters { grid-template-columns: 1fr; }
  .filters > * { grid-column: 1 !important; }
  .signal-row { grid-template-columns: minmax(0, 1fr) auto 60px; gap: 8px; padding-inline: 14px; }
  .signal-shortcuts { margin-inline: -1px; }
  .shortcut-group { grid-template-columns: 36px minmax(0, 1fr); }
  .signal-shortcuts > p { margin-left: 46px; }
  .compare-grid, .comparison-metrics { grid-template-columns: 1fr; }
  .source-health { grid-template-columns: 1fr; }
  .web-row { grid-template-columns: minmax(0, 1fr) auto 40px; gap: 8px; padding-inline: 14px; }
  footer { flex-direction: column; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #93b4ff;
    --primary-2: #7aa2ff;
    --accent: #fbbf24;
    --bg: #09111f;
    --surface: #101b2d;
    --surface-2: #17243a;
    --text: #e6edf8;
    --muted: #a9b5c9;
    --border: #2b3a52;
    --success: #5eead4;
    --ring: #93c5fd;
    --shadow: 0 12px 35px rgba(0, 0, 0, .22);
  }
  .pulse { background: #4ade80; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
