/* База знаний (v0.38): окно в игре (#codex-win) и страница codex.html — одни и те же карточки */
.codex-win {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 30;
  width: min(760px, calc(100vw - 16px)); height: min(80vh, 760px);
  padding: 0 12px 12px; display: flex; flex-direction: column; overflow: hidden;
}
.cx-tools { display: flex; gap: 4px; align-items: center; }
.cx-top { padding: 8px 0 6px; }
.cx-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.cx-tab, .cx-group {
  font: inherit; font-size: 13.5px; color: var(--muted); cursor: pointer;
  background: rgba(0,0,0,.3); border: 1px solid var(--border); border-radius: 3px; padding: 4px 10px;
}
.cx-tab.active { color: var(--gold); background: rgba(58,44,28,.6); border-color: var(--border-hi); }
.cx-groups { display: flex; flex-wrap: wrap; gap: 3px; width: 100%; margin-top: 4px; }
.cx-group { font-size: 12px; padding: 2px 8px; }
.cx-group.active { color: #e6dcc4; border-color: var(--border-hi); }
.cx-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 5px; padding: 8px 0 4px; }
.cx-found { color: var(--muted); font-size: 12px; }
.cx-card { background: rgba(0,0,0,.32); border: 1px solid var(--border); border-radius: 3px; }
.cx-head { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; padding: 6px 8px; cursor: pointer; }
.cx-head:hover { background: rgba(80,62,38,.25); }
.cx-head img { width: 38px; height: 38px; }
.cx-mid { min-width: 0; }
.cx-name { font-size: 14.5px; color: #e9dfcc; }
.cx-name.cx-boss { color: #ff9a6a; }
.cx-kind { font-size: 11.5px; color: var(--muted); line-height: 1.3; }
.cx-stats { font-size: 12.5px; color: #cfc6ae; margin-top: 2px; }
.cx-sell { font-size: 12px; color: var(--gold); white-space: nowrap; }
.cx-more { padding: 2px 10px 8px; border-top: 1px solid rgba(107,84,49,.4); }
.cx-more.hidden { display: none; }
.cx-desc { font-size: 12.5px; color: #b8ae96; line-height: 1.35; margin: 4px 0; }
.cx-src-h { font-size: 12px; color: var(--gold); margin: 6px 0 2px; }
.cx-line { font-size: 12.5px; color: #cfc6ae; line-height: 1.4; }
.cx-rows { display: flex; flex-direction: column; gap: 1px; }
.cx-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; font-size: 12.5px; align-items: baseline; }
.cx-row-n { font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cx-row-p { color: #ffd88a; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cx-row-m { color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cx-dim { color: var(--muted); font-size: 12.5px; }
/* v0.41: переходы по ссылкам, кнопка «Назад» и портреты монстров */
.cx-back { display: flex; align-items: center; gap: 8px; padding-bottom: 2px; }
.cx-back-btn { white-space: nowrap; }
.cx-back-to { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cx-link {
  font: inherit; color: #9fd0ff; background: none; border: 0; padding: 0; cursor: pointer;
  text-align: left; border-bottom: 1px dotted rgba(159,208,255,.5);
}
.cx-link:hover { color: #cfe6ff; border-bottom-style: solid; }
.cx-link-dim { color: #b8ae96; border-bottom-color: rgba(184,174,150,.45); }
.cx-link-dim:hover { color: #e6dcc4; }
.cx-row-link { grid-template-columns: auto 1fr auto 1fr; align-items: center; }
.cx-row .cx-link { justify-self: start; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cx-row-m .cx-link { display: inline; }
.cx-row-img { width: 28px; height: 28px; flex: none; object-fit: contain; }
.cx-mob-img { width: 52px; height: 52px; object-fit: contain; }
.cx-mob-none { display: grid; place-items: center; font-size: 26px; opacity: .75; }
.cx-head .cx-mob-img { width: 52px; height: 52px; }

body.mobile .codex-win { left: 0; right: 0; top: 0; bottom: 0; transform: none; width: auto; height: var(--app-h, 100vh); border-radius: 0; background: #120e0b; z-index: 60; }
body.mobile .cx-row { grid-template-columns: 1fr auto; }
body.mobile .cx-row-link { grid-template-columns: auto 1fr auto; }
body.mobile .cx-row-m { display: none; }

/* страница */
.codex-page .cp-main { max-width: 900px; margin: 0 auto; padding: 12px 16px 40px; }
.codex-page .cx-body { max-height: none; }
.codex-page .hp-play.ghost { background: transparent; color: var(--muted); }
