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

:root {
  --phosphor: #00ff41;
  --phosphor-dim: #00aa2a;
  --phosphor-dark: #003d10;
  --amber: #ff9900;
  --amber-dim: #cc7700;
  --red: #ff3333;
  --bg-dark: #0d0d0d;
  --bg-panel: #1a1a1a;
  --bg-control: #222222;
  --bg-bezel: #2a2a2a;
  --text-dim: #555555;
  --text-label: #888888;
  --metal-highlight: #3a3a3a;
}

html, body {
  height: 100%;
  background: #080808;
  color: var(--phosphor);
  font-family: 'Share Tech Mono', 'Courier New', monospace;
  overflow-x: hidden;
}

/* Vignette overlay on whole app */
#app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

#app-container::after {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.6) 100%);
  pointer-events: none;
  z-index: 1000;
}

/* Header */
#header {
  background: linear-gradient(180deg, #2e2e2e 0%, #1e1e1e 100%);
  border-bottom: 2px solid #3a3a3a;
  padding: 12px 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}

.brand-plate {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  font-size: 24px;
  color: var(--phosphor);
  text-shadow: 0 0 10px var(--phosphor), 0 0 20px var(--phosphor-dark);
}

.brand-text {
  font-family: 'Share Tech Mono', monospace;
  font-size: 28px;
  letter-spacing: 6px;
  color: #ddd;
  text-shadow: 0 1px 0 #000, 0 0 10px rgba(255,255,255,0.1);
}

.brand-sub {
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--text-dim);
}

/* Main layout */
#main {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

/* Scope section */
#scope-section {
  flex: 0 0 auto;
}

#crt-bezel {
  background: linear-gradient(145deg, #333 0%, #1a1a1a 50%, #111 100%);
  border-radius: 20px;
  padding: 16px;
  box-shadow:
    0 0 0 2px #444,
    0 0 0 4px #111,
    inset 0 2px 4px rgba(255,255,255,0.05),
    0 10px 40px rgba(0,0,0,0.8);
}

#crt-screen {
  position: relative;
  width: 500px;
  height: 500px;
  background: #050805;
  border-radius: 12px;
  overflow: hidden;
  box-shadow:
    inset 0 0 60px rgba(0,255,65,0.03),
    inset 0 0 120px rgba(0,0,0,0.8);
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 12px;
}

#scanlines {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.08) 2px,
    rgba(0,0,0,0.08) 4px
  );
  pointer-events: none;
  border-radius: 12px;
}

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

#scope-label {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'VT323', monospace;
  font-size: 18px;
  color: var(--phosphor);
  opacity: 0.7;
  text-shadow: 0 0 8px var(--phosphor);
  pointer-events: none;
  transition: opacity 0.5s;
}

/* Controls section */
#controls-section {
  flex: 1;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-group {
  background: linear-gradient(180deg, #1f1f1f, #181818);
  border: 1px solid #333;
  border-radius: 10px;
  padding: 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 2px 8px rgba(0,0,0,0.4);
}

.panel-label {
  font-size: 10px;
  letter-spacing: 4px;
  color: var(--text-label);
  margin-bottom: 10px;
  border-bottom: 1px solid #2a2a2a;
  padding-bottom: 6px;
}

/* Drop zone */
#drop-zone {
  border: 2px dashed #3a3a3a;
  border-radius: 8px;
  padding: 18px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

#drop-zone:hover, #drop-zone.drag-over {
  border-color: var(--phosphor);
  background: rgba(0,255,65,0.03);
}

#drop-zone .drop-icon {
  font-size: 28px;
  color: var(--text-label);
  margin-bottom: 4px;
}

#drop-zone .drop-text {
  font-size: 13px;
  color: var(--amber);
  letter-spacing: 2px;
}

#drop-zone .drop-sub {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 4px;
  letter-spacing: 1px;
}

#drop-zone input[type="file"] {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  opacity: 0;
  cursor: pointer;
}

/* LCD readout */
#lcd-readout {
  margin-top: 8px;
  background: #0a0f0a;
  border: 1px solid #1a2a1a;
  border-radius: 4px;
  padding: 6px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'VT323', monospace;
  font-size: 15px;
  color: var(--phosphor-dim);
  box-shadow: inset 0 1px 4px rgba(0,0,0,0.5);
}

#mono-indicator {
  color: var(--red);
  font-size: 13px;
  text-shadow: 0 0 6px var(--red);
}

#mono-indicator.hidden {
  display: none;
}

/* Transport */
.transport-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hw-button {
  font-family: 'Share Tech Mono', monospace;
  font-size: 18px;
  width: 44px;
  height: 44px;
  border: 2px solid #444;
  border-radius: 8px;
  background: linear-gradient(180deg, #3a3a3a, #222);
  color: var(--amber);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 0 #111, 0 4px 8px rgba(0,0,0,0.5);
  transition: all 0.1s;
}

.hw-button:hover {
  background: linear-gradient(180deg, #444, #2a2a2a);
}

.hw-button:active {
  box-shadow: 0 1px 0 #111;
  transform: translateY(2px);
}

.hw-button.active {
  color: var(--phosphor);
  border-color: var(--phosphor-dark);
  box-shadow: 0 3px 0 #111, 0 0 10px rgba(0,255,65,0.15);
}

#time-display {
  font-family: 'VT323', monospace;
  font-size: 22px;
  color: var(--amber);
  text-shadow: 0 0 8px rgba(255,153,0,0.4);
  margin-left: auto;
  letter-spacing: 2px;
}

.time-sep {
  color: var(--text-dim);
  margin: 0 2px;
}

.seek-row {
  margin-top: 8px;
}

/* Sliders */
.hw-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.hw-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(145deg, #555, #333);
  border: 2px solid #666;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
  cursor: pointer;
}

.hw-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(145deg, #555, #333);
  border: 2px solid #666;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
  cursor: pointer;
}

.hw-slider:hover::-webkit-slider-thumb {
  border-color: var(--phosphor-dim);
}

.seek-slider {
  height: 4px;
}

/* Knob grid */
.knob-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.knob-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.knob-label {
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--text-label);
}

.knob-value {
  font-family: 'VT323', monospace;
  font-size: 14px;
  color: var(--amber-dim);
  text-align: right;
}

/* Footer */
#footer {
  padding: 14px 20px;
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 1px;
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

#footer a {
  color: var(--phosphor-dim);
  text-decoration: none;
}

#footer a:hover {
  color: var(--phosphor);
  text-shadow: 0 0 8px var(--phosphor-dark);
}

/* CRT power-on animation */
@keyframes crt-on {
  0% {
    filter: brightness(10) saturate(0);
    transform: scaleY(0.005) scaleX(0.5);
  }
  30% {
    filter: brightness(3) saturate(0.5);
    transform: scaleY(0.01) scaleX(1);
  }
  50% {
    filter: brightness(1.5);
    transform: scaleY(1) scaleX(1);
  }
  100% {
    filter: brightness(1);
    transform: scale(1);
  }
}

#crt-screen.power-on canvas {
  animation: crt-on 0.6s ease-out;
}

/* Responsive */
@media (max-width: 900px) {
  #main {
    flex-direction: column;
    align-items: center;
  }

  #crt-screen {
    width: 90vw;
    height: 90vw;
    max-width: 500px;
    max-height: 500px;
  }

  #controls-section {
    width: 100%;
    max-width: 500px;
  }
}

@media (max-width: 500px) {
  .brand-text {
    font-size: 20px;
    letter-spacing: 3px;
  }

  .brand-sub {
    display: none;
  }

  .knob-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  #crt-bezel {
    padding: 10px;
    border-radius: 14px;
  }
}