:root {
  /* Color variables - White & Black Theme */
  --quiz-primary-color: #000000;
  --quiz-secondary-color: #ffffff;
  --quiz-accent-color: #333333;
  --quiz-text-dark: #000000;
  --quiz-text-light: #ffffff;
  --quiz-background-light: #ffffff;
  --quiz-background-dark: #000000;
  --quiz-success: #000000;
  --quiz-error: #333333;
  --quiz-warning: #666666;
  --quiz-info: #000000;
  
  /* Button color variables - White & Black Theme */
  --button-retry: #000000;
  --button-retry-hover: #333333;
  --button-view: #000000;
  --button-view-hover: #333333;
  --button-flashcards: #333333;
  --button-flashcards-hover: #000000;
  --button-progress: #000000;
  --button-progress-hover: #333333;
  --button-points: #333333;
  --button-points-hover: #000000;
  --button-home: #666666;
  --button-home-hover: #333333;
  
  /* Spacing variables */
  --quiz-spacing-xs: 0.25rem;
  --quiz-spacing-sm: 0.5rem;
  --quiz-spacing-md: 1rem;
  --quiz-spacing-lg: 1.5rem;
  --quiz-spacing-xl: 2rem;
  
  /* Font variables */
  --quiz-font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  --quiz-font-size-sm: 0.875rem;
  --quiz-font-size-md: 1rem;
  --quiz-font-size-lg: 1.125rem;
  --quiz-font-size-xl: 1.25rem;
  
  /* Border radius */
  --quiz-border-radius-sm: 4px;
  --quiz-border-radius-md: 8px;
  --quiz-border-radius-lg: 16px;
  
  /* Shadows */
  --quiz-shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
  --quiz-shadow-md: 0 4px 8px rgba(0, 0, 0, 0.1);
  --quiz-shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.1);
  
  /* Transitions */
  --quiz-transition-fast: 0.2s ease;
  --quiz-transition-medium: 0.3s ease;
  --quiz-transition-slow: 0.5s ease;
}

/* ============================================
   LAYER STRUCTURE: 4-3-2-1 Layout
   Layer 4: 100% width (outer container)
   Layer 3: 98% width
   Layer 2: 97% width
   Layer 1: Remaining width (content area)
   ============================================ */

.layer-4 {
  width: 100%;
  max-width: 100%;
  background: white;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 0;
}

.layer-3 {
  width: 98%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 10px 0;
}

.layer-2 {
  width: 97%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 10px 0;
}

.layer-1 {
  width: 100%;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Reset and base styles */
.quiz-container, 
.quiz-grid,
.flashcard-sets,
.level-card {
  font-family: var(--quiz-font-family);
  line-height: 1.5;
  color: var(--quiz-text-dark);
}

/* Common button styles */
.quiz-btn,
.level-button,
.join-button,
.submit-button,
.next-button,
.prev-button,
.study-button,
.retry-quiz-btn,
.view-answers-btn,
.study-flashcards-btn,
.my-progress-btn,
.points-table-btn,
.back-home-btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border-radius: var(--quiz-border-radius-md);
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: all var(--quiz-transition-fast);
  border: none;
  background-color: var(--quiz-primary-color);
  color: var(--quiz-text-light);
  text-decoration: none;
  box-shadow: var(--quiz-shadow-sm);
  min-width: 140px;
}

.quiz-btn:hover,
.level-button:hover,
.join-button:hover,
.submit-button:hover,
.next-button:hover,
.prev-button:hover,
.study-button:hover {
  transform: translateY(-2px);
  box-shadow: var(--quiz-shadow-md);
  background-color: #333333;
}

/* Card component */
.quiz-card,
.flashcard-item,
.level-card {
  background: white;
  border-radius: var(--quiz-border-radius-md);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: transform var(--quiz-transition-fast);
  overflow: hidden;
  border: 1px solid #000000;
}

.quiz-card:hover,
.flashcard-item:hover,
.level-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--quiz-shadow-md);
}

/* Grid layouts */
.quiz-grid,
.level-progress-grid,
.flashcard-sets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--quiz-spacing-lg);
  margin: var(--quiz-spacing-lg) 0;
}

/* Status badges */
.status-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 50px;
  font-size: var(--quiz-font-size-sm);
  font-weight: 600;
}

.status-badge.success {
  background-color: #000000;
  color: white;
}

.status-badge.warning {
  background-color: #333333;
  color: white;
}

.status-badge.error {
  background-color: #000000;
  color: white;
}

/* Container layouts */
.quiz-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--quiz-spacing-lg);
}

/* Loading spinner */
.quiz-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--quiz-spacing-xl);
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 5px solid rgba(0, 0, 0, 0.1);
  border-top-color: var(--quiz-primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Option styles - improved contrast */
.option {
  background-color: transparent;
  margin-bottom: 8px;
  border-radius: 5px;
  padding: 10px;
  transition: background-color var(--quiz-transition-fast);
}
.music-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100;
    background: #fff;
    border: 2px solid #007bff;
    color: #007bff;
    padding: 8px 15px;
    border-radius: 30px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 3px 6px rgba(0,0,0,0.1);
}

.music-toggle:hover {
    background: #007bff;
    color: #fff;
}
.option:hover {
  background-color: #ffcccc;
}

.option-text {
  color: #ffffff;
  display: inline-block;
  vertical-align: middle;
  margin-left: 8px;
  font-weight: 500;
}

.option-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: white;
  font-weight: bold;
}

/* Quiz Results Actions Styling */
.results-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin: 25px 0;
}

.results-actions button {
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  border: none;
  box-shadow: 0 3px 6px rgba(0,0,0,0.16);
  text-align: center;
  min-width: 140px;
}

.results-actions button:hover {
  transform: translateY(-3px);
  box-shadow: 0 5px 10px rgba(0,0,0,0.2);
}

/* Button-specific styles */
.retake-quiz-btn {
  background: var(--button-retry);
  color: white;
}

.retake-quiz-btn:hover {
  background: var(--button-retry-hover);
}

.view-answers-btn {
  background: var(--button-view);
  color: white;
}

.view-answers-btn:hover {
  background: var(--button-view-hover);
}

.study-flashcards-btn {
  background: var(--button-flashcards);
  color: white;
}

.study-flashcards-btn:hover {
  background: var(--button-flashcards-hover);
}

.my-progress-btn {
  background: var(--button-progress);
  color: white;
}

.my-progress-btn:hover {
  background: var(--button-progress-hover);
}

.points-table-btn {
  background: var(--button-points);
  color: white;
}

.points-table-btn:hover {
  background: var(--button-points-hover);
}

.back-home-btn {
  background: var(--button-home);
  color: white;
}

.back-home-btn:hover {
  background: var(--button-home-hover);
}

/* Review Quiz Toggle Button */
.review-toggle {
  background: #3f51b5;
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  margin: 20px auto;
  display: block;
  font-weight: 600;
  transition: all 0.2s ease;
}

.review-toggle:hover {
  background: #303f9f;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.review-toggle.active {
  background: #000000;
}

.review-toggle.active:hover {
  background: #333333;
}

/* Questions Review Section */
.questions-review {
  display: none;
  margin: 20px 0;
  border-top: 1px solid #ddd;
  padding-top: 20px;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.questions-review.visible {
  display: block;
}

/* Social Share Styling */
.social-share {
  text-align: center;
  margin: 20px 0;
  padding: 15px;
  background: #f8f8f8;
  border-radius: 8px;
}

.social-share-title {
  display: block;
  margin-bottom: 12px;
  font-weight: 500;
  color: #444;
  font-size: 1.1rem;
}

.share-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 45px;
  height: 45px;
  margin: 0 8px;
  border-radius: 50%;
  color: white;
  font-size: 20px;
  text-decoration: none;
  transition: all 0.3s ease;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.share-button:hover {
  transform: translateY(-3px) scale(1.1);
  box-shadow: 0 5px 10px rgba(0,0,0,0.25);
}

.share-whatsapp {
  background: #25d366;
}

.share-whatsapp:hover {
  background: #20bd5c;
}

.share-facebook {
  background: #1877f2;
}

.share-facebook:hover {
  background: #166bda;
}

.share-telegram {
  background: #0088cc;
}

.share-telegram:hover {
  background: #0077b3;
}

.share-twitter {
  background: #1da1f2;
}

.share-twitter:hover {
  background: #1a94da;
}

/* Quiz results card styling */
.quiz-results {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
  max-width: 800px;
  margin: 0 auto;
}

.results-summary {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px 20px;
  background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
  color: white;
}

.score-display {
  text-align: center;
  margin-bottom: 20px;
}

.score-value {
  font-size: 4rem;
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.score-label {
  font-size: 1.5rem;
  margin-top: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.score-excellent {
  color: #000000;
}

.score-good {
  color: #000000;
}

.score-average {
  color: #333333;
}

.score-poor {
  color: #000000;
}

.result-remark {
  font-size: 1.5rem;
  margin: 20px 0;
  text-align: center;
  font-weight: 500;
}

.score-breakdown {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-top: 20px;
}

.correct-answers,
.wrong-answers,
.total-questions {
  text-align: center;
  padding: 10px 15px;
  background: rgba(255,255,255,0.2);
  border-radius: 8px;
  min-width: 100px;
}

.count {
  display: block;
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1;
}

.label {
  display: block;
  margin-top: 5px;
  font-size: 0.9rem;
  opacity: 0.9;
}

/* Media queries for responsive design */
@media (max-width: 768px) {
  .quiz-grid,
  .level-progress-grid,
  .flashcard-sets-grid {
    grid-template-columns: 1fr;
  }
  
  .quiz-btn,
  .level-button,
  .join-button,
  .results-actions button {
    display: block;
    width: 100%;
    margin-bottom: var(--quiz-spacing-md);
  }

  .results-actions {
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }
  
  .score-value {
    font-size: 3rem;
  }
  
  .score-breakdown {
    flex-direction: column;
    gap: 10px;
  }
  
  .correct-answers,
  .wrong-answers,
  .total-questions {
    width: 100%;
  }
  
  .results-summary {
    padding: 20px 15px;
  }
}

/* Additional animations for better UX */
.results-actions button {
  position: relative;
  overflow: hidden;
}

.results-actions button::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255,255,255,0.1);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}

.results-actions button:hover::after {
  transform: translateX(0);
}

/* Style for detailed results section */
.detailed-results {
  padding: 20px;
}

.result-item {
  margin-bottom: 20px;
  padding: 15px;
  border-radius: 8px;
  background: #f9f9f9;
  border-left: 5px solid #ddd;
}

.result-item.correct {
  border-left-color: var(--button-retry);
  background: rgba(76, 175, 80, 0.1);
}

.result-item.incorrect {
  border-left-color: var(--button-points);
  background: rgba(244, 67, 54, 0.1);
}

.result-explanation {
  margin-top: 10px;
  border-top: 1px solid #eee;
  padding-top: 10px;
}

.explanation-toggle {
  color: var(--quiz-primary-color);
  cursor: pointer;
  font-weight: 500;
  display: inline-block;
  padding: 5px 10px;
  background: rgba(58, 86, 228, 0.1);
  border-radius: 4px;
  transition: all 0.2s ease;
}

.explanation-toggle:hover {
  background: rgba(58, 86, 228, 0.2);
}

.explanation-content {
  margin-top: 10px;
  padding: 10px;
  background: white;
  border-radius: 4px;
  border: 1px solid #eee;
}

/* Remove dark blue background from question container */
.question {
  background-color: transparent !important;
  background: transparent !important;
}

.options {
  background-color: transparent !important;
  background: transparent !important;
}

.question-item {
  background-color: transparent !important;
  background: transparent !important;
}

.options-container {
  background-color: transparent !important;
  background: transparent !important;
}

/* ============================================
   NAVIGATION - IMPROVED
   ============================================ */

.quiz-navigation {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  padding: 15px;
  background: transparent;
  margin-top: 20px;
  flex-wrap: nowrap;
}

.nav-button {
  padding: 8px 12px;
  font-size: 24px;
  font-weight: 600;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  min-width: auto;
  width: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-button:hover:not(:disabled) {
  background: #333;
  color: white;
  transform: scale(1.05);
}

.nav-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.nav-prev, .nav-next {
  font-size: 18px;
}

.question-counter {
  font-size: 16px;
  font-weight: 700;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: 0;
  width: auto;
  min-width: auto;
  text-align: center;
  color: #333;
  white-space: nowrap;
}

/* ============================================
   MATCH PAIR QUESTIONS - FIXED LAYOUT
   ============================================ */

.match-pair-container {
  display: flex;
  gap: 20px;
  width: 100%;
  overflow-x: auto;
}

.match-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 45%;
}

.match-item {
  padding: 12px;
  background: white;
  border: 2px solid #333;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  word-wrap: break-word;
  word-break: break-word;
  font-size: clamp(12px, 3vw, 16px);
  line-height: 1.3;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.match-item:hover {
  background: #f0f0f0;
  border-color: #000;
  transform: scale(1.02);
}

.match-item.selected {
  background: #333;
  color: white;
}

.match-item.matched {
  opacity: 0.5;
  pointer-events: none;
}

/* ============================================
   DRAG & DROP QUESTIONS - IMPROVED
   ============================================ */

.drag-drop-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}

.word-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 15px;
  background: #f9f9f9;
  border: 2px dashed #333;
  border-radius: 6px;
  min-height: 50px;
}

.draggable-word {
  padding: 10px 15px;
  background: #333;
  color: white;
  border-radius: 6px;
  cursor: grab;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.3s ease;
  white-space: nowrap;
  user-select: none;
}

.draggable-word:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.draggable-word:active {
  cursor: grabbing;
  opacity: 0.8;
}

.draggable-word.dragging {
  opacity: 0.5;
  transform: scale(0.95);
}

.answer-boxes {
  display: flex;
  flex-direction: column;
  gap: 15px;
  width: 100%;
}

.answer-box {
  min-height: 50px;
  padding: 12px;
  border: 2px solid #ddd;
  border-radius: 6px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: all 0.3s ease;
}

.answer-box:hover {
  border-color: #333;
  background: #f9f9f9;
}

.answer-box.drop-target {
  border: 2px dashed #333;
}

.answer-box.drag-over {
  background: #e8f4f8;
  border-color: #333;
  box-shadow: inset 0 0 10px rgba(51, 51, 51, 0.1);
}

.answer-word {
  padding: 8px 12px;
  background: #333;
  color: white;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
}

.remove-word-btn {
  background: red;
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  padding: 0;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.remove-word-btn:hover {
  background: darkred;
  transform: scale(1.1);
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 768px) {
  .match-pair-container {
    flex-direction: column;
  }

  .match-column {
    min-width: 100%;
  }

  .quiz-navigation {
    gap: 10px;
    flex-wrap: nowrap;
    justify-content: center;
  }

  .nav-button {
    font-size: 20px;
    padding: 6px 8px;
    min-width: auto;
  }

  .question-counter {
    font-size: 14px;
    padding: 6px 8px;
    min-width: auto;
    width: auto;
  }

  .word-pool {
    flex-direction: column;
  }

  .draggable-word {
    width: 100%;
    text-align: center;
  }

  .answer-box {
    flex-wrap: wrap;
  }
}