/* ── Кланы, этап 0a: значок у ника, модалка клана, диалог Смотрителя ─────────
   Модалка открывается и ПОВЕРХ профиля (.modal-overlay = 10000), поэтому своя
   подложка выше. Цвета акцента — через --accent-* (сезонная тема их перекрашивает),
   смысловые (опасная кнопка, основатель) — литералами. */

/* Диалог Смотрителя — обычная шторка NPC (.oak-overlay), только поверх профиля. */
.clan-overlay { z-index: 10050; }
/* Окно клана — СВОЯ подложка, без .oak-overlay (там на ≤768px прижатие к низу с !important).
   Высота — по ВИДИМОЙ области (dvh): 100vh на телефонах выше экрана, верх уезжал под адресную строку. */
.clan-modal-overlay {
  position: fixed; inset: 0; z-index: 10050; background: rgba(0, 0, 0, .55);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}

/* Иконка клана слева от ника (профиль, чат). Имя клана — в title (подсказка при наведении).
   Под картинкой лежит первая буква имени: если не загрузились ни аватар, ни заглушка,
   img убирает себя и остаётся буква на плашке. Размер задаёт инлайн-стиль (clanIconHtml). */
.clan-icon {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto; margin-right: 6px; padding: 0;
  /* middle, а НЕ сдвиг в px: у inline-flex базовая линия — у спрятанной буквы-запаски (11px),
     и при крупном нике профиля (22px) иконка проседала под строку. */
  vertical-align: middle; top: -0.08em;
  border: 1px solid rgba(255, 255, 255, .35); border-radius: 6px; overflow: hidden;
  background: rgba(var(--accent-dark-rgb), .45); cursor: pointer;
}
.clan-icon img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.clan-icon-letter { font: 800 11px/1 'Segoe UI', system-ui, sans-serif; color: #fff; }
.clan-icon:hover { box-shadow: 0 0 0 2px rgba(var(--accent-dark-rgb), .6); }
.chat-author .clan-icon { margin-right: 4px; border-radius: 4px; }

/* ── Модалка клана: страница клана (просмотр) и экран управления ───────────
   Шапка просмотра — «обложка» на акцентном градиенте (--accent-* перекрашивает сезонная
   тема), тело — светлая карточка. Смысловые цвета (основатель, опасная зона) — литералы. */
.clan-modal {
  position: relative; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto;
  overscroll-behavior: contain;
  background: #fff; color: #2d2d35; border-radius: 18px;
  box-shadow: 0 16px 48px rgba(0,0,0,.4);
}
.clan-x {
  /* Липкий: остаётся в верхнем правом углу, сколько окно ни прокручивай. Блок с отрицательным
     нижним отступом — чтобы не сдвигать обложку под ним. */
  position: sticky; top: max(10px, env(safe-area-inset-top)); z-index: 3;
  display: block; margin: 10px 10px -44px auto;
  width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%;
  background: rgba(0,0,0,.42); color: #fff; font-size: 22px; line-height: 34px; text-align: center; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.clan-loading { padding: 40px 16px; text-align: center; color: #888; }
.clan-body { padding: 14px 18px 18px; }

/* Шапка-обложка */
.clan-hero {
  padding: 26px 18px 18px; text-align: center; color: #fff;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255,255,255,.18), transparent 60%),
    linear-gradient(160deg, var(--accent-strong), rgba(var(--bg-glass-rgb), 1));
}
.clan-name { margin: 10px 0 0; font-size: 22px; font-weight: 800; line-height: 1.2; word-break: break-word; text-shadow: 0 2px 8px rgba(0,0,0,.35); }
.clan-motto { margin: 4px 0 0; font-style: italic; opacity: .9; word-break: break-word; }
.clan-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 12px; }
.clan-chip { padding: 3px 10px; border-radius: 999px; background: rgba(255,255,255,.16); font-size: 12px; font-weight: 600; }

/* Аватар (и в шапке, и в управлении). Под картинкой — буква-запаска. */
.clan-avatar {
  position: relative; flex: 0 0 64px; width: 64px; height: 64px; border-radius: 16px; overflow: hidden;
  display: flex; align-items: center; justify-content: center; background: rgba(var(--accent-rgb), .25);
}
.clan-avatar-lg { width: 96px; height: 96px; margin: 0 auto; border-radius: 22px;
  border: 3px solid rgba(255,255,255,.85); box-shadow: 0 6px 18px rgba(0,0,0,.35); }
.clan-avatar-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.clan-avatar-letter { font-size: 28px; font-weight: 800; color: #fff; }

/* Секции */
.clan-section { margin-top: 16px; }
.clan-section:first-child { margin-top: 0; }
.clan-section-title { font-size: 12px; font-weight: 800; letter-spacing: .06em; color: #8a8a93; text-transform: uppercase; margin-bottom: 8px; }
.clan-desc { white-space: pre-wrap; word-break: break-word; font-size: 14px; line-height: 1.5; }
.clan-note { font-size: 12px; color: #8a8a93; margin: 6px 0; }
.clan-flash { margin-bottom: 10px; padding: 8px 12px; border-radius: 10px; background: #e9f9ee; color: #1f7a3a; font-size: 13px; }
.clan-msg { font-size: 13px; color: #c0392b; margin-bottom: 8px; }
.clan-msg:empty { display: none; }

/* Состав по группам (просмотр) */
.clan-group + .clan-group { margin-top: 12px; }
.clan-group-title { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: #55555f; margin-bottom: 6px; }
.clan-group-title span { padding: 0 7px; border-radius: 999px; background: #eceef5; font-size: 11px; color: #6a6a75; }
.clan-roster { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.clan-person { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 12px; background: #f5f5fa; min-width: 0; }
.clan-group-founder .clan-person { background: #fff6df; box-shadow: inset 0 0 0 1px #f1d38a; }
.clan-group-leader  .clan-person { background: rgba(var(--accent-rgb), .08); box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), .25); }
.clan-person-dot {
  flex: 0 0 26px; width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: #d9dbe6; color: #fff; font-size: 12px; font-weight: 800;
}
.clan-group-founder .clan-person-dot { background: #e2a72e; }
.clan-group-leader  .clan-person-dot { background: var(--accent); }
.clan-person-name { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clan-person-title { margin-left: auto; flex: 0 1 auto; padding: 2px 8px; border-radius: 999px; background: #fff;
  box-shadow: inset 0 0 0 1px #e0e0ea; font-size: 11px; color: #6a6a75; font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }

/* История — свёрнута по умолчанию */
.clan-history-box { margin-top: 16px; border-top: 1px solid #eee; padding-top: 10px; }
.clan-history-box summary { cursor: pointer; font-size: 12px; font-weight: 800; letter-spacing: .06em; color: #8a8a93; text-transform: uppercase; }
.clan-history, .clan-invites, .clan-mlist { list-style: none; margin: 0; padding: 0; }
.clan-history { margin-top: 8px; }
.clan-history li { font-size: 13px; padding: 3px 0; }
.clan-hist-date { color: #8a8a93; font-size: 12px; margin-right: 6px; }
.clan-footer { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 8px; }
.clan-footer .clan-btn { flex: 1 1 160px; }

/* Экран управления */
.clan-mhead { display: flex; align-items: center; gap: 10px; padding: 14px 54px 12px 14px; border-bottom: 1px solid #eee; }
.clan-back { border: 0; background: #eceef5; color: #444; border-radius: 10px; padding: 7px 12px; font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap; }
.clan-mhead-title { font-weight: 800; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clan-card { border: 1px solid #ececf2; border-radius: 14px; padding: 12px; margin-top: 12px; }
.clan-card:first-of-type { margin-top: 0; }
.clan-card-warn { border-color: #f0c47a; background: #fff9ec; }
.clan-card-danger { border-color: #f1b0ad; background: #fff5f5; }
.clan-avatar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.clan-mrow { padding: 8px 0; border-bottom: 1px solid #f0f0f4; }
.clan-mrow:last-child { border-bottom: 0; }
.clan-mrow-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.clan-mrow-head .clan-person-title { margin-left: 0; max-width: none; }
.clan-mrow-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.clan-title-edit { margin-top: 6px; }
.clan-role { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 6px; background: #eee; color: #555; }
.clan-role-founder { background: #fff3d6; color: #9a6400; }
.clan-role-leader { background: rgba(var(--accent-rgb), .14); color: var(--accent); }
.clan-invites li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; padding: 6px 0; border-bottom: 1px solid rgba(0,0,0,.08); }

/* Вкладки «Клан | Рюкзак» (только участникам) */
.clan-tabs { display: flex; gap: 4px; padding: 8px 52px 0 18px;   /* справа место под липкий крестик */
  border-bottom: 1px solid #eee; background: #fff; position: sticky; top: 0; z-index: 1; }
.clan-tab { flex: 1 1 0; border: 0; background: transparent; padding: 10px 8px; font: inherit; font-weight: 700; color: #8a8a93;
  border-bottom: 3px solid transparent; cursor: pointer; }
.clan-tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }
.clan-tab-badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 999px;
  background: #e8a33a; color: #fff; font-size: 11px; line-height: 18px; vertical-align: 1px; }
.clan-card-req { border-color: #f0c47a; background: #fff9ec; }

/* Рюкзак */
.clan-items { list-style: none; margin: 6px 0 0; padding: 0; }
.clan-item { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid #f0f0f4; }
.clan-item:last-child { border-bottom: 0; }
.clan-item-icon { flex: 0 0 32px; width: 32px; height: 32px; border-radius: 8px; background: #f5f5fa;
  display: flex; align-items: center; justify-content: center; color: #8a8a93; font-weight: 800; }
.clan-item-icon img { width: 28px; height: 28px; object-fit: contain; image-rendering: auto; }
.clan-item-name { flex: 1 1 120px; min-width: 0; font-weight: 600; word-break: break-word; }
.clan-item-dur { font-size: 11px; font-weight: 700; color: #b26a00; background: #fff3d6; border-radius: 6px; padding: 0 5px; white-space: nowrap; }
.clan-item-qty { font-weight: 800; color: #3c3c48; text-align: right; }
.clan-item-qty small { display: block; font-size: 11px; font-weight: 600; color: #8a8a93; }
.clan-qty { display: flex; flex: 1 0 100%; justify-content: flex-end; align-items: center; gap: 6px; }   /* всегда второй строкой — ряды не скачут */
.clan-qty .clan-qty-input { flex: 0 0 72px; width: 72px; padding: 6px; text-align: center; }   /* специфичнее общего .clan-input {width:100%} */
.clan-note-inline { font-size: 12px; color: #8a8a93; }
/* Питомник */
.clan-pc-sprite { flex: 0 0 40px; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; background: #f5f5fa; border-radius: 10px; }
.clan-pc-sprite img { width: 40px; height: 40px; object-fit: contain; image-rendering: pixelated; }
.clan-pc-lv { font-size: 12px; color: #6a6a75; font-weight: 600; }
.clan-item-name small { display: block; font-size: 11px; font-weight: 600; color: #8a8a93; }
.clan-pc-status { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #e9f9ee; color: #1f7a3a; white-space: nowrap; }
.clan-pc-status.is-out { background: #fff3d6; color: #9a6400; }
.clan-pc-state { font-size: 12px; color: #6a6a75; margin: 2px 0 4px; }
.clan-pc-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: #9a9aa5; }
/* Метка «Клан» у взятого покемона: команда, бой, детали боя */
.clan-loan-tag, .clan-loan-badge, .bt-clan-loan { display: inline-block; padding: 1px 6px; border-radius: 6px; background: #e8a33a; color: #fff;
  font: 800 10px/14px 'Segoe UI', system-ui, sans-serif; letter-spacing: .04em; text-transform: uppercase; }
.bt-clan-loan { margin-left: 4px; vertical-align: 1px; }
.bt-clan-loan[hidden] { display: none; }
.pvp-bd-loan { margin: 2px auto 0; }
.clan-note b { color: #3c3c48; }

/* Поля и кнопки (общие с диалогом Смотрителя) */
.clan-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }
.clan-row .clan-input { flex: 1 1 160px; }
.clan-label { display: flex; justify-content: space-between; font-size: 12px; color: #8a8a93; margin: 10px 0 4px; }
.clan-input {
  width: 100%; box-sizing: border-box; padding: 9px 11px; border: 1px solid #d8d8e0; border-radius: 10px;
  font: inherit; font-size: 14px; color: #2d2d35; background: #fff;
}
.clan-input:focus { outline: 2px solid rgba(var(--accent-rgb), .35); border-color: var(--accent); }
.clan-textarea { min-height: 90px; resize: vertical; }
.clan-btn, .clan-mini { border: 0; cursor: pointer; font: inherit; font-weight: 700; background: var(--accent); color: #fff; }
.clan-btn { padding: 10px 16px; font-size: 14px; border-radius: 10px; margin-top: 8px; }
.clan-row .clan-btn { margin-top: 0; }
.clan-mini { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.clan-btn:disabled, .clan-mini:disabled { opacity: .45; cursor: default; }
.clan-btn-ghost, .clan-mini-ghost { background: #eceef5; color: #3c3c48; }
.clan-btn-warn { background: #e8a33a; width: 100%; }
.clan-btn-danger, .clan-mini-danger { background: #d9534f; }

@media (max-width: 480px) {
  .clan-modal-overlay { padding: 0; align-items: stretch; }
  .clan-modal { max-width: none; height: 100vh; height: 100dvh; max-height: 100vh; max-height: 100dvh; border-radius: 0;
    padding-bottom: env(safe-area-inset-bottom); }
  .clan-hero { padding-top: 30px; }
  .clan-body { padding: 12px 14px 24px; }
}

/* Вкладок пять (08.10): на узком экране полоса листается, а не сжимает подписи в кашу. */
.clan-tabs { overflow-x: auto; scrollbar-width: thin; }
.clan-tab { flex: 1 0 auto; white-space: nowrap; }

/* Недельные задания (clanWeeklyTabs.js) */
.clan-q-summary { display: flex; flex-direction: column; gap: 4px; }
.clan-q-big { font-size: 22px; font-weight: 800; color: var(--accent); }
.clan-q-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.clan-q { border: 1px solid #ececf2; border-radius: 12px; padding: 10px 12px; background: #fff; }
.clan-q.is-done { border-color: #9ad3a6; background: #f3fbf5; }
.clan-q.is-locked { opacity: .7; background: #f7f7f9; }
.clan-q-head { display: flex; align-items: center; gap: 8px; }
.clan-q-n { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%; background: rgba(var(--accent-rgb), .14);
  color: var(--accent); font-weight: 800; font-size: 12px; display: flex; align-items: center; justify-content: center; }
.clan-q-title { flex: 1 1 auto; font-weight: 700; min-width: 0; }
.clan-q-pts { flex: 0 0 auto; font-size: 12px; font-weight: 700; color: #8a6d1d; background: #fff4d6; border-radius: 999px; padding: 2px 8px; }
.clan-q-progress { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 8px; }
.clan-q-bar { flex: 1 1 160px; height: 8px; border-radius: 999px; background: #ececf2; overflow: hidden; }
.clan-q-bar > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.clan-q.is-done .clan-q-bar > span { background: #3aa65a; }
.clan-q-num { font-size: 13px; font-variant-numeric: tabular-nums; color: #55555f; }
.clan-q-status { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 2px 8px; }
.clan-q-status.is-done { color: #1f7a3a; background: #dff3e5; }
.clan-q-status.is-locked { color: #7a5b1f; background: #f6ead0; }
.clan-q-contrib { margin-top: 6px; font-size: 13px; }
.clan-q-contrib summary { cursor: pointer; color: #6b6b75; }
.clan-q-contrib ul, .clan-q-rows { list-style: none; margin: 6px 0 0; padding: 0; }
.clan-q-contrib li, .clan-q-rows li { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px dashed #eee; }
.clan-q-contrib li.is-me, .clan-q-rows li.is-me { font-weight: 700; }
.clan-q-who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clan-q-val { flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.clan-q-boss { display: flex; gap: 12px; align-items: flex-start; margin-top: 8px; padding: 8px; border-radius: 10px; background: #f7f5ff; }
.clan-q-boss-img { width: 72px; height: 72px; object-fit: contain; image-rendering: pixelated; flex: 0 0 auto; }
.clan-q-boss-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.clan-q-boss-name { font-weight: 800; }
/* В колонке flex-basis полосы (160px) ушёл бы в ВЫСОТУ — тут полоса фиксированной толщины. */
.clan-q-boss-info .clan-q-bar { flex: 0 0 auto; width: 100%; }
.clan-q-boss-info .clan-q-bar > span { background: #e0533d; }
.clan-q-boss-points { margin: 0; padding-left: 18px; font-size: 13px; }
.clan-q-target { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 14px; }
.clan-q-target img { width: 40px; height: 40px; object-fit: contain; image-rendering: pixelated; }
.clan-tr-head { display: flex; flex-direction: column; gap: 6px; }
.clan-tr-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.clan-tr-form .clan-input { flex: 1 1 140px; min-width: 0; }

/* Карточка кланового босса на локации (clanBoss.js) */
.clan-boss-card { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin: 8px 16px; border-radius: 12px; cursor: pointer;
  background: linear-gradient(135deg, rgba(var(--accent-rgb), .18), rgba(var(--accent-rgb), .05));
  border: 1px solid rgba(var(--accent-rgb), .35); }
.clan-boss-card img { width: 64px; height: 64px; object-fit: contain; image-rendering: pixelated; flex: 0 0 auto; }
.clan-boss-card .cb-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.clan-boss-card .cb-title { font-weight: 800; }
.clan-boss-card .cb-sub { font-size: 12px; opacity: .8; }
.clan-boss-card:disabled { cursor: default; opacity: .65; }

/* Иконка монеты вместо знака рубля (08.10) */
.clan-coin { width: 1.1em; height: 1.1em; object-fit: contain; vertical-align: -0.18em; margin-left: 3px; }

/* Окно «Тренеры» → вкладка «Кланы» (рейтинг по баллам) */
.trainers-clan-row { cursor: pointer; }
.trainers-clan-rank { flex: 0 0 28px; text-align: center; font-weight: 800; font-size: 15px; color: #6b7a90; font-variant-numeric: tabular-nums; }
.trainers-clan-avatar { background: rgba(var(--accent-rgb), .15); overflow: hidden; }
.trainers-clan-points { flex: 0 0 auto; margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; color: #3d7dca; white-space: nowrap; }
.trainers-clan-points span { font-weight: 600; font-size: 12px; color: #6b7a90; }

/* Клановые рейты (карточка во вкладке «Задания») */
.clan-rates { display: flex; flex-direction: column; gap: 8px; }
.clan-rates-state { font-size: 14px; color: #55555f; }
.clan-rates-state.is-on { color: #1f7a3a; font-weight: 700; }

/* Недельные награды клана (окно при входе + таблица во вкладке «Задания») */
.clan-rw-items { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.clan-rw-item { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.clan-rw-item img { width: 26px; height: 26px; object-fit: contain; }
.clan-rw-modal { max-width: 460px; }
.clan-rw-title { margin: 4px 0 6px; font-size: 20px; }
.clan-rw-card { margin-top: 10px; }
