:root {
  --ink: #e8e2d7;
  --muted: #aaa397;
  --faint: #777168;
  --paper: #161514;
  --panel: #1d1b19;
  --panel-2: #24211e;
  --line: #3b3631;
  --line-soft: #2e2a26;
  --ember: var(--ember-400);
  --ember-soft: #6e3e27;
  --gold: var(--gold-300);
  --danger: var(--red-500);
  --sans: var(--font-body);
  --serif: var(--font-display);
}

* { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); }
body { margin: 0; min-height: 100vh; font-family: var(--sans); background: #161514; }
button, input, select { font: inherit; }
a { color: inherit; }

.comp-header {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: #121110;
}
.comp-back { margin-left: auto; margin-right: 16px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; color: inherit; text-decoration: none; font-weight: 600; white-space: nowrap; }
.comp-back:hover { border-color: var(--gold-focus); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; min-width: 0; }
.brand img { width: 42px; height: 42px; border-radius: 6px; }
.brand span { display: grid; line-height: 1.05; }
.brand small { color: var(--muted); font-size: 12px; }
.brand strong { margin-top: 4px; font: 600 20px var(--serif); }
.edition { display: flex; align-items: baseline; gap: 10px; color: var(--muted); font-size: 12px; }
.edition strong { color: var(--gold); font-size: 14px; }
.edition-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.edition-switch button { min-width: 52px; border: 0; border-right: 1px solid var(--line); padding: 7px 10px; background: transparent; color: var(--muted); font: inherit; cursor: pointer; }
.edition-switch button:last-child { border-right: 0; }
.edition-switch button.is-active { background: var(--gold); color: #17130e; font-weight: 700; }

.comp-shell {
  display: grid;
  grid-template-columns: 240px minmax(300px, 430px) minmax(440px, 1fr);
  height: calc(100vh - 72px);
  min-height: 620px;
}
.comp-sidebar, .comp-browser, .entry-detail { min-width: 0; overflow-y: auto; }
.comp-sidebar { padding: 20px 14px; border-right: 1px solid var(--line); background: #181715; }
.comp-browser { border-right: 1px solid var(--line); background: var(--panel); }
.entry-detail { padding: 32px clamp(24px, 4vw, 56px) 64px; background: #1a1817; }

.search-wrap label { display: block; margin: 0 4px 7px; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.search-field { display: grid; grid-template-columns: 1fr 34px; border: 1px solid var(--line); background: #11100f; }
.search-field:focus-within { border-color: var(--ember); }
.search-field input { width: 100%; border: 0; outline: 0; padding: 10px 11px; color: var(--ink); background: transparent; }
.search-field button { border: 0; color: var(--muted); background: transparent; cursor: pointer; font-size: 20px; }

.category-nav { margin-top: 20px; display: grid; gap: 3px; }
.category-button {
  width: 100%; min-height: 42px; display: grid; grid-template-columns: 1fr auto; align-items: center;
  border: 1px solid transparent; padding: 8px 10px; color: var(--muted); background: transparent;
  text-align: left; cursor: pointer;
}
.category-button:hover { color: var(--ink); background: var(--panel-2); }
.category-button.is-active { color: #fff; border-color: var(--ember-soft); background: #2b211b; }
.category-button small { color: var(--faint); }
.category-button.is-active small { color: var(--gold); }
.category-divider { margin: 10px 8px 5px; color: var(--faint); font-size: 11px; font-weight: 700; text-transform: uppercase; }

.license-note { margin: 24px 6px 0; padding-top: 16px; border-top: 1px solid var(--line-soft); color: var(--faint); font-size: 12px; line-height: 1.45; }
.license-note strong { color: var(--muted); }
.license-note p { margin: 6px 0; }
.license-note a { color: var(--gold); }

.browser-head { min-height: 92px; display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; padding: 20px; border-bottom: 1px solid var(--line); }
.browser-head p { margin: 0 0 5px; color: var(--ember); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.browser-head h1 { margin: 0; font: 600 28px var(--serif); }
.result-count { text-align: right; color: var(--faint); font-size: 11px; }
.result-count strong { display: block; color: var(--ink); font-size: 18px; }
.filter-row { display: flex; gap: 8px; padding: 12px 20px; border-bottom: 1px solid var(--line-soft); overflow-x: auto; }
.filter-row button { white-space: nowrap; border: 1px solid var(--line); padding: 6px 9px; color: var(--muted); background: #171513; cursor: pointer; }
.filter-row button.is-active { border-color: var(--ember); color: #fff; background: #3a261c; }

.entry-list { display: grid; }
.entry-row { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center; width: 100%; min-height: 76px; padding: 10px 18px; border: 0; border-bottom: 1px solid var(--line-soft); color: inherit; background: transparent; text-align: left; cursor: pointer; }
.entry-row:hover { background: #25211e; }
.entry-row.is-active { box-shadow: inset 3px 0 var(--ember); background: #2a241f; }
.entry-thumb { width: 52px; height: 52px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); background: #111; color: var(--gold); font: 700 13px var(--serif); }
.entry-thumb img { width: 100%; height: 100%; object-fit: cover; }
.entry-copy { min-width: 0; }
.entry-copy strong { display: block; overflow: hidden; color: var(--ink); font: 600 17px var(--serif); text-overflow: ellipsis; white-space: nowrap; }
.entry-copy span { display: block; margin-top: 4px; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.entry-meta { color: var(--gold); font-size: 12px; white-space: nowrap; }
.list-status { padding: 28px 20px; color: var(--muted); text-align: center; }

.detail-empty { min-height: 70vh; display: grid; place-content: center; justify-items: center; color: var(--muted); text-align: center; }
.detail-empty h2 { margin: 18px 0 4px; color: var(--ink); font: 600 26px var(--serif); }
.detail-empty p { margin: 0; }
.detail-glyph { width: 72px; height: 72px; display: grid; place-items: center; border: 1px solid var(--ember-soft); color: var(--gold); font: 700 20px var(--serif); transform: rotate(45deg); }
.detail-glyph::first-line { transform: rotate(-45deg); }

.detail-hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: start; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.detail-hero.with-image { grid-template-columns: 150px minmax(0, 1fr); }
.detail-image { width: 150px; aspect-ratio: 1; object-fit: cover; border: 1px solid var(--line); }
.detail-kicker { margin: 0 0 6px; color: var(--ember); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.detail-title { margin: 0; color: #fff; font: 700 clamp(28px, 4vw, 44px) var(--serif); line-height: 1.05; }
.detail-alias { margin: 8px 0 0; color: var(--muted); }
.tag-list { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 16px; }
.tag { border: 1px solid var(--line); padding: 5px 8px; color: var(--muted); background: #141311; font-size: 12px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(95px, 1fr)); gap: 1px; margin: 24px 0; background: var(--line); border: 1px solid var(--line); }
.stat-grid-1 { grid-template-columns: minmax(95px, 1fr); }
.stat-grid-2 { grid-template-columns: repeat(2, minmax(95px, 1fr)); }
.stat { min-height: 68px; padding: 12px; background: var(--surface-raised); }
.stat span { display: block; color: var(--faint); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.stat strong { display: block; margin-top: 5px; color: var(--ink); font-size: 16px; }
.detail-section { margin-top: 28px; }
.detail-section h2 { margin: 0 0 10px; color: var(--gold); font: 600 20px var(--serif); }
.detail-section h3 { margin: 20px 0 6px; color: var(--ink); font: 600 17px var(--serif); }
.detail-section p, .detail-section li { color: #cbc5bb; line-height: 1.65; }
.detail-section p { margin: 8px 0; }
.detail-section ul, .detail-section ol { padding-left: 22px; }
.action-block { margin: 12px 0; padding: 14px 16px; border-left: 2px solid var(--ember-soft); background: var(--surface-raised); }
.action-block strong { color: var(--ink); }
.kv-table { width: 100%; border-collapse: collapse; }
.kv-table th, .kv-table td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: top; }
.kv-table th { width: 34%; color: var(--muted); font-weight: 500; }
.kv-table td { color: var(--ink); }
.license-copy { max-width: 780px; }
.license-copy a { color: var(--gold); }

@media (max-width: 1050px) {
  .comp-shell { grid-template-columns: 210px minmax(300px, 1fr); }
  .entry-detail { position: fixed; z-index: 5; inset: 72px 0 0 210px; display: none; }
  .entry-detail.is-open { display: block; }
  .detail-close { display: block; }
}
@media (min-width: 1051px) { .detail-close { display: none; } }
@media (max-width: 680px) {
  .comp-header { height: 64px; padding: 0 14px; }
  .brand small, .edition span { display: none; }
  .brand strong { font-size: 17px; }
  .edition { gap: 0; }
  .comp-shell { display: block; height: auto; min-height: calc(100vh - 64px); }
  .comp-sidebar { position: static; overflow: visible; padding: 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .category-nav { display: flex; margin-top: 12px; overflow-x: auto; }
  .category-button { width: auto; min-width: max-content; grid-template-columns: auto auto; gap: 8px; }
  .category-divider, .license-note { display: none; }
  .comp-browser { min-height: calc(100vh - 210px); border-right: 0; }
  .browser-head { min-height: 76px; padding: 15px; }
  .browser-head h1 { font-size: 23px; }
  .entry-detail { inset: 64px 0 0; padding: 22px 18px 48px; }
  .detail-hero.with-image { grid-template-columns: 92px minmax(0, 1fr); }
  .detail-image { width: 92px; }
  .detail-title { font-size: 28px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(95px, 1fr)); }
}
/* перемикач мови не перекриває вибір редакції */
#lang-switch { top: auto !important; bottom: 12px !important; right: 12px !important; }

/* ===== Оновлений вигляд довідника ===== */
:root { --radius: 12px; --glow: 0 0 0 1px rgba(216,115,53,.35), 0 8px 28px rgba(0,0,0,.35); }
body { background: radial-gradient(1200px 500px at 70% -10%, rgba(216,115,53,.10), transparent 60%), #141312; }
.comp-header { background: linear-gradient(180deg, #1b1917, #121110); border-bottom: 1px solid #3a342d; box-shadow: 0 1px 0 rgba(198,165,103,.12); position: sticky; top: 0; z-index: 20; }
.brand img { border-radius: 10px; box-shadow: 0 0 0 1px rgba(198,165,103,.35); }
.brand strong { letter-spacing: .02em; }
.comp-back { border-radius: 10px; background: #1d1b19; transition: border-color .15s, transform .15s; }
.comp-back:hover { transform: translateX(-2px); }
.edition-switch { border-radius: 10px; background: #1a1816; }
.edition-switch button { transition: background .15s, color .15s; }
.edition-switch button:hover:not(.is-active) { color: var(--ink); background: #25211e; }

.comp-sidebar { background: linear-gradient(180deg, #1a1816, #151412); }
.search-field { border-radius: 10px; background: #100f0e; transition: box-shadow .15s, border-color .15s; }
.search-field:focus-within { box-shadow: 0 0 0 3px rgba(216,115,53,.18); }
.category-button { border-radius: 10px; transition: background .15s, color .15s, border-color .15s; }
.category-button.is-active { background: linear-gradient(90deg, rgba(216,115,53,.22), rgba(216,115,53,.06)); border-color: rgba(216,115,53,.45); }
.category-button small { padding: 1px 7px; border-radius: 99px; background: rgba(255,255,255,.05); font-size: 11px; }
.category-divider { display: flex; align-items: center; gap: 8px; letter-spacing: .08em; }
.category-divider::after { content: ""; flex: 1; height: 1px; background: var(--line-soft); }

.comp-browser { background: #1b1917; }
.browser-head { position: sticky; top: 0; z-index: 3; background: linear-gradient(180deg, var(--surface-raised), #1b1917); }
.browser-head h1 { letter-spacing: .01em; }
.result-count strong { color: var(--gold); font: 700 22px var(--serif); }
.filter-row button { border-radius: 99px; transition: background .15s, border-color .15s, color .15s; }
.filter-row button:hover { border-color: var(--gold); color: var(--ink); }

.entry-list { padding: 8px 10px 24px; gap: 6px; }
.entry-row { border: 1px solid var(--line-soft); border-radius: var(--radius); background: #201d1a; min-height: 72px; transition: background .15s, border-color .15s, transform .15s; }
.entry-row:hover { background: #28231f; border-color: #4a4137; transform: translateY(-1px); }
.entry-row.is-active { background: linear-gradient(90deg, #35261d, #28211c); border-color: rgba(216,115,53,.6); box-shadow: inset 3px 0 var(--ember); }
.entry-thumb { border-radius: 10px; background: radial-gradient(circle at 30% 25%, #2b2520, #0e0d0c); border-color: #3d352c; }
.entry-copy strong { font-size: 16px; }
.entry-copy span { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.35; }
.entry-meta { padding: 3px 9px; border-radius: 99px; background: rgba(198,165,103,.10); border: 1px solid rgba(198,165,103,.25); font-size: 11px; }

.entry-detail { background: radial-gradient(900px 400px at 100% 0, rgba(216,115,53,.07), transparent 60%), #181614; }
.detail-hero { padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(135deg, #25201c, #1b1917); box-shadow: var(--glow); }
.detail-image { border-radius: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.45); }
.detail-title { text-shadow: 0 2px 14px rgba(216,115,53,.25); }
.tag { border-radius: 99px; background: #1a1816; }
.stat-grid { gap: 10px; border: 0; background: transparent; }
.stat { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-raised); }
.stat strong { color: var(--gold); }
.detail-section { padding: 18px 20px; border: 1px solid var(--line-soft); border-radius: 14px; background: rgba(33,30,27,.55); }
.detail-section h2 { padding-bottom: 8px; border-bottom: 1px solid var(--line-soft); }
.action-block { border-radius: 0 10px 10px 0; }
.kv-table { border-radius: 10px; overflow: hidden; }
.detail-empty .detail-glyph { border-radius: 10px; box-shadow: 0 0 40px rgba(216,115,53,.18); }

.comp-sidebar, .comp-browser, .entry-detail { scrollbar-width: thin; scrollbar-color: #4a4137 transparent; }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
@media (max-width: 680px) {
  .entry-list { padding: 8px 8px 20px; }
  .detail-hero { padding: 14px; }
  .detail-section { padding: 14px; }
}
.entry-meta:empty { display: none; }
.entry-row:has(.entry-meta:empty) { grid-template-columns: 52px 1fr; }
.table-wrap { overflow-x: auto; margin: 12px 0; border: 1px solid var(--line); border-radius: 10px; }
.md-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.md-table th, .md-table td { padding: 8px 12px; border-bottom: 1px solid var(--line-soft); text-align: left; white-space: nowrap; }
.md-table th { background: #26211d; color: var(--gold); font-weight: 700; }
.md-table tbody tr:nth-child(even) td { background: rgba(255,255,255,.025); }
.md-table tbody tr:last-child td { border-bottom: 0; }

.game-rules-note { margin: 0 0 18px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.game-rules-note strong, .game-rules-note a { color: var(--gold); }
.game-rules-note p { margin: 6px 0; }
