:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #0d1117;
  --bg-panel: #111318;
  --bg-input: #0b0e14;
  --green: #00ff41;
  --green-dim: #00cc33;
  --green-glow: rgba(0, 255, 65, 0.3);
  --amber: #ffb000;
  --amber-dim: #cc8e00;
  --amber-glow: rgba(255, 176, 0, 0.3);
  --red: #ff4444;
  --red-glow: rgba(255, 68, 68, 0.3);
  --text-primary: #c9d1d9;
  --text-dim: #484f58;
  --text-muted: #30363d;
  --border: #21262d;
  --highlight-line: rgba(0, 255, 65, 0.07);
  --yellow-flash: rgba(255, 220, 0, 0.4);
}

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

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Fira Code', 'JetBrains Mono', monospace;
  overflow-x: hidden;
}

/* CRT scanline overlay */
.crt-overlay {
  pointer-events: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 9999;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
}

.crt-vignette {
  pointer-events: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 9998;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, 0.4) 100%);
}

/* Glow text */
.glow-green {
  color: var(--green);
  text-shadow: 0 0 10px var(--green-glow), 0 0 20px var(--green-glow), 0 0 40px rgba(0, 255, 65, 0.1);
}

.glow-amber {
  color: var(--amber);
  text-shadow: 0 0 10px var(--amber-glow), 0 0 20px var(--amber-glow);
}

/* LED indicators */
.led {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  transition: all 0.2s ease;
}

.led-on {
  background: var(--green);
  box-shadow: 0 0 6px var(--green), 0 0 12px var(--green-glow);
}

.led-off {
  background: #1a2a1a;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* Register flash animation */
@keyframes regFlash {
  0% { background: var(--yellow-flash); }
  100% { background: transparent; }
}

.reg-flash {
  animation: regFlash 0.6s ease-out;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

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

.cursor-blink {
  animation: blink 1s step-end infinite;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.fade-in {
  animation: fadeIn 0.3s ease-in;
}

/* Panel borders with glow */
.panel-border {
  border: 1px solid var(--border);
  box-shadow: 0 0 1px rgba(0, 255, 65, 0.1), inset 0 0 1px rgba(0, 255, 65, 0.05);
}

/* Code editor line highlight */
.line-highlight {
  background: var(--highlight-line);
  border-left: 3px solid var(--green);
}

/* Control buttons */
.ctrl-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-primary);
  font-family: 'Fira Code', monospace;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  border-radius: 4px;
}

.ctrl-btn:hover {
  border-color: var(--green);
  box-shadow: 0 0 8px var(--green-glow);
  color: var(--green);
}

.ctrl-btn:active {
  transform: scale(0.97);
}

.ctrl-btn-run {
  border-color: var(--green-dim);
  color: var(--green);
}

.ctrl-btn-stop {
  border-color: #661111;
  color: var(--red);
}

.ctrl-btn-stop:hover {
  border-color: var(--red);
  box-shadow: 0 0 8px var(--red-glow);
}

/* Textarea styling */
.code-textarea {
  background: transparent;
  color: transparent;
  caret-color: var(--green);
  font-family: 'Fira Code', monospace;
  font-size: 13px;
  line-height: 22px;
  resize: none;
  border: none;
  outline: none;
  width: 100%;
  padding: 0;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
  tab-size: 4;
}

.code-display {
  font-family: 'Fira Code', monospace;
  font-size: 13px;
  line-height: 22px;
  white-space: pre;
  pointer-events: none;
}

/* Speed slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--green);
  cursor: pointer;
  box-shadow: 0 0 6px var(--green-glow);
}

select {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  font-family: 'Fira Code', monospace;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  outline: none;
  cursor: pointer;
}

select:focus {
  border-color: var(--green);
}

/* Tooltip */
.tooltip-container {
  position: relative;
}

.tooltip-text {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #1c2128;
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 10px;
  white-space: nowrap;
  z-index: 100;
  border: 1px solid var(--border);
  transition: opacity 0.2s;
  margin-bottom: 4px;
}

.tooltip-container:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

@media (max-width: 900px) {
  .desktop-layout {
    flex-direction: column !important;
  }
  .left-panel, .right-panel {
    width: 100% !important;
    max-width: 100% !important;
  }
}