:root {
  --bg-dark: #05080f;
  --bg-panel: rgba(14, 20, 34, 0.92);
  --bg-card: rgba(23, 33, 53, 0.88);
  --border: #283856;
  --text-main: #eef2f6;
  --text-muted: #8b9bb4;
  --accent: #f97316;
  --accent-glow: rgba(249, 115, 22, 0.45);
  --gold: #fbbf24;
  --green: #22c55e;
  --blue: #38bdf8;
  --purple: #c084fc;
  --danger: #ef4444;
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Header & HUD */
#hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px;
  background: linear-gradient(180deg, #121a2d 0%, #0b101d 100%);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  gap: 12px;
  z-index: 30;
}

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

.brand-icon {
  font-size: 26px;
  filter: drop-shadow(0 0 8px rgba(249, 115, 22, 0.6));
}

.brand h1 {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.9px;
  background: linear-gradient(90deg, #fbbf24, #f97316);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand .subtitle {
  font-size: 11px;
  color: var(--text-muted);
}

.global-planet-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 5px 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.global-planet-bar .biome-info {
  min-width: 170px;
  text-align: center;
}

.auto-advance-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--green);
  font-weight: 700;
  cursor: pointer;
  padding-left: 6px;
  border-left: 1px solid var(--border);
}

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

.res-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: 9px;
  min-width: 78px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.res-pill .icon {
  font-size: 17px;
}

.res-pill .label {
  display: block;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
}

.res-pill .val {
  font-size: 13.5px;
  font-weight: 800;
}

.res-pill .rate {
  font-size: 10.5px;
  color: var(--green);
  margin-left: 2px;
}

.tabs {
  display: flex;
  gap: 7px;
  align-items: center;
}

.tab-btn {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.tab-btn.active {
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: #fff;
  border-color: #fb923c;
  box-shadow: 0 0 16px var(--accent-glow);
}

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  transition: border-color 0.15s, transform 0.1s;
}

.icon-btn:hover {
  border-color: var(--blue);
  transform: scale(1.06);
}

.badge {
  background: var(--green);
  color: #05080d;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 99px;
  font-weight: 900;
}

.hidden {
  display: none !important;
}

/* Graphics Settings Popover */
.gfx-popover {
  position: fixed;
  top: 62px;
  right: 20px;
  width: 300px;
  background: rgba(13, 19, 33, 0.96);
  backdrop-filter: blur(12px);
  border: 1px solid var(--blue);
  border-radius: 12px;
  padding: 15px 16px;
  z-index: 200;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.gfx-header h4 {
  font-size: 13.5px;
  color: var(--blue);
}

.gfx-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
}

.gfx-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.gfx-presets {
  display: flex;
  gap: 5px;
}

.preset-btn {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.preset-btn.active {
  background: var(--blue);
  color: #040811;
  border-color: var(--blue);
}

.gfx-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  color: var(--text-main);
  cursor: pointer;
}

.audio-popover {
  border-color: var(--gold);
  width: 315px;
}

.audio-popover .gfx-header h4 {
  color: var(--gold);
}

.audio-slider-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-main);
}

.slider-label strong {
  color: var(--blue);
  font-size: 11.5px;
}

.audio-slider-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  height: 6px;
}

/* Main Area */
#main-area {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.tab-panel {
  display: none;
  width: 100%;
  height: 100%;
}

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

/* Mine Tab */
#tab-mine {
  gap: 14px;
  padding: 14px;
}

.mine-sidebar {
  width: 315px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.panel-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.panel-card h3 {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--blue);
  margin-bottom: 9px;
}

.biome-selector {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px;
  margin-bottom: 10px;
}

.nav-arrow {
  background: var(--bg-panel);
  color: var(--text-main);
  border: 1px solid var(--border);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
}

.nav-arrow:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.biome-info {
  text-align: center;
}

.biome-title {
  font-weight: 800;
  font-size: 13.5px;
  color: var(--gold);
}

.biome-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.stamina-box, .core-box {
  margin-bottom: 9px;
}

.bar-header {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  margin-bottom: 4px;
}

.progress-bar {
  width: 100%;
  height: 11px;
  background: #06090f;
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  width: 100%;
  transition: width 0.08s linear;
}

.progress-fill.fuel {
  background: linear-gradient(90deg, #ea580c, #fbbf24);
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
}

.progress-fill.core-bar {
  background: linear-gradient(90deg, #dc2626, #f59e0b);
}

.progress-fill.combo-bar {
  background: linear-gradient(90deg, #8b5cf6, #ec4899);
}

.progress-fill.emp-bar {
  background: linear-gradient(90deg, #06b6d4, #3b82f6);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.55);
}

.prestige-tab-btn.active {
  background: linear-gradient(135deg, #a855f7, #ec4899);
  border-color: #f472b6;
  box-shadow: 0 0 16px rgba(236, 72, 153, 0.5);
}

#tab-prestige {
  flex-direction: column;
  padding: 18px 26px;
  overflow-y: auto;
  gap: 18px;
}

.prestige-header {
  border-color: rgba(236, 72, 153, 0.5);
  background: linear-gradient(135deg, rgba(16, 22, 34, 0.96), rgba(45, 16, 54, 0.88));
}

.prestige-text {
  color: #f472b6;
  font-size: 18px;
}

.prestige-btn {
  background: linear-gradient(135deg, #a855f7, #ec4899);
}

.prestige-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.prestige-card {
  background: linear-gradient(160deg, #121826 0%, #241436 100%);
  border: 1px solid rgba(192, 132, 252, 0.4);
  border-radius: 12px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

.prestige-card.affordable {
  border-color: var(--green);
  box-shadow: 0 0 14px rgba(34, 197, 94, 0.28);
}

/* Steam-Style Achievement Toasts */
.ach-toast-container {
  position: fixed;
  bottom: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 999;
  pointer-events: none;
}

.ach-toast {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #111827, #1e293b);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 12px 16px;
  min-width: 280px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.75);
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

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

.ach-icon {
  font-size: 28px;
}

.ach-kicker {
  font-size: 10px;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: 0.6px;
}

.ach-title {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-main);
}

.ach-desc {
  font-size: 11.5px;
  color: var(--text-muted);
}

.run-actions {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 6px;
}

.primary-btn {
  background: linear-gradient(135deg, #f97316, #d97706);
  color: #fff;
  border: none;
  padding: 9px 14px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px var(--accent-glow);
}

.secondary-btn {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 8px 13px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 12.5px;
  cursor: pointer;
}

.secondary-btn:hover {
  border-color: var(--blue);
}

.danger-btn {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 7px 11px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
}

.auto-restart-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-muted);
  cursor: pointer;
}

.stat-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
}

.stat-list li {
  display: flex;
  justify-content: space-between;
  padding-bottom: 3px;
  border-bottom: 1px dashed rgba(255,255,255,0.06);
}

.log-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 110px;
}

.loot-log {
  flex: 1;
  overflow-y: auto;
  font-size: 11.5px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.log-entry {
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--bg-card);
  border-left: 3px solid var(--accent);
}

.log-entry.relic {
  border-left-color: var(--purple);
  background: rgba(192, 132, 252, 0.14);
}

.log-entry.core {
  border-left-color: var(--gold);
  background: rgba(251, 191, 36, 0.14);
}

/* Canvas Area */
.canvas-wrapper {
  flex: 1;
  position: relative;
  background: #04060b;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.8);
}

#mine-canvas {
  cursor: none;
  display: block;
}

.canvas-hud-top {
  position: absolute;
  top: 12px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}

.canvas-pill {
  background: rgba(12, 18, 30, 0.85);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
}

.canvas-pill.gold {
  color: var(--gold);
}

.run-overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 8, 15, 0.84);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.overlay-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 26px 32px;
  text-align: center;
  max-width: 440px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.85);
}

.overlay-card h2 {
  color: var(--gold);
  margin-bottom: 6px;
}

.overlay-card p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.overlay-loot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
}

.overlay-wave-switcher {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.overlay-wave-text {
  font-size: 13px;
  font-weight: 800;
  color: var(--gold);
  min-width: 150px;
}

.loot-badge {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
}

.overlay-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* Skill Tree Tab */
#tab-tree {
  flex-direction: column;
  position: relative;
}

.tree-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 22px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  z-index: 5;
}

.tree-toolbar h2 {
  font-size: 15px;
}

.tree-toolbar p {
  font-size: 11.5px;
  color: var(--text-muted);
}

.tree-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.buy-mode-group {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.tree-filter-hint {
  font-size: 12px;
  color: var(--green);
  font-weight: 600;
}

.tree-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  background-color: #050811;
  background-image: radial-gradient(#1b2942 1.2px, transparent 1.2px);
  background-size: 28px 28px;
  cursor: grab;
}

.tree-viewport:active {
  cursor: grabbing;
}

.tree-lines {
  position: absolute;
  top: 0;
  left: 0;
  width: 4000px;
  height: 4000px;
  pointer-events: none;
  transform-origin: 0 0;
}

.tree-nodes {
  position: absolute;
  top: 0;
  left: 0;
  width: 4000px;
  height: 4000px;
  transform-origin: 0 0;
}

.tree-node {
  position: absolute;
  width: 72px;
  height: 72px;
  margin-left: -36px;
  margin-top: -36px;
  border-radius: 14px;
  background: var(--bg-panel);
  border: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.15s, box-shadow 0.15s;
}

.tree-node:hover {
  transform: scale(1.12);
  z-index: 4;
}

.tree-node .node-icon {
  font-size: 23px;
}

.tree-node .node-lvl {
  font-size: 10.5px;
  font-weight: 800;
  margin-top: 3px;
  color: var(--text-muted);
}

.tree-node.affordable {
  border-color: var(--green);
  box-shadow: 0 0 18px rgba(34, 197, 94, 0.48);
}

.tree-node.maxed {
  border-color: var(--gold);
  background: rgba(251, 191, 36, 0.14);
}

.tree-node.maxed .node-lvl {
  color: var(--gold);
}

.tree-node.locked {
  opacity: 0.28;
  filter: grayscale(0.9);
}

.node-tooltip {
  position: fixed;
  pointer-events: none;
  background: rgba(14, 20, 34, 0.97);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 12px 15px;
  width: 280px;
  z-index: 100;
  box-shadow: 0 10px 30px rgba(0,0,0,0.85);
}

.node-tooltip h4 {
  color: var(--gold);
  font-size: 14px;
  margin-bottom: 4px;
}

.node-tooltip .tt-branch {
  font-size: 10.5px;
  text-transform: uppercase;
  color: var(--blue);
  margin-bottom: 5px;
}

.node-tooltip .tt-desc {
  font-size: 12px;
  color: var(--text-main);
  margin-bottom: 8px;
  line-height: 1.35;
}

.node-tooltip .tt-cost {
  font-size: 12px;
  font-weight: 700;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

/* Museum Tab */
#tab-museum {
  flex-direction: column;
  padding: 18px 26px;
  overflow-y: auto;
  gap: 18px;
}

.museum-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  padding: 16px 22px;
  border-radius: 12px;
  flex-wrap: wrap;
  gap: 16px;
}

.museum-summary {
  display: flex;
  align-items: center;
  gap: 20px;
}

.summary-stat {
  display: flex;
  flex-direction: column;
}

.summary-stat .label {
  font-size: 11px;
  color: var(--text-muted);
}

.summary-stat strong {
  font-size: 16px;
}

.gold-text {
  color: var(--gold);
}

.museum-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
  gap: 13px;
}

.relic-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

.relic-card.discovered {
  border-color: rgba(192, 132, 252, 0.55);
  background: linear-gradient(160deg, #101622 0%, #1c1632 100%);
}

.relic-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.relic-icon {
  font-size: 32px;
  width: 50px;
  height: 50px;
  border-radius: 10px;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
}

.relic-card:not(.discovered) .relic-icon {
  filter: brightness(0) invert(0.25);
}

.relic-title {
  font-weight: 700;
  font-size: 13.5px;
}

.relic-tier {
  font-size: 11px;
  color: var(--purple);
}

.relic-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.relic-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 12px;
}

/* ============================================================
   CUSTOM SVG ICON SYSTEM & VISUAL POLISH
   ============================================================ */
.svg-icon-host,
.svg-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
}

[data-svg-icon] {
  width: 18px;
  height: 18px;
}

.svg-icon-host svg,
.svg-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.brand-icon.svg-icon-host {
  width: 30px;
  height: 30px;
  filter: drop-shadow(0 0 10px rgba(249, 115, 22, 0.55));
}

.res-pill .icon.svg-icon-host {
  width: 21px;
  height: 21px;
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.16));
}

.tab-btn [data-svg-icon] {
  width: 16px;
  height: 16px;
}

.svg-icon-node {
  width: 24px;
  height: 24px;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.5));
}

.svg-icon-relic {
  width: 30px;
  height: 30px;
  filter: drop-shadow(0 0 8px rgba(192, 132, 252, 0.45));
}

.svg-icon-sm {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
}

.svg-icon-xs {
  width: 13px;
  height: 13px;
  vertical-align: -2px;
}

.cost-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 6px;
  padding: 2px 6px;
  margin-right: 4px;
  margin-top: 2px;
}

.loot-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Resource Pill Accent Polish */
.res-pill {
  background: linear-gradient(180deg, rgba(28, 40, 66, 0.92) 0%, rgba(16, 24, 42, 0.94) 100%);
  transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.res-pill:hover {
  transform: translateY(-1px);
  border-color: rgba(148, 163, 184, 0.5);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.res-pill.credits { border-bottom: 2px solid rgba(251, 191, 36, 0.6); }
.res-pill.iron { border-bottom: 2px solid rgba(148, 163, 184, 0.55); }
.res-pill.titanium { border-bottom: 2px solid rgba(226, 232, 240, 0.7); }
.res-pill.cobalt { border-bottom: 2px solid rgba(56, 189, 248, 0.7); }
.res-pill.plasma { border-bottom: 2px solid rgba(244, 114, 182, 0.75); }
.res-pill.voidmatter { border-bottom: 2px solid rgba(168, 85, 247, 0.8); }
.res-pill.chronon { border-bottom: 2px solid rgba(45, 212, 191, 0.75); }
.res-pill.aether { border-bottom: 2px solid rgba(250, 204, 21, 0.75); }
.res-pill.cores { border-bottom: 2px solid rgba(249, 115, 22, 0.85); }

/* Tech-Tree Node & Relic Card Polish */
.tree-node {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.tree-node.affordable {
  box-shadow: 0 0 18px rgba(34, 197, 94, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.relic-card {
  background: linear-gradient(160deg, rgba(24, 34, 56, 0.94) 0%, rgba(13, 19, 34, 0.96) 100%);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* Orbit Canvas Zoom Controls */
.canvas-zoom-controls {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(14, 20, 34, 0.88);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px 8px;
  z-index: 15;
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
}

.zoom-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(30, 41, 59, 0.9);
  color: var(--text-main);
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}

.zoom-btn:hover {
  border-color: var(--blue);
  background: rgba(56, 189, 248, 0.2);
}

.zoom-label {
  font-size: 12px;
  font-weight: 700;
  min-width: 42px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
}

.zoom-label:hover {
  color: var(--text-main);
}

/* Mechanic Discovery Toast */
.mechanic-toast {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 480px;
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid var(--blue);
  border-radius: 12px;
  padding: 10px 14px;
  z-index: 25;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7), 0 0 20px rgba(56, 189, 248, 0.25);
  backdrop-filter: blur(10px);
  animation: toastSlideIn 0.25s ease-out;
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.mechanic-toast-icon {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mechanic-toast-body strong {
  display: block;
  font-size: 13px;
  color: var(--blue);
  margin-bottom: 2px;
}

.mechanic-toast-body p {
  font-size: 11.5px;
  color: var(--text-main);
  line-height: 1.35;
}

.mechanic-toast-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  padding: 2px 4px;
}

.mechanic-toast-close:hover {
  color: var(--text-main);
}

/* Pause Menu & Roguelite Draft Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 14, 0.82);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}

.pause-card {
  width: 440px;
  max-width: 92vw;
  background: linear-gradient(160deg, rgba(20, 29, 49, 0.98) 0%, rgba(11, 16, 29, 0.98) 100%);
  border: 1px solid var(--blue);
  border-radius: 16px;
  padding: 22px 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85), 0 0 30px rgba(56, 189, 248, 0.2);
}

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

.pause-header h3 {
  font-size: 16px;
  color: var(--text-main);
}

.pause-hint {
  font-size: 11px;
  color: var(--text-muted);
}

.pause-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pause-action {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  font-size: 14px;
}

.pause-action [data-svg-icon],
.pause-action .svg-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.roguelite-card {
  width: 720px;
  max-width: 94vw;
  background: linear-gradient(160deg, rgba(24, 20, 48, 0.98) 0%, rgba(11, 16, 29, 0.98) 100%);
  border: 1px solid var(--purple);
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85), 0 0 35px rgba(192, 132, 252, 0.25);
}

.roguelite-card h3 {
  font-size: 19px;
  color: var(--gold);
  margin-bottom: 6px;
}

.roguelite-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.roguelite-choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
  gap: 12px;
}

.roguelite-option {
  background: rgba(23, 33, 53, 0.92);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 14px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  text-align: left;
  color: var(--text-main);
}

.roguelite-option:hover {
  transform: translateY(-3px);
  border-color: var(--purple);
  box-shadow: 0 8px 24px rgba(192, 132, 252, 0.28);
}

.roguelite-option .rl-icon {
  font-size: 26px;
  margin-bottom: 8px;
}

.roguelite-option .rl-name {
  font-size: 14px;
  font-weight: 800;
  color: var(--purple);
  margin-bottom: 6px;
}

.roguelite-option .rl-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.canvas-pill.event-buff {
  border-color: #22d3ee;
  color: #67e8f9;
  background: rgba(8, 51, 68, 0.88);
}

.res-pill.hyperium { border-bottom: 2px solid rgba(16, 185, 129, 0.8); }
.res-pill.nebula { border-bottom: 2px solid rgba(245, 158, 11, 0.8); }
.res-pill.singularity { border-bottom: 2px solid rgba(56, 189, 248, 0.9); }

.canvas-pill.boss-mod {
  border-color: #f87171;
  color: #fecaca;
  background: rgba(127, 29, 29, 0.88);
}

.relic-card.boss-drop.discovered {
  border-color: rgba(245, 158, 11, 0.5);
  background: linear-gradient(145deg, rgba(30, 27, 45, 0.92), rgba(52, 32, 18, 0.45));
}

/* Mobile & Touch Port */
#mine-canvas,
.tree-viewport {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

@media (min-width: 901px) {
  .brand { order: 0; }
  .resources { order: 1; }
  .global-planet-bar { order: 2; }
  .tabs { order: 3; }
}

@media (max-width: 900px) {
  body,
  #app {
    height: 100dvh;
  }

  #hud {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 4px 8px 6px 8px;
  }

  .notch-split-wrap {
    display: flex;
    align-items: center;
    width: 100%;
    min-width: 0;
  }

  .notch-split-wrap .resources-left,
  .notch-split-wrap .resources-right {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 5px;
    padding-bottom: 2px;
    min-width: 0;
  }

  .notch-split-wrap .resources-left::-webkit-scrollbar,
  .notch-split-wrap .resources-right::-webkit-scrollbar {
    display: none;
  }

  .notch-split-wrap .resources-right {
    flex: 1;
  }

  .notch-spacer {
    flex-shrink: 0;
    pointer-events: none;
  }

  .brand {
    display: none;
  }

  .resources {
    order: 2;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 5px;
    padding-bottom: 2px;
  }

  .resources::-webkit-scrollbar {
    display: none;
  }

  .res-pill {
    min-width: auto;
    flex-shrink: 0;
    padding: 4px 8px;
    gap: 6px;
    border-color: rgba(148, 163, 184, 0.25);
  }

  .res-pill .svg-icon {
    width: 16px;
    height: 16px;
  }

  .res-pill .label {
    font-size: 9px;
    color: #cbd5e1;
  }

  .res-pill .val {
    font-size: 12.5px;
  }

  .global-planet-bar {
    order: 1;
    width: 100%;
    min-height: var(--notch-h, 42px);
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    gap: var(--notch-w, 84px);
  }

  .auto-advance-pill {
    flex: 1;
    min-width: 0;
    justify-content: center;
    white-space: nowrap;
    padding: 5px 8px;
    min-height: 30px;
    border-left: none;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.35);
    border-radius: 7px;
  }

  .auto-advance-pill input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--green);
  }

  .global-planet-bar .biome-info {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  .biome-title {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .biome-sub {
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .tabs {
    order: 3;
    width: 100%;
    justify-content: space-between;
    gap: 4px;
  }

  .tab-btn {
    flex: 1;
    justify-content: center;
    padding: 6px 6px;
    font-size: 11.5px;
    gap: 4px;
  }

  #tab-mine {
    flex-direction: column;
    padding: 8px;
    gap: 8px;
  }

  #canvas-container {
    order: -1;
    flex: 1;
    min-height: 44dvh;
  }

  .canvas-hud-top,
  .canvas-hud-bottom {
    left: 8px;
    right: 8px;
    gap: 5px;
  }

  .canvas-pill {
    font-size: 10.5px;
    padding: 4px 8px;
  }

  .mine-sidebar {
    width: 100%;
    max-height: 31dvh;
    overflow-y: auto;
    flex-shrink: 0;
    padding: 0;
    gap: 6px;
  }

  .mine-sidebar .panel-card {
    width: 100%;
    padding: 8px 10px;
  }

  .mine-sidebar .panel-card h3 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    margin-bottom: 7px;
    user-select: none;
  }

  .mine-sidebar .panel-card h3::after {
    content: "▾";
    font-size: 12px;
    color: var(--text-muted);
  }

  .mine-sidebar .panel-card.mobile-collapsed h3 {
    margin-bottom: 0;
  }

  .mine-sidebar .panel-card.mobile-collapsed h3::after {
    content: "▸";
  }

  .mine-sidebar .panel-card.mobile-collapsed > :not(h3) {
    display: none;
  }

  .log-card {
    max-height: 110px;
  }

  .tree-toolbar {
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
  }

  .tree-toolbar p {
    display: none;
  }

  .tree-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    width: 100%;
  }

  .tree-controls .buy-mode-group {
    grid-column: 1 / -1;
    display: flex;
    width: 100%;
  }

  .tree-controls .buy-mode-group button {
    flex: 1;
    height: 32px;
    text-align: center;
  }

  .tree-controls > button {
    width: 100%;
    height: 36px;
    padding: 0 8px;
    font-size: 11.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .node-tooltip,
  .tree-tooltip {
    max-width: calc(100vw - 24px);
    left: 12px !important;
    right: 12px;
    top: auto !important;
    bottom: 12px !important;
    padding: 10px 12px;
  }

  .museum-header,
  .prestige-header {
    padding: 10px 12px;
    gap: 8px;
  }

  .relic-card,
  .prestige-card {
    padding: 10px 12px;
    gap: 6px;
  }

  .relic-icon {
    width: 38px;
    height: 38px;
    font-size: 22px;
  }

  #museum-grid,
  #prestige-grid,
  .roguelite-options {
    grid-template-columns: 1fr;
  }

  .canvas-zoom-controls {
    display: none !important;
  }

  .mechanic-toast {
    top: 38px;
    width: calc(100% - 28px);
    max-width: 285px;
    padding: 5px 8px;
    gap: 6px;
    border-radius: 8px;
  }

  .mechanic-toast-icon {
    width: 18px;
    height: 18px;
  }

  .mechanic-toast-body strong {
    font-size: 10.5px;
    margin-bottom: 1px;
  }

  .mechanic-toast-body p {
    font-size: 9.5px;
    line-height: 1.22;
  }

  .ach-toast-container {
    bottom: 10px;
    right: 10px;
    left: 10px;
    align-items: center;
  }

  .ach-toast {
    min-width: 0;
    width: 100%;
    max-width: 300px;
    padding: 6px 10px;
    gap: 8px;
    border-radius: 9px;
  }

  .ach-icon {
    font-size: 18px;
  }

  #btn-start-run {
    display: none !important;
  }

  .gfx-popover,
  .audio-popover {
    top: 50%;
    left: 50%;
    right: auto;
    transform: translate(-50%, -50%);
    width: calc(100vw - 24px);
    max-width: 340px;
    max-height: 82dvh;
    overflow-y: auto;
    padding: 12px 14px;
    gap: 8px;
  }

  .overlay-card {
    width: calc(100% - 20px);
    max-width: 350px;
    padding: 14px 16px;
  }

  .overlay-card h2 {
    font-size: 16px;
  }

  .overlay-card p {
    font-size: 12px;
  }

  .pause-card {
    width: calc(100vw - 24px);
    max-width: 340px;
    max-height: 85dvh;
    overflow-y: auto;
    padding: 14px;
  }

  .pause-header {
    margin-bottom: 10px;
    padding-bottom: 8px;
  }

  .pause-grid {
    gap: 7px;
  }

  .pause-action {
    padding: 8px 12px;
    font-size: 12.5px;
  }

  /* Dedicated Mobile Icon Set */
  .res-pill .icon.svg-icon-host {
    width: 16px;
    height: 16px;
  }

  .tab-btn [data-svg-icon],
  .pause-action [data-svg-icon],
  .pause-action .svg-icon {
    width: 15px;
    height: 15px;
  }

  .svg-icon-relic {
    width: 22px;
    height: 22px;
  }

  .svg-icon-node {
    width: 20px;
    height: 20px;
  }

  .mechanic-toast-icon .svg-icon {
    width: 16px;
    height: 16px;
  }
}

@media (hover: none) and (pointer: coarse) {
  .canvas-zoom-controls {
    display: none !important;
  }
}

.pause-subview {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pause-subview.hidden {
  display: none;
}

.pause-subview-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(56, 189, 248, 0.2);
}

.pause-subview-header h4 {
  margin: 0;
  font-size: 0.98rem;
  color: #f8fafc;
}

.pause-back-btn {
  padding: 6px 10px !important;
  font-size: 0.82rem !important;
  flex-shrink: 0;
}

.pause-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 9px 11px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(56, 189, 248, 0.2);
  color: #cbd5e1;
  font-size: 0.85rem;
  cursor: pointer;
}

.pause-toggle input {
  accent-color: #38bdf8;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.tutorial-card {
  width: min(92vw, 480px);
  max-height: 88dvh;
  overflow-y: auto;
  background: linear-gradient(165deg, rgba(15, 23, 42, 0.98), rgba(8, 13, 28, 0.98));
  border: 1px solid rgba(56, 189, 248, 0.42);
  border-radius: 16px;
  padding: 18px 18px 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65), 0 0 28px rgba(56, 189, 248, 0.14);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tutorial-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.tutorial-kicker {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #38bdf8;
  margin-bottom: 2px;
}

.tutorial-header h3 {
  margin: 0;
  font-size: 1.08rem;
  color: #f8fafc;
}

.tutorial-step-badge {
  background: rgba(56, 189, 248, 0.16);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #7dd3fc;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.tutorial-body {
  font-size: 0.9rem;
  line-height: 1.5;
  color: #cbd5e1;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 12px;
  padding: 12px 13px;
}

.tutorial-body p {
  margin: 0 0 8px 0;
}

.tutorial-body p:last-child {
  margin-bottom: 0;
}

.tutorial-body ul {
  margin: 4px 0 0 0;
  padding-left: 18px;
}

.tutorial-body li {
  margin-bottom: 6px;
}

.tutorial-body li:last-child {
  margin-bottom: 0;
}

.tutorial-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.tutorial-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.3);
  transition: transform 0.15s ease, background 0.15s ease;
}

.tutorial-dot.active {
  background: #38bdf8;
  transform: scale(1.25);
}

.tutorial-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: #94a3b8;
  cursor: pointer;
}

.tutorial-opt input {
  accent-color: #38bdf8;
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.tutorial-footer {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  align-items: center;
}

.tutorial-footer button {
  flex: 1;
  padding: 9px 10px;
  font-size: 0.85rem;
}
