:root {
  --beat: 0.38961s;
  --speed: 1;
  --fire: 0.25;
  --ticker-h: 5.9rem;
  --navy: #0d1638;
  --gold: #c9a74a;
  --cream: #f1e8cc;
  --dollar: #85bb65;
  --fed-red: #c8102e;
  --meme: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  --body: "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #070c22;
  color: #fff;
  font-family: var(--body);
  -webkit-user-select: none;
  user-select: none;
}

.curtain {
  position: fixed;
  inset: -60px;
  animation: sway 7s ease-in-out infinite alternate;
  background:
    radial-gradient(ellipse 55% 60% at 68% 42%, rgba(120, 140, 210, 0.22), transparent 70%),
    radial-gradient(ellipse at 50% 40%, transparent 45%, rgba(0, 0, 0, 0.7) 100%),
    repeating-linear-gradient(90deg, #0a1130 0, #17224d 22px, #1f2c5c 34px, #121b40 52px, #0a1130 70px);
  pointer-events: none;
}

.curtain::before {
  content: "";
  position: absolute;
  top: -10%;
  left: 20%;
  width: 45%;
  height: 120%;
  background: radial-gradient(ellipse 50% 60% at 50% 40%, rgba(255, 244, 200, 0.16), transparent 70%);
  animation: spotlight calc(9s / var(--speed)) ease-in-out infinite alternate;
  mix-blend-mode: screen;
}

.curtain::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(255, 90, 20, 0.55), rgba(255, 140, 40, 0.15) 45%, transparent 75%);
  opacity: var(--fire);
  animation: flicker 0.18s steps(3) infinite alternate;
}

#doom {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.market {
  position: fixed;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.7rem 0.9rem 0.6rem;
  background: rgba(6, 9, 20, 0.86);
  border: 2px solid #33437a;
  border-radius: 6px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  color: #fff;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

.market[hidden] {
  display: none;
}

.market.fading {
  opacity: 0;
}

.market-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid #22305c;
}

.market-name {
  font-weight: 800;
  font-size: clamp(1rem, 1.6vw, 1.4rem);
  letter-spacing: 0.02em;
}

.market-tag {
  font-size: 0.75rem;
  font-weight: 700;
  color: #ff8a80;
  border: 1px solid rgba(255, 138, 128, 0.6);
  border-radius: 3px;
  padding: 0.1em 0.45em;
  white-space: nowrap;
}

.market-quote {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  flex-wrap: wrap;
}

#market-last {
  font-size: clamp(1.8rem, 3.4vw, 3rem);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.market-change {
  font-size: clamp(0.9rem, 1.4vw, 1.2rem);
  font-weight: 700;
  padding: 0.15em 0.5em;
  border-radius: 3px;
  background: #c8102e;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.market-change.up {
  background: #2e7d32;
}

#market-chart {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}

.market-foot {
  margin: 0;
  font-size: 0.7rem;
  line-height: 1.3;
  color: rgba(241, 232, 204, 0.6);
}

#scene .yolo {
  animation: deal-with-it 1.1s cubic-bezier(0.3, 1.4, 0.6, 1) 1.2s both;
}

#stage {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2.5vh 2vw var(--ticker-h);
}

#stage.kick {
  animation: kick 0.18s ease-out;
}

.caption {
  margin: 0;
  max-width: 18ch;
  font-family: var(--meme);
  font-weight: normal;
  font-size: clamp(2rem, 6.5vw, 5.5rem);
  line-height: 1;
  text-align: center;
  color: #fff;
  -webkit-text-stroke: 0.05em #000;
  paint-order: stroke fill;
  text-shadow: 0 0.05em 0 #000;
}

.edition {
  margin: 0 0 0.3rem;
  padding: 0.15rem 0.7rem;
  border: 1px solid var(--gold);
  border-radius: 999px;
  background: rgba(13, 22, 56, 0.8);
  color: #ffd27a;
  font-size: clamp(0.7rem, 1vw, 0.85rem);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.timeline {
  margin: 0.4rem 0 0;
  max-width: 62ch;
  font-size: clamp(0.72rem, 1.05vw, 0.9rem);
  line-height: 1.35;
  text-align: center;
  color: rgba(241, 232, 204, 0.85);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

.debt-note {
  font-size: 0.8em;
  color: rgba(241, 232, 204, 0.7);
}

.caption .brr {
  display: inline-block;
  animation: brr calc(0.07s / var(--speed)) steps(2) infinite;
}

#scene {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow: visible;
}

#scene .body {
  animation: nod var(--beat) ease-in-out infinite alternate;
}

#scene .roller-lines {
  animation: roll calc(0.5s / var(--speed)) linear infinite;
}

#scene .roller-rev {
  animation-direction: reverse;
}

#scene .out-bill {
  animation: out-bill calc(0.39s / var(--speed)) ease-out infinite;
}

.qt #scene .roller-lines,
.qt #scene .out-bill {
  animation-play-state: paused;
}

#scene .press-body {
  animation: brr calc(0.05s / var(--speed)) steps(2) infinite;
}

#scene .led-green {
  animation: blink calc(0.2s / var(--speed)) steps(2) infinite;
}

#scene .led-red {
  animation: blink calc(0.35s / var(--speed)) steps(2) infinite reverse;
}

#scene .tape-marks {
  animation: tape calc(0.4s / var(--speed)) linear infinite;
}

#printer {
  cursor: pointer;
  outline: none;
}

#printer:focus-visible .press-body > rect {
  stroke: var(--gold);
  stroke-width: 4;
}

#printer.jam .press-body {
  animation: jam 0.03s steps(2) infinite;
}

#rain {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.pop {
  position: fixed;
  z-index: 4;
  pointer-events: none;
  font-family: var(--meme);
  font-size: clamp(1.6rem, 4.5vw, 3.6rem);
  color: #fff;
  -webkit-text-stroke: 0.06em #000;
  paint-order: stroke fill;
  white-space: nowrap;
  animation: pop 1.1s ease-out forwards;
}

.ticker {
  position: fixed;
  z-index: 5;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: var(--ticker-h);
  display: flex;
  flex-direction: column;
  background: var(--navy);
  border-top: 3px solid var(--gold);
  font-size: clamp(0.85rem, 1.8vw, 1.15rem);
  color: var(--cream);
}

.stats {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  column-gap: 3vw;
  row-gap: 0.15rem;
  padding: 0.45rem 3vw calc(0.45rem + env(safe-area-inset-bottom));
}

.crawl {
  display: flex;
  align-items: stretch;
  height: 1.9rem;
  background: #0a0f24;
  border-bottom: 1px solid rgba(201, 167, 74, 0.35);
  overflow: hidden;
  font-size: 0.9rem;
}

.crawl-tag {
  display: flex;
  align-items: center;
  padding: 0 0.8rem;
  background: #c8102e;
  color: #fff;
  font-family: var(--meme);
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex: none;
}

.crawl-track {
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
}

#crawl-text {
  margin: 0;
  white-space: nowrap;
  font-weight: 700;
  color: #fff;
  padding-left: 100%;
  animation: crawl calc(70s / var(--speed)) linear infinite;
}

#savings {
  color: #ff9f5b;
}

.bubble {
  position: fixed;
  z-index: 4;
  width: max-content;
  max-width: min(320px, 70vw);
  padding: 0.7rem 0.9rem 0.6rem;
  background: #fff;
  color: #111;
  border: 3px solid #000;
  border-radius: 18px;
  transform: translate(-100%, -100%);
  pointer-events: none;
  animation: bubble-in 0.25s cubic-bezier(0.3, 1.5, 0.6, 1);
}

.bubble::after {
  content: "";
  position: absolute;
  right: 18px;
  bottom: -16px;
  border: 8px solid transparent;
  border-top: 10px solid #000;
  border-left: 10px solid #000;
}

.bubble[hidden] {
  display: none;
}

.bubble p {
  margin: 0;
  font-family: var(--meme);
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  line-height: 1.1;
}

.bubble cite {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.72rem;
  font-style: normal;
  color: #555;
}

.toast {
  position: fixed;
  z-index: 7;
  left: 50%;
  bottom: calc(var(--ticker-h) + 1rem);
  max-width: min(520px, calc(100vw - 2rem));
  padding: 0.6rem 1rem;
  background: rgba(13, 22, 56, 0.95);
  border: 2px solid var(--gold);
  border-radius: 10px;
  color: var(--cream);
  font-size: 0.95rem;
  text-align: center;
  transform: translate(-50%, 160%);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.3, 1.4, 0.6, 1), opacity 0.3s;
  pointer-events: none;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

.toast strong {
  display: block;
  color: #ffd27a;
  font-family: var(--meme);
  font-size: 1.15rem;
  letter-spacing: 0.03em;
}

.share {
  position: fixed;
  z-index: 6;
  top: 1rem;
  right: 8.2rem;
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
  border: 2px solid var(--gold);
  border-radius: 50%;
  background: var(--navy);
  color: var(--cream);
  cursor: pointer;
}

.share:hover {
  color: #fff;
  background: #16224d;
}

.share-menu {
  position: fixed;
  z-index: 8;
  top: 4.6rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  min-width: 11rem;
  background: var(--navy);
  border: 2px solid var(--gold);
  border-radius: 10px;
  overflow: hidden;
}

.share-menu[hidden] {
  display: none;
}

.share-menu a,
.share-menu button {
  padding: 0.65rem 1rem;
  font: inherit;
  font-size: 0.95rem;
  color: var(--cream);
  background: none;
  border: 0;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.share-menu a:hover,
.share-menu button:hover,
.share-menu a:focus-visible,
.share-menu button:focus-visible {
  background: #16224d;
  outline: none;
}

#hike {
  cursor: pointer;
  outline: none;
}

#hike .hike-cap {
  transition: transform 0.12s;
}

#hike:active .hike-cap,
#hike.pressed .hike-cap {
  transform: translateY(8px);
}

#hike:focus-visible .hike-label {
  fill: #fff;
  text-decoration: underline;
}

.qt #hike .hike-cap ellipse:first-of-type {
  fill: #3ccf5a;
}

.qt #hike .hike-cap path {
  fill: #1d7a31;
}

.qt .curtain::after {
  opacity: 0;
}

.ticker p {
  margin: 0;
}

.debt span {
  color: rgba(241, 232, 204, 0.7);
  font-size: 0.85em;
}

#debt {
  color: #ffd27a;
}

.ticker strong {
  font-variant-numeric: tabular-nums;
}

#printed {
  color: #9fe07a;
}

#inflation {
  color: #ff6b5b;
}

.mute {
  position: fixed;
  z-index: 6;
  top: 1rem;
  right: 1rem;
  width: 3rem;
  height: 3rem;
  border: 2px solid var(--gold);
  border-radius: 50%;
  background: var(--navy);
  font-size: 1.3rem;
  cursor: pointer;
}

.controls {
  position: fixed;
  z-index: 6;
  left: 1rem;
  bottom: calc(var(--ticker-h) + 1rem);
  width: 10.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.7rem 0.6rem 0.75rem;
  background: rgba(13, 22, 56, 0.88);
  border: 2px solid var(--gold);
  border-radius: 10px;
  color: var(--cream);
}

.knob {
  width: 6.5rem;
  height: 6.5rem;
  cursor: grab;
  touch-action: none;
  border-radius: 50%;
  outline: none;
}

.knob:active {
  cursor: grabbing;
}

.knob:focus-visible {
  box-shadow: 0 0 0 3px var(--gold);
}

.speed {
  margin: 0;
  display: flex;
  gap: 0.4em;
  align-items: baseline;
  font-size: 0.85rem;
}

.speed {
  white-space: nowrap;
}

.speed strong {
  font-size: 1.1rem;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.overheat .speed strong {
  color: #ff8a3c;
}

.pitch {
  font: inherit;
  font-size: 0.75rem;
  padding: 0.3em 0.6em;
  color: var(--cream);
  background: transparent;
  border: 1px solid rgba(201, 167, 74, 0.7);
  border-radius: 999px;
  cursor: pointer;
}

.pitch[aria-pressed="true"] {
  background: var(--gold);
  color: var(--navy);
}

.repo {
  position: fixed;
  z-index: 6;
  top: 1rem;
  right: 4.6rem;
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
  border: 2px solid var(--gold);
  border-radius: 50%;
  background: var(--navy);
  color: var(--cream);
}

.repo:hover {
  color: #fff;
  background: #16224d;
}

.share:focus-visible,
.repo:focus-visible,
.mute:focus-visible,
.pitch:focus-visible,
.start-btn:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.overlay {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  background: rgba(3, 6, 20, 0.55);
  cursor: pointer;
  text-align: center;
  padding: 1rem;
}

.overlay[hidden] {
  display: none;
}

.overlay p {
  margin: 0;
  color: var(--cream);
  font-size: 1rem;
}

.start-btn {
  font-family: var(--meme);
  font-size: clamp(1.8rem, 5.5vw, 3.4rem);
  padding: 0.3em 0.9em;
  color: var(--navy);
  background: var(--gold);
  border: 3px solid #000;
  border-radius: 8px;
  cursor: pointer;
  animation: bob var(--beat) ease-in-out infinite alternate;
}

@keyframes crawl {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-100%);
  }
}

@keyframes bubble-in {
  from {
    transform: translate(-100%, -100%) scale(0.4);
  }
  to {
    transform: translate(-100%, -100%) scale(1);
  }
}

@keyframes deal-with-it {
  from {
    transform: translateY(-420px);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes roll {
  to {
    stroke-dashoffset: -32;
  }
}

@keyframes out-bill {
  0% {
    transform: translateX(14px);
    opacity: 0;
  }
  30% {
    opacity: 1;
  }
  100% {
    transform: translateX(-10px);
    opacity: 0.9;
  }
}

@keyframes sway {
  from {
    transform: skewX(-1.2deg) translateX(-22px);
  }
  to {
    transform: skewX(1.2deg) translateX(22px);
  }
}

@keyframes spotlight {
  from {
    transform: translateX(-35%) rotate(-6deg);
  }
  to {
    transform: translateX(80%) rotate(6deg);
  }
}

@keyframes brr {
  0% {
    transform: translate(-1.5px, 1px);
  }
  100% {
    transform: translate(1.5px, -1px);
  }
}

@keyframes jam {
  0% {
    transform: translate(-6px, 3px) rotate(-2deg);
  }
  100% {
    transform: translate(6px, -3px) rotate(2deg);
  }
}

@keyframes tape {
  to {
    stroke-dashoffset: -26;
  }
}

@keyframes flicker {
  from {
    opacity: calc(var(--fire) * 0.85);
  }
  to {
    opacity: var(--fire);
  }
}

@keyframes bob {
  from {
    transform: translateY(0) scale(1);
  }
  to {
    transform: translateY(-0.06em) scale(1.05);
  }
}

@keyframes nod {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-4px);
  }
}

@keyframes blink {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0.2;
  }
}

@keyframes kick {
  0% {
    transform: scale(1.012);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes pop {
  0% {
    transform: translate(-50%, -50%) scale(0.3) rotate(var(--r));
    opacity: 0;
  }
  20% {
    transform: translate(-50%, -50%) scale(1.15) rotate(var(--r));
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -140%) scale(1) rotate(var(--r));
    opacity: 0;
  }
}

@media (max-width: 760px) {
  :root {
    --ticker-h: 4.6rem;
  }
  .crawl,
  .savings,
  .debt-note,
  .timeline {
    display: none;
  }
  .edition {
    font-size: 0.68rem;
  }
  .stats {
    column-gap: 1.2rem;
    font-size: 0.85rem;
  }
  .share {
    top: auto;
    right: 0.75rem;
    bottom: calc(var(--ticker-h) + 3.75rem);
    width: 2.6rem;
    height: 2.6rem;
  }
  .share-menu {
    top: auto;
    bottom: calc(var(--ticker-h) + 0.75rem);
    right: 4rem;
  }
  .toast {
    max-width: calc(100vw - 2rem);
  }
  .debt span {
    display: none;
  }
  #stage {
    padding-top: 5.5rem;
  }
  .repo {
    top: auto;
    right: 0.75rem;
    bottom: calc(var(--ticker-h) + 0.75rem);
    width: 2.6rem;
    height: 2.6rem;
  }
  .controls {
    top: 0.75rem;
    left: 0.75rem;
    bottom: auto;
    width: auto;
    max-width: calc(100% - 5rem);
    display: grid;
    grid-template-columns: auto auto auto;
    grid-template-rows: auto auto;
    align-items: center;
    padding: 0.35rem 0.5rem;
    gap: 0.2rem 0.5rem;
  }
  .knob {
    width: 3.4rem;
    height: 3.4rem;
    grid-row: 1 / 3;
  }
  .speed {
    grid-row: 1 / 3;
  }
  .pitch {
    font-size: 0.68rem;
    padding: 0.2em 0.5em;
    white-space: nowrap;
  }
  .speed {
    flex-direction: column;
    gap: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .caption .brr,
  .curtain,
  .curtain::before,
  #scene .press-body,
  #scene .roller-lines,
  .curtain::before {
  content: "";
  position: absolute;
  top: -10%;
  left: 20%;
  width: 45%;
  height: 120%;
  background: radial-gradient(ellipse 50% 60% at 50% 40%, rgba(255, 244, 200, 0.16), transparent 70%);
  animation: spotlight calc(9s / var(--speed)) ease-in-out infinite alternate;
  mix-blend-mode: screen;
}

.curtain::after {
    animation: none;
  }
}
