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

#debug-badge {
  position: fixed;
  bottom: 8px;
  right: 8px;
  padding: 3px 8px;
  background: #ff0044;
  color: #fff;
  font: bold 10px 'JetBrains Mono', monospace;
  letter-spacing: 1.5px;
  border-radius: 2px;
  z-index: 10000;
  pointer-events: none;
  opacity: 0.85;
}

::selection {
  background-color: #ffffff;
  color: #000000;
}

body {
  overflow: hidden;
  background: #000;
  font-family: 'Space Grotesk', 'Pretendard Variable', 'Apple SD Gothic Neo', sans-serif;
  color: #e8e8e8;
  user-select: none;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#canvas-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* ══════════════════════════════════════════════════════════════
   Panel Base
   ══════════════════════════════════════════════════════════════ */

.panel {
  position: fixed;
  background: #000;
  border: 2px solid #fff;
  z-index: 10;
  color: #fff;
  /* Short-viewport handling: cap at viewport height and let the active tab
     scroll, so shortcut lists at the bottom of Settings stay reachable. */
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
}
.panel > .panel-drag { flex: 0 0 auto; }

/* Pin main panel to the Network tab's natural height so tab switches don't
   reflow the outer size. Components: header (~135px) + core item (~40px) +
   hierarchy-list (50vh) + bulk row (~35px) + add-path button (~50px). Stats
   and Settings fill the same envelope — short content leaves space, long
   content scrolls within the tab. */
#panel-main { height: calc(50vh + 260px); }
/* Collapsed: release the fixed height so only the header (Energy display)
   remains — without this override the outer box stays the same size and
   visually "nothing happens" when you click the minus button. */
#panel-main.collapsed { height: auto; }

.panel-drag {
  cursor: grab;
  user-select: none;
}

.panel-drag:active {
  cursor: grabbing;
}

/* ══════════════════════════════════════════════════════════════
   Tabs
   ══════════════════════════════════════════════════════════════ */

.tabs {
  display: flex;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.tab {
  flex: 1;
  background: #000;
  color: #fff;
  border: none;
  padding: 12px 8px;
  font-family: 'Space Grotesk', 'Pretendard Variable', 'Apple SD Gothic Neo', sans-serif;
  font-size: 16px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab:not(:last-child) {
  border-right: 1px solid rgba(255, 255, 255, 0.15);
}

.tab:hover {
  background: #222;
}

.tab.active {
  background: #fff;
  color: #000;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  /* Hide horizontal overflow: the vertical scrollbar eats a few px of width
     and browsers can report a phantom horizontal overflow during that reflow. */
  overflow-x: hidden;
}

/* ══════════════════════════════════════════════════════════════
   Gain Popup (resource +N float-up)
   ══════════════════════════════════════════════════════════════ */

.gain-popup {
  position: fixed;
  pointer-events: none;
  font-family: 'JetBrains Mono', 'Pretendard Variable', monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.3px;
  color: #fff;
  z-index: 8;
  transform: translate(-50%, -50%);
  animation: gain-float 0.9s ease-out forwards;
  font-variant-numeric: tabular-nums;
  --gain-scale: 1;
}

@keyframes gain-float {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(calc(var(--gain-scale) * 0.7)); }
  20%  { opacity: 1; transform: translate(-50%, -80%) scale(var(--gain-scale)); }
  100% { opacity: 0; transform: translate(-50%, -200%) scale(var(--gain-scale)); }
}

/* ══════════════════════════════════════════════════════════════
   Offline Progress Toast (shown on load after a save gap)
   ══════════════════════════════════════════════════════════════ */

.offline-toast {
  position: fixed;
  top: 40px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 10px 18px;
  background: rgba(10, 14, 20, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
  color: #fff;
  z-index: 1000;
  opacity: 0;
  animation: offline-toast-in 0.35s ease-out forwards;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.offline-toast.fade {
  animation: offline-toast-out 1.2s ease-in forwards;
}
.offline-toast-label {
  font-size: 11px;
  letter-spacing: 1.2px;
  color: rgba(255, 255, 255, 0.55);
}
.offline-toast-gain {
  font-size: 16px;
  font-weight: 600;
  color: #aaddff;
}
.offline-toast-time {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
}
@keyframes offline-toast-in {
  0%   { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes offline-toast-out {
  0%   { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-8px); }
}

/* ══════════════════════════════════════════════════════════════
   Tutorial Tooltip (floats near the current step's target element)
   ══════════════════════════════════════════════════════════════ */

.tutorial-tooltip {
  position: fixed;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  max-width: min(360px, 90vw);
  background: rgba(10, 14, 20, 0.92);
  border: 1px solid rgba(170, 221, 255, 0.35);
  border-radius: 6px;
  color: #fff;
  z-index: 999;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45), 0 0 12px rgba(170, 221, 255, 0.25);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  --tut-arrow-x: 50%;
}
.tut-step {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 1.4px;
  color: rgba(170, 221, 255, 0.9);
  flex-shrink: 0;
}
.tut-msg {
  flex: 1;
  font-family: 'Space Grotesk', 'Pretendard Variable', sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: #fff;
}
.tut-next {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 4px 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  flex-shrink: 0;
}
.tut-next:hover { background: #fff; color: #000; }

/* Arrow tail — CSS triangle via borders, positioned at the target's center
   (tracked via --tut-arrow-x so it still points at the target when the
   tooltip is clamped away from center). */
.tutorial-tooltip::before,
.tutorial-tooltip::after {
  content: '';
  position: absolute;
  left: var(--tut-arrow-x);
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left:  8px solid transparent;
  border-right: 8px solid transparent;
}
.tutorial-tooltip.above-target::before {
  bottom: -9px;
  border-top: 9px solid rgba(170, 221, 255, 0.45);
}
.tutorial-tooltip.above-target::after {
  bottom: -7px;
  border-top: 8px solid rgba(10, 14, 20, 0.92);
}
.tutorial-tooltip.below-target::before {
  top: -9px;
  border-bottom: 9px solid rgba(170, 221, 255, 0.45);
}
.tutorial-tooltip.below-target::after {
  top: -7px;
  border-bottom: 8px solid rgba(10, 14, 20, 0.92);
}
.tutorial-tooltip.floating::before,
.tutorial-tooltip.floating::after { display: none; }

/* One-shot fade-in replayed on every step advance (JS toggles the class).
   Kept to opacity-only — a scale transform also distorts the arrow pseudo-
   elements which looks jittery. */
.tutorial-tooltip.tut-advancing { animation: tut-advance 0.22s ease-out; }
@keyframes tut-advance {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}

/* Pulse outline on tutorial target elements — uses box-shadow so it doesn't
   shift layout or interfere with existing borders. */
.tutor-highlight {
  box-shadow: 0 0 0 2px rgba(170, 221, 255, 0.8), 0 0 14px 4px rgba(170, 221, 255, 0.35);
  animation: tutor-pulse 1.4s ease-in-out infinite;
  border-radius: 4px;
  position: relative;
  z-index: 1;
}
@keyframes tutor-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(170, 221, 255, 0.8), 0 0 14px 4px rgba(170, 221, 255, 0.35); }
  50%      { box-shadow: 0 0 0 2px rgba(170, 221, 255, 1.0), 0 0 22px 8px rgba(170, 221, 255, 0.55); }
}

/* Small action button for settings rows (REPLAY etc.) */
.settings-btn {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 4px 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.settings-btn:hover { background: #fff; color: #000; }

/* ══════════════════════════════════════════════════════════════
   Collapse button (main panel)
   ══════════════════════════════════════════════════════════════ */

.btn-collapse {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 22px;
  height: 22px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 2;
  transition: background 0.15s, border-color 0.15s;
}

.btn-collapse:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: #fff;
}

.btn-collapse::before {
  content: '';
  width: 10px;
  height: 2px;
  background: #fff;
}

#panel-main.collapsed .btn-collapse::after,
#panel-achievements.collapsed .btn-collapse::after {
  content: '';
  position: absolute;
  width: 2px;
  height: 10px;
  background: #fff;
}

#panel-main.collapsed .tabs,
#panel-main.collapsed .tab-content {
  display: none;
}

#panel-main.collapsed .resource-display {
  border-bottom: none;
}

/* ══════════════════════════════════════════════════════════════
   Energy Display (top of panel, above tabs)
   ══════════════════════════════════════════════════════════════ */

.resource-display {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  column-gap: 6px;
  padding: 18px 18px 16px;
  border-bottom: 2px solid #fff;
}

.resource-label {
  grid-column: 1 / -1;
  font-family: 'Space Grotesk', 'Pretendard Variable', 'Apple SD Gothic Neo', sans-serif;
  font-size: 12px;
  letter-spacing: 4px;
  color: #888;
  margin-bottom: 6px;
}

#resource-value {
  font-family: 'JetBrains Mono', 'Pretendard Variable', monospace;
  font-size: 42px;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}

.resource-unit {
  font-family: 'Space Grotesk', 'Pretendard Variable', 'Apple SD Gothic Neo', sans-serif;
  font-size: 14px;
  letter-spacing: 2px;
  color: #888;
  align-self: baseline;
}

/* ══════════════════════════════════════════════════════════════
   Add Path Button (bottom of hierarchy list)
   ══════════════════════════════════════════════════════════════ */

.btn-add-path {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: #000;
  color: #fff;
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  padding: 16px 18px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-add-path:hover {
  background: #fff;
  color: #000;
}

.btn-add-path .add-label {
  font-family: 'Space Grotesk', 'Pretendard Variable', 'Apple SD Gothic Neo', sans-serif;
  font-size: 16px;
  letter-spacing: 2px;
}

.btn-add-path .add-price {
  font-family: 'JetBrains Mono', 'Pretendard Variable', monospace;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
}

.path-bulk-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 18px 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.path-bulk-label {
  font: 700 9px 'JetBrains Mono', monospace;
  letter-spacing: 1.5px;
  color: rgba(255, 255, 255, 0.45);
  margin-right: 4px;
}

/* ══════════════════════════════════════════════════════════════
   Hierarchy List
   ══════════════════════════════════════════════════════════════ */

.hierarchy-list {
  /* Flex-grow within the Network tab (which is flex column) so the list
     absorbs any excess panel height — keeps + PATH pinned to the bottom and
     the list the same size as before across the panel's fixed envelope. */
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
#tab-network.active,
#tab-stats.active {
  display: flex;
  flex-direction: column;
}

/* Virtualized list surface: #paths-list's own height = rowCount × ROW_H,
   rows are absolute-positioned at their row index, only visible rows in DOM. */
#paths-list {
  position: relative;
}

.core-item {
  position: relative;
  border-bottom: 1px solid rgba(255, 255, 255, 0.25);
  border-top: none;
  padding-left: 18px;
}

.core-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #fff;
}

.hierarchy-item {
  position: absolute;
  left: 0;
  right: 0;
  box-sizing: border-box;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  transition: background 0.1s, color 0.1s;
}

/* [CORE] sits above the virtualized list and stays in normal flow. Taller
   than a normal row so it reads as the featured root of the tree, not just
   another entry. flex: 0 0 auto pins the height — default flex-shrink would
   let the flex column squeeze the row back down to match the list. */
.hierarchy-item.core-item {
  position: relative;
  flex: 0 0 56px;
  height: 56px;
}

.hierarchy-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.hierarchy-list .hierarchy-item.selected {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  box-shadow: inset 3px 0 0 #fff;
}

.hierarchy-list .hierarchy-item.selected .item-info {
  color: #aaa;
}

.hierarchy-item .item-label {
  font-family: 'Space Grotesk', 'Pretendard Variable', 'Apple SD Gothic Neo', sans-serif;
  font-size: 15px;
  letter-spacing: 1.2px;
  flex: 1;
}

.hierarchy-item .item-info {
  font-family: 'JetBrains Mono', 'Pretendard Variable', monospace;
  font-size: 12px;
  color: #888;
  letter-spacing: 0.5px;
  font-variant-numeric: tabular-nums;
}

.hierarchy-item.selected .item-info {
  color: #444;
}

.core-item .item-label {
  font-size: 16px;
  letter-spacing: 2px;
}

/* Path growth animation — paths-list and Inspector indicator */
.hierarchy-item.growing .gen-info {
  color: #7be3a8;
  font-weight: 500;
}
.hierarchy-item.growing .gen-pct {
  color: #7be3a8;
  font-variant-numeric: tabular-nums;
}
.hierarchy-item .gen-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: rgba(255, 255, 255, 0.04);
  overflow: hidden;
}
.hierarchy-item .gen-bar-fill {
  height: 100%;
  background: #7be3a8;
  transition: width 0.12s linear;
}

.insp-gen-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -2px -2px 10px -2px;
  padding: 6px 10px;
  background: rgba(123, 227, 168, 0.08);
  border: 1px solid rgba(123, 227, 168, 0.25);
  border-radius: 3px;
  font-family: 'JetBrains Mono', 'Pretendard Variable', monospace;
  font-size: 12px;
  letter-spacing: 1px;
}
.insp-gen-label {
  color: #7be3a8;
  font-weight: 600;
}
.insp-gen-pct {
  color: #7be3a8;
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}
.insp-gen-bar {
  flex-basis: 100%;
  order: 3;
  height: 2px;
  margin-top: 2px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.insp-gen-bar-fill {
  height: 100%;
  background: #7be3a8;
  transition: width 0.12s linear;
}
.insp-gen-banner-multi {
  justify-content: center;
}

/* ══════════════════════════════════════════════════════════════
   Settings
   ══════════════════════════════════════════════════════════════ */

.setting-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.setting-row label {
  font-family: 'Space Grotesk', 'Pretendard Variable', 'Apple SD Gothic Neo', sans-serif;
  font-size: 13px;
  letter-spacing: 1.5px;
  color: #ccc;
  min-width: 110px;
}

.setting-row input[type="range"] {
  flex: 1 1 0;
  /* Range inputs default to an intrinsic min-width (thumb + some track); that
     plus the label width + value span can exceed the scrolled tab's usable
     width and force a horizontal scrollbar. min-width:0 lets flex shrink. */
  min-width: 0;
  height: 3px;
  accent-color: #fff;
  cursor: pointer;
}

.setting-row input[type="checkbox"] {
  accent-color: #fff;
  cursor: pointer;
  width: 16px;
  height: 16px;
}

.settings-select {
  flex: 1 1 0;
  min-width: 0;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 6px 10px;
  font-family: 'Space Grotesk', 'Pretendard Variable', sans-serif;
  font-size: 12px;
  letter-spacing: 1px;
  cursor: pointer;
}
.settings-select:hover { border-color: rgba(255, 255, 255, 0.25); }
.settings-select option { background: #111; color: #fff; }

#speed-value {
  font-family: 'JetBrains Mono', 'Pretendard Variable', monospace;
  font-size: 14px;
  color: #fff;
  min-width: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Stats tab ── */
.stats-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.stats-key {
  font-family: 'Space Grotesk', 'Pretendard Variable', 'Apple SD Gothic Neo', sans-serif;
  font-size: 12px;
  letter-spacing: 1.5px;
  color: #999;
}
.stats-val {
  font-family: 'JetBrains Mono', 'Pretendard Variable', monospace;
  font-size: 15px;
  color: #fff;
  font-variant-numeric: tabular-nums;
}
#stats-dps { color: #aaddff; }
.stats-section-title {
  font-family: 'Space Grotesk', 'Pretendard Variable', 'Apple SD Gothic Neo', sans-serif;
  font-size: 12px;
  letter-spacing: 1.8px;
  color: #888;
  padding: 12px 18px 6px;
}
.stats-path-list {
  /* Fills the remaining Stats tab height — header rows sit at top, the
     per-path DPS list scrolls internally across whatever space is left. */
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
/* Virtualized surface: explicit height = rowCount × 30 gives scrollbar range
   for absolute-positioned rows above. */
.stats-path-surface {
  position: relative;
}
.stats-path-row {
  position: absolute;
  left: 0;
  right: 0;
  box-sizing: border-box;
  height: 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 18px;
  font-family: 'JetBrains Mono', 'Pretendard Variable', monospace;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.stats-path-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.stats-path-label { color: #ccc; min-width: 32px; }
.stats-path-counts { color: #888; flex: 1; }
.stats-path-dps { color: #aaddff; }

/* ══════════════════════════════════════════════════════════════
   Inspector (3D-anchored floating)
   ══════════════════════════════════════════════════════════════ */

.inspector {
  width: 360px;
  z-index: 11;
  pointer-events: auto;
  transition: opacity 0.15s;
}

.inspector .inspector-header {
  cursor: grab;
}

.inspector .inspector-header:active {
  cursor: grabbing;
}

/* SVG connector line: inspector ↔ selection center */
.connector {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9;
  display: none;
}

#connector-line,
#tree-connector-line {
  stroke: #ffffff;
  stroke-width: 2;
  fill: none;
}

#connector-dot,
#tree-connector-dot {
  fill: #ffffff;
  stroke: none;
}

.inspector-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: #fff;
  color: #000;
  font-family: 'Space Grotesk', 'Pretendard Variable', 'Apple SD Gothic Neo', sans-serif;
  font-size: 14px;
  letter-spacing: 2px;
}

#inspector-title {
  flex: 1;
}

#inspector-close,
#catalog-close,
#core-status-close {
  background: none;
  border: none;
  color: #000;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  font-weight: bold;
}

#inspector-close:hover,
#catalog-close:hover,
#core-status-close:hover {
  color: #888;
}

#inspector-focus {
  background: none;
  border: 1px solid transparent;
  color: #000;
  padding: 2px 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}

#inspector-focus:hover {
  border-color: #000;
}

#inspector-focus.active {
  background: #000;
  color: #fff;
}

#core-focus {
  background: none;
  border: 1px solid transparent;
  color: #000;
  padding: 2px 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
#core-focus:hover { border-color: #000; }
#core-focus.active { background: #000; color: #fff; }

.inspector-body {
  padding: 10px 12px;
  max-height: 320px;
  overflow-y: auto;
  /* Required so virt cards' absolute positioning + scrollTop math share this origin. */
  position: relative;
}

.insp-section {
  margin-bottom: 10px;
}

.insp-section:last-child {
  margin-bottom: 0;
}

.insp-section-title {
  font-family: 'Space Grotesk', 'Pretendard Variable', 'Apple SD Gothic Neo', sans-serif;
  font-size: 12px;
  letter-spacing: 2px;
  color: #888;
  margin-bottom: 4px;
  padding-bottom: 3px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.insp-section-title.insp-subtitle {
  margin-top: 8px;
  font-size: 11px;
  color: #666;
  border-bottom: none;
  padding-bottom: 0;
}

.insp-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 13px;
  font-family: 'JetBrains Mono', 'Pretendard Variable', monospace;
}

.insp-row .key {
  color: #888;
  letter-spacing: 0.5px;
}

.insp-row .val {
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.insp-row .val.mixed {
  color: #666;
}

/* Section header (title + capacity + ADD button) */
.insp-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.insp-section-header .insp-section-title {
  margin: 0;
  padding: 0;
  border-bottom: none;
  flex: 1;
}

.insp-cap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: 'JetBrains Mono', 'Pretendard Variable', monospace;
  font-size: 12px;
  color: #aaa;
  font-variant-numeric: tabular-nums;
}

/* Properties row: horizontal flow with dot separators */
.insp-prop-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-family: 'JetBrains Mono', 'Pretendard Variable', monospace;
  font-size: 13px;
  padding: 4px 0 8px;
}

.insp-prop {
  display: inline-flex;
  gap: 4px;
  align-items: baseline;
}

.insp-prop + .insp-prop::before,
.insp-prop + .insp-swatch::before {
  content: '·';
  color: #444;
  margin-right: 4px;
}

.insp-shader-select {
  background: #111;
  color: #ddd;
  border: 1px solid #333;
  padding: 2px 4px;
  font: 10px 'JetBrains Mono', monospace;
  letter-spacing: 0.5px;
  border-radius: 2px;
  cursor: pointer;
}
.insp-shader-select:hover { border-color: #555; }
.insp-shader-select:focus { outline: 1px solid #555; }

.insp-prop .k {
  color: #666;
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.insp-prop .v {
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.insp-prop .v.mixed {
  color: #555;
}

/* Cards */
.insp-cards {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.insp-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}

/* Virtual scrolling: only the cards in the viewport are in the DOM at any time.
   Container holds absolute-positioned cards at pre-computed y offsets so
   1000-card selections cost ~15 DOM nodes instead of thousands. */
.insp-cards.insp-virt {
  position: relative;
  display: block;
}
.insp-cards.insp-virt > .insp-card {
  position: absolute;
  left: 0;
  right: 0;
  margin: 0;
  box-sizing: border-box;
}
.insp-cards.insp-virt[data-virt-workers] > .insp-card { height: 72px; }
.insp-cards.insp-virt[data-virt-buildings] > .insp-card { height: 120px; }

.insp-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.2);
}

.insp-card-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'JetBrains Mono', 'Pretendard Variable', monospace;
  font-size: 12px;
}

.insp-card-row .k {
  color: #666;
  font-size: 11px;
  text-transform: uppercase;
}

.insp-card-row .tag {
  font-family: 'Space Grotesk', 'Pretendard Variable', 'Apple SD Gothic Neo', sans-serif;
  font-size: 11px;
  padding: 1px 4px;
  border: 1px solid #555;
  color: #aaa;
  letter-spacing: 1px;
}

.insp-card-row .name {
  font-weight: 600;
  color: #fff;
}

.insp-card-row .sub {
  color: #888;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

/* Chip row */
.insp-chips {
  flex-wrap: wrap;
  gap: 4px;
}

.insp-chip {
  background: #000;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 2px 6px;
  font-family: 'JetBrains Mono', 'Pretendard Variable', monospace;
  font-size: 11px;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: background 0.1s, border-color 0.1s;
}

.insp-chip:hover {
  background: #fff;
  color: #000;
}

.insp-chip-static {
  cursor: default;
  color: #888;
  border-color: rgba(255, 255, 255, 0.12);
}

.insp-chip-static:hover {
  background: #000;
  color: #888;
}

/* Bulk-buy mode toggle (×1 / ×10 / ×25 / MAX) */
.insp-bulk-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.insp-bulk-label {
  font-family: 'Space Grotesk', 'Pretendard Variable', 'Apple SD Gothic Neo', sans-serif;
  font-size: 11px;
  letter-spacing: 1.5px;
  color: #888;
  margin-right: 4px;
}
.insp-bulk-btn {
  background: transparent;
  color: #888;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 2px 8px;
  font-family: 'JetBrains Mono', 'Pretendard Variable', monospace;
  font-size: 12px;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.insp-bulk-btn:hover { color: #fff; border-color: rgba(255, 255, 255, 0.4); }
.insp-bulk-btn.active {
  background: #fff;
  color: #000;
  border-color: #fff;
}

/* Cost placeholder inside buttons */
.insp-cost {
  color: #888;
  font-size: 10px;
  font-family: 'JetBrains Mono', 'Pretendard Variable', monospace;
  margin-left: 2px;
  font-variant-numeric: tabular-nums;
}

.insp-chip:hover .insp-cost,
.insp-add-btn:hover .insp-cost {
  color: #333;
}

/* Building type selector */
.insp-type-select {
  background: #000;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 2px 4px;
  font-family: 'Space Grotesk', 'Pretendard Variable', 'Apple SD Gothic Neo', sans-serif;
  font-size: 11px;
  letter-spacing: 1px;
  cursor: pointer;
}

/* Building description line */
.insp-card-desc {
  font-family: 'Space Grotesk', 'Pretendard Variable', 'Apple SD Gothic Neo', sans-serif;
  font-size: 12px;
  color: #888;
  padding: 0 2px;
  line-height: 1.3;
}

/* Target tag (→WORKER, →BUILDING) */
.insp-target-tag {
  font-family: 'JetBrains Mono', 'Pretendard Variable', monospace;
  font-size: 11px;
  color: #888;
  letter-spacing: 0.5px;
}

/* Row spacer — pushes trailing items (color swatch) to the right */
.insp-card-row .spacer {
  flex: 1;
}

/* Add button */
.insp-add-btn {
  background: #000;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  padding: 3px 8px;
  font-family: 'Space Grotesk', 'Pretendard Variable', 'Apple SD Gothic Neo', sans-serif;
  font-size: 11px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.insp-add-btn:hover {
  background: #fff;
  color: #000;
}

.insp-add-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Color swatch (button-based, opens color-popover) */
.color-swatch,
.insp-swatch {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: #fff;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-block;
  transition: border-color 0.12s, transform 0.08s;
}

.color-swatch:hover,
.insp-swatch:hover {
  border-color: #fff;
  transform: scale(1.1);
}

/* ══════════════════════════════════════════════════════════════
   Color Popover (palette + hex input)
   ══════════════════════════════════════════════════════════════ */

.color-popover {
  position: fixed;
  z-index: 200;
  background: #000;
  border: 1px solid #fff;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6);
}

.color-popover-grid {
  display: grid;
  grid-template-columns: repeat(5, 22px);
  gap: 4px;
}

.color-popover-swatch {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  transition: transform 0.08s, border-color 0.12s;
}

.color-popover-swatch:hover {
  transform: scale(1.12);
  border-color: #fff;
}

.color-popover-swatch.active {
  border: 1.5px solid #aaddff;
  box-shadow: 0 0 0 1px #000;
}

.color-popover-hex {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 4px 2px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.color-popover-hex .k {
  font-family: 'JetBrains Mono', 'Pretendard Variable', monospace;
  font-size: 13px;
  color: #888;
}

#color-popover-hex-input {
  flex: 1;
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-family: 'JetBrains Mono', 'Pretendard Variable', monospace;
  font-size: 13px;
  letter-spacing: 1px;
  padding: 4px 6px;
  text-transform: lowercase;
  outline: none;
  width: 70px;
}

#color-popover-hex-input:focus {
  border-color: #fff;
}

.insp-swatch-mixed {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #555;
  font-size: 11px;
}

/* Position slider */
.insp-slider {
  flex: 1;
  height: 2px;
  accent-color: #fff;
  cursor: pointer;
  min-width: 0;
}

/* ══════════════════════════════════════════════════════════════
   Core Status Panel (floating, opens on [CORE] click)
   ══════════════════════════════════════════════════════════════ */

.core-status {
  width: 360px;
  z-index: 11;
}

.core-part-row {
  display: grid;
  grid-template-columns: 60px 1fr 20px;
  gap: 8px;
  align-items: center;
  padding: 4px 0;
}

.core-part-row .k {
  font-family: 'Space Grotesk', 'Pretendard Variable', sans-serif;
  font-size: 11px;
  letter-spacing: 1px;
  color: #888;
  text-transform: uppercase;
}

.core-part-select {
  background: #000;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 3px 6px;
  font-family: 'JetBrains Mono', 'Pretendard Variable', monospace;
  font-size: 12px;
  cursor: pointer;
  /* Long option labels ("Dual Cage 🔒", "Spike Shell 🔒" etc.) would push
     the grid's 1fr column past the panel width and force a horizontal
     scrollbar. min-width:0 lets the column shrink below intrinsic content,
     and width:100% makes the select fill the column. */
  min-width: 0;
  width: 100%;
}

.core-primary-btn {
  display: block;
  width: 100%;
  background: #fff;
  color: #000;
  border: none;
  padding: 12px;
  margin-top: 10px;
  font-family: 'Space Grotesk', 'Pretendard Variable', sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 3px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.core-primary-btn:hover {
  background: #aaddff;
}

/* ══════════════════════════════════════════════════════════════
   Growth Tree View (full-viewport, temporary layout)
   ══════════════════════════════════════════════════════════════ */

.tree-view {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 100;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  color: #fff;
}

.tree-header {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px 32px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.tree-title {
  font-family: 'Space Grotesk', 'Pretendard Variable', sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 4px;
  flex: 1;
}

.tree-level {
  font-family: 'JetBrains Mono', 'Pretendard Variable', monospace;
  font-size: 13px;
  letter-spacing: 1.5px;
  color: #aaa;
}

.tree-level .v {
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}

.tree-resource {
  font-family: 'JetBrains Mono', 'Pretendard Variable', monospace;
  font-size: 13px;
  letter-spacing: 1.5px;
  color: #aaa;
}

.tree-resource .v {
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}

#tree-close {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  font-size: 20px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  line-height: 1;
}

#tree-close:hover {
  background: #fff;
  color: #000;
}

.tree-recenter-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  font: 600 10px 'JetBrains Mono', monospace;
  letter-spacing: 1.5px;
  height: 32px;
  padding: 0 12px;
  margin-right: 6px;
  cursor: pointer;
}

.tree-recenter-btn:hover {
  background: #fff;
  color: #000;
}

.tree-body {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.tree-svg {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}
.tree-svg:active { cursor: grabbing; }

/* Tree connector SVG: full-viewport overlay so its internal coords match
   window coords (same pattern as main #connector). Sits ABOVE the detail
   panel (z 102) so the target dot stays visible when the panel covers the node. */
.tree-connector {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 103;
}

/* Links */
.sk-line {
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 1;
  fill: none;
  transition: stroke 0.18s, stroke-width 0.18s;
}
.sk-line.one-owned  { stroke: rgba(255, 255, 255, 0.22); }
.sk-line.both-owned { stroke: rgba(255, 255, 255, 0.55); stroke-width: 1.3; }
.sk-line.hover      { stroke: #aaddff; stroke-width: 2; }
.sk-line.draw-in {
  stroke-dasharray: 1200;
  stroke-dashoffset: 1200;
  animation: sk-line-draw 0.55s cubic-bezier(0.5, 0.1, 0.3, 1) forwards;
}
@keyframes sk-line-draw { to { stroke-dashoffset: 0; } }

/* Nodes */
.sk-node { cursor: pointer; }
/* LOCKED still readable — runes are visible, just clearly unreachable */
/* LOCKED: solid black fill stays opaque (hides lines behind node).
   Only stroke + rune fade so the node still reads as "unreachable". */

.sk-node .sk-base {
  fill: #000;
  stroke: rgba(255, 255, 255, 0.25);
  stroke-width: 1;
  transition: stroke 0.18s, stroke-width 0.18s, fill 0.18s;
}

/* Hold overlay on node: white rect rises from bottom, inverted (black) rune
   shows where fill covers. Both clipped to circle shape. */
.sk-hold-group { pointer-events: none; }
.sk-hold-fill { fill: #fff; }
.sk-rune-inv {
  fill: #000;
  font-family: 'Segoe UI Symbol', 'Noto Sans Runic', 'Arial Unicode MS', serif;
  font-size: 22px;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  user-select: none;
}
.sk-node.seed .sk-rune-inv { font-size: 24px; font-weight: bold; }

.sk-node .sk-rune {
  fill: rgba(255, 255, 255, 0.45);
  font-family: 'Segoe UI Symbol', 'Noto Sans Runic', 'Arial Unicode MS', serif;
  font-size: 22px;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  user-select: none;
  transition: fill 0.18s;
}

/* OWNED = solid white circle, black rune. Stroke = branch color (not white). */
.sk-node.status-owned .sk-base { fill: #fff; stroke-width: 1.5; }
.sk-node.status-owned .sk-rune { fill: #000; }
.sk-node.status-owned.branch-worker   .sk-base { stroke: #aaddff; }
.sk-node.status-owned.branch-building .sk-base { stroke: #ffb347; }
.sk-node.status-owned.branch-network  .sk-base { stroke: #bbbbbb; }
.sk-node.status-owned.branch-core     .sk-base { stroke: #fff; }

/* AVAILABLE = white stroke, SOLID BLACK interior (occludes lines behind) */
.sk-node.status-available .sk-base { stroke: #fff; stroke-width: 1.4; fill: #000; }
.sk-node.status-available .sk-rune { fill: #fff; }

/* LOCKED also opaque black so lines don't show through */
.sk-node.status-locked .sk-base { fill: #000; stroke-opacity: 0.5; }
.sk-node.status-locked .sk-rune { fill: rgba(255, 255, 255, 0.35); }

/* Branch accents: clear stroke color on non-owned nodes so branch identity reads */
.sk-node.status-available.branch-worker   .sk-base { stroke: #aaddff; }
.sk-node.status-available.branch-building .sk-base { stroke: #ffb347; }
.sk-node.status-available.branch-network  .sk-base { stroke: #cccccc; }
.sk-node.status-locked.branch-worker   .sk-base { stroke: rgba(170, 221, 255, 0.5); }
.sk-node.status-locked.branch-building .sk-base { stroke: rgba(255, 179, 71, 0.5); }
.sk-node.status-locked.branch-network  .sk-base { stroke: rgba(200, 200, 200, 0.5); }

/* Hover neighbor (revealed via connection) */
.sk-node.hover-neighbor .sk-base { stroke: #fff; stroke-width: 1.8; }

/* Selected = cyan stroke + breathing halo pulse so it's unmistakable */
.sk-node.selected .sk-base {
  stroke: #aaddff;
  stroke-width: 2.4;
  animation: sk-select-pulse 1.8s ease-in-out infinite;
}
/* Rune keeps its status color when selected (no override to cyan). */
.sk-node.selected.status-owned .sk-base { stroke: #aaddff; }
.sk-node.selected.status-owned .sk-rune { fill: #000; }

@keyframes sk-select-pulse {
  0%, 100% { stroke-opacity: 1;    filter: drop-shadow(0 0 0 rgba(170, 221, 255, 0)); }
  50%      { stroke-opacity: 0.55; filter: drop-shadow(0 0 6px rgba(170, 221, 255, 0.7)); }
}

/* Seed is the unmistakable center — larger, solid */
.sk-node.seed .sk-base { fill: #fff; stroke: #fff; stroke-width: 2; }
.sk-node.seed .sk-rune { fill: #000; font-size: 24px; font-weight: bold; }

/* Special nodes hint — slightly thicker stroke */
.sk-node.special:not(.status-owned) .sk-base { stroke-width: 1.8; }

/* ────── Tier visual differentiation ────── */
/* Filler — smallest, thin stroke */
.sk-node.tier-filler .sk-base { stroke-width: 1.4; }
.sk-node.tier-filler .sk-rune { font-size: 18px; }

/* Notable — medium, thicker stroke */
.sk-node.tier-notable .sk-base { stroke-width: 2.4; }
.sk-node.tier-notable .sk-rune { font-size: 24px; font-weight: bold; }

/* Keystone — largest, double-ring + glow + animated pulse */
.sk-node.tier-keystone .sk-base { stroke-width: 3.4; }
.sk-node.tier-keystone .sk-rune { font-size: 32px; font-weight: bold; }
.sk-node.tier-keystone.status-owned .sk-base,
.sk-node.tier-keystone.status-available .sk-base {
  filter: drop-shadow(0 0 6px currentColor);
  animation: sk-keystone-pulse 2.4s ease-in-out infinite;
}
@keyframes sk-keystone-pulse {
  0%, 100% { stroke-opacity: 1;   }
  50%      { stroke-opacity: 0.7; }
}

/* Gate — large with prominent stroke (lock icon visualization) */
.sk-node.tier-gate .sk-base { stroke-width: 2.8; stroke-dasharray: 5 3; }
.sk-node.tier-gate .sk-rune { font-size: 26px; font-weight: bold; }
.sk-node.tier-gate.status-owned .sk-base { stroke-dasharray: none; }

/* Tier badge in detail card */
.tree-detail-tier {
  font-size: 11px;
  letter-spacing: 1px;
  padding: 2px 6px;
  border: 1px solid currentColor;
  border-radius: 2px;
  margin-left: 6px;
  opacity: 0.8;
}
.tree-detail-tier.tier-notable  { color: #ffd54d; }
.tree-detail-tier.tier-keystone { color: #ff6cb0; font-weight: bold; }
.tree-detail-tier.tier-gate     { color: #4dffe0; }

/* Breathing pulse on owned non-keystone nodes (very subtle) */
.sk-node.status-owned:not(.seed):not(.tier-keystone) .sk-base {
  animation: sk-breathe 3.2s ease-in-out infinite;
}
@keyframes sk-breathe {
  0%, 100% { stroke-opacity: 1;   }
  50%      { stroke-opacity: 0.55; }
}

/* ────── Detail Panel (floating, draggable, connector to node) ────── */
.tree-detail {
  position: fixed;
  width: 400px;
  z-index: 102;
  pointer-events: auto;
}

.tree-detail-card {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 14px;
  padding: 14px;
  animation: detail-in 0.18s ease;
}
@keyframes detail-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes tree-burst-particle {
  0%   { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; }
}

@keyframes tree-burst-flash {
  0%   { transform: scale(0.3); opacity: 1; }
  50%  { transform: scale(1.5); opacity: 0.6; }
  100% { transform: scale(2.5); opacity: 0; }
}

.tree-detail-glyph {
  width: 70px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Segoe UI Symbol', 'Noto Sans Runic', 'Arial Unicode MS', serif;
  font-size: 50px;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.02);
}

/* Glyph is always white (regardless of branch). OWNED = inverted (black on white). */
.tree-detail-card.status-owned .tree-detail-glyph { color: #000; background: #fff; }

/* Branch color only on the branch label text, not the glyph */
.tree-detail-card.branch-worker   .tree-detail-branch { color: #aaddff; }
.tree-detail-card.branch-building .tree-detail-branch { color: #ffb347; }
.tree-detail-card.branch-network  .tree-detail-branch { color: #bbbbbb; }

.tree-detail-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.tree-detail-name {
  font-family: 'Space Grotesk', 'Pretendard Variable', sans-serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #fff;
}

.tree-detail-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.tree-detail-branch {
  font-family: 'JetBrains Mono', 'Pretendard Variable', monospace;
  font-size: 11px;
  letter-spacing: 1.5px;
  color: #888;
}

.tree-detail-status {
  font-family: 'JetBrains Mono', 'Pretendard Variable', monospace;
  font-size: 11px;
  letter-spacing: 1.5px;
  padding: 1px 5px;
  border: 1px solid currentColor;
  color: #aaa;
}

.tree-detail-card.status-available .tree-detail-status { color: #aaddff; }
.tree-detail-card.status-owned     .tree-detail-status { color: #fff; }
.tree-detail-card.status-locked    .tree-detail-status { color: #555; }

.tree-detail-effect {
  font-family: 'Space Grotesk', 'Pretendard Variable', sans-serif;
  font-size: 13px;
  color: #bbb;
  line-height: 1.45;
  margin-top: 4px;
}

.tree-detail-cost {
  font-family: 'JetBrains Mono', 'Pretendard Variable', monospace;
  font-size: 15px;
  color: #fff;
  font-variant-numeric: tabular-nums;
  margin-top: 6px;
}

.tree-detail-cost.insufficient { color: #ff8080; }

.tree-detail-note {
  font-family: 'JetBrains Mono', 'Pretendard Variable', monospace;
  font-size: 11px;
  letter-spacing: 2px;
  color: #666;
  margin-top: 8px;
  text-transform: uppercase;
}

/* Hold-to-purchase button */
.hold-btn {
  position: relative;
  overflow: hidden;
  width: 100%;
  margin-top: 8px;
  background: #000;
  color: #fff;
  border: 1px solid #fff;
  padding: 12px;
  cursor: pointer;
  font-family: 'Space Grotesk', 'Pretendard Variable', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 3px;
  user-select: none;
  touch-action: none;
}

.hold-btn:disabled {
  opacity: 0.3;
  cursor: default;
  border-color: rgba(255, 255, 255, 0.3);
}

.hold-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 100%;
  background: #fff;
  transform: scaleX(0);
  transform-origin: left center;
  z-index: 0;
  pointer-events: none;
}

.hold-label {
  position: relative;
  z-index: 1;
  mix-blend-mode: difference;
  color: #fff;
}

/* ══════════════════════════════════════════════════════════════
   Building Catalog (right-side floating panel)
   ══════════════════════════════════════════════════════════════ */

.catalog-panel {
  width: 300px;
  z-index: 12;
}

.catalog-title {
  flex: 1;
  letter-spacing: 2px;
}


.catalog-body {
  padding: 10px 12px;
  max-height: 60vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.catalog-card {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.12s;
}

.catalog-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: #fff;
}

.catalog-card:active {
  transform: scale(0.99);
}

.catalog-card.disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.catalog-card.locked {
  opacity: 0.4;
  cursor: not-allowed;
  border-style: dashed;
}

.catalog-lock {
  font-family: 'JetBrains Mono', 'Pretendard Variable', monospace;
  font-size: 12px;
  color: #aaddff;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.catalog-card.disabled:hover {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.2);
}

.catalog-preview {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #000;
}

.catalog-preview svg {
  display: block;
}

.catalog-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.catalog-row-top {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.catalog-name {
  font-family: 'Space Grotesk', 'Pretendard Variable', 'Apple SD Gothic Neo', sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: #fff;
}

.catalog-target {
  font-family: 'JetBrains Mono', 'Pretendard Variable', monospace;
  font-size: 11px;
  color: #888;
  letter-spacing: 0.5px;
}

.catalog-desc {
  font-family: 'Space Grotesk', 'Pretendard Variable', 'Apple SD Gothic Neo', sans-serif;
  font-size: 12px;
  color: #aaa;
  line-height: 1.35;
}

.catalog-cost {
  font-family: 'JetBrains Mono', 'Pretendard Variable', monospace;
  font-size: 12px;
  color: #fff;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
  letter-spacing: 0.3px;
}

.catalog-cost.insufficient {
  color: #ff8080;
}

.catalog-empty {
  padding: 20px 4px;
  text-align: center;
  color: #666;
  font-size: 12px;
  letter-spacing: 1px;
}

/* ══════════════════════════════════════════════════════════════
   Scrollbar
   ══════════════════════════════════════════════════════════════ */

::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

/* ══════════════════════════════════════════════════════════════
   Achievements Panel (top-right)
   ══════════════════════════════════════════════════════════════ */

#panel-achievements .ach-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  padding: 18px 44px 16px 18px;
  border-bottom: 2px solid #fff;
  column-gap: 8px;
}

#panel-achievements.collapsed .ach-header {
  border-bottom: none;
}

.ach-heading {
  font: 700 12px 'JetBrains Mono', monospace;
  letter-spacing: 2px;
  color: #fff;
}

.ach-count {
  font: 500 11px 'JetBrains Mono', monospace;
  color: rgba(255, 255, 255, 0.6);
  letter-spacing: 1px;
}

#panel-achievements.collapsed .achievements-body {
  display: none;
}

.achievements-body {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 70vh;
  overflow-y: auto;
  padding: 10px 14px 14px;
}

.ach-section {
  margin-top: 12px;
}
.ach-section:first-child { margin-top: 4px; }

.ach-section-header {
  font: 700 10px 'JetBrains Mono', monospace;
  letter-spacing: 2.5px;
  color: rgba(255, 255, 255, 0.45);
  padding: 4px 0 6px;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.12);
  margin-bottom: 6px;
}

.ach-row {
  padding: 7px 8px;
  margin-bottom: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.015);
  transition: border-color 0.2s, background 0.2s;
}

.ach-row-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.ach-name {
  font: 600 11px 'Space Grotesk', sans-serif;
  letter-spacing: 0.3px;
  color: rgba(255, 255, 255, 0.85);
}

.ach-progress-text {
  font: 500 10px 'JetBrains Mono', monospace;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.ach-row-desc {
  font: 400 10px 'Space Grotesk', sans-serif;
  color: rgba(255, 255, 255, 0.4);
  margin: 2px 0 5px;
  letter-spacing: 0.2px;
}

.ach-bar {
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
  position: relative;
  overflow: hidden;
}

.ach-bar-fill {
  height: 100%;
  background: rgba(255, 255, 255, 0.55);
  width: 0%;
  transition: width 0.4s ease-out;
}

.ach-row.ach-unlocked {
  border-color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.05);
}

.ach-row.ach-unlocked .ach-name {
  color: #fff;
}

.ach-row.ach-unlocked .ach-name::before {
  content: '✓ ';
  color: #fff;
}

.ach-row.ach-unlocked .ach-bar-fill {
  background: #fff;
}

@keyframes ach-unlock-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.6); }
  50%  { box-shadow: 0 0 14px 4px rgba(255, 255, 255, 0.3); }
  100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

.ach-row.ach-just-unlocked {
  animation: ach-unlock-pulse 1.2s ease-out;
}

@keyframes ach-panel-flash {
  0%   { border-color: #fff; }
  30%  { border-color: #fff; box-shadow: 0 0 18px rgba(255, 255, 255, 0.35); }
  100% { border-color: #fff; box-shadow: none; }
}

#panel-achievements.ach-flash {
  animation: ach-panel-flash 1.2s ease-out;
}

/* ── Unlock toast ────────────────────────────────────────────── */

.ach-toast-container {
  position: fixed;
  top: 30px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  z-index: 9999;
  pointer-events: none;
}

.ach-toast {
  background: #000;
  border: 2px solid #fff;
  padding: 10px 18px;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 12px;
  align-items: center;
  min-width: 260px;
  max-width: 360px;
  animation: ach-toast-in 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.ach-toast.ach-toast-out {
  animation: ach-toast-out 0.4s ease-in forwards;
}

.ach-toast-badge {
  font: 700 11px 'JetBrains Mono', monospace;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.45);
  border-right: 1px solid rgba(255, 255, 255, 0.25);
  padding-right: 12px;
}

.ach-toast-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ach-toast-label {
  font: 500 9px 'JetBrains Mono', monospace;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.5);
}

.ach-toast-name {
  font: 700 13px 'Space Grotesk', sans-serif;
  letter-spacing: 0.3px;
  color: #fff;
}

@keyframes ach-toast-in {
  0%   { opacity: 0; transform: translateY(-16px) scale(0.95); box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
  60%  { opacity: 1; box-shadow: 0 0 22px 4px rgba(255, 255, 255, 0.35); }
  100% { opacity: 1; transform: translateY(0)    scale(1);    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

@keyframes ach-toast-out {
  0%   { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-12px); }
}

/* ══════════════════════════════════════════════════════════════
   Settings extras — danger button, shortcuts list, confirm modal
   ══════════════════════════════════════════════════════════════ */

.settings-btn-danger {
  border-color: rgba(255, 90, 90, 0.7);
  color: #ff8a8a;
}
.settings-btn-danger:hover {
  background: #ff5a5a;
  color: #000;
}

.settings-shortcuts {
  margin-top: 12px;
  padding: 10px 12px 4px;
  border-top: 1px dashed rgba(255, 255, 255, 0.15);
}

#tab-settings, #tab-stats { padding-bottom: 20px; }

.settings-section-title {
  font: 700 10px 'JetBrains Mono', monospace;
  letter-spacing: 2.5px;
  color: rgba(255, 255, 255, 0.45);
  margin-bottom: 6px;
}

.shortcut-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  padding: 3px 0;
  font: 500 11px 'Space Grotesk', sans-serif;
  color: rgba(255, 255, 255, 0.7);
}

.shortcut-row .k {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.9);
}

.shortcut-row .d {
  color: rgba(255, 255, 255, 0.55);
}

.confirm-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.confirm-box {
  background: #000;
  border: 2px solid #fff;
  min-width: 320px;
  max-width: 420px;
  padding: 20px 22px 18px;
}

.confirm-title {
  font: 700 14px 'JetBrains Mono', monospace;
  letter-spacing: 3px;
  color: #ff8a8a;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  margin-bottom: 14px;
}

.confirm-body {
  font: 400 12px 'Space Grotesk', sans-serif;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.55;
  margin-bottom: 18px;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.confirm-actions .settings-btn {
  padding: 6px 14px;
}

/* ── Tutorial-complete hint card ─────────────────────────────── */

.tutorial-done-card {
  position: fixed;
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  background: #000;
  border: 2px solid #fff;
  padding: 14px 22px 16px;
  min-width: 340px;
  max-width: 420px;
  z-index: 9998;
  animation: tutorial-done-in 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  color: #fff;
}

.tutorial-done-card.fade {
  animation: tutorial-done-out 0.5s ease-in forwards;
}

.tutorial-done-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 20px;
  cursor: pointer;
  padding: 2px 8px;
  line-height: 1;
}
.tutorial-done-close:hover { color: #fff; }

.tutorial-done-title {
  font: 700 12px 'JetBrains Mono', monospace;
  letter-spacing: 3px;
  color: rgba(255, 255, 255, 0.7);
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  margin-bottom: 10px;
}

.tutorial-done-body {
  font: 600 13px 'Space Grotesk', sans-serif;
  margin-bottom: 8px;
}

.tutorial-done-hints {
  list-style: none;
  padding: 0;
  margin: 0;
  font: 400 12px 'Space Grotesk', sans-serif;
  color: rgba(255, 255, 255, 0.75);
  line-height: 1.6;
}
.tutorial-done-hints li {
  position: relative;
  padding-left: 14px;
}
.tutorial-done-hints li::before {
  content: '›';
  position: absolute;
  left: 0;
  color: rgba(255, 255, 255, 0.4);
}
.tutorial-done-hints b {
  color: #fff;
  letter-spacing: 0.3px;
}

@keyframes tutorial-done-in {
  0%   { opacity: 0; transform: translate(-50%, -12px); }
  100% { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes tutorial-done-out {
  0%   { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -8px); }
}

/* ── Trailer mode ───────────────────────────────────────────────
   Fake cursor (for simulated clicks), fullscreen black fade overlay,
   and a brief pulse on the resource counter when it ticks. The badge
   is intentionally absent — the trailer is captured by screen-recording,
   so any on-screen "TRAILER MODE" label would be baked into the video. */

#trailer-cursor {
  position: fixed;
  display: none;
  pointer-events: none;
  width: 22px; height: 22px;
  margin-left: -11px; margin-top: -11px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.35);
  transition: left 600ms cubic-bezier(.33,.0,.2,1), top 600ms cubic-bezier(.33,.0,.2,1);
  z-index: 99990;
}
#trailer-cursor.click {
  animation: trailer-cursor-pulse 220ms ease;
}
@keyframes trailer-cursor-pulse {
  0%   { transform: scale(1);   background: rgba(255,255,255,0.15); }
  50%  { transform: scale(0.55); background: rgba(255,255,255,0.85); }
  100% { transform: scale(1);   background: rgba(255,255,255,0.15); }
}
/* Steady "pressed" state for hold-to-confirm (growth-tree purchase).
   Sits on the target the whole pointerHold duration — no looping animation. */
#trailer-cursor.holding {
  transform: scale(0.72);
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.55);
  transition: transform 120ms ease, background 120ms ease;
}

#trailer-overlay {
  position: fixed;
  display: none;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  z-index: 99980;
}

/* Resource-value pulse during Act 3 — fires on every text change the
   MutationObserver in trailer-mode.js catches. Short, subtle, no color shift. */
#resource-value.trailer-res-pulse {
  display: inline-block;
  transform-origin: left center;
  animation: trailer-res-pulse 280ms ease;
}
@keyframes trailer-res-pulse {
  0%   { transform: scale(1);    text-shadow: none; }
  40%  { transform: scale(1.10); text-shadow: 0 0 8px rgba(255,255,255,0.55); }
  100% { transform: scale(1);    text-shadow: none; }
}

/* ── Demo mode (Vibe Jam build) ── */
/* Root flag is set by js/demo-mode.js on module load when window.SYNAPSE_DEMO */
/* is true. Keep these rules purely additive so the Steam build is unaffected. */
.demo-mode .core-appearance-section { display: none; }
.demo-mode #setting-row-language { display: none; }
.demo-mode .insp-appearance-section { display: none; }
.demo-mode [data-insp-worker-color],
.demo-mode [data-insp-building-color] { display: none; }

