@font-face {
  font-family: 'DotMatrix';
  src: local('Courier New');
}

:root {
  --bezel-color: #C8B88A;
  --bezel-dark: #A89868;
  --bezel-light: #D8CCA0;
  --screen-bg: #0a0a0a;
  --cga-green: #00AA00;
  --cga-cyan: #00AAAA;
  --cga-red: #AA0000;
  --cga-magenta: #AA00AA;
  --cga-white: #AAAAAA;
  --cga-bright-white: #FFFFFF;
  --cga-yellow: #FFFF55;
}

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

body {
  background: #111;
  font-family: 'IBM Plex Mono', monospace;
  color: #aaa;
  overflow-x: hidden;
}

.monitor-frame {
  background: linear-gradient(145deg, var(--bezel-light) 0%, var(--bezel-color) 30%, var(--bezel-dark) 100%);
  border-radius: 16px;
  padding: 24px 28px 32px 28px;
  box-shadow:
    0 8px 32px rgba(0,0,0,0.6),
    inset 0 1px 0 rgba(255,255,255,0.3),
    inset 0 -2px 4px rgba(0,0,0,0.2);
  position: relative;
}

.monitor-inner {
  background: #000;
  border-radius: 12px;
  padding: 8px;
  box-shadow:
    inset 0 0 30px rgba(0,0,0,0.8),
    inset 0 0 4px rgba(0,0,0,0.9);
  position: relative;
  overflow: hidden;
}

.screen-container {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
}

.scanlines {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 2px,
    rgba(0,0,0,0.15) 2px,
    rgba(0,0,0,0.15) 4px
  );
  pointer-events: none;
  z-index: 2;
}

.screen-curve {
  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;
}

.phosphor-glow {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  box-shadow: inset 0 0 60px rgba(0, 170, 0, 0.03);
  pointer-events: none;
  z-index: 1;
}

.power-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #333;
  box-shadow: none;
  transition: all 0.3s;
}

.power-led.on {
  background: #00ff00;
  box-shadow: 0 0 6px #00ff00, 0 0 12px rgba(0,255,0,0.4);
}

.floppy-led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #333;
  transition: all 0.15s;
}

.floppy-led.active {
  background: #ffaa00;
  box-shadow: 0 0 4px #ffaa00, 0 0 8px rgba(255,170,0,0.5);
  animation: floppyBlink 0.15s ease-in-out;
}

@keyframes floppyBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.rocker-switch {
  width: 40px;
  height: 24px;
  background: #333;
  border-radius: 4px;
  position: relative;
  cursor: pointer;
  border: 1px solid #555;
  transition: background 0.2s;
}

.rocker-switch.on {
  background: #444;
}

.rocker-switch .toggle {
  width: 18px;
  height: 20px;
  background: linear-gradient(180deg, #888 0%, #666 100%);
  border-radius: 3px;
  position: absolute;
  top: 1px;
  left: 1px;
  transition: left 0.15s;
  border: 1px solid #999;
}

.rocker-switch.on .toggle {
  left: 19px;
}

.printer-paper {
  background: repeating-linear-gradient(
    180deg,
    #f0f8e8 0px,
    #f0f8e8 16px,
    #e8f0d8 16px,
    #e8f0d8 32px
  );
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 8px 12px;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: #222;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 16px;
}

.printer-paper::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 20px;
  background: repeating-linear-gradient(
    180deg,
    transparent 0px,
    transparent 6px,
    #ddd 6px,
    #ddd 8px
  );
}

.control-panel {
  background: linear-gradient(180deg, #2a2a2a 0%, #222 100%);
  border: 1px solid #444;
  border-radius: 8px;
  padding: 12px 16px;
}

.hex-viewer {
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 11px;
  line-height: 1.4;
  color: #00AA00;
  background: #0a0a0a;
  padding: 8px;
  border-radius: 4px;
  overflow-y: auto;
  max-height: 200px;
  white-space: pre;
}

canvas#cga-display {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  width: 100%;
  height: auto;
}

.screen-turnon {
  animation: screenOn 0.8s ease-out forwards;
}

@keyframes screenOn {
  0% { 
    clip-path: inset(49% 0 49% 0);
    filter: brightness(3);
  }
  30% { 
    clip-path: inset(45% 0 45% 0);
    filter: brightness(2);
  }
  100% { 
    clip-path: inset(0 0 0 0);
    filter: brightness(1);
  }
}

.screen-turnoff {
  animation: screenOff 0.5s ease-in forwards;
}

@keyframes screenOff {
  0% { 
    clip-path: inset(0 0 0 0);
    filter: brightness(1);
  }
  60% { 
    clip-path: inset(45% 0 45% 0);
    filter: brightness(2);
  }
  100% { 
    clip-path: inset(50% 0 50% 0);
    filter: brightness(5);
  }
}

.keyboard-indicator {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 3px;
  background: #1a1a1a;
  border: 1px solid #333;
}

.keyboard-indicator.active {
  background: #003300;
  border-color: #00AA00;
  color: #00FF00;
}

.register-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 4px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
}

.reg-item {
  background: #0a0a0a;
  padding: 2px 6px;
  border-radius: 2px;
  color: #00AAAA;
  border: 1px solid #1a3a3a;
}

.reg-item span:first-child {
  color: #888;
}

@media (max-width: 768px) {
  .monitor-frame {
    padding: 12px;
    border-radius: 8px;
  }
  .monitor-inner {
    padding: 4px;
  }
}