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

html, body {
  width: 100%; height: 100%;
  background: #1a1a1a;
  font-family: 'IBM Plex Mono', monospace;
  color: #c8c8b0;
  overflow-x: hidden;
}

#scope-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
  min-height: 100vh;
}

#crt-bezel {
  background: linear-gradient(145deg, #3a3a3a 0%, #2a2a2a 30%, #222 70%, #1a1a1a 100%);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.08), 0 0 0 2px #111;
  border: 1px solid #444;
  position: relative;
}

#crt-bezel::before {
  content: '';
  position: absolute;
  top: 6px; left: 6px; right: 6px; bottom: 6px;
  border-radius: 14px;
  border: 1px solid #333;
  pointer-events: none;
}

#crt-screen-wrapper {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: #050a05;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.8), inset 0 0 4px rgba(0,80,0,0.15);
}

#canvas, #graticule {
  display: block;
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}

#canvas { z-index: 1; }
#graticule { z-index: 2; pointer-events: none; }

#crt-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 3;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(0,0,0,0.06) 2px,
      rgba(0,0,0,0.06) 4px
    ),
    radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.45) 100%);
  border-radius: 8px;
}

#controls {
  width: 100%;
  max-width: 740px;
  margin-top: 14px;
  background: linear-gradient(180deg, #333 0%, #282828 40%, #222 100%);
  border-radius: 12px;
  padding: 16px 16px 12px;
  border: 1px solid #444;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.06);
}

.ctrl-section {
  margin-bottom: 10px;
}

.ctrl-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #b0a880;
  margin-bottom: 6px;
  padding-bottom: 3px;
  border-bottom: 1px solid #3a3a3a;
}

.ctrl-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  justify-content: center;
}

.knob-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 56px;
}

.knob-label {
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #999;
  margin-bottom: 3px;
  text-align: center;
  white-space: nowrap;
}

.knob-container {
  position: relative;
  width: 48px;
  height: 48px;
}

.knob {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #555, #2a2a2a 70%, #1a1a1a);
  border: 2px solid #444;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.1);
  cursor: grab;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.knob:active { cursor: grabbing; }

.knob-pointer {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 3px;
  height: 12px;
  background: #e8e0c0;
  border-radius: 1px;
  pointer-events: none;
}

.knob-value {
  font-size: 8px;
  color: #70a070;
  margin-top: 2px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.waveform-selector {
  display: flex;
  gap: 2px;
  margin-top: 2px;
}

.wave-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 8px;
  padding: 2px 5px;
  background: #2a2a2a;
  color: #777;
  border: 1px solid #444;
  border-radius: 3px;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.wave-btn.active {
  background: #3a4a3a;
  color: #a0d0a0;
  border-color: #5a7a5a;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
}

.preset-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  font-weight: 600;
  padding: 4px 8px;
  background: linear-gradient(180deg, #3a3a3a, #2a2a2a);
  color: #a0a080;
  border: 1px solid #555;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.preset-btn:active {
  background: #222;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.4);
}

.preset-btn.active-preset {
  background: linear-gradient(180deg, #4a5a4a, #3a4a3a);
  color: #c0e0c0;
  border-color: #6a8a6a;
}

.ratio-display {
  font-size: 12px;
  font-weight: 700;
  color: #80c080;
  background: #111;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid #333;
  text-align: center;
  min-width: 70px;
  font-variant-numeric: tabular-nums;
}

footer {
  text-align: center;
  padding: 10px;
}

footer a {
  color: #444;
  text-decoration: none;
  font-size: 10px;
  font-family: 'IBM Plex Mono', monospace;
}

footer a:hover { color: #666; }

@media (max-width: 500px) {
  #crt-bezel { padding: 10px; border-radius: 12px; }
  #controls { padding: 10px; }
  .knob { width: 40px; height: 40px; }
  .knob-container { width: 40px; height: 40px; }
  .knob-pointer { height: 10px; top: 3px; }
}