/* Оформление Mini App — редизайн.
 *
 * Правила прежние и не нарушены:
 *
 * 1. Цвета берутся у Telegram. Всё, кроме «своих» зон, наследует тему
 *    пользователя. Своих зон ровно две: карточка игрока (.pcard) и
 *    полоса «сейчас на тебе» в коллекции (.char-hero). У них собственный
 *    тёмный фон И собственный текст, поэтому они читаемы в любой теме
 *    клиента, а персонаж выглядит одинаково в карточке и в примерочной.
 * 2. Ничего не прокручивается вбок. Широкое — внутри себя (.scroll-x).
 * 3. Safe area обязательна.
 * 4. Ни одного шрифтового файла и ни одной картинки: свечения, лучи,
 *    рамки — CSS. Иконки — эмодзи.
 * 5. prefers-reduced-motion выключает всё движение.
 * 6. Логические отступы (padding-inline, margin-inline, inset-inline):
 *    вёрстка зеркалится под rtl сама. Числа и графики остаются ltr.
 */

:root {
  /* ---- тема Telegram (запасные значения обязательны) ---- */
  --bg: var(--tg-theme-bg-color, #ffffff);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #f2f2f7);
  --text: var(--tg-theme-text-color, #0f0f0f);
  --hint: var(--tg-theme-hint-color, #8b8f96);
  --link: var(--tg-theme-link-color, #2481cc);
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --destructive: var(--tg-theme-destructive-text-color, #e53935);
  --section-bg: var(--tg-theme-section-bg-color, var(--bg));
  --separator: var(--tg-theme-section-separator-color, rgba(128, 128, 128, .22));

  /* Акцент в заливках и обводках. color-mix задаётся один раз здесь,
     чтобы не повторять его в тридцати правилах. */
  --accent-04: color-mix(in srgb, var(--accent) 4%, transparent);
  --accent-10: color-mix(in srgb, var(--accent) 10%, transparent);
  --accent-16: color-mix(in srgb, var(--accent) 16%, transparent);
  --accent-30: color-mix(in srgb, var(--accent) 30%, transparent);

  --ok: #2fa36b;
  --warn: #e0a11b;

  /* ---- «свои» зоны: не зависят от темы клиента ---- */
  --brand-ink: #e9e9ed;          /* текст на своём фоне */
  --brand-ink-dim: #9a9ab0;
  --brand-ink-faint: #71718a;
  --brand-glow: #9184d9;         /* только линия и свечение, не заливка */
  --brand-glow-soft: rgba(145, 132, 217, .16);
  --brand-grad: linear-gradient(160deg, #272253 0%, #1b1c34 48%, #15162a 100%);
  --brand-halo: radial-gradient(120% 80% at 88% -14%, rgba(145, 132, 217, .40), transparent 62%);
  --gold: #d4af37;
  --silver: #9aa0a6;
  --bronze: #c07b45;

  --radius: 16px;
  --radius-lg: 18px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --gap: 12px;
  --pad: 16px;

  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 6px 20px rgba(0, 0, 0, .05);
  --shadow-brand: 0 1px 2px rgba(0, 0, 0, .45), 0 14px 34px rgba(0, 0, 0, .3);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabs-h: 58px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--secondary-bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
        Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body { padding-bottom: calc(var(--tabs-h) + var(--safe-bottom)); }

/* Цифры не должны дёргаться при изменении на единицу. */
.num { font-variant-numeric: tabular-nums; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- каркас экрана ---------- */

.screen {
  padding: calc(var(--safe-top) + 12px) var(--pad) 22px;
  max-width: 640px;
  margin: 0 auto;
  animation: screen-in .18s ease-out;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

h1 { font-size: 22px; font-weight: 700; margin: 0 0 4px; letter-spacing: -.02em; }
h2 { font-size: 17px; font-weight: 650; margin: 22px 0 10px; letter-spacing: -.01em; }
p  { margin: 0 0 10px; }
.muted { color: var(--hint); }
.small { font-size: 13px; }
.center { text-align: center; }
.kicker {
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--hint); margin-bottom: 8px;
}

/* ---------- карточки ---------- */

.card {
  background: var(--section-bg);
  border-radius: var(--radius);
  padding: var(--pad);
  margin-bottom: var(--gap);
  box-shadow: var(--shadow);
}
.card.tight { padding: 12px 14px; }
.card.plain { box-shadow: none; border: 1px solid var(--separator); }
.card.flush { padding: 4px 14px; }          /* карточка-список: строки сами дают отступ */

/* =====================================================================
   КАРТОЧКА ПРОФИЛЯ — «карточка бойца»
   =====================================================================
   Своя зона: собственный тёмный фон, собственный текст и свечение — не
   зависит от темы клиента и одинаково читается в светлой и тёмной.

   Слева персонаж крупно (арт или символ одного размера), справа имя,
   уровень крупным числом со свечением, полоса XP и метрики; клан —
   полосой в подвале, вместе с местом в рейтинге.

   Слот под будущий тип косметики (титул, рамка, эффект) — .pcard-slots:
   пустой не занимает места, заполненный встаёт под именем без переделки
   макета.
*/

.pcard {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--brand-grad);
  color: var(--brand-ink);
  box-shadow: var(--shadow-brand);
  margin-bottom: var(--gap);
}
.pcard::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(90% 70% at 18% 8%, rgba(145, 132, 217, .34), transparent 58%);
  pointer-events: none;
}
.pcard > * { position: relative; }

.pcard-head { display: flex; gap: 14px; align-items: flex-start; padding: 16px 16px 14px; }

/* ---- левая колонка: персонаж ---- */
.pcard-art {
  flex: none; width: 104px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.pcard-art-face {
  width: 104px; height: 104px; border-radius: 20px;
  display: grid; place-items: center; overflow: hidden;
  font-size: 54px; line-height: 1;
  background: linear-gradient(180deg, rgba(145, 132, 217, .24), rgba(145, 132, 217, .06));
  box-shadow: inset 0 0 0 1px rgba(145, 132, 217, .4);
}
.pcard-art-face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pcard-art-name {
  font-size: 11.5px; line-height: 1.25; text-align: center; color: #b7b1dc;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
/* Нет персонажа — приглашение, а не пустота. */
.pcard-art-face.is-empty {
  background: none; color: #5c5c78; font-size: 40px;
  border: 1.5px dashed rgba(255, 255, 255, .18); box-shadow: none;
}
.pcard-art-face.is-empty + .pcard-art-name { color: #8d88b8; }

/* ---- правая колонка ---- */
.pcard-id { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pcard-id-head { display: flex; align-items: flex-start; gap: 8px; }
.pcard-name-wrap { flex: 1; min-width: 0; }
.pcard-name {
  font-size: 19px; font-weight: 700; letter-spacing: -.02em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pcard-public { margin-top: 2px; font-size: 12px; color: #8b8ba2; }

/* Имя на своей карточке — кнопка: его меняют, глядя на себя. Публичная
   карточка чужого игрока рисует тем же классом обычный div, поэтому
   сброс висит на button, а не на .pcard-name: иначе чужое имя стало бы
   выглядеть нажимаемым, ничего не открывая. */
button.pcard-name {
  display: flex; align-items: center; gap: 6px;
  max-width: 100%; padding: 0; border: 0; background: none;
  font: inherit; font-size: 19px; font-weight: 700; letter-spacing: -.02em;
  color: inherit; cursor: pointer; text-align: start;
}
.pcard-name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard-name-edit { flex: none; font-size: 12px; opacity: .55; }
button.pcard-name:active .pcard-name-edit { opacity: 1; }

/* Аватар из Telegram — маленький: главное лицо здесь у персонажа. */
.pcard-face {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  background: #2a2c46; color: #c2bce6;
  display: grid; place-items: center; overflow: hidden;
  font-size: 16px; font-weight: 700;
  box-shadow: 0 0 0 2px rgba(145, 132, 217, .5);
}
.pcard-face img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Уровень — знак отличия: число крупно, со свечением. */
.pcard-level { display: flex; align-items: baseline; gap: 7px; margin-top: 12px; }
.pcard-level-n {
  font-size: 34px; line-height: 1; font-weight: 700; letter-spacing: -.03em;
  color: #cfc7ff; text-shadow: 0 0 22px rgba(145, 132, 217, .55);
}
.pcard-level-w { font-size: 11.5px; color: #8d88b8; }
/* Эмодзи ступени — рядом с числом и одного с ним роста: она и есть
   знак отличия, а не значок при подписи. */
.pcard-level-e { font-size: 26px; line-height: 1; }

/* Полоса опыта. Ширина ставится из JS, переход плавный. */
.pcard-xp { margin-top: 8px; }
.pcard-xp-track { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, .09); overflow: hidden; }
.pcard-xp-fill {
  height: 100%; width: 0; border-radius: 99px;
  background: linear-gradient(90deg, #7b6fd0, #b6a6ff);
  box-shadow: 0 0 12px rgba(145, 132, 217, .7);
  transition: width .6s cubic-bezier(.2, .8, .2, 1);
}
.pcard-xp-label { margin-top: 5px; font-size: 11px; color: #8b8ba2; }

/* Метрики — кнопки: каждый вход стоит рядом со своим числом. */
.pcard-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.pcard-pill {
  border: 0; font: inherit; font-size: 12px; font-weight: 600;
  padding: 4px 9px; border-radius: 9px; cursor: pointer;
  background: rgba(255, 255, 255, .07); color: var(--brand-ink);
  transition: background .15s ease;
}
.pcard-pill:hover { background: rgba(255, 255, 255, .12); }
.pcard-pill:active { background: rgba(145, 132, 217, .24); }
.pcard-pill.is-static { cursor: default; }
.pcard-pill.is-static:hover { background: rgba(255, 255, 255, .07); }

/* Слот под будущую косметику. */
.pcard-slots:not(:empty) { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* ---- подвал: клан и место в рейтинге ---- */
.pcard-strip {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; border-top: 1px solid rgba(255, 255, 255, .08);
  background: rgba(0, 0, 0, .16);
}
/* Клан в подвале — кнопка в обоих состояниях: в клане она открывает свой,
   без клана зовёт вступить. Сброс системного вида обязателен: без него
   браузер рисует внутри тёмной карточки белую кнопку. */
.pcard-strip-clan {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px;
  padding: 0; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 12.5px; color: #b7b1dc; text-align: start;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pcard-strip-clan:active { color: #d8d2f5; }
.pcard-strip-rank {
  flex: none; border: 0; background: none; font: inherit; cursor: pointer;
  display: flex; align-items: center; gap: 6px; color: #7e7e97; padding: 0;
}
.pcard-strip-rank b { font-size: 15px; font-weight: 700; color: #cfc7ff; }
.pcard-strip-rank:active b { color: #e4dcff; }

/* Полоса-приглашение внизу карточки (нет персонажа, нет клана). */
.pcard-cta {
  display: block; width: 100%;
  padding: 10px 15px; border: 0; border-top: 1px solid rgba(255, 255, 255, .08);
  background: rgba(145, 132, 217, .10); color: #cfc7ff;
  font: inherit; font-size: 13px; font-weight: 600; text-align: center; cursor: pointer;
}
.pcard-cta:hover { background: rgba(145, 132, 217, .18); }
.pcard-cta:active { background: rgba(145, 132, 217, .24); }

/* ---------- чужой профиль ---------- */
/* То же тело карточки, но без денег и истории: образ, уровень, коллекция. */
.pcard--public { text-align: center; }
.pcard--public .pcard-art-face {
  width: 88px; height: 88px; margin: 0 auto; border-radius: 24px;
  background: rgba(145, 132, 217, .16); display: grid; place-items: center;
  font-size: 46px; overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(145, 132, 217, .4);
}
.pcard--public .pcard-name { margin-top: 11px; font-size: 20px; font-weight: 700; }
.pcard--public .pcard-pills { justify-content: center; padding-top: 12px; }
.pcard--public .btn { margin: 0 16px 16px; width: calc(100% - 32px); }

/* ---------- быстрые входы под карточкой ---------- */

.quick { display: flex; gap: 8px; margin-bottom: var(--gap); }
.quick-btn {
  flex: 1; display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border: 0; border-radius: 12px;
  background: var(--section-bg); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 600;
  text-align: start; cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .12s ease;
}
.quick-btn:active { transform: scale(.98); }
.quick-btn .go { margin-inline-start: auto; color: var(--hint); }

/* ---------- витрина игр ---------- */

.game { display: flex; gap: 12px; align-items: flex-start; }
.game-icon {
  width: 50px; height: 50px; flex: none; border-radius: 14px;
  background: var(--accent-16);
  display: grid; place-items: center; font-size: 26px;
}
.game-body { flex: 1; min-width: 0; }
.game-title-row { display: flex; align-items: center; gap: 7px; }
.game-title { font-size: 15px; font-weight: 650; }
.game-desc { color: var(--hint); font-size: 12.5px; margin-top: 3px; line-height: 1.4; text-wrap: pretty; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  font-size: 11.5px; padding: 3px 8px; border-radius: 99px;
  background: var(--secondary-bg); color: var(--hint);
}
.chip.ok { color: var(--ok); }
.chip.ok::before { content: '✓ '; }
.chip.miss { opacity: .6; }
.chip.miss::before { content: '✗ '; }

/* ---------- кнопки ---------- */
/* Основная — обводка акцентом, не заливка. */

.btn {
  appearance: none; cursor: pointer; font: inherit; font-weight: 600;
  padding: 11px 16px; border-radius: 12px;
  border: 1px solid var(--accent);
  background: transparent; color: var(--accent);
  transition: transform .12s ease, background .15s ease, opacity .12s ease;
}
.btn:hover { background: var(--accent-10); }
.btn:active { transform: scale(.97); background: var(--accent-16); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: var(--radius-sm); }
/* Второстепенная кнопка обводится разделителем, а не растворяется в
   фоне: её заливка — тот же --secondary-bg, что и у страницы, и на
   странице (а не внутри карточки) она без обводки перестаёт читаться
   кнопкой вовсе — остаётся висеть надпись. */
.btn.ghost { border-color: var(--separator); background: var(--secondary-bg); color: var(--text); }
.btn.ghost:hover { background: color-mix(in srgb, var(--text) 8%, var(--secondary-bg)); }
.btn.danger { border-color: var(--destructive); color: var(--destructive); }
.btn.danger:hover { background: color-mix(in srgb, var(--destructive) 10%, transparent); }
.btn.solid { background: var(--accent); color: var(--accent-text); }
.btn.block { display: block; width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 120px; }

/* ---------- списки ---------- */

.list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 0; border-bottom: 1px solid var(--separator);
  min-width: 0;
}
.row:last-child { border-bottom: 0; }
button.row, a.row {
  width: 100%; border: 0; border-bottom: 1px solid var(--separator);
  background: none; color: inherit; font: inherit; text-align: start; cursor: pointer;
}
.row-face {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  background: var(--secondary-bg); display: grid; place-items: center;
  font-size: 16px; overflow: hidden;
}
.row-face img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Название и подпись — блоками, а не строкой: разметка строк собирается
   и на div, и на span (строка бывает кнопкой, а кнопку внутрь кнопки
   вкладывать нельзя), и без явного display подпись приезжает встык к
   названию — «vito1-е место». */
.row-main { flex: 1; min-width: 0; }
.row-title, .row-sub { display: block; }
.row-title { font-size: 14px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { color: var(--hint); font-size: 12px; margin-top: 1px; }
.row-value { font-weight: 650; white-space: nowrap; }
.row-go { color: var(--hint); }
.plus  { color: var(--ok); }
.minus { color: var(--destructive); }

.rank { flex: none; width: 26px; text-align: center; font-weight: 700; color: var(--hint); }
.rank.top1 { color: var(--gold); }
.rank.top2 { color: var(--silver); }
.rank.top3 { color: var(--bronze); }

/* Своя строка. Отдельно внизу — когда игрок не в топе. */
.row.me, .row-me {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 14px; border: 0; border-radius: var(--radius);
  background: var(--accent-16);
  box-shadow: inset 0 0 0 1px var(--accent-30);
}

/* ---------- переключатель разделов ---------- */

.seg {
  display: flex; gap: 4px; padding: 3px;
  background: var(--secondary-bg); border-radius: 12px; margin-bottom: var(--gap);
  overflow-x: auto; scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg button {
  flex: 1 0 auto; border: 0; background: none; color: var(--hint);
  font: inherit; font-size: 13px; font-weight: 600;
  padding: 8px 12px; border-radius: 9px; cursor: pointer;
  white-space: nowrap; transition: background .15s ease, color .15s ease;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--bg); color: var(--text); box-shadow: var(--shadow); }

/* ---------- плитки метрик ---------- */

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--gap); }
.tile { background: var(--section-bg); border-radius: 14px; padding: 13px; box-shadow: var(--shadow); }
.tile-value { font-size: 21px; font-weight: 700; letter-spacing: -.02em; }
.tile-label { color: var(--hint); font-size: 12px; margin-top: 2px; }

/* ---------- бейджи, прогресс ---------- */

.badge {
  display: inline-block; font-size: 11px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 99px;
  background: var(--secondary-bg); color: var(--hint);
}
.badge.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.badge.warn { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.badge.bad { background: color-mix(in srgb, var(--destructive) 16%, transparent); color: var(--destructive); }

.progress { height: 10px; border-radius: 99px; background: var(--secondary-bg); overflow: hidden; display: flex; }
.progress span { height: 100%; transition: width .4s ease; }
.progress .p-sent { background: var(--ok); }
.progress .p-failed { background: var(--destructive); }
.progress .p-blocked { background: var(--warn); }

/* ---------- нижняя навигация ---------- */
/* Четыре вкладки: Дом · Рейтинг · Коллекция · Люди. Пятой нет: персонажи
   стали вкладкой «Коллекция», друзья/клан/поиск — вкладкой «Люди»,
   история 💎 открывается из баланса на карточке профиля. */

.tabs {
  position: fixed; inset-inline: 0; bottom: 0;
  height: calc(var(--tabs-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex; align-items: stretch;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--separator);
  z-index: 20;
}
/* Атрибут `hidden` обязан прятать. Браузерное правило `[hidden]` слабее
   авторского, и своя раскладка (`display: flex` выше) его перебивала:
   пустая полоса вкладок висела внизу и на экране загрузки, и на первом
   экране новичка — там, где вкладок ещё нет вовсе. */
.tabs[hidden] { display: none; }
.tab {
  flex: 1; border: 0; background: none; color: var(--hint);
  font: inherit; font-size: 10.5px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 6px 2px;
  transition: color .15s ease;
}
.tab .ico { font-size: 19px; line-height: 1; }
.tab.active { color: var(--accent); }
.tab:active .ico { transform: scale(.9); }

/* ---------- скелеты ---------- */

.boot { padding: calc(var(--safe-top) + 12px) var(--pad) 20px; max-width: 640px; margin: 0 auto; }
.skeleton-card { display: flex; gap: 14px; align-items: center; }
.sk {
  background: linear-gradient(90deg,
      color-mix(in srgb, var(--hint) 14%, transparent) 25%,
      color-mix(in srgb, var(--hint) 24%, transparent) 37%,
      color-mix(in srgb, var(--hint) 14%, transparent) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-xs);
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
.sk-avatar { width: 56px; height: 56px; border-radius: 50%; flex: none; }
.sk-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.sk-line { height: 12px; }
.sk-block { height: 64px; }
.sk-card { height: 196px; border-radius: var(--radius-lg); }   /* скелет карточки профиля */
.sk-tile { height: 62px; }
.w60 { width: 60%; } .w40 { width: 40%; }

/* ---------- всплывающее сообщение ---------- */

.toast {
  position: fixed; inset-inline-start: 50%; bottom: calc(var(--tabs-h) + var(--safe-bottom) + 14px);
  transform: translateX(-50%);
  background: color-mix(in srgb, var(--text) 88%, transparent);
  color: var(--bg);
  padding: 10px 16px; border-radius: 12px;
  font-size: 14px; max-width: calc(100vw - 32px);
  z-index: 40; animation: toast-in .2s ease-out;
  box-shadow: var(--shadow);
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- нижняя шторка ---------- */

.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); animation: fade .18s ease-out; }
.sheet-body {
  position: absolute; inset-inline: 0; bottom: 0;
  max-height: 88vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  padding: 14px var(--pad) calc(22px + var(--safe-bottom));
  animation: sheet-up .22s cubic-bezier(.2, .8, .2, 1);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
.sheet-handle { width: 36px; height: 4px; border-radius: 99px; background: var(--separator); margin: 0 auto 14px; }

/* ---------- поля ввода ---------- */

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--hint); margin-bottom: 5px; }
/* `input:not([type])` и `date` перечислены явно: у поля без атрибута тип
   по умолчанию text, но селектор [type="text"] его НЕ ловит — и такое
   поле оставалось нестилизованным, вдвое уже соседних. Файловое поле
   намеренно не здесь: оно спрятано под кнопкой (.char-upload-btn). */
input:not([type]), input[type="text"], input[type="number"],
input[type="search"], input[type="date"], textarea, select {
  width: 100%; font: inherit; color: var(--text);
  background: var(--secondary-bg);
  border: 1px solid transparent; border-radius: 12px;
  padding: 11px 12px;
  transition: border-color .15s ease;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { min-height: 110px; resize: vertical; }
.field-row { display: flex; gap: 8px; }
.field-row input { flex: 1; min-width: 0; }
.field-row .btn { flex: none; }

/* ---------- пустые состояния ---------- */
/* Пустое состояние — приглашение, а не сообщение о недостаче. */

.empty { text-align: center; color: var(--hint); padding: 28px 14px; }
.empty .ico { font-size: 34px; display: block; margin-bottom: 8px; opacity: .7; }
.empty-title { color: var(--text); font-weight: 650; font-size: 15px; margin-bottom: 4px; }
.empty-code {
  display: inline-block; margin-top: 12px; padding: 8px 14px; border-radius: 11px;
  background: var(--accent-16); color: var(--accent);
  font-size: 15px; font-weight: 700; letter-spacing: .04em;
}

/* ---------- персонажи ---------- */

.char-entry {
  display: flex; align-items: center; gap: 10px; width: 100%;
  margin: 14px 0 0; padding: 10px 12px;
  border: 0; border-radius: var(--radius-sm);
  background: var(--secondary-bg); color: var(--text);
  font: inherit; text-align: start; cursor: pointer;
  transition: transform .12s ease;
}
.char-entry:active { transform: scale(.985); }
.char-entry-face { font-size: 22px; line-height: 1; }
.char-entry-main { flex: 1; min-width: 0; }
.char-entry-title { display: block; font-weight: 550; }
.char-entry-sub {
  display: block; color: var(--hint); font-size: 12.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.char-entry-go { color: var(--hint); font-size: 20px; line-height: 1; }

/* «Сейчас на тебе» — своя зона: примерочная должна показывать персонажа
   на том же тёмном фоне, на котором его увидят в карточке профиля. */
.char-hero {
  display: flex; align-items: center; gap: 14px;
  padding: 16px; border-radius: var(--radius-lg);
  background: var(--brand-grad); color: var(--brand-ink);
  box-shadow: var(--shadow-brand); margin-bottom: var(--gap);
}
.char-hero .kicker { color: #8d88b8; }
.char-hero-main { flex: 1; min-width: 0; }
.char-hero-name { font-size: 18px; font-weight: 700; letter-spacing: -.02em; margin: 2px 0; }
.char-hero-hint { font-size: 12.5px; color: var(--brand-ink-dim); line-height: 1.4; text-wrap: pretty; }
.char-hero-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.char-hero-tag {
  font-size: 12px; font-weight: 600; padding: 4px 9px;
  border-radius: 9px; background: rgba(255, 255, 255, .07);
}

/* Ярлык редкости.
 *
 * Обводкой и цветом текста, а не заливкой: заливка сделала бы из ярлыка
 * кнопку, а он ничего не открывает. Цвет приходит из Core в атрибуте
 * style и перебивает здешний — но только он: размеры и форма остаются
 * общими, иначе ступень, заведённая владельцем, могла бы поехать вёрсткой.
 *
 * Цвет по умолчанию — от темы, а не свой: ступень без цвета в каталоге
 * обязана остаться читаемой и на светлом, и на тёмном.
 */
.rarity {
  display: inline-block; align-self: center;
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 7px;
  border: 1px solid var(--separator); color: var(--hint);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rarity.sm { font-size: 9.5px; padding: 1px 5px; letter-spacing: .03em; }
/* На тёмных зонах (карточка профиля, полоса «сейчас на тебе») своя пара
   цветов: там и фон, и текст собственные — см. раздел 8 CLAUDE.md. */
.char-hero .rarity { border-color: rgba(255, 255, 255, .22); color: var(--brand-ink-dim); }
.pcard-rarity { margin-top: 6px; }
.pcard-rarity .rarity { border-color: rgba(255, 255, 255, .22); color: var(--brand-ink-dim); }
/* В шторке примерки ярлык стоит один посреди строки, под именем. */
.char-sheet > .rarity { display: block; width: fit-content; margin: 0 auto 10px; }

/* Лицо персонажа: арт или символ, всегда один размер. */
.char-face {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; flex-shrink: 0;
  border-radius: 12px; background: var(--secondary-bg);
  font-size: 24px; line-height: 1; overflow: hidden;
}
.char-face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.char-face.lg { width: 64px; height: 64px; border-radius: 16px; font-size: 34px; }
.char-face.xl {
  width: 96px; height: 96px; border-radius: 22px; font-size: 50px;
  background: linear-gradient(180deg, rgba(145, 132, 217, .26), rgba(145, 132, 217, .05));
  box-shadow: inset 0 0 0 1px rgba(145, 132, 217, .4);
}
.char-face.empty-face {
  color: var(--hint); background: none;
  border: 1.5px dashed var(--separator);
}

/* Персонаж в карточке профиля собирается тем же charFace(), что и в
   строке списка: один обработчик заменяет не приехавшую картинку
   символом, и второго вида разметки для этого заводить нельзя. Размер
   задаёт карточка, и пара классов записана здесь явно — .char-face
   объявлен ниже по файлу и без этого ужал бы арт до размера строки. */
.pcard-art-face.char-face {
  display: grid; place-items: center;
  width: 104px; height: 104px; border-radius: 20px; font-size: 54px;
  background: linear-gradient(180deg, rgba(145, 132, 217, .24), rgba(145, 132, 217, .06));
  box-shadow: inset 0 0 0 1px rgba(145, 132, 217, .4);
}
.pcard--public .pcard-art-face.char-face {
  width: 88px; height: 88px; margin: 0 auto; border-radius: 24px; font-size: 46px;
  background: rgba(145, 132, 217, .16);
}

/* ---------- история 💎 ---------- */
/* Баланс над списком: человек приходит сюда с карточки профиля, нажав на
   число, и должен увидеть то же число, а не искать его глазами. */
.history-total { display: flex; align-items: baseline; gap: 8px; padding: 0 2px 12px; }
.history-total-value { font-size: 30px; font-weight: 700; letter-spacing: -.03em; }

.char-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: var(--gap); margin-top: var(--gap);
}
.char-tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 13px 6px 11px;
  border: 1px solid transparent; border-radius: var(--radius);
  background: var(--section-bg); box-shadow: var(--shadow);
  color: var(--text); font: inherit; cursor: pointer;
  transition: transform .12s ease;
}
.char-tile:active { transform: scale(.96); }
.char-tile.on { border-color: var(--accent); }
.char-tile.on .char-face { box-shadow: 0 0 0 2px var(--accent) inset; }
.char-tile:not(.owned):not(.on) .char-face { opacity: .78; }
.char-tile-name {
  font-size: 12px; font-weight: 550; text-align: center; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.char-tile-tag { font-size: 11.5px; color: var(--hint); font-weight: 600; }
.char-tile-tag.price { color: var(--text); }
.char-tile.owned .char-tile-tag { color: var(--ok); }
.char-tile.on .char-tile-tag { color: var(--accent); }

/* Шторка предмета. Ради этого блока экран и сделан примерочной. */
.char-sheet { text-align: center; padding-bottom: 4px; }
.char-sheet .char-face { margin: 4px auto 12px; }
.char-sheet-name { font-size: 19px; font-weight: 700; margin: 0 0 6px; letter-spacing: -.02em; }
.char-sheet-desc { margin: 0 0 14px; color: var(--hint); font-size: 13px; line-height: 1.5; text-wrap: pretty; }
.char-preview {
  margin: 14px 0 16px; padding: 13px;
  border-radius: 14px; text-align: start;
  background: var(--accent-10);
  box-shadow: inset 0 0 0 1px var(--accent-30);
}
.char-preview .kicker { margin-bottom: 7px; }
.char-preview-line {
  font-size: 17px; font-weight: 650;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.char-sheet-note { margin: 10px 0 0; color: var(--hint); font-size: 12px; }

/* Шторка имени. Своего оформления почти не нужно: это форма из одного
   поля, и она пользуется тем же, чем шторка предмета.

   Поле — латиница по правилам платформы, поэтому оно пишется слева
   направо даже на арабском экране: иначе «vito_» уезжает концом вперёд. */
.nick-sheet { text-align: center; padding-bottom: 4px; }
.nick-sheet .field { text-align: start; }
.nick-sheet .kicker { margin-bottom: 12px; }
#nick-input { direction: ltr; }

/* Первый экран новичка — тот же вопрос, но во весь экран и без вкладок.
   Своих цветов у него нет ни одного: третья тёмная зона поверх темы
   Telegram кончается тёмным текстом на тёмном фоне у того, чью схему мы
   не видели (раздел 8 в CLAUDE.md). Отсюда всё оформление — отступы. */
.welcome { max-width: 420px; margin: 0 auto; padding-top: 28px; text-align: center; }
.welcome-face { font-size: 44px; line-height: 1; margin-bottom: 12px; }
.welcome-title { margin: 0 0 8px; font-size: 22px; letter-spacing: -.02em; }
.welcome-text {
  margin: 0 0 18px; color: var(--hint); font-size: 14px;
  line-height: 1.5; text-wrap: pretty;
}
.welcome .field { text-align: start; }
.welcome-free { margin: 0 0 12px; text-align: start; }
.welcome #welcome-skip { margin-top: 12px; }
#welcome-input { direction: ltr; }

/* ---------- коллекция и мастерская ---------- */

.collection { display: flex; align-items: center; gap: 12px; }
.collection-best { display: flex; align-items: center; gap: 8px; }
.craft-head { display: flex; align-items: center; gap: 12px; }
.craft-name { min-width: 0; }
.craft-parts { margin: 11px 0 0; }

/* ---------- график (панель владельца) ---------- */

.chart { display: flex; align-items: flex-end; gap: 3px; height: 96px; margin-top: 6px; }
.bar {
  flex: 1; min-width: 2px; border-radius: 3px 3px 0 0;
  background: color-mix(in srgb, var(--accent) 55%, transparent);
  transition: height .4s cubic-bezier(.2, .8, .2, 1);
}
.bar.hi { background: var(--accent); }
.chart-legend { display: flex; justify-content: space-between; color: var(--hint); font-size: 11.5px; margin-top: 6px; }

.preview {
  background: var(--secondary-bg); border-radius: 14px; padding: 12px 14px;
  white-space: pre-wrap; word-break: break-word;
}
.preview img { max-width: 100%; border-radius: var(--radius-sm); margin-bottom: 8px; display: block; }
.preview .preview-btn {
  margin-top: 10px; text-align: center; font-weight: 600; color: var(--link);
  border-top: 1px solid var(--separator); padding-top: 8px;
}
.recipe-input { display: flex; align-items: center; gap: 8px; }
.recipe-input select { flex: 1; min-width: 0; }

/* Широкое содержимое прокручивается внутри себя. */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------- письмо справа налево ---------- */
/*
 * Вся вёрстка выше на логических свойствах, поэтому браузер зеркалит её
 * сам. Здесь только исключения: числа и графики читаются слева направо на
 * любом языке.
 */
[dir="rtl"] .chart,
[dir="rtl"] .chart-legend,
[dir="rtl"] .progress { direction: ltr; }

[dir="rtl"] .row-sub,
[dir="rtl"] .small { unicode-bidi: isolate; }

/* «120 / 300 XP» без этого превращается в «XP 300 / 120». */
[dir="rtl"] .num,
[dir="rtl"] .pcard-public,
[dir="rtl"] .pcard-xp-label,
[dir="rtl"] .pcard-level-n,
[dir="rtl"] .pcard-pill,
[dir="rtl"] .pcard-strip-rank,
[dir="rtl"] .row-value,
[dir="rtl"] .rank,
[dir="rtl"] .tile-value,
[dir="rtl"] .empty-code { direction: ltr; unicode-bidi: isolate; }

/* ---------- меньше движения ---------- */

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

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

/* Превью рядом с выбором файла: результат виден до сохранения. */
.char-upload { display: flex; align-items: center; gap: 12px; }
/* Кнопка вместо голого input[type=file]: системный вид у него разный в
   каждом браузере и ни в одном не похож на остальную форму. */
.char-upload-btn { cursor: pointer; }
