@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display&family=DM+Sans:wght@400;500;600;700&display=swap');

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

:root {
  --denim: #3a4e61;
  --denim-deep: #293a46;
  --pine: #00846a;
  --pine-dark: #006b55;
  --pine-light: #52846c;
  --pine-pale: #e8f1ed;
  --gold: #e0c460;
  --gold-pale: #fdf8ed;
  --salmon: #dea598;
  --salmon-pale: #faf0ee;
  --cream: #f7f6f3;
  --warm-white: #fdfcfa;
  --error: #c43c3c;
  --error-light: #fceaea;
  --text: #293a46;
  --text-mid: #5a6b78;
  --text-light: #8a959e;
  --border: #e4e2dd;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 2px 12px rgba(41, 58, 70, 0.06);
  --shadow-lg: 0 8px 30px rgba(41, 58, 70, 0.1);
}

body {
  font-family: 'DM Sans', -apple-system, sans-serif;
  background: var(--cream);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 280px;
  background: linear-gradient(135deg, var(--denim-deep) 0%, var(--denim) 60%, var(--pine-dark) 100%);
  z-index: -1;
}

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* Header */
header {
  text-align: center;
  padding: 36px 0 28px;
  color: white;
}

header .logo-img {
  height: 22px;
  opacity: 0.8;
  margin-bottom: 10px;
  filter: brightness(0) invert(1);
}

header h1 {
  font-family: 'DM Serif Display', serif;
  font-size: 2.2rem;
  font-weight: 400;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.subtitle {
  color: rgba(255,255,255,0.6);
  margin-top: 6px;
  font-size: 0.92rem;
}

/* Screens */
.screen { display: none; animation: fadeUp 0.35s ease; }
.screen.active { display: block; }

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

/* Card */
.card {
  background: var(--warm-white);
  border-radius: var(--radius);
  padding: 36px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(228, 226, 221, 0.5);
}

.card h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.45rem;
  font-weight: 400;
  margin-bottom: 12px;
  color: var(--denim-deep);
  line-height: 1.35;
}

.card > p { color: var(--text-mid); font-size: 0.92rem; }

/* Filters */
.filters {
  display: flex;
  gap: 8px;
  margin: 14px 0;
  flex-wrap: wrap;
}

.filters label {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 100px;
  border: 1.5px solid var(--border);
  transition: all 0.2s;
  color: var(--text-mid);
  background: var(--warm-white);
}

.filters label:hover { border-color: var(--pine); }

#category-filters label.checked {
  background: var(--denim);
  border-color: var(--denim);
  color: white;
}

#difficulty-filters label.checked {
  background: var(--gold-pale);
  border-color: var(--gold);
  color: #8a6d10;
}

.filters input[type="checkbox"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

/* Progress */
.progress {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.progress-bar {
  flex: 1;
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--pine), var(--pine-light));
  border-radius: 3px;
  transition: width 0.4s ease;
}

#progress-text {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-light);
  white-space: nowrap;
  letter-spacing: 0.5px;
}

/* Badges */
.question-meta {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.68rem;
  padding: 3px 11px;
  border-radius: 100px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.badge.category { background: var(--gold-pale); color: #a08520; }
.badge.difficulty { background: var(--cream); color: var(--text-light); }
.badge.trust[data-trust="verified"] { background: var(--pine-pale); color: var(--pine); }
.badge.trust[data-trust="documented"] { background: var(--gold-pale); color: #a08520; border: 1px solid var(--gold); }

/* Options */
.option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 15px 20px;
  margin: 8px 0;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--warm-white);
  cursor: pointer;
  font-size: 0.93rem;
  font-family: inherit;
  transition: all 0.2s;
  line-height: 1.45;
  color: var(--text);
}

.option:hover { border-color: var(--pine); background: var(--pine-pale); transform: translateY(-1px); box-shadow: var(--shadow); }
.option.selected { border-color: var(--pine); background: var(--pine-pale); }
.option.correct { border-color: var(--pine); background: var(--pine-pale); }
.option.incorrect { border-color: var(--error); background: var(--error-light); }
.option[disabled] { cursor: default; transform: none; box-shadow: none; }
.option[disabled]:hover { transform: none; box-shadow: none; }
.option.correct[disabled]:hover { border-color: var(--pine); background: var(--pine-pale); }
.option.incorrect[disabled]:hover { border-color: var(--error); background: var(--error-light); }

/* Ordering */
.ordering-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 18px;
  margin: 6px 0;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--warm-white);
  cursor: pointer;
  font-size: 0.93rem;
  transition: all 0.2s;
  user-select: none;
}

.ordering-item:active { box-shadow: var(--shadow-lg); }
.ordering-item.selected { border-color: var(--pine); background: var(--pine-pale); box-shadow: var(--shadow); }
.ordering-number { font-weight: 700; color: var(--pine); min-width: 24px; }
.ordering-item.correct { border-color: var(--pine); background: var(--pine-pale); }
.ordering-item.incorrect { border-color: var(--error); background: var(--error-light); }

/* True/False */
.tf-options { display: flex; gap: 12px; margin: 18px 0; }

.tf-option {
  flex: 1;
  padding: 18px;
  text-align: center;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 1.05rem;
  transition: all 0.2s;
  font-family: inherit;
  color: var(--text);
  background: var(--warm-white);
}

.tf-option:hover { border-color: var(--pine); transform: translateY(-1px); }
.tf-option.selected { border-color: var(--pine); background: var(--pine-pale); }
.tf-option.correct { border-color: var(--pine); background: var(--pine-pale); }
.tf-option.incorrect { border-color: var(--error); background: var(--error-light); }

/* Feedback */
.feedback {
  margin: 18px 0;
  padding: 18px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  line-height: 1.6;
  border-left: 4px solid;
}

.feedback.correct { background: var(--pine-pale); border-color: var(--pine); color: var(--pine-dark); }
.feedback.incorrect { background: var(--salmon-pale); border-color: var(--salmon); color: var(--error); }
.feedback .source { font-size: 0.78rem; margin-top: 10px; opacity: 0.6; }
.feedback .learn-more {
  display: inline-block;
  margin-top: 10px;
  color: var(--pine);
  font-weight: 600;
  text-decoration: none;
  font-size: 0.85rem;
}
.feedback .learn-more:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* Buttons */
.actions { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; }

.btn {
  padding: 13px 26px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  letter-spacing: 0.2px;
}

.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { background: var(--pine); color: white; }
.btn.primary:hover:not(:disabled) { background: var(--pine-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,132,106,0.3); }
.btn.secondary { background: var(--cream); color: var(--text); border: 1.5px solid var(--border); }
.btn.secondary:hover { background: var(--border); }
.btn.denim { background: var(--denim); color: white; }
.btn.denim:hover { background: var(--denim-deep); transform: translateY(-1px); }

/* Score */
.score-display { text-align: center; margin: 28px 0; }

.score-circle {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-family: 'DM Serif Display', serif;
  font-size: 2.4rem;
  font-weight: 400;
  border: 5px solid;
  transition: all 0.5s;
}

.score-circle.great { border-color: var(--pine); color: var(--pine); background: var(--pine-pale); }
.score-circle.good { border-color: var(--denim); color: var(--denim); background: var(--cream); }
.score-circle.poor { border-color: var(--salmon); color: var(--error); background: var(--salmon-pale); }

#score-message {
  font-family: 'DM Serif Display', serif;
  font-size: 1.15rem;
  font-weight: 400;
  color: var(--denim-deep);
  margin: 8px 0 4px;
}

#results-breakdown { margin-top: 24px; }

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.result-row:last-child { border-bottom: none; }

.result-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
}
.result-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--pine), var(--pine-light));
  border-radius: 2px;
  transition: width 0.6s ease;
}

/* Leaderboard */
.leaderboard-section { margin-top: 28px; }
.leaderboard-section h3 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--denim-deep);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--pine-pale);
}

.leaderboard-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-radius: 8px;
  margin: 4px 0;
  font-size: 0.88rem;
  transition: background 0.15s;
}

.leaderboard-entry:nth-child(even) { background: var(--cream); }
.leaderboard-entry .rank {
  font-weight: 700;
  color: var(--pine);
  min-width: 32px;
  font-size: 0.82rem;
}
.leaderboard-entry .name { flex: 1; font-weight: 500; }
.leaderboard-entry .score { font-weight: 700; color: var(--denim); font-size: 0.9rem; }

/* Name input */
.name-input-section {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.name-input-section label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--denim);
  display: block;
  margin-bottom: 8px;
}
.name-input-section input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.93rem;
  font-family: inherit;
  margin-bottom: 12px;
  background: var(--warm-white);
  color: var(--text);
  transition: all 0.2s;
}
.name-input-section input:focus {
  outline: none;
  border-color: var(--pine);
  box-shadow: 0 0 0 3px var(--pine-pale);
}

/* Review */
.review-item {
  padding: 22px 0;
  border-bottom: 1px solid var(--border);
}
.review-item:last-child { border-bottom: none; }
.review-item h3 { font-size: 0.95rem; margin-bottom: 8px; line-height: 1.4; }
.review-item .answer { font-size: 0.88rem; margin: 4px 0; line-height: 1.5; }
.review-item .answer.correct-answer { color: var(--pine); }
.review-item .answer.user-wrong { color: var(--error); }
.review-item .review-source { font-size: 0.78rem; color: var(--text-light); margin-top: 8px; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(41, 58, 70, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s;
}

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

.modal-content {
  background: var(--warm-white);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 460px;
  width: 90%;
  box-shadow: var(--shadow-lg);
}

.modal-content h3 { font-family: 'DM Serif Display', serif; font-weight: 400; margin-bottom: 6px; }
.modal-content p { color: var(--text-mid); margin-bottom: 16px; font-size: 0.9rem; }
.modal-content select, .modal-content textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 12px;
  font-family: inherit;
  background: var(--warm-white);
}
.modal-content select:focus, .modal-content textarea:focus, .modal-content input[type="email"]:focus {
  outline: none;
  border-color: var(--pine);
  box-shadow: 0 0 0 3px var(--pine-pale);
}

.modal-content input[type="email"] {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 12px;
  font-family: inherit;
  background: var(--warm-white);
}

#flag-status {
  margin-top: 12px;
  font-size: 0.88rem;
  padding: 10px;
  border-radius: 6px;
}

#flag-status.success { background: var(--pine-pale); color: var(--pine); }
#flag-status.error { background: var(--error-light); color: var(--error); }

/* Share */
.share-section { margin-top: 20px; }

.share-url-box {
  display: flex;
  gap: 8px;
  align-items: center;
}

.share-url-box input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: inherit;
  background: var(--cream);
  color: var(--text);
}

#shared-score-name {
  font-family: 'DM Serif Display', serif;
  font-size: 1.2rem;
  color: var(--denim-deep);
  margin-bottom: 4px;
}

/* Feedback link + activity */
.feedback-link {
  margin-top: 20px;
  text-align: center;
}

.feedback-activity {
  font-size: 0.82rem;
  color: var(--text-mid);
  margin-bottom: 8px;
  padding: 8px 16px;
  background: var(--pine-pale);
  border-radius: 100px;
  display: inline-block;
}

.btn-link {
  background: none;
  border: none;
  color: var(--pine);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.btn-link:hover { color: var(--pine-dark); }

/* Feedback type pills */
.feedback-type-pills {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.pill {
  padding: 6px 14px;
  border-radius: 100px;
  border: 1.5px solid var(--border);
  background: var(--warm-white);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-mid);
  transition: all 0.15s;
}

.pill:hover { border-color: var(--pine); }
.pill.active { background: var(--pine); border-color: var(--pine); color: white; }

.modal-content input[type="text"] {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 12px;
  font-family: inherit;
  background: var(--warm-white);
}

.modal-content input[type="text"]:focus {
  outline: none;
  border-color: var(--pine);
}

#feedback-status {
  margin-top: 12px;
  font-size: 0.88rem;
  padding: 10px;
  border-radius: 6px;
}

#feedback-status.success { background: var(--pine-pale); color: var(--pine); }
#feedback-status.error { background: var(--error-light); color: var(--error); }

/* Recent Activity */
.recent-activity {
  margin-top: 24px;
}

.recent-activity h3 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--denim-deep);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--cream);
}

.activity-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 0.88rem;
}

.activity-item .activity-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.activity-item .activity-name { font-weight: 600; color: var(--denim); }
.activity-item .activity-score { color: var(--pine); font-weight: 600; }
.activity-item .activity-time { color: var(--text-light); font-size: 0.78rem; }

/* Stakes */
.stakes-section {
  margin-top: 24px;
}

.stakes-section h3 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--denim-deep);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--salmon-pale);
}

.stake-card {
  background: var(--soft-cream);
  border: 1.5px solid var(--gold);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 8px 0;
}

.stake-card .stake-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.stake-card .stake-name {
  font-weight: 600;
  color: var(--denim-deep);
  font-size: 0.9rem;
}

.stake-card .stake-score {
  font-weight: 700;
  color: var(--pine);
  font-size: 0.9rem;
}

.stake-card .stake-text {
  font-size: 0.92rem;
  color: var(--text);
  font-style: italic;
  line-height: 1.5;
}

.stake-card .stake-date {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 6px;
}

.stake-input-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.stake-input-section input[type="text"],
.stake-input-section input[type="number"] {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  margin-bottom: 10px;
  background: var(--warm-white);
}

.stake-input-section input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-pale);
}

.stake-input-section label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--denim);
  display: block;
  margin-bottom: 8px;
}

.stake-input-section textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  margin-bottom: 10px;
  background: var(--warm-white);
  resize: vertical;
}

.stake-input-section textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-pale);
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 24px 0 8px;
}

.app-footer a {
  color: var(--text-light);
  font-size: 0.8rem;
  text-decoration: none;
}

.app-footer a:hover {
  color: var(--pine);
  text-decoration: underline;
}

@media (max-width: 600px) {
  #app { padding: 16px 14px 40px; }
  .card { padding: 24px 20px; }
  header { padding: 24px 0 18px; }
  header h1 { font-size: 1.7rem; }
  .tf-options { flex-direction: column; gap: 8px; }
  .filters { gap: 6px; }
  .filters label { font-size: 0.78rem; padding: 5px 11px; }
  .score-circle { width: 110px; height: 110px; font-size: 2rem; }
}
