:root {
  --primary: #4f46e5;
  --primary-light: #6366f1;
  --secondary: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --light: #f8fafc;
  --dark: #1e293b;
  --gray: #64748b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Poppins', sans-serif;
  background: linear-gradient(135deg, #1e3a8a, #3b82f6);
  color: white;
  min-height: 100vh;
  text-align: center;
  overflow-x: hidden;
  position: relative;
}

.background-animation {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: url('https://assets.codepen.io/21542/brain-academy-bg.png') center/cover;
  opacity: 0.1;
  z-index: -1;
  animation: float 15s infinite ease-in-out;
}

@keyframes float {
  0%, 100% {
    transform: translate(0, 0);
  }
  25% {
    transform: translate(-5px, -5px);
  }
  50% {
    transform: translate(5px, 5px);
  }
  75% {
    transform: translate(5px, -5px);
  }
}

.screen {
  padding: 20px;
  max-width: 800px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.hidden {
  display: none !important;
}

/* Start Screen */
.logo {
  margin-bottom: 2rem;
  text-align: center;
}

.brain-icon {
  font-size: 5rem;
  margin-bottom: 1rem;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.logo h1 {
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  background: linear-gradient(to right, #fff, #c7d2fe);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-size: 1.2rem;
  color: #cbd5e1;
  font-weight: 300;
}

.mode-selector, .difficulty-selector {
  margin: 2rem 0;
  width: 100%;
}

.mode-selector h2, .difficulty-selector h2 {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  font-weight: 400;
}

.mode-buttons, .difficulty-buttons {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.mode-btn, .difficulty-btn {
  padding: 1rem 2rem;
  font-size: 1.2rem;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.mode-btn:hover, .difficulty-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}

.mode-btn:active, .difficulty-btn:active {
  transform: translateY(1px);
}

.calculation {
  background-color: #3b82f6;
  color: white;
}

.comparison {
  background-color: #10b981;
  color: white;
}

.easy {
  background-color: #10b981;
  color: white;
}

.medium {
  background-color: #f59e0b;
  color: white;
}

.hard {
  background-color: #ef4444;
  color: white;
}

.emoji {
  font-size: 1.5rem;
}

/* Game Screen */
.hud {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background-color: rgba(30, 41, 59, 0.7);
  border-radius: 12px;
  margin-bottom: 2rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.hud-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.2rem;
}

.hud-icon {
  font-size: 1.5rem;
}

.game-content {
  width: 100%;
  background-color: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.question-text {
  font-size: 2.5rem;
  margin-bottom: 2rem;
  font-weight: 600;
  line-height: 1.4;
  color: white;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.answer-container {
  margin-bottom: 2rem;
}

/* Calculation Mode */
#answer-input {
  font-size: 2rem;
  padding: 1rem;
  width: 200px;
  text-align: center;
  border-radius: 8px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
  margin-bottom: 1rem;
}

#answer-input:focus {
  outline: none;
  border-color: var(--primary);
}

#submit-button-calc {
  padding: 1rem 2rem;
  font-size: 1.2rem;
  background-color: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

#submit-button-calc:hover {
  background-color: var(--primary-light);
}

/* Comparison Mode */
.comparison-options {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.comparison-options button {
  font-size: 2rem;
  padding: 1rem 2rem;
  min-width: 80px;
  background-color: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.comparison-options button:hover {
  background-color: var(--primary-light);
}

/* Feedback */
.feedback-container {
  min-height: 100px;
}

.feedback-text {
  font-size: 1.8rem;
  font-weight: 600;
  margin-bottom: 1rem;
  min-height: 2.5rem;
}

.correct-feedback {
  color: var(--secondary);
}

.incorrect-feedback {
  color: var(--danger);
}

.combo-counter {
  background-color: rgba(255, 215, 0, 0.2);
  border: 2px solid gold;
  border-radius: 50px;
  padding: 0.5rem 1rem;
  display: inline-block;
  font-weight: 600;
  color: gold;
  animation: comboPulse 1s infinite;
}

@keyframes comboPulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.8; }
  100% { transform: scale(1); opacity: 1; }
}

/* Countdown */
#countdown-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

#countdown-overlay.active {
  opacity: 1;
  pointer-events: all;
}

#countdown {
  font-size: 8rem;
  font-weight: 700;
  color: white;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.8);
}

/* End Screen */
.result-card {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.9), rgba(99, 102, 241, 0.9));
  padding: 2rem;
  border-radius: 16px;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.result-card h2 {
  font-size: 2rem;
  margin-bottom: 1rem;
}

.result-icon {
  font-size: 4rem;
  margin: 1rem 0;
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-20px); }
}

.final-score {
  font-size: 2.5rem;
  font-weight: 700;
  margin: 1rem 0;
}

.stats {
  margin: 1.5rem 0;
  font-size: 1.1rem;
  text-align: left;
  background-color: rgba(255, 255, 255, 0.1);
  padding: 1rem;
  border-radius: 8px;
}

.stats p {
  margin: 0.5rem 0;
}

.restart-btn {
  padding: 1rem 2rem;
  font-size: 1.2rem;
  background-color: white;
  color: var(--primary);
  border: none;
  border-radius: 50px;
  cursor: pointer;
  margin-top: 1rem;
  font-weight: 600;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.restart-btn:hover {
  background-color: var(--primary-light);
  color: white;
  transform: translateY(-2px);
}

/* Footer */
.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 1rem;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.6);
  background-color: rgba(0, 0, 0, 0.2);
}

/* Responsive */
@media (max-width: 768px) {
  .mode-buttons, .difficulty-buttons {
    flex-direction: column;
    width: 100%;
  }
  
  .mode-btn, .difficulty-btn {
    width: 100%;
    justify-content: center;
  }
  
  .question-text {
    font-size: 2rem;
  }
  
  .comparison-options {
    flex-direction: column;
  }
  
  .comparison-options button {
    width: 100%;
  }
  
  #answer-input {
    width: 100%;
  }
}