/* Fenster im HUD-Stil (Farben aus hud.css): Inventar, Laden, Crafting,
   Quests, Kontextmenü, Beute-Leiste, Anmeldung. Überschreibt ui.css. */

/* ── Gemeinsamer Fensterrahmen ────────────────────── */
#inventory-container,
#shop-container,
#quest-container,
#crafting-container,
#auth-container,
.item-context-menu {
  background: var(--panel-solid);
  border: 3px solid var(--ink);
  box-shadow: inset 0 0 0 2px var(--brass-dark), 0 6px 0 rgba(0, 0, 0, 0.4), 0 12px 40px rgba(0, 0, 0, 0.5);
  border-radius: 14px;
  color: var(--cream);
  font-family: var(--font-pixel);
}

#inventory-container,
#shop-container,
#quest-container,
#crafting-container {
  width: min(560px, calc(100% - 16px));
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 14px;
  z-index: 2800;
}

/* Kopfzeile: Titel in Gold, Schließen-Knopf rechts */
#inventory-header,
#shop-header,
#quest-header,
#crafting-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -2px -2px 12px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--brass-dark);
}

#inventory-header h3,
#shop-header h3,
#quest-header h3,
#crafting-header h3 {
  flex: 1;
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 2px 0 var(--ink);
}

#inventory-close,
#shop-close,
#quest-close,
#crafting-close {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 8px;
  border: 2px solid var(--ink);
  background: #2a352c;
  color: var(--cream);
  font-family: var(--font-pixel);
  font-size: 18px;
  cursor: pointer;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25);
}

/* Unterüberschriften */
#inventory-container h4,
#quest-objectives h4,
#quest-rewards h4 {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 8px;
}

/* NPC-Sprechzeile */
#shop-npc-message,
#quest-npc-message,
#crafting-npc-message {
  background: #232e25;
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  color: var(--cream);
  font-size: 14px;
  line-height: 1.35;
  font-style: normal;
  position: relative;
}

#shop-npc-message:empty,
#quest-npc-message:empty,
#crafting-npc-message:empty {
  display: none;
}

/* Knöpfe (Kaufen, Annehmen, Herstellen …) */
#shop-action-btn,
#quest-action-btn,
.craft-btn,
.item-context-menu button,
.sell-btn-inline,
#auth-submit {
  font-family: var(--font-pixel);
  font-weight: 700;
  color: var(--cream);
  background: #3f7a45;
  border: 2px solid var(--ink);
  border-radius: 9px;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25), inset 0 2px 0 rgba(255, 255, 255, 0.12);
  cursor: pointer;
  text-shadow: 0 1px 0 var(--ink);
}

#shop-action-btn:active,
#quest-action-btn:active,
.craft-btn:active,
.item-context-menu button:active,
.sell-btn-inline:active,
#auth-submit:active {
  transform: translateY(2px);
  box-shadow: none;
}

#shop-action-btn:disabled,
.craft-btn:disabled {
  background: #3a3f3a;
  color: var(--muted);
  cursor: default;
}

/* ── Item-Icons ───────────────────────────────────── */
.item-icon {
  display: inline-block;
  flex: none;
  width: var(--u, 32px);
  height: var(--u, 32px);
  background-image: var(--items-img, url('/assets/ui/items.png'));
  background-repeat: no-repeat;
  background-size: calc(var(--u, 32px) * var(--n, 31)) var(--u, 32px);
  background-position: calc(var(--i, 30) * var(--u, 32px) * -1) 0;
  image-rendering: pixelated;
  vertical-align: middle;
}

/* Seltenheit als Rahmenfarbe der Felder */
.rarity-common { --rar: #8c6a35; }
.rarity-uncommon { --rar: #6fcf5a; }
.rarity-rare { --rar: #5aa7ff; }
.rarity-epic { --rar: #c77dff; }
.rarity-legendary { --rar: #f2c75c; }

/* ── Inventar ─────────────────────────────────────── */
#inventory-container {
  display: none;
}

#inventory-equipment {
  display: grid;
  /* 2×2: Waffe, Nebenhand, Rüstung, Schmuck — vier nebeneinander wären am Handy zu eng */
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

#inventory-equipment h4 {
  grid-column: 1 / -1;
}

.equip-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 6px;
  background: #232e25;
  border: 2px solid var(--ink);
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(217, 184, 110, 0.2);
  min-height: 78px;
  justify-content: center;
}

.equip-slot .slot-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.equip-slot .slot-item {
  font-size: 12px;
  color: var(--cream);
  text-align: center;
}

#stat-role {
  margin-left: auto;
  color: var(--gold);
}

.equip-slot .slot-item.empty {
  color: #6c7a68;
}

#inventory-stats {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #232e25;
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 14px;
}

#inventory-stats h4 {
  margin: 0;
}

#inventory-stats div {
  margin: 0;
}

#stat-attack { color: #ff8a7a; }
#stat-defense { color: #8fc2ff; }
#stat-maxhealth { color: #9bd46a; }

#inventory-grid {
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
  max-height: 44vh;
  padding: 8px;
  background: #121912;
  border: 2px solid var(--ink);
  border-radius: 10px;
}

.inventory-slot {
  background: #232e25;
  border: 2px solid var(--rar, var(--ink));
  border-radius: 9px;
  min-height: 80px;
  padding: 6px 4px 4px;
  gap: 3px;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25);
  transition: transform 0.08s, background 0.15s;
}

.inventory-slot:hover {
  background: #2e3b30;
  border-color: var(--rar, var(--brass));
  transform: translateY(-1px);
}

.inventory-slot .item-name {
  font-size: 11px;
  line-height: 1.1;
  color: var(--cream);
  text-align: center;
}

.inventory-slot .item-quantity {
  top: 4px;
  right: 5px;
  bottom: auto;
  font-size: 12px;
  color: var(--gold);
  text-shadow: 0 1px 0 var(--ink), 0 0 2px var(--ink);
}

#inventory-gold {
  margin-top: 10px;
  font-size: 16px;
  color: var(--gold);
  text-align: right;
}

/* Kontextmenü eines Items */
.item-context-menu {
  border-radius: 12px;
  padding: 6px;
  min-width: 190px;
  z-index: 3100;
  overflow: hidden;
}

.item-context-menu > div {
  border-bottom-color: var(--brass-dark) !important;
  font-family: var(--font-pixel);
}

.item-context-menu button {
  display: block;
  width: 100%;
  margin: 6px 0 0;
  padding: 9px 12px;
  text-align: left;
  font-size: 14px;
}

.item-context-menu button:last-child {
  background: #3a3f3a;
}

/* ── Laden ────────────────────────────────────────── */
#shop-header #shop-gold {
  color: var(--gold);
  font-size: 14px;
  white-space: nowrap;
}

#shop-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.shop-tab {
  flex: 1;
  font-family: var(--font-pixel);
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  background: #232e25;
  border: 2px solid var(--ink);
  border-radius: 9px;
  padding: 8px;
  cursor: pointer;
}

.shop-tab.active {
  color: var(--ink);
  background: var(--brass);
}

#shop-items {
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  max-height: 36vh;
  background: #121912;
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 8px;
}

.shop-item {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "icon name" "icon price" "btn btn";
  align-items: center;
  column-gap: 8px;
  row-gap: 2px;
  background: #232e25;
  border: 2px solid var(--ink);
  border-left: 4px solid var(--rar, var(--ink)) !important;
  border-radius: 9px;
  padding: 7px;
  position: relative;
  text-align: left;
}

.shop-item .item-icon {
  grid-area: icon;
}

.shop-item .item-name {
  grid-area: name;
  font-size: 12px;
  color: var(--cream);
  line-height: 1.1;
}

.shop-item .item-price {
  grid-area: price;
  font-size: 12px;
  color: var(--gold);
}

.shop-item .item-stock {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 10px;
  color: var(--muted);
}

.shop-item .sell-btn-row {
  grid-area: btn;
  margin-top: 4px;
}

.shop-item.selected {
  background: #33422f;
  box-shadow: inset 0 0 0 2px var(--brass);
}

.sell-btn-inline {
  padding: 5px 8px;
  font-size: 11px;
}

.sell-btn-inline.sell-btn-all {
  background: #3e5f8a;
}

#shop-item-details {
  margin-top: 10px;
  background: #232e25;
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 12px;
  min-height: 0;
}

#shop-item-name {
  color: var(--gold);
  font-size: 17px;
}

#shop-item-desc {
  color: var(--cream);
  font-size: 13px;
}

#shop-item-stats {
  color: #9bd46a;
  font-size: 13px;
}

#shop-item-price {
  color: var(--gold);
  font-size: 14px;
}

#shop-action-btn {
  margin-top: 8px;
  padding: 10px 22px;
  font-size: 16px;
}

/* ── Crafting ─────────────────────────────────────── */
#crafting-recipes {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.crafting-recipe {
  background: #232e25;
  border: 2px solid var(--ink);
  border-left: 4px solid var(--rar, var(--ink));
  border-radius: 10px;
  padding: 10px 12px;
}

.crafting-recipe-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}

.crafting-recipe-header .recipe-stats {
  margin-left: auto;
}

.recipe-name {
  flex: 0 1 auto;
  text-align: left;
  font-size: 16px;
  color: var(--cream);
  font-weight: 700;
}

.recipe-stats {
  font-size: 12px;
  color: #9bd46a;
}

.recipe-desc {
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0;
}

.recipe-ingredients {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 8px;
}

.ingredient {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 3px 8px 3px 4px;
  border-radius: 7px;
  border: 2px solid var(--ink);
  background: #1a221c;
}

.ingredient-have {
  color: #b9e6a0;
}

.ingredient-missing {
  color: #ff9a8f;
  background: #2e1c1a;
}

.craft-btn {
  padding: 8px 20px;
  font-size: 15px;
}

/* ── Quests ───────────────────────────────────────── */
#quest-content {
  flex-direction: column;
  gap: 10px;
}

#quest-list,
#quest-details {
  background: #121912;
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 8px;
  max-height: none;
}

.quest-item {
  background: #232e25;
  border: 2px solid var(--ink);
  border-radius: 9px;
  padding: 9px 10px;
  margin-bottom: 6px;
  color: var(--cream);
  cursor: pointer;
}

.quest-item.quest-available { border-left: 4px solid var(--gold); }
.quest-item.quest-active { border-left: 4px solid #5aa7ff; }
.quest-item.quest-completed { border-left: 4px solid #9bd46a; }

.quest-item.selected {
  box-shadow: inset 0 0 0 2px var(--brass);
}

#quest-title {
  font-size: 18px;
  color: var(--gold);
  margin-bottom: 6px;
}

#quest-desc {
  font-size: 13px;
  color: var(--cream);
  line-height: 1.35;
  margin-bottom: 10px;
}

.quest-objective {
  font-size: 13px;
  color: var(--cream);
}

.reward-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--gold);
  background: #232e25;
  border: 2px solid var(--ink);
  border-radius: 7px;
  padding: 3px 8px;
  margin: 0 6px 6px 0;
}

#quest-action-btn {
  margin-top: 8px;
  padding: 10px 22px;
  font-size: 16px;
}

/* Tracker */
.tracker-quest-name {
  color: var(--cream);
  font-family: var(--font-pixel);
}

.tracker-objective {
  color: var(--muted);
  font-family: var(--font-pixel);
}

.tracker-objective.complete {
  color: #9bd46a;
}

.tracker-empty {
  color: var(--muted);
  font-size: 12px;
}

/* ── Beute-Leiste ─────────────────────────────────── */
#toast-feed {
  position: fixed;
  z-index: 2700;
  right: 12px;
  top: 76px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  pointer-events: none;
}

body.touch-device #toast-feed {
  right: auto;
  left: 50%;
  transform: translateX(-50%);
  top: calc(96px + env(safe-area-inset-top));
  align-items: center;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 6px;
  background: var(--panel);
  border: 2px solid var(--ink);
  border-left: 4px solid var(--rar, var(--brass));
  border-radius: 10px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
  font-family: var(--font-pixel);
  color: var(--cream);
  font-size: 14px;
  animation: toast-in 0.22s ease-out;
  transition: opacity 0.3s, transform 0.3s;
}

.toast-qty {
  color: var(--gold);
  font-weight: 700;
}

.toast-text {
  padding: 7px 12px;
}

.toast-gold { color: var(--gold); }
.toast-bad { border-left-color: #e0493f; }

.toast.is-bump .toast-qty {
  animation: toast-bump 0.25s ease-out;
}

.toast.is-leaving {
  opacity: 0;
  transform: translateY(-8px);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

@keyframes toast-bump {
  50% { transform: scale(1.35); }
}

/* ── Anmeldung ────────────────────────────────────── */
#auth-overlay {
  background: radial-gradient(ellipse at 50% 30%, #2b3b2d 0%, #18211b 55%, #0d130f 100%);
}

#auth-container {
  width: min(360px, calc(100% - 24px));
  padding: 22px 20px;
}

#auth-title {
  font-family: var(--font-pixel);
  font-size: 30px;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 3px 0 var(--ink);
}

.auth-tab {
  font-family: var(--font-pixel);
  font-size: 15px;
  color: var(--muted);
  background: #232e25;
  border: 2px solid var(--ink);
  border-radius: 9px;
}

.auth-tab.active {
  color: var(--ink);
  background: var(--brass);
}

.auth-field label {
  font-family: var(--font-pixel);
  color: var(--muted);
}

.auth-field input {
  font-family: var(--font-pixel);
  font-size: 16px;
  color: var(--cream);
  background: #121912;
  border: 2px solid var(--ink);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(217, 184, 110, 0.25);
}

#auth-submit {
  font-size: 17px;
  padding: 11px;
}

#auth-continue {
  font-family: var(--font-pixel);
  font-size: 15px;
  background: #2a352c;
  color: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 9px;
  padding: 9px 20px;
  cursor: pointer;
}

#auth-continue-row {
  margin-top: 12px;
  text-align: center;
}

#auth-continue-name {
  color: var(--gold);
}

#auth-hint {
  margin-top: 12px;
  font-family: var(--font-pixel);
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
  text-align: center;
}

#auth-message,
#auth-loading {
  font-family: var(--font-pixel);
}

/* Handy: Fenster fast bildschirmbreit, Laden-Raster zweispaltig */
body.touch-device #shop-items {
  grid-template-columns: repeat(2, 1fr);
}

body.touch-device #inventory-grid {
  grid-template-columns: repeat(4, 1fr);
}

/* Dienste eines NPCs im Gespräch (Laden, Schmiede, Brauen) */
#quest-services {
  display: flex;
  gap: 8px;
  margin: -4px 0 12px;
}

.quest-service-btn {
  --u: 26px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 12px;
  font-family: var(--font-pixel);
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  background: var(--brass);
  border: 2px solid var(--ink);
  border-radius: 9px;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

.quest-service-btn .ui-icon {
  filter: brightness(0.25);
}

/* Handy: pro Fenster genau EIN Scrollbereich. Verschachtelte Listen mit
   eigenem overflow fingen den Wisch ab — gescrollt hat es nur, wenn der
   Finger zufällig auf der richtigen Fläche lag. */
body.touch-device #inventory-container,
body.touch-device #shop-container,
body.touch-device #quest-container,
body.touch-device #crafting-container {
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

body.touch-device #inventory-grid,
body.touch-device #shop-items,
body.touch-device #quest-list,
body.touch-device #quest-details,
body.touch-device #crafting-recipes {
  max-height: none;
  overflow: visible;
}

/* ── Angepinnte Quests (Tracker) ──────────────────── */
#quest-tracker {
  cursor: pointer;
  width: 220px;
  padding: 8px 10px;
}

#quest-tracker .tracker-quest {
  margin-bottom: 8px;
}

#quest-tracker .tracker-quest:last-child {
  margin-bottom: 0;
}

#quest-tracker .tracker-quest-name {
  font-size: 13px;
  color: var(--gold);
  text-shadow: 0 1px 0 var(--ink);
}

#quest-tracker .tracker-objective {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 6px;
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--cream);
}

#quest-tracker .tracker-objective .quest-bar {
  grid-column: 1 / -1;
}

.tracker-obj-count {
  color: var(--muted);
}

#quest-tracker .tracker-objective.is-return {
  display: block;
  color: #9bd46a;
}

#quest-tracker .tracker-quest.is-ready .tracker-quest-name::before {
  content: '? ';
  color: #9bd46a;
}

/* Fortschrittsbalken (Tracker und Tagebuch) */
.quest-bar {
  display: block;
  height: 4px;
  margin-top: 2px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 2px;
  overflow: hidden;
}

.quest-bar-fill {
  display: block;
  height: 100%;
  background: var(--brass);
  transition: width 0.4s ease-out;
}

.is-done .quest-bar-fill,
.is-ready .quest-bar-fill {
  background: #9bd46a;
}

/* ── Quest-Tagebuch ───────────────────────────────── */
#quest-journal {
  position: fixed;
  inset: 0;
  z-index: 2900;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 9, 0.55);
  padding: 16px;
  overflow-y: auto;
}

#quest-journal[hidden] {
  display: none;
}

.journal-sheet {
  width: min(520px, 100%);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: var(--panel-solid);
  border: 3px solid var(--ink);
  box-shadow: inset 0 0 0 2px var(--brass-dark), 0 6px 0 rgba(0, 0, 0, 0.4), 0 12px 40px rgba(0, 0, 0, 0.5);
  border-radius: 14px;
  color: var(--cream);
  font-family: var(--font-pixel);
  padding: 14px;
}

.journal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 2px solid var(--brass-dark);
}

.journal-title {
  flex: 1;
  font-size: 22px;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 2px 0 var(--ink);
}

.journal-pins {
  font-size: 12px;
  color: var(--muted);
}

.journal-empty {
  color: var(--muted);
  font-size: 14px;
  padding: 12px 4px;
}

.journal-card {
  background: rgba(0, 0, 0, 0.25);
  border: 2px solid var(--ink);
  box-shadow: inset 0 0 0 1px rgba(140, 106, 53, 0.5);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

.journal-card.is-pinned {
  box-shadow: inset 0 0 0 2px var(--brass-dark);
}

.journal-card.is-ready {
  box-shadow: inset 0 0 0 2px #5f8f3e;
}

.journal-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.journal-card-name {
  flex: 1;
  font-size: 16px;
  font-weight: 700;
  color: var(--gold);
}

.journal-pin {
  font-family: var(--font-pixel);
  font-size: 13px;
  min-width: 72px;
  min-height: 34px;
  padding: 4px 10px;
  border-radius: 8px;
  border: 2px solid var(--ink);
  background: #2a352c;
  color: var(--muted);
  cursor: pointer;
}

.journal-pin[aria-pressed='true'] {
  background: var(--brass-dark);
  color: var(--cream);
}

.journal-card-giver {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.is-ready .journal-card-giver {
  color: #9bd46a;
}

.journal-card-desc {
  font-size: 13px;
  line-height: 1.35;
  margin: 8px 0;
  color: var(--cream);
  opacity: 0.9;
}

.journal-objectives {
  margin: 6px 0 8px;
}

.journal-obj {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  column-gap: 6px;
  align-items: center;
  font-size: 13px;
  margin-bottom: 6px;
}

.journal-obj .quest-bar {
  grid-column: 2 / -1;
}

.journal-obj-check {
  color: #9bd46a;
  font-weight: 700;
}

.journal-obj-count {
  color: var(--muted);
}

.journal-obj.is-done .journal-obj-text {
  color: var(--muted);
}

.journal-rewards {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(140, 106, 53, 0.5);
  font-size: 12px;
}

.journal-rewards-label {
  color: var(--muted);
  margin-right: 2px;
}

.journal-reward {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.35);
}

.journal-reward.is-xp {
  color: #9bd46a;
}

.journal-reward.is-gold {
  color: var(--gold);
}

/* Tracker-Kurzfassung (Handy): klein, halbtransparent, eine Zeile je Quest */
body.touch-device #quest-tracker.is-compact {
  width: auto;
  max-width: min(190px, calc(100% - 16px));
  padding: 5px 8px;
  background: rgba(24, 33, 27, 0.55);
  box-shadow: inset 0 0 0 1px rgba(140, 106, 53, 0.6);
  border-width: 1px;
}

.tracker-line {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  font-family: var(--font-pixel);
  font-size: 12px;
  line-height: 1.5;
  color: var(--cream);
  text-shadow: 0 1px 0 var(--ink);
}

.tracker-line-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tracker-line-count {
  color: var(--gold);
  flex: none;
}

.tracker-line.is-ready .tracker-line-text,
.tracker-line.is-ready .tracker-line-count {
  color: #9bd46a;
}

/* Kopfzeile mit Schließen-Knopf bleibt beim Scrollen oben stehen
   (die Fenster scrollen als Ganzes; ihr Innenabstand ist 14 px) */
#inventory-header,
#shop-header,
#quest-header,
#crafting-header,
.journal-head {
  position: sticky;
  top: -14px;
  z-index: 5;
  background: var(--panel-solid);
  margin-top: -14px;
  padding-top: 14px;
  box-shadow: 0 6px 8px -6px rgba(0, 0, 0, 0.6);
}

/* Handy: Fenster haben dort 10 px Innenabstand (mobile.css) */
body.touch-device #inventory-header,
body.touch-device #shop-header,
body.touch-device #quest-header,
body.touch-device #crafting-header {
  top: -10px;
  margin-top: -10px;
  padding-top: 10px;
}

/* Pin-Farbpunkt: gleiche Farbe wie Pfeil und Kartenmarker */
.q-dot {
  display: inline-block;
  flex: none;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 2px;
  border: 1px solid var(--ink);
  vertical-align: 1px;
}

.q-dot.is-off {
  display: none;
}

.tracker-line {
  align-items: center;
}

.tracker-line .q-dot {
  margin-right: 0;
}

#quest-tracker .tracker-quest.is-ready .tracker-quest-name::before {
  content: none;
}

/* ── Snappy: Fenster ploppen auf, Knöpfe geben beim Drücken nach ── */
@keyframes ui-pop {
  from { opacity: 0; transform: var(--pop-base, translate(0, 0)) scale(0.94); }
  to { opacity: 1; transform: var(--pop-base, translate(0, 0)) scale(1); }
}

.ui-pop {
  animation: ui-pop 140ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

/* zentrierte Fenster tragen translate(-50%, -50%) — beim Poppen behalten */
#inventory-container.ui-pop,
#shop-container.ui-pop,
#quest-container.ui-pop,
#crafting-container.ui-pop {
  --pop-base: translate(-50%, -50%);
}

button,
.menu-tile,
.hud-btn,
.inventory-slot,
.shop-item,
.quest-item,
.recipe-item {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button {
  transition: transform 70ms ease-out, filter 70ms ease-out;
}

button:active:not(:disabled) {
  transform: scale(0.95);
  filter: brightness(1.12);
}

.inventory-slot:active,
.shop-item:active,
.quest-item:active,
.recipe-item:active {
  transform: scale(0.97);
  filter: brightness(1.15);
}

/* Neue Aufträge (Quest-Zeichen „!“) in Tracker und Tagebuch */
.is-offer,
.is-offer .tracker-line-text {
  color: var(--cream);
}

#quest-tracker .tracker-objective.is-offer {
  display: block;
}

.journal-offers {
  border: 2px dashed rgba(246, 234, 206, 0.35);
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 10px;
}

.journal-offers-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 4px;
}

.journal-offer {
  font-size: 13px;
  color: var(--cream);
  line-height: 1.5;
}

/* aufgeklappter Tracker: Auftragszeile darf umbrechen, nie über den Rand */
#quest-tracker .tracker-objective.is-offer .tracker-line-text {
  white-space: normal;
  overflow-wrap: anywhere;
}

/* ── Figurenwahl („Look“) ─────────────────────────── */
#look-picker {
  position: fixed;
  inset: 0;
  z-index: 2900;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 9, 0.55);
  padding: 16px;
}

#look-picker[hidden] {
  display: none;
}

.look-sheet {
  width: min(520px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--brass-dark) transparent;
  background: var(--panel-solid);
  border: 3px solid var(--ink);
  box-shadow: inset 0 0 0 2px var(--brass-dark), 0 6px 0 rgba(0, 0, 0, 0.4), 0 12px 40px rgba(0, 0, 0, 0.5);
  border-radius: 14px;
  padding: 14px;
  color: var(--cream);
  font-family: var(--font-pixel);
}

.look-sheet .journal-head {
  position: sticky;
  top: -14px;
  margin-top: -14px;
  padding-top: 14px;
  background: var(--panel-solid);
  z-index: 2;
}

.look-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
}

.look-choice {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid var(--ink);
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(140, 106, 53, 0.4);
  cursor: pointer;
  padding: 0;
}

.look-choice.is-on {
  background: rgba(217, 184, 110, 0.18);
  box-shadow: inset 0 0 0 2px var(--gold);
}

/* 24×24-Bild aus dem 4×4-Blatt (96×96), 3-fach, erstes Bild = nach unten */
.look-face,
.menu-look-face {
  display: block;
  width: 72px;
  height: 72px;
  background-repeat: no-repeat;
  background-size: 288px 288px;
  background-position: 0 0;
  image-rendering: pixelated;
}

.menu-look-face {
  width: 40px;
  height: 40px;
  margin: -2px 0 0;
  background-size: 160px 160px;
  background-image: url(/assets/sprites/characters/FD_Character_001.png);
}

/* Zutaten zu Herstell-Zielen (Questfenster, Tagebuch, Tracker) */
.craft-needs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  margin: 2px 0 8px 22px;
  font-size: 12px;
  color: var(--muted);
}
.craft-needs-label {
  flex-basis: 100%;
}
.craft-needs.is-ready .craft-needs-label {
  color: #9bd46a;
}
.craft-need {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px 1px 2px;
  border: 1px solid rgba(140, 106, 53, 0.6);
  border-radius: 6px;
  background: rgba(20, 26, 21, 0.6);
  color: var(--cream);
}
.craft-need.is-have {
  color: #9bd46a;
}
#quest-tracker .craft-needs {
  margin: 1px 0 3px;
  font-size: 10px;
  gap: 2px 4px;
}
#quest-objectives .craft-needs {
  margin-left: 0;
}

/* ── Berufe (SkillsUI) ────────────────────────────── */
#skills-window {
  position: fixed;
  inset: 0;
  z-index: 2900;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 9, 0.55);
  padding: 16px;
}

#skills-window[hidden] { display: none; }

.skills-sheet { width: min(440px, 100%); }

.skill-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 16px;
}

.skill-lv { color: var(--gold); font-weight: 700; }

.skill-bar {
  position: relative;
  height: 14px;
  margin: 6px 0;
  background: #10160f;
  border: 2px solid var(--ink);
  border-radius: 6px;
  overflow: hidden;
}

.skill-bar i {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(180deg, #b7e0ff 0 45%, #9fd0ff 45% 100%);
}

.skill-bar span {
  position: relative;
  display: block;
  text-align: center;
  font-size: 10px;
  line-height: 10px;
  color: var(--cream);
  text-shadow: 0 1px 0 var(--ink);
}

.skill-next { font-size: 13px; color: var(--cream); }
.skill-perks { font-size: 12px; color: var(--muted); margin-top: 2px; }

.skill-open {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  font-size: 12px;
  color: #9bd46a;
}

.skills-hint { font-size: 12px; color: var(--muted); padding: 2px 4px; }

.recipe-locked { opacity: 0.7; }
.recipe-locked .craft-btn { font-size: 12px; }
