/* Yearbook Quiz — shared styles */

:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --ink: #26221c;
  --muted: #6f675c;
  --line: #e5ddd0;
  --accent: #8a5a2b;
  --accent-ink: #ffffff;
  --good: #2e7d43;
  --good-bg: #e6f4ea;
  --bad: #b3403a;
  --bad-bg: #fbeae9;
  --select: #2b5f8a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17140f;
    --card: #221e17;
    --ink: #ece5da;
    --muted: #a1968a;
    --line: #3a332a;
    --accent: #c9954f;
    --accent-ink: #1c1811;
    --good: #7fc98f;
    --good-bg: #1e3325;
    --bad: #e08a85;
    --bad-bg: #3a2321;
    --select: #7ab3dd;
  }
}

* { box-sizing: border-box; }
html { color-scheme: light dark; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}
.page.wide { max-width: 960px; }

h1 { font-size: 1.7rem; margin: 0.5em 0 0.3em; }
h2 { font-size: 1.2rem; margin: 1.2em 0 0.4em; }
p { margin: 0.5em 0; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

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

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin: 12px 0;
}

button {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  padding: 10px 16px;
  cursor: pointer;
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}
button:disabled { opacity: 0.45; cursor: default; }
button.danger { color: var(--bad); }

input[type="text"], input[type="password"] {
  font: inherit;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
}
input:focus, button:focus-visible { outline: 2px solid var(--select); outline-offset: 1px; }
label { display: block; font-size: 0.9rem; margin: 10px 0 4px; color: var(--muted); }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.center { text-align: center; }

.notice { border-left: 4px solid var(--accent); padding: 8px 12px; background: var(--card); border-radius: 0 10px 10px 0; }
.error-text { color: var(--bad); white-space: pre-wrap; }

/* ---- play: stage 1 face card ---- */
.face-card { text-align: center; }
.face-card img {
  width: min(320px, 70vw);
  max-height: 45vh;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
}
.feedback { min-height: 1.6em; font-weight: 600; }
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }

/* ---- play: stage 2 matching board ---- */
.match-faces { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.match-face {
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  padding: 6px;
  cursor: pointer;
  text-align: center;
}
.match-face img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 6px; display: block; }
.match-face .assigned { font-size: 0.8rem; min-height: 1.3em; overflow-wrap: anywhere; }
.match-face.selected { border-color: var(--select); }
.match-face.right { border-color: var(--good); background: var(--good-bg); }
.match-face.wrong { border-color: var(--bad); background: var(--bad-bg); }

.name-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.name-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.9rem;
}
.name-chip.used { opacity: 0.35; }
.name-chip.selected { border-color: var(--select); outline: 2px solid var(--select); }

/* ---- results / leaderboard ---- */
.big-score { font-size: 2.4rem; font-weight: 700; margin: 0.2em 0; }
table.board { width: 100%; border-collapse: collapse; }
table.board th, table.board td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.board tr.me { background: var(--good-bg); }
.reveal-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.reveal-list figure { margin: 0; text-align: center; }
.reveal-list img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.reveal-list figcaption { font-size: 0.8rem; }

/* ---- create: review screen ---- */
.page-image-wrap { position: relative; user-select: none; touch-action: none; }
.page-image-wrap img { width: 100%; display: block; border-radius: 8px; }
.det-box {
  position: absolute;
  border: 2px solid var(--select);
  background: rgba(43, 95, 138, 0.12);
  cursor: move;
}
.det-box.selected { border-color: var(--accent); background: rgba(201, 149, 79, 0.18); z-index: 2; }
.det-box .handle {
  position: absolute;
  right: -7px; bottom: -7px;
  width: 14px; height: 14px;
  background: var(--select);
  border-radius: 50%;
  cursor: nwse-resize;
}
.det-box.selected .handle { background: var(--accent); }
.roster { display: flex; flex-direction: column; gap: 8px; }
.roster-row { display: flex; gap: 10px; align-items: center; }
.roster-row.selected { outline: 2px solid var(--accent); border-radius: 10px; }
.roster-row img { width: 44px; height: 56px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.steps { padding-left: 1.2em; }
.steps li { margin: 6px 0; }
