:root {
  --bg-game: #1a0f0a;
  --panel-bg: #2a1a12;
  --card-bg: #3d271d;
  --border-gold: #d4af37;
  --text-gold: #ffda79;
  --line-color: #8a6d4b;
}

/* ==========================================
   🏠 技能模擬器主容器 (限制寬度，解決變寬版的問題)
   ========================================== */
.simulator-container {
  background: var(--panel-bg);
  border: 3px solid var(--border-gold);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
  width: 100%;
  max-width: 650px;             /* 🔥 核心關鍵：鎖定最大寬度，防止拉伸變滿版 */
  margin: 40px auto;             /* 垂直與水平居中 */
  box-sizing: border-box;
}

.simulator-container * {
  box-sizing: border-box;
}

/* ==========================================
   🏷️ 頂部頁籤選單 (Tabs)
   ========================================== */
.simulator-container #tabsContainer {
  display: flex;
  flex-wrap: nowrap;          /* 強制不換行 */
  overflow-x: auto;           /* 開啟橫向滾動 */
  gap: 8px;
  padding: 6px 12px 10px 12px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border-gold);
  box-sizing: border-box;
  width: 100%;
  
  /* 美化滾動條 */
  scrollbar-width: thin;
  scrollbar-color: #ffd369 transparent;
}

.simulator-container .tab-btn {
  background: var(--card-bg);
  color: #a8927a;
  border: 1px solid var(--line-color);
  padding: 6px 16px;
  border-radius: 6px 6px 0 0;
  font-weight: bold;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  height: auto;
  line-height: normal;
  white-space: nowrap;        
  flex-shrink: 0;             
  box-sizing: border-box;
}

.simulator-container .tab-btn:hover {
  color: var(--text-gold);
  border-color: var(--border-gold);
}

.simulator-container .tab-btn.active {
  background: var(--border-gold);
  color: #000;
  border-color: var(--border-gold);
  box-shadow: 0 -2px 10px rgba(212, 175, 55, 0.4);
}

/* ==========================================
   🎛️ 頂部控制列 (Status Bar)
   ========================================== */
.simulator-container .status-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(26, 15, 10, 0.9);
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--border-gold);
  margin-bottom: 25px;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

/* 上層設定卡片容器 */
.simulator-container .controls-config-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: center;
}

/* 獨立控制小框 (Config Card) */
.simulator-container .config-card {
  display: inline-flex;
  align-items: center;
  background: rgba(42, 26, 18, 0.6);
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 6px;
  padding: 6px 12px;
  transition: border-color 0.2s, background-color 0.2s;
}

.simulator-container .config-card:hover {
  border-color: var(--border-gold);
  background: rgba(61, 39, 29, 0.8);
}

/* 下層動作列 (點數 + 重置鈕) */
.simulator-container .controls-action-group {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}

.simulator-container .point-status-bar {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* 下拉選單與 Checkbox 微調 */
.simulator-container .config-card label {
  color: var(--text-gold);
  font-size: 0.85rem;
  font-weight: bold;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  margin: 0;
}

.simulator-container .config-card select {
  background: var(--card-bg);
  color: #fff;
  border: 1px solid var(--border-gold);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  margin-left: 4px;
}

.simulator-container select:hover,
.simulator-container select:focus {
  border-color: #ffeaa7;
  box-shadow: 0 0 6px rgba(212, 175, 55, 0.5);
}

.simulator-container input[type="checkbox"] {
  accent-color: var(--border-gold);
  width: 15px;
  height: 15px;
  cursor: pointer;
  vertical-align: middle;
}

/* 右側點數與重置按鈕區塊 */
.simulator-container .point-summary,
.simulator-container .points-badge-group {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;          
}

.simulator-container .point-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--border-gold);
  padding: 4px 12px;
  border-radius: 20px;
  color: #ddd;
  font-size: 0.85rem;
  white-space: nowrap;
}

.simulator-container .point-badge.used {
  border-color: #666;         
}

.simulator-container .point-badge .value,
.simulator-container .point-badge .highlight-point {
  color: var(--text-gold);
  font-weight: bold;
  font-size: 0.95rem;
}

.simulator-container .point-badge .sub-label {
  color: #aaa;
  font-size: 0.75rem;
  margin-left: 2px;
}

.simulator-container #resetBtn,
.simulator-container .btn-reset {
  background: linear-gradient(180deg, #990000 0%, #590000 100%);
  color: #fff;
  border: 1px solid #ff4d4d;
  padding: 5px 14px;
  border-radius: 6px;
  font-weight: bold;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.simulator-container #resetBtn:hover,
.simulator-container .btn-reset:hover {
  background: linear-gradient(180deg, #cc0000 0%, #800000 100%);
  border-color: #ff8080;
  box-shadow: 0 0 8px rgba(255, 77, 77, 0.6);
}

/* ==========================================
   🌳 技能樹畫布區域
   ========================================== */
.simulator-container .skill-tree-wrapper {
  position: relative;
  width: 100%;
  min-height: 400px;
}

.simulator-container .tree-svg-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}

.simulator-container .skill-tree-grid {
  display: grid;
  grid-template-columns: repeat(2, 80px); /* 固定 2 欄 */
  grid-auto-rows: 85px;                   /* 每列固定高度 */
  justify-content: center;
  gap: 20px 50px;                         
  padding: 20px;
  position: relative;
  z-index: 2;
}

.simulator-container .grid-skill-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  justify-self: center;
}

.simulator-container .node-icon-box {
  width: 45px;
  height: 45px;
  background: #ffd369;
  border: 2px solid var(--border-gold);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 8px rgba(0,0,0,0.4);
  cursor: pointer;
  transition: transform 0.15s;
}

.simulator-container .node-icon-box:hover {
  transform: scale(1.08);
}

.simulator-container .node-icon-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.simulator-container .grid-skill-node.locked .node-icon-box {
  filter: grayscale(100%);
  opacity: 0.4;
}

/* ==========================================
   💊 技能等級控制列 (膠囊外殼造型)
   ========================================== */
.simulator-container .node-status-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-top: 6px;
  
  /* 膠囊造型核心：深色半透明背景，遮擋 SVG 連線 */
  background: rgba(20, 10, 5, 0.95);
  border: 1px solid var(--border-gold);
  border-radius: 20px;
  padding: 2px 6px;
  
  position: relative;
  z-index: 5;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
}

.simulator-container .level-text {
  color: #5cbeff;
  font-weight: bold;
  font-size: 0.8rem;
  text-shadow: 1px 1px 2px #000;
  min-width: 32px;
  text-align: center;
  user-select: none;
}

.simulator-container .btn-step {
  background: #ffcc00;
  color: #d30000;
  border: 1px solid #d30000;
  font-weight: bold;
  font-size: 0.8rem;
  width: 18px;
  height: 18px;
  line-height: 16px;
  text-align: center;
  padding: 0;
  cursor: pointer;
  border-radius: 50%; /* 圓形加減鈕 */
  transition: all 0.15s ease;
  user-select: none;
}

.simulator-container .btn-minus {
  background: #444;
  color: #ccc;
  border-color: #666;
}

.simulator-container .btn-step:hover:not(.disabled) {
  background: #fff;
  transform: scale(1.1);
}

.simulator-container .btn-step.disabled {
  opacity: 0.25;
  cursor: not-allowed;
  filter: grayscale(100%);
}

/* ==========================================
   💬 Tooltip 浮動說明視窗
   ========================================== */
.skill-tooltip {
  position: fixed;
  z-index: 99999;
  background: rgba(26, 15, 10, 0.95);
  border: 2px solid var(--border-gold);
  border-radius: 6px;
  padding: 10px 14px;
  max-width: 260px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  box-sizing: border-box;
}

.skill-tooltip.hidden {
  display: none !important;
}

.skill-tooltip .tt-title {
  color: var(--text-gold);
  font-weight: bold;
  font-size: 1rem;
  margin-bottom: 2px;
}

.skill-tooltip .tt-type,
.skill-tooltip .tt-req {
  font-size: 0.75rem;
  color: #a8927a;
  margin-top: 2px;
}

.skill-tooltip .tt-divider {
  border: none;
  border-top: 1px solid #5c3a21;
  margin: 8px 0;
}

.skill-tooltip .tt-desc {
  font-size: 0.8rem;
  color: #f0e6d2;
  line-height: 1.4;
  white-space: pre-line;
}

/* ==========================================
   ☀️ 技能模擬器 - 白天 (Light Mode) 相容修正
   ========================================== */
[data-theme="light"] {
  /* 覆蓋技能樹專屬變數 */
  --bg-game: #f4f5f7;
  --panel-bg: rgba(255, 255, 255, 0.85);
  --card-bg: #ffffff;
  --border-gold: #c05621;
  --text-gold: #9c4221;       /* 改為深橘褐色，解決原本亮黃色文字在淺色背景看不到的問題 */
  --line-color: #cbd5e1;
}

/* 頂部控制列與小框改為淺色透光背景 */
[data-theme="light"] .simulator-container .status-bar {
  background: rgba(245, 247, 250, 0.9);
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .simulator-container .config-card {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(192, 86, 33, 0.3);
}

[data-theme="light"] .simulator-container .config-card:hover {
  background: #ffffff;
}

/* 下拉選單與 Label 文字色彩修正 */
[data-theme="light"] .simulator-container .config-card select {
  background: #ffffff;
  color: #2d3748;             /* 改為深色字，防止下拉選單變成白字白底 */
  border-color: var(--border-gold);
}

/* 點數徽章修正 */
[data-theme="light"] .simulator-container .point-badge {
  background: rgba(255, 255, 255, 0.9);
  color: #2d3748;
  border-color: var(--border-gold);
}

[data-theme="light"] .simulator-container .point-badge .sub-label {
  color: #718096;
}

/* 頁籤選單 (Tabs) 修正 */
[data-theme="light"] .simulator-container .tab-btn {
  background: rgba(255, 255, 255, 0.6);
  color: #4a5568;
}

[data-theme="light"] .simulator-container .tab-btn.active {
  background: var(--border-gold);
  color: #ffffff;
}

/* Tooltip 浮動說明視窗修正 */
[data-theme="light"] .skill-tooltip {
  background: rgba(255, 255, 255, 0.96);
  border-color: var(--border-gold);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .skill-tooltip .tt-title {
  color: var(--text-gold);
}

[data-theme="light"] .skill-tooltip .tt-type,
[data-theme="light"] .skill-tooltip .tt-req {
  color: #718096;
}

[data-theme="light"] .skill-tooltip .tt-divider {
  border-top-color: #e2e8f0;
}

[data-theme="light"] .skill-tooltip .tt-desc {
  color: #2d3748;
}

/* 膠囊外殼背景修正 */
[data-theme="light"] .simulator-container .node-status-line {
  background: rgba(255, 255, 255, 0.95);
  border-color: var(--border-gold);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* 顯示數值文字顏色修正 */
[data-theme="light"] .simulator-container .level-text {
  color: #0066cc;
  text-shadow: none;
}

/* 減號按鈕 (-) 修正 */
[data-theme="light"] .simulator-container .btn-minus {
  background: #e2e8f0;
  color: #4a5568;
  border-color: #cbd5e1;
}

/* 減號按鈕 hover 效果 */
[data-theme="light"] .simulator-container .btn-minus:hover:not(.disabled) {
  background: #cbd5e1;
  color: #1a202c;
}

.point-number-input {
  width: 60px;
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  background-color: rgba(0, 0, 0, 0.3);
  color: #fff;
  font-size: 14px;
  text-align: center;
}

.point-number-input:focus {
  outline: none;
  border-color: #4a90e2;
  box-shadow: 0 0 5px rgba(74, 144, 226, 0.5);
}

.unit-text {
  font-size: 13px;
  color: #aaa;
  margin-left: 4px;
}

/* 白天模式：補齊點數輸入與技能節點控制列的對比 */
[data-theme="light"] .simulator-container {
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
}

[data-theme="light"] .simulator-container #tabsContainer {
  scrollbar-color: var(--border-gold) transparent;
}

[data-theme="light"] .simulator-container .point-number-input {
  background-color: #ffffff;
  border-color: #cbd5e1;
  color: #2d3748;
}

[data-theme="light"] .simulator-container .unit-text {
  color: #64748b;
}

[data-theme="light"] .simulator-container .node-icon-box {
  background: #fff7ed;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.14);
}

[data-theme="light"] .simulator-container .btn-step:not(.btn-minus) {
  background: #fbbf24;
  color: #7c2d12;
  border-color: #d97706;
}

[data-theme="light"] .simulator-container .btn-step:hover:not(.disabled) {
  background: #fef3c7;
}
