:root {
  --bg: #0a0b0d;
  --panel: #1c1d20;
  --panel-edge: #2a2c30;
  --cyan: #00f0ff;
  --cyan-soft: rgba(0, 240, 255, 0.55);
  --cyan-dim: rgba(0, 240, 255, 0.18);
  --ink-dim: rgba(255, 255, 255, 0.55);
  --ink-faint: rgba(255, 255, 255, 0.08);
  --error: #ff5a5a;
}

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

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--cyan);
  font-family: "VT323", "Courier New", monospace;
  -webkit-font-smoothing: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
}

/* Scanlines overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 2px,
    rgba(0, 0, 0, 0.18) 2px,
    rgba(0, 0, 0, 0.18) 3px
  );
  pointer-events: none;
  z-index: 100;
  mix-blend-mode: multiply;
}

.stage {
  height: 100dvh;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(24px, 6vh, 64px);
  padding:
    calc(env(safe-area-inset-top) + 24px)
    calc(env(safe-area-inset-right) + 24px)
    calc(env(safe-area-inset-bottom) + 24px)
    calc(env(safe-area-inset-left) + 24px);
}

.display {
  width: min(560px, 92vw);
  min-height: clamp(160px, 28vh, 260px);
  border: 1px solid var(--cyan-soft);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--panel-edge) 0%, var(--panel) 60%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 0 0 1px rgba(0, 0, 0, 0.4),
    0 4px 18px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 12px;
  padding: 20px 22px;
  text-align: left;
  cursor: pointer;
  outline: none;
}

.display:focus-visible {
  border-color: var(--cyan);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 0 0 1px rgba(0, 0, 0, 0.4),
    0 0 18px var(--cyan-dim),
    0 4px 18px rgba(0, 0, 0, 0.55);
}

.channel-indicators {
  display: flex;
  flex-wrap: nowrap;
  gap: 2px;
  width: 100%;
  justify-content: flex-start;
  align-items: center;
}

.channel-indicator {
  flex: 1 1 0;
  min-width: 2px;
  max-width: 8px;
  height: 6px;
  background: var(--ink-faint);
  border-radius: 1px;
  transition: background 120ms ease, box-shadow 120ms ease;
}

.channel-indicator[data-group-start="true"] {
  margin-left: 8px;
}

.channel-indicator[data-group-start="true"]:first-child {
  margin-left: 0;
}

.channel-indicator.active {
  background: var(--cyan);
  box-shadow: 0 0 4px var(--cyan), 0 0 8px var(--cyan-soft);
}

.info-bar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: clamp(1.05rem, 2.86vw, 1.43rem);
  letter-spacing: 0.18em;
  color: var(--ink-dim);
  text-transform: uppercase;
  line-height: 1;
}

.info-bar .region {
  color: var(--cyan);
  text-shadow: 0 0 4px var(--cyan-dim);
}

.info-bar .bitrate:not(:empty)::after {
  content: " kbps";
  opacity: 0.55;
  letter-spacing: 0.1em;
}

.channel-name {
  font-size: clamp(2.2rem, 7.7vw, 3.74rem);
  line-height: 1.05;
  height: calc(2em * 1.05);
  letter-spacing: 0.06em;
  color: var(--cyan);
  text-shadow:
    0 0 6px var(--cyan),
    0 0 18px var(--cyan-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.status {
  font-size: clamp(1.1rem, 3.3vw, 1.54rem);
  letter-spacing: 0.3em;
  color: var(--ink-dim);
  text-transform: uppercase;
  line-height: 1;
  margin-top: auto;
}

.status[data-state="playing"] {
  color: var(--cyan);
  text-shadow: 0 0 8px var(--cyan), 0 0 20px var(--cyan-dim);
  animation: pulse 1.4s ease-in-out infinite;
}

.status[data-state="loading"],
.status[data-state="paused"] {
  color: var(--ink-dim);
}

.status[data-state="error"] {
  color: var(--error);
  text-shadow: 0 0 8px var(--error), 0 0 20px rgba(255, 90, 90, 0.4);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.controls {
  display: flex;
  gap: clamp(32px, 10vw, 96px);
  align-items: center;
  justify-content: center;
}

.arrow {
  font-family: inherit;
  font-size: clamp(3.08rem, 9.9vw, 4.84rem);
  line-height: 1;
  width: clamp(96px, 22vw, 140px);
  height: clamp(96px, 22vw, 140px);
  border-radius: 12px;
  border: 1px solid var(--cyan-soft);
  background: linear-gradient(180deg, var(--panel-edge) 0%, var(--panel) 60%);
  color: var(--cyan);
  text-shadow: 0 0 8px var(--cyan-dim);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 0 0 1px rgba(0, 0, 0, 0.4),
    0 4px 12px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 80ms ease, box-shadow 120ms ease,
              border-color 120ms ease, color 120ms ease,
              text-shadow 120ms ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  outline: none;
}

.arrow:hover,
.arrow:focus-visible {
  border-color: var(--cyan);
  text-shadow: 0 0 10px var(--cyan), 0 0 24px var(--cyan-soft);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 0 0 1px rgba(0, 0, 0, 0.4),
    0 0 18px var(--cyan-dim),
    0 4px 12px rgba(0, 0, 0, 0.5);
}

.arrow:active {
  transform: scale(0.94);
  border-color: var(--cyan);
  text-shadow: 0 0 12px var(--cyan), 0 0 28px var(--cyan);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 0 1px rgba(0, 0, 0, 0.4),
    0 0 26px var(--cyan-soft),
    0 2px 8px rgba(0, 0, 0, 0.5);
}

.github-link {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  right: calc(env(safe-area-inset-right) + 12px);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: var(--ink-dim);
  border-radius: 6px;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: color 120ms ease, background 120ms ease;
  z-index: 50;
}

.github-link:hover,
.github-link:focus-visible {
  color: var(--cyan);
  background: rgba(0, 240, 255, 0.06);
  outline: none;
}

@media (orientation: landscape) and (max-height: 520px) {
  .stage {
    flex-direction: row;
    gap: clamp(24px, 4vw, 64px);
  }
  .display {
    flex: 1 1 auto;
    width: auto;
    min-height: auto;
    height: min(70dvh, 320px);
  }
}
