:root {
  --bg: #16130f;
  --panel: #221d17;
  --panel-2: #2c251d;
  --line: #3d3328;
  --text: #ece3d3;
  --muted: #a89a85;
  --accent: #d4a24c;
  --accent-text: #1a140c;
  --danger: #c8553d;
  --ok: #6b9e5a;
  --info: #5b8fb9;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* Platz für den Scrollbalken immer freihalten: sonst rutscht beim Wechsel zwischen langen und kurzen
   Seiten (z. B. Karten ↔ Dateien) alles um dessen Breite zur Seite. Nicht im TV-Modus, der scrollt nie. */
html:not(.tv) { scrollbar-gutter: stable; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 1.05rem; color: var(--accent); letter-spacing: .02em; }

button, input, select {
  font: inherit;
  color: inherit;
}

button {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .55rem .9rem;
  min-height: 44px;
  cursor: pointer;
  touch-action: manipulation;
}
button:active { transform: scale(.97); }
a.button, label.button {
  cursor: pointer; font-size: inherit;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: .55rem .9rem; min-height: 44px; color: inherit; text-decoration: none;
}
a.button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
a.button.ghost { background: transparent; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
button.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.ghost { background: transparent; }
button:disabled { opacity: .45; }

textarea { font: inherit; color: inherit; resize: vertical; line-height: 1.4; }
input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .55rem .7rem;
  min-height: 44px;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { display: grid; gap: .25rem; font-size: .8rem; color: var(--muted); }

/* --- Kopfzeile ----------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem 1rem;
  background: rgba(22, 19, 15, .95);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.topbar h1 { font-size: 1.1rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Schriftzug in der Mitte der Kopfzeile, nur wenn genug Platz ist */
/* Cinzel (SIL Open Font License), nur die Buchstaben des Schriftzugs */
@font-face { font-family: "Cinzel"; font-weight: 700; font-display: swap; src: url("/static/fonts/cinzel-brand.ttf") format("truetype"); }
.brand { display: none; }
@media (min-width: 900px) {
  .brand {
    display: flex; align-items: center; gap: .35rem;
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    pointer-events: none; user-select: none; white-space: nowrap;
    font-family: "Cinzel", "Trajan Pro", "Times New Roman", Georgia, serif;
    font-weight: 700; font-size: 1.05rem; letter-spacing: .14em; text-transform: uppercase;
  }
  .brand span {
    background: linear-gradient(#f3dfa6, #d4a24c 55%, #9c6b23);
    -webkit-background-clip: text; background-clip: text; color: transparent;
    filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .8));
  }
  .brand b {
    font-size: 1.9rem; line-height: 1; margin: -.3rem .05rem 0; font-style: italic;
    color: #c8261d; text-shadow: 0 0 6px rgba(200, 38, 29, .55), 0 1px 0 #000;
  }
  .topbar:has(.brand) h1 { flex: 1 1 0; max-width: calc(50% - 190px); margin-right: auto; }
}
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); flex: none; }
.dot.live { background: var(--ok); }
.world-chip { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.day-chip { display: none; color: var(--text); font-weight: 600; font-size: 1rem; }
@media (min-width: 900px) { .day-chip:not(:empty) { display: inline; } }

/* --- Layout -------------------------------------------------------------- */
.layout { display: grid; gap: 1rem; padding: 1rem; max-width: 1400px; margin: 0 auto; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; display: grid; gap: .8rem; align-content: start; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1 1 auto; }
.row > button { flex: 0 0 auto; }
.row > input, .row > select { flex: 1 1 160px; width: auto; min-width: 0; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: .5rem; align-items: end; }
.grid-form .wide { grid-column: span 2; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }

.tabs { display: flex; gap: .4rem; z-index: 10; }
.tabs button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem;
  font-size: .72rem; padding: .3rem .15rem; min-height: 48px; min-width: 0; white-space: nowrap;
}
.tabs button i { font-style: normal; font-size: 1.15rem; line-height: 1; }
.tabs .d { display: none; }

@media (max-width: 899px) {
  .layout { padding: .75rem .75rem 5.5rem; }
  .tabs {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--panel); border-top: 1px solid var(--line);
    padding: .4rem .4rem calc(.4rem + env(safe-area-inset-bottom));
  }
  .layout.dm[data-tab] > .panel { display: none; }
  .layout.dm[data-tab="combat"] > #combat,
  .layout.dm[data-tab="party"] > #party,
  .layout.dm[data-tab="world"] > :is(#world, #npcs) { display: grid; }
}
@media (min-width: 900px) {
  .tabs {
    position: sticky; top: var(--top, 60px);
    padding: .5rem max(1rem, calc((100% - 1400px) / 2 + 1rem));
    background: rgba(22, 19, 15, .92); border-bottom: 1px solid var(--line);
    backdrop-filter: blur(6px);
  }
  .tabs button { flex: 0 0 auto; flex-direction: row; gap: .45rem; font-size: .95rem; padding: .4rem 1rem; min-height: 40px; }
  .tabs button i { font-size: 1rem; }
  .tabs .mobile-only { display: none; }
  .tabs .m { display: none; }
  .tabs .d { display: inline; }
  .layout.dm { grid-template-columns: 3fr 2fr; }
  .layout.dm #combat { grid-row: span 3; }
  .layout.dm[data-tab] > .panel { display: none; }
  .layout.dm:is([data-tab="combat"], [data-tab="party"], [data-tab="world"]) > :is(#combat, #party, #world, #npcs) { display: grid; }
  .layout.dm:is([data-tab="maps"], [data-tab="chronicle"], [data-tab="library"], [data-tab="files"], [data-tab="notes"]) { grid-template-columns: minmax(0, 1fr); }
}
/* Spieltisch am großen Bildschirm: links Gruppe und NSC, Mitte Kampf, rechts Zeit und Umgebung */
@media (min-width: 1400px) {
  .layout.dm[data-tab="combat"] {
    max-width: 1900px; align-items: start;
    grid-template-columns: minmax(340px, 1fr) minmax(0, 1.7fr) minmax(320px, .9fr);
    grid-template-rows: auto 1fr; /* NSC direkt unter der Gruppe, auch wenn rechts mehr steht */
  }
  /* Alle DM-Reiter gleich breit, damit die Reiterleiste beim Umschalten nicht springt */
  .layout.dm { max-width: 1900px; }
  body:has(.layout.dm) .tabs { padding-inline: max(1rem, calc((100% - 1900px) / 2 + 1rem)); }
  .layout.dm[data-tab="combat"] > #party { grid-column: 1; grid-row: 1; }
  .layout.dm[data-tab="combat"] > #npcs { grid-column: 1; grid-row: 2; }
  .layout.dm[data-tab="combat"] > #combat { grid-column: 2; grid-row: 1 / span 2; }
  .layout.dm[data-tab="combat"] > #world { grid-column: 3; grid-row: 1 / span 2; }
}
.layout.dm[data-tab="maps"] > #maps,
.layout.dm[data-tab="chronicle"] > #chronicle,
.layout.dm[data-tab="library"] > #library,
.layout.dm[data-tab="files"] > #files,
.layout.dm[data-tab="notes"] > #notes { display: grid; }
.layout.dm[data-tab="chronicle"], .layout.dm[data-tab="library"] { max-width: 900px; }

/* Acht Reiter auf schmalen Handys: nur der offene zeigt seinen Namen, die anderen ihr Symbol */
@media (max-width: 440px) {
  .tabs:has([data-tab]) { gap: .2rem; }
  .tabs:has([data-tab]) button { font-size: 0; padding-inline: 0; }
  .tabs:has([data-tab]) button i { font-size: 1.25rem; }
  .tabs:has([data-tab]) button.on { flex: 2.2; font-size: .68rem; }
  .tabs:has([data-tab]) button.on i { font-size: 1rem; }
}

/* --- Notizen des DM -------------------------------------------------------- */
.notes-layout { display: grid; gap: 1rem; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); align-items: start; }
.notes-side { display: grid; gap: .6rem; position: sticky; top: calc(var(--top, 60px) + 4rem); }
.notes-toc { display: grid; gap: .7rem; max-height: calc(100vh - var(--top, 60px) - 14rem); overflow-y: auto; }
.toc-chapter { display: grid; gap: .15rem; }
.toc-chapter-head { display: flex; align-items: center; gap: .3rem; font-size: .85rem; color: var(--accent); }
.toc-chapter-head b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc-tools { display: flex; gap: .1rem; opacity: .55; }
.toc-chapter:hover .toc-tools, .toc-tools:focus-within { opacity: 1; }
.toc-tools button { min-height: 26px; padding: 0 .35rem; font-size: .75rem; }
.toc-page {
  text-align: left; background: none; border: 0; border-left: 2px solid var(--line); border-radius: 0;
  padding: .3rem .6rem; min-height: 34px; color: var(--text); font: inherit; cursor: pointer;
}
.toc-page:hover { background: var(--panel-2); }
.toc-page.current { border-left-color: var(--accent); background: var(--panel-2); color: var(--accent); font-weight: 600; }
.notes-page { min-width: 0; }
.notes-empty { padding: 2rem 1rem; max-width: 40rem; }
.note-view { display: grid; gap: .8rem; }
.note-view-head { display: flex; align-items: flex-start; gap: .6rem; flex-wrap: wrap; }
.note-title { flex: 1; min-width: 12rem; }
.note-title h2 { font-size: 1.5rem; margin: .15rem 0 0; color: var(--text); }
.notes-back { display: none; }
.note-body { font-size: 1.02rem; line-height: 1.6; max-width: 48rem; }
.note-body h3 { font-size: 1.25rem; margin: 1.2rem 0 .3rem; color: var(--accent); }
.note-body h4 { font-size: 1.08rem; margin: 1rem 0 .25rem; }
.note-body h5 { font-size: .95rem; margin: .8rem 0 .2rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.note-body ol { margin: .3rem 0; padding-left: 1.6rem; }
.note-body li + li { margin-top: .15rem; }
.note-body hr { border: 0; border-top: 1px solid var(--line); margin: 1.2rem 0; }
.note-body s { color: var(--muted); }
.note-body mark { background: rgba(212, 162, 76, .32); color: inherit; padding: 0 .15em; border-radius: 3px; }
.note-read, .note-callout { margin: .7rem 0; padding: .7rem 1rem; border-radius: 8px; }
.note-read > b, .note-callout > b { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; margin-bottom: .25rem; }
.note-read { background: #2f2719; border-left: 4px solid var(--accent); font-family: Georgia, "Times New Roman", serif; font-style: italic; }
.note-read > b { color: var(--accent); font-family: inherit; font-style: normal; }
.note-callout { background: rgba(200, 85, 61, .12); border-left: 4px solid var(--danger); }
.note-callout > b { color: var(--danger); }
.note-checks { list-style: none; padding-left: .1rem; margin: .3rem 0; }
.note-checks label { display: flex; align-items: flex-start; gap: .5rem; cursor: pointer; font-size: inherit; color: var(--text); text-transform: none; letter-spacing: normal; }
.note-checks input { width: 1.1rem; height: 1.1rem; min-height: 0; margin: .3rem 0 0; accent-color: var(--accent); flex: none; }
.note-checks li.done span { color: var(--muted); text-decoration: line-through; }
.note-table { overflow-x: auto; margin: .6rem 0; }
.note-table table { border-collapse: collapse; min-width: 50%; font-size: .95rem; }
.note-table th, .note-table td { border: 1px solid var(--line); padding: .3rem .6rem; text-align: left; vertical-align: top; }
.note-table th { background: var(--panel-2); color: var(--accent); }
.note-table tbody tr:nth-child(even) { background: rgba(255, 255, 255, .025); }
.note-tools {
  display: flex; flex-wrap: wrap; align-items: center; gap: .2rem; padding: .3rem;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  position: sticky; top: calc(var(--top, 60px) + .3rem); z-index: 2;
}
@media (min-width: 900px) {
  .note-tools { top: calc(var(--top, 60px) + 3.6rem); }
}
.note-tools button { min-height: 32px; padding: 0 .55rem; font-size: .85rem; }
.note-tools button mark { background: rgba(212, 162, 76, .45); color: inherit; padding: 0 .2em; }
.note-tools-gap { width: 1px; align-self: stretch; background: var(--line); margin: .15rem .2rem; }
.note-help summary { cursor: pointer; }
.note-help code { background: var(--panel-2); padding: 0 .3em; border-radius: 4px; color: var(--text); }
.note-link { background: none; border: 0; padding: 0; min-height: 0; color: var(--accent); text-decoration: underline; font: inherit; cursor: pointer; }
.note-link.missing { color: var(--muted); text-decoration: underline dotted; cursor: help; }
.note-empty-page { width: 100%; min-height: 6rem; border-style: dashed; color: var(--muted); }
.note-view-foot { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: .5rem; }
.danger-text { color: var(--danger); margin-left: auto; }
#note-form { display: grid; gap: .6rem; }
.note-form-head { display: grid; grid-template-columns: 2fr 1fr; gap: .6rem; }
.note-text { min-height: 60vh; font-size: 1rem; line-height: 1.55; resize: vertical; }
.note-form-foot { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
@media (max-width: 899px) {
  .notes-layout { grid-template-columns: minmax(0, 1fr); }
  .notes-side { position: static; }
  .notes-toc { max-height: none; }
  #notes.reading .notes-side { display: none; }
  #notes:not(.reading) .notes-page { display: none; }
  .notes-back { display: inline-flex; }
  .note-form-head { grid-template-columns: 1fr; }
  .toc-tools { opacity: 1; }
}

/* --- Kreaturen-Liste ----------------------------------------------------- */
.list { display: grid; gap: .5rem; }
.creature {
  display: grid; grid-template-columns: auto 1fr auto; gap: .75rem; align-items: center;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: .6rem .75rem; cursor: pointer; text-align: left; width: 100%;
}
.creature.noinit { grid-template-columns: 1fr auto; }
.creature.current { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.creature.down { opacity: .55; }
.creature.secret { border-style: dashed; }
.creature.me { background: #33291d; }
.init {
  width: 2.6rem; height: 2.6rem; border-radius: 50%; display: grid; place-items: center;
  background: var(--bg); font-weight: 700; font-variant-numeric: tabular-nums;
}
.current .init { background: var(--accent); color: var(--accent-text); }
.cname { font-weight: 600; display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.kind { font-size: .7rem; padding: .05rem .4rem; border-radius: 6px; background: var(--bg); color: var(--muted); font-weight: 500; }
.stats { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stats .ac { color: var(--muted); font-size: .85rem; }
.hp-quick {
  min-height: 0; padding: .15rem .45rem; margin-right: -.45rem; border-radius: 8px;
  background: transparent; border: 1px dashed transparent; font-variant-numeric: tabular-nums;
}
.hp-quick:hover, .hp-quick.on { border-color: var(--accent); background: rgba(212, 162, 76, .1); }
.hp-quick-box {
  grid-column: 1 / -1; display: grid; grid-template-columns: minmax(4.5rem, 1fr) auto auto auto; gap: .4rem;
  cursor: default;
}
.hp-quick-box input { text-align: center; font-size: 1.1rem; }
.hp-quick-box button { padding: .45rem .7rem; }
@media (max-width: 420px) {
  .hp-quick-box { grid-template-columns: 1fr 1fr auto; }
  .hp-quick-box input { grid-column: 1 / -1; }
}
.chips { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .3rem; }
.chip { font-size: .75rem; padding: .1rem .5rem; border-radius: 99px; background: #4a3426; color: #f1cdb5; border: none; min-height: 0; }
.chip.conc { background: #27405a; color: #cfe3f5; }
.chip.exh { background: #54351f; }
.health { font-size: .85rem; }
.health.unverletzt { color: var(--ok); }
.health.angeschlagen { color: var(--accent); }
.health.schwer { color: var(--danger); }
.health.besiegt { color: var(--muted); }

.hpbar { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; margin-top: .35rem; display: flex; }
.hpbar > span { display: block; height: 100%; background: var(--ok); }
.hpbar > span.mid { background: var(--accent); }
.hpbar > span.low { background: var(--danger); }
.hpbar > span.temp { background: var(--info); }

.combat-bar { display: flex; gap: .5rem; align-items: center; }
.combat-bar .round { flex: 1; text-align: center; font-weight: 600; }
.combat-bar button { flex: 0 0 auto; }
.combat-bar button.next { flex: 1 1 40%; font-size: 1.1rem; }

/* --- Bottom Sheet -------------------------------------------------------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 20; }
.sheet {
  position: fixed; z-index: 21; left: 50%; top: 64px; transform: translateX(-50%);
  width: min(640px, calc(100% - 16px)); max-height: calc(100dvh - 76px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; box-shadow: 0 12px 40px rgba(0, 0, 0, .55);
  padding: 0 1rem 1rem;
  display: grid; gap: 1rem;
}
.sheet-head {
  display: flex; align-items: center; gap: .5rem;
  position: sticky; top: 0; z-index: 1; margin: 0 -1rem; padding: .75rem 1rem .5rem;
  background: var(--panel); cursor: grab; touch-action: none; user-select: none;
}
.sheet-head:active { cursor: grabbing; }
.grip { color: var(--muted); font-size: 1.2rem; line-height: 1; }
.sheet-head h3 { flex: 1; font-size: 1.25rem; }
.hp-big { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.hp-big small { font-size: 1rem; color: var(--muted); font-weight: 400; }
.hp-input { display: grid; grid-template-columns: 1fr repeat(3, auto); gap: .5rem; }
.hp-input input { font-size: 1.3rem; text-align: center; }
.cond-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .4rem; }
.cond-grid button { font-size: .9rem; padding: .4rem .5rem; }
.cond-grid button small { display: block; font-size: .7rem; opacity: .8; }
.stepper { display: flex; align-items: center; gap: .5rem; }
.stepper b { min-width: 2ch; text-align: center; font-size: 1.2rem; }
.section-title { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .4rem; }

/* --- Welt ---------------------------------------------------------------- */
.clock { font-size: 2.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.clock small { font-size: 1rem; color: var(--muted); font-weight: 400; margin-left: .4rem; }
.seg { display: flex; gap: .4rem; flex-wrap: wrap; }
.seg button { flex: 1 1 auto; }

/* --- QR + Toast ---------------------------------------------------------- */
.qr { background: #fff; border-radius: 12px; padding: .5rem; width: min(320px, 80vw); justify-self: center; }
.link-box { word-break: break-all; font-size: .85rem; color: var(--muted); }
.toast {
  position: fixed; left: 50%; bottom: calc(1.25rem + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  background: var(--panel-2); border: 1px solid var(--accent); border-radius: 12px;
  padding: .75rem 1rem; max-width: min(90vw, 520px); box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
}
.toast.error { border-color: var(--danger); }

/* --- Spieleransicht ------------------------------------------------------ */
.layout.player { max-width: 720px; }
.turn-card { text-align: center; padding: 1.25rem 1rem; }
.turn-card .who { font-size: 2rem; font-weight: 700; }
.turn-card.mine { background: #4a3714; border-color: var(--accent); }
.turn-card.mine .who { color: var(--accent); }
.mood { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; text-align: center; }
.mood > div { flex: 1 1 120px; }
.mood .big { font-size: 1.6rem; font-weight: 700; }

html.table, html.table body { font-size: 22px; }
html.table .layout.player { max-width: 1100px; }

.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .12em; color: var(--accent); font-weight: 600; }

/* --- Stimmungshintergrund ----------------------------------------------- */
body.ambient { background: transparent; }
.ambience { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.ambience > * { position: absolute; inset: 0; width: 100%; height: 100%; }
.ambience .sky { background: var(--bg); }
.ambience .shade { background: #000; opacity: 0; transition: opacity 2s ease; }
.ambience .flash { background: #dfe6ff; opacity: 0; mix-blend-mode: screen; }
/* Wetter vor den Inhalten: unter Dialogen (z 20), über Kopfleiste (z 10) */
.ambience-front, .ambience-flash { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 15; }
.ambience-flash { background: #dfe6ff; opacity: 0; mix-blend-mode: screen; }
@media print { .ambience-front, .ambience-flash { display: none; } }
body.ambient .panel { background: rgba(34, 29, 23, .74); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
body.ambient .creature { background: rgba(44, 37, 29, .82); }
body.ambient .topbar { background: rgba(22, 19, 15, .7); }

/* --- Hilfen ------------------------------------------------------------- */
abbr.tip {
  text-decoration: underline dotted; text-decoration-color: rgba(168, 154, 133, .75);
  text-underline-offset: 2px; cursor: help;
}
label.check, span.check {
  display: flex; flex-direction: row; align-items: center; gap: .5rem; font-size: .9rem; color: var(--text);
}
label.check input, span.check input { width: 1.25rem; height: 1.25rem; min-height: 0; accent-color: var(--accent); flex: none; }
.grid-form .wide-all { grid-column: 1 / -1; }
.rich p { margin: .3rem 0; }
.rich ul { margin: .3rem 0; padding-left: 1.2rem; }
.rich > :first-child { margin-top: 0; }
.rich > :last-child { margin-bottom: 0; }
.rich img.rich-img { display: block; max-width: 100%; max-height: 60vh; margin: .3rem 0; border-radius: 8px; }

/* --- Charakterbogen ----------------------------------------------------- */
.charcard { display: grid; gap: .6rem; }
.charcard .hpbar { margin-top: 0; }
.cc-head { display: flex; justify-content: space-between; align-items: start; gap: .5rem; }
.cc-head .cname { font-size: 1.15rem; }
.cc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; }
.cc-stats > div { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: .3rem .4rem; text-align: center; }
.cc-stats small { display: block; color: var(--muted); font-size: .72rem; }
.abilities { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .3rem; }
.ability { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; text-align: center; padding: .3rem .1rem; }
.ability.save { border-color: rgba(212, 162, 76, .7); }
.ab-name { font-size: .72rem; color: var(--muted); }
.ab-mod { font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ab-score { font-size: .75rem; color: var(--muted); }
.sheet-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .75rem; }
.skills { display: grid; gap: .1rem; }
.skill { display: flex; justify-content: space-between; gap: .5rem; font-size: .85rem; padding: .12rem .35rem; border-radius: 6px; }
.skill.prof { background: rgba(212, 162, 76, .13); }
.skill b { font-variant-numeric: tabular-nums; }
.ab-save { font-size: .68rem; color: var(--muted); margin-top: .15rem; white-space: nowrap; }
.ability.save .ab-save { color: var(--accent); }
.charcard.compact .cc-stats { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .25rem; }
.charcard.compact .cc-stats > div { padding: .25rem .1rem; font-size: .9rem; }
.charcard.compact .cc-stats small { font-size: .65rem; }
.skills.two { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: .3rem; }
.skills.two .skill { font-size: .78rem; padding: .1rem .3rem; }
.skills.two .skill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.charsheet-box[open] { display: grid; gap: .6rem; }
.charsheet-box > summary { margin-bottom: .2rem; }

/* --- Spieleransicht: eigener Charakter ---------------------------------- */
.me-strip {
  position: sticky; top: var(--top, 60px); z-index: 9;
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .2rem .75rem;
  width: 100%; text-align: left; min-height: 0;
  padding: .45rem 1rem; border-radius: 0; border-width: 0 0 1px;
  background: rgba(44, 37, 29, .96);
}
.me-strip:active { transform: none; }
.ms-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-stats { display: flex; gap: .7rem; font-size: .9rem; font-variant-numeric: tabular-nums; }
.ms-stats small { color: var(--muted); }
.ms-stats em { color: var(--info); font-style: normal; }
.me-strip .hpbar, .ms-cond { grid-column: 1 / -1; }
.me-strip .hpbar { margin-top: 0; }
.ms-cond { font-size: .8rem; color: #f1cdb5; }

.layout.player > [class*="ptab-"] { display: none; }
.layout.player[data-ptab="tisch"] > .ptab-tisch,
.layout.player[data-ptab="chronik"] > .ptab-chronik,
.layout.player[data-ptab="items"] > .ptab-items,
.layout.player[data-ptab="ich"] > .ptab-ich { display: grid; }

@media (min-width: 900px) {
  .me-strip, .me-side.hidden { display: none !important; }
  .player-wrap.with-side {
    display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 1rem;
    max-width: 1200px; margin: 0 auto; padding: 1rem;
  }
  .player-wrap.with-side .layout.player { padding: 0; margin: 0; max-width: none; }
  .me-side {
    position: sticky; top: calc(var(--top, 60px) + 70px); align-self: start;
    max-height: calc(100dvh - var(--top, 60px) - 86px); overflow-y: auto;
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem;
  }
  .ptabs { max-width: none; }
}
@media (max-width: 899px) {
  .me-side { display: none !important; }
}
html.table .ptabs, html.table .me-strip, html.table .me-side { display: none !important; }

/* --- Karten -------------------------------------------------------------- */
.map-stage {
  position: relative; height: min(65vh, 820px); min-height: 240px;
  background: #0c0a08; border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  touch-action: none;
}
.map-stage > canvas { position: absolute; inset: 0; display: block; touch-action: none; }
.map-toolbar { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-bottom: .5rem; }
.map-toolbar .tools { flex: 1 1 auto; }
.map-toolbar .tools button { display: flex; gap: .35rem; align-items: center; justify-content: center; }
.map-toolbar .tools button span { font-size: .8rem; }
.brush { display: flex; flex-direction: row; align-items: center; gap: .4rem; }
.brush input { width: 110px; min-height: 0; padding: 0; accent-color: var(--accent); }
.map-status { margin: .4rem 0; }
#map-editor:not(.hidden) { display: grid; gap: .5rem; }
@media (max-width: 700px) {
  .map-toolbar .tools button span { display: none; }
}
.map-full {
  position: fixed !important; inset: 0; z-index: 25; border-radius: 0 !important; max-width: none;
  overflow-y: auto; display: grid !important; align-content: start;
  background: var(--panel) !important;
}
.map-full .map-stage { height: calc(100dvh - 190px); }
.map-panel .map-stage { height: auto; max-height: 72vh; min-height: 0; min-width: 0; width: 100%; }
.map-panel.map-full .map-stage { height: calc(100dvh - 80px); max-height: none; }
.map-panel:fullscreen { padding: 1rem; }

html.table .layout.player.has-map { max-width: none; grid-template-columns: minmax(0, 1fr) minmax(320px, 30%); }
html.table .layout.player.has-map > .map-panel { grid-column: 1; grid-row: 1 / span 8; }
html.table .layout.player.has-map > :not(.map-panel) { grid-column: 2; }
html.table .map-panel .map-stage { height: calc(100dvh - 11rem); max-height: none; }

/* --- Chronik und Protokoll ------------------------------------------------ */
.session-nav { display: flex; align-items: center; gap: .5rem; }
.session-title { flex: 1; text-align: center; font-weight: 700; font-size: 1.1rem; }
.session-title small { display: block; font-weight: 400; font-size: .8rem; color: var(--muted); }
.chron-list { display: grid; gap: .6rem; }
.row-buttons { display: flex; gap: .4rem; flex-wrap: wrap; }
/* Zeitstrahl: Uhrzeit links, Linie mit Punkten, Eintrag rechts */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; display: grid; gap: .6rem; }
.timeline::before {
  content: ""; position: absolute; top: .4rem; bottom: .4rem; left: calc(4.6rem + .55rem);
  width: 2px; background: var(--line);
}
.tl-item { display: grid; grid-template-columns: 4.6rem 1fr; gap: 1.1rem; align-items: start; position: relative; }
.tl-item::before {
  content: ""; position: absolute; left: calc(4.6rem + .55rem - 5px); top: .85rem; width: 12px; height: 12px;
  border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--panel);
}
.tl-item:has(.secret)::before { background: var(--muted); }
.tl-time { text-align: right; padding-top: .55rem; line-height: 1.2; }
.tl-time b { display: block; font-variant-numeric: tabular-nums; }
.tl-time small { font-size: .7rem; color: var(--muted); }
.tl-day, .tl-session {
  position: relative; z-index: 1; justify-self: start; margin-left: calc(4.6rem + .55rem - 1.6rem);
  display: flex; align-items: baseline; gap: .5rem;
}
.tl-day span {
  background: var(--panel-2); border: 1px solid var(--accent); color: var(--accent); border-radius: 999px;
  padding: .1rem .7rem; font-weight: 700; font-size: .85rem;
}
.tl-day small { color: var(--muted); font-size: .75rem; background: var(--panel); padding: 0 .3rem; }
.tl-session {
  margin-left: 0; margin-top: .6rem; font-weight: 700; font-size: 1.05rem; background: var(--panel);
  padding-right: .5rem; flex-direction: column; gap: 0;
}
.tl-session small { font-weight: 400; font-size: .75rem; color: var(--muted); }
.timeline > .tl-session:first-child { margin-top: 0; }
.tl-item .chron-entry, .tl-card { min-width: 0; }
/* Kommentare der Spieler: eingerückt unter dem Eintrag, wie Antworten */
.chron-comments {
  display: grid; gap: .35rem; margin: .35rem 0 0 1.1rem; padding-left: .7rem;
  border-left: 2px solid var(--line);
}
.comment { display: flex; gap: .1rem; align-items: flex-start; }
.comment .avatar { margin-top: .15rem; flex: none; }
.comment-body {
  flex: 1; min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: .3rem .6rem;
}
.comment.mine .comment-body { border-color: var(--accent); }
.comment.from-dm .comment-body { border-style: dashed; }
.comment-head { display: flex; gap: .45rem; align-items: baseline; flex-wrap: wrap; font-size: .85rem; }
.comment-head small { color: var(--muted); font-size: .72rem; }
.comment-tools { margin-left: auto; display: flex; gap: .2rem; }
.comment-tools button { min-height: 28px; padding: 0 .45rem; font-size: .8rem; }
.comment-form { display: grid; gap: .35rem; }
.comment-form textarea { width: 100%; }
.chron-comments .comment-add { justify-self: start; min-height: 32px; padding: .15rem .6rem; }
body.ambient .comment-body { background: rgba(44, 37, 29, .82); }
@media (max-width: 480px) {
  .timeline::before { left: calc(3.6rem + .45rem); }
  .tl-item { grid-template-columns: 3.6rem 1fr; gap: .9rem; }
  .tl-item::before { left: calc(3.6rem + .45rem - 5px); }
  .tl-day { margin-left: calc(3.6rem + .45rem - 1.6rem); }
  .tl-time small { font-size: .62rem; }
}
.chron-when { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
.chron-images > summary { cursor: pointer; color: var(--muted); font-size: .85rem; padding: .2rem 0; }
.chron-image-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: .4rem;
  max-height: 260px; overflow-y: auto; margin-top: .4rem;
}
.chron-image-grid button {
  display: grid; gap: .2rem; padding: .3rem; min-height: 0; text-align: left;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
}
.chron-image-grid img, .chron-image-grid i {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; display: grid; place-items: center;
  font-style: normal; font-size: 1.6rem; background: rgba(0, 0, 0, .25);
}
.chron-image-grid small { font-size: .7rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chron-entry {
  background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 10px; padding: .6rem .8rem;
}
#chronicle .chron-entry[data-chron-open] { cursor: pointer; }
.chron-entry.secret { border-style: dashed; border-left-color: var(--muted); }
.chron-entry h3 { font-size: 1rem; margin-bottom: .2rem; }
.chron-meta { display: flex; gap: .4rem; align-items: center; font-size: .75rem; color: var(--muted); }
.chron-session > summary { cursor: pointer; padding: .4rem 0; }
.chron-session[open] > summary { margin-bottom: .4rem; }
.log-list { display: grid; margin: .5rem 0; max-height: 55vh; overflow-y: auto; }
.log-row {
  display: grid; grid-template-columns: 3rem 1fr auto; gap: .5rem; align-items: center;
  font-size: .85rem; border-bottom: 1px solid var(--line); padding: .15rem 0;
}
.log-row button { min-height: 32px; padding: .1rem .55rem; }
body.ambient .chron-entry { background: rgba(44, 37, 29, .82); }

/* --- Übersicht (Admin): eigene Seiten für Kampagnen, Spieler, Bibliothek, Protokoll und Sicherung --- */
.layout.admin-pages { max-width: 1500px; }
.admin-page { display: none; gap: 1rem; align-items: start; min-width: 0; }
.admin-pages[data-page="kampagnen"] > [data-page="kampagnen"],
.admin-pages[data-page="spieler"] > [data-page="spieler"],
.admin-pages[data-page="bibliothek"] > [data-page="bibliothek"],
.admin-pages[data-page="system"] > [data-page="system"] { display: grid; }
.admin-col { display: grid; gap: 1rem; align-content: start; min-width: 0; }
.admin-tabs .m { display: inline; }
.admin-tabs .d { display: none; }
@media (min-width: 900px) {
  .admin-tabs { padding-inline: max(1rem, calc((100% - 1500px) / 2 + 1rem)); }
  .admin-tabs .m { display: none; }
  .admin-tabs .d { display: inline; }
  .new-campaign { grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 1rem; }
  .new-campaign h2 { margin: 0; }
  .admin-page[data-page="kampagnen"] .campaign-grid { grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); align-items: start; gap: 1rem; }
  .admin-page[data-page="spieler"] #player-list { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
  .admin-page[data-page="bibliothek"] { grid-template-columns: minmax(0, 1.8fr) minmax(300px, 1fr); }
  .admin-page[data-page="system"] { grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr); }
  /* rechte Spalte bleibt beim Scrollen stehen */
  .admin-page:is([data-page="bibliothek"], [data-page="system"]) > .admin-col:last-child { position: sticky; top: calc(var(--top, 0px) + 4.5rem); }
  .admin-page .lib-scroll { max-height: calc(100vh - var(--top, 0px) - 20rem); overflow-y: auto; }
  .admin-page .log-list { max-height: calc(100vh - var(--top, 0px) - 13rem); }
}

.campaign-rename input { font-size: 1.05rem; font-weight: 700; }

/* --- Spielerkonten (Übersicht) --------------------------------------------- */
#player-list { gap: .45rem; }
.player-row {
  display: grid; grid-template-columns: auto 1fr auto auto; gap: .8rem; align-items: center; width: 100%;
  text-align: left; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
  padding: .55rem .8rem; min-height: 64px; font: inherit; color: inherit; cursor: pointer;
}
.player-row:hover { border-color: var(--accent); }
.player-row .avatar { margin: 0; }
.player-row-main { display: grid; gap: .15rem; min-width: 0; }
.player-row-main b { font-size: 1.05rem; }
.player-row-tags { display: flex; gap: .3rem; flex-wrap: wrap; justify-content: flex-end; }
.player-sheet .section-title { margin-top: 1rem; }
.player-login { display: grid; grid-template-columns: auto 1fr; gap: 1rem; align-items: start; }
.player-login .qr { width: 160px; height: 160px; background: #fff; border-radius: 8px; padding: 6px; }
.player-login-text { display: grid; gap: .4rem; min-width: 0; }
.player-code { font-family: ui-monospace, monospace; font-size: 1.6rem; letter-spacing: .15em; color: var(--accent); font-weight: 700; }
@media (max-width: 520px) {
  .player-row { grid-template-columns: auto 1fr auto; }
  .player-row-tags { grid-column: 2; justify-content: flex-start; }
  .player-row > :last-child { grid-column: 3; grid-row: 1 / span 2; }
  .player-login { grid-template-columns: 1fr; justify-items: center; }
  .player-login-text { justify-items: stretch; width: 100%; }
}

/* --- Sicherung (Übersicht) ------------------------------------------------ */
.backup-row { display: grid; grid-template-columns: 1fr auto; gap: .5rem; align-items: center; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.backup-row .seg button, .backup-row .seg a.button { min-height: 36px; padding: .2rem .6rem; }
.admin-log .log-row { grid-template-columns: 3.2rem 1fr; }
.log-day { position: sticky; top: 0; background: var(--panel); font-size: .75rem; color: var(--accent); font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; padding: .6rem 0 .2rem; border-bottom: 1px solid var(--line); }
.admin-log .panel-head { display: grid; grid-template-columns: 1fr; }
.log-filters { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.log-filters select { min-height: 38px; padding: .3rem .5rem; font-size: .85rem; }

/* Kampagnenkarten: Gruppe als Köpfe, Codes nur unter „Verwalten“ */
.party-faces { display: flex; flex-wrap: wrap; gap: .35rem .5rem; }
.party-faces .face { display: inline-flex; align-items: center; background: var(--bg); border: 1px solid var(--line);
  border-radius: 999px; padding: .15rem .65rem .15rem .2rem; font-size: .85rem; }
.party-faces .avatar.sm { width: 1.9rem; height: 1.9rem; font-size: .8rem; }
.code-list { display: grid; grid-template-columns: 1fr auto; gap: .2rem .75rem; font-size: .9rem; }

/* System: Zustand des Servers */
.sys-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.sys-tile { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: .55rem .7rem; display: grid; gap: .1rem; }
.sys-tile b { font-size: 1.05rem; }
.sys-tile.warn { border-color: var(--danger); }
.sys-tile.warn b { color: var(--danger); }
.sys-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.sys-actions > .button, .sys-actions > button { justify-content: center; text-align: center; }
.sys-actions > label { grid-column: 1 / -1; }
.sys-srd { margin: 0; padding-left: 1.1rem; display: grid; gap: .3rem; }
@media (max-width: 899px) {
  .toast { bottom: calc(5rem + env(safe-area-inset-bottom)); }
  html.table .toast { bottom: 1.25rem; }
}

/* --- Zauberplätze und Inventar ------------------------------------------ */
.slots { display: grid; gap: .25rem; margin-top: .3rem; }
.slot-row { display: grid; grid-template-columns: 6.5rem 1fr auto; gap: .5rem; align-items: center; font-size: .85rem; }
.pips { display: flex; flex-wrap: wrap; gap: .3rem; }
button.pip {
  width: 26px; height: 26px; min-height: 0; padding: 0; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--accent);
}
button.pip.used { background: transparent; border-color: var(--line); }
button.coins { width: 100%; text-align: left; min-height: 36px; padding: .3rem .6rem; font-size: .9rem; }
button.coins:disabled { opacity: 1; }
.inv { display: grid; gap: .2rem; margin: .4rem 0; }
.inv-row { padding: .3rem .5rem; border-radius: 8px; background: var(--panel-2); font-size: .9rem; }
.inv-row[data-inv-open] { cursor: pointer; }
.inv-row .kind { margin-left: .3rem; }

/* --- Gruppenübersicht ---------------------------------------------------- */
.small-seg button { min-height: 34px; padding: .2rem .7rem; font-size: .85rem; }
.party-table { overflow-x: auto; margin: 0 -.25rem; }
.party-table table { border-collapse: collapse; width: 100%; font-size: .88rem; font-variant-numeric: tabular-nums; }
.party-table th, .party-table td { padding: .3rem .45rem; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
.party-table tbody th { text-align: left; font-weight: 400; color: var(--muted); position: sticky; left: 0; background: var(--panel); }
.party-table thead th.pc { cursor: pointer; color: var(--accent); font-size: .95rem; vertical-align: bottom; }
.party-table thead th small { display: block; color: var(--muted); font-weight: 400; font-size: .72rem; max-width: 6.5rem; overflow: hidden; text-overflow: ellipsis; margin: 0 auto; }
.party-table tr.sep > * { border-top: 2px solid var(--line); }
.party-table .prof { color: var(--accent); font-weight: 600; }
.party-table .warn { color: var(--accent); }
.party-table .bad { color: var(--danger); }
.party-table td:nth-child(even) { background: rgba(255, 255, 255, .025); }
body.ambient .party-table tbody th { background: rgba(34, 29, 23, .95); }
@media (max-width: 599px) {
  .party-table table { font-size: .8rem; }
  .party-table th, .party-table td { padding: .25rem .3rem; }
  .party-table thead th small { max-width: 4.2rem; }
}

/* --- Spielerkonto -------------------------------------------------------- */
a.char-link { color: inherit; text-decoration: none; }
a.char-link:active { transform: scale(.99); }
a.char-link h2 { font-size: 1.2rem; }
a.char-link .panel-head { flex-wrap: nowrap; justify-content: flex-start; gap: .8rem; }
a.char-link .char-link-name { flex: 1; min-width: 0; }
a.char-link .release { justify-self: start; min-height: 34px; padding: .2rem .6rem; font-size: .8rem; }
.account-pick { font-size: .85rem; }
.lead { display: grid; gap: .35rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.lead:last-child { border-bottom: 0; }

/* --- TV-Modus (Hauptdisplay) ------------------------------------------- */
html.tv, html.tv body { height: 100%; overflow: hidden; }
html.tv body { display: grid; grid-template-rows: auto minmax(0, 1fr); font-size: clamp(16px, 1.25vw, 26px); }
.tv-bar {
  display: flex; align-items: center; gap: 1.2rem; padding: .5rem 1.2rem;
  background: rgba(22, 19, 15, .78); border-bottom: 1px solid var(--line); backdrop-filter: blur(6px);
}
.tv-bar h1 { font-size: 1.25rem; flex: 0 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-world { flex: 1; display: flex; justify-content: flex-end; gap: 1.6rem; font-size: 1.15rem; color: var(--text); white-space: nowrap; }
.tv-world b { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.tv-bar button { min-height: 40px; }
@media (min-width: 900px) {
  .tv-bar { position: relative; }
  .tv-bar .brand { font-size: 1.35em; }
  .tv-bar h1, .tv-world { max-width: calc(50% - 13em); }
  .tv-world { margin-left: auto; }
}
body.idle, body.idle * { cursor: none !important; }
body.idle .tv-bar button { opacity: 0; }

.tv-main { display: grid; gap: 1rem; padding: 1rem; min-height: 0; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
.tv-main.with-map { grid-template-columns: minmax(0, 2.6fr) minmax(300px, 1fr); }
.tv-left, .tv-right { min-height: 0; display: flex; flex-direction: column; gap: 1rem; }
.tv-left > *, .tv-right > * {
  background: rgba(34, 29, 23, .8); border: 1px solid var(--line); border-radius: var(--radius); backdrop-filter: blur(6px);
}

.tv-map { flex: 1; position: relative; overflow: hidden; background: #0c0a08 !important; }
.tv-map > canvas { position: absolute; inset: 0; }

.tv-hero { flex: 1; display: grid; place-content: center; text-align: center; gap: .4em; padding: 1rem; }
.tv-hero.compact { flex: 0 0 auto; padding: .9rem 1rem; gap: .2em; }
.tv-round { color: var(--muted); font-size: 1.1em; }
.tv-label { color: var(--accent); text-transform: uppercase; letter-spacing: .12em; font-size: .85em; }
.tv-current { font-size: clamp(2.5rem, 6vw, 7rem); font-weight: 800; line-height: 1.05; color: var(--text); }
.tv-hero.compact .tv-current { font-size: clamp(1.8rem, 2.8vw, 3.4rem); }
.tv-hero-hp { width: min(420px, 70%); justify-self: center; }
.tv-next { color: var(--muted); font-size: 1.15em; }
.tv-next b { color: var(--text); }

.tv-list {
  flex: 1; min-height: 0; padding: .6rem; display: grid; gap: .4rem;
  align-content: start; overflow: hidden;
}
.tv-entry {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: .8em;
  padding: .25em .7em; border-radius: 10px; background: rgba(44, 37, 29, .85); border: 1px solid var(--line);
  min-height: 0; overflow: hidden;
}
.tv-entry.current { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; background: rgba(74, 55, 20, .9); }
.tv-entry.next { border-color: rgba(212, 162, 76, .45); }
.tv-entry.down { opacity: .5; }
.tv-name { font-weight: 700; font-size: 1.15em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-name .kind { font-size: .6em; vertical-align: middle; }
.tv-hp { font-variant-numeric: tabular-nums; font-size: 1.05em; }
.tv-hp em { color: var(--info); font-style: normal; }
.tv-entry .health { font-size: 1em; }
.tv-sub { grid-column: 1 / -1; display: flex; gap: .5em; align-items: center; min-width: 0; }
.tv-sub .hpbar { flex: 1; margin: 0; height: .35em; }
.tv-sub .chips { margin: 0; flex-wrap: nowrap; overflow: hidden; }
.tv-sub .chip { font-size: .7em; }

.tv-recap { flex: 1; min-height: 0; overflow: hidden; padding: 1rem 1.2rem; display: flex; flex-direction: column; gap: .7rem; }
.tv-recap article { border-left: 3px solid var(--accent); padding-left: .8rem; }
.tv-recap h3 { font-size: 1.1em; }
.tv-recap .rich { font-size: 1em; line-height: 1.45; }

@media (orientation: portrait) {
  .tv-main, .tv-main.with-map { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); }
  .tv-hero.compact .tv-round { display: none; }
  .tv-world { gap: .8rem; font-size: 1rem; }
}

/* --- NSC ---------------------------------------------------------------- */
.att { font-size: .7rem; padding: .05rem .45rem; border-radius: 6px; background: var(--bg); }
.att.freundlich { color: var(--ok); }
.att.feindlich { color: var(--danger); }
.att.misstrauisch { color: var(--accent); }
.npc-row.gone { opacity: .55; }
.npc-row .seg button { min-height: 36px; padding: .2rem .6rem; }
.creature.companion { border-left: 3px solid var(--info); }

/* --- Inventar ------------------------------------------------------------ */
.inventory { display: grid; gap: .7rem; }
.coin-bar {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: .3rem; padding: .35rem; min-height: 0;
  background: var(--bg); border-radius: 12px; width: 100%;
}
.coin-bar:disabled { opacity: 1; }
.coin { display: grid; text-align: center; padding: .2rem 0; border-radius: 8px; background: var(--panel-2); }
.coin small { font-size: .65rem; color: var(--muted); letter-spacing: .08em; }
.coin b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.coin.gm b { color: #e8c45a; } .coin.pm b { color: #d9e2ea; } .coin.sm b { color: #c9c9c9; }
.coin.km b { color: #c98a5a; } .coin.em b { color: #b8c98a; }
.coin.zero b { color: var(--muted); font-weight: 400; }
.inv-section { display: grid; gap: .25rem; }
.inv-section > summary { cursor: pointer; list-style: none; margin-bottom: .1rem; }
.inv-section > summary::-webkit-details-marker { display: none; }
.inv-section > summary::before { content: "▸ "; }
.inv-section[open] > summary::before { content: "▾ "; }
.attune-slots { color: var(--accent); letter-spacing: .1em; text-transform: none; }
.inv-item { display: flex; align-items: center; gap: .4rem; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: .15rem .25rem .15rem .1rem; }
.inv-name {
  flex: 1; min-width: 0; text-align: left; background: none; border: 0; min-height: 40px; padding: .2rem .5rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.inv-name:disabled { opacity: 1; }
.inv-icon { display: inline-block; width: 1.5em; text-align: center; color: var(--accent); }
.qty { display: flex; align-items: center; gap: .2rem; }
.qty button { min-height: 34px; min-width: 34px; padding: 0; border-radius: 8px; font-size: 1.1rem; }
.qty b { min-width: 2ch; text-align: center; font-variant-numeric: tabular-nums; }
.qty-only { padding-right: .5rem; color: var(--muted); }
.inv-summary { width: 100%; text-align: left; min-height: 40px; font-size: .9rem; padding: .4rem .7rem; background: var(--panel-2); border-radius: 10px; }
div.inv-summary { border: 1px solid var(--line); }
#collection > summary { cursor: pointer; }
.inventory-box[open] { display: grid; gap: .6rem; }

/* Anmeldung Kampagnen-Übersicht */
.login-panel { max-width: 26rem; width: 100%; margin: 2rem auto 0; }
.creature.clickable { cursor: pointer; }
.creature.clickable:hover { border-color: var(--accent); }
.readonly .pip { pointer-events: none; }

/* Charakterfotos */
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none; position: relative;
  width: 2.6rem; height: 2.6rem; border-radius: 50%; overflow: hidden; vertical-align: middle;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); font-weight: 700;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.sm { width: 1.7em; height: 1.7em; font-size: .8em; margin-right: .45em; border-width: 1px; }
.avatar.md { width: 2.4rem; height: 2.4rem; }
.avatar.lg { width: 3.6rem; height: 3.6rem; font-size: 1.3rem; }
.avatar.xl { width: 1.15em; height: 1.15em; margin-right: .25em; border: 3px solid var(--accent); font-size: 1em; }
.avatar.edit { padding: 0; cursor: pointer; }
.avatar.edit i {
  position: absolute; inset: auto 0 0 0; font-style: normal; font-size: .7rem; line-height: 1.2;
  background: rgba(0, 0, 0, .55); text-align: center; opacity: 0; transition: opacity .15s;
}
.avatar.edit:hover i, .avatar.edit.empty i { opacity: 1; }
.cc-head { display: flex; gap: .7rem; align-items: center; }
.cc-head .cc-title { flex: 1; min-width: 0; }
.portrait-row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.ms-name { display: flex; align-items: center; }

/* Zauberliste */
.spell-head { display: flex; justify-content: space-between; align-items: center; margin-top: .6rem; }
.spell-grade { margin-top: .35rem; }
.spell-row { display: flex; align-items: center; gap: .3rem; border-bottom: 1px solid var(--line); }
.spell-row .prep { background: none; border: 0; color: var(--accent); padding: .3rem .4rem; min-width: 0; font-size: 1rem; }
.spell-row .prep-dot { width: 1.8rem; }
.spell-row:not(.prepared) .spell-name { color: var(--muted); }
.spell-name { flex: 1; text-align: left; background: none; border: 0; padding: .4rem .2rem; color: var(--text); font: inherit; }
.spell-name:disabled, .spell-row .prep:disabled { cursor: default; opacity: 1; }
.spell-tag { font-size: .7rem; border: 1px solid var(--line); border-radius: 4px; padding: 0 .25rem; margin-left: .2rem; color: var(--muted); }
.spell-facts { display: grid; grid-template-columns: auto 1fr; gap: .15rem .8rem; margin: .3rem 0; font-size: .9rem; }
.spell-facts dt { color: var(--muted); }
.spell-facts dd { margin: 0; }
.cast-options { display: flex; flex-wrap: wrap; gap: .4rem; }
.spell-picks { max-height: 45vh; overflow: auto; }
.lib-scroll { max-height: 60vh; overflow: auto; }

/* Bilder für NSC und Monster */
.creature.noinit:has(> .avatar:first-child) { grid-template-columns: auto minmax(0, 1fr) auto; }
.creature.person { align-items: start; }
.portrait-editor { display: flex; gap: .9rem; align-items: center; }
.portrait-editor .avatar { width: 5.5rem; height: 5.5rem; font-size: 2rem; flex: none; }
.portrait-editor button.ghost { margin-top: .4rem; }

/* Hände und Rüstung */
.gear-slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .45rem; }
.gear-slot {
  display: grid; gap: .15rem; text-align: left; align-content: start; padding: .55rem .7rem; min-height: 4.6rem;
  background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 10px;
}
.gear-slot:disabled { opacity: 1; cursor: default; }
.gear-slot.empty { border-left-color: var(--line); border-style: dashed; }
.gear-slot small { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; }
.gear-hit b { color: var(--accent); }
.attacks { display: grid; gap: .25rem; }
.attack {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: .6rem; align-items: baseline;
  border-bottom: 1px solid var(--line); padding: .15rem 0;
}
.attack b { color: var(--accent); }
.pick-row {
  display: grid; gap: .1rem; text-align: left; padding: .5rem .7rem; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line);
}
.pick-row.on { border-color: var(--accent); }

/* Hintergrundmusik */
.music-chip { position: relative; margin-left: .25rem; }
.music-chip button[data-music-toggle] { min-width: 2.6rem; }
.music-chip.on button[data-music-toggle] { border-color: var(--accent); }
.music-chip .pulse { animation: music-pulse 1.4s ease-in-out infinite; border-color: var(--accent); }
@keyframes music-pulse { 50% { box-shadow: 0 0 0 4px rgba(214, 165, 80, .35); } }
.music-pop {
  position: absolute; right: 0; top: calc(100% + .4rem); z-index: 50; width: min(280px, 85vw);
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: .75rem;
  display: grid; gap: .5rem; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); font-size: .9rem;
}
.music-pop label { display: grid; gap: .25rem; }
.music-pop input[type="range"] { accent-color: var(--accent); width: 100%; }
.music-pop label.check { display: flex; }
.music-title { font-weight: 700; overflow-wrap: anywhere; }
.music-list { display: grid; gap: .35rem; margin-bottom: .5rem; }
.music-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: .4rem; align-items: center;
  border: 1px solid var(--line); border-radius: 10px; padding: .25rem .35rem; background: var(--panel-2);
}
.music-row.on { border-color: var(--accent); }
.music-row .music-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.music-tools { align-items: center; gap: .75rem; flex-wrap: wrap; }
.tv-bar .music-chip { margin-left: .5rem; }

/* Dateiablage */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem; }
.crumbs button.on { color: var(--accent); }
.files-tools { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.files-tools input { flex: 1 1 220px; }
.files-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .5rem; }
#files.drop-on, .file-tile.drop-on { outline: 2px dashed var(--accent); outline-offset: 3px; }
.files-empty { grid-column: 1 / -1; }
.file-tile {
  display: grid; gap: .2rem; justify-items: start; text-align: left; padding: .4rem; min-height: 0;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
}
.file-tile small { font-size: .7rem; overflow-wrap: anywhere; }
.file-tile.folder .file-thumb { background: transparent; }
.file-thumb {
  width: 100%; aspect-ratio: 4 / 3; border-radius: 7px; overflow: hidden; display: grid; place-items: center;
  background: rgba(0, 0, 0, .25);
}
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-thumb i { font-style: normal; font-size: 2rem; }
.file-name { font-weight: 600; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.file-sheet { display: grid; gap: .75rem; }
.file-sheet img.file-preview { max-width: 100%; max-height: 50vh; border-radius: 10px; display: block; margin: 0 auto; }
.file-sheet audio.file-preview { width: 100%; }
.file-sheet .kv { display: grid; grid-template-columns: auto 1fr; gap: .3rem .8rem; font-size: .9rem; }
.file-sheet label { display: grid; gap: .25rem; }
.pick-dialog {
  width: min(560px, calc(100vw - 32px)); max-height: 85vh; padding: .9rem; display: grid; gap: .6rem;
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px;
}
.pick-dialog:not([open]) { display: none; }
.pick-dialog::backdrop { background: rgba(0, 0, 0, .6); }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: .45rem; overflow: auto; max-height: 50vh; }
.pick-image { display: grid; gap: .2rem; padding: .3rem; min-height: 0; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; }
.pick-image img, .pick-image i { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; display: grid; place-items: center; font-style: normal; font-size: 1.8rem; }
.pick-image span { font-size: .72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.char-file > summary { cursor: pointer; padding: .3rem 0; }
.char-file .seg { margin-top: .4rem; display: grid; grid-template-columns: 1fr 1fr; }

/* --- Charakterbogen bearbeiten (eigene Seite) ----------------------------- */
.sheet-page {
  position: fixed; inset: 0; z-index: 30; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); scroll-padding-top: 120px;
}
.sp-bar {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: .75rem;
  padding: .6rem max(1rem, calc((100% - 960px) / 2)); background: var(--panel); border-bottom: 1px solid var(--line);
}
.sp-bar h2 { flex: 1; min-width: 0; font-size: 1.15rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-bar h2 small { font-size: .85rem; font-weight: 400; }
.sp-nav {
  position: sticky; top: 61px; z-index: 1; display: flex; gap: .4rem; overflow-x: auto; scrollbar-width: none;
  padding: .5rem max(1rem, calc((100% - 960px) / 2)); background: rgba(22, 19, 15, .92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.sp-nav::-webkit-scrollbar { display: none; }
.sp-nav a {
  flex: none; padding: .3rem .8rem; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); font-size: .85rem; text-decoration: none;
}
.sp-nav a:hover { color: var(--text); border-color: var(--accent); }
.sp-body { max-width: 960px; margin: 0 auto; padding: 1rem; display: grid; gap: 1rem; }
.sp-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 1rem 1.1rem 1.1rem;
  display: grid; gap: .8rem; align-content: start;
}
.sp-card h3 { font-size: 1.05rem; color: var(--accent); display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem .6rem; }
.sp-card h3 small { font-size: .8rem; font-weight: 400; color: var(--muted); }

.sp-hero { grid-template-columns: auto minmax(0, 1fr); gap: 1.2rem; align-items: start; }
.sp-portrait { display: grid; justify-items: center; gap: .4rem; }
.sp-portrait .avatar { width: 6.5rem; height: 6.5rem; font-size: 2.4rem; border: 3px solid var(--line); }
.sp-portrait button { min-height: 36px; padding: .3rem .7rem; font-size: .8rem; }
.sp-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; align-items: end; }
.sp-fields .sp-wide { grid-column: span 2; }
.sp-toggle {
  display: flex; align-items: center; gap: .5rem; min-height: 44px; padding: 0 .7rem; color: var(--text); font-size: .9rem;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); cursor: pointer;
}
.sp-toggle input { width: 1.1rem; min-height: 0; accent-color: var(--accent); }

.sp-abilities { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .6rem; }
.sp-ability {
  display: grid; justify-items: center; gap: .35rem; padding: .7rem .5rem .6rem;
  background: var(--bg); border: 1px solid var(--line); border-radius: 14px;
}
.sp-ab-label .short { display: none; }
.sp-ab-label { font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); text-align: center; }
.sp-ab-mod { font-size: 1.9rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.sp-ability input[type=number] { width: 4.2rem; text-align: center; padding: .35rem; min-height: 38px; font-size: 1rem; }
.sp-save {
  display: flex; align-items: center; gap: .35rem; padding: .2rem .55rem; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); color: var(--muted); font-size: .75rem;
}
.sp-save input { width: .95rem; min-height: 0; accent-color: var(--accent); }
.sp-save:has(input:checked) { border-color: var(--accent); color: var(--accent); background: rgba(212, 162, 76, .1); }
.sp-ability:has(.sp-save input:checked) { border-color: rgba(212, 162, 76, .55); }

.sp-skills { columns: 3 270px; column-gap: 1.4rem; }
.sp-skill-group { display: grid; gap: .15rem; break-inside: avoid; margin-bottom: .8rem; }
.sp-group-title { font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: .2rem 0; }
.sp-skill {
  display: grid; grid-template-columns: minmax(0, 1fr) 2.6rem auto; align-items: center; gap: .5rem;
  padding: .2rem .2rem .2rem .5rem; border-radius: 10px;
}
.sp-skill:has(input[value="1"]:checked), .sp-skill:has(input[value="2"]:checked) { background: rgba(212, 162, 76, .1); }
.sp-skill-name { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-live { font-variant-numeric: tabular-nums; text-align: right; }
.sp-pills { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--bg); }
.sp-pill { display: block; cursor: pointer; }
.sp-pill input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.sp-pill span { display: grid; place-items: center; width: 2.1rem; height: 1.9rem; color: var(--muted); font-size: .85rem; }
.sp-pill input:checked + span { background: var(--accent); color: var(--accent-text); font-weight: 700; }
.sp-pill input[value="0"]:checked + span { background: var(--panel-2); color: var(--text); font-weight: 400; }
.sp-pill input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }

.sp-inline { max-width: 280px; }
.sp-auto { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: .25rem 0 .5rem; }
.sp-slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: .5rem; }
.sp-slots input { text-align: center; }
.sp-pact { grid-template-columns: repeat(auto-fill, minmax(130px, 170px)); }
.sp-card textarea { width: 100%; }
.sp-file { display: flex; flex-wrap: wrap; gap: .5rem; }
.sp-hint { text-align: center; }
.sp-save-bottom { justify-self: center; min-width: 220px; }

@media (max-width: 700px) {
  .sp-hero { grid-template-columns: 1fr; }
  .sp-portrait { grid-auto-flow: column; justify-content: start; align-items: center; }
  .sp-portrait .avatar { width: 4.5rem; height: 4.5rem; font-size: 1.7rem; }
  .sp-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sp-abilities { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sp-ab-label .long { display: none; }
  .sp-ab-label .short { display: inline; }
  .sp-bar h2 small { display: none; }
  .sp-card { padding: .9rem; }
}

/* Beute: Pakete des DM, freigegebene Beute bei den Spielern */
.loot-dm { display: grid; gap: .5rem; margin-top: .5rem; }
.loot-title { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.loot-row .kind.on { background: var(--ok); color: #fff; }
.loot-template-view { display: grid; gap: .3rem; font-size: .9rem; }
.loot-template-view ul { margin: 0; padding-left: 1.2rem; }
.loot-requests { display: grid; gap: .35rem; padding: .5rem .6rem; border: 1px solid var(--accent); border-radius: 10px; }
.loot-request, .loot-item { display: flex; align-items: center; justify-content: space-between; gap: .5rem; min-height: 40px; }
.loot-request span:last-child, .loot-take { display: flex; align-items: center; gap: .35rem; }
.loot-box { display: grid; gap: .6rem; margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.loot-pack { display: grid; gap: .35rem; padding: .6rem .7rem; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--accent); }
.loot-head { display: flex; justify-content: space-between; align-items: center; }
.loot-coins { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.loot-coins .coin { min-width: 3.2rem; padding: .2rem .4rem; background: var(--bg); }
.loot-take input { width: 4.2rem; text-align: center; }
.give-row { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.give-row input[type=number] { width: 5rem; flex: 0 0 5rem; text-align: center; }
.give-row select, .give-row input[name=name] { flex: 1 1 9rem; min-width: 0; }
/* Händler */
.shop-pack { border-color: var(--info); }
.shop-item.out, .shop-ware.out { opacity: .55; }
.shop-item .loot-take { display: grid; grid-template-columns: auto 4.2rem auto; justify-items: end; }
.shop-cost { font-variant-numeric: tabular-nums; white-space: nowrap; color: #e8c45a; }
.shop-cost.short { color: var(--danger); }
.shop-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap;
  border-top: 1px solid var(--line); padding-top: .4rem; }
.shop-wares { gap: .2rem; }
.shop-ware { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; align-items: center; gap: .35rem;
  min-height: 40px; border-bottom: 1px solid var(--line); padding: .15rem 0; }
.shop-ware-name { min-width: 0; overflow-wrap: anywhere; }
.shop-price { min-height: 32px; padding: 0 .5rem; white-space: nowrap; font-variant-numeric: tabular-nums; color: #e8c45a; }
.shop-price.missing { color: var(--danger); border-style: dashed; }
.shop-add-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) 4.5rem auto; gap: .4rem; margin-top: .5rem; }
.shop-add-row input[type=number] { text-align: center; }
@media (max-width: 520px) {
  .shop-ware { grid-template-columns: minmax(0, 1fr) auto auto; }
  .shop-ware .shop-price { grid-column: 1; justify-self: start; }
  .shop-add-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
.loot-coins-form { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); }
.loot-coins-form input { text-align: center; }
.loot-coins-form button { grid-column: 1 / -1; }

/* Auswahldialog (z. B. beim Import) */
.choose-dialog { max-width: min(32rem, calc(100vw - 2rem)); background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; }
.choose-dialog::backdrop { background: rgba(0, 0, 0, .6); }
.choose-dialog p { margin: 0 0 1rem; line-height: 1.5; }
.choose-dialog .row-buttons { justify-content: flex-end; flex-wrap: wrap; }

.economy-toggle { margin-top: .6rem; color: var(--muted); }

/* Monster dieser Kampagne */
.lib-scope { margin-bottom: .4rem; }
.lib-pick { min-height: 34px; min-width: 34px; padding: 0; font-size: 1.15rem; color: var(--muted); }
.lib-pick.on { color: var(--accent); }

/* Reihen: Kampagnen, die nacheinander gespielt werden */
#campaigns { gap: 1.5rem; }
.campaign-grid { display: grid; gap: 1rem; }
.campaign-series { display: grid; gap: .6rem; padding: .8rem; border-radius: var(--radius);
  border: 1px solid var(--line); border-left: 4px solid var(--accent); background: rgba(212, 162, 76, .05); }
.series-head { display: flex; align-items: baseline; gap: .8rem; flex-wrap: wrap; }
.series-head h2 { margin: 0; font-size: 1.15rem; }
.series-track { display: flex; flex-direction: column; gap: .5rem; padding-bottom: .2rem; }
.series-step { display: grid; gap: .3rem; align-content: start; min-width: 0; }
.series-part { justify-self: start; font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--accent-text); background: var(--accent); border-radius: 999px; padding: .15rem .6rem; }
/* Pfeil vor jedem weiteren Teil: auf dem Handy ↓ darüber, breit → links daneben (nicht am Zeilenanfang) */
.series-step + .series-step::before { content: "↓"; justify-self: center; font-size: 1.8rem; line-height: 1; color: var(--accent); }
.series-singles { margin-top: .3rem; }
.series-form { grid-template-columns: minmax(0, 2fr) minmax(5rem, 1fr); }
@media (min-width: 900px) {
  .series-track { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem 2.4rem; align-items: start; }
  .series-step { position: relative; }
  .series-step + .series-step::before { content: "→"; position: absolute; left: -1.85rem; top: 6.5rem; }
  .series-step + .series-step:nth-child(2n+1)::before { content: none; }
}
@media (min-width: 1250px) {
  .series-track { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .series-step + .series-step:nth-child(2n+1)::before { content: "→"; }
  .series-step + .series-step:nth-child(3n+1)::before { content: none; }
}
.series-forward { justify-self: start; }
