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

:root {
  --green: #33FF33;
  --amber: #FFB000;
  --phosphor: var(--green);
  --bg-dark: #0d0d0d;
  --bg-panel: #1a1a1a;
  --bg-lighter: #252525;
  --bg-input: #2a2a2a;
  --border: #3a3a3a;
  --text: #aaaaaa;
  --text-bright: #cccccc;
}

body {
  background: var(--bg-dark);
  color: var(--text);
  font-family: 'Courier New', Consolas, monospace;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 10px;
}

#pet-container {
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
}

#title-bar {
  text-align: center;
  padding: 16px 0 8px;
}

#title-bar h1 {
  font-family: 'Press Start 2P', monospace;
  font-size: 18px;
  color: var(--text-bright);
  letter-spacing: 2px;
  text-shadow: 0 0 10px rgba(51, 255, 51, 0.3);
}

#rainbow-stripe {
  height: 4px;
  margin: 8px auto;
  max-width: 500px;
  background: linear-gradient(90deg, 
    #e44 0%, #e44 14%, 
    #ea4 14%, #ea4 28%, 
    #ee4 28%, #ee4 42%, 
    #4e4 42%, #4e4 57%, 
    #48e 57%, #48e 71%, 
    #84e 71%, #84e 85%, 
    #e4e 85%, #e4e 100%
  );
  border-radius: 2px;
}

#status-bar {
  display: flex;
  justify-content: center;
  gap: 24px;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: var(--phosphor);
  padding: 6px 0;
}

#monitor-housing {
  background: #1c1c1c;
  border-radius: 16px;
  padding: 20px;
  margin: 8px 0;
  border: 3px solid #2a2a2a;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.8), 0 4px 20px rgba(0,0,0,0.5);
}

#crt-bezel {
  background: #111;
  border-radius: 12px;
  padding: 12px;
  border: 2px solid #333;
}

#screen-container {
  position: relative;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 
    0 0 20px rgba(51, 255, 51, 0.15),
    0 0 60px rgba(51, 255, 51, 0.05),
    inset 0 0 40px rgba(0,0,0,0.5);
}

#screen-container.amber {
  box-shadow: 
    0 0 20px rgba(255, 176, 0, 0.15),
    0 0 60px rgba(255, 176, 0, 0.05),
    inset 0 0 40px rgba(0,0,0,0.5);
}

#screen {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
}

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

#controls-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin: 8px 0;
}

#power-controls {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.retro-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  padding: 8px 14px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: #111;
  background: #999;
  border-top: 2px solid #bbb;
  border-left: 2px solid #bbb;
  border-bottom: 2px solid #555;
  border-right: 2px solid #555;
  transition: all 0.1s;
  white-space: nowrap;
}
.retro-btn:hover { background: #aaa; }
.retro-btn:active {
  border-top: 2px solid #555;
  border-left: 2px solid #555;
  border-bottom: 2px solid #bbb;
  border-right: 2px solid #bbb;
  transform: translateY(1px);
}

.power-btn { background: #4a4; color: #fff; border-top-color: #6c6; border-left-color: #6c6; border-bottom-color: #282; border-right-color: #282; }
.reset-btn { background: #aa4; color: #111; border-top-color: #cc6; border-left-color: #cc6; border-bottom-color: #882; border-right-color: #882; }
.off-btn { background: #a44; color: #fff; border-top-color: #c66; border-left-color: #c66; border-bottom-color: #822; border-right-color: #822; }

.sm-btn { font-size: 7px; padding: 5px 10px; }
.bulk-btn { font-size: 8px; padding: 8px 16px; display: inline-block; }

#settings-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
}

#settings-row label {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: var(--text);
}

.dip-switches { display: flex; gap: 4px; margin-top: 4px; }

.dip-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  padding: 4px 8px;
  border: 1px solid #555;
  background: #333;
  color: #888;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s;
}
.dip-btn.active {
  background: var(--phosphor);
  color: #000;
  border-color: var(--phosphor);
  box-shadow: 0 0 6px var(--phosphor);
}
.dip-btn:hover { border-color: #777; }

.warn-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  color: #e44;
  display: block;
  margin-top: 3px;
}

#speed-control {
  display: flex;
  align-items: center;
  gap: 6px;
}

#speed-slider {
  width: 80px;
  accent-color: var(--phosphor);
}
#speed-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: var(--phosphor);
  min-width: 35px;
}

/* Keyboard */
#keyboard-container {
  background: #2a2a2a;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin: 8px 0;
}

#virtual-keyboard {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 100%;
}

.kb-row {
  display: flex;
  gap: 3px;
  justify-content: center;
  align-items: stretch;
}

.kb-key {
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  padding: 6px 4px;
  min-width: 28px;
  min-height: 28px;
  border: none;
  border-radius: 4px;
  background: #d4d0c8;
  color: #222;
  cursor: pointer;
  border-top: 2px solid #f0ece4;
  border-left: 2px solid #f0ece4;
  border-bottom: 2px solid #908c84;
  border-right: 2px solid #908c84;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.2;
  transition: all 0.05s;
  flex-shrink: 1;
  overflow: hidden;
}

.kb-key:active, .kb-key.pressed {
  background: #a0a0a0;
  border-top-color: #666;
  border-left-color: #666;
  border-bottom-color: #ccc;
  border-right-color: #ccc;
  transform: translateY(1px);
}

.kb-key.wide { min-width: 50px; font-size: 5px; }
.kb-key.space { min-width: 140px; }
.kb-key.numpad { background: #c8c4bc; }
.kb-key.kb-sep { width: 8px; min-width: 8px; background: transparent; border: none; cursor: default; pointer-events: none; }

/* Panels */
.panel-section {
  margin: 8px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.panel-header {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  padding: 10px 14px;
  background: var(--bg-lighter);
  color: var(--phosphor);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.panel-header:hover { background: #2f2f2f; }

.panel-body {
  background: var(--bg-panel);
  padding: 12px;
  transition: max-height 0.3s ease;
  overflow: hidden;
}
.panel-body.collapsed {
  max-height: 0;
  padding: 0 12px;
}

#rom-slots {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.rom-slot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--bg-input);
  border-radius: 4px;
  font-size: 10px;
  flex-wrap: wrap;
}

.rom-slot .rom-name {
  font-family: 'Courier New', monospace;
  color: var(--phosphor);
  min-width: 200px;
  font-size: 9px;
}

.rom-slot .rom-addr {
  color: #888;
  font-size: 9px;
  min-width: 100px;
}

.rom-slot .rom-status {
  font-size: 12px;
  min-width: 20px;
  text-align: center;
}

.rom-slot label {
  margin-left: auto;
}

.periph-section {
  margin-bottom: 14px;
  padding: 10px;
  background: var(--bg-input);
  border-radius: 6px;
}

.periph-section h3 {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: var(--phosphor);
  margin-bottom: 8px;
}

.periph-status {
  font-size: 10px;
  color: #888;
  margin: 6px 0;
  font-family: 'Courier New', monospace;
}

.periph-section select {
  background: #333;
  color: var(--phosphor);
  border: 1px solid #555;
  padding: 2px 6px;
  font-family: monospace;
  border-radius: 3px;
}

/* Debug */
#debug-registers, #debug-disasm {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: var(--phosphor);
  padding: 8px;
  background: #111;
  border-radius: 4px;
  margin-bottom: 8px;
  white-space: pre;
  overflow-x: auto;
}

#debug-controls {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

#debug-memory {
  margin-top: 8px;
}

.hex-input {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  width: 50px;
  background: #222;
  color: var(--phosphor);
  border: 1px solid #555;
  padding: 3px 5px;
  border-radius: 3px;
  text-transform: uppercase;
}

#mem-dump {
  font-family: 'Courier New', monospace;
  font-size: 10px;
  color: var(--phosphor);
  background: #111;
  padding: 8px;
  border-radius: 4px;
  margin-top: 6px;
  overflow-x: auto;
  max-height: 200px;
  overflow-y: auto;
}

#paste-bar {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 8px 0;
}

footer {
  text-align: center;
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #555;
  padding: 16px 0;
}
footer a { color: var(--phosphor); text-decoration: none; }
footer a:hover { text-decoration: underline; }

#bulk-upload-area {
  text-align: center;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

#bulk-status {
  font-size: 10px;
  color: var(--phosphor);
  margin-top: 6px;
  font-family: 'Courier New', monospace;
}

/* Responsive */
@media (max-width: 600px) {
  #title-bar h1 { font-size: 11px; }
  .kb-key { min-width: 20px; min-height: 22px; font-size: 5px; padding: 3px 2px; }
  .kb-key.wide { min-width: 36px; }
  .kb-key.space { min-width: 80px; }
  #status-bar { font-size: 6px; gap: 10px; }
  .rom-slot .rom-name { min-width: 120px; font-size: 7px; }
  .rom-slot .rom-addr { min-width: 70px; font-size: 7px; }
}