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

body {
  background: #1a1a1a;
  color: #d4c5a0;
  font-family: 'Share Tech Mono', 'Courier New', monospace;
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, .subtitle, #cbm-badge {
  font-family: 'Press Start 2P', monospace;
}

#pet-case {
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px;
}

#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, #d4c5a0 0%, #b8a878 100%);
  padding: 10px 20px;
  border-radius: 12px 12px 0 0;
  border: 2px solid #8a7a50;
  border-bottom: none;
}

#cbm-badge {
  background: #4a5fc1;
  color: #fff;
  padding: 6px 12px;
  font-size: 10px;
  border-radius: 4px;
  letter-spacing: 2px;
}

#title h1 {
  font-size: 14px;
  color: #2a2a1a;
  letter-spacing: 1px;
}

.subtitle {
  font-size: 7px;
  color: #5a5a3a;
  margin-top: 4px;
  letter-spacing: 1px;
}

#power-led-area {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: #2a2a1a;
}

#power-led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid #555;
}

.led-off { background: #333; }
.led-on { background: #33ff33; box-shadow: 0 0 8px #33ff33; }

#main-area {
  display: flex;
  gap: 0;
  background: linear-gradient(180deg, #c8b890 0%, #b8a878 100%);
  border-left: 2px solid #8a7a50;
  border-right: 2px solid #8a7a50;
}

#screen-section {
  flex: 1;
  padding: 15px;
  min-width: 0;
}

#crt-bezel {
  background: #1a1a1a;
  border-radius: 16px;
  padding: 16px;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.8);
}

#crt-container {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 0 30px rgba(51, 255, 51, 0.2), inset 0 0 60px rgba(0,0,0,0.5);
}

#screen {
  display: block;
  width: 100%;
  height: auto;
  background: #000800;
  image-rendering: pixelated;
  border-radius: 8px;
}

#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;
  border-radius: 8px;
}

#keyboard-container {
  margin-top: 12px;
  background: #2a2a2a;
  border-radius: 8px;
  padding: 10px;
  overflow-x: auto;
}

#keyboard {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 580px;
}

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

.kb-separator {
  width: 12px;
}

.kb-key {
  background: #333;
  color: #eee;
  border: 1px solid #555;
  border-bottom: 2px solid #222;
  border-radius: 3px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 9px;
  padding: 5px 3px;
  min-width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  text-align: center;
  white-space: nowrap;
  transition: all 0.05s;
}

.kb-key:hover {
  background: #444;
}

.kb-key:active, .kb-key.pressed {
  background: #555;
  border-bottom: 1px solid #222;
  transform: translateY(1px);
}

.kb-key.wide {
  min-width: 50px;
  font-size: 7px;
}

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

/* Control Panel */
#control-panel {
  width: 280px;
  background: #3a3a3a;
  padding: 10px;
  overflow-y: auto;
  max-height: 80vh;
  border-left: 2px solid #555;
  flex-shrink: 0;
}

.panel-section {
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #555;
}

.panel-section h3 {
  font-size: 8px;
  color: #4a5fc1;
  margin-bottom: 6px;
  letter-spacing: 1px;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.ctrl-btn {
  background: #444;
  color: #ddd;
  border: 1px solid #666;
  border-radius: 4px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px;
  padding: 5px 10px;
  cursor: pointer;
  text-transform: uppercase;
}

.ctrl-btn:hover { background: #555; }
.ctrl-btn:active { background: #666; }
.ctrl-btn.active { background: #4a5fc1; color: #fff; border-color: #6a7fd1; }

.ctrl-btn.power-on { background: #1a6b1a; color: #fff; }
.ctrl-btn.power-on:hover { background: #2a8b2a; }
.ctrl-btn.reset { background: #8b6b1a; color: #fff; }
.ctrl-btn.reset:hover { background: #ab8b3a; }
.ctrl-btn.power-off { background: #6b1a1a; color: #fff; }
.ctrl-btn.power-off:hover { background: #8b3a3a; }
.ctrl-btn.small { font-size: 8px; padding: 3px 6px; }

.drop-zone {
  border: 2px dashed #666;
  border-radius: 6px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
  margin-bottom: 6px;
}

.drop-zone.small-drop { padding: 8px; }

.drop-zone:hover, .drop-zone.dragover {
  border-color: #33ff33;
  background: rgba(51, 255, 51, 0.05);
}

.drop-zone p {
  font-size: 9px;
  color: #888;
  pointer-events: none;
}

#rom-status {
  font-size: 9px;
  line-height: 1.6;
}

.rom-slot { color: #ff3333; }
.rom-slot.loaded { color: #33ff33; }

#prg-status, #tape-status, #floppy525-status, #floppy8-status, #hdd-status {
  font-size: 9px;
  color: #33ff33;
  margin: 4px 0;
}

label {
  font-size: 10px;
  color: #aaa;
}

select {
  background: #333;
  color: #ddd;
  border: 1px solid #555;
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px;
  padding: 2px;
}

/* Debug Panel */
#debug-panel {
  background: #2a2a2a;
  border: 2px solid #8a7a50;
  border-top: none;
  border-radius: 0 0 12px 12px;
  padding: 0;
}

#debug-toggle {
  padding: 6px 15px;
  cursor: pointer;
  font-size: 10px;
  color: #4a5fc1;
  text-align: center;
}

#debug-content {
  padding: 10px 15px;
  transition: max-height 0.3s;
}

#debug-content.collapsed {
  display: none;
}

.reg-display {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 11px;
  margin-bottom: 6px;
}

.reg-display b {
  color: #33ff33;
  font-family: 'Share Tech Mono', monospace;
  margin-left: 4px;
}

.flag-display {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
}

.flag {
  display: inline-block;
  width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  font-size: 10px;
  background: #1a4a1a;
  color: #33ff33;
  border-radius: 3px;
  font-weight: bold;
}

.flag.dim { background: #333; color: #666; }
.flag.off { background: #333; color: #666; }

.hex-input {
  background: #222;
  color: #33ff33;
  border: 1px solid #555;
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px;
  width: 50px;
  padding: 2px 4px;
  text-transform: uppercase;
}

#peek-result {
  color: #33ff33;
  font-size: 11px;
  margin-left: 6px;
}

/* Footer */
footer {
  text-align: center;
  padding: 15px;
  background: #1a1a1a;
}

footer a {
  color: #33ff33;
  text-decoration: none;
  font-size: 11px;
  font-family: 'Share Tech Mono', monospace;
}

footer a:hover { text-decoration: underline; }

/* Modal */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden { display: none; }

.modal-content {
  background: #2a2a2a;
  border: 2px solid #4a5fc1;
  border-radius: 10px;
  padding: 20px;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  color: #ccc;
}

.modal-content h2 {
  font-size: 11px;
  color: #4a5fc1;
  margin-bottom: 12px;
}

.modal-content h3 {
  font-size: 9px;
  color: #33ff33;
  margin: 10px 0 5px;
}

.help-text {
  font-size: 11px;
  line-height: 1.6;
}

.help-text ul {
  padding-left: 16px;
  margin: 4px 0;
}

.help-text li { margin: 2px 0; }

/* Responsive */
@media (max-width: 900px) {
  #main-area {
    flex-direction: column;
  }
  #control-panel {
    width: 100%;
    max-height: none;
    border-left: none;
    border-top: 2px solid #555;
  }
}

@media (max-width: 600px) {
  #header {
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    text-align: center;
  }
  #title h1 { font-size: 10px; }
  .kb-key { min-width: 22px; height: 24px; font-size: 7px; padding: 3px 2px; }
  .kb-key.wide { min-width: 36px; font-size: 6px; }
  .kb-key.space { min-width: 100px; }
  #keyboard { min-width: 460px; }
}