:root {
  --bg: #fbf8f3;
  --surface: #ffffff;
  --text: #1f1d1a;
  --muted: #6b665e;
  --border: #e4ded4;
  --accent: #3a5bd9;
  --real: #1f8a4c;
  --fake: #c2410c;
  --good-bg: #e6f4ea;
  --bad-bg: #fdecea;
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513;
    --surface: #211f1c;
    --text: #f1ede6;
    --muted: #a39d93;
    --border: #3a3631;
    --accent: #8ea4ff;
    --real: #4cc37f;
    --fake: #f28b54;
    --good-bg: #173222;
    --bad-bg: #3a1d17;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px;
}

header { text-align: center; margin-bottom: 24px; }
h1 { margin: 0; font-size: clamp(28px, 7vw, 40px); letter-spacing: -0.02em; }
h1 a { color: inherit; text-decoration: none; }
h1 a:hover { text-decoration: underline; }
h2 { font-size: 18px; margin: 0 0 12px; }
.tagline { margin: 4px 0 0; color: var(--muted); }

button {
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 12px 18px;
}
button:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.error { background: var(--bad-bg); padding: 10px 14px; border-radius: var(--radius); }

.eco-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.eco-card { text-align: left; display: flex; flex-direction: column; gap: 4px; min-height: 96px; }
.eco-card:hover { border-color: var(--accent); }
.eco-label { font-weight: 700; font-size: 18px; }
.eco-teaser { color: var(--muted); font-size: 14px; }

#loading { text-align: center; padding: 48px 0; color: var(--muted); }
.spinner {
  width: 36px; height: 36px; margin: 0 auto 12px;
  border: 4px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.play-top { display: flex; justify-content: space-between; align-items: center; }
.badge { font-weight: 700; font-size: 14px; padding: 4px 10px; border-radius: 999px; background: var(--accent); color: #fff; }
.badge[data-eco="cran"] { background: #2166ac; }
.badge[data-eco="bioc"] { background: #1a9850; }
.badge[data-eco="pypi"] { background: #3775a9; }
.badge[data-eco="npm"] { background: #cb3837; }
.badge[data-eco="crates"] { background: #b7410e; }
.badge[data-eco="rubygems"] { background: #9b111e; }
.counter { color: var(--muted); font-variant-numeric: tabular-nums; }

.pkg-name {
  font-family: var(--mono);
  font-size: clamp(24px, 7vw, 40px);
  text-align: center;
  margin: 40px 0;
  overflow-wrap: anywhere;
}

.answer-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.answer { font-size: 20px; font-weight: 700; padding: 18px; color: #fff; border: none; }
.answer.real { background: var(--real); }
.answer.fake { background: var(--fake); }
.answer:disabled { opacity: 0.45; cursor: default; }
kbd { font-family: var(--mono); font-size: 12px; opacity: 0.8; border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; margin-left: 6px; }
@media (hover: none) { kbd { display: none; } }

.reveal { margin-top: 20px; padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.reveal.good { background: var(--good-bg); }
.reveal.bad { background: var(--bad-bg); }
.verdict { font-weight: 700; font-size: 20px; margin: 0 0 4px; }
.detail { margin: 0 0 8px; }
.detail-link { display: inline-block; margin-bottom: 12px; color: var(--accent); }
.detail-link[hidden] { display: none; }
.next { display: block; width: 100%; font-weight: 700; }

.final-score { text-align: center; font-size: 72px; font-weight: 800; margin: 8px 0 0; font-variant-numeric: tabular-nums; }
.out-of { font-size: 32px; color: var(--muted); }
.saying { text-align: center; font-size: 20px; margin: 8px 0 24px; }
.summary { padding-left: 24px; }
.summary li { margin-bottom: 8px; }
.summary .name { font-family: var(--mono); overflow-wrap: anywhere; }
.summary .mark { font-weight: 700; margin-right: 6px; }
.summary .right { color: var(--real); }
.summary .wrong { color: var(--fake); }
.summary .meta { color: var(--muted); font-size: 14px; }
.result-buttons { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 24px; }
#btn-again { background: var(--accent); color: #fff; border: none; font-weight: 700; }
.shared-note { text-align: center; color: var(--muted); margin: 0 0 8px; }
.share-status { text-align: center; color: var(--muted); font-size: 14px; min-height: 1.4em; margin: 8px 0 0; }
.share-url:not([hidden]) { display: block; width: 100%; box-sizing: border-box; font-family: var(--mono); font-size: 13px; padding: 8px; }

/* 39px + main's 24px bottom padding matches the tagline-to-cards gap on the picker. */
footer { text-align: center; color: var(--muted); font-size: 13px; padding: 39px 16px 16px; }
footer a { color: inherit; }
