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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  color: #AAAAAA;
}

#app {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 22px);
  background: #0000AA;
  overflow: hidden;
}

#titlebar {
  background: #AAAAAA;
  color: #000000;
  text-align: center;
  padding: 2px 0;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 1px;
  flex-shrink: 0;
}

#menubar {
  background: #AAAAAA;
  color: #000;
  padding: 2px 8px;
  font-size: 13px;
  border-bottom: 2px solid #555;
  flex-shrink: 0;
  letter-spacing: 2px;
  white-space: nowrap;
  overflow: hidden;
}

#main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  min-height: 0;
  position: relative;
}

#editor-frame {
  position: relative;
  border: 2px solid #FFFF55;
  background: #000;
  width: 100%;
  max-width: 660px;
  flex: 1;
  min-height: 200px;
  display: flex;
  flex-direction: column;
}

#editor-title {
  position: absolute;
  top: -10px;
  left: 16px;
  background: #0000AA;
  color: #FFFF55;
  padding: 0 6px;
  font-size: 12px;
  z-index: 2;
}

#canvas {
  width: 100%;
  flex: 1;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  cursor: pointer;
}

#drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,170,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFF55;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 4px;
  border: 3px dashed #FFFF55;
  z-index: 10;
  pointer-events: none;
}

#controls-frame {
  flex-shrink: 0;
  border: 2px solid #AAAAAA;
  margin: 4px 8px 4px 8px;
  padding: 6px 10px;
  position: relative;
  max-width: 660px;
  width: calc(100% - 16px);
  align-self: center;
}

#controls-title {
  position: absolute;
  top: -10px;
  left: 16px;
  background: #0000AA;
  color: #FFFFFF;
  padding: 0 4px;
  font-size: 12px;
}

#controls {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  align-items: center;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.label {
  color: #FFFF55;
  white-space: nowrap;
}

select, input[type="range"] {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  background: #000;
  color: #FFFFFF;
  border: 1px solid #AAAAAA;
  padding: 1px 4px;
  outline: none;
}

select:focus, input[type="range"]:focus {
  border-color: #FFFF55;
}

input[type="range"] {
  width: 80px;
  accent-color: #FFFF55;
}

.val {
  color: #FFFFFF;
  min-width: 30px;
  text-align: right;
  font-size: 11px;
}

.buttons-row {
  gap: 8px;
  flex-wrap: wrap;
}

.dos-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  background: #AAAAAA;
  color: #000;
  border: none;
  padding: 2px 8px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.dos-btn:hover {
  background: #FFFF55;
  color: #000;
}

.dos-btn:active {
  background: #FF5555;
  color: #FFF;
}

#code-frame {
  border: 2px solid #55FF55;
  margin: 0 8px 4px;
  position: relative;
  max-width: 660px;
  width: calc(100% - 16px);
  align-self: center;
  max-height: 160px;
}

#code-title {
  position: absolute;
  top: -10px;
  left: 16px;
  background: #0000AA;
  color: #55FF55;
  padding: 0 4px;
  font-size: 12px;
}

#code-output {
  width: 100%;
  height: 140px;
  background: #000;
  color: #55FF55;
  border: none;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  padding: 8px;
  resize: none;
  outline: none;
}

#statusbar {
  height: 22px;
  background: #AAAAAA;
  color: #000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 12px;
  flex-shrink: 0;
}

#statusbar a {
  color: #0000AA;
  text-decoration: none;
  font-weight: 700;
}

#statusbar a:hover {
  text-decoration: underline;
}

#compile-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

#compile-text {
  color: #AAAAAA;
  font-size: 18px;
  animation: blink-compile 0.3s step-end infinite;
}

@keyframes blink-compile {
  50% { opacity: 0; }
}

.hidden {
  display: none !important;
}

/* Scanline overlay for canvas */
#editor-frame::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.08) 2px,
    rgba(0,0,0,0.08) 4px
  );
  pointer-events: none;
  z-index: 1;
}

/* Responsive */
@media (max-width: 700px) {
  #editor-frame {
    max-width: 100%;
  }
  #controls-frame, #code-frame {
    max-width: 100%;
  }
  .control-row {
    font-size: 11px;
  }
  select {
    font-size: 11px;
    max-width: 130px;
  }
  .dos-btn {
    font-size: 11px;
    padding: 2px 5px;
  }
  #menubar {
    font-size: 11px;
    letter-spacing: 1px;
  }
}

/* Blinking cursor animation */
@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}