:root {
  --parchment: #ece3d0;
  --parchment-dark: #ddd0b4;
  --ink: #2c2418;
  --blood: #6b1414;
  --blood-light: #8a2020;
  --gold: #a67c2e;
  --gold-light: #ebd094;
}

body {
  font-family: 'EB Garamond', Georgia, serif;
  color: var(--ink);
  position: relative;
  background-color: #110b06;
}

/* Illustration de fond (discrète, tout au fond de la pile).
   Fixe à l'écran, mais sa position verticale (--bg-pos-y) suit le scroll (voir background.js) :
   milieu de page = milieu de l'image (50 %), avec une bande symétrique autour du centre.
   L'image est la dernière chronique en date (--bg-chronicle, défini en JS). */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-image: var(--bg-chronicle);
  background-size: cover;
  background-position: center var(--bg-pos-y, 50%);
  background-repeat: no-repeat;
  opacity: 0.30;
  filter: saturate(0.85);
}

/* Halos chauds du thème, posés par-dessus l'illustration */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(ellipse 120% 60% at 50% -5%, rgba(110, 55, 10, 0.65), transparent 55%),
    radial-gradient(ellipse 80% 70% at 15% 110%, rgba(80, 30, 5, 0.55), transparent 55%),
    radial-gradient(ellipse 80% 70% at 85% 110%, rgba(60, 20, 5, 0.45), transparent 55%),
    radial-gradient(ellipse 50% 40% at 50% 50%, rgba(90, 40, 8, 0.18), transparent 65%);
}

.font-title {
  font-family: 'Cinzel', serif;
}

.font-display {
  font-family: 'Cinzel Decorative', serif;
}

/* Carte type parchemin */
.parchment {
  background-color: var(--parchment);
  background-image:
    radial-gradient(circle at 15% 20%, rgba(120, 90, 50, 0.10), transparent 25%),
    radial-gradient(circle at 85% 75%, rgba(120, 90, 50, 0.10), transparent 25%),
    radial-gradient(circle at 50% 50%, rgba(255, 252, 240, 0.4), transparent 70%);
  box-shadow:
    inset 0 0 60px rgba(120, 85, 40, 0.18),
    0 10px 30px rgba(0, 0, 0, 0.55);
  border: 1px solid var(--gold);
  position: relative;
}

.parchment::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(166, 124, 46, 0.35);
  border-radius: inherit;
  pointer-events: none;
}

.ornament {
  color: var(--gold);
  letter-spacing: 0.3em;
}

.stat-row:hover {
  background-color: rgba(166, 124, 46, 0.08);
}

/* Boutons +/- gravés */
.rune-btn {
  transition: all 0.15s ease;
}

.rune-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

select,
input {
  font-family: 'EB Garamond', serif;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

select option {
  color: #2c2418;
  background: #ece3d0;
}

/* barre dorée séparatrice */
.gold-divider {
  height: 2px;
  background: linear-gradient(to right, transparent, var(--gold), transparent);
}

.hp-orb {
  background: radial-gradient(circle at 35% 30%, #b33030, #6b1414 65%, #3d0a0a);
  box-shadow:
    inset 0 4px 12px rgba(255, 180, 180, 0.35),
    inset 0 -8px 16px rgba(0, 0, 0, 0.5),
    0 6px 20px rgba(107, 20, 20, 0.5);
}

#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* Galerie des chroniques : tableaux encadrés, légèrement de travers */
.chronicle-frame {
  background: var(--parchment);
  padding: 8px;
  border: 3px solid var(--gold);
  box-shadow:
    inset 0 0 0 1px rgba(166, 124, 46, 0.45),
    0 12px 28px rgba(0, 0, 0, 0.65);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  cursor: pointer;
}

.chronicle-item:nth-child(odd) .chronicle-frame {
  transform: rotate(-1.1deg);
}

.chronicle-item:nth-child(even) .chronicle-frame {
  transform: rotate(1.1deg);
}

.chronicle-item .chronicle-frame:hover {
  transform: rotate(0deg) scale(1.025);
  box-shadow:
    inset 0 0 0 1px rgba(199, 155, 69, 0.7),
    0 16px 40px rgba(0, 0, 0, 0.75),
    0 0 24px rgba(199, 155, 69, 0.18);
}

.chronicle-frame img {
  display: block;
  width: 100%;
  height: auto;
}

.lightbox-backdrop {
  background: rgba(12, 8, 5, 0.92);
  backdrop-filter: blur(4px);
  animation: lightbox-in 0.2s ease;
}

@keyframes lightbox-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* Onglets façon marque-pages de grimoire */
.tab-btn {
  font-family: 'Cinzel', serif;
  letter-spacing: 0.06em;
  border: 1px solid rgba(166, 124, 46, 0.45);
  color: rgba(221, 208, 180, 0.75);
  background: rgba(236, 227, 208, 0.04);
  transition: all 0.2s ease;
}

.tab-btn:hover {
  border-color: var(--gold);
  color: var(--gold-light);
  background: rgba(166, 124, 46, 0.12);
}

.tab-btn.active {
  background: linear-gradient(to bottom, var(--parchment), var(--parchment-dark));
  border-color: var(--gold);
  color: var(--blood);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(166, 124, 46, 0.3);
}

.tab-panel {
  animation: panel-in 0.25s ease;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}