:root {
  color-scheme: dark;
  --bg: #05070c;
  --panel: rgba(12, 16, 25, 0.86);
  --line: rgba(255, 255, 255, 0.1);
  --muted: #929bad;
  --text: #f6f8ff;
  --cyan: #00e9ff;
  --green: #36f397;
  --red: #ff4867;
  --yellow: #ffc83d;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 70% 8%, rgba(0, 233, 255, 0.09), transparent 30rem),
    radial-gradient(circle at 5% 50%, rgba(85, 75, 255, 0.08), transparent 28rem),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 24px;
}

.topbar,
.market-strip {
  border: 1px solid var(--line);
  background: rgba(8, 11, 18, 0.78);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(18px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 12px 18px;
  border-radius: 18px 18px 0 0;
}

.brand,
.topbar-status,
.price-block,
.counter-status {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
}

.brand img {
  width: 48px;
  height: 48px;
  border: 1px solid rgba(0, 233, 255, 0.45);
  border-radius: 15px;
  object-fit: cover;
  box-shadow: 0 0 28px rgba(0, 233, 255, 0.16);
}

.brand h1 {
  margin: 1px 0 0;
  font-size: clamp(18px, 2vw, 24px);
  letter-spacing: -0.03em;
}

.eyebrow {
  margin: 0;
  color: var(--cyan);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.topbar-status {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
  color: #c7cfde;
  font-size: 12px;
  font-weight: 650;
}

.local-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 14px var(--green);
}

.mode-pill,
.live-chip,
.render-pill {
  border: 1px solid rgba(255, 200, 61, 0.34);
  border-radius: 999px;
  color: #ffe49a;
  background: rgba(255, 200, 61, 0.1);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.render-pill {
  padding: 7px 10px;
  border-color: rgba(0, 233, 255, 0.38);
  color: #8ff7ff;
  background: rgba(0, 233, 255, 0.09);
}

.mode-pill {
  margin-left: 8px;
  padding: 7px 10px;
}

.mode-pill.is-live {
  border-color: rgba(54, 243, 151, 0.48);
  color: #8dffc4;
  background: rgba(54, 243, 151, 0.11);
  box-shadow: 0 0 18px rgba(54, 243, 151, 0.11);
}

.mode-pill.is-connecting {
  border-color: rgba(0, 233, 255, 0.42);
  color: #8ff7ff;
  background: rgba(0, 233, 255, 0.09);
}

.mode-pill.is-offline {
  border-color: rgba(255, 72, 103, 0.42);
  color: #ff9aac;
  background: rgba(255, 72, 103, 0.1);
}

.live-chip.is-live {
  border-color: rgba(54, 243, 151, 0.48);
  color: #8dffc4;
  background: rgba(54, 243, 151, 0.12);
}

.market-strip {
  display: grid;
  grid-template-columns: auto minmax(160px, 520px) auto;
  gap: 22px;
  align-items: center;
  padding: 8px 18px;
  border-top: 0;
  border-radius: 0;
}

.price-block {
  gap: 10px;
  white-space: nowrap;
}

.label,
.panel-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.price-block strong {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

#priceChange {
  padding: 4px 7px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 800;
}

.positive {
  color: var(--green);
  background: rgba(54, 243, 151, 0.1);
}

.negative {
  color: var(--red);
  background: rgba(255, 72, 103, 0.1);
}

#sparkline {
  display: block;
  width: 100%;
  height: 42px;
}

.strip-note {
  justify-self: end;
  color: #71798a;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.official-token-link {
  padding: 8px 10px;
  border: 1px solid rgba(54, 243, 151, 0.22);
  border-radius: 8px;
  color: #8dffc4;
  background: rgba(54, 243, 151, 0.07);
  text-decoration: none;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.official-token-link:hover,
.official-token-link:focus-visible {
  border-color: rgba(54, 243, 151, 0.56);
  background: rgba(54, 243, 151, 0.13);
  outline: none;
  transform: translateY(-1px);
}

.stage {
  position: relative;
  isolation: isolate;
  min-height: 540px;
  aspect-ratio: 16 / 8.35;
  overflow: hidden;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-left: 1px solid var(--line);
  border-radius: 0 0 18px 18px;
  background: #060a11;
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.45);
}

.scene-stack,
.scene,
.scene-vignette,
.reaction-flash,
.cash-particles,
.machine-motion,
.coffee-steam {
  position: absolute;
  inset: 0;
}

.scene {
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: living-scene 6s ease-in-out infinite;
  transition: opacity 720ms ease, filter 560ms ease;
}

#ling3dCanvas {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  outline: none;
  transition: opacity 700ms ease;
}

.stage.webgl-ready #ling3dCanvas {
  opacity: 1;
}

.stage.webgl-ready .scene {
  opacity: 0 !important;
}

.stage.webgl-ready .machine-motion,
.stage.webgl-ready .coffee-steam {
  display: none;
}

.scene-buy {
  opacity: 1;
}

.scene-count-alt,
.scene-coffee,
.scene-sell {
  opacity: 0;
}

.stage.count-frame-b .scene-buy,
.stage.is-coffee .scene-buy,
.stage.is-sell .scene-buy {
  opacity: 0;
}

.stage.count-frame-b:not(.is-coffee):not(.is-sell) .scene-count-alt {
  opacity: 1;
}

.stage.is-coffee .scene-count-alt,
.stage.is-sell .scene-count-alt {
  opacity: 0;
}

.stage.is-coffee .scene-coffee {
  opacity: 1;
}

.stage.is-sell .scene-coffee {
  opacity: 0;
}

.stage.is-sell .scene-sell {
  opacity: 1;
}

@keyframes living-scene {
  0%, 100% { transform: scale(1.008) translateY(0); }
  45% { transform: scale(1.022) translateY(-3px); }
  70% { transform: scale(1.017) translateY(1px); }
}

.stage.is-sell.reacting .scene-sell {
  animation: angry-shake 520ms ease;
}

@keyframes angry-shake {
  0%, 100% { transform: scale(1.018) translateX(0); }
  25% { transform: scale(1.018) translateX(-6px); }
  50% { transform: scale(1.018) translateX(6px); }
  75% { transform: scale(1.018) translateX(-4px); }
}

.scene-vignette {
  z-index: 2;
  background:
    linear-gradient(90deg, rgba(3, 5, 10, 0.78) 0%, rgba(3, 5, 10, 0.18) 40%, transparent 66%),
    linear-gradient(0deg, rgba(3, 5, 10, 0.72) 0%, transparent 36%);
  pointer-events: none;
}

.reaction-flash {
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.reaction-flash.buy {
  opacity: 1;
  background: radial-gradient(circle at 72% 56%, rgba(54, 243, 151, 0.28), transparent 44%);
}

.reaction-flash.sell {
  opacity: 1;
  background: radial-gradient(circle at 72% 56%, rgba(255, 72, 103, 0.28), transparent 46%);
}

.speech-wrap {
  position: absolute;
  z-index: 3;
  top: 11%;
  left: 4.5%;
  width: min(37%, 470px);
}

.emotion-label {
  display: inline-block;
  margin: 0 0 8px 14px;
  color: var(--cyan);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-shadow: 0 0 18px rgba(0, 233, 255, 0.45);
}

.speech-bubble {
  position: relative;
  padding: 20px 22px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 20px 20px 20px 5px;
  color: #10131b;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
  font-size: clamp(17px, 1.65vw, 27px);
  font-weight: 850;
  line-height: 1.14;
  letter-spacing: -0.035em;
  transform-origin: left bottom;
  backdrop-filter: blur(9px);
}

.speech-bubble.pop {
  animation: bubble-pop 430ms cubic-bezier(0.2, 1.55, 0.4, 1);
}

@keyframes bubble-pop {
  0% { opacity: 0; transform: scale(0.82) translateY(8px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.trade-card {
  position: absolute;
  z-index: 3;
  bottom: 5.5%;
  left: 4.5%;
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 12px;
  align-items: center;
  width: min(40%, 500px);
  padding: 13px 14px;
  border: 1px solid rgba(54, 243, 151, 0.32);
  border-radius: 15px;
  background: rgba(6, 12, 17, 0.83);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(16px);
  transition: border-color 250ms ease, transform 250ms ease;
}

.trade-card.sell-card {
  border-color: rgba(255, 72, 103, 0.38);
}

.trade-card.pulse {
  animation: card-pulse 430ms ease;
}

@keyframes card-pulse {
  50% { transform: translateY(-5px) scale(1.012); }
}

.trade-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
  color: #03110a;
  background: var(--green);
  font-size: 22px;
  font-weight: 900;
  box-shadow: 0 0 25px rgba(54, 243, 151, 0.22);
}

.sell-card .trade-icon {
  color: #190309;
  background: var(--red);
  box-shadow: 0 0 25px rgba(255, 72, 103, 0.25);
}

.trade-copy {
  min-width: 0;
}

.trade-copy span,
.trade-copy strong,
.trade-copy small {
  display: block;
}

.trade-copy span {
  color: var(--green);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.sell-card .trade-copy span {
  color: var(--red);
}

.trade-copy strong {
  margin: 3px 0 2px;
  overflow: hidden;
  font-size: clamp(14px, 1.35vw, 19px);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trade-copy small {
  color: #929bad;
  font-size: 10px;
}

.live-chip {
  padding: 5px 7px;
}

.machine-panel,
.mood-panel {
  position: absolute;
  z-index: 3;
  right: 3.5%;
  width: min(18%, 220px);
  padding: 13px 15px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(5, 9, 15, 0.72);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(12px);
}

.machine-panel {
  top: 5%;
}

.mood-panel {
  top: 24%;
}

.machine-panel strong,
.mood-panel strong,
.mood-panel span {
  display: block;
}

.machine-panel strong {
  margin: 5px 0 4px;
  color: var(--cyan);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: clamp(18px, 2.15vw, 31px);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  text-shadow: 0 0 18px rgba(0, 233, 255, 0.35);
}

.counter-status {
  gap: 6px;
  color: #a6afbf;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.11em;
}

.counter-led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.counter-led.running {
  background: var(--green);
  box-shadow: 0 0 9px var(--green);
  animation: led-blink 580ms infinite alternate;
}

.counter-led.stopped {
  background: var(--red);
  box-shadow: 0 0 9px var(--red);
}

.counter-led.paused {
  background: var(--yellow);
  box-shadow: 0 0 9px var(--yellow);
}

@keyframes led-blink {
  to { opacity: 0.34; }
}

.mood-panel strong {
  margin: 6px 0 3px;
  color: var(--green);
  font-size: clamp(15px, 1.55vw, 22px);
  letter-spacing: 0.035em;
}

.stage.is-sell .mood-panel strong {
  color: var(--red);
}

.mood-panel span:last-child {
  color: #a3acbc;
  font-size: 10px;
}

.cash-particles {
  z-index: 2;
  pointer-events: none;
}

.machine-motion {
  z-index: 2;
  overflow: hidden;
  opacity: 1;
  pointer-events: none;
  transition: opacity 400ms ease;
}

.machine-motion i {
  position: absolute;
  top: 69%;
  left: 58%;
  width: 16%;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(0, 233, 255, 0.85), transparent);
  filter: blur(0.5px);
  animation: roller-scan 1.15s linear infinite;
}

.machine-motion i:nth-child(2) {
  top: 72.5%;
  animation-delay: -0.38s;
}

.machine-motion i:nth-child(3) {
  top: 76%;
  animation-delay: -0.76s;
}

.stage.is-coffee .machine-motion,
.stage.is-sell .machine-motion {
  opacity: 0;
}

@keyframes roller-scan {
  0% { opacity: 0; transform: translateX(-24px) scaleX(0.7); }
  35% { opacity: 0.8; }
  100% { opacity: 0; transform: translateX(38px) scaleX(1.12); }
}

.coffee-steam {
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 500ms ease;
}

.stage.is-coffee .coffee-steam {
  opacity: 1;
}

.coffee-steam i {
  position: absolute;
  top: 42%;
  left: 66.5%;
  width: 8px;
  height: 38px;
  border: 3px solid rgba(255, 255, 255, 0.48);
  border-right-color: transparent;
  border-bottom-color: transparent;
  border-radius: 50%;
  filter: blur(1.5px);
  animation: steam-rise 2.4s ease-out infinite;
}

.coffee-steam i:nth-child(2) {
  left: 68%;
  animation-delay: -0.8s;
}

.coffee-steam i:nth-child(3) {
  left: 69.5%;
  animation-delay: -1.6s;
}

@keyframes steam-rise {
  0% { opacity: 0; transform: translateY(12px) scale(0.6) rotate(-8deg); }
  28% { opacity: 0.65; }
  100% { opacity: 0; transform: translateY(-45px) scale(1.35) rotate(12deg); }
}

.cash-note {
  position: absolute;
  top: 64%;
  left: 71%;
  display: grid;
  width: 54px;
  height: 24px;
  place-items: center;
  border: 2px solid rgba(0, 37, 39, 0.42);
  border-radius: 4px;
  color: #123a3d;
  background: #78ead9;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.26);
  font-size: 8px;
  font-weight: 950;
  animation: cash-fly 1.35s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}

@keyframes cash-fly {
  0% { opacity: 0; transform: translate(0, 0) rotate(0deg) scale(0.7); }
  18% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--fly-x), var(--fly-y)) rotate(var(--spin)) scale(1); }
}

footer {
  padding: 14px 10px 0;
  color: #697183;
  font-size: 10px;
  line-height: 1.5;
  text-align: center;
}

@media (max-width: 980px) {
  .stage {
    min-height: 490px;
    aspect-ratio: auto;
  }

  .scene {
    object-position: 62% center;
  }

  .speech-wrap {
    width: 44%;
  }

  .trade-card {
    width: 47%;
  }

  .machine-panel,
  .mood-panel {
    width: 22%;
  }

}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 16px, 1480px);
    padding-top: 8px;
  }

  .topbar {
    align-items: flex-start;
    gap: 10px;
  }

  .topbar-status > span:nth-child(2) {
    display: none;
  }

  .render-pill {
    display: none;
  }

  .mode-pill {
    margin-left: 0;
  }

  .market-strip {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  #sparkline {
    height: 34px;
  }

  .strip-note {
    display: none;
  }

  .stage {
    min-height: 600px;
  }

  .scene {
    object-position: 66% center;
  }

  .scene-vignette {
    background: linear-gradient(0deg, rgba(3, 5, 10, 0.84) 0%, transparent 52%);
  }

  .speech-wrap {
    top: 4%;
    left: 4%;
    width: 72%;
  }

  .speech-bubble {
    padding: 15px 16px;
    font-size: 17px;
  }

  .machine-panel,
  .mood-panel {
    top: auto;
    bottom: 23%;
    width: 42%;
  }

  .machine-panel {
    right: 52%;
  }

  .mood-panel {
    right: 4%;
  }

  .trade-card {
    bottom: 4%;
    left: 4%;
    width: 92%;
  }

}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
