/* === RESET & BASE === */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --cyan: #00f0ff;
  --green: #00ff88;
  --red: #ff3366;
  --yellow: #ffcc00;
  --purple: #b44dff;
  --bg: #0a0e17;
  --bg-card: #111827;
  --bg-card-border: #1e293b;
  --text: #e2e8f0;
  --text-dim: #64748b;
  --font-mono: 'Share Tech Mono', monospace;
  --font-display: 'Orbitron', sans-serif;
  --font-body: 'Inter', sans-serif;
}

html, body {
  height: 100%;
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  position: relative;
}

/* === BACKGROUND EFFECTS === */
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
}

.grid-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.04;
  background-image:
    linear-gradient(var(--cyan) 1px, transparent 1px),
    linear-gradient(90deg, var(--cyan) 1px, transparent 1px);
  background-size: 60px 60px;
}

/* === APP CONTAINER === */
#app {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  position: relative;
  z-index: 1;
}

/* === SCREENS === */
.screen {
  display: none;
  width: 100%;
  max-width: 640px;
  animation: fadeIn 0.5s ease;
}

.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === LOGO === */
.logo-container {
  text-align: center;
  margin-bottom: 2rem;
}

.logo-icon {
  width: 100px;
  height: 100px;
  margin: 0 auto 1.5rem;
  color: var(--cyan);
  animation: float 3s ease-in-out infinite;
}

.robot-svg {
  width: 100%;
  height: 100%;
}

.eye {
  animation: blink 4s infinite;
}

.antenna {
  animation: glow 2s ease-in-out infinite alternate;
}

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

@keyframes blink {
  0%, 90%, 100% { opacity: 1; }
  95% { opacity: 0; }
}

@keyframes glow {
  from { fill: var(--cyan); filter: drop-shadow(0 0 4px var(--cyan)); }
  to { fill: var(--green); filter: drop-shadow(0 0 8px var(--green)); }
}

/* === TITLE === */
.title {
  font-family: var(--font-display);
  font-size: 3.5rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  color: var(--cyan);
  text-shadow: 0 0 30px rgba(0, 240, 255, 0.3);
  position: relative;
}

.glitch {
  animation: glitch 5s infinite;
}

@keyframes glitch {
  0%, 90%, 100% { text-shadow: 0 0 30px rgba(0, 240, 255, 0.3); }
  91% { text-shadow: 3px 0 var(--red), -3px 0 var(--green); }
  92% { text-shadow: -3px 0 var(--red), 3px 0 var(--green); }
  93% { text-shadow: 0 0 30px rgba(0, 240, 255, 0.3); }
  96% { text-shadow: 2px 0 var(--purple), -2px 0 var(--yellow); }
  97% { text-shadow: 0 0 30px rgba(0, 240, 255, 0.3); }
}

.subtitle {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--text-dim);
  margin-top: 0.25rem;
  letter-spacing: 0.1em;
}

.highlight {
  color: var(--green);
  font-weight: 700;
}

.tagline {
  margin-top: 1rem;
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* === INFO BOX === */
.info-box {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: rgba(255, 204, 0, 0.05);
  border: 1px solid rgba(255, 204, 0, 0.2);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
  width: 100%;
}

.info-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.info-box p {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.5;
}

/* === BUTTONS === */
.btn-primary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 2.5rem;
  background: linear-gradient(135deg, var(--cyan), #0088ff);
  color: var(--bg);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 240, 255, 0.3);
}

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

.pulse {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 240, 255, 0.4); }
  50% { box-shadow: 0 0 0 15px rgba(0, 240, 255, 0); }
}

.btn-secondary {
  padding: 0.75rem 2rem;
  background: transparent;
  color: var(--cyan);
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  border: 2px solid var(--cyan);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-secondary:hover {
  background: rgba(0, 240, 255, 0.1);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.2);
}

.btn-submit {
  padding: 0.75rem 2rem;
  background: linear-gradient(135deg, var(--green), #00cc66);
  color: var(--bg);
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s;
  margin-top: 1rem;
}

.btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 255, 136, 0.3);
}

.btn-submit:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* === STATS BAR === */
.stats-bar {
  display: flex;
  gap: 2rem;
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--bg-card-border);
  width: 100%;
  justify-content: center;
}

.stat {
  text-align: center;
}

.stat-num {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.25rem;
  color: var(--cyan);
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* === CHALLENGE SCREEN === */
.challenge-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  margin-bottom: 1.5rem;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-card);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--bg-card-border);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--green));
  border-radius: 4px;
  transition: width 0.5s ease;
  width: 0%;
}

.progress-text {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text-dim);
}

.timer-display {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  color: var(--yellow);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 80px;
}

.timer-display.danger {
  color: var(--red);
  animation: timerPulse 0.5s infinite;
}

@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* === CHALLENGE CONTAINER === */
.challenge-container {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: 16px;
  padding: 2rem;
  width: 100%;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
}

.challenge-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 0.5rem;
}

.challenge-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.5rem;
  line-height: 1.4;
}

.challenge-content {
  width: 100%;
  margin-bottom: 1rem;
}

/* Challenge-specific styles */
.math-problem {
  font-family: var(--font-mono);
  font-size: 2rem;
  color: var(--cyan);
  padding: 1rem;
  background: rgba(0, 240, 255, 0.05);
  border-radius: 8px;
  border: 1px solid rgba(0, 240, 255, 0.1);
  margin-bottom: 1rem;
}

.input-answer {
  width: 100%;
  max-width: 300px;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid var(--bg-card-border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 1rem;
  text-align: center;
  outline: none;
  transition: border-color 0.3s;
}

.input-answer:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.15);
}

.input-answer::placeholder {
  color: var(--text-dim);
}

/* Binary challenge */
.binary-string {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--green);
  word-break: break-all;
  padding: 1rem;
  background: rgba(0, 255, 136, 0.05);
  border: 1px solid rgba(0, 255, 136, 0.1);
  border-radius: 8px;
  line-height: 1.8;
  margin-bottom: 1rem;
  max-height: 120px;
  overflow: hidden;
}

/* Pixel grid */
.pixel-grid-container {
  position: relative;
  display: inline-block;
  margin-bottom: 1rem;
}

.pixel-grid {
  width: 300px;
  height: 300px;
  background: #000;
  border: 2px solid var(--bg-card-border);
  border-radius: 4px;
  cursor: crosshair;
  position: relative;
  image-rendering: pixelated;
}

.pixel-coords {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
}

.click-marker {
  position: absolute;
  width: 10px;
  height: 10px;
  border: 2px solid var(--red);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* Speed type */
.type-target {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--purple);
  word-break: break-all;
  padding: 1rem;
  background: rgba(180, 77, 255, 0.05);
  border: 1px solid rgba(180, 77, 255, 0.1);
  border-radius: 8px;
  line-height: 1.8;
  margin-bottom: 1rem;
  user-select: none;
}

.input-type {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid var(--bg-card-border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.3s;
}

.input-type:focus {
  border-color: var(--purple);
  box-shadow: 0 0 15px rgba(180, 77, 255, 0.15);
}

/* Reaction test */
.reaction-circle {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: var(--red);
  margin: 1rem auto;
  cursor: pointer;
  transition: background 0.01s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  color: white;
}

.reaction-circle.go {
  background: var(--green);
}

/* Color hex challenge */
.color-swatch {
  width: 150px;
  height: 150px;
  border-radius: 12px;
  margin: 0 auto 1rem;
  border: 2px solid var(--bg-card-border);
}

/* Timestamp challenge */
.timestamp-display {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  color: var(--yellow);
  padding: 1rem;
  background: rgba(255, 204, 0, 0.05);
  border: 1px solid rgba(255, 204, 0, 0.1);
  border-radius: 8px;
  margin-bottom: 1rem;
}

/* Prime numbers */
.number-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 1rem;
  width: 100%;
}

.number-cell {
  padding: 0.6rem;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid var(--bg-card-border);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.number-cell:hover {
  border-color: var(--cyan);
  background: rgba(0, 240, 255, 0.05);
}

.number-cell.selected {
  border-color: var(--green);
  background: rgba(0, 255, 136, 0.1);
  color: var(--green);
}

/* === VERIFICATION BADGE === */
.verification-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-dim);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: dotPulse 2s infinite;
}

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

/* === RESULT SCREEN === */
.result-icon {
  font-size: 5rem;
  margin-bottom: 1rem;
}

.result-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 900;
  margin-bottom: 0.5rem;
}

.result-subtitle {
  color: var(--text-dim);
  font-size: 1rem;
  margin-bottom: 2rem;
  line-height: 1.6;
}

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: 16px;
  padding: 2rem;
  width: 100%;
  max-width: 500px;
  text-align: center;
}

.result-card.fail {
  border-color: rgba(255, 51, 102, 0.3);
}

.result-card.success {
  border-color: rgba(0, 255, 136, 0.3);
}

.score-bar {
  display: flex;
  justify-content: space-between;
  margin: 1.5rem 0;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
}

.score-item {
  text-align: center;
}

.score-value {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
}

.score-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}

.result-message {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-dim);
  padding: 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  margin: 1rem 0;
  line-height: 1.6;
}

.retry-section {
  margin-top: 1.5rem;
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* === FOOTER === */
.footer {
  text-align: center;
  padding: 2rem;
  font-size: 0.75rem;
  color: var(--text-dim);
  position: relative;
  z-index: 1;
}

.footer-small {
  font-size: 0.65rem;
  margin-top: 0.25rem;
  opacity: 0.5;
}

/* === LOADING SPINNER === */
.loading-dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin: 1rem 0;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan);
  animation: loadDot 1.2s infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes loadDot {
  0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.2); }
}

/* === CHALLENGE RESULT OVERLAY === */
.challenge-result-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(10, 14, 23, 0.95);
  border-radius: 16px;
  z-index: 10;
  animation: fadeIn 0.3s ease;
}

.challenge-result-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.challenge-result-text {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
}

.challenge-result-detail {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
}

.challenge-result-text.pass { color: var(--green); }
.challenge-result-text.fail { color: var(--red); }

/* === RESPONSIVE === */
@media (max-width: 640px) {
  .title { font-size: 2.5rem; }
  .subtitle { font-size: 1.1rem; }
  .stats-bar { gap: 1rem; }
  .challenge-container { padding: 1.5rem; }
  .math-problem { font-size: 1.25rem; }
  .number-grid { grid-template-columns: repeat(3, 1fr); }
}
