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

:root {
  --bg: #000000;
  --primary: #00FFFF;
  --secondary: #FF00FF;
  --tertiary: #FF6600;
  --text: #E0F7FF;
  --text-dim: #6B8A99;
  --glow-primary: 0 0 20px rgba(0, 255, 255, 0.5);
  --glow-secondary: 0 0 20px rgba(255, 0, 255, 0.5);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Orbitron', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

.app-container {
  min-height: 100vh;
  position: relative;
  background: 
    radial-gradient(ellipse at center, rgba(0, 40, 60, 0.3) 0%, transparent 70%),
    linear-gradient(0deg, transparent 49.9%, rgba(0, 255, 255, 0.02) 50%, transparent 50.1%),
    var(--bg);
  background-size: 100% 100%, 100% 4px, 100% 100%;
}

.scanlines {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.1) 2px,
    rgba(0, 0, 0, 0.1) 4px
  );
  pointer-events: none;
  z-index: 1000;
  opacity: 0.3;
}

.vignette {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.8) 100%);
  pointer-events: none;
  z-index: 999;
}

.system-override {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10000;
  text-align: center;
  animation: glitchIn 0.3s ease-out;
}

.override-text {
  font-size: 2rem;
  color: #FF0000;
  text-shadow: 0 0 30px #FF0000;
  animation: flicker 0.1s infinite;
}

.override-sub {
  font-size: 1rem;
  color: var(--primary);
  margin-top: 1rem;
}

@keyframes glitchIn {
  0% { transform: translate(-50%, -50%) skewX(20deg); opacity: 0; }
  100% { transform: translate(-50%, -50%) skewX(0deg); opacity: 1; }
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}

.header {
  padding: 2rem 1rem;
  text-align: center;
  border-bottom: 1px solid rgba(0, 255, 255, 0.2);
  background: linear-gradient(180deg, rgba(0, 255, 255, 0.05) 0%, transparent 100%);
}

.header-content {
  max-width: 800px;
  margin: 0 auto;
}

.logo {
  font-size: clamp(1.2rem, 4vw, 2rem);
  font-weight: 900;
  letter-spacing: 0.1em;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-shadow: var(--glow-primary);
  transition: text-shadow 0.3s;
}

.logo:hover {
  text-shadow: 0 0 40px var(--primary);
}

.logo-icon {
  font-size: 1.5em;
}

.pulse {
  animation: pulse 2s infinite;
}

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

.tagline {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.main-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.mode-selector {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.mode-card {
  background: rgba(0, 255, 255, 0.05);
  border: 1px solid rgba(0, 255, 255, 0.2);
  border-radius: 12px;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Orbitron', sans-serif;
}

.mode-card:hover:not(:disabled) {
  border-color: var(--primary);
  box-shadow: var(--glow-primary);
  transform: translateY(-2px);
}

.mode-card.active {
  background: rgba(0, 255, 255, 0.15);
  border-color: var(--primary);
  box-shadow: var(--glow-primary), inset 0 0 30px rgba(0, 255, 255, 0.1);
}

.mode-card:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.mode-icon {
  font-size: 2rem;
}

.mode-name {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text);
}

.mode-desc {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-align: center;
}

.viewport-container {
  position: relative;
  aspect-ratio: 4/3;
  max-height: 60vh;
  margin: 0 auto 2rem;
  border-radius: 16px;
  overflow: hidden;
  background: #0a0a0a;
  border: 2px solid rgba(0, 255, 255, 0.3);
  box-shadow: var(--glow-primary), inset 0 0 100px rgba(0, 255, 255, 0.05);
}

.webcam-container {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewfinder {
  position: absolute;
  top: 10%;
  left: 10%;
  right: 10%;
  bottom: 10%;
  pointer-events: none;
  z-index: 10;
}

.corner {
  position: absolute;
  width: 30px;
  height: 30px;
  border-color: var(--primary);
  border-style: solid;
  border-width: 0;
  opacity: 0.8;
}

.corner.tl { top: 0; left: 0; border-top-width: 3px; border-left-width: 3px; }
.corner.tr { top: 0; right: 0; border-top-width: 3px; border-right-width: 3px; }
.corner.bl { bottom: 0; left: 0; border-bottom-width: 3px; border-left-width: 3px; }
.corner.br { bottom: 0; right: 0; border-bottom-width: 3px; border-right-width: 3px; }

.webcam-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.webcam-video.mirrored {
  transform: scaleX(-1);
}

.loading-camera {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(0, 255, 255, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.camera-error {
  text-align: center;
  padding: 2rem;
  color: var(--text-dim);
}

.camera-error p {
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.error-actions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.retry-btn {
  background: transparent;
  border: 1px solid rgba(0, 255, 255, 0.5);
  color: var(--text);
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  transition: all 0.3s;
}

.retry-btn:hover {
  background: rgba(0, 255, 255, 0.1);
  border-color: var(--primary);
  box-shadow: var(--glow-primary);
}

.upload-btn {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: var(--bg);
  padding: 1rem 2rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  transition: all 0.3s;
}

.upload-btn:hover {
  transform: scale(1.05);
  box-shadow: var(--glow-primary);
}

.countdown {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 8rem;
  font-weight: 900;
  color: var(--primary);
  text-shadow: 0 0 60px var(--primary);
  z-index: 20;
  animation: countPop 0.5s ease-out;
}

@keyframes countPop {
  0% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.status-indicator {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(0, 255, 255, 0.3);
  border-radius: 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  z-index: 10;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: #00FF00;
  border-radius: 50%;
  animation: blink 1s infinite;
}

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

.preview-container,
.processing-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.captured-image,
.processing-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.preview-label {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem 1rem;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid var(--primary);
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
}

.scan-animation {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scan-line {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, transparent, var(--primary), var(--secondary), transparent);
  box-shadow: 0 0 20px var(--primary), 0 0 40px var(--secondary);
  animation: scanMove 2s linear infinite;
}

@keyframes scanMove {
  0% { top: 0; }
  100% { top: 100%; }
}

.processing-text {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--primary);
  text-shadow: var(--glow-primary);
}

.typewriter {
  overflow: hidden;
  white-space: nowrap;
  animation: typewriter 2s steps(30) infinite;
}

@keyframes typewriter {
  0%, 100% { width: 0; }
  50%, 80% { width: 100%; }
}

.result-container {
  width: 100%;
  height: 100%;
  padding: 1rem;
}

.comparison {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 100%;
}

.comparison-item {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.comparison-item img {
  max-width: 100%;
  max-height: calc(100% - 30px);
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid rgba(0, 255, 255, 0.2);
}

.comparison-item.result img {
  border-color: var(--secondary);
  box-shadow: var(--glow-secondary);
}

.comparison-label {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

.comparison-divider {
  font-size: 1.5rem;
  color: var(--primary);
  text-shadow: var(--glow-primary);
  animation: arrowPulse 1s infinite;
}

@keyframes arrowPulse {
  0%, 100% { opacity: 1; transform: translateX(0); }
  50% { opacity: 0.5; transform: translateX(5px); }
}

.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.capture-btn {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(0, 255, 255, 0.1), rgba(255, 0, 255, 0.1));
  border: 4px solid transparent;
  background-clip: padding-box;
  position: relative;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.capture-btn::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary), var(--tertiary));
  z-index: -1;
  animation: borderRotate 3s linear infinite;
}

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

.capture-btn:hover:not(:disabled) {
  transform: scale(1.1);
  box-shadow: 0 0 40px var(--primary);
}

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

.capture-inner {
  font-size: 2.5rem;
  color: var(--primary);
}

.capture-label {
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  color: var(--text);
  font-family: 'Orbitron', sans-serif;
}

.secondary-controls {
  display: flex;
  gap: 1rem;
}

.icon-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(0, 255, 255, 0.1);
  border: 1px solid rgba(0, 255, 255, 0.3);
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: rgba(0, 255, 255, 0.2);
  border-color: var(--primary);
  box-shadow: var(--glow-primary);
  transform: translateY(-2px);
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
}

.action-btn {
  padding: 1rem 2rem;
  border-radius: 8px;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.3s;
  border: none;
}

.action-btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: var(--bg);
  box-shadow: var(--glow-primary);
}

.action-btn.primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 0 40px var(--primary);
}

.action-btn.secondary {
  background: transparent;
  border: 1px solid rgba(0, 255, 255, 0.5);
  color: var(--text);
}

.action-btn.secondary:hover {
  background: rgba(0, 255, 255, 0.1);
  border-color: var(--primary);
}

.gallery-section {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid rgba(0, 255, 255, 0.1);
}

.gallery-toggle {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  transition: color 0.3s;
}

.gallery-toggle:hover {
  color: var(--primary);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 1rem;
}

.gallery-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(0, 255, 255, 0.2);
  cursor: pointer;
  transition: all 0.3s;
}

.gallery-item:hover {
  border-color: var(--primary);
  box-shadow: var(--glow-primary);
  transform: scale(1.05);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.delete-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 0, 0, 0.8);
  border: none;
  color: white;
  font-size: 1rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.3s;
}

.gallery-item:hover .delete-btn {
  opacity: 1;
}

.footer {
  text-align: center;
  padding: 2rem 1rem;
  border-top: 1px solid rgba(0, 255, 255, 0.1);
  background: linear-gradient(0deg, rgba(0, 255, 255, 0.02) 0%, transparent 100%);
}

.footer p {
  margin-bottom: 0.5rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.footer a {
  color: var(--primary);
  text-decoration: none;
  transition: text-shadow 0.3s;
}

.footer a:hover {
  text-shadow: var(--glow-primary);
}

.credit {
  font-size: 0.75rem !important;
}

.disclaimer {
  font-size: 0.7rem !important;
  opacity: 0.6;
  margin-top: 1rem !important;
}

@media (max-width: 600px) {
  .viewport-container {
    aspect-ratio: 3/4;
    max-height: 50vh;
  }
  
  .comparison {
    flex-direction: column;
  }
  
  .comparison-divider {
    transform: rotate(90deg);
  }
  
  .mode-selector {
    grid-template-columns: 1fr;
  }
  
  .mode-card {
    flex-direction: row;
    justify-content: flex-start;
    text-align: left;
  }
  
  .mode-icon {
    font-size: 1.5rem;
  }
  
  .action-buttons {
    flex-direction: column;
    width: 100%;
  }
  
  .action-btn {
    width: 100%;
  }
}