/* HUD styling. Deliberately restrained: thin rules, wide letter-spacing,
   bone-white on near-black, so the UI reads as carved rather than painted. */

:root {
  --ink: #f6f1e6;
  --dim: #d2c9b6;
  --faint: #a89f8e;
  --gold: #e0c078;
  --blood: #b8443a;
  --hp: #cfd8de;
  --sta: #7a8f6a;
  --rune: #7fd4e0;
  --panel: rgba(6, 8, 9, 0.72);
  --panel-deep: rgba(4, 6, 7, 0.82);
  --line: rgba(206, 196, 174, 0.32);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Inter", "Segoe UI", system-ui, sans-serif;
  /* Hard outline + soft so type stays legible on bright grass/sky. */
  --shadow:
    0 0 1px #000,
    0 1px 0 #000,
    0 -1px 0 #000,
    1px 0 0 #000,
    -1px 0 0 #000,
    0 2px 10px rgba(0, 0, 0, 0.95),
    0 0 18px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #07090a; color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

#view {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
  /* Stop browser image drag / "Save as" affordances on the WebGL canvas. */
  -webkit-user-select: none; user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
}

#hud {
  position: fixed; inset: 0; pointer-events: none;
  font-size: 14px; font-weight: 500; user-select: none;
  text-shadow: var(--shadow);
}
#hud button { pointer-events: auto; }

/* ------------------------------------------------------- placement debug */

.roster-modal[hidden] { display: none !important; }
.roster-modal {
  position: fixed; inset: 0; z-index: 25; display: grid; place-items: center;
  background: rgba(3, 5, 6, 0.58); backdrop-filter: blur(2px);
  pointer-events: auto; font-family: var(--sans); text-shadow: none;
}
.roster-card {
  width: min(760px, calc(100vw - 32px)); max-height: min(620px, calc(100vh - 48px));
  overflow: hidden; border: 1px solid var(--line); background: rgba(7, 10, 11, .96);
  box-shadow: 0 24px 80px rgba(0,0,0,.7); color: var(--ink);
}
.roster-head { display: flex; justify-content: space-between; align-items: center;
  padding: 18px 22px; border-bottom: 1px solid var(--line); }
.roster-head b { display: block; color: var(--gold); font: 16px var(--serif); letter-spacing: .22em; }
.roster-head small { color: var(--faint); font-size: 10px; letter-spacing: .12em; }
.roster-head span { color: var(--faint); font-size: 9px; letter-spacing: .14em; }
.roster-list { overflow-y: auto; max-height: 520px; padding: 8px; }
.roster-row { display: grid; grid-template-columns: 42px minmax(150px, 1fr) 58px 180px;
  align-items: center; gap: 12px; padding: 8px 12px; border-bottom: 1px solid rgba(206,196,174,.1); }
.roster-row:hover { background: rgba(201,163,92,.08); }
.roster-icon { width: 36px; height: 36px; display: grid; place-items: center; overflow: hidden;
  border: 1px solid rgba(201,163,92,.45); background: #141718; color: var(--gold); font-size: 20px; }
.roster-icon canvas { width: 100%; height: 100%; image-rendering: auto; }
.roster-info b { display: block; font-size: 12px; letter-spacing: .08em; }
.roster-info small { display: block; color: var(--faint); font-size: 10px; margin-top: 2px; }
.roster-level { color: var(--gold); font-size: 10px; font-weight: 800; }
.roster-zone { color: var(--dim); font-size: 10px; letter-spacing: .08em; text-align: right; }
.roster-empty { padding: 28px; color: var(--faint); text-align: center; font-style: italic; }

.placement-debug {
  position: fixed; z-index: 20; top: 18px; left: 50%;
  transform: translateX(-50%); width: min(620px, calc(100vw - 32px));
  padding: 10px 14px; border: 1px solid var(--gold);
  background: rgba(8, 10, 10, 0.9); color: var(--ink);
  font: 11px var(--sans); letter-spacing: 0.06em;
  pointer-events: none; user-select: text;
}
.placement-debug b { color: var(--gold); margin-right: 12px; }
.placement-debug .placement-status { color: var(--dim); }
.placement-debug code {
  display: block; margin-top: 7px; color: #e8c979; white-space: normal;
  overflow-wrap: anywhere; letter-spacing: 0;
}
.placement-debug small { display: block; margin-top: 7px; color: var(--faint); }
.gear-edit {
  position: fixed; z-index: 45; top: 12px; left: 50%;
  transform: translateX(-50%); width: min(640px, calc(100vw - 24px));
  padding: 10px 12px 12px; border: 1px solid var(--gold);
  background: rgba(8, 10, 10, 0.94); color: var(--ink);
  font: 11px var(--sans); letter-spacing: 0.04em;
}
.gear-head { display: flex; gap: 10px; align-items: baseline; }
.gear-edit b { color: var(--gold); }
.gear-edit .placement-status { color: var(--dim); }
.gear-edit code {
  display: block; margin: 8px 0; color: #e8c979; white-space: normal;
  overflow-wrap: anywhere; letter-spacing: 0;
}
.gear-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.gear-edit button {
  all: unset; cursor: pointer; padding: 7px 10px;
  border: 1px solid var(--line); color: var(--ink); background: #101416;
}
.gear-edit button:hover { border-color: var(--gold); color: var(--gold); }
.gear-edit small { display: block; margin-top: 8px; color: var(--faint); }

/* ---------------------------------------------------------------- rail */

.rail {
  position: absolute; top: 0; left: 0; right: 0;
  height: 54px;
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px 0 12px;
  background: linear-gradient(180deg,
    rgba(4, 6, 7, 0.94) 0%, rgba(4, 6, 7, 0.72) 72%, transparent 100%);
  border-bottom: 1px solid rgba(206, 196, 174, 0.1);
  z-index: 5;
}
.rail-portrait {
  all: unset; cursor: pointer; pointer-events: auto;
  position: relative; flex: none;
  width: 38px; height: 38px;
  display: grid; place-items: center; overflow: hidden;
  border: 1px solid rgba(201, 163, 92, 0.4);
  background: radial-gradient(circle at 40% 35%, #1a1e20, #080a0b);
  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.65);
  transition: border-color 0.14s, box-shadow 0.14s;
}
.rail-portrait:hover {
  border-color: var(--gold);
  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.55), 0 0 14px rgba(201, 163, 92, 0.2);
}
.rail-portrait canvas {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
.rail-portrait .sigil-fallback {
  font-family: var(--serif); font-size: 18px; color: var(--gold);
  text-shadow: 0 0 12px rgba(201, 163, 92, 0.45); z-index: 0;
}
.rail-id {
  display: flex; align-items: baseline; gap: 10px; flex: none;
}
.rail-name {
  font-family: var(--serif); font-size: 16px; font-weight: 700;
  letter-spacing: 0.14em; color: var(--ink); line-height: 1;
}
.rail-lv {
  font-size: 10px; font-weight: 800; letter-spacing: 0.12em;
  color: var(--dim);
  border: 1px solid rgba(206, 196, 174, 0.28);
  padding: 3px 8px; background: rgba(0, 0, 0, 0.45);
}
.rail-lv b { color: var(--gold); margin-left: 2px; }
.rail-sep {
  width: 1px; height: 22px; flex: none;
  background: rgba(206, 196, 174, 0.22);
}
.rail-bars {
  display: flex; flex-direction: column; gap: 4px; flex: none;
}
.bar {
  position: relative;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(206, 196, 174, 0.28);
  overflow: hidden;
}
.bar i {
  position: absolute; inset: 0; right: auto; display: block; height: 100%;
  transition: width 0.12s linear; z-index: 1;
}
.bar.hp { width: 168px; height: 7px; }
.bar.hp i {
  background: linear-gradient(180deg, #d8e2e8 0%, #a8b8c4 45%, #8a9aaa 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.bar.hp i.ghost {
  background: rgba(184, 68, 58, 0.45); z-index: 0;
  transition: width 0.5s ease-out;
}
.bar.sta { width: 110px; height: 4px; }
.bar.sta i {
  background: linear-gradient(180deg, #9aaf88 0%, #6a7f5a 50%, #4d6141 100%);
}
.rail-hpnum {
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  color: var(--faint); font-variant-numeric: tabular-nums; flex: none;
}
.rail-tag {
  font-size: 9px; letter-spacing: 0.16em; font-weight: 800;
  color: var(--gold); flex: none;
  max-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rail-sub {
  font-size: 11px; color: var(--faint); font-style: italic;
  letter-spacing: 0.04em; flex: none;
  max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rail-meta {
  margin-left: auto;
  display: flex; align-items: center; gap: 12px; flex: none;
  font-size: 11px; letter-spacing: 0.08em; color: var(--dim); font-weight: 600;
}
.rail-area {
  font-family: var(--serif); font-size: 14px; letter-spacing: 0.16em;
  color: var(--ink); font-weight: 700;
}
.rail-explored b { color: var(--ink); font-weight: 700; }
.rail-tool {
  all: unset; cursor: pointer; pointer-events: auto; flex: none;
  color: var(--faint);
  border: 1px solid rgba(206, 196, 174, 0.22);
  padding: 5px 7px; background: rgba(0, 0, 0, 0.35);
  transition: color 0.12s, border-color 0.12s, background 0.12s;
  display: grid; place-items: center;
}
.rail-tool:hover {
  color: var(--ink); border-color: rgba(201, 163, 92, 0.45);
}
.look-btn .look-icon {
  width: 18px; height: 18px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linejoin: round;
}
.look-btn .look-left,
.look-btn .look-right {
  fill: transparent;
  stroke: none;
  transition: fill 0.12s;
}
.look-btn .look-split {
  stroke: currentColor;
  stroke-width: 1.2;
  opacity: 0.55;
}
/* Free-lock: left button lit */
.look-btn.lock .look-left { fill: rgba(231, 226, 214, 0.55); }
/* RMB orbit: right button gold */
.look-btn.rmb {
  color: var(--ink);
  border-color: rgba(201, 163, 92, 0.5);
  background: rgba(201, 163, 92, 0.12);
}
.look-btn.rmb .look-right { fill: var(--gold); }
.look-btn.rmb .look-body { stroke: var(--gold); }

/* -------------------------------------------------------------- compass */

.compass {
  position: absolute; top: 56px; right: 16px; text-align: center;
  z-index: 4;
}
.map-ornament {
  position: relative; display: inline-block; padding: 0;
}
.dial {
  position: relative; width: 177px; height: 177px;
  border-radius: 50%; overflow: visible;
  border: 1px solid rgba(201, 163, 92, 0.4);
  background: #0a0d0f;
  box-shadow: inset 0 0 28px rgba(0, 0, 0, 0.85), 0 6px 20px rgba(0, 0, 0, 0.4);
}
.dial canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border-radius: 50%; image-rendering: auto; opacity: 0.92;
}
.dial .ring {
  position: absolute; inset: 9px; border-radius: 50%;
  border: 1px dashed rgba(201, 163, 92, 0.2);
  pointer-events: none;
}
.dial .cards {
  position: absolute; inset: 0; pointer-events: none;
}
.dial .card {
  position: absolute; font-size: 8px; letter-spacing: 0.08em;
  color: var(--faint); pointer-events: none; font-weight: 700;
}
.dial .n { top: 6px; left: 50%; transform: translateX(-50%); }
.dial .s { bottom: 6px; left: 50%; transform: translateX(-50%); }
.dial .e { right: 8px; top: 50%; transform: translateY(-50%); }
.dial .w { left: 8px; top: 50%; transform: translateY(-50%); }
.map-zoom {
  position: absolute; left: 50%; bottom: 14px; z-index: 3;
  transform: translateX(-50%);
  display: flex; gap: 3px; pointer-events: auto;
}
.map-zoom button {
  all: unset; cursor: pointer; width: 21px; height: 19px; display: grid;
  place-items: center; border: 1px solid rgba(231, 210, 145, 0.8);
  border-radius: 2px; background: rgba(4, 6, 7, 0.92); color: var(--ink); font-size: 16px;
  font-weight: 800;
  line-height: 1; text-shadow: none;
}
.map-zoom button:hover { color: var(--gold); border-color: var(--gold); background: rgba(45, 35, 15, 0.95); }
.dial .cone {
  position: absolute; left: 50%; top: 50%; width: 78px; height: 78px;
  margin: -39px 0 0 -39px; pointer-events: none;
  background: conic-gradient(from -22deg,
    rgba(231, 226, 214, 0.26), rgba(231, 226, 214, 0) 44deg);
  border-radius: 50%;
}
.compass .place { margin-bottom: 4px; padding: 0; background: none; border: none; }
.compass .place .area {
  font-family: var(--serif); font-size: 13px; letter-spacing: 0.16em;
  font-weight: 700; color: var(--ink);
}
.compass .coords {
  font-size: 10px; color: var(--faint); letter-spacing: 0.08em; margin-top: 2px;
  font-variant-numeric: tabular-nums; font-weight: 600;
}

/* --------------------------------------------------------------- thread */

.thread {
  position: absolute; top: 68px; left: 18px;
  max-width: 280px; text-align: left;
  padding: 0; background: none; border: none;
  z-index: 4;
}
.thread-lab {
  font-size: 8px; letter-spacing: 0.32em; color: var(--gold); font-weight: 800;
}
.thread-rule {
  margin: 6px 0 8px; width: 48px; height: 1px;
  background: linear-gradient(90deg, var(--gold), transparent);
}
.thread-title {
  font-family: var(--serif); font-size: 12px; letter-spacing: 0.1em;
  font-weight: 700; color: var(--dim); margin-bottom: 6px;
}
.thread-cur {
  font-family: var(--serif); font-size: 15px; font-weight: 600;
  letter-spacing: 0.04em; color: var(--ink); line-height: 1.3;
}
.thread-cur .obj-mark {
  color: var(--gold); font-size: 9px; margin-right: 4px; vertical-align: 1px;
}
.thread-cur .obj-count {
  margin-left: 8px; font-family: var(--sans); font-size: 11px;
  color: var(--dim); font-weight: 700; letter-spacing: 0.06em;
}
.thread-cur.done { color: var(--faint); text-decoration: line-through; }
.thread-rest {
  list-style: none; margin: 8px 0 0; padding: 0;
}
.thread-rest li {
  font-size: 11px; color: var(--faint); letter-spacing: 0.03em;
  padding: 2px 0; font-weight: 600; line-height: 1.45;
}
.thread-rest li.done { text-decoration: line-through; opacity: 0.75; }
.thread-rest li span {
  color: var(--dim); font-variant-numeric: tabular-nums; font-weight: 700;
}

/* -------------------------------------------------------------- bottom */

.bottom {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: flex-end; gap: 16px;
  padding: 0; background: none; border: none;
  z-index: 5;
}
.abilities { display: flex; gap: 12px; align-items: flex-end; }
.ab {
  all: unset; cursor: pointer; pointer-events: auto;
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  width: 48px;
}
.ab .orb {
  position: relative;
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid rgba(206, 196, 174, 0.3);
  background: radial-gradient(circle at 35% 30%, rgba(32, 36, 38, 0.98), rgba(4, 6, 7, 0.96));
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45), inset 0 0 14px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ab .orb-glyph {
  width: 20px; height: 20px;
  fill: none; stroke: var(--ink); stroke-width: 1.8;
  stroke-linecap: round; opacity: 0.95;
  position: relative; z-index: 1;
}
.ab .cd {
  position: absolute; left: 0; right: 0; bottom: 0; height: 0;
  background: rgba(6, 8, 9, 0.78); pointer-events: none; z-index: 2;
  border-radius: 0 0 50% 50%;
}
.ab.ready .orb {
  border-color: rgba(201, 163, 92, 0.55);
  box-shadow:
    0 0 18px rgba(201, 163, 92, 0.2),
    0 4px 16px rgba(0, 0, 0, 0.4),
    inset 0 0 12px rgba(0, 0, 0, 0.4);
}
.ab.ready:hover .orb {
  box-shadow:
    0 0 24px rgba(201, 163, 92, 0.32),
    0 4px 16px rgba(0, 0, 0, 0.4);
}
.ab:not(.ready) .orb-glyph { opacity: 0.4; }
.ab .key {
  position: absolute; bottom: -1px; right: 0;
  width: 16px; height: 16px;
  display: grid; place-items: center;
  font-size: 9px; font-weight: 800; color: var(--ink);
  border: 1px solid rgba(206, 196, 174, 0.35);
  border-radius: 50%;
  background: #0a0c0d;
  z-index: 3;
  letter-spacing: 0;
}

.xp-ring {
  position: relative;
  width: 40px; height: 40px; flex: none;
  margin-bottom: 2px;
}
.xp-ring svg {
  width: 100%; height: 100%;
  transform: rotate(-90deg);
  display: block;
}
.xp-ring .xp-track {
  stroke: rgba(206, 196, 174, 0.15);
  stroke-width: 3;
}
.xp-ring .xp-fill {
  stroke: var(--gold);
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dasharray 0.25s ease;
}
.xp-ring .xp-lab {
  position: absolute; left: 0; right: 0; top: 11px;
  text-align: center;
  font-size: 8px; font-weight: 800; letter-spacing: 0.08em;
  color: var(--gold); pointer-events: none;
}
.xp-ring .xp-num {
  position: absolute; left: 50%; top: 100%;
  transform: translateX(-50%);
  margin-top: 2px;
  font-size: 9px; font-weight: 700; letter-spacing: 0.04em;
  color: var(--faint); font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ------------------------------------------------------- world-space bits */

.dmg {
  position: absolute; left: 0; top: 0; display: none;
  font-family: var(--serif); font-size: 19px; font-weight: 600;
  color: #f0ece2; text-shadow: 0 2px 6px #000, 0 0 12px rgba(0, 0, 0, 0.9);
  letter-spacing: 0.02em; will-change: transform, opacity;
}
.dmg.crit { font-size: 27px; color: #ffd98a; }
.dmg.player { color: #ff8878; }
.dmg.heal { color: #a8e0a0; }

.plate {
  position: absolute; left: 0; top: 0; display: none; text-align: center;
  transform-origin: 50% 100%;
}
.plate .pn {
  font-size: 10px; letter-spacing: 0.14em; color: #d8d2c4;
  text-shadow: 0 1px 5px #000; margin-bottom: 3px; white-space: nowrap;
}
.plate .pb {
  width: 74px; height: 3px; background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(0, 0, 0, 0.8); margin: 0 auto;
}
.plate .pb i {
  display: block; height: 100%; background: #b8443a;
  transition: width 0.14s linear;
}
.plate.elite .pn { color: #ffbf8a; letter-spacing: 0.18em; }
.plate.elite .pb { width: 104px; height: 4px; }
.plate.elite .pb i { background: #e0663a; }

/* Player name tags above hero heads (local + multiplayer). */
.ptag {
  position: absolute; left: 0; top: 0; display: none; text-align: center;
  pointer-events: none; transform-origin: 50% 100%;
  z-index: 6;
  will-change: transform;
}
/* Remotes show only a slim HP bar; names live in right-click examine. */
.ptag.bare .ptag-name { display: none; }
.ptag-name {
  display: inline-block;
  font-size: 12px; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: #f0ebe0;
  background: rgba(4, 6, 7, 0.72); border: 1px solid rgba(206, 196, 174, 0.28);
  padding: 3px 10px; white-space: nowrap;
  text-shadow: 0 1px 3px #000, 0 0 8px rgba(0, 0, 0, 0.85);
}
.ptag.npc .ptag-name {
  color: #f0d58a;
  border: 0;
  border-bottom: 1px solid rgba(201, 163, 92, 0.75);
  background: transparent;
  padding: 2px 5px 1px;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-shadow: 0 1px 4px #000, 0 0 10px rgba(0, 0, 0, 0.95);
}
.ptag.npc .ptag-name::before {
  content: "☁";
  display: block;
  width: 17px;
  height: 14px;
  margin: 0 auto 2px;
  border: 1px solid #f0d58a;
  border-radius: 7px 7px 7px 2px;
  background: rgba(28, 21, 10, 0.9);
  color: #f0d58a;
  font-size: 10px;
  line-height: 13px;
  text-shadow: none;
}
.ptag.me .ptag-name {
  color: var(--gold);
  border-color: rgba(201, 163, 92, 0.5);
  background: rgba(4, 6, 7, 0.78);
}
.ptag-bar {
  width: 56px; height: 3px; margin: 3px auto 0;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(206, 196, 174, 0.28);
}
.ptag-bar i {
  display: block; height: 100%; width: 100%;
  background: #cfd8de;
}

/* World-chat bubbles above speakers' heads while chat is closed. */
.bubble {
  position: absolute; left: 0; top: 0; display: none; text-align: center;
  pointer-events: none; transform-origin: 50% 100%;
  z-index: 6; will-change: transform;
  animation: bubble-fade 0.18s ease-out;
}
/* Fade in place above the speaker — no travel. */
@keyframes bubble-fade {
  from { opacity: 0; }
}
.bubble-name {
  display: block;
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--gold);
  margin-bottom: 2px;
  text-shadow: 0 1px 3px #000, 0 0 8px rgba(0, 0, 0, 0.85);
}
.bubble-text {
  display: inline-block; max-width: 280px;
  font-size: 12.5px; line-height: 1.3; color: #f0ebe0;
  background: rgba(4, 6, 7, 0.8); border: 1px solid rgba(206, 196, 174, 0.3);
  border-radius: 4px; padding: 4px 9px; white-space: normal;
  text-align: left;
  text-shadow: 0 1px 3px #000;
}
.dmg.xp { color: #e0c078; font-size: 16px; }

.interact {
  position: absolute; bottom: 100px; left: 50%; transform: translateX(-50%);
  font-size: 12.5px; letter-spacing: 0.1em; color: var(--ink); font-weight: 600;
  background: rgba(6, 8, 9, 0.82); border: 1px solid rgba(201, 163, 92, 0.35);
  padding: 8px 16px; opacity: 0; transition: opacity 0.18s;
  display: flex; align-items: center; gap: 8px;
}
.interact.on { opacity: 1; }
.interact kbd {
  display: inline-block;
  padding: 2px 7px; border: 1px solid rgba(201, 163, 92, 0.45);
  color: var(--gold); font-size: 10px; font-weight: 800;
  font-family: inherit; letter-spacing: 0.08em;
}

.toast {
  position: absolute; top: 68px; left: 50%; transform: translateX(-50%);
  font-family: var(--serif); font-size: 16px; letter-spacing: 0.05em;
  color: var(--ink); font-weight: 600; text-shadow: var(--shadow);
  background: rgba(6, 8, 9, 0.72); border-left: 2px solid var(--gold);
  padding: 9px 20px; opacity: 0; transition: opacity 0.3s;
  max-width: 640px; text-align: center;
  z-index: 6;
}
.toast.on { opacity: 1; }

/* ------------------------------------------------------- examine / rmb */
.hover-hint {
  position: absolute; bottom: 154px; left: 50%; transform: translateX(-50%);
  font-family: var(--serif); font-size: 12px; letter-spacing: 0.14em;
  color: var(--gold); font-weight: 700; text-shadow: var(--shadow);
  background: rgba(6, 8, 9, 0.72); border: 1px solid rgba(201, 163, 92, 0.3);
  padding: 4px 14px; pointer-events: none; z-index: 7;
}
.examine-card {
  position: absolute; bottom: 132px; left: 50%; transform: translateX(-50%);
  width: min(430px, 78vw); text-align: center; pointer-events: none; z-index: 7;
  background: rgba(6, 8, 9, 0.88); border: 1px solid var(--line);
  border-top: 2px solid var(--gold);
  padding: 12px 20px 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  transition: opacity 0.45s;
}
.examine-card b {
  display: block; font-family: var(--serif); font-size: 15px;
  letter-spacing: 0.2em; color: var(--gold); font-weight: 700; margin-bottom: 6px;
}
.examine-card span {
  display: block; font-size: 12.5px; line-height: 1.45; letter-spacing: 0.04em;
  color: var(--dim); font-style: italic;
}
.examine-card.fade-out { opacity: 0; }
.dialogue {
  position: absolute; bottom: 132px; left: 50%; transform: translateX(-50%);
  width: min(560px, 92vw); z-index: 7; cursor: pointer;
  display: flex; align-items: center; gap: 16px;
  background: rgba(6, 8, 9, 0.92); border: 1px solid var(--line);
  border-top: 2px solid var(--gold);
  padding: 14px 18px 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  transition: opacity 0.3s;
}
.dialogue[hidden] { display: none; }
.dlg-face { flex: none; width: 96px; text-align: center; }
.dlg-face canvas {
  width: 96px; height: 96px; border-radius: 50%;
  border: 1px solid rgba(201, 163, 92, 0.5);
  background: #101416;
  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.6);
}
.dlg-face b {
  display: block; margin-top: 6px;
  font-size: 9px; letter-spacing: 0.18em; color: var(--gold); font-weight: 800;
}
.dlg-body { flex: 1; min-width: 0; }
.dlg-line {
  font-family: var(--serif); font-size: 15px; line-height: 1.5;
  letter-spacing: 0.04em; color: var(--ink);
}
.dlg-hint {
  margin-top: 9px; font-size: 9px; letter-spacing: 0.2em;
  color: var(--faint); text-transform: uppercase;
}
.dialogue.player-line .dlg-face { order: 2; }
.dialogue.player-line .dlg-body { order: 1; text-align: right; }
.ctxmenu {
  position: fixed; z-index: 40; min-width: 180px; max-width: 220px;
  padding: 5px; border: 1px solid var(--line); border-top: 2px solid var(--gold);
  background: rgba(4, 6, 7, 0.95); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}
.ctxmenu[hidden] { display: none; }
.ctx-row {
  all: unset; cursor: pointer; display: block; width: 100%;
  box-sizing: border-box; text-align: left;
  font-size: 11px; letter-spacing: 0.1em; color: var(--dim);
  padding: 7px 12px; border-radius: 2px;
}
.ctx-row:hover { background: rgba(201, 163, 92, 0.12); color: var(--ink); }
.ctx-row.npc { color: #e0c078; }
.ctx-row.examine { color: var(--dim); }
.ctx-row.loot { color: #7fd4e0; }

.vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center,
    rgba(0, 0, 0, 0) 42%, rgba(0, 0, 0, 0.55) 100%);
}
.hurt {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center,
    rgba(120, 20, 12, 0) 35%, rgba(150, 26, 16, 0.55) 100%);
}
.fade {
  position: absolute; inset: 0; background: #05070800; pointer-events: none;
  background: #050708; opacity: 0;
}

.dead {
  position: absolute; inset: 0; display: grid; place-content: center;
  text-align: center; opacity: 0; transition: opacity 0.6s;
  background: rgba(4, 5, 6, 0.55);
}
.dead.on { opacity: 1; }
.dead h2 {
  font-family: var(--serif); font-size: 52px; letter-spacing: 0.24em;
  margin: 0; color: #c8bfae; font-weight: 400;
}
.dead p { font-size: 12px; color: var(--dim); letter-spacing: 0.12em; }
.dead b { color: var(--ink); }

/* ------------------------------------------------------------ loading */

#loading {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 40%, #101617, #05070800), #050708;
  transition: opacity 0.7s ease;
}
#loading.gone { opacity: 0; pointer-events: none; }
#loading .box { width: min(560px, 88vw); text-align: center; }
#loading .rune-mark {
  display: block; width: min(320px, 72vw); height: auto; object-fit: contain;
  margin: 0 auto 2px; filter: drop-shadow(0 18px 26px rgba(0,0,0,.75))
    drop-shadow(0 0 24px rgba(179,90,34,.2));
}
#loading h1 {
  font-family: var(--serif); font-weight: 400; font-size: 34px;
  letter-spacing: 0.34em; margin: 6px 0 10px;
}
#loading .tagline {
  font-size: 11.5px; color: var(--dim); letter-spacing: 0.06em;
  line-height: 1.7; margin: 0 auto 22px; max-width: 420px; font-style: italic;
}
#loading .track {
  height: 2px; background: rgba(255, 255, 255, 0.08); position: relative;
}
#loading .track i {
  position: absolute; left: 0; top: 0; height: 100%; width: 0;
  background: var(--gold); transition: width 0.2s;
}
#loadlabel {
  font-size: 10px; color: var(--faint); letter-spacing: 0.2em;
  margin: 12px 0 26px;
}
#loading .keys {
  list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap;
  gap: 6px 14px; justify-content: center;
  font-size: 9.5px; color: var(--faint); letter-spacing: 0.12em;
}
#loading .keys b { color: var(--dim); font-weight: 500; }

#stats {
  position: fixed; right: 16px; bottom: 14px; font-size: 10px;
  color: var(--dim); letter-spacing: 0.1em; font-variant-numeric: tabular-nums;
  display: none; pointer-events: none;
  z-index: 12; text-align: right;
}
#stats.on { display: block; }

@media (max-width: 900px) {
  .rail-sub, .rail-tag { display: none; }
  .bar.hp { width: 120px; }
  .bar.sta { width: 80px; }
  .abilities { gap: 8px; }
  .ab { width: 42px; }
  .ab .orb { width: 40px; height: 40px; }
  .thread { max-width: 200px; }
  .dial { width: 144px; height: 144px; }
}

/* ---------------------------------------------------------------- chat */
/* Side log — left gutter, gold edge, no heavy box. Expands on focus. */

.chat {
  --chat-alpha: 0.72;
  position: fixed;
  left: 16px;
  bottom: 18px;
  width: min(460px, calc(100vw - 32px));
  z-index: 14;
  display: flex;
  flex-direction: column;
  pointer-events: none;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 550;
  color: var(--ink);
  text-shadow: 0 1px 2px #000, 0 0 8px rgba(0, 0, 0, 0.75);
  user-select: none;
}
.chat.focus,
.chat:hover { pointer-events: auto; }

.chat-shell {
  pointer-events: auto;
  border: 1px solid rgba(206, 196, 174, 0.22);
  border-left: 2px solid rgba(201, 163, 92, 0.65);
  border-radius: 3px;
  background: linear-gradient(135deg,
    rgba(4, 6, 7, calc(var(--chat-alpha) * 0.94)),
    rgba(8, 12, 14, calc(var(--chat-alpha) * 0.78)));
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  padding: 8px 10px 9px;
}

.chat-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
  opacity: 0.55;
  transition: opacity 0.15s;
}
.chat:hover .chat-head,
.chat.focus .chat-head { opacity: 1; }

.chat-tabs { display: flex; gap: 4px; min-width: 0; flex: 1; }
.chat-tab {
  all: unset;
  cursor: pointer;
  position: relative;
  padding: 5px 9px;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 800;
  border: 1px solid transparent;
}
.chat-tab:hover { color: var(--dim); }
.chat-tab.on {
  color: var(--ink);
  border-color: rgba(201, 163, 92, 0.35);
  background: rgba(0, 0, 0, 0.25);
}
.chat-badge[hidden] { display: none !important; }
.chat-badge {
  display: inline-grid;
  place-items: center;
  min-width: 13px;
  height: 13px;
  margin-left: 3px;
  padding: 0 3px;
  font-size: 8px;
  letter-spacing: 0;
  font-style: normal;
  font-weight: 800;
  color: #0a0c0d;
  background: var(--gold);
  border-radius: 7px;
  vertical-align: 1px;
}

.chat-tools { display: flex; align-items: center; gap: 2px; flex: none; }
.chat-icon {
  all: unset;
  cursor: pointer;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  color: var(--faint);
  font-size: 11px;
  font-weight: 700;
}
.chat-icon:hover { color: var(--ink); }
.chat-op {
  display: flex;
  align-items: center;
  opacity: 0.4;
}
.chat:hover .chat-op,
.chat.focus .chat-op { opacity: 1; }
.chat-op input[type="range"] {
  width: 44px;
  height: 3px;
  accent-color: var(--gold);
  cursor: pointer;
}

.chat-log {
  height: 92px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 4px 4px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(201, 163, 92, 0.25) transparent;
  mask-image: linear-gradient(180deg, transparent 0%, #000 12%, #000 100%);
}
.chat.focus .chat-log {
  height: min(36vh, 220px);
  mask-image: none;
}
.chat-log::-webkit-scrollbar { width: 4px; }
.chat-log::-webkit-scrollbar-thumb {
  background: rgba(201, 163, 92, 0.3);
  border-radius: 2px;
}

.chat-empty {
  color: var(--faint);
  font-size: 11px;
  letter-spacing: 0.03em;
  font-style: italic;
  padding: 6px 0;
  line-height: 1.4;
}

.chat-line {
  display: block;
  line-height: 1.4;
  margin: 0 0 3px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.chat-line:last-child { margin-bottom: 0; }
.chat-ts {
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.03em;
  margin-right: 5px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  opacity: 0.7;
}
.chat-lv {
  display: inline-block;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--gold);
  margin-right: 4px;
  vertical-align: 1px;
  opacity: 0.85;
}
.chat-name {
  all: unset;
  cursor: pointer;
  color: #e8d9a8;
  font-weight: 700;
  letter-spacing: 0.03em;
  pointer-events: auto;
}
.chat-name:hover {
  color: var(--gold);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.chat-body { color: var(--dim); font-weight: 500; }
.chat-line.sys .chat-body {
  color: #9ec8d4;
  font-style: italic;
}
.chat-line.sys .chat-body::before {
  content: "◆ ";
  color: var(--rune);
  font-style: normal;
  font-size: 8px;
}
.chat-line.help .chat-body {
  color: var(--dim);
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 10.5px;
  letter-spacing: 0;
  white-space: pre-wrap;
}
.chat-line.err .chat-body { color: #e08878; }
.chat-line.wh .chat-body { color: #d8c4e8; }
.chat-wh-tag {
  color: #b894d4;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  margin-right: 3px;
}

.chat-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding: 4px 0 0;
  border-top: 1px solid rgba(206, 196, 174, 0.1);
  opacity: 0.7;
  transition: opacity 0.15s;
}
.chat.focus .chat-foot { opacity: 1; }
.chat-prefix {
  flex: none;
  max-width: 38%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #b894d4;
}
.chat-prefix[hidden] { display: none !important; }
.chat-input {
  flex: 1;
  min-width: 0;
  all: unset;
  width: 100%;
  font: inherit;
  font-size: 12px;
  font-weight: 550;
  color: var(--ink);
  letter-spacing: 0.02em;
  caret-color: var(--gold);
}
.chat-input:focus { color: var(--ink); }
.chat-input::placeholder {
  color: var(--faint);
  font-style: italic;
  letter-spacing: 0.03em;
  font-size: 11px;
}

.chat-minbar {
  display: none;
  pointer-events: auto;
  cursor: pointer;
  align-items: center;
  gap: 8px;
  padding: 6px 0 6px 10px;
  border-left: 2px solid rgba(201, 163, 92, 0.4);
  background: linear-gradient(90deg, rgba(4, 6, 7, 0.7), transparent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--dim);
}
.chat-minbar:hover { color: var(--ink); }
.chat-minbar .mark {
  width: 5px; height: 5px; background: var(--gold);
  box-shadow: 0 0 6px rgba(201, 163, 92, 0.5);
}
.chat.min .chat-shell { display: none; }
.chat.min .chat-minbar { display: inline-flex; }
.chat.min { width: auto; }

.chat-menu {
  position: fixed;
  z-index: 40;
  width: 168px;
  padding: 6px;
  background: rgba(8, 10, 11, 0.96);
  border: 1px solid rgba(206, 196, 174, 0.35);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  gap: 2px;
  pointer-events: auto;
  font-family: var(--sans);
  text-shadow: none;
}
.chat-menu-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px 8px;
  border-bottom: 1px solid rgba(206, 196, 174, 0.15);
  margin-bottom: 4px;
}
.chat-menu-head b {
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--ink);
  text-transform: uppercase;
}
.chat-menu-head span {
  font-size: 10px;
  color: var(--gold);
  letter-spacing: 0.1em;
  font-weight: 700;
}
.chat-menu button {
  all: unset;
  cursor: pointer;
  padding: 7px 10px;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--dim);
  font-weight: 600;
}
.chat-menu button:hover {
  color: var(--ink);
  background: rgba(201, 163, 92, 0.12);
}

@media (max-width: 900px) {
  .chat {
    width: min(420px, calc(100vw - 20px));
    left: 10px;
    bottom: 18px;
  }
  .chat-log { height: 82px; }
  .chat.focus .chat-log { height: min(30vh, 190px); }
  .chat-op { display: none; }
}

/* ------------------------------------------------------------- creator */
/* Same visual language as the HUD: thin rules, wide tracking, bone on
   near-black, gold only as an accent. The world stays visible behind it. */

.creator {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center;
  background: rgba(4, 6, 7, 0.82);
  backdrop-filter: blur(3px);
  opacity: 0; transition: opacity 0.32s ease;
  font-family: var(--sans); color: var(--ink);
}
.creator.on { opacity: 1; }

.cr-frame {
  width: min(1180px, 95vw); max-height: 92vh; display: flex;
  flex-direction: column; gap: 18px;
  border: 1px solid var(--line); background: rgba(7, 9, 10, 0.92);
  padding: 22px 26px 26px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7), inset 0 0 60px rgba(0, 0, 0, 0.5);
}

.cr-frame header { display: flex; align-items: center; gap: 16px; }
.cr-frame header .rune {
  font-family: var(--serif); font-size: 34px; color: var(--gold);
  text-shadow: 0 0 22px rgba(201, 163, 92, 0.35);
  width: 56px; height: 56px; display: grid; place-items: center;
  border: 1px solid var(--line); flex: none;
}
.cr-frame h1 {
  margin: 0; font-family: var(--serif); font-weight: 400; font-size: 25px;
  letter-spacing: 0.26em;
}
.cr-frame .sub {
  margin: 4px 0 0; font-size: 11px; color: var(--dim);
  letter-spacing: 0.1em; font-style: italic;
}

.cr-body {
  display: grid; grid-template-columns: 1fr 320px 260px; gap: 22px;
  min-height: 0;
}

/* --- trait picker --- */
.cr-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.cr-tabs button {
  all: unset; cursor: pointer; padding: 5px 11px; font-size: 9.5px;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--dim);
  border: 1px solid var(--line); background: rgba(0, 0, 0, 0.35);
}
.cr-tabs button:hover { color: var(--ink); }
.cr-tabs button.on {
  color: #0a0c0d; background: var(--gold); border-color: var(--gold);
}

.cr-options {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  gap: 8px; overflow-y: auto; max-height: 54vh; padding-right: 8px;
  align-content: start;
}
.cr-options::-webkit-scrollbar { width: 8px; }
.cr-options::-webkit-scrollbar-thumb { background: rgba(201, 163, 92, 0.28); }

.cr-tile {
  all: unset; cursor: pointer; position: relative; display: block;
  border: 1px solid var(--line); background: #0e1113; padding: 0;
  transition: border-color 0.12s, transform 0.12s;
}
.cr-tile img {
  display: block; width: 100%; aspect-ratio: 1; object-fit: cover;
  image-rendering: pixelated;
}
.cr-tile .x {
  display: grid; place-items: center; aspect-ratio: 1; font-size: 22px;
  color: var(--faint);
}
.cr-tile em {
  display: block; font-style: normal; font-size: 8px; color: var(--faint);
  letter-spacing: 0.06em; padding: 3px 4px; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cr-tile:hover { border-color: rgba(201, 163, 92, 0.5); transform: translateY(-1px); }
.cr-tile:hover em { color: var(--dim); }
.cr-tile.on { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.cr-tile.on em { color: var(--ink); }

.cr-owned {
  all: unset; cursor: pointer; display: block; border: 1px solid var(--line);
  background: #0e1113;
}
.cr-owned img {
  display: block; width: 100%; aspect-ratio: 1; image-rendering: pixelated;
}
.cr-owned .noimg {
  display: grid; place-items: center; aspect-ratio: 1; color: var(--faint);
  font-size: 24px;
}
.cr-owned em {
  display: block; font-style: normal; font-size: 9px; color: var(--dim);
  padding: 4px; text-align: center; letter-spacing: 0.06em;
}
.cr-owned.on { border-color: var(--gold); }

/* --- previews --- */
.cr-mid { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.cr-portrait {
  border: 1px solid var(--line); padding: 8px; background: #07090a;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.7);
}
.cr-portrait canvas {
  display: block; width: 292px; height: 292px; image-rendering: pixelated;
}
.cr-shieldwrap { text-align: center; }
.cr-shieldwrap span {
  display: block; margin-top: 8px; font-size: 9px; color: var(--faint);
  letter-spacing: 0.18em; text-transform: uppercase;
}
.cr-shield {
  width: 152px; height: 152px; border-radius: 50%; overflow: hidden;
  margin: 0 auto; border: 3px solid #2e3238;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.6), inset 0 0 20px rgba(0, 0, 0, 0.5);
}
.cr-shield canvas {
  display: block; width: 100%; height: 100%; image-rendering: pixelated;
}

/* --- right column --- */
.cr-right { display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.cr-field span {
  display: block; font-size: 9px; letter-spacing: 0.24em; color: var(--gold);
  margin-bottom: 6px;
}
.cr-field input {
  width: 100%; box-sizing: border-box; background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--line); color: var(--ink); padding: 9px 11px;
  font-family: var(--serif); font-size: 17px; letter-spacing: 0.1em;
}
.cr-field input:focus { outline: none; border-color: var(--gold); }

.cr-summary { flex: 1; overflow-y: auto; min-height: 0; }
.cr-summary ul { list-style: none; margin: 0; padding: 0; }
.cr-summary li {
  display: flex; justify-content: space-between; gap: 10px; padding: 4px 0;
  font-size: 10px; border-bottom: 1px solid rgba(206, 196, 174, 0.08);
}
.cr-summary span { color: var(--faint); letter-spacing: 0.16em; text-transform: uppercase; }
.cr-summary b { color: var(--ink); font-weight: 500; text-align: right; }

.cr-actions { display: flex; flex-direction: column; gap: 8px; }
.cr-btn {
  all: unset; cursor: pointer; text-align: center; padding: 11px;
  font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase;
  border: 1px solid var(--line); transition: all 0.14s;
}
.cr-btn.ghost { color: var(--dim); }
.cr-btn.ghost:hover { color: var(--ink); border-color: rgba(201, 163, 92, 0.5); }
.cr-btn.go {
  background: var(--gold); border-color: var(--gold); color: #0a0c0d;
  font-weight: 600;
}
.cr-btn.go:hover { filter: brightness(1.12); }
.cr-note { margin: 0; font-size: 10px; color: var(--blood); min-height: 1.2em; }

@media (max-width: 1080px) {
  .cr-body { grid-template-columns: 1fr 240px; }
  .cr-right { grid-column: 1 / -1; }
  .cr-portrait canvas { width: 210px; height: 210px; }
}

/* ---- appearance panel -------------------------------- */

.appear {
  position: fixed; inset: 0; z-index: 40; display: flex; align-items: stretch;
  justify-content: flex-end; background: transparent;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.appear.on { opacity: 1; pointer-events: none; }
.appear.on .ap-frame { pointer-events: auto; }
.ap-frame {
  width: min(360px, 92vw); height: 100%; overflow: auto;
  background: rgba(7, 9, 10, 0.92);
  border-left: 1px solid var(--line); padding: 22px 22px 18px;
}
.ap-frame header {
  display: flex; gap: 14px; align-items: center; margin-bottom: 18px;
}
.ap-frame .rune { font-size: 28px; color: var(--gold); }
.ap-frame h1 {
  margin: 0; font-size: 16px; letter-spacing: 0.18em; color: var(--gold);
  font-weight: 600;
}
.ap-frame .sub { margin: 4px 0 0; font-size: 11px; color: var(--dim); }
.ap-body { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.ap-row {
  display: grid; grid-template-columns: 72px 1fr 72px; gap: 10px;
  align-items: center; font-size: 12px; color: var(--ink);
}
.ap-row span { letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); }
.ap-row input[type="color"] {
  width: 100%; height: 32px; border: 1px solid var(--line);
  background: #0a0c0d; cursor: pointer; padding: 2px;
}
.ap-row code { font-size: 11px; color: var(--dim); text-align: right; }
.ap-row.ap-toggle { grid-template-columns: 72px 1fr; }
.ap-picks { display: flex; gap: 6px; flex-wrap: wrap; }
.ap-picks button {
  all: unset; cursor: pointer; padding: 6px 10px; font-size: 11px;
  letter-spacing: 0.12em; text-transform: uppercase;
  border: 1px solid var(--line); color: var(--dim);
}
.ap-picks button.on {
  color: #0a0c0d; background: var(--gold); border-color: var(--gold);
}
.ap-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.ap-btn {
  all: unset; cursor: pointer; padding: 9px 14px; font-size: 11px;
  letter-spacing: 0.16em; text-transform: uppercase; border: 1px solid var(--line);
}
.ap-btn.ghost { color: var(--dim); }
.ap-btn.ghost:hover { color: var(--ink); border-color: rgba(201, 163, 92, 0.5); }
.ap-btn.go {
  background: var(--gold); border-color: var(--gold); color: #0a0c0d; font-weight: 600;
}

/* ------------------------------------------------------- wallet overlay */

#wallet {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  overflow: auto; color: var(--ink);
  background: radial-gradient(circle at 14% 16%, rgba(61, 118, 98, .22), transparent 29%),
    radial-gradient(circle at 84% 85%, rgba(151, 70, 28, .2), transparent 32%),
    repeating-linear-gradient(118deg, transparent 0 92px, rgba(255,255,255,.012) 93px 94px), #050708;
}
#wallet .box {
  display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(290px, .8fr);
  width: min(1050px, 94vw); min-height: 590px; overflow: hidden;
  background: linear-gradient(145deg, rgba(29, 35, 34, .98), rgba(7, 9, 10, .98) 45%, rgba(3, 5, 6, .98));
  box-shadow: 0 34px 90px rgba(0,0,0,.82), 0 8px 18px rgba(0,0,0,.72),
    inset 2px 2px 0 rgba(255,237,194,.12), inset -3px -3px 0 rgba(0,0,0,.62),
    inset 0 0 70px rgba(0,0,0,.3);
}
.wl-world { position: relative; padding: 34px 34px 28px;
  background: linear-gradient(145deg, rgba(33, 47, 43, .75), rgba(9, 13, 14, .7));
  box-shadow: inset -18px 0 32px rgba(0,0,0,.35), inset 2px 2px 0 rgba(255,255,255,.035); }
.wl-world::before { content: "KOSARVICK · WHERE SAGAS BEGIN"; position: absolute; top: 14px; right: 22px;
  color: rgba(224,192,120,.6); font-size: 8px; letter-spacing: .2em; }
.wl-kicker { color: var(--gold); font-size: 9px; letter-spacing: .25em; margin-bottom: 20px; }
.wl-title-row { display: block; }
.wl-logo { display: block; width: min(350px, 76%); height: auto; object-fit: contain; margin: -14px auto -8px;
  filter: drop-shadow(0 18px 22px rgba(0,0,0,.68)) drop-shadow(0 0 18px rgba(179,90,34,.16)); }
#wallet h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(34px, 5vw, 58px);
  line-height: .86; letter-spacing: .13em; margin: 0; }
#wallet h1 em { color: var(--gold); font-style: normal; letter-spacing: .22em; }
.wl-deck { max-width: 350px; margin: 15px 0 0; color: var(--dim); font: italic 13px/1.55 var(--serif); }
.wl-reel { display: grid; grid-template-columns: 1.1fr .72fr 1fr; gap: 8px; height: 220px; margin: 34px 0 20px; }
.wl-shot { position: relative; overflow: hidden; margin: 0; background: #111;
  box-shadow: 0 8px 14px rgba(0,0,0,.52), inset 2px 2px 0 rgba(255,238,198,.13),
    inset -2px -2px 0 rgba(0,0,0,.72); }
.wl-shot::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(0,0,0,.6)); pointer-events: none; }
.wl-shot img { width: 100%; height: 100%; display: block; object-fit: cover; filter: saturate(.84) contrast(1.05); transition: transform .4s, filter .4s; }
.wl-shot:hover img { transform: scale(1.045); filter: saturate(1) contrast(1.08); }
.wl-shot.tall img { object-position: 50% 50%; }
.wl-notes { display: flex; flex-wrap: wrap; gap: 10px 22px; color: var(--faint); font-size: 9px; letter-spacing: .1em; }
.wl-notes b { color: var(--ink); font-size: 8px; margin-right: 4px; }
.wl-gate { display: flex; flex-direction: column; justify-content: center; padding: 42px 36px;
  background: linear-gradient(150deg, rgba(18,20,20,.82), rgba(4,6,7,.78));
  box-shadow: inset 16px 0 28px rgba(0,0,0,.3), inset -2px -2px 0 rgba(0,0,0,.52); }
.wl-step[hidden] { display: none; }
.wl-step { animation: wl-rise .28s ease both; }
@keyframes wl-rise { from { opacity: 0; transform: translateY(8px); } }
.wl-gate-mark { color: var(--gold); font-size: 10px; letter-spacing: .28em; margin-bottom: 18px; }
#wallet .tagline { font-size: 13px; color: var(--dim); letter-spacing: .03em; line-height: 1.65;
  margin: 0 0 30px; font-style: italic; }
#wallet .wl-actions { display: flex; flex-direction: column; gap: 10px; margin: 0 0 18px; }
#wallet .wl-btn { all: unset; cursor: pointer; position: relative; display: grid; grid-template-columns: 1fr auto;
  gap: 5px 10px; min-height: 44px; padding: 15px 16px; transition: all .16s;
  background: linear-gradient(145deg, rgba(49,52,48,.56), rgba(17,19,19,.76));
  box-shadow: 0 6px 10px rgba(0,0,0,.42), inset 1px 1px 0 rgba(255,238,195,.14),
    inset -2px -2px 0 rgba(0,0,0,.62); }
#wallet .wl-btn b { color: var(--ink); font-size: 14px; letter-spacing: .13em; text-transform: uppercase; }
#wallet .wl-btn span { grid-column: 1; color: var(--faint); font-size: 9px; letter-spacing: .08em; }
#wallet .wl-btn .wl-rec { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
#wallet .wl-rec { font-style: normal; font-size: 8px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold);
  padding: 5px 7px; background: linear-gradient(#3a3020, #19150f);
  box-shadow: 0 3px 5px rgba(0,0,0,.48), inset 1px 1px 0 rgba(255,222,151,.2), inset -1px -1px 0 #080706; }
#wallet .wl-btn:hover:not(:disabled) { transform: translateY(-2px); color: #fff4d5;
  background: linear-gradient(145deg, rgba(74,66,48,.68), rgba(24,24,21,.82));
  box-shadow: 0 9px 15px rgba(0,0,0,.5), inset 1px 1px 0 rgba(255,235,187,.2), inset -2px -2px 0 rgba(0,0,0,.7); }
#wallet .wl-btn:active:not(:disabled) { transform: translateY(1px); box-shadow: 0 2px 4px rgba(0,0,0,.55),
  inset 2px 2px 5px rgba(0,0,0,.58), inset -1px -1px 0 rgba(255,235,187,.08); }
#wallet .wl-btn:disabled { opacity: .4; cursor: not-allowed; }
#wallet .wl-path:first-child { background: linear-gradient(145deg, rgba(91,68,36,.65), rgba(29,25,19,.82));
  box-shadow: 0 7px 12px rgba(0,0,0,.48), inset 1px 1px 0 rgba(255,218,146,.22), inset -2px -2px 0 rgba(0,0,0,.68); }
#wallet .wl-status { min-height: 1.4em; font-size: 10.5px; color: var(--blood); letter-spacing: .08em; margin: 0 0 14px; }
#wallet .wl-cancel { all: unset; cursor: pointer; color: var(--faint); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; }
#wallet .wl-cancel:hover { color: var(--dim); }
.wl-back { all: unset; cursor: pointer; display: block; color: var(--faint); font-size: 9px; letter-spacing: .12em;
  text-transform: uppercase; margin: 0 0 30px; }
.wl-back:hover { color: var(--gold); }
.wl-mobile-help { margin: 2px 0 18px; padding: 12px 14px;
  color: var(--dim); background: linear-gradient(145deg, rgba(65,105,90,.18), rgba(20,28,26,.12));
  box-shadow: 0 5px 9px rgba(0,0,0,.32), inset 2px 2px 0 rgba(171,216,199,.09),
    inset -2px -2px 0 rgba(0,0,0,.45); font-size: 10px; line-height: 1.55; }
.wl-mobile-help[hidden] { display: none; }
.wl-mobile-help b { display: block; color: #a9c9bd; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 4px; }
.wl-mobile-help em { color: var(--ink); font-style: normal; }
.wl-foot { margin: 40px 0 0; color: #77786f; font-size: 9px; line-height: 1.6; letter-spacing: .05em; }
@media (max-width: 760px) {
  #wallet { padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
      max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); align-items: start; }
  #wallet .box { grid-template-columns: 1fr; min-height: calc(100dvh - 16px); width: 100%; }
  .wl-world { padding: 24px 18px 16px; box-shadow: inset 0 -14px 24px rgba(0,0,0,.4), inset 2px 2px 0 rgba(255,255,255,.035); }
  .wl-world::before { display: none; }
  .wl-kicker { margin-bottom: 13px; font-size: 8px; }
  .wl-logo { width: min(260px, 78vw); margin: -12px auto -12px; }
  #wallet h1 { font-size: clamp(31px, 10vw, 44px); }
  .wl-deck { font-size: 11px; margin-top: 9px; }
  .wl-reel { height: 112px; margin: 18px 0 13px; gap: 5px; }
  .wl-notes { gap: 6px 12px; font-size: 8px; }
  .wl-gate { justify-content: flex-start; padding: 25px 20px max(28px, env(safe-area-inset-bottom)); }
  #wallet .tagline { margin-bottom: 20px; font-size: 12px; }
  #wallet .wl-btn { min-height: 48px; padding: 13px 14px; }
  #wallet .wl-btn:hover:not(:disabled) { transform: none; }
  .wl-back { margin-bottom: 22px; min-height: 28px; }
  .wl-foot { margin-top: 20px; }
}
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (max-width: 430px), (max-height: 680px) {
  .wl-reel { display: none; }
  .wl-notes { margin-top: 14px; }
}

/* ------------------------------------------------------- settings */
.settings-panel {
  pointer-events: auto;
  position: absolute; z-index: 8; top: 58px; right: 14px; width: 245px;
  padding: 15px 17px; border: 1px solid var(--line);
  background: var(--panel-deep); box-shadow: 0 8px 28px rgba(0,0,0,.55);
  letter-spacing: .08em;
}
.settings-head { display: flex; justify-content: space-between; color: var(--gold);
  font-size: 11px; letter-spacing: .2em; margin-bottom: 14px; }
.settings-head button { all: unset; cursor: pointer; color: var(--dim); font-size: 19px;
  line-height: 10px; }
.settings-panel label { display: flex; justify-content: space-between; align-items: center;
  gap: 12px; color: var(--dim); font-size: 11px; margin: 12px 0; }
.settings-panel input { accent-color: var(--gold); width: 125px; }
.settings-panel .settings-check { align-items: center; }
.settings-panel .settings-check input { width: 15px; height: 15px; }
.settings-disconnect {
  all: unset; cursor: pointer; display: block; width: 100%; margin: 16px 0 12px;
  padding-top: 11px; border-top: 1px solid rgba(206,196,174,.12);
  color: var(--blood); font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
}
.settings-disconnect:hover { color: #e08878; }
.settings-panel small { display: block; color: var(--faint); font-size: 9px; line-height: 1.4; }

/* ------------------------------------------------------- hero menu */
.hero-menu-btn {
  all: unset; cursor: pointer; pointer-events: auto;
  position: absolute; z-index: 6; bottom: 18px; right: 18px;
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid rgba(206, 196, 174, 0.3);
  background: radial-gradient(circle at 35% 30%, rgba(32, 36, 38, 0.98), rgba(4, 6, 7, 0.96));
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45), inset 0 0 14px rgba(0, 0, 0, 0.5);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.hero-menu-btn:hover {
  border-color: rgba(201, 163, 92, 0.55);
  box-shadow: 0 0 18px rgba(201, 163, 92, 0.2), 0 4px 16px rgba(0, 0, 0, 0.4);
}
.hero-menu-diamond {
  width: 13px; height: 13px; transform: rotate(45deg);
  border: 1.5px solid var(--gold); border-radius: 2px;
  background: rgba(201, 163, 92, 0.14);
}
.hero-panel {
  pointer-events: auto;
  position: absolute; z-index: 8; bottom: 76px; right: 16px; width: 258px;
  height: 304px; display: flex; flex-direction: column;
  padding: 14px 16px 16px; border: 1px solid var(--line);
  background: var(--panel-deep); box-shadow: 0 8px 28px rgba(0, 0, 0, .55);
  letter-spacing: .08em;
}
.hero-panel[hidden] { display: none; }
.hero-head {
  display: flex; justify-content: center;
  border-bottom: 1px solid rgba(206, 196, 174, .12); padding-bottom: 10px;
  margin-bottom: 10px;
}
.hero-tabs { display: flex; gap: 18px; }
.hero-tab {
  all: unset; cursor: pointer; pointer-events: auto;
  font-size: 10px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--faint); font-weight: 700; padding-bottom: 3px;
  border-bottom: 1px solid transparent;
}
.hero-tab:hover { color: var(--dim); }
.hero-tab.active { color: var(--gold); border-bottom-color: var(--gold); }
.hero-pane { display: none; }
.hero-pane.active {
  display: flex; flex-direction: column; flex: 1; min-height: 0;
}
.hero-footer {
  margin-top: auto; padding-top: 10px;
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 9.5px; letter-spacing: .1em; color: var(--faint);
  text-transform: uppercase;
}
.hero-footer b {
  display: block; color: var(--gold); font-size: 11px;
  font-variant-numeric: tabular-nums; margin-top: 2px;
}
.skill-grid { display: flex; gap: 6px; }
.skill-tile {
  all: unset; cursor: pointer; pointer-events: auto; position: relative;
  width: 40px; height: 48px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; border: 1px solid rgba(206, 196, 174, 0.3); border-radius: 4px;
  background: radial-gradient(circle at 35% 30%, rgba(32, 36, 38, 0.98), rgba(4, 6, 7, 0.96));
  transition: border-color 0.15s, box-shadow 0.15s;
}
.skill-tile:hover {
  border-color: rgba(201, 163, 92, 0.55);
  box-shadow: 0 0 14px rgba(201, 163, 92, 0.18);
}
.skill-tile svg {
  width: 18px; height: 18px; fill: none; stroke: var(--gold);
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.skill-tile b { font-size: 8px; letter-spacing: .08em; color: var(--faint); font-weight: 700; }
.skill-tip {
  display: none; position: absolute; bottom: calc(100% + 10px); left: 50%;
  transform: translateX(-50%); width: 150px; padding: 9px 11px; z-index: 20;
  background: var(--panel-deep); border: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55); text-align: left;
}
.skill-tile:hover .skill-tip, .gear-slot:hover .skill-tip { display: block; }
.skill-tip .tip-name {
  display: block; font-family: var(--serif); font-size: 12px;
  letter-spacing: .14em; color: var(--gold); margin-bottom: 6px;
}
.tip-row {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 9.5px; letter-spacing: .1em; color: var(--faint);
  text-transform: uppercase; margin-top: 3px;
}
.tip-row i {
  font-style: normal; color: var(--ink); font-variant-numeric: tabular-nums;
}
.bag-grid {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(5, 1fr); gap: 6px;
}
.bag-slot {
  border: 1px dashed rgba(206, 196, 174, 0.28); border-radius: 3px;
  background: rgba(7, 10, 11, 0.5); min-height: 24px;
  display: grid; place-content: center; gap: 2px; text-align: center;
  color: var(--ink); font-size: 9px; letter-spacing: .08em;
}
.bag-slot.filled {
  border-style: solid; border-color: rgba(201, 163, 92, 0.45);
  background: rgba(32, 28, 18, 0.72);
}
.bag-slot b { font-size: 9px; color: #d8c49a; }
.bag-slot i { font-style: normal; color: var(--faint); font-variant-numeric: tabular-nums; }
.gear-grid {
  flex: 1; display: grid; align-content: center; justify-content: center;
  grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(4, 46px);
  gap: 8px;
  grid-template-areas:
    ". head ."
    "weapon chest shield"
    ". legs ."
    ". feet .";
}
.gear-slot {
  all: unset; cursor: pointer; position: relative; display: grid; place-items: center;
  border: 1px dashed rgba(206, 196, 174, 0.32); border-radius: 4px;
  background: rgba(7, 10, 11, 0.5);
  transition: border-color 0.15s, background 0.15s;
}
.gear-slot:hover {
  border-color: rgba(201, 163, 92, 0.55);
  background: rgba(32, 36, 38, 0.9);
  box-shadow: 0 0 14px rgba(201, 163, 92, 0.18);
}
.gear-head { grid-area: head; }
.gear-weapon { grid-area: weapon; }
.gear-chest { grid-area: chest; }
.gear-shield { grid-area: shield; }
.gear-legs { grid-area: legs; }
.gear-feet { grid-area: feet; }

@media (max-width: 700px) {
  .hero-panel { width: min(calc(100vw - 32px), 258px); }
}

@media (max-width: 700px) {
  .roster-row { grid-template-columns: 38px minmax(0, 1fr) 48px; gap: 8px; }
  .roster-zone { grid-column: 2 / -1; text-align: left; font-size: 9px; }
  .roster-head { padding: 14px; }
}
/* Zone markup editor ------------------------------------------------------ */
#map-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  cursor: crosshair;
  touch-action: none;
}
#map-editor {
  position: fixed;
  z-index: 31;
  top: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100vw - 24px);
  padding: 9px 11px;
  color: #f8e5bd;
  background: rgba(25, 17, 13, .94);
  border: 1px solid #9b7043;
  box-shadow: 0 5px 24px rgba(0, 0, 0, .4);
  font: 12px/1.2 sans-serif;
}
#map-editor strong { letter-spacing: .12em; margin-right: 4px; }
#map-editor button, #map-editor select, #map-editor input { font: inherit; }
#map-editor button, #map-editor select { color: #f8e5bd; background: #3a2619; border: 1px solid #8b6037; padding: 4px 6px; }
#map-editor button:hover { background: #6a4222; }
#map-editor input[type="range"] { width: 70px; }
#map-editor #map-asset { max-width: 130px; }
#map-editor small { opacity: .75; margin-left: 5px; }
@media (max-width: 760px) {
  #map-editor { flex-wrap: wrap; }
  #map-editor small { width: 100%; }
}

/* Unified world editor ---------------------------------------------------- */
.world-editor-open { overflow: hidden; }
#world-editor {
  --we-bg: rgba(19, 22, 20, .97);
  --we-panel: rgba(28, 32, 28, .96);
  --we-line: #596657;
  --we-gold: #d3a75f;
  --we-ink: #f1eadb;
  --we-muted: #a8b0a4;
  position: fixed; inset: 0; z-index: 50; pointer-events: none;
  color: var(--we-ink); font: 13px/1.3 system-ui, sans-serif;
}
#world-editor button, #world-editor input, #world-editor select { font: inherit; }
#world-editor button, #world-editor select, #world-editor input[type="search"],
#world-editor input[type="number"], #world-editor input[type="text"] {
  color: var(--we-ink); background: #242a24; border: 1px solid var(--we-line);
  border-radius: 3px; padding: 7px 9px;
}
#world-editor button { cursor: pointer; }
#world-editor button:hover, #world-editor button.active { border-color: var(--we-gold); background: #3c3526; }
#world-editor .danger { color: #ef9a8f; }
.we-topbar, .we-assets, .we-inspector, .we-help { pointer-events: auto; }
.we-topbar {
  position: absolute; inset: 0 0 auto 0; min-height: 48px; display: flex; align-items: center;
  gap: 7px; padding: 7px 12px; box-sizing: border-box; background: var(--we-bg);
  border-bottom: 1px solid var(--we-line); box-shadow: 0 4px 18px #0007;
}
.we-topbar strong { color: var(--we-gold); letter-spacing: .13em; white-space: nowrap; }
.we-topbar label { display: flex; align-items: center; gap: 5px; color: var(--we-muted); white-space: nowrap; }
.we-modes { display: flex; gap: 4px; margin-right: auto; }
#we-save { border-color: var(--we-gold) !important; }
#we-play { color: #b9efb4 !important; border-color: #59855b !important; }
#we-save-state { min-width: 92px; color: #9bcf99; font-size: 11px; }
#we-save-state.dirty { color: #efc27a; }
#we-save-state.inspect { color: #9ab0c4; }
#world-editor button:disabled { opacity: .38; cursor: not-allowed; }
.we-snap { color: #839080; font-size: 10px; white-space: nowrap; }
.we-assets, .we-inspector {
  position: absolute; top: 63px; bottom: 45px; width: 230px; box-sizing: border-box;
  padding: 13px; overflow: auto; background: var(--we-panel); border: 1px solid var(--we-line);
  box-shadow: 0 6px 24px #0007;
}
.we-assets { left: 12px; width: 250px; }
.we-inspector { right: 12px; width: 250px; }
.we-assets h2, .we-inspector h2 { margin: 0 0 10px; color: var(--we-gold); font-size: 14px; letter-spacing: .12em; text-transform: uppercase; }
.we-assets p { color: var(--we-muted); font-size: 11px; }
#we-search { width: 100%; box-sizing: border-box; }
#we-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
#world-editor .we-chip { padding: 3px 9px; font-size: 11px; border-radius: 11px; background: #242a24; }
#world-editor .we-chip.active { background: var(--we-gold); color: #171a17; border-color: var(--we-gold); font-weight: 700; }
#we-recents {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin: 8px 0; padding: 7px; background: #141814; border: 1px dashed #3a443a;
  border-radius: 4px;
}
.we-recents-label { width: 100%; font-size: 9px; letter-spacing: .14em; text-transform: uppercase; color: var(--we-muted); }
#world-editor .we-recent {
  width: 40px; height: 40px; padding: 2px; display: grid; place-items: center;
  background: #242a24; font-size: 9px; color: var(--we-muted);
}
#world-editor .we-recent img { width: 100%; height: 100%; object-fit: contain; }
.we-asset-section { margin-bottom: 2px; }
#world-editor .we-asset-group {
  width: 100%; display: flex; align-items: center; gap: 6px;
  margin: 12px 0 6px; padding: 4px 6px; background: none; border: none;
  text-align: left; font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--we-muted);
}
#world-editor .we-asset-group:hover { background: #242a24; border-color: transparent; }
.we-group-arrow { width: 12px; flex: none; }
.we-asset-group em { font-style: normal; color: #6d7a6d; margin-left: auto; font-size: 9px; }
.we-asset-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; }
#world-editor .we-asset {
  display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 6px;
  text-align: left; background: #20251f;
}
#world-editor .we-asset:hover { border-color: var(--we-gold); }
.we-asset-thumb {
  width: 100%; aspect-ratio: 1; display: grid; place-items: center;
  border-radius: 4px; overflow: hidden;
  background: repeating-conic-gradient(#262d27 0% 25%, #1c211d 0% 50%) 0 0 / 16px 16px;
  color: #a89a77; font-size: 15px; font-weight: 800;
}
.we-asset-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.we-asset-name {
  font-size: 10.5px; color: var(--we-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.we-assets-empty { color: var(--we-muted); font-size: 11px; }
.we-inspector label { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin: 7px 0; color: var(--we-muted); }
.we-inspector input[type="number"], .we-inspector input[type="text"], #we-name { width: 78px; box-sizing: border-box; }
.we-inspector fieldset { margin: 10px 0; padding: 7px; border: 1px solid #465046; }
.we-inspector legend { color: var(--we-gold); font-size: 11px; }
.we-row { display: flex; gap: 5px; margin: 8px 0; }
.we-row button { flex: 1; }
.we-colors { margin-top: 12px !important; }
#we-palette, #we-wall-palette { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; margin: 5px 0 9px; }
#world-editor .we-swatch {
  width: 27px; height: 27px; padding: 0; border-radius: 50%;
  background: var(--swatch); border: 2px solid #20251f; box-shadow: 0 0 0 1px #667064;
}
#world-editor .we-swatch:hover { transform: scale(1.12); border-color: #f2ddae; background: var(--swatch); }
#world-editor input[type="color"] { width: 54px; height: 31px; padding: 2px; background: #242a24; border: 1px solid var(--we-line); }
#we-color-original, #we-wall-original { width: 100%; margin-top: 4px; }
#we-terrain select { width: 120px; }
#we-terrain input[type="range"] { width: 105px; }
.we-help {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); max-width: 720px;
  padding: 8px 14px; color: #e9dec7; background: #171b18ed; border: 1px solid var(--we-line);
  border-radius: 4px; text-align: center; box-shadow: 0 4px 16px #0007;
}
.we-toast {
  position: absolute; left: 50%; top: 72px; transform: translate(-50%, -12px); opacity: 0;
  padding: 9px 15px; color: #1b231b; background: #d4b374; border-radius: 3px;
  box-shadow: 0 5px 18px #0008; transition: .18s; pointer-events: none;
}
.we-toast.show { transform: translate(-50%, 0); opacity: 1; }
.we-minimap {
  position: absolute; left: 50%; bottom: 58px; width: 190px; height: 190px;
  transform: translateX(-50%); border-radius: 8px; overflow: hidden;
  border: 1px solid var(--we-line); background: #0d1110;
  box-shadow: 0 8px 26px #0008; pointer-events: auto;
}
.we-minimap canvas { width: 100%; height: 100%; display: block; cursor: pointer; }
.we-minimap-cam {
  position: absolute; left: 50%; top: 50%; width: 12px; height: 12px; margin: -6px;
  border-radius: 50%; background: #ffd27a; border: 2px solid #221a0e;
  box-shadow: 0 0 8px #ffd27a99; pointer-events: none;
}
.we-minimap-label {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 0;
  font-size: 10px; text-align: center; color: #cfd8e3; background: #0a0d0ba6;
  pointer-events: none;
}

@media (max-width: 900px) {
  .we-topbar { flex-wrap: wrap; }
  .we-topbar label, #we-camera, #we-redo, #we-save-state, .we-snap { display: none; }
  .we-modes { order: 2; width: 100%; }
  .we-modes button { flex: 1; padding: 6px 3px !important; }
  .we-assets { top: 100px; width: 165px; }
  .we-inspector { top: 100px; width: 190px; }
  .we-assets p { display: none; }
}

@media (max-width: 620px) {
  .we-assets { width: 122px; padding: 8px; }
  .we-inspector { width: 148px; padding: 8px; }
  .we-asset-grid { grid-template-columns: 1fr; }
  .we-asset { padding: 4px !important; }
  .we-asset-thumb { font-size: 12px; }
  .we-help { left: 132px; right: 158px; transform: none; font-size: 10px; }
}
