:root {
  --bg: #16130f;
  --panel: #221d17;
  --panel-2: #2e2720;
  --line: #4a3f31;
  --text: #ecdfc8;
  --muted: #a8987f;
  --gold: #d9b35c;
  --red: #b5472f;
  --font: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Noto Serif', serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); overflow: hidden; }
[hidden] { display: none !important; }

button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  background: #15120e; border: 1px solid var(--line); border-radius: 5px; padding: 6px 8px; width: 100%;
}
input[type=range], input[type=checkbox], input[type=color] { width: auto; padding: 0; }
input[type=color] { width: 36px; height: 30px; background: none; }
textarea { resize: vertical; min-height: 64px; }
.note-box { width: 100%; overflow: hidden; resize: vertical; min-height: 80px; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }

button {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px; padding: 6px 10px; cursor: pointer;
}
button:hover { border-color: var(--gold); }
button.primary { background: #6b4d1e; border-color: var(--gold); color: #fff3d6; }
button.danger { color: #f0a58f; }
button.on { background: #6b4d1e; border-color: var(--gold); }

label { display: block; margin: 8px 0; color: var(--muted); font-size: 13px; }
label input, label select, label textarea { margin-top: 3px; color: var(--text); font-size: 15px; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); }
label.check input { margin: 0; }

/* Connexion */
#login {
  height: 100%; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 50% 30%, #3a2c1a, #120f0b 70%);
}
#login form {
  width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 24px;
}
#login h1 { margin: 0; color: var(--gold); font-size: 34px; letter-spacing: .02em; }
#login p { margin: 4px 0 14px; color: var(--muted); }
#login button { width: 100%; margin-top: 8px; padding: 9px; background: #6b4d1e; border-color: var(--gold); }
#login button.linkish { background: none; border-color: transparent; color: var(--muted); }
.who { display: flex; flex-direction: column; white-space: normal; }
#login-error { color: #f0a58f; min-height: 1.4em; margin: 10px 0 0 !important; }

/* Mise en page de la table */
#app { position: fixed; inset: 0; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

#topbar {
  position: absolute; top: 8px; left: 64px; right: calc(var(--side-w, 332px) + 16px); height: 40px;
  display: flex; align-items: center; gap: 10px; padding: 0 12px;
  background: rgba(34, 29, 23, .92); border: 1px solid var(--line); border-radius: 8px;
}
#scene-title { color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#scene-badge { color: #f0c48f; font-size: 13px; white-space: nowrap; }
#btn-activate { padding: 3px 8px; font-size: 13px; white-space: nowrap; }
.spacer { flex: 1; }
#presence { display: flex; gap: 5px; margin: 0; padding: 0; list-style: none; }
#presence li {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: bold; color: #fff; opacity: .35;
}
#presence li.online { opacity: 1; }
.sound { display: flex; align-items: center; gap: 6px; margin: 0; white-space: nowrap; }
.sound input { width: 70px; margin: 0; }

#tools {
  position: absolute; top: 8px; left: 8px; width: 48px; display: flex; flex-direction: column; gap: 4px; padding: 4px;
  background: rgba(34, 29, 23, .92); border: 1px solid var(--line); border-radius: 8px;
  max-height: calc(100% - 16px); overflow-y: auto;
}
#tools button { width: 38px; height: 38px; padding: 0; font-size: 18px; line-height: 1; }
#tools hr { width: 100%; border: 0; border-top: 1px solid var(--line); margin: 2px 0; }

#toolopts {
  position: absolute; top: 56px; left: 64px; width: 240px; max-height: calc(100% - 66px); overflow-y: auto;
  padding: 10px; background: rgba(34, 29, 23, .95); border: 1px solid var(--line); border-radius: 8px;
}
#toolopts h3 { margin: 0 0 6px; color: var(--gold); font-size: 15px; }
#toolopts p { margin: 6px 0; color: var(--muted); font-size: 13px; }
.palette { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; }
.palette button { padding: 4px 6px; font-size: 13px; text-align: left; display: flex; align-items: center; gap: 6px; }
.palette i { width: 16px; height: 16px; border-radius: 3px; flex: none; border: 1px solid rgba(0,0,0,.5); }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row > * { flex: 1; }

#side {
  position: absolute; top: 8px; right: 8px; bottom: 8px; width: var(--side-w, 332px);
  display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  overflow: hidden;
}
/* Poignée du bord gauche : on tire pour élargir le panneau (tableaux de gestion), double-clic pour revenir. */
#side-grip {
  position: absolute; top: 0; bottom: 0; left: 0; width: 7px; cursor: ew-resize; z-index: 2;
  background: linear-gradient(90deg, transparent 2px, var(--line) 2px, var(--line) 4px, transparent 4px); opacity: .5;
}
#side-grip:hover, #side-grip.drag { opacity: 1; background: var(--gold); }
#tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
#tabs button {
  flex: 1; border: 0; border-radius: 0; background: none; padding: 9px 2px; font-size: 13px; color: var(--muted);
  border-bottom: 2px solid transparent;
}
#tabs button.on { color: var(--gold); border-bottom-color: var(--gold); }
#tab-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; }
.pane { padding: 10px; }
.pane h3 { margin: 12px 0 4px; color: var(--gold); font-size: 15px; }
.pane h3:first-child { margin-top: 0; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0 8px; }
.hint.debt { color: #e5735f; }

/* Journal */
#log { flex: 1; min-height: 0; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.entry { background: var(--panel-2); border-radius: 6px; padding: 5px 8px; overflow-wrap: anywhere; }
.entry b { font-weight: bold; }
.entry.info { background: none; color: var(--muted); font-size: 13px; font-style: italic; padding: 0 2px; }
.entry.secret { outline: 1px dashed var(--gold); }
.roll-total { font-size: 21px; color: var(--gold); font-weight: bold; margin-left: 6px; }
.roll-detail { color: var(--muted); font-size: 13px; }
.roll-detail s { opacity: .55; }
.max { color: #9fe39a; font-weight: bold; }
.min { color: #f0a58f; font-weight: bold; }
.dicebar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; padding: 6px 10px 0; flex: none; }
.dicebar button { padding: 4px 0; font-size: 13px; }
#chat { display: flex; gap: 6px; padding: 8px 10px 10px; flex: none; }
#chat-input { flex: 1; min-width: 0; }

/* Listes */
.list { list-style: none; margin: 6px 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.list li {
  display: flex; align-items: center; gap: 6px; background: var(--panel-2); border-radius: 6px; padding: 5px 7px;
}
.list li.current { outline: 1px solid var(--gold); }
.list .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.list .tag { color: var(--muted); font-size: 12px; }
.list button { padding: 1px 6px; font-size: 13px; }
.swatch { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.init-num { width: 34px; text-align: right; color: var(--gold); font-weight: bold; flex: none; }

/* Fiche de lieu */
#poi-card {
  position: absolute; left: 50%; bottom: 20px; transform: translateX(calc(-50% - 170px)); width: min(440px, calc(100% - 370px));
  max-height: 55%; overflow-y: auto; padding: 14px 16px; background: rgba(34, 29, 23, .97);
  border: 1px solid var(--gold); border-radius: 10px;
}
#poi-card h3 { margin: 0 0 6px; color: var(--gold); font-size: 19px; }
#poi-card p { margin: 6px 0; white-space: pre-wrap; }
#poi-card .secret { color: #f0c48f; border-left: 3px solid var(--red); padding-left: 8px; }
#poi-card .row { margin-top: 10px; }
#poi-card .close { position: absolute; top: 6px; right: 8px; border: 0; background: none; font-size: 18px; }

#dice-toast {
  position: absolute; top: 70px; left: calc(50% - 170px); transform: translateX(-50%); display: flex; flex-direction: column;
  align-items: center; gap: 6px; pointer-events: none;
}
.dice-pop {
  background: rgba(34, 29, 23, .96); border: 1px solid var(--gold); border-radius: 10px; padding: 6px 16px;
  text-align: center; animation: pop 3.5s forwards;
}
.dice-pop span { display: block; color: var(--muted); font-size: 13px; }
.dice-pop strong { color: var(--gold); font-size: 32px; line-height: 1.1; }
@keyframes pop {
  0% { opacity: 0; transform: scale(.7) rotate(-4deg); }
  8% { opacity: 1; transform: scale(1.08); }
  14% { transform: scale(1); }
  85% { opacity: 1; }
  100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .dice-pop { animation-duration: 3.5s; animation-timing-function: steps(1); } }

#toast {
  position: absolute; bottom: 72px; left: calc(50% - 170px); transform: translateX(-50%);
  background: #000c; padding: 5px 12px; border-radius: 6px; opacity: 0; transition: opacity .2s; pointer-events: none;
}
#toast.show { opacity: 1; }

dialog {
  background: var(--panel); color: var(--text); border: 1px solid var(--gold); border-radius: 10px; padding: 18px;
  width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h2 { margin: 0 0 10px; color: var(--gold); font-size: 21px; }
.modal-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
#preview { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #0e0c09; border-radius: 6px; border: 1px solid var(--line); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.codebox { font-family: monospace; font-size: 13px; overflow-wrap: anywhere; background: #15120e; border-radius: 5px; padding: 6px; }

@media (max-width: 820px) {
  #side { width: 100%; top: auto; left: 0; right: 0; bottom: 0; height: 40%; border-radius: 8px 8px 0 0; }
  #topbar { right: 8px; }
  #poi-card { transform: translateX(-50%); width: calc(100% - 32px); bottom: calc(40% + 10px); }
  #dice-toast, #toast { left: 50%; }
  .sound { display: none; }
  .modal-cols { grid-template-columns: 1fr; }
}

/* Modes */
#modes { display: flex; flex: none; }
#modes button { padding: 3px 10px; font-size: 13px; border-radius: 0; }
#modes button:first-child { border-radius: 5px 0 0 5px; }
#modes button:last-child { border-radius: 0 5px 5px 0; border-left: 0; }
#btn-focus { padding: 3px 8px; font-size: 13px; white-space: nowrap; flex: none; }
body[data-mode=edit] #topbar { border-color: #4f7fa8; }
body[data-mode=edit] #tabs button.on { color: #9cc7ea; border-bottom-color: #9cc7ea; }

#actionbar {
  position: absolute; left: calc(50% - 170px); bottom: 12px; transform: translateX(-50%);
  max-width: calc(100% - 420px); display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 5px;
  padding: 6px; background: rgba(34, 29, 23, .94); border: 1px solid var(--line); border-radius: 8px;
}
#actionbar .tag { color: var(--muted); font-size: 13px; padding: 0 4px; }
#poi-card { bottom: 66px; }

/* Fiche */
.sheet-head { display: flex; align-items: center; gap: 10px; }
.grow-box { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.portrait {
  width: 54px; height: 54px; border-radius: 50%; object-fit: cover; flex: none; display: grid; place-items: center;
  font-size: 24px; font-weight: bold; color: #fff; border: 2px solid var(--gold);
}
.tag { color: var(--muted); font-size: 12px; }
.hpline { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-top: 10px; }
.hpline > span:first-child { font-weight: bold; margin-right: auto; }
.hpline button { padding: 2px 7px; font-size: 13px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.stats button { display: flex; flex-direction: column; align-items: center; padding: 4px 2px; overflow: hidden; }
.stats b { font-size: 18px; color: var(--gold); line-height: 1.2; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 6px; }
.stat-grid label { margin: 3px 0; overflow: hidden; }
.action-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 4px; margin-bottom: 4px; }
.action-row button { padding: 0 8px; }
.pane textarea { min-height: 70px; }
.swatch.off { opacity: .3; }
.hint.error { color: #f0a58f; }
.linkbtn {
  display: inline-block; margin: 4px 6px 4px 0; padding: 6px 10px; border-radius: 5px; color: #fff3d6;
  background: #6b4d1e; border: 1px solid var(--gold); text-decoration: none;
}
#login .hint { font-size: 13px; margin: 8px 0 0; }
dialog { overflow-y: auto; }

@media (max-width: 820px) {
  #actionbar { left: 50%; bottom: calc(40% + 8px); max-width: calc(100% - 16px); }
  #poi-card { bottom: calc(40% + 62px); }
}

/* Accueil */
#home {
  height: 100%; overflow-y: auto; padding: 24px 16px;
  background: radial-gradient(circle at 50% 20%, #3a2c1a, #120f0b 70%);
}
#home-box { width: min(760px, 100%); margin: 0 auto; }
#home h1 { margin: 0; color: var(--gold); font-size: 34px; }
#home h2 { margin: 4px 0 14px; font-size: 19px; font-weight: normal; }
#home-error { color: #f0a58f; margin: 0 0 8px; min-height: 0; }
.cards { list-style: none; margin: 12px 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.card { display: flex; flex-direction: column; gap: 8px; padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.card h3 { margin: 0; color: var(--gold); overflow-wrap: anywhere; }
.card p { margin: 0; color: var(--muted); overflow-wrap: anywhere; }
.card .check { margin: 0; }
.row-inline { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
/* Une pièce de la bourse : son nom, combien, −1 et +1. */
.coins { display: flex; flex-direction: column; gap: 4px; }
.shop { display: flex; flex-direction: column; gap: 6px; min-width: min(460px, 80vw); }
.shop-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 6px; }
.shop-row button { padding: 2px 8px; }
.coin { display: grid; grid-template-columns: 1fr 120px; align-items: center; gap: 4px; }
.coin input { min-width: 0; padding: 3px 6px; text-align: right; }
.coin button { padding: 2px 8px; }
form.row-inline input { flex: 1; min-width: 160px; }
.pill { font-size: 12px; padding: 1px 8px; border-radius: 10px; border: 1px solid var(--line); color: var(--muted); }
.pill.on { border-color: var(--gold); color: var(--gold); }

/* Choix du personnage, attente */
#gate { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(12, 10, 8, .88); }
#gate-box { width: min(420px, 100%); max-height: 100%; overflow-y: auto; padding: 18px; background: var(--panel); border: 1px solid var(--gold); border-radius: 10px; }
#gate-box h2 { margin: 0 0 6px; color: var(--gold); }
#gate-box > button { margin-top: 8px; }
/* Distance et prix d'un voyage, à côté du pion qu'on tient. */
#travel-tip {
  position: fixed; z-index: 30; pointer-events: none; padding: 4px 10px; font-size: 13px; white-space: nowrap;
  background: rgba(34, 29, 23, .95); border: 1px solid var(--gold); border-radius: 6px; color: var(--gold);
}
#travel-tip.bad { border-color: #d9705c; color: #f0a090; }
/* Âge du monde, pour le MJ, en bas à gauche de la carte. */
#world-time { position: absolute; left: 64px; bottom: 14px; display: flex; gap: 6px; }
#world-time[hidden], #world-time button[hidden] { display: none; }
/* Chez les joueurs, la date se lit sans se régler. */
#world-time button.readonly { cursor: default; pointer-events: none; }
@media (max-width: 820px) {
  #world-time { left: 8px; bottom: calc(40% + 58px); }
}
#world-time button {
  padding: 5px 12px; font-size: 13px;
  background: rgba(34, 29, 23, .92); border: 1px solid var(--gold); border-radius: 8px; color: var(--gold);
}
#waiting {
  position: absolute; top: 58px; left: calc(50% - 170px); transform: translateX(-50%); padding: 6px 14px; white-space: nowrap;
  background: rgba(34, 29, 23, .92); border: 1px solid var(--gold); border-radius: 8px; color: var(--gold);
}
#btn-tables { padding: 2px 8px; flex: none; }
#btn-start { padding: 3px 8px; font-size: 13px; white-space: nowrap; flex: none; }

/* Clic droit */
#ctxmenu {
  position: absolute; width: 220px; max-height: 70%; overflow-y: auto; padding: 4px;
  background: var(--panel); border: 1px solid var(--gold); border-radius: 8px;
  display: flex; flex-direction: column; gap: 2px;
}
#ctxmenu h4 { margin: 6px 6px 2px; color: var(--gold); font-size: 13px; }
#ctxmenu button { border: 0; background: none; text-align: left; padding: 4px 8px; flex: none; }
#ctxmenu button:hover, #ctxmenu button:focus-visible { background: var(--panel-2); }
@media (max-width: 820px) {
  #waiting { left: 50%; white-space: normal; width: calc(100% - 32px); text-align: center; }
}

.subtabs { display: flex; gap: 4px; margin-bottom: 8px; }
.subtabs button { flex: 1; padding: 5px 2px; font-size: 13px; }
.subtabs button.on { background: #6b4d1e; border-color: var(--gold); }
.step-row { display: grid; grid-template-columns: 52px 48px 48px 1fr 28px; gap: 3px; margin-bottom: 4px; }
.step-row input { min-width: 0; padding: 4px; }
.creature-preview { display: inline-block; width: 48px; height: 48px; flex: none; }
.list canvas { flex: none; }
#login .copyright { margin: 12px 0 0; text-align: center; font-size: 11px; opacity: .7; }

dialog.wide { width: min(1100px, 94vw); max-width: none; }
.doc-scroll { overflow: auto; max-height: 66vh; }
.doc-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.doc-table th, .doc-table td { border: 1px solid var(--line); padding: 4px 7px; text-align: left; vertical-align: top; white-space: pre-line; }
.doc-table th { position: sticky; top: 0; background: #2b2419; color: var(--gold); }
.doc-edit td { padding: 1px; }
.doc-edit textarea { width: 100%; min-width: 110px; min-height: 30px; margin: 0; padding: 3px; font-size: 13px; resize: vertical; }
.doc-text { max-height: 66vh; overflow: auto; }
.doc-text p { margin: 0 0 8px; }
.doc-area { width: 100%; min-height: 46vh; }
.doc-back { margin-bottom: 8px; }
/* Nom, type, dé, bonus d'attaque, bonus de dégât, × : chaque case grandit avec la fenêtre. */
.weapon-row { display: grid; grid-template-columns: minmax(80px, 2.4fr) minmax(90px, 2fr) minmax(52px, 1.1fr) minmax(46px, 1fr) minmax(46px, 1fr) 28px; gap: 3px; margin-bottom: 4px; }
.weapon-row input, .weapon-row select { min-width: 0; padding: 4px; }
.weapon-block > .hint { margin: 0 0 6px; }
.broken { color: #e5735f; }
/* Catalogue d'équipement : deux lignes par arme, le bouton de retrait à droite. */
.gear-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) minmax(46px, .7fr) minmax(62px, .9fr) 28px; gap: 3px; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid rgba(255,255,255,.08); }
.gear-row > button { grid-column: 5; grid-row: 1 / span 2; }
.gear-row.armor { grid-template-columns: 1fr 70px 28px; }
.gear-row.armor > button { grid-column: 3; grid-row: 1; }
.gear-row.item { grid-template-columns: 1fr 70px 28px; }
.gear-row.duo { grid-template-columns: 1fr 1fr 28px; }
/* Tableaux de la partie Économie : on fait défiler sur le côté s'ils sont plus larges que le panneau. */
.table-edit { overflow-x: auto; margin-bottom: 6px; }
.table-row { display: grid; gap: 3px; margin-bottom: 3px; min-width: max-content; }
.table-row.head span { font-size: 11px; opacity: .75; }
.table-row input { min-width: 0; padding: 3px 5px; }
.gear-row.duo > button { grid-column: 3; grid-row: 1; }
.gear-row.item > input:nth-child(3) { grid-column: 1 / span 2; }
.gear-row.item > button { grid-column: 3; grid-row: 1; }
.gear-row input, .gear-row select { min-width: 0; padding: 4px; }
.attack-list { display: flex; flex-direction: column; gap: 5px; min-width: 280px; }
.attack-list button { text-align: left; padding: 8px 10px; }
#btn-combat.on { background: #6b2f2f; border-color: #d9705c; }
#btn-combat { white-space: nowrap; flex: none; }
#btn-spawn, #btn-back { white-space: nowrap; flex: none; }
.spawn-list { max-height: 46vh; overflow: auto; margin: 8px 0; }
.spawn-list button { display: flex; align-items: center; gap: 6px; }
#btn-open, #btn-save, #btn-refresh { white-space: nowrap; flex: none; }
.who select { max-width: 130px; padding: 2px; font-size: 12px; }
#topbar { flex-wrap: wrap; height: auto; }

/* Lecteur de documents */
.reader { display: flex; flex-direction: column; height: 72vh; overflow: hidden; background: #cfccc4; color: #1c1a17; border-radius: 6px; }
.reader > .hint { padding: 16px; color: #4a4640; }
.reader-view { position: relative; flex: 1; min-height: 0; overflow: hidden; cursor: grab; touch-action: none; user-select: none; }
.reader-view.grabbing { cursor: grabbing; }
.reader-stage { position: absolute; top: 0; left: 0; width: max-content; transform-origin: 0 0; }
.reader-stage > img, .reader-stage > svg { display: block; background: #fff; }
.reader-stage > pre { margin: 0; padding: 16px; max-width: 900px; background: #fff; white-space: pre-wrap; font-family: Georgia, serif; }
.reader-pages { display: flex; flex-direction: column; gap: 12px; }
.reader-pages canvas { display: block; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.reader .docx-wrapper { background: none; padding: 0; }
.reader-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; background: #e4e1d9; }
.reader-tabs button { background: #f4f2ec; color: #1c1a17; border: 1px solid #b5b0a4; }
.reader-tabs button.on { background: #1c1a17; color: #f4f2ec; }
.reader-sheet { border-collapse: collapse; background: #fff; font: 13px Calibri, Carlito, sans-serif; }
.reader-sheet td { border: 1px solid #d4d4d4; padding: 2px 6px; white-space: pre-wrap; vertical-align: bottom; }

/* Boutons brouillard et repères des cartes du monde */
.list .toggle { opacity: .45; }
.list .toggle.on { opacity: 1; }

/* Filtre des repères et informations tirées des tableaux */
.poi-filter { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; }
.place-info { margin: 6px 0; padding-left: 18px; font-size: .9em; }
.place-info.secret { color: var(--muted, #b8a98c); font-style: italic; }

/* Listes d'espèces, de classes et de caractéristiques */
.name-list { margin: 10px 0; }
.name-list .list li { align-items: flex-start; }
.name-list .list input { width: 100%; }
.bonus-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 4px; }
.bonus-row select { max-width: 9em; }
.bonus-row .short { width: 4.5em; }
.chip { display: inline-flex; align-items: center; gap: 2px; padding: 1px 6px; border: 1px solid #6b5a3a; border-radius: 10px; font-size: .85em; }
.chip button { padding: 0 4px; min-width: 0; }
.name-list .bonus-row .short { width: 4.5em; }
.name-list .bonus-row select { width: auto; }
.tiny { padding: 1px 6px; font-size: 11px; margin-left: 6px; }

/* Fenêtre étroite : la barre d'actions passe au-dessus de la date du monde. */
@media (min-width: 821px) and (max-width: 1300px) { #actionbar { margin-bottom: 44px; } }

/* Casino : tapis vert, cartes et dé 100. */
.casino-table { display: flex; gap: 14px; justify-content: space-around; flex-wrap: wrap; padding: 14px; margin: 8px 0; border-radius: 12px; border: 2px solid var(--gold);
  background: radial-gradient(circle at 50% 30%, #1f6b46, #0d3a26 75%); box-shadow: inset 0 0 30px rgba(0, 0, 0, .55); }
.cz-hand { text-align: center; padding: 8px; border-radius: 10px; }
.cz-hand .hint { color: #f3e7c8; margin: 0 0 6px; }
.cz-hand.win { box-shadow: 0 0 0 2px var(--gold), 0 0 22px rgba(217, 179, 92, .6); }
.cz-cards { display: flex; gap: 7px; justify-content: center; }
.cz-card { position: relative; width: 66px; height: 96px; border-radius: 8px; background: linear-gradient(150deg, #fffdf6, #efe6cf); border: 1px solid #b9a67a; box-shadow: 0 4px 10px rgba(0, 0, 0, .5); animation: cz-card-in .45s both; font-family: Georgia, serif; }
.cz-card.red { color: #b3202a; }
.cz-card.black { color: #1c1a22; }
.cz-card .corner { position: absolute; left: 6px; top: 4px; display: flex; flex-direction: column; align-items: center; font-weight: bold; font-size: 15px; line-height: 1; }
.cz-card .corner i { font-style: normal; font-size: 13px; }
.cz-card .corner.low { left: auto; top: auto; right: 6px; bottom: 4px; transform: rotate(180deg); }
.cz-card .center { position: absolute; inset: 0; display: grid; place-items: center; font-size: 34px; }
.cz-card.figure::after { content: ''; position: absolute; inset: 5px; border: 1px solid var(--gold); border-radius: 5px; background: radial-gradient(circle, rgba(217, 179, 92, .25), transparent 70%); pointer-events: none; }
.cz-card.figure .center { font-size: 40px; }
.cz-card.back { background: repeating-linear-gradient(45deg, #5b1d6b 0 6px, #73308a 6px 12px); border: 3px double #e9d59a; }
.cz-card.back::after { content: '⚜'; position: absolute; inset: 0; display: grid; place-items: center; color: #e9d59a; font-size: 30px; }
@keyframes cz-card-in { from { transform: translateY(-26px) rotateY(90deg); opacity: 0; } }
.cz-d100 { width: 92px; height: 92px; margin: 0 auto; display: grid; place-items: center; font-size: 32px; font-weight: bold; color: #f7ecd2; background: conic-gradient(from 45deg, #7a2036, #a8324d, #5c1528, #a8324d, #7a2036);
  clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%); animation: cz-dice-in .7s both; }
.cz-d100.wait { opacity: .6; animation: none; }
@keyframes cz-dice-in { from { transform: rotate(-540deg) scale(.3); opacity: 0; } }
.casino-win { color: #8fd18a; font-weight: bold; text-align: center; }
.casino-lose { color: #e08573; font-weight: bold; text-align: center; }
.cz-brand { font-size: 1.3em; color: var(--text); }
.cz-brand.red { color: #d9483f; }
@media (prefers-reduced-motion: reduce) { .cz-card, .cz-d100 { animation: none; } }

/* Le MJ choisit quel brouillard il regarde : celui de tous les joueurs, ou d'un seul. */
#fog-view { position: absolute; bottom: 52px; left: 64px; display: flex; gap: 6px; align-items: center; padding: 4px 8px; font-size: 13px;
  background: rgba(34, 29, 23, .92); border: 1px solid var(--line); border-radius: 8px; }
#fog-view[hidden] { display: none; }
#fog-view select { font-size: 13px; }
/* Onglet Monde */
.monde-list { display: flex; flex-direction: column; gap: 4px; }
.monde-list button.on { border-color: var(--gold); color: var(--gold); }
.runes-list li { font-size: 13px; }
.runes-list b { color: var(--gold); }
@media (max-width: 820px) { #fog-view { left: 8px; bottom: calc(40% + 100px); } }
#fog-view input[type="range"] { width: 110px; }

/* Comptes des joueurs (MJ) */
.accounts { display: flex; flex-direction: column; gap: 8px; max-height: 55vh; overflow-y: auto; }
.account { padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
.account input[type="color"] { width: 34px; height: 28px; padding: 0; }
.account ul { margin: 6px 0 0; }
.account .row-inline > input:not([type="color"]) { width: 190px; flex: 0 1 190px; }

/* Cartes du monde : calque pays / empire / compagnie, et sa transparence. */
#map-layer { position: absolute; bottom: 92px; left: 64px; display: flex; gap: 6px; align-items: center; padding: 4px 8px; font-size: 13px;
  background: rgba(20, 14, 10, .82); border: 1px solid #5a4632; border-radius: 6px; color: #f0e2c8; z-index: 5; }
#map-layer[hidden] { display: none; }
#map-layer select { font-size: 13px; }
#map-layer input[type="range"] { width: 110px; }
@media (max-width: 820px) { #map-layer { left: 8px; bottom: calc(40% + 140px); } }
