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

:root {
  --beige: #C8B88A;
  --beige-light: #D4C89E;
  --beige-dark: #A89868;
  --charcoal: #1A1A1E;
  --charcoal-light: #2A2A2E;
  --screen-bg: #0A0A0A;
  --green-glow: #33FF33;
  --amber: #FFB000;
  --led-green: #00FF44;
  --led-off: #334433;
}

body {
  background: var(--charcoal);
  background-image: 
    radial-gradient(ellipse at 50% 30%, #222228 0%, #0E0E12 70%);
  font-family: 'IBM Plex Sans', sans-serif;
  color: #CCC;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

#app-container {
  max-width: 900px;
  width: 100%;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

/* Monitor Frame */
#monitor-frame {
  width: 100%;
  max-width: 800px;
  background: linear-gradient(180deg, #2C2C30 0%, #1E1E22 100%);
  border-radius: 20px;
  padding: 18px;
  box-shadow: 
    0 10px 40px rgba(0,0,0,0.6),
    inset 0 1px 0 rgba(255,255,255,0.05);
}

#monitor-bezel {
  background: linear-gradient(180deg, #333338 0%, #28282C 50%, #222226 100%);
  border-radius: 14px;
  padding: 14px 14px 10px;
  position: relative;
  border: 1px solid #3A3A3E;
}

#badge {
  position: absolute;
  top: -8px;
  left: 24px;
  background: linear-gradient(135deg, var(--beige), var(--beige-dark));
  color: #1A1A1A;
  font-family: 'IBM Plex Sans', sans-serif;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 1px;
  padding: 3px 10px;
  border-radius: 2px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  z-index: 10;
}

#badge .js {
  color: #0060C0;
  font-weight: 500;
}

#screen-recess {
  background: #000;
  border-radius: 10px;
  padding: 8px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.8);
}

#canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  position: relative;
  z-index: 1;
}

#crt-overlay {
  position: absolute;
  top: 8px; left: 8px; right: 8px; bottom: 8px;
  border-radius: 6px;
  pointer-events: none;
  z-index: 2;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.4) 100%);
}

#scanlines {
  position: absolute;
  top: 8px; left: 8px; right: 8px; bottom: 8px;
  border-radius: 6px;
  pointer-events: none;
  z-index: 3;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 1px,
    rgba(0, 0, 0, 0.15) 1px,
    rgba(0, 0, 0, 0.15) 2px
  );
  mix-blend-mode: multiply;
}

#led-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 4px 0;
}

#power-led {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--led-off);
  box-shadow: none;
  transition: all 0.3s;
}

#power-led.on {
  background: var(--led-green);
  box-shadow: 0 0 6px var(--led-green), 0 0 12px rgba(0,255,68,0.3);
}

#led-label {
  font-size: 9px;
  letter-spacing: 2px;
  color: #666;
  font-family: 'IBM Plex Mono', monospace;
}

#kb-indicator {
  margin-left: auto;
  font-size: 9px;
  letter-spacing: 1px;
  color: #444;
  font-family: 'IBM Plex Mono', monospace;
  transition: color 0.2s;
}

#kb-indicator.active {
  color: var(--green-glow);
  text-shadow: 0 0 4px rgba(51,255,51,0.4);
}

/* Controls */
#controls {
  width: 100%;
  max-width: 800px;
  background: linear-gradient(180deg, var(--beige) 0%, var(--beige-dark) 100%);
  border-radius: 0 0 16px 16px;
  padding: 16px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  border-top: 2px solid var(--beige-light);
}

/* Drive Bay */
#drive-bay {
  display: flex;
  gap: 10px;
  flex: 1;
  min-width: 280px;
}

.drive-slot {
  flex: 1;
  min-width: 80px;
}

.drive-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  color: #3A3520;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.drive-dropzone {
  background: linear-gradient(180deg, #2A2A2A 0%, #1A1A1A 100%);
  border: 2px dashed #555;
  border-radius: 4px;
  padding: 8px;
  text-align: center;
  cursor: pointer;
  position: relative;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s;
}

.drive-dropzone:hover, .drive-dropzone.dragover {
  border-color: var(--amber);
}

.drop-text {
  font-size: 9px;
  color: #777;
  font-family: 'IBM Plex Mono', monospace;
}

.file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.drive-filename {
  font-size: 9px;
  color: #3A3520;
  font-family: 'IBM Plex Mono', monospace;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drive-activity {
  display: none;
  position: absolute;
  top: 4px; right: 4px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #FF3300;
  animation: blink-led 0.15s infinite alternate;
}

.drive-activity.active { display: block; }

@keyframes blink-led {
  from { opacity: 0.4; }
  to { opacity: 1; }
}

/* Button Panel */
#button-panel {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}

#button-panel button {
  background: linear-gradient(180deg, #E8D8B0 0%, #C8B080 100%);
  border: 1px solid #A89868;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: all 0.1s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.3);
}

#button-panel button:active {
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

#button-panel button .btn-icon {
  font-size: 18px;
  line-height: 1;
}

#button-panel button .btn-label {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #3A3520;
  font-family: 'IBM Plex Mono', monospace;
}

#power-btn.on {
  background: linear-gradient(180deg, #88CC88 0%, #55AA55 100%);
  border-color: #338833;
}

#reset-btn {
  background: linear-gradient(180deg, #DD8888 0%, #BB5555 100%) !important;
  border-color: #993333 !important;
}

#turbo-btn.on {
  background: linear-gradient(180deg, #FFCC44 0%, #DDAA22 100%);
  border-color: #AA8800;
}

#speed-display {
  background: #1A1A1A;
  border: 2px inset #444;
  border-radius: 4px;
  padding: 6px 10px;
  font-family: 'IBM Plex Mono', monospace;
  color: #FF3300;
  font-size: 16px;
  font-weight: 700;
  min-width: 80px;
  text-align: center;
  text-shadow: 0 0 6px rgba(255,51,0,0.4);
}

#speed-unit {
  font-size: 10px;
  color: #AA2200;
}

#cpu-select-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding-top: 6px;
}

#cpu-select-row label {
  font-size: 10px;
  font-weight: 700;
  color: #3A3520;
  font-family: 'IBM Plex Mono', monospace;
  letter-spacing: 1px;
}

#cpu-type {
  background: #1A1A1A;
  color: #FF3300;
  border: 2px inset #444;
  border-radius: 4px;
  padding: 4px 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-shadow: 0 0 4px rgba(255,51,0,0.3);
}

#cpu-type option {
  background: #1A1A1A;
  color: #FF3300;
}

#cpu-bus-info {
  font-size: 9px;
  color: #3A3520;
  font-family: 'IBM Plex Mono', monospace;
  letter-spacing: 1px;
  opacity: 0.7;
}

#speed-control {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding-top: 6px;
}

#speed-control label {
  font-size: 10px;
  font-weight: 700;
  color: #3A3520;
  font-family: 'IBM Plex Mono', monospace;
  letter-spacing: 1px;
}

#speed-slider {
  flex: 1;
  accent-color: var(--beige-dark);
}

#speed-label {
  font-size: 10px;
  color: #3A3520;
  font-family: 'IBM Plex Mono', monospace;
  min-width: 70px;
}

/* Debug Panel */
#debug-toggle-bar {
  width: 100%;
  max-width: 800px;
  display: flex;
  align-items: center;
  margin-top: 12px;
}

#debug-toggle {
  background: var(--charcoal-light);
  border: 1px solid #3A3A3E;
  color: var(--green-glow);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  padding: 5px 14px;
  cursor: pointer;
  border-radius: 4px 4px 0 0;
  letter-spacing: 1px;
}

#ips-counter {
  margin-left: auto;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--amber);
}

#debug-panel {
  width: 100%;
  max-width: 800px;
  background: #0D1A0D;
  border: 1px solid #1A3A1A;
  border-radius: 0 0 8px 8px;
  overflow: hidden;
  transition: max-height 0.3s ease;
  max-height: 400px;
}

#debug-panel.collapsed {
  max-height: 0;
  border: none;
}

#debug-content {
  padding: 12px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--green-glow);
}

#registers {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.reg-group h3 {
  font-size: 9px;
  color: #227722;
  letter-spacing: 2px;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.reg-row {
  display: flex;
  gap: 6px;
  line-height: 1.6;
}

.reg-name {
  color: #55AA55;
  min-width: 24px;
}

.reg-val {
  color: var(--green-glow);
  font-weight: 700;
}

#flag-bits {
  font-size: 10px;
  color: #55AA55;
  margin-top: 2px;
}

#debug-info {
  border-top: 1px solid #1A3A1A;
  padding-top: 8px;
  margin-bottom: 8px;
}

#debug-info div {
  margin-bottom: 3px;
}

#int-log {
  max-height: 60px;
  overflow-y: auto;
  font-size: 10px;
  color: #55AA55;
}

#debug-buttons {
  display: flex;
  gap: 8px;
}

#debug-buttons button {
  background: #1A2A1A;
  border: 1px solid #2A4A2A;
  color: var(--green-glow);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  padding: 4px 12px;
  cursor: pointer;
  border-radius: 3px;
}

#debug-buttons button:hover {
  background: #2A3A2A;
}

/* Footer */
#dos-footer {
  margin-top: 30px;
  padding: 10px;
  text-align: center;
}

#dos-footer a {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  color: var(--green-glow);
  text-decoration: none;
  text-shadow: 0 0 6px rgba(51,255,51,0.3);
  animation: cursor-blink 1s step-end infinite;
}

@keyframes cursor-blink {
  0%, 100% { border-right: 2px solid var(--green-glow); }
  50% { border-right: 2px solid transparent; }
}

#dos-footer a {
  border-right: 2px solid var(--green-glow);
  padding-right: 2px;
}

/* Responsive */
@media (max-width: 640px) {
  #app-container { padding: 10px; }
  #controls { flex-direction: column; }
  #drive-bay { flex-direction: column; }
  #button-panel { justify-content: center; }
  #registers { font-size: 10px; }
  #monitor-frame { border-radius: 12px; padding: 10px; }
}