:root {
  --bg-deep: #06080d;
  --bg-primary: #0b0e16;
  --bg-card: #0f1219;
  --bg-card-hover: #141820;
  --accent-sky: #38bdf8;
  --accent-amber: #fbbf24;
  --accent-emerald: #34d399;
  --accent-red: #f87171;
  --text-primary: #e2e8f0;
  --text-secondary: #8b95a5;
  --text-dim: #4b5563;
  --border: #1a1f2e;
  --border-subtle: #141924;
  --corrupt-bg: #0a0612;
  --corrupt-accent: #ff2975;
  --corrupt-glow: #39ff14;
  --corrupt-dark: #080510;
}

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

body {
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.font-mono, code { font-family: 'JetBrains Mono', monospace; }

/* ─── App Background ─── */
.app-bg {
  background-color: var(--bg-deep);
  background-image:
    radial-gradient(ellipse at 15% 5%, rgba(56,189,248,0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 95%, rgba(255,41,117,0.02) 0%, transparent 50%);
}

/* ─── Header ─── */
.header-bar {
  background: rgba(11,14,22,0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
}

.title-gradient {
  background: linear-gradient(135deg, #38bdf8 0%, #818cf8 50%, #f472b6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ─── Tab Bar ─── */
.tab-bar {
  background: rgba(6,8,13,0.8);
  border: 1px solid var(--border-subtle);
}
.tab-btn {
  color: var(--text-dim);
}
.tab-btn:hover {
  color: var(--text-secondary);
}
.tab-active-encode {
  background: rgba(56,189,248,0.15);
  color: #38bdf8;
  box-shadow: 0 0 12px rgba(56,189,248,0.1);
}
.tab-active-corrupt {
  background: rgba(255,41,117,0.15);
  color: #ff2975;
  box-shadow: 0 0 12px rgba(255,41,117,0.1);
}
.tab-active-play {
  background: rgba(251,191,36,0.15);
  color: #fbbf24;
  box-shadow: 0 0 12px rgba(251,191,36,0.1);
}

/* ─── Cards ─── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: border-color 0.2s;
}
.card:hover {
  border-color: rgba(56,189,248,0.1);
}

/* ─── Drop Zones ─── */
.drop-zone {
  border: 2px dashed var(--border);
  background: rgba(56,189,248,0.01);
  transition: all 0.3s ease;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent-sky);
  background: rgba(56,189,248,0.04);
}

.drop-zone-corrupt {
  border: 2px dashed #1f1530;
  background: rgba(255,41,117,0.01);
  transition: all 0.3s ease;
}
.drop-zone-corrupt:hover, .drop-zone-corrupt.drag-over {
  border-color: var(--corrupt-accent);
  background: rgba(255,41,117,0.04);
}

.drop-zone-icon {
  opacity: 0.15;
  filter: grayscale(0.5);
}

/* ─── Glows ─── */
.glow-blue {
  box-shadow: 0 0 20px rgba(56,189,248,0.12), 0 1px 3px rgba(0,0,0,0.4);
}

/* ─── Progress Bars ─── */
.progress-bar-fill {
  background: linear-gradient(90deg, #0ea5e9, #818cf8, #0ea5e9);
  background-size: 200% 100%;
  animation: shimmer 2s linear infinite;
}

.progress-bar-corrupt {
  background: linear-gradient(90deg, #ff2975, #ff6b35, #39ff14, #ff2975);
  background-size: 300% 100%;
  animation: shimmer 1.5s linear infinite;
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ─── Toast ─── */
@keyframes slide-in {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.toast-enter { animation: slide-in 0.25s ease-out; }

/* ─── Waveform ─── */
.waveform-bar {
  animation: wave 0.8s ease-in-out infinite alternate;
}
@keyframes wave {
  from { transform: scaleY(0.3); }
  to { transform: scaleY(1); }
}

/* ─── Glitch Animation ─── */
@keyframes glitch-screen {
  0% { transform: translate(0); filter: none; }
  10% { transform: translate(-2px, 1px); filter: hue-rotate(90deg); }
  20% { transform: translate(2px, -1px); filter: saturate(2.5) brightness(1.1); }
  30% { transform: translate(-1px, 2px); clip-path: inset(20% 0 30% 0); }
  40% { transform: translate(1px, -1px); filter: hue-rotate(180deg); }
  50% { transform: translate(0); filter: none; }
  60% { transform: translate(-1px, 1px); filter: invert(0.2); }
  70% { transform: translate(1px, -2px); clip-path: inset(40% 0 10% 0); }
  80% { transform: translate(-1px, 1px); filter: hue-rotate(270deg) saturate(1.5); }
  90% { transform: translate(1px, 0); filter: contrast(1.3); }
  100% { transform: translate(0); filter: none; }
}
.glitch-active { animation: glitch-screen 0.5s ease-in-out; }

/* ─── Skull bounce ─── */
@keyframes skull-bounce {
  0%, 100% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(1.15) rotate(-4deg); }
  50% { transform: scale(0.92) rotate(4deg); }
  75% { transform: scale(1.08) rotate(-2deg); }
}
.skull-bounce { animation: skull-bounce 0.6s ease-in-out; }

/* ─── Input Fields ─── */
.input-field {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  transition: border-color 0.2s;
}
.input-field:focus {
  outline: none;
  border-color: var(--accent-sky);
  box-shadow: 0 0 0 2px rgba(56,189,248,0.08);
}

.input-field-corrupt {
  background: var(--corrupt-dark);
  border: 1px solid #1f1530;
  color: #b388ff;
  padding: 6px 10px;
  border-radius: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  transition: border-color 0.2s;
}
.input-field-corrupt:focus {
  outline: none;
  border-color: var(--corrupt-accent);
  box-shadow: 0 0 0 2px rgba(255,41,117,0.08);
}

.seed-input {
  color: #39ff14 !important;
}

select, input[type="number"] {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
}

/* ─── Sliders ─── */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-sky);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 0 0 3px rgba(56,189,248,0.1);
}
input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 0 5px rgba(56,189,248,0.15);
}

.slider-blue::-webkit-slider-thumb { background: var(--accent-sky) !important; }

.corrupt-slider::-webkit-slider-thumb {
  background: var(--corrupt-accent) !important;
  box-shadow: 0 0 0 3px rgba(255,41,117,0.1) !important;
}
.corrupt-slider::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 5px rgba(255,41,117,0.15) !important;
}
.corrupt-slider {
  background: linear-gradient(90deg, #120a1a, #1f1530) !important;
}

/* ─── Corrupt Cards ─── */
.corrupt-card {
  background: var(--corrupt-dark);
  border: 1px solid #141020;
  transition: border-color 0.2s;
}
.corrupt-card:hover {
  border-color: rgba(255,41,117,0.08);
}

/* ─── Corrupt Button ─── */
.corrupt-btn {
  background: linear-gradient(135deg, #be123c, #9333ea, #dc2626);
  color: white;
}
.corrupt-btn:hover {
  background: linear-gradient(135deg, #e11d48, #a855f7, #ef4444);
}

/* ─── Player Buttons ─── */
.player-btn-primary {
  background: var(--accent-sky);
  color: var(--bg-deep);
}
.player-btn-primary:hover {
  background: #7dd3fc;
}
.player-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.player-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.player-canvas-container {
  border: 1px solid var(--border-subtle);
}

/* ─── Corrupt Warning ─── */
.corrupt-warning-badge {
  background: rgba(120,53,15,0.15);
  border: 1px solid rgba(245,158,11,0.2);
}

/* ─── Console ─── */
.console-bar {
  background: rgba(11,14,22,0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-subtle);
  color: var(--text-dim);
}
.console-panel {
  background: rgba(6,8,13,0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-subtle);
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #252b3b; }

/* ─── Tagline ─── */
@keyframes fadeTagline {
  0% { opacity: 0; transform: translateY(5px); }
  12% { opacity: 1; transform: translateY(0); }
  88% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-5px); }
}
.tagline-fade { animation: fadeTagline 4s ease-in-out; }

.subtitle-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.4px;
  color: var(--text-dim);
}

/* ─── Split Preview ─── */
.split-preview-container {
  position: relative;
  overflow: hidden;
  cursor: ew-resize;
}
.split-preview-container .split-label {
  position: absolute;
  top: 8px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 9px;
  font-family: 'JetBrains Mono', monospace;
  pointer-events: none;
  z-index: 5;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.split-preview-container .split-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--corrupt-accent);
  z-index: 4;
  pointer-events: none;
  box-shadow: 0 0 6px rgba(255,41,117,0.3);
}

/* ─── Animations ─── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn 0.3s ease-out; }

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 8px rgba(255,41,117,0.15), 0 2px 8px rgba(0,0,0,0.4); }
  50% { box-shadow: 0 0 24px rgba(255,41,117,0.3), 0 0 40px rgba(57,255,20,0.05), 0 2px 8px rgba(0,0,0,0.4); }
}
.pulse-glow { animation: pulse-glow 2s ease-in-out infinite; }

.corrupt-btn-glow {
  position: relative;
  overflow: hidden;
}
.corrupt-btn-glow::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(from 0deg, transparent, rgba(255,41,117,0.12), transparent, rgba(57,255,20,0.06), transparent);
  animation: rotate-glow 3s linear infinite;
}
.corrupt-btn-glow > span {
  position: relative;
  z-index: 1;
}

@keyframes rotate-glow {
  to { transform: rotate(360deg); }
}

.frame-badge { font-variant-numeric: tabular-nums; }

.scanlines::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.04) 2px,
    rgba(0,0,0,0.04) 4px
  );
  z-index: 1;
}

button:active:not(:disabled) { transform: scale(0.97); }

/* ─── Responsive ─── */
@media (max-width: 640px) {
  .header-bar h1 { font-size: 1.25rem; }
  .tab-btn { font-size: 0.75rem; padding: 0.375rem 0.625rem; }
}