/* ELDMARK - base UI stylesheet (SPEC 10.3 visual style, Phase 6b look: docs/VISUAL_STYLE.md).
   Design system: dark wooden frames around parchment bodies, brass medallions and round gold
   close buttons, pill inputs, glossy red primary / slate secondary buttons. The HUD floats on
   the world (dark translucent boxes, round brass buttons, diamond minimap).
   Colours are tokens: the dark HUD set lives on :root; everything drawn on parchment (window
   bodies, tooltips, dialogs) re-defines the same tokens (--text, --gold, --border ...) for ink on
   paper, so feature styles written against the tokens follow automatically.
   Feature styles live in css/features/. */

:root {
  --bg: #1b1712;
  --bg-deep: #110e0a;
  --bg-raise: #241e17;
  --bg-hover: #2e261c;
  --border: #6b5431;
  --border-dim: #3f3220;
  --border-bright: #9c7c46;
  --gold: #d9b45a;
  --gold-bright: #f0d48a;
  --gold-dim: #8f7640;
  --text: #ecdfc2;
  --text-dim: #b8a88a;
  --text-faint: #857759;
  --good: #7fc45a;
  --warn: #e8912d;
  --error: #e0453a;
  --info: #d9b45a;
  --hp: #c8302a;
  --energy: #2f7fd6;

  --zone-city: #d9b45a;
  --zone-blue: #3d8bfd;
  --zone-yellow: #f2c230;
  --zone-red: #e0453a;
  --zone-black: #222222;

  --t1: #8c8c8c;
  --t2: #6aa84f;
  --t3: #38a3a5;
  --t4: #3d7be0;
  --t5: #d64541;
  --t6: #e8912d;
  --t7: #f2d43d;
  --t8: #f5f5f5;

  --q0: #cfcfcf;
  --q1: #8fd16a;
  --q2: #5fb2ff;
  --q3: #c07bff;
  --q4: #f2c230;

  /* Material palette (Albion-like: parchment, dark wood, brass, slate, glossy red). */
  /* Warm peach parchment, darker towards the edges. */
  --parch-hi: #f6dbbb;
  --parch: #f0cda6;
  --parch-lo: #e0ae82;
  --parch-edge: #b0784a;
  --ink: #3a2615;
  --ink-dim: #664a2c;
  --ink-faint: #8a6d4c;
  --wood-hi: #6a4a2e;
  --wood: #45301e;
  --wood-lo: #2c1e12;
  --wood-edge: #140c06;
  --brass-hi: #fbe7a2;
  --brass: #d7a84a;
  --brass-lo: #8a6222;
  --brass-dk: #4a3210;
  --slate-hi: #7a8490;
  --slate: #4b535e;
  --slate-lo: #262b32;
  --red-hi: #f27060;
  --red: #c42b20;
  --red-lo: #7c120d;

  --font: "Fira Sans Condensed", "Arial Narrow", "Trebuchet MS", system-ui, sans-serif;
  /* Titles: a lightly flared, legible serif (window titles, headings, names on paper);
     short capital labels (section heads, column captions) use the small-caps face. */
  --font-title: "Alegreya", "Palatino Linotype", Georgia, serif;
  --font-caps: "Cinzel", "Alegreya", "Palatino Linotype", Georgia, serif;
  --radius: 4px;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(0, 0, 0, 0.55);
  --slot: 48px;
  --ab-slot: 54px;
  /* Recessed wells (lists, grids) and row separators; paper surfaces re-define them. */
  --well: rgba(0, 0, 0, 0.25);
  --line: rgba(63, 50, 32, 0.5);

  /* Procedural textures (inline SVG noise, rasterised once per tile by the browser). */
  --paper-noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .3 0 0 0 0 .14 0 0 0 .5 -.08'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
  --paper-stain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='420' height='420'%3E%3Cfilter id='s'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.012' numOctaves='3' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .55 0 0 0 0 .36 0 0 0 0 .16 1.4 0 0 0 -.62'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23s)' opacity='.5'/%3E%3C/svg%3E");
  --wood-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='w'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.006 .22' numOctaves='3' seed='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .08 0 0 0 0 .05 0 0 0 0 .02 0 0 0 1.3 -.35'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23w)' opacity='.8'/%3E%3C/svg%3E");
  /* Ragged paper edge (left / right strips) for the parchment mask of window bodies and dialogs. */
  --rag-l: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='52'%3E%3Cpath d='M6 0H2.4L1.2 4.5 2.8 9 .7 14.5 2.2 20 .5 26 2 31.5 .9 37 2.6 42.5 1 47.5 2.4 52H6z'/%3E%3C/svg%3E");
  --rag-r: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='52'%3E%3Cpath d='M0 0h3.6l1.2 4.5L3.2 9l2.1 5.5L3.8 20l1.7 6L4 31.5 5.1 37l-1.7 5.5L5 47.5 3.6 52H0z'/%3E%3C/svg%3E");
  --rag-mask: var(--rag-l) left top / 6px 52px repeat-y, var(--rag-r) right 0 top 19px / 6px 52px repeat-y,
    linear-gradient(#000, #000) center / calc(100% - 11px) 100% no-repeat;
  /* Silver: a small stack of coins (prices everywhere). */
  --coin-stack: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cg stroke='%232b3037' stroke-width='.8'%3E%3Cellipse cx='11.6' cy='8.6' rx='3.4' ry='4.9' fill='%23b9bfc6'/%3E%3Cpath d='M1.2 12.2v1.3c0 1.1 2.1 1.9 4.8 1.9s4.8-.8 4.8-1.9v-1.3' fill='%237d858e'/%3E%3Cellipse cx='6' cy='12.2' rx='4.8' ry='1.9' fill='%23dfe3e8'/%3E%3Cpath d='M1.2 9.6v1.3c0 1.1 2.1 1.9 4.8 1.9s4.8-.8 4.8-1.9V9.6' fill='%237d858e'/%3E%3Cellipse cx='6' cy='9.6' rx='4.8' ry='1.9' fill='%23e9ecf0'/%3E%3Cpath d='M1.2 7v1.3c0 1.1 2.1 1.9 4.8 1.9s4.8-.8 4.8-1.9V7' fill='%237d858e'/%3E%3Cellipse cx='6' cy='7' rx='4.8' ry='1.9' fill='%23f6f8fa'/%3E%3C/g%3E%3Cpath d='M3.2 6.4c1.2-.5 3-.6 4.4-.2M12.4 5.2c.6.6.9 1.6.9 2.6' stroke='%23fff' stroke-width='.9' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  --mount-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M9 29c1-6 3-9 3-13-2 0-4 1-6 0-2-1-2-3-1-4l7-7 1-3 2 3c5 0 10 4 10 11v13z' fill='%23d8cdb8' stroke='%23000' stroke-width='1.2' stroke-linejoin='round'/%3E%3Ccircle cx='12' cy='10' r='1.2'/%3E%3C/svg%3E");
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1h10L6 7z' fill='%233a2615' stroke='%23120a04' stroke-width='.8' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* Ink-on-parchment token set: window bodies, tooltips, dialogs and other paper surfaces. */
.panel-body,
.tooltip,
.modal,
.parchment,
.sc-popup,
.sc-menu,
.sc-em-menu,
.st-menu,
.mk-dialog,
.death-box {
  --bg: var(--parch);
  --bg-deep: rgba(96, 62, 28, 0.13);
  --bg-raise: rgba(255, 246, 222, 0.42);
  --bg-hover: rgba(150, 96, 34, 0.12);
  --border: #b08654;
  --border-dim: rgba(110, 72, 34, 0.3);
  --border-bright: #7a5020;
  --gold: #8c4f12;
  --gold-bright: #6e3a0a;
  --gold-dim: #a8804e;
  --text: var(--ink);
  --text-dim: var(--ink-dim);
  --text-faint: var(--ink-faint);
  --good: #3a7a1c;
  --warn: #a85a08;
  --error: #b0261c;
  --info: #8c4f12;
  --well: rgba(118, 76, 32, 0.12);
  --line: rgba(110, 72, 34, 0.24);
  color: var(--ink);
}

/* Dark islands inside paper windows (wooden plaques, the Destiny Board, dark list headers) get
   the dark-ground token set back, so their feature styles stay legible. */
.plaque,
.panel-body .db-head,
.panel-body .db-board,
.panel-body .jr-hero,
.panel-body .sc-tr-col.them {
  --text: #ecdfc2;
  --text-dim: #c0b090;
  --text-faint: #968768;
  --gold: #e0bc62;
  --gold-bright: #f5d98e;
  --gold-dim: #a08650;
  --border: #6b5431;
  --border-dim: #3f3220;
  --border-bright: #9c7c46;
  --bg-raise: #2c241b;
  --bg-hover: #3a2e22;
  --good: #8fd46a;
  --warn: #f0a040;
  --error: #ff6b5b;
  --well: rgba(0, 0, 0, 0.3);
  --line: rgba(255, 220, 160, 0.12);
  color: var(--text);
}

/* ------------------------------------------------------------------ base */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b0907;
  color: var(--text);
  font: 14px/1.35 var(--font);
}

body {
  user-select: none;
  -webkit-user-select: none;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

input,
textarea,
select {
  font: inherit;
  user-select: text;
  -webkit-user-select: text;
}

button {
  font: inherit;
  color: inherit;
}

canvas {
  -webkit-user-drag: none;
}

.hidden {
  display: none !important;
}

.noscript {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #0b0907;
  color: var(--text);
  font-size: 16px;
  text-align: center;
}

/* ------------------------------------------------------------------ layers */

#game {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: #0b0907;
}

#game canvas {
  display: block;
}

#labels {
  position: fixed;
  inset: 0;
  z-index: 5;
  overflow: hidden;
  pointer-events: none;
}

#labels,
#labels * {
  pointer-events: none !important;
}

#ui {
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow: hidden;
  pointer-events: none;
}

#login {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.hud {
  pointer-events: auto;
}

/* ------------------------------------------------------------------ scrollbars */

* {
  scrollbar-width: thin;
  scrollbar-color: #6b5a44 rgba(0, 0, 0, 0.25);
}

.panel-body,
.panel-body *,
.modal * {
  scrollbar-color: #5a616b rgba(110, 72, 34, 0.18);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(90deg, #8a939e, #545c67 55%, #3a4048);
  border: 1px solid #1c1f24;
  border-radius: 5px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(90deg, #d9b764, #a07a2e 55%, #6e5018);
}

.panel-body::-webkit-scrollbar-track,
.panel-body *::-webkit-scrollbar-track {
  background: rgba(110, 72, 34, 0.16);
  box-shadow: inset 0 0 0 1px rgba(90, 58, 26, 0.3);
}

::-webkit-scrollbar-corner {
  background: transparent;
}

/* ------------------------------------------------------------------ panels (wood frame + parchment body) */

.panel {
  position: absolute;
  display: flex;
  flex-direction: column;
  min-width: 240px;
  max-width: calc(100vw - 16px);
  /* Leave the bottom HUD band (ui.js HUD_BOTTOM = 152px) free; the body scrolls instead. Windows
     the game places get --auto-max-h (ui.js autoClampPos) so they also stay below the self frame. */
  max-height: var(--auto-max-h, max(300px, calc(100vh - 168px)));
  /* Thick wood only on the header band; the sides and the bottom are a thin 5 px frame. */
  padding: 0 5px 5px;
  pointer-events: auto;
  color: var(--text);
  background:
    var(--wood-grain),
    linear-gradient(180deg, var(--wood-hi) 0%, var(--wood) 56px, #3a2818 100%);
  border: 1px solid var(--wood-edge);
  border-radius: 12px 14px 12px 13px;
  box-shadow:
    0 16px 36px rgba(0, 0, 0, 0.62),
    0 0 0 1px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 214, 160, 0.22),
    inset 0 0 0 2px rgba(122, 86, 50, 0.4),
    inset 0 -3px 6px rgba(0, 0, 0, 0.35);
}

.panel::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(255, 205, 140, 0.07);
  border-radius: 10px;
  pointer-events: none;
}

.panel.focused {
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 214, 160, 0.26),
    inset 0 0 0 2px rgba(150, 108, 60, 0.5),
    inset 0 -3px 6px rgba(0, 0, 0, 0.35);
}

.panel.panel-anim {
  animation: panel-in 0.14s ease-out;
}

.panel.dragging {
  opacity: 0.93;
}

.panel-title {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: 8px 38px 7px 4px;
  cursor: move;
  touch-action: none;
}

.panel-title.has-medal {
  padding-left: 64px;
}

/* Round portrait medallion (brass ring, dark well, glyph) at the top-left of the header. */
.panel-medal {
  position: absolute;
  left: -3px;
  top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 38%, #5a4a3a 0%, #2a2019 58%, #140e09 100%);
  box-shadow:
    0 0 0 3px #1b120a,
    0 0 0 5px var(--brass),
    0 0 0 6px var(--brass-lo),
    0 0 0 7px #120a04,
    0 4px 10px 6px rgba(0, 0, 0, 0.55),
    inset 0 0 12px rgba(0, 0, 0, 0.9);
  pointer-events: none;
}

.panel-medal::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: linear-gradient(160deg, rgba(255, 240, 190, 0.55), transparent 40%, transparent 70%, rgba(0, 0, 0, 0.35));
  -webkit-mask: radial-gradient(circle, transparent 28px, #000 28.5px);
  mask: radial-gradient(circle, transparent 28px, #000 28.5px);
}

.panel-medal canvas {
  display: block;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.8));
}

/* NPC windows: the NPC's painted bust fills the medallion. */
.panel-medal .medal-face {
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 50%;
}

.panel-medal .medal-face svg {
  display: block;
  width: 100%;
  height: 100%;
}

.panel-title::after {
  content: "";
  position: absolute;
  left: 60px;
  right: 30px;
  bottom: 1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 210, 140, 0.18), transparent);
}

.panel-title-text {
  flex: 1;
  overflow: hidden;
  font-family: var(--font-title);
  font-size: 23px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #f3e2bb;
  text-shadow: 0 2px 2px rgba(0, 0, 0, 0.85), 0 0 12px rgba(0, 0, 0, 0.4);
}

.modal-check {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
}

.panel-notice {
  flex: 0 1 auto;
  min-width: 0;
  margin-left: auto;
  padding: 2px 10px;
  overflow: hidden;
  font-size: 12.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #f3e2bb;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.25s;
}

.panel-notice.show {
  opacity: 1;
}

/* Cleared after its fade (ui.js panelNotice): takes no room from the window title. */
.panel-notice:empty {
  display: none;
}

.panel-notice.notice-good {
  color: #a8ec86;
}

.panel-notice.notice-warn {
  color: #f6cc4a;
}

.panel-notice.notice-error {
  color: #ff9a8a;
}

.panel-key {
  flex: none;
  min-width: 20px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  color: #d9c49a;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 210, 140, 0.2);
  border-radius: 4px;
}

/* Round gold close button with a dark X, sitting on the frame's top-right corner. */
.panel-close {
  position: absolute;
  top: 9px;
  right: -1px;
  width: 28px;
  height: 28px;
  padding: 0 0 2px;
  font: 900 21px/1 var(--font);
  color: #2a1606;
  cursor: pointer;
  background:
    radial-gradient(circle at 42% 30%, #fff6c4 0%, #f6d467 26%, #d09a2a 62%, #8a5a12 100%);
  border: 2px solid #3a2410;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(255, 220, 140, 0.35), 0 3px 6px rgba(0, 0, 0, 0.6), inset 0 -2px 3px rgba(90, 50, 0, 0.5);
  text-shadow: 0 1px 0 rgba(255, 240, 190, 0.6);
  transition: filter 0.12s, transform 0.08s;
}

.panel-close:hover {
  filter: brightness(1.12) saturate(1.1);
}

.panel-close:active {
  transform: scale(0.94);
}

.panel-body {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  padding: 12px;
  overflow: auto;
  background:
    var(--paper-noise),
    var(--paper-stain),
    radial-gradient(ellipse 120% 90% at 50% 35%, var(--parch-hi) 0%, var(--parch) 52%, var(--parch-lo) 100%);
  border-radius: 7px 10px 8px 9px / 9px 7px 10px 8px;
  box-shadow:
    inset 0 0 0 1px rgba(92, 56, 20, 0.5),
    inset 0 0 38px rgba(150, 78, 26, 0.5),
    inset 0 0 4px 1px rgba(110, 56, 18, 0.55),
    0 1px 0 rgba(255, 220, 160, 0.16);
  /* Torn paper: ragged left and right edges. */
  -webkit-mask: var(--rag-mask);
  mask: var(--rag-mask);
}

/* Ink needs no drop shadow: the dark-theme text shadows of feature styles are dropped on paper
   (buttons, item badges and anything drawn on a dark chip bring their own back below). */
#ui .panel-body *,
#ui .tooltip *,
#ui .modal *,
#ui .sc-popup *,
#ui .sc-menu *,
#ui .sc-em-menu *,
#ui .st-menu * {
  text-shadow: none;
}

.section-title {
  margin: 12px 0 6px;
  padding-bottom: 3px;
  font-family: var(--font-title);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #5a3312;
  border-bottom: 1px solid var(--border-dim);
}

.muted {
  color: var(--text-faint);
}

/* ------------------------------------------------------------------ buttons, tabs, inputs */

/* Secondary: slate pill with a steel rim. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 29px;
  padding: 3px 16px;
  font: 600 13.5px/1.1 var(--font);
  letter-spacing: 0.02em;
  color: #f1e3bf;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.85);
  cursor: pointer;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.04) 48%, transparent 52%),
    linear-gradient(180deg, var(--slate-hi) 0%, var(--slate) 50%, var(--slate-lo) 100%);
  border: 1px solid #101216;
  border-radius: 999px;
  box-shadow: 0 0 0 1.5px #9aa1aa, 0 0 0 2.5px #2a2d32, 0 2px 4px 2px rgba(0, 0, 0, 0.3), inset 0 -2px 3px rgba(0, 0, 0, 0.3);
  transition: filter 0.12s, box-shadow 0.12s;
}

#ui .btn,
#ui .btn * {
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.85);
}

.btn:hover:not(:disabled) {
  filter: brightness(1.14);
  box-shadow: 0 0 0 1.5px #d8c07a, 0 0 0 2.5px #2a2d32, 0 2px 6px 2px rgba(0, 0, 0, 0.3), inset 0 -2px 3px rgba(0, 0, 0, 0.3);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:focus-visible,
.tab:focus-visible,
.menu-btn:focus-visible,
.chat-tab:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.btn:disabled {
  opacity: 0.5;
  filter: grayscale(0.6);
  cursor: not-allowed;
}

/* Primary: glossy red pill ("Buy", "Craft", "Update Order"). */
.btn.primary {
  color: #fff3dc;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.42) 0%, rgba(255, 255, 255, 0.08) 46%, transparent 52%),
    radial-gradient(ellipse 70% 60% at 50% 100%, rgba(255, 120, 90, 0.45), transparent 70%),
    linear-gradient(180deg, var(--red-hi) 0%, var(--red) 48%, var(--red-lo) 100%);
  border-color: #2a0604;
}

.btn.primary:hover:not(:disabled) {
  filter: brightness(1.12) saturate(1.08);
}

.btn.danger {
  color: #ffe4dc;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22) 0%, transparent 50%),
    linear-gradient(180deg, #8e3026 0%, #5c150f 55%, #350906 100%);
  border-color: #1a0503;
}

.btn.small {
  min-height: 23px;
  padding: 1px 12px;
  font-size: 12.5px;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

/* Round -/+ buttons (sliders, price fields) and round refresh buttons. */
.btn-round,
.round-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 24px;
  height: 24px;
  padding: 0;
  font: 800 15px/1 var(--font);
  color: #f3e3bd;
  cursor: pointer;
  background: radial-gradient(circle at 45% 32%, #8d96a2, #4b535e 55%, #22272e);
  border: 1px solid #0e1013;
  border-radius: 50%;
  box-shadow: 0 0 0 1.5px #a8aeb6, 0 0 0 2.5px #24272c, inset 0 -2px 2px rgba(0, 0, 0, 0.35);
}

.btn-round:hover,
.round-btn:hover {
  filter: brightness(1.18);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
  padding: 0 4px;
  border-bottom: 2px solid rgba(110, 72, 34, 0.35);
}

.tab {
  position: relative;
  bottom: -2px;
  padding: 5px 14px 4px;
  font: 600 13.5px var(--font);
  color: var(--text-dim);
  cursor: pointer;
  background: linear-gradient(180deg, rgba(120, 80, 38, 0.2), rgba(120, 80, 38, 0.08));
  border: 1px solid rgba(110, 72, 34, 0.35);
  border-bottom: 2px solid transparent;
  border-radius: 8px 8px 0 0;
}

.tab:hover {
  color: var(--text);
  background: linear-gradient(180deg, rgba(255, 245, 220, 0.4), rgba(255, 245, 220, 0.15));
}

.tab.active {
  color: #4a2a10;
  background: linear-gradient(180deg, #fbeccb, var(--parch-hi));
  border-color: #9c7446;
  border-bottom-color: var(--parch-hi);
  box-shadow: inset 0 2px 0 #b8322a;
}

/* Side tabs: square wooden tabs sticking out of a window's right edge (icon + short label).
   A window moves its .tabs.side-tabs bar into the panel element (outside the scrolling body). */
.side-tabs {
  position: absolute;
  left: calc(100% - 3px);
  top: 70px;
  z-index: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: none;
}

.side-tabs .tab {
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  width: 58px;
  min-height: 56px;
  padding: 5px 4px 4px 6px;
  font-size: 11px;
  line-height: 1.1;
  text-align: center;
  color: #e8d3a4;
  background: var(--wood-grain), linear-gradient(90deg, #2e1f13, var(--wood) 30%, var(--wood-hi));
  border: 1px solid var(--wood-edge);
  border-left: none;
  border-radius: 0 10px 10px 0;
  box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 210, 150, 0.18);
}

#ui .side-tabs .tab {
  text-shadow: 0 1px 2px #000;
}

.side-tabs .tab:hover {
  color: #fff1cc;
  background: var(--wood-grain), linear-gradient(90deg, #3a2818, #5a3e26 30%, #7a5634);
}

.side-tabs .tab.active {
  color: #3a2212;
  background: var(--paper-noise), linear-gradient(90deg, #d9b77a, var(--parch-hi) 35%, var(--parch));
  border-color: #3a2410;
  box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.45), inset 3px 0 0 #b8322a;
}

#ui .side-tabs .tab.active {
  text-shadow: none;
}

.side-tabs .tab canvas {
  display: block;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.8));
}

/* Pill inputs: light parchment field in a dark slate rim (search, amounts, prices, dropdowns). */
.input,
input[type="text"],
input[type="number"],
input[type="search"],
input[type="password"],
select,
textarea {
  min-height: 28px;
  padding: 4px 12px;
  color: #2e1d0e;
  background: linear-gradient(180deg, #fbefd2 0%, #ecd4a4 100%);
  border: 2px solid #474d56;
  border-radius: 999px;
  outline: none;
  box-shadow: 0 0 0 1px #16181c, inset 0 1px 3px rgba(80, 48, 16, 0.4), 0 1px 0 1px rgba(255, 235, 190, 0.12);
}

textarea {
  border-radius: 10px;
}

select {
  padding-right: 28px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background:
    var(--select-arrow) no-repeat right 10px center / 11px 7px,
    linear-gradient(180deg, #fbefd2 0%, #ecd4a4 100%);
}

select option {
  color: #2e1d0e;
  background: #f3e0b8;
}

.input:focus,
input[type="text"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  border-color: #8a6a2c;
  box-shadow: 0 0 0 1px #16181c, 0 0 0 3px rgba(240, 200, 110, 0.45), inset 0 1px 3px rgba(80, 48, 16, 0.4);
}

.input:disabled,
input:disabled,
select:disabled {
  opacity: 0.55;
}

::placeholder {
  color: #9a7f5c;
}

/* Sliders: slate groove, brass knob. */
input[type="range"] {
  height: 20px;
  margin: 0;
  cursor: pointer;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  background: linear-gradient(180deg, #1d2127, #4b535e);
  border: 1px solid #0d0f12;
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(160, 166, 174, 0.55);
}

input[type="range"]::-moz-range-track {
  height: 8px;
  background: linear-gradient(180deg, #1d2127, #4b535e);
  border: 1px solid #0d0f12;
  border-radius: 4px;
}

input[type="range"]::-moz-range-progress {
  height: 8px;
  background: linear-gradient(180deg, #e8c870, #a07424);
  border-radius: 4px;
}

input[type="range"]::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  margin-top: -6px;
  background: radial-gradient(circle at 40% 32%, #fff3bf, #e0b04a 45%, #8a5a12);
  border: 1px solid #2a1a06;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  -webkit-appearance: none;
  appearance: none;
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: radial-gradient(circle at 40% 32%, #fff3bf, #e0b04a 45%, #8a5a12);
  border: 1px solid #2a1a06;
  border-radius: 50%;
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: #a8321f;
}

/* Metal-framed column headers for list tables (market, bank, guild lists). */
.col-head,
.panel-body th {
  padding: 3px 10px;
  font: 600 12.5px var(--font);
  text-align: left;
  color: #3a2615;
  background: linear-gradient(180deg, #f5e3bd, #dcc08c);
  border: 1.5px solid #5d646e;
  border-radius: 999px;
  box-shadow: 0 0 0 1px #1c1f24, inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* ------------------------------------------------------------------ item slots */

.slot {
  position: relative;
  flex: 0 0 auto;
  width: var(--slot);
  height: var(--slot);
  overflow: hidden;
  cursor: pointer;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 244, 214, 0.25), rgba(110, 70, 30, 0.1) 70%),
    rgba(120, 78, 36, 0.22);
  border: 1px solid rgba(88, 56, 24, 0.55);
  border-radius: 7px;
  box-shadow: inset 0 2px 5px rgba(70, 40, 12, 0.45), 0 1px 0 rgba(255, 238, 200, 0.45);
  transition: box-shadow 0.1s, filter 0.1s;
}

.slot > canvas,
.slot > .icon {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.slot:not(.empty) {
  background: #2a2219;
  border-color: rgba(30, 20, 10, 0.8);
}

.slot.empty {
  cursor: default;
}

.slot:hover {
  box-shadow: inset 0 2px 5px rgba(70, 40, 12, 0.45), 0 0 0 2px rgba(255, 214, 110, 0.85), 0 0 10px rgba(255, 200, 90, 0.55);
}

.slot:not(.empty):hover {
  filter: brightness(1.08);
}

.slot.drop-hover,
.ab-slot.drop-hover {
  outline: 2px solid #ffd766;
  outline-offset: -1px;
  box-shadow: 0 0 12px rgba(255, 215, 110, 0.75);
}

.slot.drop-bad,
.ab-slot.drop-bad {
  outline: 2px solid var(--error);
  outline-offset: -1px;
}

.slot.drag-source {
  opacity: 0.35;
}

/* DOM badges for feature-built slots (canvas icons draw their own). */
.slot .badge,
.slot .count {
  position: absolute;
  right: 3px;
  bottom: 2px;
  min-width: 16px;
  padding: 0 3px;
  font: 700 11px/15px var(--font);
  text-align: center;
  color: #fff;
  background: rgba(15, 12, 10, 0.78);
  border: 1px solid rgba(190, 196, 204, 0.7);
  border-radius: 8px;
  pointer-events: none;
}

.slot .tier-badge {
  position: absolute;
  left: 2px;
  top: 2px;
  font-family: Georgia, serif;
  font-size: 10px;
  font-weight: bold;
  color: #f3e7cc;
  pointer-events: none;
}

#ui .slot .badge,
#ui .slot .count,
#ui .slot .tier-badge {
  text-shadow: 0 0 2px #000, 0 1px 1px #000;
}

.slot.tier-1 { --tier: #7d7f82; }
.slot.tier-2 { --tier: #7d7f82; }
.slot.tier-3 { --tier: #4f8a3a; }
.slot.tier-4 { --tier: #3f6fae; }
.slot.tier-5 { --tier: #a8392f; }
.slot.tier-6 { --tier: #c8782a; }
.slot.tier-7 { --tier: #c9a633; }
.slot.tier-8 { --tier: #c9ccd2; }

.slot[class*="tier-"] {
  background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--tier) 80%, #fff 20%), color-mix(in srgb, var(--tier) 70%, #000 30%) 80%);
}

.slot.q-1 { box-shadow: inset 0 0 0 2px var(--q1); }
.slot.q-2 { box-shadow: inset 0 0 0 2px var(--q2); }
.slot.q-3 { box-shadow: inset 0 0 0 2px var(--q3); }
.slot.q-4 { box-shadow: inset 0 0 0 2px var(--q4); }

.drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 2000;
  width: var(--slot);
  height: var(--slot);
  pointer-events: none !important;
  opacity: 0.92;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.7));
}

.drag-ghost canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  border-radius: 7px;
}

.drag-ghost.over-world {
  opacity: 0.7;
}

.drag-ghost.over-world::after {
  content: "Drop";
  position: absolute;
  left: 50%;
  top: calc(100% + 2px);
  transform: translateX(-50%);
  padding: 0 8px;
  font-size: 11px;
  font-weight: bold;
  color: #ffe6e0;
  background: linear-gradient(180deg, #c42b20, #7c120d);
  border-radius: 999px;
}

body.ui-dragging,
body.ui-dragging * {
  cursor: grabbing !important;
}

/* ------------------------------------------------------------------ tooltip (parchment, dark name band) */

.tooltip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1000;
  min-width: 160px;
  max-width: 330px;
  padding: 0 12px 10px;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.38;
  pointer-events: none !important;
  background:
    var(--paper-noise),
    linear-gradient(180deg, var(--parch-hi), var(--parch) 60%, var(--parch-lo));
  border: 2px solid #2e1f13;
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(210, 170, 110, 0.35), 0 10px 26px rgba(0, 0, 0, 0.7), inset 0 0 14px rgba(120, 72, 22, 0.35);
}

/* The first line of a tooltip is its header: a dark wooden band, name in the tier / ability colour
   (set inline) with an accent line (--tc) underneath. */
.tooltip .tt > .tt-name:first-child {
  margin: 0 -12px 6px;
  padding: 7px 12px 6px;
  color: #f3e2bb;
  background: var(--wood-grain), linear-gradient(180deg, #4e3624, #2b1c10);
  border-bottom: 2px solid var(--tc, #b08a45);
}

#ui .tooltip .tt > .tt-name:first-child,
#ui .tooltip .tt > .tt-name:first-child * {
  text-shadow: 0 1px 2px #000;
}

/* Item tooltips: the item tile at the left of the band, name / tier / quality / type beside it. */
.tooltip .tt > .tt-name.tt-band {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px 7px 8px;
}

.tt-icon {
  flex: none;
  width: 48px;
  height: 48px;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.6));
}

.tt-band-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.tt-title {
  font-size: 16.5px;
}

.tt-band-sub {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  color: #d9c7a0;
}

.tt-ip-row {
  margin-top: 2px;
  font-size: 13.5px;
}

.tt-ip-row > b {
  font-size: 15px;
  color: #7a2a0c !important;
}

.tt-item .tt-meta .tt-stat > b {
  font-weight: 600;
}

.tt-item .tt-desc {
  font-size: 12px;
  line-height: 1.35;
}

/* Tooltips without a .tt header block (plain text or other markup) keep a normal top padding. */
.tooltip:not(:has(> .tt:first-child > .tt-name:first-child)) {
  padding-top: 9px;
}

.tooltip .tt + .tt-hint,
.tooltip .tt + .tt-good,
.tooltip .tt + div {
  margin-top: 6px;
}

.tt-name {
  font-family: var(--font-title);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  color: #5a3312;
}

.tt-count {
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: normal;
  color: #d9c7a0;
}

.tt-sub {
  margin-top: 1px;
  font-size: 12.5px;
  color: var(--text-dim);
}

.tt-ip {
  margin-top: 5px;
}

.tt-ip b {
  color: #7a2a0c;
}

.tt-sep {
  height: 1px;
  margin: 7px 0;
  background: linear-gradient(90deg, transparent, rgba(110, 72, 34, 0.55), transparent);
}

.tt-stats {
  display: grid;
  gap: 1px;
  margin-top: 4px;
}

.tt-stat {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.tt-stat > span {
  color: var(--text-dim);
}

.tt-stat > b {
  font-weight: 700;
  color: #2a1a0c;
  white-space: nowrap;
}

.tt-stat.tt-buff > b {
  color: var(--good);
  text-align: right;
  white-space: normal;
}

.tt-label {
  margin-bottom: 3px;
  font-family: var(--font-caps);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}

.tt-spell {
  margin: 2px 0;
}

.tt-key {
  display: inline-block;
  min-width: 18px;
  margin-right: 6px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: bold;
  text-align: center;
  color: #f3e2bb;
  background: linear-gradient(180deg, #5b636e, #2c3139);
  border: 1px solid #111317;
  border-radius: 8px;
}

.tt-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  color: var(--text-dim);
}

.tt-dim {
  color: var(--text-faint);
}

.tt-good,
.tt-req.ok {
  color: var(--good);
}

.tt-bad,
.tt-req.bad {
  color: var(--error);
}

.tt-warn {
  color: var(--warn);
}

.tt-req {
  margin-top: 4px;
  font-weight: bold;
}

.tt-desc {
  margin-top: 6px;
  font-style: italic;
  color: #5e4328;
}

.tt-hint {
  margin-top: 6px;
  padding-top: 5px;
  font-size: 12px;
  color: var(--text-faint);
  border-top: 1px dashed rgba(110, 72, 34, 0.45);
}

/* Coloured words on paper (enchantment, quality) sit on small dark chips: their colours are made
   for dark ground, and a halo on parchment only smears them. */
#ui .tt-glow,
#ui .ink-halo {
  display: inline-block;
  padding: 0 6px;
  line-height: 1.5;
  text-shadow: none;
  background: rgba(38, 25, 14, 0.9);
  border-radius: 999px;
  box-shadow: inset 0 1px 0 rgba(255, 230, 190, 0.12);
}

/* ------------------------------------------------------------------ toasts */

#toasts {
  position: fixed;
  top: 94px;
  left: 50%;
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: min(560px, 90vw);
  transform: translateX(-50%);
  pointer-events: none !important;
  transition: top 0.2s ease;
}

/* Keep toasts clear of the target frame while one is shown (at narrow widths it sits centred). */
#ui:has(#hud-target:not(.hidden)) #toasts {
  top: 108px;
}

/* ...and below the zone banner while it shows (arrival toasts: welcome, home city). */
#ui:has(#zone-banner.show) #toasts {
  top: calc(max(96px, 13vh) + 118px);
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 6px 22px;
  font-weight: 600;
  font-size: 14px;
  color: #f3e2bb;
  text-align: center;
  text-shadow: 0 1px 2px #000;
  background: linear-gradient(90deg, rgba(20, 14, 9, 0), rgba(20, 14, 9, 0.88) 14%, rgba(20, 14, 9, 0.88) 86%, rgba(20, 14, 9, 0));
  border-top: 1px solid var(--toast-color, var(--gold));
  border-bottom: 1px solid var(--toast-color, var(--gold));
  border-image: linear-gradient(90deg, transparent, var(--toast-color, var(--gold)) 20%, var(--toast-color, var(--gold)) 80%, transparent) 1;
  animation: toast-in 0.18s ease-out;
  transition: opacity 0.35s, transform 0.35s;
}

.toast-info {
  --toast-color: var(--gold);
}

.toast-good {
  --toast-color: var(--good);
  color: #dcf7cc;
}

.toast-warn {
  --toast-color: var(--warn);
  color: #ffe4c2;
}

.toast-error {
  --toast-color: var(--error);
  color: #ffd4cc;
}

.toast.out {
  opacity: 0;
  transform: translateY(-6px);
}

.toast-count {
  font-size: 12px;
  color: var(--text-dim);
}

/* ------------------------------------------------------------------ modals & overlays */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 950;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  background: rgba(5, 3, 2, 0.5);
  animation: fade-in 0.12s ease-out;
}

.modal {
  min-width: 320px;
  max-width: min(460px, calc(100vw - 32px));
  padding: 18px 20px 16px;
  background:
    var(--paper-noise),
    radial-gradient(ellipse at 50% 35%, var(--parch-hi), var(--parch) 60%, var(--parch-lo));
  border: 8px solid var(--wood);
  border-radius: 14px;
  box-shadow:
    0 0 0 1px var(--wood-edge),
    0 0 0 2px rgba(150, 108, 60, 0.45),
    inset 0 0 0 1px rgba(92, 56, 20, 0.6),
    inset 0 0 20px rgba(120, 72, 22, 0.45),
    var(--shadow);
  animation: panel-in 0.14s ease-out;
}

.modal-text {
  margin-bottom: 16px;
  font-size: 14.5px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.modal-input {
  width: 100%;
  margin-bottom: 14px;
}

.modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.disconnect-overlay {
  position: fixed;
  inset: 0;
  z-index: 980;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.7);
  animation: fade-in 0.3s ease-out;
}

.disconnect-box {
  max-width: 420px;
  padding: 22px 30px;
  text-align: center;
  color: var(--ink);
  background: var(--paper-noise), linear-gradient(180deg, var(--parch-hi), var(--parch-lo));
  border: 8px solid var(--wood);
  border-radius: 14px;
  box-shadow: 0 0 0 1px var(--wood-edge), var(--shadow);
}

.disconnect-title {
  margin-bottom: 8px;
  font-family: var(--font-title);
  font-size: 26px;
  font-weight: 700;
  color: #9a2016;
}

.disconnect-text {
  margin-bottom: 16px;
  color: var(--ink-dim);
}

/* ------------------------------------------------------------------ HUD: self frame (top-left) */

#hud-self {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 20;
  width: 300px;
  pointer-events: none;
}

#hud-self > * {
  pointer-events: auto;
}

.hs-main {
  position: relative;
  height: 84px;
}

/* Portrait: painted bust in a steel/brass double ring. */
.hs-portrait,
.tf-portrait {
  position: absolute;
  left: 2px;
  top: 2px;
  z-index: 2;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #141a20;
  box-shadow:
    0 0 0 3px #1a120a,
    0 0 0 6px var(--brass),
    0 0 0 7px var(--brass-lo),
    0 0 0 9px #2e3238,
    0 0 0 10px #0c0d0f,
    0 5px 12px 8px rgba(0, 0, 0, 0.45);
}

.hs-portrait::after,
.tf-portrait::after {
  content: "";
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  background: conic-gradient(from 210deg, rgba(255, 244, 200, 0.7), transparent 18%, transparent 50%, rgba(255, 240, 190, 0.35) 62%, transparent 75%);
  -webkit-mask: radial-gradient(circle, transparent 42px, #000 43px);
  mask: radial-gradient(circle, transparent 42px, #000 43px);
  pointer-events: none;
}

.hs-face,
.tf-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 50%;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.85);
}

.hs-face svg,
.tf-face svg {
  display: block;
  width: 100%;
  height: 100%;
}

.tf-face {
  background: radial-gradient(circle at 50% 38%, #4c3a2c, #1c140e 70%);
}

.hs-plate,
.tf-plate {
  position: absolute;
  left: 76px;
  top: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 204px;
}

/* Parchment name ribbon with a steel end cap. */
.hs-name,
.tf-top {
  position: relative;
  display: flex;
  align-items: center;
  height: 25px;
  padding: 0 26px 0 16px;
  background:
    var(--paper-noise),
    linear-gradient(180deg, #f8e7c2 0%, #e4c58e 60%, #cfa86a 100%);
  border: 1px solid #3a2410;
  border-left: none;
  border-radius: 0 12px 12px 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.55), inset 0 -2px 3px rgba(120, 72, 20, 0.35);
}

.hs-name-text {
  flex: 1;
  overflow: hidden;
  font-family: var(--font);
  font-size: 16px;
  letter-spacing: 0.02em;
  text-align: center;
  font-weight: 700;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #3a2212;
}

.hud-bars {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 10px;
}

/* Bars: dark metal trough, arrow-tip right end, numbers centred. */
.bar {
  position: relative;
  height: 17px;
  overflow: hidden;
  background: linear-gradient(180deg, #0b0806, #231a13);
  border: 1px solid #06040a;
  border-radius: 2px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(160, 166, 174, 0.35);
}

.hud-bars .bar {
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 0 100%);
  border-radius: 0;
}

.bar-fill,
.bar-chip {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
}

.bar-fill {
  transition: width 0.12s linear;
}

/* Thin segment ticks over the fill (Albion-style notched bars). */
.bar-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 45%, rgba(0, 0, 0, 0.18)),
    repeating-linear-gradient(90deg, transparent 0 17px, rgba(0, 0, 0, 0.28) 17px 18px);
}

.bar-chip {
  background: rgba(255, 240, 220, 0.55);
  transition: width 0.6s ease-in 0.35s;
}

.bar-hp .bar-fill {
  background: linear-gradient(180deg, #f0645a 0%, var(--hp) 48%, #7e1812 100%);
}

.bar-en {
  height: 14px;
}

.bar-en .bar-fill {
  background: linear-gradient(180deg, #74b6f6, var(--energy) 52%, #174c8c);
}

.bar-en .bar-chip {
  background: rgba(200, 230, 255, 0.35);
}

.bar-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-right: 6px;
  font: 700 12.5px/1 var(--font);
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 0 0 2px #000, 0 1px 1px #000, 0 0 4px #000;
  font-variant-numeric: tabular-nums;
}

.bar-en .bar-text {
  font-size: 11px;
}

#hud-self.low-hp .bar-hp {
  animation: pulse-red 1s infinite;
}

/* Buff / debuff icons below the portrait (combat/buffs.js mounts its timed row here). */
.hud-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  /* Reserved height: the party frames below do not jump when the first buff appears. */
  min-height: 32px;
  margin: 8px 0 0 6px;
}

.hud-status > * {
  pointer-events: auto;
}

.hud-selffx,
.tf-fx {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.fx-icon {
  position: relative;
  overflow: hidden;
  border-radius: 50%;
  box-shadow: 0 0 0 1.5px #b08a45, 0 0 0 2.5px #120a04, 0 2px 4px rgba(0, 0, 0, 0.6);
}

.fx-icon canvas {
  display: block;
}

.fx-icon.cc {
  box-shadow: 0 0 0 1.5px #ff6b5b, 0 0 0 2.5px #120a04, 0 0 6px rgba(255, 70, 50, 0.7);
}

.hud-flags {
  display: flex;
  gap: 4px;
}

.flag-badge {
  padding: 1px 9px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid;
  border-radius: 10px;
}

.flag-badge.pvp {
  color: #ffb0a8;
  border-color: #e0453a;
}

.flag-badge.criminal {
  color: #fff;
  background: rgba(160, 20, 10, 0.75);
  border-color: #ff3b2b;
  animation: pulse-red 1.4s infinite;
}

/* ------------------------------------------------------------------ HUD: target frame (beside the self frame) */

#hud-target {
  position: fixed;
  top: 8px;
  left: 312px;
  z-index: 20;
  width: 290px;
  min-height: 86px;
  pointer-events: auto;
}

.tf-main {
  position: relative;
  min-height: 84px;
}

.tf-portrait {
  width: 70px;
  height: 70px;
  top: 6px;
  box-shadow:
    0 0 0 3px #1a120a,
    0 0 0 5px var(--tf-ring, #9aa1aa),
    0 0 0 6px #3a3e44,
    0 0 0 7px #0c0d0f,
    0 5px 12px 8px rgba(0, 0, 0, 0.4);
}

.tf-portrait::after {
  inset: -7px;
  -webkit-mask: radial-gradient(circle, transparent 37px, #000 38px);
  mask: radial-gradient(circle, transparent 37px, #000 38px);
}

#hud-target.tf-mob,
#hud-target.tf-hostile {
  --tf-ring: #c0473a;
}

#hud-target.tf-elite {
  --tf-ring: #e8a640;
}

.tf-face canvas {
  display: block;
}

.tf-plate {
  left: 66px;
  top: 8px;
  width: 218px;
}

.tf-top {
  gap: 6px;
  padding-right: 4px;
}

.tf-name {
  flex: 1;
  overflow: hidden;
  font-family: var(--font);
  font-size: 15.5px;
  letter-spacing: 0.02em;
  font-weight: 700;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The name reads as ink on the ribbon; the kind / tier colour shows on the portrait ring. */
#hud-target .tf-name {
  color: #3a2212 !important;
}

.tf-badge {
  flex: none;
  padding: 0 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #ffe6a6;
  background: linear-gradient(180deg, #a4621c, #5e3408);
  border: 1px solid #2a1604;
  border-radius: 8px;
}

/* An AI-played resident's "KI" badge: parchment like its nameplate badge. */
#hud-target.tf-ai .tf-badge {
  color: #2a1a04;
  background: linear-gradient(180deg, #fbf0d2, #d8b878);
  border-color: #3a2410;
  border-radius: 3px;
}

.tf-close {
  flex: none;
  width: 18px;
  height: 18px;
  padding: 0 0 1px;
  font: 900 14px/1 var(--font);
  color: #2a1606;
  cursor: pointer;
  background: radial-gradient(circle at 42% 30%, #fff6c4, #e6be55 40%, #8a5a12);
  border: 1px solid #3a2410;
  border-radius: 50%;
}

.tf-close:hover {
  filter: brightness(1.12);
}

.tf-plate .bar-target {
  margin-left: 10px;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 0 100%);
  border-radius: 0;
}

.tf-sub {
  margin: 1px 0 0 12px;
  overflow: hidden;
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #e8dcc4;
  text-shadow: 0 1px 2px #000, 0 0 3px #000;
}

.bar-target {
  height: 16px;
}

.bar-target .bar-fill {
  background: linear-gradient(180deg, #f0645a, #b0301f 55%, #6e150d);
}

#hud-target.tf-player:not(.tf-hostile) .bar-target .bar-fill {
  background: linear-gradient(180deg, #74b6f6, #2f7fd6 55%, #174c8c);
}

#hud-target.tf-dead .tf-name {
  opacity: 0.6;
  text-decoration: line-through;
}

#hud-target.tf-dead .tf-face {
  filter: grayscale(1) brightness(0.6);
}

.tf-cast {
  position: relative;
  height: 12px;
  margin: 3px 0 0 10px;
  overflow: hidden;
  background: #0b0806;
  border: 1px solid #000;
  border-radius: 6px;
}

.tf-cast-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  background: linear-gradient(180deg, #f5d98a, #b3822a);
}

.tf-cast-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 2px #000;
}

.tf-fx {
  margin: 0 0 0 76px;
}

.tf-fx:not(:empty) {
  margin-top: 2px;
}

/* ------------------------------------------------------------------ HUD: bottom centre (ability bar) */

#hud-bottom {
  position: fixed;
  left: 50%;
  bottom: 6px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transform: translateX(-50%);
  pointer-events: none;
}

#hud-bottom > * {
  pointer-events: auto;
}

#hud-bottom > .hud-cast {
  pointer-events: none;
}

.hud-cast {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 16px);
  width: 300px;
  height: 18px;
  overflow: hidden;
  transform: translateX(-50%);
  background: #0b0806;
  border: 1px solid #06040a;
  border-radius: 9px;
  box-shadow: 0 0 0 1.5px #9aa1aa, 0 0 0 2.5px #1c1f24, 0 0 10px rgba(0, 0, 0, 0.6);
}

.hud-cast-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  background: linear-gradient(180deg, #f8e19a, #d09a2e 55%, #8a5a12);
}

.hud-cast-label,
.hud-cast-time {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  font-size: 12px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 3px #000, 0 1px 1px #000;
}

.hud-cast-label {
  left: 10px;
}

.hud-cast-time {
  right: 10px;
  font-variant-numeric: tabular-nums;
}

.hud-abilities {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 4px 14px 0;
  background: radial-gradient(ellipse 60% 70% at 50% 60%, rgba(0, 0, 0, 0.35), transparent 75%);
}

/* Round metal ability button: dark well with the icon, steel rim (.ab-ring), key letter below. */
.ab-slot {
  position: relative;
  flex: none;
  width: var(--ab-slot);
  height: var(--ab-slot);
  margin-bottom: 15px;
  cursor: pointer;
  border-radius: 50%;
  background: radial-gradient(circle, #1f262d, #080a0c);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.7);
  transition: transform 0.06s, filter 0.12s;
}

.ab-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background:
    conic-gradient(from 200deg, #f4f6f8, #7e8792 12%, #3c434c 30%, #aab2bb 48%, #555d67 62%, #e3e7eb 80%, #7a838e 92%, #f4f6f8);
  -webkit-mask: radial-gradient(circle, transparent calc(50% - 4.5px), #000 calc(50% - 4px));
  mask: radial-gradient(circle, transparent calc(50% - 4.5px), #000 calc(50% - 4px));
  box-shadow: inset 0 0 0 1px #111;
  pointer-events: none;
}

.ab-slot:hover {
  filter: brightness(1.15);
}

.ab-slot:hover .ab-ring {
  background: conic-gradient(from 200deg, #fff6c8, #c89a3c 14%, #6e4c12 30%, #f0cf78 48%, #8a6220 62%, #fff0b0 80%, #a8802e 92%, #fff6c8);
}

.ab-slot.pressed {
  transform: scale(0.92);
}

.ab-icon {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 50%;
}

.ab-icon canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.ab-cd,
.ab-cd-text,
.ab-key,
.ab-ring {
  pointer-events: none;
}

.ab-cd {
  position: absolute;
  inset: 0;
  border-radius: 50%;
}

.ab-cd-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 700 19px/1 var(--font);
  color: #fff;
  text-shadow: 0 0 3px #000, 0 0 6px #000, 0 1px 1px #000;
  font-variant-numeric: tabular-nums;
}

.ab-key {
  position: absolute;
  left: 50%;
  top: calc(100% + 1px);
  transform: translateX(-50%);
  font: 800 12.5px/14px var(--font);
  color: #f3e6c8;
  text-shadow: -1px 0 0 #000, 1px 0 0 #000, 0 -1px 0 #000, 0 1px 0 #000, 0 1px 3px #000;
}

/* Mount button (A): the equipped mount's tile in a round well, greyed without a mount. */
.ab-slot.ab-mount {
  margin-right: 6px;
}

.ab-slot.ab-mount.empty .ab-icon {
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.06), transparent 62%),
    #0b0d10;
}

.ab-slot.ab-mount.empty .ab-icon::before {
  content: "";
  position: absolute;
  inset: 22%;
  opacity: 0.35;
  background: var(--mount-glyph) center / contain no-repeat;
}

.ab-slot.ab-mount.on .ab-ring {
  background: conic-gradient(from 200deg, #fff6c8, #c89a3c 14%, #6e4c12 30%, #f0cf78 48%, #8a6220 62%, #fff0b0 80%, #a8802e 92%, #fff6c8);
}

.ab-slot.empty {
  cursor: default;
}

.ab-slot.empty .ab-icon {
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.05), transparent 60%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.025) 0 5px, transparent 5px 10px);
}

.ab-slot.nomana .ab-icon::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(20, 50, 130, 0.45);
  pointer-events: none;
}

.ab-slot.locked .ab-icon,
.ab-slot.disabled .ab-icon {
  filter: grayscale(1) brightness(0.5);
}

.ab-slot.ready-flash {
  animation: ready-flash 0.45s ease-out;
}

.ab-slot.consumable {
  --ab-c: calc(var(--ab-slot) - 10px);
  width: var(--ab-c);
  height: var(--ab-c);
  margin-top: 5px;
}

.ab-sep {
  align-self: center;
  width: 8px;
  height: 8px;
  margin: 0 4px 16px;
  background: linear-gradient(135deg, var(--brass-hi), var(--brass-lo));
  border: 1px solid #1a1006;
  transform: rotate(45deg);
}

/* ------------------------------------------------------------------ HUD: zone banner */

#zone-banner {
  --zone-color: var(--gold);
  position: fixed;
  /* Below the portrait / target frames and well above the player's nameplate, also at 720p. */
  top: max(96px, 13%);
  left: 50%;
  /* Above the HUD boxes (the dungeon panel, tracker); ui/hud.js fades it out as soon as a window
     opens, so it never sits cut off under one. It never takes input. */
  z-index: 30;
  text-align: center;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(-50%);
  pointer-events: none !important;
}

#zone-banner.show {
  animation: zone-banner 4.2s ease forwards;
}

#zone-banner.gone {
  opacity: 0 !important;
  transition: opacity 0.2s;
  animation: none;
}

.zb-type {
  display: inline-block;
  margin-bottom: 4px;
  padding: 2px 18px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--zone-color);
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.9), 0 1px 1px #000;
  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.62), transparent);
  border-top: 1px solid var(--zone-color);
  border-bottom: 1px solid var(--zone-color);
}

.zb-name {
  font-family: var(--font-title);
  font-size: 52px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #f8ecd0;
  text-shadow: 0 3px 0 #000, 0 0 24px rgba(0, 0, 0, 0.9), 0 0 40px var(--zone-color);
}

.zb-tier {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: #d8c8a8;
  text-shadow: 0 1px 2px #000;
}

#zone-banner[data-type="black"] .zb-type {
  color: #ff6b5b;
  border-color: #e0453a;
}

#zone-banner[data-type="black"] .zb-name {
  text-shadow: 0 3px 0 #000, 0 0 24px rgba(0, 0, 0, 0.9), 0 0 36px #e0453a;
}

/* ------------------------------------------------------------------ HUD: top right (menu row + purse) */

#hud-tr {
  position: fixed;
  top: 10px;
  right: 12px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  /* One row of round brass buttons. features/settings/layout.js overrides max-width with the free
     width right of the portrait / target frames and shrinks the buttons (--menu-btn) so the row
     never wraps. */
  --menu-btn: 42px;
  --menu-gap: 7px;
  max-width: max(260px, calc(100vw - 640px));
  pointer-events: none;
}

#hud-tr > * {
  pointer-events: auto;
}

.hud-menu {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--menu-gap, 7px);
  padding: 3px;
}

/* Round brass-rimmed icon button with a dark well. */
.menu-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--menu-btn, 42px);
  height: var(--menu-btn, 42px);
  padding: 0;
  cursor: pointer;
  background: radial-gradient(circle at 50% 40%, #3a2f24 0%, #1a130d 62%, #0b0806 100%);
  border: 1px solid #0c0703;
  border-radius: 50%;
  box-shadow:
    0 0 0 2px var(--brass-lo),
    0 0 0 3px var(--brass),
    0 0 0 4px #3a2508,
    0 3px 8px 3px rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px rgba(255, 220, 140, 0.25),
    inset 0 0 8px rgba(0, 0, 0, 0.9);
  transition: filter 0.12s, box-shadow 0.12s;
}

.menu-btn:hover {
  filter: brightness(1.2);
  box-shadow:
    0 0 0 2px #b48a38,
    0 0 0 3px #ffe08a,
    0 0 0 4px #3a2508,
    0 0 10px 4px rgba(255, 200, 90, 0.35),
    inset 0 0 0 1px rgba(255, 220, 140, 0.35),
    inset 0 0 8px rgba(0, 0, 0, 0.9);
}

.menu-btn:active {
  transform: scale(0.94);
}

.menu-btn canvas {
  display: block;
  max-width: calc(var(--menu-btn, 42px) - 14px);
  max-height: calc(var(--menu-btn, 42px) - 14px);
}

.menu-key {
  position: absolute;
  right: -5px;
  bottom: -6px;
  min-width: 14px;
  padding: 0 3px;
  font: 700 10px/13px var(--font);
  text-align: center;
  color: #f3e2bb;
  background: #15100b;
  border: 1px solid #6e5220;
  border-radius: 7px;
  pointer-events: none;
}

.menu-letter {
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: bold;
  color: var(--gold);
}

.hud-purse {
  display: flex;
  gap: 12px;
  padding: 3px 12px;
  background: linear-gradient(90deg, rgba(12, 9, 7, 0), rgba(12, 9, 7, 0.72) 18%, rgba(12, 9, 7, 0.72));
  border-radius: 12px;
}

.purse-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  text-shadow: 0 1px 2px #000;
  font-variant-numeric: tabular-nums;
}

.purse-silver .purse-val {
  color: #eef1f5;
}

.purse-weight .purse-val {
  color: #e8dcc4;
}

.purse-weight.near .purse-val {
  color: var(--warn);
}

.purse-weight.over .purse-val {
  color: #ff5a4a;
  animation: pulse-text 1s infinite;
}

/* ------------------------------------------------------------------ death overlay */

.death-overlay {
  position: fixed;
  inset: 0;
  z-index: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none !important;
  background: radial-gradient(ellipse at center, rgba(20, 0, 0, 0.1) 0%, rgba(40, 4, 2, 0.5) 60%, rgba(12, 2, 1, 0.85) 100%);
  transition: opacity 0.6s;
}

.death-overlay.show {
  opacity: 1;
}

.death-box {
  min-width: 340px;
  max-width: calc(100vw - 32px);
  padding: 22px 40px 20px;
  text-align: center;
  color: var(--ink);
  pointer-events: auto;
  background:
    var(--paper-noise),
    radial-gradient(ellipse at 50% 35%, var(--parch-hi), var(--parch) 60%, var(--parch-lo));
  border: 9px solid var(--wood);
  border-radius: 14px;
  box-shadow: 0 0 0 1px var(--wood-edge), 0 0 0 2px rgba(150, 108, 60, 0.45), inset 0 0 22px rgba(120, 72, 22, 0.5), 0 0 60px rgba(120, 0, 0, 0.45), var(--shadow);
}

.death-title {
  font-family: var(--font-title);
  font-size: 36px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #9a1c12;
}

.death-text {
  margin-top: 8px;
  color: var(--ink-dim);
}

.death-count {
  min-height: 18px;
  margin-top: 10px;
  color: var(--ink-faint);
}

.death-btn {
  min-width: 170px;
  margin-top: 14px;
}

/* ------------------------------------------------------------------ minimap (bottom-right diamond) */

/* Albion-style flattened diamond (about 2:1 wide to tall) with a thin parchment edge, compass
   letters around it, small round buttons along the upper-right edge, FPS / ping as small text on
   the left and a thin dark status strip below. The canvas is drawn north-up and turned + squashed
   by ui/minimap.js orient() (MAP_FLAT). */
#minimap {
  --zone-color: var(--gold);
  --mm-w: 300px;
  position: fixed;
  right: 14px;
  bottom: 6px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  width: calc(var(--mm-w) + 24px);
  pointer-events: none;
}

#minimap > * {
  pointer-events: auto;
}

.mm-dia {
  position: relative;
  width: var(--mm-w);
  height: calc(var(--mm-w) * 0.55);
  margin: 20px 0 10px;
  pointer-events: none !important;
}

.mm-dia > * {
  pointer-events: auto;
}

/* Thin edge: a dark outline and a parchment / brass line, both diamond clip paths. */
.mm-rim {
  position: absolute;
  inset: 0;
  filter: drop-shadow(0 4px 7px rgba(0, 0, 0, 0.6));
  pointer-events: none !important;
}

.mm-rim::before,
.mm-rim::after {
  content: "";
  position: absolute;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.mm-rim::before {
  inset: -5px -9px;
  background: #1a1008;
}

.mm-rim::after {
  inset: -3.4px -6.2px;
  background: linear-gradient(90deg, #b8894e, #f2d8a4 30%, #e2bd82 55%, #f6e0b2 75%, #a87a42);
}

.mm-frame {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  background: #14110d;
}

.mm-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 50% 50% at 50% 50%, transparent 62%, rgba(20, 12, 4, 0.5) 100%);
  pointer-events: none;
}

.mm-canvas {
  display: block;
  flex: none;
  width: calc(var(--mm-w) * 0.7071);
  height: calc(var(--mm-w) * 0.7071);
  cursor: crosshair;
  transform-origin: 50% 50%;
}

.mm-dir,
.wm-dir {
  position: absolute;
  z-index: 2;
  font-family: var(--font);
  font-size: 19px;
  font-weight: 800;
  line-height: 1;
  color: #f4e6c4;
  text-shadow: -1px 0 0 #1a0f06, 1px 0 0 #1a0f06, 0 -1px 0 #1a0f06, 0 1px 0 #1a0f06, 0 2px 4px rgba(0, 0, 0, 0.8);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* Small round buttons stacked along the upper-right edge (outside the rim). */
.mm-ctrl {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none !important;
}

.mm-btn {
  position: absolute;
  width: 22px;
  height: 22px;
  padding: 0;
  font: 800 13px/1 var(--font);
  color: #f6e2b0;
  cursor: pointer;
  pointer-events: auto;
  background: radial-gradient(circle at 50% 38%, #4a3b2c, #150f0a 72%);
  border: 1px solid #0c0703;
  border-radius: 50%;
  box-shadow: 0 0 0 1.5px var(--brass), 0 0 0 2.5px #2a1a08, 0 2px 5px rgba(0, 0, 0, 0.6);
  transform: translate(-50%, -50%);
}

.mm-btn:nth-child(1) { left: calc(58% + 9px); top: calc(8% - 15px); }
.mm-btn:nth-child(2) { left: calc(66% + 9px); top: calc(16% - 15px); }
.mm-btn:nth-child(3) { left: calc(91% + 9px); top: calc(41% - 15px); }

.mm-btn:hover {
  filter: brightness(1.25);
}

/* FPS / ping: small coloured text left of the diamond's lower half. */
.mm-perf {
  position: absolute;
  right: calc(100% - 22px);
  bottom: -2px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0;
  font: 600 11.5px/1.25 var(--font);
  color: #e8e0cc;
  text-shadow: 0 1px 2px #000, 0 0 3px #000;
  white-space: nowrap;
  pointer-events: auto;
}

.mm-fps {
  color: #e8e0cc;
}

/* Status strip under the diamond: players nearby, zone-type diamond, zone name, clock. */
.mm-strip {
  display: flex;
  align-items: center;
  gap: 7px;
  width: calc(var(--mm-w) - 10px);
  height: 24px;
  padding: 0 10px 0 8px;
  font-size: 12.5px;
  color: #e6ddc8;
  background: rgba(20, 24, 34, 0.75);
  border: 1px solid rgba(150, 160, 175, 0.35);
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  text-shadow: 0 1px 1px #000;
}

.mm-count {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 4px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #cfd8e6;
}

.mm-count::before {
  content: "";
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 32%, #eef3fa 0 28%, transparent 30%), radial-gradient(ellipse 60% 45% at 50% 100%, #eef3fa 0 96%, transparent 100%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
  background-color: #4d6a8e;
}

.mm-sep {
  flex: none;
  width: 1px;
  height: 14px;
  background: rgba(200, 210, 225, 0.35);
}

/* Zone type as a small diamond in the zone colour (the text is in the tooltip). */
.mm-type {
  flex: none;
  width: 12px;
  height: 12px;
  overflow: hidden;
  color: transparent;
  font-size: 0;
  background: linear-gradient(135deg, color-mix(in srgb, var(--zone-color) 60%, #fff), var(--zone-color) 55%, color-mix(in srgb, var(--zone-color) 60%, #000));
  border: 1px solid var(--zone-outline, #000);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6);
  transform: rotate(45deg);
}

.mm-zone {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #eef0f4;
}

.mm-coords,
.mm-clock {
  flex: none;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.mm-coords {
  color: #98a3b4;
}

.mm-clock {
  color: #eef0f4;
}

.mm-ping {
  flex-shrink: 0;
  white-space: nowrap;
  color: #9fe27a;
  font-variant-numeric: tabular-nums;
}

.mm-ping.bad {
  color: #ffb070;
}

/* ------------------------------------------------------------------ world map (full screen) */

/* The World Map window is a full-screen sheet over the dimmed game: no wooden frame, a parchment
   header strip at the top and the tilted zone map on a torn parchment diamond (Albion 01). */
.panel.panel-map {
  position: fixed;
  left: 0 !important;
  top: 0 !important;
  width: 100vw !important;
  height: 100vh;
  max-width: none;
  max-height: none;
  padding: 0;
  background: radial-gradient(ellipse at 50% 55%, rgba(12, 9, 6, 0.5), rgba(8, 6, 4, 0.78));
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.panel.panel-map::before,
.panel.panel-map > .panel-title {
  display: none;
}

#ui.st-scaled > .panel.panel-map {
  scale: none;
  max-width: none;
  max-height: none;
}

.panel-map > .panel-body.worldmap-body {
  padding: 0;
  overflow: hidden;
  background: none;
  border-radius: 0;
  box-shadow: none;
  -webkit-mask: none;
  mask: none;
}

.worldmap {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  padding: 14px 20px 10px;
}

/* Header strip: zone icon, name + zone type, players nearby, Zone / Realm tabs, close button. */
.wm-top {
  position: relative;
  z-index: 2;
  display: flex;
  flex: none;
  align-items: center;
  gap: 16px;
  width: min(1120px, calc(100vw - 60px));
  min-height: 58px;
  padding: 6px 54px 6px 18px;
  color: var(--ink);
  background:
    var(--paper-noise),
    linear-gradient(180deg, var(--parch-hi), var(--parch) 60%, var(--parch-lo));
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(80, 48, 18, 0.55), 0 8px 22px rgba(0, 0, 0, 0.6), inset 0 0 18px rgba(150, 78, 26, 0.35);
  -webkit-mask: var(--rag-mask);
  mask: var(--rag-mask);
}

.wm-zicon {
  --zone-color: var(--gold);
  flex: none;
  width: 30px;
  height: 30px;
  margin: 0 4px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--zone-color) 55%, #fff), var(--zone-color) 50%, color-mix(in srgb, var(--zone-color) 55%, #000));
  border: 2px solid var(--zone-outline, #1a0f06);
  box-shadow: 0 0 0 1px #1a0f06, 0 2px 4px rgba(0, 0, 0, 0.4);
  transform: rotate(45deg) scaleX(1.2);
}

.wm-ztitle {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
}

.wm-zname {
  overflow: hidden;
  font-family: var(--font-title);
  font-size: 26px;
  font-weight: 800;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #3a2212;
}

.wm-ztype {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-dim);
}

.wm-players {
  flex: none;
  padding: 3px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  background: rgba(110, 70, 30, 0.12);
  border: 1px solid rgba(110, 72, 34, 0.35);
  border-radius: 999px;
}

.wm-tabs {
  display: flex;
  flex: none;
  gap: 4px;
}

.wm-tab {
  min-width: 70px;
  min-height: 28px;
  padding: 2px 14px;
  font-size: 13px;
  font-weight: 700;
  color: #e8ecf2;
  cursor: pointer;
  background: linear-gradient(180deg, #6a737e, #3b424b 55%, #2a2f36);
  border: 1px solid #14171b;
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(160, 166, 174, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.wm-tab.active {
  color: #fff;
  background: linear-gradient(180deg, var(--red-hi), var(--red) 55%, var(--red-lo));
}

.wm-close {
  position: absolute;
  top: 50%;
  right: 12px;
  width: 30px;
  height: 30px;
  padding: 0 0 2px;
  font: 900 22px/1 var(--font);
  color: #2a1606;
  cursor: pointer;
  background: radial-gradient(circle at 42% 30%, #fff6c4 0%, #f6d467 26%, #d09a2a 62%, #8a5a12 100%);
  border: 2px solid #3a2410;
  border-radius: 50%;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.5), inset 0 -2px 3px rgba(90, 50, 0, 0.5);
  transform: translateY(-50%);
}

.wm-stage {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
}

/* The zone map lies tilted (a flattened diamond) on a torn parchment diamond with the compass
   letters on its rim; minimap.js sizes the sheet and turns / squashes the canvas. */
.wm-sheet {
  position: relative;
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.65));
}

.wm-sheet::before,
.wm-sheet::after {
  content: "";
  position: absolute;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  pointer-events: none;
}

.wm-sheet::before {
  inset: 0;
  background:
    var(--paper-noise),
    radial-gradient(ellipse at 50% 50%, var(--parch-hi), var(--parch) 55%, var(--parch-lo));
}

.wm-sheet::after {
  inset: 22px 40px;
  background: #3b2a1a;
}

.wm-sheet .wm-zone {
  position: relative;
  z-index: 1;
  flex: none;
  transform-origin: 50% 50%;
}

.wm-dir {
  z-index: 2;
  font-family: var(--font-title);
  font-size: 30px;
  font-weight: 800;
  color: #4a2a10;
  text-shadow: 0 1px 0 rgba(255, 240, 200, 0.6);
}

.wm-graph,
.wm-zone {
  display: block;
  background: #0b0907;
}

.wm-zone {
  cursor: crosshair;
}

/* Realm tab: the zone graph and the legend on a parchment card. */
.wm-realm {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 20px 16px;
  color: var(--ink);
  background:
    var(--paper-noise),
    radial-gradient(ellipse at 50% 35%, var(--parch-hi), var(--parch) 60%, var(--parch-lo));
  border-radius: 4px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.6), inset 0 0 26px rgba(150, 78, 26, 0.4);
  -webkit-mask: var(--rag-mask);
  mask: var(--rag-mask);
}

.wm-caption {
  font-family: var(--font-title);
  font-size: 22px;
  font-weight: 800;
  color: #4a2a10;
}

.wm-graph {
  border: 1px solid #3a2410;
  border-radius: 6px;
  box-shadow: 0 0 0 2px #c9a468, 0 0 0 3px #6e4a22, inset 0 0 20px rgba(0, 0, 0, 0.6);
}

.wm-legend {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 3px 16px;
  font-size: 12.5px;
  color: var(--ink-dim);
}

.wm-leg {
  display: flex;
  align-items: center;
  gap: 6px;
}

.wm-leg.wm-leg-row {
  grid-column: 1 / -1;
}

.wm-sw {
  display: inline-block;
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  background: var(--sw);
  box-shadow: 0 0 0 1px rgba(40, 24, 8, 0.8);
}

.wm-sw.dot {
  border-radius: 50%;
}

.wm-sw.small {
  width: 5px;
  height: 5px;
  margin: 0 2.5px;
}

.wm-sw.card {
  width: 11px;
  height: 11px;
  box-shadow: 0 0 0 1px #5a4630;
}

.wm-sw.diamond {
  transform: rotate(45deg) scale(0.8);
}

.wm-sw.ring {
  background: none;
  border: 2px solid var(--sw);
  border-radius: 50%;
  box-shadow: none;
}

.wm-sw.arrow {
  width: 0;
  height: 0;
  background: none;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 10px solid var(--sw);
  box-shadow: none;
}

.wm-hint {
  flex: none;
  padding-top: 6px;
  font-size: 12.5px;
  color: #e6dac0;
  text-shadow: 0 1px 2px #000;
}

/* ------------------------------------------------------------------ inventory panel */

/* Docked flush to the right edge, from below the menu row (--dock-top, written by
   features/settings/layout.js) down to the minimap's status strip (Albion 06). */
.panel.docked-right {
  left: auto !important;
  right: 4px;
  top: var(--dock-top, 100px) !important;
  height: calc(100vh - var(--dock-top, 100px) - 30px);
  max-height: none;
}

.panel.docked-right .panel-title {
  cursor: default;
}

/* While the Inventory is open it covers the tracker column: hide what would peek out. The quest
   tracker stays in sight as a one-line pill on top of the dock column instead (destiny.css,
   pt12 c0-AkFirst-06); features/settings/layout.js starts the Inventory below it. */
#ui.has-inventory > #dg-progress {
  visibility: hidden;
}

.panel-inventory .panel-body.inv-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 8px 8px;
  overflow: hidden;
}

/* Equipment: gear columns left and right, portrait / item power / silver / weight between. */
.inv-eq {
  display: flex;
  flex: none;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 6px;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(255, 240, 210, 0.35), transparent 70%),
    rgba(120, 70, 30, 0.12);
  border: 1px solid rgba(110, 72, 34, 0.35);
  border-radius: 8px;
  box-shadow: inset 0 1px 6px rgba(90, 56, 20, 0.28);
}

.inv-eq-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.inv-eq .eq-slot {
  --slot: 46px;
}

.inv-eq-mid {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.inv-name,
.char-name {
  max-width: 100%;
  overflow: hidden;
  font-family: var(--font-title);
  font-size: 19px;
  font-weight: 800;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #3a2212;
}

/* Round painted bust in a brass ring (ui/portrait.js). */
.inv-face {
  flex: none;
  overflow: hidden;
  border-radius: 50%;
  background: #141a20;
  box-shadow: 0 0 0 2px #1a120a, 0 0 0 4px var(--brass), 0 0 0 5px var(--brass-lo), 0 0 0 6px #120a04, 0 4px 10px rgba(0, 0, 0, 0.45);
}

.inv-face svg {
  display: block;
  width: 100%;
  height: 100%;
}

.inv-face-sm {
  width: 82px;
  height: 82px;
}

.inv-face-lg {
  width: 132px;
  height: 132px;
  margin: 4px auto;
}

.inv-eq-mid .char-ip {
  align-self: stretch;
  padding: 3px 10px;
}

.inv-eq-mid .char-ip-label {
  font-size: 12.5px;
}

.inv-eq-mid .char-ip-val {
  font-size: 18px;
}

.inv-eq-mid .inv-silver {
  align-self: stretch;
  justify-content: center;
  font-size: 14px;
}

.inv-eq-mid .inv-weight {
  align-self: stretch;
  flex: none;
}

.inv-eq-mid .weight-bar {
  height: 16px;
}

/* The grid grows into the space under the paper doll; inventory.js fitGrid caps it (max-height)
   at whole rows of slots, so the leftover lies below the hint, never in a partial row (c6-05). */
.inv-grid {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: repeat(var(--cols, 8), var(--slot));
  grid-auto-rows: var(--slot);
  align-content: start;
  justify-content: center;
  gap: 5px;
  min-height: 0;
  padding: 8px;
  overflow-y: auto;
  background: rgba(110, 70, 30, 0.1);
  border: 1px solid rgba(110, 72, 34, 0.3);
  border-radius: 8px;
  box-shadow: inset 0 1px 4px rgba(90, 56, 20, 0.25);
}

/* A stack that just arrived in the bag glows for a few seconds (inventory.js markNew, c6-05). */
.inv-slot.inv-new {
  outline: 2px solid #ffd766;
  outline-offset: -2px;
  animation: pulse-gold 0.9s ease-in-out 4;
}

.inv-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.inv-footer.inv-head {
  margin: 0 0 8px;
}

.inv-weight {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 6px;
}

.weight-bar {
  position: relative;
  flex: 1;
  height: 18px;
  overflow: hidden;
  background: linear-gradient(180deg, #1d2127, #3c434c);
  border: 1px solid #0d0f12;
  border-radius: 9px;
  box-shadow: 0 0 0 1.5px #9aa1aa, inset 0 1px 3px rgba(0, 0, 0, 0.8);
}

.weight-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  background: linear-gradient(180deg, #f0d27a, #b88a2e 55%, #7a5616);
  transition: width 0.2s;
}

.weight-bar.near .weight-fill {
  background: linear-gradient(180deg, #f6b25a, #c06a14);
}

.weight-bar.over .weight-fill {
  background: linear-gradient(180deg, #f6705e, #a0261a);
}

.weight-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

#ui .weight-text {
  text-shadow: 0 0 2px #000, 0 1px 1px #000;
}

.inv-silver {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 12px 2px 6px;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--ink);
  background: rgba(255, 246, 222, 0.45);
  border: 1px solid rgba(110, 72, 34, 0.35);
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

.inv-hint {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-faint);
}

/* Short dock (pt12 c2-03): at 1280x720 the docked Inventory is 464 px tall (it starts below the
   tracker pill) and the 264 px paper doll left the bag grid one 48 px row of ten; scrolling that
   sliver made a player unequip her Bag by mistake. With less than 560 px of window content the
   paper doll, its portrait and the bag slots get smaller and the grid keeps a floor of three rows.
   The panel's height comes from the dock, not its content, so it can be the size container. */
.panel-inventory.docked-right {
  container: inv-dock / size;
}

@container inv-dock (max-height: 560px) {
  .panel-inventory .panel-body.inv-body {
    gap: 6px;
    padding: 6px 8px;
  }

  .inv-eq {
    padding: 4px 6px;
  }

  .inv-eq-col {
    gap: 3px;
  }

  .inv-eq .eq-slot {
    --slot: 34px;
  }

  .inv-eq .eq-slot.empty > canvas {
    width: 24px !important;
    height: 24px !important;
  }

  .inv-eq-mid {
    gap: 4px;
  }

  .inv-face-sm {
    width: 58px;
    height: 58px;
    margin: 2px 0;
  }

  .inv-grid {
    --slot: 44px;
    min-height: calc(3 * var(--slot) + 2 * 5px + 2 * 5px + 2px);
    padding: 5px;
  }

  .inv-hint {
    margin-top: 0;
  }
}

/* ------------------------------------------------------------------ character panel */

.char-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 16px;
}

/* Paper doll on a darker leather plate. */
.char-doll {
  display: grid;
  grid-template-columns: repeat(3, 64px);
  gap: 6px 12px;
  padding: 12px 14px;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(255, 240, 200, 0.35), transparent 70%),
    rgba(120, 78, 36, 0.16);
  border: 1px solid rgba(110, 72, 34, 0.4);
  border-radius: 10px;
  box-shadow: inset 0 1px 6px rgba(90, 56, 20, 0.3);
}

.eq-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.eq-cell.spacer {
  visibility: hidden;
}

.eq-slot {
  --slot: 56px;
}

.eq-slot.empty {
  display: flex;
  align-items: center;
  justify-content: center;
}

.eq-slot.empty > canvas {
  width: 34px !important;
  height: 34px !important;
  opacity: 0.45;
}

.eq-slot.blocked {
  background: repeating-linear-gradient(45deg, rgba(176, 38, 28, 0.18) 0 6px, transparent 6px 12px), rgba(120, 78, 36, 0.2);
}

.eq-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.char-left {
  display: flex;
  flex: 0 0 190px;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 10px 10px 12px;
  text-align: center;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(255, 240, 210, 0.4), transparent 70%),
    rgba(120, 70, 30, 0.12);
  border: 1px solid rgba(110, 72, 34, 0.35);
  border-radius: 10px;
}

.char-left .btn {
  width: 100%;
}

.char-right {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  min-width: 220px;
}

.char-ip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 14px;
  background: var(--wood-grain), linear-gradient(180deg, #4e3624, #2b1c10);
  border: 1px solid #1a0f06;
  border-radius: 999px;
  box-shadow: 0 0 0 1.5px var(--brass), 0 2px 5px rgba(0, 0, 0, 0.4);
}

.char-ip-label {
  font-family: var(--font-title);
  font-size: 15px;
  font-weight: 700;
  color: #e8d3a4;
}

.char-ip-val {
  font-family: var(--font-title);
  font-size: 24px;
  font-weight: 700;
  color: #ffe08a;
}

#ui .char-ip * {
  text-shadow: 0 1px 2px #000;
}

.char-stats {
  display: grid;
  gap: 1px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 8px;
  font-size: 13px;
  border-radius: 4px;
}

.stat-row:nth-child(odd) {
  background: rgba(120, 78, 36, 0.09);
}

.stat-row:hover {
  background: rgba(150, 96, 34, 0.16);
}

.stat-name {
  color: var(--text-dim);
}

.stat-val {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat-row.bad .stat-val {
  color: var(--error);
}

.char-section-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 14px 0 6px;
  padding-bottom: 3px;
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 700;
  color: #4a2a10;
  border-bottom: 1px solid var(--border-dim);
}

.char-section-hint {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 400;
  color: var(--text-faint);
}

.char-spells {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.spell-row {
  display: grid;
  grid-template-columns: 26px 56px auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 3px 8px;
  background: rgba(120, 78, 36, 0.1);
  border: 1px solid rgba(110, 72, 34, 0.2);
  border-radius: 8px;
}

.spell-row.empty {
  opacity: 0.6;
}

.spell-key {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 12.5px;
  font-weight: 700;
  color: #f3e2bb;
  background: radial-gradient(circle at 45% 35%, #6b7480, #2c3139);
  border: 1px solid #0e1013;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #9aa1aa;
}

.spell-src {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.spell-choices {
  display: flex;
  gap: 6px;
}

.spell-choice {
  position: relative;
  width: 44px;
  height: 44px;
  padding: 0;
  cursor: pointer;
  opacity: 0.6;
  filter: grayscale(0.55);
  background: #0a0806;
  border: none;
  border-radius: 50%;
  box-shadow: 0 0 0 2px #7a838e, 0 0 0 3px #22262b;
  transition: opacity 0.12s, filter 0.12s, box-shadow 0.12s;
}

.spell-choice canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  border-radius: 50%;
}

.spell-choice:hover {
  opacity: 0.95;
  filter: none;
}

.spell-choice.selected {
  cursor: default;
  opacity: 1;
  filter: none;
  box-shadow: 0 0 0 2px var(--brass), 0 0 0 3px #3a2508, 0 0 10px 2px rgba(220, 160, 50, 0.55);
}

.spell-choice.pending {
  box-shadow: 0 0 0 2px #ffe08a, 0 0 0 3px #3a2508;
  animation: pulse-gold 0.8s infinite;
}

.spell-name {
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spell-none {
  font-size: 12px;
  font-style: italic;
  color: var(--text-faint);
}

/* ------------------------------------------------------------------ chat (bottom-left, translucent) */

#chat {
  position: fixed;
  left: 10px;
  bottom: 10px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  width: clamp(260px, calc(50vw - 300px), 420px);
  height: 232px;
  /* Albion-style: borderless shadowed text over the world; the box, the tab row and the input
     field fade in while the pointer is over the chat or the player is typing. At rest only the
     log keeps a soft dark backing (below). */
  background: transparent;
  border-radius: 8px;
  transition: background 0.15s, opacity 0.4s;
}

#chat:hover,
#chat.typing,
#chat:focus-within {
  background: linear-gradient(180deg, rgba(10, 8, 6, 0.5), rgba(10, 8, 6, 0.72));
}

#chat .chat-head,
#chat .chat-input,
#chat .chat-count {
  transition: opacity 0.15s;
}

#chat:not(:hover):not(.typing):not(:focus-within) .chat-head,
#chat:not(:hover):not(.typing):not(:focus-within) .chat-input,
#chat:not(:hover):not(.typing):not(:focus-within) .chat-count {
  opacity: 0;
}

/* Resting backing behind the lines ("translucent dark", VISUAL_STYLE.md): without it the
   timestamps, [Sys] tags and system lines vanish over bright grass and cobblestone (pt12 c1-08).
   Darkest at the left, where every line starts with its timestamp and channel tag. */
#chat:not(:hover):not(.typing):not(:focus-within) .chat-log {
  scrollbar-width: none;
  background: linear-gradient(90deg, rgba(10, 8, 6, 0.62), rgba(10, 8, 6, 0.48) 60%, rgba(10, 8, 6, 0.2));
  border-radius: 6px;
}

#chat:not(:hover):not(.typing):not(:focus-within) .chat-log::-webkit-scrollbar {
  display: none;
}

/* After IDLE_MS (chat.js) the chat steps back a little but stays readable. */
#chat.idle:not(:hover):not(.typing) {
  opacity: 0.85;
}

#chat.collapsed {
  height: auto;
}

#chat.collapsed .chat-log {
  display: none;
}

.chat-head {
  display: flex;
  align-items: stretch;
  gap: 4px;
  padding: 3px 4px 2px;
}

.chat-tabs {
  display: flex;
  flex: 1;
  gap: 3px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.chat-tabs::-webkit-scrollbar {
  display: none;
}

.chat-tab {
  position: relative;
  flex: none;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  color: #b8a88a;
  text-shadow: 0 1px 2px #000;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(160, 130, 80, 0.25);
  border-radius: 999px;
}

.chat-tab:hover {
  color: #ecdfc2;
}

.chat-tab.active {
  color: #1f1409;
  text-shadow: none;
  background: linear-gradient(180deg, #f3dfb4, #cfa86a);
  border-color: #3a2410;
}

.chat-tab.unread::after {
  content: "";
  position: absolute;
  top: -1px;
  right: -1px;
  width: 7px;
  height: 7px;
  background: #ffd766;
  border: 1px solid #3a2410;
  border-radius: 50%;
  box-shadow: 0 0 4px var(--gold);
}

.chat-collapse {
  width: 26px;
  font-weight: 800;
  color: #d9c49a;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(160, 130, 80, 0.25);
  border-radius: 999px;
}

.chat-collapse:hover {
  color: #ffe08a;
}

.chat-log {
  flex: 1;
  min-height: 0;
  padding: 3px 8px;
  overflow-y: auto;
  font-size: 13.5px;
  line-height: 1.32;
  text-shadow: 0 1px 1px #000, 0 0 3px #000;
  user-select: text;
  -webkit-user-select: text;
}

.chat-line {
  padding: 1px 0;
  overflow-wrap: anywhere;
}

.chat-time {
  margin-right: 5px;
  font-size: 11.5px;
  color: #c9b894;
  font-variant-numeric: tabular-nums;
}

.chat-tag {
  margin-right: 4px;
  font-weight: 700;
}

.chat-from {
  font-weight: 700;
  cursor: pointer;
}

.chat-from:hover {
  text-decoration: underline;
}

.chat-prefix {
  opacity: 0.85;
}

/* "[KI]" before the name of an AI-played resident (server field `ai`). */
.chat-ai {
  margin-right: 3px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #f3dfb4;
}

/* Repeated identical system lines collapse into one with a counter. */
.chat-rep {
  display: inline-block;
  margin-left: 6px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 700;
  line-height: 15px;
  color: #1f1409;
  text-shadow: none;
  background: linear-gradient(180deg, #f3dfb4, #cfa86a);
  border-radius: 999px;
}

.ch-global {
  color: #ecdfc2;
}

.ch-global .chat-tag,
.ch-global .chat-from {
  color: #fff1cf;
}

.ch-zone {
  color: #c2e3a0;
}

.ch-zone .chat-tag,
.ch-zone .chat-from {
  color: #a8d672;
}

.ch-party {
  color: #a9d2ff;
}

.ch-party .chat-tag,
.ch-party .chat-from {
  color: #6fb6ff;
}

.ch-whisper {
  color: #f0bfff;
}

.ch-whisper .chat-tag,
.ch-whisper .chat-from {
  color: #e59bff;
}

.ch-system {
  color: #e8c874;
}

.ch-system .chat-tag {
  color: #b8963e;
}

.ch-system.lvl-warn {
  color: #f0b060;
}

.ch-system.lvl-error {
  color: #ff7a6a;
}

.chat-input-row {
  display: flex;
  gap: 4px;
  padding: 3px 4px 4px;
}

/* The channel button is the small "Chat" pill. */
.chat-chan {
  flex: 0 0 auto;
  max-width: 110px;
  padding: 0 12px;
  overflow: hidden;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #f5e6c4;
  text-shadow: 0 1px 1px #000;
  cursor: pointer;
  background: linear-gradient(180deg, #5b636e, #2c3139);
  border: 1px solid #0e1013;
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(160, 166, 174, 0.6);
}

.chat-chan[data-ch="zone"],
.chat-input[data-ch="zone"] {
  color: #a8d672;
}

.chat-chan[data-ch="party"],
.chat-input[data-ch="party"] {
  color: #6fb6ff;
}

.chat-chan[data-ch="whisper"],
.chat-input[data-ch="whisper"] {
  color: #e59bff;
}

.chat-chan[data-ch="guild"],
.chat-input[data-ch="guild"] {
  color: #7fd36b;
}

#chat .chat-input {
  flex: 1;
  min-width: 0;
  min-height: 24px;
  padding: 3px 10px;
  color: #ecdfc2;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(160, 130, 80, 0.25);
  border-radius: 999px;
  box-shadow: none;
}

#chat .chat-input::placeholder {
  color: #8a7c62;
}

/* Characters used of the 200 the server keeps, shown near the limit (chat.js updateCount). */
#chat .chat-count {
  flex: 0 0 auto;
  align-self: center;
  font: 700 11px/1 var(--font);
  color: #b8a888;
  font-variant-numeric: tabular-nums;
}

#chat .chat-count.full {
  color: #ff8a70;
}

#chat .chat-input:focus {
  background: rgba(0, 0, 0, 0.55);
  border-color: rgba(230, 190, 110, 0.6);
  box-shadow: none;
}

/* ------------------------------------------------------------------ login */

#login {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #070504;
  transition: opacity 0.7s ease;
}

#login.leaving {
  opacity: 0;
  pointer-events: none;
}

#login:empty {
  display: none;
}

.login-sky {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 38%, #5a3d1e 0%, #2e1f11 35%, #120c07 70%, #070504 100%),
    linear-gradient(180deg, #1a1410 0%, #070504 100%);
}

.login-sky::before {
  content: "";
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(circle at 30% 20%, rgba(217, 120, 50, 0.12), transparent 40%),
    radial-gradient(circle at 75% 35%, rgba(120, 60, 160, 0.08), transparent 45%);
  animation: sky-drift 28s ease-in-out infinite alternate;
}

.login-sky::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 24%;
  width: 560px;
  height: 560px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255, 190, 110, 0.18), transparent 65%);
}

.login-mountains {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 42vh;
}

.login-window {
  animation: flicker 3s infinite;
}

.login-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, 0.75) 100%);
}

.login-embers {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.ember {
  position: absolute;
  bottom: -10px;
  border-radius: 50%;
  opacity: 0;
  background: radial-gradient(circle, #ffd28a, #ff7a2a 60%, transparent 70%);
  box-shadow: 0 0 6px #ff8a3a;
  animation-name: ember-rise;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

/* The login card is a window like any other: wood frame, parchment page. */
.login-card {
  --text: var(--ink);
  --text-dim: var(--ink-dim);
  --text-faint: var(--ink-faint);
  --gold: #8c4f12;
  --border-dim: rgba(110, 72, 34, 0.3);
  position: relative;
  z-index: 2;
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 22px 30px 16px;
  overflow: auto;
  text-align: center;
  color: var(--ink);
  background:
    var(--paper-noise),
    var(--paper-stain),
    radial-gradient(ellipse 120% 90% at 50% 30%, var(--parch-hi), var(--parch) 55%, var(--parch-lo));
  border: 10px solid var(--wood);
  border-radius: 16px;
  box-shadow:
    0 0 0 1px var(--wood-edge),
    0 0 0 3px rgba(150, 108, 60, 0.5),
    0 0 0 4px var(--wood-edge),
    inset 0 0 0 1px rgba(92, 56, 20, 0.6),
    inset 0 0 26px rgba(120, 72, 22, 0.5),
    0 24px 60px rgba(0, 0, 0, 0.8);
  animation: card-in 0.7s ease-out;
}

.login-card.shake {
  animation: shake 0.4s;
}

.login-crest {
  display: block;
  width: 64px;
  height: 64px;
  margin: 0 auto 2px;
  filter: drop-shadow(0 2px 3px rgba(60, 30, 5, 0.6));
}

.login-title {
  /* Sized to its text (background-clip:text only paints inside the box) and centred by the
     card; the leading padding balances the tracking after the last letter. */
  display: inline-block;
  width: max-content;
  max-width: 100%;
  margin: 0;
  padding-left: 0.14em;
  font-family: var(--font-title);
  font-size: clamp(40px, 3.2vw + 14px, 54px);
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.14em;
  color: transparent;
  background: linear-gradient(180deg, #8a4a14 0%, #5a2a08 55%, #2e1404 100%);
  -webkit-background-clip: text;
  background-clip: text;
  filter: drop-shadow(0 1px 0 rgba(255, 240, 200, 0.7));
}

.login-sub {
  margin: 0 0 16px;
  font-style: italic;
  font-size: 14.5px;
  color: var(--ink-dim);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.login-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.login-row {
  display: flex;
  gap: 10px;
}

#login .login-input {
  flex: 1;
  min-width: 0;
  padding: 7px 16px;
  font-size: 16px;
}

.login-btn {
  min-width: 150px;
  font-size: 15px;
}

.login-error {
  min-height: 18px;
  font-size: 13px;
  font-weight: bold;
  color: #b0261c;
}

.login-status {
  font-size: 13px;
  color: #8c4f12;
}

#login.busy .login-status::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  vertical-align: -1px;
  border: 2px solid #8c4f12;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.login-help {
  margin-top: 12px;
  padding-top: 10px;
  text-align: left;
  border-top: 1px solid rgba(110, 72, 34, 0.3);
}

.login-help summary {
  font-family: var(--font-title);
  font-size: 17px;
  font-weight: 700;
  color: #5a3312;
  cursor: pointer;
  list-style: none;
}

.login-help summary::-webkit-details-marker {
  display: none;
}

.login-help summary::before {
  content: "\25B8";
  display: inline-block;
  margin-right: 6px;
  transition: transform 0.15s;
}

.login-help[open] summary::before {
  transform: rotate(90deg);
}

.login-tips {
  display: grid;
  gap: 7px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.login-tips li {
  display: grid;
  gap: 1px;
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--ink-dim);
}

.login-tips b {
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.login-foot {
  margin-top: 14px;
  font-size: 12px;
  color: var(--ink-faint);
}
/* ------------------------------------------------------------------ animations */

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes zone-banner {
  0% {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
  12% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  80% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -6px);
  }
}

@keyframes ready-flash {
  0% {
    box-shadow: inset 0 0 0 2px #fff6d0, 0 0 14px rgba(255, 230, 160, 0.9);
  }
  100% {
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
  }
}

@keyframes pulse-red {
  0%,
  100% {
    box-shadow: 0 0 0 rgba(224, 69, 58, 0);
  }
  50% {
    box-shadow: 0 0 12px rgba(224, 69, 58, 0.85);
  }
}

@keyframes pulse-gold {
  0%,
  100% {
    box-shadow: 0 0 0 rgba(240, 212, 138, 0);
  }
  50% {
    box-shadow: 0 0 10px rgba(240, 212, 138, 0.8);
  }
}

@keyframes pulse-text {
  50% {
    opacity: 0.55;
  }
}

@keyframes ember-rise {
  0% {
    opacity: 0;
    transform: translate(0, 0);
  }
  10% {
    opacity: 0.9;
  }
  80% {
    opacity: 0.6;
  }
  100% {
    opacity: 0;
    transform: translate(var(--drift, 40px), -105vh);
  }
}

@keyframes sky-drift {
  from {
    transform: translate(-2%, 0) scale(1);
  }
  to {
    transform: translate(2%, -2%) scale(1.05);
  }
}

@keyframes flicker {
  0%,
  100% {
    opacity: 1;
  }
  45% {
    opacity: 0.6;
  }
  50% {
    opacity: 0.9;
  }
  70% {
    opacity: 0.5;
  }
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-8px);
  }
  40% {
    transform: translateX(7px);
  }
  60% {
    transform: translateX(-5px);
  }
  80% {
    transform: translateX(3px);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ------------------------------------------------------------------ responsive */

@media (max-width: 1400px) {
  #hud-tr {
    --menu-btn: 40px;
    --menu-gap: 6px;
  }
}

@media (max-width: 1280px) {
  :root {
    --ab-slot: 50px;
  }

  #minimap {
    --mm-w: 262px;
  }
}

@media (max-width: 1100px) {
  #chat {
    height: 200px;
  }

  .zb-name {
    font-size: 40px;
  }
}

/* Below ~1000px the chat and the minimap would collide with the ability bar. */
@media (max-width: 1000px) {
  #chat {
    bottom: 160px;
    width: min(340px, calc(100vw - 24px));
    height: 170px;
  }

  #minimap {
    bottom: 150px;
  }

  #hud-target {
    top: 150px;
    left: 8px;
  }
}

@media (max-width: 720px) {
  :root {
    --ab-slot: 42px;
  }

  #minimap {
    transform: scale(0.78);
    transform-origin: bottom right;
  }

  #hud-tr {
    max-width: 50vw;
  }

  .login-title {
    font-size: 40px;
  }

  .login-row {
    flex-direction: column;
  }

  .zb-name {
    font-size: 30px;
  }
}

@media (max-height: 760px) {
  .login-card {
    padding: 14px 26px 10px;
  }

  .login-sub {
    margin-bottom: 10px;
  }
}

@media (max-height: 700px) {
  #chat {
    height: 170px;
  }

  #minimap {
    --mm-w: 244px;
  }

  .zb-name {
    font-size: 36px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ember,
  .login-sky::before,
  .login-window {
    animation: none !important;
  }

  .panel.panel-anim,
  .toast,
  .login-card,
  .inv-slot.inv-new {
    animation: none !important;
  }
}
