/* Echoklinge UI. One dark world, "forged iron and firelight": warm soot
   surfaces, brass for structure, parchment for content, ember for what you
   can act on. Echo teal is the second colour (magic, the Echotor).
   Tokens and rules: docs/UI-STYLE.md. */
/* --elev: a component's own shadow; not inherited, so focus rings only
   pick up the shadow of the focused element itself */
@property --elev {
  syntax: "*";
  inherits: false;
}

:root {
  color-scheme: dark;
  /* surfaces: sunk (wells, cells, inputs) < panel < raised (buttons, cards) */
  --bg: #0a0807;
  --surface-sunk: #0c0a08;
  --surface-panel: #16120e;
  --surface-raised: #241d17;
  --surface-hi: #30271f;
  --surface-glass: rgba(20, 16, 12, 0.93);
  --well: rgba(10, 8, 6, 0.62);
  --well-2: rgba(10, 8, 6, 0.42);
  --scrim: rgba(7, 5, 4, 0.76);
  /* lines: brass hairline, frame, strong frame; engraved groove */
  --line: rgba(214, 176, 120, 0.14);
  --line-2: rgba(214, 176, 120, 0.3);
  --line-3: rgba(232, 194, 136, 0.55);
  --groove-dark: rgba(0, 0, 0, 0.6);
  --groove-light: rgba(255, 226, 180, 0.12);
  /* text (on --surface-panel 14.6, 10.3, 7.3 : 1; text-3 stays >= 5.5 on
     every surface and tint) */
  --text-1: #efe4cc;
  --text-2: #cfc3ab;
  --text-3: #b0a490;
  --text-off: rgba(239, 228, 204, 0.4);
  --text-on-ember: #1c0f05;
  /* accent: ember = interaction and state, brass = structure */
  --ember: #ff9a3c;
  --ember-hi: #ffc98a;
  --ember-lo: #b8561c;
  --ember-tint: rgba(255, 154, 60, 0.13);
  --ember-tint-2: rgba(255, 154, 60, 0.22);
  --brass: #d6b07a;
  --brass-lo: #8a6a3e;
  --echo: #74d3c6;
  --echo-tint: rgba(116, 211, 198, 0.15);
  /* semantic */
  --good: #8fe39a;
  --bad: #ff8a7a;
  --warn: #ffb07a;
  --blood: #e0484e;
  --gold: #ffcf5a;
  --info: #7fc4ff;
  /* rarity (the item colours come from src/data/items.js as --rc) */
  --r-common: #c9c2b0;
  --r-rare: #6fb7ff;
  --r-epic: #c38bff;
  --r-legendary: #ffae3d;
  /* names used by windows written before the token set (GM tools, loading
     screen, party frames): mapped onto the tokens above */
  --night: var(--bg);
  --stone-solid: var(--surface-panel);
  --parchment: var(--text-1);
  --ash: var(--text-3);
  --ember-light: var(--ember-hi);
  --display: "Grenze Gotisch", Georgia, "Times New Roman", serif;
  --ui: "Signika", "Trebuchet MS", system-ui, sans-serif;

  /* UI scale: one place to tune the whole interface (stage px; the stage is
     scaled to the screen, 0.7x on a phone in landscape). Body text stays at
     --fs-sm or larger; --fs-tiny and --fs-xs are for badges, keys and caps. */
  --fs-tiny: 9px;
  --fs-xs: 10px;
  --fs-sm: 11px;
  --fs-base: 12px;
  --fs-md: 13px;
  --fs-lg: 14px;
  --fs-xl: 16px;
  --fs-2xl: 18px;
  --fs-3xl: 21px;
  --fs-4xl: 24px;
  --fs-5xl: 32px;
  --lh-tight: 1.15;
  --lh: 1.3;
  --lh-text: 1.4;
  --radius-sm: 3px;
  --radius: 5px;
  --radius-lg: 7px;
  --border: 1px;
  --space-1: 2px;
  --space-2: 4px;
  --space-3: 6px;
  --space-4: 8px;
  --space-5: 12px;
  --space-6: 16px;
  /* controls: button height, and the minimum on touch screens */
  --ctl-h: 28px;
  --ctl-h-sm: 22px;
  --ctl-touch: 36px;
  /* focus (keyboard, gamepad): parchment ring with a dark gap and an ember
     glow. Geometry keeps the states apart: rarity = frame colour, selected
     = inset ember ring (--elev), focus = outer ring. Components put their
     own shadow into --elev so focus keeps it. */
  --focus-line: 2px solid #fff3dc;
  --focus-ring: 0 0 0 2px var(--bg), 0 0 14px 2px rgba(255, 154, 60, 0.55);
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  --shadow-win: 0 16px 48px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(0, 0, 0, 0.6);
  /* material: bevel inside a frame, engraved groove, window background */
  --bevel: inset 0 1px 0 rgba(255, 226, 180, 0.08), inset 0 0 0 1px rgba(0, 0, 0, 0.45);
  --groove: 0 1px 0 var(--groove-light);
  --corner: rgba(214, 176, 120, 0.7);
  --corners:
    linear-gradient(var(--corner), var(--corner)) left 4px top 4px / 12px 2px no-repeat,
    linear-gradient(var(--corner), var(--corner)) left 4px top 4px / 2px 12px no-repeat,
    linear-gradient(var(--corner), var(--corner)) right 4px top 4px / 12px 2px no-repeat,
    linear-gradient(var(--corner), var(--corner)) right 4px top 4px / 2px 12px no-repeat,
    linear-gradient(var(--corner), var(--corner)) left 4px bottom 4px / 12px 2px no-repeat,
    linear-gradient(var(--corner), var(--corner)) left 4px bottom 4px / 2px 12px no-repeat,
    linear-gradient(var(--corner), var(--corner)) right 4px bottom 4px / 12px 2px no-repeat,
    linear-gradient(var(--corner), var(--corner)) right 4px bottom 4px / 2px 12px no-repeat;
  --win-fill: linear-gradient(180deg, var(--surface-raised), var(--surface-panel) 72px);
  --glass-fill: linear-gradient(180deg, rgba(38, 30, 23, 0.95), rgba(20, 16, 12, 0.94) 72px);
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-1);
  font-family: var(--ui);
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* No page zoom anywhere (the maps zoom in the game itself). touch-action
   restarts at every scroll container (chat log, lists, windows), so body's
   "none" alone lets a pinch or a double tap zoom there: every element may
   at most pan. Rules with a class ("none", "pan-y") still win. */
html {
  touch-action: none;
}

body * {
  touch-action: pan-x pan-y;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 240px;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 60%, #1f1a12 0%, var(--bg) 70%);
}

#stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 960px;
  height: 540px;
  transform-origin: 0 0;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(239, 228, 204, 0.05), 0 20px 80px rgba(0, 0, 0, 0.6);
}

#view {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#ui {
  position: absolute;
  inset: 0;
  font-size: var(--fs-base);
  line-height: var(--lh);
  scrollbar-color: rgba(214, 176, 120, 0.35) transparent;
}

.screen {
  position: absolute;
  inset: 0;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
  text-wrap: balance;
}

p {
  margin: 0;
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.eyebrow {
  font: 700 var(--fs-xs)/1.2 var(--ui);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brass);
}

.muted {
  color: var(--text-3);
}

.warn {
  color: var(--warn);
  font-size: var(--fs-base);
  margin-top: 6px;
}

/* --- Controls ---
   Buttons: secondary (default), .primary (one per view), .danger, .ghost.
   States: hover = lighter frame, pressed = darker fill, focus = ember-hi
   ring with glow, disabled = faded without hover. */
button {
  font-family: var(--ui);
  color: var(--text-1);
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: var(--ctl-h);
  box-sizing: border-box;
  padding: 4px 12px;
  font-size: var(--fs-base);
  font-weight: 600;
  line-height: var(--lh-tight);
  letter-spacing: 0.01em;
  color: var(--text-1);
  background: linear-gradient(180deg, var(--surface-hi), var(--surface-raised));
  border: var(--border) solid var(--line-2);
  border-radius: var(--radius);
  --elev: inset 0 1px 0 rgba(255, 226, 180, 0.1), 0 1px 2px rgba(0, 0, 0, 0.5);
  box-shadow: var(--elev);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

@media (hover: hover) {
  .btn:not([disabled]):hover {
    border-color: var(--line-3);
    background: linear-gradient(180deg, #3a2f25, var(--surface-hi));
  }

  .btn.primary:not([disabled]):hover {
    background: linear-gradient(180deg, #ffc275, #e97a2b);
    border-color: #ffe2b8;
  }

  .btn.danger:not([disabled]):hover {
    border-color: var(--bad);
    background: linear-gradient(180deg, #4a221c, #321713);
  }

  .btn.ghost:not([disabled]):hover {
    background: var(--surface-raised);
    border-color: var(--line);
    color: var(--text-1);
  }
}

.btn:not([disabled]):active {
  background: var(--surface-sunk);
  --elev: inset 0 1px 3px rgba(0, 0, 0, 0.7);
}

.btn.primary {
  background: linear-gradient(180deg, #ffb45c, #dc6d22);
  border-color: #ffd49a;
  color: var(--text-on-ember);
  font-weight: 700;
  --elev: inset 0 1px 0 rgba(255, 240, 210, 0.55), inset 0 -2px 0 rgba(120, 50, 10, 0.35), 0 1px 3px rgba(0, 0, 0, 0.55);
  text-shadow: 0 1px 0 rgba(255, 220, 170, 0.35);
}

.btn.primary:not([disabled]):active {
  background: linear-gradient(180deg, #e0782a, #c85f1a);
  --elev: inset 0 2px 3px rgba(90, 35, 5, 0.6);
}

.btn.danger {
  background: linear-gradient(180deg, #3a1c18, #2a1411);
  border-color: rgba(214, 80, 66, 0.75);
  color: #ffc2b8;
}

/* ghost: quiet actions next to a primary one (help, sort, filters) */
.btn.ghost {
  background: transparent;
  border-color: transparent;
  --elev: 0 0 #0000;
  color: var(--text-2);
}

.btn.small {
  min-height: var(--ctl-h-sm);
  padding: 3px 9px;
  font-size: var(--fs-sm);
}

/* --- Tabs ---
   One look for every tab, segment, filter and tier button: sunk, framed;
   "on" = raised with ember text and a 3px ember bar at the bottom (drawn
   as a background layer, so focus and hover never hide it). */
.seg.on,
.subtab.on,
.ol-tab.on,
.oc-tab.on,
.ctl-tabs .btn.on,
.help-nav .btn.on,
.sw-head .btn.on,
.sw-tab.on,
.shop-tiers .tier.sel {
  background: linear-gradient(var(--ember), var(--ember)) left bottom / 100% 3px no-repeat, linear-gradient(180deg, var(--surface-hi), var(--surface-raised));
  border-color: var(--line-3);
  color: var(--ember-hi);
}

.oc-tab.on {
  background: linear-gradient(var(--ember), var(--ember)) left top / 100% 2px no-repeat, rgba(12, 10, 8, 0.85);
}

.shop-tiers .tier:not(.sel),
.ctl-tabs .btn:not(.on),
.help-nav .btn:not(.on),
.sw-tab:not(.on) {
  background: var(--surface-sunk);
  color: var(--text-2);
  --elev: 0 0 #0000;
}

@media (hover: hover) {
  .seg:not(.on):hover,
  .subtab:not(.on):hover,
  .ol-tab:not(.on):hover,
  .shop-tiers .tier:not(.sel):hover,
  .ctl-tabs .btn:not(.on):hover,
  .help-nav .btn:not(.on):hover,
  .sw-tab:not(.on):hover {
    background: var(--surface-raised);
    border-color: var(--line-3);
    color: var(--text-1);
  }
}

/* touch screens: controls stay comfortable to hit */
html.touch-ui .btn,
html.touch-ui .btn.small {
  min-height: var(--ctl-touch);
}

.btn[disabled],
.nav[disabled] {
  opacity: 0.4;
  cursor: default;
  --elev: 0 0 #0000;
}

.nav {
  outline: none;
}

/* focus wins over every "selected" or "on" state */
.nav.is-focus,
.nav:focus-visible {
  outline: var(--focus-line);
  outline-offset: 2px;
  box-shadow: var(--focus-ring), var(--elev, 0 0 #0000);
}

/* key caps: parchment with an engraved lower edge */
.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  box-sizing: border-box;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #f6ecd6, #d9cbad);
  box-shadow: inset 0 -2px 0 rgba(90, 60, 30, 0.45);
  color: #1a120c;
  font: 700 var(--fs-xs)/1 var(--ui);
  vertical-align: middle;
}

.kbd-pad {
  border-radius: 50%;
  width: 17px;
  padding: 0;
  background: var(--kc);
  color: #1a1510;
}

.kbd + .kbd {
  margin-left: 3px;
}

.legend {
  position: absolute;
  right: 14px;
  bottom: 8px;
  display: flex;
  gap: 14px;
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.lg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* --- Titel --- */
.title-block {
  position: absolute;
  left: 520px;
  top: 78px;
  width: 400px;
  isolation: isolate;
}

.title-block::before {
  content: "";
  position: absolute;
  inset: -60px -90px -70px -80px;
  z-index: -1;
  background: radial-gradient(closest-side, rgba(7, 5, 4, 0.9), rgba(7, 5, 4, 0.78) 55%, rgba(7, 5, 4, 0));
  pointer-events: none;
}

.logo {
  font-family: var(--display);
  font-weight: 700;
  font-size: 72px;
  line-height: 0.9;
  margin: 8px 0 14px;
  white-space: nowrap;
  color: #ffe9c4;
  text-shadow: 0 2px 0 #3a1a08, 0 0 26px rgba(255, 154, 60, 0.35);
}

.tagline {
  font-size: var(--fs-md);
  line-height: var(--lh-text);
  color: var(--text-2);
  max-width: 38ch;
}

/* login menu under the logo (the title is the login, UI.title) */
.login-menu {
  margin-top: 16px;
  padding: 12px 14px 12px;
  background: var(--surface-glass);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  box-shadow: var(--bevel), 0 14px 36px rgba(0, 0, 0, 0.5);
}

.login-field {
  display: grid;
  gap: 3px;
  margin-bottom: 8px;
}

.login-field span {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-3);
}

.login-msg {
  min-height: 16px;
  margin: 0 0 6px;
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.login-msg.bad {
  color: var(--bad);
}

.login-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.login-actions .btn {
  min-height: 30px;
  padding: 5px 16px;
}

/* dialogs with a left and a right action (Abbrechen … Account erstellen) */
.actions.split {
  justify-content: space-between;
}

.fine {
  margin-top: 18px;
  font-size: var(--fs-sm);
  color: var(--text-3);
  max-width: 44ch;
}

/* --- Klassenwahl --- */
.pick {
  background: linear-gradient(180deg, rgba(11, 8, 5, 0.55), rgba(11, 8, 5, 0.85));
}

.pick-head {
  position: absolute;
  top: 10px;
  left: 0;
  right: 0;
  text-align: center;
}

.pick-head h2 {
  font-family: var(--display);
  font-size: var(--fs-4xl);
  font-weight: 700;
  margin-top: 2px;
}

.cards {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 104px;
  bottom: 40px;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.ccard {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  text-align: left;
  padding: 5px 7px 8px;
  overflow: hidden;
  background: rgba(23, 19, 13, 0.9);
  border: 1px solid var(--line);
  border-top: 2px solid var(--c);
  border-radius: var(--radius-lg);
  transition: transform 0.14s, border-color 0.14s;
}

.ccard.is-focus {
  transform: translateY(-5px);
  border-color: var(--c);
  outline-color: var(--c);
}

.ccard canvas {
  width: 100%;
  height: 112px;
}

.cname {
  font-family: var(--display);
  font-size: var(--fs-2xl);
  line-height: 1;
}

.cname small {
  font-family: var(--ui);
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.ctitle {
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crole {
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.ratings {
  display: grid;
  gap: 3px;
  margin: 6px 0 4px;
  width: 100%;
}

.rt {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.rt b {
  display: inline-flex;
  gap: 3px;
}

.rt i,
.pips i {
  display: inline-block;
  width: 7px;
  height: 7px;
  transform: rotate(45deg);
  background: rgba(255, 255, 255, 0.12);
}

.rt i.on {
  background: var(--c);
}

.cdesc {
  font-size: var(--fs-sm);
  line-height: 1.38;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- Stationen in Echofurt --- */
.station.overlay {
  display: block;
  background: linear-gradient(to bottom, rgba(8, 6, 4, 0.92), var(--scrim));
}

.st-head {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-bottom: 1px solid var(--groove-dark);
  background: linear-gradient(180deg, rgba(34, 27, 20, 0.94), rgba(14, 11, 8, 0.88));
  box-shadow: var(--groove), 0 4px 14px rgba(0, 0, 0, 0.35);
}

.st-face {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid var(--brass-lo);
  background: rgba(15, 12, 8, 0.85);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.5);
}

.st-who {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}

.st-who strong {
  font-family: var(--display);
  font-size: var(--fs-3xl);
  font-weight: 700;
  line-height: 1;
  color: #ffe6c2;
  text-shadow: 0 1px 0 #000, 0 0 16px rgba(255, 154, 60, 0.18);
}

.st-who em {
  font-style: normal;
  font-size: var(--fs-sm);
  color: var(--text-3);
}

/* stations without a subtitle: the name sits alone */
.st-who em:empty {
  display: none;
}

.st-close {
  flex: none;
}

.station .hero-card,
.station .panel {
  top: 66px;
}

.res {
  display: flex;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px 3px 6px;
  background: rgba(12, 10, 8, 0.82);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  font-weight: 600;
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}

.chip small {
  font-weight: 400;
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.chip [data-icon] {
  display: inline-flex;
}

.coin {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #ffcf4a;
  border: 1.5px solid #8a5a12;
  box-sizing: border-box;
}

.hero-card {
  position: absolute;
  left: 12px;
  top: 58px;
  width: 272px;
  box-sizing: border-box;
  padding: 9px 11px;
  background: var(--glass-fill);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  box-shadow: var(--bevel), var(--shadow);
}

.hc-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hc-lvl {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--c);
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: var(--fs-xl);
  font-weight: 700;
}

.hc-name {
  font-family: var(--display);
  font-size: var(--fs-2xl);
  line-height: 1;
}

.hc-title {
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.xp {
  height: 4px;
  margin-top: 8px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}

.xp i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--ember-lo), var(--ember));
}

.xp-label {
  font-size: var(--fs-xs);
  color: var(--text-3);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

.sp-badge {
  display: inline-block;
  margin: 6px 6px 0 0;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--ember-tint-2);
  color: var(--ember-hi);
  font-size: var(--fs-xs);
  font-weight: 600;
}

.sp-badge.spec {
  background: rgba(116, 211, 198, 0.16);
  color: var(--echo);
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 14px;
  margin: 8px 0 0;
}

.stats div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.stats dt {
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.stats dd {
  margin: 0;
  font-size: var(--fs-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.panel {
  position: absolute;
  left: 296px;
  right: 12px;
  top: 58px;
  bottom: 32px;
  display: flex;
  flex-direction: column;
  background: var(--corners), var(--glass-fill);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--bevel), var(--shadow);
}

.tab-body {
  flex: 1;
  overflow: auto;
  padding: 9px 11px;
  position: relative;
  scrollbar-width: thin;
}

.tab-body h4,
.info-col h4 {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 10px 0 4px;
}

.tab-body h4::after,
.info-col h4::after,
.ol-body h4::after {
  content: "";
  display: block;
  height: 1px;
  margin-top: 3px;
  background: linear-gradient(90deg, rgba(214, 176, 120, 0.35), rgba(214, 176, 120, 0));
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

/* Expeditions */
/* Echotor: dungeon list in the left column, description and actions in the panel */
.has-side .hero-card {
  bottom: 32px;
  display: flex;
  flex-direction: column;
}

.hero-side {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.hero-side .exp-list {
  flex: 1;
  max-height: none;
  min-height: 0;
}

.hero-side .exp-head {
  margin-bottom: 8px;
}

.hero-side .exp-head strong {
  font-size: var(--fs-xl);
}

.has-side .hero-card .stats {
  display: none;
}

.exp3 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 236px;
  gap: 18px;
  height: 100%;
}

.exp-act {
  display: flex;
  flex-direction: column;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.exp-act h4:first-child {
  margin-top: 2px;
}

.exp-act .diff {
  margin-top: 0;
  flex-direction: column;
}

.exp-act .go {
  margin-top: auto;
}

.exp {
  display: grid;
  grid-template-columns: 208px 1fr;
  gap: 16px;
}

.exp-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 336px;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
}

.exp-list .dcard {
  grid-template-columns: 24px minmax(0, 1fr) auto;
  column-gap: 8px;
  row-gap: 1px;
  padding: 5px 7px;
}

.exp-list .dcard .dname,
.exp-list .dcard .dmeta {
  grid-column: 2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.exp-list .dcard .ranks {
  grid-column: 3;
  grid-row: 1 / span 2;
  align-self: center;
  margin: 0;
  flex-direction: column;
  gap: 3px;
}

.exp-list .rank-badge {
  width: 15px;
  height: 15px;
  font-size: var(--fs-xs);
}

.dnum {
  grid-row: 1 / span 2;
  align-self: center;
  font-family: var(--display);
  font-size: var(--fs-lg);
  color: var(--text-3);
  text-align: center;
}

.exp-list .dname {
  font-size: var(--fs-md);
}

.exp:has(.exp-list .dnum) {
  grid-template-columns: 270px 1fr;
}

.dcard.done .dnum {
  color: var(--gold);
}

.exp-head {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 4px 12px;
  margin-bottom: 10px;
}

.exp-head strong {
  font-family: var(--display);
  font-size: var(--fs-2xl);
}

.exp-head span {
  font-size: var(--fs-base);
  color: var(--ember-hi);
  font-variant-numeric: tabular-nums;
}

.exp-head .bar {
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}

.exp-head .bar b {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--ember-lo), var(--gold));
}

.exp-head em {
  grid-column: 1 / -1;
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.dtags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.tag.dim {
  background: var(--line);
  color: var(--text-3);
}

.foes {
  margin-top: 4px;
  font-size: var(--fs-sm);
  color: var(--text-3);
  line-height: 1.4;
}

/* Travel gate and world map */
.travel {
  display: grid;
  grid-template-columns: 1fr 250px;
  gap: 14px;
  align-items: start;
}

.wmap-wrap {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(90, 60, 30, 0.6), 0 6px 20px rgba(0, 0, 0, 0.45);
}

.wmap {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.travel-main {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.town-pips {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.town-pips > span {
  font-family: var(--display);
  font-size: var(--fs-md);
  color: var(--ember-hi);
}

.town-pips .pips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.town-pips i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--line);
  border: 1px solid rgba(239, 228, 204, 0.18);
}

.town-pips i.open {
  border-color: #fff3dc;
}

.town-pips i.done {
  background: #e8b04a;
  border-color: #ffe39a;
}

.travel-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.town-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tcard {
  display: grid;
  gap: 2px;
  text-align: left;
  padding: 5px 8px;
  background: var(--well);
  border: 1px solid var(--line);
  border-left: 2px solid var(--tc);
  border-radius: var(--radius);
}

.tcard.sel {
  background: var(--ember-tint);
  border-color: var(--line-3);
  border-left-color: var(--tc);
}

.tcard.locked {
  opacity: 0.6;
  border-left-color: var(--line);
}

.tname {
  font-family: var(--display);
  font-size: var(--fs-xl);
}

.tname small {
  font-family: var(--ui);
  font-size: var(--fs-sm);
  color: var(--bad);
  margin-left: 4px;
}

.town-detail h3 {
  font-family: var(--display);
  font-size: var(--fs-2xl);
  color: var(--tc);
}

.town-detail .sub {
  font-size: var(--fs-sm);
  color: var(--text-3);
  font-style: italic;
}

.town-detail .desc {
  margin-top: 6px;
  font-size: var(--fs-base);
  line-height: var(--lh-text);
  color: var(--text-2);
}

.town-detail .go {
  margin-top: 10px;
  width: 100%;
}

.worldmap .dialog.wide {
  width: 600px;
  max-height: 524px;
  padding: 8px 11px;
}

.worldmap .dialog h2 {
  font-size: var(--fs-3xl);
  margin: 2px 0 4px;
}

.worldmap .dialog > p.muted {
  font-size: var(--fs-sm);
}

.worldmap .actions {
  margin-top: 6px;
}

.wmap.big {
  height: auto;
  aspect-ratio: 16 / 10;
  margin: 6px 0 4px;
  border-radius: var(--radius);
}

.town-prog {
  margin-top: 6px;
  font-size: var(--fs-base);
  color: var(--text-3);
}

.town-new {
  color: var(--gold);
}

.dcard {
  display: grid;
  gap: 3px;
  text-align: left;
  padding: 7px 9px;
  background: var(--well);
  border: 1px solid var(--line);
  border-left: 2px solid transparent;
  border-radius: var(--radius);
}

.dcard.sel {
  border-left-color: var(--ember);
  background: var(--ember-tint);
  border-color: var(--line-2);
}

.dcard.locked {
  opacity: 0.6;
}

.dname {
  font-family: var(--display);
  font-size: var(--fs-lg);
  line-height: 1.05;
}

.dmeta {
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.ranks {
  display: flex;
  gap: 5px;
  margin-top: 3px;
}

.rank-badge {
  display: inline-grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border-radius: var(--radius-sm);
  background: var(--line);
  font-family: var(--display);
  font-weight: 700;
  font-size: var(--fs-base);
  color: #14100e;
}

.rank-badge.none {
  color: var(--text-3);
}

.rS {
  background: var(--gold);
}

.rA {
  background: #9fe4ff;
}

.rB {
  background: var(--good);
}

.rC {
  background: #c9c2b0;
}

.rD {
  background: #8a8478;
}

.exp-detail h3 {
  font-family: var(--display);
  font-size: var(--fs-2xl);
  font-weight: 700;
  line-height: 1;
}

.exp-detail .desc {
  margin-top: 4px;
  font-size: var(--fs-base);
  line-height: var(--lh-text);
  color: var(--text-2);
  max-width: 62ch;
}

.boss-line {
  margin-top: 6px;
  font-size: var(--fs-base);
  color: var(--text-3);
}

.boss-line strong {
  color: #ffb49a;
}

.missions li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
  border-bottom: 1px dashed var(--line);
  font-size: var(--fs-base);
}

.missions b {
  color: var(--ember-hi);
  font-variant-numeric: tabular-nums;
}

.missions li.ok {
  color: var(--good);
}

.missions li.ok b {
  color: var(--good);
}

.missions li.no {
  color: var(--text-3);
}

.diff {
  display: flex;
  gap: 8px;
  margin: 12px 0 0;
}

.seg {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 5px 9px;
  background: var(--surface-sunk);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--text-2);
}

.seg small {
  font-size: var(--fs-xs);
  font-weight: 400;
  color: var(--text-3);
}

.seg.on {

}

.go {
  width: 100%;
  margin-top: 10px;
  font-size: var(--fs-md);
  min-height: 32px;
  padding: 6px;
}

/* Skills */
.sp-line {
  font-size: var(--fs-base);
  color: var(--text-3);
  margin-bottom: 4px;
}

.sp-line strong {
  color: var(--ember-hi);
  font-size: var(--fs-base);
}

.skill-row {
  display: grid;
  grid-template-columns: 36px 1fr auto 28px;
  gap: 10px;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
}

/* skill runes and Echo levels */
.skill-block {
  border-bottom: 1px solid var(--line);
}

.skill-block .skill-row {
  border-bottom: none;
}

.pips10 {
  display: grid;
  grid-template-columns: repeat(5, 8px);
  gap: 3px;
}

.pips10 i.gate {
  opacity: 0.25;
  outline: 1px dashed rgba(239, 228, 204, 0.4);
}

.rune-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 0 6px 46px;
}

.rune-tier {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.rune-tier .rt-lvl {
  grid-column: 1 / -1;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
}

.rune-tier.locked {
  opacity: 0.5;
}

.rune-chip,
.echo-btn {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 4px 5px;
  text-align: left;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: inherit;
  font: inherit;
}

.rune-chip strong,
.echo-btn strong {
  font-size: var(--fs-sm);
}

.rune-chip span,
.echo-btn span {
  font-size: var(--fs-xs);
  line-height: 1.25;
  color: var(--text-3);
}

.rune-chip.on {
  border-color: var(--ember);
  background: var(--ember-tint);
  box-shadow: var(--elev);
  --elev: inset 0 0 0 1px var(--ember);
}

.echo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 8px;
}

.echo-btn em {
  font-style: normal;
  color: var(--ember-hi);
  font-variant-numeric: tabular-nums;
}

.skill-row.locked {
  opacity: 0.72;
}

.sicon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-lg);
  background: rgba(15, 12, 8, 0.7);
  border: 1px solid var(--line);
}

/* the skill icons are drawn at a fixed size: shown a bit smaller */
.skill-row .sicon canvas {
  width: 28px !important;
  height: 28px !important;
}

.sname {
  font-size: var(--fs-base);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tag {
  font-size: var(--fs-tiny);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  background: rgba(214, 176, 120, 0.16);
  color: var(--brass);
}

.tag.alt {
  background: var(--echo-tint);
  color: var(--echo);
}

.sdesc {
  font-size: var(--fs-sm);
  color: var(--text-2);
  margin-top: 2px;
  max-width: 64ch;
}

.smeta {
  font-size: var(--fs-sm);
  color: var(--ember-hi);
  opacity: 0.85;
  margin-top: 2px;
}

.pips {
  display: flex;
  gap: 5px;
}

.pips i.on {
  background: var(--ember);
}

.plus {
  width: 28px;
  min-height: 28px;
  height: 28px;
  padding: 0;
  font-size: var(--fs-lg);
}

html.touch-ui .plus {
  width: 36px;
  height: 36px;
}

.spec-box {
  margin-top: 12px;
  padding: 8px 9px;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.spec-box h4 {
  margin-top: 0;
}

.spec-box p {
  font-size: var(--fs-base);
  line-height: var(--lh-text);
}

.spec-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.spec-btn {
  text-align: left;
  display: grid;
  gap: 3px;
  padding: 7px 9px;
  background: linear-gradient(180deg, var(--surface-hi), var(--surface-raised));
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  --elev: inset 0 1px 0 rgba(255, 226, 180, 0.08);
  box-shadow: var(--elev);
}

.spec-btn strong {
  font-size: var(--fs-base);
}

.spec-btn span {
  font-size: var(--fs-sm);
  color: var(--text-2);
}

/* Runes */
.runes {
  display: grid;
  grid-template-columns: 1fr 236px;
  grid-template-rows: auto 1fr;
  gap: 12px;
}

.rslots {
  grid-column: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.rslot {
  display: grid;
  gap: 2px;
  align-content: start;
  text-align: left;
  padding: 6px 8px;
  min-height: 72px;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.rs-label {
  font-size: var(--fs-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
}

.rname {
  font-size: var(--fs-base);
  font-weight: 600;
}

.rstats {
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.empty {
  font-size: var(--fs-base);
  color: var(--text-3);
}

.inv {
  grid-column: 1;
}

.inv-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: var(--fs-base);
  color: var(--text-3);
}

.inv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 46px);
  gap: 6px;
}

.inv-grid > p {
  grid-column: 1 / -1;
}

.rune {
  position: relative;
  width: 46px;
  height: 46px;
  padding: 0;
  background: linear-gradient(180deg, #1c1712, #0d0b09);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
}

.rune.sel {
  border-color: var(--rc);
  --elev: inset 0 0 0 2px var(--ember);
  box-shadow: var(--elev);
}

.hex {
  position: absolute;
  inset: 9px;
  background: var(--rc);
  clip-path: polygon(25% 5%, 75% 5%, 100% 50%, 75% 95%, 25% 95%, 0 50%);
  opacity: 0.92;
}

.rslot-ico {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: var(--fs-sm);
  color: #1a1510;
}

.rp {
  position: absolute;
  right: 3px;
  bottom: 1px;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--ember-hi);
}

.req {
  position: absolute;
  left: 3px;
  top: 3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.rune-detail {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: start;
  padding: 9px;
  background: var(--well);
  border: 1px solid var(--line);
  border-top: 2px solid var(--rc, var(--line));
  border-radius: var(--radius);
}

.rd-name {
  display: block;
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--rc);
}

.rd-meta {
  display: block;
  font-size: var(--fs-sm);
  color: var(--text-3);
  margin-top: 2px;
}

.rd-stats {
  margin-top: 8px;
}

.rd-stats li {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-base);
  padding: 3px 0;
  border-bottom: 1px dashed var(--line);
}

.rd-stats b {
  font-variant-numeric: tabular-nums;
}

.rd-power {
  margin-top: 8px;
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.up {
  color: var(--good);
}

.down {
  color: var(--bad);
}

.rd-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

/* Forge */
.frow {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

/* list rows: the row buttons stay quiet (outlined) so nine "Kaufen" in a
   column do not shout; the hovered row and the focused button light up */
.frow .btn:not(.primary):not(.danger) {
  background: rgba(12, 10, 8, 0.4);
  --elev: 0 0 #0000;
}

@media (hover: hover) {
  .frow:hover {
    background: linear-gradient(90deg, rgba(255, 154, 60, 0), rgba(255, 154, 60, 0.06) 30%, rgba(255, 154, 60, 0.06) 70%, rgba(255, 154, 60, 0));
  }

  .frow:hover .btn:not(.primary):not(.danger):not([disabled]) {
    background: linear-gradient(180deg, var(--surface-hi), var(--surface-raised));
    border-color: var(--line-3);
  }
}

.fname {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-base);
  font-weight: 600;
}

.fname small {
  font-weight: 500;
  color: var(--text-3);
}

.fcost {
  font-size: var(--fs-sm);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.note {
  margin-top: 10px;
  font-size: var(--fs-sm);
}

/* Merchant */
.shop {
  display: grid;
  grid-template-columns: 1fr 236px;
  gap: 16px;
}

.shop h4 small {
  margin-left: 6px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-3);
}

.shop .fname {
  display: block;
  min-width: 0;
}

.shop .fname [data-icon] {
  display: inline-block;
  vertical-align: -3px;
  margin-right: 4px;
}

.fname .fdesc {
  display: block;
  margin-top: 2px;
  font-size: var(--fs-sm);
  line-height: var(--lh);
}

.shop-sell .sell-good {
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 5px 0;
}

.shop-sell .sell-good .fname {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-base);
  white-space: nowrap;
}

.shop-sell .sell-good .fname [data-icon] {
  margin-right: 0;
}

/* forge next to the buy-back column: cost line under the item name */
.forge-shop .frow {
  grid-template-columns: 1fr auto;
  row-gap: 2px;
}

.forge-shop .frow .fcost {
  grid-column: 1;
  grid-row: 2;
}

.forge-shop .frow .btn {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.shop-sell .sell-good .btn {
  min-width: 0;
  padding-inline: 8px;
  font-variant-numeric: tabular-nums;
}

.shop-tiers {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 10px;
}

.shop-tiers .tier.own {
  border-color: var(--brass);
}

.shop-tiers .tier.sel {

}

.shop-tiers .tier.later {
  opacity: 0.7;
}

.frow.offer .fname > em {
  font-style: normal;
  font-size: var(--fs-xs);
  margin-left: 6px;
  color: var(--text-3);
  white-space: nowrap;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  background: rgba(214, 176, 120, 0.12);
  vertical-align: 1px;
}

.frow.offer .fname > em.up {
  color: var(--good);
  background: rgba(143, 227, 154, 0.12);
}

.frow.offer .fname > em.down {
  color: var(--bad);
  background: rgba(255, 138, 122, 0.12);
}

.frow.offer .lock {
  color: var(--bad);
  font-weight: 600;
}

.frow.sold {
  grid-template-columns: 1fr;
  opacity: 0.5;
}

.shop-sell .inv-grid {
  grid-template-columns: repeat(auto-fill, 40px);
  margin-bottom: 10px;
}

.shop-sell .rune {
  width: 40px;
  height: 40px;
}

.shop-sell .rune-detail {
  grid-column: auto;
  grid-row: auto;
}

.shop-sell .rd-actions .muted {
  font-size: var(--fs-sm);
}

/* Heroes */
.heroes > p {
  font-size: var(--fs-base);
  margin-bottom: 10px;
}

.hgrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.hcard {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: center;
  gap: 4px 10px;
  padding: 5px 9px 6px 4px;
  background: var(--well);
  border: 1px solid var(--line);
  border-left: 2px solid var(--c);
  border-radius: var(--radius);
}

.hcard.cur {
  background: var(--ember-tint);
}

.hcard canvas {
  grid-row: span 2;
  width: 96px;
  height: 90px;
}

.hcard > .btn,
.hcard > .cur-tag {
  justify-self: start;
}

.hinfo strong {
  display: block;
  font-family: var(--display);
  font-size: var(--fs-xl);
  font-weight: 700;
  line-height: 1;
}

.hinfo span {
  display: block;
  font-size: var(--fs-sm);
}

.cur-tag {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ember-hi);
}

/* Options */
.orow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-base);
}

.stepper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stepper b {
  min-width: 48px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.toggle {
  min-width: 64px;
}

.toggle.on {
  background: var(--ember-tint-2);
  border-color: var(--ember);
  color: var(--ember-hi);
}

.confirm {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-base);
  color: #ffc2b8;
}

/* --- Overlays --- */
.overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--scrim);
}

.dialog {
  width: 420px;
  max-height: 500px;
  overflow: auto;
  box-sizing: border-box;
  padding: 14px 16px;
  background: var(--corners), var(--win-fill);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  box-shadow: var(--bevel), var(--shadow-win);
}

.dialog.wide {
  width: 780px;
}

.dialog h2 {
  font-family: var(--display);
  font-size: var(--fs-4xl);
  font-weight: 700;
  line-height: 1;
  margin: 4px 0 10px;
}

.dialog > p.muted {
  font-size: var(--fs-base);
  line-height: var(--lh-text);
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.actions.col {
  flex-direction: column;
  gap: 5px;
}

.pause .dialog {
  width: 360px;
}

.town-menu .dialog {
  width: 340px;
}

.pause .missions {
  margin-top: 4px;
}

.tbl-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 4px 0 10px;
}

th {
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 4px 6px;
}

td {
  padding: 5px 6px;
  font-size: var(--fs-base);
  border-top: 1px solid var(--line);
}

td:first-child {
  color: var(--text-2);
}

.controls p.muted {
  font-size: var(--fs-base);
}

.ctl-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.ctl-tabs .btn.on {

}

/* help: topics on the left, text on the right */
.help .dialog.help-dialog {
  width: min(900px, calc(100% - 32px));
  height: calc(100% - 40px);
  display: flex;
  flex-direction: column;
}

.help-body {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 16px;
  min-height: 0;
  flex: 1;
  margin-bottom: 12px;
}

.help-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  min-height: 0;
  padding: 2px;
}

.help-nav .btn {
  justify-content: flex-start;
  text-align: left;
}

.help-nav .btn.on {

}

.help-text {
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
  font-size: var(--fs-base);
  line-height: var(--lh-text);
  color: var(--text-1);
}

.help-text h3 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: var(--fs-xl);
  color: var(--ember-hi);
}

.help-text p,
.help-text ul {
  margin: 0 0 10px;
}

.help-text ul {
  padding-left: 14px;
}

.help-text li {
  margin-bottom: 4px;
}

.help-text td,
.help-text th {
  font-size: var(--fs-base);
}

.ctl-keys {
  max-height: 262px;
  overflow-y: auto;
}

.ctl-keys td {
  padding: 3px 6px;
}

.ctl-keys td.keys {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.keychip {
  min-width: 30px;
  height: 22px;
  padding: 0 6px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: var(--radius);
  background: #28221d;
  color: var(--text-1);
  font: 600 var(--fs-sm) var(--ui, system-ui, sans-serif);
  cursor: pointer;
}

.keychip.add {
  color: var(--text-3);
  border-style: dashed;
  border-bottom-width: 1px;
}

.keychip.wait {
  border-color: var(--ember);
  color: var(--ember-hi);
  animation: keywait 0.9s ease-in-out infinite;
}

.keychip.fixed {
  opacity: 0.6;
  cursor: default;
}

@keyframes keywait {
  50% {
    background: #3a2a18;
  }
}

.unbound td:first-child {
  color: var(--bad);
}

.ctl-msg {
  min-height: 1.5em;
}

.res-grid {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 26px;
}

.rank-col {
  text-align: center;
}

.rank {
  font-family: var(--display);
  font-weight: 900;
  font-size: 170px;
  line-height: 0.9;
  margin-top: 6px;
  animation: rank-in 0.55s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.rank.rS {
  background: none;
  color: var(--gold);
  text-shadow: 0 0 40px rgba(255, 207, 90, 0.55);
}

.rank.rA {
  background: none;
  color: #9fe4ff;
  text-shadow: 0 0 30px rgba(159, 228, 255, 0.4);
}

.rank.rB {
  background: none;
  color: var(--good);
}

.rank.rC {
  background: none;
  color: var(--text-2);
}

.rank.rD {
  background: none;
  color: #a39c90;
}

@keyframes rank-in {
  from {
    transform: scale(2.2);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.score {
  font-size: var(--fs-base);
  color: var(--ember-hi);
  margin-top: 4px;
}

.parts {
  margin: 14px 0 0;
  text-align: left;
}

.parts div {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px dashed var(--line);
  font-size: var(--fs-base);
}

.parts dt {
  color: var(--text-3);
}

.parts dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.loot li {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-size: var(--fs-base);
}

.loot b {
  font-variant-numeric: tabular-nums;
}

.loot-runes {
  margin-top: 4px;
}

.loot-runes li {
  font-size: var(--fs-base);
  font-weight: 600;
}

.loot-runes small {
  font-weight: 500;
  color: var(--text-3);
  margin-left: 4px;
}

.lvl-up {
  margin-top: 8px;
  color: var(--ember-hi);
  font-weight: 600;
  font-size: var(--fs-base);
}

.fallen {
  color: #ff7a6a;
}

/* --- Meldung --- */
#toast {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 6px 14px 6px 15px;
  background: linear-gradient(var(--ember), var(--ember)) left / 3px 100% no-repeat, var(--win-fill);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  font-size: var(--fs-base);
  opacity: 0;
  transform: translate(-50%, -24px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  box-shadow: var(--bevel), var(--shadow);
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

#toast span {
  font-size: var(--fs-sm);
  color: var(--text-2);
}

/* "Beleben mit Kristall": prompt next to a fallen member (group run on the
   server), styled like the town's interaction prompt */
.revive-prompt {
  position: absolute;
  left: 50%;
  bottom: 150px;
  z-index: 19;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-weight: 700;
  font-size: 16px;
  font-family: var(--ui);
  color: #ffe3b0;
  background: rgba(12, 9, 8, 0.82);
  border: 1.5px solid rgba(255, 207, 90, 0.6);
  border-radius: 10px;
  cursor: pointer;
}

.revive-prompt[hidden] {
  display: none;
}

.revive-prompt kbd {
  padding: 1px 7px;
  font: inherit;
  color: #1a1410;
  background: #ffcf5a;
  border-radius: 5px;
}

.revive-prompt small {
  font-size: 12px;
  font-weight: 500;
  opacity: 0.8;
}

/* Esc-hold reminder (fullscreen with keyboard lock) */
#lockhint {
  position: absolute;
  top: 6px;
  left: 50%;
  z-index: 21;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--win-fill);
  border: 1px solid var(--line-3);
  border-radius: var(--radius-lg);
  font-size: var(--fs-base);
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, -16px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  box-shadow: var(--bevel), var(--shadow);
}

#lockhint.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* "Welt verlassen": options with a line on what happens */
.leave-world .leave-opt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
}

.leave-world .leave-opt small {
  font-size: var(--fs-sm);
  font-weight: 500;
  opacity: 0.75;
}

/* back into fullscreen (with keyboard lock) after leaving it */
#relock {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 31;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px 5px 8px;
  background: var(--surface-glass);
  color: var(--text-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  pointer-events: auto;
  opacity: 0.88;
}

#relock:hover,
#relock:focus-visible {
  opacity: 1;
}

#relock[hidden] {
  display: none;
}

#relock svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--brass);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* touch: the action buttons sit bottom right, so below the hero card */
html.touch-ui #relock {
  top: 84px;
  left: 14px;
  right: auto;
  bottom: auto;
}

/* music and effects on/off (src/ui/sound.js): bottom right, the fullscreen button sits left of them */
.soundbtn {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 31;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  background: var(--stone-solid);
  color: inherit;
  border: 1px solid var(--ember, #ffb35c);
  border-radius: 8px;
  cursor: pointer;
  pointer-events: auto;
  opacity: 0.88;
}

.soundbtn:hover,
.soundbtn:focus-visible {
  opacity: 1;
}

.soundbtn[hidden] {
  display: none;
}

.soundbtn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--ember, #ffb35c);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.soundbtn svg .solid {
  fill: var(--ember, #ffb35c);
}

.soundbtn.off {
  border-color: rgba(239, 228, 204, 0.45);
}

.soundbtn.off svg {
  stroke: #efe4cc;
  opacity: 0.8;
}

.soundbtn.off svg .solid {
  fill: #efe4cc;
}

#musicbtn {
  right: 58px;
}

.soundbtn:not([hidden]) ~ #relock,
#relock:has(~ .soundbtn:not([hidden])) {
  right: 102px;
}

/* touch: under the hero card (the action buttons sit bottom right) */
html.touch-ui .soundbtn {
  top: 96px;
  left: 18px;
  right: auto;
  bottom: auto;
}

html.touch-ui #musicbtn {
  left: 62px;
}

html.touch-ui .soundbtn:not([hidden]) ~ #relock,
html.touch-ui #relock:has(~ .soundbtn:not([hidden])) {
  left: 106px;
  right: auto;
}

.lock-note .kbd {
  vertical-align: 1px;
}

/* team dungeon request (EK.TeamAsk): not modal, the hero can still walk */
#teamask {
  position: absolute;
  top: 58px;
  left: 50%;
  z-index: 22;
  width: 340px;
  transform: translateX(-50%);
  padding: 8px 11px 9px;
  background: var(--win-fill);
  border: 1px solid var(--line-3);
  border-radius: var(--radius-lg);
  font-size: var(--fs-base);
  pointer-events: auto;
  box-shadow: var(--bevel), var(--shadow);
}

#teamask[hidden] {
  display: none;
}

#teamask .eyebrow {
  margin: 0 0 4px;
}

#teamask p {
  margin: 0 0 8px;
  line-height: var(--lh);
}

#teamask ul {
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
}

#teamask li {
  display: grid;
  grid-template-columns: 1fr 120px;
  align-items: center;
  gap: 8px;
  padding: 3px 0 3px 6px;
  border-left: 2px solid var(--pc);
}

#teamask li b {
  font-size: var(--fs-sm);
  text-align: right;
}

#teamask li b.yes {
  color: #8fe35a;
}

#teamask li b.no {
  color: #ff6b5a;
}

#teamask .bar {
  display: block;
  height: 4px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 2px;
  overflow: hidden;
}

#teamask .bar > i {
  display: block;
  height: 100%;
  background: var(--ember);
}

#teamask .acts {
  display: flex;
  gap: 8px;
}

/* --- Item rolls of an online group (src/ui/online-roll.js) --- */
#lootroll {
  position: absolute;
  top: 118px;
  right: 12px;
  z-index: 22;
  width: 286px;
  max-width: calc(100% - 24px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  pointer-events: auto;
}

#lootroll[hidden] {
  display: none;
}

#lootroll .lr-card {
  padding: 8px 11px 9px;
  background: var(--stone-solid);
  border: 1px solid var(--ember, #ffb35c);
  border-radius: 10px;
}

#lootroll .lr-card.lr-done {
  border-color: rgba(239, 228, 204, 0.35);
}

#lootroll p {
  margin: 0 0 4px;
  line-height: 1.3;
}

#lootroll .eyebrow {
  display: flex;
  justify-content: space-between;
  margin-bottom: 2px;
}

#lootroll .lr-name {
  font-weight: 700;
  font-size: 14px;
}

#lootroll .lr-meta,
#lootroll .lr-stats,
#lootroll .lr-hint {
  color: rgba(239, 228, 204, 0.72);
  font-size: 11px;
}

#lootroll .bar {
  display: block;
  height: 5px;
  margin: 2px 0 6px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 3px;
  overflow: hidden;
}

#lootroll .bar > i {
  display: block;
  height: 100%;
  background: var(--ember, #ffb35c);
}

#lootroll ul {
  margin: 0 0 6px;
  padding: 0;
  list-style: none;
}

#lootroll li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0 2px 7px;
  border-left: 3px solid var(--pc);
}

#lootroll li i {
  color: rgba(239, 228, 204, 0.55);
}

#lootroll li.lr-win {
  background: rgba(255, 207, 90, 0.14);
}

#lootroll .lr-need {
  color: #8fe35a;
}

#lootroll .lr-greed {
  color: #ffcf5a;
}

#lootroll .lr-pass,
#lootroll .lr-no {
  color: rgba(239, 228, 204, 0.55);
}

#lootroll .acts {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
}

#lootroll .acts .btn {
  flex: 1;
  padding-left: 4px;
  padding-right: 4px;
}

#lootroll .lr-end {
  margin: 0;
}

#lootroll .lr-more {
  margin: 0;
  text-align: right;
  color: rgba(239, 228, 204, 0.72);
}

/* --- Touch-Steuerung --- */
#touch {
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
}

#touch[hidden] {
  display: none;
}

.stick {
  position: absolute;
  left: calc(22px + env(safe-area-inset-left, 0px));
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  width: 164px;
  height: 164px;
  pointer-events: auto;
  touch-action: none;
}

/* a wider invisible grab zone around the stick, so a thumb that lands a
   bit off still takes it (the stick keeps the finger via pointer capture) */
.stick::before {
  content: '';
  position: absolute;
  inset: -36px -36px -22px -22px;
  border-radius: 50%;
}

.stick-base {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(239, 228, 204, 0.06);
  border: 1.5px solid rgba(214, 176, 120, 0.3);
}

.knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 70px;
  height: 70px;
  margin: -35px 0 0 -35px;
  border-radius: 50%;
  background: rgba(239, 228, 204, 0.22);
  border: 1.5px solid rgba(232, 194, 136, 0.6);
}

.tbtns {
  position: absolute;
  right: calc(14px + env(safe-area-inset-right, 0px));
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  width: 260px;
  height: 240px;
  pointer-events: none;
  transform: scale(0.92);
  transform-origin: 100% 100%;
}

.tb {
  position: absolute;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  padding: 0;
  pointer-events: auto;
  touch-action: none;
  border-radius: 50%;
  background: rgba(23, 19, 13, 0.62);
  border: 1.5px solid rgba(214, 176, 120, 0.45);
  color: var(--text-1);
  font: 500 var(--fs-sm)/1 var(--ui);
}

.tb.down {
  background: rgba(255, 154, 60, 0.45);
}

.tb-attack {
  width: 86px;
  height: 86px;
  right: 16px;
  bottom: 16px;
  background: var(--ember-tint-2);
  border-color: var(--ember);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.tb-jump {
  right: 112px;
  bottom: 4px;
}

.tb-dash {
  right: 28px;
  bottom: 112px;
}

.tb.sk {
  width: 52px;
  height: 52px;
}

.tb-s1 {
  right: 184px;
  bottom: 40px;
}

.tb-s2 {
  right: 172px;
  bottom: 102px;
}

.tb-s3 {
  right: 124px;
  bottom: 150px;
}

.tb-s4 {
  right: 62px;
  bottom: 176px;
}

.tb.cd {
  opacity: 0.45;
}

.tb.link {
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(255, 207, 90, 0.45);
}

.tb-transform {
  width: 48px;
  height: 48px;
  right: 206px;
  bottom: 166px;
  border-color: rgba(255, 154, 60, 0.5);
}

.tb-transform.ready {
  background: rgba(255, 154, 60, 0.5);
  border-color: var(--ember-hi);
  animation: glow 0.8s ease-in-out infinite alternate;
}

#touch.town .tb.sk,
#touch.town .tb-transform,
#touch.town .tb-potion,
#touch.town .tb-target {
  display: none;
}

/* Target switch (Tab / R3 on keyboard and controller) */
.tb-target {
  width: 44px;
  height: 44px;
  right: 4px;
  bottom: 238px;
  border-color: rgba(143, 227, 255, 0.6);
}

.tb-potion {
  width: 44px;
  height: 44px;
  right: 4px;
  bottom: 186px;
  border-color: rgba(224, 112, 122, 0.6);
}

.pausebtn {
  top: calc(10px + env(safe-area-inset-top, 0px));
  right: calc(10px + env(safe-area-inset-right, 0px));
  width: 40px;
  height: 40px;
  font-size: var(--fs-sm);
}

.portrait .stick {
  bottom: calc(40px + env(safe-area-inset-bottom, 0px));
  transform: scale(0.86);
  transform-origin: bottom left;
}

.portrait .tbtns {
  bottom: calc(30px + env(safe-area-inset-bottom, 0px));
  transform: scale(0.86);
  transform-origin: bottom right;
}

#rotate {
  display: none;
  position: absolute;
  left: 16px;
  right: 16px;
  top: 50%;
  text-align: center;
  font-size: var(--fs-base);
  color: var(--text-3);
  pointer-events: none;
}

/* touch devices held upright: the game needs landscape and stays locked */
.portrait.touch-ui #rotate {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 100;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 19px 12px;
  overflow-y: auto;
  background: rgba(12, 10, 8, 0.97);
  color: var(--text-1);
  font: 600 var(--fs-xl)/1.35 var(--ui);
  pointer-events: auto;
  touch-action: none;
}

#rotate .rot-main {
  margin: 0;
}

#rotate .rot-icon {
  width: 52px;
  height: 86px;
  flex: none;
  border: 1.5px solid var(--ember);
  border-radius: var(--radius-lg);
  animation: rotate-hint 1.8s ease-in-out infinite;
}

@keyframes rotate-hint {
  0%, 25% {
    transform: rotate(0deg);
  }
  60%, 100% {
    transform: rotate(-90deg);
  }
}

#rotate .rot-app {
  max-width: 460px;
  padding: 11px 12px;
  border: 1px solid rgba(255, 179, 92, 0.45);
  border-radius: var(--radius-lg);
  background: rgba(255, 179, 92, 0.07);
  font: 400 var(--fs-lg)/1.45 var(--ui);
  color: var(--text-3);
  text-align: left;
}

#rotate .rot-app b {
  display: block;
  margin-bottom: 6px;
  color: var(--ember);
  font-size: var(--fs-lg);
  font-weight: 600;
}

#rotate .rot-app p {
  margin: 6px 0 0;
}

#rotate .rot-key {
  display: inline-block;
  min-width: 1.4em;
  padding: 0 4px;
  border: 1px solid var(--text-3);
  border-radius: var(--radius-sm);
  text-align: center;
  color: var(--text-1);
}

/* show only the steps for this device; all of them when it is unknown */
.dev-ios #rotate .rot-android,
.dev-android #rotate .rot-ios,
.dev-android #rotate .rot-ipad,
.dev-android #rotate .rot-iphone,
.dev-ipad #rotate .rot-iphone,
.dev-iphone #rotate .rot-ipad,
#rotate .rot-app .rot-inapp,
.dev-app #rotate .rot-app .rot-web,
.dev-app #rotate .rot-ios,
.dev-app #rotate .rot-android {
  display: none;
}

.dev-app #rotate .rot-app .rot-inapp {
  display: block;
}

.portrait.touch-ui #touch {
  display: none;
}

/* low landscape screens (phones): smaller touch controls */
@media (max-height: 460px) {
  .tbtns {
    transform: scale(0.74);
    transform-origin: 100% 100%;
  }

  .stick {
    transform: scale(0.76);
    transform-origin: 0 100%;
  }
}

@keyframes glow {
  from {
    box-shadow: 0 0 6px rgba(255, 154, 60, 0.4);
  }
  to {
    box-shadow: 0 0 14px rgba(255, 207, 138, 0.75);
  }
}

@media (prefers-reduced-motion: reduce) {
  .rank,
  .tb-transform.ready {
    animation: none;
  }
  .ccard,
  .btn,
  .sw-bag,
  .sw-store,
  .oc-bar,
  #toast,
  #lockhint {
    transition: none;
  }
  .ccard.is-focus,
  .btn.primary.is-focus {
    transform: none;
  }
  .keychip.wait {
    animation: none;
    background: #3a2a18;
  }
}

/* --- Controller einrichten --- */
.padsetup .dialog {
  text-align: center;
}

.padsetup .ps-pad {
  display: block;
  width: 420px;
  height: 220px;
  margin: 4px auto 0;
}

.ps-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 4px 0 10px;
}

.ps-dots i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(239, 228, 204, 0.18);
}

.ps-dots i.on {
  background: var(--good);
}

.padsetup .actions {
  justify-content: center;
}

.fine.warn {
  color: var(--warn);
}

/* Gear and inventory */
.gear.overlay {
  background: var(--scrim);
}

.gear-win {
  position: absolute;
  inset: 10px;
  display: grid;
  grid-template-columns: 292px 452px 1fr;
  grid-template-rows: 40px 1fr;
  gap: 8px 10px;
  padding: 6px 9px 9px;
  box-sizing: border-box;
  background: var(--corners), var(--win-fill);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  box-shadow: var(--bevel), var(--shadow-win);
}

.gw-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--groove-dark);
  box-shadow: var(--groove);
}

.gw-head > div {
  display: grid;
  flex: 1;
}

.gw-head strong {
  font-family: var(--display);
  font-size: var(--fs-2xl);
  line-height: 1;
}

.gw-head .eyebrow {
  font-size: var(--fs-xs);
}

.gw-who {
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.gw-equip {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}

.gw-doll {
  display: grid;
  grid-template-columns: 58px 1fr 58px;
  align-items: center;
  background: radial-gradient(ellipse at 50% 60%, rgba(255, 207, 138, 0.08), rgba(0, 0, 0, 0) 70%), var(--well);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 5px;
}

.gw-doll-l,
.gw-doll-r {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gd-refine {
  font-size: var(--fs-sm);
  color: #9fe4c8;
  line-height: var(--lh);
}

.gw-fig {
  width: 150px;
  height: 230px;
  justify-self: center;
}

.gslot {
  position: relative;
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  padding: 0;
  background: linear-gradient(180deg, #16120e, #0b0908);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  --elev: inset 0 1px 4px rgba(0, 0, 0, 0.6);
  box-shadow: var(--elev);
}

.gslot.full {
  border-color: var(--rc);
  --elev: inset 0 0 0 2px color-mix(in srgb, var(--rc) 25%, transparent), inset 0 1px 4px rgba(0, 0, 0, 0.6);
}

.gslot.sel,
.gcell.sel {
  --elev: inset 0 0 0 2px var(--ember), inset 0 0 0 3px rgba(0, 0, 0, 0.6);
  background: linear-gradient(180deg, #3a2614, #1a110a);
}

.gs-empty {
  font-size: var(--fs-tiny);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(214, 176, 120, 0.5);
  font-weight: 700;
}

.gi {
  display: block;
  line-height: 0;
}

.gp {
  position: absolute;
  right: 2px;
  top: 1px;
  font-style: normal;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 1px 2px #000;
}

.gw-statbox .gw-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 12px;
  margin: 0;
  font-size: var(--fs-sm);
}

.gw-stats div {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px dashed var(--line);
}

.gw-stats dt {
  color: var(--text-3);
}

.gw-stats dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.gw-power {
  margin-top: 4px;
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.gw-power b {
  color: var(--ember-hi);
  font-size: var(--fs-base);
}

.gw-toggle {
  margin-top: 4px;
  padding: 3px 5px;
  font-size: var(--fs-sm);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  text-align: left;
}

.gw-inv {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}

.gw-filter {
  display: flex;
  align-items: center;
  gap: 4px;
}

.gw-filter .seg {
  padding: 3px 8px;
  font-size: var(--fs-sm);
}

.gw-count {
  margin-left: auto;
  font-size: var(--fs-sm);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.gw-grid {
  display: grid;
  grid-template-columns: repeat(10, 42px);
  grid-auto-rows: 42px;
  gap: 3px;
}

.gcell {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  background: linear-gradient(180deg, #1c1712, #0d0b09);
  border: 1px solid var(--rc, #6a6252);
  border-radius: var(--radius);
  --elev: inset 0 0 0 2px color-mix(in srgb, var(--rc, #6a6252) 22%, transparent), inset 0 1px 0 rgba(255, 226, 180, 0.06);
  box-shadow: var(--elev);
}

.gcell.empty {
  border-color: var(--line);
  background: var(--well-2);
  --elev: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

.gcell.nofit .gi {
  filter: saturate(0.25) brightness(0.7);
}

/* wrong class (never wearable by this hero): red frame, diagonal bar */
.gcell.locked {
  border-color: var(--bad);
  --elev: inset 0 0 0 1px color-mix(in srgb, var(--bad) 55%, transparent);
}

.gcell.later .gi {
  /* right class, level too low: greyed out until the hero gets there */
  filter: grayscale(1) brightness(0.6);
  opacity: 0.75;
}

.gcell.locked::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: var(--radius);
  background: linear-gradient(to top right, transparent calc(50% - 1.5px), color-mix(in srgb, var(--bad) 85%, transparent) calc(50% - 1.5px), color-mix(in srgb, var(--bad) 85%, transparent) calc(50% + 1.5px), transparent calc(50% + 1.5px));
  pointer-events: none;
}

.gcell .gw {
  position: absolute;
  left: 3px;
  top: 3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #000;
}

.gcell .glv {
  position: absolute;
  left: 2px;
  bottom: 1px;
  font-style: normal;
  font-size: var(--fs-tiny);
  font-weight: 700;
  color: var(--bad);
  text-shadow: 0 1px 2px #000;
}

.gw-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: var(--fs-sm);
  color: var(--text-2);
}

.gw-stack > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.gw-detail {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 8px;
  background: var(--well);
  border: 1px solid var(--line);
  border-top: 2px solid var(--rc, var(--line));
  border-radius: var(--radius-lg);
  font-size: var(--fs-sm);
}

.gw-detail.empty .muted {
  font-size: var(--fs-sm);
  line-height: var(--lh-text);
}

.gd-top {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
}

/* classes that can wear the item: portraits, the others greyed out */
.gd-classes {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin: 6px 0 2px;
}

.gd-cls {
  width: 20px;
  height: 20px;
  border-radius: 50%;
}

.gd-cls.off {
  filter: grayscale(1) brightness(0.45);
  opacity: 0.7;
}

.gd-cls.me {
  box-shadow: 0 0 0 2px var(--ember);
}

.gd-top > div {
  min-width: 0;
}

.gd-name {
  font-family: var(--display);
  font-size: var(--fs-md);
  line-height: 1.05;
  color: var(--rc);
  overflow-wrap: break-word;
  hyphens: auto;
}

.gd-meta,
.gd-type {
  color: var(--text-3);
  font-size: var(--fs-sm);
  line-height: var(--lh);
}

.gd-warn {
  color: var(--bad);
  font-size: var(--fs-sm);
}

.gd-stats li {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
  border-bottom: 1px dashed var(--line);
}

.gd-stats em,
.gd-power em {
  font-style: normal;
  font-size: var(--fs-xs);
}

.gd-stats em.up,
.gd-power em.up {
  color: var(--good);
}

.gd-stats em.down,
.gd-power em.down {
  color: var(--bad);
}

.gd-power {
  color: var(--text-3);
}

.gd-actions {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: auto;
}

.rune.gcell .hex,
.rune.gcell .rslot-ico {
  display: none;
}

/* Hero choice: man or woman */
.sexpick {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.sexpick .seg {
  flex: 0 0 auto;
  width: auto;
  padding: 3px 11px;
  font-size: var(--fs-base);
}

.sexpick small {
  color: var(--text-3);
  font-size: var(--fs-sm);
}

.hsex {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ==========================================================================
   Online mode (src/ui/online*.js): online menu, name dialog, save choice,
   party, ignore list, vending stalls and the town chat. Everything stays
   inside the 960×540 stage.
   ========================================================================== */
.ol.overlay,
.om.overlay {
  background: var(--scrim);
}

.ol-win {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 780px;
  height: 468px;
  transform: translate(-50%, -52%);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  padding: 6px 12px 6px;
  background: var(--corners), var(--win-fill);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  box-shadow: var(--bevel), var(--shadow-win);
}

.ol-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--groove-dark);
  box-shadow: var(--groove);
}

.ol-head > div {
  display: grid;
  flex: 1;
  min-width: 0;
}

.ol-head .eyebrow {
  font-size: var(--fs-xs);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ol-head strong {
  font-family: var(--display);
  font-size: var(--fs-2xl);
  line-height: 1.05;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ol-tabs {
  display: flex;
  gap: 6px;
  margin: 8px 0 6px;
}

.ol-tab {
  padding: 4px 11px;
  font-size: var(--fs-sm);
  font-weight: 500;
  background: var(--surface-sunk);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  color: var(--text-2);
}

.ol-tab.on {

}

.ol-tab small {
  color: var(--text-3);
  font-weight: 500;
}

.ol-badge {
  display: inline-grid;
  place-items: center;
  min-width: 16px;
  height: 16px;
  margin-left: 3px;
  border-radius: var(--radius-lg);
  background: #4fb4ff;
  color: #20140b;
  font: 700 var(--fs-xs)/1 var(--ui);
}

.ol-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 2px 2px 4px;
}

.ol-body h4 {
  margin: 10px 0 5px;
  font-size: var(--fs-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brass);
}

.ol-body h4 small {
  margin-left: 6px;
  letter-spacing: 0;
  text-transform: none;
  font-weight: 500;
  color: var(--text-3);
}

.ol-msg {
  min-height: 18px;
  padding-top: 4px;
  border-top: 1px solid var(--groove-dark);
  font-size: var(--fs-base);
  color: var(--echo);
  box-shadow: inset 0 1px 0 var(--groove-light);
}

.ol-msg.bad {
  color: var(--warn);
}

.ol-body .small,
.ol-dlg .small {
  font-size: var(--fs-sm);
}

/* Text fields */
.ol-field {
  display: grid;
  gap: 3px;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
}

.ol-field small {
  letter-spacing: 0;
  text-transform: none;
  font-weight: 500;
}

.ol-field.grow {
  flex: 1;
}

.ol-in {
  box-sizing: border-box;
  width: 100%;
  padding: 5px 8px;
  font: 500 var(--fs-base) var(--ui);
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-1);
  background: var(--surface-sunk);
  border: 1px solid var(--line-3);
  border-radius: var(--radius);
  -webkit-user-select: text;
  user-select: text;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);
}

.ol-in::placeholder {
  color: rgba(176, 164, 144, 0.7);
}

.ol-in:focus,
.ol-in.is-focus {
  border-color: var(--ember-hi);
}

.ol-in.small {
  padding: 4px 6px;
  font-size: var(--fs-base);
}

.ol-in.code {
  font: 600 var(--fs-lg)/1 var(--ui);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  width: 150px;
}

.ol-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: 10px;
}

/* Login */
.ol-auth {
  display: grid;
  grid-template-columns: 330px 1fr;
  gap: 22px;
  padding-top: 4px;
}

.ol-form {
  display: grid;
  gap: 10px;
  align-content: start;
}

.ol-form .btn.primary {
  margin-top: 2px;
}

.ol-server {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.ol-info {
  padding: 9px 12px;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  font-size: var(--fs-base);
  line-height: var(--lh-text);
}

.ol-info h4 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: var(--fs-xl);
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-1);
}

.ol-info ul {
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
}

.ol-info li {
  padding-left: 11px;
  position: relative;
}

.ol-info li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ember);
}

.ol-info .muted {
  font-size: var(--fs-sm);
}

/* Account */
.ol-acc {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 9px;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.ol-acc > div:not(.ol-accbtn) {
  display: grid;
  flex: 1;
}

.ol-acc strong {
  font-size: var(--fs-base);
}

.ol-acc .muted {
  font-size: var(--fs-sm);
}

.ol-accbtn {
  display: flex;
  gap: 6px;
}

.ol-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bad);
  box-shadow: 0 0 8px currentColor;
}

.ol-dot.st-open {
  background: var(--good);
}

.ol-dot.st-connecting {
  background: var(--ember-hi);
}

.ol-save {
  margin-top: 6px;
  font-size: var(--fs-sm);
}

/* title flow: start playing right from the account tab */
.ol-play {
  width: 100%;
  min-height: 32px;
  margin-bottom: 8px;
  font-size: var(--fs-md);
}

/* stored session that could not be resumed yet */
.ol-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  color: var(--ember-hi);
}

.ol-heroes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}

.ol-hero {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 3px 6px 3px 4px;
  background: var(--well);
  border: 1px solid var(--line);
  border-left: 2px solid var(--c);
  border-radius: var(--radius);
}

.ol-hero.cur {
  border-color: color-mix(in srgb, var(--c) 60%, transparent);
}

.ol-hero canvas {
  width: 54px;
  height: 62px;
}

.ol-hinfo {
  display: grid;
  min-width: 0;
}

.ol-hinfo strong {
  font-size: var(--fs-base);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ol-hinfo em {
  color: var(--warn);
}

.ol-hinfo span {
  font-size: var(--fs-sm);
  color: var(--text-3);
}

/* Party */
.ol-code {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: baseline;
  gap: 12px;
  padding: 6px 9px;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.ol-code span {
  font-size: var(--fs-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
}

.ol-code b {
  font: 700 var(--fs-3xl)/1 var(--ui);
  letter-spacing: 0.24em;
  color: var(--ember-hi);
  -webkit-user-select: text;
  user-select: text;
}

.ol-code small {
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.ol-members {
  display: grid;
  gap: 2px;
  margin-top: 8px;
}

.ol-members .btn.small {
  padding: 2px 8px;
}

/* Only the topmost window shows its key legend (they share one spot) */
#ui > .screen:has(~ .ol, ~ .om, ~ .ol-name, ~ .ol-choose, ~ .ol-inv) .legend {
  visibility: hidden;
}

.ol-members li {
  display: grid;
  grid-template-columns: 4px 1.2fr 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 27px;
  padding: 0 6px 0 0;
  background: var(--well-2);
  border-radius: var(--radius);
  overflow: hidden;
}

.ol-members li > i {
  align-self: stretch;
  background: var(--pc);
}

.ol-members li.offline {
  opacity: 0.5;
  filter: grayscale(1);
}

.ol-members li.free {
  opacity: 0.55;
  grid-template-columns: 4px 1fr;
}

.ol-mname {
  font-weight: 600;
  font-size: var(--fs-base);
}

.ol-mname small {
  margin-left: 4px;
  padding: 1px 5px;
  border-radius: var(--radius-lg);
  background: rgba(239, 228, 204, 0.12);
  font-size: var(--fs-xs);
  font-weight: 600;
}

.ol-mname .crown {
  color: var(--gold);
}

.ol-mcls {
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.ol-invite {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 5px 8px;
  background: rgba(79, 180, 255, 0.12);
  border: 1px solid rgba(79, 180, 255, 0.5);
  border-radius: var(--radius-lg);
  font-size: var(--fs-base);
}

.ol-invite span {
  flex: 1;
}

/* Ignore list */
.ol-list {
  display: grid;
  gap: 3px;
  margin-top: 10px;
}

.ol-list li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 5px 6px;
  background: var(--well-2);
  border-radius: var(--radius);
}

/* Small dialogs: name, save choice, invite */
.ol-dlg h3 {
  font-family: var(--display);
  font-size: var(--fs-3xl);
  line-height: 1.1;
  margin: 4px 0 6px;
}

.ol-dlg .muted {
  font-size: var(--fs-base);
  line-height: var(--lh-text);
}

.ol-name .dialog {
  width: 520px;
}

.ol-name-row {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 14px;
  margin-top: 8px;
}

.ol-name-row canvas {
  width: 96px;
  height: 112px;
  border-radius: var(--radius-lg);
  background: var(--well);
}

.ol-name-main {
  display: grid;
  gap: 8px;
  align-content: start;
}

.ol-name-main h3 {
  margin: 0;
}

.ol-avail {
  font-size: var(--fs-sm);
  min-height: 16px;
}

.ol-avail.good {
  color: var(--good);
}

.ol-avail.bad {
  color: var(--warn);
}

.ol-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 12px;
}

.ol-cols section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 9px;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.ol-cols h4 {
  font-size: var(--fs-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brass);
}

.ol-sum {
  display: grid;
  gap: 2px;
  font-size: var(--fs-base);
}

.ol-sum li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.ol-sum b {
  font-weight: 500;
  color: var(--text-3);
}

.ol-sumline {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  font-size: var(--fs-sm);
  color: var(--text-3);
}

/* --- Vending stalls ------------------------------------------------------ */
.om-win .ol-body {
  padding-top: 6px;
}

.om-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  min-height: 0;
}

.om-cols h4 {
  margin-top: 4px;
}

.om-ohead {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
}

.om-ohead > div:first-child {
  display: grid;
  flex: 1;
  min-width: 0;
}

.om-ohead strong {
  font-family: var(--display);
  font-size: var(--fs-2xl);
  line-height: 1.1;
}

.om-earn {
  display: grid;
  justify-items: end;
  padding: 5px 11px;
  background: rgba(255, 207, 90, 0.1);
  border: 1px solid rgba(255, 207, 90, 0.45);
  border-radius: var(--radius-lg);
}

.om-earn span {
  font-size: var(--fs-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
}

.om-earn b {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-2xl);
  color: var(--gold);
}

.om-sales,
.om-rest,
.om-list {
  display: grid;
  gap: 3px;
}

.om-sales li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  background: var(--well-2);
  border-radius: var(--radius);
  font-size: var(--fs-base);
}

.om-t {
  display: grid;
  justify-items: center;
  font-size: var(--fs-sm);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* sale the owner has not looked at yet */
.om-new {
  font-style: normal;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8fe3b0;
}

.om-g {
  display: grid;
  justify-items: end;
  font-weight: 600;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.om-g small {
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-3);
}

.om-rest li,
.om-list li {
  display: grid;
  grid-template-columns: 40px 1fr auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 3px 6px 3px 3px;
  background: var(--well-2);
  border-radius: var(--radius);
  font-size: var(--fs-base);
}

.om-rest li {
  grid-template-columns: 40px 1fr auto;
}

.om-w {
  display: grid;
  min-width: 0;
  font-weight: 600;
}

.om-w small {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-3);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.om-stats {
  color: var(--text-2) !important;
}

.om-fit {
  display: inline-block;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: var(--radius);
  background: rgba(143, 227, 154, 0.16);
  color: var(--good);
  font-size: var(--fs-xs);
  font-style: normal;
  font-weight: 600;
}

.om-ico {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  background: linear-gradient(180deg, #1c1712, #0d0b09);
  border: 1px solid var(--rc, #6a6252);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--rc, #6a6252) 22%, transparent);
}

.om-ico.good {
  --rc: #6a6252;
}

.om-qty {
  display: flex;
  align-items: center;
  gap: 5px;
  font-variant-numeric: tabular-nums;
}

.om-qty b {
  min-width: 22px;
  text-align: center;
}

.om-qty .btn.small {
  padding: 2px 6px;
}

.om-price {
  display: flex;
  align-items: center;
  gap: 5px;
}

.om-price .ol-in {
  width: 92px;
  padding: 4px 6px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.om-acts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.om-confirm {
  font-size: var(--fs-base);
  color: #ffc2b8;
}

.om-none {
  display: grid;
  gap: 10px;
  max-width: 560px;
  font-size: var(--fs-base);
  line-height: var(--lh-text);
}

.om-none .btn {
  justify-self: start;
}

.om-setup .om-su {
  flex: 1;
  min-height: 0;
  grid-template-columns: 318px 1fr;
  padding-top: 5px;
}

.om-pick,
.om-offer {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.om-offer {
  gap: 6px;
}

.om-offer h4 {
  margin: 4px 0 0;
}

.om-offer .om-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  align-content: start;
}


.om-good {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  font-size: var(--fs-base);
  font-weight: 600;
  text-align: left;
  background: var(--well);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
}

.om-good small {
  margin-left: auto;
  color: var(--text-3);
  font-weight: 500;
}

.om-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 42px);
  grid-auto-rows: 42px;
  gap: 3px;
  overflow: auto;
  min-height: 0;
  padding: 2px;
}

.om-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 5px;
  border-top: 1px solid var(--groove-dark);
  box-shadow: inset 0 1px 0 var(--groove-light);
}

.om-foot span {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-base);
  color: var(--text-3);
}

.om-foot b {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--gold);
}

.om-empty {
  flex: 1;
}

.om-purse {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-base);
  color: var(--text-3);
}

.om-view .om-list li {
  grid-template-columns: 40px 1fr auto auto 150px;
}

.om-view .om-list .btn.small {
  justify-content: center;
}

/* shop of a stall: name with the comparison against the worn item */
.om-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.om-cmp {
  margin-left: 6px;
  font-size: 12px;
  font-style: normal;
  color: var(--ash);
}

.om-cmp.up {
  color: var(--good);
}

.om-cmp.down,
.om-lock {
  color: #ff8a7a;
}

.om-lock {
  font-weight: 600;
}

.om-view .om-g small {
  font-size: 10px;
}

/* setup: both columns fill the window, the offers scroll */
.om-setup .om-body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.om-setlist li {
  grid-template-columns: 40px minmax(0, 1fr) auto auto;
}

.om-hint {
  margin-top: auto;
  padding-top: 6px;
}

/* prices: recommendation and floor under the item, fee in the footer */
.om-rec {
  color: var(--ember-light) !important;
}

p.om-rec {
  margin: 4px 0 0;
  font-size: 11.5px;
}

.om-low .om-price .ol-in {
  border-color: #ff8a7a;
  color: #ff8a7a;
}

.om-low .om-rec {
  color: #ff8a7a !important;
}

.om-foot {
  flex-wrap: wrap;
}

.om-fee.bad b {
  color: #ff8a7a;
}

.om-feeinfo {
  flex-basis: 100%;
}

/* own stall: a slot that a sale emptied, and the picker that fills it */
.om-ownlist li.om-freeslot {
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 6px 8px;
  border: 1px dashed var(--line-2);
  background: none;
}

.om-rules {
  margin-top: 6px;
}

.om-refill {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}

.om-refill .om-acts {
  margin-top: 2px;
}

/* the pick grid keeps room for a row of cells; the cancel button sits below it */
.om-refill .om-grid {
  flex: 1 1 auto;
  min-height: 96px;
}

.om-refill > .btn {
  align-self: flex-start;
  flex: none;
}

/* empty pick list, shop or sales log: one plain line, no scroll box */
.om-empty-hint {
  margin: 4px 0 8px;
  min-width: 12em;
}

/* own stall: listings with price field and actions, sales beside them */
.om-manage {
  grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr);
}

.om-ownlist li {
  grid-template-columns: 40px minmax(0, 1fr) auto auto auto;
  gap: 6px;
}

.om-ownlist .om-w > span,
.om-setlist .om-w > span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.om-ownlist .om-price .ol-in {
  width: 78px;
}

.om-ownlist .btn.small {
  padding-left: 8px;
  padding-right: 8px;
  white-space: nowrap;
}

/* --- Town chat ----------------------------------------------------------- */
.ol-chat {
  position: absolute;
  left: 12px;
  bottom: 34px;
  width: 330px;
  display: flex;
  flex-direction: column;
  font-size: var(--fs-base);
  line-height: var(--lh);
  color: var(--text-1);
}

.ol-chat[hidden] {
  display: none;
}

.oc-bar {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}

.ol-chat.open .oc-bar,
.ol-chat:hover .oc-bar,
.ol-chat.touch .oc-bar {
  opacity: 1;
}

.oc-tab,
.oc-openbtn {
  padding: 2px 5px;
  font: 600 var(--fs-xs)/1.4 var(--ui);
  color: var(--text-3);
  background: rgba(12, 10, 8, 0.7);
  border: 1px solid transparent;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.oc-tab.on {
  border-bottom-color: transparent;
}

.oc-openbtn {
  margin-left: auto;
  color: var(--text-1);
}

.oc-log {
  max-height: 104px;
  overflow-y: auto;
  padding: 4px 6px;
  background: linear-gradient(180deg, rgba(12, 10, 8, 0.05), rgba(12, 10, 8, 0.5));
  border-radius: 0 var(--radius) var(--radius) var(--radius);
  text-shadow: 0 1px 2px #000, 0 0 3px #000;
  scrollbar-width: thin;
  -webkit-user-select: text;
  user-select: text;
}

.ol-chat.open .oc-log,
.ol-chat.fresh .oc-log {
  background: rgba(12, 10, 8, 0.72);
}

.ol-chat.open .oc-log {
  max-height: 150px;
}

.oc-l {
  overflow-wrap: anywhere;
}

.oc-ts {
  font-size: var(--fs-xs);
  opacity: 0.5;
  font-variant-numeric: tabular-nums;
}

.oc-tag {
  font-size: var(--fs-tiny);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.oc-l.ch-town .oc-tag {
  color: #d9c9a8;
}

.oc-l.ch-party,
.oc-l.ch-party .oc-tag {
  color: #a8dcff;
}

.oc-l.ch-whisper,
.oc-l.ch-whisper .oc-tag {
  color: #ffa8e0;
}

.oc-l.ch-system {
  color: #ffd98a;
}

.oc-l.ch-system.err {
  color: var(--warn);
}

.oc-l.oc-empty {
  color: var(--text-3);
  font-style: italic;
}

.oc-n {
  padding: 0;
  font: 600 var(--fs-base)/1.35 var(--ui);
  color: inherit;
  background: none;
  border: 0;
  text-shadow: inherit;
}

.oc-n:hover {
  text-decoration: underline dotted;
}

.oc-self {
  color: #ffe3b0;
}

.oc-to {
  font-size: var(--fs-sm);
  opacity: 0.8;
}

.oc-line {
  display: none;
  gap: 4px;
  margin-top: 3px;
}

.ol-chat.open .oc-line {
  display: flex;
}

.oc-ch {
  flex: none;
  max-width: 120px;
  padding: 0 6px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font: 600 var(--fs-sm)/1 var(--ui);
  background: rgba(12, 10, 8, 0.85);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  color: #d9c9a8;
}

.oc-ch.ch-party {
  color: #a8dcff;
}

.oc-ch.ch-whisper {
  color: #ffa8e0;
}

.oc-in {
  flex: 1;
  min-width: 0;
  padding: 5px 7px;
  font: 500 var(--fs-base) var(--ui);
  color: var(--text-1);
  background: var(--surface-sunk);
  border: 1px solid var(--line-3);
  border-radius: var(--radius);
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}

.oc-menu {
  position: absolute;
  z-index: 2;
  display: grid;
  min-width: 150px;
  padding: 4px;
  background: var(--surface-panel);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.oc-menu[hidden] {
  display: none;
}

.oc-menu strong {
  padding: 3px 6px 5px;
  font-size: var(--fs-sm);
  color: var(--ember-hi);
}

.oc-menu button {
  padding: 5px 6px;
  font: 600 var(--fs-base) var(--ui);
  text-align: left;
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
}

.oc-menu button:hover {
  background: var(--ember-tint);
}

/* Touch: stick and buttons own the lower corners; chat goes to the top */
.ol-chat.touch {
  left: 290px;
  top: 12px;
  bottom: auto;
  width: 360px;
}

.ol-chat.touch .oc-log {
  max-height: 64px;
}

.ol-chat.touch.open .oc-log {
  max-height: 110px;
}

/* Map window (key M) */
.mapview .dialog.wide {
  width: 860px;
}

.mapcv {
  display: block;
  width: 100%;
  height: 318px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #1a1410;
}

/* key cap at the end of a menu button */
.town-menu .btn .mkey {
  float: right;
  margin-left: 10px;
  opacity: 0.85;
}

/* Merchant sub tabs (Kaufen / Verkaufen …) */
.subtabs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
}

.subtab {
  min-height: var(--ctl-h-sm);
  padding: 3px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface-sunk);
  color: var(--text-2);
  font: 500 var(--fs-sm) var(--ui);
  cursor: pointer;
}

html.touch-ui .subtab,
html.touch-ui .ol-tab,
html.touch-ui .seg,
html.touch-ui .oc-tab {
  min-height: var(--ctl-touch);
}

.subtab.on {
  font-weight: 600;
}

.sub-key {
  opacity: 0.7;
}

/* Rune smith */
.rune-smith .skill-block {
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.rs-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.rune-line {
  margin: 4px 0 0 46px;
  font-size: var(--fs-sm);
}

.rune-line [data-icon] {
  display: inline-block;
  vertical-align: -2px;
}

/* Refine smith */
.refine {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 18px;
}

.refine .inv-grid {
  grid-template-columns: repeat(auto-fill, 44px);
}

.refine .rune {
  position: relative;
  width: 44px;
  height: 44px;
}

.refine .rune.worn {
  box-shadow: var(--elev);
  --elev: inset 0 0 0 2px rgba(214, 176, 120, 0.6);
}

.refine .rl {
  position: absolute;
  left: 2px;
  bottom: 1px;
  font-size: var(--fs-tiny);
  font-weight: 600;
  color: var(--good);
}

.ref-detail {
  padding: 11px;
  border: 1px solid var(--rc, var(--line-2));
  border-radius: var(--radius-lg);
  background: rgba(12, 8, 10, 0.45);
}

.ref-detail h3 {
  font-size: var(--fs-lg);
  color: var(--rc, var(--text-1));
}

.ref-arrow {
  color: var(--ember-hi);
}

.ref-gain {
  margin: 6px 0;
  font-size: var(--fs-base);
}

.ref-chance {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.ref-chance strong {
  font-size: var(--fs-lg);
  font-variant-numeric: tabular-nums;
}

.ref-bar {
  flex: 1;
  display: flex;
  height: 8px;
  overflow: hidden;
  border-radius: var(--radius);
  background: #251f1a;
}

.ref-bar .base {
  background: linear-gradient(90deg, #d9822b, var(--gold));
}

.ref-bar .luck {
  background: repeating-linear-gradient(135deg, #5fc27a 0 5px, #3e9a5a 5px 10px);
}

.ref-cost {
  margin: 10px 0;
  padding: 0;
  list-style: none;
  font-size: var(--fs-base);
}

.ref-cost li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
}

.ref-cost li.short {
  color: var(--bad);
}

.ref-msg {
  margin-top: 8px;
  font-weight: 600;
}

.ref-msg.ok {
  color: var(--good);
}

.ref-msg.bad {
  color: #e0906a;
}

.ref-mats {
  display: flex;
  gap: 14px;
  margin-top: 12px;
  font-size: var(--fs-base);
  color: var(--text-3);
}

.refine .rl {
  top: 1px;
  bottom: auto;
}

.ref-note {
  font-size: var(--fs-sm);
  line-height: var(--lh-text);
}

.sell-view .fcost {
  white-space: nowrap;
}

.keychip.pad {
  border-color: var(--kc, var(--line-2));
  color: var(--kc, var(--text-1));
}

/* Exit portal question after the boss */
.run-rank {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 8px 0 14px;
}

.run-rank .rank {
  font-size: 64px;
}

.run-rank strong {
  display: block;
  font-size: var(--fs-lg);
}

.res-hint {
  align-self: center;
  font-size: var(--fs-base);
}

.gw-hint {
  margin-top: 6px;
  font-size: var(--fs-sm);
  color: var(--text-3);
}

/* Storage and mailbox (ui/storage.js, ui/mailbox.js) */
.stash.overlay {
  display: block;
  background: var(--scrim);
}

.stash-win {
  position: absolute;
  inset: 10px;
  display: grid;
  gap: 8px 10px;
  padding: 6px 9px 34px;
  box-sizing: border-box;
  background: var(--corners), var(--win-fill);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  box-shadow: var(--bevel), var(--shadow-win);
}

/* two panes (bag, storage) and the detail; the grids fill their width and
   scroll, so both panes keep their room on every stage size */
.sw-storage {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) minmax(200px, 0.8fr);
  grid-template-rows: 48px minmax(0, 1fr);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.mw-win {
  grid-template-columns: 300px 1fr;
  grid-template-rows: 48px minmax(0, 1fr);
}

.sw-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--groove-dark);
  box-shadow: var(--groove);
}

.sw-head > div {
  display: grid;
  flex: 1;
  min-width: 0;
}

.sw-head strong {
  font-family: var(--display);
  font-size: var(--fs-xl);
  line-height: 1.05;
}

.sw-head em {
  font-style: normal;
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.sw-head .st-face {
  width: 40px;
  height: 40px;
}

.sw-hint {
  flex: 0 1 auto;
  min-width: 0;
  padding: 4px 2px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--text-3);
  font-size: var(--fs-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sw-bag,
.sw-store {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  min-height: 0;
  padding: 5px 4px 5px 6px;
  background: var(--well-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  transition: border-color 0.12s, box-shadow 0.12s, background 0.12s;
}

/* the pane under a dragged entry that takes it */
.sw-bag.drop-on,
.sw-store.drop-on {
  border-color: var(--ember-hi);
  background: rgba(255, 154, 60, 0.08);
  box-shadow: var(--elev);
  --elev: inset 0 0 0 1px var(--ember-hi), 0 0 14px rgba(255, 154, 60, 0.35);
}

/* touch: a drag on an entry always moves the entry, never the pane (and
   a double tap is no zoom); a pane that really overflows scrolls from its
   empty cells, the gaps and its edge */
.sw-grid .gcell.nav,
.sw-gname {
  touch-action: none;
}

.gcell.dragging,
.sw-gname.dragging {
  opacity: 0.35;
}

/* while dragging, the hover focus does not light up the cells passed over */
.storage.sw-dragging .nav.is-focus,
.station.sw-dragging .nav.is-focus {
  outline: none;
  box-shadow: var(--elev, 0 0 #0000);
}

.sw-ghost {
  position: absolute;
  z-index: 50;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1.15);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.7);
  opacity: 0.92;
}

.sw-ghost.gcell {
  width: 32px;
  height: 32px;
}

.sw-ghost.good {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 6px;
  background: var(--surface-panel);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font: var(--fs-sm) var(--ui);
  white-space: nowrap;
}

.sw-ghost.ok {
  outline: 1.5px solid var(--ember-hi);
  outline-offset: 1px;
}

.sw-bag h4,
.sw-store h4,
.mw-paper h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-base);
}

.sw-bag h4 span,
.sw-store h4 span {
  color: var(--ember-hi);
  font-weight: 400;
}

.sw-bag h4 small,
.sw-store h4 small,
.mw-paper h4 small {
  margin-left: auto;
  font-weight: 400;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.sw-grid {
  display: grid;
  grid-auto-rows: 32px;
  gap: 3px;
}

.sw-bagcells,
.sw-storecells,
.sl-bagcells,
.sl-cartcells {
  grid-template-columns: repeat(auto-fill, 32px);
}

.sw-grid .gcell {
  width: 32px;
  height: 32px;
}

.sw-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

/* the entries fit the pane (UI.fitGrid): nothing to scroll, no bounce */
.sw-scroll.fits {
  overflow-y: hidden;
}

/* touch: a pane that overflows gets a wider edge to scroll it by */
html.touch-ui .sw-scroll:not(.fits) {
  padding-right: 14px;
  background: linear-gradient(90deg, transparent calc(100% - 10px), rgba(255, 255, 255, 0.05) calc(100% - 10px)) no-repeat;
  overscroll-behavior: contain;
}

.gcell.worn .gi {
  opacity: 0.55;
}

.gcell .sw-qty {
  position: absolute;
  right: 2px;
  bottom: 0;
  font-style: normal;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px #000;
  font-variant-numeric: tabular-nums;
}

.sw-goods {
  display: grid;
  gap: 3px;
}

.sw-good {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sw-gname {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 5px;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font: var(--fs-sm) var(--ui);
  text-align: left;
}

.sw-gname b {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.sw-gname small {
  color: var(--text-3);
}

.sw-good.sel .sw-gname {
  border-color: var(--ember-hi);
}

.sw-good .btn.small,
.sw-sort.btn.small {
  padding: 2px 6px;
  font-size: var(--fs-sm);
}

.sw-note {
  font-size: var(--fs-sm);
  color: var(--text-3);
}

/* storage tabs: Heldenlager / Kontolager (a storage entry dropped on the
   other tab moves between the two storages) */
.sw-store h4.sw-tabs {
  gap: 4px;
}

.sw-tab.btn.small {
  padding: 2px 8px;
  font-size: var(--fs-sm);
  font-weight: 600;
}

.sw-tab.drop-on {
  border-color: var(--ember-hi);
  --elev: inset 0 0 0 1px var(--ember-hi), 0 0 12px rgba(255, 154, 60, 0.45);
  box-shadow: var(--elev);
}

.sw-boxnote {
  margin-top: -3px;
  font-size: var(--fs-xs);
  color: var(--text-3);
}

/* --- selling (ui/sell.js): bag, basket, detail ------------------------- */
.tab-body.tb-fill {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sell2 {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(190px, 0.8fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 4px 8px;
  margin-top: 6px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.sell2 .sl-hint {
  grid-column: 1 / -1;
  padding: 0 2px;
  text-align: right;
}

.sell2 h4 {
  margin: 0;
}

.sl-cart .sw-scroll {
  position: relative;
}

.sl-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-3);
  font-size: var(--fs-sm);
  pointer-events: none;
}

.sl-sum {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 2px 0;
  border-top: 1px solid var(--line);
  font-size: var(--fs-sm);
  color: var(--text-2);
}

.sl-sum b {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  font-size: var(--fs-lg);
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.sl-go {
  display: flex;
  gap: 6px;
}

.sl-go .btn.primary {
  flex: 1;
}

.sl-ask p {
  margin-bottom: 4px;
  font-size: var(--fs-sm);
  color: var(--warn);
}

.sl-price {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.sw-detail {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 8px;
  background: var(--well);
  border: 1px solid var(--line);
  border-top: 2px solid var(--rc, var(--line));
  border-radius: var(--radius-lg);
  font-size: var(--fs-sm);
}

.sw-detail.empty .muted {
  line-height: var(--lh-text);
}

.sw-detail .small {
  font-size: var(--fs-sm);
}

.sw-msg {
  font-size: var(--fs-sm);
  line-height: var(--lh);
}

.sw-msg.ok {
  color: var(--good);
}

.sw-msg.bad {
  color: var(--bad);
}

.mw-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.mw-letter {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  column-gap: 8px;
  padding: 5px 6px;
  text-align: left;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text-1);
  font-family: var(--ui);
}

.mw-letter.sel {
  border-color: var(--line-3);
  background: var(--ember-tint);
}

.mw-dot {
  grid-row: 1 / 3;
  align-self: center;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.mw-letter.unread .mw-dot {
  background: var(--blood);
  box-shadow: 0 0 6px var(--blood);
}

.mw-subj {
  overflow: hidden;
  font-size: var(--fs-base);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.mw-letter.unread .mw-subj {
  font-weight: 600;
}

.mw-from {
  grid-column: 2;
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.mw-clip {
  grid-column: 3;
  grid-row: 1 / 3;
  align-self: center;
  padding: 1px 5px;
  border-radius: var(--radius-lg);
  background: rgba(255, 207, 90, 0.18);
  color: var(--ember-hi);
  font-size: var(--fs-sm);
}

.mw-read {
  min-height: 0;
  overflow-y: auto;
}

.mw-paper {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  background: linear-gradient(180deg, rgba(239, 228, 204, 0.08), rgba(239, 228, 204, 0.03));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.mw-paper h3 {
  font-family: var(--display);
  font-size: var(--fs-xl);
}

.mw-meta {
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.mw-body {
  font-size: var(--fs-base);
  line-height: var(--lh-text);
}

.mw-atts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.mw-atts .gcell {
  width: 40px;
  height: 40px;
}

.mw-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.mw-empty {
  padding: 8px 4px;
  font-size: var(--fs-base);
  line-height: var(--lh-text);
}

.mw-err {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 4px;
  font-size: var(--fs-base);
  line-height: var(--lh-text);
  color: var(--bad);
}

.mw-err p {
  margin: 0;
}

.mw-body {
  white-space: pre-line;
}

.mw-letter.k-player .mw-from,
.mw-letter.k-return .mw-from {
  color: var(--ember-hi);
}

.mw-exp {
  color: #ffb37a;
}

.sw-head .btn.on {

}

/* Writing a letter */
.mw-compose {
  gap: 7px;
  padding: 8px 11px;
}

/* a reply: the answered letter in a small read-only panel left of the form */
.mw-reply {
  display: grid;
  grid-template-columns: minmax(150px, 0.34fr) minmax(0, 1fr);
  gap: 8px;
  min-height: 100%;
}

.mw-reply > .mw-compose {
  min-width: 0;
}

/* the narrower form wraps the bag cells */
.mw-reply .mw-bagcells {
  grid-template-columns: repeat(auto-fill, 30px);
}

.mw-quote {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  padding: 8px 9px;
  background: var(--well);
  border: 1px solid var(--line);
  border-left: 2px solid var(--brass-lo);
  border-radius: var(--radius-lg);
  font-size: var(--fs-sm);
  color: var(--text-2);
  scrollbar-width: thin;
}

.mw-qfrom {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 6px;
  font-weight: 600;
  color: var(--ember-hi);
}

.mw-qfrom small {
  font-weight: 400;
  color: var(--text-3);
}

.mw-qsubj {
  font-weight: 600;
  color: var(--text-1);
}

.mw-qbody {
  white-space: pre-line;
  line-height: var(--lh-text);
}

.mw-qatts {
  margin-top: auto;
  padding-top: 5px;
  border-top: 1px solid var(--line);
  color: var(--text-3);
}

.mw-row2 {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 10px;
}

.mw-compose .ol-in {
  padding: 5px 6px;
  font-size: var(--fs-base);
}

.mw-text {
  resize: none;
  min-height: 56px;
  line-height: var(--lh);
  font-family: var(--ui);
}

.mw-compose h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-base);
}

.mw-compose h4 small {
  margin-left: auto;
  font-weight: 400;
  color: var(--text-3);
}

.mw-bagcells {
  grid-template-columns: repeat(15, 30px);
  grid-auto-rows: 30px;
}

.mw-bagcells .gcell {
  width: 30px;
  height: 30px;
}

.mw-bagcells .gcell[disabled] {
  cursor: default;
}

.mw-bagcells .gcell.on {
  background: var(--ember-tint-2);
  --elev: inset 0 0 0 2px var(--ember);
}

.mw-check {
  position: absolute;
  left: 1px;
  bottom: -2px;
  font-style: normal;
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--ember-hi);
  text-shadow: 0 1px 2px #000;
}

.mw-goodsrow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
}

.mw-good {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.mw-good .ol-in.small {
  width: 46px;
  padding: 3px 5px;
  text-align: right;
}

.mw-good.gold .ol-in.small {
  width: 78px;
}

.mw-good .ol-in[disabled] {
  opacity: 0.4;
}

.mw-compose .mw-actions {
  align-items: center;
  margin-top: 2px;
}

.mw-from-me {
  margin-left: auto;
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.mw-cmsg:empty {
  display: none;
}

/* newer server version: the page reloads (online.js, O.outdated) */
.ek-outdated {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(12, 10, 8, 0.92);
}

/* --- Loading screen (town change, src/ui/loading.js) --- */
.ld {
  position: absolute;
  inset: 0;
  z-index: 19;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3.2%;
  padding: 4% 6%;
  box-sizing: border-box;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(255, 154, 60, 0.07) 0%, rgba(255, 154, 60, 0) 55%),
    radial-gradient(ellipse at 50% 60%, #131c21 0%, var(--night) 72%);
  color: var(--parchment);
  opacity: 1;
  transition: opacity 0.25s ease-out;
}

.ld[hidden] {
  display: none;
}

.ld.out {
  opacity: 0;
  pointer-events: none;
}

.ek-loading #touch {
  visibility: hidden;
}

.ld-head {
  text-align: center;
}

.ld-eyebrow {
  letter-spacing: 0.24em;
}

.ld-town {
  margin-top: 4px;
  font: 700 54px/1 var(--display);
  color: var(--ember-light);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5), 0 0 28px rgba(255, 154, 60, 0.28);
}

.ld-sub {
  margin-top: 6px;
  font-size: 15px;
  color: var(--ash);
}

/* Central slot for art or a promotion (EK.LoadingScreens) */
.ld-slot {
  position: relative;
  margin: 0;
  height: 46%;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: repeating-linear-gradient(135deg, rgba(239, 228, 204, 0.025) 0 14px, rgba(239, 228, 204, 0) 14px 28px), var(--stone-solid);
  box-shadow: inset 0 0 0 4px rgba(11, 16, 20, 0.85), inset 0 0 0 5px var(--line), 0 12px 40px rgba(0, 0, 0, 0.55);
}

.ld-slot img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ld-ph {
  font: 600 13px/1 var(--ui);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ash);
  opacity: 0.8;
}

.ld-slot figcaption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 14px;
  background: linear-gradient(0deg, rgba(8, 10, 12, 0.88), rgba(8, 10, 12, 0));
  font-size: 14px;
}

.ld-slot figcaption b {
  display: block;
  font: 700 20px/1.1 var(--display);
  color: var(--ember-light);
}

.ld-slot:not(.has-image) figcaption {
  position: static;
  background: none;
  text-align: center;
}

.ld-foot {
  width: min(560px, 70%);
  text-align: center;
}

.ld-status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ld-label {
  font: 600 11px/1 var(--ui);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ash);
}

/* The spinner and the shimmer animate transforms only, so they keep moving
   while the main thread paints the town ground */
.ld-spin {
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 154, 60, 0.22);
  border-top-color: var(--ember);
  will-change: transform;
  animation: ld-spin 0.9s linear infinite;
}

.ld-bar {
  position: relative;
  flex: 1;
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: rgba(239, 228, 204, 0.1);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.ld-bar i {
  position: absolute;
  inset: 0;
  transform-origin: 0 50%;
  transform: scaleX(0);
  background: linear-gradient(90deg, var(--ember-deep), var(--ember) 70%, var(--ember-light));
  transition: transform 0.2s ease-out;
}

.ld-bar::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 30%;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 235, 200, 0.28), rgba(255, 255, 255, 0));
  will-change: transform;
  animation: ld-shimmer 1.4s ease-in-out infinite;
}

.ld-tip {
  margin-top: 14px;
  min-height: 1.35em;
  font-size: 14.5px;
  color: var(--parchment);
  opacity: 0.86;
}

.ld-tip b {
  margin-right: 8px;
  font: 600 11px/1 var(--ui);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--echo);
}

@keyframes ld-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes ld-shimmer {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(340%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ld-spin,
  .ld-bar::after {
    animation-duration: 3s;
  }
}

/* --- GM panel (src/ui/online-gm.js), game master accounts only --- */
.oc-gm {
  margin-left: 2px;
  padding: 2px 7px;
  font: 700 10.5px/1.4 var(--ui);
  letter-spacing: 0.06em;
  color: #1c0f05;
  background: var(--echo);
  border: 1px solid transparent;
  border-radius: 5px 5px 0 0;
}

.oc-gm[hidden] {
  display: none;
}

.gm-panel.dialog {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 900px;
  max-width: calc(100% - 24px);
  max-height: 520px;
  padding: 12px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gm-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.gm-head h3 {
  margin: 0;
  font-size: 22px;
}

.gm-flags {
  display: flex;
  align-items: center;
  gap: 6px;
  font: 600 11.5px/1.4 var(--ui);
}

.gm-flags span {
  padding: 3px 9px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  color: var(--ash);
}

.gm-god.on {
  color: #1c0f05 !important;
  background: var(--ember-light);
  border-color: var(--ember-light) !important;
}

.gm-look.on {
  color: #062622;
  background: #6ff0dc;
  border-color: #6ff0dc;
}

.gm-state {
  color: var(--good) !important;
}


.gm-state.off {
  color: var(--blood) !important;
}

.gm-panel .small {
  font-size: 12px;
  margin: 0;
}

.gm-body {
  display: grid;
  grid-template-columns: 330px 1fr;
  gap: 10px;
  min-height: 0;
}

.gm-cmds {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-content: start;
  gap: 4px;
  overflow: auto;
  max-height: 420px;
}

.gm-cmd.btn {
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  min-width: 0;
  padding: 4px 8px;
  font-size: 12.5px;
  text-align: left;
}

.gm-cmd span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 400 10.5px/1.3 ui-monospace, Consolas, monospace;
  color: var(--ash);
}

.gm-out {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.gm-log {
  height: 370px;
  overflow: auto;
  padding: 6px 9px;
  font: 11.5px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace;
  background: rgba(6, 9, 11, 0.75);
  border: 1px solid var(--line);
  border-radius: 6px;
  -webkit-user-select: text;
  user-select: text;
}

.gm-l {
  margin: 1px 0 2px;
  word-break: break-word;
}

.gm-l.in {
  color: var(--ember-light);
}

.gm-l.ok {
  color: var(--parchment);
}

.gm-l.err {
  color: #ffb0a8;
}

.gm-ts {
  color: var(--ash);
  opacity: 0.7;
}

.gm-line {
  display: flex;
  align-items: center;
  gap: 6px;
}

.gm-pre {
  font: 600 12.5px/1 ui-monospace, Consolas, monospace;
  color: var(--echo);
}

.gm-in {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  font: 12.5px/1.3 ui-monospace, "Cascadia Mono", Consolas, monospace;
  color: var(--parchment);
  background: rgba(6, 9, 11, 0.85);
  border: 1px solid var(--line-2);
  border-radius: 5px;
  -webkit-user-select: text;
  user-select: text;
}

.gm-in:focus {
  outline: none;
  border-color: var(--echo);
}

/* --- Character selection (src/ui/charselect.js): 3x3 cards with pages --- */
.charselect {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px 18px 8px;
  box-sizing: border-box;
  background: radial-gradient(ellipse at 50% 15%, #281e16, var(--bg) 72%);
}

.cs-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.cs-head .eyebrow {
  margin: 0 0 2px;
}

.cs-head h2 {
  font-family: var(--display);
  font-size: var(--fs-4xl);
  font-weight: 700;
  line-height: 1;
  color: var(--text-1);
}

.cs-account {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cs-acct-line {
  display: flex;
  gap: 12px;
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.cs-acct-line b {
  color: var(--text-1);
  font-weight: 600;
}

.cs-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 8px;
  min-height: 0;
}

.cs-card {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 6px;
  text-align: left;
  color: inherit;
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--surface-hi), var(--surface-panel));
  box-shadow: var(--bevel);
  overflow: hidden;
}

.cs-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--c);
}

.cs-card canvas {
  width: 88px;
  height: 112px;
  max-height: 100%;
}

.cs-info {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.cs-name {
  font-family: var(--display);
  font-size: var(--fs-2xl);
  font-weight: 700;
  line-height: 1;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cs-class {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--c);
}

.cs-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1px 8px;
  margin-top: 3px;
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.cs-facts b {
  color: var(--text-1);
  font-weight: 600;
}

.cs-last {
  position: absolute;
  right: 8px;
  top: 6px;
  font-size: var(--fs-tiny);
  color: var(--ember-hi);
}

.cs-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-3);
  font: inherit;
  font-size: var(--fs-sm);
  cursor: pointer;
  border: 2px dashed var(--line-2);
  border-radius: var(--radius-lg);
  background: var(--well-2);
}

.cs-empty b {
  color: var(--text-2);
  font-size: var(--fs-md);
}

.cs-empty.off {
  cursor: default;
  opacity: 0.6;
}

.cs-plus {
  font-family: var(--display);
  font-size: var(--fs-4xl);
  line-height: 1;
  color: var(--brass);
}

.cs-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cs-foot .legend {
  position: static;
}

.cs-pages {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  font-weight: 600;
}

.cs-dots {
  display: flex;
  gap: 5px;
}

.cs-dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line-2);
}

.cs-dots i.on {
  background: var(--ember);
}

/* a class that already has a hero (one hero per class) */
.ccard.taken {
  opacity: 0.45;
}
