:root {
  --bg-primary: #0d0f14;
  --bg-secondary: #161922;
  --bg-tertiary: #1e222d;
  --text-primary: #e4e8f1;
  --text-secondary: #8b93a7;
  --accent-purple: #8b5cf6;
  --accent-indigo: #6366f1;
  --accent-green: #10b981;
  --accent-orange: #f59e0b;
  --accent-blue: #3b82f6;
  --accent-pink: #ec4899;
  --error-red: #ef4444;
  --gradient-header: linear-gradient(135deg, #4c1d95 0%, #312e81 50%, #1e1b4b 100%);
}

.light {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-tertiary: #e2e8f0;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
}

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

body {
  font-family: 'Space Grotesk', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  background: var(--gradient-header);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}

.header::before {
  content: '{ } [ ] : , " "';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 4rem;
  opacity: 0.05;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 2rem;
}

.header-content {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-title h1 {
  font-size: 1.8rem;
  font-weight: 700;
  background: linear-gradient(90deg, #fff, #c4b5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-brace {
  font-family: 'JetBrains Mono', monospace;
  font-size: 2.5rem;
  color: var(--accent-purple);
  font-weight: 300;
  animation: pulse-brace 2s ease-in-out infinite;
}

@keyframes pulse-brace {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

.header-berry {
  font-size: 1.5rem;
  animation: bounce-berry 1s ease-in-out infinite;
}

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

.header-subtitle {
  color: #c4b5fd;
  font-size: 0.9rem;
  flex: 1;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

.theme-toggle, .cheat-toggle {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.theme-toggle:hover, .cheat-toggle:hover {
  background: rgba(255,255,255,0.2);
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  padding: 1rem;
  gap: 1rem;
}

/* Stepper */
.stepper {
  width: 200px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stepper-inner {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.85rem;
  text-align: left;
  transition: all 0.2s;
}

.step-item:hover {
  background: var(--bg-tertiary);
}

.step-item.active {
  background: var(--accent-purple);
  color: white;
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.4);
}

.step-item.completed {
  color: var(--accent-green);
}

.step-icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
}

.step-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badges-section {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 1rem;
}

.badges-section h3 {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.badges-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.badge {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 1.2rem;
  transition: transform 0.2s;
}

.badge.earned {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-indigo));
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
}

.badge.locked {
  background: var(--bg-tertiary);
  opacity: 0.4;
  filter: grayscale(1);
}

.badge.earned:hover {
  transform: scale(1.1);
}

/* Split Panel */
.split-panel {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  min-width: 0;
}

/* Tutorial Panel */
.tutorial-panel {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow: auto;
}

.tutorial-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.tutorial-icon {
  font-size: 1.5rem;
}

.tutorial-header h2 {
  font-size: 1.3rem;
  font-weight: 600;
}

.tutorial-content {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

.tutorial-content p {
  margin-bottom: 1rem;
  white-space: pre-line;
}

.challenge-box {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(99, 102, 241, 0.1));
  border: 1px solid var(--accent-purple);
  border-radius: 8px;
  padding: 1rem;
}

.challenge-box h4 {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.challenge-box p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Mascot */
.mascot-container {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.mascot {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  animation: float 3s ease-in-out infinite;
}

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

.mascot-brace {
  color: var(--accent-purple);
  font-size: 1.5rem;
}

.mascot-face {
  margin: 0 0.25rem;
}

.mascot-bubble {
  background: var(--bg-tertiary);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  position: relative;
}

.mascot-bubble::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-right-color: var(--bg-tertiary);
}

/* Editor Panel */
.editor-panel {
  background: var(--bg-secondary);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--bg-tertiary);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.line-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
}

.editor-container {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 250px;
}

.line-numbers {
  padding: 1rem 0.75rem;
  background: rgba(0,0,0,0.2);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-align: right;
  user-select: none;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

.line-numbers span.error-line {
  color: var(--error-red);
  background: rgba(239, 68, 68, 0.2);
  margin: 0 -0.75rem;
  padding: 0 0.75rem;
}

.code-editor {
  flex: 1;
  background: transparent;
  border: none;
  padding: 1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--text-primary);
  resize: none;
  outline: none;
  line-height: 1.5;
}

.validation-box {
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
}

.validation-box.valid {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
}

.validation-box.invalid {
  background: rgba(239, 68, 68, 0.15);
  color: var(--error-red);
}

.preview-panel {
  padding: 1rem;
  border-top: 1px solid var(--bg-tertiary);
  max-height: 200px;
  overflow: auto;
}

.preview-panel h4 {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.tree-view {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
}

.tree-node {
  line-height: 1.6;
}

.tree-toggle {
  cursor: pointer;
  margin-right: 0.25rem;
  color: var(--text-secondary);
  font-size: 0.7rem;
}

.tree-bracket {
  color: var(--text-secondary);
}

.tree-children {
  margin-left: 1rem;
}

.tree-index {
  color: var(--text-secondary);
}

.tree-comma {
  color: var(--text-secondary);
}

.tree-collapsed {
  color: var(--text-secondary);
}

.json-key {
  color: var(--accent-blue);
}

.json-string {
  color: var(--accent-green);
}

.json-number {
  color: var(--accent-orange);
}

.json-boolean {
  color: var(--accent-purple);
}

.json-null {
  color: var(--accent-pink);
}

/* Cheat Sheet */
.cheat-sheet {
  width: 220px;
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 1rem;
  flex-shrink: 0;
}

.cheat-sheet h3 {
  font-size: 0.9rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.cheat-item {
  margin-bottom: 1rem;
}

.cheat-item h4 {
  font-size: 0.75rem;
  color: var(--accent-purple);
  margin-bottom: 0.25rem;
}

.cheat-item code {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--accent-green);
  background: var(--bg-tertiary);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  margin-bottom: 0.25rem;
}

.cheat-item small {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* Templates Bar */
.templates-bar {
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  padding: 0 1rem 1rem;
}

.templates-bar h3 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.templates-grid {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.template-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.template-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent-purple);
}

.template-icon {
  font-size: 1.1rem;
}

/* Footer */
.footer {
  background: var(--bg-secondary);
  padding: 1rem;
}

.footer-actions {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn.download {
  background: var(--accent-green);
  color: white;
}

.action-btn.download:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.action-btn.copy {
  background: var(--accent-blue);
  color: white;
}

.action-btn.copied {
  background: var(--accent-green);
}

.remix-link {
  color: var(--accent-purple);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.2s;
}

.remix-link:hover {
  color: var(--accent-pink);
}

/* Confetti */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 100vh;
  pointer-events: none;
  z-index: 1000;
  overflow: hidden;
}

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

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

/* Mobile Responsiveness */
@media (max-width: 1024px) {
  .main-content {
    flex-direction: column;
  }
  
  .stepper {
    width: 100%;
    flex-direction: row;
    gap: 1rem;
  }
  
  .stepper-inner {
    flex-direction: row;
    overflow-x: auto;
    flex: 1;
  }
  
  .step-item {
    flex-shrink: 0;
  }
  
  .badges-section {
    display: none;
  }
  
  .split-panel {
    grid-template-columns: 1fr;
  }
  
  .cheat-sheet {
    width: 100%;
    order: 10;
  }
}

@media (max-width: 640px) {
  .header-content {
    flex-direction: column;
    text-align: center;
  }
  
  .header-subtitle {
    text-align: center;
  }
  
  .header-actions {
    justify-content: center;
  }
  
  .step-title {
    display: none;
  }
  
  .footer-actions {
    flex-direction: column;
  }
  
  .action-btn {
    width: 100%;
    justify-content: center;
  }
}