:root {
  /* Color Palette */
  --primary-color: #800020;
  --primary-light: #b33a3a;
  --primary-dark: #4d0013;
  --secondary-color: #c72c41;
  --background-light: #f8f6f8;
  --text-dark: #400000;
  --text-light: #ffffff;
  --border-color: #d4a5a5;
  --success-color: #4caf50;
  --warning-color: #ffc107;
  --error-color: #f44336;
  
  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  
  /* Border Radius */
  --border-radius-sm: 4px;
  --border-radius-md: 8px;
  --border-radius-lg: 12px;
  
  /* Box Shadow */
  --box-shadow: 0 4px 16px rgba(128, 0, 32, 0.09);
  --shadow: 0 10px 20px rgba(0,0,0,0.1);
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
}

/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--background-light);
  font-family: 'Segoe UI', Arial, sans-serif;
  color: var(--text-dark);
  line-height: 1.6;
}

.material-icons {
  display: none !important;
}

.container {
  max-width: 900px;
  margin: var(--spacing-lg) auto;
  background: #fff;
  box-shadow: var(--box-shadow);
  border-radius: var(--border-radius-lg);
  padding: var(--spacing-xl) var(--spacing-lg);
  border-top: 6px solid var(--primary-color);
  min-height: calc(100vh - 100px);
}

h1, h2, h3, h4, h5, h6 {
  color: var(--primary-color);
  margin-bottom: var(--spacing-md);
  text-align: center;
}

/* Buttons */
.btn {
  background: var(--primary-color);
  color: var(--text-light);
  border: 2px solid transparent;
  border-radius: var(--border-radius-md);
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  box-shadow: 0 2px 8px rgba(128, 0, 32, 0.2);
}

.btn:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(128, 0, 32, 0.3);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--primary-color);
  color: var(--primary-color);
  box-shadow: 0 2px 8px rgba(128, 0, 32, 0.1);
}

.btn-outline:hover {
  background: rgba(128, 0, 32, 0.1);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(128, 0, 32, 0.2);
}

/* Forms */
.form-group {
  margin-bottom: var(--spacing-md);
}

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius-md);
  font-size: 1rem;
  transition: all 0.3s ease;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(128, 0, 32, 0.15), 0 4px 8px rgba(0,0,0,0.1);
  transform: translateY(-1px);
}

/* Quiz Styles */
.quiz-progress {
  width: 100%;
  height: 6px;
  background: #f0f0f0;
  border-radius: 3px;
  margin: 15px 0;
  overflow: hidden;
}

#progress-bar {
  height: 100%;
  background: var(--primary-color);
  width: 0%;
  transition: width 0.3s ease;
}

#question-counter {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9em;
  margin-bottom: 20px;
}

.question {
  font-size: 1.25em !important;
  font-weight: 500 !important;
  color: #800020 !important;
  margin-bottom: 1.5rem;
  padding-bottom: 0 !important;
  margin-top: 0 !important;      /* Sát với câu hỏi */
  gap: 0px !important;           /* Các đáp án cũng gần nhau hơn */
  line-height: 1.5 !important;
}

.answers {
  display: flex;
  flex-direction: column;
  margin-top: 0px !important;
  gap: 0px !important;     /* Giảm khoảng cách giữa các đáp án */
  margin-bottom: 8px !important;
}

.answer {
  padding: 15px;
  border: 2px solid #e0e0e0;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px !important;      /* Khoảng cách nhỏ giữa checkbox/radio và nhãn A,B,C,D */
  padding: 10px 14px !important;
  padding-left: 2px !important; /* giảm sát lề trái */
}

.answer:hover {
  border-color: var(--primary-color);
  background: rgba(128, 0, 32, 0.05);
}

.answer.selected {
  border-color: var(--primary-color);
  background: rgba(128, 0, 32, 0.1);
}

.answer .option {
  min-width: 24px !important;   /* nhỏ lại cho sát hơn */
  margin-right: 6px !important; /* khoảng cách nhẹ giữa ký tự và nội dung đáp án */
  margin-left: 0 !important;
  font-size: 1.15em !important;
  font-weight: 600 !important;
  text-align: left !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
}

.answer-input {
  width: 18px;
  height: 18px;
  margin: 0 4px 0 0 !important; /* sát với chữ A/B/C/D */
  flex: 0 0 auto;
}

.answer .text {
  flex: 1;
}

.quiz-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid #eee;
}

.quiz-actions {
  display: flex;
  gap: 16px;
}

.btn-flag {
  background: #fff3e0;
  color: #e65100;
  border: 1px solid #ffe0b2;
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.btn-flag.active {
  background: #ffe0b2;
  color: #e65100;
}

.flag-count {
  background: #f44336;
  color: white;
  border-radius: 10px;
  font-size: 0.7em;
  padding: 2px 6px;
  position: absolute;
  top: -8px;
  right: -8px;
}

/* Quiz Feedback */
.feedback {
  padding: 12px 16px;
  border-radius: var(--border-radius);
  margin: 16px 0;
  font-weight: 500;
  display: none;
}

.feedback.correct {
  background: #e8f5e9;
  color: #2e7d32;
  border-left: 4px solid #4caf50;
}

.feedback.incorrect {
  background: #ffebee;
  color: #c62828;
  border-left: 4px solid #f44336;
}

#explanation {
  background: #f5f5f5;
  padding: 12px 16px;
  border-radius: var(--border-radius);
  margin: 16px 0;
  border-left: 4px solid #2196f3;
  display: none;
}

.answer {
  position: relative;
  transition: all 0.2s ease;
}

.answer.selected {
  background: rgba(128, 0, 32, 0.1);
  border-color: var(--primary-color);
}

.answer.correct {
  background: #8B0000 !important; /* Đỏ đậm cho đáp án đúng */
  color: #fff !important;
  border: 2px solid #8B0000 !important;
}

.answer.incorrect {
  background: #ffebee !important; /* Đỏ nhạt cho đáp án sai */
  color: #d32f2f !important;
  border: 2px solid #ffcdd2 !important;
}
.answer.correct .option {
  background: #8B0000 !important; /* Đỏ đậm cho option đúng */
  color: #fff !important;
}

.answer.incorrect .option {
  background: #ffcdd2 !important; /* Đỏ nhạt cho option sai */
  color: #d32f2f !important;
}
.answer.correct::after {
  color: #fff !important;
}

.answer.incorrect::after {
  color: #800020 !important;
}
/* Flagged Questions */
.flagged-questions-panel {
  display: none;
  padding: 20px;
  background: #fff;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
}

.flagged-questions-panel h2 {
  color: var(--primary-color);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.flagged-item {
  padding: 12px 16px;
  border: 1px solid #e0e0e0;
  border-radius: var(--border-radius);
  margin-bottom: 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s ease;
}

.flagged-item:hover {
  background: #f5f5f5;
  border-color: var(--primary-color);
}

.flagged-item .status {
  font-size: 0.85em;
  color: #757575;
  font-style: italic;
}

/* Navigation Buttons */
.quiz-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid #eee;
}

.quiz-actions {
  display: flex;
  gap: 10px;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: #e0e0e0;
  color: #9e9e9e;
  border-color: #e0e0e0;
}

/* Question Counter */
#question-counter {
  text-align: center;
  color: var(--text-secondary);
  font-weight: 500;
  margin: 10px 0 20px;
  font-size: 0.95em;
}

/* Progress Bar */
.quiz-progress {
  height: 6px;
  background: #f0f0f0;
  border-radius: 3px;
  margin: 15px 0;
  overflow: hidden;
}

#progress-bar {
  height: 100%;
  background: var(--primary-color);
  width: 0%;
  transition: width 0.3s ease;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .quiz-controls {
    flex-direction: column;
    gap: 15px;
  }
  
  .quiz-actions {
    width: 100%;
    justify-content: space-between;
  }
  
  .btn {
    width: 100%;
    justify-content: center;
  }
}

/* Results */
.result-panel {
  display: none;
  text-align: center;
  padding: 30px;
  background: #f9f9f9;
  border-radius: var(--border-radius);
  margin-top: 20px;
}

.result-panel h2 {
  color: var(--primary-color);
  margin-bottom: 20px;
}

.score {
  margin: 30px 0;
}

.score-number {
  font-size: 3em;
  font-weight: bold;
  color: var(--primary-color);
  line-height: 1;
}

.score-percentage {
  font-size: 1.5em;
  color: var(--text-secondary);
  margin-top: 10px;
}

.actions {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-top: 30px;
}

/* Error message */
.error-message {
  text-align: center;
  padding: 40px 20px;
  max-width: 500px;
  margin: 0 auto;
}

.error-message h2 {
  color: var(--secondary-color);
  margin-bottom: 15px;
}

.error-message p {
  color: var(--text-secondary);
  margin-bottom: 25px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .quiz-controls {
    flex-direction: column;
    gap: 15px;
  }
  
  .quiz-actions {
    width: 100%;
    justify-content: space-between;
  }
  
  .actions {
    flex-direction: column;
  }
  
  .actions .btn {
    width: 100%;
    justify-content: center;
  }
}

/* Navigation */
.nav {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--spacing-lg);
}

/* Logo Styles */
.logo {
  display: flex;
  align-items: center;
  margin-bottom: 2rem;
  padding: 1rem;
  background: linear-gradient(135deg, rgba(128, 0, 32, 0.05) 0%, rgba(128, 0, 32, 0.02) 100%);
  border-radius: var(--border-radius-lg);
  border: 1px solid rgba(128, 0, 32, 0.1);
}

.logo img {
  height: 60px;
  margin-right: 1.5rem;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.logo-text {
  line-height: 1.2;
}

.logo h1 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--primary-color);
  text-align: left;
}

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    margin: 0;
    border-radius: 0;
    padding: var(--spacing-lg);
    min-height: 100vh;
  }
  
  h1 {
    font-size: 1.5rem;
  }
  
  .logo {
    margin-bottom: 1.5rem;
    padding: 0.75rem;
  }
  
  .logo img {
    height: 50px;
    margin-right: 1rem;
  }
  
  .quiz-controls {
    flex-direction: column;
    gap: 1rem;
  }
  
  .quiz-actions {
    width: 100%;
    justify-content: space-between;
  }
  
  .btn {
    width: 100%;
    justify-content: center;
  }
}

/* Utility Classes */
.text-center {
  text-align: center;
}

.mt-1 { margin-top: var(--spacing-xs); }
.mt-2 { margin-top: var(--spacing-sm); }
.mt-3 { margin-top: var(--spacing-md); }
.mt-4 { margin-top: var(--spacing-lg); }
.mt-5 { margin-top: var(--spacing-xl); }

.mb-1 { margin-bottom: var(--spacing-xs); }
.mb-2 { margin-bottom: var(--spacing-sm); }
.mb-3 { margin-bottom: var(--spacing-md); }
.mb-4 { margin-bottom: var(--spacing-lg); }
.mb-5 { margin-bottom: var(--spacing-xl); }

/* Login Form */
#login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: #f5f5f5;
}

.login-form {
  background: white;
  padding: 2rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-form .logo {
  margin-bottom: 2rem;
}

.login-form .logo img {
  max-height: 80px;
  margin-bottom: 1rem;
}

/* Admin Section */
.admin-section {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 2px solid rgba(128, 0, 32, 0.1);
}

.admin-buttons-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.admin-btn {
  min-height: 48px;
  font-size: 0.9rem;
  padding: 12px 16px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Admin Panel */
#admin-container header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #eee;
}

#admin-container .logo {
  display: flex;
  align-items: center;
  gap: 1rem;
}

#admin-container .logo img {
  height: 50px;
  width: auto;
}

/* Topic List */
.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.topic-card {
  background: white;
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  transition: all 0.3s ease;
  border: 1px solid rgba(128, 0, 32, 0.1);
}

.topic-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(128, 0, 32, 0.15);
  border-color: rgba(128, 0, 32, 0.2);
}

.topic-card-content {
  padding: 2rem 1.5rem;
  text-align: center;
}

.topic-card h3 {
  margin: 0 0 0.5rem;
  color: var(--primary-color);
}

.topic-card p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
  grid-column: 1 / -1;
}

.empty-state .material-icons {
  font-size: 3rem;
  color: #ddd;
  margin-bottom: 1rem;
  display: block;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .topics-grid {
    grid-template-columns: 1fr;
  }
  
  .admin-buttons-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  .admin-btn {
    font-size: 0.85rem;
    padding: 10px 12px;
  }
  
  #admin-container header {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }
  
  .login-form {
    margin: 1rem;
    padding: 1.5rem;
  }
}

/* Button Styles */
.btn-outline {
  background: transparent;
  border: 2px solid var(--primary-color);
  color: var(--primary-color);
  box-shadow: 0 2px 8px rgba(128, 0, 32, 0.1);
}

.btn-outline:hover {
  background: rgba(128, 0, 32, 0.1);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(128, 0, 32, 0.2);
}

.btn-delete {
  background: #f8d7da;
  color: #721c24;
  border: none;
}

.btn-delete:hover {
  background: #f5c6cb;
}

/* Form Styles */
.form-group {
  margin-bottom: 1.5rem;
  text-align: left;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-dark);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="file"] {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: var(--border-radius-sm);
  font-size: 1rem;
}

.form-group input[type="file"] {
  padding: 0.5rem 0;
  border: none;
}

/* Utility Classes */
.mt-4 { margin-top: 1.5rem; }
.mb-4 { margin-bottom: 1.5rem; }
.ml-2 { margin-left: 0.5rem; }
.text-center { text-align: center; }

/* Ensure logo has consistent size */
#logo-img {
  max-height: 60px;
  width: auto;
  object-fit: contain;
}

/* Admin specific logo */
#admin-logo {
  max-height: 60px;
  width: auto;
  object-fit: contain;
}

.topic-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  margin-bottom: 1rem;
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
}

.welcome-section h2 {
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.welcome-section p {
  color: var(--text-secondary);
  margin-bottom: 0;
}

/* Admin section */
.admin-section {
  margin-top: 2rem;
  text-align: center;
  padding-top: 2rem;
  border-top: 1px solid #eee;
}

/* Admin actions button row */
.admin-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

/* Responsive adjustments for small screens */
@media (max-width: 480px) {
  .topic-item {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }
  
  .welcome-section {
    padding: 1rem;
  }
  
  .btn {
    width: 100%;
    justify-content: center;
  }
}

/* Footer */
.footer {
  background: linear-gradient(135deg, #8e0e00 0%, #1f1c18 100%);
  color: #fff;
  padding: 40px 0 20px;
  margin-top: 60px;
  font-size: 0.95em;
  position: relative;
  overflow: hidden;
}

.footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--primary-color);
}

.footer .container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  position: relative;
  z-index: 1;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 40px;
  margin-bottom: 30px;
}

.footer-brand {
  flex: 1;
  min-width: 300px;
}

.footer-logo {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 20px;
}

.footer-logo-img {
  width: 70px;
  height: 70px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.footer-info h3 {
  font-size: 1.1em;
  margin: 0 0 5px;
  color: #fff;
  font-weight: 600;
}

.footer-info p {
  margin: 0;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.95em;
}

.footer-contact {
  background: rgba(255, 255, 255, 0.05);
  padding: 25px;
  border-radius: 8px;
  min-width: 300px;
  backdrop-filter: blur(5px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-contact h4 {
  color: #fff;
  margin-top: 0;
  margin-bottom: 20px;
  font-size: 1.3em;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--primary-color);
  display: inline-block;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 15px;
  color: rgba(255, 255, 255, 0.9);
  transition: all 0.3s ease;
  padding: 8px 12px;
  border-radius: 6px;
}

.contact-item:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateX(5px);
}

.contact-item .material-icons {
  color: var(--primary-color);
  font-size: 1.2em;
  min-width: 24px;
  text-align: center;
}

.footer-copyright {
  text-align: center;
  padding-top: 25px;
  margin-top: 25px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.9em;
}

/* Quiz Counter */
.question-counter {
  text-align: center;
  font-size: 1.1em;
  margin: 15px 0 25px;
  color: var(--primary-color);
  font-weight: 600;
  background: rgba(142, 14, 0, 0.1);
  padding: 10px;
  border-radius: 6px;
  display: inline-block;
  min-width: 120px;
  border: 1px solid rgba(142, 14, 0, 0.2);
}

/* Quiz Controls */
.quiz-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 30px 0;
  padding: 15px 0;
  border-top: 1px solid #eee;
  border-bottom: 1px solid #eee;
}

.quiz-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn-flag {
  background: #f5f5f5;
  color: #555;
  border: 1px solid #ddd;
  transition: all 0.3s ease;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  padding: 0;
}

.btn-flag:hover, .btn-flag.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.btn-flag .material-icons {
  font-size: 1.2em;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .footer-content {
    flex-direction: column !important;
    gap: 30px !important;
  }
  
  .footer-brand, .footer-contact {
    width: 100% !important;
    min-width: auto !important;
  }
  
  footer {
    padding: 30px 15px 15px !important;
  }
  
  footer .footer-content > div {
    min-width: auto !important;
  }
  
  footer .footer-content > div:last-child {
    min-width: auto !important;
  }
  
  .quiz-controls {
    flex-direction: column;
    gap: 15px;
  }
  
  .quiz-actions {
    width: 100%;
    justify-content: center;
  }
  
  .question-counter {
    width: 100%;
    margin: 15px 0;
  }
}

/* Print Styles */
@media print {
  .footer,
  .quiz-controls,
  .btn-flag,
  #submit-quiz-btn {
    display: none !important;
  }
  
  .container {
    max-width: 100%;
    padding: 0;
  }
  
  .question {
    page-break-inside: avoid;
  }
}

/* Quiz Container */
.quiz-container {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  margin: 2rem auto;
  max-width: 800px;
}

/* Question Styling */
.question {
  font-size: 1.2rem;
  font-weight: 500;
  color: #2c3e50;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

/* Answer Options */
.answers {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.answer {
  background: #f8f9fa;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.answer:hover {
  background: rgba(128, 0, 32, 0.08);
  border-color: var(--primary-color);
}

.answer.selected {
  background: rgba(128, 0, 32, 0.15);
  border-color: var(--primary-color);
  color: inherit;
}

.answer.correct {
  background: #8B0000; /* Đỏ đậm cho đáp án đúng */
  border-color: #8B0000;
  color: #fff;
}

.answer.incorrect {
  background: #ffebee; /* Đỏ nhạt cho đáp án sai */
  border-color: #ffcdd2;
  color: #d32f2f;
  opacity: 0.8;
}

.answer .option {
  font-weight: 600;
  min-width: 24px;
  text-align: center;
}

/* Flag Button */
.btn-flag {
  background: #fff8e6;
  color: #fa8c16;
  border: 1px solid #ffe7ba;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-flag:hover, .btn-flag.active {
  background: #fff1e6;
  border-color: #ffbb96;
  color: #fa541c;
}

.btn-flag.active {
  background: #ffd591;
  border-color: #ffa940;
  color: #d46b08;
}

.flag-count {
  background: #ff4d4f;
  color: white;
  border-radius: 10px;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  margin-left: 0.25rem;
}

/* Results Page */
.result-container {
  text-align: center;
  padding: 2rem;
}

.score-display {
  margin: 2rem 0;
}

.score {
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--primary-color);
  line-height: 1;
}

.score span {
  font-size: 1.5rem;
  color: #8c8c8c;
  font-weight: 400;
}

.percentage {
  font-size: 1.5rem;
  color: #8c8c8c;
  margin-top: 0.5rem;
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin: 2rem 0;
}

.review-section {
  margin-top: 3rem;
  text-align: left;
  background: #f8f9fa;
  border-radius: 8px;
  padding: 1.5rem;
}

.review-section h3 {
  color: #2c3e50;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e9ecef;
}

.flagged-question {
  background: white;
  border-radius: 6px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.flagged-question .question {
  font-weight: 500;
  margin-bottom: 1rem;
}

.your-answer, .correct-answer {
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  margin: 0.5rem 0;
}

.your-answer.correct {
  background: #e6f7ff;
  color: #52c41a;
}

.your-answer.incorrect {
  background: #fff2f0;
  color: #ff4d4f;
}

.correct-answer {
  background: #f0f5ff;
  color: #1890ff;
}

/* Progress Bar */
.quiz-progress {
  background: #f0f2f5;
  height: 6px;
  border-radius: 3px;
  margin: 1.5rem 0;
  overflow: hidden;
}

#progress-bar {
  height: 100%;
  background: var(--primary-color);
  width: 0;
  transition: width 0.3s ease;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .quiz-container {
    margin: 1rem;
  }
  
  .question {
    font-size: 1.1rem;
  }
  
  .answer {
    padding: 0.75rem 1rem;
  }
  
  .result-actions {
    flex-direction: column;
  }
  
  .btn {
    width: 100%;
  }
}

/* Error Message */
.error-message {
  text-align: center;
  padding: 2rem;
  background: #fff2f0;
  border-radius: 8px;
  border-left: 4px solid #ff4d4f;
  margin: 2rem 0;
}

.error-message h2 {
  color: #ff4d4f;
  margin-bottom: 1rem;
}

.error-message p {
  color: #595959;
  margin-bottom: 1.5rem;
}

.error-message .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #ff4d4f;
  color: white;
  padding: 0.5rem 1.25rem;
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.2s;
}

.error-message .btn:hover {
  background: #ff7875;
}

/* Question Header */
.question-header {
  margin-bottom: 1.5rem;
  border-bottom: 1px solid #e9ecef;
  padding-bottom: 1rem;
}

.question-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: #6c757d;
}

#question-number {
  font-weight: 500;
  color: #495057;
}

/* Explanation */
.explanation {
  margin-top: 1.5rem;
  padding: 1rem;
  background-color: #f8f9fa;
  border-radius: 6px;
  border-right: 4px solid #17a2b8;
  display: none;
}

.explanation.show {
  display: block;
  animation: fadeIn 0.3s ease-in-out;
}

.explanation h4 {
  color: #17a2b8;
}

/* Review Panel */
.review-panel {
  position: fixed;
  top: 0;
  right: -400px;
  width: 380px;
  height: 100vh;
  background: white;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  transition: right 0.3s ease;
  padding: 1.5rem;
  overflow-y: auto;
  display: none !important; /* Ẩn hoàn toàn khi chưa có câu đánh dấu */
}

.review-panel.show {
  right: 0 !important;
  display: block !important; /* Hiện khi có class show */
}

.review-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e9ecef;
}

.review-header h3 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.2rem;
  color: #2c3e50;
}

.flagged-questions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.flagged-question {
  background: #f8f9fa;
  border-radius: 6px;
  padding: 1rem;
  border-left: 3px solid #ffc107;
  cursor: pointer;
  transition: all 0.2s ease;
}

.flagged-question:hover {
  transform: translateX(5px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.flagged-question .question {
  font-weight: 500;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.flagged-question .your-answer,
.flagged-question .correct-answer {
  font-size: 0.85rem;
  padding: 0.5rem;
  border-radius: 4px;
  margin: 0.25rem 0;
}

.flagged-question .your-answer.correct {
  background: #e6f7e6;
  color: #2e7d32;
}

.flagged-question .your-answer.incorrect {
  background: #ffebee;
  color: #c62828;
}

.flagged-question .correct-answer {
  background: #e3f2fd;
  color: #1565c0;
}

/* Overlay for review panel */
.overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
}

.overlay.show {
  display: block;
  animation: fadeIn 0.3s ease-in-out;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .review-panel {
    width: 90%;
    right: -100%;
  }
  
  .question-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
}

/* Button styles */
.btn-danger {
  background-color: var(--primary-color);
  color: white;
  border: 1px solid var(--primary-color);
}

.btn-danger:hover {
  background-color: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-icon {
  background: none;
  border: none;
  color: #6c757d;
  padding: 0.375rem;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-icon:hover {
  background: #f1f3f5;
  color: #495057;
}

/* Flag count badge */
#flag-count {
  background: #ffc107;
  color: #212529;
  border-radius: 10px;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 0.25rem;
}

/* Quiz controls */
.quiz-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e9ecef;
}

.quiz-actions {
  display: flex;
  gap: 5rem; /* increase spacing between flag and submit buttons */
}

/* Answer feedback */
.answer.correct {
  background: #8B0000; /* Đỏ đậm cho đáp án đúng */
  border-color: #8B0000;
  color: #fff;
}

.answer.incorrect {
  background: #ffebee; /* Đỏ nhạt cho đáp án sai */
  border-color: #ffcdd2;
  color: #d32f2f;
}

.answer.correct .option {
  background: #8B0000; /* Đỏ đậm cho option đúng */
  color: white;
}

.answer.incorrect .option {
  background: #ffcdd2; /* Đỏ nhạt cho option sai */
  color: #d32f2f;
}

.answer.correct::after {
  content: '✓';
  margin-left: auto;
  color: #fff; /* Màu trắng cho dấu tích */
  font-weight: bold;
}

.answer.incorrect::after {
  content: '✗';
  margin-left: auto;
  color: #d32f2f; /* Đỏ đậm cho dấu X */
  font-weight: bold;
}

/* Override flag button to match primary buttons and be larger */
.btn-flag {
  background: var(--primary-color);
  color: #fff;
  border: 2px solid var(--primary-color);
  padding: 10px 16px;
  border-radius: var(--border-radius-md);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: auto;
  height: auto;
  white-space: nowrap;
  font-size: 1rem;
}

.btn-flag:hover,
.btn-flag.active {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
}
#topic-name, .topic-title, h1 {
  font-size: 1.25em;
  font-weight: 400;
  color: #800020;
  margin-bottom: 18px;
  text-align: left;
}
.btn-prev, .prev-btn {
  background: var(--primary-color) !important;
  color: #fff !important;
  border: 2px solid var(--primary-color) !important;
  border-radius: var(--border-radius-md);
  padding: 10px 20px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-prev:hover, .prev-btn:hover {
  background: var(--primary-dark) !important;
  border-color: var(--primary-dark) !important;
}
.footer-copyright {
  text-align: center;
  color: #800020;
  font-size: 0.98em;
  margin: 40px 0 10px 0;
  padding-top: 18px;
  border-top: 1px solid #e0e0e0;
  background: transparent;
  font-family: 'Segoe UI', Arial, sans-serif;
  opacity: 0.85;
  line-height: 1.6;
  font-weight: 1000; /* chữ đậm hơn */

}
/* Hiệu ứng nháy nhẹ cho nút */
#next-btn.pulse { animation: pulse .6s ease; }
@keyframes pulse { 0%{transform:scale(1)} 50%{transform:scale(1.05)} 100%{transform:scale(1)} }

/* Nếu có header cố định, khi scrollIntoView sẽ chừa phần trên */
#next-btn { scroll-margin-top: 80px; }  /* chỉnh 80px theo chiều cao header của bạn */
/* Chừa khoảng top khi scroll để câu hỏi không bị header che */
#question, .question-text, #question-container { 
  scroll-margin-top: 80px; /* chỉnh theo chiều cao header của bạn */
}
/* Badge trạng thái gắn vào nút Câu tiếp */
.status-badge{
  display:inline-flex; align-items:center; gap:6px;
  padding:3px 8px; border-radius:999px; font-size:12px; font-weight:600;
  border:1px solid rgba(0,0,0,.12);
}
.status-pending  { background:#fff8e1; color:#8a6d3b; border-color:#f0e1a3; }   /* Chưa chọn */
.status-correct  { background:#e8f5e9; color:#2e7d32; border-color:#a5d6a7; }   /* Đúng */
.status-incorrect{ background:#ffebee; color:#c62828; border-color:#ef9a9a; }   /* Sai */

/* Badge nằm gọn phía sau chữ trên nút */
  #next-btn .status-badge { margin-left:8px; }

  /* 
  ----------------------------------------------------------
  Bản quyền © 2025 Hệ thống ôn luyện trắc nghiệm Cần Thơ
  Tác giả: [Tên của bạn hoặc nhóm]
  Không được sử dụng lại hoặc sao chép khi chưa có sự đồng ý.
  ------------------------------------------------
  */
/* Timer styles */
.timer { font-variant-numeric: tabular-nums; }
.timer.warning { color: #e67e22 !important; }
.timer.danger  { color: #e53935 !important; animation: timerPulse 1s ease-in-out infinite; }
@keyframes timerPulse { 0%{transform:scale(1)} 50%{transform:scale(1.05)} 100%{transform:scale(1)} }
/* Force ẩn review panel và nút close */
#review-panel,
#close-review {
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

#review-panel.show {
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

#review-panel.show #close-review {
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* Hide CSV export button on all platforms */
button[onclick*="exportGlobalStatistics"],
button[onclick*="exportWrongAnswers"]:not([onclick*="Excel"]) {
  display: none !important;
}