:root {
  --bg: #f6f4ef; --card: #ffffff; --ink: #1f1d1a; --muted: #77716a;
  --line: #e6e1d8; --accent: #8a3b12; --accent-soft: #f6e9df; --ok: #2f7d4a; --bad: #b3261e;
  --r: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
.top { display: flex; justify-content: space-between; align-items: center; padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--card); }
.logo { font-weight: 700; letter-spacing: .02em; color: var(--accent); }
main { padding: 24px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; }
.narrow { max-width: 440px; margin: 40px auto; display: flex; flex-direction: column; gap: 12px; }
h1, h2, h3 { margin: 0 0 6px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 8px; }
input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
button { padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); font: inherit; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
hr { border: 0; border-top: 1px solid var(--line); width: 100%; }
.row { display: flex; gap: 16px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.code { font-family: ui-monospace, monospace; background: var(--accent-soft); color: var(--accent); padding: 1px 6px; border-radius: 4px; }

.classes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.classes button.sel { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.table { display: grid; grid-template-columns: 240px 1fr 300px; gap: 16px; align-items: start; }
.party .pc { padding: 8px 0; border-bottom: 1px solid var(--line); }
.party .pc.mine b { color: var(--accent); }
.hpbar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.hpbar i { display: block; height: 100%; background: var(--ok); }
.dice { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }

.avatar-slot { aspect-ratio: 16/9; background: var(--accent-soft); border-radius: 10px; display: grid; place-items: center; color: var(--accent); margin-bottom: 16px; }
.narration { font-size: 17px; font-style: italic; }
.gm-line { font-weight: 600; }
.options { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.options button { text-align: left; }
.options .check { float: right; font-size: 12px; color: var(--muted); }
.gm-controls { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.gm-controls textarea { min-height: 70px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }

.log { max-height: 75vh; overflow: auto; }
.ev { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.ev .who { font-weight: 600; }
.ev.ok .res { color: var(--ok); } .ev.bad .res { color: var(--bad); }

@media (max-width: 1000px) { .table { grid-template-columns: 1fr; } }

.speaking { outline: 3px solid var(--accent); outline-offset: 2px; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: 640px; background: #fff; border: 1px solid var(--bad); color: var(--bad); padding: 12px 16px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.08); cursor: pointer; z-index: 10; }
.avatar-slot { background-size: cover; background-position: center; transition: background-image .4s; }
.avatar-slot.has-image { color: transparent; }

/* ---------- sidebar extras ---------- */
.place { padding: 4px 0 10px; }
.panel-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.options .check.travel { margin-left: 6px; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 28px;
  background: rgba(0, 0, 0, .6); backdrop-filter: blur(3px); }
.sheet { width: min(1040px, 100%); max-height: calc(100vh - 56px); overflow: auto; padding: 26px 30px; }
.ov-close { position: absolute; top: 12px; right: 14px; width: 36px; height: 36px; padding: 0; font-size: 22px; line-height: 1; z-index: 2; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; padding: 0 40px 16px 0;
  border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.stats-row { display: flex; gap: 10px; }
.stat { min-width: 74px; text-align: center; border: 1px solid var(--line); border-radius: var(--r); padding: 6px 10px; }
.stat span { display: block; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.stat b { font-size: 22px; }
.sheet-body { display: grid; grid-template-columns: 1fr 1.2fr; gap: 28px; }

.ico { width: 26px; height: 26px; color: var(--accent); flex: none; }
.ico.big { width: 44px; height: 44px; }

.doll-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.slot { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 8px; min-height: 104px; text-align: center; }
.slot-label { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.slot-empty { color: var(--muted); font-style: italic; opacity: .6; margin-top: 8px; }
.slot.filled .ico { width: 32px; height: 32px; }
.slot-item { font-size: 14px; }
.slot.sel, .item.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }

.abil { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.ab { border: 1px solid var(--line); border-radius: var(--r); padding: 6px 8px; display: grid; grid-template-columns: 1fr auto; align-items: baseline; }
.ab span { grid-column: 1 / -1; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.ab b { font-size: 20px; } .ab i { font-style: normal; color: var(--accent); }

.bag-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.item { position: relative; aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 8px; }
.item.empty { border: 1px dashed var(--line); border-radius: var(--r); opacity: .5; }
.item .ico { width: 34px; height: 34px; }
.item-name { font-size: 12px; line-height: 1.2; text-align: center; }
.qty { position: absolute; top: 6px; right: 8px; font-size: 12px; font-weight: 700; color: var(--accent); }
.item-detail { margin-top: 16px; border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; min-height: 92px; }
.id-head { display: flex; gap: 14px; align-items: center; }
.id-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* ---------- map ---------- */
.map-sheet { width: min(1240px, 100%); }
.map-legend { max-width: 420px; text-align: right; }
.map-wrap { position: relative; }
#map { width: 100%; height: auto; display: block; border-radius: var(--r); border: 1px solid var(--line); }
.road { fill: none; stroke: #6b5a3e; stroke-width: 2.5; stroke-linecap: round; opacity: .55; }
.road.trail { stroke-dasharray: 2 7; stroke-width: 2.5; }
.road.live { stroke: var(--accent); opacity: 1; stroke-width: 3; filter: drop-shadow(0 0 4px rgba(201,164,92,.6)); }
.road-days { fill: var(--accent); font-size: 12px; text-anchor: middle; letter-spacing: .05em; }
.d-tree { fill: #24301f; opacity: .9; } .d-peak { fill: none; stroke: #4a4033; stroke-width: 2; }
.d-reed, .d-wave, .d-hill { fill: none; stroke: #3b3427; stroke-width: 1.6; }
.d-wave { stroke: #2f4650; }
.node { cursor: pointer; }
.node-bg { fill: #15110d; stroke: #5d4e38; stroke-width: 1.5; }
.node-ico { color: #b49764; }
.node.unknown .node-ico, .node.unknown .node-name { opacity: .5; }
.node.exit .node-bg { stroke: var(--accent); stroke-width: 2; }
.node.exit:hover .node-bg { fill: #2a2117; }
.node-name { fill: #d9ccb4; font-size: 13px; text-anchor: middle; paint-order: stroke; stroke: #0b0a09; stroke-width: 4px; }
.node-q { fill: var(--accent); font-size: 14px; text-anchor: middle; opacity: .7; }
.here-glow { fill: rgba(201,164,92,.12); animation: herePulse 2.4s ease-in-out infinite; }
.here-ring { fill: none; stroke: var(--accent); stroke-width: 2; }
.node.here .node-ico { color: #f0d79a; }
@keyframes herePulse { 50% { transform: scale(1.25); opacity: .4; } }
.compass circle { fill: none; stroke: #4a4033; } .compass path { fill: #6b5a3e; } .compass text { fill: #6b5a3e; text-anchor: middle; font-size: 12px; }
.map-tip { position: absolute; transform: translate(-50%, calc(-100% - 30px)); background: var(--card); border: 1px solid var(--accent);
  border-radius: var(--r); padding: 10px 14px; min-width: 200px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.5); z-index: 3; }
.map-tip button { margin-top: 8px; width: 100%; }

@media (max-width: 860px) { .sheet-body { grid-template-columns: 1fr; } .bag-grid { grid-template-columns: repeat(3, 1fr); } }

/* ---------- art style picker ---------- */
.art-styles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.art-styles button { padding: 8px 6px; font-size: 13px; }
.art-styles button.sel { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.avatar-slot.redrawing::before { content: "Przerysowuję scenę..."; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 2; padding: 8px 14px; border-radius: 6px; background: rgba(0,0,0,.6); color: var(--accent); font-size: 13px; letter-spacing: .12em; }
.avatar-slot.redrawing { filter: saturate(.4) brightness(.7); transition: filter .4s; }

/* pixel art assets */
img.ico.px { image-rendering: pixelated; object-fit: contain; }
.item img.ico.px { width: 48px; height: 48px; }
.slot.filled img.ico.px { width: 44px; height: 44px; }
img.ico.px.big { width: 64px; height: 64px; }
.node-px { image-rendering: pixelated; }
.node.unknown .node-px { opacity: .5; }
