:root {
  color-scheme: dark;
  --ink: #f7f0df;
  --red: #ff3b28;
  --green: #00f09b;
  --blue: #65a8ff;
  --void: #050506;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--void);
  color: var(--ink);
  font-family: Arial Black, Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  letter-spacing: 0;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  isolation: isolate;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.16) 0,
      rgba(255, 255, 255, 0.16) 2px,
      rgba(0, 0, 0, 0.30) 3px,
      rgba(0, 0, 0, 0.30) 9px
    );
  mix-blend-mode: overlay;
  opacity: 0.78;
}

body::after {
  content: "";
  position: fixed;
  inset: -12%;
  pointer-events: none;
  z-index: 4;
  background:
    radial-gradient(circle at 50% 50%, transparent 0 46%, rgba(0, 0, 0, 0.55) 84%),
    linear-gradient(90deg, rgba(255, 0, 0, 0.07), rgba(0, 255, 156, 0.04), rgba(0, 72, 255, 0.06));
  filter: blur(0.8px);
}

#metaballs {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  filter: blur(18px) contrast(2.4) saturate(1.35);
  transform: scale(1.08);
}

.signal-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  opacity: 0.48;
  background:
    linear-gradient(115deg, rgba(255, 59, 40, 0.26), transparent 28%, rgba(0, 240, 155, 0.12) 52%, transparent 76%),
    repeating-linear-gradient(93deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 19px);
  mix-blend-mode: screen;
  animation: drift 7s steps(5, end) infinite;
}

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

.chat-toggle {
  position: fixed;
  left: clamp(14px, 2vw, 28px);
  top: clamp(12px, 2vw, 24px);
  z-index: 9;
  border: 0;
  padding: 8px 10px;
  background: rgba(5, 5, 6, 0.72);
  color: var(--green);
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: clamp(0.78rem, 1.4vw, 1rem);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0.05em 0 var(--red), -0.04em 0 var(--blue);
  box-shadow: inset 0 -2px 0 var(--red), 0 0 28px rgba(0, 240, 155, 0.2);
}

.chat-toggle:hover,
.chat-toggle:focus-visible,
.chat-close:hover,
.chat-close:focus-visible,
.chat-form button:hover,
.chat-form button:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

.chat-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 10;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(520px, 100vw);
  background:
    linear-gradient(180deg, rgba(255, 59, 40, 0.24), transparent 22%),
    linear-gradient(120deg, rgba(0, 240, 155, 0.12), rgba(5, 5, 6, 0.92) 42%),
    rgba(5, 5, 6, 0.94);
  border-left: 3px solid var(--red);
  color: var(--ink);
  transform: translateX(104%);
  transition: transform 180ms ease;
  box-shadow: -34px 0 90px rgba(0, 0, 0, 0.64);
  backdrop-filter: blur(12px);
  text-shadow: 0.04em 0 rgba(255, 59, 40, 0.65), -0.03em 0 rgba(0, 240, 155, 0.45);
}

body.chat-open .chat-drawer {
  transform: translateX(0);
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 14px;
  color: var(--green);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: clamp(1.05rem, 2vw, 1.4rem);
  font-weight: 950;
  text-transform: uppercase;
}

.chat-close,
.chat-form button {
  border: 0;
  background: var(--ink);
  color: var(--void);
  cursor: pointer;
  font-family: Arial Black, Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: 1rem;
  font-weight: 950;
  line-height: 1;
}

.chat-close {
  width: 38px;
  height: 38px;
  padding: 0;
}

.chat-list {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 24px 20px;
  display: grid;
  align-content: end;
  gap: 14px;
  -webkit-overflow-scrolling: touch;
}

.chat-empty,
.chat-error {
  margin: 0;
  color: rgba(247, 240, 223, 0.78);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.95rem;
  line-height: 1.35;
}

.chat-error {
  color: var(--red);
}

.chat-message {
  display: grid;
  gap: 5px;
  max-width: 92%;
  padding: 12px 13px;
  background: rgba(247, 240, 223, 0.08);
  border: 1px solid rgba(247, 240, 223, 0.28);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  line-height: 1.28;
  overflow-wrap: anywhere;
}

.chat-message.listener {
  justify-self: end;
  color: #05110c;
  background: rgba(0, 240, 155, 0.84);
  border-color: rgba(0, 240, 155, 0.96);
  text-shadow: none;
}

.chat-message.station,
.chat-message.system {
  justify-self: start;
}

.chat-message-label {
  color: var(--red);
  font-family: Arial Black, Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: 0.78rem;
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
}

.chat-message.listener .chat-message-label {
  color: #052016;
}

.chat-form {
  display: grid;
  gap: 10px;
  padding: 16px 24px 24px;
  border-top: 1px solid rgba(247, 240, 223, 0.26);
  background: rgba(5, 5, 6, 0.72);
}

.chat-form textarea {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  border: 1px solid rgba(247, 240, 223, 0.36);
  background: rgba(247, 240, 223, 0.95);
  color: var(--void);
  padding: 12px;
  font: 900 1rem/1.25 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  text-transform: none;
}

.chat-form textarea:focus {
  outline: 3px solid var(--green);
  outline-offset: 2px;
}

.chat-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#chat-count {
  color: rgba(247, 240, 223, 0.75);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-weight: 900;
}

.chat-form button {
  min-width: 112px;
  padding: 14px 18px;
}

.chat-scrim {
  position: fixed;
  inset: 0;
  z-index: 8;
  background: rgba(0, 0, 0, 0.42);
}

.broadcast {
  position: relative;
  z-index: 5;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  padding: clamp(24px, 5vw, 72px);
  gap: clamp(12px, 2.2vw, 24px);
  text-shadow:
    0.05em 0 rgba(255, 59, 40, 0.75),
    -0.035em 0 rgba(0, 240, 155, 0.55),
    0 0 28px rgba(255, 240, 223, 0.18);
}

.kicker {
  margin: 0;
  color: var(--green);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: clamp(0.8rem, 1.7vw, 1.3rem);
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 0 -0.045em;
  max-width: min(8ch, 96vw);
  color: var(--ink);
  font-size: clamp(3.8rem, 16vw, 12.5rem);
  line-height: 0.78;
  text-transform: uppercase;
}

h1 span {
  display: block;
}

.frequency {
  color: var(--red);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: clamp(1.05rem, 2.6vw, 2.3rem);
  font-weight: 900;
  line-height: 1;
  text-transform: lowercase;
}

.meta-line {
  display: flex;
  align-items: baseline;
  gap: clamp(18px, 3vw, 42px);
  max-width: min(1120px, 100%);
}

.now-track {
  max-width: min(46vw, 620px);
  overflow: hidden;
  color: #fff0df;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: clamp(1.05rem, 2.6vw, 2.3rem);
  font-weight: 900;
  line-height: 1;
  text-transform: lowercase;
  white-space: nowrap;
  mix-blend-mode: difference;
  opacity: 0.92;
}

.now-track[hidden] {
  display: none;
}

.now-track-text {
  display: inline-block;
  min-width: 100%;
  transform: translateX(0);
  will-change: transform;
}

.now-track.is-overflowing .now-track-text {
  animation: now-playing-scan var(--marquee-duration, 9s) ease-in-out infinite alternate;
}

audio {
  width: min(720px, 100%);
  max-width: 100%;
  height: 48px;
  filter: invert(1) contrast(1.25) saturate(0.15);
  opacity: 0.92;
}

.power-button {
  position: fixed;
  right: clamp(18px, 7vw, 92px);
  top: clamp(78px, 15vh, 150px);
  z-index: 7;
  width: clamp(190px, 28vw, 420px);
  aspect-ratio: 1.18;
  border: 0;
  padding: 0;
  color: #050506;
  background:
    radial-gradient(circle at 34% 26%, rgba(255, 240, 223, 0.98), rgba(255, 240, 223, 0.84) 31%, transparent 32%),
    radial-gradient(circle at 69% 32%, rgba(0, 240, 155, 0.95), rgba(0, 240, 155, 0.74) 33%, transparent 34%),
    radial-gradient(circle at 42% 70%, rgba(255, 59, 40, 0.96), rgba(255, 59, 40, 0.76) 35%, transparent 36%),
    radial-gradient(circle at 72% 72%, rgba(101, 168, 255, 0.94), rgba(101, 168, 255, 0.74) 31%, transparent 32%);
  clip-path: polygon(48% 0%, 68% 7%, 87% 17%, 100% 39%, 91% 62%, 95% 84%, 73% 100%, 49% 91%, 27% 100%, 8% 83%, 13% 60%, 0% 41%, 12% 19%, 31% 9%);
  cursor: pointer;
  filter: drop-shadow(0 0 30px rgba(0, 240, 155, 0.38)) drop-shadow(0 0 54px rgba(255, 59, 40, 0.28));
  opacity: 0.94;
  mix-blend-mode: hard-light;
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
  overflow: hidden;
  transform-origin: 50% 50%;
  animation: spin-cw 50s linear infinite;
}

.power-button::before {
  content: "";
  position: absolute;
  inset: 8%;
  background: rgba(255, 240, 223, 0.58);
  clip-path: polygon(42% 0%, 69% 10%, 94% 28%, 91% 59%, 100% 80%, 67% 95%, 44% 88%, 17% 100%, 0% 74%, 10% 47%, 4% 23%, 25% 8%);
  mix-blend-mode: screen;
  transform-origin: 50% 50%;
  animation: spin-ccw 34s linear infinite;
}

.power-button:hover,
.power-button:focus-visible {
  transform: scale(1.035) rotate(-1deg);
  outline: none;
}

.word-cloud {
  position: absolute;
  inset: 8%;
  display: block;
  transform-origin: 50% 50%;
  animation: spin-ccw 70s linear infinite;
  font-family: Arial Black, Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  text-transform: uppercase;
}

.word-cloud span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: max-content;
  text-align: center;
  font-size: clamp(1rem, 2.6vw, 2.25rem);
  line-height: 0.85;
  opacity: 0.06;
  filter: blur(5px);
  text-shadow: 0.035em 0 rgba(255, 59, 40, 0.8), -0.03em 0 rgba(0, 240, 155, 0.7);
  translate: -50% -50%;
  transform-origin: 50% 50%;
  animation-name: word-focus, spin-cw;
  animation-duration: 24.5s, var(--spin, 24s);
  animation-timing-function: ease-in-out, linear;
  animation-iteration-count: infinite;
  animation-delay: calc(var(--slot) * -3.5s);
}

.word-cloud span:nth-child(1) { --slot: 0; --spin: 22s; }
.word-cloud span:nth-child(2) { --slot: 1; --spin: 28s; animation-name: word-focus, spin-ccw; }
.word-cloud span:nth-child(3) { --slot: 2; --spin: 18s; }
.word-cloud span:nth-child(4) { --slot: 3; --spin: 31s; animation-name: word-focus, spin-ccw; }
.word-cloud span:nth-child(5) { --slot: 4; --spin: 25s; }
.word-cloud span:nth-child(6) { --slot: 5; --spin: 16s; animation-name: word-focus, spin-ccw; }
.word-cloud span:nth-child(7) { --slot: 6; --spin: 27s; }

body.is-playing .power-button {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92);
}

@keyframes drift {
  0% { transform: translate3d(0, 0, 0); }
  25% { transform: translate3d(-1.5%, 0.8%, 0); }
  50% { transform: translate3d(1.1%, -0.4%, 0); }
  75% { transform: translate3d(-0.6%, -1.2%, 0); }
  100% { transform: translate3d(0, 0, 0); }
}

@keyframes word-focus {
  0%,
  9% {
    opacity: 0.05;
    filter: blur(5px);
    scale: 0.9;
  }

  13%,
  25% {
    opacity: 0.96;
    filter: blur(0);
    scale: 1.08;
  }

  32%,
  100% {
    opacity: 0.05;
    filter: blur(5px);
    scale: 0.9;
  }
}

@keyframes spin-cw {
  to { rotate: 360deg; }
}

@keyframes spin-ccw {
  to { rotate: -360deg; }
}

@keyframes now-playing-scan {
  from { transform: translateX(0); }
  to { transform: translateX(calc(-1 * var(--marquee-distance, 0px))); }
}

@media (max-width: 720px) {
  html,
  body {
    overflow: auto;
  }

  .broadcast {
    min-height: 100svh;
    padding: 24px 18px;
  }

  h1 {
    width: 100%;
    margin-left: -0.035em;
    font-size: clamp(2.9rem, 15vw, 4.3rem);
  }

  audio {
    height: 44px;
  }

  .meta-line {
    display: block;
  }

  .now-track {
    max-width: 100%;
    margin-top: 4px;
    font-size: clamp(0.92rem, 4.4vw, 1.15rem);
  }

  .power-button {
    right: 12px;
    top: 76px;
    width: min(42vw, 168px);
  }

  .word-cloud span {
    font-size: clamp(0.72rem, 4vw, 1rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .signal-noise {
    animation: none;
  }

  .power-button,
  .power-button::before,
  .word-cloud {
    animation: none;
    rotate: 0deg;
  }

  .word-cloud span {
    animation: none;
    opacity: 0.28;
    filter: none;
    rotate: 0deg;
    scale: 1;
  }

  .now-track.is-overflowing .now-track-text {
    animation: none;
    transform: none;
  }
}
