:root {
  --bg-deep: #0a0a1a;
  --bg-panel: #111128;
  --bg-panel-alt: #161638;
  --green-glow: #33ff66;
  --amber: #ffaa33;
  --amber-dim: #cc8822;
  --blue-accent: #4488ff;
  --red-accent: #ff4444;
  --crt-green: #33ff66;
  --text-dim: #667788;
  --border-color: #222244;
}

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

body {
  background: var(--bg-deep);
  color: #ccddee;
  font-family: 'IBM Plex Mono', monospace;
  min-height: 100vh;
  overflow-x: hidden;
}

.font-pixel { font-family: 'Press Start 2P', monospace; }
.font-mono { font-family: 'IBM Plex Mono', monospace; }

/* CRT Screen Effect */
.crt-screen {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  box-shadow:
    0 0 60px rgba(51, 255, 102, 0.08),
    inset 0 0 40px rgba(0,0,0,0.6),
    0 0 2px rgba(51, 255, 102, 0.3);
  background: #000;
}

.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-bezel {
  background: linear-gradient(145deg, #1a1a2e, #0d0d1a);
  border: 3px solid #2a2a4a;
  border-radius: 20px;
  padding: 12px;
  box-shadow:
    0 8px 32px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.05);
}

/* Keyboard Styles */
.key-cap {
  background: linear-gradient(180deg, #3a3a4a 0%, #2a2a3a 100%);
  border: 1px solid #4a4a5a;
  border-bottom: 3px solid #1a1a2a;
  border-radius: 4px;
  color: #ddd;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: all 0.05s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 2px 6px;
}

.key-cap:active, .key-cap.pressed {
  background: linear-gradient(180deg, #2a2a3a 0%, #3a3a5a 100%);
  border-bottom: 1px solid #4a4a5a;
  transform: translateY(2px);
  box-shadow: 0 0 8px rgba(51, 255, 102, 0.3);
  color: var(--green-glow);
}

.key-cap.modifier {
  background: linear-gradient(180deg, #4a2a2a 0%, #3a1a1a 100%);
  border-color: #5a3a3a;
  min-width: 56px;
}

.key-cap.space-bar {
  min-width: 200px;
}

/* Retro Button */
.retro-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  padding: 8px 16px;
  border: 2px solid;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.1s;
  text-transform: uppercase;
}

.retro-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.retro-btn:active {
  transform: translateY(1px);
}

/* LED indicator */
.led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.led.green { background: #33ff66; box-shadow: 0 0 6px #33ff66; }
.led.amber { background: #ffaa33; box-shadow: 0 0 6px #ffaa33; }
.led.blue { background: #4488ff; box-shadow: 0 0 6px #4488ff; }
.led.off { background: #333; box-shadow: none; }

/* Blink animation */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.blink { animation: blink 1s infinite; }

@keyframes blink-slow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.blink-slow { animation: blink-slow 2s infinite; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: #333366; border-radius: 3px; }

/* Drop zone */
.drop-zone {
  border: 2px dashed #444466;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
}

.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--amber);
  background: rgba(255, 170, 51, 0.05);
}

/* Hex view */
.hex-byte {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  display: inline-block;
  width: 22px;
  text-align: center;
}

.hex-byte.changed {
  color: var(--amber);
  animation: flash 0.5s;
}

@keyframes flash {
  0% { background: rgba(255, 170, 51, 0.3); }
  100% { background: transparent; }
}

/* Panel styling */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
}

.panel-header {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: var(--amber);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Toggle switch */
.toggle-switch {
  width: 48px;
  height: 24px;
  background: #2a2a3a;
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  border: 2px solid #444;
  transition: all 0.2s;
}

.toggle-switch.on {
  background: #1a3a1a;
  border-color: var(--green-glow);
}

.toggle-switch::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  background: #666;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: all 0.2s;
}

.toggle-switch.on::after {
  left: 26px;
  background: var(--green-glow);
  box-shadow: 0 0 8px var(--green-glow);
}

/* Canvas pixel rendering */
canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Responsive */
@media (max-width: 1200px) {
  .main-layout {
    flex-direction: column !important;
  }
}

/* Help modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.8);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--bg-panel);
  border: 2px solid var(--amber);
  border-radius: 12px;
  padding: 24px;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  width: 90%;
}