:root {
  --hintergrund: #f6f1ea;
  --karte: #fffdf9;
  --text: #2b1d2a;
  --leise: #7a6a74;
  --zwetschge: #5b2a5e;
  --zwetschge-hell: #8a4c8d;
  --blatt: #4f7a3a;
  --gold: #b07a12;
  --rand: #e6dccf;
  --fehler: #a83232;
  --ok-hg: #e3efda;
  --ok-text: #2f4d22;
  --fehler-hg: #f6dede;
  --knopf-text: #fff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --hintergrund: #1c1420;
    --karte: #271d2c;
    --text: #f1e8ef;
    --leise: #b3a2b0;
    --zwetschge: #b77bbb;
    --zwetschge-hell: #d3a1d6;
    --blatt: #8dbb74;
    --gold: #e0b44a;
    --rand: #3c2f42;
    --fehler: #e07a7a;
    --ok-hg: #24361c;
    --ok-text: #cfe8c0;
    --fehler-hg: #3d1f22;
    --knopf-text: #1c1420;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--hintergrund);
  color: var(--text);
}
body.mit-nav { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
a { color: var(--zwetschge); }
main { max-width: 720px; margin: 0 auto; padding: 12px 16px; }

/* Kopf */
.kopf {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 16px; background: #5b2a5e; color: #fff;
}
.kopf a { color: #fff; text-decoration: none; }
.logo { font-weight: 800; font-size: 1.15rem; }
.kopf-info { display: flex; gap: 12px; font-weight: 700; font-size: .95rem; font-variant-numeric: tabular-nums; }
.xpleiste { height: 4px; background: var(--rand); }
.xpleiste div { height: 100%; background: var(--gold); }

/* Untere Navigation (Handy) */
nav.unten {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; background: var(--karte); border-top: 1px solid var(--rand);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.unten a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 2px 10px; text-decoration: none; color: var(--leise); font-size: .72rem;
}
nav.unten a span { font-size: 1.35rem; line-height: 1; position: relative; }
nav.unten a.aktiv { color: var(--zwetschge); font-weight: 700; }
.badge {
  position: absolute; top: -4px; right: -12px; min-width: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--fehler); color: #fff; font-size: .7rem; line-height: 18px; text-align: center;
}

/* Karten */
.karte {
  background: var(--karte); border: 1px solid var(--rand); border-radius: 14px;
  padding: 16px; margin-bottom: 14px;
}
.karte.schmal { max-width: 420px; margin: 32px auto; }
h1 { font-size: 1.4rem; margin: 0 0 8px; }
h2 { font-size: 1.1rem; margin: 0 0 10px; }
p { margin: 0 0 10px; }
.leise { color: var(--leise); font-size: .9rem; }
.mitte { text-align: center; }

.status { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 6px; }
.status div {
  background: var(--karte); border: 1px solid var(--rand); border-radius: 12px;
  padding: 10px 4px; text-align: center; font-size: .78rem; color: var(--leise);
}
.status span { display: block; font-size: 1.15rem; font-weight: 700; color: var(--zwetschge); font-variant-numeric: tabular-nums; }
.rang { margin: 4px 0 14px; color: var(--leise); }
.rang strong { color: var(--text); }

.banner { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; font-weight: 600; }
.banner.kirchweih { background: #fbe7b5; color: #5a3d00; }
.banner.graben { background: var(--fehler-hg); color: var(--fehler); }

.zeile { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.uhr { font-weight: 800; color: var(--blatt); font-variant-numeric: tabular-nums; }
.gross .uhr, p.gross { font-size: 2rem; }

/* Formulare */
form { margin: 0; }
form.inline { display: inline-block; }
label { display: block; margin-bottom: 12px; font-size: .92rem; }
input, select {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit;
  border: 1px solid var(--rand); border-radius: 10px; background: var(--hintergrund); color: var(--text);
}
button {
  font: inherit; font-weight: 600; padding: 10px 14px; border: 0; border-radius: 10px;
  background: var(--zwetschge); color: var(--knopf-text); cursor: pointer; min-height: 44px;
}
button:hover:not(:disabled) { background: var(--zwetschge-hell); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.zweit { background: transparent; color: var(--zwetschge); border: 1px solid var(--zwetschge); }
button.klein { padding: 4px 10px; font-size: .85rem; min-height: 32px; }
button.voll, form.inline:has(button.voll) { width: 100%; margin-top: 10px; }

.knopfreihe { display: flex; flex-wrap: wrap; gap: 8px; }
.reihe { display: flex; gap: 8px; margin-top: 8px; }
.reihe input, .reihe select { width: 90px; margin: 0; flex: none; }
.reihe select { width: auto; }
.reihe input[name="name"] { flex: 1; width: auto; }
.reihe button { flex: 1; }
.stapel { display: grid; gap: 8px; }
.stapel select, .stapel input { margin: 0; }

.ausruestung, .posten {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 0; border-top: 1px solid var(--rand);
}
.karte > .ausruestung:first-of-type { border-top: 0; }
.ausruestung > div, .posten > div { min-width: 0; }
.ausruestung form, .posten form { flex: none; }
.posten form.reihe { margin: 0; }
.posten input { width: 64px; }

.reife { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 700; background: var(--rand); color: var(--text); }
.reife-gereift { background: #e3efda; color: #2f4d22; }
.reife-alt { background: #f6e3b8; color: #6b4a00; }
.reife-uralt { background: #5b2a5e; color: #fff; }

.meldung { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; background: var(--ok-hg); color: var(--ok-text); }
.meldung.fehler { background: var(--fehler-hg); color: var(--fehler); }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--rand); word-break: break-word; vertical-align: top; }
tr.ich td { font-weight: 700; color: var(--zwetschge); }
.online { color: var(--blatt); }
code { font-size: 1rem; font-weight: 700; letter-spacing: 1px; }

.liste { padding: 4px 0; }
.liste a { display: flex; gap: 12px; align-items: center; padding: 14px 16px; text-decoration: none; color: var(--text); border-top: 1px solid var(--rand); font-weight: 600; }
.liste a:first-child { border-top: 0; }
.liste a span { font-size: 1.3rem; }

.nachricht { padding: 10px 0; border-top: 1px solid var(--rand); }
.nachricht p { margin: 2px 0 0; }
.nachricht.neu p { font-weight: 700; }

details.weg { margin-top: 14px; border-top: 1px solid var(--rand); padding-top: 10px; }
details.weg summary { cursor: pointer; color: var(--zwetschge); font-weight: 600; margin-bottom: 8px; }

footer { text-align: center; padding: 24px 16px; color: var(--leise); font-size: .85rem; }

/* ---------- Version 3 ---------- */
.kopf-info { text-decoration: none; }
.banner { display: block; text-decoration: none; }
.banner.event { background: #e3eef7; color: #1f4e8c; }
@media (prefers-color-scheme: dark) {
  .banner.event { background: #1d2c3d; color: #b7d3f0; }
  .banner.kirchweih { background: #4a3a12; color: #fbe7b5; }
}
.abstand { margin-top: 12px; }
.gruss { margin: 4px 0 12px; }

/* Ortsbilder */
.karte.ort { padding: 0; overflow: hidden; }
.ortbild { display: block; width: 100%; height: auto; }
.ort-text { padding: 12px 16px 14px; }
.ort-text h1 { margin: 0 0 4px; }
.ort-text p { margin: 0; }

/* Dorfkarte */
.karte-dorf { padding: 0; overflow: hidden; }
.dorfkarte { display: block; width: 100%; height: auto; }
.kartenort { cursor: pointer; }
.kartenort:hover g, .kartenort:focus g { filter: brightness(1.08) drop-shadow(0 0 3px #fff); }
.kartentext { font: 700 13px system-ui, sans-serif; fill: #2b1d2a; paint-order: stroke; stroke: #ffffffcc; stroke-width: 4px; }
.kartensub { font: 600 10.5px system-ui, sans-serif; fill: #5b2a5e; paint-order: stroke; stroke: #ffffffcc; stroke-width: 3px; }

/* Link, der wie ein Knopf aussieht */
a.knopf {
  display: inline-block; font-weight: 600; padding: 10px 16px; border-radius: 10px; text-decoration: none;
  background: var(--zwetschge); color: var(--knopf-text); min-height: 44px; line-height: 24px;
}
a.knopf.zweit { background: transparent; color: var(--zwetschge); border: 1px solid var(--zwetschge); }
button.mini { padding: 0 8px; min-height: 24px; font-size: .8rem; border: 0; }

.tutorial { border: 2px solid var(--gold); }
.tutorial .inline { margin-left: 0; }
.auftrag .balken, .balken { height: 8px; border-radius: 4px; background: var(--rand); overflow: hidden; margin: 6px 0 4px; }
.balken div { height: 100%; background: var(--blatt); }
.stufe { display: inline-block; font-size: .75rem; font-weight: 700; padding: 0 7px; border-radius: 999px; background: var(--rand); color: var(--text); vertical-align: middle; }
.knopfreihe .inline { display: inline-block; }

/* Pinnwand */
.post-form { margin-bottom: 10px; }
.post-form input[name="text"], .reihe input[name="name"] { flex: 1; width: auto; min-width: 0; }
.reihe { min-width: 0; }
.reihe button { flex: none; }
.posten .reihe button, .karte > .reihe button { flex: 1; }
.post { padding: 8px 0; border-top: 1px solid var(--rand); }
.post p { margin: 2px 0 0; word-break: break-word; }
.post-kopf { display: flex; align-items: center; gap: 8px; }
.post-kopf .inline { margin-left: auto; }
.spielerlink { font-weight: 700; text-decoration: none; }

/* Profil */
.profilkopf { display: flex; gap: 14px; align-items: center; }
.wappen-gross { font-size: 3.2rem; line-height: 1; flex: none; width: 72px; height: 72px; display: grid; place-items: center; background: var(--hintergrund); border-radius: 16px; }
.profilkopf h1 { margin: 0; }
.profilkopf p { margin: 2px 0; }
.spruch { font-style: italic; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats div { text-align: center; font-size: .78rem; color: var(--leise); background: var(--hintergrund); border-radius: 10px; padding: 8px 4px; }
.stats span { display: block; font-size: 1.15rem; font-weight: 700; color: var(--zwetschge); }
.pokal { margin: 4px 0; font-weight: 600; }
.abzeichen { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.abzeichen div { text-align: center; padding: 8px 4px; border-radius: 10px; background: var(--hintergrund); display: flex; flex-direction: column; gap: 2px; }
.abzeichen span { font-size: 1.6rem; }
.abzeichen strong { font-size: .78rem; }
.abzeichen small { font-size: .68rem; color: var(--leise); }
.abzeichen .fehlt { opacity: .45; }
.wappenwahl { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.wappenwahl label { margin: 0; }
.wappenwahl input { position: absolute; opacity: 0; width: 0; height: 0; }
.wappenwahl span { display: grid; place-items: center; font-size: 1.4rem; aspect-ratio: 1; border-radius: 10px; border: 2px solid var(--rand); cursor: pointer; }
.wappenwahl input:checked + span { border-color: var(--zwetschge); background: var(--hintergrund); }
.wappenwahl input:focus-visible + span { outline: 2px solid var(--gold); }

/* Tabs */
.tabs { display: flex; gap: 6px; margin: 6px 0 10px; }
.tabs a { padding: 6px 12px; border-radius: 999px; text-decoration: none; border: 1px solid var(--rand); color: var(--text); font-size: .9rem; }
.tabs a.aktiv { background: var(--zwetschge); border-color: var(--zwetschge); color: var(--knopf-text); }

@media (max-width: 400px) {
  .wappenwahl { grid-template-columns: repeat(6, 1fr); }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
.post-form button, .post-form.reihe button { flex: none; }
.testknopf { margin: -4px 0 12px; text-align: right; }
