:root {
  /* Monokai Color Palette */
  --bg-primary: #0d0d0d;
  --bg-secondary: #1e1e1e;
  --bg-tertiary: #252526;
  --bg-elevated: #2d2d30;
  
  /* Accent Colors (Monokai) */
  --accent-green: #a6e22e;
  --accent-pink: #f92672;
  --accent-orange: #fd971f;
  --accent-yellow: #e6db74;
  --accent-purple: #ae81ff;
  --accent-cyan: #66d9ef;
  
  /* Text Colors */
  --text-primary: #f8f8f2;
  --text-secondary: #888888;
  --text-muted: #5a5a5a;
  
  /* Glow Effects */
  --glow-green: 0 0 10px rgba(166, 226, 46, 0.5), 0 0 20px rgba(166, 226, 46, 0.3);
  --glow-pink: 0 0 10px rgba(249, 38, 114, 0.5), 0 0 20px rgba(249, 38, 114, 0.3);
  --glow-cyan: 0 0 10px rgba(102, 217, 239, 0.5), 0 0 20px rgba(102, 217, 239, 0.3);
  
  /* Spacing */
  --control-bar-height: 80px;
  --border-radius: 8px;
}

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

body {
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
}

.app-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
}

.credit {
  position: fixed;
  top: 16px;
  right: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent-pink);
  opacity: 0.7;
  z-index: 10;
  transition: opacity 0.2s ease;
}

.credit:hover {
  opacity: 1;
}

.credit.hidden {
  display: none;
}

.mobile-hint {
  display: none;
}

.view-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.dual-view {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: center;
  padding: 20px;
  max-height: calc(100vh - var(--control-bar-height) - 40px);
}

.video-container,
.canvas-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.view-label {
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 4px 12px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  white-space: nowrap;
}

.video-container .view-label {
  color: var(--accent-orange);
}

.canvas-container .view-label {
  color: var(--accent-cyan);
}

#webcam {
  max-width: calc(45vw - 30px);
  max-height: calc(100vh - var(--control-bar-height) - 80px);
  border: 2px solid var(--bg-tertiary);
  border-radius: var(--border-radius);
  box-shadow: 
    0 0 0 1px var(--bg-elevated),
    0 10px 30px rgba(0, 0, 0, 0.4);
  transform: scaleX(-1); /* Mirror the video */
}

#shader-canvas {
  max-width: calc(45vw - 30px);
  max-height: calc(100vh - var(--control-bar-height) - 80px);
  border: 2px solid var(--bg-tertiary);
  border-radius: var(--border-radius);
  box-shadow: 
    0 0 0 1px var(--bg-elevated),
    0 10px 30px rgba(0, 0, 0, 0.4);
}

.loading-state {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  z-index: 100;
}

.loading-state.hidden {
  display: none;
}

.loading-content {
  text-align: center;
}

.terminal-prompt {
  font-size: 1.2rem;
  margin-bottom: 2rem;
  color: var(--text-secondary);
}

.prompt-symbol {
  color: var(--accent-green);
  margin-right: 0.5rem;
}

.prompt-text {
  color: var(--accent-cyan);
}

.cursor-blink {
  color: var(--accent-green);
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.start-btn {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 1rem 2rem;
  background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-elevated));
  border: 1px solid var(--accent-green);
  border-radius: var(--border-radius);
  color: var(--accent-green);
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
}

.start-btn:hover {
  background: var(--accent-green);
  color: var(--bg-primary);
  box-shadow: var(--glow-green);
  transform: translateY(-2px);
}

.btn-icon {
  font-size: 0.8rem;
}

.control-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--control-bar-height);
  background: linear-gradient(to top, var(--bg-secondary), rgba(30, 30, 30, 0.95));
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--bg-tertiary);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 2rem;
}

.control-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 800px;
  gap: 2rem;
}

.style-switcher {
  display: flex;
  gap: 0.5rem;
  background: var(--bg-primary);
  padding: 0.5rem;
  border-radius: var(--border-radius);
  border: 1px solid var(--bg-tertiary);
}

.style-btn {
  font-family: inherit;
  background: transparent;
  border: none;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  min-width: 90px;
}

.style-btn:hover {
  background: var(--bg-tertiary);
}

.style-btn.active {
  background: var(--bg-elevated);
}

.style-btn[data-style="binary"].active {
  box-shadow: inset 0 0 0 1px var(--accent-green);
}

.style-btn[data-style="regex"].active {
  box-shadow: inset 0 0 0 1px var(--accent-pink);
}

.style-btn[data-style="source"].active {
  box-shadow: inset 0 0 0 1px var(--accent-cyan);
}

.style-icon {
  font-size: 1.1rem;
  font-weight: 700;
  transition: color 0.2s ease;
}

.style-btn[data-style="binary"] .style-icon {
  color: var(--accent-green);
}

.style-btn[data-style="regex"] .style-icon {
  color: var(--accent-pink);
}

.style-btn[data-style="source"] .style-icon {
  color: var(--accent-cyan);
}

.style-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
}

.style-subtitle {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.timer-selector {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.timer-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.timer-options {
  display: flex;
  gap: 0.25rem;
  background: var(--bg-primary);
  padding: 0.25rem;
  border-radius: 6px;
  border: 1px solid var(--bg-tertiary);
}

.timer-btn {
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.timer-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.timer-btn.active {
  background: var(--accent-yellow);
  color: var(--bg-primary);
}

.countdown-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(13, 13, 13, 0.7);
  z-index: 150;
  pointer-events: none;
}

.countdown-overlay.hidden {
  display: none;
}

.countdown-number {
  font-size: 12rem;
  font-weight: 700;
  color: var(--accent-yellow);
  text-shadow: 
    0 0 40px rgba(230, 219, 116, 0.8),
    0 0 80px rgba(230, 219, 116, 0.5),
    0 0 120px rgba(230, 219, 116, 0.3);
  animation: countdown-pulse 1s ease-in-out;
}

@keyframes countdown-pulse {
  0% {
    transform: scale(1.5);
    opacity: 0;
  }
  20% {
    transform: scale(1);
    opacity: 1;
  }
  80% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(0.8);
    opacity: 0;
  }
}

.action-buttons {
  display: flex;
  gap: 0.5rem;
}

.capture-btn {
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.5rem;
  background: linear-gradient(135deg, var(--accent-pink), #c41e5c);
  border: none;
  border-radius: var(--border-radius);
  color: white;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(249, 38, 114, 0.3);
}

.capture-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--glow-pink);
}

.capture-btn:active {
  transform: translateY(0);
}

.capture-icon svg {
  width: 20px;
  height: 20px;
}

.record-btn {
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.5rem;
  background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-elevated));
  border: 1px solid var(--accent-orange);
  border-radius: var(--border-radius);
  color: var(--accent-orange);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(253, 151, 31, 0.15);
}

.record-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 10px rgba(253, 151, 31, 0.5), 0 0 20px rgba(253, 151, 31, 0.3);
}

.record-btn:active {
  transform: translateY(0);
}

.record-btn.recording {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  border-color: #e74c3c;
  color: white;
  animation: recording-pulse 1.5s ease-in-out infinite;
  box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
}

@keyframes recording-pulse {
  0%, 100% { box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4); }
  50% { box-shadow: 0 4px 25px rgba(231, 76, 60, 0.7); }
}

.record-icon svg {
  width: 20px;
  height: 20px;
}

.flash {
  position: fixed;
  inset: 0;
  background: white;
  opacity: 0;
  pointer-events: none;
  z-index: 200;
}

.flash.active {
  animation: flash-animation 0.3s ease-out;
}

@keyframes flash-animation {
  0% { opacity: 0.8; }
  100% { opacity: 0; }
}

@media (max-width: 1024px) {
  body {
    overflow-y: auto;
    overflow-x: hidden;
  }
  
  .app-container {
    height: auto;
    min-height: 100vh;
    padding-bottom: 200px;
  }
  
  .dual-view {
    flex-direction: row;
    gap: 10px;
    padding-top: 40px;
    max-height: none;
    width: 100%;
    align-items: center;
    justify-content: center;
  }
  
  .video-container,
  .canvas-container {
    width: 46vw;
  }
  
  #webcam,
  #shader-canvas {
    width: 100%;
    max-width: 46vw;
    max-height: none;
  }
}

@media (max-width: 768px) {
  .mobile-hint {
    display: block;
    width: 100%;
    text-align: center;
    font-size: 0.65rem;
    color: var(--text-muted);
    padding: 10px 0 0;
    letter-spacing: 0.5px;
  }
  
  .app-container {
    padding-bottom: 260px;
  }
  
  .control-bar {
    height: auto;
    padding: 1rem;
  }
  
  .control-bar-inner {
    flex-direction: column;
    gap: 1rem;
  }
  
  .style-switcher {
    width: 100%;
    justify-content: center;
  }
  
  .style-btn {
    flex: 1;
    min-width: auto;
    padding: 0.5rem;
  }
  
  .style-subtitle {
    display: none;
  }
  
  .timer-selector {
    flex-direction: row;
    gap: 1rem;
  }
  
  .action-buttons {
    width: 100%;
  }

  .capture-btn,
  .record-btn {
    flex: 1;
    justify-content: center;
  }
  
  #webcam,
  #shader-canvas {
    max-height: none;
  }
  
  .view-label {
    font-size: 0.65rem;
  }
  
  .countdown-number {
    font-size: 8rem;
  }
}

@media (max-width: 480px) {
  .style-name {
    font-size: 0.65rem;
  }
  
  .style-icon {
    font-size: 1rem;
  }
}
