/* Gruppe Handel — Ausrüstungstausch.
 *
 * Skin-adaptiv über die --mobile-* / --space-* / --touch-target-* Tokens
 * (jeder Skin überschreibt die --mobile-* Farben am :root → passt automatisch
 * zu Antamar hell, Bombast, Simple, Classic, Pergament).
 *
 * WICHTIG: Diese Datei wird global geladen (html_head_css.inc.php). Alle
 * Seiten-Regeln sind daher unter `.gruppe-handel` gescoped, damit sie nicht
 * ins übrige Spiel-UI auslaufen (bare body/.button/.success etc.). Die
 * Modal-Regeln sind bewusst global: mBox hängt das Modal an <body>, also
 * außerhalb des .gruppe-handel-Wrappers — ihre Klassennamen sind eindeutig.
 */

/* ===================== Seite (gescoped) ===================== */
.gruppe-handel {
    text-align: center;
    color: var(--mobile-text);
    line-height: var(--mobile-line-height);
    padding: var(--space-md);
    box-sizing: border-box;
}

.gruppe-handel h1 {
    margin: var(--space-xs) 0 var(--space-sm);
    color: var(--mobile-text);
    font-size: var(--mobile-font-h1);
}

.gruppe-handel h2 {
    margin: var(--space-sm) 0;
    color: var(--mobile-text);
    font-size: var(--mobile-font-h2);
}

.gruppe-handel .small {
    font-size: 90%;
    color: var(--mobile-text-soft);
    margin-bottom: var(--space-md);
}

/* Helden-Uebersicht */
.gruppe-handel .helden_uebersicht {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    padding: var(--space-sm);
    background: var(--mobile-surface-2);
    border-radius: 6px;
}

.gruppe-handel .held_card {
    width: 100px;
    padding: var(--space-sm);
    border: 1px solid var(--mobile-border-soft);
    border-radius: 6px;
    background: var(--mobile-surface);
    text-align: center;
}

.gruppe-handel .held_card.eigener {
    border-color: var(--mobile-accent);
    background: var(--mobile-chip-bg);
}

.gruppe-handel .held_card.abwesend {
    opacity: 0.5;
}

.gruppe-handel .held_portrait {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gruppe-handel .held_portrait img,
.gruppe-handel .portrait_img {
    max-width: 70px;
    max-height: 70px;
    border-radius: 3px;
}

.gruppe-handel .held_name {
    font-weight: bold;
    font-size: 0.85em;
    margin-top: var(--space-xs);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gruppe-handel .held_status {
    font-size: 0.75em;
    color: var(--mobile-text-muted);
    margin-top: 3px;
}

.gruppe-handel .held_status.eigener_held {
    color: var(--mobile-accent);
}

/* Waren-Container */
.gruppe-handel .waren_container {
    margin-bottom: 60px;
}

.gruppe-handel .keine_items {
    padding: var(--space-md);
    color: var(--mobile-text-muted);
    font-style: italic;
}

/* Waren-Liste (Grid Layout) */
.gruppe-handel .waren_liste {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    justify-content: center;
    max-height: 400px;
    overflow-y: auto;
    padding: var(--space-sm);
    border: 1px solid var(--mobile-border-soft);
    border-radius: 6px;
    background: var(--mobile-surface-2);
}

/* Einzelnes Waren-Item */
.gruppe-handel .ware_item {
    width: 140px;
    padding: var(--space-sm);
    border: 1px solid var(--mobile-border-soft);
    border-radius: 6px;
    background: var(--mobile-surface);
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

.gruppe-handel .ware_item:hover,
.gruppe-handel .ware_item:active {
    border-color: var(--mobile-accent);
    background: var(--mobile-chip-bg);
}

.gruppe-handel .ware_item.marked_for_transfer {
    border-color: var(--mobile-accent-strong);
    background: var(--mobile-chip-bg);
}

.gruppe-handel .ware_item.komplett_vergeben {
    opacity: 0.5;
    cursor: default;
}

.gruppe-handel .ware_item.komplett_vergeben:hover,
.gruppe-handel .ware_item.komplett_vergeben:active {
    border-color: var(--mobile-border-soft);
    background: var(--mobile-surface);
}

/* Waren-Bild */
.gruppe-handel .ware_bild {
    position: relative;
    width: 50px;
    height: 50px;
    margin: 0 auto var(--space-sm);
}

.gruppe-handel .ware_bild img,
.gruppe-handel .ware_img {
    max-width: 50px;
    max-height: 50px;
    display: block;
    margin: 0 auto;
}

/* Anzahl-Badge */
.gruppe-handel .ware_anzahl {
    position: absolute;
    right: -5px;
    bottom: -5px;
    background: var(--mobile-accent);
    color: var(--mobile-accent-contrast);
    font-size: 0.75em;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
    /* Dunkler Text auf hellem Akzent-Chip: Bombast vererbt global einen dunklen
       text-shadow (body{1px 1px 0 #040404}) — auf dem Chip wirkt der matschig/"off".
       Badge ist ein flacher Chip → kein Schatten. (Auf anderen Skins No-op.) */
    text-shadow: none;
}

/* Waren-Name */
.gruppe-handel .ware_name {
    font-size: 0.85em;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Transfer-Marker */
.gruppe-handel .transfer_marker {
    font-size: 0.75em;
    color: var(--mobile-accent-strong);
    margin-top: var(--space-xs);
    font-weight: bold;
}

/* Geld-Element */
.gruppe-handel .geld_item {
    width: 140px;
    padding: var(--space-sm);
    border: 2px solid var(--bar-gold-color);
    border-radius: 6px;
    background: var(--mobile-surface);
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

.gruppe-handel .geld_item:hover,
.gruppe-handel .geld_item:active {
    background: var(--mobile-chip-bg);
}

.gruppe-handel .geld_item.marked_for_transfer {
    border-color: var(--mobile-accent-strong);
    background: var(--mobile-chip-bg);
}

.gruppe-handel .geld_item.komplett_vergeben {
    opacity: 0.5;
    cursor: default;
}

.gruppe-handel .geld_bild {
    width: 50px;
    height: 50px;
    margin: 0 auto var(--space-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.gruppe-handel .geld_bild img,
.gruppe-handel .geld_img {
    max-width: 50px;
    max-height: 50px;
}

.gruppe-handel .geld_betrag {
    font-size: 0.85em;
    text-align: center;
    font-weight: bold;
    color: var(--bar-gold-color);
}

/* Münz-Icons aus heller2preis an die Textgröße binden. Ohne das rendern die
   120×128-PNGs (dukat/silber/heller) in Originalgröße und sprengen das Geld-Kärtchen:
   die globale Fallback-Regel aus antamarGeneralv97.css greift hier nicht (Standalone-
   Seite lädt sie nicht, und es gibt keinen div.geld-Wrapper). Spiegelt deren Werte. */
.gruppe-handel .geld_betrag img {
    height: 1em;
    width: auto;
    vertical-align: -0.15em;
    margin: 0;
}

.gruppe-handel .geld_label {
    font-size: 0.85em;
    text-align: center;
    color: var(--mobile-text-muted);
    margin-top: 3px;
}

/* Handel abschliessen — Button-Leiste */
.gruppe-handel .handel_abschliessen {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--space-sm);
    background: var(--mobile-surface);
    border-top: 1px solid var(--mobile-border);
    text-align: center;
    z-index: 100;
}

.gruppe-handel .button {
    border: 1px solid var(--mobile-border);
    background-color: var(--mobile-surface-2);
    color: var(--mobile-text);
    padding: var(--space-sm) var(--space-lg);
    cursor: pointer;
    font-size: 1em;
    font-family: inherit;
    border-radius: 6px;
    transition: background-color 0.15s ease;
}

.gruppe-handel .button:hover,
.gruppe-handel .button:active {
    background-color: var(--mobile-chip-bg);
    border-color: var(--mobile-accent);
}

/* Primärer Abschluss-Button als CTA */
.gruppe-handel #btnAbschliessen {
    background-color: var(--mobile-action-bg);
    border-color: var(--mobile-action-border);
    font-weight: 600;
}

.gruppe-handel #btnAbschliessen:hover,
.gruppe-handel #btnAbschliessen:active {
    background-color: var(--mobile-action-bg-hover);
}

/* Erfolgs/Fehler-Meldungen */
.gruppe-handel .success {
    font-weight: bold;
    color: var(--mobile-text);
    background-color: var(--mobile-action-bg);
    border: 1px solid var(--mobile-action-border);
    padding: var(--space-md);
    margin: var(--space-md);
    border-radius: 6px;
}

.gruppe-handel .error {
    font-weight: bold;
    color: var(--mobile-text);
    background-color: rgba(192, 57, 43, 0.18);
    border: 1px solid #c0392b;
    padding: var(--space-md);
    margin: var(--space-md);
    border-radius: 6px;
}

.gruppe-handel .warning {
    font-weight: bold;
    color: var(--mobile-text);
    background-color: rgba(212, 160, 40, 0.18);
    border: 1px solid var(--bar-gold-color);
    padding: var(--space-md);
    margin: var(--space-md);
    border-radius: 6px;
}

/* Spinner Overlay */
.gruppe-handel .spinner {
    position: absolute;
    background: var(--mobile-surface-overlay);
    z-index: 999;
}

.gruppe-handel .spinner-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.gruppe-handel .spinner-img {
    width: 40px;
    height: 40px;
    background: url(../bilder/loading.svg) no-repeat center center;
    background-size: contain;
}

/* ===================== Modal (global, in <body> via mBox) ===================== */
.transfer_modal_content {
    padding: var(--space-sm);
    min-width: 280px;
    color: var(--mobile-text);
}

.modal_instanzen {
    margin-bottom: var(--space-md);
}

.instanz_tabelle {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.instanz_tabelle th,
.instanz_tabelle td {
    padding: var(--space-xs) var(--space-sm);
    border: 1px solid var(--mobile-border-soft);
    text-align: left;
}

.instanz_tabelle th {
    background: var(--mobile-surface-2);
}

.instanz_tabelle input[type="checkbox"] {
    width: 22px;
    height: 22px;
    cursor: pointer;
}

.instanz_tabelle tr.bereits_vergeben {
    opacity: 0.5;
    text-decoration: line-through;
}

.instanz_tabelle tr.bereits_vergeben input[type="checkbox"] {
    cursor: not-allowed;
}

.bereits_vergeben {
    color: var(--mobile-text-muted);
    font-style: italic;
}

/* Sonder-Instanzen (Container/gebunden/beschriftet) — eigene, nicht bündelbare Zeilen */
.instanz_tabelle tr.instanz_disabled {
    opacity: 0.6;
}

.instanz_tabelle_caption {
    margin: var(--space-sm) 0 var(--space-xs);
    font-weight: bold;
    color: var(--mobile-text-muted);
    font-size: 0.85em;
}

.modal_ziel {
    margin-top: var(--space-md);
}

.modal_ziel p {
    margin: 0 0 var(--space-sm);
}

.ziel_helden {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    justify-content: center;
}

.ziel_held_btn {
    min-height: var(--touch-target-min);
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--mobile-accent);
    border-radius: 6px;
    background: var(--mobile-chip-bg);
    color: var(--mobile-text);
    cursor: pointer;
    font-size: 0.9em;
    font-family: inherit;
    transition: all 0.15s ease;
}

.ziel_held_btn:hover,
.ziel_held_btn:active {
    background: var(--mobile-accent);
    color: var(--mobile-accent-contrast);
}

/* Mengen-Auswahl für grosse Warenmengen.
   GETEILT mit dem Transfer-System (Lager/Orden/Verkauf an Händler): das Markup
   erzeugt render_instanz_auswahl() (functions_ausruestung.inc.php), die Bedienung
   QualityBuckets.js. Diese Datei wird sowohl game-weit (html_head_css.inc.php) als
   auch standalone (ajax/gruppe_handel.php) geladen — daher hier zentral und
   skin-adaptiv über --mobile-*/--space-*-Tokens. NICHT nach gruppe_handel verschieben. */
.mengen_auswahl {
    padding: var(--space-sm) 0;
}

.zustand_gruppe {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm);
    margin-bottom: var(--space-xs);
    background: var(--mobile-surface-2);
    border-radius: 6px;
}

.zustand_gruppe.keine_verfuegbar {
    display: none;
}

.zustand_label {
    font-weight: bold;
    min-width: 80px;
}

.verfuegbar {
    color: var(--mobile-text-muted);
    font-size: 0.85em;
    flex: 1;
}

/* Preis pro Qualitätsstufe (nur Händler-Verkauf, wenn render_quality_buckets Preise erhält) */
.bucket_preis {
    font-size: 0.9em;
    font-weight: 600;
    white-space: nowrap;
    color: var(--mobile-text);
}

/* Preis-EINGABE pro Qualitätsstufe (Markt-Verkauf: render_quality_buckets mit price_input).
   Drei Münzfelder G/Th/Gr inline, Höhe an .menge_input angeglichen. Auf Mobile greifen
   zusätzlich die Touch-Größen aus antamarGeneralv97.css (.mBox.Modal input.gulden/...). */
.bucket_preis_input {
    display: flex;
    align-items: center;
    gap: 2px;
    white-space: nowrap;
}
.bucket_preis_input input {
    width: 40px;
    height: var(--touch-target-min);
    text-align: center;
    border: 1px solid var(--mobile-border);
    border-radius: 6px;
    background: var(--mobile-surface);
    color: var(--mobile-text);
    font-family: inherit;
    font-size: 0.95em;
    box-sizing: border-box;
}
.bucket_preis_input .gulden { width: 52px; }
.bucket_preis_input img {
    vertical-align: middle;
}

/* "» für alle"-Button hinter den Preisfeldern (Bucket + Tabelle): kompakter als .quick_btn,
   aber touch-tauglich. Kopiert diesen Preis in alle Felder (Transfer.js .js-preis-all). */
.js-preis-all {
    min-height: var(--touch-target-min);
    padding: 0 var(--space-sm);
    margin-left: var(--space-xs);
    border: 1px solid var(--mobile-accent);
    border-radius: 6px;
    background: var(--mobile-chip-bg);
    color: var(--mobile-text);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.8em;
    white-space: nowrap;
}
.js-preis-all:hover,
.js-preis-all:active {
    background: var(--mobile-accent);
    color: var(--mobile-accent-contrast);
}

/* Preis-Eingabezelle der Einzelstück-/Kleinmengen-Tabelle: Felder + "» für alle" in einer Zeile;
   Münzfelder kompakt wie im Bucket (.bucket_preis_input), damit die Zeile nicht ausufert. */
.instanz_tabelle .pr {
    white-space: nowrap;
}
.instanz_tabelle .pr input.gulden,
.instanz_tabelle .pr input.thaler,
.instanz_tabelle .pr input.groschen {
    width: 40px;
    text-align: center;
}
.instanz_tabelle .pr input.gulden {
    width: 52px;
}

/* Dezenter Listenpreis-Hinweis oben im Markt-Aufstell-Dialog (price_input).
   Nutzt .ui-note (gedaempft/klein); hier nur Position + Muenz-Icon-Ausrichtung. */
.listenpreis-hinweis {
    margin: 0 0 var(--space-sm);
    text-align: center;
}
.listenpreis-hinweis img {
    vertical-align: middle;
}

.menge_controls {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.menge_btn {
    width: var(--touch-target-min);
    height: var(--touch-target-min);
    font-size: 1.3em;
    line-height: 1;
    border: 1px solid var(--mobile-border);
    border-radius: 6px;
    background: var(--mobile-surface);
    color: var(--mobile-text);
    cursor: pointer;
    font-family: inherit;
    padding: 0;
}

.menge_btn:hover {
    background: var(--mobile-chip-bg);
}

.menge_input {
    width: 55px;
    height: var(--touch-target-min);
    text-align: center;
    font-size: 1em;
    border: 1px solid var(--mobile-border);
    border-radius: 6px;
    background: var(--mobile-surface);
    color: var(--mobile-text);
    font-family: inherit;
}

.schnellauswahl {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
    justify-content: center;
}

.quick_btn {
    min-height: var(--touch-target-min);
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--mobile-accent);
    border-radius: 6px;
    background: var(--mobile-chip-bg);
    color: var(--mobile-text);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9em;
}

.quick_btn:hover,
.quick_btn:active {
    background: var(--mobile-accent);
    color: var(--mobile-accent-contrast);
}

/* Read-only-Anzeige (render_instanz_anzeige): Angebotsinhalt nach Qualitätsstufe
   gruppiert, ohne Bedienelemente. Spiegelt das Bucket-Layout (.zustand_gruppe)
   kompakt; nutzt dieselben Klassen .zustand_label/.verfuegbar/.bucket_preis. */
.instanz_anzeige {
    margin-top: var(--space-xs);
}
.instanz_anzeige .zustand_zeile {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-xs);
    font-size: 0.9em;
    padding: 2px 0;
}

/* Geld-Modal */
.geld_info {
    text-align: center;
    margin-bottom: var(--space-md);
    color: var(--mobile-text);
}

.geld_info p {
    margin: 0;
}

.geld_eingabe {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    justify-content: center;
    margin: var(--space-md) 0;
}

.geld_input {
    width: 100px;
    height: var(--touch-target-min);
    text-align: center;
    font-size: 1.1em;
    border: 1px solid var(--bar-gold-color);
    border-radius: 6px;
    background: var(--mobile-surface);
    color: var(--mobile-text);
    font-family: inherit;
}

.geld_einheit {
    color: var(--mobile-text-muted);
}

.geld_schnellauswahl {
    display: flex;
    gap: var(--space-sm);
    justify-content: center;
    margin: var(--space-sm) 0 var(--space-md);
}

.geld_quick_btn {
    min-height: var(--touch-target-min);
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--bar-gold-color);
    border-radius: 6px;
    background: var(--mobile-chip-bg);
    color: var(--mobile-text);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9em;
    transition: background-color 0.15s ease;
}

.geld_quick_btn:hover,
.geld_quick_btn:active {
    background: var(--bar-gold-color);
    color: var(--mobile-accent-contrast);
}

/* mBox Modal Overrides (mbox-mobile-defaults.js setzt 90vw bereits) */
.mBox .mBoxContainer {
    max-width: 90vw;
}

/* mBox-Chrome der Tausch-Popups skin-adaptiv einfärben (Container/Inhalt/Titel/
   Close/Footer). Gescoped über addClass 'gruppe-handel-modal' (GruppeHandel-v11.js),
   damit andere App-Modals unberührt bleiben. 4 Klassen → schlägt mBoxModal.css. */
.mBox.Modal.gruppe-handel-modal .mBoxContainer {
    background: var(--mobile-surface);
    border-color: var(--mobile-surface);
}
.mBox.Modal.gruppe-handel-modal .mBoxContent {
    background: var(--mobile-surface);
    border-color: var(--mobile-border);
    color: var(--mobile-text);
}
.mBox.Modal.gruppe-handel-modal .mBoxTitle {
    background: var(--mobile-surface-2);
    background-image: none;
    color: var(--mobile-text);
    border-color: var(--mobile-border);
    text-shadow: none;
    box-shadow: none;
}
.mBox.Modal.gruppe-handel-modal .mBoxFooterContainer {
    background: var(--mobile-surface-2);
    border-color: var(--mobile-border);
    box-shadow: none;
}
/* Default-Close ist ein dunkles Mini-X auf Weiß → durch skin-farbiges × ersetzen */
.mBox.Modal.gruppe-handel-modal .mBoxClose {
    background: transparent;
    border: 0;
    box-shadow: none;
    width: 24px;
    height: 24px;
    top: 10px;
    right: 14px;
}
.mBox.Modal.gruppe-handel-modal .mBoxClose > div {
    display: none;
}
.mBox.Modal.gruppe-handel-modal .mBoxClose::before {
    content: '\00d7';
    display: block;
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    font-size: 22px;
    color: var(--mobile-text);
}
/* Footer-Button "Abbrechen" tokenisiert + Touch-Ziel */
.mBox.Modal.gruppe-handel-modal .mBoxButton {
    min-height: var(--touch-target-min);
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--mobile-border);
    border-radius: 6px;
    background: var(--mobile-surface-2);
    color: var(--mobile-text);
    font-family: inherit;
    cursor: pointer;
}
.mBox.Modal.gruppe-handel-modal .mBoxButton:hover {
    background: var(--mobile-chip-bg);
    border-color: var(--mobile-accent);
}

/* ===================== Mobil (<=770px) ===================== */
@media (max-width: 770px) {
    /* Volle Breite, Page scrollt selbst (keine innere 400px-Scrollbox) */
    .gruppe-handel .waren_liste {
        max-height: none;
        overflow: visible;
        gap: var(--space-sm);
    }

    /* Item-Grid 2-spaltig, volle Breite */
    .gruppe-handel .ware_item,
    .gruppe-handel .geld_item {
        width: calc(50% - var(--space-sm));
        box-sizing: border-box;
        min-height: var(--touch-target-min);
    }

    /* Helden-Kacheln etwas kompakter */
    .gruppe-handel .held_card {
        width: 84px;
        padding: var(--space-xs);
    }
    .gruppe-handel .held_portrait {
        height: 56px;
    }
    .gruppe-handel .held_portrait img,
    .gruppe-handel .portrait_img {
        max-width: 56px;
        max-height: 56px;
    }

    /* Abschluss-Leiste klebt über der App-Bottom-Nav statt am Viewport-Rand */
    .gruppe-handel .handel_abschliessen {
        position: sticky;
        bottom: calc(var(--mobile-bottombar-height) + var(--safe-bottom));
        display: flex;
        gap: var(--space-sm);
        padding: var(--space-sm) 0;
        background: transparent;
        border-top: none;
    }
    .gruppe-handel .handel_abschliessen .button {
        flex: 1;
        min-height: var(--touch-target-comfort);
    }
    /* Inhalt nicht hinter Sticky-Leiste + App-Nav verstecken */
    .gruppe-handel .waren_container {
        margin-bottom: var(--space-md);
    }
    .gruppe-handel {
        padding-bottom: calc(var(--mobile-bottombar-height) + var(--safe-bottom) + var(--space-md));
    }

    /* Modal: Zielauswahl volle Breite, große Tap-Ziele */
    .ziel_helden {
        flex-direction: column;
    }
    .ziel_held_btn {
        width: 100%;
        box-sizing: border-box;
    }
    .verfuegbar {
        width: 100%;
        order: 3;
        margin-top: 2px;
    }
    .menge_controls {
        margin-left: auto;
    }
    .geld_eingabe,
    .geld_schnellauswahl {
        flex-wrap: wrap;
    }
}

/* ===================== Desktop (>=771px, Mediabox-Lightbox-Standalone) =====================
 * Auf dem Desktop öffnet die Gruppen-Ansicht diese Seite als eigenständiges Dokument in einer
 * fast bildschirmfüllenden Mediabox-Lightbox. Die Mobile-First-Basis (zentriert, 400px-
 * Scrollkasten, kleine Schriften) verschenkt dort Fläche und legt den „nackten" Kopftext auf
 * das dekorative Skin-Body-Bild (Bombast/Pergament: heller Himmel → unlesbar).
 *
 * Fix: zweispaltiges Layout (Helden-Rail links, Ausrüstungs-Raster rechts), durchgehend
 * lesbares Panel (--mobile-surface, pro Skin korrekt), größere Bilder/Schriften, volle Höhe.
 * Alles token-basiert → passt automatisch zu allen Skins (Bombast, Antamar, Classic,
 * Pergament, Simple). Greift praktisch nur hier (Mobil nutzt < 771px die Inline-Ansicht).
 */
@media (min-width: 771px) {

    /* (1) Lesbarkeit: durchgehendes Panel deckt das dekorative Skin-Body-Bild ab.
       Token-basiert → in jedem Skin korrekter Kontrast. Volle Breite = max. Fläche. */
    .gruppe-handel {
        background: var(--mobile-surface);
        min-height: 100vh;
        box-sizing: border-box;
        padding: var(--space-lg) var(--space-xl) 96px;   /* unten Platz für die fixe Leiste */
        text-align: left;
    }
    .gruppe-handel h1 { text-align: center; }
    .gruppe-handel .small { text-align: center; font-size: 1em; }

    /* (2) Zweispaltig: Helden-Rail links, Ausrüstung rechts.
       Versteckte Inputs (display:none) und die fixe Abschluss-Leiste (position:fixed) sind
       keine Grid-Items → es bleiben exakt die zwei Spalten. */
    .gruppe-handel #formToBeSent {
        display: grid;
        grid-template-columns: 240px 1fr;
        grid-template-areas: "heroes wares";
        gap: var(--space-xl);
        align-items: start;
    }

    /* Linke Spalte: vertikale Helden-Rail mit „Deine Gruppe"-Label, klebt beim Scrollen */
    .gruppe-handel .helden_uebersicht {
        grid-area: heroes;
        flex-direction: column;
        flex-wrap: nowrap;
        position: sticky;
        top: var(--space-lg);
        margin-bottom: 0;
    }
    .gruppe-handel .helden_uebersicht::before {
        content: "Deine Gruppe";
        font-size: var(--mobile-font-h2);
        color: var(--mobile-text);
        margin-bottom: var(--space-sm);
    }
    .gruppe-handel .held_card { width: 100%; box-sizing: border-box; }
    .gruppe-handel .held_portrait { height: 88px; }
    .gruppe-handel .held_portrait img,
    .gruppe-handel .portrait_img { max-width: 88px; max-height: 88px; }
    .gruppe-handel .held_name { font-size: 1em; }
    .gruppe-handel .held_status { font-size: 0.85em; }

    /* Rechte Spalte: Ausrüstung füllt Höhe & Breite — KEIN 400px-Scrollkasten mehr */
    .gruppe-handel .waren_container { grid-area: wares; margin-bottom: 0; }
    .gruppe-handel .waren_container h2 { text-align: left; margin-top: 0; }
    .gruppe-handel .waren_liste {
        max-height: none;
        overflow: visible;
        justify-content: flex-start;   /* echtes linksbündiges Raster statt zentriert */
        gap: var(--space-md);
    }

    /* (3) Größere Bilder/Karten auf dem Desktop */
    .gruppe-handel .ware_item,
    .gruppe-handel .geld_item { width: 160px; }
    .gruppe-handel .ware_bild,
    .gruppe-handel .geld_bild { width: 64px; height: 64px; }
    .gruppe-handel .ware_bild img, .gruppe-handel .ware_img,
    .gruppe-handel .geld_bild img, .gruppe-handel .geld_img { max-width: 64px; max-height: 64px; }
    .gruppe-handel .ware_name,
    .gruppe-handel .geld_betrag,
    .gruppe-handel .geld_label { font-size: 1em; }

    /* (4) Abschluss-Leiste bleibt fixiert (spannt volle Lightbox-Breite), Buttons etwas größer */
    .gruppe-handel .handel_abschliessen { padding: var(--space-md); }
    .gruppe-handel .button { font-size: 1.05em; }

    /* Modal-Text leicht anheben (liegt auf dunklem mBox-Surface, daher nur Größe) */
    .instanz_tabelle { font-size: 1em; }
}

/* ============================================================
 * Drag & Drop (Desktop/Maus) + Undo-Marker
 * .gh_dnd / .gh_dragging setzt GruppeHandel-v45.js nur, wenn das
 * matchMedia-Gate (hover+fine) zutrifft — Touch/Mobil bleibt unverändert.
 * ============================================================ */

/* Undo-×: immer aktiv (gilt auch für den Klick-Flow auf Touch) */
.gruppe-handel .marker_clear {
    display: inline-block;
    margin-left: var(--space-xs);
    padding: 0 6px;
    border: none;
    background: none;
    color: var(--mobile-text-muted);
    font-size: 1.15em;
    line-height: 1;
    cursor: pointer;
    vertical-align: middle;
}

.gruppe-handel .marker_clear:hover {
    color: var(--mobile-accent-strong);
}

/* Drag-Affordance nur, wenn DnD wirklich aktiv ist */
.gh_dnd .ware_item:not(.komplett_vergeben),
.gh_dnd .geld_item:not(.komplett_vergeben) {
    cursor: grab;
}

.gh_dnd .ware_img,
.gh_dnd .geld_img {
    -webkit-user-drag: none;
    user-drag: none;
}

/* Pending-Badge auf den Ziel-Karten ("3× · 2G 5T" vorgemerkt) */
.gh_dnd .held_card {
    position: relative;
}

.gh_dnd .gh_pending_badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--mobile-accent);
    color: var(--mobile-accent-contrast);
    font-size: 0.7em;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    white-space: nowrap;
    text-shadow: none; /* flacher Chip, wie .ware_anzahl (Bombast-Schatten aus) */
}

/* Während des Drags: gültige Ziele hervorheben, Rest dimmen */
.gh_dragging {
    cursor: grabbing;
    user-select: none;
    -webkit-user-select: none;
}

.gh_dragging .held_card.gh_drop_ziel {
    border-color: var(--mobile-accent);
    background: var(--mobile-chip-bg);
}

.gh_dragging .held_card:not(.gh_drop_ziel) {
    opacity: 0.35;
}

.gh_dragging .held_card.gh_drop_hover {
    border-color: var(--mobile-accent-strong);
    box-shadow: 0 0 0 2px var(--mobile-accent-strong);
}

/* Ghost hängt an document.body — der .gruppe-handel-Scope greift dort NICHT.
   pointer-events:none ist Pflicht: sonst fängt der Ghost das mouseup ab und
   der Klick->Modal-Fallback stirbt (click landet auf body statt Item). */
.gh_ghost {
    position: absolute;
    z-index: 12000;
    margin: 0;
    opacity: 0.85;
    pointer-events: none;
}

.gh_ghost img {
    display: block;
    max-width: 64px;
    max-height: 64px;
}

.gh_ghost .ware_anzahl {
    position: absolute;
    right: -5px;
    bottom: -5px;
    background: var(--mobile-accent);
    color: var(--mobile-accent-contrast);
    font-size: 0.75em;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
    text-shadow: none;
}

/* Vormerkungen anderer Quellen (Schwebeliste nach Heldenwechsel).
   Sitzt nach .helden_uebersicht im Formular — das Desktop-Grid platziert
   sie automatisch unter die Helden-Rail, mobil normaler Block. */
.gruppe-handel .gh_fremd_box {
    margin: var(--space-sm) 0;
    padding: var(--space-sm);
    border: 1px solid var(--mobile-border-soft);
    border-radius: 6px;
    background: var(--mobile-surface-2);
    font-size: 0.85em;
    text-align: left;
}

.gruppe-handel .gh_fremd_titel {
    font-weight: bold;
    color: var(--mobile-text-muted);
    margin-bottom: var(--space-xs);
}

.gruppe-handel .gh_fremd_zeile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-xs);
    padding: 2px 0;
}

.gruppe-handel .gh_fremd_text {
    color: var(--mobile-accent-strong);
    font-weight: bold;
}

/* Drop-Bestätigung: kurzes Aufblitzen der Ziel-Karte */
.held_card.gh_drop_flash {
    animation: gh-drop-flash 0.45s ease-out;
}

@keyframes gh-drop-flash {
    0% {
        background: var(--mobile-chip-bg);
        box-shadow: 0 0 0 4px var(--mobile-accent);
    }
    100% {
        box-shadow: 0 0 0 0 transparent;
    }
}

/* Begleiter-Übernahme beim Plündern einer Leiche (Zeilen-Layout, Sofort-Aktion) */
.gruppe-handel .begleiter_container {
    margin-bottom: var(--space-md);
}

.gruppe-handel .leichen_begleiter {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm);
    margin-bottom: var(--space-xs);
    border: 1px solid var(--mobile-border-soft);
    border-radius: 6px;
    background: var(--mobile-surface);
}

.gruppe-handel .leichen_begleiter .begleiter_bild .ware_img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.gruppe-handel .leichen_begleiter .begleiter_info {
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
}

.gruppe-handel .leichen_begleiter .begleiter_name {
    font-weight: bold;
}

.gruppe-handel .leichen_begleiter .begleiter_detail {
    color: var(--mobile-text-muted);
}

.gruppe-handel .leichen_begleiter .begleiter_aktion {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    align-items: stretch;
    flex: 0 0 auto;
}

.gruppe-handel .leichen_begleiter .begleiter_ziel {
    max-width: 220px;
}

@media (max-width: 520px) {
    .gruppe-handel .leichen_begleiter {
        flex-wrap: wrap;
    }

    .gruppe-handel .leichen_begleiter .begleiter_aktion {
        flex: 1 1 100%;
    }

    .gruppe-handel .leichen_begleiter .begleiter_ziel {
        max-width: none;
    }
}
