:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1f2433;
  --muted: #6b7280;
  --border: #e3e7ef;
  --accent: #4f6df5;
  --accent-dark: #3a52d1;
  --good: #1fa25a;
  --good-bg: #e6f8ee;
  --bad: #e0433f;
  --bad-bg: #fdeceb;
  --radius: 16px;
  --shadow: 0 6px 20px rgba(30, 40, 80, 0.08);
}

:root[data-theme="gamer"] {
  --accent: #33b679;
  --accent-dark: #229158;
  --bg: #f1f8f4;
}

:root[data-theme="anime"] {
  --accent: #e0559d;
  --accent-dark: #c23f83;
  --bg: #fdf3fa;
}

@media (prefers-color-scheme: dark) {
  :root,
  :root[data-theme="gamer"],
  :root[data-theme="anime"] {
    --bg: #14161f;
    --card: #1d2030;
    --text: #eef0f6;
    --muted: #9aa0b4;
    --border: #2b2f45;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", Roboto, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 60px;
  min-height: 100vh;
}

.screen { display: none; }
.screen.active { display: block; animation: fadein .25s ease; }

@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

h1, h2, h3 { line-height: 1.25; }

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.top-bar .brand {
  font-weight: 700;
  font-size: 1.1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform .1s ease, background .15s ease;
}
.btn:hover { background: var(--accent-dark); }
.btn:active { transform: scale(.97); }
.btn.secondary {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
}
.btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.block { width: 100%; }

.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 24px;
}
@media (max-width: 520px) {
  .profile-grid { grid-template-columns: 1fr; }
}

.profile-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color .15s ease, transform .1s ease;
}
.profile-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.profile-card .emoji { font-size: 2.6rem; display: block; margin-bottom: 8px; }
.profile-card .sub { color: var(--muted); font-size: .9rem; margin-top: 4px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
  margin: 10px 0 20px;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width .25s ease;
}

.q-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: .85rem;
  margin-bottom: 6px;
}

.q-category {
  display: inline-block;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--accent-dark);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.q-text {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0 0 16px;
}

.q-image { margin: 12px 0 18px; text-align: center; }
.q-image svg { max-width: 100%; height: auto; overflow: visible; }

.options { display: flex; flex-direction: column; gap: 10px; }

.option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.option:hover { border-color: var(--accent); }
.option.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--card)); }
/* good-bg/bad-bg sind immer helle Pastelltöne, egal ob Hell- oder Dunkelmodus - Text
   braucht deshalb eine fixe dunkle Farbe statt der theme-abhängigen --text-Variable. */
.option.correct { border-color: var(--good); background: var(--good-bg); color: #2b2f45; }
.option.incorrect { border-color: var(--bad); background: var(--bad-bg); color: #2b2f45; }
.option:disabled { cursor: default; }

.text-answer-row { display: flex; gap: 10px; }
.text-answer-row input,
#login-form input,
#catalog-search {
  flex: 1;
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 2px solid var(--border);
  font-size: 1rem;
  background: var(--card);
  color: var(--text);
}
.text-answer-row input:focus,
#login-form input:focus,
#catalog-search:focus { outline: none; border-color: var(--accent); }
#login-form label { display: block; margin-bottom: 4px; }

.catalog-item { margin-bottom: 14px; }
.catalog-correct { color: var(--good); font-weight: 600; }

.feedback {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  font-size: .95rem;
  line-height: 1.45;
}
/* good-bg/bad-bg sind immer helle Pastelltöne, egal ob Hell- oder Dunkelmodus aktiv ist -
   der Text darin braucht deshalb fix dunkle Farben statt der theme-abhängigen --text-Variable,
   sonst wird er im Dunkelmodus (weißer --text) auf hellem Hintergrund unlesbar. */
.feedback.good { background: var(--good-bg); color: var(--good); }
.feedback.bad { background: var(--bad-bg); color: var(--bad); }
.feedback .explanation { color: #2b2f45; margin-top: 8px; }
.feedback .hint { color: #6b4a00; background: rgba(255, 209, 102, 0.35); border-radius: 8px; padding: 8px 10px; margin-top: 8px; font-size: 0.92rem; }

.win-graphic { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.win-graphic-img { width: 44px; height: 44px; flex-shrink: 0; }
.win-graphic-img svg { width: 100%; height: 100%; }
.win-graphic-caption { font-weight: 700; }
.win-graphic-photo { max-width: 170px; max-height: 120px; border-radius: 10px; object-fit: cover; display: block; box-shadow: var(--shadow); }

.actions-row { display: flex; justify-content: flex-end; margin-top: 18px; gap: 10px; }

.result-score {
  text-align: center;
  padding: 10px 0 4px;
}
.result-score .big {
  font-size: 3rem;
  font-weight: 800;
  color: var(--accent);
}
.result-score .tier-label {
  font-size: 1.2rem;
  font-weight: 700;
  margin-top: 6px;
}
.result-score .minutes {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 18px;
  border-radius: 999px;
  background: var(--good-bg);
  color: var(--good);
  font-weight: 700;
}
.result-score .minutes.zero { background: var(--bad-bg); color: var(--bad); }
.result-score .minutes.unlimited { background: linear-gradient(90deg, #ffd166, #ff9f6b); color: #6b3d00; }

.review-item { border-top: 1px solid var(--border); padding: 14px 0; }
.review-item:first-child { border-top: none; }
.review-item .q { font-weight: 600; margin-bottom: 6px; }
.review-item .your-answer { color: var(--bad); font-size: .9rem; }
.review-item .right-answer { color: var(--good); font-size: .9rem; }
.review-item .explanation { color: var(--muted); font-size: .9rem; margin-top: 6px; }

.bonus-box {
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
  text-align: center;
}
.bonus-box .doodle { margin-bottom: 8px; }

.history-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.history-table th, .history-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.history-table th { color: var(--muted); font-weight: 600; }

.hero { max-width: 420px; margin: 10px auto 6px; }
.hero svg { width: 100%; height: auto; }
.brand-logo { display: inline-flex; width: 1.4em; height: 1.4em; vertical-align: -0.3em; }
.brand-logo svg { width: 100%; height: 100%; }
.brand-title { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 1.5rem; margin-bottom: 4px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.05rem; }

.admin-child-card { margin-bottom: 20px; }
.admin-child-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.admin-child-head .emoji { font-size: 1.6rem; }
.admin-stat-row { display: flex; gap: 16px; flex-wrap: wrap; margin: 10px 0; }
.admin-stat { background: var(--bg); border-radius: 10px; padding: 8px 14px; font-size: .85rem; }
.admin-stat strong { display:block; font-size: 1.2rem; }

.muted { color: var(--muted); }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.small { font-size: .85rem; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
