:root {
  --bg: #fbf7f0;
  --surface: #ffffff;
  --ink: #2c2a26;
  --muted: #7c756a;
  --line: #ece4d6;
  --brand: #e07a5f;
  --brand-ink: #ffffff;
  --correct: #3a9d6d;
  --correct-bg: #e5f4ec;
  --wrong: #d1495b;
  --wrong-bg: #fbe7ea;
  --shadow: 0 2px 10px rgba(60, 50, 35, 0.08);
  --radius: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1917;
    --surface: #262320;
    --ink: #efe9df;
    --muted: #a89f92;
    --line: #38332d;
    --brand: #e88a70;
    --correct: #4cb583;
    --correct-bg: #1e3a2d;
    --wrong: #e06576;
    --wrong-bg: #3a2126;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

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

a { color: var(--brand); }

/* ---------- Header ---------- */
.site-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
  flex-wrap: wrap;
}
.brand {
  font-weight: 800;
  font-size: 1.15rem;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
}
.hud {
  display: flex;
  gap: 0.4rem 0.9rem;
  flex: 1;
  flex-wrap: wrap;
  justify-content: center;
  color: var(--muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}
.hud-item:empty { display: none; }
.archive-link {
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

/* ---------- Layout ---------- */
#main {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 1rem;
}
.view { animation: fade 0.2s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.centered {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}
.big-emoji { font-size: 3rem; margin: 0 0 0.5rem; }

.spinner {
  width: 40px; height: 40px;
  margin: 0 auto 1rem;
  border: 4px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Nameplate ---------- */
.nameplate {
  text-align: center;
  font-size: 1.35rem;
  margin: 0.5rem 0 1.1rem;
}
.nameplate strong { color: var(--brand); }

/* ---------- Cards ---------- */
.cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  align-items: start;
}
.card-slot { min-width: 0; }

.photo {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 3px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, border-color 0.12s ease;
  aspect-ratio: 4 / 5;
}
.photo:hover:not(:disabled) { transform: translateY(-2px); }
.photo:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.photo:disabled { cursor: default; }
/* A blurred, zoomed copy of the same photo fills the frame so the whole pet can
   be shown (object-fit: contain) without empty letterbox bars around it. */
.photo::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image: var(--photo-bg, none);
  background-size: cover;
  background-position: center;
  filter: blur(22px) brightness(0.82);
  transform: scale(1.2);
}
.photo img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;   /* show the whole pet — never crop the face */
  display: block;
}

.photo.correct { border-color: var(--correct); }
.photo.wrong { border-color: var(--wrong); }

.marker {
  position: absolute;
  z-index: 2;
  top: 8px; left: 8px;
  width: 34px; height: 34px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
  font-size: 1.2rem;
}
.photo.correct .marker { display: flex; background: var(--correct); }
.photo.wrong .marker { display: flex; background: var(--wrong); }

/* ---------- Info (reveal) ---------- */
.info {
  margin-top: 0.6rem;
  padding: 0.75rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 0.9rem;
}
.info.correct { border-color: var(--correct); background: var(--correct-bg); }
.info.wrong { border-color: var(--wrong); background: var(--wrong-bg); }
.info h3 { margin: 0 0 0.15rem; font-size: 1.1rem; }
.info .attrs { color: var(--muted); font-size: 0.82rem; margin: 0 0 0.35rem; }
.info .shelter { font-size: 0.82rem; margin: 0 0 0.4rem; }
.info .desc { margin: 0 0 0.6rem; }
.info .meet {
  display: inline-block;
  font-weight: 700;
  text-decoration: none;
}
.info .meet::after { content: " →"; }

/* ---------- Buttons ---------- */
.actions { text-align: center; margin: 1.25rem 0; }
.btn {
  font: inherit;
  font-weight: 700;
  padding: 0.7rem 1.6rem;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.1s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.btn-primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

/* Share button flash-and-fade feedback (replaces the old toast) */
#shareBtn { transition: opacity 0.25s ease, transform 0.1s ease; }
#shareBtn.is-fading { opacity: 0; }

/* ---------- Results ---------- */
.result-score { text-align: center; font-size: 2.4rem; margin: 1rem 0 0.2rem; }
.result-sub { text-align: center; color: var(--muted); margin: 0 0 1rem; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin: 1rem 0;
  box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 0.75rem; font-size: 1.1rem; }
.chart-wrap { position: relative; height: 220px; }
.muted { color: var(--muted); font-size: 0.9rem; }
.countdown { text-align: center; color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); }

/* ---------- Archive ---------- */
.archive-list { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: 0.5rem; }
.archive-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
  font: inherit;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.archive-row:hover { border-color: var(--brand); }
.archive-num { font-weight: 800; }
.archive-date { color: var(--muted); font-size: 0.85rem; flex: 1; }
.badge {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: var(--line);
  color: var(--ink);
  white-space: nowrap;
}
.badge.done { background: var(--correct-bg); color: var(--correct); }
.badge.progress { background: var(--wrong-bg); color: var(--wrong); }

/* ---------- Footer / a11y ---------- */
.site-footer {
  text-align: center;
  padding: 1.25rem 1rem;
  color: var(--muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--line);
}
.site-footer p { margin: 0.3rem 0; }
.footer-note { opacity: 0.85; }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* Dev-only reset button (MOCK_API mode) */
.dev-reset {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 30;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  border: 1px dashed var(--muted);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  opacity: 0.85;
  box-shadow: var(--shadow);
}
.dev-reset:hover { opacity: 1; border-color: var(--brand); color: var(--brand); }
.dev-reset:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

@media (min-width: 620px) {
  .cards { gap: 1.25rem; }
  .nameplate { font-size: 1.6rem; }
}
