/* Mobile-First Design */
body {
  background-color: #f0f4f8;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  padding: 0;
  font-size: 14px;
  transition: all 0.3s ease;
  overflow-x: hidden;
  width: 100%;
  box-sizing: border-box;
}

body.dark {
  background-color: #2d3748;
  color: #edf2f7;
}

body.dark .card {
  background-color: #4a5568;
}

body.dark .action-btn {
  background-color: #63b3ed;
}

.header {
  background-color: #4c51bf;
  color: #ffffff;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
}

.header h1 {
  font-size: 1.25rem;
  margin: 0.5rem 0;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding: 0 0.5rem;
}

.controls span {
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
}

.controls button {
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
  border-radius: 0.3rem;
  background-color: #9f7aea;
  color: #ffffff;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
}

.controls button:hover {
  background-color: #805ad5;
  transform: scale(1.02);
}

.card {
  background-color: #ffffff;
  padding: 1rem;
  border-radius: 0.5rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  width: 90%;
  max-width: 100%;
  margin: 1rem auto;
  transition: transform 0.2s ease;
  box-sizing: border-box;
}

.card:hover {
  transform: translateY(-2px);
}

.card h2 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  text-align: center;
}

.action-btn {
  background-color: #9f7aea;
  color: #ffffff;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  width: 100%;
  box-sizing: border-box;
  margin: 0.25rem 0;
}

.action-btn:hover {
  background-color: #805ad5;
  transform: scale(1.02);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

label {
  display: block;
  font-size: 0.9rem;
  margin: 0.5rem 0 0.25rem 0;
}

select {
  display: block;
  width: 100%;
  max-width: 100%;
  padding: 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid #cbd5e0;
  font-size: 0.9rem;
  box-sizing: border-box;
  background-color: #fff;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23333' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 1rem;
  position: relative;
  overflow: hidden;
}

select:focus {
  border-color: #4c51bf;
  outline: none;
}

input[type="hidden"] {
  display: none;
}

.progress-bar {
  height: 0.4rem;
  background-color: #edf2f7;
  border-radius: 0.25rem;
  overflow: hidden;
  margin-bottom: 1rem;
  animation: pulse 2s infinite;
}

.progress-bar-fill {
  height: 100%;
  background-color: #48bb78;
  transition: width 0.3s ease;
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.6; }
  100% { opacity: 1; }
}

.options label {
  display: flex;
  align-items: center;
  padding: 0.5rem;
  border: 1px solid #cbd5e0;
  border-radius: 0.5rem;
  margin: 0.5rem 0;
  transition: all 0.3s ease;
  width: 100%;
  box-sizing: border-box;
  font-size: 0.9rem;
}

.options label:hover {
  background-color: #edf2f7;
  transform: translateX(3px);
}

.options input {
  margin-right: 0.5rem;
}

.feedback, .score-summary {
  margin-top: 1rem;
}

.feedback-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background-color: #4c51bf;
  padding: 1rem;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  text-align: center;
  width: 80%;
  max-width: 280px;
  box-sizing: border-box;
  opacity: 0;
  animation: slideIn 0.4s ease-out forwards;
}


.feedback-popup.hidden {
  display: none;
}

.feedback-popup .close-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: #4a5568;
}

.feedback-popup-content {
  padding: 0.5rem;
  color: white;
}

@keyframes slideIn {
  0% {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0;
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

.score-summary {
  opacity: 0;
  animation: fadeSlideUp 0.5s ease-out forwards;
}

@keyframes fadeSlideUp {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

.hidden {
  display: none;
}

img, audio {
  max-width: 100%;
  margin: 0.5rem 0;
}

.button-row {
  display: flex;
  justify-content: space-between;
  margin-top: 1rem;
  width: 100%;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.button-row .action-btn {
  flex: 1 1 45%;
  box-sizing: border-box;
  margin-bottom: 0.5rem;
}

.nav-buttons {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
  width: 100%;
}

.nav-buttons .action-btn {
  width: 48%;
  box-sizing: border-box;
}

/* MathJax Styling */
.MathJax {
  font-size: 1em !important;
  display: inline-block !important;
}

/* Larger Screens */
@media (min-width: 640px) {
  body {
    font-size: 16px;
  }

  .header h1 {
    font-size: 1.5rem;
  }

  .controls {
    flex-wrap: nowrap;
  }

  .controls span, .controls button {
    font-size: 1rem;
    padding: 0.5rem 0.75rem;
  }

  .card {
    padding: 1.5rem;
    max-width: 400px;
  }

  .card h2 {
    font-size: 1.25rem;
  }

  .action-btn {
    padding: 0.75rem 1rem;
    font-size: 1rem;
  }

  label {
    font-size: 1rem;
  }

  select {
    padding: 0.75rem 2rem 0.75rem 0.75rem;
    font-size: 1rem;
    max-width: 100%;
  }

  .options label {
    font-size: 1rem;
  }

  .feedback-popup {
    width: 300px;
    padding: 1.5rem;
  }

  .button-row .action-btn {
    flex: 1 1 48%;
    margin-bottom: 0;
  }

  .controls button {
    width: auto;
  }
}

.instructions {
  font-style: italic;
  color: #555;
  margin-bottom: 10px;
}

body.dark .instructions {
  color: #bbb;
}

