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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f0f2f5;
  color: #333;
  line-height: 1.6;
  min-height: 100vh;
}

.app {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

.header {
  text-align: center;
  padding: 24px 0 16px;
}

.header h1 {
  font-size: 24px;
  color: #1a1a2e;
  font-weight: 700;
}

/* ---- Tabs ---- */
.tabs {
  display: flex;
  gap: 4px;
  background: #e8e8e8;
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 20px;
}

.tab {
  flex: 1;
  padding: 10px 8px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: #666;
  transition: all 0.2s;
  font-weight: 500;
}

.tab.active {
  background: #fff;
  color: #1a73e8;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

.tab:hover:not(.active) { color: #333; }

/* ---- Progress ---- */
.progress-bar {
  height: 6px;
  background: #e0e0e0;
  border-radius: 3px;
  margin-bottom: 6px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #1a73e8, #4fc3f7);
  border-radius: 3px;
  transition: width 0.4s ease;
  width: 0%;
}

.progress-text {
  display: block;
  text-align: right;
  font-size: 12px;
  color: #999;
  margin-bottom: 16px;
}

/* ---- Quiz Area ---- */
.quiz-area {
  background: #fff;
  border-radius: 12px;
  padding: 28px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  min-height: 360px;
}

.type-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 12px;
}

.type-badge.single { background: #e3f2fd; color: #1565c0; }
.type-badge.multi  { background: #fce4ec; color: #c62828; }
.type-badge.judge  { background: #e8f5e9; color: #2e7d32; }

.question-number {
  font-size: 13px;
  color: #999;
  margin-bottom: 8px;
}

.question-text {
  font-size: 17px;
  color: #222;
  margin-bottom: 24px;
  line-height: 1.7;
  font-weight: 500;
}

/* ---- Options ---- */
.options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 18px;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 15px;
  line-height: 1.5;
  position: relative;
  overflow: hidden;
}

.option:hover {
  border-color: #90caf9;
  background: #f5f9ff;
  transform: translateX(3px);
}

.option:active {
  transform: scale(0.99);
}

.option.selected {
  border-color: #1a73e8;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
}

.option.selected .option-letter {
  color: #1a73e8;
  font-weight: 800;
}

.option input {
  display: none;
}

.option .option-letter {
  font-weight: 700;
  color: #90a4ae;
  min-width: 24px;
  font-size: 14px;
  transition: color 0.2s;
}

.option .option-text { flex: 1; }

.option .option-icon {
  display: none;
  font-size: 20px;
  margin-left: 8px;
}

/* ---- Chosen by user (multi-choice result) ---- */
.option.chosen {
  border-color: #1a73e8 !important;
  box-shadow: inset 0 0 0 2px rgba(26, 115, 232, 0.3);
}

/* ---- Correct state ---- */
.option.correct {
  border-color: #4caf50;
  background: #e8f5e9;
  animation: pulse-correct 0.5s ease;
}

.option.correct .option-letter { color: #2e7d32; }

.option.correct .option-icon {
  display: block;
  color: #4caf50;
}

/* ---- Wrong state ---- */
.option.wrong {
  border-color: #f44336;
  background: #ffebee;
  animation: shake 0.4s ease;
}

.option.wrong .option-letter { color: #c62828; }

.option.wrong .option-icon {
  display: block;
  color: #f44336;
}

/* ---- Dimmed after answering ---- */
.option.dimmed {
  opacity: 0.45;
  pointer-events: none;
}

/* ---- Disable pointer after answered ---- */
.options.answered .option {
  pointer-events: none;
}

/* ---- Confirm button (multi-choice only) ---- */
.btn-confirm {
  display: none;
  width: 100%;
  padding: 12px;
  background: #1a73e8;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  margin-bottom: 16px;
}

.btn-confirm:hover { background: #1557b0; }
.btn-confirm:active { transform: scale(0.97); }
.btn-confirm:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* ---- Feedback banner ---- */
.feedback {
  padding: 14px 18px;
  border-radius: 10px;
  margin-bottom: 20px;
  font-size: 15px;
  line-height: 1.6;
  display: none;
  font-weight: 600;
  text-align: center;
  animation: fadeInUp 0.35s ease;
}

.feedback.show { display: block; }

.feedback.correct {
  background: #e8f5e9;
  border: 1px solid #a5d6a7;
  color: #2e7d32;
}

.feedback.wrong {
  background: #ffebee;
  border: 1px solid #ef9a9a;
  color: #c62828;
}

/* ---- Nav buttons ---- */
.nav-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.btn-nav {
  padding: 10px 32px;
  border: 2px solid #1a73e8;
  background: #fff;
  color: #1a73e8;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.btn-nav:hover {
  background: #1a73e8;
  color: #fff;
}

.btn-nav:disabled {
  border-color: #ddd;
  color: #ccc;
  cursor: not-allowed;
  background: #fafafa;
}

/* ---- Stats ---- */
.stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  padding: 20px 0;
  font-size: 14px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.stat.correct { color: #2e7d32; }
.stat.wrong   { color: #c62828; }
.stat.pending { color: #999; }

.stat strong { font-size: 18px; }

.stat .stat-icon { font-size: 16px; }

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #999;
}

.empty-state p { font-size: 16px; margin-bottom: 8px; }

/* ---- Animations ---- */
@keyframes pulse-correct {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.03); }
  60%  { transform: scale(0.98); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15%  { transform: translateX(-6px); }
  30%  { transform: translateX(6px); }
  45%  { transform: translateX(-5px); }
  60%  { transform: translateX(4px); }
  75%  { transform: translateX(-2px); }
  90%  { transform: translateX(2px); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ---- Stats clickable ---- */
.stat {
  cursor: pointer;
  user-select: none;
  transition: transform 0.15s, box-shadow 0.15s;
}

.stat:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* ---- Modal ---- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.modal-overlay.show {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  max-width: 520px;
  width: 90%;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  animation: fadeInUp 0.25s ease;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #eee;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: #222;
}

.modal-close {
  border: none;
  background: #f0f0f0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  color: #666;
  transition: background 0.15s;
}

.modal-close:hover { background: #ddd; }

.modal-body {
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.modal-body .q-chip {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 2px solid #e0e0e0;
  background: #fafafa;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  color: #555;
}

.modal-body .q-chip:hover {
  border-color: #1a73e8;
  background: #e8f0fe;
  color: #1a73e8;
  transform: scale(1.06);
}

.modal-body .q-chip.correct-chip { border-color: #4caf50; background: #e8f5e9; color: #2e7d32; }
.modal-body .q-chip.wrong-chip   { border-color: #f44336; background: #ffebee; color: #c62828; }
.modal-body .q-chip.pending-chip { border-color: #ccc; background: #fafafa; color: #999; }

/* ---- Responsive ---- */
@media (max-width: 600px) {
  .app { padding: 10px; }
  .quiz-area { padding: 18px; }
  .tabs { flex-direction: column; }
  .nav-buttons { flex-direction: column; }
  .btn-nav { width: 100%; }
  .stats { gap: 12px; }
  .stat { padding: 4px 12px; font-size: 13px; }
}
