:root {
  --bg: #0a0d0a;
  --panel: #14181a;
  --panel2: #1c2124;
  --phosphor: #4dff88;
  --phosphor-dim: #2fae5c;
  --amber: #ffb347;
  --text: #cfe0d4;
  --muted: #6f8073;
  --border: #2a3330;
}

* { box-sizing: border-box; }

body {
  font-family: 'IBM Plex Mono', monospace;
  background:
    radial-gradient(ellipse at 50% -10%, #16261c 0%, transparent 60%),
    repeating-linear-gradient(0deg, rgba(0,0,0,0.25) 0px, rgba(0,0,0,0.25) 1px, transparent 1px, transparent 3px),
    var(--bg);
  color: var(--text);
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 24px 16px 48px;
}

.crt-vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 50;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.55) 100%);
}

.container {
  width: 100%;
  max-width: 780px;
  animation: bootUp 0.7s ease-out both;
}

@keyframes bootUp {
  0% { opacity: 0; transform: scaleY(0.6); filter: brightness(2); }
  100% { opacity: 1; transform: scaleY(1); filter: brightness(1); }
}

header { text-align: center; margin-bottom: 22px; }

.onair {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: 'VT323', monospace; font-size: 1.4rem;
  letter-spacing: 3px; color: #ff4d4d;
  border: 2px solid #ff4d4d; border-radius: 4px;
  padding: 2px 12px; margin-bottom: 14px;
  text-shadow: 0 0 8px #ff4d4d;
  box-shadow: 0 0 14px rgba(255,77,77,0.35);
}
.onair .dot {
  width: 10px; height: 10px; border-radius: 50%; background: #ff4d4d;
  box-shadow: 0 0 8px #ff4d4d; animation: blink 1.2s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0.15; } }

h1 {
  font-family: 'VT323', monospace;
  font-weight: 400;
  font-size: clamp(1.8rem, 6vw, 3.2rem);
  margin: 0.1em 0;
  color: var(--phosphor);
  text-shadow: 0 0 12px rgba(77,255,136,0.55), 0 0 2px #fff;
  letter-spacing: 1px;
}

.sub { color: var(--muted); font-size: 0.82rem; margin: 6px 0 0; letter-spacing: 0.5px; }

.dropzone {
  border: 2px dashed var(--phosphor-dim);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--panel) 0%, #0d1210 100%);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--phosphor);
  background: linear-gradient(180deg, #17201b 0%, #0d1210 100%);
  box-shadow: 0 0 24px rgba(77,255,136,0.2) inset;
}
.tv-icon { font-size: 3rem; margin-bottom: 8px; filter: drop-shadow(0 0 10px rgba(77,255,136,0.4)); }
.dz-inner p { margin: 6px 0; color: var(--text); }
.dz-inner .hint { color: var(--muted); font-size: 0.75rem; }

.upload-btn, button {
  font-family: 'IBM Plex Mono', monospace;
  display: inline-block;
  background: var(--phosphor-dim);
  color: #04140a;
  font-weight: 600;
  border: none;
  padding: 10px 18px;
  border-radius: 6px;
  cursor: pointer;
  margin-top: 10px;
  transition: all 0.15s;
  letter-spacing: 0.5px;
}
.upload-btn:hover, button:hover {
  background: var(--phosphor);
  box-shadow: 0 0 14px rgba(77,255,136,0.5);
  transform: translateY(-1px);
}

.loader {
  display: none;
  text-align: center;
  font-family: 'VT323', monospace;
  font-size: 1.3rem;
  color: var(--amber);
  margin: 18px 0;
  text-shadow: 0 0 8px rgba(255,179,71,0.5);
}
.loader .ell { animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0%{opacity:0.2} 50%{opacity:1} 100%{opacity:0.2} }

.workspace { margin-top: 18px; }

.canvas-wrap {
  position: relative;
  background: #000;
  border: 3px solid #1a1e1b;
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 0 0 4px #0a0d0a, 0 10px 30px rgba(0,0,0,0.7), inset 0 0 60px rgba(0,0,0,0.6);
  overflow: hidden;
}
canvas {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  image-rendering: pixelated;
  border-radius: 4px;
}
.scanline-overlay {
  position: absolute; inset: 10px; pointer-events: none; border-radius: 4px;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.14) 0px, rgba(0,0,0,0.14) 1px, transparent 1px, transparent 3px);
  mix-blend-mode: multiply;
}
.compare-label {
  position: absolute; top: 16px; left: 16px;
  font-family: 'VT323', monospace; font-size: 1.1rem; letter-spacing: 2px;
  color: var(--phosphor); background: rgba(0,0,0,0.6);
  padding: 1px 8px; border-radius: 3px; pointer-events: none;
  text-shadow: 0 0 6px currentColor;
}
.compare-label.orig { color: var(--amber); }

.controls {
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  display: grid;
  gap: 14px;
}
.ctrl { display: flex; flex-direction: column; gap: 6px; }
.ctrl > label {
  font-size: 0.78rem; letter-spacing: 0.5px; color: var(--muted);
  display: flex; justify-content: space-between;
}
.ctrl > label span { color: var(--phosphor); font-weight: 600; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 2px;
  background: linear-gradient(90deg, var(--phosphor-dim), var(--border));
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--phosphor); cursor: pointer;
  box-shadow: 0 0 8px rgba(77,255,136,0.6);
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; border: none;
  background: var(--phosphor); cursor: pointer;
}

.toggle-row { flex-direction: row; align-items: center; gap: 10px; }
.toggle-row span { font-size: 0.82rem; color: var(--text); }
.tip { color: var(--amber); cursor: help; font-style: normal; border-bottom: 1px dotted var(--amber); }

.switch { position: relative; display: inline-block; width: 44px; height: 22px; }
.switch input { display: none; }
.switch .slider {
  position: absolute; inset: 0; background: var(--border);
  border-radius: 22px; transition: 0.2s; cursor: pointer;
}
.switch .slider::before {
  content: ''; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px;
  background: #90a498; border-radius: 50%; transition: 0.2s;
}
.switch input:checked + .slider { background: var(--phosphor-dim); }
.switch input:checked + .slider::before { transform: translateX(22px); background: var(--phosphor); box-shadow: 0 0 8px var(--phosphor); }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.btn-row button { margin-top: 0; font-size: 0.8rem; flex: 1 1 auto; }

footer {
  margin-top: 28px; text-align: center; font-size: 0.75rem; color: var(--muted);
  display: flex; flex-direction: column; gap: 6px;
}
footer a { color: var(--phosphor-dim); text-decoration: none; border-bottom: 1px solid transparent; }
footer a:hover { color: var(--phosphor); border-bottom-color: var(--phosphor); }

.hidden { display: none !important; }

@media (max-width: 480px) {
  .btn-row button { flex: 1 1 45%; }
  h1 { letter-spacing: 0; }
}