:root {
  --bg: #14121c;
  --bg-panel: #1e1b2a;
  --bg-card: #262238;
  --border: #3a3550;
  --text: #ece9f5;
  --text-dim: #a29cc0;
  --accent: #d9a441;
  --accent-2: #7a5fd0;
  --danger: #d9534f;
  --hp-high: #4caf6d;
  --hp-mid: #d9a441;
  --hp-low: #d9534f;

  --element-nature: #5a9c4a;
  --element-water: #4a90c4;
  --element-air: #b9c6dd;
  --element-metal: #b7bec7;
  --element-fire: #e2572b;
  --element-light: #f2d878;
  --element-dark: #8a5fbf;

  /* Общая визуальная база (графит + золото). С Раздела 7 на ней сидит
     весь сайт: старая фиолетовая палитра выше осталась только для
     нескольких служебных цветов (HP, стихии, опасность). */
  --void: #0a0a0e;
  --panel: #151319;
  --panel-2: #1d1a22;
  --graphite: #26232c;
  --hairline: #3a3540;
  --gold: #c9a35c;
  --gold-bright: #f0d190;
  --gold-dim: #8a713f;
  --parchment: #ece3cf;
  --muted: #a89fae;

  /* Псевдонимы --cg-*: раньше объявлялись на .collection-screen и каждый
     новый экран приходилось дописывать в тот селектор (модалка в body и
     экран отряда на этом уже спотыкались). Теперь живут в :root и
     доступны везде. Это именно псевдонимы имён выше — в новом коде берите
     глобальные названия, --cg-* оставлены, чтобы не переименовывать
     несколько сотен обращений в collection.css разом. */
  --cg-bg: var(--void);
  --cg-bg-panel: var(--panel);
  --cg-bg-card: var(--panel-2);
  --cg-border: var(--hairline);
  --cg-border-soft: rgba(201, 163, 92, 0.25);
  --cg-gold: var(--gold);
  --cg-gold-bright: var(--gold-bright);
  --cg-gold-dim: var(--gold-dim);
  --cg-text: var(--parchment);
  --cg-text-dim: var(--muted);

  --cg-el-fire: var(--element-fire);
  --cg-el-water: var(--element-water);
  --cg-el-nature: var(--element-nature);
  --cg-el-air: var(--element-air);
  --cg-el-metal: var(--element-metal);
  --cg-el-light: var(--element-light);
  --cg-el-dark: var(--element-dark);

  /* ЕДИНСТВЕННОЕ место, где заданы цвета редкости. Меняются здесь и
     разъезжаются везде: JS не хранит их копию, а читает эти же
     переменные через getComputedStyle (см. rarityColor в config.js). */
  --rarity-1: #f2f2f0; /* белый */
  --rarity-2: #4fae6a; /* зелёный */
  --rarity-3: #4f9fe0; /* синий */
  --rarity-4: #a768e0; /* фиолетовый */
  --rarity-5: #ff3b47; /* алый */

  /* Боевой красный намеренно другой: приглушённый кирпичный. Урон, низкое
     HP и подсветка цели не должны читаться как «выпала пятёрка», поэтому
     алый редкости выше по яркости и насыщенности. */
  --combat-red: #d15656;
  --combat-red-dim: #8f3f3f;

  /* Подсветка союзной цели — пара к боевому красному: тёплый приглушённый
     зелёный, по яркости вровень с ним. Цвета стихий и редкостей нарочно
     не переиспользуются — боевые подсветки живут своей парой, как и сам
     --combat-red выше. */
  --pick-ally: #5e8f4f;
}

/* Цвет редкости берётся из data-rarity, а не назначается из JS: так
   значение живёт ровно в одном месте — в :root выше. */
[data-rarity="1"] { --rarity: var(--rarity-1); }
[data-rarity="2"] { --rarity: var(--rarity-2); }
[data-rarity="3"] { --rarity: var(--rarity-3); }
[data-rarity="4"] { --rarity: var(--rarity-4); }
[data-rarity="5"] { --rarity: var(--rarity-5); }
[data-rarity="6"] { --rarity: var(--rarity-5); }

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Work Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--void);
  color: var(--parchment);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

a {
  color: var(--accent);
}

/* Fixed page background: floating particles + edge vignette. Both use
   inset:0 (not 100vw/100vh) so a vertical scrollbar can never make them
   wider than the viewport and shift the centered layout sideways. */
#bg-particles,
#vignette {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

#vignette {
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.55) 100%);
}

.app {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 16px 64px;
}

/* Navbar */
.navbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--hairline);
  border-radius: 0 0 12px 12px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.navbar a,
.navbar button {
  position: relative;
  color: var(--muted);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 999px;
  font-family: "Work Sans", system-ui, sans-serif;
  font-size: 14px;
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
}

/* Точка на «Профиле» — есть что забрать в достижениях. Гаснет тем же
   способом, каким загорается: перечитыванием сервера, а не памятью
   о том, что было раньше (achievements.js, refreshAchievementsBadge). */
.navbar a.has-claim::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold-bright);
  box-shadow: 0 0 6px var(--gold);
}

.navbar a:hover,
.navbar button:hover {
  background: var(--panel-2);
  color: var(--parchment);
}

.navbar a.active {
  color: var(--void);
  background: var(--gold);
  font-weight: 600;
}

.navbar a.active:hover {
  background: var(--gold-bright);
  color: var(--void);
}

.navbar .spacer {
  flex: 1;
}

/* На телефоне навбар с шестью ссылками, брендом и двумя кнопками не
   помещался в строку и переносился на три — около 130px, и он sticky,
   то есть висел постоянно. Вместе с нижним отступом .app это забирало
   больше двухсот пикселей ещё до того, как начинался экран боя.
   Теперь одна строка с прокруткой вбок. */
@media (max-width: 640px) {
  .navbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    gap: 2px;
    padding: 6px 10px;
  }

  .navbar::-webkit-scrollbar {
    display: none;
  }

  .navbar > * {
    flex: 0 0 auto;
  }

  /* Распорка растянула бы строку и увела ссылки за экран. */
  .navbar .spacer {
    display: none;
  }

  .navbar a,
  .navbar button {
    padding: 6px 10px;
    font-size: 13px;
    white-space: nowrap;
  }

  .navbar .brand {
    font-size: 15px;
    padding: 6px 8px 6px 2px;
  }

  .app {
    /* 64px снизу под липкой панелью действий были просто пустой
       прокруткой. */
    padding: 10px 10px 12px;
  }
}

/* Правила .navbar__sound убраны вместе с кнопкой: звук переехал
   на экран настроек обычной галочкой, и подсвечивать в шапке больше
   нечего. */

.navbar .brand {
  font-family: "Cinzel Decorative", "Cinzel", serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 8px 16px 8px 4px;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold) 65%, var(--gold-dim));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Кнопки — единственный комплект на весь сайт. До Раздела 7 их было два
   (.btn фиолетовый и .cg-btn золотой), и экраны выглядели из разных игр. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: 8px;
  border: 1px solid var(--gold-dim);
  background: var(--panel-2);
  color: var(--gold-bright);
  cursor: pointer;
  font-family: "Cinzel", serif;
  font-size: 14px;
  letter-spacing: 0.03em;
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s, opacity 0.15s;
}

.btn:hover:not(:disabled) {
  border-color: var(--gold);
  box-shadow: 0 0 14px -2px var(--gold);
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn--primary {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold) 70%);
  border-color: var(--gold);
  color: #171217;
  font-weight: 600;
}

.btn--primary:hover:not(:disabled) {
  box-shadow: 0 0 18px -2px var(--gold);
}

.btn--danger {
  border-color: #8f3f3f;
  color: #d17a7a;
}

.btn--danger:hover:not(:disabled) {
  border-color: #d15656;
  box-shadow: 0 0 14px -2px #8f3f3f;
}

.btn--ghost {
  background: none;
  border-color: transparent;
  color: var(--muted);
}

.btn--ghost:hover:not(:disabled) {
  color: var(--parchment);
  box-shadow: none;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* Layout helpers */
.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 16px 18px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.divider {
  height: 1px;
  margin: 16px 0;
  background: linear-gradient(90deg, transparent, var(--cg-border-soft) 20%, var(--cg-border-soft) 80%, transparent);
}

/* Заголовок экрана — один вид на всех девяти экранах. */
.page-header {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.page-header__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.title {
  font-family: "Cinzel", serif;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin: 0 0 4px;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold) 65%, var(--gold-dim));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 18px rgba(212, 175, 55, 0.25);
}

.title--sub {
  font-size: 19px;
}

.subtitle {
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
  font-size: 16px;
  color: var(--muted);
  margin: 0;
}

.banner {
  background: linear-gradient(180deg, rgba(201, 163, 92, 0.16), rgba(201, 163, 92, 0.07));
  border: 1px solid var(--gold-dim);
  color: var(--parchment);
  padding: 11px 15px;
  border-radius: 10px;
  margin-bottom: 12px;
}

.banner a {
  color: var(--gold-bright);
  text-decoration: underline;
}

/* ---- Загрузка / пустота / ошибка --------------------------------------- */

.skeleton-group {
  display: grid;
  gap: 12px;
}

.skeleton-group--card {
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 20px;
}

.skeleton {
  border-radius: 10px;
  background: linear-gradient(100deg, var(--panel) 30%, var(--graphite) 50%, var(--panel) 70%);
  background-size: 300% 100%;
  animation: skeleton-sheen 1.5s ease-in-out infinite;
}

.skeleton--row { height: 62px; }
.skeleton--panel { height: 132px; }
.skeleton--card { aspect-ratio: 2 / 3; }

@keyframes skeleton-sheen {
  from { background-position: 130% 0; }
  to { background-position: -30% 0; }
}

.empty-state,
.error-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 38px 16px;
  text-align: center;
  border: 1px dashed var(--hairline);
  border-radius: 12px;
}

.empty-state__mark,
.error-state__mark {
  font-family: "Cinzel", serif;
  font-size: 22px;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--gold-dim);
  color: var(--gold);
}

.empty-state__text,
.error-state__text {
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
  font-size: 18px;
  color: var(--parchment);
  max-width: 460px;
}

.empty-state__hint {
  font-family: "Work Sans", system-ui, sans-serif;
  font-size: 13px;
  color: var(--muted);
  max-width: 460px;
}

.error-state {
  border-color: #6d3434;
}

.error-state__mark {
  border-color: #8f3f3f;
  color: #d17a7a;
}

@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
  }
}

/* Forms */
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.field label {
  font-family: "Work Sans", system-ui, sans-serif;
  font-size: 12px;
  color: var(--muted);
}

.field input,
.field select,
input[type="text"],
input[type="number"],
select {
  background: var(--panel-2);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  color: var(--parchment);
  padding: 9px 14px;
  font-size: 14px;
  font-family: "Work Sans", system-ui, sans-serif;
}

.field input:focus,
.field select:focus,
input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 1px var(--gold-dim);
}

.field input::placeholder,
input::placeholder {
  color: var(--muted);
}

.field-error {
  color: #d17a7a;
  font-size: 13px;
  min-height: 18px;
}

/* .hero-card* удалены в Разделе 7: «Каталог» рисовал ими свою карточку, и
   один и тот же герой выглядел там иначе, чем в «Коллекции». Теперь оба
   экрана берут heroGridCardEl из components.js — то есть .cg-card. */

.stars {
  color: var(--gold);
  font-size: 12px;
}

.badge {
  display: inline-block;
  font-family: "Work Sans", system-ui, sans-serif;
  font-size: 11px;
  letter-spacing: 0.02em;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--hairline);
  color: var(--muted);
}

.badge--healthy { color: #7fd99a; border-color: #3f8f5a; }
.badge--wounded { color: var(--gold-bright); border-color: var(--gold-dim); }
.badge--unconscious { color: #d17a7a; border-color: #8f3f3f; }
.badge--active { color: #171217; background: var(--gold); border-color: var(--gold); font-weight: 600; }

/* Bars */
.bar {
  height: 10px;
  border-radius: 999px;
  background: #0d0c0e;
  border: 1px solid var(--hairline);
  overflow: hidden;
  position: relative;
}

.bar__fill {
  height: 100%;
  transition: width 0.2s;
}

.bar__fill--high { background: linear-gradient(90deg, #3f8f5a, #58c97a); }
.bar__fill--mid { background: linear-gradient(90deg, var(--gold-dim), var(--gold)); }
.bar__fill--low { background: linear-gradient(90deg, #8f3f3f, #d15656); }
.bar__fill--energy { background: linear-gradient(90deg, #3d6f92, var(--element-water)); }

.bar-label {
  font-family: "Work Sans", system-ui, sans-serif;
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 5, 6, 0.68);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Выше карточки героя (cg-modal-overlay, 300): модалка вызывается в
     том числе из неё — выбор снаряжения, — и была бы под ней. */
  z-index: 400;
  padding: 16px;
}

.modal {
  position: relative;
  background: linear-gradient(165deg, rgba(31, 28, 34, 0.94), rgba(12, 11, 14, 0.96));
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid var(--cg-border-soft);
  border-radius: 14px;
  padding: 24px;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 70px -20px rgba(0, 0, 0, 0.85), 0 0 40px -14px var(--gold);
  font-family: "Cormorant Garamond", serif;
  color: var(--parchment);
}

.modal__close {
  float: right;
  padding: 4px 12px;
}

/* Toast */
#toast-root {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  /* Поверх модалок: сообщение об ошибке чаще всего относится к тому,
     что игрок только что нажал в модалке. */
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.toast {
  background: var(--panel-2);
  border: 1px solid var(--hairline);
  border-left: 3px solid #8f3f3f;
  color: var(--parchment);
  padding: 11px 18px;
  border-radius: 8px;
  font-family: "Work Sans", system-ui, sans-serif;
  font-size: 14px;
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.8);
  animation: toast-in 0.15s ease-out;
}

.toast--info {
  border-left-color: var(--gold);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Боевой экран переехал на .cb-* в collection.css (Раздел 5). Прежние
   .combat-grid / .combatant-card / .combat-log / .action-bar удалены —
   ими пользовался только combat.js. */

/* Плашка «Игроки». Спокойный список: точка состояния, имя, время.
   Зелёная точка — в сети, серая — нет; кислотных цветов здесь не нужно,
   состояние читается и без них. */
.players {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel);
}

.players__row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--hairline);
}

.players__row:last-child {
  border-bottom: none;
}

.players__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.players__dot.is-online {
  background: var(--hp-high);
  box-shadow: 0 0 8px -1px var(--hp-high);
}

.players__dot.is-offline {
  background: var(--hairline);
}

.players__name {
  font-family: "Cinzel", serif;
  font-size: 16px;
  color: var(--parchment);
  flex: 1 1 auto;
}

.players__seen {
  font-family: "Cormorant Garamond", "Georgia", serif;
  font-size: 15px;
  color: var(--muted);
  flex: 0 0 auto;
}

.players__seen.is-online {
  color: var(--gold);
}

/* ---------------------------------------------------------------------------
   Поселение

   Местность, а не список кнопок. Арта пока нет, поэтому земля нарисована
   градиентами, а постройки — силуэтами из разметки.

   Ни одного background-image и ни одного <img>: экран с отключёнными
   картинками выглядит ровно так же, потому что показывать ему нечего,
   кроме того, что уже нарисовано стилями. Когда придёт настоящий арт,
   он ляжет фоном на .settlement-map, а участки останутся на своих местах.
--------------------------------------------------------------------------- */

.settlement-map {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--hairline);
  /* Земля: тёплый отсвет сверху, темнота у нижнего края. */
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(201, 163, 92, 0.10), transparent 60%),
    linear-gradient(180deg, var(--panel-2), var(--void));
}

/* На телефоне участков в ряду два: при четырёх постройка ужимается
   до подписи в две строки и перестаёт читаться. */
@media (max-width: 620px) {
  .settlement-map {
    grid-template-columns: repeat(2, 1fr);
  }
}

.settlement-plot {
  min-height: 132px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 10px;
  text-align: center;
}

.settlement-plot--building {
  cursor: pointer;
  /* Кнопка не наследует шрифт страницы сама: без этого подпись уровня
     набралась бы системным шрифтом браузера и выпала из оформления. */
  font: inherit;
  color: var(--gold);
  border: 1px solid var(--cg-border-soft);
  background: linear-gradient(180deg, rgba(38, 35, 44, 0.9), rgba(21, 19, 25, 0.9));
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.settlement-plot--building:hover,
.settlement-plot--building:focus-visible {
  border-color: var(--gold);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px -10px var(--gold);
}

.settlement-plot__glyph {
  width: 40px;
  height: 40px;
  color: var(--gold);
  opacity: 0.85;
}

.settlement-plot__name {
  font-family: "Cinzel", serif;
  font-size: 16px;
  letter-spacing: 0.03em;
  color: var(--gold-bright);
}

.settlement-plot__level {
  font-size: 12px;
  color: var(--muted);
}

.settlement-plot__blurb {
  font-family: "Cormorant Garamond", "Georgia", serif;
  font-size: 14px;
  line-height: 1.25;
  color: var(--muted);
}

/* Пустырь. Ни рамки, ни подписи: пять пустых рамок со служебным текстом
   читаются как недоделанный интерфейс, пять пустырей — как «есть куда
   расти». Три варианта земли, чтобы участки не выглядели штампованными. */
.settlement-plot--empty {
  border: none;
  background: linear-gradient(180deg, rgba(58, 53, 64, 0.22), transparent 70%);
  opacity: 0.75;
}

.settlement-plot--empty[data-plot="1"] {
  background:
    radial-gradient(60% 40% at 30% 70%, rgba(58, 53, 64, 0.30), transparent 70%),
    linear-gradient(180deg, rgba(58, 53, 64, 0.14), transparent 70%);
}

.settlement-plot--empty[data-plot="2"] {
  background:
    radial-gradient(50% 35% at 70% 60%, rgba(90, 156, 74, 0.10), transparent 70%),
    linear-gradient(180deg, rgba(58, 53, 64, 0.18), transparent 70%);
}

/* Место Посланника: размечено, но пусто. Она появляется только
   в обучении, которого ещё нет. */
.settlement-plot--envoy {
  border: none;
  background: radial-gradient(50% 45% at 50% 55%, rgba(240, 209, 144, 0.07), transparent 70%);
}

/* ---------------------------------------------------------------------------
   Знания

   Слева оглавление, справа текст. На узком экране одно под другим:
   справочник читают с телефона, и колонка в half-экрана там не работает.
--------------------------------------------------------------------------- */

.knowledge {
  display: grid;
  grid-template-columns: minmax(180px, 240px) 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 720px) {
  .knowledge {
    grid-template-columns: 1fr;
  }
}

.knowledge__list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 16px;
}

/* Прилипшее оглавление на телефоне съедало бы пол-экрана при чтении. */
@media (max-width: 720px) {
  .knowledge__list {
    position: static;
  }
}

.knowledge__section-name {
  font-family: "Cinzel", serif;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 4px 0 6px;
}

.knowledge__topic {
  font: inherit;
  font-family: "Cormorant Garamond", "Georgia", serif;
  font-size: 16px;
  text-align: left;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.knowledge__topic:hover,
.knowledge__topic:focus-visible {
  color: var(--parchment);
  border-color: var(--cg-border-soft);
}

.knowledge__topic.is-open {
  color: var(--gold-bright);
  border-color: var(--cg-border-soft);
  background: var(--panel);
}

.knowledge__text {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 18px 20px;
  /* Длинная строка на широком мониторе читается плохо. */
  max-width: 62ch;
}

.knowledge__paragraph {
  font-family: "Cormorant Garamond", "Georgia", serif;
  font-size: 17px;
  line-height: 1.55;
  color: var(--parchment);
  margin: 10px 0 0;
}

/* Номер версии. Мелко, в углу, поверх фона, но под всем, с чем игрок
   работает: подсказка для жалобы, а не элемент интерфейса.
   Кликам не мешает — pointer-events выключены. */
.version-tag {
  position: fixed;
  right: 10px;
  bottom: 8px;
  z-index: 1;
  pointer-events: none;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
  opacity: 0.55;
}

/* ---------------------------------------------------------------------------
   Контекстные подсказки

   Выделение элемента, короткий текст рядом и затемнение остального.
   Общий механизм клиента: обучение станет первым потребителем, но
   не хозяином — см. шапку js/hints.js.

   Слой выше модалки (400), но ниже тоста (500): подсказка может однажды
   показать что-то внутри модального окна, а сообщение об ошибке обязано
   остаться видным поверх любой из них.
--------------------------------------------------------------------------- */

.hint-layer {
  position: fixed;
  inset: 0;
  z-index: 450;
  /* Затемнение кликов не ловит. Жёсткой блокировки интерфейса в игре
     нет — правило паспорта про мягкий выход, — и подсказка не должна
     становиться первой: игрок волен уйти, не выполнив её. */
  pointer-events: none;
}

/* ВИДИМОСТЬ — СОСТОЯНИЕ, А НЕ РЕЗУЛЬТАТ ПЕРЕХОДА, и это не придирка.
   Сначала слой открывался переходом opacity 0 → 1, и в скрытой вкладке
   переход не стартовал вовсе: слой оставался прозрачным при выставленном
   классе (замер: visibilityState hidden, computed opacity 0 против 1
   каскада). Теперь показанный слой виден сам по себе, а появление
   только украшает — не отработай оно, подсказка всё равно на экране. */
.hint-layer.is-shown {
  animation: hint-appear 180ms ease-out;
}

/* Цели ещё нет: слой стоит пустым и невидимым. Пустое затемнение
   посреди экрана — самостоятельная поломка, хуже отсутствия подсказки. */
.hint-layer.is-waiting {
  opacity: 0;
}

@keyframes hint-appear {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Одна из четырёх штор вокруг выреза. Приглушённая, не чёрная стена:
   игрок должен видеть, где он находится, а не только куда нажать. */
.hint-dim {
  position: absolute;
  background: rgba(6, 5, 6, 0.62);
}

/* Кольцо вокруг цели. Над самой целью не лежит ничего — вырез
   настоящий, — поэтому кольцо только обводит её по краю. */
.hint-ring {
  position: absolute;
  border-radius: 12px;
  border: 1px solid var(--gold);
  box-shadow:
    0 0 0 1px rgba(6, 5, 6, 0.5),
    0 0 18px -2px var(--gold);
  /* Дышит только прозрачностью: фильтры и тени, анимируемые непрерывно,
     на iOS дорогие (правило проекта). */
  animation: hint-ring-breath 1900ms ease-in-out infinite;
}

@keyframes hint-ring-breath {
  0%, 100% { opacity: 0.75; }
  50% { opacity: 1; }
}

.hint-bubble {
  position: absolute;
  max-width: min(320px, calc(100vw - 20px));
  /* Сжатому пузырю нужна прокрутка внутри: когда места не хватает ни
     снизу, ни сверху, ни вбок, он садится ростом в свободную полосу
     и текст листается в нём. Лечь на цель он не может ни при каких
     размерах окна — это правило, а не пожелание. */
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 16px;
  border-radius: 12px;
  background: linear-gradient(165deg, rgba(31, 28, 34, 0.97), rgba(12, 11, 14, 0.98));
  border: 1px solid var(--cg-border-soft);
  box-shadow: 0 18px 44px -16px rgba(0, 0, 0, 0.9);
}

/* Пузырь приезжает к цели, а не от неё: снизу вверх, если стоит под
   целью, и сверху вниз, если над. Тем же правилом, что и слой, —
   движением, а не переходом: не сыграет, и пузырь просто на месте. */
.hint-layer.is-shown .hint-bubble {
  animation: hint-bubble-rise 180ms ease-out;
}

.hint-layer.is-shown .hint-bubble--above {
  animation-name: hint-bubble-drop;
}

@keyframes hint-bubble-rise {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes hint-bubble-drop {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.hint-bubble__text {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: 17px;
  line-height: 1.45;
  color: var(--parchment);
}

/* Просьбу не двигать интерфейс уважаем: подсказка остаётся целиком,
   уходит только движение. */
@media (prefers-reduced-motion: reduce) {
  .hint-layer.is-shown,
  .hint-layer.is-shown .hint-bubble,
  .hint-layer.is-shown .hint-bubble--above {
    animation: none;
  }

  .hint-ring {
    animation: none;
    opacity: 1;
  }
}

/* Стенд приёмки подсказок (?hints=1). Служебный, не игра — оттого
   и вид служебный: моноширинный, в углу, поверх подсказки, чтобы
   автор мог навести следующую, не гася предыдущую вслепую. */
.hint-demo {
  position: fixed;
  left: 10px;
  bottom: 10px;
  z-index: 460;
  width: 232px;
  max-height: 70vh;
  overflow-y: auto;
  padding: 10px;
  border-radius: 10px;
  background: rgba(12, 11, 14, 0.94);
  border: 1px solid var(--hairline);
  font-family: "Work Sans", system-ui, sans-serif;
  font-size: 12px;
  color: var(--muted);
}

.hint-demo.is-active {
  border-color: var(--gold-dim);
}

.hint-demo__title {
  font-family: "Cinzel", serif;
  font-size: 13px;
  color: var(--gold-bright);
  margin-bottom: 4px;
}

.hint-demo__note {
  margin-bottom: 8px;
  opacity: 0.75;
}

.hint-demo__list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.hint-demo__target,
.hint-demo__btn {
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--hairline);
  background: var(--panel-2);
  color: var(--parchment);
  font-family: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.hint-demo__target:hover,
.hint-demo__btn:hover {
  border-color: var(--gold-dim);
}

.hint-demo__row {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.hint-demo__btn {
  flex: 1 1 auto;
  text-align: center;
}

.hint-demo__field {
  flex: 1 1 auto;
  min-width: 0;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--hairline);
  background: var(--void);
  color: var(--parchment);
  font-family: inherit;
  font-size: 12px;
}

.hint-demo__empty {
  opacity: 0.6;
  font-style: italic;
}

/* ---------------------------------------------------------------------------
   Обучение
   ---------------------------------------------------------------------------

   Два слоя поверх игры, и оба выше подсказки (450), но ниже тоста (500):
   сообщение об ошибке относится к тому, что игрок только что нажал,
   и прятать его за обучением нельзя.

   Панель шага живёт рядом с подсказкой, а не вместо неё: подсказка
   обводит цель и говорит одну фразу, панель ведёт вперёд. Слить их
   в одно значило бы заводить кнопку внутри пузыря — и пузырь, который
   у цели помещался, перестал бы помещаться. */

.tut-scene {
  position: fixed;
  inset: 0;
  z-index: 470;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  /* Затемнение кликов не ловит — то же правило, что у подсказки,
     и по той же причине. Жёсткой блокировки интерфейса в игре нет:
     игрок волен уйти в другой раздел посреди реплики, и вкладки
     в шапке обязаны остаться нажимаемыми. Уйдёт — увидит кнопку
     возврата. */
  pointer-events: none;
}

/* Портрет во весь экран, прижат к низу и по центру.
   ПОЗЫ ПОДМЕНЯЮТ ДРУГ ДРУГА НА ОДНОМ МЕСТЕ: все семь файлов одного
   размера и выровнены по лицу, поэтому смена позы не должна двигать
   картинку. Отсюда и жёсткая привязка к низу — любой из способов
   «вписать» её по-своему сдвинул бы лицо на пару десятков пикселей,
   и смена реплики читалась бы скачком. */
.tut-scene__portrait {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  height: 100%;
  max-width: 100%;
  object-fit: contain;
  object-position: bottom center;
  /* Портрет — картинка, а не кнопка: касания уходят сквозь него
     на панель и на шапку. */
  pointer-events: none;
  /* Низ портрета уходит под панель: градиент внизу панели делает
     переход, а резкая граница выдала бы вырезанную фигуру. */
  -webkit-mask-image: linear-gradient(to bottom, #000 72%, transparent 98%);
  mask-image: linear-gradient(to bottom, #000 72%, transparent 98%);
}

/* Панель текста поверх нижней части экрана. Она же и есть «касание»:
   одно нажатие — один абзац. */
.tut-scene__panel {
  position: relative;
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 20px 22px calc(20px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(
    to bottom,
    rgba(6, 5, 6, 0) 0%,
    rgba(10, 9, 12, 0.88) 18%,
    rgba(10, 9, 12, 0.97) 100%
  );
  border-top: 1px solid var(--cg-border-soft);
  cursor: pointer;
  pointer-events: auto;
  -webkit-user-select: none;
  user-select: none;
}

/* Пустой текст показывается пустым и реплику не роняет — требование
   задания. Высота строки остаётся, чтобы низ панели не прыгал, когда
   абзацы разной длины сменяют друг друга. */
.tut-scene__text {
  margin: 0 0 14px;
  min-height: 3.2em;
  white-space: pre-line;
  line-height: 1.6;
  font-size: 1.02rem;
}

.tut-scene__row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.tut-scene__spacer {
  flex: 1 1 auto;
}

.tut-scene__count,
.tut-scene__more {
  font-size: 13px;
  color: var(--muted);
}

/* Указатель «дальше» дышит прозрачностью, а не движением: непрерывно
   анимируемые тени и фильтры на iOS дороги — правило проекта. */
.tut-scene__more {
  animation: tut-more-breath 1900ms ease-in-out infinite;
}

@keyframes tut-more-breath {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .tut-scene__more { animation: none; opacity: 0.8; }
}

.tut-bar {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 470;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  width: min(560px, calc(100vw - 20px));
  padding: 10px 14px;
  border-radius: 12px;
  background: linear-gradient(165deg, rgba(31, 28, 34, 0.97), rgba(12, 11, 14, 0.98));
  border: 1px solid var(--cg-border-soft);
  box-shadow: 0 18px 44px -16px rgba(0, 0, 0, 0.9);
}

.tut-bar__step {
  font-size: 13px;
  color: var(--muted);
}

.tut-bar__spacer {
  flex: 1 1 auto;
}

/* Где обучение ждёт. Словами, без нажатия: кнопки перехода у обучения
   нет — она уносила игрока с боевого экрана посреди боя. */
.tut-bar__where {
  font-size: 13px;
  color: var(--parchment);
  opacity: 0.85;
}

/* ---------------------------------------------------------------------
   Арена (блок 3 PvP, 13 сентября 2026). Материалы сайта — графит
   и золото; акцент у героя — свет его стихии (--glow), без кислоты.
   --------------------------------------------------------------------- */
.arena-screen .stack {
  gap: 14px;
}

.arena-mine {
  display: grid;
  gap: 10px;
}

.arena-mine__list {
  display: grid;
  gap: 8px;
}

.arena-mine__row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--panel-2);
  border: 1px solid var(--hairline);
  border-radius: 10px;
}

.arena-mine__row.is-active {
  border-color: var(--gold-dim);
}

.arena-mine__info {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.arena-mine__name-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.arena-mine__name {
  font-weight: 600;
}

.arena-mine__power {
  color: var(--gold);
  font-family: "Cinzel", serif;
  font-size: 13px;
}

.arena-mine__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.arena-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.arena-picker select {
  min-width: 160px;
  padding: 8px 10px;
  background: var(--panel-2);
  color: var(--parchment);
  border: 1px solid var(--hairline);
  border-radius: 8px;
}

.arena-list {
  display: grid;
  gap: 14px;
}

.arena-card {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 14px 16px;
  display: grid;
  gap: 12px;
}

.arena-card__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.arena-card__nick {
  font-family: "Cinzel", serif;
  font-size: 18px;
  color: var(--parchment);
}

.arena-card__power {
  text-align: right;
  display: grid;
}

.arena-card__power-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.arena-card__power-value {
  font-family: "Cinzel", serif;
  font-size: 22px;
  color: var(--gold-bright);
  font-variant-numeric: tabular-nums;
}

.arena-heroes {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.arena-hero {
  display: grid;
  gap: 4px;
  padding: 8px;
  min-width: 0;
  background: var(--panel-2);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  box-shadow: inset 0 -18px 30px -24px var(--glow, var(--gold));
}

.arena-hero__art {
  height: 96px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  border-radius: 8px;
  background: radial-gradient(
    ellipse at 50% 100%,
    color-mix(in srgb, var(--glow, var(--gold)) 35%, transparent),
    transparent 70%
  );
}

.arena-hero__img {
  max-height: 96px;
  max-width: 100%;
  object-fit: contain;
}

.arena-hero__chibi {
  height: 96px;
  width: 100%;
}

.arena-hero__placeholder {
  font-family: "Cinzel", serif;
  font-size: 28px;
  color: var(--muted);
  padding-bottom: 8px;
}

.arena-hero__name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.arena-hero__stars {
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 1px;
}

.arena-hero__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.arena-hero__element {
  display: inline-flex;
}

.arena-hero__element svg {
  width: 14px;
  height: 14px;
}

.arena-hero__gear {
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.arena-card__foot {
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 640px) {
  .arena-heroes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .arena-card__head {
    flex-direction: column;
    align-items: flex-start;
  }

  .arena-card__power {
    text-align: left;
  }
}

/* Арена: боты и отчёт о бое (блок 5 PvP) */
.arena-card__bot {
  display: inline-block;
  margin-top: 2px;
  padding: 1px 8px;
  border: 1px solid var(--line, rgba(201, 163, 92, 0.45));
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--gold, #c9a35c);
}
.cb-report {
  margin: 14px auto 0;
  max-width: 720px;
  padding: 0 10px;
}
.cb-report__title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}
.cb-report__scroll {
  overflow-x: auto;
}
.cb-report__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.cb-report__table th,
.cb-report__table td {
  padding: 4px 6px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.cb-report__table th:first-child,
.cb-report__table td:first-child {
  text-align: left;
}
.cb-report__row--enemy .cb-report__name {
  opacity: 0.8;
}

/* Арена: живой бой (блок 6 PvP) — ждущий соперник и ожидание */
.arena-card__live {
  display: inline-block;
  margin-top: 2px;
  margin-left: 6px;
  padding: 1px 8px;
  border: 1px solid rgba(120, 200, 160, 0.55);
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: #8fd6b0;
}
.arena-live {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line, rgba(201, 163, 92, 0.35));
  border-radius: 10px;
}
.arena-live__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.arena-live__row.is-waiting {
  justify-content: flex-start;
}
.arena-live__pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #8fd6b0;
  box-shadow: 0 0 0 0 rgba(143, 214, 176, 0.6);
  animation: arena-live-pulse 1.6s ease-out infinite;
}
@keyframes arena-live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(143, 214, 176, 0.6); }
  100% { box-shadow: 0 0 0 10px rgba(143, 214, 176, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .arena-live__pulse { animation: none; }
}
