:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #e0e7ff;
  --accent: #f59e0b;
  --success: #10b981;
  --success-bg: #d1fae5;
  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --warning: #f59e0b;
  --info: #0284c7;
  --bg-gradient: linear-gradient(135deg, #0b0f19 0%, #1e1b4b 50%, #312e81 100%);
  --card-bg: rgba(255, 255, 255, 0.96);
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius-lg: 20px;
  --radius-md: 14px;
  --shadow-lg: 0 12px 30px -5px rgba(0, 0, 0, 0.25), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background: var(--bg-gradient);
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 16px;
}

.app-container {
  width: 100%;
  max-width: 480px;
  margin: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Header & Brand */
.app-header {
  text-align: center;
  color: #fff;
  padding: 12px 0 6px;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.08);
  padding: 6px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
}

.logo-icon {
  font-size: 1.5rem;
}

.logo-text {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #fff;
}

.logo-accent {
  color: #38bdf8;
}

.brand-badge {
  font-size: 0.75rem;
  background: rgba(99, 102, 241, 0.4);
  color: #c7d2fe;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  transition: all 0.25s ease;
}

.card-header-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin: 0 auto 14px;
}

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

.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 14px 16px;
  font-size: 1.1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  background: #f8fafc;
  transition: all 0.2s;
  font-family: inherit;
}

.form-control:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px var(--primary-light);
}

.pin-input {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 6px;
  text-align: center;
  text-transform: uppercase;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 15px 20px;
  font-size: 1.1rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.4);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #f1f5f9;
  color: var(--text-main);
}

.btn-secondary:hover {
  background: #e2e8f0;
}

/* Pulse / Waiting state */
.waiting-box {
  text-align: center;
  padding: 30px 10px;
}

.pulse-circle {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.pulse-circle::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--primary);
  opacity: 0.3;
  animation: pulse 1.8s infinite cubic-bezier(0.4, 0, 0.6, 1);
}

.pulse-icon {
  font-size: 2.2rem;
  z-index: 2;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.4); opacity: 0; }
  100% { transform: scale(0.9); opacity: 0; }
}

.pin-pill {
  display: inline-block;
  background: #f1f5f9;
  border: 1px solid var(--border);
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 10px;
}

/* Question view */
.question-header {
  margin-bottom: 20px;
}

.question-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.question-title {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.35;
  color: var(--text-main);
}

/* Options Grid */
.options-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-btn {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  background: #f8fafc;
  color: var(--text-main);
  font-size: 1.05rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.option-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.option-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #e2e8f0;
  color: var(--text-main);
  font-weight: 800;
  font-size: 0.95rem;
  margin-right: 14px;
  flex-shrink: 0;
  transition: background 0.2s;
}

.option-btn:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

/* Selected state */
.option-btn.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-hover);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.25);
}

.option-btn.selected .option-tag {
  background: var(--primary);
  color: #fff;
}

/* Correct / Incorrect Highlights */
.option-btn.is-correct {
  border-color: var(--success) !important;
  background: var(--success-bg) !important;
  color: #065f46 !important;
  opacity: 1 !important;
}

.option-btn.is-correct .option-tag {
  background: var(--success) !important;
  color: #fff !important;
}

.option-btn.is-wrong {
  border-color: var(--danger) !important;
  background: var(--danger-bg) !important;
  color: #991b1b !important;
}

.option-btn.is-wrong .option-tag {
  background: var(--danger) !important;
  color: #fff !important;
}

/* Result Feedback Cards */
.result-banner {
  margin-top: 18px;
  padding: 16px;
  border-radius: var(--radius-md);
  text-align: center;
  font-weight: 700;
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.result-banner.success {
  background: var(--success-bg);
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.result-banner.error {
  background: var(--danger-bg);
  color: #991b1b;
  border: 1px solid #fecaca;
}

.result-banner.info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

@keyframes popIn {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Notification / Alert toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 600;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  animation: fadeIn 0.3s;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.hidden {
  display: none !important;
}

/* ========================================================
   STUDENT RECAP STYLES
   ======================================================== */
.recap-header {
  text-align: center;
  margin-bottom: 18px;
}

.recap-trophy {
  font-size: 3.2rem;
  margin-bottom: 6px;
  animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.score-circle-container {
  display: flex;
  justify-content: center;
  margin: 10px 0 14px;
}

.score-circle {
  width: 95px;
  height: 95px;
  border-radius: 50%;
  border: 4px solid var(--primary);
  background: var(--primary-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-weight: 900;
  font-size: 1.6rem;
  line-height: 1;
}

.score-circle small {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 4px;
}

.badge-rank {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.95rem;
}

.recap-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0;
}

.stat-box {
  border-radius: 12px;
  padding: 12px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-box.stat-correct {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.stat-box.stat-wrong {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.stat-box.stat-unanswered {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

.stat-num {
  font-size: 1.6rem;
  font-weight: 900;
  line-height: 1.1;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.recap-breakdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 22px;
  margin-bottom: 12px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.badge-pill {
  font-size: 0.8rem;
  font-weight: 700;
  background: #e2e8f0;
  color: #475569;
  padding: 2px 8px;
  border-radius: 999px;
}

.recap-questions-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}

.recap-q-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  text-align: left;
}

.recap-q-card.is-correct {
  border-left: 5px solid var(--success);
}

.recap-q-card.is-wrong {
  border-left: 5px solid var(--danger);
}

.recap-q-card.is-unanswered {
  border-left: 5px solid var(--text-muted);
}

.recap-q-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  margin-bottom: 6px;
}

.recap-q-text {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.35;
  color: var(--text-main);
  margin-bottom: 8px;
}

.recap-answer-row {
  font-size: 0.85rem;
  margin-bottom: 4px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.recap-ans-label {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
}

.recap-ans-value {
  font-weight: 700;
}
