:root {
  --bg: #05060a;
  --fg: #e8eaf2;
  --muted: rgba(232, 234, 242, 0.72);
  --glass: rgba(8, 10, 18, 0.58);
  --glassBorder: rgba(232, 234, 242, 0.14);
  --green: #41ff85;
  --green2: #00ffa8;
  --green3: #b8ff3d;
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.6);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    "Liberation Mono",
    "Courier New",
    monospace;
  overflow: hidden;
}

#app {
  height: 100%;
  width: 100%;
  position: relative;
}

#stage {
  height: 100%;
  width: 100%;
  position: relative;
  z-index: 1;
  background: radial-gradient(
    1200px 800px at 50% 40%,
    rgba(40, 60, 120, 0.10),
    rgba(0, 0, 0, 0.92) 65%,
    #000 100%
  );
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#staticCanvas {
  opacity: 1;
  filter: contrast(1.4) brightness(1.15);
  z-index: 1;
  transition: filter 420ms ease;
}

body.tv-ambient #staticCanvas {
  filter: contrast(1.18) brightness(1.08);
}

#matrixCanvas {
  opacity: 0;
  filter: blur(0.25px) contrast(1.05);
  z-index: 5;
}

#tvMask {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 3;
}

/* TV power on */
body.phase-tv #tvMask {
  animation: tvOn 1.1s ease-out 0.1s both;
}

@keyframes tvOn {
  0% {
    transform: scaleX(1) scaleY(0.02);
    filter: brightness(2) contrast(2) saturate(0);
  }
  35% {
    transform: scaleX(1.12) scaleY(0.05);
    filter: brightness(1.6) contrast(2.2) saturate(0.2);
  }
  70% {
    transform: scaleX(0.98) scaleY(1.02);
    filter: brightness(1.05) contrast(1.2) saturate(0.9);
  }
  100% {
    transform: scaleX(1) scaleY(1);
    filter: none;
  }
}

.glitch-in #slideshow {
  animation: channelZap 760ms steps(6, end) 1 both;
}

.glitch-in #slideshow img {
  animation: channelFlicker 760ms steps(7, end) 1 both;
}

@keyframes channelZap {
  0% {
    transform: translateX(-2px) skewX(-8deg);
    filter: saturate(0.4) contrast(1.7) brightness(1.25);
  }
  22% {
    transform: translateX(3px) skewX(10deg);
    filter: saturate(1.2) contrast(1.9) brightness(1.35);
  }
  45% {
    transform: translateX(-4px) skewX(-12deg);
    filter: saturate(0.8) contrast(2.05) brightness(1.15);
  }
  70% {
    transform: translateX(2px) skewX(6deg);
    filter: saturate(1.05) contrast(1.25) brightness(1.05);
  }
  100% {
    transform: none;
    filter: none;
  }
}

@keyframes channelFlicker {
  0% {
    opacity: 0;
    filter: saturate(0.2) contrast(2.0) brightness(1.45);
  }
  12% {
    opacity: 1;
  }
  24% {
    opacity: 0.2;
  }
  36% {
    opacity: 1;
  }
  48% {
    opacity: 0.55;
  }
  60% {
    opacity: 1;
  }
  74% {
    opacity: 0.85;
  }
  100% {
    opacity: 1;
    filter: saturate(1.05) contrast(1.03);
  }
}

.hidden {
  visibility: hidden;
}

/* Slideshow container */
#slideshow {
  position: absolute;
  inset: 0;
  visibility: visible;
}

#slideshow img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  opacity: 0;
  transform: scale(1);
  filter: saturate(1.05) contrast(1.03);
  will-change: opacity, transform, filter;
}

#imgA {
  opacity: 1;
}

/* Extended slow buzz transition */
body.buzz #slideshow img {
  animation: buzzJitter 120ms steps(2, end) infinite;
}

@keyframes buzzJitter {
  0% {
    transform: translate(0, 0) scale(1.002);
    filter: saturate(1.1) contrast(1.06) hue-rotate(0deg);
  }
  50% {
    transform: translate(1px, -1px) scale(1.006);
    filter: saturate(1.15) contrast(1.1) hue-rotate(6deg);
  }
  100% {
    transform: translate(-1px, 1px) scale(1.003);
    filter: saturate(1.1) contrast(1.06) hue-rotate(0deg);
  }
}

#vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    1200px 700px at 50% 45%,
    rgba(0, 0, 0, 0) 55%,
    rgba(0, 0, 0, 0.55) 100%
  );
  mix-blend-mode: multiply;
  pointer-events: none;
}

#scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.0) 0px,
    rgba(0, 0, 0, 0.0) 2px,
    rgba(0, 0, 0, 0.18) 3px
  );
  opacity: 0.38;
  mix-blend-mode: multiply;
  pointer-events: none;
}

#grain {
  position: absolute;
  inset: -20%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='.45'/%3E%3C/svg%3E");
  opacity: 0.12;
  mix-blend-mode: overlay;
  transform: translateZ(0);
  animation: grainMove 7s steps(8, end) infinite;
  pointer-events: none;
}

@keyframes grainMove {
  0% {
    transform: translate(0, 0);
  }
  20% {
    transform: translate(-5%, 4%);
  }
  40% {
    transform: translate(6%, -3%);
  }
  60% {
    transform: translate(-3%, -6%);
  }
  80% {
    transform: translate(4%, 5%);
  }
  100% {
    transform: translate(0, 0);
  }
}

/* HUD overlay */
.hud {
  position: absolute;
  inset: 0;
  display: grid;
  align-items: end;
  justify-items: start;
  padding: clamp(14px, 2.4vw, 28px);
  pointer-events: none;
  z-index: 10;
}

.hudCard {
  width: min(560px, calc(100vw - 28px));
  background:
    linear-gradient(180deg, rgba(10, 14, 26, 0.72), rgba(6, 8, 14, 0.52)),
    radial-gradient(
      800px 300px at 20% 0%,
      rgba(65, 255, 133, 0.14),
      transparent 60%
    ),
    radial-gradient(
      700px 260px at 80% 0%,
      rgba(0, 255, 168, 0.10),
      transparent 55%
    ),
    var(--glass);
  border: 1px solid rgba(65, 255, 133, 0.22);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 18px 18px 14px;
  box-shadow: var(--shadow);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity 700ms ease,
    transform 700ms ease,
    box-shadow 3s ease-in-out;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.hudCard > * {
  position: relative;
  z-index: 1;
}

body.info-on .hudCard::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: 16px;
  padding: 1px;
  background: linear-gradient(
    90deg,
    rgba(65, 255, 133, 0.12),
    rgba(65, 255, 133, 0.55),
    rgba(0, 255, 168, 0.42),
    rgba(184, 255, 61, 0.28),
    rgba(65, 255, 133, 0.12)
  );
  background-size: 220% 100%;
  animation: borderShimmer 5s ease-in-out infinite;
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

body.info-on .hudCard::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: 16px;
  background:
    linear-gradient(
      180deg,
      rgba(65, 255, 133, 0.10) 0%,
      rgba(65, 255, 133, 0.0) 28%
    ),
    repeating-linear-gradient(
      to bottom,
      rgba(65, 255, 133, 0.0) 0px,
      rgba(65, 255, 133, 0.0) 10px,
      rgba(65, 255, 133, 0.04) 11px
    );
  pointer-events: none;
}

@keyframes borderShimmer {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

body.info-on .hudCard {
  opacity: 1;
  transform: translateY(0);
  box-shadow:
    0 20px 70px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(65, 255, 133, 0.12),
    0 0 28px rgba(65, 255, 133, 0.14);
  animation: cardGlow 3.5s ease-in-out infinite;
}

@keyframes cardGlow {
  0%,
  100% {
    box-shadow:
      0 20px 70px rgba(0, 0, 0, 0.6),
      0 0 0 1px rgba(65, 255, 133, 0.10),
      0 0 22px rgba(65, 255, 133, 0.10);
  }
  50% {
    box-shadow:
      0 20px 70px rgba(0, 0, 0, 0.6),
      0 0 0 1px rgba(65, 255, 133, 0.22),
      0 0 36px rgba(65, 255, 133, 0.20);
  }
}

.hudTop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.badge {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(65, 255, 133, 0.34);
  background: rgba(65, 255, 133, 0.08);
  color: rgba(65, 255, 133, 0.95);
  letter-spacing: 0.08em;
  font-weight: 700;
  font-size: 12px;
  text-shadow: 0 0 18px rgba(65, 255, 133, 0.35);
}

.ticker {
  opacity: 0.85;
  letter-spacing: 0.22em;
  font-size: 12px;
}

.title {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.02;
  letter-spacing: -0.02em;
  text-shadow:
    0 0 26px rgba(65, 255, 133, 0.12),
    0 0 12px rgba(0, 255, 168, 0.10);
}

.motto {
  margin: 10px 0 14px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.tokenGrid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}

.kv {
  border-radius: 12px;
  border: 1px solid rgba(65, 255, 133, 0.14);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.22), rgba(0, 0, 0, 0.12));
  padding: 10px 10px 9px;
}

.k {
  font-size: 11px;
  opacity: 0.7;
  margin-bottom: 6px;
}

.v {
  font-size: 13px;
  font-weight: 700;
}

.caWrap {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid rgba(232, 234, 242, 0.14);
  background: rgba(0, 0, 0, 0.22);
  position: relative;
}

.caLabel {
  opacity: 0.75;
  font-size: 12px;
}

.caValue {
  display: block;
  font-size: 12px;
  color: rgba(232, 234, 242, 0.9);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copyBtn {
  appearance: none;
  border: 1px solid rgba(65, 255, 133, 0.34);
  background: rgba(65, 255, 133, 0.10);
  color: rgba(65, 255, 133, 0.95);
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.35),
    0 0 22px rgba(65, 255, 133, 0.18);
}

.copyBtn:active {
  transform: translateY(1px);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  position: relative;
  z-index: 1;
}

.pillBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid rgba(232, 234, 242, 0.16);
  background: rgba(0, 0, 0, 0.22);
  color: rgba(232, 234, 242, 0.9);
  text-decoration: none;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.03em;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background-color 160ms ease,
    box-shadow 160ms ease;
}

.pillBtn:hover {
  transform: translateY(-1px);
  border-color: rgba(65, 255, 133, 0.30);
  box-shadow: 0 0 0 4px rgba(65, 255, 133, 0.06);
}

.pillBtn.primary {
  border-color: rgba(65, 255, 133, 0.55);
  background: linear-gradient(
    90deg,
    rgba(65, 255, 133, 0.22),
    rgba(0, 255, 168, 0.16)
  );
  color: rgba(232, 234, 242, 0.98);
  box-shadow:
    0 10px 34px rgba(0, 0, 0, 0.35),
    0 0 26px rgba(65, 255, 133, 0.22);
}

.pillBtn.primary::before {
  content: "▲";
  font-size: 11px;
  color: rgba(184, 255, 61, 0.95);
  text-shadow: 0 0 14px rgba(184, 255, 61, 0.40);
}

.toast {
  position: absolute;
  right: 12px;
  top: -10px;
  transform: translateY(-100%);
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(65, 255, 133, 0.14);
  border: 1px solid rgba(65, 255, 133, 0.34);
  color: rgba(65, 255, 133, 0.95);
  opacity: 0;
  transition: opacity 220ms ease;
  font-size: 12px;
  pointer-events: none;
}

.toast.on {
  opacity: 1;
}

.fineprint {
  margin-top: 12px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 11px;
  opacity: 0.6;
}

/* Fake TradingView widget — top right */
.tvWidget {
  position: absolute;
  top: clamp(10px, 1.8vw, 18px);
  right: clamp(10px, 1.8vw, 18px);
  width: min(570px, calc(100vw - 24px));
  height: min(372px, 51vh);
  z-index: 12;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  grid-template-columns: 28px 1fr;
  grid-template-areas:
    "header header"
    "tools tf"
    "tools chart"
    "footer footer";
  border-radius: 4px;
  border: 1px solid #2a2e39;
  background: #131722;
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Trebuchet MS",
    Roboto,
    Ubuntu,
    sans-serif;
  opacity: 0;
  transform: translateY(-6px) scale(0.985);
  transition:
    opacity 520ms ease,
    transform 520ms ease;
  pointer-events: none;
}

.tvWidget.on {
  opacity: 1;
  transform: none;
}

.tvWidget.pump {
  animation: tvPumpFlash 500ms ease-out 1;
}

@keyframes tvPumpFlash {
  0% {
    box-shadow:
      0 12px 40px rgba(0, 0, 0, 0.55),
      0 0 0 1px rgba(38, 166, 154, 0.0);
  }
  35% {
    box-shadow:
      0 12px 40px rgba(0, 0, 0, 0.55),
      0 0 28px rgba(38, 166, 154, 0.45),
      0 0 0 1px rgba(38, 166, 154, 0.55);
  }
  100% {
    box-shadow:
      0 12px 40px rgba(0, 0, 0, 0.55),
      0 0 0 1px rgba(0, 0, 0, 0.35);
  }
}

.tvHeader {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px 4px;
  border-bottom: 1px solid #2a2e39;
  background: #1e222d;
  min-width: 0;
}

.tvSymbol {
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
}

.tvSymbolName {
  color: #d1d4dc;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.tvSymbolEx {
  color: #787b86;
  font-size: 10px;
  white-space: nowrap;
}

.tvOhlc {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  font-size: 10px;
  color: #787b86;
}

.tvOhlc b {
  color: #d1d4dc;
  font-weight: 600;
}

.tvOhlc b.up,
.tvChange.up {
  color: #26a69a;
}

.tvChange {
  font-weight: 700;
}

.tvToolbar {
  grid-area: tools;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 2px;
  border-right: 1px solid #2a2e39;
  background: #1e222d;
}

.tvTool {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  font-size: 9px;
  color: #787b86;
  border-radius: 2px;
}

.tvTool.active {
  color: #2962ff;
  background: rgba(41, 98, 255, 0.12);
}

.tvTimeframes {
  grid-area: tf;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px 6px;
  border-bottom: 1px solid #2a2e39;
  background: #131722;
  font-size: 10px;
  color: #787b86;
}

.tvTimeframes span {
  padding: 2px 5px;
  border-radius: 2px;
}

.tvTimeframes span.active {
  color: #2962ff;
  background: rgba(41, 98, 255, 0.14);
}

.tvChartWrap {
  grid-area: chart;
  position: relative;
  min-height: 0;
  background: #131722;
}

#tvChartCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.tvFooter {
  grid-area: footer;
  display: flex;
  justify-content: space-between;
  padding: 3px 8px;
  border-top: 1px solid #2a2e39;
  background: #1e222d;
  font-size: 9px;
  color: #787b86;
}

@media (max-width: 520px) {
  .tvWidget {
    width: min(450px, calc(100vw - 20px));
    height: min(315px, 42vh);
  }

  .tvOhlc {
    display: none;
  }

  .tokenGrid {
    grid-template-columns: 1fr;
  }
  .caWrap {
    grid-template-columns: 44px 1fr;
  }
  .copyBtn {
    grid-column: 1 / -1;
    width: 100%;
  }
}
