:root {
  --bg: #f4f2ee; --panel: #ffffff; --text: #23201b; --muted: #6f685e; --line: #e3ded5;
  --accent: #8a5a2b; --accent-soft: #f3e8dc; --link: #7a4a1e; --up: #2f7d32; --down: #c0392b;
  --head: #2b2620; --head-text: #f3ece2; --chart: #8a5a2b; --chart-fill: rgba(138, 90, 43, .12);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15130f; --panel: #1e1b16; --text: #ece6dc; --muted: #a39a8c; --line: #332e26;
    --accent: #d39a5c; --accent-soft: #2e251b; --link: #e0aa6e; --up: #6cc070; --down: #ef7a6c;
    --head: #0f0d0a; --head-text: #ece6dc; --chart: #d39a5c; --chart-fill: rgba(211, 154, 92, .15);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15130f; --panel: #1e1b16; --text: #ece6dc; --muted: #a39a8c; --line: #332e26;
  --accent: #d39a5c; --accent-soft: #2e251b; --link: #e0aa6e; --up: #6cc070; --down: #ef7a6c;
  --head: #0f0d0a; --head-text: #ece6dc; --chart: #d39a5c; --chart-fill: rgba(211, 154, 92, .15);
  color-scheme: dark;
}

* { box-sizing: border-box; min-width: 0; }
html { font-size: clamp(14px, 0.35vw + 12.5px, 18px); -webkit-text-size-adjust: 100%; }
body { margin: 0; overflow-x: clip; font: 1rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: clamp(1.35rem, 1.2rem + 1vw, 2rem); overflow-wrap: anywhere; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
small.up, .up { color: var(--up); }
small.down, .down { color: var(--down); }

/* Kopf */
.topbar { background: var(--head); color: var(--head-text); }
.topbar .inner { max-width: min(1600px, 96vw); margin: 0 auto; padding: .5rem 1rem; display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.topbar a { color: var(--head-text); }
.brand { font-weight: 700; font-size: 1.15rem; letter-spacing: .02em; }
.brand span { color: var(--accent); }
.menu { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.menu > details { position: relative; }
.menu summary, .menu > a { list-style: none; cursor: pointer; padding: .35rem .6rem; border-radius: 6px; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary:hover, .menu > a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.menu .drop { position: absolute; z-index: 20; top: 100%; left: 0; min-width: 220px; max-height: 70vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .35rem; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.menu .drop a { display: block; padding: .3rem .5rem; border-radius: 4px; color: var(--text); }
.menu .drop a:hover { background: var(--accent-soft); text-decoration: none; }
.menu .drop .grp { font-size: .75rem; text-transform: uppercase; color: var(--muted); padding: .4rem .5rem .1rem; }
.icon-btn { background: none; border: 1px solid rgba(255,255,255,.2); color: var(--head-text); border-radius: 6px; padding: .25rem .55rem; cursor: pointer; }

form.search { position: relative; }
form.search input { width: clamp(160px, 22vw, 320px); padding: .35rem .6rem; border-radius: 6px; border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.08); color: var(--head-text); }
.search-results { position: absolute; right: 0; top: 110%; z-index: 30; width: min(420px, 92vw); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .3rem; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.search-results a { display: block; padding: .3rem .4rem; color: var(--text); border-radius: 4px; }
.search-results a:hover { background: var(--accent-soft); text-decoration: none; }
.badge { display: inline-block; font-size: .7rem; padding: 0 .4rem; border-radius: 4px; background: var(--accent-soft); color: var(--accent); }

/* Inhalt */
main { max-width: min(1600px, 96vw); margin: 1.5rem auto; padding: 0 1rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1.1rem 1.2rem; margin-bottom: 1.2rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 1.2rem; }
.grid2 > .card { margin-bottom: 0; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 1rem; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .45rem .55rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.asc::after { content: " ▲"; } .table th.desc::after { content: " ▼"; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tbody tr:hover { background: var(--accent-soft); }
.dt-wrap { overflow-x: auto; }
.dt-tools { display: flex; gap: 1rem; align-items: center; margin-bottom: .6rem; flex-wrap: wrap; }
.dt-tools input, .dt-tools select, input[type=date] { padding: .35rem .6rem; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); }
.dt-foot { display: flex; justify-content: space-between; align-items: center; margin-top: .6rem; font-size: .9rem; color: var(--muted); flex-wrap: wrap; gap: .5rem; }
.dt-pages button { border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: .2rem .55rem; margin-left: .2rem; border-radius: 5px; cursor: pointer; }
.dt-pages button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: .8rem; }
.fact { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .8rem; }
.fact .k { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.fact .v { font-size: 1.2rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.fact .s { font-size: .8rem; color: var(--muted); }

.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { flex: none; padding: .45rem .9rem; border-radius: 6px 6px 0 0; color: var(--muted); border: 1px solid transparent; border-bottom: none; }
.tabs a.active { color: var(--text); background: var(--panel); border-color: var(--line); margin-bottom: -1px; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.subnav { display: flex; gap: .6rem; flex-wrap: wrap; margin: -.4rem 0 1rem; font-size: .92rem; }
.subnav a { flex: none; padding: .2rem .6rem; border: 1px solid var(--line); border-radius: 999px; }
.subnav a.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.chart { margin: 0; position: relative; border: 1px solid var(--line); border-radius: 8px; padding: .6rem .8rem; min-height: 120px; }
.chart-title { font-weight: 600; font-size: .92rem; margin-bottom: .2rem; }
.chart svg .grid { stroke: var(--line); }
.chart svg .axis { fill: var(--muted); font-size: 11px; }
.chart svg .line { fill: none; stroke: var(--chart); stroke-width: 2; }
.chart svg .area { fill: var(--chart-fill); stroke: none; }
.chart svg .hover-line { stroke: var(--muted); stroke-dasharray: 3 3; }
.chart svg .hover-dot { fill: var(--chart); }
.chart-tip { position: absolute; top: 2rem; background: var(--head); color: var(--head-text); font-size: .8rem; padding: .15rem .45rem; border-radius: 4px; pointer-events: none; }

.btn { display: inline-block; padding: .45rem .9rem; border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; font: inherit; }
.btn.secondary { background: none; color: var(--accent); }
.btn:disabled { opacity: .5; cursor: wait; }
pre.log { background: var(--head); color: var(--head-text); padding: .8rem; border-radius: 8px; max-height: 360px; overflow: auto; font-size: .82rem; white-space: pre-wrap; }

footer { max-width: min(1600px, 96vw); margin: 2rem auto; padding: 0 1rem; color: var(--muted); font-size: .85rem; }
footer a { color: var(--muted); }

/* Formulare */
.form { display: grid; gap: .8rem; }
.form label { display: grid; gap: .25rem; font-size: .92rem; color: var(--muted); }
.form input, .form select, .form textarea { font: inherit; font-size: 16px; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 6px; padding: .55rem .7rem; width: 100%; min-height: 44px; }
.form textarea { min-height: 8rem; resize: vertical; }
.form input:focus-visible, .form select:focus-visible, .form textarea:focus-visible, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.form fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .8rem; margin: 0; display: grid; gap: .3rem; }
.form legend { color: var(--muted); font-size: .85rem; padding: 0 .3rem; }
.form label.check { display: flex; align-items: center; gap: .5rem; color: var(--text); min-height: 36px; }
.form label.check input { width: auto; min-height: 0; }
.form .inline { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.form .btn { justify-self: start; }
.form-card { max-width: 520px; margin-inline: auto; }
.hp { position: absolute !important; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.note { background: var(--accent-soft); border-left: 3px solid var(--accent); padding: .55rem .8rem; border-radius: 4px; color: var(--text); }
.note.error { border-left-color: var(--down); }
.small { font-size: .85rem; }
.units { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); gap: .6rem; }
.units .unit { display: grid; gap: .2rem; font-size: .9rem; color: var(--muted); }
.units input { font-size: 16px; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); min-height: 44px; }
.bb { display: grid; gap: .5rem; margin-bottom: 1rem; }
.bb textarea { width: 100%; font: .85rem/1.4 ui-monospace, Consolas, monospace; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: .6rem; }
a.icon-btn { display: inline-flex; align-items: center; min-height: 34px; }
a.icon-btn:hover { text-decoration: none; }

/* Planer */
.plan-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px); gap: 1rem; align-items: start; margin-bottom: 1rem; }
.title-edit { display: grid; gap: .25rem; color: var(--muted); font-size: .9rem; max-width: 520px; }
.title-edit input, .copyrow input, .bulk input, .bulk select, .inline-row input, .inline-row select { font: inherit; font-size: 16px; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 6px; padding: .45rem .6rem; min-height: 40px; }
.share { margin: 0; }
.share summary { cursor: pointer; font-weight: 600; }
.share label { display: grid; gap: .25rem; margin-top: .6rem; color: var(--muted); font-size: .88rem; }
.copyrow { display: flex; gap: .4rem; } .copyrow input { flex: 1; min-width: 0; font-size: .85rem; }
.lead { font-size: 1.1rem; margin: 0; }
.mono { font: .85rem/1.45 ui-monospace, Consolas, monospace; width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: .6rem; }
.ap-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); align-items: end; }
.ap-grid .wide { grid-column: 1 / -1; }
.bulk, .inline-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: .8rem; }
.bulk label, .inline-row label { display: flex; gap: .4rem; align-items: center; color: var(--muted); font-size: .9rem; }
.bulk input[type=number] { width: 6rem; }
.btn.danger { border-color: var(--down); color: var(--down); }
.tag { display: inline-block; padding: .05rem .45rem; border-radius: 4px; font-size: .78rem; font-weight: 600; background: var(--accent-soft); white-space: nowrap; }
.tag.t-off { background: #c0392b; color: #fff; } .tag.t-conquer { background: #8e44ad; color: #fff; } .tag.t-fake { background: #7f8c8d; color: #fff; }
.tag.t-wallbreaker { background: #d35400; color: #fff; } .tag.t-support, .tag.t-standsupport { background: #2471a3; color: #fff; }
.tag.t-fastsupport { background: #17a589; color: #fff; } .tag.t-fakesupport { background: #85929e; color: #fff; }
tr.sent { opacity: .5; }
td.actions { white-space: nowrap; } td.actions .btn { padding: .25rem .5rem; min-height: 34px; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 380px); gap: 1.2rem; align-items: start; }
.map-card { padding: .8rem; }
.map-wrap { position: relative; line-height: 0; }
.map-wrap img, .map-wrap canvas { width: 100%; height: auto; display: block; border-radius: 6px; }
#mp-canvas { position: absolute; inset: 0; pointer-events: none; }
.map-loading[hidden] { display: none; }
.map-loading { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.35); color: #fff; line-height: 1.4; border-radius: 6px; }
.wt-wrap canvas { aspect-ratio: 1; }
.legend { list-style: none; padding: 0; margin: .8rem 0 0; display: grid; gap: .4rem; }
.legend li { display: flex; align-items: center; gap: .5rem; }
.legend li > span:nth-child(2) { flex: 1; }
.legend input[type=color] { width: 36px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: none; }
.swatch { width: 16px; height: 16px; border-radius: 3px; border: 1px solid rgba(0,0,0,.3); flex: none; }
.form input[type=color] { padding: 2px; height: 44px; }
.player { display: flex; gap: .8rem; align-items: center; margin-top: .8rem; flex-wrap: wrap; }
.player input[type=range] { flex: 1; min-width: 160px; accent-color: var(--accent); }
.stars { color: #e0a800; letter-spacing: 1px; }
.rate { display: flex; align-items: center; gap: .2rem; margin: 1rem 0; flex-wrap: wrap; }
.star-btn { background: none; border: 0; font-size: 1.6rem; color: var(--line); cursor: pointer; min-height: 44px; min-width: 36px; }
.star-btn.on, .star-btn:hover { color: #e0a800; }
.steps { padding-left: 1.4rem; display: grid; gap: .3rem; max-height: 60vh; overflow: auto; }
.steps li > * { vertical-align: middle; } .steps li { display: list-item; }
.steps li span:last-child { float: right; } .steps .btn { padding: .1rem .45rem; min-height: 30px; }
ul.plain { padding-left: 1.1rem; }

/* ---------- Responsive: Handy, Tablet, Desktop, 4K ---------- */
.card { overflow-wrap: anywhere; }
button, .btn, .dt-pages button, .tabs a, .subnav a { min-height: 40px; }
.dt-pages button { min-width: 40px; }
@media (max-width: 900px) {
  .plan-head, .map-layout { grid-template-columns: minmax(0, 1fr); }
  .topbar .inner { gap: .5rem; }
  .menu { order: 3; flex-basis: 100%; }
  form.search { flex: 1; }
  form.search input { width: 100%; }
}
@media (max-width: 640px) {
  main { margin-top: 1rem; }
  .card { padding: .9rem; border-radius: 8px; }
  .menu .drop { position: fixed; left: 8px; right: 8px; top: auto; min-width: 0; max-height: 60vh; }
  .table th, .table td { padding: .4rem .45rem; font-size: .9rem; }
  .dt-tools { flex-direction: column; align-items: stretch; }
  .dt-tools input, .dt-tools select { width: 100%; font-size: 16px; }
  .dt-foot { flex-direction: column; align-items: flex-start; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
  .fact { padding: .5rem .6rem; }
  .fact .v { font-size: 1.05rem; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; }
  .tabs a { white-space: nowrap; flex: none; }
}
@media (min-width: 2200px) {
  html { font-size: 19px; }
  .charts { grid-template-columns: repeat(auto-fit, minmax(560px, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Textseiten, News, Changelog */
.prose h2 { margin: 1.1rem 0 .4rem; font-size: 1.15rem; }
.prose h2:first-child { margin-top: 0; }
.prose p, .prose ul { margin: .5rem 0; line-height: 1.55; }
.prose ul { padding-left: 1.3rem; }
.news-item + .news-item { border-top: 1px solid var(--line); padding-top: .8rem; margin-top: .8rem; }
.share summary { cursor: pointer; }
.share-grid { display: grid; gap: .8rem; margin-top: .9rem; }
.share-grid label { display: grid; gap: .25rem; font-size: .9rem; color: var(--muted); }
.share-grid img { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.share-grid input, .share-grid select { width: 100%; }

/* Hervorhebung bei Adelungen */
tr.hl-win td { background: rgba(34, 160, 80, .14); }
tr.hl-loss td { background: rgba(210, 50, 50, .14); }
tr.hl-self td { background: rgba(120, 120, 120, .14); }
tr.hl-intern td { background: rgba(37, 99, 235, .13); }
tr.hl-barb td { background: rgba(200, 160, 40, .14); }
tr.hl-deleted td { background: rgba(150, 80, 200, .13); }
.hl-legend { display: flex; gap: .4rem; flex-wrap: wrap; margin: 0 0 .6rem; }
.hl-legend span { padding: .1rem .5rem; border-radius: 4px; }
.hl-legend .hl-win { background: rgba(34, 160, 80, .18); } .hl-legend .hl-loss { background: rgba(210, 50, 50, .18); }
.hl-legend .hl-self { background: rgba(120, 120, 120, .18); } .hl-legend .hl-intern { background: rgba(37, 99, 235, .16); }
.hl-legend .hl-barb { background: rgba(200, 160, 40, .2); } .hl-legend .hl-deleted { background: rgba(150, 80, 200, .16); }
.oauth { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 1rem 0; }
.follow-btn.on { background: var(--accent); color: #fff; }
.verified { color: #1f9d55; font-size: .9rem; }
.hl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; }
.hl-grid fieldset { border: 1px solid var(--line); border-radius: 6px; padding: .4rem .7rem; }
.hl-grid legend { font-weight: 600; padding: 0 .3rem; }
label.check { display: flex !important; align-items: center; gap: .4rem; color: inherit !important; }
.title-actions { display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; margin: -.3rem 0 1rem; }
td.actions { white-space: nowrap; }
.map-img { width: 100%; height: auto; display: block; border-radius: 6px; image-rendering: auto; }
.swatch { display: inline-block; width: .8rem; height: .8rem; border-radius: 2px; margin-right: .4rem; vertical-align: -1px; }
.overview-map { max-width: 640px; }
footer .version { font-variant-numeric: tabular-nums; }

/* ================= Stil „Pergament & Burg“ =================
   Angelehnt an die bisherige DS-Ultimate-Seite und das Spiel: Pergament, Gold, Holzbraun.
   Hintergrund: Burg auf dem Hügel über weitem Land (Bild vom Betreiber), dunkel als abendlich abgedunkelte Fassung. */
:root {
  --bg: #e9dcb8; --panel: #f6ead0; --text: #2b2014; --muted: #6e5a3c; --line: #d6bf8c;
  --accent: #8a5a1f; --accent-soft: #f0dcab; --link: #7a4210; --up: #2e7a1f; --down: #b3261e;
  --head: #2b2014; --head-text: #f6ead0; --chart: #8a4a14; --chart-fill: rgba(138, 74, 20, .14);
  --nav-bg: linear-gradient(180deg, #f3dfa2 0%, #e8cd83 100%); --nav-text: #4a3008; --nav-hover: rgba(122, 66, 16, .14);
  --nav-edge: #7d510f; --th: #c1a264; --th-text: #3b2608; --row: #fff5da; --row2: #f4e4bc; --row-hover: #ecd59c;
  --btn-a: #a07a46; --btn-b: #74522a; --btn-edge: #4f3514; --btn-text: #fff8e6;
  --serif: "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", "Iowan Old Style", Georgia, serif;
  --paper: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .32 0 0 0 0 .12 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --panel-glass: rgba(246, 234, 208, .94);
  --bg-img: image-set(url("img/bg-burg-light.webp") type("image/webp"), url("img/bg-burg-light.jpg") type("image/jpeg"));
  --bg-img-sm: url("img/bg-burg-light-sm.webp");
  --bg-veil: linear-gradient(180deg, rgba(233,220,184,.10) 0%, rgba(233,220,184,.35) 45%, rgba(233,220,184,.75) 100%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #17110a; --panel: #241a10; --text: #eedfbd; --muted: #b29d78; --line: #4a3822;
  --accent: #d9b45a; --accent-soft: #3a2a17; --link: #e6c06a; --up: #7cc46a; --down: #ef7a6c;
  --head: #0e0a06; --head-text: #eedfbd; --chart: #d9b45a; --chart-fill: rgba(217, 180, 90, .16);
  --nav-bg: linear-gradient(180deg, #33241400 0%, #2a1d10 0%, #1f150b 100%); --nav-text: #ecd08a; --nav-hover: rgba(236, 208, 138, .12);
  --nav-edge: #a37b35; --th: #4e3a1f; --th-text: #f0d792; --row: #261c11; --row2: #2e2215; --row-hover: #3d2e1a;
  --btn-a: #8a6630; --btn-b: #5c4119; --btn-edge: #c9a050; --btn-text: #fff3d4;
  --panel-glass: rgba(36, 26, 16, .94);
  --bg-img: image-set(url("img/bg-burg-dark.webp") type("image/webp"), url("img/bg-burg-dark.jpg") type("image/jpeg"));
  --bg-img-sm: url("img/bg-burg-dark-sm.webp");
  --bg-veil: linear-gradient(180deg, rgba(23,17,10,.30) 0%, rgba(23,17,10,.55) 45%, rgba(23,17,10,.85) 100%);
  color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #17110a; --panel: #241a10; --text: #eedfbd; --muted: #b29d78; --line: #4a3822;
  --accent: #d9b45a; --accent-soft: #3a2a17; --link: #e6c06a; --up: #7cc46a; --down: #ef7a6c;
  --head: #0e0a06; --head-text: #eedfbd; --chart: #d9b45a; --chart-fill: rgba(217, 180, 90, .16);
  --nav-bg: linear-gradient(180deg, #2a1d10 0%, #1f150b 100%); --nav-text: #ecd08a; --nav-hover: rgba(236, 208, 138, .12);
  --nav-edge: #a37b35; --th: #4e3a1f; --th-text: #f0d792; --row: #261c11; --row2: #2e2215; --row-hover: #3d2e1a;
  --btn-a: #8a6630; --btn-b: #5c4119; --btn-edge: #c9a050; --btn-text: #fff3d4;
  --panel-glass: rgba(36, 26, 16, .94);
  --bg-img: image-set(url("img/bg-burg-dark.webp") type("image/webp"), url("img/bg-burg-dark.jpg") type("image/jpeg"));
  --bg-img-sm: url("img/bg-burg-dark-sm.webp");
  --bg-veil: linear-gradient(180deg, rgba(23,17,10,.30) 0%, rgba(23,17,10,.55) 45%, rgba(23,17,10,.85) 100%);
  color-scheme: dark; }

body { background: transparent; }
body::before { content: ""; position: fixed; inset: 0; z-index: -1; background: var(--bg-veil), var(--bg-img) center 42% / cover no-repeat, var(--bg); }
@media (max-width: 900px) { body::before { background: var(--bg-veil), var(--bg-img-sm) center 40% / cover no-repeat, var(--bg); } }

/* Überschriften in Buchschrift */
h1, h2, h3, .brand, .fact .k, .tabs a, .chart-title, .table th { font-family: var(--serif); }
h2 { font-weight: 700; letter-spacing: .01em; padding-bottom: .35rem; margin-bottom: .8rem;
  background: linear-gradient(90deg, var(--nav-edge), transparent 70%) left bottom / 100% 1px no-repeat; }
h2::before { content: "◆"; color: var(--accent); font-size: .6em; vertical-align: .25em; margin-right: .45rem; }

/* Seitentitel als Banner auf dem Bild */
main > h1 { display: inline-block; max-width: 100%; padding: .35rem 2.2rem .4rem 1rem; margin-bottom: .7rem;
  background: var(--paper), var(--panel-glass); color: var(--text); border: 1px solid var(--nav-edge); border-left: 5px solid var(--nav-edge);
  clip-path: polygon(0 0, 100% 0, calc(100% - 1.1rem) 50%, 100% 100%, 0 100%); box-shadow: 0 3px 12px rgba(0,0,0,.18); }
main > h1 a.muted { color: var(--link); }
main > .title-actions { margin-top: 0; }

/* Kopfleiste: Pergament mit Holzkante, alle Links in einer Zeile */
.topbar { background: var(--paper), var(--nav-bg); color: var(--nav-text); border-bottom: 3px solid var(--nav-edge);
  box-shadow: 0 2px 0 rgba(0,0,0,.12), 0 6px 18px rgba(0,0,0,.18); position: sticky; top: 0; z-index: 40; }
.topbar .inner { flex-wrap: nowrap; gap: .6rem; padding: .4rem 1rem; }
.topbar a, .topbar summary { color: var(--nav-text); }
.brand { font-size: 1.3rem; font-weight: 700; white-space: nowrap; flex: none; }
.brand::before { content: "⚔"; font-variant-emoji: text; margin-right: .35rem; color: var(--nav-edge); }
.brand span { color: var(--accent); }
:root:not([data-theme="dark"]) .brand span { color: #a0400f; }
.menu { flex: 0 1 auto; flex-wrap: nowrap; gap: .1rem; }
.menu summary, .menu > a { white-space: nowrap; font-weight: 600; }
.menu summary:hover, .menu > a:hover, .menu details[open] > summary { background: var(--nav-hover); }
.menu .drop, details.lang .drop { background: var(--paper), var(--panel); border: 1px solid var(--nav-edge); border-radius: 4px; box-shadow: 0 10px 26px rgba(0,0,0,.28); }
.menu .drop a, details.lang .drop a { color: var(--text); }
.menu .drop .grp { font-family: var(--serif); color: var(--accent); font-weight: 700; border-bottom: 1px solid var(--line); margin-bottom: .2rem; }
.topbar form.search { margin-left: auto; }
.topbar form.search input { background: rgba(255,255,255,.55); border: 1px solid var(--nav-edge); color: var(--text); border-radius: 4px; }
:root[data-theme="dark"] .topbar form.search input { background: rgba(0,0,0,.3); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .topbar form.search input { background: rgba(0,0,0,.3); } }
.topbar form.search input::placeholder { color: var(--muted); }
.topbar .icon-btn { border: 1px solid var(--nav-edge); color: var(--nav-text); border-radius: 4px; background: rgba(255,255,255,.18); white-space: nowrap; }
.topbar .icon-btn:hover { background: var(--nav-hover); }
/* Sprachwahl: echtes Dropdown unter dem Globus */
details.lang { position: relative; flex: none; }
details.lang summary { list-style: none; cursor: pointer; padding: .3rem .5rem; border: 1px solid var(--nav-edge); border-radius: 4px; white-space: nowrap; }
details.lang summary::-webkit-details-marker { display: none; }
details.lang .drop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 170px; padding: .3rem; }
details.lang .drop a { display: block; padding: .3rem .55rem; border-radius: 3px; }
details.lang .drop a:hover, details.lang .drop a.on { background: var(--accent-soft); text-decoration: none; }
@media (max-width: 1180px) {
  .topbar .inner { flex-wrap: wrap; }
  .menu { order: 3; flex: 1 1 100%; flex-wrap: wrap; }
}
@media (max-width: 1180px) { .topbar form.search { flex: 1 1 200px; } .topbar form.search input { width: 100%; } }
@media (max-width: 900px) { .topbar { position: relative; } }
@media (max-width: 640px) {
  .topbar form.search { order: 4; flex: 1 1 100%; margin-left: 0; }
  details.lang { margin-left: auto; }
  details.lang .drop { position: fixed; left: 8px; right: 8px; top: auto; }
}

/* Karten wie Pergamentbögen */
.card { background: var(--paper), var(--panel-glass); border: 1px solid var(--line); border-top: 3px solid var(--nav-edge); border-radius: 4px;
  box-shadow: 0 1px 0 rgba(255,255,255,.4) inset, 0 6px 22px rgba(0,0,0,.16); }
.fact { background: var(--row); border: 1px solid var(--line); border-radius: 3px; border-left: 3px solid var(--accent); }
.fact .k { text-transform: none; letter-spacing: 0; font-size: .85rem; font-weight: 700; color: var(--muted); }
.fact .v { font-family: var(--serif); font-size: 1.35rem; }

/* Tabellen im Stil der Spieltabellen */
.table { border: 1px solid var(--line); }
.table th { background: var(--th); color: var(--th-text); text-transform: none; letter-spacing: 0; font-size: .9rem; border-bottom: 1px solid var(--nav-edge); }
.table tbody tr:nth-child(odd) td { background: var(--row); }
.table tbody tr:nth-child(even) td { background: var(--row2); }
.table tbody tr:hover td { background: var(--row-hover); }
.table th, .table td { border-bottom: 1px solid var(--line); }

/* Reiter wie im Spiel */
.tabs { border-bottom: 2px solid var(--nav-edge); gap: .25rem; }
.tabs a { background: var(--row2); border: 1px solid var(--line); border-bottom: none; border-radius: 4px 4px 0 0; color: var(--text); font-weight: 600; }
.tabs a.active { background: var(--th); color: var(--th-text); border-color: var(--nav-edge); margin-bottom: 0; }
.tabs a:hover { background: var(--row-hover); }
.subnav a { border-color: var(--nav-edge); border-radius: 4px; background: var(--row); }
.subnav a.active { background: var(--th); color: var(--th-text); border-color: var(--nav-edge); }

/* Knöpfe aus Holz, deaktivierte gut erkennbar */
.btn { background: linear-gradient(180deg, var(--btn-a), var(--btn-b)); border: 1px solid var(--btn-edge); color: var(--btn-text);
  border-radius: 4px; font-weight: 600; text-shadow: 0 1px 0 rgba(0,0,0,.35); box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 2px 4px rgba(0,0,0,.2); }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.secondary { background: var(--row); color: var(--link); border: 1px solid var(--nav-edge); text-shadow: none; }
.btn.danger { background: var(--row); color: var(--down); border-color: var(--down); text-shadow: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 1; filter: grayscale(.6); cursor: not-allowed; background: var(--row2); color: var(--muted);
  border: 1px dashed var(--nav-edge); text-shadow: none; box-shadow: none; }
.dt-pages button { background: var(--row); border-color: var(--line); border-radius: 4px; }
.dt-pages button.active { background: linear-gradient(180deg, var(--btn-a), var(--btn-b)); border-color: var(--btn-edge); color: var(--btn-text); }
.dt-tools input, .dt-tools select, .form input, .form select, .form textarea, .units input, input[type=date] { background: var(--row); border-color: var(--line); border-radius: 4px; }
.note { background: var(--row); border-left-color: var(--nav-edge); }
.chart { background: var(--row); border-color: var(--line); border-radius: 4px; }
.map-img { border: 2px solid var(--nav-edge); border-radius: 3px; }
.map-legend { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin: .55rem 0 0; color: var(--muted); }
.map-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.map-legend i { width: .8rem; height: .8rem; border: 1px solid rgba(0,0,0,.5); display: inline-block; }
.overview-map { max-width: none; }

footer { background: var(--paper), var(--panel-glass); border: 1px solid var(--line); border-top: 3px solid var(--nav-edge); border-radius: 4px; padding: .6rem 1rem; color: var(--muted); }
@media print { body::before { display: none; } .card { background: #fff; box-shadow: none; } .topbar { position: static; } }
.icon-btn.gear { font-size: 1.1rem; line-height: 1; }
/* Öffentliche Roadmap */
.rmp-head { display: flex; gap: 1.5rem; align-items: center; flex-wrap: wrap; }
.rmp-total { display: flex; flex-direction: column; }
.rmp-total b { font-size: clamp(2.5rem, 2rem + 3vw, 4.5rem); line-height: 1; color: var(--accent); }
.rmp-bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin: .2rem 0 .8rem; }
.rmp-bar i { display: block; height: 100%; background: var(--accent); }
.rmp-list { list-style: none; margin: 0; padding: 0; }
.rmp-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; border-bottom: 1px solid var(--line); }
.rmp-list li small { color: var(--muted); white-space: nowrap; }
.rmp-list li.done small { color: var(--up); }
.rmp-list li.done span::before { content: "✓ "; color: var(--up); }
.rmp-list li.test small { color: var(--accent); }
.rmp-list li span { flex: 1; } .rmp-list li small { flex: none; }

/* ================= Chat (Hauptseite und Admin) ================= */
.chat-card > summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: .8rem; flex-wrap: wrap; }
.chat-card > summary::-webkit-details-marker { display: none; }
.chat-card > summary h2 { margin: 0; flex: none; }
.chat-card > summary::after { content: "▾"; margin-left: auto; color: var(--muted); transition: transform .15s; }
.chat-card:not([open]) > summary::after { transform: rotate(-90deg); }
.chat { margin-top: .7rem; }
.chat-rooms { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .5rem; }
.chat-room { display: inline-flex; align-items: stretch; border: 1px solid var(--line); border-radius: 4px; background: var(--row2); overflow: hidden; }
.chat-room button, .chat-room-new { background: none; border: 0; padding: .25rem .6rem; color: var(--text); cursor: pointer; font: inherit; font-weight: 600; }
.chat-room.active { background: var(--th); border-color: var(--nav-edge); }
.chat-room.active button { color: var(--th-text); }
.chat-room .chat-room-del { padding: .25rem .45rem; color: var(--muted); border-left: 1px solid var(--line); font-weight: 400; }
.chat-room-new { border: 1px dashed var(--nav-edge); border-radius: 4px; color: var(--link); }
.chat-log { height: 260px; overflow-y: auto; background: var(--row); border: 1px solid var(--line); border-radius: 4px; padding: .5rem .6rem; display: flex; flex-direction: column; gap: .35rem; }
.chat-msg { position: relative; padding: .3rem 2rem .3rem .55rem; border-radius: 4px; background: var(--row2); border-left: 3px solid var(--line); max-width: 92%; }
.chat-msg.mine { align-self: flex-end; border-left-color: var(--accent); background: var(--accent-soft); }
.chat-meta { display: block; font-size: .78rem; color: var(--muted); }
.chat-meta b { color: var(--text); font-family: var(--serif); }
.chat-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-del { position: absolute; top: .2rem; right: .3rem; border: 0; background: none; color: var(--muted); cursor: pointer; }
.chat-del:hover, .chat-room-del:hover { color: var(--down); }
.chat-form { display: flex; gap: .4rem; margin-top: .5rem; }
.chat-form input { flex: 1; min-width: 0; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 4px; background: var(--row); color: var(--text); font: inherit; }
.chat-login { margin: .5rem 0 0; }
.chat-status { min-height: 1.1em; margin: .3rem 0 0; color: var(--muted); }
@media (max-width: 640px) { .chat-log { height: 220px; } .chat-msg { max-width: 100%; } }
.chat-card > summary .chat-gear { margin-left: auto; order: 2; text-decoration: none; }
.chat-card > summary::after { order: 3; margin-left: .5rem; }
.chat-main { display: grid; grid-template-columns: 1fr 190px; gap: .6rem; }
.chat-online { background: var(--row); border: 1px solid var(--line); border-radius: 4px; padding: .4rem .55rem; max-height: 260px; overflow-y: auto; }
.chat-online h3 { margin: 0 0 .35rem; font-size: .9rem; font-family: var(--serif); }
.chat-online ul { list-style: none; margin: 0; padding: 0; }
.chat-online li { display: flex; align-items: center; gap: .25rem; padding: .15rem 0; }
.chat-online .chat-user { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-online .chat-user::before { content: "●"; color: var(--up); font-size: .7em; margin-right: .35rem; vertical-align: .1em; }
.chat-online .chat-user.me { font-weight: 700; }
.chat-online button { border: 1px solid var(--line); background: var(--row2); color: var(--link); border-radius: 3px; padding: 0 .35rem; cursor: pointer; font: inherit; line-height: 1.5; }
.chat-room.dm { border-style: dashed; }
.chat-room.unread button { color: var(--down); }
mark.chat-at { background: var(--accent-soft); color: var(--link); padding: 0 .15rem; border-radius: 3px; font-weight: 600; }
@media (max-width: 760px) { .chat-main { grid-template-columns: 1fr; } .chat-online { max-height: 140px; } }
.chat-card .chat-gear { color: var(--link); border: 1px solid var(--line); background: var(--row); }
@media (max-width: 640px) { .chat-card > summary { flex-wrap: nowrap; } .chat-card > summary .small { display: none; } }
.chat-gear[hidden] { display: none !important; }

/* Live-Überwachung im Admin-Bereich */
.monitor-dot{display:inline-block;width:.7rem;height:.7rem;border-radius:50%;background:#999;vertical-align:middle}
.monitor-dot[data-state=ok]{background:#2e9d4b}
.monitor-dot[data-state=warn]{background:#e0a100}
.monitor-dot[data-state=problem]{background:#d33;box-shadow:0 0 0 3px rgba(221,51,51,.25)}
.monitor-card h2 .btn{float:right}
.monitor-table td:first-child{white-space:nowrap;width:1%}
.monitor-bar{display:inline-block;width:6rem;height:.5rem;border-radius:.25rem;background:rgba(127,127,127,.25);vertical-align:middle;overflow:hidden}
.monitor-bar i{display:block;height:100%;background:#2e9d4b}
.monitor-bar[data-state=warn] i{background:#e0a100}
.monitor-bar[data-state=problem] i{background:#d33}
#admin-monitor-punkt{display:inline-flex;align-items:center;gap:.35rem}
.monitor-graph-box{position:relative}
.monitor-graph{width:100%;height:auto;display:block}
.monitor-graph text{font-size:11px;fill:currentColor;opacity:.65}
.monitor-graph .grid{stroke:currentColor;opacity:.12}
.monitor-graph .cursor{stroke:currentColor;opacity:.4;stroke-dasharray:3 3}
.monitor-legend{display:flex;flex-wrap:wrap;gap:.4rem 1.2rem;font-size:.85rem;margin-top:.3rem}
.monitor-legend i{display:inline-block;width:.8rem;height:.25rem;border-radius:.1rem;margin-right:.35rem;vertical-align:middle}
.monitor-tip{position:absolute;top:.5rem;right:.5rem;background:var(--panel);border:1px solid rgba(127,127,127,.3);border-radius:.4rem;padding:.4rem .6rem;font-size:.8rem;pointer-events:none}

/* Lastsimulation im Admin-Bereich */
.lastsim-form{display:flex;flex-wrap:wrap;gap:.8rem 1.2rem;align-items:flex-end}
.lastsim-form label{display:flex;flex-direction:column;gap:.25rem;min-width:12rem}
.lastsim-form .actions{display:flex;gap:.5rem;flex-wrap:wrap}
.lastsim-fortschritt{height:.5rem;border-radius:.25rem;background:rgba(127,127,127,.2);overflow:hidden;margin:.3rem 0 .6rem}
.lastsim-fortschritt i{display:block;height:100%;width:0;background:#3b82f6;transition:width .5s}
.lastsim-zahlen{display:grid;grid-template-columns:repeat(auto-fit,minmax(9rem,1fr));gap:.6rem;margin:.6rem 0 1rem}
.lastsim-zahlen div{display:flex;flex-direction:column;padding:.5rem .7rem;border:1px solid rgba(127,127,127,.25);border-radius:.4rem}
.lastsim-graphen{display:grid;grid-template-columns:repeat(auto-fit,minmax(320px,1fr));gap:1rem}
.lastsim-graphen h3{font-size:.95rem;margin:.2rem 0}
.lastsim-ergebnis td:first-child{white-space:nowrap;width:1%;font-weight:600}
.lastsim-titel-btn{float:right}
.nowrap{white-space:nowrap}

/* Seite direkt bearbeiten (Impressum) */
.page-view { position: relative; }
.page-edit-btn { float: right; margin: 0 0 .5rem 1rem; }
.page-editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
.page-editor[hidden], .page-view[hidden] { display: none; }
.page-editor textarea { width: 100%; font-family: ui-monospace, Consolas, monospace; }
.page-preview { border: 1px dashed var(--line); border-radius: 4px; padding: .6rem .8rem; max-height: 70vh; overflow: auto; }
@media (max-width: 900px) { .page-editor-grid { grid-template-columns: minmax(0, 1fr); } }

/* Bildschirmgrößen 280–7680 px: Mindestgrößen auf kleinen Displays, mitwachsende Schrift auf 4K/5K/8K */
.badge { font-size: max(.7rem, 11px); }
.menu .drop .grp { font-size: max(.75rem, 11px); }
.table td small, .table th small { font-size: max(.8em, 11px); }
@media (max-width: 640px) { footer a { display: inline-block; padding: .3rem .1rem; } }
@media (min-width: 2200px) { .topbar .inner, main, footer { max-width: min(100rem, 96vw); } }
@media (min-width: 3000px) and (min-height: 1600px) { html { font-size: 24px; } .charts { grid-template-columns: repeat(auto-fit, minmax(720px, 1fr)); } }
@media (min-width: 4600px) and (min-height: 2500px) { html { font-size: 30px; } .charts { grid-template-columns: repeat(auto-fit, minmax(900px, 1fr)); } }
@media (min-width: 6400px) and (min-height: 3400px) { html { font-size: 40px; } .charts { grid-template-columns: repeat(auto-fit, minmax(1200px, 1fr)); } }
label.check input[type="checkbox"], label.check input[type="radio"] { flex: none; }
@media (max-width: 640px) { .fact .v a, .fact .s a { display: inline-block; min-width: 24px; min-height: 24px; line-height: 24px; text-align: center; } }
.note.warn { border-left-color: #c98a00; }
