:root {
  --bg-deep: #0d0d1a;
  --bg-panel: #12122a;
  --bezel-light: #8B7355;
  --bezel-dark: #4a3a25;
  --cyan: #00ffff;
  --magenta: #ff00ff;
  --green-phosphor: #33ff33;
  --amber: #ffaa00;
  --key-bg: #2a2a3a;
  --key-special: #c44;
  --key-border: #444;
}

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

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

body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at 30% 20%, rgba(0,255,255,0.03) 0%, transparent 50%),
              radial-gradient(ellipse at 70% 80%, rgba(255,0,255,0.02) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ===== BLINKING CURSOR - CRITICAL ===== */
@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.blink-cursor {
  animation: blink 1s step-end infinite;
  color: var(--green-phosphor);
  font-size: inherit;
  line-height: 1;
  display: inline-block;
  vertical-align: baseline;
}

/* ===== CRT SCREEN ===== */
.crt-screen {
  position: relative;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  box-shadow:
    0 0 30px rgba(51, 255, 51, 0.15),
    0 0 60px rgba(51, 255, 51, 0.05),
    inset 0 0 80px rgba(0,0,0,0.5);
}

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

.crt-screen::after {
  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;
}

/* ===== MONITOR BEZEL ===== */
.monitor-bezel {
  background: linear-gradient(145deg, #8B7355 0%, #6B5335 40%, #4a3a25 100%);
  border-radius: 20px;
  padding: 20px;
  box-shadow:
    0 8px 32px rgba(0,0,0,0.6),
    inset 0 1px 0 rgba(255,255,255,0.15),
    inset 0 -2px 0 rgba(0,0,0,0.3);
  position: relative;
}

.monitor-bezel::before {
  content: 'ORIC ATMOS';
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: rgba(255,255,255,0.3);
  letter-spacing: 3px;
}

/* ===== KEYBOARD KEYS ===== */
.key-btn {
  background: linear-gradient(180deg, #3a3a4a 0%, #2a2a3a 60%, #222235 100%);
  border: 1px solid #555;
  border-bottom: 3px solid #333;
  border-radius: 5px;
  color: #eee;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.05s ease;
  user-select: none;
  -webkit-user-select: none;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 2px 6px;
}

.key-btn:active, .key-btn.pressed {
  background: linear-gradient(180deg, #222235 0%, #3a3a5a 100%);
  border-bottom: 1px solid #333;
  transform: translateY(2px);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.4), 0 0 8px rgba(0,255,255,0.3);
}

.key-btn.special {
  background: linear-gradient(180deg, #b83030 0%, #8a2020 60%, #6a1515 100%);
  border-color: #c44;
  border-bottom-color: #611;
  color: #fff;
}

.key-btn.special:active, .key-btn.special.pressed {
  background: linear-gradient(180deg, #6a1515 0%, #b83030 100%);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.4), 0 0 8px rgba(255,0,255,0.3);
}

/* ===== CONTROL BUTTONS ===== */
.ctrl-btn {
  background: linear-gradient(180deg, #444 0%, #333 50%, #222 100%);
  border: 1px solid #555;
  border-bottom: 3px solid #222;
  border-radius: 6px;
  color: #ddd;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 16px;
  cursor: pointer;
  transition: all 0.1s;
  user-select: none;
  white-space: nowrap;
}

.ctrl-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: 0 0 8px rgba(0,255,255,0.2);
}

.ctrl-btn:active {
  transform: translateY(2px);
  border-bottom-width: 1px;
}

.ctrl-btn.active {
  border-color: var(--magenta);
  color: var(--magenta);
  box-shadow: 0 0 12px rgba(255,0,255,0.3);
}

/* ===== STATUS LED ===== */
.led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 6px currentColor;
}

.led.green { background: #33ff33; color: #33ff33; }
.led.red { background: #ff3333; color: #ff3333; }
.led.yellow { background: #ffaa00; color: #ffaa00; }

/* ===== DEBUG PANEL ===== */
.debug-panel {
  background: rgba(12, 12, 30, 0.95);
  border: 1px solid rgba(0,255,255,0.2);
  border-radius: 8px;
  padding: 12px;
  font-size: 11px;
  line-height: 1.6;
  max-height: 500px;
  overflow-y: auto;
}

.debug-panel::-webkit-scrollbar { width: 6px; }
.debug-panel::-webkit-scrollbar-track { background: #111; }
.debug-panel::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }

.register-val {
  color: var(--cyan);
  font-weight: 700;
}

.flag-on {
  color: var(--green-phosphor);
  font-weight: 800;
  text-shadow: 0 0 4px rgba(51,255,51,0.5);
  padding: 2px 4px;
  border-radius: 2px;
  background: rgba(51,255,51,0.1);
}

.flag-off {
  color: #444;
  padding: 2px 4px;
}

.hex-dump {
  font-size: 10px;
  line-height: 1.5;
  white-space: pre;
  color: #999;
}

.hex-dump .addr { color: var(--amber); }
.hex-dump .ascii { color: var(--magenta); }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: rgba(0,255,255,0.15);
  border: 1px solid var(--cyan);
  color: var(--cyan);
  padding: 12px 20px;
  border-radius: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  z-index: 1000;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  backdrop-filter: blur(8px);
}

@keyframes toastIn { from { transform: translateX(100px); opacity:0; } to { transform: translateX(0); opacity:1; } }
@keyframes toastOut { from { opacity:1; } to { opacity:0; transform: translateY(-20px); } }

/* ===== MEMORY MAP ===== */
.memory-map-bar {
  width: 20px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #444;
}

.disasm-line { padding: 1px 4px; border-radius: 2px; }
.disasm-line.current { background: rgba(0,255,255,0.15); color: var(--cyan); }

/* ===== CANVAS BLINK ===== */
@keyframes canvasBlink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .monitor-bezel { padding: 10px; border-radius: 12px; }
  .key-btn { min-width: 26px; height: 28px; font-size: 9px; }
  .ctrl-btn { padding: 6px 10px; font-size: 10px; }
}