:root {
  --bg: #14161a;
  --panel: #1d2026;
  --line: #2c3038;
  --text: #eef0f3;
  --muted: #9aa1ad;
  --plainA: #2a2d33;
  --plainB: #33373e;
  --blue: #3b82f6;
  --yellow: #f5b301;
  --pink: #ec4899;
  --purple: #8b5cf6;
  --red: #ef4444;
  --good: #22c55e;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f5f7; --panel: #ffffff; --line: #d9dce1; --text: #15171b; --muted: #5b6270;
  --plainA: #e6e8ec; --plainB: #d4d7dd; color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f5f7; --panel: #ffffff; --line: #d9dce1; --text: #15171b; --muted: #5b6270;
    --plainA: #e6e8ec; --plainB: #d4d7dd; color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 560px; margin: 0 auto; padding: 16px 16px 40px; }
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1 { font-size: 1.25rem; margin: 4px 0 12px; }

button {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 14px; cursor: pointer; min-height: 44px;
}
button.ghost { background: transparent; }
button.wide { width: 100%; margin-top: 12px; }
button[aria-pressed="true"] { outline: 2px solid var(--text); outline-offset: 1px; }
input {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; min-height: 44px; flex: 1; min-width: 0;
}
.row { display: flex; gap: 8px; align-items: center; }
.row.center { justify-content: center; }
#settings { margin-bottom: 16px; }
#settings label { display: block; color: var(--muted); font-size: .9rem; margin-bottom: 6px; }

.camera {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  background: var(--blue); color: #fff; font-weight: 600; font-size: 1.15rem;
  border-radius: 16px; min-height: 72px; cursor: pointer; user-select: none;
}
.camera:active { transform: scale(.99); }
.camera.busy { opacity: .6; pointer-events: none; }

.status { min-height: 1.5em; margin: 10px 2px; color: var(--muted); font-size: .95rem; }
.status.error { color: var(--red); }

.answer {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px 16px; text-align: center; margin-bottom: 14px;
}
.answer-label { color: var(--muted); font-size: .9rem; }
.answer-num { font-size: 4rem; font-weight: 700; line-height: 1.1; color: var(--good); }
.answer-num.bad { color: var(--red); font-size: 2rem; padding: 10px 0; }
.warnings { list-style: none; padding: 0; margin: 6px 0 0; color: var(--yellow); font-size: .9rem; text-align: left; }
.warnings li + li { margin-top: 4px; }

.board-wrap svg { width: 100%; height: auto; display: block; touch-action: manipulation; }
.board-wrap svg path, .board-wrap svg circle.hit { cursor: pointer; }
.hint { color: var(--muted); font-size: .85rem; text-align: center; margin: 6px 0 10px; }
#preview { width: 100%; border-radius: 12px; margin-top: 12px; }

details { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-top: 16px; }
summary { cursor: pointer; font-weight: 600; }
#steps { padding-left: 1.4em; margin: 8px 0 0; font-variant-numeric: tabular-nums; font-size: .92rem; }
#steps li { margin: 3px 0; white-space: pre-wrap; }
footer { color: var(--muted); font-size: .75rem; margin-top: 24px; text-align: center; }

.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet[hidden] { display: none; }
.sheet-inner {
  background: var(--panel); width: 100%; max-width: 560px; border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}
.sheet-title { font-weight: 600; margin-bottom: 12px; }
.sheet-label { color: var(--muted); font-size: .85rem; margin: 10px 0 6px; }
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.choices button { display: flex; align-items: center; gap: 8px; justify-content: center; }
.swatch { width: 16px; height: 16px; border-radius: 4px; flex: none; border: 1px solid var(--line); }
