:root { 
  --ink: #0f172a; 
  --ink2: #111827; 
  --panel: rgba(255, 255, 255, 0.55);
  --panel-tile: rgba(255, 255, 255, 0.65);
  --text-main: #000000;
  --text-muted: #374151;
}

* { 
  box-sizing: border-box; 
}

html, body { 
  margin: 0; 
  padding: 0; 
  font-family: system-ui, Segoe UI, Arial, sans-serif; 
  overflow-x: hidden;
  min-height: 100dvh; /* Replaces 100vh to prevent mobile address bar shifts */
}

body {
  background: url("../assets/background.jpg") center/cover no-repeat fixed,
              radial-gradient(1200px 600px at 50% -10%, #e6f0ff, #c7d2fe, #93c5fd);
  color: var(--text-main);
  min-height: 100dvh;
}

.wrap { 
  max-width: 960px; 
  margin: 0 auto; 
  padding: 16px 16px 48px; 
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.card {
  width: min(920px, 95%);
  max-height: 88dvh; /* Restricts height on mobile/desktop so short content stays fixed */
  overflow-y: auto;  /* Only enables scrollbars when content exceeds card max-height */
  overscroll-behavior: contain; /* Prevents rubber-band scrolling on iOS/Android */
  
  background: var(--panel);
  backdrop-filter: blur(6px);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 6px 24px rgba(0,0,0,.18);
  border: 1px solid rgba(0,0,0,.08);
  margin-bottom: 16px;
  color: var(--text-main);
}

h1 { 
  margin: 0 0 16px; 
  font-size: clamp(28px, 4vw, 40px);
  color: var(--text-main);
  text-align: center;
}

p.lead { 
  color: var(--text-main); 
  opacity: 0.85; 
  margin: 8px 0 16px; 
  text-align: center;
}

/* Accessible Form Labeling & Controls */
label {
  color: var(--text-main);
  font-weight: 700;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

select, input[type="number"], input[type="text"] {
  background: #fff; 
  border: 2px solid var(--ink2); 
  border-radius: 10px; 
  color: var(--text-main); 
  padding: 10px; 
  font-weight: 600; 
  width: 100%;
  font-size: 16px;
}

input[type="number"] {
  width: 140px;
}

.section-title { 
  font-weight: 800; 
  color: var(--text-main); 
  margin: 12px 0 6px; 
}

/* Original Option Button Base Styles */
.opt {
  border: 1px solid rgba(0,0,0,.18);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  background: #fff;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
  color: var(--text-main);
}

.opt:hover {
  background: rgba(255,255,255,0.85);
}

/* Selection State */
.opt.selected {
  border-color: var(--ink2);
  background: #e0e7ff;
}

/* Bright Green & Red Feedback Highlights for Correct/Incorrect Answers */
.opt.correct {
  background: #16a34a !important;
  border-color: #16a34a !important;
  color: #fff !important;
}

.opt.correct span {
  color: #fff !important;
}

.opt.correct input {
  accent-color: #fff;
}

.opt.incorrect {
  background: #ef4444 !important;
  border-color: #ef4444 !important;
  color: #fff !important;
}

.opt.incorrect span {
  color: #fff !important;
}

.opt.incorrect input {
  accent-color: #fff;
}

/* Action & Control Buttons */
.btn {
  appearance: none; 
  -webkit-appearance: none; 
  font: inherit; 
  line-height: 1;
  border: 2px solid var(--ink2); 
  border-radius: 12px; 
  background: #fff; 
  color: #111;
  padding: 12px 18px; 
  font-weight: 800; 
  cursor: pointer; 
  box-shadow: 0 2px 0 #00000020;
  text-decoration: none; 
  display: inline-flex; 
  align-items: center; 
  justify-content: center;
  box-sizing: border-box;
  transition: background 0.15s ease;
}

.btn[disabled] { 
  opacity: 0.6; 
  cursor: not-allowed; 
}

.btn:hover:not([disabled]) {
  background: #f3f4f6;
}

/* Debug Components */
.debugIcon {
  width: 22px; 
  height: 22px; 
  cursor: pointer; 
  opacity: 0.9; 
  margin: 10px auto 0;       
  display: block; 
  transition: transform .12s ease, opacity .12s ease;
}

.debugIcon:hover { 
  opacity: 1; 
  transform: scale(1.06); 
}

#debugBar, .debugBar {
  margin-top: 16px; 
  width: 100%; 
  padding: 8px 10px; 
  background: rgba(17, 24, 39, 0.8);
  color: #f3f4f6; 
  font-size: 13px; 
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  border-radius: 10px; 
  text-align: left; 
  box-shadow: inset 0 0 3px rgba(0,0,0,0.4);
  white-space: pre-wrap; 
  line-height: 1.3em; 
  max-height: 7em; 
  overflow-y: auto; 
  display: none;
}

.actions { 
  margin-top: 14px; 
  display: flex; 
  justify-content: flex-end; 
  align-items: center; 
  gap: 10px; 
}

/* Table Diagnostics & Progress Components */
.res-table {
  width: 100%; 
  border-collapse: collapse; 
  margin-top: 12px; 
  background: #fff;
  border-radius: 12px; 
  overflow: hidden; 
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.res-table th, .res-table td { 
  padding: 10px 14px; 
  text-align: left; 
  border-bottom: 1px solid rgba(0,0,0,0.08); 
  color: var(--text-main);
}

.res-table th { 
  background: #f1f5f9; 
  font-weight: 800; 
}

.score-badge { 
  display: inline-block; 
  padding: 4px 10px; 
  border-radius: 6px; 
  font-weight: 800; 
  color: #fff; 
}

.bg-green { background: #16a34a; }
.bg-amber { background: #d97706; }
.bg-red { background: #ef4444; }
.bg-gray { background: #94a3b8; }

/* Quiz Action Bar & Mobile Alignment */
.quiz-action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.quiz-meta-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.report-btn {
  appearance: none;
  background: transparent;
  border: 1px solid #dc2626;
  color: #dc2626;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  margin-right: 8px;
  transition: all 0.15s ease;
}

.report-btn:hover {
  background: #fef2f2;
}

.report-btn[disabled] {
  opacity: 0.65;
  cursor: default;
  border-color: #6b7280;
  color: #374151;
}

@media (max-width: 600px) {
  .quiz-action-bar {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 8px;
  }

  .quiz-meta-info {
    justify-self: end;
    font-size: 13px;
    text-align: right;
  }
}