:root {
  --bg: #f4f5fb;
  --card: #ffffff;
  --text: #1c1d33;
  --muted: #6b6e8a;
  --line: #e1e3f0;
  --accent: #4f46e5;
  --accent-text: #ffffff;
  --good: #16a34a;
  --good-bg: #dcfce7;
  --bad: #dc2626;
  --bad-bg: #fee2e2;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12131f;
    --card: #1c1e30;
    --text: #eceefb;
    --muted: #9a9dba;
    --line: #2d3048;
    --accent: #7c75ff;
    --accent-text: #0e0f1a;
    --good: #4ade80;
    --good-bg: #123a22;
    --bad: #f87171;
    --bad-bg: #4a1818;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
#app { max-width: 720px; margin: 0 auto; padding: 16px; }
h1, h2 { margin: 0 0 12px; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.hidden { display: none !important; }

header.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}
header.top a.brand { font-weight: 700; font-size: 1.25rem; text-decoration: none; color: var(--text); }
header.top .who { display: flex; align-items: center; gap: 10px; font-size: .9rem; color: var(--muted); }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.grow > * { flex: 1 1 140px; }
.spread { justify-content: space-between; }
.toolbar { margin-bottom: 12px; }
.stack > * + * { margin-top: 12px; }

button, .btn {
  font: inherit; cursor: pointer; border: 1px solid var(--line);
  background: var(--card); color: var(--text);
  border-radius: 10px; padding: 10px 14px; min-height: 44px;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button:disabled { opacity: .5; cursor: default; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.danger { color: var(--bad); }
button.icon { padding: 8px 10px; min-width: 44px; }
button.link { border: 0; background: none; color: var(--accent); padding: 4px 6px; min-height: 0; }

input[type=text], select {
  font: inherit; width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text);
}
input:focus, select:focus, button:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }
label.field { display: block; font-size: .85rem; color: var(--muted); }
label.field > :last-child { margin-top: 4px; }

.error { background: var(--bad-bg); color: var(--bad); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }

/* login */
.login { text-align: center; padding: 48px 8px; }
.login .big-emoji { font-size: 4rem; }

/* list cards */
.list-card { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.list-card .name { font-weight: 600; font-size: 1.1rem; word-break: break-word; }
.badge {
  display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 99px;
  background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent);
  margin-right: 6px; font-weight: 600;
}

/* items */
.item-row { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.item-row:first-child { border-top: 0; }
.item-row .texts { flex: 1; min-width: 0; word-break: break-word; }
.item-row .texts .sub { color: var(--muted); font-size: .9rem; }
.thumb { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: var(--line); flex: none; }
.preview { max-width: 100%; max-height: 180px; border-radius: 10px; display: block; }

/* practice */
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-bottom: 16px; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .25s; }
.prompt {
  text-align: center; padding: 28px 16px; min-height: 160px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
}
.prompt .big { font-size: 2rem; font-weight: 700; word-break: break-word; }
.prompt .hint { color: var(--muted); font-size: .9rem; }
.photo { max-width: 100%; max-height: 40vh; border-radius: 12px; object-fit: contain; }
.tap-card { cursor: pointer; user-select: none; -webkit-user-select: none; }
.answer-reveal { border-top: 2px dashed var(--line); margin-top: 12px; padding-top: 16px; width: 100%; }

.options { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 520px) { .options { grid-template-columns: 1fr 1fr; } }
.option {
  min-height: 64px; font-size: 1.15rem; padding: 12px; text-align: center;
  white-space: normal; word-break: break-word;
}
.option.has-img { padding: 6px; }
.option .photo { max-height: 140px; }
.option.wrong { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); animation: shake .3s; }
.option.right { background: var(--good-bg); border-color: var(--good); color: var(--good); font-weight: 700; }
.option:disabled.dim { opacity: .6; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.feedback { text-align: center; font-weight: 700; padding: 10px; border-radius: 10px; margin: 12px 0; }
.feedback.good { background: var(--good-bg); color: var(--good); }
.feedback.bad { background: var(--bad-bg); color: var(--bad); }

.choice { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; cursor: pointer; }
.choice input { margin-top: 4px; width: 20px; height: 20px; flex: none; }
.choice .desc { color: var(--muted); font-size: .9rem; }

.summary { text-align: center; padding: 24px 8px; }
.summary .score { font-size: 3rem; font-weight: 800; color: var(--accent); }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }
