*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #03040c;
  --glass: rgba(8, 11, 26, 0.72);
  --line: rgba(120, 200, 255, 0.12);
  --cyan: #00f0ff;
  --violet: #a58bff;
  --magenta: #ff2d95;
  --green: #3dffb0;
  --red: #ff4d7a;
  --gold: #ffd23f;
  --text: #eaf4ff;
  --muted: #7d8db0;
  --dim: #4a5878;
  --font: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
  --display: 'Orbitron', 'Space Grotesk', sans-serif;
  --mono: 'JetBrains Mono', 'Cascadia Code', Consolas, monospace;
  --radius: 14px;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

#canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

#canvas.grabbing { cursor: grabbing !important; }

.vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.65) 100%);
}

.scanlines {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent 0 2px, rgba(0, 0, 0, 0.12) 2px 3px);
  opacity: 0.35;
  mix-blend-mode: multiply;
}

/* ---------- loader ---------- */

.loader {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1rem;
  background: radial-gradient(circle at center, #0b0f2a, #03040c 70%);
  transition: opacity 0.9s ease, visibility 0.9s;
}

.loader.hidden { opacity: 0; visibility: hidden; }

.loader-glyph {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.45), 0 0 60px rgba(255, 45, 149, 0.25);
  animation: pulse-glow 2.4s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.06); filter: brightness(1.15); }
}

.loader-text {
  font-family: var(--display);
  font-size: 0.8rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
  max-width: 420px;
  text-align: center;
  line-height: 1.6;
}

.loader.error .loader-glyph { animation: none; filter: grayscale(0.4) hue-rotate(300deg); }
.loader.error .loader-text { color: var(--red); letter-spacing: 0.06em; text-transform: none; font-family: var(--font); }

/* ---------- shared ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.overlay > * { pointer-events: auto; }

.panel {
  background:
    linear-gradient(var(--glass), var(--glass)) padding-box,
    linear-gradient(140deg, rgba(0, 240, 255, 0.55), rgba(165, 139, 255, 0.12) 45%, rgba(255, 45, 149, 0.5)) border-box;
  border: 1px solid transparent;
  border-radius: var(--radius);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.label {
  display: block;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.bar {
  display: block;
  height: 3px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--violet), var(--cyan));
  box-shadow: 0 0 10px var(--cyan);
  transition: width 0.4s ease;
}

.bump { animation: bump 0.6s ease; }

@keyframes bump {
  0% { color: #fff; text-shadow: 0 0 16px currentColor; transform: translateY(-2px); }
  100% { transform: none; }
}

@keyframes spin { to { transform: rotate(360deg); } }

@keyframes shimmer { to { background-position: -300% 0; } }

/* ---------- top bar ---------- */

.top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  background: linear-gradient(180deg, rgba(3, 4, 12, 0.9), transparent);
  flex-wrap: wrap;
  pointer-events: none;
}

.top-bar > * { pointer-events: auto; }

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.brand-glyph {
  display: block;
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.35), 0 0 32px rgba(255, 45, 149, 0.2);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.1; }

.brand-name {
  font-family: var(--display);
  font-weight: 900;
  font-size: 1.05rem;
  letter-spacing: 0.2em;
  background: linear-gradient(90deg, var(--cyan), var(--violet), var(--magenta), var(--cyan));
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 10s linear infinite;
}

.brand-name b { font-weight: 500; margin-left: 0.4em; }

.brand-tag {
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.token {
  padding: 0.25rem 0.6rem;
  border: 1px solid rgba(165, 139, 255, 0.45);
  border-radius: 999px;
  background: rgba(165, 139, 255, 0.1);
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--violet);
}

.mint-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.45rem 0.22rem 0.5rem;
  border: 1px solid rgba(0, 240, 255, 0.35);
  border-radius: 999px;
  background: rgba(0, 240, 255, 0.06);
  font-family: var(--mono);
  font-size: 0.62rem;
}

.mint-chip.hidden { display: none; }

.mint-label {
  font-size: 0.55rem;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.mint-link {
  color: var(--cyan);
  text-decoration: none;
}

.mint-link:hover { text-shadow: 0 0 10px var(--cyan); }

.copy-mint {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.75rem;
  line-height: 1;
  padding: 0.1rem;
}

.copy-mint:hover { color: var(--cyan); }
.copy-mint.done { color: var(--green); }

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.stat {
  min-width: 96px;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(8, 11, 26, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.stat .value {
  display: block;
  margin-top: 0.15rem;
  font-family: var(--mono);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--cyan);
  text-shadow: 0 0 12px rgba(0, 240, 255, 0.35);
}

.stat-next .bar { margin-top: 0.35rem; }

.stat.hot .value {
  color: var(--red);
  text-shadow: 0 0 16px var(--red);
}

.stat.hot-up .value {
  color: var(--green);
  text-shadow: 0 0 16px var(--green);
}

.stat.hot-down .value {
  color: var(--red);
  text-shadow: 0 0 16px var(--red);
}

/* ---------- core bar + banner ---------- */

.core-bar {
  position: absolute;
  top: 3.6rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 1.1rem;
  border: 1px solid rgba(165, 139, 255, 0.3);
  border-radius: 999px;
  background: rgba(8, 11, 26, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 0.74rem;
  white-space: nowrap;
}

.core-pulse {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--magenta);
  box-shadow: 0 0 12px var(--magenta);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.7); opacity: 0.5; }
}

.core-label {
  font-family: var(--display);
  font-size: 0.66rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--violet);
}

.core-action { text-transform: capitalize; }
.core-sep { width: 1px; height: 12px; background: var(--line); }
.core-next { color: var(--muted); font-size: 0.68rem; }
.core-timer { font-family: var(--mono); color: var(--magenta); }

.banner {
  --c: #00f0ff;
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translate(-50%, -10px) scale(0.96);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 1rem 2.4rem;
  opacity: 0;
  pointer-events: none !important;
  text-align: center;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.banner::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 999px;
  background: radial-gradient(ellipse at center, color-mix(in srgb, var(--c) 22%, transparent), transparent 70%);
}

.banner.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

.banner-kicker {
  font-size: 0.62rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--muted);
}

.banner-title {
  font-family: var(--display);
  font-size: clamp(1.4rem, 3.4vw, 2.4rem);
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--c);
  text-shadow: 0 0 24px var(--c), 0 0 60px var(--c);
}

.banner-sub { font-size: 0.85rem; color: var(--text); opacity: 0.85; }

/* ---------- feed ---------- */

.feed-panel {
  position: absolute;
  top: 6.5rem;
  left: 1rem;
  width: min(320px, 30vw);
  max-height: calc(100vh - 17rem);
  display: flex;
  flex-direction: column;
  padding: 1rem;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.panel-head h2 {
  font-family: var(--display);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text);
}

.live-dot {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--red);
}

.live-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 8px var(--red);
  animation: pulse 1.2s infinite;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.2rem;
  margin-bottom: 0.6rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.tab {
  flex: 1;
  padding: 0.35rem 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.66rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab:hover { color: var(--text); }

.tab.active {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.18), rgba(165, 139, 255, 0.18));
  color: var(--cyan);
}

.feed {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  margin-right: -0.4rem;
  padding-right: 0.4rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 240, 255, 0.25) transparent;
}

.ev {
  --c: var(--cyan);
  display: grid;
  grid-template-columns: 1.3rem 1fr auto;
  align-items: start;
  gap: 0.45rem;
  padding: 0.5rem 0.4rem;
  border-left: 2px solid color-mix(in srgb, var(--c) 60%, transparent);
  border-radius: 0 6px 6px 0;
  margin-bottom: 0.25rem;
  font-size: 0.72rem;
  line-height: 1.4;
  background: linear-gradient(90deg, color-mix(in srgb, var(--c) 7%, transparent), transparent 70%);
}

.ev.clickable { cursor: pointer; }
.ev.clickable:hover { background: linear-gradient(90deg, color-mix(in srgb, var(--c) 18%, transparent), transparent 80%); }

.ev-icon { color: var(--c); text-align: center; text-shadow: 0 0 8px var(--c); }
.ev-text { color: var(--text); }
.ev-time { font-family: var(--mono); font-size: 0.6rem; color: var(--dim); padding-top: 0.1rem; }

.ev-spawn { --c: var(--violet); }
.ev-buy { --c: var(--green); }
.ev-sell { --c: var(--red); }
.ev-pulse { --c: var(--green); }
.ev-purge { --c: var(--red); }
.ev-dark { --c: #5a6a88; }
.ev-revive { --c: var(--cyan); }
.ev-command { --c: var(--magenta); }
.ev-tier { --c: var(--gold); }

.ev.new { animation: slide-in 0.5s ease; }

@keyframes slide-in {
  from { opacity: 0; transform: translateX(-14px); background-color: color-mix(in srgb, var(--c) 30%, transparent); }
  to { opacity: 1; transform: none; }
}

/* ---------- node panel ---------- */

.node-panel {
  position: absolute;
  top: 6.5rem;
  right: 1rem;
  width: min(310px, 32vw);
  max-height: calc(100vh - 20rem);
  overflow-y: auto;
  padding: 1.1rem;
  opacity: 0;
  transform: translateX(calc(100% + 2rem));
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s;
  scrollbar-width: thin;
}

.node-panel.open { opacity: 1; transform: none; }

.close-panel {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 1.8rem;
  height: 1.8rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 1.15rem;
  cursor: pointer;
}

.close-panel:hover { border-color: var(--line); color: var(--text); }

.node-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.7rem;
}

.node-chip {
  --c: var(--cyan);
  width: 2.4rem;
  height: 2.4rem;
  flex-shrink: 0;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  background: radial-gradient(circle, #fff 0 12%, var(--c) 40%, color-mix(in srgb, var(--c) 30%, transparent) 75%);
  filter: drop-shadow(0 0 10px var(--c));
  animation: spin 6s linear infinite;
}

.node-head h2 {
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.node-state { font-size: 0.72rem; font-weight: 500; }

.wallet {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.55rem;
  margin-bottom: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--muted);
  word-break: break-all;
}

.copy {
  flex-shrink: 0;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
}

.copy:hover { color: var(--cyan); }
.copy.done { color: var(--green); }

.spark-wrap {
  padding: 0.5rem 0.65rem 0.15rem;
  margin-bottom: 0.55rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
}

.spark-head { display: flex; justify-content: space-between; align-items: baseline; }

.pnl { font-family: var(--mono); font-size: 0.85rem; font-weight: 600; color: var(--green); }
.pnl.neg { color: var(--red); }

#node-spark { display: block; width: 100%; height: 40px; margin-top: 0.2rem; }

.dna {
  display: grid;
  gap: 0.32rem;
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.55rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(0, 240, 255, 0.14);
}

.dna-row {
  display: grid;
  grid-template-columns: 5.2rem 1fr auto;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.68rem;
  color: var(--muted);
}

.dna-row.pair { grid-template-columns: 1fr auto; }

.dna-row .bar { height: 4px; }

.dna-row b {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.68rem;
  color: var(--text);
  min-width: 2.4rem;
  text-align: right;
}

.dna-row:nth-child(3) b { color: var(--green); }
.dna-row:nth-child(4) b { color: var(--red); }

.node-stats { display: grid; gap: 0.45rem; font-size: 0.76rem; }

.node-stats div {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px dashed var(--line);
}

.node-stats dt { color: var(--muted); }
.node-stats dd { font-family: var(--mono); color: var(--text); }

.btn-follow {
  width: 100%;
  margin-top: 1rem;
  padding: 0.7rem;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--magenta), var(--violet));
  color: #fff;
  font-family: var(--display);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(255, 45, 149, 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-follow:hover { transform: translateY(-1px); box-shadow: 0 8px 30px rgba(255, 45, 149, 0.5); }

.btn-follow.active {
  background: linear-gradient(135deg, var(--gold), #ff8a3d);
  color: #1a1000;
  box-shadow: 0 6px 24px rgba(255, 210, 63, 0.35);
}

/* ---------- tier + radar ---------- */

.tier {
  position: absolute;
  left: 1rem;
  bottom: 3.4rem;
  width: min(320px, 30vw);
  padding: 0.8rem 1rem;
}

.tier-top { margin-bottom: 0.5rem; }

.tier-name {
  font-family: var(--display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255, 210, 63, 0.4);
}

.tier .bar { height: 5px; }
.tier .bar i { background: linear-gradient(90deg, var(--gold), var(--magenta)); box-shadow: 0 0 12px var(--gold); }

.tier-next { display: block; margin-top: 0.45rem; font-size: 0.68rem; color: var(--muted); }

.radar-wrap {
  position: absolute;
  right: 1rem;
  bottom: 3.4rem;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 240, 255, 0.06), rgba(8, 11, 26, 0.75) 70%);
  border: 1px solid rgba(0, 240, 255, 0.3);
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.12), inset 0 0 30px rgba(0, 240, 255, 0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  pointer-events: none !important;
}

#radar { width: 100%; height: 100%; display: block; }

.radar-label {
  position: absolute;
  bottom: -1.2rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--display);
  font-size: 0.55rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------- bottom bar ---------- */

.bottom-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1.25rem;
  background: linear-gradient(0deg, rgba(3, 4, 12, 0.92), transparent);
  font-size: 0.68rem;
  color: var(--muted);
  pointer-events: none;
}

kbd {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  margin: 0 0.1rem 0 0.35rem;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--text);
}

.preview-tag { font-family: var(--mono); font-size: 0.64rem; color: var(--violet); white-space: nowrap; }

/* ---------- in-world labels ---------- */

.panel,
.top-bar,
.core-bar,
.banner,
.radar-wrap { z-index: 2; }

.tooltip,
.node-tag {
  position: absolute;
  z-index: 1;
  top: 0;
  left: 0;
  opacity: 0;
  pointer-events: none !important;
  white-space: nowrap;
  transition: opacity 0.15s;
}

.tooltip.show,
.node-tag.show { opacity: 1; }

.tooltip {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid rgba(0, 240, 255, 0.35);
  border-radius: 8px;
  background: rgba(6, 9, 22, 0.85);
  font-size: 0.68rem;
  color: var(--muted);
}

.tooltip b { font-family: var(--display); font-size: 0.72rem; letter-spacing: 0.08em; color: var(--text); }

.node-tag {
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: var(--gold);
  color: #1a1000;
  font-family: var(--display);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  box-shadow: 0 0 18px rgba(255, 210, 63, 0.6);
}

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  .stat { min-width: 80px; padding: 0.35rem 0.55rem; }
  .brand-tag { display: none; }
}

@media (max-width: 860px) {
  .feed-panel, .tier { display: none; }
  .controls-hint { display: none; }
  .node-panel { width: min(320px, calc(100vw - 2rem)); }
  .core-bar { top: auto; bottom: 3rem; }
  .radar-wrap { width: 110px; height: 110px; bottom: 5.5rem; }
}
