:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --accent: #10b981;
  --error: #ef4444;
  --bg-dark: #0f172a;
  --container-bg: rgba(30, 41, 59, 0.7);
  --glass-border: rgba(255, 255, 255, 0.1);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --error-bg: rgba(239, 68, 68, 0.1);
  --font-main: "Outfit", sans-serif;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  line-height: 1.6;
}

.background-mesh {
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(
      circle at 50% 50%,
      rgba(59, 130, 246, 0.15),
      transparent 60%
    ),
    radial-gradient(
      circle at 80% 20%,
      rgba(139, 92, 246, 0.15),
      transparent 50%
    );
  z-index: 0;
  animation: rotate 60s linear infinite;
  pointer-events: none;
}

@keyframes rotate {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.app-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 850px;
  background: var(--container-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 40px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  margin: auto;
}

.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: fadeIn 0.5s ease forwards;
}

.screen.active {
  display: flex;
}

.hidden {
  display: none !important;
}

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

h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 10px;
  background: linear-gradient(to right, #60a5fa, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

p {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.badge {
  background: rgba(59, 130, 246, 0.1);
  color: #60a5fa;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.info-badges {
  display: flex;
  gap: 10px;
  margin-bottom: 30px;
}

.primary-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
  padding: 16px 32px;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
  font-family: var(--font-main);
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(59, 130, 246, 0.4);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  padding: 14px 28px;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-main);
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.secondary-btn.hidden {
  display: none;
}

.result-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.mt-10 {
  margin-top: 40px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 16px;
  width: 100%;
  margin-bottom: 30px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.profile-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.quiz-header {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 20px;
  align-items: center;
}

.question-tracker {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.timer-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.timer-bar {
  width: 100px;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.timer-bar::after {
  content: "";
  display: block;
  height: 100%;
  width: 100%;
  background: var(--accent);
  transform-origin: left;
  transition:
    width 1s linear,
    background-color 0.3s;
}

.timer-container.warning .timer-bar::after {
  background: var(--error);
}

.timer-text {
  font-size: 0.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.options-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin-bottom: 24px;
}

.option {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  width: 100%;
  font-family: var(--font-main);
}

.option-main {
  padding: 16px 20px;
  width: 100%;
  font-size: 1rem;
}

.option-reasoning {
  display: none;
  padding: 12px 20px;
  background: rgba(0, 0, 0, 0.25);
  font-size: 0.85rem;
  line-height: 1.5;
  color: #e2e8f0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  animation: slideDown 0.3s ease forwards;
}

.option-reasoning:not(.hidden) {
  display: block;
}

.option:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
  border-color: var(--primary);
}

.option.correct {
  background: rgba(16, 185, 129, 0.15);
  border-color: #10b981;
}

.option.correct .option-reasoning {
  background: rgba(16, 185, 129, 0.1);
}

.option.wrong {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
}

.option.wrong .option-reasoning {
  background: rgba(239, 68, 68, 0.1);
}

.option:disabled {
  cursor: default;
  opacity: 1;
}

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

@keyframes shake {
  10%,
  90% {
    transform: translate3d(-1px, 0, 0);
  }
  20%,
  80% {
    transform: translate3d(2px, 0, 0);
  }
  30%,
  50%,
  70% {
    transform: translate3d(-4px, 0, 0);
  }
  40%,
  60% {
    transform: translate3d(4px, 0, 0);
  }
}

.explanation-box {
  background: rgba(59, 130, 246, 0.05);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
  text-align: left;
  width: 100%;
}

.explanation-box.hidden {
  display: none;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  color: white;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.icon-btn.active {
  color: #fbbf24;
  border-color: #fbbf24;
  background: rgba(251, 191, 36, 0.1);
}

.category-badge {
  align-self: flex-start;
  background: rgba(59, 130, 246, 0.1);
  color: #60a5fa;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 12px;
}

h2 {
  font-size: 1.5rem;
  margin-bottom: 24px;
  text-align: left;
  width: 100%;
}

.score-display {
  font-size: 5rem;
  font-weight: 800;
  margin: 20px 0;
  color: var(--accent);
}

.score-display .total {
  font-size: 2rem;
  color: var(--text-secondary);
}

.result-message {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 40px;
}

.knowledge-map {
  width: 100%;
  margin-bottom: 40px;
  text-align: left;
}

.knowledge-map h3 {
  margin-bottom: 20px;
  font-size: 1.2rem;
}

.k-bar-container {
  margin-bottom: 16px;
}

.k-bar-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.k-bar-bg {
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
}

.k-bar-fill {
  height: 100%;
  background: linear-gradient(to right, #3b82f6, #10b981);
  border-radius: 4px;
  transition: width 1s ease;
}

@media (max-width: 480px) {
  .app-container {
    padding: 24px;
    border-radius: 16px;
  }

  h1 {
    font-size: 2rem;
  }

  .timer-bar {
    width: 60px;
  }
}

/* Toggle Switch Styling */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.6);
  transition: 0.4s;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.4s;
}

input:checked + .slider {
  background-color: #8b5cf6;
}

input:focus + .slider {
  shadow: 0 0 1px #8b5cf6;
}

input:checked + .slider:before {
  transform: translateX(20px);
}

.slider.round {
  border-radius: 24px;
}

.slider.round:before {
  border-radius: 50%;
}

.reference-label {
  margin-top: 12px;
  font-size: 0.85rem;
  color: #94a3b8;
  text-align: left;
  display: block;
}

.exit-btn-header {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(248, 113, 113, 0.3);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.exit-btn-header:hover {
  background: rgba(239, 68, 68, 0.25);
  transform: translateY(-1px);
}

@keyframes slideDown {
  from {
    opacity: 0;
    height: 0;
  }
  to {
    opacity: 1;
    height: auto;
  }
}
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(4px);
  }
}
.shake {
  animation: shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}
