:root {
  --bg: #0a0a0e;
  --phos: #39ff14;
  --amber: #ffb000;
  --cyan: #34d0e0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 20% 10%, rgba(57,255,20,0.06), transparent 40%),
    radial-gradient(circle at 80% 90%, rgba(255,176,0,0.05), transparent 40%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.012) 0 1px, transparent 1px 3px);
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  color: #e5e5e5;
  min-height: 100vh;
}

/* Power LED */
.led {
  width: 12px; height: 12px; border-radius: 50%;
  background: #2a2a2a; box-shadow: inset 0 0 3px #000;
}
.led.on {
  background: var(--phos);
  box-shadow: 0 0 8px var(--phos), 0 0 16px rgba(57,255,20,0.6);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:0.5;} }

/* Buttons */
.btn-neon {
  background: rgba(57,255,20,0.08);
  border: 1px solid rgba(57,255,20,0.4);
  color: var(--phos);
  padding: 6px 14px; border-radius: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.1em;
  transition: all 0.15s;
}
.btn-neon:hover { background: rgba(57,255,20,0.2); box-shadow: 0 0 12px rgba(57,255,20,0.4); }

.btn-transport {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.1);
  color: #cfcfcf;
  padding: 8px 16px; border-radius: 6px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.08em;
  transition: all 0.15s;
}
.btn-transport:hover { border-color: var(--phos); color: var(--phos); }
.btn-transport:active { transform: translateY(1px); }
.btn-transport.active {
  background: rgba(57,255,20,0.15); border-color: var(--phos); color: var(--phos);
  box-shadow: 0 0 10px rgba(57,255,20,0.3);
}

.chip-toggle, .chip-toggle-static {
  font-size: 9px; letter-spacing: 0.15em; font-weight: 700;
  padding: 4px 10px; border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.12); color: #888;
  transition: all 0.15s;
}
.chip-toggle.on { border-color: var(--phos); color: var(--phos); background: rgba(57,255,20,0.1); }
.chip-toggle-static { color: var(--amber); border-color: rgba(255,176,0,0.3); }

/* Modules */
.module {
  background: linear-gradient(180deg, rgba(20,22,26,0.9), rgba(10,10,14,0.9));
  box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
}

/* CRT */
.crt-bezel {
  padding: 14px;
  border-radius: 18px;
  background: linear-gradient(145deg, #1a1a1e, #050506);
  box-shadow: inset 0 0 30px rgba(0,0,0,0.9), 0 8px 24px rgba(0,0,0,0.6);
  border: 2px solid #222;
  max-width: 100%;
}
.crt-bezel.glow {
  box-shadow: inset 0 0 30px rgba(0,0,0,0.9), 0 0 40px rgba(57,255,20,0.15), 0 8px 24px rgba(0,0,0,0.6);
}
.crt-canvas {
  display: block;
  width: 100%;
  max-width: 512px;
  aspect-ratio: 256/240;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border-radius: 6px;
  background: #000;
}
.crt-canvas.scan {
  position: relative;
}
.crt-bezel { position: relative; }
.crt-canvas.scan::after {
  content: '';
}
/* scanline overlay via bezel pseudo */
.crt-bezel.glow::before, .crt-bezel::before {
  content: '';
  position: absolute;
  inset: 14px;
  border-radius: 6px;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.18) 0 2px, transparent 2px 4px);
  z-index: 5;
  opacity: 0;
}
.crt-bezel:has(.scan)::before { opacity: 1; }

/* Flags */
.flag {
  width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; border-radius: 3px;
  background: rgba(255,255,255,0.04); color: #555;
  border: 1px solid rgba(255,255,255,0.06);
}
.flag.on { background: rgba(57,255,20,0.2); color: var(--phos); border-color: var(--phos); box-shadow: 0 0 6px rgba(57,255,20,0.4); }

/* Palette swatches */
.swatch { width: 16px; height: 16px; border-radius: 2px; border: 1px solid rgba(0,0,0,0.4); }

/* Bars */
.bar-track { height: 4px; background: rgba(255,255,255,0.06); border-radius: 2px; overflow: hidden; margin-top: 2px; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--cyan), var(--phos)); transition: width 0.1s; }

/* Volume cells */
.vol-cell { flex: 1; height: 6px; border-radius: 1px; background: rgba(255,255,255,0.05); }
.vol-cell.lit { background: var(--phos); box-shadow: 0 0 3px var(--phos); }
.vol-cell.noise.lit { background: var(--amber); box-shadow: 0 0 3px var(--amber); }

/* Dropzone */
.dropzone {
  border: 2px dashed rgba(57,255,20,0.25);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  font-size: 12px;
  color: #888;
  transition: all 0.2s;
}
.dropzone.drag-over {
  border-color: var(--phos);
  background: rgba(57,255,20,0.08);
  color: var(--phos);
}

/* Gamepad */
.gamepad-btn {
  width: 44px; height: 44px;
  background: linear-gradient(145deg, #2a2a30, #131316);
  border: 1px solid #333;
  border-radius: 8px;
  color: #bbb; font-weight: 700; font-size: 14px;
  box-shadow: 0 3px 0 #000, inset 0 1px 1px rgba(255,255,255,0.1);
  transition: all 0.08s;
  user-select: none;
}
.gamepad-btn:active, .gamepad-btn.active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #000;
  color: var(--phos);
  border-color: var(--phos);
}
.dpad { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.dpad-center { width: 44px; height: 44px; background: #131316; border: 1px solid #333; }

/* Toast */
.toast {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  background: rgba(10,15,10,0.95); border: 1px solid var(--phos);
  color: var(--phos); padding: 10px 18px; border-radius: 8px;
  font-size: 12px; z-index: 100;
  box-shadow: 0 0 20px rgba(57,255,20,0.3);
  animation: slideDown 0.3s ease;
}
@keyframes slideDown { from { transform: translate(-50%,-20px); opacity: 0; } to { transform: translate(-50%,0); opacity: 1; } }

.hidden { display: none; }

input[type=range] { cursor: pointer; }
::-webkit-scrollbar { height: 6px; width: 6px; }
::-webkit-scrollbar-thumb { background: rgba(57,255,20,0.3); border-radius: 3px; }