:root {
  --bg: #FAFAF7;
  --bg-elevated: #FFFFFF;
  --text: #2C2E3F;
  --text-muted: #6E7081;
  --border: #E8E8EE;
  --accent: #6B7FD7;
  --accent-2: #9B7FD7;
  --accent-soft: #EEF0FB;
  --accent-gradient: linear-gradient(135deg, #6B7FD7 0%, #9B7FD7 100%);
  --caution: #E8A63C;
  --caution-bg: #FFF6E0;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 2px 6px rgba(43, 46, 63, 0.04), 0 1px 2px rgba(43, 46, 63, 0.06);
  --shadow-md: 0 6px 16px rgba(107, 127, 215, 0.12), 0 2px 4px rgba(43, 46, 63, 0.05);
  --shadow-lg: 0 12px 32px rgba(107, 127, 215, 0.18);
  --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1A1B2E;
    --bg-elevated: #24253C;
    --text: #E8E8F0;
    --text-muted: #9B9DB2;
    --border: #353752;
    --accent-soft: #2A2C4A;
    --caution-bg: #3A2E1A;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

h1, h2, h3, h4 {
  font-family: 'Manrope', 'Inter', sans-serif;
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
}

p { margin: 0; }
ul { margin: 0; padding-left: 20px; }
ul li { margin-bottom: 6px; }

/* ---------- Top bar ---------- */
.top-bar {
  padding: 16px;
  display: flex;
  justify-content: flex-end;
}

.lang-switcher {
  display: inline-flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  box-shadow: var(--shadow-sm);
}

.lang-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
}

@media (hover: hover) {
  .lang-btn:hover { color: var(--text); }
}
.lang-btn.active {
  background: var(--accent-gradient);
  color: white;
}

/* ---------- Main container ---------- */
.app {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 20px 40px;
}

.screen {
  animation: fadeIn 260ms ease-out;
}

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

.screen-title {
  font-size: 28px;
  margin-bottom: 20px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.section-title {
  font-size: 20px;
  margin: 32px 0 16px;
  color: var(--text);
}

/* ---------- Intro ---------- */
.intro-screen {
  text-align: center;
  padding-top: 20px;
}

.eyebrow {
  font-family: 'Manrope', sans-serif;
  font-style: italic;
  color: var(--accent);
  letter-spacing: 0.02em;
  font-size: 16px;
  margin-bottom: 8px;
}

.hero-title {
  font-size: 38px;
  line-height: 1.1;
  margin-bottom: 10px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  color: var(--text-muted);
  font-size: 16px;
  margin-bottom: 28px;
}

.description-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 28px;
  text-align: left;
  box-shadow: var(--shadow-sm);
  font-size: 15px;
  color: var(--text-muted);
}

.intro-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 4px;
}

@media (min-width: 640px) {
  .intro-cards {
    grid-template-columns: 1fr 1fr;
  }
}

.intro-card {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  padding: 22px 20px;
  text-align: center;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  font-family: inherit;
}

.intro-card-title {
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
}

.intro-card-desc {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.4;
}

.intro-card-primary {
  background: var(--accent-gradient);
  border-color: transparent;
  box-shadow: var(--shadow-md);
}

.intro-card-primary .intro-card-title,
.intro-card-primary .intro-card-desc {
  color: #ffffff;
}

.intro-card-primary .intro-card-desc {
  opacity: 0.9;
}

@media (hover: hover) {
  .intro-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent);
  }
  .intro-card-primary:hover {
    border-color: transparent;
  }
}

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: none;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  padding: 14px 24px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition), color var(--transition);
  min-height: 48px;
  min-width: 120px;
}

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

.btn-primary {
  background: var(--accent-gradient);
  color: #ffffff;
  box-shadow: var(--shadow-md);
}

@media (hover: hover) {
  .btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
  }
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

@media (hover: hover) {
  .btn-secondary:hover:not(:disabled) {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
  }
}

.btn-link {
  background: transparent;
  color: var(--text-muted);
  box-shadow: none;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 10px 14px;
}

@media (hover: hover) {
  .btn-link:hover { color: var(--text); }
}

.btn-large {
  font-size: 17px;
  padding: 16px 32px;
  min-width: 200px;
}

/* ---------- Instructions ---------- */
.instruction-step {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.step-label {
  font-size: 14px;
  color: var(--accent);
  margin-bottom: 8px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.scale-box {
  margin-top: 16px;
  display: grid;
  gap: 8px;
}

.scale-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
}

.scale-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--accent-gradient);
  color: white;
  border-radius: 50%;
  font-weight: 700;
  flex-shrink: 0;
}

.scale-label {
  font-weight: 500;
}

.caution-block {
  background: var(--caution-bg);
  border-left: 4px solid var(--caution);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 16px;
}

.caution-label {
  display: inline-block;
  font-weight: 700;
  color: var(--caution);
  margin-bottom: 6px;
  letter-spacing: 0.05em;
}

/* ---------- Actions row ---------- */
.actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}

.quiz-actions {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
}

@media (min-width: 560px) {
  .actions {
    flex-direction: row;
    justify-content: center;
  }
  .actions .btn-primary { order: 2; }
  .actions .btn-secondary { order: 1; }
}

/* ---------- Quiz ---------- */
.progress {
  position: relative;
  background: var(--border);
  border-radius: 999px;
  height: 8px;
  margin-bottom: 24px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 999px;
  transition: width 400ms ease-out;
}

.progress-text {
  position: absolute;
  top: 14px;
  right: 0;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.question-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px;
  margin-top: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.question-number {
  display: inline-block;
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.question-text {
  font-size: 17px;
  line-height: 1.35;
  font-family: 'Manrope', sans-serif;
  font-weight: 600;
}

.answers {
  display: grid;
  gap: 8px;
}

.answer-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text);
  min-height: 44px;
}

@media (hover: hover) {
  .answer-btn:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
  }
}

.answer-btn.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: var(--shadow-md);
}

.answer-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--border);
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  transition: all var(--transition);
  flex-shrink: 0;
}

@media (hover: hover) {
  .answer-btn:hover .answer-num {
    background: var(--accent-gradient);
    color: white;
  }
}

.answer-btn.selected .answer-num {
  background: var(--accent-gradient);
  color: white;
}

.answer-label { font-weight: 500; }

/* ---------- Results ---------- */
.top-gifts {
  display: grid;
  gap: 14px;
  margin-bottom: 20px;
}

.gift-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.gift-card[open] { box-shadow: var(--shadow-md); }

.gift-card summary {
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  list-style: none;
  font-family: 'Manrope', sans-serif;
}

.gift-card summary::-webkit-details-marker { display: none; }

.gift-card summary::after {
  content: '▾';
  margin-left: auto;
  color: var(--text-muted);
  transition: transform var(--transition);
}

.gift-card[open] summary::after { transform: rotate(180deg); }

.rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--accent-gradient);
  color: white;
  border-radius: 50%;
  font-weight: 700;
  flex-shrink: 0;
}

.gift-name {
  font-size: 18px;
  font-weight: 700;
  flex: 1;
}

.gift-score {
  font-weight: 700;
  color: var(--accent);
  font-size: 16px;
}

.score-bar {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  margin: 14px 0 16px;
  overflow: hidden;
}

.score-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 999px;
  transition: width 400ms ease-out;
}

.gift-card .gift-def {
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 14px;
  padding-left: 12px;
  border-left: 3px solid var(--accent);
}

.gift-card h4 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin: 14px 0 8px;
}

.gift-card ul { font-size: 15px; color: var(--text); }

/* ---------- Full table ---------- */
.results-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  font-size: 15px;
}

.results-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.results-table tr:last-child td { border-bottom: none; }

.rank-cell {
  font-weight: 700;
  color: var(--text-muted);
  width: 32px;
  text-align: center;
}

.score-cell {
  font-weight: 700;
  color: var(--accent);
  text-align: right;
  white-space: nowrap;
  width: 60px;
}

.bar-cell { width: 35%; }

.mini-bar {
  background: var(--border);
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
}

.mini-bar-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 999px;
}

@media (max-width: 520px) {
  .bar-cell { display: none; }
}

/* ---------- Modal ---------- */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-root[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 22, 40, 0.5);
  backdrop-filter: blur(4px);
  animation: fadeIn 180ms ease-out;
}

.modal {
  position: relative;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: modalIn 220ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

.modal-body {
  font-size: 16px;
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@media (min-width: 480px) {
  .modal-actions {
    flex-direction: row;
    justify-content: flex-end;
  }
}

/* ---------- Footer ---------- */
.footer {
  padding: 24px 20px 32px;
  text-align: center;
}

.donate-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 999px;
  transition: color var(--transition), background var(--transition);
}

@media (hover: hover) {
  .donate-link:hover {
    color: var(--accent);
    background: var(--accent-soft);
  }
}

/* ---------- Desktop adjustments ---------- */
@media (min-width: 768px) {
  .app {
    padding: 16px 24px 48px;
  }
  .hero-title { font-size: 44px; }
  .screen-title { font-size: 32px; }
  .question-text { font-size: 22px; }
  .description-card { padding: 28px; }
  .answers {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
}

@media (min-width: 960px) {
  .answers {
    grid-template-columns: repeat(5, 1fr);
  }
  .answer-btn {
    flex-direction: column;
    text-align: center;
    padding: 18px 10px;
  }
}

/* ---------- Auth & Dashboard ---------- */
.auth-screen { padding-top: 24px; }

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--text-muted);
}

.field input {
  appearance: none;
  font-family: inherit;
  font-size: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  color: var(--text);
  min-height: 44px;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-error {
  color: #c62828;
  font-size: 14px;
  margin: 0;
}

.form-success {
  color: #2e7d32;
  font-size: 14px;
  margin: 0;
}

.form-meta {
  font-size: 14px;
  color: var(--text-muted);
  margin: 12px 0;
}

.form-meta a {
  color: var(--accent);
}

.dashboard-screen { padding-top: 12px; }

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.dashboard-actions {
  margin: 16px 0;
}

.church-list {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
}

.church-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}

.church-card header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.church-card h2 {
  font-size: 18px;
  margin: 0;
  font-family: 'Manrope', sans-serif;
}

.church-count {
  font-size: 13px;
  color: var(--text-muted);
}

.church-code {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 6px 10px;
  border-radius: 6px;
  word-break: break-all;
  display: block;
}

.church-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.share-link-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 14px 0 10px;
}

.share-label {
  font-size: 14px;
  color: var(--text-muted);
}

.share-link-row .church-code {
  flex: 1;
  min-width: 200px;
}

.empty-state {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 24px 12px;
}

.modal-title {
  font-size: 18px;
  font-family: 'Manrope', sans-serif;
  margin: 0 0 14px;
}

.stub-screen { text-align: center; padding-top: 40px; }

.member-message {
  text-align: center;
  padding: 60px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 30px);
  background: #2c2f3d;
  color: #ffffff;
  padding: 14px 20px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  font-size: 15px;
  font-weight: 500;
  max-width: min(92vw, 480px);
  text-align: center;
  opacity: 0;
  transition: transform 0.28s ease, opacity 0.28s ease;
  z-index: 9999;
  pointer-events: none;
  line-height: 1.4;
}

.toast-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

.toast-leaving {
  transform: translate(-50%, 30px);
  opacity: 0;
}

.toast-success { background: #2e7d32; }
.toast-error { background: #c62828; }
.toast-info { background: #2c2f3d; }

.member-message .form-success,
.member-message .form-error,
.member-message .subtitle {
  font-size: 16px;
  max-width: 480px;
  margin: 0;
}

