:root {
  --bg-start: #0f172a;
  --bg-end: #1e293b;
  --card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --correct: #10b981;
  --wrong: #ef4444;
  --border: #e2e8f0;
  --radius: 20px;
}

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

body {
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--bg-start), var(--bg-end));
  color: var(--text);
  padding: 24px 16px;
}

.app {
  width: 100%;
  max-width: 640px;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: fadeUp 0.4s ease both;
}

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

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 40px 36px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.logo {
  font-size: 56px;
  text-align: center;
  line-height: 1;
  margin-bottom: 16px;
}

h1 {
  font-size: 28px;
  text-align: center;
  margin-bottom: 8px;
}

.subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.6;
}

.rules {
  list-style: none;
  margin: 0 auto 32px;
  max-width: 360px;
}

.rules li {
  padding: 10px 0 10px 32px;
  position: relative;
  color: var(--text-muted);
  border-bottom: 1px dashed var(--border);
}

.rules li:last-child {
  border-bottom: none;
}

.rules li::before {
  content: "✓";
  position: absolute;
  left: 4px;
  color: var(--primary);
  font-weight: 700;
}

.btn {
  display: block;
  width: 100%;
  padding: 15px;
  font-size: 17px;
  font-weight: 700;
  font-family: inherit;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 10px 24px rgba(99, 102, 241, 0.4);
}

.btn.primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(99, 102, 241, 0.5);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

/* ---------- Quiz ---------- */

.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
}

.counter {
  color: var(--text-muted);
}

.score-live {
  color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
  padding: 4px 12px;
  border-radius: 999px;
}

.progress-track {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 28px;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  border-radius: 999px;
  transition: width 0.35s ease;
}

.question-text {
  font-size: 20px;
  line-height: 1.55;
  margin-bottom: 24px;
  min-height: 62px;
}

.options {
  display: grid;
  gap: 12px;
  margin-bottom: 24px;
}

.option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 15px 18px;
  font-size: 16px;
  font-family: inherit;
  text-align: left;
  color: var(--text);
  background: #f8fafc;
  border: 2px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.option:hover:not(:disabled) {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.06);
  transform: translateX(4px);
}

.option .key {
  flex: 0 0 28px;
  height: 28px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 8px;
}

.option.selected {
  border-color: var(--primary);
}

.option.correct {
  border-color: var(--correct);
  background: rgba(16, 185, 129, 0.12);
}

.option.correct .key {
  background: var(--correct);
  border-color: var(--correct);
  color: #fff;
}

.option.wrong {
  border-color: var(--wrong);
  background: rgba(239, 68, 68, 0.1);
}

.option.wrong .key {
  background: var(--wrong);
  border-color: var(--wrong);
  color: #fff;
}

.option:disabled {
  cursor: default;
}

.quiz-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.quiz-footer .btn {
  width: auto;
  min-width: 130px;
  padding: 13px 28px;
}

.feedback {
  font-weight: 700;
  font-size: 15px;
}

.feedback.ok { color: var(--correct); }
.feedback.no { color: var(--wrong); }

/* ---------- Result ---------- */

.result-score {
  text-align: center;
  font-size: 48px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 4px;
}

.review {
  margin: 24px 0;
  max-height: 240px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}

.review-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 4px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  line-height: 1.5;
}

.review-item .mark {
  flex: 0 0 auto;
  font-weight: 800;
}

.review-item .mark.ok { color: var(--correct); }
.review-item .mark.no { color: var(--wrong); }

.review-item .answer {
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

.review-item .answer b {
  color: var(--correct);
}

.footer {
  margin-top: 20px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.55);
}

@media (max-width: 520px) {
  .card { padding: 28px 22px; }
  h1 { font-size: 24px; }
  .question-text { font-size: 18px; }
  .quiz-footer { flex-direction: column-reverse; align-items: stretch; }
  .quiz-footer .btn { width: 100%; }
  .feedback { text-align: center; }
}
