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

:root {
  --primary: #2563EB;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --accent: #1e40af;
  --success: #2563EB;
  --danger: #e74c3c;
  --warning: #f0a500;
  --bg: #f0f4ff;
  --card-bg: #ffffff;
  --text: #2c3e50;
  --text-light: #6b8299;
  --border: #d4dff0;
  --radius: 16px;
  --shadow: 0 4px 20px rgba(37, 99, 235, 0.12);
  --shadow-lg: 0 8px 32px rgba(37, 99, 235, 0.18);
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 32px 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

h1 {
  font-size: 22px;
  text-align: center;
  margin-bottom: 4px;
  color: var(--text);
}
h2 { font-size: 20px; margin-bottom: 16px; color: var(--text); }

.subtitle {
  text-align: center;
  color: var(--text-light);
  margin-bottom: 20px;
  font-size: 14px;
}

/* Mascot */
.mascot-container {
  text-align: center;
  margin-bottom: 16px;
}
.mascot-img {
  width: 100px;
  height: 100px;
  object-fit: contain;
  border-radius: 50%;
  background: var(--primary-light);
  padding: 8px;
}

/* Form */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-group input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: var(--bg);
}
.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  background: #fff;
}

button {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  margin-top: 8px;
}
button:hover { background: var(--primary-dark); }
button:active { transform: scale(0.98); }
button:disabled { background: #93b5e0; cursor: not-allowed; }

.btn-success { background: var(--success); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #c0392b; }
.btn-secondary { background: var(--text-light); }

.error-text { color: var(--danger); font-size: 14px; margin-top: 12px; text-align: center; }
.warning-text { color: var(--warning); font-size: 14px; font-weight: 600; margin-top: 12px; text-align: center; }

.error-card {
  border: 2px solid var(--danger);
  text-align: center;
}
.error-card h2 { color: var(--danger); }
.error-card p { margin-bottom: 12px; color: var(--text-light); }

/* Welcome screen */
.welcome-card {
  text-align: center;
  padding: 40px 24px;
}
.welcome-card .mascot-img {
  width: 120px;
  height: 120px;
  margin-bottom: 20px;
}
.welcome-card .subtitle { margin-bottom: 8px; font-size: 15px; }
.welcome-card h1 { font-size: 24px; color: var(--primary-dark); }

/* Stacking instructions */
#instructions-screen {
  flex-direction: column;
  padding: 0;
  background: var(--primary);
}
.instructions-layout {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0;
}
.instruction-stack {
  padding: 24px 24px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.instruction-stacked {
  font-size: 13px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.7);
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  border-left: 3px solid rgba(255, 255, 255, 0.4);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.instruction-active-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 28px;
}
.instruction-text {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.5;
  color: #ffffff;
  text-align: center;
  transition: opacity 0.4s ease, transform 0.4s ease;
  opacity: 0;
  transform: translateY(20px);
}

/* Quiz screen */
#quiz-screen { flex-direction: column; padding: 0; background: var(--bg); }

.quiz-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--card-bg);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  z-index: 100;
  border-bottom: 2px solid var(--primary-light);
}

.progress-info { flex: 1; }
#q-counter { font-size: 13px; font-weight: 600; color: var(--text-light); }
.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 6px;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.3s;
  width: 0%;
}

.timer {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-left: 20px;
  padding: 6px 14px;
  background: var(--primary-light);
  border-radius: 8px;
  color: var(--primary-dark);
}
.timer.warning { color: var(--warning); background: #fef3c7; }
.timer.danger { color: var(--danger); background: #fee2e2; animation: pulse 1s infinite; }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }

.question-card {
  margin-top: 80px;
  padding: 24px 20px;
  width: 100%;
  max-width: 600px;
  align-self: center;
  position: relative;
}

.difficulty-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.difficulty-badge.easy { background: #dcfce7; color: #166534; }
.difficulty-badge.medium { background: #fef3c7; color: #92400e; }
.difficulty-badge.hard { background: #fee2e2; color: #991b1b; }

.question-text {
  font-size: 17px;
  line-height: 1.6;
  margin-bottom: 20px;
  font-weight: 500;
  position: relative;
}

.options-container { display: flex; flex-direction: column; gap: 10px; }

.option-btn {
  width: 100%;
  display: flex;
  align-items: flex-start;
  padding: 14px 16px;
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
  margin-top: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.option-btn:hover { border-color: var(--primary); background: var(--primary-light); }
.option-btn:active { transform: scale(0.98); }
.option-btn.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.option-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  background: var(--bg);
  font-weight: 700;
  font-size: 13px;
  margin-right: 12px;
  border: 2px solid var(--border);
}
.option-btn.selected .option-label {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Watermark */
.watermark {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0.04;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  display: none;
}
.watermark.active { display: block; }
.watermark span {
  display: inline-block;
  transform: rotate(-35deg);
  white-space: nowrap;
  margin: 40px 30px;
}

/* Result */
.result-card {
  text-align: center;
  padding: 40px 24px;
}
.result-card h2 { font-size: 20px; }
.score-display {
  font-size: 48px;
  font-weight: 800;
  margin: 20px 0;
  color: var(--primary);
}
#result-details { color: var(--text-light); margin-bottom: 8px; }
#result-time { color: var(--text-light); font-size: 14px; }

/* Cheated result */
.result-card h2[style*="dc2626"] ~ .score-display { color: var(--danger); }

/* Anti-OCR: invisible garbage characters */
.ocr-trap {
  font-size: 1px;
  color: transparent;
  position: absolute;
  overflow: hidden;
  width: 0;
  height: 0;
  display: inline;
  user-select: none;
  pointer-events: none;
  line-height: 0;
  letter-spacing: -1px;
}

/* Anti-OCR: decoy text layer */
.ocr-decoy-layer {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 10;
  overflow: hidden;
}
.ocr-decoy-text {
  position: absolute;
  font-size: 14px;
  color: var(--text);
  opacity: 0.025;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
  font-weight: 400;
}

/* Submit answer button */
.btn-submit-answer {
  margin-top: 20px;
  width: 100%;
  padding: 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.btn-submit-answer:hover { background: var(--primary-dark); }
.btn-submit-answer:active { transform: scale(0.98); }
.btn-submit-answer:disabled { background: #93b5e0; cursor: not-allowed; }

/* Welcome quiz info */
.quiz-info-line {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
  margin-top: 16px;
  text-align: center;
}
.quiz-info-teacher {
  font-size: 14px;
  color: var(--text-light);
  text-align: center;
  margin-top: 4px;
  font-style: italic;
}

/* Do Not Disturb warning */
.dnd-warning {
  margin-top: 16px;
  padding: 12px 14px;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
  color: #92400e;
  text-align: center;
}

/* Question number label */
.question-number {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
