:root {
  --bg-deep: #070b14;
  --bg-surface: rgba(12, 20, 38, 0.36);
  --bg-surface-solid: #10182c;
  --bg-hover: rgba(24, 40, 72, 0.52);
  --border-glass: rgba(255, 255, 255, 0.24);
  --border-glow: rgba(125, 211, 252, 0.65);
  --text-main: #f8fafc;
  --text-muted: #cbd5e1;
  --azure: #38bdf8;
  --gold: #fbbf24;
  --emerald: #34d399;
  --rose: #fb7185;
  --violet: #c4b5fd;
  --radius: 14px;
  --shadow-card: 0 8px 28px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, -apple-system, sans-serif;
  background-color: var(--bg-deep);
  color: var(--text-main);
  line-height: 1.65;
  min-height: 100vh;
  overflow-x: hidden;
}

.starfield {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100lvh;
  z-index: -1;
  background-color: #070b14;
  background-image: url("bg-luruka.webp");
  background-size: cover;
  background-position: center 22%;
  background-repeat: no-repeat;
  transition: background 0.3s ease;
  overflow: hidden;
  transform: translateZ(0);
}

.bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 22%;
  pointer-events: none;
}

.starfield::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(7, 11, 20, 0.24) 0%, rgba(11, 19, 37, 0.36) 100%);
  pointer-events: none;
  transition: background 0.3s ease;
}

/* Crystal-clear transparent glass blocks (no frosted blur) for Luruka animated theme */
body:not(.theme-wiki-light) .panel,
body:not(.theme-wiki-light) .card,
body:not(.theme-wiki-light) .hero,
body:not(.theme-wiki-light) .char-card {
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.65);
}

body:not(.theme-wiki-light) .hero {
  background: linear-gradient(135deg, rgba(14, 24, 48, 0.38), rgba(10, 18, 36, 0.44));
}

body:not(.theme-wiki-light) .stat-pill,
body:not(.theme-wiki-light) .portal-card,
body:not(.theme-wiki-light) .wiki-item-card,
body:not(.theme-wiki-light) .guide-card,
body:not(.theme-wiki-light) .ach-card,
body:not(.theme-wiki-light) .code-btn,
body:not(.theme-wiki-light) .check-item,
body:not(.theme-wiki-light) .advice-item,
body:not(.theme-wiki-light) .ai-block,
body:not(.theme-wiki-light) .calc-result,
body:not(.theme-wiki-light) .sim-output {
  background: rgba(10, 18, 34, 0.36);
}

body:not(.theme-wiki-light) .topbar {
  background: rgba(7, 11, 20, 0.48);
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 12px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ai-top-btn {
  border: 1px solid rgba(56, 189, 248, 0.45);
  background: rgba(56, 189, 248, 0.14);
  color: #bae6fd;
}

.ai-top-btn:hover {
  background: rgba(56, 189, 248, 0.28);
  color: #fff;
}

body.has-custom-bg .starfield::after {
  background: rgba(7, 11, 20, 0.62);
}

body.theme-starlight .starfield {
  background-image:
    radial-gradient(circle at 15% 18%, rgba(56, 189, 248, 0.13), transparent 42%),
    radial-gradient(circle at 85% 12%, rgba(251, 191, 36, 0.09), transparent 38%),
    radial-gradient(circle at 50% 85%, rgba(167, 139, 250, 0.1), transparent 48%),
    linear-gradient(180deg, #070b14 0%, #0b1325 100%);
}
body.theme-starlight .starfield::after { background: transparent; }

body.theme-dawn .starfield {
  background-image:
    radial-gradient(circle at 20% 20%, rgba(56, 189, 248, 0.28), transparent 45%),
    radial-gradient(circle at 80% 75%, rgba(99, 102, 241, 0.25), transparent 50%),
    linear-gradient(160deg, #0d2137 0%, #153456 50%, #10203a 100%);
}
body.theme-dawn .starfield::after { background: transparent; }

body.theme-forest .starfield {
  background-image:
    radial-gradient(circle at 20% 20%, rgba(52, 211, 153, 0.22), transparent 45%),
    radial-gradient(circle at 80% 80%, rgba(16, 185, 129, 0.16), transparent 48%),
    linear-gradient(160deg, #061816 0%, #0c2a24 55%, #071412 100%);
}
body.theme-forest .starfield::after { background: transparent; }

body.theme-sakura .starfield {
  background-image:
    radial-gradient(circle at 20% 15%, rgba(244, 114, 182, 0.22), transparent 44%),
    radial-gradient(circle at 80% 80%, rgba(167, 139, 250, 0.22), transparent 48%),
    linear-gradient(160deg, #1a0d1f 0%, #261433 55%, #120b1c 100%);
}
body.theme-sakura .starfield::after { background: transparent; }

body.theme-amoled .starfield {
  background-image: none;
  background-color: #000000;
}
body.theme-amoled .starfield::after { background: transparent; }

/* BWIKI White / Light Theme */
body.theme-wiki-light {
  --bg-deep: #f4f7fb;
  --bg-surface: rgba(255, 255, 255, 0.94);
  --bg-surface-solid: #ffffff;
  --bg-hover: #eef5ff;
  --border-glass: rgba(15, 23, 42, 0.12);
  --border-glow: rgba(2, 132, 199, 0.45);
  --text-main: #0f172a;
  --text-muted: #475569;
  --azure: #0284c7;
  --gold: #b45309;
  --emerald: #047857;
  --rose: #be123c;
  --violet: #6d28d9;
  --shadow-card: 0 6px 20px rgba(15, 23, 42, 0.08);
}

body.theme-wiki-light .starfield {
  background-image: none;
  background-color: #f4f7fb;
}
body.theme-wiki-light .starfield::after { background: transparent; }
body.theme-wiki-light .topbar {
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid rgba(15, 23, 42, 0.1);
}
body.theme-wiki-light .hero {
  background: linear-gradient(135deg, #ffffff, #e8f3ff);
}
body.theme-wiki-light .hero h1 {
  background: linear-gradient(90deg, #0f172a, #0284c7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
body.theme-wiki-light .stat-pill,
body.theme-wiki-light .code-btn,
body.theme-wiki-light .check-item,
body.theme-wiki-light .advice-item,
body.theme-wiki-light .calc-result,
body.theme-wiki-light .sim-output,
body.theme-wiki-light .box-chip,
body.theme-wiki-light .ai-block,
body.theme-wiki-light .wiki-item-card,
body.theme-wiki-light .guide-card,
body.theme-wiki-light .portal-card,
body.theme-wiki-light .subtab-btn,
body.theme-wiki-light .layer-pill,
body.theme-wiki-light .map-detail-bar,
body.theme-wiki-light .search-input,
body.theme-wiki-light .filter-select,
body.theme-wiki-light .form-field input {
  background: #f8fafc;
  color: #0f172a;
}
body.theme-wiki-light .portal-title,
body.theme-wiki-light .char-summary,
body.theme-wiki-light .card p,
body.theme-wiki-light .card li {
  color: #1e293b !important;
}
body.theme-wiki-light .nav-btn.active,
body.theme-wiki-light .subtab-btn.active {
  color: #ffffff;
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
}
body.theme-wiki-light .tier-T0 { background: #fef3c7; color: #92400e; border-color: #f59e0b; }
body.theme-wiki-light .tier-T1 { background: #e0f2fe; color: #075985; border-color: #38bdf8; }
body.theme-wiki-light .tier-T2 { background: #f1f5f9; color: #334155; border-color: #94a3b8; }

.theme-trigger-btn {
  background: rgba(251, 191, 36, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.38);
  color: var(--gold);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.theme-trigger-btn:hover {
  background: rgba(251, 191, 36, 0.28);
}

.elem-calc-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.elem-matrix-table th, .elem-matrix-table td {
  text-align: center;
  padding: 8px 6px;
  font-size: 0.82rem;
}

.elem-cell-up { color: var(--emerald); font-weight: 800; background: rgba(52, 211, 153, 0.12); }
.elem-cell-down { color: var(--rose); font-weight: 700; background: rgba(251, 113, 133, 0.1); }
.elem-mini-icon { width: 18px; height: 18px; vertical-align: middle; margin-right: 3px; }

/* Achievements Tracker */
.ach-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 10px;
}

.ach-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(7, 11, 20, 0.62);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease;
  content-visibility: auto;
  contain-intrinsic-size: 300px 92px;
}

.ach-card:hover {
  border-color: var(--azure);
}

.ach-card.done {
  border-color: rgba(52, 211, 153, 0.45);
  background: rgba(52, 211, 153, 0.08);
}

.ach-card.done .ach-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.ach-card input {
  margin-top: 4px;
  width: 17px;
  height: 17px;
  accent-color: var(--emerald);
  flex-shrink: 0;
}

body.theme-wiki-light .ach-card {
  background: #f8fafc;
}
body.theme-wiki-light .ach-card.done {
  background: #ecfdf5;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(7, 11, 20, 0.55);
  border-bottom: 1px solid var(--border-glass);
}

.topbar-inner {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding-top: 10px;
  padding-bottom: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.brand-star {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--azure), #6366f1);
  color: #fff;
  font-size: 1.25rem;
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.4);
}

.brand-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  border: 1.5px solid rgba(56, 189, 248, 0.65);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.35);
  background: rgba(7, 11, 20, 0.8);
  transition: opacity 0.3s ease;
}

.brand-title {
  font-weight: 800;
  font-size: 1.08rem;
  letter-spacing: 0.02em;
}

.brand-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.nav-links {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.nav-links::-webkit-scrollbar {
  display: none;
}

.nav-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 7px 11px;
  border-radius: 999px;
  font-size: 0.87rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
}

.nav-btn.active {
  color: #070b14;
  background: linear-gradient(135deg, #7dd3fc, #38bdf8);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.35);
}

/* Main & Hero */
.main-content {
  padding-top: 28px;
  padding-bottom: 64px;
}

.hero {
  background: linear-gradient(135deg, rgba(20, 34, 66, 0.85), rgba(14, 22, 42, 0.92));
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  padding: 32px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.hero-badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--gold);
  background: rgba(251, 191, 36, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.35);
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.hero h1 {
  font-size: clamp(1.65rem, 3vw, 2.3rem);
  font-weight: 800;
  margin-bottom: 10px;
  background: linear-gradient(90deg, #ffffff, #bae6fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-desc {
  color: var(--text-muted);
  max-width: 780px;
  margin-bottom: 22px;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.stat-pill {
  background: rgba(7, 11, 20, 0.55);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.stat-val {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--azure);
}

/* Tabs */
.tab-panel {
  display: none;
  animation: fadeIn 0.24s ease;
}

.tab-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-header {
  margin-bottom: 20px;
}

.section-header h2 {
  font-size: 1.45rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.section-header p {
  color: var(--text-muted);
  font-size: 0.94rem;
}

.section-subheader {
  margin: 28px 0 14px;
}

/* Grids & Panels */
.card-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 24px;
}

.cols-2 {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.cols-3 {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.split-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
  margin-top: 12px;
}

.panel, .card {
  background: var(--bg-surface);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.panel-head h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-gold {
  background: rgba(251, 191, 36, 0.16);
  color: var(--gold);
  border: 1px solid rgba(251, 191, 36, 0.35);
}

.badge-azure {
  background: rgba(56, 189, 248, 0.16);
  color: var(--azure);
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.badge-emerald {
  background: rgba(52, 211, 153, 0.15);
  color: var(--emerald);
  border: 1px solid rgba(52, 211, 153, 0.35);
}

.badge-rose {
  background: rgba(251, 113, 133, 0.15);
  color: var(--rose);
  border: 1px solid rgba(251, 113, 133, 0.35);
}

.badge-violet {
  background: rgba(167, 139, 250, 0.16);
  color: var(--violet);
  border: 1px solid rgba(167, 139, 250, 0.35);
}

/* Tier & Element tags */
.tier-T0 { background: rgba(251, 191, 36, 0.2); color: #fde68a; border: 1px solid rgba(251, 191, 36, 0.5); }
.tier-T1 { background: rgba(56, 189, 248, 0.18); color: #bae6fd; border: 1px solid rgba(56, 189, 248, 0.45); }
.tier-T2 { background: rgba(148, 163, 184, 0.18); color: #cbd5e1; border: 1px solid rgba(148, 163, 184, 0.4); }

/* Redeem codes */
.codes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.code-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(7, 11, 20, 0.7);
  border: 1px dashed rgba(56, 189, 248, 0.4);
  color: var(--text-main);
  padding: 10px 12px;
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  transition: all 0.18s ease;
}

.code-btn:hover {
  border-color: var(--gold);
  background: rgba(251, 191, 36, 0.1);
}

.code-copy-icon {
  font-size: 0.75rem;
  color: var(--azure);
}

/* Checklist */
.checklist {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(7, 11, 20, 0.5);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.check-item:hover {
  border-color: var(--border-glass);
}

.check-item input {
  margin-top: 4px;
  accent-color: var(--azure);
  width: 16px;
  height: 16px;
}

.check-item.done span {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* Filters */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.search-input, .filter-select, .form-field input {
  background: rgba(7, 11, 20, 0.75);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.92rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease;
}

.search-input {
  flex: 1 1 260px;
}

.filter-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.search-input:focus, .filter-select:focus, .form-field input:focus {
  border-color: var(--azure);
}

.char-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* Character Cards */
.char-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.char-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-glow);
  background: var(--bg-hover);
}

.char-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.char-name {
  font-size: 1.15rem;
  font-weight: 800;
}

.char-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.char-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.char-summary {
  font-size: 0.9rem;
  color: #cbd5e1;
  flex: 1;
}

.char-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--azure);
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* Advice & Forms */
.advice-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.advice-item {
  background: rgba(7, 11, 20, 0.55);
  border-left: 3px solid var(--azure);
  padding: 12px 14px;
  border-radius: 0 10px 10px 0;
}

.advice-item h4 {
  font-size: 0.98rem;
  margin-bottom: 4px;
}

.advice-item p {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.calc-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.calc-result {
  background: rgba(7, 11, 20, 0.72);
  border: 1px solid rgba(56, 189, 248, 0.28);
  border-radius: 12px;
  padding: 14px 16px;
}

.calc-highlight {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--gold);
  margin: 4px 0;
}

.warning-panel {
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.07);
}

.warning-panel h3 {
  color: var(--gold);
  margin-bottom: 6px;
}

/* Team Simulator */
.team-slots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.sim-output {
  background: rgba(7, 11, 20, 0.7);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 16px;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.82rem;
}

.btn-ghost:hover {
  color: var(--text-main);
  border-color: var(--azure);
}

/* Table */
.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th, .data-table td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.data-table th {
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.82rem;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.quick-budgets {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0 14px;
}

.chip-btn {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: var(--azure);
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
}

.chip-btn:hover {
  background: rgba(56, 189, 248, 0.25);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(3, 6, 14, 0.86);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  background: var(--bg-surface-solid);
  border: 1px solid var(--border-glow);
  border-radius: 18px;
  max-width: 640px;
  width: 100%;
  max-height: 90dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px;
  position: relative;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
  will-change: transform;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border-glass);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  cursor: pointer;
  font-size: 1rem;
}

.modal-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-section h4 {
  color: var(--azure);
  font-size: 0.92rem;
  margin-bottom: 4px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 120;
  background: var(--bg-surface-solid);
  border: 1px solid var(--azure);
  color: var(--text-main);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 0.9rem;
  box-shadow: var(--shadow-card);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: all 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.hint-text {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.footer {
  border-top: 1px solid var(--border-glass);
  padding: 22px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.84rem;
}

/* AI Analysis */
.box-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 8px;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 4px;
}

.box-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(7, 11, 20, 0.65);
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.16s ease;
  user-select: none;
}

.box-chip:hover {
  border-color: var(--azure);
}

.box-chip.selected {
  background: rgba(56, 189, 248, 0.18);
  border-color: var(--azure);
  color: #fff;
}

.box-chip input {
  accent-color: var(--azure);
}

.llm-details {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.86rem;
  color: var(--text-muted);
}

.llm-details summary {
  cursor: pointer;
  color: var(--azure);
  font-weight: 600;
}

.ai-report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.ai-block {
  background: rgba(7, 11, 20, 0.62);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 14px 16px;
}

.ai-block h4 {
  color: var(--gold);
  margin-bottom: 8px;
  font-size: 0.96rem;
}

/* BWIKI Portal Grid */
.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.portal-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: linear-gradient(145deg, rgba(22, 34, 62, 0.85), rgba(11, 18, 36, 0.9));
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  padding: 16px;
  text-align: left;
  color: var(--text-main);
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.portal-card:hover {
  transform: translateY(-3px);
  border-color: var(--azure);
  box-shadow: 0 10px 26px rgba(56, 189, 248, 0.18);
}

.portal-title {
  font-size: 1.02rem;
  font-weight: 800;
  color: #fff;
}

.portal-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Official BWIKI Thumbnails & Catalog Grid */
.char-avatar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.char-avatar {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  object-fit: cover;
  object-position: top center;
  background: rgba(7, 11, 20, 0.8);
  border: 1px solid var(--border-glass);
  flex-shrink: 0;
}

.catalog-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.subtab-btn {
  background: rgba(7, 11, 20, 0.65);
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  padding: 8px 15px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.subtab-btn:hover {
  color: var(--text-main);
  border-color: var(--azure);
}

.subtab-btn.active {
  color: #070b14;
  background: linear-gradient(135deg, #7dd3fc, #38bdf8);
  border-color: transparent;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.35);
}

.wiki-thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 10px;
}

.wiki-item-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  background: rgba(7, 11, 20, 0.65);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 12px 10px;
  color: var(--text-main);
  cursor: pointer;
  font-family: inherit;
  width: 100%;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.wiki-item-card:hover {
  transform: translateY(-2px);
  border-color: var(--azure);
  background: rgba(24, 38, 68, 0.8);
}

.wiki-item-img {
  width: 68px;
  height: 68px;
  object-fit: contain;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
}

.wiki-item-name {
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.3;
}

.wiki-item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Interactive Tactical Map */
.map-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.map-layer-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.layer-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(7, 11, 20, 0.7);
  border: 1px solid var(--border-glass);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.8rem;
  cursor: pointer;
  user-select: none;
}

.layer-pill input {
  accent-color: var(--azure);
}

.map-viewport {
  width: 100%;
  max-height: 680px;
  overflow: auto;
  border-radius: 14px;
  border: 1px solid var(--border-glow);
  background: #091322;
}

.interactive-map-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  transform-origin: top left;
  transition: width 0.2s ease;
}

.real-map-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  pointer-events: none;
}

.map-dot-pin {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
  cursor: pointer;
  padding: 0;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
  font-size: 0.7rem;
  color: #fff;
}

.map-dot-pin img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  pointer-events: none;
}

.map-dot-pin:hover, .map-dot-pin.active {
  transform: translate(-50%, -50%) scale(1.35);
  z-index: 20;
  box-shadow: 0 0 14px #38bdf8;
}

.dot-waypoint { background: rgba(14, 165, 233, 0.92); }
.dot-settlement { background: rgba(16, 185, 129, 0.92); }
.dot-boss { background: rgba(225, 29, 72, 0.94); }
.dot-chest { background: rgba(234, 179, 8, 0.92); }
.dot-puzzle { background: rgba(139, 92, 246, 0.9); }

.map-grid-lines {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(148, 163, 184, 0.08) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(148, 163, 184, 0.08) 1px, transparent 1px);
  background-size: 10% 10%;
  pointer-events: none;
}

.map-region-watermark {
  position: absolute;
  bottom: 12px;
  right: 16px;
  font-size: 0.82rem;
  color: rgba(186, 230, 253, 0.55);
  font-weight: 700;
  pointer-events: none;
}

.map-pin {
  position: absolute;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  border: 1.5px solid rgba(255, 255, 255, 0.45);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
  font-family: inherit;
  white-space: nowrap;
}

.map-pin:hover, .map-pin.active {
  transform: translate(-50%, -50%) scale(1.1);
  z-index: 10;
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.75);
}

.pin-settlement { background: rgba(16, 185, 129, 0.9); }
.pin-waypoint { background: rgba(14, 165, 233, 0.92); }
.pin-boss { background: rgba(225, 29, 72, 0.92); border-color: #fda4af; }
.pin-puzzle { background: rgba(217, 119, 6, 0.92); }

.map-detail-bar {
  margin-top: 12px;
  background: rgba(7, 11, 20, 0.72);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 0.9rem;
  color: #e2e8f0;
}

/* Character Infographic Gallery & Lightbox */
.guide-thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

.guide-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(7, 11, 20, 0.7);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  padding: 10px;
  cursor: pointer;
  color: var(--text-main);
  font-family: inherit;
  text-align: left;
  transition: transform 0.16s ease, border-color 0.16s ease;
}

.guide-card:hover {
  transform: translateY(-3px);
  border-color: var(--gold);
}

.guide-card img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  object-position: top center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
}

.guide-card.guide-card-lite {
  flex-direction: row;
  align-items: center;
  gap: 12px;
  padding: 12px;
}

.guide-card.guide-card-lite img.char-avatar {
  width: 52px;
  height: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 10px;
}

.modal-card.wide-modal {
  max-width: 1040px;
}

.infographic-full-img {
  width: 100%;
  height: auto;
  border-radius: 12px;
  margin-top: 10px;
  border: 1px solid var(--border-glass);
  display: block;
  background: rgba(7, 11, 20, 0.7);
}

.img-loading-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 28px 16px;
  color: var(--azure);
  font-size: 0.92rem;
  background: rgba(7, 11, 20, 0.65);
  border-radius: 12px;
  margin-top: 10px;
  border: 1px dashed var(--border-glass);
}

/* Performance: skip offscreen layout/paint for large grids */
.wiki-item-card, .char-card, .guide-card {
  content-visibility: auto;
  contain-intrinsic-size: 160px 180px;
}

/* Mobile Responsive Adaptation */
@media (max-width: 768px) {
  .starfield {
    background-position: 68% 20%;
  }

  .bg-video {
    object-position: 68% 20%;
  }

  .container {
    padding: 0 12px;
  }

  .topbar-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .brand-star {
    width: 32px;
    height: 32px;
    font-size: 1.05rem;
  }

  .brand-title {
    font-size: 0.98rem;
  }

  .nav-links {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
    gap: 6px;
  }

  .nav-links::-webkit-scrollbar {
    display: none;
  }

  .nav-btn {
    flex-shrink: 0;
    padding: 7px 12px;
    font-size: 0.84rem;
  }

  .main-content {
    padding-top: 16px;
    padding-bottom: 44px;
  }

  .hero {
    padding: 18px 16px;
    border-radius: 14px;
    margin-bottom: 18px;
  }

  .hero-desc {
    font-size: 0.88rem;
    margin-bottom: 14px;
  }

  .hero-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .stat-pill {
    padding: 10px 12px;
  }

  .stat-val {
    font-size: 0.92rem;
  }

  .cols-2, .cols-3, .split-layout {
    grid-template-columns: 1fr;
  }

  .portal-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .portal-card {
    padding: 12px;
  }

  .wiki-thumb-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .guide-thumb-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .guide-card img {
    height: 118px;
  }

  .panel, .card {
    padding: 14px;
  }

  .filter-groups {
    width: 100%;
  }

  .filter-select {
    flex: 1 1 45%;
    min-width: 0;
  }

  .box-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 260px;
  }

  .map-viewport {
    max-height: 60dvh;
  }

  .modal-backdrop {
    padding: 8px;
    align-items: flex-end;
  }

  .modal-card {
    padding: 16px;
    border-radius: 16px 16px 12px 12px;
    max-height: 92dvh;
  }

  .modal-close {
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
  }

  .table-wrap {
    -webkit-overflow-scrolling: touch;
  }

  .data-table {
    font-size: 0.82rem;
  }

  .data-table th, .data-table td {
    padding: 9px 7px;
  }
}
