* {
  box-sizing: border-box;
}

body {
  font-family: 'Space Grotesk', sans-serif;
  background: #0f0f1a;
  margin: 0;
  padding: 0;
}

.header-gradient {
  background: linear-gradient(135deg, #a855f7 0%, #ec4899 50%, #f97316 100%);
  position: relative;
}

.glitch-text {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  text-shadow: 
    2px 2px 0 #ec4899,
    -2px -2px 0 #06b6d4;
  animation: glitch 3s infinite;
}

@keyframes glitch {
  0%, 90%, 100% { text-shadow: 2px 2px 0 #ec4899, -2px -2px 0 #06b6d4; }
  92% { text-shadow: -2px 2px 0 #ec4899, 2px -2px 0 #06b6d4; }
  94% { text-shadow: 2px -2px 0 #ec4899, -2px 2px 0 #06b6d4; }
}

.sparkle {
  position: absolute;
  width: 8px;
  height: 8px;
  background: white;
  border-radius: 50%;
  animation: sparkle 2s infinite;
}

.sparkle-1 { top: 20%; left: 10%; animation-delay: 0s; }
.sparkle-2 { top: 40%; right: 15%; animation-delay: 0.5s; }
.sparkle-3 { bottom: 20%; left: 30%; animation-delay: 1s; }

@keyframes sparkle {
  0%, 100% { opacity: 0; transform: scale(0); }
  50% { opacity: 1; transform: scale(1); }
}

.theme-btn {
  padding: 0.5rem 0.75rem;
  border-radius: 9999px;
  background: rgba(168, 85, 247, 0.2);
  border: 1px solid rgba(168, 85, 247, 0.4);
  color: white;
  font-size: 0.75rem;
  font-weight: 500;
  transition: all 0.3s;
  cursor: pointer;
  white-space: nowrap;
}

@media (min-width: 768px) {
  .theme-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
  }
}

.theme-btn:hover {
  background: rgba(168, 85, 247, 0.4);
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.4);
}

.theme-btn.active {
  background: linear-gradient(135deg, #a855f7, #ec4899);
  border-color: transparent;
  box-shadow: 0 0 25px rgba(168, 85, 247, 0.6);
}

.editor-container {
  display: flex;
  background: #1e1e2e;
  border-radius: 12px;
  border: 1px solid rgba(168, 85, 247, 0.3);
  overflow: hidden;
  max-height: 250px;
}

@media (min-width: 1024px) {
  .editor-container {
    max-height: 400px;
  }
}

.line-numbers {
  padding: 0.75rem 0.5rem;
  background: rgba(0, 0, 0, 0.3);
  color: rgba(168, 85, 247, 0.5);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.625rem;
  line-height: 1.4rem;
  text-align: right;
  user-select: none;
  min-width: 30px;
  overflow-y: auto;
}

@media (min-width: 768px) {
  .line-numbers {
    padding: 1rem 0.5rem;
    font-size: 0.75rem;
    line-height: 1.5rem;
    min-width: 40px;
  }
}

.code-input {
  flex: 1;
  padding: 0.75rem;
  background: transparent;
  color: #e2e8f0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.625rem;
  line-height: 1.4rem;
  border: none;
  outline: none;
  resize: none;
  min-height: 200px;
}

@media (min-width: 768px) {
  .code-input {
    padding: 1rem;
    font-size: 0.75rem;
    line-height: 1.5rem;
    min-height: 300px;
  }
}

.btn-run {
  padding: 0.625rem 1rem;
  background: linear-gradient(135deg, #22c55e, #10b981);
  border: none;
  border-radius: 9999px;
  color: white;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.4);
}

@media (min-width: 768px) {
  .btn-run {
    padding: 0.75rem 1.5rem;
  }
}

.btn-run:hover {
  transform: scale(1.05);
  box-shadow: 0 0 30px rgba(34, 197, 94, 0.6);
}

.btn-secondary {
  padding: 0.625rem 0.875rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 9999px;
  color: white;
  font-weight: 500;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.3s;
  backdrop-filter: blur(8px);
}

@media (min-width: 768px) {
  .btn-secondary {
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
  }
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(168, 85, 247, 0.5);
}

.canvas-container {
  background: #0a0a12;
  border-radius: 16px;
  border: 2px solid transparent;
  background-clip: padding-box;
  position: relative;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 10px;
}

@media (min-width: 768px) {
  .canvas-container {
    min-height: 350px;
  }
}

.canvas-container::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(135deg, #a855f7, #ec4899, #f97316, #a855f7);
  border-radius: 18px;
  z-index: -1;
  animation: border-rotate 4s linear infinite;
  background-size: 300% 300%;
}

@keyframes border-rotate {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.canvas-container canvas {
  border-radius: 14px;
  max-width: 100%;
  max-height: 100%;
}

.error-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 15, 26, 0.9);
  color: #f87171;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  padding: 1rem;
  text-align: center;
  border-radius: 14px;
}

@media (min-width: 768px) {
  .error-overlay {
    font-size: 0.875rem;
  }
}

.controls-panel {
  background: rgba(30, 30, 46, 0.8);
  backdrop-filter: blur(16px);
  border-radius: 12px;
  padding: 1rem;
  border: 1px solid rgba(168, 85, 247, 0.2);
}

@media (min-width: 768px) {
  .controls-panel {
    padding: 1.5rem;
  }
}

.slider-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

@media (min-width: 768px) {
  .slider-group {
    gap: 0.5rem;
  }
}

.slider-group label {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.8);
}

@media (min-width: 768px) {
  .slider-group label {
    font-size: 0.875rem;
  }
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(168, 85, 247, 0.3);
  border-radius: 3px;
  outline: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: linear-gradient(135deg, #a855f7, #ec4899);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.2s;
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: linear-gradient(135deg, #a855f7, #ec4899);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.palette-select {
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: 8px;
  color: white;
  outline: none;
  cursor: pointer;
  font-size: 0.875rem;
  width: 100%;
}

.palette-select:focus {
  border-color: #a855f7;
}

.gallery-scroll {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding: 1rem 0;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 768px) {
  .gallery-scroll {
    gap: 1rem;
  }
}

.gallery-scroll::-webkit-scrollbar {
  height: 8px;
}

.gallery-scroll::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.gallery-scroll::-webkit-scrollbar-thumb {
  background: linear-gradient(90deg, #a855f7, #ec4899);
  border-radius: 4px;
}

.gallery-card {
  flex-shrink: 0;
  width: 120px;
  background: rgba(30, 30, 46, 0.8);
  border-radius: 12px;
  padding: 0.75rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  border: 1px solid rgba(168, 85, 247, 0.2);
  scroll-snap-align: start;
}

@media (min-width: 768px) {
  .gallery-card {
    width: 150px;
    padding: 1rem;
  }
}

.gallery-card:hover {
  transform: translateY(-4px);
  border-color: #a855f7;
  box-shadow: 0 10px 30px rgba(168, 85, 247, 0.3);
}

.gallery-preview {
  width: 100%;
  aspect-ratio: 1;
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.2), rgba(236, 72, 153, 0.2));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tooltip-bubble {
  background: rgba(168, 85, 247, 0.9);
  backdrop-filter: blur(8px);
  padding: 0.625rem 0.875rem;
  border-radius: 12px;
  font-size: 0.75rem;
  animation: float 2s ease-in-out infinite;
  max-width: 200px;
}

@media (min-width: 768px) {
  .tooltip-bubble {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    max-width: none;
  }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -20px;
  animation: confetti-fall 2s ease-out forwards;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}