:root {
  --bg: #0d0b10; --panel: rgba(22, 18, 28, .92); --line: #3a3045; --text: #ece4d8;
  --muted: #9c8fa8; --gold: #e8b04a; --whisper: #b48cff; --danger: #e05555;
  font-family: Georgia, 'Times New Roman', serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
button, input, select, textarea { font: inherit; font-family: var(--serif); font-size: 14px; }
button {
  background: #2b2234; color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 12px; cursor: pointer; transition: .15s;
}
button:hover { border-color: var(--gold); }
button.on { background: var(--gold); color: #1a1208; border-color: var(--gold); }
button.small, .small { font-size: 12px; }
button.danger { border-color: var(--danger); color: #ffb3b3; }
input, select, textarea {
  width: 100%; background: #17131c; color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 9px; margin: 3px 0;
}
input[type=checkbox] { width: auto; margin: 0 4px 0 0; vertical-align: middle; }
label.small { color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
label.small input[type=number] { margin: 0; padding: 4px 6px; }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 4px 0; }
.row input { flex: 1; }

/* Accueil */
#lobby {
  height: 100%; display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 30%, #2a1d36 0%, #0d0b10 70%);
}
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 32px 36px; width: min(640px, 92vw); }
.card h1 { margin: 0; font-size: 40px; color: var(--gold); letter-spacing: 1px; }
.sub { color: var(--muted); margin-top: 4px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-top: 20px; }
.cols h2 { font-size: 18px; margin: 0 0 8px; }
.cols button { width: 100%; margin-top: 6px; }
.err { color: var(--danger); min-height: 1em; }
@media (max-width: 600px) { .cols { grid-template-columns: 1fr; } }

/* Jeu */
#game { position: fixed; inset: 0; }
#view { position: absolute; inset: 0 330px 0 0; }
#view canvas { display: block; }
#topbar {
  position: absolute; top: 12px; left: 12px; display: flex; gap: 8px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px;
}
#roomTitle { font-weight: bold; color: var(--gold); }
.pill { font-family: monospace; background: #17131c; border-radius: 6px; padding: 2px 8px; letter-spacing: 2px; }

#side {
  position: absolute; top: 0; right: 0; bottom: 0; width: 330px; background: var(--panel);
  border-left: 1px solid var(--line); display: flex; flex-direction: column; overflow-y: auto; padding: 8px 12px;
}
.block { padding: 8px 0; border-bottom: 1px solid var(--line); }
.block.grow { flex: 1; min-height: 160px; border-bottom: none; display: flex; flex-direction: column; }
.block h3 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 2px; color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; margin: 4px 0; font-family: var(--serif); }
.modes { display: flex; gap: 6px; }
.modes button { flex: 1; }
.dice { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.dice button { padding: 7px 0; }
.dice .d20 { border-color: var(--gold); }
#tokenPanel { background: #17131c; border-radius: 8px; padding: 8px; margin: 6px 0; }

#players { list-style: none; padding: 0; margin: 0; font-family: var(--serif); font-size: 14px; }
#players li { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.off { opacity: .4; }
.lastReact { margin-left: auto; font-size: 18px; }
#players li.talk .dot { box-shadow: 0 0 0 3px #6bff8c88, 0 0 12px #6bff8c; }
#players li .apart { margin-left: 6px; padding: 2px 8px; font-size: 11px; }
#players li .apart.on { background: var(--whisper); border-color: var(--whisper); color: #120a1f; }
.priv { background: #2a1d42; border: 1px solid var(--whisper); color: #e2d4ff; border-radius: 8px; padding: 6px 10px; font-family: var(--serif); font-size: 13px; margin: 6px 0 0; }
#btnVoice.on { background: #2f5a3a; border-color: #6bff8c; color: #e8ffe8; }

#log { list-style: none; padding: 0; margin: 0; overflow-y: auto; flex: 1; font-family: var(--serif); font-size: 13px; }
#log li { padding: 5px 0; border-bottom: 1px dashed #2b2234; }
#log .w { color: var(--whisper); }
#log .n { color: var(--gold); font-style: italic; font-family: Georgia, serif; }
#log .s { color: var(--muted); }
#log .tot { font-weight: bold; font-size: 15px; color: #fff; }
#log .crit { color: #6bff8c; }
#log .fail { color: #ff7070; }

/* Narration plein écran */
#narration {
  position: absolute; left: 0; right: 330px; top: 18%; text-align: center; pointer-events: none;
  font-size: clamp(22px, 3vw, 38px); color: #fff4dc; padding: 0 10%;
  text-shadow: 0 0 20px #000, 0 2px 4px #000; opacity: 0; transition: opacity 1.2s; font-style: italic;
}
#narration.show { opacity: 1; }

/* Toasts (chuchotements, dés) */
#toasts { position: absolute; left: 50%; bottom: 80px; transform: translateX(calc(-50% - 165px)); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: rgba(20, 14, 30, .96); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px;
  font-family: var(--serif); max-width: 460px; animation: pop .3s ease-out; box-shadow: 0 6px 30px #0008;
}
.toast.w { border-color: var(--whisper); box-shadow: 0 0 24px #b48cff55; }
.toast.w b { color: var(--whisper); }
@keyframes pop { from { transform: translateY(12px); opacity: 0; } }

#reactions {
  position: absolute; left: 12px; bottom: 12px; display: flex; gap: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px;
}
#reactions button { font-size: 20px; padding: 4px 8px; background: transparent; border-color: transparent; }
#reactions button:hover { border-color: var(--gold); }

@media (max-width: 800px) {
  #view { inset: 0 0 45% 0; } #side { top: 55%; width: 100%; } #narration { right: 0; }
  #toasts { transform: translateX(-50%); bottom: 47%; }
}

[hidden] { display: none !important; }

/* Onglets */
#side { padding: 0; }
#tabs { display: flex; position: sticky; top: 0; z-index: 2; background: #1a1520; border-bottom: 1px solid var(--line); }
#tabs button { flex: 1; border: none; border-radius: 0; background: transparent; padding: 10px 0; color: var(--muted); border-bottom: 2px solid transparent; }
#tabs button.on { color: var(--gold); border-bottom-color: var(--gold); background: transparent; }
.pane { padding: 4px 12px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
#journal { flex: 0 0 26%; min-height: 120px; padding: 6px 12px; border-top: 1px solid var(--line); }
#advBar { display: flex; gap: 4px; align-items: center; padding: 6px 12px; border-top: 1px solid var(--line); color: var(--muted); }
#advBar button { padding: 4px 8px; }
#side { overflow: hidden; }

/* Fiche */
.sheetEdit label, .sheetEdit h5 { display: block; font-family: var(--serif); font-size: 13px; color: var(--muted); }
.sheetEdit h4 { margin: 8px 0; color: var(--gold); }
.sheetEdit h5 { margin: 12px 0 4px; color: var(--text); font-size: 14px; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.note { font-family: var(--serif); font-size: 12px; color: var(--muted); margin: 4px 0; line-height: 1.35; }
.ok { color: #6bff8c; } .warn { color: #e0a53a; }
.abil { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-family: var(--serif); font-size: 13px; }
.abil > div { background: #17131c; border-radius: 8px; padding: 6px; display: grid; grid-template-columns: 34px 54px 1fr; align-items: center; gap: 4px; }
.abil input { margin: 0; padding: 4px; }
.skillPick { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; font-family: var(--serif); font-size: 13px; }
.skillPick label { color: var(--text) !important; display: flex !important; align-items: center; gap: 4px; }
.skillPick i, .skillList i { color: var(--muted); font-size: 11px; font-style: normal; }
.skillPick .dim { opacity: .45; }
.sheetView { font-family: var(--serif); font-size: 13px; }
.sheetView .head { display: flex; justify-content: space-between; align-items: center; margin: 8px 0; }
.sheetView .nm { font-family: Georgia, serif; font-size: 20px; color: var(--gold); }
.hp .bar { position: relative; height: 22px; background: #17131c; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.hp .bar div { height: 100%; transition: width .4s; }
.hp .bar span { position: absolute; inset: 0; display: grid; place-items: center; font-weight: bold; text-shadow: 0 1px 2px #000; }
.hp input { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 8px 0; }
.stats > div, .abilView > div { background: #17131c; border-radius: 8px; padding: 5px 2px; text-align: center; display: flex; flex-direction: column; }
.stats i, .abilView i { font-style: normal; font-size: 10px; color: var(--muted); text-transform: uppercase; }
.stats b { font-size: 16px; }
.abilView { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.abilView b { font-size: 20px; }
.abilView span { font-size: 11px; color: var(--muted); }
.abilView .save { margin-top: 4px; padding: 2px; font-size: 11px; background: #221b2a; }
.abilView .save.p { border-color: var(--gold); }
.rollable { cursor: pointer; transition: .15s; border: 1px solid transparent; }
.rollable:hover { border-color: var(--gold); background: #231c2c !important; }
.skillList { list-style: none; padding: 0; margin: 8px 0; }
.skillList li { display: flex; gap: 6px; align-items: center; padding: 4px 6px; border-radius: 6px; color: var(--muted); }
.skillList li.p { color: var(--text); }
.skillList li span { width: 12px; color: var(--gold); }
.skillList li b { margin-left: auto; color: var(--text); }

/* Combat */
#initStrip {
  position: absolute; top: 64px; left: 12px; right: 342px; display: flex; gap: 6px; overflow-x: auto; pointer-events: none;
}
#initStrip .ini { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 4px 10px; font-family: var(--serif); font-size: 12px; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
#initStrip .ini.cur { border-color: var(--gold); box-shadow: 0 0 14px #e8b04a66; color: var(--gold); font-weight: bold; }
#initStrip .round { color: var(--muted); }
.combatList { list-style: none; padding: 0; margin: 6px 0; font-family: var(--serif); font-size: 13px; }
.combatList li { display: flex; align-items: center; gap: 6px; padding: 6px; border-radius: 8px; margin-bottom: 4px; background: #17131c; border: 1px solid transparent; flex-wrap: wrap; }
.combatList li.cur { border-color: var(--gold); }
.combatList .ini { font-weight: bold; width: 26px; text-align: center; color: var(--gold); }
.combatList .nm { flex: 1; }
.combatList .w { font-size: 11px; color: var(--muted); }
.combatList input { width: 52px; margin: 0; padding: 3px 5px; }
.mini { height: 5px; width: 100%; background: #2b2234; border-radius: 3px; overflow: hidden; }
.mini div { height: 100%; }
#notes { height: calc(100% - 60px); min-height: 300px; font-family: ui-monospace, monospace; font-size: 13px; line-height: 1.5; resize: none; }
#pane-carnet { display: flex; flex-direction: column; }
#pane-carnet[hidden] { display: none; }
.fileBtn { background: #2b2234; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; cursor: pointer; font-family: var(--serif); font-size: 13px; white-space: nowrap; }
.fileBtn:hover { border-color: var(--gold); }
#imgOverlay { position: absolute; inset: 0 330px 0 0; background: rgba(5,4,8,.85); display: grid; place-items: center; z-index: 5; cursor: pointer; animation: pop .4s; }
#imgOverlay figure { margin: 0; text-align: center; }
#imgOverlay img { max-width: 80%; max-height: 72vh; border-radius: 10px; box-shadow: 0 10px 60px #000; border: 2px solid #3a3045; }
#imgOverlay p { font-style: italic; font-size: 22px; color: #fff4dc; }
#imgOverlay > span { position: absolute; bottom: 16px; color: var(--muted); font-family: var(--serif); font-size: 12px; }
@media (max-width: 800px) { #imgOverlay { inset: 0; } }
details.traits { background: #17131c; border-radius: 8px; padding: 6px 10px; margin: 6px 0; font-family: var(--serif); font-size: 13px; }
details.traits summary { cursor: pointer; color: var(--text); }
details.traits .src { opacity: .6; }
label.inline { display: flex !important; align-items: center; gap: 6px; }

/* Livre */
#book { position: fixed; inset: 0; background: rgba(5,4,8,.8); z-index: 20; display: grid; place-items: center; }
#book[hidden] { display: none; }
.bookPanel { position: relative; width: min(1100px, 94vw); height: min(780px, 90vh); display: grid; grid-template-columns: 220px 1fr;
  background: #f3e9d2; color: #2b2016; border-radius: 14px; overflow: hidden; box-shadow: 0 20px 80px #000; border: 3px solid #6b4f2a; }
.bookNav { background: #2a2018; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.bookNav h4 { color: #e8b04a; margin: 12px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: 2px; }
.bookNav button { text-align: left; background: transparent; border: none; color: #e9dcc4; padding: 5px 8px; border-radius: 6px; font-family: Georgia, serif; font-size: 15px; }
.bookNav button.on, .bookNav button:hover { background: #4a3826; color: #fff; }
.bookPage { overflow-y: auto; padding: 30px 46px; font-family: Georgia, serif; font-size: 16px; line-height: 1.55; }
.bookPage h1 { font-size: 36px; color: #7a1f12; margin: 0 0 6px; font-variant: small-caps; border-bottom: 2px solid #c9a96a; }
.bookPage h2 { color: #7a1f12; font-variant: small-caps; margin-top: 22px; border-bottom: 1px solid #c9a96a; font-size: 22px; }
.bookPage h3 { margin: 4px 0; color: #4a2a14; }
.bookPage .lead { font-style: italic; font-size: 17px; }
.bookPage .muted { color: #6b5a44; font-size: 14px; font-style: italic; }
.bookPage .facts { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; font-family: var(--serif); font-size: 13px; }
.bookPage .facts span { background: #e6d6b4; border-radius: 6px; padding: 4px 10px; }
.bookPage .facts .src { background: #2a2018; color: #e8b04a; }
.bookPage .lineage { background: #ebdfc4; border-left: 4px solid #7a1f12; padding: 6px 14px; margin: 10px 0; border-radius: 0 8px 8px 0; }
.bookPage .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.bookPage .chips span { background: #2a2018; color: #f3e9d2; border-radius: 20px; padding: 3px 12px; font-family: var(--serif); font-size: 13px; }
.bookClose { position: absolute; top: 10px; right: 12px; background: #2a2018; color: #fff; border: none; }
@media (max-width: 700px) { .bookPanel { grid-template-columns: 1fr; grid-template-rows: 140px 1fr; } .bookPage { padding: 16px; } }
.presetGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.layerRow { display: grid; grid-template-columns: 150px 1fr; gap: 8px; align-items: center; margin: 3px 0; }
.layerRow .tog { text-align: left; }
.layerRow input, #clipNow input { accent-color: var(--gold); }
#sndList { list-style: none; padding: 0; margin: 6px 0; font-family: var(--serif); font-size: 13px; }
#sndList li { display: flex; gap: 4px; align-items: center; padding: 3px 0; }
#sndList li span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#sndList li.playing span { color: var(--gold); font-weight: bold; }
label.vol input { width: 70px; accent-color: var(--gold); margin: 0; }
.soundOff { border-color: var(--gold); animation: pulse 1.5s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 12px #e8b04a; } }

/* ===================== Thème dark fantasy ===================== */
:root {
  --bg: #08060a; --panel: rgba(18, 13, 16, .95); --line: #3b2a22; --text: #e8dcc6; --muted: #9b8b78;
  --gold: #c9a25c; --gold-hi: #f0cf8a; --blood: #8e1b1b; --blood-hi: #c0392b; --whisper: #a98be0;
  --display: 'Cinzel', 'Trajan Pro', Georgia, serif; --serif: 'EB Garamond', Georgia, serif;
  font-family: var(--serif);
}
body { background: var(--bg); }
button, input, select, textarea { font-family: var(--serif); font-size: 15px; }
button {
  font-family: var(--display); font-weight: 600; letter-spacing: .04em; font-size: 12.5px;
  background: linear-gradient(180deg, #2a1d1c, #1a1213); border: 1px solid #4b3527; color: var(--text);
  box-shadow: inset 0 1px 0 rgba(240, 207, 138, .08), 0 1px 2px #0008;
}
button:hover { border-color: var(--gold); color: var(--gold-hi); box-shadow: inset 0 1px 0 rgba(240,207,138,.15), 0 0 10px rgba(201,162,92,.25); }
button.on { background: linear-gradient(180deg, #a27a3a, #6f4e22); color: #170f08; border-color: var(--gold-hi); text-shadow: 0 1px 0 rgba(255,230,180,.4); }
button.danger { border-color: var(--blood); color: #f2b0a8; background: linear-gradient(180deg, #3a1414, #1e0b0b); }
input, select, textarea { background: #0f0b0d; border: 1px solid #3a2a22; color: var(--text); box-shadow: inset 0 1px 3px #000a; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); }
input::placeholder, textarea::placeholder { color: #6c5f52; font-style: italic; }

/* Panneaux : cuir sombre et liseré doré */
#side, #topbar, #reactions, .toast {
  background: linear-gradient(180deg, rgba(26,18,20,.97), rgba(13,9,11,.97));
  border-color: #4b3527;
  box-shadow: inset 0 0 0 1px rgba(201,162,92,.12), 0 8px 30px #000c;
}
#side { border-left: 2px solid #3b2a22; }
#side::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 1px; background: linear-gradient(180deg, transparent, var(--gold), transparent); opacity: .5; }
.block h3, #journal h3 { font-family: var(--display); color: var(--gold); letter-spacing: .18em; font-size: 12px; display: flex; align-items: center; gap: 8px; }
.block h3::after, #journal h3::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, #5a4128, transparent); }
.block { border-bottom: none; }
#tabs { background: linear-gradient(180deg, #1d1416, #120c0e); border-bottom: 1px solid #4b3527; }
#tabs button { font-family: var(--display); font-size: 12px; box-shadow: none; background: transparent; letter-spacing: .08em; }
#tabs button.on { color: var(--gold-hi); border-bottom-color: var(--gold); background: radial-gradient(ellipse at 50% 120%, rgba(201,162,92,.18), transparent 70%); }
#roomTitle { font-family: var(--display); font-weight: 800; color: var(--gold-hi); letter-spacing: .06em; text-shadow: 0 0 12px rgba(201,162,92,.35); }
.pill { background: #0f0b0d; color: var(--gold); border: 1px solid #3a2a22; }
#players, #log, .note, .hint, .combatList, #sndList, .sheetView, .skillPick, .abil { font-family: var(--serif); }
#players { font-size: 16px; }
#log { font-size: 15px; }
#log .n { color: var(--gold-hi); }
#log .tot { font-family: var(--display); }
.hint { font-size: 13.5px; font-style: italic; }
.note { font-size: 13.5px; }
.priv { font-family: var(--serif); font-size: 15px; background: linear-gradient(180deg, #24183a, #160f24); }
.dice button { font-family: var(--display); font-size: 13px; }
.dice .d20 { border-color: var(--gold); color: var(--gold-hi); }
#advBar { border-top-color: #3b2a22; }

/* Fiche */
.sheetView .nm { font-family: var(--display); font-weight: 800; font-size: 22px; color: var(--gold-hi); letter-spacing: .04em; }
.stats > div, .abilView > div { background: linear-gradient(180deg, #1c1416, #110c0e); border: 1px solid #33251e; }
.stats b, .abilView b { font-family: var(--display); }
.abilView i, .stats i { font-family: var(--display); letter-spacing: .08em; }
.skillList li { font-size: 15px; }
.skillList li span { color: var(--gold); }
.hp .bar { border-color: #4b3527; background: #0d090b; }
.hp .bar span { font-family: var(--display); font-size: 13px; }
details.traits { background: #120d0f; border: 1px solid #2c201a; }
.sheetEdit h4 { font-family: var(--display); color: var(--gold-hi); }
.sheetEdit h5 { font-family: var(--display); font-size: 13px; letter-spacing: .05em; }
.sheetEdit label { font-size: 14px; }
.abil > div, #tokenPanel, .combatList li { background: #120d0f; border: 1px solid #2c201a; }
.combatList li.cur { border-color: var(--gold); box-shadow: 0 0 12px rgba(201,162,92,.25); }
.combatList .ini { font-family: var(--display); }
#initStrip .ini { font-family: var(--display); font-size: 12px; background: linear-gradient(180deg, rgba(26,18,20,.95), rgba(13,9,11,.95)); border-color: #4b3527; }
#initStrip .ini.cur { color: var(--gold-hi); border-color: var(--gold); }

/* Narration : grande lettre gravée */
#narration { font-family: var(--serif); font-size: clamp(24px, 3.2vw, 42px); color: #f6e7c8; letter-spacing: .01em;
  text-shadow: 0 0 30px #000, 0 0 12px #000, 0 2px 3px #000; }
#narration::first-letter { font-family: var(--display); font-size: 1.4em; color: var(--gold-hi); }
.toast { font-family: var(--serif); font-size: 16px; border: 1px solid #4b3527; }
.toast.w { border-color: var(--whisper); }
#imgOverlay p { font-family: var(--serif); }
#imgOverlay img { border: 3px solid #6b4f2a; box-shadow: 0 0 0 1px #000, 0 0 0 5px #2a1d14, 0 20px 80px #000; }

/* Accueil */
#lobby { position: relative; overflow: hidden;
  background: radial-gradient(ellipse at 50% 110%, rgba(150,60,20,.35), transparent 55%), radial-gradient(ellipse at 50% 30%, #1d1219 0%, #07050a 70%); }
#lobby .card { position: relative; z-index: 1; background: linear-gradient(180deg, rgba(24,16,18,.94), rgba(10,7,9,.96));
  border: 1px solid #5a4128; box-shadow: inset 0 0 0 4px #0c080a, inset 0 0 0 5px rgba(201,162,92,.35), 0 30px 90px #000; border-radius: 6px; text-align: center; }
#lobby .card h1 { font-family: var(--display); font-weight: 800; font-size: 54px; letter-spacing: .08em; color: var(--gold-hi);
  text-shadow: 0 0 24px rgba(240,160,60,.35), 0 2px 0 #3a2410; }
#lobby .sub { font-style: italic; font-size: 18px; }
#lobby .sigil { color: var(--blood-hi); font-size: 22px; text-shadow: 0 0 12px var(--blood-hi); }
#lobby .cols { text-align: left; }
#lobby .cols h2 { font-family: var(--display); color: var(--gold); font-size: 16px; letter-spacing: .1em; }
#lobby .cols > div + div { border-left: 1px solid #3b2a22; padding-left: 28px; }
.embers i { position: absolute; bottom: -10px; width: 4px; height: 4px; border-radius: 50%; background: #ffb347;
  box-shadow: 0 0 8px 2px #ff7a1a; opacity: 0; animation: rise 9s linear infinite; }
.embers i:nth-child(1) { left: 8%; animation-delay: 0s; } .embers i:nth-child(2) { left: 17%; animation-delay: 2.1s; animation-duration: 11s; }
.embers i:nth-child(3) { left: 26%; animation-delay: 4.5s; } .embers i:nth-child(4) { left: 34%; animation-delay: 1.2s; animation-duration: 12s; }
.embers i:nth-child(5) { left: 45%; animation-delay: 6s; } .embers i:nth-child(6) { left: 53%; animation-delay: 3.3s; animation-duration: 10s; }
.embers i:nth-child(7) { left: 61%; animation-delay: 7.4s; } .embers i:nth-child(8) { left: 70%; animation-delay: .6s; animation-duration: 13s; }
.embers i:nth-child(9) { left: 78%; animation-delay: 5.1s; } .embers i:nth-child(10) { left: 86%; animation-delay: 2.8s; animation-duration: 11s; }
.embers i:nth-child(11) { left: 92%; animation-delay: 8.2s; } .embers i:nth-child(12) { left: 40%; animation-delay: 9.5s; animation-duration: 14s; }
@keyframes rise { 0% { transform: translate(0, 0); opacity: 0; } 10% { opacity: .9; } 70% { opacity: .5; } 100% { transform: translate(40px, -100vh); opacity: 0; } }
@media (max-width: 600px) { #lobby .cols > div + div { border-left: none; padding-left: 0; } #lobby .card h1 { font-size: 38px; } }
/* Bestiaire */
.addInfo { font-size: 14px; color: var(--muted); margin: 4px 0; line-height: 1.35; }
.addInfo b { color: var(--gold); font-family: var(--display); font-size: 12px; }
.addInfo a { color: var(--gold-hi); }
#addKind { font-size: 14px; }
.statblock { font-family: var(--serif); font-size: 14px; line-height: 1.4; margin-top: 8px; }
.statblock p { margin: 4px 0; }
.statblock i { color: var(--gold); font-style: normal; font-family: var(--display); font-size: 11px; letter-spacing: .05em; margin-right: 3px; }
.statblock h5 { font-family: var(--display); color: var(--blood-hi); border-bottom: 1px solid #5a2a22; margin: 10px 0 4px; font-size: 13px; letter-spacing: .08em; }
.sb-head b { font-family: var(--display); font-size: 17px; color: var(--gold-hi); display: block; }
.sb-head span { font-style: italic; color: var(--muted); font-size: 13px; }
.sb-spec { font-style: italic; color: #d8c8a8; }
.sb-line { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 6px 0; }
.sb-abil { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; margin: 6px 0; text-align: center; }
.sb-abil > div { background: #120d0f; border: 1px solid #2c201a; border-radius: 6px; padding: 3px 0; display: flex; flex-direction: column; font-size: 12px; }
.sb-abil b { font-size: 14px; }
.sb-atk .atk { padding: 1px 6px; margin-right: 4px; }
.statblock .muted { color: var(--muted); font-size: 13px; }
.bookPage .statblock { color: #2b2016; font-size: 16px; }
.bookPage .statblock i { color: #7a1f12; }
.bookPage .statblock h5 { color: #7a1f12; border-color: #c9a96a; }
.bookPage .sb-head { display: none; }
.bookPage .sb-spec { display: none; }
.bookPage .sb-abil > div { background: #e6d6b4; border-color: #c9a96a; }
.bookPage .statblock .muted { color: #6b5a44; }
.monsterTop { display: grid; grid-template-columns: 240px 1fr; gap: 20px; align-items: center; }
.preview3d { width: 240px; height: 240px; border-radius: 50%; background: radial-gradient(circle at 50% 60%, #3a2a22, #120c0a 70%); overflow: hidden; border: 3px solid #6b4f2a; box-shadow: inset 0 0 30px #000; }
.bookNav small { opacity: .55; font-size: 11px; font-family: var(--serif); }
.modelBox { margin-top: 8px; padding-top: 6px; border-top: 1px solid #2c201a; }
.modelBox h5 { font-family: var(--display); color: var(--gold); margin: 0 0 4px; font-size: 12px; letter-spacing: .08em; }
.fileBtn.small { font-size: 12px; padding: 4px 8px; font-family: var(--display); }
/* Bibliothèque de figurines */
#minilib { position: fixed; inset: 0; background: rgba(5,4,8,.82); z-index: 21; display: grid; place-items: center; }
#minilib[hidden] { display: none; }
.libPanel { width: min(1100px, 94vw); height: min(800px, 90vh); display: flex; flex-direction: column; padding: 14px 18px;
  background: linear-gradient(180deg, #1c1416, #0e0a0c); border: 1px solid #5a4128; border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(201,162,92,.2), 0 20px 80px #000; }
.libHead { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.libHead h2 { font-family: var(--display); color: var(--gold-hi); margin: 0 10px 0 0; font-size: 20px; }
.libHead input#libSearch { flex: 1; min-width: 220px; }
#libGrid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; padding: 6px 2px; }
.libItem { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; height: 170px; font-family: var(--serif); font-size: 12.5px; letter-spacing: 0; font-weight: 400; text-transform: none; }
.libItem img, .libItem .noThumb { width: 116px; height: 116px; object-fit: contain; background: radial-gradient(circle, #3a2a22, #120c0a 75%); border-radius: 8px; display: grid; place-items: center; font-size: 40px; }
.libItem span { line-height: 1.15; text-align: center; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.libCredit { font-size: 12px; margin: 6px 0 0; }
/* Fiche : ressources, attaques, sorts, états */
.secH { font-family: var(--display); color: var(--gold); font-size: 13px; letter-spacing: .1em; margin: 14px 0 6px; border-bottom: 1px solid #3b2a22; padding-bottom: 3px; }
.atkList { list-style: none; padding: 0; margin: 4px 0; }
.atkList li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 4px 0; border-bottom: 1px dashed #2b2024; font-size: 14.5px; }
.atkList li span { color: var(--gold-hi); font-family: var(--display); font-size: 12.5px; }
.atkList li i { width: 100%; color: var(--muted); font-size: 12.5px; padding-left: 34px; }
.atkList .x { margin-left: auto; padding: 1px 6px; }
.slots { display: flex; flex-wrap: wrap; gap: 6px 12px; margin: 6px 0; }
.slots > div { display: flex; align-items: center; gap: 4px; }
.slots i { font-family: var(--display); font-size: 11px; color: var(--muted); font-style: normal; margin-right: 2px; }
.pip { width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--gold); background: radial-gradient(circle, #9a6cff, #4a2a9a); cursor: pointer; box-shadow: 0 0 6px #8a5cff88; }
.pip.used { background: #120d0f; box-shadow: none; opacity: .6; }
.insp { cursor: pointer; padding: 3px 8px; border-radius: 12px; border: 1px solid #3b2a22; color: var(--muted); font-size: 13px; }
.insp.on { color: #ffe08a; border-color: var(--gold); box-shadow: 0 0 10px #e8b04a66; }
.death { background: #2a0d0d; border: 1px solid var(--blood); border-radius: 8px; padding: 6px 10px; margin: 6px 0; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 14px; }
.death em { color: #ff7a6a; font-style: normal; }
.conds { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
.cond { font-size: 12.5px; padding: 2px 7px; border-radius: 10px; border: 1px solid #2c201a; background: #120d0f; color: var(--muted); cursor: pointer; user-select: none; }
.cond.on { border-color: var(--blood-hi); color: #ffd8d0; background: #3a1414; }
.conds label { width: 100%; margin-top: 4px; }
.coins label { gap: 3px; }
.moveInfo { font-size: 14px; background: #120d0f; border: 1px solid #2c201a; border-radius: 8px; padding: 6px 8px; }
.moveInfo b { color: var(--gold-hi); }
.combatList .half, .combatList .dbl { padding: 2px 6px; }
.priv a { color: var(--gold-hi); }
#toolbar { position: absolute; right: 342px; bottom: 12px; display: flex; gap: 4px; align-items: center; background: var(--panel); border: 1px solid #4b3527; border-radius: 10px; padding: 5px; }
#toolbar select { width: auto; margin: 0; padding: 3px 5px; font-size: 13px; }
#tplPanel { position: absolute; right: 342px; bottom: 62px; width: 300px; background: linear-gradient(180deg, rgba(26,18,20,.97), rgba(13,9,11,.97)); border: 1px solid #4b3527; border-radius: 10px; padding: 10px; z-index: 4; }
#tplPanel b { font-family: var(--display); color: var(--gold-hi); }
#tplList { list-style: none; padding: 0; margin: 6px 0; max-height: 120px; overflow-y: auto; font-size: 13.5px; }
#tplList li { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
#tplList li span:nth-child(2) { flex: 1; }
#measure { position: absolute; pointer-events: none; background: rgba(10,8,12,.9); border: 1px solid var(--gold); color: var(--gold-hi); font-family: var(--display); font-size: 12px; padding: 2px 8px; border-radius: 8px; z-index: 3; }
@media (max-width: 800px) { #toolbar, #tplPanel { right: 8px; bottom: 47%; } }
/* Dés 3D */
.diceLayer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: 0; transition: opacity .35s; z-index: 2; }
.diceLayer.on { opacity: 1; }
.diceTotal { position: absolute; left: 50%; bottom: 9%; transform: translate(-50%, 0) scale(.8); text-align: center; pointer-events: none; opacity: 0; transition: opacity .3s, transform .3s; z-index: 3; text-shadow: 0 0 20px #000, 0 2px 6px #000; }
.diceTotal.on { opacity: 1; transform: translate(-50%, 0) scale(1); }
.diceTotal small { display: block; font-family: var(--serif); font-style: italic; font-size: 18px; color: #e8dcc6; }
.diceTotal b { display: block; font-family: var(--display); font-weight: 800; font-size: 72px; color: #fff4dc; line-height: 1; }
.diceTotal em { display: block; font-family: var(--display); font-style: normal; font-size: 18px; color: var(--gold-hi); }
.diceTotal.crit b { color: #ffd76a; text-shadow: 0 0 30px #ffb020, 0 0 60px #ff8a00; }
.diceTotal.fumble b { color: #ff6a5a; text-shadow: 0 0 30px #a01010; }
/* Télépathie : l'écran du joueur pulse en violet */
#telepathy { position: absolute; left: 0; top: 0; bottom: 0; right: 330px; pointer-events: none; opacity: 0; transition: opacity 1.2s; z-index: 2;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(120, 60, 220, .35) 80%, rgba(60, 10, 120, .75) 100%); }
body.telepathy #telepathy { opacity: 1; animation: tele 3.2s ease-in-out infinite; }
@keyframes tele { 50% { filter: hue-rotate(25deg) brightness(1.4); transform: scale(1.02); } }
#voiceFxRow select { width: auto; padding: 3px 6px; margin: 0; }
@media (max-width: 800px) { #telepathy { right: 0; } }
/* Aide */
#help { position: fixed; inset: 0; background: rgba(5,4,8,.8); z-index: 22; display: grid; place-items: center; }
#help[hidden] { display: none; }
.helpPanel { position: relative; width: min(820px, 94vw); height: min(720px, 88vh); display: flex; flex-direction: column; background: linear-gradient(180deg, #1c1416, #0e0a0c); border: 1px solid #5a4128; border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(201,162,92,.2), 0 20px 80px #000; }
.helpPanel nav { display: flex; flex-wrap: wrap; gap: 4px; padding: 10px 50px 10px 12px; border-bottom: 1px solid #3b2a22; }
.helpPanel article { flex: 1; overflow-y: auto; padding: 8px 24px 20px; font-size: 16.5px; line-height: 1.5; }
.helpPanel h2 { font-family: var(--display); color: var(--gold-hi); }
.helpPanel h4 { font-family: var(--display); color: var(--gold); margin: 14px 0 2px; font-size: 14px; letter-spacing: .05em; }
.helpPanel p, .helpPanel li { margin: 3px 0; }
.helpPanel .tip { background: #24183a; border: 1px solid var(--whisper); border-radius: 8px; padding: 6px 10px; }
.helpPanel .checks { list-style: none; padding: 0; columns: 2; }
.helpClose { position: absolute; top: 10px; right: 10px; }
/* Visite guidée */
.tour { position: fixed; inset: 0; background: rgba(5,4,8,.55); z-index: 30; display: grid; place-items: center; }
.tourBox { width: min(460px, 90vw); background: linear-gradient(180deg, #221719, #110b0d); border: 1px solid var(--gold); border-radius: 12px; padding: 18px 22px; box-shadow: 0 0 40px rgba(201,162,92,.25), 0 20px 60px #000; font-size: 17px; }
.tourBox small { color: var(--muted); font-family: var(--display); }
.tourBox h3 { font-family: var(--display); color: var(--gold-hi); margin: 4px 0 8px; }
.tourBox .row { justify-content: flex-end; margin-top: 12px; }
@media (max-width: 700px) { .helpPanel .checks { columns: 1; } }
/* Grimoire */
#grimoire { position: fixed; inset: 0; background: rgba(5,4,8,.82); z-index: 23; display: grid; place-items: center; }
#grimoire[hidden] { display: none; }
.grimPanel { position: relative; width: min(1100px, 95vw); height: min(800px, 90vh); display: flex; flex-direction: column; padding: 12px 16px; background: linear-gradient(180deg, #1c1416, #0e0a0c); border: 1px solid #5a4128; border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(201,162,92,.2), 0 20px 80px #000; }
.grimPanel.small { width: min(640px, 94vw); height: auto; max-height: 86vh; overflow-y: auto; }
.grimPanel.small .grimClose { position: absolute; right: 10px; top: 10px; }
.grimHead { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grimHead h2 { font-family: var(--display); color: var(--gold-hi); margin: 0 8px 0 0; font-size: 20px; }
.grimHead .grimSearch { flex: 1; min-width: 200px; }
.grimHead select { width: auto; }
.grimBody { flex: 1; min-height: 0; display: grid; grid-template-columns: 320px 1fr; gap: 12px; margin-top: 8px; }
.grimList { list-style: none; padding: 0; margin: 0; overflow-y: auto; border-right: 1px solid #3b2a22; }
.grimList li { display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: 6px; font-size: 15px; cursor: pointer; }
.grimList li:hover, .grimList li.sel { background: #231a1e; }
.grimList li span { flex: 1; }
.grimList li em { color: var(--gold); font-style: normal; font-family: var(--display); font-size: 11px; }
.grimList .add { padding: 1px 8px; }
.grimLvlH { font-family: var(--display); color: var(--blood-hi) !important; font-size: 12px !important; letter-spacing: .12em; margin-top: 8px; cursor: default !important; background: none !important; }
.grimDetail { overflow-y: auto; padding-right: 8px; }
.grimCredit { font-size: 11.5px; margin: 6px 0 0; }
.spellCard h3 { font-family: var(--display); color: var(--gold-hi); margin: 4px 0; font-size: 24px; }
.spellCard .sp-kind { font-style: italic; color: var(--muted); }
.sp-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; background: #120d0f; border: 1px solid #2c201a; border-radius: 8px; padding: 8px 10px; margin: 8px 0; font-size: 14.5px; }
.sp-facts i { font-family: var(--display); font-style: normal; color: var(--gold); font-size: 11px; display: block; letter-spacing: .06em; }
.spellCard p { line-height: 1.5; font-size: 16px; }
.sp-classes { color: var(--gold); font-family: var(--display); font-size: 12px; letter-spacing: .05em; }
.mySpells { list-style: none; padding: 0; margin: 6px 0; }
.mySpells li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 3px 0; font-size: 15px; border-bottom: 1px dashed #2b2024; }
.mySpells li span { cursor: pointer; text-decoration: underline dotted #6a5040; }
.mySpells li em { color: var(--gold); font-style: normal; font-family: var(--display); font-size: 11px; }
.mySpells li i { width: 100%; padding-left: 34px; color: var(--muted); font-size: 12.5px; }
@media (max-width: 760px) { .grimBody { grid-template-columns: 1fr; } .grimList { max-height: 40vh; border-right: none; } }
.castBox { position: absolute; left: 50%; top: 70px; transform: translateX(calc(-50% - 165px)); z-index: 6; background: linear-gradient(180deg, #2a1d3a, #160f24); border: 1px solid var(--whisper); border-radius: 10px; padding: 8px 12px; box-shadow: 0 0 24px #8a5cff55, 0 10px 40px #000; }
.castBox b { font-family: var(--display); color: #e2d4ff; }
@media (max-width: 800px) { .castBox { transform: translateX(-50%); } }

#lobby .hint { font-size: 13px; margin: -4px 0 8px; opacity: .75; }
#lobby .recover { margin-top: 14px; font-size: 14px; }
#lobby .recover summary { cursor: pointer; color: var(--gold); opacity: .85; }
#lobby .recover[open] summary { margin-bottom: 8px; }
#btnPass.warn { border-color: var(--blood-hi); color: #ffb4a0; }
.warnNote { color: #ffb4a0 !important; }
.skillList .dis { color: #e07a5f; font-style: normal; font-size: 11px; margin-left: 4px; }
.armorRow select { flex: 1; min-width: 0; }

#improv .impBtns { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
#improv .impEnc { flex-wrap: wrap; gap: 6px; align-items: center; }
#improv .impEnc select { width: auto; padding: 3px 6px; }
.impCard { margin-top: 10px; padding: 10px 12px; border: 1px solid #5a3f2a; border-radius: 8px; background: linear-gradient(180deg, rgba(40,26,20,.85), rgba(20,13,11,.9)); }
.impCard h4 { margin: 0 0 2px; font-family: var(--display); color: var(--gold-hi); letter-spacing: .04em; }
.impCard dl { margin: 8px 0; display: grid; grid-template-columns: max-content 1fr; gap: 4px 10px; font-size: 14px; }
.impCard dt { color: var(--gold); font-style: italic; }
.impCard dd { margin: 0; }

.mapsBox { margin: 8px 0; padding: 8px; border: 1px solid #3b2a22; border-radius: 8px; background: rgba(0,0,0,.18); }
.mapsBox h4 { margin: 0 0 6px; font-family: var(--display); color: var(--gold); font-size: 13px; letter-spacing: .06em; }
.mapsBox select { flex: 1; min-width: 0; }
.mapsBox .row { flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }

/* Icônes au trait (remplacent les émojis) */
.ico { width: 1.1em; height: 1.1em; vertical-align: -0.18em; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button .ico { margin-right: .15em; }
#reactions .ico { width: 1.5em; height: 1.5em; color: var(--gold-hi); }

#aiBox .row { flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
#aiBox select, #aiBox input { flex: 1; min-width: 0; }
#aiKeyLink { color: var(--gold); align-self: center; }
#aiChat { max-height: 420px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
#aiChat:empty { display: none; }
.aiMsg { padding: 8px 10px; border-radius: 8px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; }
.aiMsg.me { align-self: flex-end; max-width: 88%; background: rgba(120,90,50,.25); border: 1px solid #5a4030; }
.aiMsg.ai { background: linear-gradient(180deg, rgba(40,26,20,.85), rgba(20,13,11,.9)); border: 1px solid #5a3f2a; }
.aiMsg.wait { opacity: .7; font-style: italic; }
.aiMsg.err { border-color: var(--blood-hi); color: #ffb4a0; }
.aiMsg .row { margin: 6px 0 0; white-space: normal; }
.aiInput textarea { flex: 1; min-width: 0; resize: vertical; }
#offmapBox h4 { margin: 8px 0 4px; }
#offmapList { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
#offmapList li { display: flex; flex-direction: column; gap: 3px; padding: 6px; border: 1px solid #3b2a22; border-radius: 6px; }

/* Texte courant en Garamond, un peu plus grand pour rester lisible */
.sheetView, .combatList, #log, .sheetEdit label, .sheetEdit h5, .skillPick, .abil { font-size: 14px; }
.note, .hint { font-size: 13px; }
/* Réactions en colonne à gauche : elles ne recouvrent plus la barre d'outils */
#reactions { flex-direction: column; bottom: 70px; }
#reactions button { font-size: 18px; padding: 3px 6px; }
/* Journal repliable */
#journal h3 { cursor: pointer; user-select: none; }
#journal h3::after { content: '▾'; margin-left: auto; opacity: .7; }
#journal.folded h3::after { content: '▸'; }
#journal.folded { flex: 0 0 auto !important; }
#journal.folded #log { max-height: 1.6em; overflow: hidden; }
#journal.folded #log li:not(:last-child) { display: none; }
#initStrip .ini.unseen, .nm.unseen { opacity: .65; font-style: italic; }

/* Barre « mon tour » */
#turnHud { position: absolute; left: 50%; transform: translateX(calc(-50% - 165px)); bottom: 64px; z-index: 2; min-width: 420px; max-width: 720px;
  background: linear-gradient(180deg, rgba(30,20,16,.94), rgba(14,10,9,.96)); border: 1px solid #6a4a2e; border-radius: 12px; padding: 8px 10px; box-shadow: 0 8px 30px #000a; }
#turnHud .hudHead { display: flex; gap: 12px; align-items: baseline; font-family: var(--display); color: var(--gold-hi); margin-bottom: 6px; }
#turnHud .hudHead span { font-family: var(--serif); color: var(--muted); font-size: 14px; }
#turnHud .hudMove { margin-left: auto; color: var(--gold) !important; }
#turnHud .hudRow { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
#turnHud .atkBtn i { opacity: .7; font-style: normal; font-size: 12px; margin-left: 4px; }
#turnHud .hudTarget { margin-top: 8px; color: #ffcf8a; font-size: 14px; }
body.targeting #view { cursor: crosshair; }
.hitv { color: #e8b04a; } .missv { color: #a09890; }
/* pendant un jet, les dés passent devant la barre de tour */
.diceLayer.on ~ #turnHud, body:has(.diceLayer.on) #turnHud { opacity: .25; pointer-events: none; transition: opacity .2s; }
