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

body {
  background: #1A1A2E;
  color: #E0E0E0;
  font-family: 'JetBrains Mono', monospace;
  overflow-x: hidden;
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #1A1A2E; }
::-webkit-scrollbar-thumb { background: #352879; border-radius: 4px; }

.retro-header {
  font-family: 'Press Start 2P', cursive;
}

.crt-screen {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  box-shadow:
    0 0 40px rgba(53, 40, 121, 0.6),
    0 0 80px rgba(53, 40, 121, 0.3),
    inset 0 0 30px rgba(0,0,0,0.4);
}

.crt-screen::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0,0,0,0.15) 0px,
    rgba(0,0,0,0.15) 1px,
    transparent 1px,
    transparent 3px
  );
  pointer-events: none;
  z-index: 2;
}

.crt-screen::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.4) 100%);
  pointer-events: none;
  z-index: 3;
}

.crt-screen canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

@keyframes flicker {
  0% { opacity: 1; }
  5% { opacity: 0.95; }
  10% { opacity: 1; }
  15% { opacity: 0.97; }
  100% { opacity: 1; }
}

.crt-flicker {
  animation: flicker 0.15s ease-in-out;
}

.key-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  user-select: none;
  transition: all 0.08s ease;
  text-transform: uppercase;
  line-height: 1.1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.key-btn:active, .key-btn.pressed {
  transform: translateY(2px);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.5) !important;
}

.key-normal {
  background: #C8B49A;
  color: #2A2A2A;
  box-shadow: 0 3px 0 #8A7A60, 0 4px 6px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.3);
}

.key-special {
  background: #6B6B6B;
  color: #E0E0E0;
  box-shadow: 0 3px 0 #4A4A4A, 0 4px 6px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.15);
}

.key-fn {
  background: #8B6B4A;
  color: #E0E0E0;
  box-shadow: 0 3px 0 #5A4A30, 0 4px 6px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.15);
}

.rainbow-bar {
  height: 4px;
  background: linear-gradient(90deg, #FF0000, #FF7700, #FFFF00, #00FF00, #0000FF, #8B00FF);
}

.panel-section {
  background: rgba(53, 40, 121, 0.2);
  border: 1px solid rgba(112, 164, 178, 0.2);
  border-radius: 8px;
}

.upload-zone {
  border: 2px dashed rgba(112, 164, 178, 0.4);
  border-radius: 8px;
  transition: all 0.2s;
  cursor: pointer;
}

.upload-zone:hover {
  border-color: #70A4B2;
  background: rgba(112, 164, 178, 0.1);
}

.reg-value {
  font-family: 'JetBrains Mono', monospace;
  color: #B8D058;
}

.flag-bit {
  display: inline-flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
}

.flag-set { background: #B8D058; color: #1A1A2E; }
.flag-clear { background: rgba(112,164,178,0.2); color: #6B6B6B; }

.channel-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.channel-on { background: #B8D058; box-shadow: 0 0 6px #B8D058; }
.channel-off { background: #3A3A3A; }

@media (max-width: 1024px) {
  .desktop-sidebar { display: none !important; }
  .mobile-controls { display: block !important; }
}

@media (min-width: 1025px) {
  .mobile-controls { display: none !important; }
}