/* Clan & Faction system styles
   Follows the design system from app.css (CSS vars, card pattern, etc.) */

/* ── Clan Page Layout ──────────────────────────────────────────────── */

.clan-page,
.clan-find-page,
.clan-create-page,
.clan-leaderboard-page {
  max-width: min(960px, 100%);
  margin: 0 auto;
  padding-left: max(clamp(6px, 1.5vw, 14px), env(safe-area-inset-left));
  padding-right: max(clamp(6px, 1.5vw, 14px), env(safe-area-inset-right));
}

/* ── Header ────────────────────────────────────────────────────────── */

.clan-header {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(8px, 1.2vw, 16px);
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: clamp(10px, 1.2vw, 16px);
}

.clan-header__icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  margin-right: 12px;
  border: 2px solid var(--border);
  flex-shrink: 0;
}

/* Compact public clan card (from profile tooltip) */
.clan-mini-card{
  max-width:360px;
  padding:14px 16px;
  background:#f9fafb;
  border-radius:14px;
  border:1px solid var(--border);
  box-shadow:0 10px 30px rgba(15,23,42,.12);
  font-size:13px;
}
.clan-mini-head{
  display:flex;
  gap:10px;
  align-items:flex-start;
  margin-bottom:8px;
}
.clan-mini-icon{
  width:40px;
  height:40px;
  border-radius:10px;
  object-fit:cover;
  border:2px solid var(--border);
}
.clan-mini-title{
  flex:1;
  min-width:0;
}
.clan-mini-name{
  font-weight:700;
  font-size:14px;
  margin-bottom:4px;
}
.clan-mini-meta{
  display:flex;
  flex-wrap:wrap;
  gap:4px 8px;
  color:var(--muted);
}
.clan-mini-desc{
  margin:4px 0 8px;
}
.clan-mini-foot{
  display:flex;
  flex-wrap:wrap;
  gap:6px 10px;
  font-size:12px;
  color:var(--muted);
}

.clan-header__info {
  display: flex;
  align-items: flex-start;
  gap: clamp(8px, 1vw, 12px);
  flex: 1;
  min-width: 0;
}

.clan-header__name {
  margin: 0 0 4px;
  font-size: 1.4em;
  font-weight: 800;
}

.clan-tag {
  color: var(--muted);
  font-weight: 600;
  margin-right: 4px;
}

.clan-header__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: clamp(12px, 1.2vw, 13px);
}

.clan-meta-item {
  color: var(--muted);
}

.clan-announcement {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--primary-weak);
  border-radius: 8px;
  font-size: 13px;
  color: var(--primary);
}

.clan-header__tokens {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.token-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(5px, 0.8vw, 8px) clamp(8px, 1.2vw, 12px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 64px;
}

.token-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.token-value {
  font-size: 16px;
  font-weight: 700;
}

/* ── Faction / Division badges ─────────────────────────────────────── */

.faction-badge,
.faction-badge-sm {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .3px;
}
.faction-badge {
  padding: 3px 10px;
  font-size: 13px;
}
.faction-badge-sm {
  height: 18px;
  line-height: 18px;
  font-size: 11px;
}

.division-badge,
.division-badge-sm {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.division-badge {
  padding: 3px 10px;
  font-size: 13px;
}
.division-badge-sm {
  font-size: 11px;
}

/* ── Tabs ──────────────────────────────────────────────────────────── */

.clan-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: clamp(10px, 1.2vw, 14px);
  padding: clamp(4px, 0.8vw, 6px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.clan-tab {
  flex: 1 1 auto;
  min-width: max(80px, 12ch);
  padding: 8px 12px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}

.clan-tab:hover {
  background: rgba(0,0,0,.04);
}

.clan-tab.active {
  background: var(--primary);
  color: #fff;
}

.clan-section.hidden {
  display: none;
}

/* ── Cards ─────────────────────────────────────────────────────────── */

.clan-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(10px, 1.2vw, 16px);
  margin-bottom: clamp(8px, 1vw, 12px);
  box-shadow: var(--shadow);
}

.clan-card h4 {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 700;
}

.clan-card h5 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
}

/* ── Members list ──────────────────────────────────────────────────── */

.clan-members-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.clan-member-row {
  display: flex;
  align-items: center;
  gap: clamp(6px, 1vw, 10px);
  padding: clamp(4px, 0.8vw, 8px) clamp(6px, 1vw, 10px);
  border-radius: 8px;
  transition: background .1s;
}

.clan-member-row:hover {
  background: rgba(0,0,0,.02);
}

.member-pic {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.member-pic-placeholder {
  display: inline-flex;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--border);
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--muted);
}

.clan-member-name {
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.clan-member-role {
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.role-leader  { background: #fef3c7; color: #92400e; }
.role-officer  { background: #dbeafe; color: #1e40af; }
.role-veteran  { background: #d1fae5; color: #065f46; }
.role-member   { background: #f1f5f9; color: #475569; }

.clan-member-level {
  font-size: 12px;
  color: var(--muted);
}

.clan-member-contribution {
  font-size: 12px;
  color: var(--muted);
  margin-left: auto;
}

.clan-member-title{
  display:inline-block;
  margin-left:6px;
  padding:0 6px;
  border-radius:999px;
  background:rgba(147,197,253,.25);
  color:#1d4ed8;
  font-size:11px;
  font-weight:600;
}

.clan-member-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Clan: responsive ───────────────────────────────────────────────── */

@media (max-width: 768px) {
  .clan-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px 16px;
  }
  .clan-header__info {
    flex-wrap: wrap;
  }
  .clan-header__icon {
    width: 48px;
    height: 48px;
  }
  .clan-header__name {
    font-size: 1.2em;
  }
  .clan-header__meta {
    font-size: 11px;
    gap: 6px;
  }
  .clan-header__tokens {
    justify-content: flex-start;
    gap: 8px;
  }
  .token-card {
    min-width: 64px;
    padding: 8px 12px;
  }
  .token-value {
    font-size: 15px;
  }
  .clan-tab {
    min-width: 68px;
    padding: 8px 10px;
    font-size: 12px;
  }
  .clan-card h4 {
    font-size: 15px;
    margin-bottom: 10px;
  }
  .clan-member-row {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
  }
  .member-pic,
  .member-pic-placeholder {
    width: 32px;
    height: 32px;
  }
  .clan-member-contribution {
    width: 100%;
    margin-left: 0;
    margin-top: 2px;
    padding-left: 44px;
  }
  .clan-member-actions {
    width: 100%;
    margin-left: 44px;
  }
}

@media (max-width: 480px) {
  .clan-page,
  .clan-find-page,
  .clan-create-page,
  .clan-leaderboard-page {
    padding-left: 8px;
    padding-right: 8px;
  }
  .clan-header__icon {
    width: 40px;
    height: 40px;
  }
  .clan-header__name {
    font-size: 1.1em;
  }
  .clan-header__tokens {
    flex-direction: row;
    justify-content: space-between;
  }
  .token-card {
    min-width: 0;
    flex: 1;
  }
  .token-value {
    font-size: 13px;
  }
  .clan-tabs {
    padding: 4px;
    gap: 2px;
  }
  .clan-tab {
    flex: 1 1 45%;
    min-width: 0;
    font-size: 10px;
    padding: 6px 6px;
  }
  .clan-members-list {
    gap: 2px;
  }
  .clan-member-row {
    padding: 5px 6px;
  }
  .member-pic,
  .member-pic-placeholder {
    width: 24px;
    height: 24px;
  }
  .clan-member-name {
    font-size: 13px;
  }
  .clan-member-level,
  .clan-member-contribution {
    font-size: 10px;
  }
}

.request-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background .1s;
}

.request-row:hover {
  background: rgba(0,0,0,.02);
}

.request-avatar {
  flex-shrink: 0;
}

.request-name {
  font-weight: 600;
  font-size: 14px;
}

.request-level {
  font-size: 12px;
}

.request-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

.friend-request-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background .1s;
}

.friend-request-row:hover {
  background: rgba(0,0,0,.02);
}

.friend-request-avatar { flex-shrink: 0; }
.friend-request-name { font-weight: 600; font-size: 14px; }
.friend-request-level { font-size: 12px; }
.friend-request-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

.user-notifications-list { display: flex; flex-direction: column; gap: 10px; }
.user-notif-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
  transition: box-shadow .15s, border-color .15s;
}
.user-notif-row:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.08);
  border-color: rgba(37,99,235,.15);
}
.user-notif-icon {
  font-size: 24px;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--primary-weak);
}
.user-notif-body { flex: 1; min-width: 0; }
.user-notif-body strong { font-size: 15px; display: block; margin-bottom: 2px; }
.user-notif-body .muted { font-size: 13px; margin-top: 4px; line-height: 1.4; }
.user-notif-time { font-size: 11px; color: var(--muted); margin-top: 6px; display: block; }

/* Modern notifications page */
.notif-page-modern .notif-page__header h2 { font-size: 1.5em; }
.notif-section-card { border-radius: 16px; box-shadow: 0 2px 12px rgba(0,0,0,.06); }
.notif-section-card h4 { margin-bottom: 12px; font-size: 1.1em; }
.notif-empty-card {
  text-align: center;
  padding: 32px 24px;
  border-radius: 16px;
}
.notif-empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--primary-weak), rgba(34,197,94,.15));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 800;
  color: var(--ok);
}
.friend-request-row,
.invite-row {
  border-radius: 12px;
  padding: 12px 14px;
  transition: background .15s;
}
.friend-request-row:hover,
.invite-row:hover { background: rgba(0,0,0,.02); }

/* ── Notifications panel (tabs + cards, light grey) ──────────────────── */
.notif-panel {
  max-width: 520px;
  margin: 0 auto;
  padding: 0;
  background: var(--card, #fff);
  border-radius: 16px;
  overflow: hidden;
}
.notif-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  background: #f9fafb;
}
.notif-panel__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text, #111827);
}
.notif-panel__actions { flex-shrink: 0; }
.notif-panel__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: #e5e7eb;
  color: #6b7280;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.notif-panel__close:hover {
  background: #d1d5db;
  color: #374151;
}
.notif-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 14px;
  background: #f3f4f6;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.notif-tab {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  background: #e5e7eb;
  color: #6b7280;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.notif-tab:hover {
  background: #d1d5db;
  color: #374151;
}
.notif-tab--active {
  background: var(--primary, #2563eb);
  color: #fff;
}
.notif-tab--active:hover {
  background: var(--primary-hover, #1d4ed8);
  color: #fff;
}
.notif-content {
  padding: 14px 16px;
  max-height: 60vh;
  overflow-y: auto;
  background: #fafafa;
}
.notif-section { margin-bottom: 18px; }
.notif-section:last-child { margin-bottom: 0; }
.notif-section__title {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #4b5563;
}
.notif-cards { display: flex; flex-direction: column; gap: 10px; }
.notif-card {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  transition: box-shadow .12s, border-color .12s;
}
.notif-card:hover {
  border-color: #d1d5db;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.notif-card--read { opacity: 0.82; background: #f9fafb; }
.notif-card__main {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.notif-card__main + .notif-card__actions { margin-top: 10px; }
.notif-card__avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
}
.notif-card__avatar-img { width: 100%; height: 100%; object-fit: cover; }
.notif-card__avatar-placeholder {
  font-size: 1rem;
  font-weight: 700;
  color: #9ca3af;
}
.notif-card__body { flex: 1; min-width: 0; }
.notif-card__body--full { margin-bottom: 0; }
.notif-card__title { display: block; font-size: 14px; margin-bottom: 2px; color: var(--text, #111827); }
.notif-card__meta { font-size: 12px; color: #6b7280; }
.notif-card__time { font-size: 11px; color: #9ca3af; display: block; margin-bottom: 4px; }
.notif-card__top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}
.notif-card__icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}
.notif-card__icon-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.notif-card__expand { margin: 8px 0 10px; }
.notif-card__expand-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  background: none;
  border: none;
  cursor: pointer;
}
.notif-card__expand-btn:hover { color: var(--primary); }
.notif-card__expand-arrow { font-size: 10px; transition: transform .15s; }
.notif-card__detail {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  font-size: 12px;
  line-height: 1.5;
  color: #4b5563;
}
.notif-card__detail-inner { white-space: pre-wrap; word-break: break-word; }
.notif-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.notif-card__actions--wrap { margin-top: 8px; padding-top: 8px; border-top: 1px solid #f3f4f6; }
.notif-system-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.notif-empty {
  text-align: center;
  padding: 28px 20px;
  background: #f9fafb;
  border-radius: 12px;
  border: 1px dashed #d1d5db;
}
.notif-empty--in-tab { padding: 24px 16px; }
.notif-empty__icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: #e5e7eb;
  color: #6b7280;
  font-size: 1.25rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}
.notif-empty__text { margin: 0 0 14px; font-size: 14px; color: #6b7280; }
.notif-empty__btn { margin: 0; }
.notif-panel__footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border, #e5e7eb);
  background: #f9fafb;
}
@media (max-width: 480px) {
  .notif-panel__header { padding: 12px 14px; }
  .notif-tabs { padding: 10px 12px; gap: 6px; }
  .notif-tab { padding: 6px 12px; font-size: 12px; }
  .notif-content { padding: 12px 14px; max-height: 55vh; }
  .notif-card { padding: 10px 12px; }
}

.role-select {
  font-size: 12px;
  padding: 2px 4px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* ── Raid ──────────────────────────────────────────────────────────── */

.raid-rules-block {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.raid-rules-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.raid-rules-toggle:hover {
  background: rgba(37,99,235,.06);
  border-color: rgba(37,99,235,.3);
}
.raid-rules-content {
  margin-top: 12px;
  padding: 14px 0;
  font-size: 13px;
  line-height: 1.5;
}
.raid-rules-content h5 {
  margin: 12px 0 6px;
  font-size: 13px;
}
.raid-rules-content h5:first-child {
  margin-top: 0;
}
.raid-rules-content ul {
  margin: 0 0 8px;
  padding-left: 20px;
}

.raid-active {
  position: relative;
}

.raid-hint {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  font-size: 14px;
  color: var(--muted);
  cursor: help;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.raid-hint:hover {
  color: var(--text);
}

.raid-active h4 {
  margin-bottom: 10px;
  padding-right: 24px;
}

.raid-hp-bar {
  height: 24px;
  background: #f1f5f9;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 4px;
}

.raid-hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #dc2626, #f97316);
  border-radius: 12px;
  transition: width .5s ease;
}

.raid-hp-text {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}

.raid-meta {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.raid-victory {
  text-align: center;
  padding: 16px;
  font-size: 18px;
  font-weight: 800;
  color: var(--ok);
}

.raid-lb {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.raid-lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
  font-size: 13px;
}

.raid-lb-rank {
  font-weight: 700;
  min-width: 30px;
  color: var(--muted);
}

.raid-lb-name {
  font-weight: 600;
  flex: 1;
}

.raid-lb-dmg {
  color: var(--muted);
}

/* ── Clan Location tab: карта локаций и постройки (наглядно) ─────────── */

.location-section {
  margin-bottom: 20px;
}

.location-section h4 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
}

/* Карта локаций — сетка карточек, каждая локация видна */
.location-map {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.location-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-align: center;
  transition: border-color .15s, background .15s;
}

.location-card:hover {
  border-color: var(--primary);
  background: var(--soft, #f8fafc);
}

.location-card__icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--primary-weak, rgba(37, 99, 235, .1));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.location-card__name {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
  line-height: 1.3;
}

.location-card__status {
  font-size: 12px;
  color: var(--muted);
}

.location-card--unlocked .location-card__status {
  color: var(--ok, #16a34a);
}

/* Банк и бонусы */
.location-bank {
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--soft, #f8fafc);
  border-radius: 10px;
  font-size: 14px;
  border: 1px solid var(--border);
}

.location-effects {
  margin-bottom: 14px;
  padding: 10px 14px;
  background: var(--ok-weak, rgba(34, 197, 94, .08));
  border-radius: 10px;
  font-size: 13px;
  border: 1px solid rgba(34, 197, 94, .2);
}

/* Постройки — карточки с иконкой и уровнем */
.building-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.building-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color .15s;
}

.building-card:hover {
  border-color: var(--primary);
}

.building-card__head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.building-card__icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--primary-weak, rgba(37, 99, 235, .1));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.building-card__title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.building-name {
  font-weight: 700;
  font-size: 14px;
}

.building-level {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.building-level-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.building-level-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width .3s ease;
}

.building-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.building-effects-row {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.building-effect-pill {
  font-size: 11px;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(37,99,235,.06);
  border: 1px solid rgba(37,99,235,.18);
  color: #1d4ed8;
}

.building-card .btn {
  margin-top: 4px;
}

/* ── Boss selection ────────────────────────────────────────────────── */

.boss-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.boss-card {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.boss-name {
  font-weight: 700;
  font-size: 15px;
  flex: 1;
}

.boss-stats {
  font-size: 12px;
  color: var(--muted);
}

/* ── Missions ──────────────────────────────────────────────────────── */

.mission-card {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
}

.mission-card.completed {
  opacity: .6;
  border-color: var(--ok);
}

.mission-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.mission-type {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
}

.type-daily   { background: #dbeafe; color: #1e40af; }
.type-weekly  { background: #ede9fe; color: #5b21b6; }
.type-event   { background: #fef3c7; color: #92400e; }

.mission-name {
  font-weight: 700;
  font-size: 14px;
}

.mission-desc {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.mission-progress-bar {
  height: 10px;
  background: #f1f5f9;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 4px;
}

.mission-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 5px;
  transition: width .3s ease;
}

.mission-progress-text {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.mission-rewards {
  display: flex;
  gap: 6px;
}

.reward-badge {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--ok-weak);
  color: var(--ok);
  font-weight: 600;
}

/* ── Shop ──────────────────────────────────────────────────────────── */

.shop-balances {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.shop-item-card {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.shop-item-name {
  font-weight: 700;
  font-size: 14px;
}

.shop-item-desc {
  font-size: 12px;
  color: var(--muted);
}

.shop-item-cost {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
}

.shop-item-limit {
  font-size: 11px;
  color: var(--muted);
}

/* ── Warehouse ─────────────────────────────────────────────────────── */

.wh-deposit-section { margin-bottom: 16px; padding: 12px; background: var(--soft); border-radius: 12px; border: 1px solid var(--border); }
.wh-deposit-section h4 { margin: 0 0 10px; font-size: 14px; }
.wh-deposit-coins, .wh-deposit-items { margin-bottom: 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.wh-deposit-coins .wh-bank-coins { margin-right: 12px; font-size: 14px; }
.wh-deposit-row { display: flex; gap: 8px; align-items: center; }

.wh-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.wh-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}

.wh-item-card {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: center;
}

.wh-item-name {
  font-weight: 600;
  font-size: 13px;
}

.wh-item-qty {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
}

.wh-item-cat {
  font-size: 11px;
  color: var(--muted);
}

.wh-log-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wh-log-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}

.wh-log-actor {
  font-weight: 600;
  min-width: 80px;
}

.wh-log-action {
  color: var(--muted);
}

.wh-log-item {
  flex: 1;
}

.wh-log-time {
  font-size: 11px;
  color: var(--muted);
}

/* ── Upgrades ──────────────────────────────────────────────────────── */

.upgrade-card {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
}

.upgrade-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.upgrade-name {
  font-weight: 700;
  font-size: 14px;
}

.upgrade-level {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.upgrade-desc {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

/* ── Find Clan page ────────────────────────────────────────────────── */

.clan-find-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.clan-find-header h2 {
  margin: 0;
}

.clan-find-actions {
  display: flex;
  gap: 8px;
}

.clan-find-header__close {
  margin-left: auto;
  flex-shrink: 0;
}

.clan-search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.clan-search-bar input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}

.clan-search-bar input:focus {
  border-color: var(--primary);
}

/* ── Clan list ─────────────────────────────────────────────────────── */

.clan-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.clan-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: border-color .15s, box-shadow .15s, background .15s;
  background: var(--card);
}

.clan-list-row:hover {
  border-color: rgba(51, 65, 85, .4);
  box-shadow: 0 2px 12px rgba(0, 0, 0, .05);
}

.clan-list-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.clan-list-name {
  font-weight: 700;
  font-size: 14px;
}

.clan-list-meta {
  font-size: 12px;
  color: var(--muted);
}

.clan-list-desc {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

/* ── Invites ───────────────────────────────────────────────────────── */

.clan-invites-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.invite-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.invite-clan-name {
  font-weight: 700;
  flex: 1;
}

.invite-from {
  font-size: 12px;
  color: var(--muted);
}

.invite-actions {
  display: flex;
  gap: 6px;
}

/* ── Leaderboard ───────────────────────────────────────────────────── */

.faction-leaderboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.faction-lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.faction-lb-score {
  font-weight: 700;
  font-size: 14px;
}

.faction-lb-members {
  font-size: 12px;
  color: var(--muted);
  margin-left: auto;
}

.clan-filter-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.clan-lb-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.clan-lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
}

.clan-lb-row:hover {
  background: rgba(0,0,0,.02);
}

.clan-lb-rank {
  font-weight: 800;
  min-width: 36px;
  color: var(--muted);
}

.clan-lb-name {
  font-weight: 700;
  flex: 1;
  color: var(--text);
  text-decoration: none;
}
a.clan-lb-name:hover {
  color: var(--primary);
  text-decoration: underline;
}

.clan-lb-rating {
  font-weight: 700;
  min-width: 60px;
  text-align: right;
}

.clan-lb-members {
  font-size: 12px;
  color: var(--muted);
  min-width: 30px;
  text-align: right;
}

/* ── Create Clan form ──────────────────────────────────────────────── */

.clan-form .form-group {
  margin-bottom: 14px;
}

.clan-form label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
}

.clan-form label small {
  font-weight: 400;
  color: var(--muted);
}

.clan-form input[type="text"],
.clan-form input[type="number"],
.clan-form textarea,
.clan-form select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
}

.clan-form input:focus,
.clan-form textarea:focus,
.clan-form select:focus {
  border-color: var(--primary);
}

.clan-form .form-row {
  display: flex;
  gap: 12px;
}

.clan-form .form-row .form-group {
  flex: 1;
}

.clan-form .form-hint {
  font-size: 13px;
  color: var(--muted);
  margin: 4px 0 0;
}

/* ── Buttons (shared, extend from app.css) ──────────────────────────── */

.btn-lg {
  padding: 10px 24px;
  font-size: 15px;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  border-radius: 8px;
  font-weight: 600;
  padding: 6px 14px;
  transition: all .15s;
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-danger:hover {
  opacity: .9;
}

/* ── Responsive ────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  .clan-header {
    flex-direction: column;
  }

  .clan-header__tokens {
    width: 100%;
    justify-content: space-between;
  }

  .clan-form .form-row {
    flex-direction: column;
    gap: 0;
  }

  .shop-grid {
    grid-template-columns: 1fr;
  }

  .wh-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .clan-member-row {
    flex-wrap: wrap;
  }
}

/* ── Public clan view (read-only) ───────────────────────────────────── */

.clan-view-page {
  max-width: min(560px, 100%);
  margin: 0 auto;
  padding: 0 12px;
}

.clan-view-header {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.clan-view-header__icon {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  object-fit: cover;
  border: 2px solid var(--border);
  flex-shrink: 0;
}

.clan-view-header__icon-placeholder {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
  background: var(--card);
}

.clan-view-header__info {
  flex: 1;
  min-width: 0;
}

.clan-view-header__name {
  font-size: 18px;
  font-weight: 800;
  margin: 0 0 6px 0;
  line-height: 1.3;
}

.clan-view-header__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}

.clan-view-header__meta--extra {
  margin-top: 4px;
}

.clan-view-header__leader {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.clan-view-header__leader-pic {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  vertical-align: middle;
}

.clan-view-header__leader-pic-placeholder {
  display: inline-flex;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--border);
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--muted);
}

.clan-view-announcement {
  margin-bottom: 16px;
}

.clan-view-announcement h4 {
  margin: 0 0 8px 0;
  font-size: 14px;
  color: var(--muted);
}

.clan-view-announcement__text {
  font-size: 14px;
  line-height: 1.5;
  padding: 10px 12px;
  background: var(--card);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.clan-view-description {
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--card);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.clan-view-members-wrap {
  margin-bottom: 16px;
  overflow-x: auto;
}

.clan-view-members-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.clan-view-members-table th {
  text-align: left;
  padding: 8px 10px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.clan-view-members-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.clan-view-member .clan-view-member__pic,
.clan-view-member .clan-view-member__pic-placeholder {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
  vertical-align: middle;
  margin-right: 8px;
}

.clan-view-member .clan-view-member__pic-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--border);
  font-size: 12px;
  color: var(--muted);
}

.clan-view-member__name {
  font-weight: 700;
}

.clan-view-apply {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.clan-view-apply h4 {
  margin: 0 0 8px 0;
  font-size: 14px;
}

.clan-view-apply__msg {
  width: 100%;
  min-height: 60px;
  padding: 8px 10px;
  margin-bottom: 10px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: vertical;
  box-sizing: border-box;
}

.clan-view-apply__submit {
  display: flex;
  justify-content: flex-end;
}

.clan-view-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

a.clan-list-name {
  color: var(--text);
  text-decoration: none;
}

a.clan-list-name:hover {
  color: var(--primary);
  text-decoration: underline;
}
