@font-face { font-family: "Cinzel"; font-style: normal; font-weight: 400 900; font-display: swap; src: url(/assets/fonts/cinzel.woff2) format("woff2"); }
@font-face { font-family: "Crimson Pro"; font-style: normal; font-weight: 200 900; font-display: swap; src: url(/assets/fonts/crimson.woff2) format("woff2"); }
@font-face { font-family: "Crimson Pro"; font-style: italic; font-weight: 200 900; font-display: swap; src: url(/assets/fonts/crimson-italic.woff2) format("woff2"); }

/* Dark: Fackelschein im Gewölbe – warmes Schwarzbraun, Pergamentschrift, Gold & Blutrot */
:root {
  --bg: #120e0b;
  --bg2: #1c1611;
  --card: #231b14;
  --card2: #2e241a;
  --line: #4b3a27;
  --line-gold: #8a6a35;
  --text: #f0e3c6;
  --muted: #b39d7c;
  --accent: #d9aa4e;
  --accent2: #9c7428;
  --accent-ink: #1e1408;
  --crimson: #d4553f;
  --red: #e0604f;
  --green: #6cbf7f;
  --blue: #74a9de;
  --purple: #b08ee6;
  --grain: .07;
  --head-color: var(--accent);
  --radius: 10px;
  --tabbar: 62px;
  --top: 52px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font-head: "Cinzel", "Trajan Pro", Georgia, serif;
  --font-body: "Crimson Pro", var(--font-head);
  color-scheme: dark;
}
/* Light: Pergament wie im Regelbuch – Tinte, rote Überschriften */
:root[data-theme="light"] {
  --bg: #efe1bf;
  --bg2: #e6d5ad;
  --card: #f7ecd2;
  --card2: #ecdcb7;
  --line: #cdb383;
  --line-gold: #a8884f;
  --text: #2a1c11;
  --muted: #6d5841;
  --accent: #8e1f17;
  --accent2: #6b140e;
  --accent-ink: #fbf1da;
  --crimson: #8e1f17;
  --red: #b0281c;
  --green: #2f7d4a;
  --blue: #2c629e;
  --purple: #64439f;
  --grain: .12;
  --head-color: var(--crimson);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 var(--font-body);
  font-variant-numeric: lining-nums;
  overscroll-behavior-y: none;
}
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.2; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: .4rem 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
small, .muted { color: var(--muted); }
.serif { font-family: var(--font-head); }

/* ---------- layout */
#topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  height: calc(var(--top) + var(--safe-t)); padding: var(--safe-t) 8px 0;
  display: flex; align-items: center; gap: 4px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
#title { flex: 1; font-size: 1.1rem; margin: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--font-head); }
#topActions { display: flex; gap: 4px; }
#view {
  padding: calc(var(--top) + var(--safe-t) + 12px) 16px calc(var(--tabbar) + var(--safe-b) + 24px);
  max-width: 900px; margin: 0 auto; outline: none; min-height: 100%;
}
body.no-tabs #view { padding-bottom: 32px; }
#tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  height: calc(var(--tabbar) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; background: var(--bg2); border-top: 1px solid var(--line);
}
#tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 600;
}
#tabbar a .ti { font-size: 1.35rem; filter: grayscale(1) opacity(.7); }
#tabbar a.active { color: var(--accent); }
#tabbar a.active .ti { filter: none; }

/* ---------- controls */
button, .btn {
  font: inherit; color: var(--text); background: var(--card2); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 14px; min-height: 44px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none;
  touch-action: manipulation; user-select: none;
}
button:active, .btn:active { transform: scale(.97); }
button:disabled { opacity: .5; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent2); font-weight: 700; }
.btn-danger { color: var(--red); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { min-height: 34px; padding: 4px 10px; font-size: .9rem; border-radius: 8px; }
.btn-block { width: 100%; }
.icon-btn { background: transparent; border: 0; min-width: 44px; padding: 0 8px; font-size: 1.4rem; color: var(--text); }
#backBtn { font-size: 2rem; line-height: 1; padding-bottom: 4px; }
input, select, textarea {
  font: inherit; font-size: 16px; color: var(--text); background: var(--bg2);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; min-height: 44px;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stack > * + * { margin-top: 10px; }
.right { text-align: right; }
.center { text-align: center; }
.mt { margin-top: 14px; } .mb { margin-bottom: 14px; }

.seg { display: flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1; min-height: 36px; border: 0; background: transparent; padding: 4px 8px; font-size: .9rem; color: var(--muted); }
.seg button.on { background: var(--card2); color: var(--text); box-shadow: 0 1px 3px #0004; font-weight: 700; }
.seg button.on.adv { color: var(--green); } .seg button.on.dis { color: var(--red); }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border-radius: 999px; padding: 6px 12px; min-height: 34px; font-size: .88rem;
  background: var(--card); border: 1px solid var(--line); color: var(--muted);
}
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent2); font-weight: 700; }
.tag { display: inline-block; font-size: .72rem; padding: 2px 7px; border-radius: 6px; background: var(--card2); color: var(--muted); border: 1px solid var(--line); vertical-align: middle; }
.tag.c { color: var(--blue); border-color: color-mix(in srgb, var(--blue) 40%, transparent); }
.tag.r { color: var(--purple); border-color: color-mix(in srgb, var(--purple) 40%, transparent); }
.tag.h { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }

/* ---------- cards & lists */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card + .card { margin-top: 10px; }
.card h3 { display: flex; align-items: center; gap: 8px; }
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list > .item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 56px; border-top: 1px solid var(--line); text-decoration: none; color: inherit; cursor: pointer; }
.list > .item:first-child { border-top: 0; }
.list > .item:active { background: var(--card2); }
.item .t { font-weight: 600; }
.item .s { font-size: .85rem; color: var(--muted); }
.item .end { margin-left: auto; text-align: right; flex: none; }
.avatar { width: 44px; height: 44px; border-radius: 12px; flex: none; display: grid; place-items: center; font-size: 1.2rem; font-weight: 800; background: linear-gradient(135deg, var(--accent), var(--purple)); color: #fff; font-family: var(--font-head); }
.section-title { font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 20px 4px 8px; display: flex; align-items: center; gap: 8px; }
.section-title .end { margin-left: auto; text-transform: none; letter-spacing: 0; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.searchbar { position: sticky; top: calc(var(--top) + var(--safe-t)); z-index: 5; background: var(--bg); padding: 8px 0; margin: -8px 0 4px; }
.sheet-panel .searchbar { top: -6px; background: var(--card); margin: 0 -16px 4px; padding: 8px 16px; }
.searchbar input { padding-left: 38px; background: var(--bg2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%23999' stroke-width='2'%3E%3Ccircle cx='8' cy='8' r='6'/%3E%3Cpath d='m13 13 4 4'/%3E%3C/svg%3E") no-repeat 12px center; }

/* ---------- character sheet */
.hero { display: flex; gap: 12px; align-items: center; }
.hero .avatar { width: 56px; height: 56px; font-size: 1.6rem; }
.hero h2 { margin: 0; font-family: var(--font-head); }
.statbar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 4px; text-align: center; cursor: pointer; }
.stat .v { font-size: 1.35rem; font-weight: 800; }
.stat .l { font-size: .66rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.hpbox { margin-top: 10px; }
.hpbar { height: 10px; border-radius: 5px; background: var(--bg2); overflow: hidden; margin: 8px 0; border: 1px solid var(--line); }
.hpbar > div { height: 100%; background: var(--green); transition: width .3s; }
.hpbar > div.mid { background: var(--accent); } .hpbar > div.low { background: var(--red); }
.hpbar .tmp { background: var(--blue); }
.hpnum { font-size: 1.6rem; font-weight: 800; }
.abil { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (min-width: 560px) { .abil { grid-template-columns: repeat(6, 1fr); } .statbar { grid-template-columns: repeat(6, 1fr); } }
.abil .a { background: var(--card); border: 1px solid var(--line); border-radius: 12px; text-align: center; padding: 8px 4px 6px; cursor: pointer; }
.abil .a .n { font-size: .7rem; font-weight: 800; color: var(--muted); letter-spacing: .08em; }
.abil .a .m { font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.abil .a .sc { font-size: .8rem; color: var(--muted); border-top: 1px solid var(--line); margin-top: 4px; padding-top: 2px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; margin: 14px -16px 12px; padding: 0 16px; scrollbar-width: none; padding-top: 6px; padding-bottom: 6px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; min-height: 38px; border-radius: 999px; font-size: .9rem; padding: 4px 14px; background: transparent; color: var(--muted); }
.tabs button.on { background: var(--card2); color: var(--text); font-weight: 700; border-color: var(--accent2); }
.rollrow { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line); min-height: 48px; cursor: pointer; }
.rollrow:first-child { border-top: 0; }
.rollrow:active { background: var(--card2); }
.rollrow .bonus { min-width: 44px; text-align: center; font-weight: 800; background: var(--bg2); border-radius: 8px; padding: 4px 6px; border: 1px solid var(--line); }
.rollrow .name { flex: 1; }
.rollrow .ab { font-size: .75rem; color: var(--muted); }
.dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--muted); flex: none; }
.dot.p { background: var(--accent); border-color: var(--accent); }
.dot.e { background: var(--purple); border-color: var(--purple); box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--purple); }
.slots { display: flex; gap: 6px; flex-wrap: wrap; }
.slot { width: 30px; height: 30px; border-radius: 8px; border: 2px solid var(--purple); background: color-mix(in srgb, var(--purple) 30%, transparent); cursor: pointer; padding: 0; min-height: 0; }
.slot.used { background: transparent; border-style: dashed; opacity: .6; }
.pips { display: flex; gap: 6px; }
.pip { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); background: transparent; padding: 0; min-height: 0; }
.pip.s.on { background: var(--green); border-color: var(--green); }
.pip.f.on { background: var(--red); border-color: var(--red); }
.counter { display: flex; align-items: center; gap: 6px; }
.counter button { min-width: 44px; padding: 0; font-size: 1.2rem; font-weight: 700; }
.counter .val { min-width: 54px; text-align: center; font-weight: 800; font-size: 1.15rem; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: .92rem; }
.kv > :nth-child(odd) { color: var(--muted); }

/* ---------- spells */
.lvlhead { display: flex; align-items: center; gap: 8px; margin: 18px 2px 8px; }
.lvlhead h3 { margin: 0; font-size: 1rem; }
.lvlhead .slots { margin-left: auto; }
.spell-desc { white-space: pre-wrap; }
.md table { border-collapse: collapse; width: 100%; font-size: .88rem; margin: 8px 0; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; }
.md th { background: var(--card2); }
.md h1, .md h2, .md h3, .md h4 { margin-top: 1rem; font-family: var(--font-head); }
.md ul { padding-left: 1.2rem; }

/* ---------- dice */
.dice-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.die {
  aspect-ratio: 1; min-height: 0; min-width: 0; padding: 4px; flex-direction: column; gap: 0; border-radius: 16px; font-weight: 800;
  background: linear-gradient(160deg, var(--card2), var(--card)); position: relative;
}
.die .dn { font-size: 1.3rem; }
.die .dc { position: absolute; top: 6px; right: 8px; font-size: .75rem; color: var(--accent); }
.die svg { width: 34px; height: 34px; stroke: var(--accent); fill: none; stroke-width: 2.2; margin-bottom: 2px; }
.result {
  text-align: center; padding: 18px 12px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line);
  min-height: 130px; display: flex; flex-direction: column; justify-content: center;
}
.result .total { font-size: 3.4rem; font-weight: 900; line-height: 1; font-family: var(--font-head); }
.result .total.crit { color: var(--green); text-shadow: 0 0 18px color-mix(in srgb, var(--green) 60%, transparent); }
.result .total.fumble { color: var(--red); }
.result .label { color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.result .break { color: var(--muted); font-size: .9rem; margin-top: 6px; word-break: break-word; }
.roll-anim { animation: pop .35s ease-out; }
@keyframes pop { 0% { transform: scale(.6) rotate(-12deg); opacity: 0; } 70% { transform: scale(1.12) rotate(3deg); } 100% { transform: scale(1); opacity: 1; } }
.d-kept { color: var(--text); font-weight: 700; } .d-drop { text-decoration: line-through; opacity: .55; }
.d-max { color: var(--green); font-weight: 800; } .d-min { color: var(--red); font-weight: 800; }
.feed .item { align-items: flex-start; }
.feed .tot { font-size: 1.3rem; font-weight: 800; min-width: 40px; text-align: right; }

/* ---------- combat */
.combatant { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--line); }
.combatant:first-child { border-top: 0; }
.combatant.turn { background: color-mix(in srgb, var(--accent) 14%, transparent); box-shadow: inset 4px 0 0 var(--accent); }
.combatant.dead { opacity: .45; }
.combatant .init { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: 1.15rem; background: var(--bg2); border: 1px solid var(--line); flex: none; cursor: pointer; }
.combatant .pc { border-color: var(--blue); color: var(--blue); }
.combatant .hp { font-weight: 800; cursor: pointer; padding: 6px 10px; border-radius: 8px; background: var(--bg2); border: 1px solid var(--line); min-width: 64px; text-align: center; }

/* ---------- monster statblock */
.statblock { font-size: .93rem; }
.statblock .abil .a { cursor: default; }
.statblock h4 { color: var(--accent); border-bottom: 1px solid var(--accent2); padding-bottom: 2px; margin-top: 14px; font-family: var(--font-head); }
.statblock .act { margin: 6px 0; }
.statblock .act b { font-style: italic; }

/* ---------- bottom sheet */
.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop { position: absolute; inset: 0; background: #0009; animation: fade .2s; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; max-height: 92dvh; overflow-y: auto;
  background: var(--bg); border-radius: 20px 20px 0 0; border-top: 1px solid var(--line);
  padding: 6px 16px calc(20px + var(--safe-b)); animation: up .25s ease-out; overscroll-behavior: contain;
  max-width: 760px; margin: 0 auto;
}
.sheet-grip { width: 42px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 12px; }
.sheet-head { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.sheet-head h2 { flex: 1; margin: 6px 0 0; font-family: var(--font-head); }
@keyframes up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@media (min-width: 760px) { .sheet-panel { bottom: 50%; transform: translateY(50%); border-radius: 20px; animation: fade .2s; max-height: 86vh; border: 1px solid var(--line); } }

/* ---------- toasts */
#toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar) + var(--safe-b) + 10px); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; padding: 0 16px; }
.toast { background: var(--card2); border: 1px solid var(--line); color: var(--text); padding: 10px 16px; border-radius: 12px; box-shadow: 0 6px 20px #0006; animation: up .2s; pointer-events: auto; max-width: 100%; }
.toast.err { border-color: var(--red); }
.toast.roll { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.toast.roll .tot { font-size: 1.8rem; font-weight: 900; font-family: var(--font-head); }
.toast.roll .tot.crit { color: var(--green); } .toast.roll .tot.fumble { color: var(--red); }

/* ---------- auth */
.auth { max-width: 380px; margin: 8vh auto 0; }
.auth .logo { font-size: 3.5rem; text-align: center; }
.auth h1 { text-align: center; font-family: var(--font-head); }
.fab {
  position: fixed; right: 18px; bottom: calc(var(--tabbar) + var(--safe-b) + 16px); z-index: 15;
  width: 58px; height: 58px; border-radius: 50%; font-size: 1.8rem; padding: 0;
  background: var(--accent); color: var(--accent-ink); border: 0; box-shadow: 0 6px 18px #0007;
}
.wizard-steps { display: flex; gap: 4px; margin-bottom: 14px; }
.wizard-steps div { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.wizard-steps div.on { background: var(--accent); }
.pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.pick button { flex-direction: column; align-items: flex-start; text-align: left; min-height: 64px; }
.pick button.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 15%, var(--card2)); }
.pick button small { font-weight: 400; }
.sticky-actions { position: sticky; bottom: calc(var(--tabbar) + var(--safe-b) + 8px); display: flex; gap: 8px; margin-top: 16px; z-index: 3; }
body.no-tabs .sticky-actions { bottom: 12px; }
.sticky-actions > * { flex: 1; box-shadow: 0 4px 14px #0006; }
.inline-num { width: 70px; text-align: center; padding: 6px; min-height: 38px; }
.cond { display: flex; gap: 6px; flex-wrap: wrap; }
.cond .tag { font-size: .8rem; padding: 4px 8px; cursor: pointer; }
.cond .tag.on { color: var(--red); border-color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); }

/* ============================================================
   Fantasy-Look: Pergament, Zierlinien, Siegel, Prägung
   ============================================================ */
body {
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse at 50% -10%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 60%),
    radial-gradient(ellipse at 50% 120%, #0000, color-mix(in srgb, #000 22%, transparent) 75%);
  background-attachment: fixed;
}
/* Papierkorn über allem Hintergrund */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: var(--grain);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .25 0 0 0 0 .12 0 0 0 1.4 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
:root[data-theme="light"] body {
  background-image:
    radial-gradient(ellipse at 50% 40%, #fff6 0%, transparent 65%),
    radial-gradient(ellipse at 50% 50%, transparent 55%, #8a5a2433 100%);
}

h1, h2, h3, h4, #title, .hero h2, .sheet-head h2 { font-family: var(--font-head); font-weight: 700; letter-spacing: .02em; }
h2, h3, .sheet-head h2, .hero h2 { color: var(--head-color); }
#title { color: var(--accent); letter-spacing: .06em; font-size: 1.15rem; }
a { color: var(--accent); text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent); }

/* Kopf- und Tableiste: dunkles Leder mit Goldkante */
#topbar, #tabbar {
  background: linear-gradient(180deg, #2a1f15, #18120c);
  border-color: var(--line-gold);
}
#topbar { border-bottom: 1px solid var(--line-gold); box-shadow: 0 1px 0 #0006, 0 4px 14px #0005; }
#tabbar { border-top: 1px solid var(--line-gold); box-shadow: 0 -4px 14px #0005; }
#topbar #title, #topbar .icon-btn { color: #e8c374; }
#tabbar a { color: #a8916d; font-family: var(--font-head); font-size: .66rem; letter-spacing: .06em; text-transform: uppercase; }
#tabbar a.active { color: #f0c56a; text-shadow: 0 0 10px #f0c56a55; }
#tabbar a.active .ti { filter: drop-shadow(0 0 6px #f0c56a66); }

/* Karten & Listen: Pergament- bzw. Lederfläche mit feiner Doppelkante */
.card, .list, .result, .stat, .abil .a {
  background: linear-gradient(170deg, color-mix(in srgb, var(--card) 100%, #fff 3%), var(--card));
  border: 1px solid var(--line);
  box-shadow: inset 0 0 0 3px var(--card), inset 0 0 0 4px color-mix(in srgb, var(--line-gold) 35%, transparent), 0 2px 6px #0003;
}
:root[data-theme="light"] .card, :root[data-theme="light"] .list, :root[data-theme="light"] .result,
:root[data-theme="light"] .stat, :root[data-theme="light"] .abil .a { box-shadow: inset 0 0 0 3px var(--card), inset 0 0 0 4px #a8884f40, 0 1px 3px #6b4a1f26; }
.list > .item:active, .rollrow:active { background: color-mix(in srgb, var(--accent) 10%, var(--card)); }
.item .t { font-weight: 600; font-size: 1.05rem; }

/* Abschnittstitel mit Zierlinie */
.section-title {
  font-family: var(--font-head); color: var(--head-color); font-size: .8rem; letter-spacing: .12em; margin: 24px 2px 10px;
}
.section-title::before { content: "◆"; font-size: .55rem; opacity: .8; }
.section-title::after {
  content: ""; flex: 1; height: 2px; min-width: 20px;
  background: linear-gradient(90deg, var(--head-color), transparent);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}
.section-title .end { order: 3; font-family: var(--font-body); }
label.field > span { font-family: var(--font-head); font-size: .7rem; letter-spacing: .08em; color: var(--muted); }

/* Wachssiegel-Avatar */
.avatar {
  border-radius: 50%; font-family: var(--font-head); color: #f6dfa6; text-shadow: 0 1px 1px #0008;
  background: radial-gradient(circle at 35% 30%, #c2483a, #7d1a12 60%, #4a0c07);
  box-shadow: inset 0 0 0 2px #e0b35a99, inset 0 -3px 6px #0007, 0 2px 5px #0006;
}

/* Buttons: geprägt */
button, .btn { border-radius: 8px; box-shadow: inset 0 1px 0 #ffffff10, 0 1px 2px #0004; }
.btn-primary {
  font-family: var(--font-head); letter-spacing: .05em;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 100%, #fff 18%), var(--accent) 55%, var(--accent2));
  border-color: var(--accent2); text-shadow: 0 1px 0 #ffffff30;
  box-shadow: inset 0 1px 0 #ffffff45, inset 0 -2px 0 #0003, 0 2px 6px #0005;
}
:root[data-theme="light"] .btn-primary { text-shadow: 0 1px 0 #0004; }
.fab { background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--accent) 100%, #fff 25%), var(--accent) 55%, var(--accent2)); box-shadow: inset 0 0 0 2px #ffffff30, 0 6px 18px #0007; font-family: var(--font-head); }
.chip { font-family: var(--font-body); font-size: .95rem; }
.chip.on, .tabs button.on { font-family: var(--font-body); }
.tabs { background: transparent; }
.tabs button.on { background: var(--card2); border-color: var(--line-gold); color: var(--head-color); }
.searchbar { background: linear-gradient(var(--bg) 70%, transparent); }
input, select, textarea { border-radius: 8px; box-shadow: inset 0 1px 3px #0003; }

/* Werte im Bogen */
.stat .v, .abil .a .m, .hpnum, .counter .val, .rollrow .bonus, .combatant .init, .feed .tot {
  font-family: var(--font-head); font-variant-numeric: lining-nums tabular-nums;
}
.stat .l, .abil .a .n { font-family: var(--font-head); color: var(--head-color); }
.abil .a { border-radius: 10px 10px 40% 40% / 10px 10px 18% 18%; }
.result .total, .toast.roll .tot { font-family: var(--font-head); color: var(--accent); }
.die { border-radius: 12px; }
.die .dn { font-family: var(--font-head); }

/* Monster-Werteblock wie im Regelbuch: rote, spitz zulaufende Linien */
.statblock h4 {
  color: var(--crimson); border: 0; padding-bottom: 4px; position: relative; font-variant: small-caps; letter-spacing: .04em;
}
.statblock h4::after, .statblock .rule {
  content: ""; display: block; height: 3px; margin-top: 3px;
  background: linear-gradient(90deg, var(--crimson), color-mix(in srgb, var(--crimson) 30%, transparent));
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}
.statblock .act b { color: var(--text); }

/* Unterbögen & Hinweise */
.sheet-panel {
  background: linear-gradient(180deg, var(--card), var(--bg));
  border-top: 1px solid var(--line-gold);
}
.sheet-grip { background: var(--line-gold); }
.toast { font-family: var(--font-body); border-color: var(--line-gold); }
.md { line-height: 1.5; }
.md h1, .md h2, .md h3, .md h4 { color: var(--head-color); }
.md strong, .md b { color: color-mix(in srgb, var(--text) 85%, var(--head-color)); }

/* Anmeldung: Titel mit Zierrahmen */
.auth .logo { filter: drop-shadow(0 0 16px color-mix(in srgb, var(--accent) 50%, transparent)); }
.auth h1 { color: var(--accent); letter-spacing: .08em; }
.auth h1::after {
  content: ""; display: block; height: 2px; width: 60%; margin: 10px auto 0;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}
.wizard-steps div.on { background: linear-gradient(90deg, var(--accent2), var(--accent)); }

/* Porträts */
.avatar.img { position: relative; padding: 0; overflow: hidden; border-radius: 12px; background: #2a1f15; box-shadow: 0 0 0 2px #c99a45, 0 2px 6px #0007; }
.avatar.img img { position: absolute; max-width: none; display: block; object-fit: cover; }
.hero .avatar.img { border-radius: 14px; }
.hero .avatar.img { width: 72px; height: 72px; }
.portrait-big { display: block; width: 100%; max-width: 420px; margin: 0 auto; aspect-ratio: 1; object-fit: cover; border-radius: 12px; box-shadow: 0 0 0 2px var(--line-gold), 0 8px 24px #0008; }
.portrait-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.portrait-grid button { padding: 0; min-height: 0; aspect-ratio: 1; overflow: hidden; border-radius: 10px; border: 2px solid var(--line); }
.portrait-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- Spielfeld (Battlemap) */
.bm { display: flex; flex-direction: column; gap: 8px; }
.bm-tools { display: flex; gap: 6px; align-items: center; overflow-x: auto; scrollbar-width: none; }
.bm-tools::-webkit-scrollbar { display: none; }
.bm-tools button { flex: none; gap: 4px; }
.bm-tools button span { font-size: .8rem; }
.bm-tools button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent2); font-weight: 700; }
@media (max-width: 520px) { .bm-tools button[data-tool] span { display: none; } }
.bm-stage {
  position: relative; height: calc(100dvh - var(--top) - var(--safe-t) - var(--tabbar) - var(--safe-b) - 250px); min-height: 320px;
  border-radius: 10px; overflow: hidden; border: 1px solid var(--line-gold);
  background: #0d0a08; box-shadow: inset 0 0 30px #000a;
}
.bm-svg { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.bm-board { fill: #3a2f24; }
:root[data-theme="light"] .bm-board { fill: #d9c49a; }
.bm-grid { stroke: #f0e3c63a; stroke-width: 1; fill: none; vector-effect: non-scaling-stroke; }
:root[data-theme="light"] .bm-grid { stroke: #3a28184d; }
.bm-grid.on-img { stroke: #0000004d; }
.bm-edge { fill: none; stroke: var(--line-gold); stroke-width: 2; vector-effect: non-scaling-stroke; }
.bm-wall { fill: #15110d; stroke: #000; stroke-width: 1; }
.bm-diff { fill: #5c8a3a59; }
.bm-area { stroke-width: 2.5; vector-effect: non-scaling-stroke; stroke-dasharray: 8 5; }
.bm-areat { font: 700 22px var(--font-head); paint-order: stroke; stroke: #000a; stroke-width: 3px; text-anchor: middle; dominant-baseline: central; pointer-events: none; opacity: .9; }
.bm-tok { cursor: pointer; }
.bm-tok.drag { opacity: .85; filter: drop-shadow(0 6px 8px #000c); }
.bm-tok.dead { opacity: .55; filter: grayscale(1); }
.bm-fill.pc { fill: #2c5a8a; } .bm-fill.npc { fill: #7d1a12; }
.bm-ini { fill: #f6dfa6; font-family: var(--font-head); font-weight: 700; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.bm-ring { fill: none; stroke-width: 3.5; }
.bm-ring.pc { stroke: #74a9de; } .bm-ring.npc { stroke: #d4553f; }
.bm-tok.hit .bm-ring { stroke: #f0d060; stroke-dasharray: 5 3; }
.bm-glow { fill: none; stroke: #f0c56a; stroke-width: 5; filter: drop-shadow(0 0 6px #f0c56a); animation: bmPulse 1.4s ease-in-out infinite; }
@keyframes bmPulse { 50% { stroke-opacity: .35; } }
.bm-hpbg { fill: #000a; } .bm-hp { fill: #6cbf7f; } .bm-hp.mid { fill: #d9aa4e; } .bm-hp.low { fill: #e0604f; }
.bm-cond { fill: #e0604f; stroke: #000; stroke-width: 1; }
.bm-condt { fill: #fff; font: 700 10px system-ui, sans-serif; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.bm-dead { stroke: #e0604f; stroke-width: 5; stroke-linecap: round; }
.bm-ghost { fill: #f0c56a22; stroke: #f0c56a; stroke-width: 2; stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; }
.bm-line { stroke: #f0c56a; stroke-width: 3; stroke-dasharray: 2 6; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.bm-line.over { stroke: #e0604f; }
.bm-lblbg { fill: #120e0bdd; stroke: #8a6a35; }
.bm-lbl { fill: #f0e3c6; font: 700 14px var(--font-body); text-anchor: middle; dominant-baseline: central; }
.bm-lbl.over { fill: #ff8a75; }
.bm-hint { position: absolute; left: 8px; right: 56px; bottom: 8px; font-size: .78rem; color: #e8d9b8; background: #120e0bb3; padding: 4px 8px; border-radius: 6px; pointer-events: none; }
.bm-zoom { position: absolute; right: 8px; bottom: 8px; display: flex; flex-direction: column; gap: 6px; }
.bm-zoom button { width: 40px; min-height: 40px; padding: 0; font-size: 1.2rem; background: #231b14e6; color: #f0e3c6; border-color: #8a6a35; }
.bm-turn { display: flex; align-items: center; gap: 8px; }
.bm-turn > button { flex: none; }
.bm-who { display: flex; flex-direction: column; align-items: center; line-height: 1.15; }
.bm-who b { font-family: var(--font-head); color: var(--accent); font-size: 1.05rem; }

/* Vollbild für das Tablet auf dem Tisch */
body.bm-full #topbar, body.bm-full #tabbar, body.bm-full .bm-head, body.bm-full .bm-add { display: none !important; }
body.bm-full #view { padding: calc(var(--safe-t) + 8px) 8px calc(var(--safe-b) + 8px); max-width: none; }
body.bm-full .bm-stage { height: calc(100dvh - var(--safe-t) - var(--safe-b) - 120px); }
body.bm-full #toasts { bottom: calc(var(--safe-b) + 70px); }
.bm-maps { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.bm-maps button { flex-direction: column; padding: 4px; gap: 4px; min-height: 0; border-radius: 8px; font-size: .78rem; line-height: 1.15; }
.bm-maps img { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 5px; display: block; }
.bm-maps button.on, .bm-pics button.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.bm-pics { display: flex; flex-wrap: wrap; gap: 6px; }
.bm-pics button { width: 60px; height: 60px; min-height: 0; padding: 0; overflow: hidden; border-radius: 10px; font-size: 1.1rem; }
.bm-pics img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 15%; display: block; }

/* Große Bildvorschau (Hover / langes Drücken) */
.img-preview {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 100; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 8px; animation: fade .12s;
}
.img-preview img {
  width: min(78vw, 440px); aspect-ratio: 1; object-fit: cover; border-radius: 14px; display: block;
  box-shadow: 0 0 0 2px var(--line-gold), 0 20px 60px #000d;
}
.img-preview.map img { width: auto; height: min(82dvh, 960px); max-width: 92vw; aspect-ratio: 2 / 3; }
.img-preview span { font-family: var(--font-head); color: #f0e3c6; background: #120e0bdd; padding: 4px 12px; border-radius: 8px; border: 1px solid var(--line-gold); }
.img-preview span:empty { display: none; }
.bm-maps img, .bm-pics img, .portrait-grid img { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; -webkit-user-drag: none; }

/* ---------- Kampfaktionen */
.acts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; }
.act { flex-direction: column; align-items: flex-start; text-align: left; gap: 1px; min-height: 52px; padding: 8px 12px; }
.act b { font-weight: 700; }
.act small { color: var(--muted); font-size: .8rem; line-height: 1.2; }
.act.dim { opacity: .55; }
.checks { display: flex; flex-direction: column; gap: 4px; }
.chk { padding: 6px 10px; border-radius: 8px; background: var(--bg2); border-left: 3px solid var(--line); font-size: .95rem; }
.chk.ok { border-left-color: var(--green); } .chk.warn { border-left-color: var(--accent); } .chk.bad { border-left-color: var(--red); color: var(--red); }
.result-log { display: flex; flex-direction: column; gap: 6px; font-size: 1.02rem; }
.result-log > div { padding: 8px 10px; background: var(--bg2); border-radius: 8px; }
.bm-range { fill: #6cbf7f14; stroke: #6cbf7f; stroke-width: 2; stroke-dasharray: 10 6; vector-effect: non-scaling-stroke; pointer-events: none; }
.bm-range.long { fill: #d9aa4e0c; stroke: #d9aa4e; stroke-dasharray: 4 6; }
.bm-range.thrown { fill: #5b9bd514; stroke: #5b9bd5; stroke-dasharray: 8 6; }
.bm-tok.t-bad { opacity: .35; }
.bm-tok.t-ok .bm-ring { stroke: #6cbf7f; stroke-width: 5; }
.bm-tok.t-warn .bm-ring { stroke: #d9aa4e; stroke-width: 5; }
.bm-tok.t-sel .bm-ring { stroke: #fff; stroke-width: 6; }
.bm-tok.t-sel { filter: drop-shadow(0 0 8px #fff); }
.bm-tok.t-actor .bm-ring { stroke: #f0c56a; stroke-width: 5; }
.tag.econ.free { color: var(--green); border-color: color-mix(in srgb, var(--green) 50%, transparent); }
.tag.econ.spent { opacity: .55; text-decoration: line-through; }
.act { position: relative; padding-right: 40px; }
.act-q {
  position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font: 700 .9rem var(--font-head); color: var(--accent); border: 1.5px solid var(--accent2); background: var(--bg2);
}
.act-q:hover { background: var(--accent); color: var(--accent-ink); }

/* ---------- Effekte, Sterben, Nebel */
.tag.fx { cursor: pointer; border-style: dashed; }
.ds-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.ds-row span:first-child { width: 110px; color: var(--muted); }
.ds-row .pip { display: inline-block; }
.bm-tok.statue { filter: grayscale(1) brightness(.8) contrast(1.2); }
.bm-conc { fill: #5aa8e6; stroke: #000; stroke-width: 1; }
.bm-fx { fill: #a070e8; stroke: #000; stroke-width: 1; }
.bm-ds circle { fill: #0009; stroke: #fff; stroke-width: 1; }
.bm-ds circle.s { fill: var(--green); } .bm-ds circle.f { fill: var(--red); }
.bm-fog { fill: #0b0806; pointer-events: none; }
.bm-fog.dm { fill: #0b0806a6; }
.result-log.log > div { padding: 5px 10px; font-size: .92rem; }
.result-log .log-r { background: transparent !important; color: var(--accent); font-family: var(--font-head); padding: 6px 2px 0 !important; }

/* ---------- Schwierigkeit */
.diffbar { position: relative; height: 10px; background: var(--bg2); border-radius: 6px; margin: 10px 0 6px; overflow: hidden; }
.diffbar span { position: absolute; inset: 0 auto 0 0; border-radius: 6px; }
.diffbar i { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--line); }
.diff-bg-0 { background: var(--green); } .diff-bg-1 { background: #c9b44a; } .diff-bg-2 { background: var(--accent); } .diff-bg-3 { background: var(--red); }
.diff-3 { color: var(--red); } .diff-2 { color: var(--accent); } .diff-0 { color: var(--green); }
.xpin { min-height: 36px; text-align: right; }

/* ---------- Kampagne */
.cal-date { font: 700 1.25rem var(--font-head); color: var(--head-color, var(--text)); }
.moons .moon { display: flex; gap: 12px; align-items: center; padding: 10px 12px; }
.moon.high { box-shadow: inset 3px 0 0 var(--accent); }
.card.eye { border-color: var(--accent); text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-grid > b { text-align: center; font-size: .75rem; color: var(--muted); }
.cal-grid button { min-height: 42px; padding: 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: .9rem; }
.cal-grid button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.cal-grid button.ev { text-decoration: underline; text-decoration-color: var(--accent); }
.cal-grid button span { display: flex; gap: 2px; height: 6px; }
.cal-grid button i { width: 6px; height: 6px; border-radius: 50%; border: 1px solid #0006; }
.coins { display: flex; justify-content: space-between; gap: 6px; margin-bottom: 6px; }
.coins > div { flex: 1; text-align: center; background: var(--bg2); border-radius: 8px; padding: 6px 2px; }
.coins b { display: block; font: 700 1.2rem var(--font-head); }
.coins small { color: var(--muted); }
.gen-out { margin-top: 8px; }
.gen-out .card div { padding: 2px 0; }
.lu-list { margin: 0; padding-left: 20px; color: var(--muted); }
.lu-list li { margin: 3px 0; }

/* ---------- Spielleiter & Spieler */
.role-pick { display: grid; gap: 10px; margin: 14px 0; }
.role-pick button { flex-direction: column; gap: 4px; padding: 16px; font-size: 1.6rem; min-height: 0; }
.role-pick b { font-size: 1.05rem; } .role-pick small { font-size: .85rem; color: var(--muted); font-weight: 400; }
.role-pick .btn-primary small { color: inherit; opacity: .8; }
.card.live-on { border-color: var(--green); box-shadow: 0 0 0 1px var(--green) inset; }
.dm-party { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.dm-pc { display: flex; gap: 10px; align-items: flex-start; color: inherit; text-decoration: none; margin: 0; }
.dm-stats { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 6px; font-size: .9rem; }
.bm-tok.hiddenfig { opacity: .45; }
.bm-tok.hiddenfig .bm-ring { stroke-dasharray: 6 4; }
.pl-panel { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 10px; background: var(--card); display: flex; flex-direction: column; gap: 8px; }
.pl-panel.mine { border-color: var(--accent); box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 35%, transparent); }
.pl-turn { font: 700 1.2rem var(--font-head); color: var(--accent); text-align: center; animation: plpulse 1.6s ease-in-out infinite; }
@keyframes plpulse { 50% { opacity: .55; } }
.pl-wait { text-align: center; color: var(--muted); }
.pl-hero { display: flex; gap: 10px; align-items: center; }
.pl-hero .hpbar { margin-top: 4px; }
.read-aloud { font-size: 1.15rem; line-height: 1.55; font-style: italic; padding: 12px 14px; border-left: 3px solid var(--accent); background: var(--bg2); border-radius: 8px; }

/* ---------------------------------------------------------------- tutorials */
.tut-cta { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; margin-bottom: 6px;
  border-color: var(--line-gold); background: color-mix(in srgb, var(--accent) 8%, var(--card)); }
.tut-poster { width: 112px; height: 63px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); flex: none; background: var(--bg); }
.tut-video { display: block; width: 100%; max-height: 80vh; aspect-ratio: 16 / 9; border-radius: var(--radius); background: #000; }
