:root {
  --mint: #97fce4;
  --mint-dim: #5fc9b2;
  --ink: #e9f2f4;
  --muted: #93a3b5;
  --panel: rgba(9, 14, 28, 0.72);
  --panel-solid: #0b1222;
  --line: rgba(151, 252, 228, 0.16);
  --radius: 14px;
  --font: "Space Grotesk", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --t0: #e8d5b5;
  --t1: #c0584a;
  --t2: #4fd8ff;
  --t3: #9fb3c8;
  --t4: #7aa2ff;
  --t5: #97fce4;
  --t6: #a7a1c4;
  --t7: #6b6f75;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #050817;
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

button,
.btn {
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
  white-space: nowrap;
}
button:hover,
.btn:hover {
  background: rgba(151, 252, 228, 0.12);
  border-color: rgba(151, 252, 228, 0.4);
}
button.primary,
.btn.primary {
  background: var(--mint);
  color: #04221c;
  border-color: var(--mint);
  font-weight: 700;
}
button.primary:hover,
.btn.primary:hover {
  background: #b9fff0;
}
.btn.disabled {
  opacity: 0.55;
  pointer-events: none;
}

.mono {
  font-family: var(--mono);
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

/* ---------- brand ---------- */
.mark {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 30px;
}
.mark span {
  width: 8px;
  background: var(--mint);
  border-radius: 2px;
  box-shadow: 0 0 12px rgba(151, 252, 228, 0.7);
}
.mark span:nth-child(1) {
  height: 40%;
}
.mark span:nth-child(2) {
  height: 100%;
}
.mark span:nth-child(3) {
  height: 65%;
}

/* ---------- loading ---------- */
#loader {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at 50% 60%, #14204a 0%, #050817 70%);
  transition: opacity 0.8s ease, visibility 0.8s;
}
#loader.done {
  opacity: 0;
  visibility: hidden;
}
.loader-card {
  text-align: center;
  width: min(360px, calc(100vw - 32px));
}
.loader-card .mark {
  justify-content: center;
  height: 56px;
}
.loader-card .mark span {
  width: 14px;
  animation: rise 1.4s ease-in-out infinite;
}
.loader-card .mark span:nth-child(2) {
  animation-delay: 0.2s;
}
.loader-card .mark span:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes rise {
  50% {
    transform: scaleY(0.6);
  }
}
.loader-card h1 {
  font-size: 44px;
  letter-spacing: 0.18em;
  margin: 18px 0 6px;
  color: var(--mint);
  text-shadow: 0 0 24px rgba(151, 252, 228, 0.5);
}
.loader-card p {
  color: var(--muted);
  min-height: 1.4em;
}
.bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
}
#loader-bar {
  height: 100%;
  width: 0;
  background: var(--mint);
  transition: width 0.4s ease;
}

/* ---------- top bar ---------- */
.topbar {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: none;
}
.topbar > * {
  pointer-events: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  padding: 8px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
}
.brand strong {
  display: block;
  font-size: 20px;
  letter-spacing: 0.16em;
  color: var(--mint);
}
.brand small {
  color: var(--muted);
  font-size: 12px;
}
#search {
  flex: 1;
  max-width: 440px;
  display: flex;
  gap: 6px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
}
#search input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--ink);
  font: 14px var(--mono);
  padding: 0 8px;
}
#search input::placeholder {
  color: var(--muted);
  font-family: var(--font);
}
.actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}
.actions button:not(.primary) {
  background: var(--panel);
  backdrop-filter: blur(14px);
}

/* ---------- stats ---------- */
.stats {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, auto);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  backdrop-filter: blur(14px);
}
.stats div {
  background: var(--panel);
  padding: 10px 16px;
}
.stats small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.stats b {
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

/* ---------- feed ---------- */
#feed {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 10;
  width: 300px;
  padding: 12px 14px;
}
#feed header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
#feed h2 {
  font-size: 14px;
  margin: 0;
}
#block {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 10px var(--mint);
  animation: blink 1.6s infinite;
}
.dot.off {
  background: #f4a261;
  box-shadow: none;
  animation: none;
}
@keyframes blink {
  50% {
    opacity: 0.3;
  }
}
#feed ul {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 240px;
  overflow: auto;
}
#feed li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0 8px;
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}
#feed li:hover {
  background: rgba(151, 252, 228, 0.08);
}
#feed li b {
  color: var(--mint);
  font-weight: 500;
  text-align: right;
}
#feed li small {
  color: var(--muted);
  font-size: 11px;
}

/* ---------- legend ---------- */
#legend {
  position: fixed;
  left: 16px;
  top: 92px;
  z-index: 10;
  padding: 10px 12px;
  width: 260px;
}
#legend-toggle {
  display: none;
}
#legend ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
#legend li {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  padding: 5px 0;
  font-size: 13px;
}
#legend li i {
  grid-row: span 2;
}
#legend li small {
  grid-column: 2;
  color: var(--muted);
  font-size: 11px;
}
#legend li em {
  grid-row: 1 / span 2;
  grid-column: 3;
  font-style: normal;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
i[class^="tier-"] {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
}
.tier-0 { background: var(--t0); }
.tier-1 { background: var(--t1); }
.tier-2 { background: var(--t2); }
.tier-3 { background: var(--t3); }
.tier-4 { background: var(--t4); }
.tier-5 { background: var(--t5); box-shadow: 0 0 8px var(--t5); }
.tier-6 { background: var(--t6); }
.tier-7 { background: var(--t7); }

/* ---------- building panel ---------- */
#panel {
  position: fixed;
  right: 16px;
  top: 92px;
  z-index: 11;
  width: 320px;
  padding: 18px;
  animation: slide 0.25s ease;
}
@keyframes slide {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
}
.close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  padding: 0;
  font-size: 18px;
  border-radius: 8px;
}
.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--mint);
  display: flex;
  align-items: center;
  gap: 8px;
}
#panel h2 {
  margin: 0 0 8px;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}
#panel p {
  color: #c4d0dc;
  font-size: 14px;
  line-height: 1.5;
}
#panel .big {
  font-size: 32px;
  font-weight: 700;
  margin: 6px 0 12px;
  color: var(--ink);
}
#panel .big span {
  font-size: 15px;
  color: var(--muted);
  font-weight: 400;
}
dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  margin: 0 0 16px;
  font-size: 13px;
}
dt {
  color: var(--muted);
}
dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.row {
  display: flex;
  gap: 8px;
}
.row .btn {
  flex: 1;
}
.copy {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
}

/* ---------- tooltip and toasts ---------- */
#tooltip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 20;
  pointer-events: none;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  white-space: nowrap;
}
#tooltip b {
  color: var(--mint);
  font-weight: 500;
}
#toasts {
  position: fixed;
  top: 92px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--panel-solid);
  border: 1px solid rgba(151, 252, 228, 0.4);
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4), 0 0 20px rgba(151, 252, 228, 0.15);
  animation: drop 0.3s ease;
  transition: opacity 0.5s, transform 0.5s;
  max-width: calc(100vw - 32px);
}
.toast b {
  color: var(--mint);
}
.toast a {
  color: var(--mint);
}
.toast.clickable {
  cursor: pointer;
}
.toast.out {
  opacity: 0;
  transform: translateY(-8px);
}
@keyframes drop {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* ---------- token ---------- */
dialog#token {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: var(--panel-solid);
  color: var(--ink);
  border: 1px solid rgba(151, 252, 228, 0.35);
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 0 60px rgba(151, 252, 228, 0.15);
}
dialog#token::backdrop {
  background: rgba(3, 6, 15, 0.7);
  backdrop-filter: blur(4px);
}
#token h2 {
  font-size: 44px;
  margin: 0 0 10px;
  color: var(--mint);
  letter-spacing: 0.04em;
  text-shadow: 0 0 30px rgba(151, 252, 228, 0.4);
}
#token h3 {
  font-size: 15px;
  margin: 24px 0 8px;
}
#token p,
#token ol {
  color: #c4d0dc;
  line-height: 1.55;
  font-size: 14px;
}
#token ol {
  padding-left: 20px;
}
.token-grid {
  margin: 18px 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 14px;
}
.token-grid dd {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  word-break: break-all;
}
#token-buy {
  width: 100%;
  padding: 12px;
  font-size: 16px;
}
.links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 14px;
}
.links a {
  color: var(--mint);
  font-size: 13px;
}
.fine {
  font-size: 12px !important;
  color: var(--muted) !important;
  margin-top: 18px;
}

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  .topbar {
    flex-wrap: wrap;
    top: 12px;
    left: 12px;
    right: 12px;
    gap: 8px;
  }
  .brand small {
    display: none;
  }
  #search {
    order: 3;
    flex-basis: 100%;
    max-width: none;
  }
  .actions {
    gap: 6px;
  }
  #wallet,
  #overview {
    display: none;
  }
  .stats {
    left: 12px;
    right: 12px;
    bottom: 12px;
    grid-template-columns: repeat(2, 1fr);
  }
  .stats div {
    padding: 8px 12px;
  }
  .stats b {
    font-size: 17px;
  }
  #feed {
    display: none;
  }
  #legend {
    top: 128px;
    left: 12px;
    width: auto;
    padding: 6px;
  }
  #legend-toggle {
    display: inline-flex;
  }
  #legend ul {
    display: none;
    padding: 6px 6px 0;
    width: 240px;
  }
  #legend.open ul {
    display: block;
  }
  #panel {
    left: 12px;
    right: 12px;
    top: auto;
    bottom: 132px;
    width: auto;
    max-height: 55vh;
    overflow: auto;
  }
  #toasts {
    top: 128px;
  }
}
