:root {
  color-scheme: dark;
  --ink: #030806;
  --panel: #07110d;
  --panel-deep: #020705;
  --phosphor: #c9e0d2;
  --phosphor-dim: #789989;
  --line: #385246;
  --line-bright: #668a77;
  --accent: #ff4d24;
  --accent-soft: rgba(255, 77, 36, 0.24);
  --shadow: rgba(111, 169, 137, 0.18);
  font-family: "Courier New", "Lucida Console", monospace;
  background: #010403;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  display: grid;
  place-items: center;
  padding: 12px;
  color: var(--phosphor);
  background:
    radial-gradient(circle at 50% 40%, rgba(19, 47, 34, 0.32), transparent 48%),
    repeating-linear-gradient(0deg, rgba(139, 183, 157, 0.025) 0 1px, transparent 1px 4px),
    #010403;
}

button {
  font: inherit;
}

button,
.screen {
  -webkit-tap-highlight-color: transparent;
}

.receiver {
  position: relative;
  width: min(100%, 280px);
  min-height: 320px;
  padding: 12px 11px 9px;
  overflow: hidden;
  background:
    linear-gradient(rgba(75, 111, 91, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(75, 111, 91, 0.025) 1px, transparent 1px),
    var(--ink);
  background-size: 4px 4px;
  border: 1px solid rgba(88, 124, 103, 0.24);
  box-shadow: 0 0 42px rgba(0, 0, 0, 0.9), inset 0 0 24px rgba(46, 94, 68, 0.06);
}

.receiver::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.018) 0,
    rgba(255, 255, 255, 0.018) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: screen;
}

.topbar,
.filter-rack,
.controls,
.screen-status,
.screen-tags,
.tuned-state {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  margin-bottom: 8px;
}

h1 {
  margin: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.45px;
  line-height: 1;
  text-shadow: 0 0 7px var(--shadow);
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--accent);
  font-size: 8px;
  letter-spacing: 1.2px;
}

.live-lamp {
  width: 6px;
  height: 6px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 2s ease-in-out infinite;
}

.filter-rack {
  position: relative;
  z-index: 3;
  gap: 5px;
  margin-bottom: 7px;
}

.filter-control {
  min-width: 0;
  flex: 1;
  height: 26px;
  padding: 0 24px 0 8px;
  color: var(--phosphor);
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  background:
    linear-gradient(45deg, transparent 50%, var(--phosphor-dim) 50%) calc(100% - 10px) 10px / 4px 4px no-repeat,
    linear-gradient(135deg, var(--phosphor-dim) 50%, transparent 50%) calc(100% - 6px) 10px / 4px 4px no-repeat,
    rgba(9, 22, 16, 0.88);
  border: 1px solid var(--line);
  border-radius: 5px;
}

.filter-control:focus-visible,
.filter-control:hover {
  border-color: var(--phosphor);
  outline: none;
  box-shadow: 0 0 0 1px var(--phosphor);
}

.filter-divider {
  color: var(--phosphor-dim);
  font-size: 8px;
}

.screen {
  position: relative;
  height: 144px;
  overflow: hidden;
  background:
    linear-gradient(rgba(87, 132, 106, 0.075) 1px, transparent 1px),
    linear-gradient(90deg, rgba(87, 132, 106, 0.075) 1px, transparent 1px),
    radial-gradient(circle at 50% 42%, #173226, #07110d 68%);
  background-size: 23px 23px, 23px 23px, auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: inset 0 0 24px rgba(53, 114, 82, 0.16);
  touch-action: manipulation;
  cursor: pointer;
}

.screen video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  filter: saturate(0.6) sepia(0.12) hue-rotate(84deg) brightness(0.78) contrast(1.14);
  transition: opacity 360ms ease;
}

.screen.is-playing video {
  opacity: 0.84;
}

.video-wash,
.scanlines,
.signal-noise {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.video-wash {
  background: rgba(38, 100, 67, 0.1);
  mix-blend-mode: color;
}

.scanlines {
  z-index: 2;
  background: repeating-linear-gradient(0deg, rgba(2, 8, 5, 0.2) 0 1px, transparent 1px 3px);
}

.signal-noise {
  opacity: 0.15;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.32'/%3E%3C/svg%3E");
  animation: static-jump 220ms steps(2) infinite;
}

.is-playing .signal-noise {
  opacity: 0.035;
}

.screen-status {
  position: absolute;
  z-index: 4;
  top: 8px;
  right: 8px;
  left: 8px;
  justify-content: space-between;
  font-size: 6px;
  letter-spacing: 1px;
}

.tuned-state {
  gap: 5px;
  color: var(--accent);
  font-weight: 700;
}

.status-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 5px var(--accent);
}

.screen-tags {
  gap: 4px;
}

.screen-tags span {
  max-width: 72px;
  padding: 4px 6px;
  overflow: hidden;
  color: var(--phosphor);
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(3, 9, 7, 0.72);
  border: 1px solid var(--line-bright);
  border-radius: 4px;
}

.signal-message {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  text-align: center;
  text-shadow: 0 0 10px #001b0e;
  transition: opacity 180ms ease;
}

.is-playing .signal-message {
  opacity: 0;
}

.signal-message strong {
  font-size: 8px;
  letter-spacing: 1.4px;
}

.signal-message small {
  color: var(--phosphor-dim);
  font-size: 5px;
  letter-spacing: 0.9px;
}

.signal-mark {
  width: 21px;
  height: 21px;
  border: 1px solid var(--phosphor);
  box-shadow: 0 0 13px var(--shadow);
  transform: rotate(45deg);
  animation: scan 1.5s ease-in-out infinite;
}

.signal-message.is-counting .signal-mark {
  display: none;
}

.signal-countdown {
  --countdown-angle: 360deg;
  position: relative;
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  color: var(--phosphor);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0;
  background: conic-gradient(var(--accent) var(--countdown-angle), rgba(91, 127, 107, 0.18) 0);
  border-radius: 50%;
  box-shadow: 0 0 14px var(--accent-soft);
}

.signal-countdown[hidden] {
  display: none;
}

.signal-countdown::before {
  content: "";
  position: absolute;
  inset: 3px;
  background: #06100b;
  border: 1px solid rgba(126, 162, 141, 0.34);
  border-radius: inherit;
}

.signal-countdown span {
  position: relative;
  z-index: 1;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 7px var(--phosphor);
}

.reticle {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  width: 34px;
  height: 1px;
  background: rgba(209, 232, 217, 0.82);
  transform: translate(-50%, -50%);
  opacity: 0.5;
  pointer-events: none;
}

.reticle span {
  position: absolute;
  top: -16px;
  left: 16px;
  width: 1px;
  height: 34px;
  background: inherit;
}

.is-playing .reticle {
  opacity: 0.18;
}

.audio-toggle {
  position: absolute;
  z-index: 5;
  right: 8px;
  bottom: 8px;
  min-width: 30px;
  height: 18px;
  padding: 0 6px;
  color: var(--phosphor-dim);
  font-size: 5px;
  letter-spacing: 0.8px;
  background: rgba(2, 7, 5, 0.78);
  border: 1px solid var(--line);
  border-radius: 3px;
  cursor: pointer;
}

.audio-toggle.is-audible {
  color: var(--accent);
  border-color: var(--accent);
}

.channel-card {
  position: relative;
  min-height: 83px;
  margin-top: 6px;
  padding: 12px 12px 10px;
  background: rgba(1, 6, 4, 0.82);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: inset 0 0 18px rgba(36, 86, 59, 0.08);
}

.channel-index {
  position: absolute;
  top: 9px;
  right: 10px;
  color: var(--phosphor-dim);
  font-size: 5px;
  letter-spacing: 0.8px;
}

.channel-card h2 {
  max-width: 205px;
  margin: 0 0 7px;
  overflow: hidden;
  font-size: clamp(10px, 4.2vw, 13px);
  line-height: 1.1;
  letter-spacing: 1.35px;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 0 8px var(--shadow);
}

.channel-card p {
  margin: 0 0 5px;
  overflow: hidden;
  font-size: 6px;
  letter-spacing: 0.95px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-meta {
  color: #94b7a3;
}

.channel-tech,
.channel-note {
  color: #a6b4ac;
}

.channel-note {
  color: var(--accent) !important;
}

.controls {
  position: relative;
  z-index: 3;
  justify-content: space-between;
  gap: 6px;
  min-height: 20px;
  margin-top: 4px;
  border-top: 1px solid rgba(56, 82, 70, 0.45);
}

.controls p {
  margin: 0;
  color: #5d7368;
  font-size: 5px;
  letter-spacing: 0.8px;
}

.controls button {
  padding: 5px 0;
  color: var(--phosphor-dim);
  font-size: 5px;
  letter-spacing: 0.7px;
  background: none;
  border: 0;
  cursor: pointer;
}

.controls button:hover,
.controls button:focus-visible {
  color: var(--phosphor);
  outline: none;
}

.side-trigger {
  position: absolute;
  z-index: 7;
  top: 62px;
  right: -1px;
  width: 10px;
  height: 45px;
  padding: 0;
  overflow: hidden;
  color: transparent;
  background: var(--line);
  border: 1px solid var(--line-bright);
  border-right: 0;
  border-radius: 4px 0 0 4px;
  cursor: pointer;
  box-shadow: -2px 0 8px rgba(89, 139, 110, 0.16);
}

.side-trigger::before {
  content: "";
  position: absolute;
  inset: 5px 3px;
  border-left: 1px solid var(--phosphor-dim);
  border-right: 1px solid var(--phosphor-dim);
}

.side-trigger:hover,
.side-trigger:focus-visible {
  background: var(--line-bright);
  outline: 1px solid var(--phosphor);
  outline-offset: -2px;
}

.filter-overlay {
  position: absolute;
  z-index: 10;
  inset: 0;
  padding: 38px 11px 12px;
  background: rgba(1, 5, 3, 0.88);
  backdrop-filter: blur(2px);
}

.filter-overlay[hidden] {
  display: none;
}

.filter-panel {
  display: flex;
  height: 100%;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  background:
    linear-gradient(rgba(87, 132, 106, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(87, 132, 106, 0.055) 1px, transparent 1px),
    rgba(3, 11, 7, 0.98);
  background-size: 18px 18px;
  border: 1px solid var(--line-bright);
  border-radius: 8px;
  box-shadow: 0 0 24px #000, inset 0 0 20px rgba(52, 103, 75, 0.12);
}

.filter-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 11px 12px 9px;
  border-bottom: 1px solid var(--line);
}

.filter-panel-header span {
  display: block;
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 5px;
  letter-spacing: 1px;
}

.filter-panel-header h2 {
  margin: 0;
  font-size: 10px;
  letter-spacing: 1.2px;
}

.filter-panel-header button {
  width: 22px;
  height: 22px;
  padding: 0;
  color: var(--phosphor-dim);
  font-size: 14px;
  line-height: 1;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
}

.filter-list {
  min-height: 0;
  flex: 1;
  padding: 5px;
  overflow-y: auto;
  scrollbar-color: var(--line-bright) transparent;
  scrollbar-width: thin;
}

.filter-option {
  position: relative;
  display: block;
  width: 100%;
  min-height: 27px;
  padding: 7px 22px 7px 8px;
  overflow: hidden;
  color: var(--phosphor-dim);
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(56, 82, 70, 0.38);
  cursor: pointer;
}

.filter-option:hover,
.filter-option:focus-visible,
.filter-option.is-selected {
  color: var(--phosphor);
  background: rgba(80, 126, 99, 0.12);
  outline: none;
}

.filter-option.is-selected::after {
  content: "●";
  position: absolute;
  top: 8px;
  right: 8px;
  color: var(--accent);
  font-size: 5px;
}

.filter-option:first-child {
  position: sticky;
  z-index: 2;
  top: 0;
  color: var(--phosphor);
  background: #07110d;
  border: 1px solid var(--line-bright);
  border-radius: 4px;
  box-shadow: 0 5px 10px rgba(1, 5, 3, 0.92);
}

.filter-help {
  margin: 0;
  padding: 8px 10px;
  color: #5d7368;
  font-size: 5px;
  letter-spacing: 0.8px;
  text-align: center;
  border-top: 1px solid var(--line);
}

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

@keyframes pulse {
  50% {
    opacity: 0.45;
  }
}

@keyframes static-jump {
  50% {
    transform: translate(1px, -1px);
  }
}

@keyframes scan {
  50% {
    transform: rotate(45deg) scale(0.62);
    opacity: 0.45;
  }
}

/* The Rabbit R1 display is a 240 × 282 canvas. Keep every control inside it
   and use the full panel instead of treating it as a 4:3 desktop viewport. */
html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  padding: 0;
}

.receiver {
  display: grid;
  width: min(240px, 100vw);
  height: min(282px, 100dvh);
  min-height: 0;
  aspect-ratio: auto;
  grid-template-rows: 15px 25px minmax(0, 1fr) 71px 18px;
  gap: 4px;
  padding: 8px;
  transform: none;
}

.topbar,
.filter-rack,
.screen-status,
.screen-tags,
.tuned-state,
.controls {
  min-width: 0;
}

.topbar,
.filter-rack,
.channel-card,
.controls {
  margin: 0;
}

h1 {
  min-width: 0;
  overflow: hidden;
  font-size: 9px;
}

.live-indicator {
  font-size: 7px;
}

.live-lamp {
  width: 5px;
  height: 5px;
}

.filter-rack {
  gap: 5px;
}

.filter-control {
  height: 25px;
  padding: 0 22px 0 7px;
  font-size: 7px;
}

.filter-divider {
  font-size: 8px;
}

.screen {
  height: auto;
  min-height: 0;
  border-radius: 10px;
}

.screen-status {
  top: 7px;
  right: 7px;
  left: 7px;
  gap: 4px;
  font-size: 6px;
}

.screen-tags span {
  max-width: 62px;
  padding: 3px 4px;
}

.signal-message strong,
.signal-message small {
  max-width: calc(100% - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.signal-message strong {
  font-size: 8px;
}

.signal-message small {
  font-size: 5px;
}

.audio-toggle {
  right: 7px;
  bottom: 7px;
  min-width: 30px;
  height: 18px;
  padding: 0 6px;
  font-size: 5px;
}

.channel-card {
  min-height: 0;
  padding: 10px 10px 7px;
}

.channel-index {
  top: 7px;
  right: 8px;
  font-size: 5px;
}

.channel-card h2 {
  max-width: calc(100% - 60px);
  margin: 0 0 6px;
  font-size: 11px;
}

.channel-card p {
  margin: 0 0 4px;
  font-size: 6px;
}

.controls {
  gap: 6px;
  min-height: 0;
}

.controls p {
  overflow: hidden;
  font-size: 5px;
}

.controls button {
  flex: 0 0 auto;
  padding: 5px 0;
  font-size: 5px;
}

.side-trigger {
  top: 52px;
  width: 9px;
  height: 42px;
}

.filter-overlay {
  padding: 8px;
}

.filter-panel-header {
  padding: 9px 10px 7px;
}

.filter-panel-header span,
.filter-help {
  font-size: 5px;
}

.filter-panel-header h2 {
  font-size: 9px;
}

.filter-panel-header button {
  width: 22px;
  height: 22px;
  font-size: 14px;
}

.filter-option {
  min-height: 27px;
  padding: 7px 22px 7px 8px;
  font-size: 7px;
}

.filter-option.is-selected::after {
  top: 8px;
  right: 8px;
  font-size: 5px;
}

.filter-help {
  padding: 8px 10px;
}

@media (max-width: 239px), (max-height: 281px) {
  .receiver {
    grid-template-rows: 5.319% 8.865% minmax(0, 1fr) 25.177% 6.383%;
    gap: 1.418%;
    padding: 2.837%;
  }

  h1 {
    font-size: clamp(7px, 3.75vw, 9px);
  }

  .live-indicator,
  .filter-control,
  .screen-status,
  .channel-card p,
  .controls p,
  .controls button,
  .filter-option {
    font-size: clamp(5px, 2.92vw, 7px);
  }

  .channel-card h2 {
    font-size: clamp(9px, 4.58vw, 11px);
  }
}

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