:root {
  --board-bg: #1f4736;
  --board-bg-dark: #173629;
  --board-row: rgba(255, 255, 255, 0.08);
  --board-row-hover: rgba(255, 255, 255, 0.14);
  --board-border: #a36832;
  --board-border-inner: #7b4b1f;
  --chalk-yellow: #fbbf24;
  --chalk-cream: #fef3c7;
  --cta-orange: #ea6817;
  --cta-orange-hover: #d85a0c;
  --cta-orange-shadow: #a54106;
  --boy-blue: #93c5fd;
  --boy-text: #0f294a;
  --girl-pink: #fbcfe8;
  --girl-text: #591234;
  --present-green: #22c55e;
  --absent-muted: rgba(255, 255, 255, 0.22);
  --quiz-cream: #fff9eb;
  --quiz-box: #fef3d6;
  --font-main: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

mjx-container,
mjx-container * {
  box-sizing: content-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-main);
  background: #1a241e;
  color: #1f2937;
  user-select: none;
}

#stage-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 1;
}

/* ==================== TOP-RIGHT HUD ==================== */
.top-hud {
  position: fixed;
  top: 16px;
  right: 20px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-btn {
  height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1.5px solid rgba(30, 41, 59, 0.14);
  background: rgba(255, 255, 255, 0.94);
  color: #1e293b;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.14);
  transition: transform 0.12s ease, background 0.15s ease;
}

.hud-btn.icon-only {
  width: 42px;
  padding: 0;
  border-radius: 12px;
  font-size: 18px;
}

.hud-btn:hover {
  background: #ffffff;
  transform: translateY(-1px);
}

.hud-btn:active {
  transform: translateY(1px);
}

.hud-btn.hidden {
  display: none;
}

/* ==================== IDLE STAGE TITLE BANNER & PRIMARY CTA ==================== */
.idle-title-banner {
  position: fixed;
  top: 38.5%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 14;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.idle-title-banner.hidden {
  opacity: 0;
  transform: translate(-50%, calc(-50% - 16px)) scale(0.96);
}

.idle-title-img {
  width: clamp(420px, 46.5vw, 900px);
  max-height: 48vh;
  object-fit: contain;
  filter: drop-shadow(0 14px 26px rgba(24, 16, 10, 0.32));
  animation: luluTitleFloat 3.6s ease-in-out infinite;
}

@keyframes luluTitleFloat {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-6px);
  }
}

.idle-stage-cta {
  position: fixed;
  bottom: 34px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.idle-stage-cta.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(10px);
}

.stage-start-btn {
  min-width: 260px;
  height: 58px;
  padding: 0 34px;
  border: 2.5px solid #fff7ed;
  border-radius: 999px;
  background: var(--cta-orange);
  box-shadow: 0 6px 0 var(--cta-orange-shadow), 0 14px 28px rgba(0, 0, 0, 0.28);
  color: #ffffff;
  font-family: inherit;
  font-size: 21px;
  font-weight: 900;
  letter-spacing: 0.01em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  white-space: nowrap;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.12s ease;
}

.stage-start-btn:hover {
  background: var(--cta-orange-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 0 var(--cta-orange-shadow), 0 18px 32px rgba(0, 0, 0, 0.32);
}

.stage-start-btn:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 var(--cta-orange-shadow), 0 8px 16px rgba(0, 0, 0, 0.24);
}

/* ==================== MODAL BACKDROP ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(15, 23, 20, 0.36);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  transition: opacity 0.22s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ==================== CHALKBOARD SETUP MODAL ==================== */
.chalkboard-modal {
  position: relative;
  width: min(1140px, 96vw);
  max-height: 92vh;
  background: var(--board-bg);
  border: 14px solid var(--board-border);
  outline: 3px solid var(--board-border-inner);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.48), inset 0 0 40px rgba(0, 0, 0, 0.22);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  padding: 22px 28px 22px;
  overflow: hidden;
}

.board-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1.5px dashed rgba(255, 255, 255, 0.2);
}

.board-title {
  font-size: clamp(26px, 3vw, 35px);
  font-weight: 900;
  color: var(--chalk-yellow);
  letter-spacing: -0.01em;
  line-height: 1.15;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.28);
}

.board-subtitle {
  margin-top: 4px;
  font-size: 14px;
  color: rgba(248, 250, 252, 0.84);
  font-weight: 600;
}

.board-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.loaded-data-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.board-close-btn {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1.5px solid rgba(255, 255, 255, 0.24);
  background: var(--board-bg-dark);
  color: #f8fafc;
  font-family: inherit;
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.1s ease;
}

.board-close-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: scale(1.04);
}

.board-close-btn:active {
  transform: scale(0.96);
}

.data-pill {
  background: var(--board-bg-dark);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--chalk-cream);
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 800;
  white-space: nowrap;
}

/* Main 2-column Chalkboard Body */
.board-grid {
  display: grid;
  grid-template-columns: 330px 1fr;
  gap: 24px;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.left-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  padding-right: 4px;
}

.config-group {
  background: rgba(0, 0, 0, 0.16);
  border: 1px dashed rgba(255, 255, 255, 0.22);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.config-group-title {
  font-size: 15px;
  font-weight: 900;
  color: var(--chalk-yellow);
  letter-spacing: 0.01em;
}

.field-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.field-label-inline {
  font-size: 14px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.92);
  white-space: nowrap;
}

.inline-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-num-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--chalk-cream);
}

.num-mini-input {
  width: 58px;
  background: #ffffff;
  color: #1e293b;
  border: none;
  border-radius: 8px;
  padding: 5px 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 900;
  text-align: center;
  outline: none;
}

.quiz-subsettings {
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding-top: 8px;
  border-top: 1px dashed rgba(255, 255, 255, 0.15);
  transition: opacity 0.15s ease;
}

.muted-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  cursor: pointer;
}

.check-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--cta-orange);
  cursor: pointer;
  flex-shrink: 0;
}

.speed-select {
  background: #ffffff;
  color: #1e293b;
  border: none;
  border-radius: 8px;
  padding: 7px 10px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 800;
  cursor: pointer;
}

/* Right Roster Column */
.right-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.roster-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.roster-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 900;
}

.stats-pill {
  background: rgba(0, 0, 0, 0.26);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.92);
}

.roster-links {
  display: flex;
  align-items: center;
  gap: 14px;
}

.chalk-link {
  border: none;
  background: none;
  color: var(--chalk-yellow);
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  text-decoration: underline;
  cursor: pointer;
}

.chalk-link:hover {
  color: #fde68a;
}

.student-list-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 8px;
  padding-right: 6px;
}

.student-list-grid::-webkit-scrollbar {
  width: 7px;
}

.student-list-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.28);
  border-radius: 999px;
}

.student-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--board-row);
  padding: 7px 11px;
  border-radius: 10px;
  transition: background 0.12s ease, opacity 0.12s ease;
}

.student-item:hover {
  background: var(--board-row-hover);
}

.student-item.absent {
  opacity: 0.48;
}

.st-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 11.5px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.st-avatar.male {
  background: var(--boy-blue);
  color: var(--boy-text);
}

.st-avatar.female {
  background: var(--girl-pink);
  color: var(--girl-text);
}

.st-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
  font-weight: 800;
  color: #ffffff;
}

.st-star {
  color: var(--chalk-yellow);
  font-size: 14px;
  flex-shrink: 0;
}

.mini-pill {
  border: none;
  border-radius: 999px;
  padding: 4px 10px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 800;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.08s ease;
}

.mini-pill:active {
  transform: scale(0.95);
}

.mini-pill.male {
  background: var(--boy-blue);
  color: var(--boy-text);
}

.mini-pill.female {
  background: var(--girl-pink);
  color: var(--girl-text);
}

.mini-pill.present {
  background: var(--present-green);
  color: #052e16;
}

.mini-pill.absent {
  background: var(--absent-muted);
  color: #e2e8f0;
}

.roster-footer {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.roster-hint {
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.74);
  font-weight: 600;
}

/* SINGLE PRIMARY CTA ON SETUP SCREEN */
.primary-start-btn {
  width: 100%;
  height: 54px;
  border: none;
  border-radius: 14px;
  background: var(--cta-orange);
  box-shadow: 0 5px 0 var(--cta-orange-shadow);
  color: #ffffff;
  font-family: inherit;
  font-size: 20px;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.1s ease, background 0.15s ease;
}

.primary-start-btn:hover:not(:disabled) {
  background: var(--cta-orange-hover);
}

.primary-start-btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--cta-orange-shadow);
}

.primary-start-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ==================== PICKED STUDENT POPUP ("NGƯỜI ĐƯỢC CHỌN") ==================== */
.picked-modal {
  position: relative;
  width: min(680px, 92vw);
  background: linear-gradient(180deg, #25533f 0%, #1c4030 100%);
  border: 13px solid var(--board-border);
  outline: 3px solid var(--board-border-inner);
  border-radius: 20px;
  box-shadow: 0 28px 65px rgba(0, 0, 0, 0.52), inset 0 0 42px rgba(0, 0, 0, 0.2);
  padding: 36px 32px 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  color: #f8fafc;
}

.picked-badge {
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  background: #d94826;
  color: #ffffff;
  border: 2.5px solid #7c2d12;
  border-radius: 999px;
  padding: 6px 24px;
  font-size: 14.5px;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.28);
  white-space: nowrap;
}

.picked-avatar-ring {
  padding: 7px;
  border-radius: 50%;
  border: 3.5px dashed #facc15;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.picked-avatar-circle {
  width: 164px;
  height: 164px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #fffdf6 0%, #fef3c7 100%);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.26);
}

#picked-avatar-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.picked-name {
  font-size: clamp(32px, 4.4vw, 48px);
  font-weight: 900;
  color: #ffffff;
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.26);
}

.picked-callout {
  margin-top: 8px;
  font-size: clamp(18px, 2.2vw, 24px);
  font-weight: 800;
  color: #fde047;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.22);
}

.picked-meta {
  margin-top: 8px;
  font-size: 14.5px;
  font-weight: 700;
  color: rgba(248, 250, 252, 0.82);
}

.picked-actions {
  margin-top: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.picked-btn-primary {
  height: 50px;
  min-width: 158px;
  padding: 0 28px;
  border-radius: 999px;
  border: 2px solid #1c2e24;
  outline: 2px solid #fef08a;
  outline-offset: -4px;
  background: #fcd34d;
  color: #14241b;
  font-family: inherit;
  font-size: 17px;
  font-weight: 900;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.28);
  transition: transform 0.1s ease, background 0.15s ease;
}

.picked-btn-primary:hover {
  background: #fde047;
  transform: translateY(-1px);
}

.picked-btn-primary:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.28);
}

.picked-btn-secondary {
  height: 50px;
  min-width: 148px;
  padding: 0 26px;
  border-radius: 999px;
  border: 1.6px solid rgba(248, 250, 252, 0.56);
  background: rgba(15, 34, 25, 0.55);
  color: #f8fafc;
  font-family: inherit;
  font-size: 16.5px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s ease, transform 0.1s ease;
}

.picked-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
  transform: translateY(-1px);
}

.picked-btn-secondary:active {
  transform: translateY(1px);
}

.picked-btn-primary.hidden,
.picked-btn-secondary.hidden {
  display: none;
}

/* ==================== 6-QUESTION-TYPE QUIZ MODAL ==================== */
.winner-modal {
  position: relative;
  width: min(960px, 95vw);
  max-height: 92vh;
  background: var(--quiz-cream);
  border: 3px solid #2b1810;
  border-radius: 24px;
  box-shadow: 0 26px 65px rgba(0, 0, 0, 0.44);
  padding: 22px 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* Question Container inside Quiz Modal */
.question-container {
  width: 100%;
  margin-top: 0;
  background: var(--quiz-box);
  border: 2px dashed #d6bc8b;
  border-radius: 18px;
  padding: 16px 20px;
  text-align: left;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.question-container::-webkit-scrollbar {
  width: 7px;
}

.question-container::-webkit-scrollbar-thumb {
  background: rgba(161, 98, 7, 0.35);
  border-radius: 999px;
}

.question-container.hidden {
  display: none;
}

.q-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.q-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.q-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 900;
  color: #ffffff;
  letter-spacing: 0.02em;
}

.badge-mc {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
}

.badge-tf {
  background: linear-gradient(135deg, #0d9488, #14b8a6);
}

.badge-sa {
  background: linear-gradient(135deg, #7c3aed, #8b5cf6);
}

.badge-fb {
  background: linear-gradient(135deg, #d97706, #f59e0b);
}

.badge-ma {
  background: linear-gradient(135deg, #db2777, #ec4899);
}

.badge-es {
  background: linear-gradient(135deg, #059669, #10b981);
}

.q-counter {
  font-size: 13.5px;
  font-weight: 900;
  color: #a16207;
  text-transform: uppercase;
}

.q-controls-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.timer-pill {
  background: #291d12;
  color: #ffffff;
  border-radius: 999px;
  padding: 4px 13px;
  font-size: 14px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.timer-pill.hidden {
  display: none;
}

.timer-pill.urgent {
  background: #dc2626;
}

/* Question Prompt + Optional 50/50 Image Split */
.q-content-row {
  margin: 6px 0 14px;
}

.q-content-row.q-content-with-img {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 16px;
  align-items: center;
}

.question-text {
  text-align: center;
  font-size: 25px;
  font-weight: 800;
  color: #1c1917;
  line-height: 1.42;
  user-select: text;
}

.q-content-with-img .question-text {
  text-align: left;
}

.q-img-wrap {
  position: relative;
  background: #ffffff;
  border: 2px solid #e5dcc8;
  border-radius: 14px;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-in;
  overflow: hidden;
}

.q-img-wrap.hidden {
  display: none;
}

.q-img-wrap img {
  max-width: 100%;
  max-height: 205px;
  object-fit: contain;
  display: block;
  border-radius: 8px;
}

.q-img-zoom-hint {
  position: absolute;
  right: 8px;
  top: 8px;
  background: rgba(15, 23, 42, 0.68);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
  pointer-events: none;
}

.q-blank-inline {
  display: inline-block;
  padding: 1px 10px;
  margin: 0 3px;
  border-radius: 8px;
  background: #fef9c3;
  border-bottom: 2.5px solid #d97706;
  color: #92400e;
  font-weight: 900;
}

.q-blank-inline.filled {
  background: #dcfce7;
  border-bottom-color: #16a34a;
  color: #15803d;
}

/* ==================== 1. MULTIPLE CHOICE ==================== */
.options-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
}

.option-btn {
  background: #ffffff;
  border: 2px solid #e5dcc8;
  border-radius: 14px;
  padding: 11px 15px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: 17px;
  font-weight: 800;
  color: #1e293b;
  transition: border-color 0.14s ease, transform 0.1s ease, background 0.14s ease;
}

.option-btn:hover:not(:disabled) {
  border-color: #ea6817;
  transform: translateY(-1px);
}

.option-btn:disabled {
  cursor: default;
}

.option-letter {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #ea6817;
  color: #ffffff;
  font-size: 15px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.option-content {
  flex: 1;
  min-width: 0;
  line-height: 1.35;
}

.option-btn.correct {
  background: #dcfce7;
  border-color: #16a34a;
  color: #14532d;
}

.option-btn.correct .option-letter {
  background: #16a34a;
}

.option-btn.wrong {
  background: #fee2e2;
  border-color: #dc2626;
  color: #7f1d1d;
}

.option-btn.wrong .option-letter {
  background: #dc2626;
}

/* ==================== 2. TRUE / FALSE ==================== */
.tf-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.tf-list.single-col {
  grid-template-columns: 1fr;
}

.tf-row {
  background: #ffffff;
  border: 2px solid #e5dcc8;
  border-radius: 13px;
  padding: 10px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tf-text {
  flex: 1;
  min-width: 0;
  font-size: 16.5px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.35;
}

.tf-btns {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.tf-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 2px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
  font-family: inherit;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  transition: all 0.12s ease;
}

.tf-btn.tf-true:hover:not(:disabled) {
  border-color: #16a34a;
  color: #15803d;
}

.tf-btn.tf-false:hover:not(:disabled) {
  border-color: #dc2626;
  color: #b91c1c;
}

.tf-btn.tf-true.selected {
  background: #16a34a;
  border-color: #16a34a;
  color: #ffffff;
}

.tf-btn.tf-false.selected {
  background: #dc2626;
  border-color: #dc2626;
  color: #ffffff;
}

.tf-row.tf-correct {
  background: #dcfce7;
  border-color: #16a34a;
}

.tf-row.tf-wrong {
  background: #fee2e2;
  border-color: #dc2626;
}

.tf-btn.tf-timeout-correct {
  outline: 3px dashed #15803d;
  outline-offset: 2px;
  background: #bbf7d0;
  border-color: #16a34a;
  color: #14532d;
}

/* ==================== 3, 4, 6. SHORT ANSWER / FILL BLANK / ESSAY ==================== */
.q-confirm-wrap {
  margin-top: 14px;
  display: flex;
  justify-content: center;
}

.q-confirm-wrap.hidden,
.q-btn-confirm.hidden,
.q-btn-show-ans.hidden {
  display: none;
}

.q-btn-confirm,
.q-btn-show-ans {
  border: none;
  border-radius: 999px;
  padding: 10px 26px;
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
}

.q-btn-confirm {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.28);
}

.q-btn-confirm:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.q-btn-show-ans {
  background: #fffbeb;
  border: 2px solid #d97706;
  color: #78350f;
}

.q-btn-show-ans:hover {
  background: #fef3c7;
}

.q-ans-container.hidden {
  display: none;
}

.q-ans-box {
  background: #ffffff;
  border: 2px solid #86efac;
  border-radius: 14px;
  padding: 12px 16px;
  margin-top: 6px;
}

.q-ans-label {
  font-size: 12.5px;
  font-weight: 900;
  text-transform: uppercase;
  color: #15803d;
  margin-bottom: 4px;
}

.q-ans-content {
  font-size: 17.5px;
  font-weight: 800;
  color: #14532d;
  line-height: 1.45;
  user-select: text;
}

.q-ans-line+.q-ans-line {
  margin-top: 4px;
}

.q-mark-btns {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.markBtn {
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 9px 22px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
}

.markBtn.mark-correct {
  background: #16a34a;
  color: #ffffff;
}

.markBtn.mark-wrong {
  background: #dc2626;
  color: #ffffff;
}

.markBtn:disabled:not(.chosen) {
  opacity: 0.38;
  cursor: default;
}

/* ==================== 5. MATCHING (SVG CONNECTOR) ==================== */
.match-wrap {
  position: relative;
  width: 100%;
}

.match-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.match-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px 76px;
}

.match-item {
  position: relative;
  background: #ffffff;
  border: 2px solid #e5dcc8;
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-weight: 800;
  color: #1e293b;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.match-item:hover:not(:disabled) {
  border-color: #ea6817;
}

.match-item.selected {
  background: #fff7ed;
  border-color: #ea580c;
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.18);
}

.match-item.paired {
  border-color: #64748b;
  background: #f8fafc;
}

.match-item.match-correct {
  background: #dcfce7;
  border-color: #16a34a;
  color: #14532d;
}

.match-item.match-wrong {
  background: #fee2e2;
  border-color: #dc2626;
  color: #7f1d1d;
}

.match-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #ea6817;
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.match-num.match-letter {
  background: #2563eb;
}

.match-label {
  flex: 1;
  min-width: 0;
  font-size: 17px;
  line-height: 1.35;
}

.match-dot {
  position: absolute;
  top: 50%;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid #64748b;
  transform: translateY(-50%);
  z-index: 3;
}

.match-dot-r {
  right: -8px;
}

.match-dot-l {
  left: -8px;
}

.match-item.selected .match-dot {
  border-color: #ea580c;
  background: #ea580c;
}

.match-answer-key {
  margin-top: 10px;
  background: #ecfdf5;
  border: 1.5px solid #6ee7b7;
  color: #065f46;
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 13.5px;
  font-weight: 800;
  text-align: center;
}

/* Status Banner */
.q-status-banner {
  margin-top: 12px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 800;
  text-align: center;
}

.q-status-banner.hidden {
  display: none;
}

.q-status-banner.correct {
  background: #dcfce7;
  color: #15803d;
  border: 1.5px solid #86efac;
}

.q-status-banner.wrong {
  background: #fee2e2;
  color: #b91c1c;
  border: 1.5px solid #fca5a5;
}

.q-status-banner.neutral {
  background: #fef3c7;
  color: #92400e;
  border: 1.5px solid #fcd34d;
}

/* Bottom Modal Actions */
.winner-actions {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-shrink: 0;
}

/* SINGLE PRIMARY CTA ON WINNER MODAL */
.next-call-btn {
  height: 50px;
  padding: 0 28px;
  border: none;
  border-radius: 14px;
  background: var(--cta-orange);
  box-shadow: 0 5px 0 var(--cta-orange-shadow);
  color: #ffffff;
  font-family: inherit;
  font-size: 17.5px;
  font-weight: 900;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.next-call-btn:hover {
  background: var(--cta-orange-hover);
}

.back-list-btn {
  height: 50px;
  padding: 0 22px;
  border: 1.8px solid #cbd5e1;
  border-radius: 14px;
  background: #ffffff;
  color: #334155;
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 800;
  cursor: pointer;
}

/* ============================================================
   END-OF-QUIZ CONGRATULATIONS MODAL (Synchronized with ddkt)
   ============================================================ */
.congrats-card {
  position: relative;
  width: min(490px, 92vw);
  background: #fffaf0;
  border: 3px solid #2b1d12;
  border-radius: 26px;
  padding: 36px 34px 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  overflow: hidden;
  box-shadow:
    0 0 0 6px rgba(251, 191, 36, 0.35),
    0 28px 65px rgba(0, 0, 0, 0.5);
  animation: congratsPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes congratsPop {
  0% {
    transform: scale(0.76) translateY(28px);
    opacity: 0;
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.congrats-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 7px;
  background: linear-gradient(90deg, #ea580c, #fbbf24, #22c55e, #3b82f6, #a855f7, #ea580c);
  background-size: 200% 100%;
  animation: congratsStripeSlide 3.2s linear infinite;
}

@keyframes congratsStripeSlide {
  0% {
    background-position: 0% 0%;
  }
  100% {
    background-position: 200% 0%;
  }
}

.congrats-close-x {
  position: absolute;
  top: 15px;
  right: 16px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid #e2d6c1;
  background: #ffffff;
  color: #64748b;
  font-family: inherit;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.congrats-close-x:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
  transform: scale(1.06);
}

.congrats-trophy {
  font-size: 64px;
  line-height: 1;
  margin-bottom: 4px;
  filter: drop-shadow(0 6px 14px rgba(245, 158, 11, 0.42));
  animation: congratsTrophyBounce 1.8s ease-in-out infinite;
}

@keyframes congratsTrophyBounce {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  45% {
    transform: translateY(-9px) scale(1.06);
  }
  60% {
    transform: translateY(-3px) scale(1.02);
  }
}

.congrats-stars {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 19px;
  line-height: 1;
  margin-bottom: 10px;
  animation: congratsStarPulse 2s ease-in-out infinite;
}

.congrats-stars span:nth-child(2) {
  font-size: 25px;
}

@keyframes congratsStarPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.14);
  }
}

.congrats-sub {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #c2410c;
}

.congrats-name-wrap {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 2px solid #f59e0b;
  border-radius: 16px;
  padding: 11px 26px;
  max-width: 100%;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.22);
}

.congrats-name {
  margin: 0;
  font-size: clamp(26px, 3vw, 34px);
  font-weight: 900;
  color: #78350f;
  line-height: 1.2;
  word-break: break-word;
}

.congrats-score-wrap {
  margin-top: 14px;
  margin-bottom: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.congrats-score-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.congrats-score-stars {
  font-size: 36px;
  font-weight: 900;
  line-height: 1.1;
  background: linear-gradient(135deg, #d97706, #ea580c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.congrats-score-emoji {
  font-size: 30px;
  line-height: 1;
  filter: drop-shadow(0 3px 6px rgba(245, 158, 11, 0.35));
}

.congrats-score-detail {
  font-size: 14.5px;
  font-weight: 800;
  color: #475569;
}

.congrats-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Single Primary CTA on Congratulations Modal */
.congrats-btn-primary {
  height: 50px;
  padding: 0 32px;
  border: none;
  border-radius: 999px;
  background: var(--cta-orange);
  box-shadow: 0 5px 0 var(--cta-orange-shadow);
  color: #ffffff;
  font-family: inherit;
  font-size: 17.5px;
  font-weight: 900;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.1s ease, background 0.15s ease;
}

.congrats-btn-primary:hover {
  background: var(--cta-orange-hover);
  transform: translateY(-1px);
}

.congrats-btn-primary:active {
  transform: translateY(2px);
}

.congrats-btn-secondary {
  height: 50px;
  padding: 0 24px;
  border: 1.8px solid #cbd5e1;
  border-radius: 999px;
  background: #ffffff;
  color: #334155;
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.congrats-btn-secondary:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

/* Fullscreen Image Zoom Lightbox */
.img-lightbox {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(15, 23, 42, 0.86);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  cursor: zoom-out;
}

.img-lightbox.hidden {
  display: none;
}

.img-lightbox img {
  max-width: 92vw;
  max-height: 90vh;
  object-fit: contain;
  background: #ffffff;
  padding: 14px;
  border-radius: 16px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
}

/* Loading Splash */
.loading-bar-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: #1f4736;
  color: #fef3c7;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-weight: 900;
  font-size: 20px;
}

.loading-bar-overlay.hidden {
  display: none;
}

.loading-bar-overlay [hidden] {
  display: none;
}

#loading-status {
  max-width: min(640px, 90vw);
  text-align: center;
}

.progress-track {
  width: 260px;
  height: 12px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: #fbbf24;
  transition: width 0.15s ease;
}

@media (max-width: 860px) {
  .board-grid {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }

  .student-list-grid,
  .options-grid,
  .tf-list,
  .q-content-row.q-content-with-img {
    grid-template-columns: 1fr;
  }

  .match-grid {
    gap: 10px 44px;
  }
}
