@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;600;700&family=JetBrains+Mono:wght@400;700&display=swap");

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --secondary: #ec4899;
  --accent: #06b6d4;
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --dark: #0f172a;
  --darker: #020617;
  --glass: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);
}

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

body {
  font-family: "Space Grotesk", sans-serif;
  background: var(--darker);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative;
  color: #e2e8f0;
}

/* Animated Background */
.bg-animation {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  background:
    radial-gradient(
      circle at 20% 80%,
      rgba(99, 102, 241, 0.15) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 80% 20%,
      rgba(236, 72, 153, 0.15) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 40% 40%,
      rgba(6, 182, 212, 0.1) 0%,
      transparent 40%
    );
}

.particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: hidden;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--primary);
  border-radius: 50%;
  opacity: 0.5;
  animation: float 15s infinite;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0) translateX(0);
    opacity: 0;
  }
  10% {
    opacity: 0.5;
  }
  90% {
    opacity: 0.5;
  }
  100% {
    transform: translateY(-100vh) translateX(50px);
    opacity: 0;
  }
}

/* Main Container */
.quiz-container {
  width: 90%;
  max-width: 800px;
  background: var(--glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 40px;
  box-shadow:
    0 25px 50px -12px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.05) inset;
  position: relative;
  overflow: hidden;
}

.quiz-container::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--primary),
    var(--secondary),
    transparent
  );
  animation: scan 4s linear infinite;
}

@keyframes scan {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

/* Header */
.game-header {
  text-align: center;
  margin-bottom: 30px;
}

.game-header img {
  width: 150px;
  height: 150px;
  border-radius: 50%;
}

.logo {
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(
    135deg,
    var(--primary),
    var(--secondary),
    var(--accent)
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px;
  letter-spacing: -1px;
}

.subtitle {
  color: #64748b;
  font-size: 1.1rem;
  font-weight: 300;
}

/* Screens */
.screen {
  display: none;
  animation: fadeIn 0.5s ease;
}

.screen.active {
  display: block;
}

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

/* Input Styling */
.input-group {
  position: relative;
  margin-bottom: 30px;
}

.input-field {
  width: 100%;
  padding: 16px 20px;
  background: rgba(15, 23, 42, 0.6);
  border: 2px solid var(--glass-border);
  border-radius: 12px;
  color: #fff;
  font-size: 1.1rem;
  font-family: "Space Grotesk", sans-serif;
  transition: all 0.3s ease;
  outline: none;
}

.input-field:focus {
  border-color: var(--primary);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

.input-field::placeholder {
  color: #64748b;
}

/* Buttons */
.btn {
  width: 100%;
  padding: 16px 32px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border: none;
  border-radius: 12px;
  color: white;
  font-size: 1.1rem;
  font-weight: 600;
  font-family: "Space Grotesk", sans-serif;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.4);
}

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

.btn::after {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  transform: rotate(45deg);
  transition: all 0.5s;
  opacity: 0;
}

.btn:hover::after {
  animation: shimmer 0.5s ease;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%) translateY(-100%) rotate(45deg);
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    transform: translateX(100%) translateY(100%) rotate(45deg);
    opacity: 0;
  }
}

/* Timer Section */
.timer-container {
  display: flex;
  justify-content: space-between;
  margin-bottom: 30px;
  gap: 20px;
}

.timer-box {
  flex: 1;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 20px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.timer-box::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.timer-label {
  font-size: 0.85rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.timer-value {
  font-family: "JetBrains Mono", monospace;
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
}

.timer-value.warning {
  color: var(--warning);
  animation: pulse 1s infinite;
}

.timer-value.danger {
  color: var(--error);
  animation: pulse 0.5s infinite;
}

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

/* Progress Bar */
.progress-container {
  margin-bottom: 30px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 0.9rem;
  color: #64748b;
}

.progress-bar {
  height: 8px;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 4px;
  transition: width 0.5s ease;
  position: relative;
  overflow: hidden;
}

.progress-fill::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: progressShine 2s infinite;
}

@keyframes progressShine {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* Question Card */
.question-card {
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 30px;
  margin-bottom: 30px;
  position: relative;
}

.question-number {
  display: inline-block;
  padding: 6px 16px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 20px;
  text-transform: uppercase;
}

.question-text {
  font-size: 1.4rem;
  line-height: 1.6;
  color: #f1f5f9;
  font-weight: 500;
}

/* Answer Buttons */
.answers-grid {
  display: grid;
  gap: 15px;
}

.answer-btn {
  width: 100%;
  padding: 20px 24px;
  background: rgba(15, 23, 42, 0.6);
  border: 2px solid var(--glass-border);
  border-radius: 12px;
  color: #e2e8f0;
  font-size: 1.1rem;
  font-family: "Space Grotesk", sans-serif;
  cursor: pointer;
  text-align: left;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 15px;
}

.answer-btn::before {
  content: "";
  width: 24px;
  height: 24px;
  border: 2px solid var(--glass-border);
  border-radius: 50%;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.answer-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
  transform: translateX(5px);
}

.answer-btn:hover:not(:disabled)::before {
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

.answer-btn.correct {
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--success);
  color: var(--success);
  animation: correctPulse 0.5s ease;
}

.answer-btn.correct::before {
  background: var(--success);
  border-color: var(--success);
  box-shadow: 0 0 20px var(--success);
}

.answer-btn.wrong {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--error);
  color: var(--error);
  animation: shake 0.5s ease;
}

.answer-btn.wrong::before {
  background: var(--error);
  border-color: var(--error);
}

.answer-btn:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

@keyframes correctPulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.02);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-10px);
  }
  75% {
    transform: translateX(10px);
  }
}

/* Next Button */
.next-btn {
  width: 100%;
  padding: 18px;
  background: linear-gradient(135deg, var(--secondary), #be185d);
  border: none;
  border-radius: 12px;
  color: white;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
  pointer-events: none;
}

.next-btn.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

.next-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(236, 72, 153, 0.4);
}

/* Results Screen */
.results-card {
  text-align: center;
  padding: 40px;
}

.score-circle {
  width: 200px;
  height: 200px;
  margin: 0 auto 30px;
  position: relative;
}

.score-circle svg {
  transform: rotate(-90deg);
}

.score-circle-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 10;
}

.score-circle-progress {
  fill: none;
  stroke: url(#gradient);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s ease;
}

.score-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 3rem;
  font-weight: 700;
  font-family: "JetBrains Mono", monospace;
}

.score-label {
  font-size: 1.2rem;
  color: #64748b;
  margin-bottom: 30px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 30px;
}

.stat-box {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 20px;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
  font-family: "JetBrains Mono", monospace;
}

.stat-label {
  font-size: 0.9rem;
  color: #64748b;
  margin-top: 5px;
}

/* Leaderboard */
.leaderboard {
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 25px;
  margin-bottom: 30px;
}

.leaderboard-title {
  font-size: 1.3rem;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.leaderboard-title::before {
  content: "🏆";
}

.leaderboard-item {
  display: flex;
  align-items: center;
  padding: 15px;
  background: rgba(15, 23, 42, 0.4);
  border-radius: 10px;
  margin-bottom: 10px;
  transition: all 0.3s ease;
  border: 1px solid transparent;
}

.leaderboard-item:hover {
  border-color: var(--glass-border);
  transform: translateX(5px);
}

.leaderboard-rank {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  margin-right: 15px;
  font-family: "JetBrains Mono", monospace;
}

.leaderboard-rank.gold {
  background: linear-gradient(135deg, #ffd700, #ffed4e);
  color: #000;
}

.leaderboard-rank.silver {
  background: linear-gradient(135deg, #c0c0c0, #e8e8e8);
  color: #000;
}

.leaderboard-rank.bronze {
  background: linear-gradient(135deg, #cd7f32, #daa520);
  color: #fff;
}

.leaderboard-rank.other {
  background: rgba(255, 255, 255, 0.1);
  color: #64748b;
}

.leaderboard-name {
  flex: 1;
  font-weight: 600;
}

.leaderboard-score {
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  color: var(--accent);
}

/* Category Tags */
.category-tags {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 30px;
}

.category-tag {
  padding: 8px 16px;
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid var(--primary);
  border-radius: 20px;
  font-size: 0.9rem;
  color: var(--primary);
  cursor: pointer;
  transition: all 0.3s ease;
}

.category-tag:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-2px);
}

.category-tag.active {
  background: var(--primary);
  color: white;
}

/* Responsive */
@media (max-width: 600px) {
  .quiz-container {
    width: 95%;
    padding: 25px;
  }

  .logo {
    font-size: 1.8rem;
  }

  .timer-container {
    flex-direction: column;
  }

  .question-text {
    font-size: 1.2rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .category-tags {
    gap: 8px;
  }

  .category-tag {
    padding: 6px 12px;
    font-size: 0.8rem;
  }
}

/* Confetti Canvas */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
}

/* Code styling in questions */
code {
  background: rgba(99, 102, 241, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.9em;
  color: var(--accent);
}
