:root {
  --green: #39ff14;
  --red: #ff3b3b;
  --void: #07070a;
  --glow: #8cff6a;
}

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

html, body {
  height: 100%;
  background: #000;
  color: #eee;
  font-family: Arial, Helvetica, sans-serif;
  overflow: hidden;
}

body { min-height: 100vh; }

#world {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--void);
  opacity: 0;
  transition: opacity .45s ease;
}
#world.ready { opacity: 1; }
#world.fading { opacity: 0; }

#stage {
  position: absolute;
  width: max(100vw, calc(100vh * 2752 / 1536));
  height: max(100vh, calc(100vw * 1536 / 2752));
  left: calc((100vw - max(100vw, calc(100vh * 2752 / 1536))) * 0.85);
  top: calc((100vh - max(100vh, calc(100vw * 1536 / 2752))) * 0.5);
  z-index: 1;
}

#plate {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  user-select: none;
}

body[data-state="SAD"] #plate,
body[data-state="DEPRESSED"] #plate,
body[data-state="ROCK_BOTTOM"] #plate,
body[data-state="HAPPY"] #plate,
body[data-state="EUPHORIC"] #plate,
body[data-state="ATH"] #plate,
body[data-state="BASELINE"] #plate { filter: none; }

#monitor {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 8;
  overflow: hidden;
  background: #05070a;
  transform-origin: 0 0;
  box-shadow: 0 0 28px color-mix(in srgb, var(--glow) 45%, transparent);
  visibility: hidden;
}
body.monitor-ready #monitor { visibility: visible; }
#gmgn-chart {
  position: absolute;
  /* Keep the right edge (live price). Crop top chrome + bottom volume. */
  left: -10%;
  top: -6%;
  width: 110%;
  height: 122%;
  border: 0;
  background: #05070a;
  pointer-events: none;
}

#cal-hint {
  position: absolute;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  z-index: 50;
  background: #000;
  color: #39ff14;
  font: 13px/1.3 Arial, sans-serif;
  padding: 8px 12px;
  border: 2px solid #39ff14;
  pointer-events: none;
  max-width: 70vw;
  text-align: center;
}
#cal-hint[hidden] { display: none; }
.cal-dot {
  position: absolute;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  background: #39ff14;
  border: 2px solid #000;
  z-index: 51;
  pointer-events: none;
}
body.calibrating #monitor { opacity: .2; pointer-events: none; }
body.calibrating #stage { cursor: crosshair; }
#scan {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(180deg, transparent 0 2px, rgba(0,0,0,.12) 2px 3px);
  pointer-events: none;
  animation: scan 8s linear infinite;
}
@keyframes scan { to { background-position: 0 40px; } }
#glare {
  position: absolute; inset: 0;
  background: linear-gradient(115deg, rgba(255,255,255,.08), transparent 40%);
  pointer-events: none;
}

body[data-state="EUPHORIC"] { --glow: #39ff14; }
body[data-state="HAPPY"] { --glow: #7cff7c; }
body[data-state="BASELINE"] { --glow: #8cff6a; }
body[data-state="SAD"] { --glow: #6a8aaa; }
body[data-state="DEPRESSED"] { --glow: #ff3b3b; }
body[data-state="ROCK_BOTTOM"] { --glow: #c4a878; }
body[data-state="ATH"] { --glow: #39ff14; }
body[data-state="ROCK_BOTTOM"] #monitor { opacity: .55; }

#flicker {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 9;
  mix-blend-mode: screen;
  background: radial-gradient(ellipse at 74% 48%, color-mix(in srgb, var(--glow) 18%, transparent), transparent 42%);
  animation: glowpulse 2.8s ease-in-out infinite;
}
@keyframes glowpulse {
  0%, 100% { opacity: .7; }
  50% { opacity: 1; }
}

#vignette {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 10;
  box-shadow: inset 0 0 120px 40px #000;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='80' height='80'><filter id='n'><feTurbulence baseFrequency='.8'/></filter><rect width='80' height='80' filter='url(%23n)' opacity='.35'/></svg>");
  opacity: .22;
  mix-blend-mode: overlay;
}

#dust {
  position: absolute; inset: 0;
  z-index: 11;
  pointer-events: none;
}

#hud-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 14px 22px;
}
#brand,
#pnl,
#caption-bar { display: none; }
#mute {
  background: #111;
  color: #888;
  border: 2px solid #000;
  font-size: 10px;
  letter-spacing: .12em;
  padding: 6px 10px;
  cursor: pointer;
  font-weight: 700;
}
#mute.on {
  background: var(--green);
  color: #000;
}

#pnl {
  position: absolute;
  top: 48px;
  left: 22px;
  z-index: 20;
  pointer-events: none;
}
#pnl-text {
  background: #000;
  color: var(--green);
  font-family: "Arial Black", Impact, sans-serif;
  font-size: clamp(28px, 4vw, 52px);
  padding: 4px 16px 8px;
  line-height: 1;
  text-shadow: 0 0 18px rgba(57,255,20,.5);
}
#pnl.down #pnl-text { color: var(--red); text-shadow: 0 0 18px rgba(255,59,59,.45); }

#caption-bar {
  position: absolute;
  left: 22px;
  right: 200px;
  bottom: 28px;
  z-index: 20;
  font-family: Impact, "Arial Black", sans-serif;
  font-size: clamp(22px, 3.2vw, 42px);
  line-height: 1.05;
  color: #fff;
  text-transform: uppercase;
  -webkit-text-stroke: 4px #000;
  paint-order: stroke fill;
  padding-bottom: 12px;
  pointer-events: none;
}

.buy-bar {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 30;
  min-width: 160px;
  height: 48px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
  color: #666;
  text-decoration: none;
  font-family: "Arial Black", Impact, sans-serif;
  font-size: 18px;
  letter-spacing: .06em;
  border: 3px solid #000;
}
.buy-bar.disabled { pointer-events: none; }
.buy-bar:not(.disabled) { background: var(--green); color: #000; }

#tape {
  position: absolute;
  left: 16px;
  bottom: 78px;
  z-index: 20;
  width: min(340px, calc(100vw - 32px));
  max-height: 28vh;
  overflow: auto;
  padding: 10px 12px 12px;
  background: rgba(0, 0, 0, .62);
  border: 2px solid #000;
  color: #c9c9c9;
  font: 11px/1.45 ui-monospace, "Cascadia Mono", Menlo, monospace;
  pointer-events: auto;
}
#tape[hidden] { display: none; }
#tape-label {
  display: block;
  margin-bottom: 8px;
  color: #666;
  letter-spacing: .16em;
  font-size: 9px;
  text-transform: uppercase;
}
#tape ol { list-style: none; }
#tape li {
  margin: 0 0 7px;
  padding: 0 0 7px;
  border-bottom: 1px solid #222;
}
#tape li:last-child { margin: 0; padding: 0; border: 0; }
#tape .k { color: #666; margin-right: 6px; }
#tape .nft .k { color: #c4a878; }
#tape .ape .k { color: #8cff6a; }
#tape .sell .k { color: #ff3b3b; }
#tape a { color: #8cff6a; text-decoration: none; }
#tape a:hover { text-decoration: underline; }

#studio-nav {
  position: absolute;
  top: 44px;
  right: 18px;
  z-index: 40;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 280px;
  justify-content: flex-end;
}
#studio-nav button {
  font-size: 10px;
  padding: 6px 8px;
  background: #111;
  color: #ccc;
  border: 2px solid #000;
  cursor: pointer;
}
#studio-nav button.on { background: var(--green); color: #000; }

@media (max-width: 375px) {
  #caption-bar { right: 12px; font-size: 18px; }
  #pnl-text { font-size: 26px; }
}
