/* Willowmere: worn stone and bronze for everything you use, parchment for everything you read. */
:root {
  --bg: #050404;
  --ink: #050403;
  --stone-1: #100e0b;
  --stone-2: #191611;
  --stone-3: #252018;
  --line: #3a3224;
  --bronze-lo: #5a4c34;
  --bronze: #8f7a52;
  --bronze-hi: #c9ae7a;
  --gold: #d9b777;
  --gold-hi: #ffd100;
  --gold-lo: #5a4c34;
  --text: #d8cdb6;
  --muted: #92876f;
  --parch: #ecdcae;
  --parch-ink: #3b2410;
  --parch-muted: #7a5a34;
  --blood: #7a1a12;
  --red: #c8352c;
  --mp: #3a78d8;
  --cyan: #7fd4e8;
  --purple: #c8a8ff;
  --rare: #c98cf5;
  --green: #5fd65c;
  --r0: #c8c8c8;
  --r1: #38d934;
  --r2: #4d9fff;
  --r3: #b96cf5;
  --r4: #ff8c1a;
  --serif: 'Cinzel', 'Trajan Pro', Georgia, serif;
  --fancy: 'Cinzel Decorative', 'Cinzel', Georgia, serif;
  --caps: 'Alegreya SC', 'Cinzel', Georgia, serif;
  --body: 'Alegreya', Georgia, 'Times New Roman', serif;
  /* Sizes: window widths, spacing and type. */
  --win-sm: 430px;
  --win-md: 560px;
  --win-lg: 800px;
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --t-title: 21px;
  --t-head: 16px;
  --t-body: 16px;
  --t-small: 14px;
  /* Fine grain for stone and parchment. */
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.25 0 0 0 0 0.16 0 0 0 0 0.06 0 0 0 0.22 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  --stains: radial-gradient(ellipse at 18% 22%, rgba(150, 100, 40, 0.18), transparent 40%),
    radial-gradient(ellipse at 82% 76%, rgba(140, 90, 30, 0.2), transparent 45%),
    radial-gradient(ellipse at 70% 12%, rgba(255, 250, 230, 0.35), transparent 40%);
  /* The forged frame around every window: bronze edges, heavier riveted corners. */
  --frame: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='48' height='48' viewBox='0 0 48 48'><defs><linearGradient id='m' x1='0' y1='0' x2='1' y2='1'><stop offset='0' stop-color='%23c9ae7a'/><stop offset='.5' stop-color='%234f4330'/><stop offset='1' stop-color='%23967f55'/></linearGradient><g id='c'><path d='M.5 .5h13v5.5H6v7.5H.5z' fill='%23a8915f' stroke='%23000' stroke-width='.8'/><circle cx='3.2' cy='3.2' r='1.5' fill='%23f0dcaa' stroke='%23000' stroke-width='.5'/></g></defs><rect x='.5' y='.5' width='47' height='47' fill='none' stroke='%23000'/><rect x='3' y='3' width='42' height='42' fill='none' stroke='url(%23m)' stroke-width='4'/><rect x='5.5' y='5.5' width='37' height='37' fill='none' stroke='%23000'/><use xlink:href='%23c'/><use xlink:href='%23c' transform='translate(48 0) scale(-1 1)'/><use xlink:href='%23c' transform='translate(0 48) scale(1 -1)'/><use xlink:href='%23c' transform='translate(48 48) scale(-1 -1)'/></svg>");
}

* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: #6e5c3c transparent; }

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 17px;
}

.hidden { display: none !important; }
.gold { color: var(--gold); }
.muted { color: var(--muted); }
.legendary { color: var(--r4); }
.rare { color: var(--rare); }
.rarity-0 { color: var(--r0); }
.rarity-1 { color: var(--r1); }
.rarity-2 { color: var(--r2); }
.rarity-3 { color: var(--r3); }
.rarity-4 { color: var(--r4); }
.up { color: var(--green); }
.down { color: #ff6f61; }

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 700;
  margin: 0 0 12px;
  line-height: 1.2;
  letter-spacing: 0.04em;
}

#app {
  height: 100vh;
  height: 100dvh;
}

#stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}

#view {
  position: absolute;
  inset: 0;
  display: block;
  touch-action: none;
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='26' height='26'><path d='M3 2 L3 20 L8 15 L12 23 L15 21 L11 13 L18 13 Z' fill='%23f1d58a' stroke='%23140b05' stroke-width='2' stroke-linejoin='round'/></svg>") 3 2, default;
}
#view.aim-attack {
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='28' height='28'><path d='M4 4 L18 18 M15 21 L21 15 M19 19 L25 25' stroke='%23140b05' stroke-width='6' stroke-linecap='round'/><path d='M4 4 L18 18 M15 21 L21 15 M19 19 L25 25' stroke='%23e8e2d0' stroke-width='3' stroke-linecap='round'/><path d='M4 4 L9 4 M4 4 L4 9' stroke='%23e04848' stroke-width='3'/></svg>") 4 4, crosshair;
}
#view.aim-use {
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='26' height='26'><path d='M3 2 L3 20 L8 15 L12 23 L15 21 L11 13 L18 13 Z' fill='%23fff0b8' stroke='%23140b05' stroke-width='2' stroke-linejoin='round'/><circle cx='20' cy='6' r='4' fill='%23f7d046' stroke='%23140b05' stroke-width='1.5'/></svg>") 3 2, pointer;
}

/* ---------- framed stone panel (HUD) ---------- */
.panel {
  position: relative;
  background: var(--grain), linear-gradient(180deg, #1d1a14 0%, #0e0c09 100%);
  background-clip: border-box;
  border: 9px solid transparent;
  border-image: var(--frame) 15 / 9px stretch;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.6);
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
#hud > * { pointer-events: auto; }

#top-left {
  position: absolute;
  top: 10px;
  left: 10px;
  display: grid;
  gap: 8px;
  justify-items: start;
  pointer-events: none;
}
#top-left > * { pointer-events: auto; }

/* The hero's frame: a round portrait overlapping a plate with name and bars. */
#unit-frame {
  display: flex;
  align-items: center;
  width: 280px;
}
.portrait {
  position: relative;
  z-index: 1;
  flex: none;
  width: 78px;
  height: 78px;
  margin-right: -20px;
  border-radius: 50%;
  border: 4px solid transparent;
  background:
    radial-gradient(circle at 50% 35%, #4a3a2a, #0d0a07) padding-box,
    conic-gradient(from 210deg, #6e5c3c, #e0c88f, #4f4330, #c9ae7a, #3a3024, #967f55, #6e5c3c) border-box;
  box-shadow: 0 0 0 1px #000, inset 0 0 12px #000, 0 4px 10px rgba(0, 0, 0, 0.7);
  display: grid;
  place-items: center;
}
.portrait img {
  width: 58px;
  height: 58px;
  image-rendering: pixelated;
}
.lvl-badge {
  position: absolute;
  bottom: -5px;
  left: -5px;
  min-width: 27px;
  height: 27px;
  padding: 0 4px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-weight: 900;
  font-size: 13px;
  line-height: 1;
  color: var(--gold-hi);
  background: radial-gradient(circle at 40% 30%, #3a3024, #0b0907);
  border: 1px solid var(--bronze-hi);
  box-shadow: 0 0 0 1px #000;
  text-shadow: 0 1px 0 #000;
}
.uf-body {
  flex: 1;
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 1px 6px 1px 18px;
}
.uf-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.15;
}
.uf-name b {
  font-family: var(--caps);
  font-size: 16px;
  font-weight: 700;
  color: var(--gold-hi);
  text-shadow: 0 1px 1px #000;
}
.uf-name span { color: var(--muted); font-size: 14px; font-style: italic; margin-left: 4px; }
.uf-bar {
  position: relative;
  height: 14px;
  background: #060505;
  border: 1px solid #000;
  box-shadow: 0 0 0 1px var(--bronze-lo);
  overflow: hidden;
}
.uf-bar .fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  transition: width 0.25s ease-out;
}
.uf-bar.hp .fill { background: linear-gradient(#58d84f, #1f8a1c 60%, #0f5a10); }
.uf-bar.mp .fill { background: linear-gradient(#5a9af0, #2456c0 60%, #10307a); }
.uf-bar .text {
  position: relative;
  display: block;
  text-align: center;
  font-family: var(--serif);
  font-size: 10px;
  font-weight: 700;
  line-height: 12px;
  color: #fff;
  text-shadow: 0 1px 0 #000, 0 0 2px #000;
}
.uf-gold {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  line-height: 1.1;
}
.uf-gold img { width: 16px; height: 16px; image-rendering: pixelated; }
.uf-gold b { font-family: var(--serif); font-size: 13px; }

/* Buffs and ailments under the hero's frame. */
#buffs { display: flex; flex-wrap: wrap; gap: 4px; max-width: 280px; }
#buffs:empty { display: none; }
.buff {
  padding: 1px 7px;
  font-family: var(--caps);
  font-size: 13px;
  font-weight: 700;
  color: var(--c);
  background: rgba(8, 7, 6, 0.9);
  border: 1px solid var(--c);
  box-shadow: 0 0 5px color-mix(in srgb, var(--c) 35%, transparent);
  text-shadow: 0 1px 0 #000;
}
.buff b { color: #fff; margin-left: 3px; }
.buff.bad { animation: throb 0.8s infinite alternate; }
@keyframes throb { to { filter: brightness(1.4); } }

/* The party, under the hero's frame. */
#party-frames { display: grid; gap: 3px; width: 190px; margin-left: 12px; }
#party-frames:empty { display: none; }
.party-member {
  padding: 3px 7px 4px;
  background: rgba(8, 7, 6, 0.82);
  border: 1px solid var(--bronze-lo);
  box-shadow: 0 0 0 1px #000;
}
.party-member.away { opacity: 0.55; }
.party-member.down { filter: grayscale(1); }
.party-name { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; line-height: 1.15; }
.party-name b { font-family: var(--caps); font-size: 14px; color: var(--gold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.party-name small { font-family: var(--serif); font-size: 10px; color: var(--muted); white-space: nowrap; }
.party-where { display: block; font-size: 12px; font-style: italic; color: var(--muted); line-height: 1.1; }
.party-bar { height: 5px; margin-top: 2px; background: #060505; border: 1px solid #000; overflow: hidden; }
.party-bar i { display: block; height: 100%; transition: width 0.2s; }
.party-bar.hp i { background: linear-gradient(#58d84f, #1f8a1c); }
.party-bar.mp i { background: linear-gradient(#5a9af0, #2456c0); }
button.link.party-leave { justify-self: start; font-size: 12px; font-family: var(--body); color: var(--muted); text-shadow: 0 1px 1px #000; }

/* Top centre: boss / rare bar and the target frame. */
#top-center {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: min(430px, calc(100vw - 660px));
  min-width: 290px;
  display: grid;
  gap: 8px;
  justify-items: center;
  pointer-events: none;
}
#top-center > * { pointer-events: auto; }
#boss-bar {
  width: 100%;
  display: grid;
  gap: 3px;
  justify-items: center;
}
#bb-name {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 900;
  color: #ff9a5a;
  letter-spacing: 0.06em;
  text-shadow: 0 0 8px rgba(255, 80, 40, 0.6), 0 2px 0 #000, 0 0 2px #000;
}
.bb-track {
  width: 100%;
  height: 14px;
  background: #0a0404;
  border: 1px solid #000;
  box-shadow: 0 0 0 1px var(--bronze), inset 0 2px 6px #000, 0 4px 10px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
#bb-fill {
  height: 100%;
  background: linear-gradient(#e04a3a, #9a1a14 55%, #4a0808);
  transition: width 0.25s ease-out;
}
#boss-bar.rare #bb-name { color: var(--rare); text-shadow: 0 0 8px rgba(190, 110, 255, 0.7), 0 2px 0 #000, 0 0 2px #000; }
#boss-bar.rare #bb-fill { background: linear-gradient(#c88cf0, #7a30c0 55%, #2a0c50); }

#target-frame {
  width: 100%;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 1px 6px 1px 2px;
}
#tf-icon {
  width: 44px;
  height: 44px;
  image-rendering: pixelated;
  flex: none;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #3a2a20, #0d0a07);
  border: 2px solid var(--bronze);
  box-shadow: 0 0 0 1px #000;
}
.tf-body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.tf-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.15; }
.tf-name b { font-family: var(--caps); font-size: 16px; font-weight: 700; text-shadow: 0 1px 1px #000; }
.tf-name span { font-size: 13px; font-family: var(--serif); }
.tf-tags { margin: 0; font-size: 13px; line-height: 1.2; color: var(--muted); }
.tag {
  display: inline-block;
  margin: 1px 0 0 4px;
  padding: 0 5px;
  font-size: 12px;
  color: var(--text);
  background: #241f17;
  border: 1px solid #453a29;
}
.tag.boss { background: #5a1a14; border-color: #a8402a; }
.tag.elite { background: #5a4510; border-color: #b08a2a; }
.tag.rare { background: #3f1a5e; border-color: #9a5ad0; color: #f0dcff; }
.tag.frost { background: #1a4060; }
.tag.poison { background: #1a5024; }

.meter {
  position: relative;
  height: 14px;
  background: #0a0404;
  border: 1px solid #000;
  box-shadow: 0 0 0 1px var(--bronze-lo);
  overflow: hidden;
}
.meter .fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  transition: width 0.25s ease-out;
}
.meter .text {
  position: relative;
  display: block;
  text-align: center;
  font-family: var(--serif);
  font-size: 10px;
  font-weight: 700;
  line-height: 12px;
  color: #fff;
  text-shadow: 0 1px 0 #000, 0 0 2px #000;
}
.meter.hp .fill { background: linear-gradient(#d84a3a, #981c14 60%, #500808); }

/* Top right: the place's name, a round minimap with buttons on its ring, objectives. */
#top-right {
  position: absolute;
  top: 8px;
  right: 14px;
  width: 196px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  justify-items: center;
  pointer-events: none;
}
#top-right > * { pointer-events: auto; }
.where {
  margin: 0;
  max-width: 230px;
  font-family: var(--caps);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  color: var(--gold-hi);
  text-shadow: 0 1px 1px #000, 0 0 6px #000;
}
.mm-wrap { position: relative; width: 176px; height: 176px; }
.mm-ring {
  width: 100%;
  height: 100%;
  padding: 6px;
  border-radius: 50%;
  background: conic-gradient(from 210deg, #6e5c3c, #e0c88f, #4f4330, #c9ae7a, #3a3024, #967f55, #6e5c3c);
  box-shadow: 0 0 0 1px #000, 0 6px 14px rgba(0, 0, 0, 0.7);
}
#minimap {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #000, inset 0 0 12px #000;
  image-rendering: pixelated;
  background: #0b0910;
}
/* The buttons sit around the ring's lower left. */
.menu-buttons { position: absolute; inset: 0; pointer-events: none; }
.menu-buttons button.round { pointer-events: auto; position: absolute; transform: translate(-50%, -50%); }
/* The press nudge has to keep the centring, or the button jumps out from under the cursor. */
.menu-buttons button.round:active:not(:disabled) { transform: translate(-50%, calc(-50% + 1px)); }
.menu-buttons button.round:nth-child(1) { left: 73px; top: 177px; }
.menu-buttons button.round:nth-child(2) { left: 30px; top: 157px; }
.menu-buttons button.round:nth-child(3) { left: 3px; top: 120px; }
.menu-buttons button.round:nth-child(4) { left: -1px; top: 73px; }
.menu-buttons button.round:nth-child(5) { left: 19px; top: 30px; }
.menu-buttons button.round:nth-child(6) { left: 116px; top: 182px; }
button.round {
  position: relative;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-weight: 900;
  font-size: 16px;
  color: var(--gold);
  background: radial-gradient(circle at 50% 30%, #3a3024, #0b0907 75%);
  border: 2px solid var(--bronze);
  box-shadow: 0 0 0 1px #000, 0 3px 6px rgba(0, 0, 0, 0.7);
  text-shadow: 0 1px 0 #000;
}
button.round img { width: 22px; height: 22px; image-rendering: pixelated; }
button.round:hover:not(:disabled) { background: radial-gradient(circle at 50% 30%, #54462f, #15110c 75%); border-color: var(--bronze-hi); }

/* Objectives: plain words on the world, with no box around them. */
#tracker {
  justify-self: end;
  width: 272px;
  margin-top: 26px;
  padding: 8px 12px 12px 26px;
  text-shadow: 0 1px 0 #000, 0 0 4px #000;
  /* A soft backing, so the words hold up over the bright town ground. It fades out to the left. */
  background: linear-gradient(90deg, transparent, rgba(6, 5, 4, 0.72) 26px);
  pointer-events: none;
}
.tracker-head {
  font-family: var(--caps);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--gold-hi);
  padding-bottom: 5px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--bronze-lo);
}
#quest-tracker {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 14px;
  line-height: 1.25;
}
#quest-tracker li { font-family: var(--caps); font-weight: 700; font-size: 15px; color: var(--gold); }
/* What to do next: the line everything else is below. */
#quest-tracker li.q-next { color: #f4e3b8; }
.q-line { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.q-step { font-size: 13px; }
.q-step-done, .q-step-done small, .q-step-done b { color: var(--green) !important; }
.q-line b { flex: none; font-family: var(--serif); font-size: 13px; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }
#quest-tracker li small { display: block; margin-top: 3px; font-size: 13px; font-weight: 500; color: var(--text); }
.q-bar { height: 3px; margin-top: 6px; background: rgba(255, 255, 255, 0.13); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.7); overflow: hidden; }
.q-bar div { height: 100%; background: linear-gradient(90deg, #a8843f, var(--gold-hi)); }
#quest-tracker li.done,
#quest-tracker li.done .q-line b,
#quest-tracker li.done small { color: var(--green); }
#quest-tracker li.done .q-bar div { background: var(--green); }

/* Message log, beside the life globe, with the chat box under it. They stack, so the log can grow
   without ever covering the box. */
#log-box {
  position: absolute;
  left: 12px;
  bottom: 20px;
  width: clamp(240px, calc(50vw - 320px), 400px);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#log {
  max-height: 124px;
  cursor: pointer;
  transition: max-height 0.2s;
  padding: 6px 10px;
  overflow-y: auto;
  font-size: 15px;
  line-height: 1.2;
  background: linear-gradient(90deg, rgba(6, 5, 4, 0.72), rgba(6, 5, 4, 0.2));
  text-shadow: 0 1px 1px #000;
}
#log:not(.expanded) { -webkit-mask-image: linear-gradient(transparent, #000 16px); mask-image: linear-gradient(transparent, #000 16px); }
#log.expanded { max-height: 330px; background: rgba(6, 5, 4, 0.94); }
#chat-input { width: 100%; height: 38px; font-size: 15px; }
.line { color: #d0c6b2; }
.line:not(:nth-last-child(-n+4)) { opacity: 0.55; }
.line:last-child { animation: arrive 0.35s ease-out; }
.line.good { color: var(--green); }
.line.bad { color: #ff8a7a; }
.line.gold { color: var(--gold); }
.line.crit { color: #ffb347; }
.line.level { color: var(--cyan); }
.line.boss { color: #ff9f6b; }
.line.quest { color: var(--gold-hi); }
.line.rare { color: var(--rare); }
.line.rarity-0 { color: var(--r0); }
.line .count { color: var(--muted); }

@keyframes arrive {
  from { transform: translateX(-6px); filter: brightness(1.8); }
  to { transform: none; filter: none; }
}

#hud-hint {
  position: absolute;
  left: 50%;
  bottom: 136px;
  transform: translateX(-50%);
  margin: 0;
  max-width: 56vw;
  padding: 0 12px;
  text-align: center;
  font-family: var(--caps);
  font-weight: 700;
  font-size: 16px;
  color: var(--gold);
  text-shadow: 0 2px 0 #000, 0 0 6px #000;
  pointer-events: none;
}

/* ---------- life globe · skills and potions · mana globe ---------- */
#actionbar {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  width: max-content;
  display: flex;
  align-items: center;
  pointer-events: none;
}
#actionbar > * { pointer-events: auto; }
.bar-mid {
  position: relative;
  /* Its ends go behind the globes, far enough that the corners don't show around the curve. */
  margin: 0 -22px;
  padding: 5px 20px 9px;
  background: var(--grain), linear-gradient(180deg, #221d16, #0d0b08);
  background-clip: border-box;
  border: 9px solid transparent;
  border-image: var(--frame) 15 / 9px stretch;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.75);
}
.globe {
  position: relative;
  z-index: 1;
  flex: none;
  border-radius: 50%;
}
.orb {
  position: relative;
  width: 108px;
  height: 108px;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #1c0d0f, #050303);
  border: 4px solid var(--gold);
  box-shadow: 0 0 0 3px #0a0806, 0 0 0 5px var(--bronze), inset 0 0 16px #000, 0 8px 18px rgba(0, 0, 0, 0.7);
}
.orb-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 100%;
  transition: height 0.35s ease-out;
}
/* The liquid's surface. */
.orb-fill::before {
  content: '';
  position: absolute;
  top: -3px;
  left: -10%;
  right: -10%;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
}
.orb.hp .orb-fill { background: radial-gradient(circle at 35% 25%, #e8604f, #a81418 45%, #3a0408 100%); }
.orb.mp .orb-fill { background: radial-gradient(circle at 35% 25%, #6a9cf0, #1e4ab8 45%, #06103f 100%); }
.orb.hp.poisoned .orb-fill { background: radial-gradient(circle at 35% 25%, #a8e87a, #3a8a1e 45%, #0e3408 100%); }
.orb.low .orb-fill { animation: pulse 0.7s infinite alternate; }
.orb.shielded { border-color: #ffe066; box-shadow: 0 0 0 3px #0a0806, 0 0 0 5px var(--bronze), inset 0 0 16px #000, 0 0 18px rgba(255, 224, 102, 0.8); }
/* Glass highlight. */
.orb::after {
  content: '';
  position: absolute;
  top: 6%;
  left: 20%;
  width: 46%;
  height: 30%;
  border-radius: 50%;
  background: linear-gradient(rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0));
  transform: rotate(-20deg);
  pointer-events: none;
}
.orb-text {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  text-align: center;
  line-height: 1;
  color: #fff;
  text-shadow: 0 2px 0 #000, 0 0 4px #000;
  pointer-events: none;
}
.orb-text b { font-family: var(--serif); font-size: 21px; font-weight: 900; }
.orb-text b i { font-style: normal; font-size: 13px; color: #ffe066; margin-left: 2px; }
.orb-text small { font-family: var(--serif); font-size: 11px; opacity: 0.8; border-top: 1px solid rgba(255, 255, 255, 0.5); padding-top: 2px; margin-top: 2px; }

@keyframes pulse {
  from { filter: brightness(1); }
  to { filter: brightness(1.6); }
}

/* Experience: a thin segmented line along the screen's bottom edge. */
#xpbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 9px;
  background: #060505;
  border-top: 1px solid var(--bronze-lo);
  overflow: hidden;
}
#xpbar:hover { overflow: visible; }
#xpbar .fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(#b888f0, #6a30c0 60%, #38127a);
  transition: width 0.3s ease-out;
}
/* Twenty segments, as ticks over the fill. */
#xpbar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 calc(5% - 1px), rgba(0, 0, 0, 0.75) calc(5% - 1px) 5%);
  pointer-events: none;
}
#xpbar .text {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 1;
  padding: 1px 8px;
  white-space: nowrap;
  font-family: var(--serif);
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: rgba(6, 5, 4, 0.92);
  border: 1px solid var(--bronze-lo);
  opacity: 0;
  pointer-events: none;
}
#xpbar:hover .text { opacity: 1; }

#hotbar {
  display: flex;
  gap: 5px;
  align-items: flex-end;
}
.slot {
  position: relative;
  width: 52px;
  height: 52px;
  padding: 0;
  border-radius: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 30%, #2a241b, #0a0807 80%);
  border: 1px solid #000;
  box-shadow: 0 0 0 1px var(--bronze), inset 0 0 8px #000;
  cursor: pointer;
}
.slot img {
  width: 40px;
  height: 40px;
  image-rendering: pixelated;
}
.slot .key {
  position: absolute;
  left: 3px;
  top: 1px;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 11px;
  color: #eee;
  text-shadow: 0 1px 0 #000, 0 0 3px #000;
}
.slot .cost {
  position: absolute;
  right: 3px;
  bottom: 1px;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 11px;
  color: #8fb8ff;
  text-shadow: 0 1px 0 #000, 0 0 3px #000;
}
/* A cooldown sweeps away like a clock hand. --sweep is the share still to go. */
.slot .shade {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-weight: 900;
  font-size: 15px;
  color: #fff;
  background: conic-gradient(rgba(0, 0, 0, 0.74) calc(var(--sweep, 1) * 360deg), rgba(0, 0, 0, 0.28) 0);
  text-shadow: 0 1px 0 #000, 0 0 3px #000;
}
.slot.ready { box-shadow: 0 0 0 1px var(--bronze-hi), inset 0 0 8px #000, 0 0 7px rgba(255, 209, 0, 0.3); }
.slot.empty img { filter: grayscale(1) brightness(0.55); }
.slot.nomana { box-shadow: 0 0 0 1px #2c4c94, inset 0 0 8px #000; }
.slot.nomana img { filter: sepia(1) hue-rotate(185deg) saturate(2.5) brightness(0.55); }
/* Potions stand beside the skills as tall flasks. */
.slot.potion { width: 34px; }
.slot.potion img { width: 28px; height: 28px; }
.slot.potion .cost { color: #fff; }
.slot:hover:not(:disabled) { background: radial-gradient(circle at 50% 30%, #3a3124, #0a0807 80%); filter: brightness(1.15); }
.hotbar-gap { width: 1px; align-self: stretch; background: var(--bronze-lo); margin: 2px 3px; }
.slot .pips {
  position: absolute;
  left: 50%;
  bottom: -9px;
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
  pointer-events: none;
}
.pips i {
  display: inline-block;
  width: 5px;
  height: 5px;
  transform: rotate(45deg);
  background: #15110c;
  border: 1px solid var(--bronze-lo);
}
.pips i.on { background: var(--gold-hi); border-color: #5a4010; box-shadow: 0 0 3px rgba(255, 209, 0, 0.7); }
.slot .rank-up {
  position: absolute;
  top: -8px;
  right: -7px;
  z-index: 2;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-weight: 900;
  font-size: 14px;
  line-height: 1;
  color: #fff;
  background: radial-gradient(circle at 40% 30%, #ffd100, #a87800);
  border: 1px solid #000;
  box-shadow: 0 0 6px rgba(255, 209, 0, 0.7);
  text-shadow: 0 1px 0 #000;
  cursor: pointer;
  animation: beckon-plus 1.6s infinite alternate ease-in-out;
}
@keyframes beckon-plus { to { filter: brightness(1.35); } }

/* ---------- tooltips ---------- */
#tooltip {
  position: fixed;
  z-index: 20;
  max-width: 600px;
  pointer-events: none;
  line-height: 1.2;
  font-size: 15px;
  color: var(--text);
}
.tip-pair { display: flex; gap: 6px; align-items: flex-start; }
/* Skills and potions: a plain midnight box with a silver edge. */
.tip-box {
  width: 300px;
  padding: 8px 11px;
  background: rgba(6, 8, 22, 0.96);
  border: 1px solid #8a8fa0;
  border-radius: 3px;
  box-shadow: 0 0 0 1px #000, 0 8px 22px rgba(0, 0, 0, 0.8);
}
.tip-box p { margin: 4px 0; }
.tip-title { font-family: var(--caps); font-size: 17px; font-weight: 700; color: #fff; line-height: 1.2; }
/* Items: a header band in the item's rarity colour, centred lines, thin rules between them. */
.it {
  --rc: var(--r0);
  width: 268px;
  background: rgba(6, 5, 4, 0.97);
  border: 1px solid color-mix(in srgb, var(--rc) 70%, #000);
  box-shadow: 0 0 0 1px #000, 0 8px 22px rgba(0, 0, 0, 0.8);
  text-align: center;
}
.it.r0 { --rc: var(--r0); }
.it.r1 { --rc: var(--r1); }
.it.r2 { --rc: var(--r2); }
.it.r3 { --rc: var(--r3); }
.it.r4 { --rc: var(--r4); }
.it header {
  padding: 5px 10px 6px;
  background: linear-gradient(color-mix(in srgb, var(--rc) 30%, #0a0908), color-mix(in srgb, var(--rc) 9%, #0a0908));
  border-bottom: 1px solid color-mix(in srgb, var(--rc) 55%, #000);
}
.it header b { display: block; font-family: var(--caps); font-size: 18px; font-weight: 700; line-height: 1.1; color: var(--rc); text-shadow: 0 1px 1px #000; }
.it header small { color: var(--muted); font-size: 14px; }
.it-label { margin: 0; padding: 2px; font-family: var(--caps); font-size: 13px; color: var(--muted); background: #000; }
.it-body { padding: 5px 10px 7px; }
.it-body p { margin: 0; }
.it-body hr {
  height: 1px;
  margin: 5px 18px;
  border: 0;
  background: linear-gradient(90deg, transparent, var(--bronze), transparent);
}
.it-body ul { list-style: none; margin: 0; padding: 0; }
.it-stats li { color: #a9b6ff; }
.it-diff li { font-size: 14px; }

/* Loot toasts */
#toasts {
  position: absolute;
  right: 14px;
  bottom: 24px;
  display: grid;
  gap: 6px;
  justify-items: end;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 6px;
  max-width: 330px;
  animation: toast-in 0.25s ease-out;
  transition: opacity 0.4s, transform 0.4s;
}
.toast img { width: 32px; height: 32px; image-rendering: pixelated; }
.toast b { display: block; font-weight: 700; line-height: 1.1; font-family: var(--caps); font-size: 16px; }
.toast small { color: var(--muted); font-size: 14px; }
.toast.leaving { opacity: 0; transform: translateX(20px); }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: none; }
}

/* Badges on the round buttons */
.badge-count {
  position: absolute;
  right: -6px;
  bottom: -5px;
  min-width: 18px;
  padding: 0 4px;
  border-radius: 9px;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 10px;
  line-height: 15px;
  color: var(--text);
  background: #241f17;
  border: 1px solid #000;
}
.badge-count:empty { display: none; }
.badge-count.upgrade { background: #1f7a1c; color: #fff; }
.badge-count.full { background: #a8282c; color: #fff; }

/* ---------- buttons ---------- */
button {
  font-family: var(--caps);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.02em;
  color: var(--gold);
  background: linear-gradient(#2c261d, #15110c);
  border: 1px solid var(--bronze-lo);
  border-radius: 1px;
  padding: 4px 13px;
  cursor: pointer;
  text-shadow: 0 1px 0 #000;
  box-shadow: 0 0 0 1px #000, inset 0 1px 0 rgba(255, 230, 180, 0.12);
}
button:hover:not(:disabled) {
  color: #fff0cf;
  background: linear-gradient(#3e3527, #1d1811);
  border-color: var(--bronze-hi);
}
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled {
  opacity: 0.45;
  filter: grayscale(0.6);
  cursor: not-allowed;
}
button:focus-visible {
  outline: 1px solid var(--gold-hi);
  outline-offset: 2px;
}
/* The main action on a screen: dark red with a gold word. */
button.primary {
  font-size: 17px;
  line-height: 1.2;
  padding: 7px 22px;
  color: var(--gold-hi);
  background: linear-gradient(#8a1c14, #5a0f0a 55%, #340806);
  border: 1px solid var(--bronze-hi);
  box-shadow: 0 0 0 1px #000, inset 0 1px 0 rgba(255, 190, 150, 0.3), 0 3px 8px rgba(0, 0, 0, 0.5);
}
button.primary:hover:not(:disabled) {
  color: #fff3b0;
  background: linear-gradient(#a8241a, #70140e 55%, #420a08);
  border-color: #f0dca8;
}
button.small {
  font-size: 15px;
  padding: 2px 10px;
}
/* ---------- the window system ----------
   Every window is built the same way. See "UI design system" in README.md.

     .win (.win-sm | .win-md | .win-lg) (.win-tall) (.skin-parch)
       .win-head    .win-title, optional .win-sub, and .win-close in the corner
       .win-tabs    optional: a few tabs along the top
       .win-split   optional: .win-rail (many tabs, listed down the side) beside the body
       .win-body    the only part that scrolls
       .win-foot    optional: the purse or a note on the left, actions on the right

   Every window opens in the centre of the screen, over a dimmed world.

   Colours come only from the --win-* tokens, so a skin is just a new set of tokens. */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: var(--sp-3);
  overflow-y: auto;
  background: radial-gradient(ellipse at center, rgba(6, 5, 4, 0.5), rgba(3, 2, 2, 0.84));
}
.overlay:not(.hidden) > .win, .overlay:not(.hidden) > .scroll, .overlay:not(.hidden) > .stash-wrap > .win { animation: window-in 0.14s ease-out; }
@keyframes window-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

.win {
  /* Stone, the default skin. */
  --win-paper: var(--grain), linear-gradient(#1b1812, #0c0a08);
  --win-ink: var(--text);
  --win-muted: var(--muted);
  --win-title: var(--gold);
  --win-rule: var(--line);
  --win-diamond: var(--bronze);
  --win-accent: var(--gold-hi);
  --win-tab-ink: var(--muted);
  --win-tab-hover: rgba(255, 240, 200, 0.06);
  --win-tab-on: rgba(255, 209, 0, 0.09);
  --win-row: rgba(255, 240, 200, 0.035);
  --win-row-hover: rgba(255, 240, 200, 0.06);
  --win-row-line: #2c261c;
  --win-well: rgba(0, 0, 0, 0.3);
  --win-gold: var(--gold);
  --muted: var(--win-muted);
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: calc(100dvh - 24px);
  color: var(--win-ink);
  background: var(--win-paper);
  background-clip: border-box;
  border: 13px solid transparent;
  border-image: var(--frame) 15 / 13px stretch;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.85);
}
.win-sm { max-width: var(--win-sm); }
.win-md { max-width: var(--win-md); }
.win-lg { max-width: var(--win-lg); }
/* Tall windows keep one height, so changing tabs never makes them jump. */
.win-tall { height: min(660px, calc(100dvh - 24px)); }

/* Parchment, for what you read: the same window with different tokens. */
.skin-parch {
  --win-paper: var(--grain), var(--stains), radial-gradient(ellipse at center, #f6e8c2 0%, #e8d29c 62%, #c9a464 100%);
  --win-ink: var(--parch-ink);
  --win-muted: var(--parch-muted);
  --win-title: #6a1a10;
  --win-rule: rgba(106, 70, 32, 0.4);
  --win-diamond: #8a5a10;
  --win-accent: #8a1c14;
  --win-tab-ink: var(--parch-muted);
  --win-tab-hover: rgba(120, 76, 24, 0.12);
  --win-tab-on: rgba(138, 28, 20, 0.12);
  --win-row: rgba(255, 250, 232, 0.45);
  --win-row-hover: rgba(255, 250, 232, 0.6);
  --win-row-line: #a8885a;
  --win-well: rgba(255, 250, 230, 0.4);
  --win-gold: #8a5a10;
  --r0: #5a5248;
  --r1: #2a7a1a;
  --r2: #1f58b0;
  --r3: #7a2ab8;
  --r4: #b4600a;
  --rare: #7a2ab8;
  --green: #2a7a1a;
  --gold: #8a5a10;
  box-shadow: inset 0 0 50px rgba(120, 76, 24, 0.45), 0 16px 44px rgba(0, 0, 0, 0.85);
}

/* The head: a centred title over a thin rule with a diamond on it, and the close button. */
.win-head {
  position: relative;
  flex: none;
  min-height: 42px;
  padding: var(--sp-1) 36px var(--sp-2);
  border-bottom: 1px solid var(--win-rule);
  text-align: center;
}
.win-head::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -4px;
  width: 7px;
  height: 7px;
  transform: translateX(-50%) rotate(45deg);
  background: var(--win-diamond);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6);
}
.win-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: var(--t-title);
  line-height: 1.2;
  letter-spacing: 0.04em;
  color: var(--win-title);
}
.win-sub {
  margin: 2px 0 0;
  font-size: var(--t-small);
  font-style: italic;
  line-height: 1.2;
  color: var(--win-muted);
}
/* The one close button: same look and same corner on every window, in either skin. */
.win-close {
  position: absolute;
  top: 2px;
  right: 2px;
  z-index: 2;
  width: 28px;
  height: 28px;
  padding: 0;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  color: #e0b0a0;
  background: linear-gradient(#2c261d, #15110c);
  border: 1px solid var(--bronze);
  border-radius: 1px;
  box-shadow: 0 0 0 1px #000, inset 0 1px 0 rgba(255, 230, 180, 0.12);
}
.win-close:hover:not(:disabled) { color: #fff; background: linear-gradient(#7a1a12, #4a0d08); border-color: var(--bronze-hi); }

/* A few tabs along the top. They scroll sideways before they would ever wrap. */
.win-tabs {
  flex: none;
  display: flex;
  gap: 2px;
  margin-top: var(--sp-2);
  overflow-x: auto;
  border-bottom: 1px solid var(--win-rule);
}
.win-tabs:empty { display: none; }
.win-tabs button, .win-rail button {
  flex: none;
  color: var(--win-tab-ink);
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  text-shadow: none;
}
.win-tabs button { padding: 5px 14px 6px; border-bottom: 2px solid transparent; }
.win-tabs button small, .win-rail button small { font-family: var(--body); font-weight: 400; font-size: var(--t-small); opacity: 0.8; }
.win-tabs button:hover:not(:disabled), .win-rail button:hover:not(:disabled) { color: var(--win-ink); background: var(--win-tab-hover); }
.win-tabs button.active { color: var(--win-accent); background: var(--win-tab-on); border-bottom-color: var(--win-accent); }

/* Many tabs: a list down the side, with room for as many as there will ever be. */
.win-split {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  margin-top: var(--sp-2);
}
.win-rail {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-right: var(--sp-2);
  overflow-y: auto;
  border-right: 1px solid var(--win-rule);
}
.win-rail button {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-2);
  padding: 6px 10px;
  text-align: left;
  border-left: 2px solid transparent;
}
.win-rail button.active { color: var(--win-accent); background: var(--win-tab-on); border-left-color: var(--win-accent); }

.win-body {
  flex: 1;
  min-height: 0;
  padding: var(--sp-3) var(--sp-1) var(--sp-1);
  overflow-x: hidden;
  overflow-y: auto;
}
.win-split .win-body { padding: var(--sp-1) var(--sp-1) var(--sp-1) var(--sp-3); }
.win-foot {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-3);
  margin-top: var(--sp-2);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--win-rule);
}
.win-foot:empty { display: none; }
.win-foot .grow { flex: 1; margin: 0; min-width: 0; }
.win-foot-center { justify-content: center; }

/* Small parts every window shares. */
.section-title {
  margin: var(--sp-3) 0 var(--sp-1);
  font-family: var(--caps);
  font-weight: 700;
  font-size: var(--t-head);
  color: var(--win-title);
}
.win-body > .section-title:first-child { margin-top: 0; }
.purse {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  font-family: var(--serif);
  font-weight: 700;
  font-size: 14px;
}
.purse img { width: 16px; height: 16px; image-rendering: pixelated; }
.win .gold { color: var(--win-gold); }
.win .muted { color: var(--win-muted); }
.win h3 { color: var(--win-title); font-size: var(--t-head); }
.win .lvl {
  display: inline-block;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 13px;
}
.list { display: grid; gap: 5px; }
.row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 6px 9px;
  background: var(--win-row);
  border: 1px solid var(--win-row-line);
}
.row:hover { background: var(--win-row-hover); }
.row img {
  width: 42px;
  height: 42px;
  image-rendering: pixelated;
  background: #0a0807;
  border: 1px solid var(--bronze-lo);
  padding: 3px;
}
.row .info { min-width: 0; line-height: 1.15; }
.row .info b { display: block; font-family: var(--caps); font-weight: 700; font-size: 17px; }
.row .info small { display: block; color: var(--win-muted); font-size: var(--t-small); }
.row .side { display: grid; gap: 4px; justify-items: end; }
.row .price { font-family: var(--serif); font-weight: 700; font-size: 14px; color: var(--win-gold); }
.row.quest-row { grid-template-columns: minmax(0, 1fr) auto; }
.quest-row .info b { color: var(--win-accent); }
.quest-row .reward { color: var(--win-gold); font-weight: 700; }
.win .quest-row small.lvl { display: block; width: fit-content; margin: 1px 0 3px; font-size: 12.5px; line-height: 1.45; }
.empty-note { color: var(--win-muted); font-style: italic; margin: 6px 0; }
.quote { color: var(--win-ink); font-style: italic; font-size: var(--t-body); margin: 0; }

/* A progress bar. */
.bar {
  display: block;
  height: 5px;
  margin: 3px 0;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--win-row-line);
  overflow: hidden;
}
.bar i { display: block; height: 100%; background: var(--win-accent); }
/* A few totals side by side. */
.stat-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-1); }
.stat-tiles > div { padding: var(--sp-2); text-align: center; background: var(--win-well); border: 1px solid var(--win-rule); }
.stat-tiles b { display: block; font-family: var(--serif); font-size: 18px; color: var(--win-accent); }
.stat-tiles small { display: block; font-size: var(--t-small); line-height: 1.1; color: var(--win-muted); }
/* A line per region: its name, marks and a count, with an optional bar along the bottom. */
.region-list { gap: 3px; }
.region-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0 var(--sp-3);
  padding: 4px 9px;
  background: var(--win-row);
  border: 1px solid var(--win-row-line);
}
.region-row b { font-family: var(--caps); font-size: 16px; font-weight: 700; color: var(--win-title); }
.region-row .count { font-size: var(--t-small); color: var(--win-muted); text-align: right; }
.region-row .marks { display: flex; gap: var(--sp-1); font-size: 13px; }
.region-row .marks i { font-style: normal; color: var(--win-row-line); }
.region-row .marks i.on { color: var(--win-accent); }
.region-row .bar { grid-column: 1 / -1; margin-bottom: 1px; }
.region-row.later { grid-template-columns: minmax(0, 1fr) auto; }
.region-row.unknown { opacity: 0.55; }
.region-row.unknown b { color: var(--win-muted); font-weight: 500; }
.win-actions { display: flex; justify-content: center; margin-top: var(--sp-3); }
#npc-body > .list + .row, #npc-body > .stat-tiles + .row { margin-top: var(--sp-2); }

/* Who you're talking to. */
.npc-intro {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-2);
}
.npc-intro img {
  flex: none;
  width: 56px;
  height: 56px;
  image-rendering: pixelated;
  border-radius: 50%;
  border: 3px solid transparent;
  background:
    radial-gradient(circle at 50% 35%, #4a3a2a, #0d0a07) padding-box,
    conic-gradient(from 210deg, #6e5c3c, #e0c88f, #4f4330, #c9ae7a, #3a3024, #967f55, #6e5c3c) border-box;
  box-shadow: 0 0 0 1px #000;
  padding: 4px;
}

.title-card { text-align: center; }
.title-card h1 {
  font-family: var(--fancy);
  font-weight: 900;
  font-size: clamp(30px, 10vw, 44px);
  letter-spacing: 0.02em;
  margin-bottom: 2px;
  background: linear-gradient(#fff2c0 0%, #dcb868 45%, #7a5216 62%, #d0a850 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 1px #1a0e02;
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.8));
}
.title-card h1 span { color: transparent; }
.season {
  margin: 0 0 var(--sp-4);
  font-family: var(--caps);
  font-size: var(--t-head);
  color: var(--gold);
}
.title-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}
/* create */
/* A labelled input: the label always sits above its box. */
.field {
  display: grid;
  gap: var(--sp-1);
  text-align: left;
  font-family: var(--caps);
  font-weight: 700;
  color: var(--gold);
}
.field input,
.chat-form input,
.trade-gold input,
.ko-epitaph select {
  font-family: var(--body);
  font-size: 17px;
  color: #f0e8d8;
  background: #070605;
  border: 1px solid var(--bronze-lo);
  border-radius: 0;
  padding: 6px 10px;
  box-shadow: 0 0 0 1px #000, inset 0 1px 4px #000;
}
#hero-name { font-family: var(--caps); font-size: 20px; }
#create-screen .field { margin-bottom: var(--sp-3); }
.field input:focus, .chat-form input:focus, .trade-gold input:focus { outline: 1px solid var(--bronze-hi); }
.class-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.class-card {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 8px 6px;
  text-align: center;
  background: radial-gradient(circle at 50% 30%, #2a241b, #0a0807 80%);
}
.class-card img { width: 58px; height: 58px; image-rendering: pixelated; }
.class-card b { font-size: 16px; color: var(--gold); }
.class-card.selected {
  border-color: var(--gold-hi);
  box-shadow: 0 0 0 1px #000, 0 0 12px rgba(255, 209, 0, 0.45), inset 0 0 14px rgba(255, 209, 0, 0.1);
}
.class-card.selected b { color: var(--gold-hi); }
.class-detail {
  min-height: 160px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
}
.class-detail p { margin: 0 0 8px; }
.skill-row {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 7px;
  line-height: 1.15;
}
.skill-row img { width: 34px; height: 34px; image-rendering: pixelated; background: #0a0807; border: 1px solid var(--bronze-lo); padding: 2px; }
.skill-row b { font-family: var(--caps); color: var(--gold); font-size: 16px; }
.skill-row small { color: var(--muted); font-size: 15px; }
.warning { color: #ff7a6a; margin: 10px 0 0; font-style: italic; }
/* ---------- character: gear around the hero, stats, then the bag ---------- */
.doll {
  display: grid;
  grid-template-columns: 60px 92px 60px;
  grid-template-rows: 60px 92px 60px;
  grid-template-areas:
    ". helm ."
    "weapon hero cape"
    ". armor .";
  gap: 6px;
  justify-content: center;
  align-items: center;
  justify-items: center;
  margin-bottom: 10px;
  background: radial-gradient(ellipse at center, rgba(120, 95, 50, 0.16), transparent 62%);
}
#inv-equipped { display: contents; }
#inv-portrait {
  grid-area: hero;
  width: 78px;
  height: 78px;
  image-rendering: pixelated;
}
.doll .cell { width: 60px; height: 60px; }
.doll-helm { grid-area: helm; }
.doll-weapon { grid-area: weapon; }
.doll-cape { grid-area: cape; }
.doll-armor { grid-area: armor; }
.equipped {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  width: 100%;
}
.cell {
  --rc: transparent;
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  display: grid;
  place-items: center;
  background: #0c0a08;
  border: 1px solid #2c261c;
  border-radius: 0;
  box-shadow: none;
}
.cell img { width: 80%; height: 80%; image-rendering: pixelated; }
.cell .slot-label { font-size: 13px; color: var(--bronze-lo); font-family: var(--caps); font-weight: 500; }
button.cell:hover:not(:disabled) { background: color-mix(in srgb, var(--rc) 22%, #1a1610); border-color: var(--bronze-hi); }
.cell.selected { box-shadow: 0 0 0 1px var(--gold-hi); }
/* Items sit on a wash of their rarity's colour. */
.cell.r0 { --rc: var(--r0); }
.cell.r1 { --rc: var(--r1); }
.cell.r2 { --rc: var(--r2); }
.cell.r3 { --rc: var(--r3); }
.cell.r4 { --rc: var(--r4); }
.cell.r0, .cell.r1, .cell.r2, .cell.r3, .cell.r4 {
  background: color-mix(in srgb, var(--rc) 13%, #0c0a08);
  border-color: color-mix(in srgb, var(--rc) 45%, #000);
}
.cell.r4 { box-shadow: 0 0 8px rgba(255, 140, 26, 0.45); }
.cell .plus {
  position: absolute;
  left: 2px;
  bottom: 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 10px;
  color: var(--gold-hi);
  text-shadow: 0 1px 0 #000;
}
.cell .badge {
  position: absolute;
  right: 1px;
  top: -1px;
  font-size: 12px;
  color: var(--r1);
  text-shadow: 0 1px 0 #000;
}
.mini-stats {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  gap: 1px 10px;
  width: 100%;
  margin: 0 0 10px;
  padding: 7px 10px;
  line-height: 1.25;
  font-size: 15px;
  background: var(--win-well);
  border: 1px solid var(--win-rule);
}
.mini-stats dt { color: var(--win-muted); }
.mini-stats dd { margin: 0; text-align: right; font-family: var(--serif); font-weight: 700; font-size: 13px; color: var(--win-ink); }
.bag-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 2px;
  margin-bottom: 8px;
}
/* The item on the cursor, where it left a dimmed place behind it, and the slots that would take it. */
.held-item {
  position: fixed;
  z-index: 30;
  width: 48px;
  height: 48px;
  margin: -24px 0 0 -24px;
  pointer-events: none;
  image-rendering: pixelated;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.9));
}
.cell.lifted img { opacity: 0.25; }
.cell.fits { border-color: var(--gold-hi); box-shadow: 0 0 8px rgba(255, 209, 0, 0.55), inset 0 0 8px rgba(255, 209, 0, 0.15); }
.move-hint { font-size: var(--t-small); }

/* ---------- stash: its tabs on the left, the bag on the right ---------- */
.stash-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
}
.stash-wrap > .win { flex: 0 1 var(--win-md); }
.stash-wrap > .win-sm { flex-basis: var(--win-sm); }
#stash-bag { margin-bottom: 0; }

/* ---------- character selection ---------- */
.char-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  min-height: 62px;
  padding: 4px 10px;
  text-align: left;
  color: var(--win-ink);
  background: var(--win-row);
  border: 1px solid var(--win-row-line);
  box-shadow: none;
}
.char-row img { width: 50px; height: 50px; image-rendering: pixelated; }
.char-info b { display: block; font-family: var(--caps); font-size: 18px; font-weight: 700; color: var(--win-title); }
.char-info small { display: block; font-family: var(--body); font-weight: 400; font-size: var(--t-small); color: var(--win-muted); }
.char-row.selected { background: var(--win-tab-on); border-color: var(--gold-hi); box-shadow: inset 2px 0 0 var(--gold-hi); }
.char-row.selected .char-info b { color: var(--gold-hi); }
.char-row.empty { justify-content: center; min-height: 44px; background: none; border-style: dashed; }
.char-row.empty .char-info b { font-size: 15px; color: var(--win-muted); }
.grow-left { margin-right: auto; }
#delete-screen { z-index: 7; }
.delete-text { margin: 0; text-align: center; }
.system-menu { display: grid; gap: var(--sp-2); }
.system-menu p { margin: 0; font-size: var(--t-small); text-align: center; }
.system-menu p:empty { display: none; }
.system-menu .volume { grid-template-columns: 9em 1fr; align-items: center; font-size: var(--t-small); }
.system-menu .volume input { padding: 0; background: none; border: 0; box-shadow: none; accent-color: var(--gold); }

/* ---------- world map: a travelling map on a scroll ---------- */
.scroll {
  width: min(1000px, 100%, calc((100dvh - 170px) * 10 / 7));
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}
.scroll-rod {
  position: relative;
  z-index: 1;
  height: 24px;
  margin: 0 -18px;
  border-radius: 12px;
  background: linear-gradient(#a8743a, #6a4018 40%, #2a1606);
  box-shadow: inset 0 2px 0 rgba(255, 220, 160, 0.4), 0 5px 10px rgba(0, 0, 0, 0.6);
}
.scroll-rod::before,
.scroll-rod::after {
  content: '';
  position: absolute;
  top: -4px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #fff0b8, #c9902a 45%, #5a3408);
  box-shadow: 0 0 0 2px var(--ink);
}
.scroll-rod::before { left: -14px; }
.scroll-rod::after { right: -14px; }
.map-sheet {
  position: relative;
  aspect-ratio: 10 / 7;
  container-type: inline-size;
  color: var(--parch-ink);
  background: var(--grain), var(--stains), radial-gradient(ellipse at center, #f4e4b8 0%, #e6cf98 60%, #c8a060 100%);
  box-shadow: inset 0 0 60px rgba(110, 70, 20, 0.55), inset 0 10px 18px rgba(60, 30, 5, 0.35), inset 0 -10px 18px rgba(60, 30, 5, 0.35);
  overflow: hidden;
}
#map-art { position: absolute; inset: 0; width: 100%; height: 100%; }
.map-title {
  position: absolute;
  left: 3%;
  top: 3%;
  max-width: 30%;
  pointer-events: none;
  color: #5a3a1a;
}
.map-title small { display: block; font-family: var(--serif); font-weight: 700; font-size: 1.5cqw; letter-spacing: 0.08em; }
.map-title span {
  display: block;
  font-family: var(--fancy);
  font-weight: 900;
  font-size: 5.2cqw;
  line-height: 1;
  background: linear-gradient(#fff2b8, #d8a03a 50%, #8a5010);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 1px #3a1e06;
  filter: drop-shadow(0 2px 0 rgba(58, 30, 6, 0.5));
}
.map-title p { margin: 4px 0 0; font-size: 1.35cqw; font-style: italic; line-height: 1.2; }
#zone-list { position: absolute; inset: 0; }
.map-node {
  position: absolute;
  transform: translate(-50%, -32%);
  display: grid;
  justify-items: center;
  padding: 0;
  background: none;
  border: 0;
  box-shadow: none;
  text-shadow: none;
  cursor: pointer;
}
.map-node:hover:not(:disabled) { background: none; }
.map-node:active:not(:disabled) { transform: translate(-50%, -32%); }
.map-node .medal {
  position: relative;
  width: max(26px, 5.4cqw);
  height: max(26px, 5.4cqw);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 35%, #5a4430, #140b05 80%);
  border: 3px solid #c9a24a;
  box-shadow: 0 0 0 2px #2a1a0c, inset 0 0 0 2px var(--region, transparent), 0 4px 6px rgba(60, 30, 5, 0.55);
  transition: transform 0.15s;
}
.map-node .medal img { width: 72%; height: 72%; image-rendering: pixelated; }
.map-node:hover .medal { transform: scale(1.12); }
.node-name {
  margin-top: 2px;
  font-family: var(--serif);
  font-weight: 700;
  font-size: max(9.5px, 1.45cqw);
  color: #7a1408;
  white-space: nowrap;
  /* A parchment halo keeps names readable over roads, trees and coastline. */
  text-shadow: 1px 0 1px #f6ecd0, -1px 0 1px #f6ecd0, 0 1px 1px #f6ecd0, 0 -1px 1px #f6ecd0, 0 0 5px #f6ecd0, 0 0 5px #f6ecd0;
}
.node-sub { font-size: max(9px, 1.25cqw); color: #4a2e12; font-style: italic; line-height: 1; text-shadow: 1px 0 1px #f6ecd0, -1px 0 1px #f6ecd0, 0 1px 1px #f6ecd0, 0 0 4px #f6ecd0; }
.map-node.locked .medal { filter: grayscale(1) brightness(0.75) sepia(0.4); border-color: #8a7a5a; }
.map-node.locked .node-name { color: #5a4c36; }
.map-node.current .medal {
  border-color: #ffe08a;
  animation: beckon 1.3s infinite alternate;
}
@keyframes beckon {
  from { box-shadow: 0 0 0 2px #2a1a0c, 0 0 6px 2px rgba(255, 200, 80, 0.4); }
  to { box-shadow: 0 0 0 2px #2a1a0c, 0 0 18px 7px rgba(255, 200, 80, 0.85); }
}
.map-node.cleared .medal::after {
  content: '✓';
  position: absolute;
  right: -6px;
  bottom: -4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 900;
  color: #fff;
  background: #2f7a1e;
  border: 2px solid #f0d890;
}
.map-node.selected .medal { outline: 3px solid #a8202a; outline-offset: 3px; }
.map-node.town { cursor: default; }
.map-node.town .medal { width: max(32px, 6.6cqw); height: max(32px, 6.6cqw); border-color: #ffe08a; }
.map-node.town .node-name { color: #3a2410; font-size: max(10px, 1.65cqw); }
.map-sheet .win-close { top: 10px; right: 10px; }
.map-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  color: var(--parch-ink);
  background: var(--grain), linear-gradient(#e6cf98, #d4b478);
  box-shadow: inset 0 0 24px rgba(110, 70, 20, 0.45);
}
.map-info { flex: 1; display: flex; align-items: center; gap: 14px; min-width: 0; }
.zi-text { flex: 1; min-width: 0; line-height: 1.2; }
.zi-text b { font-family: var(--serif); font-weight: 900; font-size: 18px; color: #6a1a10; }
.zi-region { font-family: var(--serif); font-weight: 700; font-size: 13px; filter: brightness(0.65) saturate(1.3); }
.zi-text small { display: block; font-size: 15px; }
.zi-meta { color: var(--parch-muted); font-style: italic; }
.zi-meta .lvl { font-style: normal; display: inline-block; padding: 0 7px; border-radius: 3px; background: #2a1a0c; font-family: var(--serif); font-weight: 700; font-size: 13px; }

/* On a small map there's no room for every name: the footer names the place you tap. */
@container (max-width: 560px) {
  .node-name, .node-sub, .map-title p { display: none; }
  .map-node.cleared .medal::after { width: 13px; height: 13px; font-size: 9px; right: -4px; bottom: -3px; border-width: 1px; }
  .map-node.selected .medal { outline-width: 2px; outline-offset: 2px; }
  .map-title small { font-size: 8px; }
  .map-title span { -webkit-text-stroke-width: 0.5px; }
}

/* ---------- journal & lore ---------- */
.journal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.entry {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  align-items: start;
  padding: 10px 12px;
  background: rgba(255, 250, 232, 0.45);
  border: 1px solid #a8885a;
  border-radius: 4px;
}
.entry img {
  width: 56px;
  height: 56px;
  image-rendering: pixelated;
  background: radial-gradient(circle at 50% 35%, #4a3424, #140b05);
  border: 2px solid var(--gold-lo);
  border-radius: 50%;
  padding: 4px;
}
.entry .silhouette {
  position: relative;
  flex: none;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 35%, #4a3424, #140b05);
  border: 2px solid var(--gold-lo);
  border-radius: 50%;
}
.entry .silhouette img { background: none; border: 0; padding: 0; width: 44px; height: 44px; border-radius: 0; filter: brightness(0) invert(0.34) sepia(0.5); }
.entry .silhouette::after {
  content: '?';
  position: absolute;
  font-family: var(--serif);
  font-weight: 900;
  font-size: 22px;
  color: #f0d890;
  text-shadow: 0 1px 2px #000, 0 0 4px #000;
}
.entry h3 { font-size: 15px; margin: 0 0 4px; }
.entry p { margin: 0; font-size: 15px; line-height: 1.25; }
.entry.beast h3 { color: #7a2ab8; }
.beast-stats { font-size: var(--t-small); color: var(--win-muted); }
.beast-tags { margin-top: 3px !important; }
.beast-tags .tag { margin: 2px 3px 0 0; color: #f0e6d0; }
.entry.unknown { opacity: 0.75; }
.entry.unknown h3 { color: var(--parch-muted); }
.pages-title { margin: 16px 0 8px; }
.page {
  margin: 0 0 10px;
  padding: 10px 16px 12px;
  background: var(--grain), linear-gradient(#fbf2d6, #efdcac);
  border: 1px solid #b8986a;
  border-radius: 2px 14px 2px 10px;
  box-shadow: 2px 3px 6px rgba(90, 60, 20, 0.35);
}
.page h4 { margin: 0 0 4px; font-size: 15px; color: #5a2a10; }
.page p { margin: 0; font-style: italic; font-size: 16px; line-height: 1.35; }
.page .new { font-family: var(--body); font-weight: 700; font-size: 12px; color: #fff; background: #a8202a; border-radius: 3px; padding: 0 5px; vertical-align: middle; }
.page.missing { opacity: 0.55; background: none; box-shadow: none; border-style: dashed; }

.lore-card { text-align: center; }
.lore-text { margin: 6px 0 14px; font-size: 18px; line-height: 1.45; font-style: italic; }
.lore-card[data-kind='monument'] .lore-text { font-style: normal; font-family: var(--serif); font-size: 16px; letter-spacing: 0.02em; }
.lore-sub { margin: 0; color: var(--win-gold); font-weight: 700; }


/* knockout & help */
.ko-card { text-align: center; }
.ko-card .win-title { color: #ff5a48; }
.ko-card p { margin: 0; font-size: 17px; }
/* Help is laid out like the chronicle: each card's round icon holds the key, the mouse button
   (drawn, with the one to press filled in) or the game's own icon. */
.key-badge {
  width: 56px;
  height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: radial-gradient(circle at 50% 35%, #4a3424, #140b05);
  border: 2px solid var(--gold-lo);
  border-radius: 50%;
  font-family: var(--caps);
  font-weight: 700;
  font-size: 20px;
  line-height: 1;
  color: #f0d890;
  text-shadow: 0 1px 2px #000;
}
.key-badge.small { font-size: 14px; }
.key-badge small { font-size: 10px; letter-spacing: 0.04em; }
.key-badge svg { width: 20px; height: 27px; }
.key-badge svg * { fill: none; stroke: #f0d890; stroke-width: 1.6; }
.key-badge svg .on { fill: #f7d046; }
.key-badge small + svg { width: 16px; height: 22px; }
#help-screen .page p { font-style: normal; font-size: 15px; }

/* ---------- touch controls ---------- */
#touch {
  position: absolute;
  left: 12px;
  bottom: 150px;
  display: none;
  gap: 12px;
  align-items: flex-end;
}
body.touch #touch { display: flex; }
@media (pointer: coarse) {
  #touch { display: flex; }
}
.dpad {
  display: grid;
  grid-template-columns: repeat(3, 48px);
  grid-template-rows: repeat(3, 48px);
  grid-template-areas:
    ". up ."
    "left mid right"
    ". down .";
  gap: 4px;
}
.dpad button {
  padding: 0;
  font-size: 18px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.dpad .up { grid-area: up; }
.dpad .down { grid-area: down; }
.dpad .left { grid-area: left; }
.dpad .right { grid-area: right; }
.dpad .mid { grid-area: mid; color: var(--muted); }
.touch-actions { display: grid; gap: 7px; }
.touch-actions button {
  min-width: 92px;
  min-height: 40px;
  font-size: 15px;
  touch-action: none;
}
#touch-descend.ready { color: var(--gold-hi); background: linear-gradient(#8a1c14, #340806); border-color: var(--bronze-hi); }

/* ---------- smaller screens: the side windows take turns with the middle ---------- */
/* Too narrow for the log and toasts to sit beside the globes: they go above them. */
@media (max-width: 1180px) {
  #log-box { bottom: 150px; width: min(330px, calc(100vw - 24px)); }
  #toasts { bottom: 156px; }
}
@media (max-width: 1000px) {
  .slot { width: 46px; height: 46px; }
  .slot img { width: 34px; height: 34px; }
  .slot.potion { width: 30px; }
  .slot.potion img { width: 24px; height: 24px; }
  .orb { width: 96px; height: 96px; }
  #top-center { width: min(330px, calc(100vw - 520px)); min-width: 250px; }
  #hud-hint { bottom: 124px; }
}

/* ---------- narrow screens ---------- */
@media (max-width: 760px) {
  html, body { font-size: 15px; }
  #unit-frame { width: min(230px, calc(100vw - 80px)); }
  .portrait { width: 58px; height: 58px; margin-right: -16px; }
  .portrait img { width: 42px; height: 42px; }
  .uf-gold { display: none; }
  .uf-body .uf-gold { display: none; }
  .bag-line .uf-gold { display: flex; }
  #top-right { width: auto; top: 10px; right: 8px; }
  #tracker, .mm-ring, #hud-where { display: none; }
  .mm-wrap { width: auto; height: auto; }
  .menu-buttons { position: static; display: flex; flex-direction: column; gap: 6px; }
  .menu-buttons button.round { position: relative; left: auto !important; top: auto !important; transform: none; }
  .menu-buttons button.round:active:not(:disabled) { transform: translateY(1px); }
  #top-center { top: auto; bottom: 122px; left: 8px; right: 8px; width: auto; max-width: none; transform: none; min-width: 0; }
  #toasts { bottom: 210px; right: 8px; }
  #actionbar { bottom: 11px; align-items: flex-end; }
  .orb { width: 70px; height: 70px; border-width: 3px; }
  .orb-text b { font-size: 15px; }
  .orb-text small { font-size: 9px; }
  .bar-mid { padding: 3px 12px 9px; border-width: 6px; border-image-width: 6px; margin: 0 -14px; }
  #hotbar { flex-wrap: wrap; justify-content: center; max-width: 174px; gap: 3px 4px; }
  .slot { width: 40px; height: 40px; }
  .slot img { width: 30px; height: 30px; }
  .slot.potion { width: 40px; height: 26px; order: 5; }
  .slot.potion img { width: 20px; height: 20px; }
  .hotbar-gap { display: none; }
  .slot .pips { bottom: -6px; }
  #hud-hint { bottom: auto; top: 160px; left: 50%; right: auto; transform: translateX(-50%); max-width: 86vw; font-size: 14px; text-align: center; padding: 4px 10px; background: rgba(6, 5, 4, 0.72); }
  #log-box { top: 84px; bottom: auto; left: 8px; width: calc(100vw - 96px); }
  #log, body.touch #log { max-height: 56px; }
  #touch { bottom: 212px; left: 8px; right: 8px; justify-content: space-between; pointer-events: none; }
  #touch > * { pointer-events: auto; }
  .touch-actions button { min-width: 78px; }
  .win { border-width: 9px; border-image-width: 9px; }
  .win-split { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .win-rail { flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 0; border-right: 0; border-bottom: 1px solid var(--win-rule); }
  .win-rail button { border-left: 0; border-bottom: 2px solid transparent; white-space: nowrap; }
  .win-rail button.active { border-bottom-color: var(--win-accent); }
  .win-split .win-body { padding: var(--sp-2) var(--sp-1) var(--sp-1); }
  .stash-wrap { flex-direction: column; align-items: stretch; }
  .stash-wrap > .win { flex: none; max-height: none; }
  .class-list { grid-template-columns: repeat(2, 1fr); }
  .row { grid-template-columns: 34px minmax(0, 1fr) auto; gap: 8px; }
  .row img { width: 34px; height: 34px; }
  .journal-grid { grid-template-columns: 1fr; }
  .node-sub { display: none; }
  .map-foot { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 12px; }
  .map-info { flex-direction: column; align-items: stretch; gap: 8px; }
  .zi-buttons { flex-direction: row; }
  .zi-buttons button { flex: 1; }
  .scroll-rod { height: 16px; margin: 0 -8px; }
  .scroll-rod::before, .scroll-rod::after { top: -3px; width: 22px; height: 22px; }
  .scroll-rod::before { left: -8px; }
  .scroll-rod::after { right: -8px; }
  .trade-cols, .inspect-body { grid-template-columns: 1fr; }
  .tip-pair { flex-direction: column; }
}

/* ---------- skills ---------- */
#skills-points b { font-family: var(--serif); font-style: normal; color: var(--win-accent); }
#skills-foot { justify-content: flex-start; font-size: var(--t-small); }
.skill-rank .info b { display: flex; align-items: center; gap: 10px; color: var(--win-accent); }
.skill-rank .pips { display: inline-flex; gap: 4px; }
.skill-rank .pips i { width: 8px; height: 8px; }
.skill-rank .next { color: var(--green); }
.skill-rank.locked { opacity: 0.55; }
#skills-list > .section-title { margin: var(--sp-2) 0 0; }
#skills-list > .section-title:first-child { margin-top: 0; }

/* ---------- online ---------- */
.online-box { margin: 0 0 var(--sp-3); }
.login-form { display: grid; gap: var(--sp-2); }
.login-form .warning:empty { display: none; }
.login-form .warning { margin: 0; }
/* Keep the browser's autofill from painting the fields pale blue. */
.login-form input:-webkit-autofill, .login-form input:-webkit-autofill:focus {
  -webkit-text-fill-color: #f0e8d8;
  caret-color: #f0e8d8;
  box-shadow: inset 0 0 0 40px #070605, 0 0 0 1px #000;
  transition: background-color 9999s;
}
.online-account { margin: 0 0 12px; }
button.link {
  padding: 0;
  font-family: var(--body);
  font-weight: 700;
  font-size: inherit;
  color: var(--gold);
  background: none;
  border: 0;
  box-shadow: none;
  text-shadow: none;
  text-decoration: underline;
}
button.link:hover:not(:disabled) { background: none; color: var(--gold-hi); }
.offline-switch { margin: 8px 0 0; font-size: 15px; }

.online-pill {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  font-family: var(--caps);
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  text-shadow: 0 1px 1px #000, 0 0 4px #000;
}
.online-pill i { width: 8px; height: 8px; border-radius: 50%; background: #5cd65a; box-shadow: 0 0 6px #5cd65a; }
.online-pill.bad i { background: #e04848; box-shadow: 0 0 6px #e04848; }

.line.chat { color: #f0e6ff; }
.line.feed { color: var(--gold-hi); font-style: italic; }
.line.feed::before { content: '◆ '; color: var(--bronze); font-style: normal; font-size: 11px; }

.trade-ask { gap: 8px; }
.trade-ask small { display: block; }

.inspect-body { display: grid; grid-template-columns: 110px 1fr; gap: 14px; align-items: start; }
#insp-portrait {
  width: 110px;
  height: 110px;
  image-rendering: pixelated;
  background: radial-gradient(circle at 50% 35%, #3a2e20, #0a0807);
  border: 1px solid var(--bronze);
  box-shadow: 0 0 0 1px #000;
  padding: 8px;
}
#insp-equipped { margin-bottom: 10px; }
#insp-record { grid-template-columns: 1fr auto; }

.trade-cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.trade-cols .section-title { margin-top: 0; }
.trade-offer {
  display: grid;
  grid-template-columns: repeat(6, 48px);
  gap: 3px;
  min-height: 58px;
  padding: 5px;
  margin-bottom: 8px;
  background: var(--win-well);
  border: 1px solid var(--win-rule);
}
.trade-offer p { grid-column: 1 / -1; margin: 10px 4px; }
.trade-gold { display: flex; align-items: center; gap: 10px; font-family: var(--caps); font-weight: 700; color: var(--gold); margin-bottom: 6px; }
.trade-gold input { width: 120px; }
#trade-bag { grid-template-columns: repeat(8, 1fr); }
.trade-their-gold { font-family: var(--serif); font-weight: 700; color: var(--gold); }
.trade-status { margin: 10px 0 0; font-weight: 700; }

.board-top { margin: 6px 0 8px; padding-left: 28px; }
.board-top li { padding: 3px 0; border-bottom: 1px solid var(--line); }
.board-top li::marker { font-family: var(--serif); font-weight: 900; color: var(--gold-hi); }
.board-top .floor { font-family: var(--serif); font-weight: 700; color: var(--gold); margin-left: 6px; }
.board-mine { font-weight: 700; margin: 4px 0 8px; }
.board-feed { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; }
.board-feed li { padding: 3px 0; border-bottom: 1px solid var(--line); }
.zi-buttons { display: flex; flex-direction: column; gap: 6px; }
button.primary.weekly { background: linear-gradient(#6a3a9a, #3a1a6a 55%, #220c44); border-color: #d8c0f0; color: #f0e0ff; }
.ko-epitaph { display: grid; gap: 6px; margin: 0 auto 16px; max-width: 420px; text-align: left; font-style: italic; }
.ko-epitaph select { font-style: normal; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
