:root {
  --dos-blue: #0000AA;
  --dos-blue-light: #0055AA;
  --dos-cyan: #00AAAA;
  --dos-yellow: #FFFF55;
  --dos-white: #FFFFFF;
  --dos-gray: #AAAAAA;
  --dos-gray-dark: #555555;
  --dos-gray-light: #C0C0C0;
  --dos-black: #000000;
  --dos-red: #AA0000;
  --dos-green: #00AA00;
  --dos-magenta: #AA00AA;
  --btn-face: #C0C0C0;
  --btn-highlight: #FFFFFF;
  --btn-shadow: #808080;
  --btn-dark-shadow: #000000;
}

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

body {
  background: var(--dos-blue);
  color: var(--dos-white);
  font-family: 'VT323', monospace;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Scanline overlay */
body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.08) 2px,
    rgba(0, 0, 0, 0.08) 4px
  );
}

.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 8px;
}

/* Header */
.header {
  background: var(--dos-blue);
  border: 2px solid var(--dos-cyan);
  padding: 16px 24px;
  margin-bottom: 8px;
  text-align: center;
  position: relative;
}

.header h1 {
  font-family: 'Press Start 2P', monospace;
  font-size: 22px;
  color: var(--dos-yellow);
  margin-bottom: 8px;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.5);
  letter-spacing: 1px;
}

.header p {
  font-family: 'VT323', monospace;
  font-size: 20px;
  color: var(--dos-cyan);
}

.blink-cursor {
  animation: blink 1s step-end infinite;
  color: var(--dos-yellow);
  font-weight: bold;
}

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

/* DOS Panel */
.dos-panel {
  background: var(--dos-blue);
  border: 2px solid var(--dos-gray);
  position: relative;
}

.dos-panel-title {
  background: var(--dos-cyan);
  color: var(--dos-black);
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  padding: 4px 8px;
  position: absolute;
  top: -10px;
  left: 12px;
  z-index: 1;
}

.dos-panel-body {
  padding: 16px;
  padding-top: 20px;
}

/* DOS Button */
.dos-btn {
  font-family: 'VT323', monospace;
  font-size: 18px;
  padding: 4px 16px;
  background: var(--btn-face);
  color: var(--dos-black);
  border: none;
  outline: none;
  cursor: pointer;
  border-top: 2px solid var(--btn-highlight);
  border-left: 2px solid var(--btn-highlight);
  border-bottom: 2px solid var(--btn-dark-shadow);
  border-right: 2px solid var(--btn-dark-shadow);
  box-shadow: inset -1px -1px 0 var(--btn-shadow), inset 1px 1px 0 var(--btn-highlight);
  min-width: 80px;
  text-align: center;
  white-space: nowrap;
}

.dos-btn:hover {
  background: #D0D0D0;
}

.dos-btn:active {
  border-top: 2px solid var(--btn-dark-shadow);
  border-left: 2px solid var(--btn-dark-shadow);
  border-bottom: 2px solid var(--btn-highlight);
  border-right: 2px solid var(--btn-highlight);
  box-shadow: inset 1px 1px 0 var(--btn-shadow);
  padding: 5px 15px 3px 17px;
}

.dos-btn-primary {
  background: var(--dos-cyan);
  color: var(--dos-black);
  font-weight: bold;
}

.dos-btn-sm {
  font-size: 15px;
  padding: 2px 10px;
  min-width: 60px;
}

/* Layout */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

@media (max-width: 900px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
}

/* Drop Zone */
.drop-zone {
  border: 2px dashed var(--dos-cyan);
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.drop-zone:hover, .drop-zone.drag-over {
  background: rgba(0, 170, 170, 0.15);
  border-color: var(--dos-yellow);
}

.drop-zone-icon {
  font-size: 48px;
  margin-bottom: 8px;
  color: var(--dos-gray);
}

.drop-zone-text {
  font-size: 20px;
  color: var(--dos-gray);
}

.drop-zone-hint {
  font-size: 16px;
  color: var(--dos-gray-dark);
  margin-top: 4px;
}

/* Preview */
.preview-thumb {
  max-width: 100%;
  max-height: 200px;
  border: 1px solid var(--dos-gray);
  image-rendering: pixelated;
  display: block;
  margin: 8px auto;
}

/* EGA Canvas Container */
.ega-canvas-wrap {
  position: relative;
  display: inline-block;
  margin: 8px auto;
}

.ega-canvas-wrap canvas {
  display: block;
  image-rendering: pixelated;
  border: 1px solid var(--dos-gray);
}

.ega-canvas-wrap::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 1px,
    rgba(0, 0, 0, 0.1) 1px,
    rgba(0, 0, 0, 0.1) 2px
  );
}

/* Palette Swatches */
.palette-row {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-top: 8px;
}

.palette-swatch {
  width: 28px;
  height: 28px;
  border: 1px solid var(--dos-gray);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
}

.palette-swatch:hover {
  border-color: var(--dos-yellow);
  z-index: 1;
  transform: scale(1.2);
}

.palette-swatch-label {
  font-family: 'VT323', monospace;
  font-size: 10px;
  color: var(--dos-white);
  text-shadow: 0 0 2px black, 1px 1px 0 black;
  text-align: center;
  line-height: 28px;
  pointer-events: none;
}

/* Dropdown */
.dos-select {
  font-family: 'VT323', monospace;
  font-size: 18px;
  background: var(--dos-white);
  color: var(--dos-black);
  border: 2px inset var(--btn-shadow);
  padding: 2px 4px;
  cursor: pointer;
}

/* Checkbox */
.dos-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 18px;
  margin: 4px 0;
}

.dos-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--dos-cyan);
  cursor: pointer;
}

/* Code Panel */
.code-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 0;
}

.code-tab {
  font-family: 'VT323', monospace;
  font-size: 18px;
  padding: 4px 16px;
  background: var(--btn-face);
  color: var(--dos-black);
  border: 2px solid var(--btn-shadow);
  border-bottom: none;
  cursor: pointer;
  position: relative;
  top: 2px;
}

.code-tab.active {
  background: #000080;
  color: var(--dos-yellow);
  border-color: var(--dos-gray);
  z-index: 1;
}

.code-output {
  background: #000080;
  border: 2px solid var(--dos-gray);
  padding: 12px;
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
}

.code-output pre {
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.4;
  white-space: pre;
  color: var(--dos-gray-light);
  margin: 0;
}

/* QBasic syntax colors */
.qb-keyword { color: #5555FF; font-weight: bold; }
.qb-string { color: #55FF55; }
.qb-comment { color: #808080; font-style: italic; }
.qb-number { color: #FF5555; }
.qb-function { color: #FFFF55; }

/* Accordion */
.accordion-header {
  background: var(--dos-cyan);
  color: var(--dos-black);
  font-family: 'VT323', monospace;
  font-size: 20px;
  padding: 8px 16px;
  cursor: pointer;
  border: 2px outset var(--btn-highlight);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.accordion-header:hover {
  background: #00CCCC;
}

.accordion-body {
  background: #000055;
  border: 2px solid var(--dos-gray);
  border-top: none;
  padding: 16px;
  font-size: 18px;
  line-height: 1.5;
}

/* Plane diagram */
.plane-diagram {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 12px 0;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
}

.plane-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.plane-label {
  width: 70px;
  text-align: right;
  font-weight: bold;
}

.plane-bits {
  display: flex;
  gap: 1px;
}

.plane-bit {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 13px;
  border: 1px solid rgba(255,255,255,0.3);
}

/* Settings sidebar */
.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-label {
  font-size: 18px;
  color: var(--dos-cyan);
  min-width: 100px;
}

/* Image info text */
.info-text {
  font-size: 16px;
  color: var(--dos-gray);
  margin: 4px 0;
}

.info-text strong {
  color: var(--dos-yellow);
}

/* Footer */
.footer {
  border-top: 2px solid var(--dos-cyan);
  padding: 12px;
  text-align: center;
  font-family: 'VT323', monospace;
  font-size: 18px;
  color: var(--dos-gray);
  margin-top: 8px;
}

.footer a {
  color: var(--dos-yellow);
  text-decoration: none;
}

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

/* Status message */
.status-msg {
  font-size: 16px;
  padding: 4px 8px;
  margin: 4px 0;
}

.status-success { color: #55FF55; }
.status-error { color: #FF5555; }
.status-info { color: var(--dos-cyan); }

/* Buttons row */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

/* File input hidden */
.file-input-hidden {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

/* Full-width bottom section */
.full-width {
  grid-column: 1 / -1;
}

/* Copied toast */
.copy-toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #00AA00;
  color: white;
  font-family: 'VT323', monospace;
  font-size: 18px;
  padding: 8px 16px;
  border: 2px outset #55FF55;
  z-index: 10000;
  animation: fadeInOut 1.5s ease-in-out;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translateY(10px); }
  15% { opacity: 1; transform: translateY(0); }
  85% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-10px); }
}

/* Responsive tweaks */
@media (max-width: 600px) {
  .header h1 { font-size: 14px; }
  .header p { font-size: 16px; }
  .dos-panel-title { font-size: 8px; }
  .code-output pre { font-size: 11px; }
}