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

:root {
  --bg: #0C0C0C;
  --bg-dark: #000080;
  --cyan: #00FFFF;
  --green: #00FF00;
  --yellow: #FFFF00;
  --white: #AAAAAA;
  --bright-white: #FFFFFF;
  --red: #FF5555;
  --magenta: #FF00FF;
  --blue: #0000AA;
  --font: 'IBM Plex Mono', 'Courier New', monospace;
}

body {
  background: var(--bg);
  color: var(--green);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.4;
  overflow-x: hidden;
  min-height: 100vh;
}

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

#titlebar {
  background: var(--bg-dark);
  text-align: center;
  padding: 10px 0;
  border-bottom: 2px solid #333;
  margin-bottom: 6px;
}

.title-border {
  color: #555;
  font-size: 15px;
}

.title-text {
  color: var(--cyan);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 2px;
}

.blink {
  animation: blink 1s step-end infinite;
  color: var(--cyan);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Controls Bar */
#controls-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 8px 12px;
  background: #111;
  border: 1px solid #333;
  margin-bottom: 4px;
  align-items: center;
}

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

.control-group label {
  color: var(--yellow);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

select {
  background: #000;
  color: var(--cyan);
  border: 1px solid #555;
  font-family: var(--font);
  font-size: 12px;
  padding: 3px 6px;
  cursor: pointer;
  border-radius: 0;
}

select:focus {
  outline: 1px solid var(--cyan);
}

/* Sliders */
#sliders-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 8px 12px;
  background: #111;
  border: 1px solid #333;
  border-top: none;
  margin-bottom: 4px;
  align-items: center;
}

.slider-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.slider-group label {
  color: var(--white);
  font-size: 11px;
  white-space: nowrap;
  min-width: 120px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 140px;
  height: 8px;
  background: #222;
  border: 1px solid #444;
  cursor: pointer;
  border-radius: 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 18px;
  background: var(--green);
  border: 1px solid #0a0;
  cursor: pointer;
  border-radius: 0;
}

input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 18px;
  background: var(--green);
  border: 1px solid #0a0;
  cursor: pointer;
  border-radius: 0;
}

.slider-val {
  color: var(--cyan);
  font-size: 12px;
  min-width: 30px;
  text-align: right;
}

/* Palette Display */
#palette-display {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: #0a0a0a;
  border: 1px solid #333;
  border-top: none;
  margin-bottom: 8px;
  overflow-x: auto;
}

.palette-label {
  color: var(--yellow);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

#palette-swatches {
  display: flex;
  gap: 3px;
}

.swatch {
  width: 24px;
  height: 24px;
  border: 1px solid #555;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  font-size: 8px;
  color: #888;
  cursor: default;
  position: relative;
}

.swatch.hot {
  border-color: var(--bright-white);
  box-shadow: 0 0 4px rgba(255,255,255,0.3);
}

.swatch .hex-label {
  position: absolute;
  bottom: -12px;
  font-size: 8px;
  color: #666;
}

/* Drop Zone */
#drop-zone {
  cursor: pointer;
  text-align: center;
  padding: 0;
  transition: background 0.2s;
}

#drop-zone:hover, #drop-zone.drag-over {
  background: #0a1a0a;
}

.dos-box {
  font-size: 12px;
  color: var(--green);
}

.box-top, .box-bot {
  color: #555;
  letter-spacing: -0.5px;
  white-space: nowrap;
  overflow: hidden;
}

.box-content {
  display: flex;
  color: #555;
  justify-content: center;
}

.drop-inner {
  padding: 30px 40px;
}

.drop-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--green);
  margin-bottom: 6px;
}

.drop-text-sub {
  font-size: 13px;
  color: var(--white);
}

.drop-text-fmt {
  font-size: 10px;
  color: #555;
  margin-top: 8px;
}

/* Preview Area */
#preview-area {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.preview-panel {
  flex: 1;
  min-width: 300px;
  max-width: 650px;
}

.preview-label {
  color: var(--cyan);
  font-size: 12px;
  margin-bottom: 4px;
  font-weight: 700;
}

.canvas-wrap {
  border: 1px solid #444;
  background: #000;
  position: relative;
  overflow: hidden;
  line-height: 0;
}

.canvas-wrap canvas {
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
}

.scanlines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0,0,0,0.12) 2px,
    rgba(0,0,0,0.12) 4px
  );
  z-index: 2;
}

/* Stats */
#stats-panel {
  margin-top: 8px;
}

.dos-box-inline {
  font-size: 11px;
}

.stats-title, .stats-bot {
  color: #555;
  white-space: nowrap;
  overflow: hidden;
}

.stats-body {
  color: var(--white);
  padding: 4px 0;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
}

.stats-body .highlight {
  color: var(--cyan);
}

.stats-body .val {
  color: var(--green);
}

/* Export */
#export-bar {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  padding: 8px 12px;
  background: #111;
  border: 1px solid #333;
  flex-wrap: wrap;
}

.dos-btn {
  background: #222;
  color: var(--yellow);
  border: 1px solid #555;
  font-family: var(--font);
  font-size: 12px;
  padding: 6px 14px;
  cursor: pointer;
  border-radius: 0;
  transition: all 0.15s;
}

.dos-btn:hover {
  background: var(--yellow);
  color: #000;
}

.dos-btn:active {
  background: var(--bright-white);
}

/* Footer */
#footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  margin-top: 8px;
  border-top: 1px solid #333;
  font-size: 11px;
  color: #555;
}

#footer a {
  color: var(--cyan);
  text-decoration: none;
}

#footer a:hover {
  color: var(--bright-white);
  text-decoration: underline;
}

.footer-right {
  color: #555;
}

/* Processing indicator */
.processing-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--green);
  font-size: 14px;
  z-index: 10;
}

/* Responsive */
@media (max-width: 768px) {
  #controls-bar {
    gap: 8px;
  }
  .drop-inner {
    padding: 20px;
  }
  .drop-text {
    font-size: 14px;
  }
  input[type="range"] {
    width: 100px;
  }
  .slider-group label {
    min-width: 90px;
    font-size: 10px;
  }
  #preview-area {
    flex-direction: column;
  }
  .preview-panel {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  body { font-size: 11px; }
  .title-text { font-size: 13px; letter-spacing: 1px; }
  .title-border { font-size: 12px; }
  .swatch { width: 18px; height: 18px; }
}