:root {
  --bg: #050508;
  --fg: #f5f5f5;
  --border-subtle: #333;
  --accent: #c62828;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
}

html, body {
  max-width: 100%;
  overflow-x: hidden;
}

/* =========================
   HEADER + LAYOUT GLOBAL
   ========================= */

header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  background: #111;
}

header .title {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  margin: 0.5rem 0 0.8rem;
  text-shadow: 0 0 4px rgba(0,0,0,0.5);
  font-size: 1.1rem;
}

.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 48px);
  max-width: 100%;
}

/* =========================
   NAV / MENU DES SECTIONS
   ========================= */

#modules-nav {
  border-right: 1px solid var(--border-subtle);
  background: #111;
  padding: 0.75rem;
}

#modules-nav h2 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.8);
}

.modules-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.modules-list > li {
  margin-bottom: 0.3rem;
}

.module-btn {
  width: 100%;
  text-align: left;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 0.9rem;
}

.module-btn:hover {
  background: rgba(255,255,255,0.05);
}

/* État actif si tu ajoutes la classe depuis main.js */
.module-btn-active {
  background: rgba(198,40,40,0.18);
  border: 1px solid rgba(198,40,40,0.7);
}

/* Séparateur entre groupes (PC) */
.modules-separator {
  border-top: 1px solid var(--border-subtle);
  margin: 0.5rem 0;
}

#module-container {
  padding: 0.75rem;
}

/* =========================
   RESPONSIVE GLOBAL
   ========================= */

@media (max-width: 800px) {
  /* On désactive complètement la grille pour éviter tout effet bizarre */
  .layout {
    display: block;
    min-height: auto;
    width: 100%;
    max-width: 100%;
  }

  #modules-nav {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.5rem 0.5rem 0.4rem;
  }

  #module-container {
    width: 100%;
    max-width: 100%;
    padding: 0.5rem;
  }

  /* Menu horizontal scrollable */
  .modules-list {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.25rem;
    overflow-x: auto;
    padding: 0 0.5rem 0.3rem;
  }

  .modules-list > li {
    margin-bottom: 0;
    flex: 0 0 auto;
  }

  .module-btn {
    text-align: center;
    white-space: nowrap;
    padding: 0.35rem 0.7rem;
    font-size: 0.85rem;
  }

  .modules-separator {
    border-left: 1px solid var(--border-subtle);
    border-top: none;
    height: 1.4rem;
    align-self: center;
    margin: 0 0.25rem;
    flex: 0 0 auto;
  }
}


/* =========================================
   MODULE GROUPE - THEME D&D PARCHEMIN
   ========================================= */

.grp-root {
  max-width: 100%;
  margin: 0 auto 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  font-size: 0.95rem;
  color: #f6efe4;
}

/* Aspect "parchemin / cadre" pour chaque bloc */
.grp-section {
  position: relative;
  padding: 14px 16px;
  background: #2b2218;
  background-image:
    radial-gradient(circle at 0 0, rgba(255,255,255,0.06), transparent 60%),
    radial-gradient(circle at 100% 0, rgba(255,255,255,0.06), transparent 60%),
    radial-gradient(circle at 0 100%, rgba(0,0,0,0.35), transparent 55%),
    radial-gradient(circle at 100% 100%, rgba(0,0,0,0.45), transparent 55%);
  border: 2px solid #9b7a4a;
  box-shadow:
    0 0 0 1px rgba(0,0,0,0.8),
    0 6px 14px rgba(0,0,0,0.7);
  border-radius: 10px;
}

/* Petite bordure interne "cadre" */
.grp-section::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 8px;
  border: 1px solid rgba(255, 240, 210, 0.18);
  pointer-events: none;
}

.grp-section h2 {
  margin: 0 0 8px 0;
  padding-bottom: 4px;
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid rgba(255, 240, 210, 0.18);
}

/* =======================
   RESSOURCES DU GROUPE
   ======================= */

.grp-res-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 10px;
}

.grp-res-box {
  flex: 1 1 220px;
  background: rgba(0,0,0,0.35);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.grp-res-label {
  font-size: 0.85rem;
  opacity: 0.85;
}

.grp-res-value {
  font-weight: 600;
  font-size: 1.1rem;
}

.grp-res-controls {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 2px;
}

.grp-res-amount {
  width: 90px;
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid #6b543b;
  background: rgba(0,0,0,0.6);
  color: #f6efe4;
  font-size: 0.85rem;
}

.grp-res-btn {
  min-width: 28px;
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid #9b7a4a;
  background: #704525;
  color: #f6efe4;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
}

.grp-res-btn:hover {
  background: #91552d;
}

/* Inventaire */

.grp-inv-title {
  margin-top: 10px;
  margin-bottom: 4px;
  font-size: 0.95rem;
}

.grp-inv-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.grp-inv-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid #7b6245;
  background: rgba(0,0,0,0.45);
  font-size: 0.8rem;
}

.grp-inv-chip-del {
  border: none;
  background: transparent;
  color: #ffb0b0;
  cursor: pointer;
  font-size: 0.85rem;
}

.grp-inv-add-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.grp-inv-add-name,
.grp-inv-add-qty {
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid #6b543b;
  background: rgba(0,0,0,0.6);
  color: #f6efe4;
  font-size: 0.85rem;
}

.grp-inv-add-name {
  flex: 1 1 150px;
}

.grp-inv-add-qty {
  width: 70px;
}

.grp-inv-add-btn {
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid #4d7b45;
  background: #356035;
  color: #f6efe4;
  cursor: pointer;
  font-size: 0.9rem;
}

.grp-inv-add-btn:hover {
  background: #467a46;
}

/* =======================
   CARTES PJ
   ======================= */

.grp-pj-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px;
}

.grp-pj-card {
  display: flex;
  gap: 8px;
  padding: 8px 9px;
  border-radius: 8px;
  background: rgba(0,0,0,0.45);
  border: 1px solid #7b6245;
}

.grp-pj-avatar {
  flex: 0 0 64px;
  height: 64px;
  border-radius: 6px;
  overflow: hidden;
  background: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.grp-pj-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.grp-pj-avatar-ph {
  font-size: 0.9rem;
  opacity: 0.7;
}

.grp-pj-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1 1 auto;
  min-width: 0;
}

.grp-pj-name {
  font-weight: 600;
  font-size: 0.98rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.grp-pj-meta {
  font-size: 0.83rem;
  opacity: 0.9;
}

.grp-pj-xp {
  font-size: 0.8rem;
  opacity: 0.85;
}

.grp-pj-kills {
  margin-top: 2px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.grp-pj-kill-count {
  font-size: 0.8rem;
  opacity: 0.85;
}

.grp-pj-kill-btn {
  padding: 2px 8px;
  font-size: 0.8rem;
  border-radius: 999px;
  border: 1px solid #9b7a4a;
  background: #704525;
  color: #f6efe4;
  cursor: pointer;
}

.grp-pj-kill-btn:hover {
  background: #91552d;
}

/* =======================
   RENCONTRE & XP
   ======================= */

.grp-enc-pjs {
  margin-bottom: 10px;
}

.grp-label {
  font-size: 0.9rem;
  margin-bottom: 4px;
  opacity: 0.9;
}

.grp-enc-pjlist {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}

.grp-enc-pjitem {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,0.5);
}

/* Table des monstres */

.grp-mons-table {
  width: 100%;
  margin-top: 4px;
  margin-bottom: 6px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #7b6245;
  background: rgba(0,0,0,0.45);
}

.grp-mons-row {
  display: grid;
  grid-template-columns: 3fr 0.35fr 0.8fr 0.6fr auto;
  gap: 0.25rem;
  padding: 5px 8px;
  align-items: center;
}

.grp-mons-head {
  background: #3c2b1f;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.grp-mons-row:nth-child(2n+1):not(.grp-mons-head) {
  background: rgba(0,0,0,0.25);
}

.grp-mons-cell input {
  width: 100%;
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid #6b543b;
  background: rgba(0,0,0,0.65);
  color: #f6efe4;
  font-size: 0.85rem;
}

.grp-mons-total span {
  font-size: 0.9rem;
  font-weight: 600;
}

.grp-mons-actions {
  display: flex;
  justify-content: flex-end;
}

.grp-mons-del-btn {
  padding: 2px 8px;
  font-size: 0.8rem;
  border-radius: 999px;
  border: 1px solid #a05757;
  background: #7a3434;
  color: #f6efe4;
  cursor: pointer;
}

.grp-mons-del-btn:hover {
  background: #934040;
}

/* Boutons ajout + valider */

.grp-mons-add-btn,
.grp-enc-validate-btn {
  margin-top: 6px;
  padding: 5px 12px;
  border-radius: 4px;
  border: 1px solid #45668e;
  background: #345170;
  color: #f6efe4;
  cursor: pointer;
  font-size: 0.9rem;
}

.grp-mons-add-btn:hover,
.grp-enc-validate-btn:hover {
  background: #43678c;
}

.grp-enc-validate-btn {
  display: inline-block;
  margin-top: 10px;
}

/* Résumé XP */

.grp-enc-summary {
  margin-top: 6px;
  font-size: 0.83rem;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  opacity: 0.95;
}

/* =======================
   HISTORIQUE RENCONTRES
   ======================= */

.grp-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.grp-session-card {
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(0,0,0,0.45);
  border: 1px solid #7b6245;
}

.grp-session-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px;
  font-size: 0.83rem;
}

.grp-session-title {
  font-weight: 600;
}

.grp-session-xp {
  opacity: 0.9;
}

.grp-session-participants {
  margin-top: 4px;
  font-size: 0.82rem;
}

.grp-session-monsters {
  margin: 4px 0 0;
  padding-left: 16px;
  font-size: 0.8rem;
}

/* =======================
   RESPONSIVE GROUPE
   ======================= */

@media screen and (max-width: 960px) {
  .grp-section {
    padding: 10px 10px;
  }

  .grp-pj-grid {
    grid-template-columns: 1fr;
  }

  .grp-encounter-inner {
    padding: 8px;
  }

  .grp-mons-table {
    padding: 0.3rem;
  }

  .grp-mons-row {
    grid-template-columns: 3.5fr 0.7fr 0.9fr auto;
  }

  .grp-enc-summary {
    flex-direction: column;
    gap: 0.35rem;
  }
}

@media screen and (max-width: 600px) {
  .grp-mons-row {
    grid-template-columns: 3fr 0.5fr 0.8fr auto;
    align-items: center;
  }

  .grp-mons-total span {
    font-size: 0.8rem;
  }

  .grp-mons-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 2px;
  }

  .grp-pj-card {
    padding: 6px;
  }

  .grp-pj-avatar {
    flex: 0 0 56px;
    height: 56px;
  }
}


/* =========================================
   THEME GLOBAL D&D - PARCHEMIN / CADRES
   ========================================= */

.dnd-panel {
  position: relative;
  padding: 14px 16px;
  background: #2b2218;
  background-image:
    radial-gradient(circle at 0 0, rgba(255,255,255,0.06), transparent 60%),
    radial-gradient(circle at 100% 0, rgba(255,255,255,0.06), transparent 60%),
    radial-gradient(circle at 0 100%, rgba(0,0,0,0.35), transparent 55%),
    radial-gradient(circle at 100% 100%, rgba(0,0,0,0.45), transparent 55%);
  border: 2px solid #9b7a4a;
  box-shadow:
    0 0 0 1px rgba(0,0,0,0.8),
    0 6px 14px rgba(0,0,0,0.7);
  border-radius: 10px;
  color: #f6efe4;
}

.dnd-panel::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 8px;
  border: 1px solid rgba(255, 240, 210, 0.18);
  pointer-events: none;
}

.dnd-panel > h2,
.dnd-panel .dnd-title {
  margin: 0 0 8px 0;
  padding-bottom: 4px;
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid rgba(255, 240, 210, 0.18);
}

/* Cartes (PJ, PNJ, entrées de journal, etc.) */
.dnd-card {
  background: rgba(0,0,0,0.45);
  border-radius: 8px;
  border: 1px solid #7b6245;
  padding: 8px 9px;
}

/* Grille de cartes */
.dnd-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px;
}

/* Boutons */
.dnd-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid #9b7a4a;
  background: #704525;
  color: #f6efe4;
  cursor: pointer;
  font-size: 0.9rem;
}

.dnd-btn:hover {
  background: #91552d;
}

/* Variante danger */
.dnd-btn-danger {
  border-color: #a05757;
  background: #7a3434;
}

.dnd-btn-danger:hover {
  background: #934040;
}

/* Variante secondaire */
.dnd-btn-secondary {
  border-color: #45668e;
  background: #345170;
}

.dnd-btn-secondary:hover {
  background: #43678c;
}

/* Champs de formulaire */
.dnd-input,
.dnd-textarea,
.dnd-select {
  width: 100%;
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid #6b543b;
  background: rgba(0,0,0,0.65);
  color: #f6efe4;
  font-size: 0.85rem;
}

.dnd-textarea {
  min-height: 80px;
  resize: vertical;
}

.dnd-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 6px;
}

.dnd-label {
  font-size: 0.85rem;
  opacity: 0.9;
}

/* Tags / chips */
.dnd-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid #7b6245;
  background: rgba(0,0,0,0.45);
  font-size: 0.8rem;
}

/* Responsive global D&D */
@media screen and (max-width: 960px) {
  .dnd-panel {
    padding: 10px 10px;
  }
  .dnd-card-grid {
    grid-template-columns: 1fr;
  }
}

@media screen and (max-width: 600px) {
  .dnd-panel {
    margin-left: -4px;
    margin-right: -4px;
    border-radius: 0;
  }
}

/* =========================================
   MODULE PJ
   ========================================= */

.pj-root {
  max-width: 100%;
  margin: 0 auto 24px;
}

.pj-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 12px;
}

/* Liste PJ */

.pj-list-toolbar {
  margin-bottom: 6px;
}

.pj-list-inner h3 {
  margin: 8px 0 4px;
  font-size: 0.95rem;
}

.pj-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.pj-list-card {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0.95;
}

.pj-list-card:hover {
  opacity: 1;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08);
}

.pj-list-card-active {
  border-color: #d5b890;
}

.pj-list-card-dead {
  opacity: 0.6;
}

.pj-list-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.pj-list-avatar {
  flex: 0 0 40px;
  height: 40px;
  border-radius: 6px;
  overflow: hidden;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pj-list-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pj-list-avatar-ph {
  font-size: 0.8rem;
  opacity: 0.7;
}

.pj-list-body {
  flex: 1 1 auto;
  min-width: 0;
}

.pj-list-name {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.pj-list-meta,
.pj-list-xp {
  font-size: 0.78rem;
  opacity: 0.85;
}

/* Fiche détaillée */

.pj-detail-inner {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Header fiche */

.pj-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.pj-header-avatar {
  flex: 0 0 80px;
  width: 80px;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pj-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pj-header-avatar-ph {
  font-size: 1rem;
  opacity: 0.8;
}

.pj-header-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pj-header-name {
  font-size: 1.05rem;
  font-weight: 600;
}

.pj-header-sub {
  font-size: 0.85rem;
  opacity: 0.9;
}

.pj-header-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pj-header-btn {
  font-size: 0.78rem;
  padding: 3px 8px;
}

/* Onglets */

.pj-tabs-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.pj-tab-btn {
  border: none;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
  background: rgba(0,0,0,0.5);
  color: #f6efe4;
  border: 1px solid transparent;
}

.pj-tab-btn:hover {
  border-color: rgba(255,255,255,0.15);
}

.pj-tab-active {
  background: #704525;
  border-color: #d5b890;
}

/* Contenu onglets */

.pj-tab-content {
  margin-top: 6px;
}

.pj-tab-card {
  margin-top: 2px;
}

/* Section header / titres */

.pj-section-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.pj-section-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.pj-section-subtitle {
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 4px;
}

/* Bouton modifier/valider */

.pj-edit-btn {
  font-size: 0.78rem;
  padding: 3px 8px;
}

/* FICHE : grille de champs */

.pj-sheet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 6px 10px;
}

/* INVENTAIRE */

.pj-inv-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.pj-inv-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.pj-inv-col-left {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.pj-inv-name {
  font-size: 0.9rem;
  font-weight: 600;
}

.pj-inv-cat {
  font-size: 0.78rem;
  opacity: 0.8;
}

.pj-inv-desc {
  font-size: 0.8rem;
  opacity: 0.9;
}

.pj-inv-col-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.pj-inv-qty {
  font-size: 0.8rem;
}

.pj-inv-add-form {
  margin-top: 8px;
}

/* HISTORIQUE */

.pj-backstory-display {
  white-space: pre-line;
  font-size: 0.9rem;
}

/* RESPONSIVE PJ */

@media screen and (max-width: 960px) {
  .pj-layout {
    grid-template-columns: 1fr;
  }
}

@media screen and (max-width: 600px) {
  .pj-root {
    margin-left: -4px;
    margin-right: -4px;
  }

  .pj-header {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto;
  }

  .pj-header-actions {
    grid-column: 1 / -1;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .pj-tabs-bar {
    overflow-x: auto;
  }
}

/* ===== Module Liens ===== */

.liens-panel {
  margin-top: 1rem;
}

.liens-intro {
  margin: 0.3rem 0 1rem;
  font-size: 0.95rem;
  opacity: 0.85;
}

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

.liens-col {
  padding: 0.75rem 1rem;
}

.liens-col h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: 1.05rem;
}

.liens-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.liens-item {
  margin-bottom: 0.4rem;
}

.liens-item a {
  text-decoration: none;
  color: var(--accent);
}

.liens-item a:hover {
  text-decoration: underline;
}

/* Mobile : 1 colonne, puis 2, puis 3 */
@media (max-width: 768px) {
  .liens-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 769px) and (max-width: 1100px) {
  .liens-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* =========================================
   CORRECTIFS MOBILE GLOBALS
   ========================================= */

@media (max-width: 800px) {
  /* Layout en une seule colonne, hauteur auto */
  .layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  #module-container {
    padding: 0.5rem;
  }
}

@media (max-width: 600px) {
  /* Titre un peu plus compact */
  header {
    padding: 0.4rem 0.6rem;
  }

  header .title {
    font-size: 0.9rem;
    line-height: 1.2;
    margin-bottom: 0.4rem;
  }

  /* Panneaux D&D moins lourds sur mobile */
  .dnd-panel {
    padding: 8px 9px;
    margin-left: 0;
    margin-right: 0;
    border-radius: 0;
    box-shadow: none;
    border-width: 1px;
  }

  .dnd-panel::before {
    display: none;
  }

  /* Sections groupe / PJ sans débordement latéral */
  .grp-root,
  .pj-root {
    margin: 0;
    max-width: 100%;
  }

  /* Grille du layout PJ bien serrée */
  .pj-layout {
    gap: 8px;
  }

  /* Cartes un peu plus compactes */
  .dnd-card {
    padding: 6px 7px;
  }

  /* Liste de modules déjà horizontale : on garde,
     mais on réduit légèrement la taille */
  .module-btn {
    font-size: 0.8rem;
    padding: 0.3rem 0.6rem;
  }
}

/* =========================================
   CARTE DU MONDE
   ========================================= */

#map-wrapper {
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  margin-top: 0.4rem;
}

/* zone visible de la carte */
#map-viewport {
  width: 100%;
  height: 70vh;
  max-height: 720px;
  position: relative;
  overflow: hidden;
  background: #000;
  cursor: grab;
  touch-action: none; /* pour pan sur mobile */
}

#map-viewport.dragging {
  cursor: grabbing;
}

/* conteneur translaté / zoomé */
#map-inner {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
}

/* image de la carte */
#map-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

/* Pins */

.map-pin {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #000;
  transform: translate(-50%, -100%);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.6);
  cursor: pointer;
}

/* couleurs de pins */
.map-pin-red    { background: #e53935; }
.map-pin-blue   { background: #1e88e5; }
.map-pin-green  { background: #43a047; }
.map-pin-yellow { background: #fdd835; }

/* popup type "parchemin" */
.map-pin-popup {
  position: absolute;
  min-width: 220px;
  max-width: 320px;
  background: #2b2218;
  border: 2px solid #9b7a4a;
  border-radius: 8px;
  box-shadow:
    0 0 0 1px rgba(0,0,0,0.8),
    0 6px 14px rgba(0,0,0,0.7);
  color: #f6efe4;
  padding: 6px 8px 8px;
  z-index: 20;
  /* IMPORTANT : on enlève tout transform,
     c'est le JS qui gère la position/clamp */
  transform: none;
  pointer-events: auto;
}


.map-pin-popup::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 6px;
  border: 1px solid rgba(255, 240, 210, 0.18);
  pointer-events: none;
}

.map-pin-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.map-pin-popup-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.map-pin-popup-close {
  border: none;
  background: transparent;
  color: #f6efe4;
  cursor: pointer;
  font-size: 0.9rem;
}

.map-pin-popup-meta {
  font-size: 0.8rem;
  opacity: 0.9;
  margin-bottom: 4px;
}

.map-pin-popup-desc {
  font-size: 0.82rem;
  line-height: 1.4;
  margin-bottom: 6px;
}

.map-pin-popup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.map-pin-popup .dnd-btn {
  font-size: 0.78rem;
  padding: 2px 6px;
}

/* Responsive carte */

@media (max-width: 800px) {
  #map-viewport {
    height: 60vh;
    max-height: none;
  }
}

@media (max-width: 600px) {
  #map-wrapper {
    border-radius: 0;
  }

  .map-pin-popup {
    max-width: 80vw;
  }
}
@media (max-width: 768px) {
  .grp-mons-row {
  grid-template-columns: 0.35fr 3fr 0.8fr 0.6fr auto;
  }
}
/* Forcer la largeur du champ quantité dans le module groupe */

/* cellule QTé plus petite que le nom du monstre */
.grp-mons-cell.grp-mons-qty {
  max-width: 70px !important;
}

/* l'input à l'intérieur hérite de cette largeur */
.grp-mons-cell.grp-mons-qty input {
  width: 100% !important;
  max-width: 70px !important;
  box-sizing: border-box;
}

/* pour les petits écrans (mobile), encore un peu plus étroit */
@media (max-width: 768px) {
  .grp-mons-cell.grp-mons-qty {
    max-width: 60px !important;
  }

  .grp-mons-cell.grp-mons-qty input {
    max-width: 60px !important;
  }
}

