/* Reference-image style for test_calculator (comments in English) */

@font-face {
  font-family: "MantouSans";
  src: url("../fonts/MantouSans-Regular.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0f0f0f;
  --panel: #161616;
  --panel-2: rgba(40, 40, 40, 0.3);
  --border: #333;
  --border-2: #444;
  --text: #fff;
  --muted: #999;
  --muted-2: #ccc;
  --accent: #d9f20b;
  /* Left equip row scale: 0.5 = half, 0.66 = two-thirds, 1 = original */
  --left-equip-scale: 0.55;
  /* Left equip icon sizing (tweak to match reference image) */
  --left-equip-icon-size: 66px;
  --left-equip-icon-pad: 10px;
  /* Space tuning (tweak when icon gets bigger) */
  --left-equip-icon-col-extra: 8px; /* extra width reserved for icon column */
  --left-equip-slot-gap: 0.85rem; /* gap between icon/text/right area */
  /* Left divider tuning */
  --left-divider-height: 2px;
  --left-divider-margin-top: 1.75rem;
  --left-divider-margin-bottom: 1.95rem;
  --left-divider-toggle-margin-top: 1.2rem;
  --left-divider-toggle-margin-bottom: 2.4rem;
  /* Equip modal (armor list) icon sizing */
  --equip-modal-part-icon-size: 52px;
  --equip-modal-part-icon-pad: 6px;
  --equip-modal-part-icon-radius: 12px;
  /* Layout sizing */
  --top-nav-height: 76px;
  --stage-left: 50%;
  --stage-width: 80vw;
  --max-width: 1800px;
  --canvas-max-width: 1826.4px;
  --canvas-max-height: 1011.2px;
  /* 中間版型（隱藏 stage + 3D）斷點，僅供參考；media query 需手動同步 */
  --layout-compact-min: 1000px;
  --layout-compact-max: 1300px;
  /* compact 模式下右側欄最小寬度（避免被擠壓過窄） */
  --layout-compact-right-min: 280px;
  /* Right equip panel font sizes */
  --right-equip-title-size: 2.15rem;
  --right-equip-name-size: 1.12rem;
  --right-equip-sub-size: 1.38rem;
  --right-equip-gem-size: 0.92rem;
}

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

html,
body {
  height: 100vh;
  overflow: hidden; /* page size fixed; internal panels scroll */
}

body {
  background: var(--bg);
  color: var(--text);
  font-family:
    "Noto Sans",
    "Noto Sans TC",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-weight: 500;
  line-height: 1.5;
}

/* Full-page background (reference image) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: url("../imgs/background-small.png") center/cover no-repeat;
  opacity: 0.95;
  filter: brightness(0.55) contrast(1.05) saturate(0.9);
  z-index: -2;
  pointer-events: none;
}

/* Dark vignette overlay for readability */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(
    1200px 600px at 50% 20%,
    rgba(0, 0, 0, 0.15) 0%,
    rgba(0, 0, 0, 0.55) 55%,
    rgba(0, 0, 0, 0.82) 100%
  );
  z-index: -1;
  pointer-events: none;
}

/* 3D background canvas (Pixi3D) */
#bg-canvas {
  position: fixed;
  top: 0;
  left: var(--stage-left);
  width: min(var(--stage-width), var(--canvas-max-width));
  height: min(100vh, var(--canvas-max-height));
  z-index: 0;
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
  transform: translateX(-50%);
}

/* If 3D background is enabled, hide static fallback background */
body.has-3d-bg::before,
body.has-3d-bg::after {
  opacity: 0;
}

.app-container {
  min-height: 100vh;
  /* Let the body background image show through */
  background: transparent;
  position: relative;
  z-index: 2;
  pointer-events: none;
  /* Add padding at bottom to prevent content from being hidden by disclaimer footer */
  padding-bottom: 4rem;
}

.top-nav,
.left-panel,
.right-panel,
.stage-overlay,
.modal-overlay {
  pointer-events: auto;
}

/* Top Navigation */
.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: rgba(0, 0, 0, 0.95);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: var(--top-nav-height);
}

.nav-left {
  display: flex;
  align-items: center;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}

.logo {
  height: 32px;
}

.brand-name {
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--accent);
}

.nav-center {
  display: flex;
  gap: 1rem;
}

.nav-button {
  padding: 0.75rem 1.5rem;
  border: none;
  background: rgba(60, 60, 60, 0.8);
  color: #888;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-button-text {
  white-space: nowrap;
}

.nav-button.active {
  background: var(--accent);
  color: #000;
  box-shadow: 0 2px 8px rgba(217, 242, 11, 0.25);
}

.nav-button:hover:not(.active) {
  background: rgba(80, 80, 80, 0.9);
  color: #bbb;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.language-switch {
  padding: 0.5rem 1rem;
  border: 1px solid #666;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 600;
  text-decoration: none;
  color: #fff;
}

.language-switch:hover {
  border-color: #999;
  color: #bbb;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid #777;
  cursor: pointer;
  transition: all 0.2s ease;
}

.user-avatar:hover {
  border-color: #fff;
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(217, 242, 11, 0.28);
}

.avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Main Content */
.main-content {
  height: calc(100vh - var(--top-nav-height));
  overflow: hidden;
  padding: 2rem;
}

.main-grid {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
  gap: 1.5rem;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  height: 100%;
  min-height: 0;
}

.page-title {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text);
  font-family: "Noto Sans", "Noto Sans TC", sans-serif;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1.95fr) minmax(0, 2.65fr) minmax(
      0,
      4.15fr
    );
  gap: 2rem;
  min-height: 0;
  height: 100%;
  align-items: stretch;
}

.left-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 340px;
  min-height: 0;
  height: 100%;
}

.stage-panel {
  position: relative;
  min-height: 0;
  height: 100%;
}

.other-panel {
  min-height: 0;
}

.stage-overlay {
  position: sticky;
  top: calc(var(--top-nav-height) + 16px);
  max-width: 520px;
  padding: 14px;
  border-radius: 18px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  background: rgba(12, 12, 12, 0.35);
  backdrop-filter: blur(6px);
  pointer-events: none;
  display: none;
}

.stage-controls {
  pointer-events: auto;
}

body.debug-open .stage-overlay {
  display: block;
}

.stage-controls {
  display: grid;
  gap: 8px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.86);
}

.stage-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  align-items: center;
  gap: 10px;
}

.stage-row input[type="range"] {
  width: 100%;
}

.stage-btn-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.stage-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.92);
  border-radius: 10px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

.stage-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.72);
}

#ctl-animSelect {
  min-width: 160px;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.92);
}

/* Left panel: closer to the reference image layout */
.left-search-panel {
  padding: 1rem;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 10px; /* room for scrollbar */

  /* Modern gray scrollbar (Firefox) */
  scrollbar-width: thin;
  scrollbar-color: rgba(210, 210, 210, 0.35) rgba(0, 0, 0, 0);
}

/* Modern gray scrollbar (Chromium/WebKit) */
.left-search-panel::-webkit-scrollbar {
  width: 10px;
}
.left-search-panel::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0);
}
.left-search-panel::-webkit-scrollbar-thumb {
  background: rgba(210, 210, 210, 0.28);
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, 0);
  background-clip: padding-box;
}
.left-search-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(210, 210, 210, 0.4);
}

.left-title {
  font-size: 1.55rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.9rem;
}

.left-block {
  /* border: 1px solid #2f2f2f;
  background: rgba(10, 10, 10, 0.35); */
  border-radius: 14px;
  padding: 0.9rem;
  margin-bottom: 0.85rem;
}

.left-block:last-child {
  margin-bottom: 0;
}

.left-divider {
  height: var(--left-divider-height);
  background: rgba(255, 255, 255, 0.1);
  margin: var(--left-divider-margin-top) 0 var(--left-divider-margin-bottom) 0;
}

.left-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 0.6rem;
}

.left-divider-toggle-wrap {
  position: relative;
  margin: var(--left-divider-toggle-margin-top) 0
    var(--left-divider-toggle-margin-bottom) 0;
}

.left-divider-toggle-wrap .left-divider {
  margin: 0;
}

.left-divider-toggle {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: #ddd;
  cursor: pointer;
  font-weight: 900;
  font-size: 18px;
  display: grid;
  place-items: center;
  transition:
    transform 160ms cubic-bezier(0, 0.01, 0.18, 0.98),
    background 160ms cubic-bezier(0, 0.01, 0.18, 0.98);
}

.left-divider-toggle:hover {
  filter: brightness(1.08);
}

.left-divider-toggle[aria-expanded="false"] {
  transform: translate(-50%, -50%) rotate(-90deg);
}

/* left-collapse-btn removed (collapse is controlled by divider toggle) */

.left-block-body.is-collapsed {
  display: none;
}

.left-block-title {
  font-size: 1.25rem;
  font-weight: 750;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.left-skill-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Override skill item to match the reference left sidebar row */
.skill-item {
  padding: 0.85rem 0.9rem;
  background: rgba(20, 20, 20, 0.55);
  border: 1px solid #3b3b3b;
  border-radius: 14px;
}

.skill-item.skill-optional {
  border: 2px dashed var(--accent, #d9f20b);
  border-radius: 14px;
}

.skill-item.skill-required {
  border: 2px dashed var(--accent, #d9f20b);
  border-radius: 14px;
}

.skill-name {
  font-size: 1.05rem;
  font-weight: 700;
}

.skill-level-label {
  font-size: 0.95rem;
  font-weight: 750;
  color: #bdbdbd;
}

.level-dot {
  width: 12px;
  height: 12px;
  border-color: #6a6a6a;
}

.level-dot.active {
  background: var(--accent);
  border-color: var(--accent);
}

.icon-btn {
  border-radius: 999px;
  width: 34px;
  height: 34px;
  border-color: #666;
  background: rgba(0, 0, 0, 0.35);
}

.left-add-slot {
  width: 100%;
  height: 44px;
  margin-top: 0.75rem;
  border: 2px dashed #5a5a5a;
  background: transparent;
  border-radius: 12px;
  color: #bdbdbd;
  font-size: 1.35rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.left-add-slot:hover {
  border-color: #8a8a8a;
  background: rgba(255, 255, 255, 0.05);
}

.left-equip-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.left-control {
  height: 44px;
  border-radius: 12px;
  border: 1px solid #555;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  padding: 0 12px;
  outline: none;
  font-weight: 650;
}

.left-control:focus {
  border-color: rgba(217, 242, 11, 0.85);
  box-shadow: 0 0 0 3px rgba(217, 242, 11, 0.12);
}

.left-button {
  cursor: pointer;
}

.left-equip-slot-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  --es: var(--left-equip-scale, 1);
}

.weapon-search-wrap {
  margin-top: 0.35rem;
  margin-bottom: 0.25rem;
}

.weapon-search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #1e1e1e;
  color: var(--text);
  font-size: 14px;
}

.weapon-search-input::placeholder {
  color: var(--muted);
}

.weapon-search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.weapon-search-results {
  max-height: 200px;
  overflow-y: auto;
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #1a1a1a;
}

.weapon-search-results:empty {
  display: none;
}

.weapon-search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 13px;
}

.weapon-search-result-item:last-child {
  border-bottom: none;
}

.weapon-search-result-item:hover {
  background: rgba(217, 242, 11, 0.12);
}

.weapon-search-result-item.selected {
  background: rgba(217, 242, 11, 0.18);
  color: var(--accent);
}

.weapon-search-result-item .weapon-type-tag {
  font-size: 11px;
  color: var(--muted);
  margin-left: 8px;
}

.weapon-custom-btn {
  width: 100%;
  margin-top: 8px;
  padding: 8px 12px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
}

.weapon-custom-btn:hover {
  background: rgba(217, 242, 11, 0.1);
}

.equip-weapon-actions {
  margin-bottom: 10px;
}

.weapon-custom-btn-inline {
  padding: 8px 14px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
}

.weapon-custom-btn-inline:hover {
  background: rgba(217, 242, 11, 0.1);
}

/* ============================================
   Custom Weapon (巨戟強化) Modal
   ============================================ */

.custom-weapon-modal-overlay {
  z-index: 1998;
}

.custom-weapon-modal-content {
  position: relative;
  max-width: 920px;
  width: 90vw;
  max-height: 85vh;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--border-2);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.custom-weapon-modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.custom-weapon-modal-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.custom-weapon-modal-body {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 0;
  min-height: 420px;
  max-height: calc(85vh - 60px);
  overflow: hidden;
}

.custom-weapon-editor-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
  padding: 1.25rem;
  border-right: 1px solid var(--border);
}

.custom-weapon-preview-card {
  background: linear-gradient(
    145deg,
    rgba(30, 30, 30, 0.95),
    rgba(22, 22, 22, 0.98)
  );
  border: 1px solid var(--border-2);
  border-radius: 12px;
  padding: 1.25rem;
  text-align: center;
}

.custom-weapon-preview-icon-wrap {
  margin-bottom: 0.75rem;
}

.custom-weapon-preview-icon {
  width: 56px;
  height: 56px;
  object-fit: contain;
  opacity: 0.95;
}

.custom-weapon-preview-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
  min-height: 1.5em;
}

.custom-weapon-preview-type {
  font-size: 0.8rem;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.custom-weapon-preview-skills {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.custom-weapon-preview-skill {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  background: rgba(217, 242, 11, 0.12);
  color: var(--accent);
}

.custom-weapon-preview-skill.combo {
  background: rgba(100, 180, 255, 0.15);
  color: #7eb8f7;
}
.custom-weapon-preview-skill.equip {
  background: rgba(150, 220, 130, 0.15);
  color: #9ed882;
}

.custom-weapon-preview-slots {
  display: flex;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
}

.custom-weapon-preview-slots .left-slot-stack {
  flex-direction: row;
  gap: 4px;
}

.custom-weapon-preview-slots .left-slot-icon {
  width: 36px;
  height: 28px;
}

.custom-weapon-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.custom-weapon-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}

.custom-weapon-section-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted-2);
  margin: 0 0 0.75rem 0;
  display: block;
}

.custom-weapon-field {
  margin-bottom: 0.75rem;
}

.custom-weapon-field:last-child {
  margin-bottom: 0;
}

.custom-weapon-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.custom-weapon-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  box-sizing: border-box;
}

.custom-weapon-input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
}

.custom-weapon-input::placeholder {
  color: var(--muted);
}

.custom-weapon-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.custom-weapon-select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
}

.custom-weapon-select:focus {
  outline: none;
  border-color: var(--accent);
}

.custom-weapon-skill-picker {
  position: relative;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s;
}

.custom-weapon-skill-picker:hover {
  border-color: var(--border-2);
  background: rgba(255, 255, 255, 0.06);
}

.custom-weapon-skill-picker:focus-within {
  border-color: var(--accent);
  outline: none;
}

.custom-weapon-listbox-dropdown {
  position: fixed;
  z-index: 2100;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  min-width: 360px;
  max-width: 520px;
  max-height: 280px;
  overflow-y: auto;
  overflow-x: auto;
  background: #0f0f0f;
  border: 1px solid var(--border-2);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.custom-weapon-listbox-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.5rem 0.6rem;
  cursor: pointer;
  color: var(--text);
  font-size: 0.85rem;
  border: none;
  background: transparent;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  text-align: left;
  transition: background 0.12s;
  box-sizing: border-box;
}

.custom-weapon-listbox-option:hover {
  background: rgba(217, 242, 11, 0.12);
}

.custom-weapon-listbox-option .custom-weapon-listbox-option-icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
}

.custom-weapon-listbox-option .custom-weapon-listbox-option-name {
  flex: 1;
  min-width: 0;
  word-break: break-word;
  white-space: normal;
  line-height: 1.3;
}

.custom-weapon-type-display {
  font-size: 0.95rem;
  color: var(--text);
}

.custom-weapon-skill-display {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
}

.custom-weapon-skill-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
}

.custom-weapon-skill-name {
  font-size: 0.9rem;
  color: var(--text);
}

.custom-weapon-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.custom-weapon-btn {
  padding: 0.65rem 1.25rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
}

.custom-weapon-btn.primary {
  background: var(--accent);
  color: #0f0f0f;
  border: none;
}

.custom-weapon-btn.primary:hover {
  filter: brightness(1.1);
}

.custom-weapon-btn.secondary {
  background: transparent;
  color: var(--muted-2);
  border: 1px solid var(--border);
}

.custom-weapon-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.custom-weapon-list-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
}

.custom-weapon-list-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.custom-weapon-list {
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.custom-weapon-list-card {
  display: flex;
  align-items: stretch;
  gap: 0.75rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  transition:
    border-color 0.15s,
    background 0.15s;
  cursor: pointer;
}

.custom-weapon-list-card:hover {
  border-color: var(--border-2);
  background: rgba(255, 255, 255, 0.04);
}

.custom-weapon-list-card-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
}

.custom-weapon-list-card-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.custom-weapon-list-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.custom-weapon-list-card-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.custom-weapon-list-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.custom-weapon-list-card-type {
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: rgba(217, 242, 11, 0.12);
  color: var(--accent);
  font-weight: 500;
}

.custom-weapon-list-card-skills {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.custom-weapon-list-card-skill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--muted-2);
}

.custom-weapon-list-card-skill img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.custom-weapon-list-card-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: auto;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.custom-weapon-delete-btn {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition:
    color 0.15s,
    border-color 0.15s;
}

.custom-weapon-delete-btn:hover {
  color: #e86c6c;
  border-color: rgba(232, 108, 108, 0.4);
}

.custom-weapon-empty-state {
  padding: 2rem 1.25rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.custom-weapon-empty-state p {
  margin: 0 0 0.5rem 0;
}

.custom-weapon-empty-hint {
  font-size: 0.8rem !important;
  color: var(--muted);
  opacity: 0.9;
}

@media (max-width: 768px) {
  .custom-weapon-modal-body {
    grid-template-columns: 1fr;
  }

  .custom-weapon-editor-panel {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .custom-weapon-list-panel {
    min-height: 200px;
  }
}

.left-outside-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: calc(12px * var(--es, 1));
  align-items: center;
}

.left-trash-outside {
  width: calc(18px * var(--es, 1));
  height: calc(18px * var(--es, 1));
}

.left-equip-slot {
  display: grid;
  grid-template-columns:
    calc(
      (var(--left-equip-icon-size) + var(--left-equip-icon-col-extra)) *
        var(--es, 1)
    )
    1fr
    auto;
  gap: calc(var(--left-equip-slot-gap) * var(--es, 1));
  align-items: center;
  padding: calc(0.75rem * var(--es, 1)) calc(0.85rem * var(--es, 1));
  background: #1e1e1e;
  /* border: 1px solid #3b3b3b; */
  border-radius: calc(14px * var(--es, 1));
  cursor: pointer;
  position: relative;
  /* Sharper easing to match requested feel */
  transition:
    border-color 160ms cubic-bezier(0, 0.01, 0.18, 0.98),
    background 160ms cubic-bezier(0, 0.01, 0.18, 0.98),
    transform 160ms cubic-bezier(0, 0.01, 0.18, 0.98),
    box-shadow 160ms cubic-bezier(0, 0.01, 0.18, 0.98);
}

.left-equip-right {
  display: flex;
  align-items: center;
  gap: calc(6px * var(--es, 1));
}

.left-slot-stack {
  display: flex;
  flex-direction: column;
  gap: 0px;
}

.left-slot-icon {
  position: relative;
  /* Bigger but flatter (match reference) */
  width: calc(44px * var(--es, 1));
  height: calc(36px * var(--es, 1));
}

.left-slot-icon img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /* Fill the container as much as possible */
  object-fit: cover;
  display: block;
  transform: scale(1.06);
  filter: drop-shadow(0 10px 12px rgba(0, 0, 0, 0.48));
}

.left-slot-icon .slot-base {
  z-index: 1;
}

.left-slot-icon .slot-fill {
  z-index: 2;
  opacity: 0.92;
}

.left-slot-icon .slot-detail {
  position: absolute;
  right: calc(100% + var(--gem-row-offset, 8px));
  top: 50%;
  transform: translateY(-50%);
  padding: 2px 8px;
  color: #f5f5f5;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  background: linear-gradient(
    to right,
    rgba(0, 0, 0, 0) 0%,
    rgba(0, 0, 0, 0.8) 40%,
    rgba(0, 0, 0, 1) 100%
  );
  border-radius: 999px;
  pointer-events: none;
  z-index: var(--gem-row-z, 32);
}

.left-slot-stack.is-collapsed .slot-detail {
  display: none;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(8, 8, 8, 0.35);
  z-index: 9999;
  pointer-events: none;
}

.loading-overlay.is-visible {
  display: flex;
}

.loading-card {
  min-width: 220px;
  padding: 18px 22px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(20, 20, 20, 0.95);
  color: #f2f2f2;
  text-align: center;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.35);
}

.loading-spinner {
  width: 44px;
  height: 44px;
  margin: 4px auto 10px;
  border-radius: 999px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: rgba(255, 255, 255, 0.9);
  animation: loading-spin 1s linear infinite;
}

.loading-text {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.loading-bar {
  margin-top: 10px;
  width: 220px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
}

.loading-bar-fill {
  width: 0%;
  height: 100%;
  background: rgba(217, 242, 11, 0.9);
  transition: width 600ms ease-out;
}

@keyframes loading-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Initial loading overlay (shown on page load until 3D canvas and data are ready) */
.initial-loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0f0f0f;
  z-index: 99999;
  transition:
    opacity 0.4s ease-out,
    visibility 0.4s ease-out;
  pointer-events: auto;
}

.initial-loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.initial-loading-spinner {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 4px solid rgba(217, 242, 11, 0.2);
  border-top-color: rgba(217, 242, 11, 0.9);
  animation: loading-spin 0.8s linear infinite;
  margin-bottom: 20px;
}

.initial-loading-text {
  font-size: 16px;
  font-weight: 600;
  color: #d9f20b;
  letter-spacing: 0.05em;
}

.left-slot-badge {
  position: absolute;
  right: calc(-8px * var(--es, 1));
  bottom: calc(-8px * var(--es, 1));
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: rgba(217, 242, 11, 0.95);
  color: rgba(0, 0, 0, 0.9);
  font-size: 11px;
  font-weight: 900;
  display: grid;
  place-items: center;
}

.left-equip-action {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: none;
  background: transparent;
  display: grid;
  place-items: center;
  color: #cfcfcf;
  font-weight: 900;
  font-size: 18px;
}

/* Weapon row should not show the "+" hint on the right */
.left-equip-slot[data-slot="weapon"] .left-equip-action {
  display: none;
}

.left-trash-btn {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.18s ease;
}

.left-trash-btn:hover {
  opacity: 0.9;
  filter: brightness(1.08);
}

.left-trash-btn img {
  width: 12px;
  height: 12px;
  object-fit: contain;
}

/* Rarity tint on equipment icons (apply to armor_base/glove_base/helmet_base/...) */
.rarity-icon {
  position: relative;
  background: transparent;
}

/* Base grayscale layer (keeps luminance/shading) */
.rarity-icon::before {
  content: "";
  position: absolute;
  inset: var(--icon-pad, 10px);
  border-radius: inherit;
  background: var(--icon-url) center/contain no-repeat;
  filter: grayscale(1) contrast(1.05) brightness(0.98);
  opacity: 1;
}

/* Color overlay layer (tints grayscale) */
.rarity-icon::after {
  content: "";
  position: absolute;
  inset: var(--icon-pad, 10px);
  border-radius: inherit;
  background: var(--rarity-color, transparent);
  -webkit-mask: var(--icon-url) center/contain no-repeat;
  mask: var(--icon-url) center/contain no-repeat;
  opacity: 0.85;
  mix-blend-mode: color;
  pointer-events: none;
}

/* Rarity 8 keeps original color */
.rarity-icon[data-rarity="8"]::before {
  filter: none;
  background: var(--icon-url) center/contain no-repeat;
}
.rarity-icon[data-rarity="8"]::after {
  opacity: 0;
}

/* 7/6/5: tint with exact RGB */
.rarity-icon[data-rarity="7"] {
  --rarity-color: rgb(130, 49, 222);
}
.rarity-icon[data-rarity="6"] {
  --rarity-color: rgb(18, 52, 204);
}
.rarity-icon[data-rarity="5"] {
  --rarity-color: rgb(49, 185, 222);
}

/* 1-4 (-1) : grayscale (no color overlay) */
.rarity-icon[data-rarity="4"],
.rarity-icon[data-rarity="3"],
.rarity-icon[data-rarity="2"],
.rarity-icon[data-rarity="1"],
.rarity-icon[data-rarity="-1"],
.rarity-icon[data-rarity="0"] {
  --rarity-color: transparent;
}

.left-equip-slot:hover {
  border-color: rgba(255, 255, 255, 0.75);
  background: rgba(90, 90, 90, 0.32);
  transform: translateY(calc(-4px * var(--es, 1))) scale(1.02);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.62);
}

.left-equip-slot:active {
  transform: translateY(0px);
}

.left-equip-icon {
  /* Make the container bigger but the actual icon smaller with padding */
  width: calc(var(--left-equip-icon-size) * var(--es, 1));
  height: calc(var(--left-equip-icon-size) * var(--es, 1));
  padding: calc(var(--left-equip-icon-pad) * var(--es, 1));
  box-sizing: border-box;
  border-radius: calc(14px * var(--es, 1));
  object-fit: contain;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid #555;
  --icon-pad: calc(var(--left-equip-icon-pad) * var(--es, 1));
}

.left-equip-text {
  min-width: 0;
}

.left-equip-title {
  font-weight: 750;
  font-size: 1.02rem;
  line-height: 1.15;
  color: #fff;
}

.left-equip-sub {
  color: #bdbdbd;
  font-weight: 650;
  font-size: 0.9rem;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Text stroke for equip title/subtitle (match reference image) */
.left-equip-text .left-equip-title,
.left-equip-text .left-equip-sub {
  -webkit-text-stroke: 0.6px rgba(0, 0, 0, 0.95);
  paint-order: stroke fill;
  /* Fallback stroke using shadow for non-webkit engines */
  text-shadow:
    -1px 0 rgba(187, 136, 136, 0.85),
    1px 0 rgba(0, 0, 0, 0.85),
    0 -1px rgba(0, 0, 0, 0.85),
    0 1px rgba(0, 0, 0, 0.85),
    -1px -1px rgba(0, 0, 0, 0.55),
    1px -1px rgba(0, 0, 0, 0.55),
    -1px 1px rgba(0, 0, 0, 0.55),
    1px 1px rgba(0, 0, 0, 0.55);
}

.left-equip-plus {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px dashed #6a6a6a;
  background: rgba(0, 0, 0, 0.2);
  color: #d8d8d8;
  font-size: 1.35rem;
  font-weight: 800;
  pointer-events: none; /* click the whole slot instead */
  transition: all 0.2s ease;
}

.left-equip-plus:hover {
  border-color: #9a9a9a;
  background: rgba(255, 255, 255, 0.05);
}

.left-control-hidden {
  /* Do NOT use display:none, otherwise the native select picker can't open */
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}

.left-priority-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #cfcfcf;
  font-weight: 650;
  margin-bottom: 0.9rem;
}

/* Priority conditions list (same visual language as equip/skills) */
.left-condition-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.left-condition-slot {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem 0.85rem;
  background: #1e1e1e;
  border-radius: 14px;
}

.left-condition-icon {
  width: 48px;
  height: 48px;
  padding: 10px;
  box-sizing: border-box;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid #555;
  display: grid;
  place-items: center;
}

.left-condition-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.left-condition-text {
  min-width: 0;
}

.left-condition-title {
  color: #fff;
  font-weight: 800;
  font-size: 1.02rem;
  line-height: 1.15;
}

.left-condition-sub {
  color: #bdbdbd;
  font-weight: 650;
  font-size: 0.9rem;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.left-primary {
  width: 100%;
  height: 46px;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: #000;
  font-weight: 800;
  cursor: pointer;
}

/* Give breathing room between priority add button and calc button */
#block-priority .left-add-slot {
  margin-bottom: 0.75rem;
}

.left-limit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0.35rem 0 0.8rem;
  color: #f2f2f2;
  font-weight: 700;
}

.left-limit-row-toggle {
  cursor: pointer;
}

.left-limit-row-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: rgba(217, 242, 11, 0.9);
}

.left-fav-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}

.left-fav-toggle {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
  color: #f8f8f8;
  font-weight: 800;
  cursor: pointer;
}

.fav-build-panel {
  display: none;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(20, 20, 20, 0.72);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.fav-build-panel.is-open {
  display: grid;
  gap: 0.6rem;
}

.left-fav-btn {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: #f5f5f5;
  font-size: 12px;
  cursor: pointer;
}

.left-limit-input {
  width: 84px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(20, 20, 20, 0.65);
  color: #fff;
  padding: 0 8px;
}

.left-primary:hover {
  filter: brightness(1.02);
}

.center-panel {
  flex: 0.95;
  min-width: 320px;
  display: flex;
  justify-content: center;
  min-height: 0;
}

.right-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1.5rem;
  flex: 1.25;
  min-width: 360px;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 10px; /* room for scrollbar */

  /* Modern gray scrollbar (Firefox) */
  scrollbar-width: thin;
  scrollbar-color: rgba(210, 210, 210, 0.35) rgba(0, 0, 0, 0);
}

.right-panels-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: 1.2rem;
  width: 100%;
  height: 100%;
}

/* Right panel result summary */
.right-result-panel {
  width: 100%;
  max-width: none;
  height: 100%;
  overflow-y: auto;
}

.right-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

.right-result-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 10px rgba(217, 242, 11, 0.35);
}

.right-result-nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.result-nav-btn {
  width: 32px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(20, 20, 20, 0.65);
  color: #f2f2f2;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.18s ease;
}

.result-nav-btn:hover {
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(40, 40, 40, 0.7);
}

.result-nav-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.right-section {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1rem;
}

.right-section-title,
.right-subsection-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  color: var(--accent);
}

.right-section-title {
  font-size: 1.05rem;
}

.right-subsection-title {
  font-size: 0.98rem;
}

.right-section-title::before,
.right-subsection-title::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(217, 242, 11, 0.95);
  box-shadow: 0 0 10px rgba(217, 242, 11, 0.35);
}

.right-skill-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.right-skill-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 0.75rem;
  align-items: center;
}

.right-skill-row.is-inactive {
  opacity: 0.45;
  filter: grayscale(0.2);
}

.right-skill-row.is-missing {
  border: 1px dashed rgba(255, 80, 80, 0.85);
  background: rgba(255, 80, 80, 0.12);
  border-radius: 10px;
  padding: 4px 6px;
}

.right-skill-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;

  background: rgba(0, 0, 0, 0.25);
}

.right-skill-info {
  min-width: 0;
}

.right-skill-name {
  font-weight: 700;
  color: #fff;
  font-size: 1rem;
}

.right-skill-dots {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 4px;
}

.right-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid #666;
  background: rgba(255, 255, 255, 0.12);
}

.right-dot.active {
  border-color: rgba(217, 242, 11, 0.95);
  background: rgba(217, 242, 11, 0.95);
}

.right-skill-level {
  font-weight: 800;
  color: #c9b88a;
  font-size: 0.95rem;
}

.right-stat-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 0.25rem;
}

.right-stat-row {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 0.75rem;
  align-items: center;
}

.right-stat-icon {
  width: 48px;
  height: 48px;
  padding: 6px;
  border-radius: 12px;
  object-fit: contain;
  border: 1px solid #555;
  background: rgba(0, 0, 0, 0.25);
}

.right-stat-title {
  color: #fff;
  font-weight: 800;
  font-size: 0.98rem;
}

.right-stat-sub {
  color: #bdbdbd;
  font-weight: 650;
  font-size: 0.9rem;
}

/* Right panel equip list */
.right-equip-panel {
  width: 100%;
  max-width: none;
  height: 100%;
  overflow-y: auto;
}

.right-equip-header {
  margin-bottom: 0.65rem;
}

.right-equip-title {
  font-size: var(--right-equip-title-size);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 10px rgba(217, 242, 11, 0.3);
}

.right-equip-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.right-equip-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 0.85rem;
  align-items: center;
  padding: 0.4rem 0.3rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid rgba(255, 255, 255, 0.14);
}
.right-equip-row:last-child {
  border-bottom: none;
}

.right-equip-icon {
  width: 52px;
  height: 52px;
  padding: 8px;
  border-radius: 14px;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.25);
  border: 2px solid #555;
  box-sizing: border-box;
}

/* Tooltip */
.equip-tooltip {
  position: fixed;
  z-index: 9999;
  min-width: 240px;
  max-width: 320px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(20, 20, 24, 0.93);
  border: 1px solid rgba(130, 49, 222, 0.4);
  box-shadow:
    0 12px 24px rgba(0, 0, 0, 0.4),
    0 0 10px rgba(130, 49, 222, 0.35);
  color: #f1f1f1;
  pointer-events: none;
  backdrop-filter: blur(4px);
}
.equip-tooltip .muted {
  color: #b2b2b2;
}
.et-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.et-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: 1px solid #555;
}
.et-meta {
  flex: 1;
  min-width: 0;
}
.et-name {
  font-weight: 800;
  font-size: 1rem;
  margin-bottom: 2px;
  color: #fff;
}
.et-sub {
  font-size: 0.85rem;
  color: #d6d6d6;
  line-height: 1.2;
}
.et-block {
  margin-top: 6px;
}
.et-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #cfe6ff;
  margin-bottom: 4px;
}
.et-skill-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
}
.et-skill-row .lvl {
  color: #ffd16f;
  font-weight: 700;
}
.et-reason-item {
  font-size: 0.9rem;
  color: #e6e6e6;
  line-height: 1.35;
}
/* Right armor icon rarity tint (reuse the same rarity-icon logic as left) */
.right-equip-icon.rarity-icon {
  width: 52px;
  height: 52px;
  padding: 8px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.25);
  border: 2px solid #555;
  box-sizing: border-box;
  --icon-pad: 8px;
}

.right-equip-plus {
  position: absolute;
  top: 0px;
  left: 2px;
  font-weight: 900;
  font-size: 20px;
  line-height: 1;
  color: rgb(196, 110, 255);
  text-shadow:
    0 0 8px rgba(130, 49, 222, 0.9),
    0 0 2px rgba(0, 0, 0, 0.9);
  pointer-events: none;
}

.right-equip-text {
  min-width: 0;
}

.right-equip-name {
  font-weight: 600;
  color: #b4b4b4;
  font-size: var(--right-equip-name-size);
  line-height: 1.1;
}

.right-equip-sub {
  color: #ffffff;
  font-weight: 650;
  font-size: var(--right-equip-sub-size);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.right-equip-text .right-equip-name,
.right-equip-text .right-equip-sub {
  -webkit-text-stroke: 0.6px rgba(0, 0, 0, 0.95);
  paint-order: stroke fill;
  /* Fallback stroke using shadow for non-webkit engines */
  text-shadow:
    -1px 0 rgba(187, 136, 136, 0.85),
    1px 0 rgba(0, 0, 0, 0.85),
    0 -1px rgba(0, 0, 0, 0.85),
    0 1px rgba(0, 0, 0, 0.85),
    -1px -1px rgba(0, 0, 0, 0.55),
    1px -1px rgba(0, 0, 0, 0.55),
    -1px 1px rgba(0, 0, 0, 0.55),
    1px 1px rgba(0, 0, 0, 0.55);
}

.right-equip-meta {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.right-slot-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  --es: 0.8;
}

.right-slot-icon {
  width: 34px;
  height: 28px;
  object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.5));
}

.right-gem-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 80px;
}

.right-gem-item {
  color: #cfcfcf;
  font-size: var(--right-equip-gem-size);
  font-weight: 700;
  white-space: nowrap;
}

/* Modern gray scrollbar (Chromium/WebKit) */
.right-panel::-webkit-scrollbar {
  width: 10px;
}
.right-panel::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0);
}
.right-panel::-webkit-scrollbar-thumb {
  background: rgba(210, 210, 210, 0.28);
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, 0);
  background-clip: padding-box;
}
.right-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(210, 210, 210, 0.4);
}

/* Panels */
.panel {
  background: var(--panel);
  border-radius: 16px;
  padding: 1.25rem;
  border: 2px solid var(--border-2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.section-title {
  color: var(--accent);
  font-size: 1.35rem;
  margin-bottom: 0.9rem;
  font-weight: 650;
}

.subsection-title {
  font-size: 1.05rem;
  color: #fff;
  font-weight: 650;
  margin-bottom: 0.75rem;
}

.muted {
  color: var(--muted);
}

/* Left: skills list */
.skills-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.skill-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  background: rgba(40, 40, 40, 0.5);
  border-radius: 12px;
  border: 1px solid var(--border-2);
}

.skill-item.skill-optional {
  border: 2px dashed var(--accent, #d9f20b);
  border-radius: 12px;
}

.skill-item.skill-required {
  border: 2px dashed var(--accent, #d9f20b);
  border-radius: 12px;
}

.drag-handle {
  width: 18px;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 900;
  font-size: 16px;
  letter-spacing: -2px;
  cursor: grab;
  user-select: none;
}

.skill-item[draggable="true"] {
  cursor: grab;
}

.skill-item.is-dragging {
  opacity: 0.55;
}

.skill-item.is-drop-target {
  outline: 1px dashed rgba(217, 242, 11, 0.6);
  outline-offset: 2px;
}

.skill-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid #555;
  background: rgba(0, 0, 0, 0.3);
}

/* Equip modal uses a different icon size than skill icons */
.equip-part-icon {
  /* Prevent flex from squeezing the icon into a thin pill */
  flex: 0 0 var(--equip-modal-part-icon-size);
  min-width: var(--equip-modal-part-icon-size);
  width: var(--equip-modal-part-icon-size);
  height: var(--equip-modal-part-icon-size);
  border-radius: var(--equip-modal-part-icon-radius);
  border: 1px solid #555;
  background: rgba(0, 0, 0, 0.3);
  --icon-pad: var(--equip-modal-part-icon-pad);
}

.skill-info {
  flex: 1;
  min-width: 0;
}

.skill-name {
  font-weight: 650;
  color: #fff;
  font-size: 1rem;
  line-height: 1.2;
}

.skill-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.35rem;
}

.skill-level-label {
  color: #aaa;
  font-weight: 650;
  font-size: 0.9rem;
  white-space: nowrap;
}

.level-dots {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.level-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 1px solid #666;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition:
    transform 0.12s ease,
    background 0.12s ease,
    border-color 0.12s ease;
}

.level-dot.active {
  border-color: rgba(217, 242, 11, 0.9);
  background: rgba(217, 242, 11, 0.95);
}

.level-dot:hover {
  transform: translateY(-1px);
}

.skill-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid #555;
  background: rgba(0, 0, 0, 0.25);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  border-color: #777;
  background: rgba(0, 0, 0, 0.35);
}

.icon-btn img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.add-skill-button {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

.add-button {
  width: 100%;
  height: 56px;
  border: 2px dashed #666;
  background: transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.add-button:hover {
  border-color: #999;
  background: rgba(153, 153, 153, 0.1);
}

.plus-icon {
  color: #999;
  font-size: 1.8rem;
  font-weight: 650;
}

/* Equipment controls */
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.label {
  color: #bbb;
  font-size: 0.9rem;
  font-weight: 600;
}

.control {
  height: 42px;
  border-radius: 10px;
  border: 1px solid #555;
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  padding: 0 10px;
  outline: none;
  font-weight: 600;
}

.control:focus {
  border-color: rgba(217, 242, 11, 0.8);
  box-shadow: 0 0 0 3px rgba(217, 242, 11, 0.12);
}

.primary-button {
  width: 100%;
  height: 46px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #000;
  font-weight: 750;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.primary-button:hover {
  transform: translateY(-1px);
}

/* Center preview */
.character-stage {
  width: 100%;
  max-width: 520px;
  min-height: 720px;
  background: radial-gradient(
    900px 600px at 50% 35%,
    rgba(255, 255, 255, 0.06),
    rgba(0, 0, 0, 0.18)
  );
  border-radius: 16px;
  border: 2px solid #222;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: sticky; /* fixed inside center column frame */
  top: calc(var(--top-nav-height) + 14px);
  z-index: 1;
}

.character-stage img {
  width: 92%;
  max-height: 690px;
  object-fit: contain;
  filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.55));
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
}

/* Right: results */
.result-block {
  background: rgba(40, 40, 40, 0.35);
  border: 1px solid #444;
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.result-block:last-child {
  margin-bottom: 0;
}

.result-block-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 0.75rem;
}

.result-block-title b {
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
}

.badge {
  color: #000;
  background: var(--accent);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-weight: 750;
  font-size: 0.85rem;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.equip-list,
.needed-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.equip-row {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 0.75rem;
  align-items: center;
  padding: 0.65rem 0.75rem;
  background: rgba(20, 20, 20, 0.35);
  border: 1px solid #333;
  border-radius: 12px;
}

.equip-row img {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid #555;
}

.equip-row .equip-name {
  font-weight: 650;
  color: #fff;
  font-size: 0.95rem;
  line-height: 1.2;
}

.equip-row .equip-sub {
  color: #aaa;
  font-size: 0.85rem;
  margin-top: 2px;
}

.needed-item {
  padding: 0.65rem 0.75rem;
  background: rgba(20, 20, 20, 0.35);
  border: 1px solid #333;
  border-radius: 12px;
  color: #ddd;
  font-weight: 600;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 760px;
  width: calc(100% - 36px);
  background: rgba(10, 14, 20, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  color: rgba(255, 255, 255, 0.92);
  padding: 10px 12px;
  border-radius: 14px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  display: none;
  z-index: 999;
}

.toast.show {
  display: block;
}

.toast b {
  color: rgba(255, 255, 255, 0.95);
}

/* Skill tooltip (fade-in after 1s hover, better-looking) */
.skill-tooltip {
  position: fixed;
  z-index: 3000;
  max-width: 320px;
  background: rgba(20, 20, 20, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  opacity: 0;
  transform: translateY(6px) scale(0.98);
  transition:
    opacity 180ms cubic-bezier(0, 0.01, 0.18, 0.98),
    transform 180ms cubic-bezier(0, 0.01, 0.18, 0.98);
  pointer-events: none;
}

.skill-tooltip.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.skill-tooltip-title {
  color: rgba(217, 242, 11, 0.95);
  font-weight: 900;
  font-size: 13px;
  margin-bottom: 6px;
}

.skill-tooltip-body {
  color: #ddd;
  font-weight: 650;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-line;
}

/* Favorites (skills & combos) */
.fav-section {
  margin: 0.75rem 0 1rem;
  padding: 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(20, 20, 20, 0.4);
  display: grid;
  gap: 0.5rem;
}

.fav-title {
  font-weight: 800;
  color: var(--accent, #d9f20b);
  font-size: 0.95rem;
}

.fav-chips,
.fav-combo-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.fav-chip,
.fav-combo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #f6f6f6;
  font-weight: 700;
  font-size: 13px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  cursor: pointer;
  user-select: none;
}

.fav-chip .remove,
.fav-combo .remove {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.16);
}

.fav-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.fav-btn {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.1);
  color: #f6f6f6;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

.fav-btn.ghost {
  background: rgba(255, 255, 255, 0.05);
}

/* Modal (keep naming aligned with OLDTOOL) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: rgba(20, 20, 20, 0.95);
  border-radius: 16px;
  border: 2px solid #444;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  width: 90%;
  max-width: 900px;
  max-height: 90vh;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid #333;
}

.modal-header h2 {
  color: var(--accent);
  margin: 0;
  font-size: 1.5rem;
}

.close-button {
  background: none;
  border: none;
  color: #ccc;
  font-size: 2rem;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.close-button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.modal-body {
  padding: 1.5rem;
  max-height: calc(90vh - 100px);
  overflow-y: auto;
}

.skill-selector {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.search-container {
  margin-bottom: 0.2rem;
}

.search-input {
  width: 100%;
  padding: 1rem;
  border: 1px solid #444;
  border-radius: 8px;
  background: rgba(40, 40, 40, 0.5);
  color: #fff;
  font-size: 1rem;
  outline: none;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 242, 11, 0.12);
}

.categories-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.category-button {
  padding: 0.5rem 1rem;
  border: 1px solid #444;
  background: rgba(60, 60, 60, 0.8);
  color: #ccc;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 650;
}

.category-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.category-button.active {
  background: var(--accent);
  color: #000;
}

.skills-grid {
  /* Use a responsive grid so cards don't become overly wide on large screens */
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 0.75rem;
}

@media (max-width: 740px) {
  .skills-grid {
    grid-template-columns: 1fr;
  }
}

.equip-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* 武器類型篩選：skill-card 樣式，只選大劍／只選太刀… selected 狀態 */
.equip-weapon-type-bar .categories-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.equip-weapon-type-bar .weapon-type-filter-card {
  min-width: 100px;
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  transition:
    border-color 0.2s,
    background 0.2s;
}

.equip-weapon-type-bar .weapon-type-filter-card:hover {
  border-color: var(--accent);
}

.equip-weapon-type-bar .weapon-type-filter-card.selected {
  border-color: var(--accent);
  background: rgba(217, 242, 11, 0.15);
  color: var(--accent);
}

.equip-sort {
  display: flex;
  align-items: center;
  gap: 10px;
}

.equip-sort-label {
  color: #bbb;
  font-weight: 700;
  font-size: 0.95rem;
}

.equip-sort-select {
  height: 38px;
  border-radius: 10px;
  border: 1px solid #555;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  padding: 0 10px;
  outline: none;
  font-weight: 700;
}

.equip-sort-select:focus {
  border-color: rgba(217, 242, 11, 0.85);
  box-shadow: 0 0 0 3px rgba(217, 242, 11, 0.12);
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.25);
  color: #ddd;
  font-size: 12px;
  font-weight: 800;
  margin-right: 6px;
  margin-top: 6px;
}

.tag-chip.monster {
  border-color: rgba(217, 242, 11, 0.35);
  color: rgba(217, 242, 11, 0.95);
  background: rgba(217, 242, 11, 0.08);
}

.equip-skill-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.equip-skill-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.22);
  color: #cfcfcf;
  font-size: 12px;
  font-weight: 800;
}

/* Equip modal: skill icons (instead of skill id/text) */
.equip-skill-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
  align-items: center;
}

.equip-skill-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px 2px 6px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.22);
  color: #ddd;
  font-size: 12px;
  font-weight: 800;
  max-width: 100%;
}

.equip-skill-chip img {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.22);
}

.equip-skill-chip-text {
  color: #e6e6e6;
  font-weight: 300;
  white-space: nowrap;
}

.equip-skill-chip-value {
  color: rgba(217, 242, 11, 0.95);
  font-weight: 950;
}

.skill-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.1rem;
  background: rgba(40, 40, 40, 0.5);
  border-radius: 12px;
  border: 1px solid #444;
  cursor: pointer;
  transition: all 0.2s ease;
}

.skill-card:hover {
  border-color: #777;
  box-shadow: 0 4px 16px rgba(119, 119, 119, 0.1);
}

/* 選擇武器列表中的自訂機械武器：--accent 外框標註 */
.skill-card.weapon-card-custom {
  border-color: var(--accent, #d9f20b);
  box-shadow: 0 0 0 1px var(--accent, #d9f20b);
}

.skill-card.weapon-card-custom:hover {
  border-color: var(--accent, #d9f20b);
  box-shadow:
    0 0 0 1px var(--accent, #d9f20b),
    0 4px 16px rgba(217, 242, 11, 0.15);
}

.skill-card.favorite-skill {
  border: 2px dashed var(--accent, #d9f20b);
  border-radius: 12px;
}

.skill-card-left {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 0;
}

.skill-card-title {
  font-weight: 650;
  color: #fff;
  font-size: 1rem;
  line-height: 1.2;
}

.skill-card-sub {
  color: #aaa;
  font-size: 0.9rem;
  margin-top: 3px;
}

.skill-card-levels {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.level-chip {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid #666;
  display: grid;
  place-items: center;
  font-weight: 750;
  color: #ddd;
  background: rgba(0, 0, 0, 0.2);
}

.level-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.level-chip.active {
  border-color: rgba(217, 242, 11, 0.9);
  background: rgba(217, 242, 11, 0.95);
  color: #000;
}

/* 中間版型：1001px ≤ 寬度 ≤ 1300px，維持三欄但隱藏 stage、隱藏 3D，左右貼齊獲得更多空間。
   若要調整斷點，請同步修改 :root 的 --layout-compact-min / --layout-compact-max 與本 media 的 min-width/max-width 數值（media 無法使用 var()）。 */
@media (max-width: 1300px) and (min-width: 1001px) {
  .content-grid {
    grid-template-columns: minmax(320px, 1.95fr) 0fr minmax(
        var(--layout-compact-right-min),
        4.15fr
      );
    gap: 0.6rem;
  }
  /* 保留 stage 在 grid 流中（僅視覺隱藏），否則 right-panel 會掉到第二欄被壓成 0 寬 */
  .stage-panel {
    visibility: hidden;
    pointer-events: none;
    overflow: hidden;
    min-width: 0;
    width: 0;
  }
  #bg-canvas {
    display: none !important;
  }
  /* 右側欄填滿可用寬度，避免被 min-width 擠壓 */
  .right-panel {
    min-width: 0;
    width: 100%;
    align-items: stretch;
  }
  .right-panels-row {
    min-width: 0;
  }
  .right-result-panel,
  .right-equip-panel {
    min-width: 0;
  }
}

/* 小於 1165px 時 nav 只顯示「給我一顆星」「教學」 */
@media (max-width: 1164px) {
  .nav-center .nav-button:nth-child(1),
  .nav-center .nav-button:nth-child(2),
  .nav-center .nav-button:nth-child(3) {
    display: none;
  }
}

/* 小於 1100px 時縮小右側裝備面板字體 */
@media (max-width: 1099px) {
  .right-result-title {
    font-size: 1.1rem;
  }
  .right-equip-title {
    font-size: 1.75rem;
  }
  .right-equip-name {
    font-size: 0.98rem;
  }
  .right-equip-sub {
    font-size: 1.18rem;
  }
  .right-gem-item {
    font-size: 0.82rem;
  }
}

/* Mobile layout (single column, no 3D) — 1000px 以下為手機版 */
@media (max-width: 1000px) {
  :root {
    --top-nav-height: 60px;
  }

  html,
  body {
    height: auto;
    overflow: auto;
  }

  /* Disable 3D canvas on mobile */
  #bg-canvas {
    display: none !important;
  }

  .top-nav {
    padding: 0.75rem;
  }

  /* Keep header compact */
  .nav-center {
    display: none;
  }

  .main-content {
    height: auto;
    overflow: visible;
    padding: 0.75rem;
  }

  .content-grid {
    grid-template-columns: 1fr;
    gap: 0.9rem;
    height: auto;
  }

  /* Middle column is only for 3D debug panel; hide on mobile */
  .stage-panel {
    display: none;
  }

  .left-panel,
  .right-panel {
    min-width: 0;
    height: auto;
  }

  .left-search-panel,
  .right-panel {
    overflow: visible;
    padding-right: 0;
  }

  .right-panels-row {
    grid-template-columns: 1fr;
    height: auto;
  }

  .right-result-panel,
  .right-equip-panel {
    height: auto;
    overflow: visible;
  }

  /* Fixed footer is hard to use on small screens */
  .disclaimer-footer {
    position: static;
  }

  .app-container {
    padding-bottom: 1.5rem;
  }
}

/* ============================================
   Charm Customizer Styles
   ============================================ */

.charm-customizer-modal {
  max-width: 1000px;
  width: 85vw;
  max-height: 75vh;
  overflow: hidden;
}

/* Ensure charm customizer modal is above other modals */
#charmCustomizerModal.modal-overlay {
  z-index: 2000;
}

#charmCustomizerModal .modal-content {
  z-index: 2001;
}

.charm-customizer-body {
  padding: 0;
  overflow: hidden;
}

.charm-customizer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  height: calc(75vh - 80px);
  overflow: hidden;
}

/* Left Panel: Charm Editor */
.charm-editor-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.charm-preview-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
}

.charm-image-container {
  margin-bottom: 1rem;
}

.charm-preview-image {
  width: 80px;
  height: 80px;
  object-fit: contain;
}

.charm-name-input-wrapper {
  margin-top: 1rem;
}

.charm-name-input {
  width: 100%;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  text-align: center;
}

.charm-name-input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
}

.charm-editor-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

.editor-section-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.editor-skills-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
  min-height: 60px;
}

.editor-skill-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.editor-skill-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.editor-skill-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.editor-skill-name {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
}

.editor-skill-level-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.editor-skill-level-dots {
  display: flex;
  gap: 0.25rem;
}

.editor-skill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  cursor: pointer;
  transition: all 0.2s;
}

.editor-skill-dot.active {
  background: var(--accent);
}

.editor-skill-dot:hover {
  transform: scale(1.2);
}

.editor-skill-level-text {
  font-size: 0.85rem;
  color: var(--muted);
  min-width: 40px;
}

.editor-skill-remove {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0.25rem;
  font-size: 1.2rem;
  line-height: 1;
  transition: color 0.2s;
}

.editor-skill-remove:hover {
  color: #ff6b6b;
}

.add-skill-btn {
  width: 100%;
  padding: 0.75rem;
  background: rgba(217, 242, 11, 0.1);
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.add-skill-btn:hover {
  background: rgba(217, 242, 11, 0.2);
}

.plus-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.editor-slots-container {
  margin-bottom: 1rem;
  position: relative;
}

/* Slot Picker (from wilds-main) */
.slot-picker {
  display: inline-block;
  cursor: pointer;
  position: relative;
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.03);
  transition: all 0.2s;
}

.slot-picker:hover {
  border-color: var(--accent);
  background: rgba(217, 242, 11, 0.1);
}

.slot-picker:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.slot-trigger-image {
  display: block;
  max-width: 260px;
  height: auto;
  object-fit: contain;
}

.slot-trigger-fallback {
  padding: 0.5rem;
  color: var(--text);
  font-size: 0.9rem;
  text-align: center;
}

.slot-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0.5rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  z-index: 4000;
  max-width: 400px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.slot-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  background: rgba(255, 255, 255, 0.03);
}

.slot-option:hover {
  border-color: var(--accent);
  background: rgba(217, 242, 11, 0.1);
  transform: translateY(-2px);
}

.slot-option:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.slot-option-image {
  width: 60px;
  height: 60px;
  object-fit: contain;
}

.slot-option-caption {
  font-size: 0.85rem;
  color: var(--text);
  text-align: center;
}

.validation-message {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
  display: none;
}

.validation-message.error {
  display: block;
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid #ff6b6b;
  color: #ff6b6b;
}

.validation-message.warning {
  display: block;
  background: rgba(255, 193, 7, 0.1);
  border: 1px solid #ffc107;
  color: #ffc107;
}

.validation-message.success {
  display: block;
  background: rgba(76, 175, 80, 0.1);
  border: 1px solid #4caf50;
  color: #4caf50;
}

.charm-editor-actions {
  display: flex;
  gap: 1rem;
}

.btn-save-charm,
.btn-clear-editor {
  flex: 1;
  padding: 0.875rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.btn-save-charm {
  background: var(--accent);
  color: #000;
}

.btn-save-charm:hover:not(:disabled) {
  background: #c4d80a;
}

.btn-save-charm:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-clear-editor {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-clear-editor:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Right Panel: Charm Manager */
.charm-manager-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

.charm-type-toggle {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0 0.5rem;
}

.charm-type-btn {
  flex: 1;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.charm-type-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent);
}

.charm-type-btn.active {
  background: rgba(217, 242, 11, 0.2);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-select-charm {
  padding: 0.4rem 0.8rem;
  background: rgba(217, 242, 11, 0.15);
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--accent);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-select-charm:hover {
  background: rgba(217, 242, 11, 0.25);
}

.btn-select-charm.selected {
  background: rgba(217, 242, 11, 0.3);
  color: var(--accent);
  font-weight: 600;
}

.manager-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.manager-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.manager-actions {
  display: flex;
  gap: 0.75rem;
}

.btn-export-charms,
.btn-import-charms {
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-export-charms:hover,
.btn-import-charms:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent);
}

.search-box-wrapper {
  margin-bottom: 1rem;
}

.charm-search-input {
  width: 100%;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
}

.charm-search-input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
}

.charm-list-container {
  flex: 1;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.charm-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.charm-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  transition: all 0.2s;
  cursor: pointer;
}

.charm-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--accent);
}

.charm-card-selected {
  background: rgba(217, 242, 11, 0.1) !important;
  border-color: var(--accent) !important;
}

.charm-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.charm-card-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.charm-card-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-edit-charm,
.btn-delete-charm {
  padding: 0.375rem 0.75rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-edit-charm:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-delete-charm:hover {
  border-color: #ff6b6b;
  color: #ff6b6b;
}

.charm-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.charm-skills-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.skill-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text);
}

.skill-tag-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.charm-slots-preview {
  display: flex;
  gap: 0.5rem;
}

.slot-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.03);
}

.slot-badge.empty {
  color: var(--muted);
}

.slot-badge.level-1 {
  color: #4a9eff;
  border-color: #4a9eff;
}

.slot-badge.level-2 {
  color: #9d4edd;
  border-color: #9d4edd;
}

.slot-badge.level-3 {
  color: #ff6b6b;
  border-color: #ff6b6b;
}

.slot-badge.weapon-slot {
  color: var(--accent);
  border-color: var(--accent);
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}

.empty-state p {
  margin: 0;
  font-size: 1rem;
}

/* Charm Editor Skill Selector */
.charm-editor-skill-selector {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.skill-selector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.skill-selector-header h4 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.close-skill-selector-btn {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  transition: color 0.2s;
}

.close-skill-selector-btn:hover {
  color: var(--accent);
}

.skill-selector-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.5rem;
}

.charm-editor-section {
  position: relative;
}

.charm-editor-skill-selector {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.charm-editor-skill-selector > .skill-selector-container {
  width: 85vw;
  max-width: 1000px;
  height: 75vh;
  max-height: 75vh;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8);
}

.skill-selector-container {
  width: 85vw;
  max-width: 1000px;
  height: 75vh;
  max-height: 75vh;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8);
}

.skill-selector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
}

.skill-selector-header h4 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.close-skill-selector-btn {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  transition: color 0.2s;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.close-skill-selector-btn:hover {
  color: var(--accent);
  background: rgba(217, 242, 11, 0.1);
}

.skill-selector-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.skill-selector-body .search-container {
  flex-shrink: 0;
}

.skill-selector-body .search-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
}

.skill-selector-body .search-input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
}

.skill-selector-body .categories-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  flex-shrink: 0;
}

.skill-selector-body .category-button {
  padding: 0.4rem 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.skill-selector-body .category-button:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent);
}

.skill-selector-body .category-button.active {
  background: rgba(217, 242, 11, 0.2);
  border-color: var(--accent);
  color: var(--accent);
}

.skill-selector-body .skills-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
  padding: 0.5rem;
  background: rgba(20, 20, 20, 0.5);
  border-radius: 8px;
  border: 1px solid #333;
  flex: 1;
}

.skill-selector-body .skill-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  background: rgba(40, 40, 40, 0.8);
  border: 1px solid #444;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  min-height: 60px;
}

.skill-selector-body .skill-card:hover {
  border-color: #d9f20b;
  background: rgba(217, 242, 11, 0.1);
  transform: translateY(-1px);
}

.skill-selector-body .skill-card.selected {
  border-color: #d9f20b;
  background: rgba(217, 242, 11, 0.2);
}

.skill-selector-body .skill-card.favorite-skill {
  border: 2px dashed var(--accent, #d9f20b);
}

.skill-selector-body .skill-icon {
  width: auto;
  height: auto;
  max-width: 40px;
  max-height: 40px;
  object-fit: contain;
  flex-shrink: 0;
}

.skill-selector-body .skill-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.skill-selector-body .skill-name {
  font-size: 0.9rem;
  color: #fff;
  line-height: 1.2;
  font-weight: 500;
  white-space: normal;
  word-wrap: break-word;
  overflow: visible;
  text-overflow: clip;
}

.skill-selector-body .skill-level-info {
  font-size: 0.75rem;
  color: #d9f20b;
  font-weight: 400;
}

.skill-selector-body .available-levels {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.skill-selector-body .level-badge {
  background: rgba(217, 242, 11, 0.3);
  color: #d9f20b;
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 12px;
  font-weight: 500;
  border: 1px solid rgba(217, 242, 11, 0.5);
}

/* Responsive */
@media (max-width: 1200px) {
  .charm-customizer-grid {
    grid-template-columns: 1fr;
    height: auto;
    max-height: none;
  }

  .charm-editor-panel,
  .charm-manager-panel {
    max-height: 50vh;
  }
}

/* Disclaimer Footer */
.disclaimer-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.85);
  border-top: 1px solid var(--border, #333);
  padding: 0.75rem 1.5rem;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.disclaimer-content {
  max-width: var(--max-width, 1800px);
  margin: 0 auto;
  text-align: center;
}

.disclaimer-text {
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--muted, #999);
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.disclaimer-lang-zh,
.disclaimer-lang-en {
  display: block;
}

@media (min-width: 768px) {
  .disclaimer-text {
    flex-direction: row;
    justify-content: center;
    gap: 1.5rem;
  }

  .disclaimer-lang-zh::after {
    content: " |";
    margin-left: 0.5rem;
  }
}
