/* Full-viewport quiz play mode — Evalumax / Board Prep / school portal */

:root {
  --quiz-primary: var(--qp-primary, var(--sms-primary, #4f46e5));
  --quiz-primary-dark: var(--qp-primary-dark, #3730a3);
  --quiz-secondary: var(--qp-secondary, #06b6d4);
  --quiz-accent: var(--qp-accent, #f59e0b);
  --quiz-bg: #eef2ff;
  --quiz-surface: #ffffff;
  --quiz-text: #0f172a;
  --quiz-muted: #64748b;
  --quiz-border: #e2e8f0;
  --quiz-success: #059669;
  --quiz-warning: #d97706;
  --quiz-danger: #dc2626;
  --quiz-ok: #1cc88a;
  --quiz-ink: #223;
  --brand: var(--quiz-primary);
  --brand-2: var(--quiz-secondary);
  --ok: var(--quiz-ok);
  --warn: #f6c23e;
  --danger: var(--quiz-danger);
  --ink: var(--quiz-ink);
  --card: var(--quiz-surface);
  --bg: var(--quiz-bg);
  --quiz-nav-h: 3.75rem;
}

html.quiz-play-html,
html:has(body.quiz-play-mode),
html:has(body.quiz-fullscreen-mode) {
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

body.quiz-play-mode,
body.quiz-fullscreen-mode.quiz-attempt-page {
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--quiz-bg);
  color: var(--quiz-text);
  font-family: Inter, "Source Sans Pro", system-ui, sans-serif;
}

body.quiz-play-mode .ccd-nav,
body.quiz-play-mode .ccd-footer,
body.quiz-play-mode .board-prep-nav,
body.quiz-play-mode .bp-bottom-nav,
body.quiz-play-mode .board-prep-footer,
body.quiz-play-mode .qp-play-bar,
body.quiz-attempt-page .main-header,
body.quiz-attempt-page .main-sidebar,
body.quiz-attempt-page .parent-portal-bottomnav {
  display: none !important;
}

body.quiz-attempt-page .content-wrapper {
  margin-left: 0 !important;
  padding: 0 !important;
  min-height: 0;
}

.quiz-play-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  min-width: 0;
  background:
    radial-gradient(1200px 400px at 10% -10%, rgba(79, 70, 229, 0.08), transparent 60%),
    var(--quiz-bg);
}
.quiz-play-header,
.quiz-play-nav {
  flex: 0 0 auto;
}
.quiz-play-main {
  flex: 1 1 auto;
}

.quiz-play-loading {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: var(--quiz-bg);
  color: var(--quiz-text);
  transition: opacity 0.2s ease;
}

.quiz-play-loading.is-done {
  opacity: 0;
  pointer-events: none;
}

.quiz-play-loading__spin {
  width: 36px;
  height: 36px;
  border: 3px solid #c7d2fe;
  border-top-color: var(--quiz-primary);
  border-radius: 50%;
  animation: quiz-play-spin 0.7s linear infinite;
}

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

/* Header */
.quiz-play-header {
  background: linear-gradient(90deg, var(--quiz-primary) 0%, var(--quiz-primary-dark) 100%);
  color: #fff;
  padding: 0.45rem 0.85rem;
  padding-top: calc(0.45rem + env(safe-area-inset-top, 0px));
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08);
  min-width: 0;
  z-index: 30;
}

.quiz-play-header__row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  min-height: 52px;
}

.quiz-play-exit {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff !important;
  font-weight: 700;
  font-size: 0.82rem;
  text-decoration: none !important;
  border: 1px solid rgba(255, 255, 255, 0.28);
  min-height: 36px;
}

.quiz-play-exit:hover,
.quiz-play-exit:focus {
  color: #fff !important;
  background: rgba(255, 255, 255, 0.28);
}

.quiz-play-title-wrap {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
}

.quiz-play-title {
  margin: 0;
  font-size: clamp(0.85rem, 1.6vw, 1.05rem);
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quiz-play-plan {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  opacity: 0.85;
  margin-top: 0.1rem;
}

.quiz-play-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.quiz-play-progress {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.2rem;
  min-width: 92px;
  padding: 0.28rem 0.55rem;
  border: 0;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
  color: #fff;
  font-weight: 700;
  font-size: 0.78rem;
  cursor: pointer;
}

.quiz-play-progress:hover,
.quiz-play-progress:focus-visible {
  background: rgba(0, 0, 0, 0.28);
  outline: 2px solid #fff;
  outline-offset: 1px;
}

.quiz-play-progress__track {
  display: block;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
  overflow: hidden;
}

.quiz-play-progress__bar {
  display: block;
  height: 100%;
  width: 0;
  background: #fff;
  border-radius: inherit;
  transition: width 0.2s ease;
}

.quiz-play-timer {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 5.25rem;
  justify-content: center;
  padding: 0.32rem 0.6rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.18);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.timer-ok { color: #ecfeff; }
.timer-warn { color: #fef3c7; background: rgba(217, 119, 6, 0.35); }
.timer-danger { color: #fee2e2; background: rgba(220, 38, 38, 0.4); }

.quiz-play-autosave {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.45rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.16);
}

.autosave-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
}

.autosave-ok { background: var(--quiz-success); }
.autosave-pending { background: var(--quiz-warning); }
.autosave-fail { background: var(--quiz-danger); }
#autosaveText { display: none; }

.quiz-play-fs {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.quiz-play-fs:hover,
.quiz-play-fs:focus-visible {
  background: rgba(255, 255, 255, 0.24);
  outline: 2px solid #fff;
  outline-offset: 1px;
}

/* Main */
.quiz-play-app .content.quiz-play-main,
.quiz-play-main {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0.75rem 0.85rem 0.5rem;
  -webkit-overflow-scrolling: touch;
}

.quiz-play-app #attemptForm {
  display: block;
  min-height: 0;
  height: auto;
}

.quiz-wrap {
  width: min(100%, 1000px);
  max-width: 100%;
  margin: 0 auto;
  padding: 0;
  min-width: 0;
}

.question-block { display: none; }
.question-block.active { display: block; }

.q-card {
  background: var(--quiz-surface);
  border: 1px solid var(--quiz-border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  min-width: 0;
}

.q-header {
  padding: 1rem 1.15rem 0.35rem;
  background: transparent;
  display: block;
}

.q-kicker {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--quiz-primary);
}

.q-bubble { display: none; }

.q-text {
  font-size: clamp(1.05rem, 2.1vw, 1.55rem);
  line-height: 1.5;
  color: var(--quiz-text);
  margin: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.q-body {
  padding: 0.65rem 1.15rem 1.1rem;
}

.option {
  border: 1.5px solid var(--quiz-border);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  margin-bottom: 0.55rem;
  cursor: pointer;
  background: #f8fafc;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  min-height: 44px;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  min-width: 0;
}

@media (hover: hover) and (pointer: fine) {
  .option:hover {
    border-color: #c7d2fe;
    background: #eef2ff;
  }
}

.option:has(input:focus-visible) {
  outline: 2px solid var(--quiz-primary);
  outline-offset: 1px;
}

.option input {
  margin-top: 0.2rem;
  flex-shrink: 0;
  cursor: pointer;
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--quiz-primary);
}

.option span {
  font-size: clamp(0.95rem, 1.4vw, 1.05rem);
  flex: 1;
  line-height: 1.45;
  overflow-wrap: anywhere;
  min-width: 0;
}

.option:has(input:checked),
.option.checked {
  border-color: var(--quiz-primary);
  background: #eef2ff;
  box-shadow: 0 0 0 1px var(--quiz-primary);
}

.question-media { width: 100%; }
.question-img {
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: min(42vh, 360px);
  object-fit: contain;
  display: block;
  margin: 0 auto;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--quiz-border);
  cursor: zoom-in;
}

.q-image-question .options-wrap {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

@media (min-width: 992px) {
  .q-image-question .options-wrap {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 575.98px) {
  .q-image-question .options-wrap {
    grid-template-columns: 1fr;
  }
}

/* Footer */
.quiz-play-nav,
.quiz-play-app .quiz-footer {
  position: static;
  background: #fff;
  border-top: 1px solid var(--quiz-border);
  padding: 0.45rem 0.75rem;
  padding-bottom: calc(0.45rem + env(safe-area-inset-bottom, 0px));
  z-index: 20;
}

.quiz-play-nav__inner,
.quiz-play-app .quiz-footer .d-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  max-width: 1000px;
  margin: 0 auto;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  padding: 0;
}

.quiz-play-btn {
  border-radius: 999px;
  font-weight: 700;
  padding: 0.5rem 1.1rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.quiz-play-btn--prev,
.btn-prev {
  border: 1.5px solid var(--quiz-border);
  background: #fff;
  color: var(--quiz-text);
}

.quiz-play-btn--next,
.btn-next {
  background: linear-gradient(90deg, var(--quiz-primary), var(--quiz-primary-dark));
  color: #fff;
  border: 0;
}

.btn-submit,
.quiz-play-btn--next.btn-submit {
  background: var(--quiz-success);
  color: #fff;
  border: 0;
}

.quiz-play-btn:disabled,
.btn-prev:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.quiz-play-btn:focus-visible,
.quiz-play-nav__index:focus-visible {
  outline: 2px solid var(--quiz-primary);
  outline-offset: 2px;
}

.quiz-play-nav__index {
  border: 0;
  background: #eef2ff;
  color: var(--quiz-primary);
  font-weight: 800;
  border-radius: 999px;
  min-height: 36px;
  padding: 0.25rem 0.75rem;
  font-variant-numeric: tabular-nums;
}

/* Palette */
#quizPlayPaletteGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 0.45rem;
}

.quiz-play-dot {
  min-height: 44px;
  border-radius: 10px;
  border: 1.5px solid var(--quiz-border);
  background: #fff;
  font-weight: 700;
  color: var(--quiz-text);
}

.quiz-play-dot.is-current {
  border-color: var(--quiz-primary);
  background: var(--quiz-primary);
  color: #fff;
}

.quiz-play-dot.is-answered {
  border-color: var(--quiz-success);
  background: #ecfdf5;
  color: #065f46;
}

.quiz-play-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.78rem;
  color: var(--quiz-muted);
  margin-bottom: 0.75rem;
}

/* Match */
.match-wrapper { margin-top: 0.5rem; }
.match-row { margin-bottom: 0.5rem; }
.match-left-label { width: 45%; min-width: 0; overflow-wrap: anywhere; }
.match-bank { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.match-chip {
  display: block;
  width: 100%;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #fff;
  cursor: grab;
  font-size: 0.9rem;
}
.match-dropzone {
  min-height: 38px;
  border: 1px dashed #cbd5e0;
  border-radius: 8px;
  padding: 4px 8px;
  background: #f9fbff;
  display: flex;
  align-items: center;
}
.match-dropzone.over { background: #e0f2fe; border-color: #60a5fa; }
.match-chip.dragging { opacity: 0.7; }

input.has-answer,
textarea.has-answer {
  border-color: var(--quiz-primary) !important;
  background-color: #eef2ff !important;
}

.match-dropzone.has-answer {
  border-color: var(--quiz-primary) !important;
  background-color: #eef2ff !important;
}

.quiz-play-note {
  max-width: 1000px;
  margin: 0.25rem auto 0;
  padding: 0 0.25rem;
  font-size: 0.78rem;
  color: var(--quiz-warning);
}

/* Practice: keep IDs, adopt academic shell */
.quiz-play-app--practice .quiz-compact-header {
  background: linear-gradient(90deg, var(--quiz-primary), var(--quiz-primary-dark));
  border-bottom: 0;
  box-shadow: none;
  padding: 0.4rem 0.75rem;
  padding-top: calc(0.4rem + env(safe-area-inset-top, 0px));
}

.quiz-play-app--practice .compact-header-row {
  max-width: 1000px;
}

.quiz-play-app--practice .timer-display,
.quiz-play-app--practice .question-counter,
.quiz-play-app--practice .score-counter {
  color: #fff;
}

.quiz-play-app--practice .question-label,
.quiz-play-app--practice .score-label {
  color: rgba(255, 255, 255, 0.8);
}

.quiz-play-app--practice .q-card {
  background: #fff;
  color: var(--quiz-text);
}

.quiz-play-app--practice .q-text {
  color: var(--quiz-text);
}

.quiz-play-app--practice .q-bubble {
  display: none;
}

.quiz-play-app--practice .q-header {
  background: transparent;
  display: block;
  padding: 1rem 1.15rem 0.35rem;
}

.quiz-play-app--practice .option-card {
  background: #f8fafc;
  border: 1.5px solid var(--quiz-border);
  color: var(--quiz-text);
  min-height: 44px;
  box-shadow: none;
}

.quiz-play-app--practice .option-card.selected {
  border-color: var(--quiz-primary);
  background: #eef2ff;
}

.quiz-play-app--practice .quiz-wrap {
  margin-bottom: 0.5rem;
  max-width: 1000px;
}

.quiz-play-app--practice .quiz-complete-screen {
  color: var(--quiz-text);
  background: #fff;
  border-radius: 16px;
  padding: 1.5rem;
}

@media (max-width: 767.98px) {
  .quiz-play-header__row {
    flex-wrap: wrap;
    min-height: 0;
    gap: 0.4rem;
  }

  .quiz-play-title-wrap {
    order: 3;
    flex: 1 1 100%;
    text-align: left;
  }

  .quiz-play-progress__words {
    display: none;
  }

  .quiz-play-exit span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .quiz-play-nav,
  .quiz-play-app .quiz-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 40;
    padding: 0.5rem 0.65rem;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.08);
  }

  .quiz-play-btn {
    padding: 0.5rem 0.7rem;
    font-size: 0.85rem;
  }

  .quiz-play-main {
    padding: 0.55rem 0.65rem calc(var(--quiz-nav-h) + env(safe-area-inset-bottom, 0px) + 0.5rem);
  }

  .q-header,
  .q-body {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }
}

@media (max-width: 379.98px) {
  .quiz-play-autosave { display: none; }
}

@media (orientation: landscape) and (max-height: 500px) {
  .quiz-play-header {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
  }

  .quiz-play-header__row { min-height: 40px; }
  .q-text { font-size: 1rem; }
}
