/* Kingshot Tracker — clean modern theme (light + dark) */

:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg0: #0f1115;
  --bg1: #141820;
  --panel: #181c24;
  --panel2: #1c212b;
  --panel-edge: #2a3140;
  --text: #eef1f6;
  --muted: #9aa3b2;
  --faint: #6b7383;
  --accent: #5b8def;
  --accent-dim: #3d6fd4;
  --accent-glow: rgba(91, 141, 239, 0.18);
  --accent-text: #ffffff;
  --ember: #e0a04a;
  --ember-dim: #b07a30;
  --ok: #3ecf8e;
  --warn: #e0b04a;
  --danger: #e06a5c;
  --chip: #222836;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  --header-border: rgba(255, 255, 255, 0.06);
  --input-bg: #0f131a;
  --btn-secondary-bg: transparent;
  --btn-secondary-border: var(--panel-edge);
  --btn-secondary-text: var(--text);
  --hero-grad: linear-gradient(135deg, #181c24 0%, #1a2233 100%);
  --inset: rgba(0, 0, 0, 0.22);
  --inset-strong: rgba(0, 0, 0, 0.32);
}

[data-theme="light"] {
  color-scheme: light;
  --bg0: #f4f5f7;
  --bg1: #eef0f4;
  --panel: #ffffff;
  --panel2: #f8f9fb;
  --panel-edge: #e2e6ee;
  --text: #151921;
  --muted: #3a4250;
  --faint: #546074;
  --accent: #3b6fd9;
  --accent-dim: #2f5bb8;
  --accent-glow: rgba(59, 111, 217, 0.14);
  --accent-text: #ffffff;
  --ember: #c8862a;
  --ember-dim: #a56c1e;
  --ok: #1fa86a;
  --warn: #c4921f;
  --danger: #d14b3d;
  --chip: #eef1f6;
  --shadow: 0 6px 20px rgba(20, 28, 45, 0.08);
  --header-border: rgba(20, 28, 45, 0.08);
  --input-bg: #ffffff;
  --btn-secondary-bg: #ffffff;
  --btn-secondary-border: var(--panel-edge);
  --btn-secondary-text: var(--text);
  --hero-grad: linear-gradient(135deg, #ffffff 0%, #f0f4fb 100%);
  --inset: rgba(20, 28, 45, 0.04);
  --inset-strong: rgba(20, 28, 45, 0.08);
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--text);
  font-family: var(--font);
  overflow-x: hidden;
  background: var(--bg0);
  transition: background 0.2s ease, color 0.2s ease;
}

html.spa-js .seo-crawl {
  display: none !important;
}
.seo-crawl {
  margin: 0 0 16px;
  padding: 14px 16px;
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  background: var(--panel);
}
.seo-crawl h1 {
  margin: 0 0 8px;
  font-size: 1.35rem;
}
.seo-crawl p {
  margin: 0 0 8px;
  color: var(--muted);
}
.seo-crawl p:last-child {
  margin-bottom: 0;
}

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px 16px 72px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  width: 100%;
}

.site-legal {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px 28px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: max(28px, env(safe-area-inset-bottom));
}
.site-legal-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 16px;
  margin: 0 0 10px;
}
.site-legal-nav a {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
  text-decoration: none;
}
.site-legal-nav a:hover {
  color: var(--accent);
  text-decoration: underline;
}
.site-legal p {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--faint);
  text-align: center;
}

/* —— Header —— */
.site-header {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--header-border);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.brand-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

.logo {
  display: inline-flex;
  align-items: baseline;
  gap: 0;
  text-decoration: none;
  color: var(--text);
  line-height: 1;
}
.logo-text {
  display: inline-flex;
  align-items: baseline;
  white-space: nowrap;
}
.logo-name {
  font-size: 1.38rem;
  font-weight: 800;
  letter-spacing: -0.048em;
}
.logo-tld {
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--accent);
}
.logo-api {
  margin-left: 0.5rem;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.logo:hover .logo-tld {
  color: var(--accent-dim);
}

.nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}
.nav a,
.nav-btn {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 6px 12px;
  border-radius: 999px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.2;
  transition: background 0.15s, color 0.15s;
}
.nav a:hover,
.nav-btn:hover,
.nav a.active,
.nav-btn.active {
  color: var(--text);
  background: var(--chip);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
  flex: 1 1 16rem;
  justify-content: flex-end;
}

.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--panel-edge);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.theme-toggle:hover {
  border-color: var(--accent);
  background: var(--chip);
}
[data-theme="dark"] .theme-icon-moon { display: none; }
[data-theme="light"] .theme-icon-sun { display: none; }

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  max-width: 100%;
  min-width: 0;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  min-width: 5.6rem;
  flex: 0 1 auto;
  text-align: center;
  overflow: visible;
}
.stat b {
  display: block;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 700;
  line-height: 1.25;
  overflow: visible;
  white-space: nowrap;
}
.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  line-height: 1.3;
}

/* —— Global search panel —— */
.global-search {
  margin-bottom: 16px;
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.global-search[hidden] { display: none !important; }
.global-search-inner {
  padding: 14px 16px 16px;
}
.deep-search-box {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--panel-edge);
  background: var(--panel2);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  justify-content: space-between;
}
.deep-search-box[hidden] { display: none !important; }
.deep-search-copy {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  flex: 1 1 12rem;
}
.btn-deep {
  background: transparent !important;
  color: var(--accent) !important;
  border: 1px solid var(--accent) !important;
  box-shadow: none !important;
  font-weight: 650;
  white-space: nowrap;
}
.btn-deep:hover {
  background: var(--accent-glow) !important;
}

/* —— Panels —— */
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.section-title {
  margin: 18px 0 10px;
  font-size: 0.78rem;
  color: var(--faint);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

h2 {
  margin: 0 0 8px;
  font-size: 1.15rem;
  font-weight: 700;
}

/* —— Search —— */
.search-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.search-kind {
  display: flex;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: var(--inset);
  border: 1px solid var(--panel-edge);
  flex: 0 0 auto;
}
.search-kind-btn {
  padding: 7px 12px;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.search-kind-btn.active {
  background: var(--accent);
  color: var(--accent-text);
}
input[type="search"],
input[type="text"],
input[type="password"],
input[type="number"],
select {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  height: 44px;
  min-height: 44px;
  max-height: 44px;
  background: var(--input-bg);
  border: 1px solid var(--panel-edge);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  font-size: 1rem;
  line-height: 44px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="search"] {
  -webkit-appearance: none;
  appearance: none;
}
input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

button, .btn {
  background: var(--accent);
  color: var(--accent-text);
  border: 0;
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  font-family: inherit;
}
button:hover { filter: brightness(1.05); }
button.secondary {
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-text);
  border: 1px solid var(--btn-secondary-border);
}
button.danger {
  background: var(--danger);
  color: #fff;
  border: 1px solid transparent;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }

.hint {
  color: var(--muted);
  font-size: 0.84rem;
  margin-top: 10px;
  line-height: 1.45;
}
.danger-hint { color: #e8a59c; }

/* display:flex would override the HTML [hidden] attribute — keep both. */
.search-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  color: var(--accent);
  font-size: 0.9rem;
}
.search-loading[hidden] {
  display: none !important;
}
.spinner, .btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--panel-edge);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}
.spinner[hidden],
.btn-spinner[hidden] {
  display: none !important;
}
#btnSearch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 7.5rem;
}
#btnSearch.searching .btn-label {
  opacity: 0.85;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* —— Results —— */
.results { display: grid; gap: 10px; margin-top: 12px; }
.results.searching { opacity: 0.55; pointer-events: none; }

.card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--bg0);
  border: 1px solid var(--panel-edge);
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.12s;
}
a.card:visited {
  color: inherit;
}
.card:hover {
  border-color: var(--accent-dim);
  transform: translateY(-1px);
}
.card-avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--chip);
  border: 1px solid var(--panel-edge);
  display: grid;
  place-items: center;
  font-weight: 800;
  color: var(--accent);
  overflow: hidden;
}
.card-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.card-avatar.al .al-flag,
.card-avatar.al .al-flag.letter {
  width: 100%;
  height: 100%;
}
.card h3 {
  margin: 0 0 4px;
  font-size: 1rem;
  font-weight: 700;
}
.meta {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.badge {
  display: inline-block;
  background: var(--chip);
  border: 1px solid var(--panel-edge);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--muted);
  margin-right: 4px;
}
.badge.ok { color: var(--ok); border-color: rgba(94, 211, 154, 0.35); }
.badge.warn { color: var(--warn); border-color: rgba(224, 176, 74, 0.35); }
.badge.pink {
  color: var(--ember);
  border-color: rgba(224, 160, 74, 0.4);
}

/* —— Profile (Governor card) —— */
.profile-shell {
  margin-top: 4px;
  scroll-margin-top: 12px;
}
.profile-card,
.gov-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  color: var(--text);
}
.profile-loading {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--bg0) 72%, transparent);
  backdrop-filter: blur(3px);
}
.profile-loading[hidden] {
  display: none !important;
}
.profile-loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px 28px;
  border-radius: var(--radius);
  border: 1px solid var(--panel-edge);
  background: var(--panel);
  color: var(--accent);
  font-weight: 650;
  box-shadow: var(--shadow);
}
.profile-spinner {
  width: 28px;
  height: 28px;
  border-width: 3px;
}
.gov-card.is-loading .gov-banner,
.gov-card.is-loading .gov-tabs,
.gov-card.is-loading .gov-tab-body {
  opacity: 0.35;
  pointer-events: none;
}
.profile-loading-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.profile-body {
  min-height: 120px;
}
/* One slim refresh strip under the hero — not a second card */
.profile-sync-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px 11px;
  margin: 0;
  background: color-mix(in srgb, var(--accent) 9%, var(--panel2));
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 22%, var(--panel-edge));
}
.profile-sync-bar[hidden] {
  display: none !important;
}
.profile-sync-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.profile-sync-copy {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 1px 8px;
  min-width: 0;
}
.profile-sync-copy strong {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}
.profile-sync-copy span {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.3;
  min-width: 0;
}
.profile-sync-ring {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent) 28%, transparent);
  border-top-color: var(--accent);
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}
.profile-sync-track {
  height: 3px;
  border-radius: 999px;
  overflow: hidden;
  background: color-mix(in srgb, var(--accent) 16%, var(--chip));
}
.profile-sync-fill {
  height: 100%;
  width: 36%;
  border-radius: inherit;
  background: var(--accent);
  animation: profile-sync-slide 1.35s ease-in-out infinite;
}
@keyframes profile-sync-slide {
  0% { transform: translateX(-90%); }
  100% { transform: translateX(320%); }
}
.btn-refresh.is-syncing {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--accent);
}
.btn-refresh.is-syncing .btn-refresh-icon {
  animation: spin 0.9s linear infinite;
}
.gov-card.is-enriching .gov-tab-body {
  /* keep content readable while skeletons fill gaps */
}

/* Section skeletons for missing deep data */
.section-skeleton {
  display: grid;
  gap: 10px;
}
.section-skeleton-gear,
.section-skeleton-skins {
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
}
.section-skeleton-heroes {
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.section-skeleton-ranks {
  grid-template-columns: 1fr;
}
.skel-tile,
.skel-hero,
.skel-line {
  border-radius: var(--radius-sm);
  background: linear-gradient(
    90deg,
    var(--panel2) 0%,
    color-mix(in srgb, var(--chip) 70%, var(--panel2)) 50%,
    var(--panel2) 100%
  );
  background-size: 200% 100%;
  animation: skel-shimmer 1.2s ease-in-out infinite;
  border: 1px solid var(--panel-edge);
}
.skel-tile {
  height: 108px;
}
.skel-hero {
  height: 160px;
}
.skel-line {
  height: 44px;
}
.section-pending-hint {
  margin: 8px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}
@keyframes skel-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.privacy-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 14px;
  border-radius: 14px;
  border: 1px dashed rgba(224, 160, 74, 0.35);
  background: rgba(224, 160, 74, 0.06);
  color: var(--ember);
  font-weight: 650;
  text-align: center;
  line-height: 1.45;
}
.privacy-lock {
  font-size: 1.1rem;
  flex-shrink: 0;
}
.gov-banner,
.profile-hero {
  position: relative;
  padding: 12px 14px 12px;
  text-align: left;
  background: var(--panel2);
  border-bottom: 1px solid var(--panel-edge);
}
.gov-banner-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 36px;
  width: 100%;
  box-sizing: border-box;
}
.gov-banner-top > .icon-btn {
  position: relative;
  left: auto;
  top: auto;
  flex: 0 0 auto;
}
.gov-updated {
  position: static;
  margin: 0 0 0 auto;
  text-align: right;
  white-space: nowrap;
  line-height: 1.25;
  max-width: calc(100% - 52px);
  overflow: hidden;
  text-overflow: ellipsis;
}
.gov-banner-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  justify-content: center;
  padding: 2px 4px 0;
}
.gov-banner-main {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 4px;
  align-items: center;
  justify-content: center;
  flex: 0 1 auto;
  min-width: 0;
  width: 100%;
  text-align: center;
}
.gov-refresh-panel {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  margin-left: auto;
}
.btn-refresh {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  min-width: 44px;
  margin: 0;
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--panel-edge);
  background: var(--panel);
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  box-shadow: none;
}
.btn-refresh:hover {
  filter: brightness(1.08);
  border-color: var(--accent);
}
.btn-refresh:disabled {
  opacity: 0.7;
  cursor: wait;
}
.btn-refresh.is-cooldown {
  min-width: 52px;
  color: var(--ember);
  border-color: color-mix(in srgb, var(--ember) 55%, var(--border));
  cursor: not-allowed;
  opacity: 1;
}
.btn-refresh.is-cooldown .btn-refresh-icon {
  font-size: 0.95rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.btn-refresh-icon {
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  line-height: 1;
}
.btn-refresh-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.btn-refresh-copy,
.btn-refresh-label {
  display: none;
}
.gov-portrait {
  position: relative;
  flex: 0 0 auto;
  width: 88px;
  height: 88px;
  align-self: center;
  overflow: visible;
}
.gov-portrait.has-frame {
  width: 88px;
  height: 88px;
  margin: 20px 0 30px;
}
.gov-portrait .avatar {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 88px;
  height: 88px;
  margin: 0;
}
.gov-portrait.has-frame .avatar {
  width: 88px;
  height: 88px;
  border-radius: 6px;
  border-color: transparent;
  box-shadow: none;
}
.gov-avatar-frame {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 255%;
  height: auto;
  aspect-ratio: 288 / 214;
  transform: translate(-50%, -50%);
  object-fit: fill;
  pointer-events: none;
  z-index: 4;
  -webkit-mask-image: linear-gradient(#000 0 0), linear-gradient(#000 0 0);
  -webkit-mask-size: 100% 100%, 38% 51%;
  -webkit-mask-position: center, center;
  -webkit-mask-repeat: no-repeat, no-repeat;
  -webkit-mask-composite: xor;
  mask-image: linear-gradient(#000 0 0), linear-gradient(#000 0 0);
  mask-size: 100% 100%, 38% 51%;
  mask-position: center, center;
  mask-repeat: no-repeat, no-repeat;
  mask-composite: exclude;
}
.gov-avatar-frame[hidden] { display: none !important; }
.gov-skin-badge {
  display: none !important;
}
.gov-skin-badge img,
.city-skin-thumb {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.gov-identity {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 1 auto;
  min-width: 0;
  width: 100%;
  text-align: center;
}
.gov-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.gov-name-row .gov-name {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
}
#profileChips { display: none !important; }
.gov-hero-strip {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-top: 10px;
  padding-left: 0;
  min-width: 0;
}
.gov-alliance-card,
.gov-alliance {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--panel-edge);
  background: var(--panel);
  color: inherit;
  text-decoration: none;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ember) 10%, transparent);
}
.gov-alliance-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.gov-alliance-card[hidden],
.gov-alliance[hidden] { display: none !important; }
.gov-alliance-card.is-empty {
  box-shadow: none;
  opacity: 0.88;
}
.gov-alliance-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1 1 auto;
}
.gov-alliance-headline {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.gov-alliance-tag {
  flex: 0 0 auto;
  font-weight: 800;
  color: var(--ember);
  letter-spacing: 0.02em;
}
.gov-alliance-name {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gov-alliance-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
}
.gov-alliance-rank {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-glow);
  border-radius: 999px;
  padding: 3px 8px;
}
.gov-hero-strip .btn-refresh {
  width: auto;
  min-width: 68px;
  height: auto;
  padding: 8px 10px;
  border-radius: 12px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.gov-hero-strip .btn-refresh-icon {
  font-size: 1.15rem;
}
.gov-hero-strip .btn-refresh-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.gov-hero-strip .btn-refresh.is-cooldown {
  min-width: 72px;
}
.gov-hero-strip .btn-refresh.is-cooldown .btn-refresh-label {
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}
.alliance-hero .btn-refresh {
  width: auto;
  min-width: 68px;
  height: auto;
  padding: 8px 10px;
  border-radius: 12px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.alliance-hero .btn-refresh-icon {
  font-size: 1.15rem;
}
.alliance-hero .btn-refresh-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.alliance-hero .btn-refresh.is-cooldown {
  min-width: 72px;
}
.alliance-hero .btn-refresh.is-cooldown .btn-refresh-icon {
  font-size: 1.05rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.alliance-hero .btn-refresh.is-cooldown .btn-refresh-label {
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}
.gov-name,
.profile-name {
  margin: 0 0 6px;
  font-size: clamp(1.15rem, 3vw, 1.4rem);
  font-weight: 850;
  letter-spacing: -0.02em;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.gov-sub,
.profile-sub {
  color: var(--muted);
  font-size: 0.86rem;
  margin: 0 0 2px;
  line-height: 1.4;
}
.gov-stat-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.gov-stat-link {
  display: block;
  color: inherit;
  text-decoration: none;
}
.gov-stat.is-map {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--panel-edge));
  background: var(--accent-glow);
}
.gov-stat.is-map b { color: var(--accent); }
.gov-stat-link:hover b { color: var(--accent); }
.gov-stat {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
}
.gov-stat.is-on {
  border-color: color-mix(in srgb, var(--ok) 45%, var(--panel-edge));
  background: color-mix(in srgb, var(--ok) 10%, var(--panel));
}
.gov-stat.is-burn {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--panel-edge));
  background: color-mix(in srgb, var(--danger) 10%, var(--panel));
}
.gov-stat.is-burn b { color: var(--danger); }
.gov-stat.is-on b { color: var(--ok); }
.gov-stat b {
  display: block;
  font-size: 0.98rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.chip.chip-ok {
  border-color: rgba(94, 211, 154, 0.4);
  color: var(--ok);
}
.chip.chip-warn {
  border-color: rgba(224, 106, 92, 0.45);
  color: #f0a090;
}
.gov-fact .v.warn { color: var(--danger); }
.gov-fact.is-on .v { color: var(--ok); }
.gov-fact.is-burn .v { color: var(--danger); }
.intel-map-link {
  display: inline-block;
  margin-left: 8px;
  font-size: 0.78rem;
  font-weight: 750;
  color: var(--accent);
  text-decoration: none;
}
.intel-map-link:hover { text-decoration: underline; }
.gov-stat span {
  display: block;
  margin-top: 2px;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}
.gov-tabs {
  background: var(--panel);
}
.gov-tab-body {
  padding: 16px;
  background: var(--panel);
}
.gov-section {
  margin-bottom: 18px;
}
.gov-section-title {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}
.gov-facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  gap: 8px;
}
.gov-fact {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--panel2);
  border: 1px solid var(--panel-edge);
  font-size: 0.9rem;
}
.gov-fact .k {
  color: var(--muted);
  flex: 0 1 auto;
}
.gov-fact .v {
  font-weight: 700;
  text-align: right;
  flex: 1 1 auto;
  min-width: 6ch;
  overflow-wrap: anywhere;
}
.office-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px 3px 5px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  border: 1px solid var(--panel-edge);
  background: var(--panel2);
}
.office-chip-icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}
.office-chip.kind-sovereign {
  color: #f3d48a;
  border-color: #8a6a2a;
  background: #2a2110;
}
.office-chip.kind-office {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--panel-edge));
}
.office-chip.kind-punishment {
  color: #f0a0a0;
  border-color: #7a3030;
  background: #2a1212;
}
.office-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 10px;
}
.office-card {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--panel2);
  border: 1px solid var(--panel-edge);
}
.office-card.kind-sovereign {
  border-color: #8a6a2a;
}
.office-card.kind-punishment {
  border-color: #7a3030;
}
.office-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.office-card-icon {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}
.office-icon {
  width: 56px;
  height: 56px;
  object-fit: contain;
  display: block;
}
.office-card-copy {
  min-width: 0;
}
.office-card-head .office-kind {
  display: block;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.office-card-head h4 {
  margin: 0;
  font-size: 1.05rem;
}
.office-realm,
.office-when {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}
.office-buffs {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.office-buffs li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.85rem;
}
.office-buffs .k { color: var(--muted); }
.office-buffs .v { font-weight: 700; }
.office-card.kind-punishment .office-buffs .v { color: #f0a0a0; }
.lord-gear-rack {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
}
.skin-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
}
.skin-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--panel-edge);
}
.skin-row:last-child { border-bottom: 0; }
.skin-row-type {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  flex-shrink: 0;
}
.skin-row-name {
  font-size: 0.92rem;
  font-weight: 700;
  text-align: right;
  overflow-wrap: anywhere;
}
.skin-row-name.is-empty {
  color: var(--faint);
  font-weight: 600;
}
.lord-gear-rack {
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 12px 10px;
  justify-items: center;
}
.lord-gear-tile,
.skin-tile {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--panel2);
  border: 1px solid var(--panel-edge);
  min-width: 0;
}
/* In-game style: quality color is the icon square, not the card. */
.lord-gear-tile {
  align-items: center;
  gap: 6px;
  padding: 4px 2px 6px;
  background: transparent;
  border: 0;
  box-shadow: none;
}
.lord-gear-icon-wrap {
  position: relative;
  width: 78px;
  height: 78px;
  margin: 0 auto;
  flex-shrink: 0;
}
.lord-gear-icon,
.skin-icon-wrap,
.gear-tile-icon {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: var(--inset-strong);
  border: 1px solid var(--panel-edge);
  display: grid;
  place-items: center;
  overflow: hidden;
  margin: 0 auto;
}
.lord-gear-icon-wrap .lord-gear-icon {
  width: 78px;
  height: 78px;
  margin: 0;
  border-radius: 14px;
  border-width: 2px;
}
.lord-gear-q-green .lord-gear-icon {
  background: linear-gradient(180deg, #6ed18a 0%, #2f9a52 100%);
  border-color: #1e7a3c;
}
.lord-gear-q-blue .lord-gear-icon {
  background: linear-gradient(180deg, #6aa8f0 0%, #2f6fc4 100%);
  border-color: #1e4f96;
}
.lord-gear-q-purple .lord-gear-icon {
  background: linear-gradient(180deg, #c49bff 0%, #7a3fc0 100%);
  border-color: #5a2494;
}
.lord-gear-q-gold .lord-gear-icon {
  background: linear-gradient(180deg, #f3cc62 0%, #c48a14 100%);
  border-color: #9a6a0c;
}
.lord-gear-q-red .lord-gear-icon {
  background: linear-gradient(180deg, #f4a094 0%, #d45a52 100%);
  border-color: #b0443c;
}
/* Game-style T5 / T6 in the top-left of the icon. */
.lord-gear-lv {
  position: absolute;
  left: 5px;
  top: 2px;
  z-index: 3;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.1;
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.95),
    0 0 4px rgba(0, 0, 0, 0.75);
  pointer-events: none;
}
/* Gold stars stacked on the left of the piece, like the in-game comparison. */
.lord-gear-stars {
  position: absolute;
  left: 2px;
  top: 18px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 0;
  background: none;
  box-shadow: none;
  color: #ffd24a;
  font-size: 0.78rem;
  line-height: 0.86;
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.95),
    0 0 5px rgba(255, 180, 40, 0.85);
  pointer-events: none;
}
.gear-icon,
.skin-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  image-rendering: auto;
}
.icon-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font-weight: 800;
  color: var(--accent);
  background: var(--chip);
}
.lord-gear-meta,
.skin-meta {
  display: grid;
  gap: 2px;
  text-align: center;
  min-width: 0;
}
.lord-gear-meta {
  width: 100%;
}
.gear-name,
.skin-name {
  font-size: 0.78rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lord-gear-tile .gear-name {
  overflow: visible;
  text-overflow: unset;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
}
.skin-name-na {
  color: var(--muted);
  font-weight: 600;
  font-style: italic;
}
.skin-tile-missing {
  opacity: 0.88;
}
.skin-tile-missing .skin-icon-wrap {
  border-style: dashed;
  color: var(--muted);
}
.skin-type,
.gear-slot {
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.profile-hero {
  /* legacy alias kept for absolute back-btn rule */
}
/* Back control: in-flow by default (page heroes / alliance). Absolute only on profile. */
.icon-btn {
  position: relative;
  flex: 0 0 auto;
  align-self: flex-start;
  display: inline-grid;
  place-items: center;
  background: var(--bg0);
  border: 1px solid var(--panel-edge);
  color: var(--text);
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  border-radius: 10px;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
  z-index: 2;
  cursor: pointer;
}
.icon-btn:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
  filter: none;
}
.profile-hero > .icon-btn,
.gov-banner > .icon-btn {
  position: absolute;
  left: 12px;
  top: 12px;
}
.avatar-wrap { display: flex; justify-content: center; margin-bottom: 10px; }
.avatar {
  width: 96px;
  height: 96px;
  border-radius: 22px;
  background: var(--chip);
  border: 2px solid var(--accent-dim);
  display: grid;
  place-items: center;
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  overflow: hidden;
  box-shadow: 0 0 0 4px var(--accent-glow), 0 12px 28px var(--inset-strong);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.gov-banner .chip-row { justify-content: center; }
.gov-banner .profile-actions { justify-content: center; }
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-bottom: 12px;
}
.chip {
  background: var(--chip);
  border: 1px solid var(--panel-edge);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--text);
}
.tag {
  display: inline-block;
  background: rgba(224, 160, 74, 0.12);
  border: 1px solid rgba(224, 160, 74, 0.35);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ember);
}
.profile-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}
.enrich-status {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.35;
}

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--panel-edge);
  background: var(--panel);
}
.tab {
  flex: 1;
  background: transparent;
  color: var(--muted);
  border: 0;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  padding: 12px 8px;
  font-weight: 650;
  font-size: 0.85rem;
}
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: transparent;
}
.tab-body { padding: 16px; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.ov-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 12px;
}
.ov-card {
  background: var(--bg0);
  border: 1px solid var(--panel-edge);
  border-radius: 12px;
  padding: 14px;
}
.ov-card h3 {
  margin: 0 0 10px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
  font-weight: 700;
}
.row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--panel-edge);
  font-size: 0.9rem;
}
.row:last-child { border-bottom: 0; }
.row .k { color: var(--muted); flex: 0 1 auto; min-width: 0; }
.row .v {
  font-weight: 650;
  text-align: right;
  min-width: 0;
  overflow-wrap: anywhere;
}
.row .v.ok { color: var(--ok); }

.battle-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.battle-stat {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
}
.battle-stat b {
  display: block;
  font-size: 1rem;
  color: var(--ember);
}
.battle-stat span {
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.lb-list { display: grid; gap: 8px; }
.lb-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
}
.lb-name { font-weight: 650; }
.lb-val {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

/* —— Heroes & gear —— */
.heroes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.hero-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg0);
  border: 1px solid var(--panel-edge);
  border-radius: 14px;
  padding: 12px;
  border-top: 3px solid var(--accent-dim);
  overflow: visible;
}
.hero-top {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}
.hero-intro {
  min-width: 0;
}
.hero-intro h4 {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 800;
  overflow-wrap: anywhere;
  line-height: 1.2;
}
.hero-star-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin: 0 0 8px;
}
.hero-widget {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--ember) 48%, var(--panel-edge));
  background: color-mix(in srgb, var(--ember) 16%, var(--panel));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ember) 10%, transparent);
  line-height: 1;
  white-space: nowrap;
}
.hero-widget-k {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ember);
}
.hero-widget-v {
  font-size: 0.86rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
[data-theme="light"] .hero-widget {
  background: color-mix(in srgb, var(--ember) 12%, #ffffff);
  border-color: color-mix(in srgb, var(--ember) 40%, #c5cad3);
}
.hero-card.q-legend { border-top-color: var(--ember); }
.hero-card.q-mythic { border-top-color: #c47cff; }

.hero-portrait {
  position: relative;
  width: 100%;
  max-width: 96px;
  aspect-ratio: 1;
  height: auto;
  border-radius: 14px;
  overflow: hidden;
  background: var(--panel2);
  border: 1px solid var(--panel-edge);
  display: grid;
  place-items: center;
}
.hero-portrait .hero-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.hero-fallback {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent);
}
.hero-stars {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
  color: var(--ember);
  font-size: 0.72rem;
  letter-spacing: 1px;
  text-align: center;
  padding: 10px 2px 4px;
}
.hero-star-row {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 6px 9px 6px 8px;
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  background: var(--panel);
}
.petal-star {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: block;
  overflow: visible;
}
.petal-star .petal {
  fill: #2a2e36;
  stroke: #8b929e;
  stroke-width: 1.2;
  stroke-linejoin: round;
}
.petal-star .petal.on {
  fill: #ffc62e;
  stroke: #6a4308;
  stroke-width: 1.15;
}
[data-theme="light"] .hero-star-row {
  background: #ffffff;
  border-color: #c5cad3;
}
[data-theme="light"] .petal-star .petal {
  fill: #e6e8ee;
  stroke: #6b7280;
}
[data-theme="light"] .petal-star .petal.on {
  fill: #f0b400;
  stroke: #6a4308;
}

.hero-body {
  min-width: 0;
}
.hero-body h4 {
  margin: 0 0 8px;
  font-size: 1.05rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}
.hero-stats-text {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
  font-size: 0.82rem;
}
.hero-stats-text > div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.hero-stats-text .k { color: var(--muted); }
.hero-stats-text .v {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.gear-heading {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
  font-weight: 700;
  margin-bottom: 8px;
}
.gear-tiles {
  display: grid;
  gap: 8px;
  padding: 0;
}
.gear-tile {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--panel-edge);
  background: var(--panel2);
  min-width: 0;
  align-items: stretch;
}
.gear-tile-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.gear-emoji {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  line-height: 1;
  background: var(--inset);
  border: 1px solid var(--panel-edge);
}
.gear-tile-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.gear-tile .gear-slot {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.gear-tile.exclusive .gear-slot { color: var(--ember); }
.gear-piece-name {
  font-size: 0.82rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.gear-facts {
  display: grid;
  gap: 4px;
  margin: 0;
}
.gear-facts > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 0.8rem;
}
.gear-facts dt {
  color: var(--muted);
  font-weight: 650;
}
.gear-facts dd {
  margin: 0;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.gear-tile.hq-common .gear-emoji {
  background: linear-gradient(180deg, #c8cdd6 0%, #8b919c 100%);
  border-color: #6a707a;
}
.gear-tile.hq-uncommon .gear-emoji {
  background: linear-gradient(180deg, #8ed9a4 0%, #2f9a52 100%);
  border-color: #1e7a3c;
}
.gear-tile.hq-rare .gear-emoji {
  background: linear-gradient(180deg, #6aa8f0 0%, #2f6fc4 100%);
  border-color: #1e4f96;
}
.gear-tile.hq-epic .gear-emoji {
  background: linear-gradient(180deg, #c49bff 0%, #7a3fc0 100%);
  border-color: #5a2494;
}
.gear-tile.hq-mythic .gear-emoji,
.gear-tile.exclusive:not(.hq-legendary) .gear-emoji {
  background: linear-gradient(180deg, #f3cc62 0%, #c48a14 100%);
  border-color: #9a6a0c;
}
.gear-tile.hq-legendary .gear-emoji {
  background: linear-gradient(180deg, #f4a094 0%, #d45a52 100%);
  border-color: #b0443c;
}
.gear-tile.hq-common .gear-type { color: #9aa3b2; }
.gear-tile.hq-uncommon .gear-type { color: var(--ok); }
.gear-tile.hq-rare .gear-type { color: var(--accent); }
.gear-tile.hq-epic .gear-type { color: #c49bff; }
.gear-tile.hq-mythic .gear-type,
.gear-tile.exclusive:not(.hq-legendary) .gear-type { color: var(--ember); }
.gear-tile.hq-legendary .gear-type { color: var(--danger); }
.gear-stat {
  font-size: 0.72rem;
  color: var(--muted);
}
.gear-stat b {
  color: var(--text);
  font-weight: 700;
}

/* —— History / members —— */
.member-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  margin: 24px 0 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
}
.member-head .section-title {
  margin: 0;
  line-height: 1.2;
}
.al-export {
  position: relative;
  flex: 0 0 auto;
}
.al-export-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--panel-edge);
  background: var(--bg0);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 750;
  cursor: pointer;
}
.al-export-btn::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: 0.7;
}
.al-export-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.al-export-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.al-export-btn[aria-expanded="true"] {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}
.al-export-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 8;
  min-width: 11.5rem;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--panel-edge);
  background: var(--panel);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.al-export-menu[hidden] {
  display: none !important;
}
.al-export-menu button {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 650;
  cursor: pointer;
}
.al-export-menu button:hover {
  background: var(--accent-glow);
  color: var(--accent);
}
.al-pdf-frame {
  position: fixed;
  inset: 0;
  z-index: 80;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
.hist-list, .member-list { display: grid; gap: 8px; }
.hist-row, .member-row {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg0);
  border: 1px solid var(--panel-edge);
  border-radius: 12px;
}
.member-row { cursor: pointer; grid-template-columns: auto auto 1fr auto; }
.member-row:hover { border-color: var(--accent-dim); }
.member-copy b { display: block; line-height: 1.25; }
.member-gov-id {
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.member-copy .meta { margin-top: 2px; }
.hist-avatar, .member-av {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--chip);
  display: grid;
  place-items: center;
  font-weight: 800;
  color: var(--accent);
  overflow: hidden;
}
.member-av.letter { font-size: 0.9rem; }
.member-av img, img.member-av {
  width: 36px;
  height: 36px;
  object-fit: cover;
}
.rank-pill {
  min-width: 36px;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--muted);
  background: var(--chip);
  border-radius: 8px;
  padding: 4px 6px;
}
.rank-pill.leader {
  color: var(--ember);
  border: 1px solid rgba(224, 160, 74, 0.4);
}
.power {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--ember);
}
.hist-date { color: var(--muted); font-size: 0.8rem; text-align: right; }
.hist-summary {
  margin-top: 6px;
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.4;
  opacity: 0.92;
}

/* —— Alliance page —— */
.alliance-link {
  color: var(--ember);
  text-decoration: none;
  font-weight: 750;
}
.alliance-link:hover { text-decoration: underline; color: var(--accent); }
.alliance-page-hero {
  margin-bottom: 16px;
}
.alliance-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}
.alliance-hero h2 {
  margin: 0;
  font-size: clamp(1.25rem, 4vw, 1.7rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.alliance-hero-refresh {
  position: absolute;
  top: 12px;
  right: 12px;
}
.al-hero-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.al-hero-rank {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 650;
}
.alliance-hero .kd-map-btn {
  margin-top: 4px;
}
.alliance-hero .enrich-status {
  min-height: 1.1em;
}
.alliance-flag {
  width: min(96px, 38vw);
  height: min(96px, 38vw);
  border-radius: 18px;
  background: var(--inset);
  border: 1px solid var(--panel-edge);
  overflow: hidden;
  display: grid;
  place-items: center;
  font-size: 2.4rem;
  color: var(--accent);
  flex: 0 0 auto;
  line-height: 1;
}
.notice-text {
  color: var(--muted);
  line-height: 1.55;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

a { color: var(--accent); }
a:hover { color: var(--ember); }

.empty-note {
  color: var(--muted);
  padding: 22px 10px;
  line-height: 1.55;
  text-align: center;
}

/* —— Admin —— */
.admin-wrap .panel h2,
.admin-wrap .panel h3 { margin-top: 0; }
.admin-stats {
  display: grid;
  margin: 12px 0;
  min-width: 100%;
  grid-template-columns: repeat(5, 1fr);
}
.ops-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 12px 0 0;
}
.ops-grid-3 { grid-template-columns: repeat(3, 1fr); }
.ops-grid-wide { margin-top: 12px; }
.api-users-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin: 10px 0 0;
}
.api-users-toolbar select {
  height: 40px;
  min-width: 240px;
  max-width: 100%;
}
.api-users-pager {
  margin: 12px 0 0;
  justify-content: flex-start;
}
.api-users { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.api-users-head,
.api-user-row {
  display: grid;
  grid-template-columns: minmax(180px, 2fr) minmax(140px, 1.3fr) 64px 72px 72px minmax(150px, 1.2fr);
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
}
.api-users-head {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.api-user-row {
  background: var(--inset);
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
}
.api-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.api-user img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--chip);
  flex-shrink: 0;
}
.api-user strong { display: block; }
.api-user .muted,
.api-user-row .muted { color: var(--muted); font-size: 0.8rem; }
.api-user-id { font-size: 0.8rem; overflow-wrap: anywhere; }
@media (max-width: 900px) {
  .api-users-head { display: none; }
  .api-user-row {
    grid-template-columns: 1fr 1fr;
    gap: 8px 14px;
  }
  .api-user { grid-column: 1 / -1; }
}
.ops-card {
  background: var(--inset);
  border: 1px solid var(--panel-edge);
  border-radius: 12px;
  padding: 12px 14px;
  min-width: 0;
}
.ops-card.is-bad { border-color: rgba(224, 106, 92, 0.55); }
.ops-card.is-warn { border-color: rgba(224, 176, 74, 0.55); }
.ops-card.is-ok { border-color: rgba(62, 207, 142, 0.35); }
.ops-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}
.ops-card-head h3 {
  margin: 0;
  font-size: 0.92rem;
}
.ops-sub {
  color: var(--muted);
  font-size: 0.72rem;
  margin: 0 0 10px;
}
.ops-pill {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--panel-edge);
  color: var(--muted);
  white-space: nowrap;
}
.ops-pill.is-ok { color: var(--ok); border-color: rgba(62, 207, 142, 0.45); }
.ops-pill.is-warn { color: var(--warn); border-color: rgba(224, 176, 74, 0.45); }
.ops-pill.is-bad { color: var(--danger); border-color: rgba(224, 106, 92, 0.45); }
.ops-meters { display: flex; flex-direction: column; gap: 7px; }
.ops-meter-row {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 0.72rem;
}
.ops-meter-row span:first-child { color: var(--muted); }
.ops-meter-row b { font-variant-numeric: tabular-nums; font-weight: 650; }
.ops-meter {
  height: 7px;
  border-radius: 999px;
  background: var(--chip);
  border: 1px solid var(--panel-edge);
  overflow: hidden;
}
.ops-meter > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--ok);
}
.ops-meter.is-warn > i { background: var(--warn); }
.ops-meter.is-bad > i { background: var(--danger); }
.ops-kv {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  margin-top: 10px;
  font-size: 0.74rem;
}
.ops-kv div { min-width: 0; }
.ops-kv span { color: var(--muted); }
.ops-kv b { font-variant-numeric: tabular-nums; }
.code-block {
  background: var(--bg0);
  border: 1px solid var(--panel-edge);
  border-radius: 12px;
  padding: 12px;
  overflow: auto;
  font-size: 0.78rem;
  font-family: var(--mono);
  color: var(--accent);
  max-height: 320px;
}
.crawl-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0;
}
.crawl-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--muted);
  min-width: 140px;
}
.crawl-field-sm { min-width: 90px; max-width: 110px; }
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.db-clear-actions { margin-top: 10px; }

/* Admin live crawl + log console */
.crawl-live {
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--panel-edge);
  background: var(--inset);
}
.crawl-live.is-running {
  border-color: rgba(61, 190, 154, 0.45);
  box-shadow: 0 0 0 1px rgba(61, 190, 154, 0.12);
}
.crawl-live-status {
  font-weight: 700;
  font-size: 0.8rem;
  margin-bottom: 6px;
}
.crawl-live-meta {
  color: var(--muted);
  font-size: 0.72rem;
  font-family: var(--mono);
  line-height: 1.35;
  word-break: break-word;
  margin-top: 4px;
}
.crawl-overall .health-bar { height: 10px; }
.crawl-base {
  margin-top: 10px;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.crawl-base-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.78rem;
  font-weight: 700;
}
.crawl-base-meta {
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}
.crawl-timing {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 8px 0 10px;
}
.crawl-stat {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  padding: 8px 10px;
}
.crawl-stat b {
  display: block;
  font-size: 1.05rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.2;
}
.crawl-stat span {
  display: block;
  margin-top: 2px;
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.crawler-bars {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 8px;
  margin: 8px 0 6px;
}
.crawler-bar {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  padding: 8px 9px 7px;
}
.crawler-bar-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.crawler-bar-name {
  font-size: 0.92rem;
  font-weight: 750;
  color: var(--text);
}
.crawler-bar-node {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}
.crawler-bar-kid {
  margin-top: 3px;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--text);
}
.crawler-bar-speed {
  margin-top: 2px;
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.crawler-bar-track {
  height: 8px;
  border-radius: 99px;
  background: rgba(255,255,255,0.10);
  overflow: hidden;
  margin-top: 6px;
}
.crawler-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--accent, #3dbe9a);
  transition: width 0.35s ease;
}
.crawler-bar.is-idle {
  opacity: 0.62;
}
.crawl-hist-title {
  margin: 16px 0 8px;
  font-size: 0.95rem;
}
.crawl-hist-wrap {
  overflow-x: auto;
}
.crawl-hist {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.crawl-hist th,
.crawl-hist td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--panel-edge);
  color: var(--text);
}
.crawl-hist th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
@media (max-width: 720px) {
  .crawl-timing { grid-template-columns: 1fr 1fr; }
}
.log-console {
  background: #070c0a;
  border: 1px solid var(--panel-edge);
  border-radius: 12px;
  padding: 10px 12px;
  max-height: 220px;
  min-height: 100px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.45;
}
.log-line {
  display: grid;
  grid-template-columns: 150px 52px 1fr;
  gap: 8px;
  padding: 2px 0;
  border-bottom: 1px solid rgba(42, 64, 56, 0.35);
}
.log-line.muted { color: var(--faint); display: block; }
.log-ts { color: var(--faint); white-space: nowrap; }
.log-lv { font-weight: 800; letter-spacing: 0.04em; }
.log-line.level-info .log-lv { color: var(--accent); }
.log-line.level-warn .log-lv,
.log-line.level-warning .log-lv { color: var(--warn); }
.log-line.level-error .log-lv { color: var(--danger); }
.log-msg { color: var(--text); word-break: break-word; }

/* Admin settings catalog */
.settings-root { display: grid; gap: 16px; margin-top: 12px; }
.settings-group h4 {
  margin: 0 0 10px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--faint);
}
.setting-row {
  display: grid;
  grid-template-columns: 1fr minmax(140px, 220px);
  gap: 12px;
  align-items: start;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--panel-edge);
  background: var(--inset);
  margin-bottom: 8px;
}
.setting-row.is-override {
  border-color: rgba(61, 190, 154, 0.45);
  box-shadow: inset 0 0 0 1px rgba(61, 190, 154, 0.12);
}
.setting-row.is-readonly { opacity: 0.85; }
.setting-label {
  font-weight: 750;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.setting-key {
  font-size: 0.72rem;
  color: var(--accent);
  background: rgba(61, 190, 154, 0.1);
  padding: 2px 6px;
  border-radius: 6px;
}
.setting-src {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.setting-desc {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}
.setting-hint {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--ember);
}
.setting-control input,
.setting-control select {
  width: 100%;
  min-width: 0;
  background: var(--bg0);
  border: 1px solid var(--panel-edge);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}
#nextScanLine {
  color: var(--accent);
  font-weight: 650;
}

@media (max-width: 720px) {
  .setting-row { grid-template-columns: 1fr; }
  .log-line { grid-template-columns: 1fr; gap: 2px; }
}

/* —— Home redesign —— */
.eyebrow {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
#profileKingdomLine,
.gov-kingdom {
  display: inline-block;
  margin: 2px 0 0;
  padding: 0;
  border: 0;
  background: none;
  font-size: 0.82rem;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: none;
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}
#profileKingdomLine:hover,
.gov-kingdom:hover {
  text-decoration: underline;
}
#profileKingdomLine[hidden] { display: none !important; }
.hero-banner {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  padding: 26px 24px;
  margin-bottom: 16px;
  background: var(--hero-grad);
  border: 1px solid var(--panel-edge);
  box-shadow: var(--shadow);
}
.hero-banner h1 {
  margin: 0 0 10px;
  font-size: clamp(1.45rem, 3vw, 1.95rem);
  letter-spacing: -0.025em;
  line-height: 1.15;
  font-weight: 750;
}
.hero-sub {
  margin: 0;
  max-width: 52ch;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.95rem;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}
.btn-glow {
  background: var(--accent);
  color: var(--accent-text);
  border: 0;
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: filter 0.15s, transform 0.15s;
}
.btn-glow:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}
.btn-ghost {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-edge);
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
  font-size: 0.92rem;
  background: var(--panel);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}
.community-ctas {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 16px;
}
.patreon-invite,
.discord-invite {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, #5865f2 42%, var(--panel-edge));
  background:
    linear-gradient(135deg, color-mix(in srgb, #5865f2 18%, var(--panel)) 0%, var(--panel) 62%);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, transform 0.15s;
}
.patreon-invite {
  border: 1px solid color-mix(in srgb, #ff424d 46%, var(--panel-edge));
  background:
    linear-gradient(135deg, color-mix(in srgb, #ff424d 16%, var(--panel)) 0%, var(--panel) 64%);
}
.patreon-invite:hover {
  border-color: #ff424d;
  transform: translateY(-1px);
  text-decoration: none;
  color: inherit;
}
.discord-invite:hover {
  border-color: #5865f2;
  transform: translateY(-1px);
  text-decoration: none;
  color: inherit;
}
.patreon-invite-mark,
.discord-invite-mark {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: #5865f2;
  color: #fff;
  box-shadow: 0 8px 18px rgba(88, 101, 242, 0.28);
}
.patreon-invite-mark {
  background: #ff424d;
  box-shadow: 0 8px 18px rgba(255, 66, 77, 0.28);
}
.patreon-invite-copy,
.discord-invite-copy {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.patreon-invite-copy strong,
.discord-invite-copy strong {
  font-size: 1.02rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}
.patreon-invite-copy em,
.discord-invite-copy em {
  font-style: normal;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}
.patreon-invite-btn,
.discord-invite-btn {
  flex: 0 0 auto;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  background: #5865f2;
  color: #fff;
  font-weight: 750;
  font-size: 0.88rem;
  white-space: nowrap;
}
.patreon-invite-btn {
  background: #ff424d;
}
.patreon-invite:hover .patreon-invite-btn,
.discord-invite:hover .discord-invite-btn {
  filter: brightness(1.06);
}
.results-compact {
  margin-top: 12px;
  max-height: min(420px, 50dvh);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.home-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}
.lb-panel {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  min-height: 280px;
}
.lb-panel h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}
.section-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}
.pill-live {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}
.lb-list { display: grid; gap: 6px; margin-top: 12px; }
.lb-row-item[hidden] {
  display: none !important;
}
.lb-list.is-preview > .lb-row-item:nth-of-type(n + 31) {
  display: none !important;
}
.lb-expand-btn {
  margin-top: 6px;
  width: 100%;
  border: 1px dashed var(--panel-edge);
  background: var(--panel2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font: inherit;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
}
.lb-expand-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.lb-row-item {
  display: grid;
  grid-template-columns: 2.6rem 40px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--panel2);
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s, background 0.12s;
  text-align: left;
  color: inherit;
  font: inherit;
  width: 100%;
}
.lb-row-item:hover {
  transform: translateX(2px);
  border-color: var(--panel-edge);
  background: var(--chip);
}
.lb-rank {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--faint);
  text-align: center;
  min-width: 2.4rem;
  flex-shrink: 0;
}
.lb-row-item.top-1 .lb-rank { color: #f5d76e; }
.lb-row-item.top-2 .lb-rank { color: #c0c8d4; }
.lb-row-item.top-3 .lb-rank { color: #d4a574; }
.lb-av {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--chip);
  border: 1px solid var(--panel-edge);
  display: grid;
  place-items: center;
  overflow: hidden;
  font-weight: 800;
  color: var(--accent);
}
.lb-av img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.lb-hero-icon,
.lb-meta-line img.lb-hero-icon {
  width: 18px !important;
  height: 18px !important;
  max-width: 18px;
  max-height: 18px;
  border-radius: 4px;
  object-fit: cover;
  object-position: top center;
  vertical-align: -3px;
  margin-right: 4px;
}
.lb-name {
  font-weight: 750;
  line-height: 1.25;
}
.lb-meta-line {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 2px;
}
.lb-power {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--ember);
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.15;
}
.lb-power-sub {
  display: block;
  margin-top: 2px;
  font-size: 0.68rem;
  font-weight: 650;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.kingdom-rank-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.kingdom-rank-row .lb-row-item {
  flex: 1;
  min-width: 0;
}
.kingdom-rank-map {
  flex-shrink: 0;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-edge);
  background: var(--accent-glow);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.kingdom-rank-map:hover {
  border-color: var(--accent);
  color: var(--accent-dim);
}

/* —— Kingdoms —— */
.page-hero {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
  position: relative;
  padding: 4px 0;
}
.page-hero > :not(.icon-btn) {
  flex: 1 1 auto;
  min-width: 0;
}
.page-hero h1 {
  margin: 0 0 6px;
  font-size: clamp(1.25rem, 4.5vw, 1.65rem);
  word-break: break-word;
}
.page-hero .hero-sub {
  word-break: break-word;
}
.kingdoms-tabs {
  margin: 0 0 16px;
}
.kingdom-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.kingdom-toolbar-right {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}
.kingdom-search {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  flex: 1 1 22rem;
  min-width: 0;
  max-width: 100%;
}
.kingdom-search-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  min-width: 0;
  width: 100%;
}
.kingdom-search input {
  flex: 1 1 0;
  width: 0;
  max-width: 320px;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  line-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--panel-edge);
  background: var(--bg0);
  color: var(--text);
  font: inherit;
}
.kingdom-search-actions {
  display: flex;
  flex-wrap: nowrap;
  flex: 0 0 auto;
  gap: 8px;
  align-items: center;
}
.kingdom-search-actions > button {
  flex: 0 0 auto;
  height: 44px;
  min-height: 44px;
  padding: 0 14px;
  white-space: nowrap;
}
.kingdom-search-actions > button[hidden] {
  display: none !important;
}
.kingdom-search-hint {
  margin: 6px 2px 0;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--muted);
}
.kingdom-search input:focus {
  outline: none;
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.kingdom-page-size {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}
.kd-sort-dir {
  height: 40px;
  min-width: 3.6rem;
  padding: 0 10px;
  flex: 0 0 auto;
  border-radius: 10px;
  border: 1px solid var(--panel-edge);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  cursor: pointer;
  line-height: 1;
}
.kd-sort-dir:hover {
  border-color: var(--accent);
}
.back-to-top {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 40;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--panel-edge);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  align-items: center;
  justify-content: center;
}
.back-to-top:not([hidden]) {
  display: inline-flex;
}
.back-to-top[hidden] {
  display: none !important;
}
.back-to-top:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.kingdom-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  margin: 0 0 14px;
}
.kingdom-range-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.kingdom-filter-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-right: 2px;
  white-space: nowrap;
}
.kd-range-chip {
  border: 1px solid var(--panel-edge);
  background: var(--chip);
  color: var(--text);
  border-radius: 999px;
  padding: 5px 10px;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}
.kd-range-chip:hover {
  border-color: var(--accent-dim);
}
.kd-range-chip.active {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 700;
}
.kingdom-sort select {
  min-width: 9.5rem;
}
.kingdom-count-filter {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  min-width: 0;
}
.kingdom-count-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
}
.kingdom-count-filter input {
  width: 4.8rem;
  min-width: 0;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid var(--panel-edge);
  background: var(--bg0);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
}
.kingdom-count-sep {
  color: var(--muted);
}
.kingdom-page-size select {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--panel-edge);
  background: var(--bg0);
  color: var(--text);
  font: inherit;
}
.kd-ranks-sub {
  margin: 0;
  max-width: 42rem;
}
.kd-rank-kind-tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 14px;
  border: 0;
  background: transparent;
}
.kd-rank-kind-tabs .tab {
  flex: 0 1 auto;
  min-width: 7.5rem;
  border: 1px solid var(--panel-edge);
  border-radius: 999px;
  padding: 8px 16px;
  background: var(--panel);
  color: var(--muted);
  font-weight: 700;
}
.kd-rank-kind-tabs .tab.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-glow);
  border-bottom-color: var(--accent);
}
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin: 18px 0 8px;
}
.pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.kingdom-rank-list {
  max-width: 920px;
}
.kingdom-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 12px;
}
@media (max-width: 640px) {
  .kingdom-search input {
    max-width: none;
    width: 0;
  }
  .kingdom-toolbar-right {
    width: 100%;
    justify-content: space-between;
  }
}
.kingdom-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--panel-edge);
  background: var(--panel);
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  transition: transform 0.14s, border-color 0.14s, box-shadow 0.14s;
  overflow: visible;
}
.kingdom-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}
.kingdom-card::after {
  display: none;
}
.kingdom-card-top {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 12px;
}
.k-flag {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  border-radius: 12px;
  overflow: hidden;
  line-height: 1;
  background: var(--inset);
  border: 1px solid var(--panel-edge);
}
.k-flag-gen {
  display: grid;
  place-items: center;
  background:
    radial-gradient(120% 90% at 12% 0%, hsl(var(--h, 210) 70% 48% / 0.35), transparent 52%),
    linear-gradient(160deg, hsl(var(--h, 210) 42% 32%), hsl(var(--h, 210) 48% 14%));
  color: #fff;
  font-weight: 800;
  font-size: 1.02rem;
  letter-spacing: -0.04em;
  border-color: hsl(var(--h, 210) 40% 38% / 0.55);
}
.k-flag-gen span { line-height: 1; }
.k-flag-empty {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--muted);
}
.letter-av {
  display: grid;
  place-items: center;
  align-content: center;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  border-radius: inherit;
  overflow: hidden;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #fff;
  text-align: center;
  background: linear-gradient(160deg, hsl(var(--h, 210) 42% 40%), hsl(var(--h, 210) 50% 18%));
}
.kingdom-card .k-head {
  min-width: 0;
}
.kingdom-card h3 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.2;
}
.kingdom-card .k-rank {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.grade-badge {
  min-width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 1.1rem;
  border: 1px solid var(--panel-edge);
  background: var(--chip);
}
.grade-badge.elite { color: #f5d76e; border-color: rgba(245, 215, 110, 0.45); background: rgba(245, 215, 110, 0.1); }
.grade-badge.strong { color: var(--ok); border-color: rgba(94, 211, 154, 0.4); background: rgba(94, 211, 154, 0.1); }
.grade-badge.stable {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--panel-edge));
  background: var(--accent-glow);
}
.grade-badge.average { color: var(--ember); border-color: rgba(224, 160, 74, 0.35); background: rgba(224, 160, 74, 0.1); }
.grade-badge.soft { color: var(--warn); border-color: rgba(224, 176, 74, 0.35); background: rgba(224, 176, 74, 0.08); }
.grade-badge.quiet,
.grade-badge.empty { color: var(--muted); }
.grade-badge.pending {
  color: var(--ember);
  border-color: rgba(224, 160, 74, 0.4);
  background: rgba(224, 160, 74, 0.1);
}

.k-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.k-pulse {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  padding: 10px 12px;
  background: var(--inset);
  border-radius: 10px;
}
.k-pulse > div {
  min-width: 0;
}
.k-pulse .k-pulse-wide {
  grid-column: 1 / -1;
  padding-top: 8px;
  margin-top: 2px;
  border-top: 1px solid var(--panel-edge);
}
.k-pulse b {
  display: block;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}
.k-pulse span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 2px;
}
.k-power {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
}
.k-power-head {
  grid-column: 1 / -1;
  margin: 4px 0 2px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.k-kv {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 0 8px;
  border-bottom: 1px solid color-mix(in srgb, var(--panel-edge) 70%, transparent);
  min-width: 0;
}
.k-kv span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}
.k-kv b {
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
  line-height: 1.25;
}
.k-stat {
  background: var(--inset);
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 0;
  overflow: visible;
}
.k-stat b {
  display: block;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  white-space: normal;
  overflow: visible;
  word-break: break-word;
}
.k-stat span {
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: none;
  letter-spacing: 0.01em;
  font-weight: 650;
  line-height: 1.2;
}
.k-stat small {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.85;
}
.k-health-label {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}
.k-health-label strong { color: var(--text); }

.kingdom-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 2px;
  position: relative;
  z-index: 1;
}
.kingdom-card-map {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-edge);
  background: var(--accent-glow);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.kingdom-card-map:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, var(--panel));
  color: var(--accent);
}
.kingdom-card-title {
  color: inherit;
  text-decoration: none;
}
.kingdom-card-title:hover {
  color: var(--accent);
}
.kingdom-card-open {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--panel-edge);
  background: var(--inset);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.kingdom-card-open:hover {
  color: var(--text);
  border-color: var(--accent-dim);
}

.kingdom-detail-hero { align-items: flex-start; }
.kingdom-detail-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 14px;
  align-items: flex-start;
  flex: 1;
  min-width: 0;
}
.kingdom-detail-head > div:not(.grade-badge) {
  flex: 1 1 12rem;
  min-width: 0;
}
.kingdom-detail-head .chip-row {
  justify-content: flex-start;
}

/* —— Kingdom detail (pleasant layout) —— */
.kd-hero {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 16px;
}
.kd-hero > .icon-btn.back {
  flex: 0 0 auto;
}
.kd-hero-body {
  flex: 1 1 16rem;
  min-width: 0;
  width: 100%;
  padding: 18px 18px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--panel-edge);
  background: var(--hero-grad);
  box-shadow: var(--shadow);
}
.kd-identity {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  margin-bottom: 16px;
}
.kd-identity .eyebrow {
  margin: 4px 0 0;
}
.kd-identity h1 {
  margin: 0;
  font-size: clamp(1.35rem, 4vw, 1.85rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.kd-rule {
  margin: 0 0 6px;
  font-weight: 700;
  color: var(--ember);
  font-size: 0.95rem;
}
.kd-banner {
  width: min(112px, 42vw);
  margin: 0 auto;
  border-radius: 12px;
  overflow: hidden;
  line-height: 1;
}
.kd-banner .k-flag {
  width: 100%;
  height: min(112px, 42vw);
  border-radius: 12px;
}
.kd-people {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 6px 0 0;
}
.kd-person {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  border: 1px solid var(--panel-edge);
  background: var(--panel);
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.kd-person:hover { border-color: var(--accent); }
.kd-person.is-king {
  border-color: color-mix(in srgb, #c9a227 55%, var(--panel-edge));
  background: color-mix(in srgb, #c9a227 14%, var(--panel));
}
.kd-person.is-alliance { border-color: color-mix(in srgb, var(--accent) 40%, var(--panel-edge)); }
.kd-person-av {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--inset);
  flex-shrink: 0;
  font-weight: 800;
}
.kd-person-av img,
.kd-person-av .al-flag {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.kd-person-copy { display: flex; flex-direction: column; min-width: 0; }
.kd-person-role {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.kd-person.is-king .kd-person-role { color: #f3d48a; }
.kd-person strong {
  font-size: 0.9rem;
  line-height: 1.15;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.al-flag,
.kd-court-flag,
.gov-alliance-flag,
.alliance-flag-img,
.legend-flag {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.al-flag.letter,
.kd-court-flag.letter,
.gov-alliance-flag.letter,
.letter-av.al-flag,
.letter-av.gov-alliance-flag,
.letter-av.alliance-flag-img {
  display: grid;
  place-items: center;
  align-content: center;
  line-height: 1;
  overflow: hidden;
  font-weight: 800;
}
.gov-alliance-flag {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  flex-shrink: 0;
  background: var(--inset);
  border: 1px solid var(--panel-edge);
}
.alliance-flag .letter-av,
.alliance-flag-img.letter-av {
  width: 100%;
  height: 100%;
  border-radius: 18px;
  font-size: 2.4rem;
}
.lb-av.al {
  background: var(--inset);
  overflow: hidden;
}
.legend-flag {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  flex-shrink: 0;
}
.kd-map-btn {
  flex-shrink: 0;
  margin-top: 8px;
  width: min(100%, 22rem);
  justify-content: center;
}
.kd-hero-visual {
  display: block;
  min-width: 0;
}
.kd-hive-link {
  position: relative;
  display: block;
  width: 280px;
  height: 280px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--panel-edge);
  background: var(--inset-strong);
  text-decoration: none;
}
.kd-hive-link canvas {
  display: block;
  width: 280px;
  height: 280px;
}
.kd-hive-label,
.kd-hive-empty {
  position: absolute;
  left: 10px;
  right: 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  pointer-events: none;
}
.kd-hive-label {
  bottom: 8px;
  color: var(--faint);
}
.kd-hive-empty {
  top: 50%;
  transform: translateY(-50%);
  text-align: center;
  color: var(--muted);
}
[data-theme="light"] .kd-hive-link {
  background: #d8e0ec;
}
[data-theme="light"] .kd-hive-label {
  color: var(--muted);
}
.kd-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 8px;
}
.kd-board-totals-head {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 6px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--panel-edge);
}
.kd-board-totals-head strong {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.kd-board-totals-head span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 650;
  text-transform: none;
  letter-spacing: 0;
}
.kd-stat {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--inset);
  border: 1px solid var(--panel-edge);
  min-width: 0;
}
.kd-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.kd-stat-split span {
  text-transform: none;
  letter-spacing: 0.01em;
  font-weight: 650;
  line-height: 1.2;
  white-space: normal;
}
.kd-stat-period {
  display: block;
  margin-top: 2px;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.9;
}
.kd-stat b {
  display: block;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  overflow: visible;
  text-overflow: unset;
  white-space: normal;
  line-height: 1.25;
  word-break: break-word;
}
.kd-story {
  padding: 14px 16px 12px;
  margin-bottom: 14px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--panel-edge);
}
.kd-story .health-bar-wrap { margin: 0 0 12px; }
.kd-pyramid-copy {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: baseline;
  margin-bottom: 10px;
}
.kd-pyramid-copy strong { font-size: 0.98rem; }
.kd-pyramid-copy span { color: var(--muted); font-size: 0.85rem; }
.kd-shares { display: grid; gap: 7px; }
.kd-share {
  display: grid;
  grid-template-columns: 4.2rem 1fr 3.2rem;
  gap: 8px;
  align-items: center;
  font-size: 0.8rem;
}
.kd-share-lab { color: var(--muted); font-weight: 700; }
.kd-share-track {
  height: 8px;
  border-radius: 999px;
  background: var(--chip);
  overflow: hidden;
  border: 1px solid var(--panel-edge);
}
.kd-share-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--ember), var(--accent));
}
.kd-share-pct {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}
.kd-tg-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.kd-tg-pill {
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--panel2);
  border: 1px solid var(--panel-edge);
  font-size: 0.75rem;
  color: var(--muted);
}
.kd-tg-pill b { color: var(--text); }
.kd-section-title {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}
.kd-more {
  margin-bottom: 16px;
  padding: 14px 14px 12px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--panel-edge);
}
.kd-more-tabs {
  margin: 0 0 16px;
  padding: 5px;
  flex-wrap: wrap;
  gap: 4px;
  border: 1px solid var(--panel-edge);
  border-radius: 14px;
  background: var(--inset-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
.kd-more-tabs .kd-tab {
  position: relative;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
  letter-spacing: 0.01em;
  line-height: 1.2;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.kd-more-tabs .kd-tab-short {
  display: none;
}
.kd-more-tabs .kd-tab:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 7%, transparent);
}
.kd-more-tabs .kd-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.kd-more-tabs .kd-tab.active {
  color: #fff;
  border-color: transparent;
  transform: translateY(-1px);
}
.kd-more-tabs .kd-tab.active:hover {
  color: #fff;
  filter: brightness(1.06);
}
.kd-more-tabs .kd-tab[data-more="kvk"].active {
  background: linear-gradient(180deg, #f0b25c 0%, #c47a22 100%);
  box-shadow: 0 6px 16px rgba(224, 160, 74, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.kd-more-tabs .kd-tab[data-more="momentum"].active {
  background: linear-gradient(180deg, #4ee0a4 0%, #1fa86a 100%);
  box-shadow: 0 6px 16px rgba(62, 207, 142, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.kd-more-tabs .kd-tab[data-more="throne"].active {
  background: linear-gradient(180deg, #e06a5c 0%, #b43c34 100%);
  box-shadow: 0 6px 16px rgba(224, 106, 92, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.24);
}
.kd-more-tabs .kd-tab[data-more="appoint"].active {
  background: linear-gradient(180deg, #7aa4f5 0%, #3d6fd4 100%);
  box-shadow: 0 6px 16px rgba(91, 141, 239, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.kd-more-tabs .kd-tab[data-more="rankings"].active {
  background: linear-gradient(180deg, #b28cff 0%, #6d4fd6 100%);
  box-shadow: 0 6px 16px rgba(140, 110, 230, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.kd-more-tabs .kd-tab[data-more="events"].active {
  background: linear-gradient(180deg, #4fd0e0 0%, #1f8fa8 100%);
  box-shadow: 0 6px 16px rgba(64, 196, 214, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.kd-more-tabs .kd-tab[data-more="kvk"]:not(.active):hover { color: #f0b25c; }
.kd-more-tabs .kd-tab[data-more="momentum"]:not(.active):hover { color: #4ee0a4; }
.kd-more-tabs .kd-tab[data-more="throne"]:not(.active):hover { color: #e06a5c; }
.kd-more-tabs .kd-tab[data-more="appoint"]:not(.active):hover { color: #7aa4f5; }
.kd-more-tabs .kd-tab[data-more="rankings"]:not(.active):hover { color: #b28cff; }
.kd-more-tabs .kd-tab[data-more="events"]:not(.active):hover { color: #4fd0e0; }
.kd-more-pane { min-height: 80px; }
.kd-more-pane.kd-appoint {
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
}
.kd-rank-board-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 12px;
  padding: 10px 10px 8px;
  border-radius: 12px;
  background: var(--inset);
  border: 1px solid var(--panel-edge);
}
.kd-rank-board-label {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.kd-rank-type-tabs {
  margin: 0;
  flex-wrap: wrap;
  gap: 5px;
}
.kd-rank-type-tabs .kd-tab {
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.kd-rank-type-tabs .kd-tab.is-empty {
  opacity: 0.55;
}
.kd-rank-type-tabs .kd-tab.active {
  color: var(--text);
  background: var(--panel);
  border-color: var(--panel-edge);
  box-shadow: none;
}
.kd-events-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 18px 4px;
}
.kd-events-loading[hidden] {
  display: none !important;
}
.kd-event-cat {
  margin: 0 0 18px;
}
.kd-event-cat:last-child {
  margin-bottom: 0;
}
.kd-event-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kd-event-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--inset);
  border: 1px solid var(--panel-edge);
  min-width: 0;
}
.kd-event-main {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  min-width: 0;
  flex: 1 1 auto;
}
.kd-event-name {
  font-weight: 700;
  color: var(--text);
  min-width: 0;
  overflow-wrap: anywhere;
}
.kd-event-badge {
  flex: 0 0 auto;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.2;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.kd-event-badge--running {
  color: var(--ok);
  background: color-mix(in srgb, var(--ok) 16%, transparent);
  border-color: color-mix(in srgb, var(--ok) 38%, transparent);
}
.kd-event-badge--ending {
  color: #ff8a5c;
  background: color-mix(in srgb, #ff8a5c 16%, transparent);
  border-color: color-mix(in srgb, #ff8a5c 42%, transparent);
  animation: kd-event-pulse 1.6s ease-in-out infinite;
}
.kd-event-badge--soon {
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 16%, transparent);
  border-color: color-mix(in srgb, var(--warn) 40%, transparent);
}
.kd-event-badge--upcoming {
  color: var(--accent);
  background: var(--accent-glow);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}
.kd-event-badge--ended {
  color: var(--muted);
  background: color-mix(in srgb, var(--muted) 12%, transparent);
  border-color: var(--panel-edge);
}
.kd-event-row--running {
  border-color: color-mix(in srgb, var(--ok) 28%, var(--panel-edge));
}
.kd-event-row--ending {
  border-color: color-mix(in srgb, #ff8a5c 36%, var(--panel-edge));
}
.kd-event-row--soon {
  border-color: color-mix(in srgb, var(--warn) 32%, var(--panel-edge));
}
.kd-event-row--ended {
  opacity: 0.72;
}
@keyframes kd-event-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.72; }
}
@media (prefers-reduced-motion: reduce) {
  .kd-event-badge--ending { animation: none; }
  .kd-more-tabs .kd-tab,
  .kd-more-tabs .kd-tab.active { transform: none; transition: none; }
}
.kd-event-when {
  color: var(--muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex: 0 0 auto;
  text-align: right;
}
.kd-appoint {
  margin-bottom: 16px;
  padding: 14px 14px 12px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--panel-edge);
}
.kd-appoint-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}
.kd-appoint-status {
  color: var(--ember);
  font-size: 0.8rem;
  font-weight: 700;
}
.kd-appoint-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.kd-ap-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 10px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-edge);
  background: var(--panel2);
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: center;
}
.kd-ap-card:hover:not(.is-vacant) { border-color: var(--accent); }
.kd-ap-card.is-vacant { cursor: default; opacity: 0.72; }
.kd-ap-role {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.kd-ap-office {
  width: 28px;
  height: 28px;
  object-fit: contain;
}
.kd-ap-face {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--inset);
}
.kd-ap-face img { width: 100%; height: 100%; object-fit: cover; }
.kd-ap-face.vacant img { object-fit: contain; padding: 8px; }
.kd-ap-card strong {
  font-size: 0.82rem;
  line-height: 1.25;
  max-width: 100%;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.kd-ap-time {
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ember);
}
.kd-court {
  margin-bottom: 14px;
}
.kd-court-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.kd-court-card {
  display: grid;
  grid-template-columns: 48px 1fr;
  grid-template-rows: auto auto auto;
  column-gap: 10px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-edge);
  background: var(--panel);
  color: inherit;
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.12s, transform 0.12s;
}
.kd-court-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.kd-court-icon {
  grid-row: 1 / span 3;
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 12px;
  align-self: center;
}
.kd-court-icon.face,
.kd-court-icon.hive {
  display: grid;
  place-items: center;
  background: var(--inset);
  border: 1px solid var(--panel-edge);
  overflow: hidden;
  font-size: 1.1rem;
}
.kd-court-icon.face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.kd-court-role {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.kd-court-card.kind-sovereign .kd-court-role { color: #f3d48a; }
.kd-court-card.kind-alliance .kd-court-role { color: var(--accent); }
.kd-court-card strong {
  font-size: 0.95rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kd-court-meta {
  color: var(--muted);
  font-size: 0.78rem;
}
.kd-week {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--panel-edge);
}
.kd-week-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.kd-week-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding: 8px 12px 8px 8px;
  border-radius: 999px;
  border: 1px solid var(--panel-edge);
  background: var(--panel2);
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.kd-week-chip:hover { border-color: var(--accent); }
.kd-week-av {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--inset);
  font-size: 0.75rem;
  font-weight: 800;
}
.kd-week-av img { width: 100%; height: 100%; object-fit: cover; }
.kd-week-chip b { display: block; font-size: 0.85rem; }
.kd-week-chip span span { color: var(--muted); font-size: 0.72rem; }
.kd-momentum {
  margin-bottom: 16px;
  padding: 14px 14px 12px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--panel-edge);
}
.kd-mom-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.kd-mom-head .kd-section-title { margin: 0; }
.kd-mom-head .kd-tabs { margin: 0; }
.kd-mom-tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0 4px;
}
.kd-kvk-tiles {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.kd-mom-tiles .kd-stat em {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 600;
}
.kd-mom-gain { color: var(--ok); font-variant-numeric: tabular-nums; }
.kd-mom-delta {
  color: var(--ember);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.kd-mom-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 8px;
}
.kd-mom-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.kd-mom-table th {
  text-align: left;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 8px;
  border-bottom: 1px solid var(--panel-edge);
}
.kd-mom-table td {
  padding: 8px;
  border-bottom: 1px solid var(--panel-edge);
  vertical-align: middle;
}
.kd-mom-table tr[data-uid] { cursor: pointer; }
.kd-mom-table tr[data-uid]:hover td { background: var(--panel2); }
.kd-mom-table td:first-child {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.kd-mom-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}
.kd-throne {
  margin-bottom: 16px;
  padding: 14px 14px 12px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--panel-edge);
}
.kd-throne .kd-section-title { margin-top: 14px; }
.kd-throne .kd-section-title:first-child { margin-top: 0; }
.kd-throne-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.kd-throne-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-edge);
  background: var(--panel2);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.kd-throne-row:hover { border-color: var(--accent); }
.kd-throne-row.is-lost { border-left: 3px solid var(--danger); }
.kd-throne-row.is-won { border-left: 3px solid var(--ok); }
.kd-throne-row.is-held { border-left: 3px solid var(--accent); }
.kd-throne-row.is-high { border-left: 3px solid var(--ember); }
.kd-throne .kd-mom-note {
  margin: 8px 0 4px;
  color: var(--faint);
  font-size: 0.72rem;
}
.kd-throne-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.kd-throne-copy b { font-size: 0.88rem; }
.kd-throne-copy span { color: var(--muted); font-size: 0.75rem; }
.kd-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 4px;
}
.kd-tab {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--panel-edge);
  background: var(--panel2);
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}
.kd-tab.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-glow);
}
.kd-boards { margin-top: 2px; }
.health-bar-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: -4px 0 16px;
}
.health-bar {
  flex: 1;
  min-width: 0;
  height: 8px;
  border-radius: 999px;
  background: var(--chip);
  border: 1px solid var(--panel-edge);
  overflow: hidden;
}
.health-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.5s ease;
}

/* —— Responsive —— */
@media (max-width: 900px) {
  .home-grid { grid-template-columns: 1fr; }
  .site-header {
    align-items: stretch;
  }
  .header-right {
    width: 100%;
    justify-content: stretch;
  }
  .stats {
    min-width: 0;
    max-width: none;
    flex: 1;
  }
  .stat {
    min-width: 5.2rem;
  }
}

@media (max-width: 640px) {
  .wrap {
    padding: 14px 12px 64px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  .site-legal {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .site-header {
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 12px;
  }
  .logo {
    font-size: 1.2rem;
  }
  .nav {
    gap: 4px;
  }
  .nav a,
  .nav-btn {
    font-size: 0.82rem;
    padding: 6px 10px;
  }
  .header-right {
    width: 100%;
    justify-content: stretch;
  }
  .stats {
    min-width: 0;
    max-width: none;
    width: 100%;
    justify-content: stretch;
    gap: 5px;
  }
  .stat {
    padding: 6px 8px;
    flex: 1 1 calc(33.33% - 5px);
    min-width: 5rem;
  }
  .stat b {
    font-size: 0.85rem;
    line-height: 1.3;
  }
  .stat span {
    font-size: 0.55rem;
  }

  .panel {
    padding: 14px 12px;
  }
  .hero-banner {
    padding: 18px 14px;
    border-radius: 16px;
  }
  .hero-banner h1 {
    font-size: 1.4rem;
  }
  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .btn-ghost,
  .btn-glow {
    justify-content: center;
    text-align: center;
    width: 100%;
  }
  .patreon-invite,
  .discord-invite {
    flex-wrap: wrap;
    padding: 14px 12px;
  }
  .patreon-invite-btn,
  .discord-invite-btn {
    width: 100%;
    text-align: center;
  }

  .search-row {
    flex-direction: column;
    align-items: stretch;
  }
  .search-row input[type="search"],
  .search-row input[type="text"] {
    flex: 0 0 auto;
    height: 44px;
    min-height: 44px;
    max-height: 44px;
  }
  .search-row button,
  #btnSearch {
    width: 100%;
    min-height: 44px;
  }
  .deep-search-box {
    flex-direction: column;
    align-items: stretch;
  }
  .btn-deep {
    width: 100%;
  }

  .section-head {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .hero-card { display: flex; flex-direction: column; }
  .hero-top { grid-template-columns: 72px minmax(0, 1fr); gap: 10px; }
  .hero-portrait { max-width: 72px; }
  .hero-star-line {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .hero-star-row { width: 100%; justify-content: flex-start; }
  .hero-widget { align-self: flex-start; }
  .admin-stats { grid-template-columns: repeat(2, 1fr); }
  .ops-grid,
  .ops-grid-3 { grid-template-columns: 1fr; }
  .ops-kv { grid-template-columns: 1fr; }

  .card {
    grid-template-columns: auto 1fr;
    gap: 10px;
    padding: 10px 12px;
  }
  .card > .meta:last-child { display: none; }

  .lb-row-item {
    grid-template-columns: 2.5rem 32px minmax(0, 1fr) auto;
    gap: 8px;
    padding: 8px;
  }
  .lb-av {
    width: 32px;
    height: 32px;
    border-radius: 9px;
  }
  .lb-power {
    font-size: 0.85rem;
  }
  .lb-name {
    font-size: 0.92rem;
    overflow-wrap: anywhere;
  }
  .lb-meta-line {
    overflow-wrap: anywhere;
  }

  .profile-hero,
  .gov-banner {
    padding: 10px 10px 10px;
  }
  .gov-banner-toolbar {
    padding: 0;
    flex-direction: column;
    align-items: center;
  }
  .gov-banner-main {
    flex-direction: column;
    align-items: center;
    flex: 0 1 auto;
  }
  .gov-portrait {
    align-self: center;
  }
  .gov-identity {
    flex: 0 1 auto;
    width: 100%;
    text-align: center;
  }
  .gov-updated {
    font-size: 0.7rem;
    white-space: nowrap;
  }
  .gov-refresh-panel {
    margin-left: 0;
    width: auto;
  }
  .gov-hero-strip {
    padding-left: 0;
    flex-wrap: nowrap;
    gap: 6px;
    margin-top: 8px;
  }
  .gov-alliance-card {
    flex: 1 1 auto;
    padding: 7px 8px;
  }
  .gov-hero-strip .btn-refresh {
    width: auto;
    min-width: 56px;
    flex: 0 0 auto;
    height: auto;
    max-width: none;
    flex-direction: column;
    gap: 1px;
    padding: 6px 8px;
  }
  .profile-sync-bar {
    padding: 8px 12px 10px;
  }
  .profile-sync-copy {
    flex-direction: column;
    gap: 1px;
  }
  .profile-sync-copy strong,
  .profile-sync-copy span {
    overflow-wrap: anywhere;
  }
  .gov-facts {
    grid-template-columns: 1fr 1fr;
  }
  .gov-fact {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 8px 10px;
  }
  .gov-fact .v {
    text-align: left;
  }
  .gov-stat-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .gov-stat span {
    letter-spacing: 0.04em;
    overflow-wrap: anywhere;
    line-height: 1.2;
  }
  .gov-name,
  .profile-name {
    font-size: 1.25rem;
    overflow-wrap: anywhere;
  }
  .lord-gear-rack {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  }
  .skin-row {
    padding: 10px 12px;
  }
  .heroes-grid {
    grid-template-columns: 1fr;
  }
  .chip-row {
    gap: 5px;
  }
  .chip {
    font-size: 0.72rem;
    padding: 3px 8px;
  }
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab {
    flex: 0 0 auto;
    padding: 12px 14px;
    font-size: 0.85rem;
  }
  .tab-body {
    padding: 12px;
  }

  .ov-grid {
    grid-template-columns: 1fr;
  }
  .member-head {
    flex-wrap: wrap;
    gap: 8px;
  }

  .page-hero {
    gap: 10px;
  }
  .kingdom-detail-head {
    width: 100%;
  }
  .kingdom-detail-head .btn-ghost {
    width: 100%;
  }
  .kd-hero {
    flex-direction: column;
  }
  .kd-hero-body { padding: 14px 12px; }
  .kd-banner { width: min(104px, 38vw); }
  .kd-stat-grid {
    width: 100%;
    grid-template-columns: repeat(3, 1fr);
  }
  .kd-stat { padding: 8px; }
  .kd-stat b { font-size: 0.92rem; }
  .kd-mom-tiles { grid-template-columns: 1fr 1fr; }
  .kd-kvk-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kd-map-btn { width: 100%; justify-content: center; }
  .kd-share {
    grid-template-columns: 3.6rem 1fr 2.8rem;
  }
  .kd-court-grid {
    grid-template-columns: 1fr;
  }
  .kd-more-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    overflow: visible;
    padding: 4px;
  }
  .kd-more-tabs .kd-tab {
    width: 100%;
    min-width: 0;
    white-space: nowrap;
    padding: 9px 4px;
    font-size: 0.72rem;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .kd-more-tabs .kd-tab-full {
    display: none;
  }
  .kd-more-tabs .kd-tab-short {
    display: inline;
  }
  .kd-event-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 10px;
  }
  .kd-event-when {
    white-space: normal;
    text-align: left;
  }
  .kingdom-grid {
    grid-template-columns: 1fr;
  }
  .kingdom-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .kingdom-filters {
    flex-direction: column;
    align-items: stretch;
  }
  .kingdom-count-filter {
    width: 100%;
  }
  .kingdom-count-inputs {
    width: 100%;
  }
  .kingdom-count-filter input {
    flex: 1 1 0;
    width: auto;
    max-width: none;
  }
  .kingdom-filter-label {
    white-space: normal;
    line-height: 1.25;
  }
  .kingdom-search {
    width: 100%;
    flex-basis: 100%;
  }
  .kingdom-search input {
    max-width: none;
    min-width: 0;
    width: 0;
  }
  .kingdom-search-actions > button {
    padding: 0 12px;
    font-size: 0.85rem;
  }
  .kingdom-toolbar-right {
    width: 100%;
    justify-content: space-between;
  }
  .kingdoms-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .kingdoms-tabs .tab {
    flex: 1 1 auto;
    text-align: center;
  }
  .kd-rank-kind-tabs {
    width: 100%;
  }
  .kd-rank-kind-tabs .tab {
    flex: 1 1 0;
    min-width: 0;
    text-align: center;
  }
  .pagination {
    gap: 8px;
  }
  .pagination button {
    flex: 1 1 auto;
    min-width: 0;
  }

  .alliance-hero-refresh {
    top: 8px;
    right: 8px;
  }

  .member-row {
    grid-template-columns: 1fr auto;
    gap: 8px;
  }
  .health-bar-wrap {
    flex-wrap: wrap;
  }
  .health-bar-wrap .meta {
    width: 100%;
  }

  .crawl-controls {
    flex-direction: column;
    align-items: stretch;
  }
  .crawl-field,
  .crawl-field-sm {
    max-width: none;
    min-width: 0;
    width: 100%;
  }
}

@media (max-width: 400px) {
  .stats {
    grid-template-columns: 1fr 1fr 1fr;
  }
  .stat b {
    font-size: 0.88rem;
  }
  .lb-row-item {
    grid-template-columns: 2.2rem 28px minmax(0, 1fr) auto;
  }
  .lb-row-item .lb-av {
    display: grid;
    width: 28px;
    height: 28px;
    border-radius: 8px;
  }
}

/* Light theme: never use pale-on-white / white-on-white text */
[data-theme="light"] .nav a,
[data-theme="light"] .nav-btn {
  color: #3a4250;
}
[data-theme="light"] .nav a.active,
[data-theme="light"] .nav-btn.active,
[data-theme="light"] .nav a:hover,
[data-theme="light"] .nav-btn:hover {
  color: #151921;
}
[data-theme="light"] .stat span,
[data-theme="light"] .meta,
[data-theme="light"] .lb-meta-line,
[data-theme="light"] .hero-stats-text .k,
[data-theme="light"] .gear-heading,
[data-theme="light"] .lb-rank {
  color: #4a5363;
}
[data-theme="light"] .danger-hint {
  color: #b42318;
}
[data-theme="light"] .gov-fact .v.warn {
  color: #b42318;
}
[data-theme="light"] .badge.ok { color: #157347; }
[data-theme="light"] .crawler-bar-name,
[data-theme="light"] .crawler-bar-kid,
[data-theme="light"] .crawl-stat b,
[data-theme="light"] .crawl-hist td {
  color: #151921;
}
[data-theme="light"] .crawler-bar-node,
[data-theme="light"] .crawler-bar-speed,
[data-theme="light"] .crawl-stat span {
  color: #3a4250;
}
[data-theme="light"] .crawler-bar-track {
  background: #e6e9ef;
}

/* —— 404 page —— */
.page-404 {
  margin: 28px 0 40px;
  padding: 28px 24px 32px;
  border-radius: var(--radius);
  background: var(--hero-grad);
  border: 1px solid var(--panel-edge);
  box-shadow: var(--shadow);
}
.page-404 h1 {
  margin: 0 0 10px;
  font-size: clamp(1.6rem, 3.4vw, 2.15rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
  font-weight: 750;
}
.page-404 .btn-glow {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
@media (max-width: 640px) {
  .page-404 {
    margin-top: 16px;
    padding: 22px 16px 24px;
  }
}

/* —— Blog —— */
.blog-index {
  display: grid;
  gap: 12px;
}
.blog-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.15s;
}
.blog-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.blog-card-date,
.blog-meta {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--faint);
}
.blog-card h2 {
  margin: 0 0 8px;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  line-height: 1.3;
}
.blog-card-desc {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.94rem;
}
.blog-card-more {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--accent);
}
.blog-article {
  max-width: 46rem;
}
.blog-crumb {
  margin: 0 0 10px;
  font-size: 0.86rem;
  font-weight: 650;
}
.blog-crumb a {
  color: var(--accent);
  text-decoration: none;
}
.blog-crumb a:hover {
  text-decoration: underline;
}
.blog-hero h1 {
  margin: 0 0 10px;
  font-size: clamp(1.4rem, 3.2vw, 1.9rem);
  letter-spacing: -0.03em;
  line-height: 1.2;
  font-weight: 750;
}
.blog-hero .hero-sub {
  max-width: none;
  margin-bottom: 8px;
}
.blog-body {
  margin-top: 18px;
  font-size: 1.02rem;
  line-height: 1.65;
  color: var(--text);
}
.blog-body > *:first-child {
  margin-top: 0;
}
.blog-body h2 {
  margin: 1.7rem 0 0.55rem;
  font-size: 1.22rem;
  letter-spacing: -0.02em;
  line-height: 1.3;
}
.blog-body h3 {
  margin: 1.35rem 0 0.45rem;
  font-size: 1.05rem;
}
.blog-body p {
  margin: 0 0 0.9rem;
}
.blog-body ul,
.blog-body ol {
  margin: 0 0 0.95rem;
  padding-left: 1.3rem;
}
.blog-body li {
  margin: 0.2rem 0;
}
.blog-body hr {
  border: 0;
  border-top: 1px solid var(--panel-edge);
  margin: 1.6rem 0;
}
.blog-body strong {
  font-weight: 700;
}
.blog-body a {
  color: var(--accent);
}
.blog-body code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--chip);
  padding: 0.12em 0.38em;
  border-radius: 4px;
}
.blog-body pre {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  overflow-x: auto;
  margin: 0 0 1rem;
}
.blog-body pre code {
  background: none;
  padding: 0;
  font-size: 0.86rem;
  line-height: 1.5;
}
.blog-table-wrap {
  overflow-x: auto;
  margin: 0 0 1.1rem;
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius-sm);
  background: var(--panel);
}
.blog-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  line-height: 1.4;
}
.blog-body th,
.blog-body td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--panel-edge);
  vertical-align: top;
}
.blog-body th {
  background: var(--panel2);
  font-weight: 700;
  white-space: nowrap;
}
.blog-body tr:last-child td {
  border-bottom: 0;
}
.legal-article h1 {
  margin: 0 0 14px;
  font-size: clamp(1.4rem, 3.2vw, 1.9rem);
  letter-spacing: -0.03em;
  line-height: 1.2;
  font-weight: 750;
}
