:root {
  --maroon: #800000;
  --maroon-dark: #5a0000;
  --gold: #ffd700;
  --gold-dark: #e6c200;
  --bg-main: #f4f6f9;
  --card-bg: #ffffff;
  --text-dark: #1e293b;
  --text-muted: #64748b;
  --border-color: #cbd5e1;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  background-color: var(--bg-main);
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.noselect {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
}

input, textarea {
  user-select: auto !important;
  -webkit-user-select: auto !important;
}

.school-header {
  background: linear-gradient(135deg, var(--maroon) 0%, var(--maroon-dark) 100%);
  color: white;
  padding: 14px 24px;
  border-bottom: 3px solid var(--gold);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.header-content {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: #fff;
}

.school-titles h1 {
  font-size: 19px;
  font-weight: 800;
  color: var(--gold);
}

.school-titles .subtitle {
  font-size: 11px;
  color: #f1f5f9;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #0f172a;
  color: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 24px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.top-bar-left, .top-bar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  padding: 4px 10px;
  border-radius: 999px;
}

.pulse-dot {
  width: 9px;
  height: 9px;
  background-color: #ef4444;
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
  100% { transform: scale(0.95); }
}

.status-text {
  font-size: 0.75rem;
  font-weight: 700;
  color: #fca5a5;
}

.timer-box {
  background: #1e293b;
  padding: 6px 14px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 1rem;
  color: #38bdf8;
  border: 1px solid #334155;
  display: flex;
  align-items: center;
  gap: 6px;
}

.violation-box {
  background: #1e293b;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  border: 1px solid #334155;
  display: flex;
  align-items: center;
  gap: 8px;
}

.violation-badge {
  background: #475569;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
}

.violation-badge.danger { background: #ef4444; }

.progress-bar-container {
  width: 100%;
  height: 4px;
  background: #e2e8f0;
  position: sticky;
  top: 52px;
  z-index: 99;
}

.progress-bar-fill {
  height: 100%;
  background: var(--maroon);
  transition: width 0.3s ease;
}

.main-container {
  max-width: 960px;
  width: 100%;
  margin: 24px auto;
  padding: 0 20px;
  flex-grow: 1;
}

.card {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.05);
  border: 1px solid var(--border-color);
  padding: 26px;
  margin-bottom: 24px;
}

.login-card {
  max-width: 480px;
  margin: 40px auto;
  text-align: center;
}

.restricted-notice {
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  color: #9a3412;
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group textarea {
  width: 100%;
  padding: 11px 14px;
  font-size: 13.5px;
  border: 1.5px solid var(--border-color);
  border-radius: 6px;
  outline: none;
}

.slug-input-wrapper {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
}

.slug-prefix {
  background: #f1f5f9;
  padding: 11px 14px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 700;
  border-right: 1.5px solid var(--border-color);
}

.slug-input-wrapper input {
  border: none !important;
  flex-grow: 1;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  padding: 14px;
  border-radius: 8px;
  margin-bottom: 18px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  cursor: pointer;
}

.btn {
  padding: 11px 20px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.btn-primary { background: var(--maroon); color: white; }
.btn-primary:hover { background: var(--maroon-dark); transform: translateY(-1px); }
.btn-secondary { background: #64748b; color: white; }
.btn-secondary:hover { background: #475569; }
.btn-submit { background: #10b981; color: white; width: 100%; font-size: 15px; padding: 14px; }
.btn-submit:hover { background: #059669; }
.btn-warning { background: #ef4444; color: white; }

.exam-header-box {
  background: white;
  padding: 24px;
  border-radius: 12px;
  border-top: 6px solid var(--maroon);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  margin-bottom: 20px;
}

.question-card {
  background: white;
  border-radius: 12px;
  padding: 22px;
  margin-bottom: 18px;
  border: 1.5px solid var(--border-color);
  transition: border-color 0.2s;
}

.question-card.answered {
  border-color: #93c5fd;
  background: #fcfdfe;
}

.question-header {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}

.question-number {
  background: #f1f5f9;
  color: #334155;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 4px 10px;
  border-radius: 6px;
  height: fit-content;
}

.question-text {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-dark);
  line-height: 1.5;
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.option-label {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border: 1.5px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
}

.option-label.selected {
  border-color: #3b82f6;
  background: #eff6ff;
  color: #1e40af;
  font-weight: 600;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.exam-item-card {
  background: white;
  border: 1.5px solid var(--border-color);
  border-radius: 10px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.exam-item-card h4 {
  color: var(--maroon);
  margin-bottom: 6px;
}

.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-box {
  background: white;
  border-radius: 12px;
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  background: var(--maroon);
  color: white;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.modal-footer {
  padding: 14px 20px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}

.rules-box {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
}

.rules-box ul {
  list-style-position: inside;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12.5px;
  color: #475569;
}

.score-container {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  padding: 18px;
  border-radius: 10px;
  margin-bottom: 16px;
}

.score-value {
  font-size: 2.2rem;
  font-weight: 800;
  color: #0f172a;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 6px;
}

.answer-review-box {
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.review-item {
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
}

.review-item.correct { background: #ecfdf5; color: #065f46; }
.review-item.incorrect { background: #fef2f2; color: #991b1b; }

/* QR CODE VISUAL BOX */
.qr-canvas-box {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
  background: #ffffff;
  border: 1.5px dashed var(--border-color);
  border-radius: 10px;
  padding: 12px;
  margin-top: 12px;
}

.qr-link-display {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  padding: 10px;
  border-radius: 8px;
  font-size: 13px;
  word-break: break-all;
}

@media (max-width: 600px) {
  .top-bar { flex-direction: column; align-items: flex-start; gap: 8px; }
  .top-bar-right { width: 100%; justify-content: space-between; }
}