/* Tabletop Draconis — client joueur. Médiéval-fantasy sobre, lumineux par défaut, sombre si le système le demande. */
:root {
  --bg: #f4eee1; --panel: #fffaf0; --ink: #2a2017; --muted: #6a5946; --line: #d6c7ab;
  --accent: #7a3410; --accent-ink: #fffaf0; --ok: #2c6335; --warn: #8a5a00; --bad: #962626;
  --floor: #efe5cf; --wall: #4a3b2c; --door: #a8662a; --door-open: #5b9a66; --me: #7a3410; --other: #3d5a80; --thing: #6a5946;
  --text-scale: 1;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17130f; --panel: #241d17; --ink: #f1e7d5; --muted: #b6a58c; --line: #4a3d30;
    --accent: #e3a563; --accent-ink: #1b140d; --ok: #86c992; --warn: #e5b85a; --bad: #f09090;
    --floor: #2c241c; --wall: #cdbb9c; --door: #d08b48; --door-open: #86c992; --me: #e3a563; --other: #9ab8dc; --thing: #b6a58c;
  }
}
* { box-sizing: border-box; }
html { font-size: calc(16px * var(--text-scale)); }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: Georgia, 'Iowan Old Style', 'Times New Roman', serif; line-height: 1.45; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 1.15rem; } h2 { font-size: 1.05rem; color: var(--accent); margin-bottom: .5rem; } h3 { font-size: .95rem; }
p { margin: 0 0 .5rem; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); border-radius: 6px; padding: .4rem .8rem; cursor: pointer; min-height: 2.25rem; }
button.ghost { background: transparent; color: var(--accent); }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: .4rem .55rem; min-height: 2.25rem; max-width: 100%; }
textarea { width: 100%; min-height: 4.5rem; resize: vertical; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); } .ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.stack { display: flex; flex-direction: column; gap: .5rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .75rem; }

/* Connexion */
.join { max-width: 26rem; margin: 12vh auto 0; padding: 0 1rem; }
.join input { font-family: Consolas, monospace; font-size: 1.4rem; letter-spacing: .15em; text-transform: uppercase; width: 100%; text-align: center; }
.join button { width: 100%; }

/* En-tête */
header.top { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; padding: .5rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line); }
header.top .spacer { flex: 1; }
.pill { border: 1px solid var(--line); border-radius: 999px; padding: .1rem .6rem; font-size: .85rem; white-space: nowrap; }
.chars { display: flex; gap: .35rem; flex-wrap: wrap; }
.chars button[aria-pressed="true"] { box-shadow: inset 0 -3px 0 var(--accent-ink); font-weight: 700; }
.chars button[aria-pressed="false"] { background: transparent; color: var(--accent); }

/* Disposition */
main.game { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(18rem, 1fr); gap: 1rem; padding: 1rem; align-items: start; }
@media (max-width: 900px) { main.game { grid-template-columns: 1fr; padding: .75rem; } }
.banner { padding: .5rem 1rem; border-left: 4px solid var(--warn); background: var(--panel); }
.banner.bad { border-left-color: var(--bad); }

/* Carte */
.map-wrap { position: relative; }
svg.map { width: 100%; height: auto; max-height: 70vh; background: var(--floor); border: 1px solid var(--line); border-radius: 8px; display: block; touch-action: manipulation; cursor: crosshair; }
svg.map .wall { stroke: var(--wall); stroke-width: .35; stroke-linecap: round; }
svg.map .wall.window { stroke-dasharray: .25 .2; opacity: .7; }
svg.map .door { stroke: var(--door); stroke-width: .5; stroke-linecap: round; }
svg.map .door.open { stroke: var(--door-open); stroke-dasharray: .6 .6; }
svg.map .stair { fill: none; stroke: var(--muted); stroke-width: .15; stroke-dasharray: .4 .3; }
svg.map .reach { fill: none; stroke: var(--me); stroke-width: .08; stroke-dasharray: .3 .3; opacity: .6; }
svg.map .ent { cursor: pointer; }
svg.map .ent circle { stroke: var(--panel); stroke-width: .12; }
svg.map .ent.me circle { fill: var(--me); } svg.map .ent.actor circle { fill: var(--other); } svg.map .ent.thing circle { fill: var(--thing); }
svg.map .ent.sel circle { stroke: var(--ink); stroke-width: .3; }
svg.map text { font-size: 1px; fill: var(--ink); paint-order: stroke; stroke: var(--floor); stroke-width: .25; pointer-events: none; font-family: Georgia, serif; }
.map-help { font-size: .85rem; }

/* Panneau */
.tabs { display: flex; flex-wrap: wrap; gap: .25rem; margin-bottom: .5rem; }
.tabs button { background: transparent; color: var(--accent); border-color: var(--line); padding: .3rem .6rem; }
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
ul.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
ul.list li { border-bottom: 1px solid var(--line); padding-bottom: .35rem; }
ul.list li:last-child { border-bottom: 0; }
dl.sheet { display: grid; grid-template-columns: max-content 1fr; gap: .15rem .75rem; margin: 0; } dl.sheet dt { color: var(--muted); } dl.sheet dd { margin: 0; }
.dialogue { border: 2px solid var(--accent); }
.dialogue .speaker { font-weight: 700; color: var(--accent); }
.dialogue .line { font-size: 1.1rem; margin: .35rem 0 .6rem; }
.dialogue .choices { display: flex; flex-direction: column; gap: .35rem; } .dialogue .choices button { text-align: left; }
#toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; max-width: min(26rem, calc(100vw - 2rem)); z-index: 10; }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 6px; padding: .5rem .75rem; box-shadow: 0 2px 10px rgba(0,0,0,.2); }
.toast.bad { border-left-color: var(--bad); }
@media (prefers-reduced-motion: no-preference) { .toast { animation: rise .2s ease-out; } @keyframes rise { from { transform: translateY(6px); opacity: 0; } } }

/* Stage 2D */
.stage-frame { position: relative; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 8px; border: 1px solid var(--line); background: radial-gradient(ellipse at center, #4a3828 0%, #1f1710 80%); }
.stage-frame .bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.stage-frame .slots { position: absolute; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(3, 1fr); align-items: end; gap: 2%; padding: 0 3% 3%; height: 82%; }
.stage-frame .slot { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: .4rem; }
.stage-frame .portrait { max-width: 90%; max-height: 82%; object-fit: contain; filter: drop-shadow(0 6px 12px rgba(0, 0, 0, .45)); }
.stage-frame .silhouette { width: 46%; aspect-ratio: 3 / 4; border-radius: 45% 45% 12% 12%; background: linear-gradient(#0d0907cc, #0d0907); box-shadow: 0 0 24px #000a; }
.stage-frame .name { background: rgba(20, 14, 9, .82); color: #fff3df; padding: .15rem .7rem; border-radius: 999px; font-size: .95rem; }
@media (prefers-reduced-motion: no-preference) { .stage-frame .enter .portrait, .stage-frame .enter .silhouette { animation: stage-in .35s ease-out; } @keyframes stage-in { from { opacity: 0; transform: translateY(8px); } } }

/* Fiche de règles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr)); gap: .4rem; }
.stat, .ability { display: flex; flex-direction: column; align-items: center; gap: .1rem; border: 1px solid var(--line); border-radius: 6px; padding: .35rem .3rem; background: var(--bg); }
.stat strong { font-size: 1.1rem; }
.abilities { display: grid; grid-template-columns: repeat(6, 1fr); gap: .35rem; }
@media (max-width: 560px) { .abilities { grid-template-columns: repeat(3, 1fr); } }
.ability strong { font-size: 1.25rem; color: var(--accent); }
.small { font-size: .78rem; }
ul.skills { list-style: none; margin: .4rem 0 0; padding: 0; columns: 2; column-gap: 1.2rem; }
ul.skills li { display: flex; justify-content: space-between; gap: .5rem; break-inside: avoid; padding: .1rem 0; border-bottom: 1px dotted var(--line); }
details summary { cursor: pointer; color: var(--accent); }

/* Avatar vocal */
details.voice { border: 1px solid var(--line); border-radius: 6px; padding: .4rem .6rem; }
details.voice .row { display: flex; align-items: center; gap: .4rem; }
.meter { height: .5rem; border-radius: 4px; background: var(--bg); border: 1px solid var(--line); overflow: hidden; margin: .4rem 0; }
.meter span { display: block; height: 100%; width: 0; background: var(--line); transition: width .06s linear; }
.meter span.on { background: var(--accent); }
