:root {
  --bg-dark: #0f0f1a;
  --panel-bg: #1a1a2e;
  --amber: #f0c040;
  --green: #33ff33;
  --red: #ff4444;
  --text: #e0e0e0;
  --key-beige: #d4c5a0;
  --key-border: #8b7d5e;
}

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

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

body::before {
  content:'';
  position:fixed;
  inset:0;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events:none;
  z-index:0;
}

#root { position:relative; z-index:1; }

.crt-screen {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 40px rgba(51,255,51,0.08), inset 0 0 60px rgba(0,0,0,0.6);
}

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

.crt-scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 1px,
    rgba(0,0,0,0.15) 1px,
    rgba(0,0,0,0.15) 2px
  );
  pointer-events: none;
  z-index: 2;
}

.crt-curvature {
  position: absolute;
  inset: 0;
  border-radius: 18px;
  box-shadow: inset 0 0 100px rgba(0,0,0,0.5);
  pointer-events: none;
  z-index: 3;
}

.crt-bloom {
  position: absolute;
  inset: -2px;
  border-radius: 20px;
  box-shadow: 0 0 20px rgba(51,255,51,0.1), 0 0 60px rgba(51,255,51,0.05);
  pointer-events: none;
  z-index: 1;
}

.power-led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  transition: all 0.3s;
}
.power-led.off {
  background: #661111;
  box-shadow: 0 0 4px #661111;
}
.power-led.on {
  background: #33ff33;
  box-shadow: 0 0 8px #33ff33, 0 0 16px rgba(51,255,51,0.4);
  animation: led-pulse 2s ease-in-out infinite;
}

@keyframes led-pulse {
  0%,100% { box-shadow: 0 0 8px #33ff33, 0 0 16px rgba(51,255,51,0.4); }
  50% { box-shadow: 0 0 12px #33ff33, 0 0 24px rgba(51,255,51,0.6); }
}

.retro-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 700;
  font-size: 11px;
  padding: 8px 14px;
  border: 2px solid #555;
  border-radius: 4px;
  background: linear-gradient(180deg, #3a3a4e 0%, #2a2a3e 100%);
  color: var(--text);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: all 0.1s;
  box-shadow: 0 3px 0 #111, 0 4px 8px rgba(0,0,0,0.3);
  position: relative;
  top: 0;
  user-select: none;
}
.retro-btn:active {
  top: 3px;
  box-shadow: 0 0 0 #111, 0 1px 4px rgba(0,0,0,0.3);
}
.retro-btn:hover {
  border-color: var(--amber);
  color: var(--amber);
}
.retro-btn.active-btn {
  border-color: var(--green);
  color: var(--green);
  background: linear-gradient(180deg, #2a3a2e 0%, #1a2a1e 100%);
}

.oric-key {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  min-width: 38px;
  height: 34px;
  border: 2px solid var(--key-border);
  border-radius: 4px;
  background: linear-gradient(180deg, #e0d4b0 0%, #c8bc96 100%);
  color: #333;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.05s;
  box-shadow: 0 3px 0 #6b5f43, 0 4px 6px rgba(0,0,0,0.2);
  position: relative;
  top: 0;
  user-select: none;
  padding: 0 4px;
}
.oric-key:active, .oric-key.pressed {
  top: 3px;
  box-shadow: 0 0 0 #6b5f43, 0 1px 2px rgba(0,0,0,0.2);
  background: linear-gradient(180deg, #b8ac8a 0%, #a89c7a 100%);
}
.oric-key.sticky-active {
  background: linear-gradient(180deg, #f0c040 0%, #d4a830 100%);
  border-color: #c89820;
  color: #1a1a2e;
}

.drop-zone {
  border: 2px dashed #555;
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  transition: all 0.3s;
  cursor: pointer;
  background: rgba(26,26,46,0.6);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--amber);
  background: rgba(240,192,64,0.05);
}

.debug-panel {
  background: rgba(0,0,0,0.7);
  border: 1px solid #333;
  border-radius: 6px;
  padding: 10px;
  font-size: 11px;
}

.reg-value {
  font-family: 'IBM Plex Mono', monospace;
  color: var(--green);
  background: #0a0a15;
  padding: 2px 6px;
  border-radius: 2px;
  font-size: 12px;
}

.flag-led {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 700;
  border: 1px solid #444;
}
.flag-led.on { background: var(--green); color: #000; }
.flag-led.off { background: #222; color: #555; }

.matrix-cell {
  width: 32px;
  height: 24px;
  border: 1px solid #333;
  font-size: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  transition: background 0.1s;
  margin: 1px;
}
.matrix-cell.active {
  background: rgba(51,255,51,0.35);
  border-color: var(--green);
  color: #fff;
  font-weight: bold;
}
.matrix-cell.col-sel {
  border-bottom: 2px solid var(--amber);
}
.matrix-cell.row-sel {
  border-left: 2px solid var(--amber);
}
.matrix-cell.scan-point {
  background: rgba(240,192,64,0.25);
  border: 2px solid var(--amber);
  box-shadow: 0 0 6px rgba(240,192,64,0.3);
}
.matrix-cell.active.scan-point {
  background: rgba(51,255,51,0.5);
  border: 2px solid var(--green);
  box-shadow: 0 0 10px rgba(51,255,51,0.5);
}

.warmup-overlay {
  position: absolute;
  inset: 0;
  background: #000;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}
.warmup-line {
  width: 100%;
  height: 2px;
  background: rgba(200,200,200,0.8);
  animation: warmup 0.8s ease-out forwards;
}
@keyframes warmup {
  0% { transform: scaleX(0) scaleY(1); opacity: 1; }
  50% { transform: scaleX(1) scaleY(1); opacity: 1; }
  80% { transform: scaleX(1) scaleY(50); opacity: 0.8; }
  100% { transform: scaleX(1) scaleY(200); opacity: 0; }
}

.header-scanline {
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 2px,
    rgba(240,192,64,0.03) 2px,
    rgba(240,192,64,0.03) 4px
  );
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #0a0a15; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }