:root {
  --bg: #f5f6f4;
  --surface: #ffffff;
  --surface-2: #eceeea;
  --ink: #1d2321;
  --muted: #5f6b66;
  --line: #dde1dc;
  --accent: #2f7d53;
  --accent-ink: #ffffff;
  --good: #2f7d53;
  --good-bg: #e0efe6;
  --mid: #9a7420;
  --mid-bg: #f5ebd4;
  --bad: #a94a41;
  --bad-bg: #f6e1de;
  --na: #7b8580;
  --na-bg: #e8ebe8;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181a;
    --surface: #1b2124;
    --surface-2: #222a2e;
    --ink: #e4e9e5;
    --muted: #98a29c;
    --line: #2c3539;
    --accent: #56b782;
    --accent-ink: #10201a;
    --good: #6bbf87;
    --good-bg: #1e3227;
    --mid: #d0a247;
    --mid-bg: #33290f;
    --bad: #d4776e;
    --bad-bg: #38201d;
    --na: #8d968f;
    --na-bg: #262d30;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-underline-offset: 2px; }
h1, h2, h3, h4 { line-height: 1.25; text-wrap: balance; }
img { max-width: 100%; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: 0.9em; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.content { padding-top: 28px; padding-bottom: 56px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* --- шапка --- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 18px; height: 60px; }
.brand { font-size: 20px; font-weight: 700; text-decoration: none; color: var(--ink); letter-spacing: -0.01em; }
.brand span { color: var(--accent); }
.nav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav a {
  padding: 7px 12px; border-radius: 8px; text-decoration: none;
  color: var(--muted); font-size: 15px;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--accent); color: var(--accent-ink); }

.footer { border-top: 1px solid var(--line); padding: 18px 0 28px; color: var(--muted); font-size: 13px; }

.page-title { margin: 0 0 6px; font-size: clamp(24px, 4vw, 32px); }
.breadcrumb { margin: 0 0 14px; font-size: 14px; }

/* --- формы --- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0 8px; }
.input, .select {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 12px; font: inherit; font-size: 15px; min-width: 0;
}
.input { flex: 1 1 260px; }
.select { flex: 0 1 220px; }
.input:focus-visible, .select:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 16px; font: inherit; font-size: 15px; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.07); background: var(--accent); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 13px; }

.result-count { color: var(--muted); font-size: 14px; margin: 14px 0; }

/* --- сетка карточек --- */
.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.09); }
.card-link { text-decoration: none; color: inherit; display: block; height: 100%; }
.cover { position: relative; aspect-ratio: 3 / 4; background: var(--surface-2); }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-stub {
  display: flex; align-items: center; justify-content: center; height: 100%;
  color: var(--muted); font-size: 13px;
}
.cover .badge { position: absolute; right: 8px; bottom: 8px; }
.card-body { padding: 12px 14px 14px; }
.card-title { margin: 0 0 6px; font-size: 15px; }
.card-meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.card-dev { color: var(--muted); font-size: 13px; margin-top: 4px; }
.user-score { font-weight: 600; }
.user-score.good { color: var(--good); }
.user-score.mid { color: var(--mid); }
.user-score.bad { color: var(--bad); }
.dot { width: 3px; height: 3px; border-radius: 50%; background: var(--muted); display: inline-block; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.chip {
  font-size: 11.5px; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.chip-lead { background: var(--good-bg); color: var(--good); margin-left: 6px; }
.status-ok { background: var(--good-bg); color: var(--good); }
.status-partial { background: var(--mid-bg); color: var(--mid); }
.status-error, .status-failed { background: var(--bad-bg); color: var(--bad); }
.status-interrupted { background: var(--mid-bg); color: var(--mid); }
.status-running { background: var(--surface-2); color: var(--muted); }

.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 38px; height: 34px; padding: 0 8px; border-radius: 8px;
  font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums;
}
.badge.sm { min-width: 32px; height: 26px; font-size: 14px; }
.badge.good { background: var(--good); color: #fff; }
.badge.mid { background: var(--mid); color: #fff; }
.badge.bad { background: var(--bad); color: #fff; }
.badge.na { background: var(--na-bg); color: var(--na); }

.empty {
  background: var(--surface); border: 1px dashed var(--line);
  border-radius: var(--radius); padding: 32px; text-align: center;
}
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 26px 0 0; }
.pager-info { color: var(--muted); font-size: 14px; }

/* --- карточка игры --- */
.game-head { display: grid; grid-template-columns: minmax(180px, 260px) 1fr; gap: 26px; }
.game-cover img { width: 100%; border-radius: var(--radius); border: 1px solid var(--line); display: block; }
.game-title { margin: 0 0 14px; font-size: clamp(22px, 3.5vw, 30px); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 20px; font-size: 14.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.tablewrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; background: var(--surface); }
.table th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); font-weight: 600; padding: 9px 12px;
  border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.table td { padding: 9px 12px; border-bottom: 1px solid var(--line); }
.table tr:last-child td { border-bottom: none; }
.scores { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }

.description, .trailer, .letsplay, .similar, .summary { margin-top: 30px; }
.description p { max-width: 76ch; }
.video { position: relative; aspect-ratio: 16 / 9; max-width: 820px; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: var(--radius); }

.summaries { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; margin-top: 30px; }
.summary { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-top: 0; }
.summary h3 { margin: 0 0 10px; font-size: 17px; }
.tldr { margin: 0 0 14px; }
.likes { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.likes h4 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; }
.likes h4.pos { color: var(--good); }
.likes h4.neg { color: var(--bad); }
.likes ul { margin: 0; padding-left: 18px; font-size: 14.5px; }
.likes li { margin: 4px 0; }
.summary-foot { margin: 14px 0 0; font-size: 12.5px; }

.similar-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.similar-list a {
  display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
}
.similar-list a:hover { background: var(--surface-2); }
.similar-list img { width: 38px; height: 50px; object-fit: cover; border-radius: 5px; }
.similar-title { flex: 1; font-size: 14px; }

/* --- мониторинг --- */
.monitor-head { display: flex; flex-wrap: wrap; gap: 20px; justify-content: space-between; align-items: flex-start; }
.run-box { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.run-box .input { flex: 0 1 200px; }
.run-box p { flex-basis: 100%; margin: 0; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 24px 0; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile-label { display: block; color: var(--muted); font-size: 12.5px; margin-bottom: 4px; }
.tile-value { font-size: 24px; font-variant-numeric: tabular-nums; }

.monitor-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 26px; }
.monitor-cols h3 { margin: 0 0 12px; font-size: 17px; }
.monitor-cols section > h3:not(:first-child) { margin-top: 26px; }
.workers { display: grid; gap: 8px; }
.worker {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px;
}
.worker .dot.live { width: 9px; height: 9px; background: var(--good); box-shadow: 0 0 0 3px var(--good-bg); }

.events { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 560px; overflow-y: auto; }
.events li {
  display: flex; gap: 10px; align-items: baseline;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: 8px; padding: 8px 12px; font-size: 14px;
}
.events li.level-error { border-left-color: var(--bad); }
.events li.level-warning { border-left-color: var(--mid); }
.events li.level-info { border-left-color: var(--accent); }
.ev-stage { color: var(--muted); font-size: 12px; min-width: 62px; }
.ev-msg { flex: 1; }
.events li.fresh { animation: fade-in 0.4s ease; }

@keyframes fade-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .card, .events li.fresh { transition: none; animation: none; }
}

@media (max-width: 640px) {
  .game-head { grid-template-columns: 1fr; }
  .game-cover { max-width: 220px; }
}
