/* Grimoire du Héros — thème parchemin / or / bordeaux, mobile d'abord. */
:root {
	--parch: #f4ead5;
	--parch-2: #ead9b5;
	--paper: #fffaf0;
	--ink: #2b1d14;
	--ink-2: #5a4632;
	--muted: #7b6852;
	--gold: #b8862b;
	--gold-2: #d4a64a;
	--burgundy: #7a1f2b;
	--burgundy-2: #9b2c3a;
	--green: #2f6b3a;
	--red: #a32020;
	--blue: #1f4e7a;
	--radius: 10px;
	--shadow: 0 2px 8px rgba(43, 29, 20, .15);
	--font: Georgia, "Palatino Linotype", "Book Antiqua", Palatino, serif;
	--font-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0; color: var(--ink); font: 16px/1.5 var(--font);
	background: radial-gradient(ellipse at top, #fbf4e3 0%, var(--parch) 45%, var(--parch-2) 100%) fixed;
	min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--burgundy); }
a:hover { color: var(--burgundy-2); }
h1, h2, h3 { font-family: var(--font); color: var(--burgundy); line-height: 1.2; margin: .4em 0 .5em; }
h1 { font-size: 1.6rem; letter-spacing: .02em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--paper); padding: 8px; z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--gold-2); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Barre du haut */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: linear-gradient(#5a1520, var(--burgundy)); color: #f6e7c1; border-bottom: 3px solid var(--gold); position: sticky; top: 0; z-index: 50; }
.brand { display: flex; align-items: center; gap: 8px; color: #f6e7c1; text-decoration: none; font-weight: bold; font-size: 1.1rem; }
.nav-toggle { background: none; border: 1px solid var(--gold-2); color: #f6e7c1; border-radius: 6px; font-size: 1.3rem; padding: 2px 10px; cursor: pointer; }
.mainnav { display: none; position: absolute; top: 100%; right: 0; left: 0; background: var(--burgundy); flex-direction: column; padding: 8px 16px 16px; border-bottom: 3px solid var(--gold); }
.mainnav.open { display: flex; }
.mainnav a, .mainnav .linklike { color: #f6e7c1; text-decoration: none; padding: 8px 0; font: inherit; }
.mainnav .btn { color: var(--ink); }
.linklike { background: none; border: 0; cursor: pointer; padding: 0; color: inherit; text-align: left; }
form.inline { display: inline; }
@media (min-width: 860px) {
	.nav-toggle { display: none; }
	.mainnav { display: flex; position: static; flex-direction: row; align-items: center; gap: 18px; padding: 0; border: 0; background: none; }
}

.main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 16px; }
.footer { font-size: .78rem; color: var(--muted); text-align: center; padding: 16px; border-top: 1px solid var(--parch-2); }
.footer p { max-width: 900px; margin: 4px auto; }

/* Cartes, grilles */
.card { background: var(--paper); border: 1px solid #d9c49a; border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); position: relative; }
.card.narrow { max-width: 520px; margin: 16px auto; }
.center { text-align: center; }
.grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .grid { grid-template-columns: repeat(3, 1fr); } .grid.two { grid-template-columns: repeat(2, 1fr); } }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.muted { color: var(--muted); }
.help { font-size: .85rem; color: var(--muted); margin: 2px 0 10px; }
.lead { font-size: 1.1rem; color: var(--ink-2); }
.lead.small { font-size: 1rem; }
.prose { max-width: 820px; margin: 0 auto; }
.loading { color: var(--muted); font-style: italic; }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: 600 .95rem var(--font-ui); padding: 9px 14px; border-radius: 8px; border: 1px solid #c9ad74; background: linear-gradient(#fffaf0, #f1e2c0); color: var(--ink); cursor: pointer; text-decoration: none; min-height: 40px; transition: transform .08s, box-shadow .15s; }
.btn:hover { box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-disabled { opacity: .45; cursor: not-allowed; filter: grayscale(.6); }
.btn-primary { background: linear-gradient(var(--burgundy-2), var(--burgundy)); color: #fff7e6; border-color: #5a1520; }
.btn-primary:hover { color: #fff; }
.btn-danger { background: var(--red); color: #fff; border-color: #6b1010; }
.btn-danger-ghost { background: transparent; color: var(--red); border-color: var(--red); }
.btn-ghost { background: transparent; }
.btn-small { padding: 5px 10px; min-height: 34px; font-size: .85rem; }
.btn.is-on { background: linear-gradient(var(--gold-2), var(--gold)); border-color: #8a6420; color: #2b1d14; }

/* Formulaires */
.form { display: flex; flex-direction: column; gap: 4px; }
.form label { font-weight: bold; margin-top: 8px; font-family: var(--font-ui); font-size: .9rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input:not([type]), select, textarea {
	font: 1rem var(--font-ui); padding: 9px 10px; border: 1px solid #c9ad74; border-radius: 8px; background: #fffdf7; color: var(--ink); width: 100%; min-height: 42px;
}
textarea { min-height: 90px; resize: vertical; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: normal !important; }
.check input { margin-top: 4px; }
.form .btn { margin-top: 12px; align-self: flex-start; }
fieldset { border: 1px solid #d9c49a; border-radius: 8px; padding: 8px 12px; margin: 8px 0; }
legend { font-weight: bold; font-family: var(--font-ui); font-size: .9rem; padding: 0 4px; }
.radio-row label { display: block; font-weight: normal; margin: 4px 0; }
.code-input { text-transform: uppercase; letter-spacing: .2em; font-family: ui-monospace, monospace !important; }

.alert { padding: 10px 14px; border-radius: 8px; margin: 8px 0 14px; border: 1px solid; font-family: var(--font-ui); font-size: .95rem; }
.alert-success { background: #e6f2e2; border-color: #9cc69a; }
.alert-error { background: #f8e1df; border-color: #d99a95; }
.alert-warn { background: #fbf0d4; border-color: #e0c06c; }
.alert-info { background: #e8eef6; border-color: #9ab0c9; }
.alert ul { margin: 6px 0 0; padding-left: 20px; }
.danger-title { color: var(--red); margin-top: 28px; }

/* Badges de session */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font: 600 .8rem var(--font-ui); background: var(--parch-2); color: var(--ink); }
.badge-session { --badge: var(--burgundy); background: var(--badge); color: #fff; box-shadow: inset 0 0 0 2px rgba(255,255,255,.35); }
.badge.big { font-size: 1rem; padding: 6px 14px; }
.badge-none { background: #ece3cf; color: var(--muted); }
.badge-copy { background: #e1d6f0; color: #4b2f73; }
.char-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.char-badges.big .badge { font-size: .95rem; padding: 5px 12px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.swatch input { position: absolute; opacity: 0; }
.swatch span { --badge: #7a1f2b; display: block; width: 30px; height: 30px; border-radius: 50%; background: var(--badge); border: 3px solid transparent; cursor: pointer; }
.swatch input:checked + span { border-color: var(--ink); box-shadow: 0 0 0 2px var(--gold-2); }
.swatch input:focus-visible + span { outline: 3px solid var(--gold-2); }

/* Accueil */
.hero { text-align: center; padding: 24px 8px 8px; }
.hero h1 { font-size: 1.9rem; }
.hero .actions { justify-content: center; }
.hero-dice { display: flex; justify-content: center; margin-bottom: 8px; perspective: 600px; }
.features { margin-top: 24px; }
@media (min-width: 1000px) { .features { grid-template-columns: repeat(4, 1fr); } }

/* Liste de personnages */
.family-label { font-family: var(--font-ui); font-size: .85rem; color: var(--muted); margin: 18px 0 4px; }
.grid.family { border-left: 4px solid var(--gold); padding-left: 10px; margin-bottom: 18px; }
.char-card h2 { margin-top: 8px; }
.char-sub { color: var(--ink-2); font-size: .92rem; margin: 0 0 8px; }
.char-stats { display: flex; gap: 14px; font-family: var(--font-ui); font-weight: 600; margin-bottom: 10px; }
.char-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.empty { padding: 32px; }
.session-card { text-decoration: none; color: inherit; display: block; }

/* Assistant */
.wizard { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.wiz-main, .play-main, .gm-chars { min-width: 0; }
@media (min-width: 1000px) { .wizard { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; } }
.steps { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin: 0 0 10px; list-style: none; padding-left: 0; }
.steps li button { white-space: nowrap; font: 600 .8rem var(--font-ui); border-radius: 999px; padding: 6px 12px; border: 1px solid #c9ad74; background: var(--paper); cursor: pointer; color: var(--ink); }
.steps li button[aria-current=step] { background: var(--burgundy); color: #fff; border-color: var(--burgundy); }
.steps li button.done::before { content: "✓ "; color: var(--green); }
.steps li button[aria-current=step].done::before { color: #c7f0c0; }
.steps li button.err::after { content: " •"; color: var(--red); }
.step-panel h2 { margin-top: 0; }
.explain { background: #f8f0dc; border-left: 4px solid var(--gold); padding: 10px 12px; border-radius: 6px; font-size: .95rem; margin: 6px 0 12px; }
.choices { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .choices { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1200px) { .choices.three { grid-template-columns: repeat(3, 1fr); } }
.choice { display: block; text-align: left; padding: 12px; border: 2px solid #d9c49a; border-radius: 10px; background: #fffdf7; cursor: pointer; font: inherit; color: inherit; width: 100%; }
.choice:hover { border-color: var(--gold); }
.choice[aria-pressed=true], .choice.selected { border-color: var(--burgundy); background: #fbeff0; box-shadow: 0 0 0 2px rgba(122,31,43,.2); }
.choice strong { display: block; color: var(--burgundy); font-size: 1.05rem; }
.choice small { color: var(--muted); display: block; margin-top: 4px; font-family: var(--font-ui); }
.choice.disabled { opacity: .45; cursor: not-allowed; }
.checklist { display: grid; gap: 6px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .checklist { grid-template-columns: repeat(2, 1fr); } }
.checkitem { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border: 1px solid #e0cfa8; border-radius: 8px; background: #fffdf7; font-family: var(--font-ui); font-size: .92rem; }
.checkitem.disabled { opacity: .5; }
.checkitem input { margin-top: 3px; width: 18px; height: 18px; flex: none; }
.checkitem .more { margin-left: auto; background: none; border: 0; color: var(--burgundy); cursor: pointer; font-size: .85rem; }
.counter { font: 700 .9rem var(--font-ui); padding: 4px 10px; border-radius: 999px; background: var(--parch-2); display: inline-block; }
.counter.ok { background: #d9eed5; color: var(--green); }
.counter.over { background: #f6d5d2; color: var(--red); }
.abilities-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .abilities-grid { grid-template-columns: repeat(3, 1fr); } }
.ability-box { border: 2px solid #d9c49a; border-radius: 12px; padding: 10px; text-align: center; background: #fffdf7; }
.ability-box .name { font: 700 .85rem var(--font-ui); text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); }
.ability-box .score { font-size: 1.8rem; font-weight: bold; }
.ability-box .mod { display: inline-block; min-width: 46px; border-radius: 999px; background: var(--burgundy); color: #fff; font: 700 .95rem var(--font-ui); padding: 2px 8px; }
.ability-box select, .ability-box input { margin-top: 6px; text-align: center; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 6px; }
.stepper button { width: 36px; height: 36px; border-radius: 50%; border: 1px solid #c9ad74; background: #fff; font-size: 1.2rem; cursor: pointer; }
.wiz-nav { display: flex; justify-content: space-between; gap: 8px; margin-top: 16px; }
.summary { position: sticky; top: 80px; font-size: .92rem; }
.summary dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 0; }
.summary dt { font-weight: bold; color: var(--ink-2); font-family: var(--font-ui); font-size: .85rem; }
.summary dd { margin: 0; }
.errlist { color: var(--red); font-family: var(--font-ui); font-size: .85rem; padding-left: 18px; }
.dice-rolls { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }

/* Mode jeu */
.play-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 8px; }
.play-name { margin-bottom: 0; }
.sim-banner { position: sticky; top: 58px; z-index: 40; background: repeating-linear-gradient(45deg, #2f4f6b, #2f4f6b 12px, #375b7a 12px, #375b7a 24px); color: #fff; padding: 10px 14px; border-radius: 8px; margin: 10px 0; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; box-shadow: var(--shadow); font-family: var(--font-ui); }
body.is-sim .play-main { outline: 3px dashed #375b7a; outline-offset: 6px; border-radius: 8px; }
.play-layout { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1000px) { .play-layout { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; } }
.play-main { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.vitals { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .vitals { grid-template-columns: repeat(4, 1fr); } }
.vital { text-align: center; padding: 10px; }
.vital .big { font-size: 1.7rem; font-weight: bold; }
.vital .lbl { font: 700 .75rem var(--font-ui); text-transform: uppercase; color: var(--muted); letter-spacing: .05em; }
.hpbar { height: 12px; border-radius: 999px; background: #e8d9b8; overflow: hidden; margin: 6px 0; }
.hpbar span { display: block; height: 100%; background: linear-gradient(90deg, #3f8a4c, #6fbf6a); transition: width .4s; }
.hpbar.low span { background: linear-gradient(90deg, #a32020, #d65b3a); }
.hp-controls { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; }
.hp-controls input { width: 80px; text-align: center; }
.hp-crit { flex: 1 1 100%; margin-top: 4px; }
.hp-crit .help { margin: 2px 0 0 1.6rem; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.rollmode { display: inline-flex; border: 1px solid #c9ad74; border-radius: 999px; overflow: hidden; flex-wrap: wrap; }
.rollmode button { border: 0; background: #fffdf7; padding: 6px 12px; font: 600 .82rem var(--font-ui); cursor: pointer; color: var(--ink); }
.rollmode button[aria-pressed=true] { background: var(--burgundy); color: #fff; }
.dice-source { margin-top: 8px; }
.dice-source-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tag.physical { background: #3d5a3a; color: #f3f6e8; }
.rollbtns { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
@media (min-width: 640px) { .rollbtns { grid-template-columns: repeat(3, 1fr); } }
.rollbtn { display: flex; justify-content: space-between; align-items: center; gap: 6px; width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid #e0cfa8; background: #fffdf7; cursor: pointer; font: .9rem var(--font-ui); color: var(--ink); text-align: left; }
.rollbtn:hover { border-color: var(--gold); background: #fff7e3; }
.rollbtn .val { font-weight: 700; min-width: 38px; text-align: center; border-radius: 6px; padding: 2px 6px; background: var(--parch-2); }
.rollbtn.prof .val { background: var(--burgundy); color: #fff; }
.rollbtn.exp .val { background: linear-gradient(var(--gold-2), var(--gold)); color: #2b1d14; }
.attack-row, .spell-row, .res-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px dashed #e0cfa8; }
.attack-row:last-child, .spell-row:last-child, .res-row:last-child { border-bottom: 0; }
.attack-row .name, .spell-row .name, .res-row .name { flex: 1 1 160px; font-weight: bold; }
.attack-row small, .spell-row small, .res-row small { display: block; font-weight: normal; color: var(--muted); font-family: var(--font-ui); font-size: .8rem; }
.pips { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.pip { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--gold); background: var(--gold-2); display: inline-block; cursor: pointer; padding: 0; }
.pip.used { background: #ddd2bc; border-color: #b9ab8c; }
.locked { opacity: .45; filter: grayscale(.8); }
.locked .btn { pointer-events: none; }
.lock-note { font: .78rem var(--font-ui); color: var(--red); }
.cond-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.cond { border: 1px solid #c9ad74; border-radius: 999px; padding: 4px 10px; background: #fffdf7; font: .82rem var(--font-ui); cursor: pointer; color: var(--ink); }
.cond[aria-pressed=true] { background: #5a1520; color: #fff; border-color: #5a1520; }
.mod-list { list-style: none; padding: 0; margin: 6px 0; display: grid; gap: 6px; }
.mod-list li { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 6px 10px; border-radius: 8px; background: #f6edd6; font: .85rem var(--font-ui); }
.mod-list li.gm { background: #e3ecf6; }
.tag { font: 700 .7rem var(--font-ui); text-transform: uppercase; padding: 1px 6px; border-radius: 4px; background: var(--parch-2); color: var(--ink-2); }
.tag.gm { background: var(--blue); color: #fff; }
.tag.off { background: #6b3a8a; color: #fff; }
.death { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; font-family: var(--font-ui); }
.death .pips .pip { cursor: default; }
.pip.ok { background: var(--green); border-color: var(--green); }
.pip.ko { background: var(--red); border-color: var(--red); }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 2px solid #d9c49a; margin-bottom: 10px; }
.tabs button { border: 0; background: none; padding: 8px 12px; font: 700 .9rem var(--font-ui); color: var(--ink-2); cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button[aria-selected=true] { color: var(--burgundy); border-color: var(--burgundy); }
.feature-list details { border-bottom: 1px dashed #e0cfa8; padding: 6px 0; }
.feature-list summary { cursor: pointer; font-weight: bold; }
.feature-list summary small { color: var(--muted); font-weight: normal; font-family: var(--font-ui); }
.desc p { margin: 6px 0; }
.inspiration { display: inline-flex; align-items: center; gap: 6px; }
.inspiration .star { font-size: 1.6rem; color: #c9b88f; }
.inspiration.on .star { color: var(--gold-2); text-shadow: 0 0 8px rgba(212,166,74,.8); }
.freeroll { display: flex; gap: 6px; flex-wrap: wrap; }
.freeroll input { flex: 1 1 120px; }
.quick-dice { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* Historique */
.history { background: var(--paper); border: 1px solid #d9c49a; border-radius: var(--radius); box-shadow: var(--shadow); }
.history-toggle { width: 100%; text-align: left; border: 0; background: none; padding: 12px 14px; font: 700 1rem var(--font); color: var(--burgundy); cursor: pointer; }
.history-body { display: none; padding: 0 12px 12px; }
.history.open .history-body { display: block; }
@media (min-width: 1000px) {
	.history { position: sticky; top: 80px; max-height: calc(100vh - 100px); display: flex; flex-direction: column; }
	.history-toggle { pointer-events: none; }
	.history-body { display: flex; flex-direction: column; min-height: 0; flex: 1; }
	.history-list { overflow-y: auto; flex: 1; }
}
.history-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.history-list { list-style: none; margin: 0; padding: 0; font: .82rem var(--font-ui); }
.history-list li { padding: 6px 8px; border-left: 3px solid var(--gold); margin: 4px 0; background: #fffdf7; border-radius: 0 6px 6px 0; cursor: pointer; }
.history-list li:hover { background: #fff3d9; }
.history-list li.head { border-left-color: var(--burgundy); background: #fbeff0; font-weight: 600; }
.history-list li.future { opacity: .45; text-decoration: line-through; }
.history-list li.sim { border-left-color: #375b7a; background: #e8eff6; }
.history-list li.gm { border-left-color: var(--blue); }
.history-list li.barrier { cursor: default; }
.history-list time { color: var(--muted); font-size: .75rem; margin-right: 4px; }

/* Dés 3D et résultats */
.dice-stage { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; background: rgba(30, 18, 10, .55); padding: 16px; }
.roll-card { background: var(--paper); border: 3px solid var(--gold); border-radius: 14px; max-width: 460px; width: 100%; padding: 18px; box-shadow: 0 10px 40px rgba(0,0,0,.4); max-height: 90vh; overflow-y: auto; animation: pop .25s ease-out; }
.roll-card h3 { margin-top: 0; }
.roll-card .total { font-size: 2.6rem; font-weight: bold; text-align: center; color: var(--burgundy); }
.roll-card .total.crit { color: var(--gold); text-shadow: 0 0 10px rgba(212,166,74,.6); }
.roll-card .total.fumble { color: var(--muted); }
.roll-card .parts { list-style: none; padding: 0; margin: 8px 0; font: .88rem var(--font-ui); }
.roll-card .parts li { display: flex; justify-content: space-between; border-bottom: 1px dotted #e0cfa8; padding: 3px 0; }
.roll-card .parts li.gm { color: var(--blue); }
.roll-card .notes { font: .85rem var(--font-ui); color: var(--ink-2); padding-left: 18px; }
.roll-card .dmg { margin-top: 12px; padding-top: 10px; border-top: 2px solid #e0cfa8; }
.roll-card .actions { justify-content: center; margin-top: 12px; }
.dice-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; perspective: 700px; margin: 10px 0; min-height: 64px; }
.die3d { --size: 56px; width: var(--size); height: var(--size); position: relative; display: flex; align-items: center; justify-content: center; font: 700 1.3rem var(--font-ui); color: #fff7e6; transform-style: preserve-3d; }
.die3d::before { content: ""; position: absolute; inset: 0; background: linear-gradient(135deg, var(--burgundy-2), #4e1018); border: 2px solid var(--gold-2); border-radius: 10px; box-shadow: inset 0 -4px 8px rgba(0,0,0,.35), 0 4px 10px rgba(0,0,0,.3); transform: translateZ(0); }
.die3d.d20::before, .die3d.d12::before, .die3d.d10::before, .die3d.d8::before, .die3d.d4::before { border-radius: 4px; clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }
.die3d.d4::before { clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.die3d.d8::before { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.die3d span { position: relative; z-index: 1; transform: translateZ(2px); }
.die3d.small { --size: 40px; font-size: 1rem; }
.die3d.rolling { animation: tumble .9s cubic-bezier(.2,.7,.3,1) both; }
.die3d.dropped { animation: tumble .9s cubic-bezier(.2,.7,.3,1) both, fade 0.5s 1s forwards; }
.die3d.dropped::after { content: ""; position: absolute; left: 6px; right: 6px; top: 50%; height: 3px; background: #2b1d14; transform: rotate(-20deg); z-index: 2; opacity: 0; animation: strike .3s 1.1s forwards; }
.die3d.kept.crit::before { background: linear-gradient(135deg, var(--gold-2), #8a6420); }
.die3d.kept.fumble::before { background: linear-gradient(135deg, #6f6658, #3c362e); }
.die3d.gm::before { background: linear-gradient(135deg, #2f6b9a, #173a5a); }
.die3d.alt { opacity: .4; }
.dice-row.physical .die3d.rolling { animation: pop .28s ease-out; }
.dice-row.physical .die3d.dropped { animation: fade 0.35s forwards; }
.dice-row.physical .die3d.dropped::after { animation: strike .2s .08s forwards; }
.roll-card.physical { border-color: #3d5a3a; }
.die-entry-form { display: grid; gap: 10px; }
.die-entry { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; padding: 8px 10px; background: #fffdf7; border: 1px solid #e0cfa8; border-radius: 8px; }
.die-entry-face { font: 700 .85rem var(--font-ui); background: var(--burgundy); color: #fff7e6; border-radius: 6px; min-width: 42px; text-align: center; padding: 6px 8px; }
.die-entry-label { font: .85rem var(--font-ui); color: var(--ink-2); }
.die-entry input { width: 72px; min-height: 44px; text-align: center; font: 700 1.2rem var(--font-ui); }
@media (max-width: 520px) {
	.die-entry { grid-template-columns: auto 1fr; }
	.die-entry input { width: 100%; grid-column: 1 / -1; }
}
.spin-slow { animation: spin 12s linear infinite; --size: 72px; font-size: 1.6rem; }
@keyframes tumble {
	0% { transform: translate3d(0, -120px, 0) rotateX(540deg) rotateY(320deg) scale(.6); opacity: 0; }
	60% { transform: translate3d(0, 10px, 0) rotateX(-20deg) rotateY(15deg) scale(1.05); opacity: 1; }
	100% { transform: translate3d(0, 0, 0) rotateX(0) rotateY(0) scale(1); }
}
@keyframes fade { to { opacity: .35; filter: grayscale(1); transform: scale(.85); } }
@keyframes strike { to { opacity: 1; } }
@keyframes spin { from { transform: rotateY(0) rotateX(10deg); } to { transform: rotateY(360deg) rotateX(10deg); } }
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Vue MJ */
.gm-layout { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1000px) { .gm-layout { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; } }
.gm-chars { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .gm-chars { grid-template-columns: repeat(2, 1fr); } }
.gm-char h3 { margin: 0; }
.gm-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.gm-code { font-family: var(--font-ui); }
.code { font: 700 1.2rem ui-monospace, monospace; letter-spacing: .2em; background: #2b1d14; color: var(--gold-2); border: 0; border-radius: 6px; padding: 6px 12px; cursor: pointer; }
.roll-list { list-style: none; padding: 0; margin: 0; font: .85rem var(--font-ui); }
.roll-list li { padding: 6px 8px; border-bottom: 1px dotted #e0cfa8; }
.roll-list li.hidden-roll { background: #eee6f4; }
.danger-zone { margin-top: 16px; }
.danger-zone summary { cursor: pointer; font-weight: bold; }
.recent { font: .78rem var(--font-ui); color: var(--ink-2); padding-left: 16px; margin: 6px 0 0; }

/* Fenêtre modale */
.modal { position: fixed; inset: 0; background: rgba(30,18,10,.55); z-index: 90; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-card { background: var(--paper); border: 3px solid var(--gold); border-radius: 14px; max-width: 560px; width: 100%; padding: 18px; max-height: 90vh; overflow-y: auto; animation: pop .2s ease-out; }
.modal-card h3 { margin-top: 0; }

.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%) translateY(100px); background: #2b1d14; color: #f6e7c1; padding: 10px 16px; border-radius: 8px; font: .9rem var(--font-ui); transition: transform .25s; z-index: 95; max-width: 92vw; }
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--red); color: #fff; }

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
	.spin-slow { animation: none; }
}
@media print {
	.topbar, .footer, .history, .sim-banner, .btn { display: none !important; }
	body { background: #fff; }
}
.toast:empty { display: none; }
.toast:not(.show) { visibility: hidden; }

/* ------------------------------------------------------------ inventaire et bourse */
.inline-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0; }
.inline-form input[type=number] { width: 96px; flex: none; }
.inline-form select { width: auto; flex: none; }
.form-row { display: grid; gap: 0 10px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .form-row { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.inline { display: flex; gap: 6px; }
.inline input { min-width: 0; }
.inline select { width: auto; }
.inv-purse, .inv { margin-bottom: 18px; }
.purse-total { font-size: 1.2rem; color: var(--gold); }
.coins { display: grid; gap: 6px; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.coin { display: flex; flex-direction: column; align-items: center; padding: 6px 2px; border: 1px solid #e0cfa8; border-radius: 8px; background: #fffdf7; font-family: var(--font-ui); min-width: 0; }
.coin-face { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font: 700 .72rem var(--font-ui); color: #fff; box-shadow: inset 0 -2px 0 rgba(0,0,0,.2); }
.coin-pp .coin-face { background: #8a9aa6; }
.coin-po .coin-face { background: var(--gold); }
.coin-pe .coin-face { background: #9b8f4a; }
.coin-pa .coin-face { background: #a7a7a7; }
.coin-pc .coin-face { background: #a8603a; }
.coin-name { font-size: .7rem; color: var(--muted); }
.coin-n { font-size: 1.05rem; }
.coin .stepper { gap: 3px; margin-top: 2px; }
.coin .stepper button, .inv-line .stepper button { width: 32px; height: 32px; min-height: 32px; padding: 0; border-radius: 50%; }
.inv-sum { font: .85rem var(--font-ui); color: var(--ink-2); }
.inv-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.inv-line { border: 1px solid #e0cfa8; border-radius: 8px; background: #fffdf7; padding: 8px 10px; font-family: var(--font-ui); }
.inv-line.equipped { border-color: var(--gold); box-shadow: inset 3px 0 0 var(--gold); }
.inv-line.empty { opacity: .6; }
.inv-head { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.inv-name { font-weight: 600; overflow-wrap: anywhere; }
.btn.equip.on { background: var(--gold); color: #fff; border-color: var(--gold); }
.inv-body { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; margin-top: 4px; font-size: .88rem; color: var(--ink-2); }
.inv-body .stepper { margin: 0; }
.inv-body .qty { min-width: 2.2em; text-align: center; color: var(--ink); font-size: 1rem; }
.inv-act { margin-left: auto; display: flex; gap: 2px; }
.inv-note { font-size: .85rem; color: var(--muted); margin-top: 2px; font-style: italic; }
@media (max-width: 420px) { .coin-name { display: none; } }

/* Page d’erreur d’installation de la base (migrate). */
.db-setup { max-width: 40rem; margin: 2rem auto; }

/* Éléments personnalisés */
.custom-form { margin-top: 1rem; }
.custom-form .field { margin: 0.6rem 0; }
.custom-form textarea, .custom-form input[type=text], .custom-form input[type=number], .custom-form select { width: 100%; max-width: 32rem; }
.custom-form .checklist { display: flex; flex-wrap: wrap; gap: 0.35rem 0.8rem; }
.custom-uncertain ul { margin: 0.4rem 0 0; padding-left: 1.2rem; }
.btn.custom-pick { margin: 0.6rem 0 1rem; }
.tag.uncertain { background: #c9a227; color: #1a1208; }

/* Import : champs à confirmer et ancrages */
.import-notices { margin: 0 0 1rem; }
.import-notices .alert { margin-bottom: 0.75rem; }
.import-notices .alert a { font-weight: 600; }
.custom-confirm-block { margin: 0.85rem 0 0.4rem; padding: 0.7rem 0.8rem; }
.custom-confirm-block p { margin: 0.3rem 0 0.5rem; }
.needs-confirm { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 8px; background: #fff8e6; padding: 0.55rem 0.7rem; }
.custom-highlight { outline: 3px solid var(--burgundy); outline-offset: 3px; background: #f8e9e4; }
.btn-confirm { margin-top: 0.45rem; }
.custom-field .btn-confirm { display: inline-flex; }
#cb-name, #cb-desc, #cb-skills, #cb-tool, #cb-abilities, #cb-feat, #bg-bonus, #masteries { scroll-margin-top: 5rem; }
.custom-form, .custom-confirm-block, .custom-field { scroll-margin-top: 5rem; }
