:root {
  --slate: #151b26;
  --storm: #26344d;
  --storm-light: #3d5375;
  --gold: #d9b25f;
  --gold-ui: #ffd100;
  --parchment: #ead9b0;
  --parchment-dark: #d6c08e;
  --ink: #3a2914;
  --ink-soft: #6b5233;
  --class: #ffd100;

  --q-poor: #9d9d9d; --q-common: #ffffff; --q-uncommon: #1eff00; --q-rare: #0070dd;
  --q-epic: #a335ee; --q-legendary: #ff8000; --q-artifact: #e6cc80; --q-heirloom: #00ccff;

  --display: 'Marcellus', 'Palatino Linotype', serif;
  --text: 'Alegreya', Georgia, serif;

  /* échelle typographique : quarte (1,333) */
  --s-1: 0.75rem; --s0: 1rem; --s1: 1.333rem; --s2: 1.777rem; --s3: 2.369rem; --s4: 3.157rem;
}

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--slate);
  color: #e9e4d8;
  font: 400 var(--s0)/1.6 var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { display: block; }
a { color: var(--gold); text-underline-offset: 3px; }
a:hover { color: var(--gold-ui); }
:focus-visible { outline: 2px solid var(--gold-ui); outline-offset: 3px; }

/* Ciel d'orage : nuages lents par dégradés, éclair unique au chargement */
.storm {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60% 45% at 50% 32%, rgba(120, 150, 200, .22), transparent 70%),
    radial-gradient(40% 30% at 15% 10%, rgba(61, 83, 117, .55), transparent 70%),
    radial-gradient(45% 35% at 88% 18%, rgba(38, 52, 77, .8), transparent 70%),
    linear-gradient(180deg, #1c2536 0%, var(--slate) 55%, #10141c 100%);
}
.storm::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(35% 25% at 50% 30%, rgba(200, 220, 255, .55), transparent 70%);
  opacity: 0;
}
.ready .storm::after { animation: flash 1.6s ease-out .15s 1; }
@keyframes flash { 0% { opacity: 0 } 6% { opacity: .9 } 12% { opacity: .15 } 18% { opacity: .6 } 100% { opacity: 0 } }

.notice {
  max-width: 64rem; margin: 1rem auto 0; padding: .6rem 1rem;
  border: 1px solid rgba(217, 178, 95, .4); border-radius: 4px;
  background: rgba(38, 52, 77, .6); color: var(--parchment); font-size: .95rem;
}

/* ---------- Plaque de nom ---------- */
.nameplate {
  max-width: 72rem; margin: 0 auto; padding: 2.5rem 1.5rem 1rem;
  display: grid; grid-template-columns: auto 1fr auto; gap: 1.25rem; align-items: center;
}
.crest {
  width: 64px; height: 64px; border-radius: 50%;
  border: 2px solid var(--gold); box-shadow: 0 0 0 4px rgba(0, 0, 0, .45), 0 0 24px rgba(217, 178, 95, .25);
  background: #000;
}
h1 {
  margin: 0; font: 400 var(--s4)/1 var(--display); letter-spacing: .01em;
  color: var(--gold-ui); text-shadow: 0 2px 0 #000, 0 0 30px rgba(255, 209, 0, .18);
}
h1 .surname { color: var(--parchment); }
.guild { margin: .35rem 0 0; font: 400 var(--s1)/1.2 var(--display); color: #40ff40; text-shadow: 0 1px 0 #000; }
.guild:empty { display: none; }
.line { margin: .2rem 0 0; color: #c8c2b4; font-size: var(--s1); }
.line::first-letter { text-transform: uppercase; }

.quick { display: flex; gap: 1.75rem; margin: 0; }
.quick div { text-align: right; }
.quick dt { font-size: var(--s-1); color: #9aa6ba; letter-spacing: .02em; }
.quick dd { margin: 0; font: 400 var(--s1)/1.2 var(--display); color: var(--parchment); }

/* ---------- Panneau personnage ---------- */
.pane {
  max-width: 72rem; margin: 0 auto; padding: 1rem 1.5rem 2rem;
  display: grid;
  grid-template-columns: 1fr minmax(260px, 380px) 1fr;
  grid-template-areas: "left render right" ". weapons .";
  gap: 0 1.5rem;
}
.slots { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; align-content: start; }
.slots-left { grid-area: left; }
.slots-right { grid-area: right; }
.slots-weapons { grid-area: weapons; grid-template-columns: repeat(3, auto); justify-content: center; gap: .75rem; margin-top: .5rem; }

.slot { display: flex; align-items: center; gap: .75rem; min-height: 52px; border-radius: 4px; cursor: default; }
.slots-left .slot { flex-direction: row-reverse; text-align: right; }
.slots-weapons .slot { flex-direction: column; text-align: center; max-width: 9.5rem; }
.slot .frame, .talent .frame, .profs .frame {
  flex: none; position: relative; width: 48px; height: 48px; border-radius: 5px; overflow: hidden;
  background: linear-gradient(145deg, #0d1118, #222b3a);
  border: 1px solid #000;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08), 0 0 0 2px var(--qc, #4a4a4a), 0 3px 8px rgba(0, 0, 0, .6);
}
.slot .frame img { width: 100%; height: 100%; }
.slot.empty .frame { box-shadow: inset 0 0 12px rgba(0, 0, 0, .8), 0 0 0 2px #2c3443; opacity: .6; }
.slot .label { display: grid; line-height: 1.25; min-width: 0; }
.item-name { font-weight: 500; color: var(--qc, #7f8796); font-size: .98rem; }
.item-meta { font-size: .8rem; color: #8b93a3; }
.slot.empty .item-name { color: #6c7486; font-weight: 400; }
.slot:not(.empty):hover .frame, .slot:focus-visible .frame { filter: brightness(1.2); }
.slot:focus-visible { outline-offset: 4px; }

.q-poor { --qc: var(--q-poor); } .q-common { --qc: var(--q-common); } .q-uncommon { --qc: var(--q-uncommon); }
.q-rare { --qc: var(--q-rare); } .q-epic { --qc: var(--q-epic); } .q-legendary { --qc: var(--q-legendary); }
.q-artifact { --qc: var(--q-artifact); } .q-heirloom { --qc: var(--q-heirloom); }
.slot.q-common .frame { box-shadow: inset 0 0 0 1px rgba(255,255,255,.08), 0 0 0 2px #5b5b5b, 0 3px 8px rgba(0,0,0,.6); }

.render {
  grid-area: render; position: relative; margin: 0; min-height: 520px;
  display: grid; place-items: end center;
}
.render-glow {
  position: absolute; inset: 8% 0 0; border-radius: 50% 50% 0 0 / 40% 40% 0 0;
  background: radial-gradient(50% 60% at 50% 70%, rgba(217, 178, 95, .16), transparent 70%);
}
.render::after {
  content: ''; position: absolute; left: 10%; right: 10%; bottom: 0; height: 28px;
  background: radial-gradient(50% 50% at 50% 50%, rgba(0, 0, 0, .7), transparent);
}
#render-img { position: relative; z-index: 1; width: 100%; height: auto; }
.render.raw #render-img { width: 150%; max-width: none; margin: -8% -25% -2%; filter: drop-shadow(0 10px 30px rgba(0, 0, 0, .55)); }
.render.boxed #render-img { border-radius: 6px; box-shadow: 0 0 0 1px var(--gold), 0 20px 50px rgba(0,0,0,.6); }
.render-empty { position: relative; z-index: 1; align-self: center; text-align: center; max-width: 16rem; color: #9aa6ba; font-size: .95rem; }
.render-empty img { margin: 0 auto 1rem; border-radius: 50%; border: 2px solid var(--gold); box-shadow: 0 0 40px rgba(217, 178, 95, .25); }
.render-empty img:not([src]) { display: none; }

/* Séquence d'ouverture : le perso se matérialise, les emplacements s'allument */
.ready #render-img:not([hidden]) { animation: materialize 1.1s cubic-bezier(.2, .7, .2, 1) both; }
.ready .slot { animation: slot-in .5s ease-out both; animation-delay: calc(.35s + var(--i) * 35ms); }
@keyframes materialize { from { opacity: 0; filter: blur(12px) brightness(2); transform: translateY(12px); } }
@keyframes slot-in { from { opacity: 0; } }

/* ---------- Caractéristiques ---------- */
.stats {
  max-width: 72rem; margin: 0 auto 3rem; padding: 1.25rem 1.5rem;
  border-top: 1px solid rgba(217, 178, 95, .35); border-bottom: 1px solid rgba(217, 178, 95, .35);
  background: linear-gradient(180deg, rgba(16, 20, 28, .65), rgba(16, 20, 28, .35));
}
.bars { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-bottom: 1.25rem; }
.bar {
  display: flex; justify-content: space-between; align-items: baseline; padding: .35rem .8rem;
  border-radius: 3px; border: 1px solid #000; box-shadow: inset 0 1px 0 rgba(255,255,255,.2);
  font-family: var(--display); text-shadow: 0 1px 0 #000;
}
.bar strong { font-weight: 400; font-size: var(--s1); }
.bar.hp { background: linear-gradient(180deg, #1fa31f, #0b5e0b); }
.bar.power { background: linear-gradient(180deg, #2a5fd8, #12307a); }
.bar.power.rage { background: linear-gradient(180deg, #c62a2a, #6d1111); }
.bar.power.energy { background: linear-gradient(180deg, #d9c02a, #806e0c); color: #1a1505; text-shadow: none; }
.stat-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 1rem 2rem; }
.stat-group h3 { margin: 0 0 .35rem; font: 400 var(--s0)/1.3 var(--display); color: var(--gold-ui); }
.stat-group dl { margin: 0; }
.stat-group dl div { display: flex; justify-content: space-between; gap: 1rem; padding: .12rem 0; border-bottom: 1px dotted rgba(154, 166, 186, .25); }
.stat-group dt { color: #c8c2b4; }
.stat-group dd { margin: 0; color: #fff; font-variant-numeric: tabular-nums; }

/* ---------- Journal (parchemin) ---------- */
.journal {
  max-width: 72rem; margin: 0 auto; padding: 0 1.5rem 3rem;
  display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; align-items: start;
}
.journal:not(:has(.page:not([hidden]))) { display: none; }
.page-col { display: grid; gap: 1.5rem; }
.page-col:not(:has(.page:not([hidden]))) { display: none; }
.page {
  position: relative; padding: 1.5rem 1.75rem 1.75rem; color: var(--ink);
  background:
    radial-gradient(120% 90% at 50% 40%, transparent 55%, rgba(120, 84, 40, .35) 100%),
    linear-gradient(175deg, #f1e3bf, var(--parchment) 40%, var(--parchment-dark));
  border-radius: 3px;
  box-shadow: 0 0 0 1px #6b5233, 0 0 0 4px #2a1f12, 0 18px 40px rgba(0, 0, 0, .5);
  line-height: 1.7;
}
.page h2 {
  margin: 0 0 1rem; font: 400 var(--s2)/1.15 var(--display); color: #5a2d0c;
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  padding-bottom: .4rem; border-bottom: 1px solid rgba(90, 45, 12, .3);
}
.split { font-size: var(--s1); color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-soft); font-style: italic; margin: 0; }

.trees { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 1.5rem; }
.tree h3 { margin: 0 0 .6rem; font: 400 var(--s1)/1.2 var(--display); color: var(--ink); display: flex; justify-content: space-between; }
.tree h3 span { color: var(--ink-soft); }
.tree.main h3 { color: #7a1f0c; }
.talent-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, 44px); gap: .6rem; }
.talent { position: relative; cursor: default; }
.talent .frame { display: block; }
.talent .frame { width: 40px; height: 40px; --qc: #c9a03c; box-shadow: 0 0 0 2px #2a1f12, 0 0 0 3px #c9a03c; }
.talent .frame img { width: 100%; height: 100%; }
.talent .rank {
  position: absolute; right: -6px; bottom: -6px; min-width: 18px; padding: 0 4px; border-radius: 3px;
  background: #111; color: var(--q-uncommon); font: 700 .72rem/18px var(--text); text-align: center; box-shadow: 0 0 0 1px #6b5233;
}

.profs { list-style: none; margin: 0; padding: 0; display: grid; gap: .9rem; }
.profs li { display: flex; gap: .8rem; align-items: center; }
.profs .frame { width: 36px; height: 36px; box-shadow: 0 0 0 2px #2a1f12; }
.profs .frame img { width: 100%; height: 100%; }
.profs li > div { flex: 1; }
.prof-name { margin: 0 0 .2rem; font-weight: 500; }
.prof-name small { color: var(--ink-soft); font-weight: 400; }
.skill { position: relative; height: 18px; border-radius: 2px; background: #2a1f12; overflow: hidden; }
.skill i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(180deg, #3a66c4, #1c3b80); }
.skill span { position: relative; display: block; text-align: center; font-size: .75rem; line-height: 18px; color: #fff; text-shadow: 0 1px 0 #000; }

.facts { margin: 0; }
.facts div { display: flex; justify-content: space-between; gap: 1rem; padding: .2rem 0; border-bottom: 1px dotted rgba(90, 45, 12, .3); }
.facts dt { color: var(--ink-soft); }
.facts dd { margin: 0; font-weight: 500; text-align: right; }

/* ---------- Infobulle façon jeu ---------- */
.tooltip {
  position: fixed; left: 0; top: 0; z-index: 10; pointer-events: none;
  max-width: 22rem; padding: .6rem .75rem;
  background: rgba(6, 8, 22, .94); border: 1px solid #8a8a8a; border-radius: 5px;
  box-shadow: inset 0 0 0 1px #000, 0 8px 24px rgba(0, 0, 0, .6);
  font: 400 .9rem/1.35 var(--text); color: #fff;
}
.tooltip p { margin: 0; }
.t-name { font-family: var(--display); font-size: 1.05rem; margin-bottom: .1rem !important; color: var(--qc, #fff); }
.t-split { display: flex; justify-content: space-between; gap: 1.5rem; }
.t-gold { color: var(--gold-ui); }
.t-green { color: var(--q-uncommon); }
.t-grey { color: #808080; }
.t-setitem { color: #ffff98; }
.t-indent { padding-left: .75rem; }
.t-gap { margin-top: .5rem !important; }
.t-gap-s { margin-top: .2rem !important; }

/* ---------- Pied ---------- */
.foot { max-width: 72rem; margin: 0 auto; padding: 1.5rem 1.5rem 3rem; color: #8b93a3; font-size: .9rem; border-top: 1px solid rgba(154, 166, 186, .15); }
.foot p { margin: .25rem 0; }
.foot p:empty { display: none; }
.legal { font-size: .8rem; color: #6c7486; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .nameplate { grid-template-columns: auto 1fr; }
  .quick { grid-column: 1 / -1; flex-wrap: wrap; gap: 1rem 1.5rem; }
  .quick div { text-align: left; }
  .pane { grid-template-columns: 1fr 1fr; grid-template-areas: "render render" "weapons weapons" "left right"; gap: 1rem; }
  .render { min-height: 420px; max-width: 380px; width: 100%; justify-self: center; }
  .slots-left .slot { flex-direction: row; text-align: left; }
  .journal { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  h1 { font-size: var(--s3); }
  .pane { grid-template-columns: 1fr; grid-template-areas: "render" "weapons" "left" "right"; }
  .slots-weapons { grid-template-columns: 1fr; justify-content: stretch; }
  .slots-weapons .slot { flex-direction: row; text-align: left; max-width: none; }
  .slot.empty { display: none; }
  .render { min-height: 360px; }
  .bars { grid-template-columns: 1fr; }
  .page { padding: 1.25rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
