:root {
  --bg: #0b0e12;
  --panel: #10161e;
  --panel-edge: #1d2a38;
  --text: #e8f0ff;
  --muted: #9fb3c8;
  --accent: #5ee6ff;
  --accent-2: #ffb34d;
  --ok: #4bf3a1;
  --bad: #ff6b6b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; background: var(--bg); color: var(--text); font-family: "Trebuchet MS", "Segoe UI", sans-serif; }
body.playing { cursor: none; }
#game { display: block; width: 100vw; height: 100vh; }

#hint {
  position: fixed;
  left: 16px;
  bottom: 14px;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0.3px;
  opacity: 0.9;
}

.audio-controls {
  position: fixed;
  right: 16px;
  bottom: 14px;
  display: flex;
  gap: 8px;
  z-index: 6;
}

.audio-toggle {
  background: #0f151d;
  border: 1px solid #223242;
  color: var(--text);
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
  letter-spacing: 0.3px;
  cursor: pointer;
}

.audio-toggle.off {
  color: var(--muted);
  opacity: 0.75;
}

.panel {
  position: fixed;
  inset: 0;
  background: rgba(7, 10, 14, 0.88);
  display: grid;
  place-items: center;
  z-index: 5;
}

.hidden { display: none; }

.panel-inner {
  width: min(1100px, 92vw);
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  position: relative;
  overflow: visible;
}

.panel-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.panel-top-right {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

h1 { font-size: 28px; margin-bottom: 8px; }
h2 { font-size: 18px; margin-bottom: 10px; }

p { color: var(--muted); margin-bottom: 18px; }

.tabs { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.tab { background: #0f151d; border-color: #223242; }
.tab.active { border-color: var(--accent); color: var(--accent); }
.tab-panels { margin-top: 6px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.paused-banner {
  background: rgba(255, 179, 77, 0.15);
  color: var(--accent-2);
  border: 1px solid rgba(255, 179, 77, 0.35);
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 12px;
  display: inline-block;
}

.list {
  background: #0e141c;
  border: 1px solid #1b2633;
  border-radius: 12px;
  padding: 10px;
  max-height: 420px;
  overflow: auto;
}

.item {
  padding: 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  margin-bottom: 8px;
  background: #0b1118;
}

.item:last-child { margin-bottom: 0; }
.item.locked { opacity: 0.55; }
.item h3 { font-size: 15px; margin-bottom: 4px; }
.item p { margin-bottom: 6px; font-size: 13px; }
.item button { width: 100%; }
.benefit-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  border-radius: 8px;
  background: #0f151d;
  border: 1px solid #223242;
  font-size: 12px;
}
.benefit-pill img { width: 14px; height: 14px; }

.shop-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 6px 0 8px;
}
.shop-line .benefit-pill img { margin-right: 0; }

.tree-scroll {
  overflow-x: auto;
  overflow-y: visible;
  padding-bottom: 4px;
  position: relative;
  z-index: 1;
}

.research-tree {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0;
  min-height: 280px;
}

.branch-row,
.shop-row {
  display: flex;
  gap: 6px;
  align-items: center;
  min-width: max-content;
}

.branch-label {
  width: 120px;
  flex: 0 0 120px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  align-self: center;
}

.branch-nodes,
.shop-items {
  display: flex;
  gap: 2px;
}

.node-button {
  position: relative;
  background: #0b1118;
  border: 1px solid #1f2c3a;
  border-radius: 12px;
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  box-shadow: none;
}

.node-button.locked .node-icon,
.node-button.unlocked .node-icon { opacity: 0.45; }
.node-button.ready {
  border-color: rgba(94, 230, 255, 0.7);
  box-shadow: 0 0 0 1px rgba(94, 230, 255, 0.25);
}
.node-button:hover { transform: none; border-color: var(--accent); }
.node-button:disabled { cursor: not-allowed; }
.node-icon { width: 70px; height: 70px; }
.node-button:hover,
.pool-item:hover,
.slot:hover,
.stat-chip:hover { z-index: 5; }

.node-button[data-tip]:hover::after,
.pool-item[data-tip]:hover::after,
.slot[data-tip]:hover::after,
.stat-chip[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: 0;
  top: 100%;
  margin-top: 8px;
  background: #111a24;
  color: var(--text);
  border: 1px solid #223242;
  padding: 8px 10px;
  border-radius: 10px;
  width: 220px;
  font-size: 12px;
  z-index: 30;
  pointer-events: none;
}

.node-button[data-tip]:hover::before,
.pool-item[data-tip]:hover::before,
.slot[data-tip]:hover::before,
.stat-chip[data-tip]:hover::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 100%;
  margin-top: 2px;
  border: 6px solid transparent;
  border-bottom-color: #223242;
}

.loadout-panel { display: grid; gap: 12px; }
.loadout-section {
  background: #0e141c;
  border: 1px solid #1b2633;
  border-radius: 12px;
  padding: 10px;
}
.loadout-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, #1f2c3a, transparent);
}

.slot-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 6px 0;
}

.slot {
  width: 82px;
  height: 82px;
  border: 2px solid rgba(255, 179, 77, 0.65);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  background: #0b1118;
  position: relative;
  text-align: center;
}

.slot.filled {
  border-style: solid;
  color: var(--text);
}
.slot.locked {
  border-color: rgba(255, 214, 74, 0.9);
  box-shadow: 0 0 0 1px rgba(255, 214, 74, 0.25);
}
.slot-icon { width: 70px; height: 70px; }
.slot-lock {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 2px 6px;
  font-size: 9px;
  border-radius: 6px;
  border: 1px solid rgba(255, 214, 74, 0.45);
  background: rgba(20, 24, 30, 0.85);
  color: #ffd64a;
}

.pool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
}

.pool-item {
  background: #0b1118;
  border: 1px solid #1f2c3a;
  border-radius: 10px;
  padding: 4px;
  font-size: 12px;
  cursor: grab;
  position: relative;
  display: grid;
  place-items: center;
  min-height: 64px;
}

.pool-item.locked {
  opacity: 0.55;
  cursor: not-allowed;
}
.pool-item.dragging { opacity: 0.5; }
.muted { color: var(--muted); font-size: 12px; }
.pool-icon { width: 70px; height: 70px; }
.pool-cost {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
}
.pool-cost img { width: 12px; height: 12px; }

.shop-tree {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 6px;
  min-height: 280px;
}

.shop-items .item { margin-bottom: 0; min-width: 200px; }

.level-complete-card {
  text-align: left;
}

.level-complete-header {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 16px;
  min-height: 10px;
}

.level-complete-stats {
  display: none;
}

.level-complete-hero {
  display: grid;
  place-items: center;
  padding: 16px 0 6px;
}

.level-complete-hero img {
  width: min(420px, 60vw);
  height: auto;
}

.level-complete-rewards {
  display: flex;
  gap: 18px;
  justify-content: center;
  align-items: center;
  margin: 6px 0 6px;
}

.big-reward {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 40px;
  font-weight: 700;
  color: var(--text);
}

.big-reward img {
  width: 40px;
  height: 40px;
}

.reward-list {
  list-style: none;
  padding-left: 0;
  margin-top: 8px;
  display: grid;
  gap: 6px;
  font-size: 14px;
  color: var(--text);
}

.footer { margin-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.stats { color: var(--muted); font-size: 14px; display: flex; gap: 10px; flex-wrap: wrap; }
.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #0b1118;
  border: 1px solid #1f2c3a;
  border-radius: 10px;
  padding: 4px 8px;
  position: relative;
}
.stat-chip img { width: 16px; height: 16px; }
.life-icon { width: 16px; height: 16px; }
.inline-icon { width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; }
.cost-line { display: flex; align-items: center; gap: 6px; }
.buttons { display: flex; gap: 10px; flex-wrap: wrap; }
button {
  background: linear-gradient(135deg, #1c2734, #101723);
  border: 1px solid #2a3b4f;
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  transition: transform 0.12s ease, border 0.12s ease, color 0.12s ease;
}
button:hover { transform: translateY(-1px); border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; border-color: #2a3b4f; color: var(--muted); }

button.node-button {
  background: #0b1118;
  border-color: #1f2c3a;
  padding: 0;
  transform: none;
}
