/* 
   Container wrapper
*/
.tnma1-quiz-root {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
  padding: 0;
  
  /* Chỉ vùng chứa chính cuộn, bỏ mọi scroll khác */
  max-height: 100vh;
  overflow-y: auto;
  position: relative;
}

/* Giữ phần inner tự động cao, không cố định 100vh */
.tnma1-quiz-root .mqp-inner {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  box-sizing: border-box;
  font-family: Arial, sans-serif;
  min-height: 200px;
  height: auto !important;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Left and right panels
   ──────────────────────────────────────────────────────────────────────────── */
.tnma1-quiz-root .mqp-left {
  box-sizing: border-box;
  width: 65%;
  padding: 6px;
  border: 1px solid #eee;
  border-radius: 2px;
  background: #fff;
  overflow: visible !important;
}

.tnma1-quiz-root .mqp-right {
  box-sizing: border-box;
  width: 35%;
  padding: 2px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: stretch;
  justify-content: flex-start;
  border: 1px solid #eee;
  border-radius: 1px;
  background-color: #f9f9f9;
  overflow: visible !important;
  height: auto !important;
  position: sticky;
  top: 0;
  align-self: flex-start;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Countdown timer
   ──────────────────────────────────────────────────────────────────────────── */
.mqp-timer-wrap {
  text-align: center;
  margin-bottom: 10px;
  border: 1px solid #ddd;
  border-radius: 2px;
  padding: 6px;
}

.mqp-timer-label {
  font-size: 1rem;
  margin-bottom: 3px;
}

.mqp-timer {
  font-size: 1.5rem;
  font-weight: bold;
  color: #d00;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Question grid
   ──────────────────────────────────────────────────────────────────────────── */
.mqp-question-grid {
  display: flex;
  gap: 1px;
  margin-bottom: 5px;
  border: 1px solid #ddd;
  border-radius: 1px;
  padding: 1px;
  background: linear-gradient(#fff, #fafafa);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.02);
  width: 100%;
  box-sizing: border-box;
  flex-wrap: wrap;
  overflow: visible !important;
}

/* Hai cột trong grid */
.mqp-grid-column-left,
.mqp-grid-column-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Grid cell styling (5 cột đều nhau)
   ──────────────────────────────────────────────────────────────────────────── */
.mqp-grid-cell {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: center;
  justify-items: stretch;
  padding: 1px;
  border: 0.5px solid rgba(0,0,0,0.08);
  border-radius: 0.5px;
  background-color: #f7f7f7;
  color: #333;
  gap: 1px;
  min-height: 2.5em;
  transition: transform 0.08s ease, box-shadow 0.12s ease, background 0.12s ease;
  box-sizing: border-box;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  white-space: nowrap;
}

.mqp-grid-cell:not(.empty):hover {
  transform: translateY(-2px);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* Cột 1/5: số câu hỏi */
.mqp-grid-number {
  grid-column: 1 / 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(10px, 5vw, 16px);
  height: clamp(10px, 5vw, 16px);
  aspect-ratio: 1 / 1;
  border-radius: 1px;
  background: transparent;
  border: 1px solid transparent;
  font-size: clamp(8px, 2.5vw, 12px);
  font-weight: 700;
  color: inherit;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
  justify-self: center;
  align-self: center;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Cột 2–5/5: vùng chứa 4 ô lựa chọn */
.mqp-grid-inner-choices {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  align-items: center;
  justify-items: stretch;
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

/* Ô đáp án nhỏ (luôn vuông) */
.mqp-grid-choice {
  aspect-ratio: 1 / 1;
  padding: 0;
  font-size: clamp(8px, 2vw, 12px);
  text-align: center;
  border-radius: 1px;
  background: rgba(255,255,255,0.95);
  border: 1px solid rgba(0,0,0,0.08);
  color: #333;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, transform 0.08s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mqp-grid-choice:hover,
.mqp-grid-choice:focus {
  background: #eef6fb;
  transform: translateY(-1px);
}

/* Ô trống */
.mqp-grid-empty {
  font-size: 0.875rem;
  color: #aaa;
  padding: 0.5px;
  text-align: center;
}

/* Trạng thái cell */
.mqp-grid-cell.active {
  background: linear-gradient(180deg,#0073aa,#00658f);
  color: #fff;
}

.mqp-grid-cell.answered {
  background: linear-gradient(180deg,#4caf50,#3e8e41);
  color: #fff;
}

.mqp-grid-cell.empty {
  background: transparent;
  border: 1px dashed #eee;
  color: #bbb;
  cursor: default;
  transform: none;
  box-shadow: none;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Question area (sticky)
   ──────────────────────────────────────────────────────────────────────────── */
.mqp-question-area {
  margin-bottom: 20px;
  border: 1px solid #ddd;
  border-radius: 2px;
  padding: 10px;
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
}

.mqp-q-content {
  font-size: 1.125rem;
  margin-bottom: 15px;
}

/* Hình ảnh câu hỏi */
.mqp-question-image {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Choices (radio)
   ──────────────────────────────────────────────────────────────────────────── */
.mqp-choices {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
}

.mqp-choices label {
  display: flex;
  align-items: center;
  padding: 0.5px;
  border: 1px solid #ccc;
  border-radius: 1px;
  background: #fff;
  cursor: pointer;
  transition: background 0.2s ease;
}

.mqp-choices label:hover {
  background: #f0f0f0;
}

.mqp-choices input[type="radio"] {
  margin-right: 1px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Progress bar
   ──────────────────────────────────────────────────────────────────────────── */
.mqp-progress-wrap {
  margin-top: 2px;
}

.mqp-progress-bg {
  background: #ddd;
  height: 15px;
  width: 100%;
  border-radius: 5px;
  overflow: hidden;
}

.mqp-progress-bar {
  background: #0073aa;
  height: 10px;
  width: 0%;
  transition: width 0.3s ease;
}

.mqp-progress-text {
  text-align: right;
  font-size: 0.875rem;
  margin-top: 2px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Submit button
   ──────────────────────────────────────────────────────────────────────────── */
.mqp-end-wrap {
  text-align: center;
  margin-top: 20px;
}

.mqp-submit-btn {
  padding: 12px 24px;
  font-size: 16px;
  background: #d00;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.3s ease;
}

.mqp-submit-btn:hover,
.mqp-submit-btn:focus {
  background: #a00;
  outline: none;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Responsive adjustments (mobile & tablet)
   ──────────────────────────────────────────────────────────────────────────── */
@media screen and (max-width: 480px) {
  .tnma1-quiz-root .mqp-inner {
    flex-direction: column;
  }

  .tnma1-quiz-root .mqp-left,
  .tnma1-quiz-root .mqp-right {
    width: 100%;
    padding: 1px;
  }

  .mqp-question-grid {
    max-height: none !important;
    overflow: visible !important;
  }

  .mqp-grid-column-left,
  .mqp-grid-column-right {
    flex: 1 1 auto;
  }
  .mqp-question-area {
    position: sticky;
    top: 0;
    z-index: 999;
    background: #fff;
    padding: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  }

  /* Đảm bảo ảnh không bị co nhỏ */
  .mqp-question-image {
    width: 100% !important;
    height: auto !important;
    display: block;
    margin: 0 auto;
  }

  /* Cho phép phần còn lại cuộn bình thường */
  .tnma1-quiz-root {
    overflow-y: auto;
    max-height: 100vh;
  }
}

@media screen and (max-width: 768px) {
  .mqp-grid-number {
    width: clamp(6px, 6vw, 10px);
    height: clamp(8px, 6vw, 10px);
    aspect-ratio: 1 / 1;
    font-size: clamp(8px, 2.5vw, 12px);
  }

  .mqp-grid-choice {
    min-width: clamp(6px, 5vw, 10px);
    height: clamp(8px, 5vw, 10px);
    aspect-ratio: 1 / 1;
    font-size: clamp(8px, 2vw, 11px);
  }

  .mqp-choices {
    grid-template-columns: 1fr;
  }
}

/* ─────────────────────────────────────────────────────────────────────────────
   Modal confirm-submit
   ──────────────────────────────────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

#confirm-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#confirm-modal .modal-content {
  background: #fff;
  padding: 20px;
  border-radius: 4px;
  text-align: center;
}

#confirm-modal button {
  margin: 0 8px;
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

#confirm-modal #modal-ok {
  background-color: #4caf50;
  color: #fff;
}

#confirm-modal #modal-cancel {
  background-color: #f44336;
  color: #fff;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Ảnh câu hỏi auto co dãn vừa khít vùng chứa
   ──────────────────────────────────────────────────────────────────────────── */
.mqp-question-area img,
.mqp-question-image {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  margin: 0;
  max-width: 100%;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Cho phép grid-cell co giãn linh hoạt, giữ 5 cột 1 hàng
   ──────────────────────────────────────────────────────────────────────────── */
.mqp-grid-cell {
  display: grid;
  grid-template-columns: min-content 1fr; /* 2 cột: số câu + đáp án */
  align-items: center;
  gap: 0.5px;
  padding: 0px;
  border: 0.5px solid rgba(0,0,0,0.08);
  border-radius: 0.5px;
  background-color: #f7f7f7;
  box-sizing: border-box;
}

.mqp-grid-inner-choices {
  display: grid;
  grid-template-columns: repeat(4, minmax(6px, 1fr)); /* mỗi ô đáp án min 32px */
  gap: 0.5px;
  width: 100%;
  box-sizing: border-box;
}

.mqp-grid-choice {
  width: 100%;
  aspect-ratio: 1 / 1;
  box-sizing: border-box;
}
```
