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

body {
  background: #0a0a0a;
  color: #d4c5a9;
  font-family: 'VT323', monospace;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 10px;
}

#app {
  max-width: 960px;
  width: 100%;
}

.title {
  font-family: 'Press Start 2P', monospace;
  text-align: center;
  font-size: 20px;
  color: #d4c5a9;
  margin: 16px 0 10px;
  letter-spacing: 3px;
  text-shadow: 0 0 10px rgba(212,197,169,0.3);
}

.monitor-bezel {
  background: linear-gradient(145deg, #c4b599, #a89878);
  border-radius: 20px;
  padding: 22px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.7), inset 0 2px 4px rgba(255,255,255,0.2);
  margin: 0 auto;
  max-width: 700px;
}

.screen-container {
  position: relative;
  background: #001100;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.8), 0 0 20px rgba(51,255,51,0.15);
}

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

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

.screen-glow {
  position: absolute;
  top: -2px; left: -2px; right: -2px; bottom: -2px;
  border-radius: 14px;
  box-shadow: inset 0 0 60px rgba(51,255,51,0.08);
  pointer-events: none;
}

.control-panel {
  max-width: 700px;
  margin: 12px auto 0;
  background: linear-gradient(145deg, #3a3632, #2a2622);
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.control-group {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.power-section { display: flex; align-items: center; gap: 8px; }

.btn-power {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  padding: 8px 16px;
  background: #2a6e2a;
  color: #33ff33;
  border: 2px solid #1a4e1a;
  border-radius: 6px;
  cursor: pointer;
  text-shadow: 0 0 6px rgba(51,255,51,0.5);
  transition: all 0.15s;
}
.btn-power:hover { background: #3a8e3a; }
.btn-power.on { background: #6e2a2a; color: #ff3333; border-color: #4e1a1a; text-shadow: 0 0 6px rgba(255,51,51,0.5); }

.btn-reset {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  padding: 6px 12px;
  background: #5a4a3a;
  color: #d4c5a9;
  border: 2px solid #3a2a1a;
  border-radius: 6px;
  cursor: pointer;
}
.btn-reset:hover { background: #6a5a4a; }

.power-led {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #1a1a1a;
  border: 1px solid #333;
  transition: all 0.3s;
}
.power-led.on {
  background: #33ff33;
  box-shadow: 0 0 8px #33ff33, 0 0 16px rgba(51,255,51,0.4);
}

.control-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #a89878;
  display: block;
  margin-bottom: 4px;
}

.ram-buttons { display: flex; gap: 3px; }

.ram-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  padding: 5px 8px;
  background: #1a1a1a;
  color: #888;
  border: 1px solid #444;
  border-radius: 3px;
  cursor: pointer;
}
.ram-btn.active { background: #2a4a2a; color: #33ff33; border-color: #33ff33; }
.ram-btn:hover { background: #2a2a2a; }

.speed-section { margin-left: auto; text-align: right; }
.speed-display { font-size: 16px; color: #33ff33; display: block; }

.btn-pause {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  padding: 4px 8px;
  background: #3a3a1a;
  color: #cccc33;
  border: 1px solid #666633;
  border-radius: 3px;
  cursor: pointer;
  margin-top: 2px;
}

.panels-container {
  max-width: 700px;
  margin: 12px auto 0;
}

.panel-tabs {
  display: flex;
  gap: 2px;
}

.panel-tab {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  padding: 8px 14px;
  background: #1a1816;
  color: #887766;
  border: none;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  transition: all 0.15s;
}
.panel-tab.active { background: #2a2622; color: #d4c5a9; }
.panel-tab:hover { color: #d4c5a9; }

.panel-content {
  background: #2a2622;
  border-radius: 0 6px 6px 6px;
  padding: 14px;
  min-height: 100px;
}
.panel-content.hidden { display: none; }

.rom-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 14px;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-upload-all {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  padding: 6px 12px;
  background: #2a4a6a;
  color: #66aaff;
  border: 1px solid #3366aa;
  border-radius: 4px;
  cursor: pointer;
}
.btn-upload-all:hover { background: #3a5a7a; }

.rom-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 6px;
}

.rom-slot {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1a1816;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 13px;
}

.rom-slot .rom-status { font-size: 14px; flex-shrink: 0; }
.rom-slot .rom-info { flex: 1; min-width: 0; }
.rom-slot .rom-name { font-size: 11px; color: #d4c5a9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rom-slot .rom-addr { font-size: 11px; color: #888; font-family: 'VT323', monospace; }

.rom-slot label {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  padding: 4px 8px;
  background: #3a3632;
  color: #aaa;
  border: 1px solid #555;
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
}
.rom-slot label:hover { background: #4a4642; }

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.media-card {
  background: #1a1816;
  border-radius: 6px;
  padding: 12px;
  text-align: center;
}
.media-card-wide { grid-column: 1 / -1; }

.media-icon { font-size: 28px; margin-bottom: 4px; }
.media-label { font-size: 12px; color: #d4c5a9; margin-bottom: 8px; }

.btn-media-upload {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  padding: 6px 12px;
  background: #3a3632;
  color: #d4c5a9;
  border: 1px solid #555;
  border-radius: 4px;
  cursor: pointer;
  display: inline-block;
}
.btn-media-upload:hover { background: #4a4642; }

.media-status {
  font-size: 13px;
  color: #888;
  margin-top: 6px;
}
.media-status.loaded { color: #33ff33; }

.btn-run {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  padding: 6px 16px;
  background: #2a6e2a;
  color: #33ff33;
  border: 1px solid #1a4e1a;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 6px;
}
.btn-run:hover { background: #3a8e3a; }
.btn-run:disabled { opacity: 0.4; cursor: not-allowed; }

.debug-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.debug-registers, .debug-disasm, .debug-info, .debug-memory {
  background: #0a0f0a;
  border: 1px solid #1a3a1a;
  border-radius: 4px;
  padding: 8px;
}

.debug-memory { grid-column: 1 / -1; }

.debug-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #33ff33;
  margin-bottom: 6px;
}

.debug-grid pre {
  font-family: 'VT323', monospace;
  font-size: 15px;
  color: #33ff33;
  white-space: pre-wrap;
  word-break: break-all;
}

.debug-mem-input {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
  font-size: 14px;
  color: #33ff33;
}

.debug-mem-input input {
  font-family: 'VT323', monospace;
  font-size: 15px;
  width: 50px;
  background: #001a00;
  color: #33ff33;
  border: 1px solid #1a3a1a;
  padding: 2px 4px;
  border-radius: 2px;
  text-transform: uppercase;
}

#btn-mem-view {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  padding: 4px 8px;
  background: #1a3a1a;
  color: #33ff33;
  border: 1px solid #2a5a2a;
  border-radius: 3px;
  cursor: pointer;
}

.mem-dump { font-size: 13px !important; line-height: 1.3; }

.keyboard-container {
  max-width: 700px;
  margin: 12px auto 0;
  background: linear-gradient(145deg, #3a3632, #2a2622);
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.kb-row {
  display: flex;
  gap: 3px;
  margin-bottom: 3px;
  justify-content: center;
}

.kb-row-with-numpad {
  display: flex;
  gap: 10px;
  margin-bottom: 3px;
}

.kb-main { display: flex; gap: 3px; flex: 1; }
.kb-numpad { display: flex; gap: 3px; }

.kb-key {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  padding: 6px 5px;
  min-width: 30px;
  height: 30px;
  background: linear-gradient(180deg, #555, #3a3a3a);
  color: #ddd;
  border: 1px solid #222;
  border-bottom: 2px solid #111;
  border-radius: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  user-select: none;
  transition: all 0.08s;
  line-height: 1;
}

.kb-key:active, .kb-key.pressed {
  background: linear-gradient(180deg, #3a3a3a, #555);
  border-bottom: 1px solid #111;
  transform: translateY(1px);
  color: #33ff33;
}

.kb-key.special {
  background: linear-gradient(180deg, #4a3a2a, #2a1a0a);
  color: #d4c5a9;
  min-width: 42px;
  font-size: 6px;
}

.kb-key.space { min-width: 160px; }

.footer {
  text-align: center;
  padding: 16px;
  font-size: 13px;
}
.footer a { color: #888; text-decoration: none; }
.footer a:hover { color: #d4c5a9; }

@media (max-width: 720px) {
  .title { font-size: 14px; }
  .monitor-bezel { padding: 12px; border-radius: 14px; }
  .control-group { gap: 10px; }
  .debug-grid { grid-template-columns: 1fr; }
  .kb-key { min-width: 22px; height: 24px; font-size: 5px; padding: 3px 2px; }
  .kb-key.special { min-width: 32px; }
  .kb-key.space { min-width: 100px; }
  .keyboard-container { overflow-x: auto; }
}