/* WH Companion · Styles */
:root {
  /* Marken-Palette (neutral): Necron-Neongrün im Clinch mit Grey-Knights-Silber/Neonblau */
  --bg: #090f12;
  --surface: #101a1c;
  --surface-2: #162427;
  --border: #284043;
  --text: #e7f0ee;
  --muted: #8aa3a0;
  --accent: #39ff88;
  --accent-ink: #03170b;
  --accent-2: #62b9ff;
  --silver: #cdd6e3;
  --ok: #3fc08a;
  --warn: #f0b13a;
  --danger: #f0524a;
  --info: #62b9ff;
  --radius: 4px;
  --cut: 10px;
  --tab-h: 62px;
  --shadow: 0 6px 24px rgba(0, 0, 0, .5);
  --glow: 0 0 14px color-mix(in srgb, var(--accent) 45%, transparent);
  --fac: #39ff88;
  --font-head: "Bahnschrift", "Barlow Condensed", "Rajdhani", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
}
:root[data-theme="light"] {
  --bg: #f3f4f7; --surface: #ffffff; --surface-2: #eef0f5; --border: #d6dbe5;
  --text: #151922; --muted: #5b6678; --accent: #b87d0b; --accent-ink: #ffffff;
  --ok: #1e8a5a; --warn: #a96b00; --danger: #c9332b; --info: #2a6fc4; --shadow: 0 6px 20px rgba(20, 30, 50, .12);
}

/* Fraktions-Themes: werden von der App je nach Armee/Einheit/Spiel gesetzt (data-faction am <html>) */
:root[data-faction="NEC"] {
  --bg: #050e09; --surface: #0b1a12; --surface-2: #11261a; --border: #1d4a30;
  --text: #e4f5ea; --muted: #7db592;
  --accent: #39ff88; --accent-ink: #02150a; --accent-2: #1fe0a8; --info: #1fe0a8; --fac: #39ff88;
}
:root[data-faction="GK"] {
  --bg: #090c11; --surface: #10151c; --surface-2: #171e28; --border: #313d4e;
  --text: #e9eef5; --muted: #8e9bb0;
  --accent: #cdd6e3; --accent-ink: #0b1119; --accent-2: #4db3ff; --info: #4db3ff; --fac: #cdd6e3;
}
:root[data-faction="GK"] { --glow: 0 0 16px color-mix(in srgb, var(--accent-2) 55%, transparent); }
:root[data-faction="NEC"] { --glow: 0 0 16px color-mix(in srgb, var(--accent) 55%, transparent); }
:root[data-theme="light"][data-faction="NEC"] { --accent: #0b8a47; --accent-ink: #ffffff; --accent-2: #08906e; --fac: #0b8a47; }
:root[data-theme="light"][data-faction="GK"] { --accent: #4a5b73; --accent-ink: #ffffff; --accent-2: #1f78c8; --fac: #4a5b73; }
:root[data-theme="light"] { --accent: #0b8a47; --accent-2: #2a6fc4; --fac: #0b8a47; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-text-size-adjust: 100%; overscroll-behavior-y: none;
}
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px; background: var(--bg);
  border-bottom: 1px solid var(--border); min-height: 52px;
}
.topbar h1 { font-size: 17px; margin: 0; letter-spacing: .02em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .back { background: none; border: 0; color: var(--text); padding: 6px; margin-left: -6px; cursor: pointer; display: flex; border-radius: 8px; }
.topbar .actions { display: flex; gap: 6px; }
.main { flex: 1; padding: 14px 16px calc(var(--tab-h) + env(safe-area-inset-bottom) + 24px); max-width: 920px; width: 100%; margin: 0 auto; outline: none; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; background: var(--surface);
  border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--tab-h); color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--accent); }
a { color: var(--info); }

h2 { font-size: 20px; margin: 22px 0 10px; }
h3 { font-size: 16px; margin: 18px 0 8px; }
h2:first-child, h3:first-child { margin-top: 0; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 11.5px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (min-width: 700px) { .grid-auto { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; } }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
}
.card.tight { padding: 10px 12px; }
.card.link { display: block; color: inherit; text-decoration: none; cursor: pointer; }
.card.link:active { background: var(--surface-2); }
.card h3 { margin-top: 0; }
.card.accent { border-left: 4px solid var(--fac); }
.hero {
  background: linear-gradient(135deg, var(--surface-2), var(--surface)); border: 1px solid var(--border);
  border-radius: 16px; padding: 18px; margin-bottom: 14px;
}
.hero h2 { margin: 0 0 4px; font-size: 22px; }

.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  border-radius: 10px; padding: 10px 14px; font: inherit; font-weight: 600; cursor: pointer; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, var(--border)); }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 34px; padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.xs { min-height: 28px; padding: 2px 8px; font-size: 12px; border-radius: 7px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.icon-btn { background: none; border: 0; color: var(--text); padding: 8px; border-radius: 8px; cursor: pointer; display: inline-flex; }
.icon-btn svg { width: 22px; height: 22px; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%;
}
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }
label.field { display: block; font-size: 12.5px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.field-group { margin-bottom: 12px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text); white-space: nowrap;
}
button.chip { cursor: pointer; font: inherit; font-size: 13px; min-height: 34px; padding: 4px 12px; }
.chip.on, button.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.chip.ok { color: var(--ok); border-color: var(--ok); }
.chip.warn { color: var(--warn); border-color: var(--warn); }
.chip.bad { color: var(--danger); border-color: var(--danger); }
.chip.info { color: var(--info); border-color: var(--info); }
.chip.fac { border-color: var(--fac); }
.scroll-x { overflow-x: auto; display: flex; gap: 6px; padding-bottom: 6px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.scroll-x::-webkit-scrollbar { display: none; }
.scroll-x > * { flex: 0 0 auto; }

.seg { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; color: var(--muted); font: inherit; font-weight: 600; padding: 8px 6px; border-radius: 8px; cursor: pointer; min-height: 38px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, .25); }

.banner { border-radius: 10px; padding: 10px 12px; font-size: 13.5px; border: 1px solid var(--border); background: var(--surface-2); margin-bottom: 12px; }
.banner.warn { border-color: var(--warn); }
.banner.bad { border-color: var(--danger); }
.banner.ok { border-color: var(--ok); }
.banner.info { border-color: var(--info); }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--border); }
.list > li:last-child { border-bottom: 0; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 11px 0; color: inherit; text-decoration: none; cursor: pointer; width: 100%; background: none; border: 0; font: inherit; text-align: left; }
.list-item .meta { color: var(--muted); font-size: 12.5px; }
.badge-pts { font-variant-numeric: tabular-nums; font-weight: 700; }

/* Datasheet */
.ds-head { border-left: 5px solid var(--fac); padding-left: 12px; margin-bottom: 12px; }
.ds-head h2 { margin: 0; font-size: 22px; }
.stat-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 8px 0; }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; text-align: center; padding: 6px 2px; }
.stat b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 10.5px; color: var(--muted); font-weight: 700; letter-spacing: .06em; }
.stat.inv { border-color: var(--info); }
table.wt { width: 100%; border-collapse: collapse; font-size: 13px; margin: 4px 0 10px; }
table.wt th { text-align: left; color: var(--muted); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; padding: 4px 4px; border-bottom: 1px solid var(--border); }
table.wt td { padding: 6px 4px; border-bottom: 1px solid var(--border); vertical-align: top; font-variant-numeric: tabular-nums; }
table.wt td.name { font-weight: 600; min-width: 110px; }
.kw { display: inline-block; font-size: 11.5px; padding: 1px 7px; margin: 1px 2px 1px 0; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); cursor: pointer; }
.kw.hot { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.ability { padding: 8px 0; border-bottom: 1px solid var(--border); }
.ability:last-child { border-bottom: 0; }
.ability b.t { color: var(--accent); }
.richtext { white-space: pre-line; }
.richtext b { font-weight: 700; }
a.gl, .gl { color: inherit; text-decoration: underline dotted var(--accent); text-underline-offset: 3px; cursor: help; }

/* Game */
.scoreboard { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.pcard { background: var(--surface); border: 2px solid var(--border); border-radius: 14px; padding: 12px; }
.pcard.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.pcard .pname { font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.counter { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 8px; }
.counter .lbl { font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.counter .val { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 2ch; text-align: center; line-height: 1; }
.counter .val.sm { font-size: 22px; }
.counter .btn { min-width: 44px; padding: 0; }
.roundbar { display: flex; gap: 6px; margin-bottom: 8px; }
.roundbar .r { flex: 1; text-align: center; padding: 6px 0; border-radius: 8px; border: 1px solid var(--border); font-weight: 700; font-size: 13px; color: var(--muted); }
.roundbar .r.done { background: var(--surface-2); }
.roundbar .r.cur { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.phasebar { display: flex; gap: 4px; margin: 8px 0 12px; }
.phasebar button { flex: 1; border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 10px; padding: 8px 2px; font: inherit; font-size: 11.5px; font-weight: 700; cursor: pointer; min-height: 46px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.phasebar button.cur { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.phasebar button.past { color: var(--text); }
.phasebar button svg { width: 18px; height: 18px; }
.unit-row { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; background: var(--surface); }
.unit-row.dead { opacity: .45; }
.unit-row.shocked { border-color: var(--warn); }
.bar { height: 8px; border-radius: 6px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--ok); transition: width .2s; }
.bar > i.half { background: var(--warn); }
.bar > i.low { background: var(--danger); }
.log { font-size: 13px; }
.log li { padding: 5px 0; border-bottom: 1px dashed var(--border); display: flex; gap: 8px; }
.log .t { color: var(--muted); min-width: 56px; font-variant-numeric: tabular-nums; }

/* Calc */
.result-big { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.hist { display: flex; align-items: flex-end; gap: 2px; height: 90px; margin: 8px 0; }
.hist > div { flex: 1; background: var(--accent); min-width: 2px; border-radius: 2px 2px 0 0; opacity: .85; }
.hist > div.hot { opacity: 1; background: var(--ok); }
.dice { display: inline-flex; width: 34px; height: 34px; border-radius: 8px; align-items: center; justify-content: center; font-weight: 800; background: var(--surface-2); border: 1px solid var(--border); margin: 2px; font-variant-numeric: tabular-nums; }
.dice.hit { background: var(--ok); color: #04170d; border-color: var(--ok); }
.dice.miss { opacity: .55; }
.dice.six { box-shadow: 0 0 0 2px var(--accent); }

/* Modal / toast */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--surface); width: 100%; max-width: 640px; max-height: 88dvh; overflow: auto; border-radius: 18px 18px 0 0; padding: 16px 16px calc(env(safe-area-inset-bottom) + 20px); box-shadow: var(--shadow); border: 1px solid var(--border); }
@media (min-width: 700px) { .overlay { align-items: center; } .sheet { border-radius: 18px; } }
.sheet h3 { margin-top: 0; }
.sheet .close { float: right; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 14px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; z-index: 120; font-weight: 600; font-size: 14px; box-shadow: var(--shadow); max-width: 90vw; }

.sep { height: 1px; background: var(--border); margin: 14px 0; }
.kbd { font-variant-numeric: tabular-nums; font-weight: 700; }
.pill-num { display: inline-flex; min-width: 22px; height: 22px; align-items: center; justify-content: center; border-radius: 11px; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 12px; padding: 0 6px; }
details.fold { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); margin-bottom: 10px; }
details.fold > summary { cursor: pointer; padding: 12px 14px; font-weight: 700; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: "▾"; color: var(--muted); }
details.fold[open] > summary::after { content: "▴"; }
details.fold > .body { padding: 0 14px 12px; }
.rule-block ul { margin: 0 0 10px; padding-left: 20px; }
.rule-block li { margin-bottom: 4px; }
.rule-block .callout { border-left: 3px solid var(--accent); background: var(--surface-2); padding: 8px 12px; border-radius: 0 8px 8px 0; margin: 8px 0 12px; font-size: 14px; }
.rule-block table { border-collapse: collapse; width: 100%; font-size: 13.5px; margin: 6px 0 12px; }
.rule-block th, .rule-block td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; }
.rule-block th { background: var(--surface-2); }
.q { border-left: 3px solid var(--info); padding-left: 10px; margin: 8px 0; }
.verdict { border-radius: 12px; padding: 14px; border: 2px solid var(--border); margin-top: 12px; }
.verdict.yes { border-color: var(--ok); }
.verdict.no { border-color: var(--danger); }
.verdict.maybe { border-color: var(--warn); }
.verdict h3 { margin: 0 0 6px; }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }
@media print {
  .topbar, .tabbar, .btn, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .card { border-color: #999; break-inside: avoid; }
}

/* ================= HUD-Theme (Überschreibungen) ================= */
body {
  background:
    radial-gradient(1200px 600px at 85% -10%, color-mix(in srgb, var(--accent-2) 12%, transparent), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
body::before { /* feines Hex-/Topo-Raster */
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .5;
  background-image:
    repeating-linear-gradient(60deg, color-mix(in srgb, var(--accent-2) 5%, transparent) 0 1px, transparent 1px 34px),
    repeating-linear-gradient(-60deg, color-mix(in srgb, var(--accent-2) 5%, transparent) 0 1px, transparent 1px 34px);
}
h1, h2, h3, .tabbar a, .btn, .chip, .seg button, .phasebar button, .counter .lbl, .stat span, table.wt th, label.field, .roundbar .r {
  font-family: var(--font-head); text-transform: uppercase; letter-spacing: .07em;
}
h2 { font-size: 21px; letter-spacing: .08em; }
h3 { font-size: 15.5px; color: var(--accent-2); }
.card h3, .sheet h3, .ability b.t { color: var(--accent-2); }
.topbar { background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.topbar h1 { font-size: 18px; letter-spacing: .12em; }

/* abgeschrägte Panels: Rahmen über Hintergrund + inneren Pseudo-Layer */
.card, .pcard, .unit-row, .hero, details.fold, .banner, .btn, .sheet, .stat, .seg, input, select, textarea {
  --c: var(--cut);
}
.card, .pcard, .unit-row, .hero, details.fold {
  position: relative; background: var(--border); border: 0; isolation: isolate;
  clip-path: polygon(var(--c) 0, 100% 0, 100% calc(100% - var(--c)), calc(100% - var(--c)) 100%, 0 100%, 0 var(--c));
}
.card::before, .pcard::before, .unit-row::before, .hero::before, details.fold::before {
  content: ""; position: absolute; inset: 1px; z-index: -1; background: var(--surface);
  clip-path: polygon(var(--c) 0, 100% 0, 100% calc(100% - var(--c)), calc(100% - var(--c)) 100%, 0 100%, 0 var(--c));
}
.hero::before { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 14%, var(--surface-2)), var(--surface)); }
.card.accent { border: 0; background: linear-gradient(90deg, var(--fac) 0 3px, var(--border) 3px); }
.pcard.active { background: var(--accent); box-shadow: none; filter: drop-shadow(0 0 8px color-mix(in srgb, var(--accent) 55%, transparent)); }
.pcard { border: 0; }
.unit-row.shocked { background: var(--warn); }
.unit-row.dead { opacity: .4; }
details.fold { margin-bottom: 10px; }
.card.link:active { filter: brightness(1.2); }

.btn {
  border: 0; border-radius: 0; position: relative; isolation: isolate; background: var(--border); color: var(--text);
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px); --c: 8px;
}
.btn::before { content: ""; position: absolute; inset: 1px; z-index: -1; background: var(--surface-2);
  clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary::before { background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, #fff), var(--accent)); }
.btn.danger { background: var(--danger); color: var(--danger); }
.btn.ghost::before { background: transparent; }
.btn.sm, .btn.xs { clip-path: polygon(5px 0, 100% 0, 100% calc(100% - 5px), calc(100% - 5px) 100%, 0 100%, 0 5px); }
.btn.sm::before, .btn.xs::before { clip-path: polygon(4px 0, 100% 0, 100% calc(100% - 4px), calc(100% - 4px) 100%, 0 100%, 0 4px); }
.btn.primary:active, .btn:active { filter: brightness(1.15); }
.counter .btn { background: color-mix(in srgb, var(--accent-2) 55%, var(--border)); }

input, select, textarea { border-radius: 0; border-color: var(--border); background: color-mix(in srgb, var(--surface-2) 85%, #000); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--glow); }
.chip { border-radius: 0; clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%); padding: 3px 14px; border: 0; background: var(--surface-2); }
.chip.on, button.chip[aria-pressed="true"] { background: var(--accent); }
.chip.ok { background: color-mix(in srgb, var(--ok) 20%, var(--surface-2)); }
.chip.warn { background: color-mix(in srgb, var(--warn) 20%, var(--surface-2)); }
.chip.bad { background: color-mix(in srgb, var(--danger) 22%, var(--surface-2)); }
.chip.info { background: color-mix(in srgb, var(--accent-2) 18%, var(--surface-2)); }
.seg { border-radius: 0; background: var(--surface); }
.seg button { border-radius: 0; }
.seg button[aria-pressed="true"] { background: transparent; color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.banner { border-radius: 0; border-left: 3px solid var(--border); }
.banner.warn { border-left-color: var(--warn); } .banner.bad { border-left-color: var(--danger); }
.banner.ok { border-left-color: var(--ok); } .banner.info { border-left-color: var(--accent-2); }

/* Tabbar mit Ember-Indikator */
.tabbar { background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px); }
.tabbar a { position: relative; font-size: 10.5px; }
.tabbar a[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; background: var(--accent); box-shadow: var(--glow); }
.tabbar a[aria-current="page"] svg { filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 70%, transparent)); }

/* Listen-/Navigationseinträge im Codex-Stil */
.navitem { display: flex; align-items: center; gap: 14px; padding: 14px 16px; margin-bottom: 8px; color: var(--text); text-decoration: none; position: relative; isolation: isolate;
  background: var(--border); clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px); font-family: var(--font-head); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.navitem::before { content: ""; position: absolute; inset: 1px; z-index: -1; background: var(--surface);
  clip-path: polygon(9px 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%, 0 9px); }
.navitem svg { width: 26px; height: 26px; color: var(--accent); flex: none; }
.navitem small { display: block; font-family: system-ui, sans-serif; text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--muted); font-size: 12.5px; }
.navitem:active, .navitem.sel { background: var(--accent); filter: drop-shadow(0 0 8px color-mix(in srgb, var(--accent) 50%, transparent)); }

/* Schmale Fortschrittsbalken mit schrägem Ende */
.bar { height: 6px; border-radius: 0; background: color-mix(in srgb, var(--border) 60%, #000); clip-path: polygon(0 0, 100% 0, calc(100% - 4px) 100%, 0 100%); }
.bar > i { background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 70%, #000), var(--accent)); clip-path: polygon(0 0, 100% 0, calc(100% - 4px) 100%, 0 100%); }
.bar > i.half { background: var(--warn); } .bar > i.low { background: var(--danger); }
.stat { border-radius: 0; background: var(--surface-2); border-color: var(--border); border-top: 2px solid var(--accent-2); }
.stat b { font-family: var(--font-head); font-size: 20px; }
.stat.inv { border-top-color: var(--accent); }
.roundbar .r { border-radius: 0; clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%); border: 0; background: var(--surface-2); }
.roundbar .r.cur { background: var(--accent); box-shadow: var(--glow); }
.phasebar button { border-radius: 0; border: 0; background: var(--surface-2); clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%); }
.phasebar button.cur { background: var(--accent); filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 60%, transparent)); }
.counter .val { font-family: var(--font-head); text-shadow: 0 0 12px color-mix(in srgb, var(--accent-2) 40%, transparent); }
.dice { border-radius: 4px; }
.sheet { border-radius: 0; border: 0; border-top: 2px solid var(--accent); background: var(--surface); }
.overlay { backdrop-filter: blur(3px); }
.toast { border-radius: 0; background: var(--accent); color: var(--accent-ink); font-family: var(--font-head); text-transform: uppercase; letter-spacing: .06em; }
.ds-head { border-left: 4px solid var(--accent); }
.ds-head h2 { text-shadow: 0 0 14px color-mix(in srgb, var(--accent) 35%, transparent); }
.kw { border-radius: 0; }
.pill-num { border-radius: 0; clip-path: polygon(4px 0, 100% 0, calc(100% - 4px) 100%, 0 100%); }
.hist > div { border-radius: 0; background: var(--accent-2); }
.hist > div.hot { background: var(--accent); }
a.gl, .gl { text-decoration-color: var(--accent-2); }
.rule-block .callout { border-left-color: var(--accent-2); border-radius: 0; }
.list > li { border-bottom-color: var(--border); }

/* Icon-Größen (Standard für alle eingebetteten SVG-Icons) */
svg[aria-hidden="true"] { width: 20px; height: 20px; flex: none; }
.btn.sm svg[aria-hidden], .chip svg[aria-hidden] { width: 16px; height: 16px; }
.counter .btn svg { width: 20px; height: 20px; }
.list-item > svg[aria-hidden] { color: var(--accent); width: 22px; height: 22px; }
details.fold > summary svg[aria-hidden] { width: 18px; height: 18px; color: var(--accent); margin-right: 4px; }
.phasebar button { font-size: 10px; letter-spacing: .02em; padding: 6px 0; overflow: hidden; }
.phasebar button svg[aria-hidden] { width: 18px; height: 18px; }
.btn.primary.grow svg[aria-hidden] { width: 22px; height: 22px; }
input[type="checkbox"] { flex: none; }

.scoreboard { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.pcard { padding: 10px; min-width: 0; }
.counter .btn { min-width: 38px; width: 38px; }
.counter .val { font-size: 28px; }
input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; width: 22px; height: 22px; min-height: 0; padding: 0; flex: none;
  border: 2px solid var(--muted); background: transparent; border-radius: 0; position: relative; cursor: pointer;
  clip-path: polygon(4px 0, 100% 0, 100% calc(100% - 4px), calc(100% - 4px) 100%, 0 100%, 0 4px);
}
input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
input[type="checkbox"]:checked::after { content: ""; position: absolute; left: 5px; top: 1px; width: 5px; height: 11px; border: solid var(--accent-ink); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }

/* Missionskarten (Originalbilder) */
img.mcard { display: block; width: 100%; max-width: 420px; margin: 8px auto; border: 1px solid var(--border); cursor: zoom-in; background: #fff; }

/* Anmeldung */
.login-screen { position: fixed; inset: 0; z-index: 200; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto; }
.login-card { width: 100%; max-width: 380px; }

/* Einheitenfotos */
.photo-block { text-align: center; margin: 4px 0 12px; }
img.unit-photo { max-width: 100%; max-height: 300px; object-fit: contain; filter: drop-shadow(0 6px 18px rgba(0,0,0,.55)) drop-shadow(0 0 22px color-mix(in srgb, var(--accent) 18%, transparent)); }
.photo-add { width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 18px; margin-bottom: 12px; background: transparent; border: 1px dashed var(--border); color: var(--muted); cursor: pointer; font: inherit; font-family: var(--font-head); text-transform: uppercase; letter-spacing: .08em; }
.photo-add svg { width: 24px; height: 24px; color: var(--accent); }
.avatar { width: 46px; height: 46px; flex: none; object-fit: contain; background: var(--surface-2); border: 1px solid var(--border); }
.avatar.empty { display: inline-flex; align-items: center; justify-content: center; color: var(--muted); opacity: .5; }
.avatar.empty svg { width: 22px; height: 22px; }
.checker { background: repeating-conic-gradient(#2a3d43 0% 25%, #1a2a2f 0% 50%) 50% / 18px 18px; padding: 8px; border: 1px solid var(--border); }

/* Regel-Assistent */
.chat { display: flex; flex-direction: column; gap: 10px; min-height: 160px; max-height: 52dvh; overflow-y: auto; padding: 4px 2px; }
.msg { padding: 10px 12px; max-width: 92%; font-size: 14.5px; }
.msg.user { align-self: flex-end; background: color-mix(in srgb, var(--accent) 22%, var(--surface-2)); border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border)); clip-path: polygon(0 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%); }
.msg.bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent-2); }

/* Marke */
.brand { display: inline-flex; align-items: center; gap: 8px; flex: none; }
.brand svg { width: 30px; height: 30px; }
.brand-word { font-family: var(--font-head); font-weight: 800; letter-spacing: .14em; text-transform: uppercase; font-size: 13px; line-height: 1; }
.brand-word b { color: var(--accent); }
.login-card .brand-big svg { width: 84px; height: 84px; filter: drop-shadow(0 0 18px color-mix(in srgb, var(--accent) 35%, transparent)) drop-shadow(0 0 22px color-mix(in srgb, var(--accent-2) 30%, transparent)); }

/* Duell-Modus */
.duel-arena { display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px; align-items: stretch; }
.duel-unit { background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--fac); padding: 10px; min-width: 0; }
.duel-role { font-family: var(--font-head); text-transform: uppercase; letter-spacing: .12em; font-size: 11px; color: var(--fac); margin-bottom: 4px; }
.duel-name { font-weight: 800; font-size: 15px; overflow-wrap: anywhere; }
.vs { display: flex; align-items: center; }
.vs span { font-family: var(--font-head); font-weight: 800; letter-spacing: .1em; color: var(--accent); text-shadow: var(--glow); writing-mode: vertical-rl; }
.mini-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(38px, 1fr)); gap: 4px; margin-top: 8px; }
.mini-stats div { background: var(--surface-2); border: 1px solid var(--border); text-align: center; padding: 3px 0; }
.mini-stats b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; }
.mini-stats span { font-size: 9.5px; color: var(--muted); letter-spacing: .06em; }
.wcard { background: var(--surface); border: 1px solid var(--border); padding: 10px; opacity: .7; }
.wcard.on { opacity: 1; border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); box-shadow: inset 3px 0 0 var(--accent); }
.modchips { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.modchip { display: flex; flex-direction: column; padding: 4px 8px; font-size: 12.5px; border-left: 3px solid var(--muted); background: var(--surface-2); }
.modchip b { font-size: 12.5px; letter-spacing: .02em; }
.modchip span { color: var(--muted); font-size: 11.5px; }
.modchip.plus { border-left-color: var(--ok); background: color-mix(in srgb, var(--ok) 11%, var(--surface-2)); }
.modchip.plus b { color: var(--ok); }
.modchip.minus { border-left-color: var(--danger); background: color-mix(in srgb, var(--danger) 11%, var(--surface-2)); }
.modchip.minus b { color: var(--danger); }
.wres { display: flex; gap: 12px; align-items: center; margin-top: 8px; padding-top: 6px; border-top: 1px dashed var(--border); font-size: 13px; flex-wrap: wrap; }
.duel-sides { display: grid; grid-template-columns: 1fr; gap: 12px; }
.sidebox.att, .sidebox.def { border-top: 3px solid var(--fac); }
.sidebox h4 { margin: 12px 0 4px; font-family: var(--font-head); text-transform: uppercase; letter-spacing: .08em; font-size: 12px; color: var(--muted); }
details.mini { border-bottom: 1px solid var(--border); padding: 6px 0; }
details.mini > summary { cursor: pointer; list-style: none; }
details.mini > summary::-webkit-details-marker { display: none; }
@media (min-width: 900px) { .duel-sides { grid-template-columns: 1fr 1fr; } }

/* Live-Spiel */
.unit-row.readonly .counter, .unit-row.readonly .chip:not(.allow) { pointer-events: none; opacity: .55; }
.btn[disabled].sm { opacity: .35; }

/* ---------- Match-Cockpit ---------- */
.cp-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; position: sticky; top: var(--top-h, 52px); z-index: 20; background: var(--bg); padding: 6px 0 8px; }
.cp-tabs button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; min-height: 48px; font-family: var(--font-head); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; background: var(--surface); color: var(--muted); border: 1px solid var(--border); cursor: pointer; }
.cp-tabs button svg { width: 18px; height: 18px; }
.cp-tabs button[aria-selected="true"] { color: var(--accent); border-color: var(--accent); box-shadow: 0 0 10px var(--glow); }
.cockpit .cp-main, .cockpit .cp-pane { display: none; min-width: 0; }
.cockpit[data-tab="game"] .cp-main,
.cockpit[data-tab="duel"] .cp-pane[data-p="duel"],
.cockpit[data-tab="dice"] .cp-pane[data-p="dice"],
.cockpit[data-tab="cards"] .cp-pane[data-p="cards"] { display: block; }
.cp-unit { border-bottom: 1px solid var(--border); }
.cp-unit .list-item { background: none; border: 0; color: inherit; display: flex; gap: 10px; align-items: center; padding: 8px 4px; cursor: pointer; }
.cp-unit.open > .list-item { color: var(--accent); }
.cp-sheet { padding: 6px 2px 14px; }
@media (min-width: 1000px) {
  .main.wide { max-width: 1680px; }
  .cockpit { display: grid; grid-template-columns: minmax(360px, 5fr) minmax(480px, 6fr); gap: 0 20px; align-items: start; grid-template-rows: auto 1fr; }
  .cockpit .cp-tabs { grid-column: 2; grid-row: 1; grid-template-columns: repeat(3, 1fr); top: var(--top-h, 52px); }
  .cockpit .cp-tabs .cp-game { display: none; }
  .cockpit .cp-main { display: block; grid-column: 1; grid-row: 1 / span 2; }
  .cockpit .cp-dock { grid-column: 2; grid-row: 2; }
  .cockpit[data-dock="duel"] .cp-pane[data-p="duel"],
  .cockpit[data-dock="dice"] .cp-pane[data-p="dice"],
  .cockpit[data-dock="cards"] .cp-pane[data-p="cards"] { display: block; }
  .cockpit[data-tab="game"][data-dock] .cp-pane { }
  .cp-dock .duel-sides { grid-template-columns: 1fr; }
}
@media (min-width: 1500px) {
  .cp-dock .duel-sides { grid-template-columns: 1fr 1fr; }
  .cockpit { grid-template-columns: minmax(420px, 5fr) minmax(640px, 7fr); }
}
@media (min-width: 1000px) and (min-height: 700px) {
  .cp-dock { max-height: calc(100vh - 130px); overflow-y: auto; padding-right: 4px; }
}
