* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;
  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
}

body {
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  line-height: 1.7;
  min-height: 100vh;
  padding: 16px;
  font-size: 16px;
}

.screen {
  display: none;
  max-width: 720px;
  margin: 0 auto;
}
.screen.active { display: block; }

.card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
  margin-bottom: 16px;
}
.card.center { text-align: center; }

.header { text-align: center; margin-bottom: 20px; }
.header h1 {
  font-size: 22px;
  color: var(--primary-dark);
  margin-bottom: 8px;
}
.subtitle { color: var(--text-light); font-size: 15px; }
.exam-date { color: var(--text-light); font-size: 14px; margin-top: 4px; }

.info-box {
  background: #eff6ff;
  border-right: 4px solid var(--primary);
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 14px;
}

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 15px;
}
.required { color: var(--danger); }
.form-group input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 15px;
  transition: border-color 0.2s;
  direction: rtl;
}
.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.hint { color: var(--text-light); font-size: 12px; }

.rules-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 14px 18px;
  margin: 20px 0;
}
.rules-box h3 { font-size: 15px; margin-bottom: 8px; color: #92400e; }
.rules-box ul { list-style-position: inside; font-size: 14px; }
.rules-box li { margin-bottom: 4px; }

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  touch-action: manipulation;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; }
.btn-large { width: 100%; padding: 16px; font-size: 17px; margin-top: 10px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.exam-header {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.student-name { font-weight: 600; font-size: 14px; }
.timer {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary-dark);
  font-variant-numeric: tabular-nums;
  background: #eff6ff;
  padding: 4px 12px;
  border-radius: 8px;
}
.timer.warning { background: #fee2e2; color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.6; } }
.progress-text { font-size: 14px; color: var(--text-light); }

.progress-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 16px;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s;
  width: 0%;
}

.exam-card { padding: 24px; }
.topic-badge {
  display: inline-block;
  background: #eff6ff;
  color: var(--primary-dark);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 14px;
}
.question-text {
  font-size: 18px;
  line-height: 1.8;
  margin-bottom: 20px;
  font-weight: 600;
}

.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  background: white;
  font-size: 16px;
  text-align: right;
  font-family: inherit;
  width: 100%;
}
.option:hover { border-color: var(--primary); background: #f8fafc; }
.option.selected {
  border-color: var(--primary);
  background: #eff6ff;
  font-weight: 600;
}
.option-num {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e2e8f0;
  color: var(--text);
  font-weight: 700;
  margin-left: 12px;
  flex-shrink: 0;
}
.option.selected .option-num {
  background: var(--primary);
  color: white;
}

.nav-buttons {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.nav-buttons .btn { flex: 1; min-width: 100px; }
.hidden { display: none !important; }

.success-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--success);
  color: white;
  font-size: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}
.result-box {
  background: #f8fafc;
  border-radius: 12px;
  padding: 20px;
  margin: 20px 0;
  text-align: right;
}
.result-box h3 { margin-bottom: 12px; color: var(--primary-dark); }
.result-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.result-row:last-child { border-bottom: none; }
.result-row .val { font-weight: 700; }
.score-big {
  font-size: 42px;
  font-weight: 800;
  color: var(--primary);
  text-align: center;
  margin: 12px 0;
}

@media (max-width: 480px) {
  body { padding: 10px; font-size: 15px; }
  .card { padding: 18px; }
  .question-text { font-size: 16px; }
  .option { padding: 12px; font-size: 15px; }
  .timer { font-size: 17px; padding: 3px 8px; }
  .exam-header { padding: 10px 12px; }
}
/* ===== امضای دبیر ===== */
.teacher-signature {
  text-align: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
  font-size: 14px;
  color: var(--text-light);
}
.teacher-signature p {
  margin: 0;
}
.teacher-signature strong {
  color: var(--primary-dark);
  font-weight: 700;
}
/* ===== دکمه‌های رادیویی (جنسیت و محل سکونت) ===== */
.radio-group {
  display: flex;
  gap: 12px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.radio-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  background: white;
  font-size: 15px;
  flex: 1;
  min-width: 100px;
  justify-content: center;
}
.radio-item:hover {
  border-color: var(--primary);
  background: #f8fafc;
}
.radio-item input[type="radio"] {
  width: auto;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
  transform: scale(1.2);
}
.radio-item input[type="radio"]:checked + span {
  font-weight: 700;
  color: var(--primary-dark);
}
.radio-item:has(input:checked) {
  border-color: var(--primary);
  background: #eff6ff;
}