:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --text: #1f1d1a;
  --muted: #6f6a62;
  --line: #e2ddd5;
  --accent: #2f5d8a;
  --accent-text: #ffffff;
  --ok: #2e7d4f;
  --ok-bg: #e5f3ea;
  --bad: #b23a2e;
  --bad-bg: #f8e6e3;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614;
    --surface: #23211e;
    --text: #eeebe5;
    --muted: #a29c92;
    --line: #38352f;
    --accent: #7fb0e0;
    --accent-text: #10202f;
    --ok: #7dcc9a;
    --ok-bg: #1e3326;
    --bad: #f08f84;
    --bad-bg: #3a201d;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  max-width: 560px; margin: 0 auto; padding: 16px;
}
.topbar h1 { font-size: 1.25rem; margin: 0; }
nav { display: flex; gap: 4px; }
.link { background: none; border: 0; color: var(--accent); padding: 6px 8px; cursor: pointer; font: inherit; border-radius: 8px; }
.link:hover { background: var(--surface); }

main { max-width: 560px; margin: 0 auto; padding: 0 16px 32px; display: grid; gap: 16px; }

.settings { display: grid; gap: 12px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 8px 4px; border-radius: 9px; cursor: pointer; font-size: .9rem; }
.seg input:checked + span { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.field { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .9rem; }
.check { display: flex; align-items: center; gap: 6px; font-size: .9rem; cursor: pointer; }
select { font: inherit; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; text-align: center; }
.prompt-label { color: var(--muted); font-size: .9rem; }
.prompt { font-size: clamp(2.5rem, 12vw, 4rem); font-weight: 700; line-height: 1.2; margin: 8px 0 16px; word-break: break-word; }
.picture {
  position: relative; margin: 0 auto 16px; width: 240px; max-width: 100%; aspect-ratio: 1;
  border-radius: var(--radius); overflow: hidden; background: var(--bg);
}
/* Unscharfer Hintergrund fuellt die Flaeche, das Bild selbst wird vollstaendig gezeigt */
.picture::before {
  content: ""; position: absolute; inset: -20px;
  background: var(--pic) center / cover; filter: blur(16px) saturate(1.2); opacity: .55;
}
.picture img { position: relative; width: 100%; height: 100%; object-fit: contain; display: block; }

#answer {
  width: 100%; font: inherit; font-size: 1.5rem; font-weight: 600; text-align: center;
  padding: 10px 12px; border: 2px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text);
}
#answer:focus { outline: none; border-color: var(--accent); }
#answer.shake { animation: shake .3s; border-color: var(--bad); }
#answer.right { border-color: var(--ok); }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.buttons { display: flex; gap: 8px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
button { font: inherit; }
.buttons button, dialog form button {
  padding: 10px 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; min-width: 110px;
}
.buttons button.primary, dialog button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button:disabled { opacity: .5; cursor: default; }

.feedback { min-height: 1.5em; margin-top: 12px; font-weight: 600; }
.feedback.ok { color: var(--ok); }
.feedback.bad { color: var(--bad); }
.feedback.info { color: var(--muted); font-weight: 400; }

.score { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.score div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 4px; }
.score b { display: block; font-size: 1.4rem; }
.score span { font-size: .75rem; color: var(--muted); }
@media (max-width: 420px) {
  .score { grid-template-columns: repeat(2, 1fr); }
  .seg span { font-size: .8rem; padding: 8px 2px; }
  .card { padding: 20px 16px; }
}
.score .ok b { color: var(--ok); }
.score .bad b { color: var(--bad); }
.score .muted b { color: var(--muted); }

dialog {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text);
  width: min(480px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 20px;
}
dialog.wide { width: min(820px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog h2 { margin-top: 0; }
dialog > form { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.code { width: 100%; border-collapse: collapse; }
.code td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
.code td:first-child { font-size: 1.4rem; font-weight: 700; width: 3rem; text-align: center; }
.code td:last-child { color: var(--muted); font-size: .9rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.grid figure { margin: 0; text-align: center; background: var(--bg); border-radius: 10px; padding: 6px; }
.grid img { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 6px; display: block; background: var(--surface); }
.grid figcaption { font-size: .85rem; margin-top: 4px; }
.grid figcaption b { margin-right: 4px; }

.credits { margin-top: 16px; font-size: .8rem; color: var(--muted); }
.credits summary { cursor: pointer; }
.credits ul { padding-left: 1.2em; }
.credits a { color: var(--accent); word-break: break-word; }

.weak { padding-left: 1.4em; }
.weak li { padding: 2px 0; }
.weak .rate { color: var(--muted); font-size: .85rem; }
