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

:root {
  --bg-dark: #0a0a0a;
  --bg-panel: #111111;
  --bg-panel-border: #2a2a2a;
  --scope-green: #00ff41;
  --scope-green-dim: #00aa2a;
  --phosphor-amber: #ffb000;
  --crt-blue: #3388cc;
  --wood-dark: #3d2b1f;
  --wood-mid: #5c3d2e;
  --wood-light: #7a5740;
  --text-primary: #cccccc;
  --text-dim: #666666;
  --knob-bg: #222;
  --knob-ring: #444;
  --accent-red: #ff3333;
}

body {
  background: var(--bg-dark);
  color: var(--text-primary);
  font-family: 'Share Tech Mono', 'Courier New', monospace;
  min-height: 100vh;
  overflow-x: hidden;
}

#app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 10px;
}

#main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  border-bottom: 1px solid var(--bg-panel-border);
  margin-bottom: 10px;
}

#main-header h1 {
  font-family: 'VT323', monospace;
  font-size: 24px;
  color: var(--scope-green);
  text-shadow: 0 0 10px rgba(0,255,65,0.5);
  letter-spacing: 3px;
}

.header-controls {
  display: flex;
  gap: 10px;
}

.header-controls button {
  background: var(--bg-panel);
  border: 1px solid var(--bg-panel-border);
  color: var(--scope-green);
  font-family: 'VT323', monospace;
  font-size: 16px;
  padding: 6px 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.header-controls button:hover {
  background: #1a1a1a;
  border-color: var(--scope-green);
  text-shadow: 0 0 8px rgba(0,255,65,0.6);
}

/* Signal Lab */
#signal-lab {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--bg-panel-border);
  border-radius: 4px;
  padding: 10px;
  flex: 1;
  min-width: 300px;
}

#panel-combined {
  min-width: 340px;
}

.panel-label {
  font-family: 'VT323', monospace;
  font-size: 18px;
  color: var(--phosphor-amber);
  text-shadow: 0 0 8px rgba(255,176,0,0.4);
  letter-spacing: 2px;
  text-align: center;
  margin-bottom: 8px;
  border-bottom: 1px solid #2a2a0a;
  padding-bottom: 4px;
}

.scope-container {
  position: relative;
  margin-bottom: 8px;
  background: #050505;
  border: 1px solid #1a1a1a;
  border-radius: 3px;
  padding: 2px;
}

.scope-container.wide canvas {
  width: 100%;
}

.scope-label {
  font-family: 'VT323', monospace;
  font-size: 12px;
  color: var(--text-dim);
  padding: 2px 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.scope-container canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 2px;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 6px 0;
  align-items: flex-end;
}

.knob-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 80px;
}

.knob-group label {
  font-family: 'VT323', monospace;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 1px;
}

.knob-group input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: #1a1a1a;
  border-radius: 3px;
  outline: none;
}

.knob-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #666, #222);
  border: 2px solid #555;
  cursor: pointer;
  box-shadow: 0 0 4px rgba(0,0,0,0.8);
}

.knob-group input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #666, #222);
  border: 2px solid #555;
  cursor: pointer;
}

.knob-group select {
  background: #1a1a1a;
  color: var(--scope-green);
  border: 1px solid #333;
  font-family: 'VT323', monospace;
  font-size: 13px;
  padding: 3px 6px;
  border-radius: 2px;
}

.readout {
  font-family: 'VT323', monospace;
  font-size: 14px;
  color: var(--scope-green);
  text-shadow: 0 0 6px rgba(0,255,65,0.3);
}

.carrier-offset {
  font-family: 'VT323', monospace;
  font-size: 12px;
  color: var(--phosphor-amber);
  text-align: center;
  margin-top: 4px;
  opacity: 0.7;
}

.small-btn, .tiny-btn {
  background: #1a1a1a;
  border: 1px solid #333;
  color: var(--accent-red);
  font-family: 'VT323', monospace;
  font-size: 13px;
  padding: 3px 10px;
  cursor: pointer;
  border-radius: 2px;
}

.small-btn.active {
  color: var(--scope-green);
  border-color: var(--scope-green);
  text-shadow: 0 0 6px rgba(0,255,65,0.5);
}

.tiny-btn {
  font-size: 11px;
  padding: 1px 6px;
}

/* TV Section */
#tv-section {
  display: flex;
  justify-content: center;
  padding: 20px 0;
}

#tv-set {
  position: relative;
  width: 720px;
  max-width: 100%;
}

.antenna {
  position: absolute;
  width: 3px;
  height: 80px;
  background: linear-gradient(to top, #888, #bbb);
  top: -78px;
  border-radius: 1px;
  transform-origin: bottom center;
  transition: transform 0.3s ease;
}

#antenna-left {
  left: 42%;
  transform: rotate(-25deg);
}

#antenna-right {
  right: 42%;
  transform: rotate(25deg);
}

#antenna-base {
  position: absolute;
  top: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 10px;
  background: #666;
  border-radius: 3px 3px 0 0;
  z-index: 2;
}

#tv-body {
  background: #2a2a2a;
  border-radius: 16px;
  padding: 18px;
  display: flex;
  gap: 15px;
  border: 2px solid #3a3a3a;
  position: relative;
  z-index: 1;
  box-shadow: 0 10px 40px rgba(0,0,0,0.7), inset 0 1px 0 rgba(255,255,255,0.05);
}

#tv-screen-bezel {
  position: relative;
  background: #0a0a0a;
  border-radius: 14px;
  padding: 8px;
  flex: 1;
  overflow: hidden;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.9), inset 0 0 4px rgba(0,0,0,0.5);
}

#tv-screen {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 10px;
}

#scanline-overlay {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  bottom: 8px;
  border-radius: 10px;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0,0,0,0.15) 2px,
    rgba(0,0,0,0.15) 4px
  );
  z-index: 2;
}

#screen-reflection {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  bottom: 8px;
  border-radius: 10px;
  pointer-events: none;
  background: radial-gradient(ellipse at 30% 20%, rgba(255,255,255,0.04) 0%, transparent 60%);
  z-index: 3;
}

#tv-controls-panel {
  width: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding-top: 10px;
}

.tv-brand {
  font-family: 'VT323', monospace;
  font-size: 20px;
  color: #c0a060;
  text-shadow: 0 1px 0 rgba(0,0,0,0.5);
  letter-spacing: 4px;
}

.model-no {
  display: block;
  font-size: 11px;
  color: #888;
  letter-spacing: 2px;
  text-align: center;
}

.tv-knob-row {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

.tv-knob-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.tv-knob-group span {
  font-family: 'VT323', monospace;
  font-size: 10px;
  color: #999;
  letter-spacing: 1px;
}

.knob-visual {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #555, #1a1a1a);
  border: 2px solid #444;
  position: relative;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.1);
}

.knob-indicator {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 10px;
  background: #ddd;
  border-radius: 1px;
}

.tv-knob-group input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 90%;
  height: 4px;
  background: #333;
  border-radius: 2px;
  outline: none;
}

.tv-knob-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #888;
  border: 1px solid #555;
  cursor: pointer;
}

.channel-indicator {
  font-family: 'VT323', monospace;
  font-size: 28px;
  color: var(--phosphor-amber);
  text-shadow: 0 0 10px rgba(255,176,0,0.5);
  margin-top: 10px;
  background: #111;
  padding: 4px 12px;
  border-radius: 3px;
  border: 1px solid #333;
}

.wood-panel {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 20px;
  z-index: 0;
  border-radius: 16px;
  background: linear-gradient(
    180deg,
    var(--wood-light) 0%,
    var(--wood-dark) 15%,
    var(--wood-mid) 30%,
    var(--wood-dark) 50%,
    var(--wood-mid) 70%,
    var(--wood-dark) 85%,
    var(--wood-light) 100%
  );
}

#tv-wood-left {
  left: -10px;
  border-radius: 16px 0 0 16px;
}

#tv-wood-right {
  right: -10px;
  border-radius: 0 16px 16px 0;
}

.tv-leg {
  position: absolute;
  bottom: -20px;
  width: 30px;
  height: 22px;
  background: linear-gradient(180deg, #444, #222);
  border-radius: 0 0 6px 6px;
}

#tv-stand-left { left: 60px; }
#tv-stand-right { right: 60px; }

#tv-manufacturer {
  text-align: center;
  margin-top: 28px;
  padding-top: 4px;
}

#tv-manufacturer a {
  font-family: 'VT323', monospace;
  font-size: 11px;
  color: #555;
  text-decoration: none;
  letter-spacing: 2px;
  transition: color 0.3s;
}

#tv-manufacturer a:hover {
  color: var(--phosphor-amber);
}

/* Info Overlay */
#info-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.92);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-y: auto;
  padding: 20px;
}

#info-overlay.hidden {
  display: none;
}

#info-content {
  max-width: 700px;
  width: 100%;
  background: #111;
  border: 1px solid var(--scope-green);
  border-radius: 6px;
  padding: 30px;
  position: relative;
  box-shadow: 0 0 40px rgba(0,255,65,0.15);
}

#info-content h2 {
  font-family: 'VT323', monospace;
  font-size: 26px;
  color: var(--scope-green);
  text-shadow: 0 0 10px rgba(0,255,65,0.4);
  margin-bottom: 20px;
  letter-spacing: 3px;
}

#btn-close-info {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: 1px solid #444;
  color: var(--accent-red);
  font-family: 'VT323', monospace;
  font-size: 16px;
  padding: 4px 10px;
  cursor: pointer;
}

.info-step {
  display: flex;
  gap: 15px;
  margin-bottom: 20px;
  padding: 12px;
  background: #0a0a0a;
  border: 1px solid #222;
  border-radius: 4px;
}

.step-num {
  font-family: 'VT323', monospace;
  font-size: 36px;
  color: var(--phosphor-amber);
  text-shadow: 0 0 10px rgba(255,176,0,0.5);
  min-width: 40px;
  text-align: center;
}

.step-text h3 {
  font-family: 'VT323', monospace;
  font-size: 18px;
  color: var(--phosphor-amber);
  margin-bottom: 6px;
  letter-spacing: 2px;
}

.step-text p {
  font-size: 13px;
  line-height: 1.6;
  color: #aaa;
}

.step-text em {
  color: var(--scope-green);
  font-style: normal;
}

.step-text strong {
  color: #ddd;
}

.formula {
  font-family: 'Share Tech Mono', monospace;
  font-size: 14px;
  color: var(--scope-green);
  background: #050505;
  padding: 6px 12px;
  border-radius: 3px;
  margin-top: 8px;
  text-shadow: 0 0 6px rgba(0,255,65,0.3);
}

/* CRT Power animation */
@keyframes crt-on {
  0% { transform: scaleY(0.005) scaleX(1); filter: brightness(5); }
  40% { transform: scaleY(0.005) scaleX(1); filter: brightness(5); }
  50% { transform: scaleY(1) scaleX(1); filter: brightness(1.5); }
  100% { transform: scaleY(1) scaleX(1); filter: brightness(1); }
}

@keyframes crt-off {
  0% { transform: scaleY(1) scaleX(1); filter: brightness(1); }
  40% { transform: scaleY(0.005) scaleX(1); filter: brightness(5); }
  70% { transform: scaleY(0.005) scaleX(0.005); filter: brightness(10); }
  100% { transform: scaleY(0) scaleX(0); filter: brightness(0); }
}

#tv-screen.power-on {
  animation: crt-on 0.8s ease-out forwards;
}

#tv-screen.power-off {
  animation: crt-off 0.6s ease-in forwards;
}

/* Antenna sway */
@keyframes antenna-sway {
  0%, 100% { transform: rotate(-25deg); }
  50% { transform: rotate(-27deg); }
}

@keyframes antenna-sway-r {
  0%, 100% { transform: rotate(25deg); }
  50% { transform: rotate(27deg); }
}

#antenna-left { animation: antenna-sway 4s ease-in-out infinite; }
#antenna-right { animation: antenna-sway-r 4.5s ease-in-out infinite; }

/* Responsive */
@media (max-width: 900px) {
  #signal-lab {
    flex-direction: column;
  }
  
  .panel {
    min-width: unset;
  }

  #tv-body {
    flex-direction: column;
  }

  #tv-controls-panel {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }

  .tv-knob-row {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }
}

@media (max-width: 500px) {
  #main-header h1 {
    font-size: 16px;
    letter-spacing: 1px;
  }

  .controls-row {
    flex-direction: column;
  }
}