:root {
  --crt-green: #33ff33;
  --crt-amber: #ffaa00;
  --crt-buff: #ffcc88;
  --bg-dark: #111111;
  --panel-bg: #1a1a1a;
  --panel-border: #333333;
  --btn-red: #cc0000;
  --btn-yellow: #ccaa00;
  --highlight: #ffff00;
}

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

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

.font-pixel { font-family: 'Press Start 2P', monospace; }
.font-vt { font-family: 'VT323', monospace; }

/* Woodgrain top bar */
.woodgrain-bar {
  background: linear-gradient(180deg, 
    #8B7355 0%, #6B5B45 15%, #7D6B52 30%, 
    #5C4B38 50%, #7D6B52 65%, #6B5B45 85%, #8B7355 100%);
  background-size: 100% 8px;
  position: relative;
  overflow: hidden;
}

.woodgrain-bar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent 0px, transparent 3px,
    rgba(0,0,0,0.05) 3px, rgba(0,0,0,0.05) 6px
  );
}

/* CRT Monitor housing */
.crt-housing {
  background: linear-gradient(145deg, #2a2a2a 0%, #1a1a1a 50%, #0d0d0d 100%);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 
    0 0 0 3px #333,
    0 0 0 6px #1a1a1a,
    inset 0 0 30px rgba(0,0,0,0.5),
    0 10px 40px rgba(0,0,0,0.8);
  position: relative;
}

.crt-bezel {
  background: #0a0a0a;
  border-radius: 12px;
  padding: 8px;
  position: relative;
  overflow: hidden;
}

/* CRT Screen Effects */
.crt-screen {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
}

.crt-screen canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  width: 100%;
  border-radius: 4px;
}

.crt-screen::before {
  content: '';
  position: absolute;
  inset: 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;
  border-radius: 4px;
}

.crt-screen::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at center,
    transparent 60%,
    rgba(0,0,0,0.4) 100%
  );
  pointer-events: none;
  z-index: 3;
  border-radius: 4px;
}

.crt-glow {
  filter: brightness(1.05) contrast(1.1);
  animation: flicker 0.05s infinite alternate;
}

@keyframes flicker {
  0% { opacity: 0.98; }
  100% { opacity: 1.0; }
}

/* Panels */
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
}

.panel-header {
  cursor: pointer;
  user-select: none;
  padding: 8px 12px;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Big RUN button */
.btn-run {
  background: linear-gradient(180deg, #ee2222 0%, #aa0000 100%);
  color: white;
  border: 3px solid #880000;
  border-radius: 8px;
  padding: 12px 32px;
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 4px 0 #660000, 0 6px 12px rgba(0,0,0,0.4);
  transition: all 0.05s;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.btn-run:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #660000, 0 2px 4px rgba(0,0,0,0.4);
}

.btn-run:hover {
  background: linear-gradient(180deg, #ff3333 0%, #cc0000 100%);
}

.btn-reset {
  background: linear-gradient(180deg, #ddaa00 0%, #aa8800 100%);
  color: #333;
  border: 2px solid #886600;
  border-radius: 6px;
  padding: 8px 16px;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  cursor: pointer;
  box-shadow: 0 3px 0 #664400;
  transition: all 0.05s;
}

.btn-reset:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #664400;
}

.btn-ctrl {
  background: linear-gradient(180deg, #444 0%, #222 100%);
  color: #ccc;
  border: 2px solid #555;
  border-radius: 6px;
  padding: 8px 16px;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  cursor: pointer;
  box-shadow: 0 3px 0 #111;
  transition: all 0.05s;
}

.btn-ctrl:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #111;
}

.btn-ctrl:hover {
  background: linear-gradient(180deg, #555 0%, #333 100%);
}

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

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

/* Register display */
.reg-val {
  font-family: 'VT323', monospace;
  font-size: 20px;
  padding: 2px 6px;
  background: #0a0a0a;
  border: 1px solid #333;
  border-radius: 3px;
  min-width: 60px;
  display: inline-block;
  text-align: right;
}

.reg-changed {
  animation: regFlash 0.5s ease-out;
}

@keyframes regFlash {
  0% { color: #ffff00; background: #333300; }
  100% { color: var(--crt-green); background: #0a0a0a; }
}

/* Memory hex dump */
.hex-dump {
  font-family: 'VT323', monospace;
  font-size: 16px;
  line-height: 1.4;
  white-space: pre;
  overflow-x: auto;
}

.hex-dump .addr { color: #888; }
.hex-dump .byte { color: var(--crt-green); }
.hex-dump .byte-program { color: #66ccff; }
.hex-dump .byte-pc { color: #ffff00; background: #333300; }
.hex-dump .ascii { color: #666; }

/* Speed slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: #333;
  height: 6px;
  border-radius: 3px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--crt-green);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #1a1a1a;
}

/* Toast */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: 8px;
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  z-index: 1000;
  animation: toastIn 0.3s ease-out, toastOut 0.3s ease-in 2.7s forwards;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

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

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

/* Progress bar */
.progress-bar {
  height: 16px;
  background: #0a0a0a;
  border: 1px solid #333;
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--crt-green);
  transition: width 0.3s;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 4px;
  font-size: 10px;
  font-family: 'VT323', monospace;
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #111; }
::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* Instruction log */
.instruction-log {
  max-height: 200px;
  overflow-y: auto;
  font-family: 'VT323', monospace;
  font-size: 15px;
  background: #0a0a0a;
  padding: 8px;
  border-radius: 4px;
}

/* Tandy badge */
.tandy-badge {
  background: linear-gradient(180deg, #cc0000 0%, #990000 100%);
  color: white;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  padding: 3px 8px;
  border-radius: 3px;
  letter-spacing: 2px;
}

/* On-screen keyboard */
.kb-key {
  background: linear-gradient(180deg, #555 0%, #333 100%);
  color: #ddd;
  border: 1px solid #666;
  border-radius: 4px;
  padding: 4px 6px;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  cursor: pointer;
  min-width: 28px;
  text-align: center;
  transition: all 0.05s;
  user-select: none;
}

.kb-key:active, .kb-key.pressed {
  background: linear-gradient(180deg, #333 0%, #222 100%);
  transform: translateY(1px);
  color: var(--crt-green);
}

.kb-key-wide { min-width: 60px; }
.kb-key-space { min-width: 180px; }

/* Oscilloscope */
.oscilloscope {
  background: #0a0a0a;
  border: 2px solid #333;
  border-radius: 4px;
}

/* Footer */
.retro-footer a {
  color: var(--crt-green);
  text-decoration: none;
  font-family: 'VT323', monospace;
  font-size: 16px;
}

.retro-footer a:hover {
  text-shadow: 0 0 8px var(--crt-green);
}