.quiz-container {
    max-width: 900px;
    margin: 20px auto;
    padding: 0;
}

/* Card styling */
.quiz-question.card {
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.quiz-question.card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* Question number */
.question-number {
    font-size: 1rem;
    min-width: 40px;
    text-align: center;
}

/* Question text and code styling */
.question-text {
    font-weight: 500;
    margin-bottom: 15px;
    line-height: 1.5;
}

.question-text code,
.statement p code {
    background-color: #f8f9fa;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: Consolas, Monaco, 'Andale Mono', monospace;
    font-size: 0.9em;
    color: #e83e8c;
    white-space: pre-wrap;
    word-wrap: break-word;
    border: 1px solid #eee;
    display: inline-block;
    margin: 2px 0;
}

.question-text pre,
.statement p pre {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid #eee;
    margin: 10px 0;
    overflow-x: auto;
}

.question-text pre code,
.statement p pre code {
    border: none;
    padding: 0;
    margin: 0;
    background: none;
}

/* Multiple Choice styling */
.option {
    padding: 10px;
    margin: 8px 0;
    border-radius: 6px;
    transition: all 0.2s ease;
    cursor: pointer;
    border: 1px solid transparent;
}

.option:hover {
    background-color: rgba(0,123,255,0.05);
    border-color: #007bff;
    transform: translateX(5px);
}

.option input[type="radio"] {
    margin-right: 10px;
}

/* True/False styling */
.statement {
    background: #fff;
    border-radius: 6px;
    margin-bottom: 15px;
    transition: all 0.2s ease;
}

.statement:hover {
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.tf-options {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

@media (max-width: 767.98px) {
    .tf-options {
        justify-content: flex-start;
        margin-top: 10px;
    }
}

.tf-options label {
    transition: all 0.2s ease;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid #dee2e6;
    margin: 0;
}

.tf-options label:hover {
    background-color: rgba(0,123,255,0.05);
    border-color: #007bff;
}

/* Answer highlighting */
.answer-highlight.correct {
    background-color: rgba(40, 167, 69, 0.1);
    border: 1px solid #28a745;
}

.answer-highlight.incorrect {
    background-color: rgba(220, 53, 69, 0.1);
    border: 1px solid #dc3545;
}

.answer-highlight.correct-answer {
    background-color: rgba(0, 123, 255, 0.1);
    border: 1px solid #007bff;
}

/* Khi show_answer=no, chỉ hiển thị highlight cho đáp án đúng mà người dùng đã chọn */
.hide-answers .answer-highlight.incorrect,
.hide-answers .answer-highlight.correct-answer {
    background-color: transparent !important;
    border-color: transparent !important;
}
.hide-answers .correct-answer-indicator,
.hide-answers .question-score {
    display: none !important;
}

/* Giữ highlight cho đáp án đúng khi người dùng chọn đúng (ngay cả khi show_answer=no) */
.hide-answers .answer-highlight.correct {
    background-color: rgba(40, 167, 69, 0.1) !important;
    border: 1px solid #28a745 !important;
}

/* Score indicators */
.correct-answer-indicator {
    margin-top: 8px;
    font-size: 0.9em;
    color: #007bff;
    padding: 4px 8px;
    background: rgba(0,123,255,0.05);
    border-radius: 4px;
    display: inline-block;
}

.question-score {
    margin-top: 10px;
    padding: 8px 12px;
    background-color: #f8f9fa;
    border-radius: 4px;
    font-weight: bold;
    color: #0056b3;
    border: 1px solid #dee2e6;
}

/* Controls */
.quiz-controls {
    margin-top: 30px;
    text-align: center;
}

.quiz-submit {
    padding: 12px 30px;
    font-size: 1.1em;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quiz-submit:hover:not(:disabled) {
    background: #0056b3;
    transform: translateY(-1px);
}

.quiz-submit:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Timer */
.quiz-timer {
    text-align: right;
    margin-bottom: 20px;
    font-weight: bold;
    color: #0056b3;
}

/* Results */
.quiz-results {
    margin: 30px 0;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.quiz-results h3 {
    margin-bottom: 20px;
    color: #0056b3;
    text-align: center;
    font-size: 1.5em;
}

/* Leaderboard */
.quiz-leaderboard {
    margin-top: 40px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.quiz-leaderboard h3 {
    color: #0056b3;
    margin-bottom: 20px;
    text-align: center;
}

.quiz-leaderboard-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 15px;
}

.quiz-leaderboard-table th,
.quiz-leaderboard-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}

.quiz-leaderboard-table th {
    background-color: #e9ecef;
    font-weight: 600;
    color: #495057;
}

.quiz-leaderboard-table tr:first-child td {
    background-color: rgba(255, 193, 7, 0.1);
    font-weight: bold;
}

.quiz-leaderboard-table tr:nth-child(2) td {
    background-color: rgba(108, 117, 125, 0.1);
}

.quiz-leaderboard-table tr:nth-child(3) td {
    background-color: rgba(176, 136, 96, 0.1);
}

/* Form states */
.quiz-form {
    pointer-events: none;
    transition: all 0.3s ease;
}

.quiz-form.active {
    pointer-events: auto;
}

.quiz-form.submitted {
    pointer-events: none;
}

.quiz-form.submitted input[type="radio"],
.quiz-form.submitted label {
    cursor: default;
}

.quiz-form.submitted .quiz-submit {
    display: none;
}

.quiz-form input:disabled + label {
    color: #999;
    cursor: not-allowed;
}

/* Thêm style mới cho options khi chưa active */
.quiz-form:not(.active) .option,
.quiz-form:not(.active) .tf-options label {
    cursor: not-allowed !important;
}

.quiz-form:not(.active) input[type="radio"] {
    cursor: not-allowed;
}

/* Start section */
.quiz-start-section {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.quiz-user-name {
    padding: 10px;
    margin-right: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1em;
    width: 250px;
    max-width: 100%;
}

.quiz-start-button {
    padding: 10px 20px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quiz-start-button:hover {
    background: #218838;
    transform: translateY(-1px);
}

/* Custom styles */
.quiz-container {
    max-width: 1200px;
    margin: 0 auto;
}

.quiz-title {
    color: #2c3e50;
    position: relative;
    padding-bottom: 15px;
}

.quiz-title:after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background-color: #3498db;
}

.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label {
    color: #3498db;
}

.quiz-start-button {
    transition: all 0.3s ease;
}

.quiz-start-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .card-body {
        padding: 1.5rem;
    }
    
    .quiz-title {
        font-size: 1.5rem;
    }
    
    .btn-lg {
        padding: 0.5rem 1rem;
        font-size: 1rem;
    }
}

/* Animation for error message */
.alert-danger {
    animation: shake 0.5s ease-in-out;
}

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

.tf-options {
    display: flex;
    gap: 10px;
    justify-content: flex-start;
}

.tf-options label {
    transition: all 0.2s ease;
    margin: 0;
    text-align: center;
    min-width: 80px;
}

.tf-options label span {
    display: block;
    width: 100%;
}

@media (max-width: 767.98px) {
    .tf-options {
        margin-top: 10px;
    }
    
    .tf-options label {
        min-width: 0;
        padding: 8px 12px;
    }
    
    .statement {
        background-color: #f8f9fa;
    }
    
    .statement:hover {
        background-color: #f1f3f5;
    }
}

/* Ngăn chọn nội dung câu hỏi và đáp án */
.quiz-question .question-text,
.quiz-question .option label,
.quiz-question .statement p {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Level Colors - Unified */
.bg-level-nb .number {
    color: #198754;
    border-color: #198754;
}
.bg-level-nb .level {
    background-color: #198754;
    color: white;
    border-color: #198754;
}

.bg-level-th .number {
    color: #fd7e14;
    border-color: #fd7e14;
}
.bg-level-th .level {
    background-color: #fd7e14;
    color: white;
    border-color: #fd7e14;
}

.bg-level-vd .number {
    color: #dc3545;
    border-color: #dc3545;
}
.bg-level-vd .level {
    background-color: #dc3545;
    color: white;
    border-color: #dc3545;
}

/* Badge styles for True/False statements */
.statement .badge.bg-level-nb {
    background-color: #198754 !important;
    color: white !important;
    border-color: #198754;
}

.statement .badge.bg-level-th {
    background-color: #fd7e14 !important;
    color: white !important;
    border-color: #fd7e14;
}

.statement .badge.bg-level-vd {
    background-color: #dc3545 !important;
    color: white !important;
    border-color: #dc3545;
}

/* Level badge positioning */
.question-level {
    font-size: 0.8em;
    padding: 4px 8px;
}

.statement .badge {
    font-size: 0.75em;
    padding: 3px 6px;
}

/* Question number box styling */
.question-number-box {
    display: flex;
    flex-direction: column;
    min-width: 40px;
    overflow: hidden;
    /* Xóa border mặc định ở đây */
}

.question-number-box .number {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 600;
    background: white;
    border: 2px solid; /* Thêm viền và độ dày */
    border-bottom: none; /* Bỏ viền dưới */
}

.question-number-box .level {
    width: 40px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.5px;
    border: 2px solid; /* Thêm viền và độ dày */
}

/* Level specific styles */
.bg-level-nb .number {
    color: #198754;
    border-color: #198754;
}
.bg-level-nb .level {
    background-color: #e7f5ec;
    color: #198754;
    border-color: #198754;
}

.bg-level-th .number {
    color: #fd7e14;
    border-color: #fd7e14;
}
.bg-level-th .level {
    background-color: #fff3e6;
    color: #fd7e14;
    border-color: #fd7e14;
}

.bg-level-vd .number {
    color: #dc3545;
    border-color: #dc3545;
}
.bg-level-vd .level {
    background-color: #fbebed;
    color: #dc3545;
    border-color: #dc3545;
}

/* Question number box styling */
.question-number-box {
    display: flex;
    flex-direction: column;
    min-width: 40px;
    overflow: hidden;
    border-radius: 4px;
}

.question-number-box .number {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 600;
    background: white;
    border: 2px solid;
}

.question-number-box .level {
    width: 40px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.5px;
    border: 2px solid;
}

/* Level Colors */
.bg-level-nb .number,
.bg-level-nb .level {
    border-color: #198754;
}
.bg-level-nb .number {
    color: #198754;
}
.bg-level-nb .level {
    background: #198754;
    color: white;
}

.bg-level-th .number,
.bg-level-th .level {
    border-color: #fd7e14;
}
.bg-level-th .number {
    color: #fd7e14;
}
.bg-level-th .level {
    background: #fd7e14;
    color: white;
}

.bg-level-vd .number,
.bg-level-vd .level {
    border-color: #dc3545;
}
.bg-level-vd .number {
    color: #dc3545;
}
.bg-level-vd .level {
    background: #dc3545;
    color: white;
}

/* Quiz Navigation Bar */
.quiz-navigation-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: #fff;
  z-index: 99999;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
  padding: 8px 0;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* Leaderboard Animation Effects */
.leaderboard-row {
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: center;
}

.leaderboard-row.new-entry {
  animation: newEntrySlide 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.leaderboard-row.updated {
  animation: rowUpdate 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.leaderboard-row.top3-change {
  animation: top3Change 1.2s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.leaderboard-row.rank-change {
  animation: rankChange 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

/* New Entry Animation */
@keyframes newEntrySlide {
  0% {
    opacity: 0;
    transform: translateX(-100%) scale(0.8);
    background: linear-gradient(90deg, #e3f2fd, #bbdefb);
  }
  50% {
    transform: translateX(0) scale(1.05);
    background: linear-gradient(90deg, #e8f5e8, #c8e6c9);
  }
  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
    background: inherit;
  }
}

/* Row Update Animation */
@keyframes rowUpdate {
  0% {
    transform: scale(1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  }
  50% {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    background: rgba(255, 255, 0, 0.1);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    background: inherit;
  }
}

/* Top 3 Change Animation */
@keyframes top3Change {
  0% {
    transform: scale(1) rotate(0deg);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  }
  25% {
    transform: scale(1.1) rotate(2deg);
    box-shadow: 0 8px 25px rgba(255, 193, 7, 0.3);
    background: linear-gradient(45deg, #fff3cd, #ffeaa7);
  }
  50% {
    transform: scale(1.15) rotate(-1deg);
    box-shadow: 0 12px 35px rgba(255, 193, 7, 0.4);
    background: linear-gradient(45deg, #fff3cd, #ffeaa7);
  }
  75% {
    transform: scale(1.05) rotate(0.5deg);
    box-shadow: 0 6px 20px rgba(255, 193, 7, 0.2);
    background: linear-gradient(45deg, #fff3cd, #ffeaa7);
  }
  100% {
    transform: scale(1) rotate(0deg);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    background: inherit;
  }
}

/* Rank Change Animation */
@keyframes rankChange {
  0% {
    transform: translateX(0);
    background: rgba(255, 193, 7, 0.1);
  }
  25% {
    transform: translateX(10px);
    background: rgba(255, 193, 7, 0.2);
  }
  75% {
    transform: translateX(-5px);
    background: rgba(255, 193, 7, 0.15);
  }
  100% {
    transform: translateX(0);
    background: inherit;
  }
}

/* Medal Glow Effect */
.medal-glow {
  animation: medalGlow 2s ease-in-out infinite alternate;
}

@keyframes medalGlow {
  0% {
    filter: drop-shadow(0 0 5px rgba(255, 193, 7, 0.5));
    transform: scale(1);
  }
  100% {
    filter: drop-shadow(0 0 15px rgba(255, 193, 7, 0.8));
    transform: scale(1.1);
  }
}

/* Score Update Flash */
.score-update {
  animation: scoreFlash 0.8s ease-out;
}

@keyframes scoreFlash {
  0% {
    background: rgba(40, 167, 69, 0.2);
    transform: scale(1);
  }
  50% {
    background: rgba(40, 167, 69, 0.4);
    transform: scale(1.05);
  }
  100% {
    background: inherit;
    transform: scale(1);
  }
}

/* Smooth Table Transitions */
.quiz-leaderboard .table {
  transition: all 0.3s ease;
}

.quiz-leaderboard .table tbody tr {
  transition: all 0.3s ease;
}

/* Loading Indicator */
.leaderboard-loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #3498db;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-left: 10px;
}

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

/* New Name Highlight */
.new-name-highlight {
  background: linear-gradient(45deg, #e8f5e8, #c8e6c9) !important;
  border-radius: 4px;
  padding: 2px 8px;
  font-weight: bold;
  color: #2e7d32;
  text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Smooth hover effects */
.leaderboard-row:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Pulse effect for important changes */
.leaderboard-row.important-change {
  animation: pulse 1.5s ease-in-out;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}
.quiz-nav-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid #0d6efd;
  background: #fff;
  color: #0d6efd;
  font-weight: bold;
  transition: all 0.2s;
  outline: none;
  cursor: pointer;
  margin-bottom: 4px;
}
.quiz-nav-btn.selected, .quiz-nav-btn.answered {
  background: #0d6efd;
  color: #fff;
  border-color: #0d6efd;
}
.quiz-nav-btn:focus {
  box-shadow: 0 0 0 2px #b6d4fe;
}
.quiz-nav-btn.partial {
  background: #fd7e14;
  color: #fff;
  border-color: #fd7e14;
}
@media (max-width: 600px) {
  .quiz-navigation-bar {
    gap: 4px;
    padding: 4px 0;
    flex-wrap: wrap;
    max-width: 100vw;
    justify-content: center;
  }
  .quiz-nav-btn {
    width: 28px;
    height: 28px;
    font-size: 14px;
    margin-bottom: 2px;
  }
}