/* ── Google Fonts ───────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Poppins:wght@300;400;500;600&display=swap');

/* ── Variables ──────────────────────────────────────────────────── */
:root {
  --bg:           #083B1E;
  --bg-deep:      #052815;
  --bg-card:      rgba(5, 40, 21, 0.85);
  --bg-card-2:    rgba(8, 60, 30, 0.7);
  --bg-input:     rgba(3, 50, 22, 0.8);
  --bg-hover:     rgba(255, 249, 214, 0.08);
  --border:       rgba(255, 249, 214, 0.18);
  --border-focus: rgba(255, 249, 214, 0.5);
  --cream:        #FFF9D6;
  --cream-dim:    rgba(255, 249, 214, 0.65);
  --cream-faint:  rgba(255, 249, 214, 0.25);
  --green-dark:   #085226;
  --green-mid:    #005226;
  --text:         #FFF9D6;
  --text-muted:   rgba(255, 249, 214, 0.45);
  --danger:       #c0392b;
  --danger-dim:   rgba(192, 57, 43, 0.2);
  --radius:       6px;
  --shadow:       0 4px 20px rgba(0, 0, 0, 0.5);
}

/* ── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
/* Empêche le "tirer pour rafraîchir" mobile (rechargement accidentel) */
html, body { overscroll-behavior-y: none; }

body {
  background: radial-gradient(ellipse at top, var(--green-mid) 0%, var(--bg-deep) 80%);
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Poppins', Arial, sans-serif;
  font-weight: 300;
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Typographie ────────────────────────────────────────────────── */
h1 {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 1.7rem;
  color: var(--cream);
  letter-spacing: .06em;
}
h2 {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 1.1rem;
  color: var(--cream);
  letter-spacing: .06em;
}
h3 {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 1rem;
  color: var(--cream);
}

/* ── Layout ─────────────────────────────────────────────────────── */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem;
}

/* ── Header ─────────────────────────────────────────────────────── */
.site-header,
.fiche-header {
  background: rgba(5, 40, 21, 0.95);
  border-bottom: 1px solid var(--border);
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(6px);
}

/* ── Boutons ────────────────────────────────────────────────────── */
button, .btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .45rem .9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--cream);
  font-family: 'Poppins', Arial, sans-serif;
  font-size: .85rem;
  font-weight: 400;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  text-decoration: none;
  white-space: nowrap;
}
button:hover, .btn:hover {
  background: var(--bg-hover);
  border-color: var(--cream-dim);
  color: var(--cream);
}

.btn-primary {
  background: var(--cream);
  border-color: var(--cream);
  color: var(--green-dark);
  font-weight: 600;
}
.btn-primary:hover {
  background: #fffae8;
  border-color: #fffae8;
  color: var(--green-dark);
}

.btn-danger {
  border-color: rgba(192, 57, 43, 0.5);
  color: #e07070;
  background: var(--danger-dim);
}
.btn-danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn-retour {
  color: var(--cream-dim);
  font-size: .85rem;
  text-decoration: none;
  border: none;
  background: transparent;
  padding: .3rem .5rem;
}
.btn-retour:hover {
  color: var(--cream);
  background: transparent;
  border: none;
}

.btn-icon {
  padding: .3rem .5rem;
  font-size: .8rem;
  border-radius: 4px;
}

/* ── Inputs ─────────────────────────────────────────────────────── */
input[type="text"],
input[type="number"],
select,
textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--cream);
  font-family: 'Poppins', Arial, sans-serif;
  font-size: .9rem;
  padding: .4rem .6rem;
  width: 100%;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
}
input[type="number"] { text-align: center; }
textarea { resize: vertical; min-height: 60px; }
input::placeholder { color: var(--text-muted); }
.notes-textarea { min-height: 320px; }

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: .75rem;
  backdrop-filter: blur(4px);
}
.card-title {
  font-family: 'Cinzel', Georgia, serif;
  font-size: .68rem;
  color: var(--cream-dim);
  text-transform: uppercase;
  letter-spacing: .14em;
  margin-bottom: .65rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--border);
}

/* ── Badges de tome ─────────────────────────────────────────────── */
.badge-tome {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 3px;
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-family: 'Cinzel', Georgia, serif;
}
.badge-t1 { background: rgba(8, 82, 38, 0.6); color: var(--cream); border: 1px solid rgba(255,249,214,0.3); }
.badge-t2 { background: rgba(5, 55, 30, 0.8); color: var(--cream); border: 1px solid rgba(255,249,214,0.4); }
.badge-t3 { background: rgba(3, 35, 18, 0.9); color: var(--cream); border: 1px solid rgba(255,249,214,0.5); }

/* ── Page d'accueil ─────────────────────────────────────────────── */
.accueil-header {
  text-align: center;
  padding: 2.5rem 1rem 1.5rem;
}
.accueil-header h1 { font-size: 2.2rem; text-shadow: 0 2px 12px rgba(0,0,0,0.5); }
.accueil-header .serie { color: var(--cream-dim); font-size: .85rem; margin-top: .35rem; letter-spacing: .05em; }

.accueil-actions {
  display: flex;
  justify-content: center;
  gap: .75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.liste-vide {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  padding: 2rem;
}

.grille-personnages {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: .75rem;
}

.carte-personnage {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  transition: border-color .2s, background .2s;
  backdrop-filter: blur(4px);
}
.carte-personnage:hover {
  border-color: var(--cream-dim);
  background: var(--bg-card-2);
}
.carte-personnage h3 {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 1.05rem;
  color: var(--cream);
}
.carte-meta {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  font-size: .78rem;
}
.carte-pv { color: var(--cream-dim); }
.carte-chapitre { color: var(--gold); }
.carte-actions { display: flex; gap: .5rem; margin-top: .25rem; }
.carte-actions .btn-primary { flex: 1; justify-content: center; }

/* ── Modale ─────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .7);
  z-index: 200;
  padding: 1rem;
  backdrop-filter: blur(3px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
/* Grid (plutôt que flex) : évite le bug de centrage flex qui rend
   le haut/bas d'un contenu débordant inatteignable au scroll tactile mobile */
.modal-overlay.active { display: grid; place-items: center; }
.modal {
  background: rgba(5, 40, 21, 0.97);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
  box-shadow: var(--shadow);
}
.modal h2 { margin-bottom: 1rem; }
.modal-close {
  position: absolute;
  top: .75rem;
  right: .75rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: .2rem .4rem;
}
.modal-close:hover { color: var(--cream); background: transparent; border: none; }

.form-group { margin-bottom: .85rem; }
.form-group label {
  display: block;
  font-size: .72rem;
  color: var(--cream-dim);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: .35rem;
}
.form-actions {
  display: flex;
  gap: .5rem;
  margin-top: 1rem;
  justify-content: flex-end;
}

/* ── Sélecteur de tome ──────────────────────────────────────────── */
.tome-selector { display: flex; gap: .4rem; }
.tome-btn {
  flex: 1;
  justify-content: center;
  font-size: .8rem;
  padding: .4rem .5rem;
}
.tome-btn.active {
  background: var(--cream);
  border-color: var(--cream);
  color: var(--green-dark);
  font-weight: 600;
}

/* ── Fiche header ───────────────────────────────────────────────── */
.fiche-header { flex-direction: column; align-items: stretch; gap: .6rem; }
.fiche-header-row { display: flex; align-items: center; gap: .75rem; }
.fiche-header-nom { flex: 1; min-width: 0; }
.fiche-header-nom input {
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 1.05rem;
  color: var(--cream);
  padding: .2rem 0;
  width: 100%;
}
.fiche-header-nom input:focus {
  border-bottom-color: var(--cream-dim);
  outline: none;
}
.fiche-header-sub { display: flex; align-items: center; gap: .4rem; }
.icone-chapitre { font-size: .8rem; flex-shrink: 0; }
.input-chapitre-header {
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  color: var(--cream-dim);
  font-size: .75rem;
  padding: .1rem 0;
  width: auto;
  flex: 1;
  min-width: 0;
}
.input-chapitre-header:focus {
  border-bottom-color: var(--cream-dim);
  outline: none;
  color: var(--cream);
}
.fiche-header-actions { display: flex; gap: .5rem; align-items: center; justify-content: center; }

/* ── Menu déroulant ─────────────────────────────────────────────── */
.dropdown-wrapper { position: relative; }
.dropdown {
  display: none;
  position: absolute;
  top: calc(100% + .35rem);
  right: 0;
  background: rgba(5, 40, 21, 0.97);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 210px;
  box-shadow: var(--shadow);
  z-index: 150;
  overflow: hidden;
}
.dropdown.open { display: block; }
.dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  border-radius: 0;
  padding: .65rem 1rem;
  background: transparent;
  border-bottom: 1px solid var(--border);
}
.dropdown button:last-child { border-bottom: none; }
.dropdown button:hover { background: var(--bg-hover); }

/* ── Stats ──────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .6rem;
}
.stat-grid.triple { grid-template-columns: 1fr 1fr 1fr; }
.stat-grid.quad   { grid-template-columns: 1fr 1fr 1fr 1fr; }

.stat-box {
  background: rgba(3, 50, 22, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem .6rem;
  text-align: center;
}
.stat-box label {
  display: block;
  font-size: .62rem;
  color: var(--cream-dim);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: .3rem;
}
.stat-box input[type="number"] {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  color: var(--cream);
  font-weight: 600;
  width: 100%;
  padding: 0;
}
.stat-box input[type="number"]:focus { outline: none; }

/* ── Stat verrouillée (PV Max) ──────────────────────────────────── */
.stat-locked-val {
  font-size: 1.4rem;
  color: var(--cream);
  font-weight: 600;
  text-align: center;
  padding: .15rem 0;
}

/* ── Barre PV ───────────────────────────────────────────────────── */
.pv-barre {
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  margin-top: .5rem;
  overflow: hidden;
}
.pv-barre-fill {
  height: 100%;
  background: var(--cream);
  border-radius: 3px;
  transition: width .3s;
}
.pv-barre-fill.danger  { background: #c0392b; }
.pv-barre-fill.warning { background: #a07020; }

/* ── Stepper +/- (Chance) ───────────────────────────────────────── */
.stat-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
}
.stat-stepper .btn-step {
  width: 1.8rem;
  height: 1.8rem;
  padding: 0;
  font-size: 1rem;
  border-radius: 3px;
  justify-content: center;
  flex-shrink: 0;
}
.stat-stepper .step-val {
  font-size: 1.4rem;
  color: var(--cream);
  font-weight: 600;
  min-width: 2rem;
  text-align: center;
}

/* ── Talents (verrouillés) ──────────────────────────────────────── */
.talents-wrapper { display: flex; flex-wrap: wrap; gap: .35rem; }
.talent-tag {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: rgba(255, 249, 214, 0.1);
  border: 1px solid var(--cream-faint);
  border-radius: 3px;
  padding: .25rem .65rem;
  font-size: .82rem;
  color: var(--cream);
}
.talent-tag .niv-label { font-size: .65rem; color: var(--text-muted); }
.talent-tag input[type="number"] {
  width: 42px;
  font-size: .78rem;
  padding: .1rem .2rem;
  border-radius: 2px;
  border-color: var(--cream-faint);
  background: rgba(3, 50, 22, 0.6);
}

/* ── Choix de talent (radio) ────────────────────────────────────── */
.talent-radio-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .3rem;
}
.talent-radio {
  display: flex;
  align-items: center;
  gap: .4rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .4rem .6rem;
  cursor: pointer;
  font-size: .85rem;
  transition: border-color .15s, background .15s;
  color: var(--cream);
}
.talent-radio input[type="radio"] { width: auto; accent-color: var(--cream); }
.talent-radio.selected {
  border-color: var(--cream);
  background: rgba(255, 249, 214, 0.12);
  color: var(--cream);
}

/* ── Mode de jeu ────────────────────────────────────────────────── */
.mode-jeu-selector { display: flex; gap: .4rem; }
.mode-btn {
  flex: 1;
  justify-content: center;
  padding: .4rem .3rem;
  font-size: .8rem;
}
.mode-btn.active {
  background: var(--cream);
  border-color: var(--cream);
  color: var(--green-dark);
  font-weight: 600;
}
.mode-jeu-badge {
  display: inline-block;
  padding: .3rem .9rem;
  border-radius: 3px;
  font-size: .9rem;
  background: rgba(255, 249, 214, 0.12);
  border: 1px solid var(--cream-faint);
  color: var(--cream);
  font-weight: 500;
  font-family: 'Cinzel', Georgia, serif;
  letter-spacing: .05em;
}

/* ── Réputation ─────────────────────────────────────────────────── */
.rep-scale { display: flex; gap: .2rem; flex-wrap: wrap; }
.rep-btn {
  width: 2rem;
  height: 2rem;
  justify-content: center;
  padding: 0;
  font-size: .75rem;
  border-radius: 3px;
}
.rep-btn.active {
  background: var(--cream);
  color: var(--green-dark);
  border-color: var(--cream);
  font-weight: bold;
}
.rep-labels {
  display: flex;
  justify-content: space-between;
  font-size: .65rem;
  color: var(--text-muted);
  margin-top: .2rem;
}

/* ── Jours écoulés ──────────────────────────────────────────────── */
.jours-selector { display: flex; gap: .4rem; }
.jour-btn {
  width: 2.4rem;
  height: 2.4rem;
  justify-content: center;
  padding: 0;
  font-size: .9rem;
  border-radius: 3px;
}
.jour-btn.active {
  background: var(--cream);
  color: var(--green-dark);
  border-color: var(--cream);
  font-weight: bold;
}

/* ── Sauvegarde ─────────────────────────────────────────────────── */
.sauvegarde-row { display: flex; gap: .5rem; }
.sauvegarde-row input[type="text"] { text-align: center; font-size: .85rem; }

/* ── Sauvegardes (Mode simplifié) ──────────────────────────────── */
.sauvegardes-liste { display: flex; flex-direction: column; gap: .4rem; }
.sauvegarde-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  background: rgba(3, 50, 22, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .45rem .6rem;
  font-size: .82rem;
}
.sauvegarde-chapitre { color: var(--gold); font-weight: 600; }
.sauvegarde-date { color: var(--text-muted); font-size: .75rem; }

/* ── Liste de chapitres (Tome 2) ──────────────────────────────── */
.chapitres-liste { display: flex; flex-direction: column; gap: .4rem; margin-top: .75rem; }
.chapitre-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  background: rgba(3, 50, 22, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .45rem .6rem;
  font-size: .85rem;
}
.chapitre-item label { display: flex; align-items: center; gap: .5rem; cursor: pointer; }
.chapitre-item input[type="checkbox"] { width: 1.1rem; height: 1.1rem; cursor: pointer; }
.chapitre-item input[type="checkbox"]:checked + span { color: var(--text-muted); text-decoration: line-through; }

/* ── Armes ──────────────────────────────────────────────────────── */
.armes-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.armes-table th {
  text-align: left;
  color: var(--text-muted);
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: .3rem .4rem;
  border-bottom: 1px solid var(--border);
  font-family: 'Cinzel', Georgia, serif;
}
.armes-table td {
  padding: .35rem .4rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.armes-table tr:last-child td { border-bottom: none; }
.armes-table .col-bonus { width: 80px; text-align: center; }
.armes-table .col-action { width: 36px; text-align: center; }

.dommages-total {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .85rem;
  margin-top: .5rem;
  padding-top: .5rem;
  border-top: 1px solid var(--border);
}
.dommages-val {
  font-size: 1.2rem;
  color: var(--cream);
  font-weight: 600;
  font-family: 'Cinzel', Georgia, serif;
}

/* ── Inventaire ─────────────────────────────────────────────────── */
.inventaire-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .4rem;
}
@media (max-width: 480px) { .inventaire-grid { grid-template-columns: 1fr; } }

.inv-slot {
  display: flex;
  align-items: center;
  gap: .35rem;
  background: rgba(3, 50, 22, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .3rem .4rem;
  transition: border-color .15s;
}
.inv-slot.occupee { border-color: rgba(255, 249, 214, 0.25); }
.inv-slot.arme    { border-left: 2px solid var(--cream-dim); }

.inv-num {
  font-size: .65rem;
  color: var(--text-muted);
  min-width: 1.2rem;
  text-align: center;
}
.inv-nom {
  flex: 1;
  font-size: .82rem;
  background: transparent;
  border: none;
  color: var(--cream);
  padding: .1rem 0;
  min-width: 0;
}
.inv-nom:focus { outline: none; }
.inv-qte {
  width: 36px;
  font-size: .75rem;
  padding: .1rem .2rem;
  text-align: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-muted);
}
.inv-boulons {
  display: flex;
  align-items: center;
  gap: .25rem;
  font-size: .75rem;
  color: var(--cream-dim);
}
.inv-boulons input {
  width: 44px;
  font-size: .75rem;
  padding: .1rem .2rem;
}
.inv-info { flex: 1; min-width: 0; }

.inv-compteur { font-size: .75rem; color: var(--text-muted); text-align: right; margin-bottom: .4rem; }
.inv-compteur.plein { color: #e07070; }

.inv-actions { display: flex; gap: .25rem; flex-shrink: 0; }
.btn-soin {
  border-color: rgba(80, 180, 100, 0.5);
  color: #7ed87e;
  background: rgba(80, 180, 100, 0.12);
}
.btn-soin:hover {
  background: rgba(80, 180, 100, 0.3);
  border-color: rgba(80, 180, 100, 0.8);
  color: #b0ffb0;
}

/* ── Ajouter un objet ───────────────────────────────────────────── */
.recherche-objet { display: flex; gap: .5rem; align-items: flex-end; }
.recherche-objet .form-group { flex: 1; margin-bottom: 0; }

.resultats-objets { margin-top: .75rem; }
.objet-result {
  background: rgba(3, 50, 22, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .75rem;
  margin-bottom: .4rem;
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  transition: border-color .15s;
}
.objet-result:hover { border-color: var(--cream-dim); }
.objet-result-info { flex: 1; min-width: 0; }
.objet-result-nom {
  font-size: .9rem;
  color: var(--cream);
  font-weight: 500;
  font-family: 'Cinzel', Georgia, serif;
}
.marquee-tag {
  display: inline-block;
  font-size: .62rem;
  background: rgba(192, 57, 43, 0.3);
  color: #e07070;
  border: 1px solid rgba(192, 57, 43, 0.5);
  border-radius: 2px;
  padding: 0 .3rem;
  margin-left: .3rem;
  vertical-align: middle;
  font-family: 'Poppins', sans-serif;
}
.objet-result-detail {
  font-size: .75rem;
  color: var(--cream-dim);
  margin-top: .2rem;
  line-height: 1.4;
}
.objet-result-add { flex-shrink: 0; }
.resultats-vide { font-size: .85rem; color: var(--text-muted); font-style: italic; padding: .5rem 0; }

/* ── PV Max / Chance (création) ─────────────────────────────────── */
.roll-row { display: flex; gap: .5rem; align-items: center; }
.roll-row input { flex: 1; font-size: 1.1rem; text-align: center; }
.roll-detail { font-size: .78rem; color: var(--cream-dim); margin-top: .3rem; min-height: 1.2em; }

/* ── Lanceur de dés (3D) ────────────────────────────────────────── */
.des-modal-content { text-align: center; padding: .25rem 0; }
.des-btns { display: flex; gap: .75rem; justify-content: center; margin: .75rem 0 0; flex-wrap: wrap; }
.des-btns button { font-size: 1rem; padding: .6rem 1.4rem; }

#des-cubes-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
  margin: .75rem 0 .25rem;
  padding: .6rem 0;
  perspective: 400px;
}
.des-cube-wrapper {
  font-size: 70px;
  width: 1em;
  height: 1em;
  position: relative;
  margin: .35em;
}
.des-hidden { display: none !important; }
.des-cube {
  position: absolute;
  width: 1em;
  height: 1em;
  transform-origin: .5em .5em;
  transform-style: preserve-3d;
  transition: transform 2s ease-out;
}
.des-face, .des-beam {
  position: absolute;
  width: 1em;
  height: 1em;
  border-radius: .12em;
  background: var(--cream);
  box-sizing: border-box;
}
.des-face {
  border: .025em solid var(--green-dark);
  display: flex;
  padding: .1em;
}
.des-beam { width: .96em; height: .96em; }

/* 3D face positions */
.des-face-1 { transform: translateZ(.5em); justify-content: center; align-items: center; }
.des-face-2 { transform: rotateY(90deg) translateZ(.5em); justify-content: space-between; }
.des-face-3 { transform: rotateX(90deg) translateZ(.5em); justify-content: space-between; }
.des-face-4 { transform: rotateX(-90deg) translateZ(.5em); flex-direction: column; justify-content: space-between; }
.des-face-5 { transform: rotateY(-90deg) translateZ(.5em); flex-direction: column; justify-content: space-between; }
.des-face-6 { transform: rotateX(-180deg) translateZ(.5em); justify-content: space-between; }
.des-beam-1 { transform: rotateX(-180deg) translateX(.02em) translateY(-.02em) translateZ(0); }
.des-beam-2 { transform: rotateX(90deg) translateX(.02em) translateY(.02em) translateZ(0); }
.des-beam-3 { transform: rotateY(90deg) translateX(.02em) translateY(.02em) translateZ(0); }

/* Pip (die dot) */
.des-pip {
  background: var(--green-dark);
  width: .18em;
  height: .18em;
  border-radius: .09em;
  box-shadow: 0 0 .025em var(--green-dark);
  flex-shrink: 0;
}
/* Face 2: top-left + bottom-right */
.des-face-2 .des-pip:first-child { align-self: flex-start; }
.des-face-2 .des-pip:last-child  { align-self: flex-end; }
/* Face 3: top-left + center + bottom-right */
.des-face-3 .des-pip:nth-child(1) { align-self: flex-start; }
.des-face-3 .des-pip:nth-child(2) { align-self: center; }
.des-face-3 .des-pip:nth-child(3) { align-self: flex-end; }
/* Faces 4 & 5: rows */
.des-pip-row { display: flex; justify-content: space-between; width: 100%; }
.des-pip-mid { justify-content: center; }
/* Face 6: columns */
.des-pip-col { display: flex; flex-direction: column; justify-content: space-between; height: 100%; }

.des-resultat {
  font-size: 2.8rem;
  color: var(--cream);
  font-weight: 700;
  font-family: 'Cinzel', Georgia, serif;
  min-height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.des-detail { font-size: .85rem; color: var(--cream-dim); min-height: 1.4rem; }

.des-chance-section {
  margin-top: .85rem;
  padding: .6rem .75rem;
  background: rgba(255,249,214,.06);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
}
.des-chance-label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--cream-dim);
}
.des-chance-info {
  font-size: .85rem;
  color: var(--cream);
}
.des-chance-info span { font-weight: 600; }

.des-relance-section {
  margin-top: .5rem;
}
.des-relance-section button {
  width: 100%;
  font-size: .82rem;
  padding: .5rem .75rem;
  border-color: rgba(200, 170, 80, 0.5);
  color: #e8c860;
  background: rgba(200, 170, 80, 0.1);
}
.des-relance-section button:hover {
  background: rgba(200, 170, 80, 0.25);
  border-color: rgba(200, 170, 80, 0.8);
}

.btn-warning {
  border-color: rgba(200, 140, 40, 0.5);
  color: #d4a040;
  background: rgba(200, 140, 40, 0.12);
}
.btn-warning:hover {
  background: rgba(200, 140, 40, 0.3);
  border-color: rgba(200, 140, 40, 0.8);
  color: #f0c060;
}

/* ── Simulateur de combat ───────────────────────────────────────── */
.combat-hidden { display: none !important; }

.combat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .75rem 0 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: .75rem;
}
.combat-side { flex: 1; }
.combat-side-label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--cream-dim);
  margin-bottom: .2rem;
}
.combat-side-pv {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 1.6rem;
  color: var(--cream);
  font-weight: 700;
}
.combat-side-pv .pv-label { font-size: .85rem; font-weight: 400; opacity: .7; }
.combat-side--droite { text-align: right; }
.combat-epee { font-size: 1.4rem; flex-shrink: 0; }

.combat-log {
  min-height: 100px;
  max-height: 180px;
  overflow-y: auto;
  background: rgba(0,0,0,.25);
  border-radius: var(--radius);
  padding: .5rem .75rem;
  margin-bottom: .75rem;
  font-size: .8rem;
  line-height: 1.5;
}
.combat-log-line { padding: .1rem 0; }
.log-hit   { color: #f0c040; }
.log-miss  { color: var(--cream-dim); }
.log-dgt   { color: #ff8888; }
.log-sep   { color: var(--border); text-align: center; padding: .25rem 0; letter-spacing: .2em; }

.combat-action { text-align: center; padding: .25rem 0 .5rem; }
.combat-turn-label {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--cream-dim);
  margin-bottom: .6rem;
}
.btn-combat-roll { font-size: 1rem; padding: .6rem 1.8rem; }

.combat-result-msg {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 1.4rem;
  text-align: center;
  padding: 1.5rem 0 .75rem;
  font-weight: 600;
}
.combat-victoire { color: #7ed87e; }
.combat-defaite  { color: #ff7c7c; }
.combat-livre-choix {
  text-align: center;
  font-size: .85rem;
  color: var(--cream-dim);
  font-style: italic;
  margin-bottom: .75rem;
}
.combat-bonus-panel {
  background: rgba(255,249,214,.06);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .45rem .75rem;
  margin-bottom: .6rem;
  font-size: .78rem;
}
.combat-bonus-title {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--cream-dim);
  margin-bottom: .3rem;
}
.combat-bonus-list { display: flex; flex-wrap: wrap; gap: .4rem; }
.combat-bonus-item {
  background: rgba(255,249,214,.09);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .15rem .45rem;
  color: var(--cream);
}
/* ── Sections conditionnelles par tome ──────────────────────────── */
.only-t1, .only-t2, .only-t3, .from-t2, .from-t3 { display: none; }

body.tome-1 .only-t1  { display: block; }
body.tome-2 .only-t2  { display: block; }
body.tome-3 .only-t3  { display: block; }
body.tome-2 .from-t2,
body.tome-3 .from-t2  { display: block; }
body.tome-3 .from-t3  { display: block; }

body.tome-1 .only-t1.stat-grid  { display: grid; }
body.tome-2 .from-t2.stat-grid,
body.tome-3 .from-t2.stat-grid  { display: grid; }

/* ── Utilitaires ────────────────────────────────────────────────── */
.hidden      { display: none !important; }
.text-muted  { color: var(--text-muted); font-size: .8rem; }
.mt-sm       { margin-top: .5rem; }
.separator   { border: none; border-top: 1px solid var(--border); margin: .75rem 0; }

/* ── Footer ─────────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  font-size: .75rem;
  color: var(--text-muted);
  padding: 1.5rem 1rem 2rem;
}

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .stat-grid.triple { grid-template-columns: 1fr 1fr; }
  .accueil-header h1 { font-size: 1.6rem; }
  #card-sauvegardes-simplifie .form-actions .btn-label { display: none; }
  #card-sauvegardes-simplifie .form-actions button { padding: .5rem .7rem; }
}
