:root {
  color-scheme: light dark;
  --bg: #f5f5f7;
  --card-bg: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --border: #d2d2d7;
  --accent: #0071e3;
  --accent-text: #ffffff;
  --yes: #1a7f37;
  --no: #b3261e;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1e;
    --card-bg: #2c2c2e;
    --text: #f5f5f7;
    --muted: #a1a1a6;
    --border: #48484a;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: 1.5rem;
}

.card {
  width: 100%;
  max-width: 640px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

.hidden {
  display: none !important;
}

.progress {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1rem;
  text-align: center;
}

.stimulus-container {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
  background: repeating-conic-gradient(#00000010 0% 25%, transparent 0% 50%) 50% / 16px 16px;
  border-radius: 10px;
  padding: 1rem;
}

#stimulus-image {
  max-width: 100%;
  max-height: 360px;
  border-radius: 6px;
  image-rendering: -webkit-optimize-contrast;
}

.prompt {
  font-size: 1.15rem;
  font-weight: 500;
  text-align: center;
  margin-bottom: 1.75rem;
  line-height: 1.4;
}

.section-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.answer-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}

.answer-button {
  flex: 1;
  padding: 0.9rem;
  font-size: 1.05rem;
  font-weight: 600;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: all 0.12s ease;
}

.answer-button[data-answer="yes"].selected {
  background: var(--yes);
  border-color: var(--yes);
  color: #fff;
}

.answer-button[data-answer="no"].selected {
  background: var(--no);
  border-color: var(--no);
  color: #fff;
}

.answer-button:hover {
  border-color: var(--accent);
}

.confidence-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.confidence-button {
  flex: 1;
  padding: 0.6rem 0.25rem;
  font-size: 0.75rem;
  text-align: center;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: all 0.12s ease;
}

.confidence-button.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.confidence-button:hover {
  border-color: var(--accent);
}

#submit-button {
  width: 100%;
  padding: 0.9rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
}

#submit-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.center-text {
  text-align: center;
}

.completion-code {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 1.4rem;
  font-weight: 700;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  letter-spacing: 0.05em;
}

.error-box {
  color: var(--no);
}

#retry-button {
  margin-top: 1rem;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

/* ---- CropGround study additions: consent, instructions, practice feedback, progress ---- */
h1 {
  font-size: 1.35rem;
  margin: 0 0 1rem;
}

.card p, .card li {
  line-height: 1.5;
}

.card ul {
  padding-left: 1.2rem;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

kbd {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 0.3rem;
}

.consent-text {
  max-height: 45vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 1rem;
  margin-bottom: 1rem;
}

.consent-check {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  margin-bottom: 1.25rem;
  cursor: pointer;
}

#consent-button, #instructions-button, #main-start-button, .button-link {
  display: inline-block;
  width: 100%;
  padding: 0.9rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}

#consent-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.badge {
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  font-size: 0.75rem;
}

.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-bottom: 1rem;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.2s ease;
}

/* fixed display box: small crops are scaled up, large ones down, so every picture appears the same size */
#stimulus-image {
  width: min(384px, 100%);
  height: auto;
  max-height: none;
  aspect-ratio: 1 / 1;
  object-fit: contain;
}

.feedback {
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.feedback.good {
  background: color-mix(in srgb, var(--yes) 15%, transparent);
  border: 1px solid var(--yes);
}

.feedback.bad {
  background: color-mix(in srgb, var(--no) 15%, transparent);
  border: 1px solid var(--no);
}

@media (max-width: 480px) {
  body { padding: 0.75rem; align-items: flex-start; }
  .card { padding: 1.25rem; }
  .confidence-row { flex-wrap: wrap; }
  .confidence-button { flex: 1 1 30%; }
}
