@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;700&family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&display=swap');

:root {
  --wood-deep: #1a120b;
  --wood: #3d2914;
  --wood-light: #5a3d22;
  --parchment: #f3e6c8;
  --parchment-dark: #e4d2a8;
  --ink: #2a2118;
  --ink-soft: #5c4a36;
  --gold: #c4a35a;
  --gold-bright: #e0c078;
  --burgundy: #8c3a2f;
  --burgundy-deep: #6b2a22;
  --success: #4a7c45;
  --shadow: rgba(0, 0, 0, 0.45);
  --radius: 14px;
  --font-display: 'Cinzel', serif;
  --font-body: 'Libre Baskerville', Georgia, serif;
  /* 9-Slice-Rahmen aus /img/frame-panel.png (763×384) */
  --ui-frame-slice: 88;
  --ui-frame-width: 42px;
  --ui-frame-pad: 0.35rem 0.75rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-body);
  color: var(--parchment);
  background:
    radial-gradient(ellipse at top, rgba(196, 163, 90, 0.08), transparent 55%),
    linear-gradient(180deg, #24180f 0%, var(--wood-deep) 40%, #0f0b07 100%);
  background-attachment: fixed;
}

body {
  line-height: 1.5;
}

html:has(body.tavern-scene),
body.tavern-scene {
  min-height: 100%;
  background:
    linear-gradient(180deg, rgba(12, 8, 5, 0.28), rgba(12, 8, 5, 0.42)),
    var(--scene-bg, url('/img/tavern-bg.png')) center center / cover no-repeat fixed;
}

body.tavern-scene .topbar h1,
body.tavern-scene .topbar a,
body.tavern-scene .brand,
body.tavern-scene .brand-hero p {
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.85);
}

body.tavern-scene .badge {
  background: rgba(15, 10, 6, 0.72);
}

.bg-preview {
  height: 160px;
  margin: 0.35rem 0 0.75rem;
  border: 2px solid var(--gold);
  border-radius: 12px;
  background: #1a120b center / cover no-repeat;
}

a {
  color: var(--gold-bright);
  text-decoration: none;
}

a:hover {
  color: var(--parchment);
}

img {
  max-width: 100%;
  display: block;
}

h1,
h2,
h3,
.brand {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--gold-bright);
  margin: 0 0 0.5rem;
}

.page {
  width: min(1100px, 100% - 2rem);
  margin: 0 auto;
  padding: 1.5rem 0 3rem;
}

.page-wide {
  width: min(1600px, 100% - 1rem);
}

.page-wide .panel-full {
  width: 100%;
  max-width: none;
}

.brand-hero {
  text-align: center;
  margin: 2rem 0 2.5rem;
}

.brand-hero .brand {
  font-size: clamp(2rem, 6vw, 3.4rem);
  text-shadow: 0 2px 0 #000, 0 0 24px rgba(196, 163, 90, 0.25);
}

.brand-hero p {
  color: var(--parchment-dark);
  max-width: 28rem;
  margin: 0.75rem auto 0;
}

.panel {
  background: linear-gradient(160deg, rgba(90, 61, 34, 0.95), rgba(61, 41, 20, 0.98));
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.panel-full {
  width: 100%;
}

.note-editor {
  min-height: 280px;
  width: 100%;
  font-size: 1.05rem;
  line-height: 1.6;
}

.panel h2 {
  font-size: 1.25rem;
  border-bottom: 1px solid rgba(196, 163, 90, 0.35);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

.fold-panel > .fold-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin: 0;
}

.fold-panel > .fold-summary::-webkit-details-marker {
  display: none;
}

.fold-panel > .fold-summary h2 {
  margin: 0;
  border: 0;
  padding: 0;
}

.fold-panel:not([open]) > .fold-summary h2 {
  border: 0;
  margin: 0;
  padding: 0;
}

.fold-panel[open] > .fold-summary {
  border-bottom: 1px solid rgba(196, 163, 90, 0.35);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

.fold-panel[open] .fold-hint::after,
.fold-panel:not([open]) .fold-hint {
  content: none;
}

.fold-panel:not([open]) .fold-hint {
  opacity: 0.85;
}

.fold-panel[open] .fold-hint {
  display: none;
}

.fold-inline {
  margin-bottom: 1rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid rgba(196, 163, 90, 0.3);
  border-radius: 10px;
  background: rgba(26, 18, 11, 0.35);
}

.fold-inline > summary {
  cursor: pointer;
  font-family: var(--font-display);
  color: var(--gold-bright);
}

.figure-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 0.5rem;
}

.figure-card-grid.player-card-grid {
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
}

.figure-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.9rem;
  background: rgba(26, 18, 11, 0.45);
  border: 1px solid rgba(196, 163, 90, 0.35);
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.figure-card-head {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.figure-card-head img,
.figure-card-fallback {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  border: 2px solid var(--gold);
  object-fit: cover;
  flex-shrink: 0;
  background: #0a0705;
}

.figure-card-fallback {
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--gold);
}

.figure-card-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--gold-bright);
  margin: 0;
}

.figure-card-meta {
  display: grid;
  gap: 0.45rem;
}

.figure-card-meta dt {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(196, 163, 90, 0.85);
  margin: 0;
}

.figure-card-meta dd {
  margin: 0.1rem 0 0;
  color: var(--parchment);
  white-space: pre-wrap;
  line-height: 1.35;
}

.figure-card-meta dd.empty {
  opacity: 0.55;
  font-style: italic;
}

.figure-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: auto;
  padding-top: 0.35rem;
  border-top: 1px solid rgba(196, 163, 90, 0.2);
}

.player-card {
  min-width: 0;
}

.player-attr-summary,
.player-inv-summary {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.3rem;
}

.player-attr-summary li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  background: rgba(26, 18, 11, 0.35);
  border: 1px solid rgba(196, 163, 90, 0.2);
  border-radius: 8px;
  font-size: 0.92rem;
}

.player-inv-summary li {
  padding: 0.25rem 0;
  border-bottom: 1px solid rgba(196, 163, 90, 0.15);
  color: var(--parchment);
}

.player-inv-summary li:last-child {
  border-bottom: 0;
}

.menu-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.wood-sign {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 120px;
  padding: 1.25rem 1rem;
  text-align: center;
  color: var(--parchment);
  background:
    linear-gradient(180deg, rgba(90, 61, 34, 0.5), transparent),
    var(--wood);
  border: 3px solid var(--gold);
  border-radius: 12px;
  box-shadow: 0 8px 20px var(--shadow), inset 0 0 0 2px rgba(0, 0, 0, 0.25);
  font-family: var(--font-display);
  font-size: 1.2rem;
  transition: transform 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  cursor: pointer;
}

.wood-sign span {
  display: block;
  margin-top: 0.4rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--parchment-dark);
  font-weight: 400;
  letter-spacing: 0;
}

.wood-sign:hover,
.wood-sign:focus-visible {
  transform: translateY(-3px);
  border-color: var(--gold-bright);
  color: var(--gold-bright);
  outline: none;
}

label {
  display: block;
  margin: 0.75rem 0 0.35rem;
  color: var(--parchment-dark);
  font-size: 0.95rem;
}

input[type='text'],
input[type='password'],
input[type='number'],
input[type='file'],
select,
textarea {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  border: 1px solid rgba(196, 163, 90, 0.45);
  background: rgba(26, 18, 11, 0.65);
  color: var(--parchment);
  font: inherit;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.65rem 1.1rem;
  border-radius: 10px;
  border: 2px solid var(--gold);
  background: linear-gradient(180deg, var(--burgundy), var(--burgundy-deep));
  color: var(--parchment);
  font-family: var(--font-display);
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--shadow);
}

.btn:hover {
  background: linear-gradient(180deg, #a34538, var(--burgundy));
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: linear-gradient(180deg, var(--wood-light), var(--wood));
}

.btn-ghost {
  background: transparent;
  box-shadow: none;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.stack {
  display: grid;
  gap: 0.75rem;
}

.muted {
  color: var(--parchment-dark);
  font-size: 0.9rem;
}

.error {
  color: #ffb4a8;
  background: rgba(140, 58, 47, 0.25);
  border: 1px solid var(--burgundy);
  border-radius: 8px;
  padding: 0.65rem 0.8rem;
  margin: 0.75rem 0;
}

.success {
  color: #c8efc0;
  background: rgba(74, 124, 69, 0.2);
  border: 1px solid var(--success);
  border-radius: 8px;
  padding: 0.65rem 0.8rem;
  margin: 0.75rem 0;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.tab {
  flex: 1;
  min-width: 120px;
}

.tab.active {
  border-color: var(--gold-bright);
  color: var(--gold-bright);
}

.grid-2 {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem;
  background: rgba(26, 18, 11, 0.4);
  border: 1px solid rgba(196, 163, 90, 0.25);
  border-radius: 10px;
}

.list-item img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--gold);
}

.list-item .grow {
  flex: 1;
  min-width: 0;
}

.deck {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.75rem;
}

.deck-btn {
  min-height: 88px;
  padding: 0.75rem;
  text-align: center;
  font-size: 0.9rem;
  touch-action: manipulation;
}

.attr-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
}

.player-card .attr-grid,
.page-leiter .attr-grid {
  grid-template-columns: 1fr;
  gap: 0.25rem;
}

.attr-grid label {
  margin-top: 0;
}

.attr-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem;
  align-items: center;
  padding: 0.3rem 0.45rem;
  background: rgba(26, 18, 11, 0.4);
  border: 1px solid rgba(196, 163, 90, 0.25);
  border-radius: 7px;
}

.attr-row.attr-row-leiter,
.attr-row.attr-row-compact {
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 0.3rem 0.4rem;
}

.attr-row .attr-label {
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.attr-row .attr-controls,
.attr-row .attr-mod-controls,
.attr-row .attr-display {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.attr-row .attr-mod-controls {
  grid-column: auto;
  justify-content: flex-end;
  flex-wrap: nowrap;
  padding-top: 0;
  border-top: 0;
  padding-left: 0.25rem;
  border-left: 1px solid rgba(196, 163, 90, 0.2);
}

.attr-row .attr-value {
  min-width: 1.2rem;
  text-align: center;
  font-family: var(--font-display);
  font-size: 0.9rem;
  color: var(--gold-bright);
}

.attr-mod {
  min-width: 1.35rem;
  text-align: center;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
}

.attr-mod-plus {
  color: #22c55e;
}

.attr-mod-minus {
  color: #ef4444;
}

.attr-effective {
  min-width: 1.6rem;
  text-align: right;
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--parchment);
  opacity: 0.9;
  padding-left: 0.2rem;
  border-left: 1px solid rgba(196, 163, 90, 0.35);
}

.page-leiter .attr-row .qty-btn {
  min-width: 22px;
  min-height: 22px;
  font-size: 0.75rem;
  padding: 0;
}

.page-leiter .player-card .muted[data-points-hint],
.page-leiter .player-card p.muted {
  font-size: 0.78rem;
  margin: 0.15rem 0;
}

.class-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.65rem;
}

.class-card {
  text-align: left;
  padding: 0.85rem;
  border: 2px solid rgba(196, 163, 90, 0.35);
  border-radius: 12px;
  background: rgba(26, 18, 11, 0.45);
  color: var(--parchment);
  cursor: pointer;
  font: inherit;
}

.class-card strong {
  display: block;
  font-family: var(--font-display);
  color: var(--gold-bright);
  margin-bottom: 0.35rem;
}

.class-card span {
  display: block;
  font-size: 0.85rem;
  color: var(--parchment-dark);
}

.class-card.selected {
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 1px var(--gold);
}

.points-banner {
  display: inline-block;
  margin: 0.35rem 0 0.75rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--gold);
  color: var(--gold-bright);
  font-family: var(--font-display);
}

.map-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: #0a0705;
  border: 2px solid var(--gold);
  border-radius: 12px;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

.map-layers {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.map-stage img.map-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #0a0705;
  opacity: 0;
  transition: opacity 1.2s ease;
  pointer-events: none;
  z-index: 0;
}

.map-stage img.map-bg.is-visible {
  opacity: 1;
  z-index: 1;
}

.map-stage img.map-bg.is-hidden {
  opacity: 0 !important;
  z-index: 0;
}

.map-token {
  position: absolute;
  width: 52px;
  height: 52px;
  margin-left: -26px;
  margin-top: -26px;
  border-radius: 50%;
  border: 3px solid var(--gold-bright);
  box-shadow: 0 4px 12px var(--shadow);
  background: var(--wood);
  overflow: hidden;
  cursor: grab;
  z-index: 2;
}

.map-token-character {
  border-radius: 10px;
  border-color: #c4783a;
  box-shadow: 0 4px 12px var(--shadow), 0 0 0 1px rgba(196, 120, 58, 0.35);
}

.map-token-character.is-speaking {
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 3px rgba(224, 192, 120, 0.55), 0 6px 16px var(--shadow);
  z-index: 3;
}

.map-token img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.map-token .token-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--gold);
}

.tv-shell {
  position: fixed;
  inset: 0;
  background: #050403;
  overflow: hidden;
}

.tv-map {
  position: absolute;
  inset: 0;
}

.tv-map .map-stage {
  height: 100%;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
}

.combat-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.combat-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.75rem;
  background: rgba(26, 18, 11, 0.55);
  border: 1px solid rgba(196, 163, 90, 0.35);
  border-radius: 10px;
  cursor: grab;
  user-select: none;
  color: var(--parchment);
}

.combat-item.dragging {
  opacity: 0.55;
}

.combat-item.drag-over {
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 1px rgba(224, 192, 120, 0.45);
}

.combat-item.is-active {
  border-color: var(--gold-bright);
  color: var(--gold-bright);
}

.combat-item .combat-handle {
  font-family: var(--font-display);
  color: var(--muted, #8b7355);
  letter-spacing: 0.08em;
}

.combat-item .combat-avatar,
.combat-item .combat-avatar-fallback {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  border: 2px solid var(--gold);
  object-fit: cover;
  flex-shrink: 0;
  background: #0a0705;
}

.combat-item .combat-avatar-fallback {
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--gold);
}

.combat-item .combat-name {
  flex: 1;
  font-family: var(--font-display);
}

.combat-item .combat-hp {
  min-width: 7.5rem;
  max-width: 9rem;
}

.combat-banner-hp {
  margin-top: 0.45rem;
  min-width: min(280px, 55vw);
}

.hp-banner {
  margin: 0.35rem 0 0.85rem;
  max-width: 320px;
}

.hp-bar {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
}

.hp-bar-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  font-family: var(--font-display);
}

.hp-bar-label {
  color: rgba(196, 163, 90, 0.9);
  letter-spacing: 0.06em;
  font-size: 0.8rem;
}

.hp-bar-nums {
  color: var(--parchment);
  font-size: 0.95rem;
}

.hp-bar-track {
  width: 100%;
  height: 0.85rem;
  border-radius: 999px;
  background: rgba(10, 7, 5, 0.75);
  border: 1px solid rgba(196, 163, 90, 0.45);
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.45);
}

.hp-bar-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  transition: width 0.35s ease, background 0.35s ease;
}

.hp-bar-sm .hp-bar-track {
  height: 0.55rem;
}

.hp-bar-sm .hp-bar-nums,
.hp-bar-sm .hp-bar-label {
  font-size: 0.75rem;
}

.hp-bar-lg .hp-bar-track {
  height: 1.15rem;
}

.hp-bar-lg .hp-bar-nums {
  font-size: 1.15rem;
}

.hp-bar-lg .hp-bar-label {
  font-size: 0.9rem;
}

.hp-ok .hp-bar-fill {
  background: linear-gradient(90deg, #16a34a, #4ade80);
}

.hp-warn .hp-bar-fill {
  background: linear-gradient(90deg, #ca8a04, #facc15);
}

.hp-crit .hp-bar-fill {
  background: linear-gradient(90deg, #b91c1c, #f87171);
}

.hp-ok .hp-bar-nums {
  color: #4ade80;
}

.hp-warn .hp-bar-nums {
  color: #facc15;
}

.hp-crit .hp-bar-nums {
  color: #f87171;
}

.hp-editor {
  display: grid;
  gap: 0.4rem;
  margin-top: 0.15rem;
}

.combat-banner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 7;
  display: flex;
  justify-content: center;
  padding: clamp(0.85rem, 2vw, 1.4rem) clamp(1rem, 3vw, 2.5rem) 0;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-18px);
  transition: opacity 0.35s ease, transform 0.4s ease;
}

.combat-banner.visible {
  opacity: 1;
  transform: translateY(0);
}

.combat-banner-inner {
  display: flex;
  align-items: center;
  gap: clamp(0.85rem, 2vw, 1.25rem);
  min-width: min(460px, 92vw);
  text-align: left;
  padding: 0.75rem 1.35rem 0.85rem 0.85rem;
  background:
    linear-gradient(180deg, rgba(61, 41, 20, 0.97), rgba(26, 18, 11, 0.98));
  border: 3px solid var(--gold);
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}

.combat-banner-portrait {
  position: relative;
  width: clamp(72px, 10vw, 110px);
  aspect-ratio: 1;
  border-radius: 12px;
  border: 2px solid var(--gold-bright);
  overflow: hidden;
  background: #0a0705;
  flex-shrink: 0;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
}

.combat-banner-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.combat-banner-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--gold);
  background: rgba(26, 18, 11, 0.9);
}

.combat-banner-fallback.hidden,
.combat-banner-portrait img.hidden {
  display: none;
}

.combat-banner-text {
  min-width: 0;
  flex: 1;
}

.combat-banner-title {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2.6vw, 2rem);
  color: var(--gold-bright);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 0 2px 6px #000;
}

.combat-banner-turn {
  margin-top: 0.25rem;
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 2vw, 1.45rem);
  color: var(--parchment);
  text-shadow: 0 2px 6px #000;
}

.dialogue-bar {
  --dialogue-portrait: clamp(320px, 52vh, 680px);
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0 clamp(1.25rem, 3vw, 2.75rem) clamp(0.85rem, 2vw, 1.5rem);
  pointer-events: none;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.4s ease, transform 0.45s ease;
}

.dialogue-bar.visible {
  opacity: 1;
  transform: translateY(0);
}

.dialogue-frame {
  width: 100%;
  min-height: clamp(150px, 22vh, 240px);
  margin-top: 0;
  padding: clamp(1rem, 2vw, 1.35rem) clamp(1.25rem, 4vw, 3rem) clamp(1.15rem, 2.4vw, 1.8rem);
  background:
    linear-gradient(180deg, rgba(61, 41, 20, 0.97), rgba(26, 18, 11, 0.98));
  border: 3px solid var(--gold);
  border-radius: 16px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55);
}

.dialogue-portrait {
  position: relative;
  z-index: 2;
  align-self: center;
  width: max-content;
  height: auto;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  flex-shrink: 0;
  line-height: 0;
}

.dialogue-portrait img {
  display: block;
  width: auto;
  height: var(--dialogue-portrait);
  max-width: min(78vw, 760px);
  object-fit: contain;
  background: transparent;
}

.dialogue-portrait-fallback {
  position: static;
  display: grid;
  place-items: center;
  min-width: 4.5rem;
  min-height: 4.5rem;
  font-family: var(--font-display);
  font-size: clamp(3rem, 6vw, 5rem);
  line-height: 1;
  color: var(--gold);
  background: transparent;
}

.dialogue-portrait-fallback.hidden {
  display: none;
}

.dialogue-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  width: 100%;
  margin: 0;
  text-align: left;
}

.dialogue-name {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3.6vw, 3rem);
  color: var(--gold-bright);
  letter-spacing: 0.06em;
  padding-bottom: 0.4rem;
  margin-bottom: 0.65rem;
  border-bottom: 2px solid rgba(196, 163, 90, 0.55);
  text-shadow: 0 2px 8px #000;
}

.dialogue-text {
  align-self: stretch;
  width: 100%;
  font-family: var(--font-display);
  font-size: clamp(1.45rem, 2.8vw, 2.35rem);
  line-height: 1.4;
  color: var(--parchment);
  text-shadow: 0 2px 8px #000;
  white-space: pre-wrap;
}

.dialogue-text .dialogue-cursor {
  display: inline-block;
  width: 0.55ch;
  margin-left: 1px;
  border-right: 2px solid var(--gold-bright);
  animation: dialogue-blink 0.9s steps(1) infinite;
}

@keyframes dialogue-blink {
  50% {
    opacity: 0;
  }
}

@media (max-width: 700px) {
  .dialogue-bar {
    --dialogue-portrait: min(220px, 46vw);
  }

  .dialogue-frame {
    min-height: 0;
    padding-inline: 1rem;
  }

  .dialogue-name {
    font-size: 1.55rem;
  }

  .dialogue-text {
    font-size: 1.25rem;
  }
}

.tv-arm {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(10, 7, 5, 0.82);
  z-index: 20;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--gold);
  color: var(--gold-bright);
  font-size: 0.8rem;
}

.inv-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  gap: 0.4rem;
  align-items: center;
}

.inv-row input[type='number'] {
  width: 4.5rem;
}

.qty-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0;
}

/* Ornat-Rahmen (border-image / 9-Slice) */
.ui-frame {
  position: relative;
  box-sizing: border-box;
  padding: var(--ui-frame-pad);
  color: var(--parchment);
  background: transparent;
  border-style: solid;
  border-width: var(--ui-frame-width);
  border-image-source: url('/img/frame-panel.png');
  border-image-slice: var(--ui-frame-slice) fill;
  border-image-width: var(--ui-frame-width);
  border-image-repeat: stretch;
  border-image-outset: 0;
}

.ui-frame-lg {
  --ui-frame-width: 52px;
  --ui-frame-slice: 96;
  --ui-frame-pad: 0.5rem 1rem;
}

.ui-frame-sm {
  --ui-frame-width: 28px;
  --ui-frame-slice: 80;
  --ui-frame-pad: 0.25rem 0.55rem;
}

/* Lobby-Leiter Story: PC-Bedienung → kompaktere Buttons */
.page-leiter .btn {
  min-height: 30px;
  padding: 0.3rem 0.7rem;
  font-size: 0.82rem;
  border-radius: 7px;
  border-width: 1px;
}

.page-leiter .qty-btn {
  min-width: 28px;
  min-height: 28px;
  font-size: 0.85rem;
}

.page-leiter .btn-row {
  gap: 0.4rem;
  margin-top: 0.65rem;
}

.page-leiter .figure-card-actions {
  gap: 0.35rem;
}

.hidden {
  display: none !important;
}

.page-spieler .add-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 5.5rem auto;
  gap: 0.6rem;
  align-items: end;
  margin-top: 1rem;
}

.page-spieler .add-item label {
  margin-top: 0;
}

.page-spieler .add-item-qty input {
  width: 100%;
}

.page-spieler .inv-row {
  grid-template-columns: minmax(0, 1fr) auto minmax(3.2rem, 4.5rem) auto auto;
}

.page-spieler .inv-row input[type='text'],
.page-spieler .inv-row input[type='number'] {
  min-width: 0;
  width: 100%;
}

.page-spieler .btn-row > .btn,
.page-spieler .sheet-head > .btn,
.page-spieler .list-item > .btn {
  flex-shrink: 0;
}

.page-spieler .sheet-head h2 {
  min-width: 0;
  overflow-wrap: anywhere;
}

.page-spieler .points-banner {
  max-width: 100%;
  white-space: normal;
}

@media (max-width: 700px) {
  .page {
    width: min(100% - 1rem, 1100px);
    padding-top: 1rem;
  }

  .inv-row {
    grid-template-columns: 1fr 4.5rem;
  }

  .inv-row .qty-btn,
  .inv-row .del-btn {
    grid-column: span 1;
  }

  .map-token {
    width: 44px;
    height: 44px;
    margin-left: -22px;
    margin-top: -22px;
  }

  .page-spieler {
    width: min(100% - 0.75rem, 1100px);
  }

  .page-spieler .panel {
    padding: 0.9rem 0.75rem;
  }

  .page-spieler .topbar {
    align-items: flex-start;
  }

  .page-spieler .sheet-head {
    flex-wrap: nowrap;
    gap: 0.5rem;
  }

  .page-spieler .sheet-head .btn {
    padding-inline: 0.7rem;
  }

  .page-spieler .btn-row {
    flex-direction: column;
    align-items: stretch;
  }

  .page-spieler .btn-row > .btn {
    width: 100%;
  }

  .page-spieler .list-item {
    flex-wrap: wrap;
    align-items: center;
  }

  .page-spieler .list-item > .btn {
    flex: 1 1 100%;
  }

  .page-spieler .attr-grid {
    grid-template-columns: 1fr;
  }

  .page-spieler .attr-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .page-spieler .attr-row strong {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .page-spieler .class-grid {
    grid-template-columns: 1fr;
  }

  .page-spieler .add-item {
    grid-template-columns: minmax(0, 1fr) 5.25rem;
  }

  .page-spieler .add-item > .btn {
    grid-column: 1 / -1;
    width: 100%;
  }

  .page-spieler .inv-row {
    grid-template-columns: 44px minmax(0, 1fr) 44px 44px;
    gap: 0.45rem;
  }

  .page-spieler .inv-row > input[type='text'] {
    grid-column: 1 / -1;
  }

  .page-spieler .inv-row .qty-btn {
    width: 44px;
    min-width: 44px;
    padding: 0;
  }
}
