/* VELSCOUR - UI styles */
:root {
  --gold: #d8b26a;
  --gold-dim: #8a6a34;
  --gold-bright: #ffe2a0;
  --blood: #a3120e;
  --panel: rgba(14, 9, 7, 0.94);
  --panel-2: rgba(28, 19, 14, 0.96);
  --line: #5c4424;
  --text: #e9dcc4;
  --text-dim: #a8977c;
  --common: #e8e8e8;
  --uncommon: #4fd65a;
  --rare: #4f8dff;
  --epic: #b45cff;
  --legendary: #ff9a2a;
  --mythic: #ff4058;
  --hud-w: min(96vw, 1180px, calc(100vh * 1.3));
  --hud-k: 0.148;
  /* bar height / width, set from assets/ui/hud.json by HUD.init */
  --font-head: "Cinzel", "Trajan Pro", Georgia, serif;
  --font-body: "Alegreya Sans", "Segoe UI", Tahoma, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  scrollbar-width: thin;
  scrollbar-color: #5c4424 rgba(12, 8, 6, 0.7);
}

/* Universal slim stylistic scrollbars matching gothic fantasy UI */
*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

*::-webkit-scrollbar-track {
  background: rgba(12, 8, 6, 0.7);
  border-radius: 3px;
}

*::-webkit-scrollbar-thumb {
  background: #5c4424;
  border-radius: 3px;
  border: 1px solid rgba(142, 92, 46, 0.5);
  box-shadow: inset 0 0 2px rgba(216, 178, 106, 0.2);
}

*::-webkit-scrollbar-thumb:hover {
  background: #7d592f;
  border-color: #caa050;
  box-shadow: inset 0 0 4px rgba(216, 178, 106, 0.4);
}

*::-webkit-scrollbar-thumb:active {
  background: #8e5c2e;
  border-color: #ffe2a0;
}

*::-webkit-scrollbar-corner {
  background: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #050303;
  color: var(--text);
  font-family: var(--font-body);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24'><path d='M2 2 L20 9 L12 12 L9 20 Z' fill='%23d8b26a' stroke='%23200' stroke-width='1.5'/></svg>") 2 2, crosshair;
}

.hidden {
  display: none !important;
}

button {
  font-family: var(--font-head);
}

/* ------------------------------------------------------------------ buttons */
.btn {
  font-family: var(--font-head);
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--gold-bright);
  background: linear-gradient(#3a2414, #1c0f08);
  border: 2px solid var(--gold-dim);
  border-radius: 4px;
  padding: 8px 18px;
  cursor: pointer;
  font-size: 15px;
  text-shadow: 0 1px 2px #000;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, .6), 0 2px 6px rgba(0, 0, 0, .6);
}

.btn:hover {
  border-color: var(--gold);
  color: #fff;
  background: linear-gradient(#5a3418, #24120a);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: .45;
  cursor: default;
}

.btn.small {
  padding: 4px 10px;
  font-size: 12px;
}

.btn.red {
  background: linear-gradient(#5e1410, #2a0705);
  border-color: #8f2a20;
}

.btn.big {
  font-size: 22px;
  padding: 12px 34px;
}

.btn.blue {
  background: linear-gradient(#14306e, #060f2c);
  border-color: #3a6cff;
  color: #cfe0ff;
}

.btn.blue:hover {
  background: linear-gradient(#1e449a, #0a1840);
  border-color: #7aa0ff;
  color: #fff;
}

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

#hud>* {
  pointer-events: auto;
}

#hud-bar {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: var(--hud-w);
  height: calc(var(--hud-w) * var(--hud-k));
  pointer-events: none;
}

/* the bar catches clicks only on its rail; above it, between the orbs, clicks reach the world */
#hud-rail {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: 29%;
  z-index: 1;
  pointer-events: auto;
}

#hud #hud-bar {
  pointer-events: none;
}

#hud-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

#xp-track {
  position: absolute;
  z-index: 3;
  background: #0d0806;
  left: 13.15%;
  width: 73.7%;
  top: 80.07%;
  height: 6.08%;
  overflow: hidden;
  pointer-events: auto;
  cursor: pointer;
}

#xp-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(#ffd36a, #c27b14 60%, #6b3a05);
  box-shadow: 0 0 8px #ffb43a;
  transition: width .25s;
}

#xp-text {
  position: absolute;
  z-index: 4;
  left: 17.5%;
  width: 65%;
  top: 80.5%;
  height: 7%;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 700 9.5px/1 var(--font-head);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--gold-bright, #ffe2a0);
  text-shadow: 0 0 2px #000, 0 0 4px #000, 0 1px 2px #000;
  pointer-events: auto;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  opacity: 0.95;
  transition: color 0.15s ease, opacity 0.15s ease, text-shadow 0.15s ease;
}

#xp-text .xp-text-full {
  display: none;
}

#xp-text .xp-text-short {
  display: inline;
}

#hud-bar:hover #xp-text,
#xp-track:hover~#xp-text,
#xp-text:hover,
#xp-text.show-full {
  opacity: 1;
  color: #ffffff;
  text-shadow: 0 0 3px #000, 0 0 5px #000, 0 0 8px rgba(255, 211, 106, 0.45);
}

#hud-bar:hover #xp-text .xp-text-short,
#xp-track:hover~#xp-text .xp-text-short,
#xp-text:hover .xp-text-short,
#xp-text.show-full .xp-text-short {
  display: none;
}

#hud-bar:hover #xp-text .xp-text-full,
#xp-track:hover~#xp-text .xp-text-full,
#xp-text:hover .xp-text-full,
#xp-text.show-full .xp-text-full {
  display: inline;
}

.orb-cover {
  position: absolute;
  z-index: 5;
  border-radius: 50%;
  overflow: hidden;
  pointer-events: none;
}

.orb-empty {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 0%;
  background: linear-gradient(rgba(0, 0, 0, .86), rgba(5, 0, 0, .8));
  transition: height .15s;
  box-shadow: 0 2px 6px rgba(255, 255, 255, .08);
}

.orb-text {
  position: absolute;
  z-index: 10;
  font: 700 clamp(9px, 1.3vw, 14px) var(--font-head);
  color: #fff;
  text-shadow: 0 0 3px #000, 0 0 4px #000, 0 0 2px #000;
  text-align: center;
  pointer-events: none;
  white-space: nowrap;
}

#hud-slots {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

#hud-slots .slot {
  pointer-events: auto;
}

.slot {
  position: absolute;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 2px;
}

.slot canvas,
.slot img.icon {
  width: 100%;
  height: 100%;
  border-radius: 2px;
  image-rendering: auto;
}

.slot .cd {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 100%;
  background: rgba(0, 0, 0, .72);
  pointer-events: none;
}

.slot .cdtext {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 700 clamp(9px, 1.2vw, 14px) var(--font-head);
  color: #fff;
  text-shadow: 0 0 3px #000;
  pointer-events: none;
}

.slot .count {
  position: absolute;
  right: 2px;
  bottom: 0;
  font: 700 clamp(9px, 1.1vw, 13px) var(--font-body);
  color: #fff;
  text-shadow: 0 0 3px #000, 0 0 3px #000;
  pointer-events: none;
}

.slot .nomana {
  position: absolute;
  inset: 0;
  background: rgba(20, 40, 160, .45);
  pointer-events: none;
}

.slot.drop-target {
  outline: 2px solid var(--gold-bright);
  box-shadow: 0 0 12px var(--gold);
}

.slot:hover {
  filter: brightness(1.2);
}

.slot.flash {
  animation: slotflash .25s;
}

@keyframes slotflash {
  from {
    filter: brightness(2.2);
  }

  to {
    filter: brightness(1);
  }
}

/* ==========================================================================
   Class & Feature Gauges (.class-gauge) & Action Buttons
   Unified container and styling for class-specific and feature meters (Rage,
   Madness, Smite, etc.). Action buttons (Madness, Smite) sit NORTH of the
   gauges in #gauge-buttons so they never overlap or render behind bars.
   To tweak colors for any gauge, modify the CSS variables on its class/ID.
   ========================================================================== */

#gauge-box {
  position: absolute;
  left: 50%;
  bottom: 73%;
  transform: translateX(-50%);
  width: 34%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  z-index: 6;
}

#gauge-buttons {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: 100%;
}

#gauge-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
}

/* Base class for all class and feature gauges */
.class-gauge {
  position: relative;
  width: 100%;
  height: 11px;
  background: var(--gauge-bg, rgba(14, 10, 8, 0.88));
  border: 1px solid var(--gauge-border, #444444);
  border-radius: 5px;
  overflow: hidden;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.9), inset 0 1px 2px rgba(0, 0, 0, 0.6);
  box-sizing: border-box;
  pointer-events: none;
}

.class-gauge.hidden {
  display: none !important;
}

.class-gauge .gauge-fill,
.class-gauge #barbarian-rage-fill,
.class-gauge #mad-fill,
.class-gauge #smite-fill {
  height: 100%;
  width: 0%;
  background: var(--gauge-fill, #888888);
  transition: width 0.15s ease-out;
}

.class-gauge .gauge-text,
.class-gauge #barbarian-rage-text,
.class-gauge #mad-text,
.class-gauge #smite-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 700 8.5px/10px var(--font-head);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--gauge-text-color, #ffffff);
  text-shadow: 0 0 2px #000, 0 0 3px #000, 0 1px 2px #000;
  pointer-events: none;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Gauge Color Tweaks:
   Edit these CSS variables to tweak the colors of any gauge.
   -------------------------------------------------------------------------- */

/* 1. Barbarian Rage */
#barbarian-rage,
.gauge-rage {
  --gauge-border: #8e4920;
  --gauge-fill: linear-gradient(90deg, #852510, #e06b20, #ffbe48);
  --gauge-text-color: #fff4d2;
  --gauge-bg: rgba(22, 8, 4, 0.88);
  box-shadow: 0 0 6px rgba(18, 6, 2, 0.8), inset 0 1px 2px rgba(0, 0, 0, 0.6);
}

/* 2. Madness */
#mad-track,
.gauge-madness {
  --gauge-border: #5a1838;
  --gauge-fill: linear-gradient(90deg, #5a0a3a, #c0104a 60%, #ff3070);
  --gauge-text-color: #ffffff;
  --gauge-bg: rgba(10, 0, 8, 0.85);
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.9), inset 0 1px 2px rgba(0, 0, 0, 0.6);
}

#mad-track.full,
.gauge-madness.full,
#madness.full #mad-fill {
  --gauge-fill: linear-gradient(90deg, #ff2050, #ff80b0, #c020ff);
}

#mad-track.full .gauge-fill,
#mad-track.full #mad-fill,
.gauge-madness.full .gauge-fill,
#madness.full #mad-fill {
  animation: madglow 0.8s ease-in-out infinite;
}

#mad-track.on,
.gauge-madness.on,
#madness.on #mad-fill {
  --gauge-fill: linear-gradient(90deg, #c020ff, #ff2050);
}

/* 3. Smite */
#smite-track,
.gauge-smite {
  --gauge-border: #6a5418;
  --gauge-fill: linear-gradient(90deg, #6a4a08, #d0a020 60%, #ffe070);
  --gauge-text-color: #fff8e0;
  --gauge-bg: rgba(20, 14, 0, 0.85);
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.9), inset 0 1px 2px rgba(0, 0, 0, 0.6);
}

#smite-track.full,
#smite-track.armed,
.gauge-smite.full,
.gauge-smite.armed {
  --gauge-fill: linear-gradient(90deg, #ffd040, #fff6c0, #ffb020);
}

#smite-track.full .gauge-fill,
#smite-track.full #smite-fill,
#smite-track.armed .gauge-fill,
#smite-track.armed #smite-fill,
.gauge-smite.full .gauge-fill,
.gauge-smite.armed .gauge-fill {
  animation: madglow 0.8s ease-in-out infinite;
}

/* --------------------------------------------------------------------------
   Special Ability Action Buttons (Madness & Smite)
   Dedicated round buttons on the bottom left, to the left of the HP orb.
   -------------------------------------------------------------------------- */
#special-actions {
  position: absolute;
  left: max(8px, calc(50% - var(--hud-w) * 0.5 - 176px));
  bottom: 16px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  z-index: 6;
}

.special-btn {
  position: relative;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 2px solid rgba(180, 130, 60, 0.45);
  padding: 0;
  margin: 0;
  outline: none;
  background: #0d0604;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.9), inset 0 0 6px #000;
  cursor: pointer;
  pointer-events: auto;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, filter 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.special-btn:active {
  transform: scale(0.92);
}

.special-btn .special-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: block;
  pointer-events: none;
  transition: opacity 0.2s ease, filter 0.2s ease;
}

.special-btn .special-ring {
  position: absolute;
  inset: -2px;
  width: 50px;
  height: 50px;
  pointer-events: none;
  transform: rotate(-90deg);
}

.special-btn .ring-track {
  fill: none;
  stroke: rgba(14, 8, 5, 0.85);
  stroke-width: 3.5px;
}

.special-btn .ring-fill {
  fill: none;
  stroke-width: 3.5px;
  stroke-linecap: round;
  stroke-dasharray: 144.5;
  stroke-dashoffset: 144.5;
  transition: stroke-dashoffset 0.15s linear;
}

.special-btn.smite {
  border-color: rgba(200, 150, 60, 0.5);
}

.special-btn.smite .ring-fill {
  stroke: #ffcc33;
  filter: drop-shadow(0 0 4px #ff9900);
}

.special-btn.madness {
  border-color: rgba(160, 30, 80, 0.5);
}

.special-btn.madness .ring-fill {
  stroke: #ff2570;
  filter: drop-shadow(0 0 5px #b80d46);
}

.special-btn.hidden,
.special-btn.charging {
  display: flex !important;
  pointer-events: auto;
}

.special-btn.hidden .special-icon,
.special-btn.charging .special-icon {
  opacity: 0.5;
  filter: saturate(0.5) brightness(0.7);
}

.special-btn.ready {
  box-shadow: 0 0 16px rgba(0, 0, 0, 0.95);
  animation: specialReadyPulse 1.8s ease-in-out infinite;
}

.special-btn.ready::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  pointer-events: none;
  animation: specialRingAura 2s ease-in-out infinite;
}

.special-btn.smite.ready::after {
  box-shadow: 0 0 14px 2px rgba(255, 204, 51, 0.65);
}

.special-btn.madness.ready::after {
  box-shadow: 0 0 16px 2px rgba(255, 37, 112, 0.7);
}

.special-btn.hearth.ready::after {
  box-shadow: 0 0 14px 2px rgba(127, 216, 255, 0.65);
}

.special-btn.just-ready {
  animation: specialJustReadyPop 0.85s cubic-bezier(0.18, 0.89, 0.32, 1.28) 1 !important;
}

@keyframes specialJustReadyPop {
  0% {
    transform: scale(0.92);
    filter: brightness(2) saturate(1.8);
  }

  35% {
    transform: scale(1.28);
    filter: brightness(2.5) saturate(2);
    box-shadow: 0 0 36px 10px rgba(255, 255, 255, 0.9), inset 0 0 16px #fff;
  }

  65% {
    transform: scale(1.08);
    filter: brightness(1.5) saturate(1.4);
    box-shadow: 0 0 24px 6px rgba(255, 215, 80, 0.8), inset 0 0 10px #ffe060;
  }

  100% {
    transform: scale(1);
    filter: brightness(1) saturate(1);
  }
}

@keyframes specialRingAura {

  0%,
  100% {
    opacity: 0.45;
    transform: scale(0.98);
  }

  50% {
    opacity: 1;
    transform: scale(1.08);
  }
}

.special-btn.ready .special-icon {
  opacity: 1;
  filter: saturate(1.2) brightness(1.2);
}

.special-btn.smite.ready {
  border-color: #ffe680;
  box-shadow: 0 0 16px rgba(255, 190, 40, 0.7), inset 0 0 8px rgba(255, 220, 100, 0.45);
}

.special-btn.madness.ready {
  border-color: #ff5098;
  box-shadow: 0 0 18px rgba(255, 30, 110, 0.75), inset 0 0 8px rgba(255, 60, 140, 0.45);
}

@keyframes specialReadyPulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.05);
  }
}

.special-btn.smite.armed {
  border-color: #ffffff;
  box-shadow: 0 0 24px rgba(255, 235, 130, 0.95), inset 0 0 12px #fff;
  animation: smiteAimPulse 0.75s ease-in-out infinite alternate;
}

@keyframes smiteAimPulse {
  from {
    filter: brightness(1);
    transform: scale(1);
  }

  to {
    filter: brightness(1.35);
    transform: scale(1.06);
  }
}

.special-btn.madness.active {
  border-color: #ff70b0;
  box-shadow: 0 0 24px rgba(255, 30, 100, 0.95), inset 0 0 12px rgba(255, 160, 210, 0.6);
  animation: madnessFrenzy 0.35s ease-in-out infinite alternate;
}

@keyframes madnessFrenzy {
  from {
    filter: brightness(1) saturate(1.2);
  }

  to {
    filter: brightness(1.35) saturate(1.5);
  }
}

.special-btn .special-badge {
  position: absolute;
  top: -3px;
  left: -2px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  border-radius: 4px;
  background: linear-gradient(#2a180e, #100804);
  border: 1px solid #c29548;
  color: #ffdf8a;
  font: 700 8.5px/14px var(--font-head);
  text-align: center;
  pointer-events: none;
  box-shadow: 0 1px 3px #000;
  text-shadow: 0 0 2px #000;
}

.special-btn .special-status {
  position: absolute;
  bottom: -4px;
  right: -2px;
  min-width: 22px;
  height: 13px;
  padding: 0 3px;
  border-radius: 3px;
  background: rgba(10, 6, 4, 0.92);
  border: 1px solid rgba(180, 130, 60, 0.6);
  color: #fff;
  font: 700 8px/13px var(--font-head);
  text-align: center;
  letter-spacing: 0.5px;
  pointer-events: none;
  box-shadow: 0 1px 3px #000;
  text-shadow: 0 0 2px #000;
  white-space: nowrap;
}

.special-btn.ready .special-status {
  background: linear-gradient(#4a2c00, #1e1000);
  border-color: #ffcc44;
  color: #ffea88;
}

.special-btn.madness.ready .special-status {
  background: linear-gradient(#4a0528, #1c0010);
  border-color: #ff3080;
  color: #ffd0e8;
}

.special-btn.madness.active .special-status {
  background: #600835;
  border-color: #ff4090;
  color: #ffffff;
}

.special-btn.hearth {
  border-color: rgba(90, 170, 220, 0.5);
}

.special-btn.hearth .ring-fill {
  stroke: #7fd8ff;
  filter: drop-shadow(0 0 4px #2a9ad8);
}

.special-btn.hearth.ready {
  border-color: #aee8ff;
  box-shadow: 0 0 16px rgba(90, 200, 255, 0.7), inset 0 0 8px rgba(150, 225, 255, 0.45);
}

.special-btn.hearth.ready .special-status {
  background: linear-gradient(#08324a, #02141e);
  border-color: #7fd8ff;
  color: #dff6ff;
}

/* full, but in town: nothing to return from */
.special-btn.hearth.idle .special-icon {
  opacity: 0.85;
}

.special-btn.hearth.casting {
  border-color: #ffffff;
  box-shadow: 0 0 24px rgba(140, 220, 255, 0.95), inset 0 0 12px #e6fbff;
  animation: smiteAimPulse 0.4s ease-in-out infinite alternate;
}

body.touch #special-actions {
  gap: 8px;
}

body.touch #special-actions .special-btn {
  width: 48px;
  height: 48px;
}

body.touch #special-actions .special-btn .special-icon {
  width: 40px;
  height: 40px;
}

body.touch #special-actions .special-btn .special-ring {
  width: 48px;
  height: 48px;
}

canvas#game.aiming {
  cursor: crosshair !important;
}

body.touch #gauge-box {
  width: 38%;
}

body.touch .class-gauge {
  height: 10px;
}

body.touch .class-gauge .gauge-text,
body.touch .class-gauge #barbarian-rage-text,
body.touch .class-gauge #mad-text,
body.touch .class-gauge #smite-text {
  font-size: 8px;
  line-height: 9px;
}

/* sealed treasures waiting in the bag (ui/sealed.js) */
#sealed-btn {
  pointer-events: auto;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 4px;
  border: 1px solid #c8a050;
  border-radius: 14px;
  background: linear-gradient(#3a2408, #1a0e02);
  color: #ffdf8a;
  font: 700 11px var(--font-head);
  letter-spacing: 1.5px;
  box-shadow: 0 0 10px rgba(255, 200, 90, .45);
  animation: sealglow 2s ease-in-out infinite;
}

#sealed-btn i {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #e04050, #8a1020 70%);
  box-shadow: 0 0 6px #ff4050, inset 0 0 0 2px #c8a050;
}

#sealed-btn.urgent {
  border-color: #ff6050;
  color: #fff;
  animation: sealurgent .7s ease-in-out infinite;
}

@keyframes sealglow {
  50% {
    box-shadow: 0 0 18px rgba(255, 220, 120, .8);
  }
}

@keyframes sealurgent {
  50% {
    box-shadow: 0 0 22px #ff6050;
    transform: scale(1.08);
  }
}

.rs {
  border-color: #a07828 !important;
  background: rgba(70, 45, 5, .45) !important;
  box-shadow: inset 0 0 10px rgba(255, 210, 110, .4);
}

.rs-gilded {
  border-color: #f0c030 !important;
  background: rgba(88, 60, 8, .55) !important;
  box-shadow: inset 0 0 12px rgba(255, 215, 70, .55);
}

.rs-armament {
  border-color: #d86038 !important;
  background: rgba(78, 28, 12, .52) !important;
  box-shadow: inset 0 0 11px rgba(255, 130, 80, .48);
}

.rs-armor {
  border-color: #50a4e8 !important;
  background: rgba(16, 44, 72, .52) !important;
  box-shadow: inset 0 0 11px rgba(110, 200, 255, .48);
}

.rs-reliquary {
  border-color: #c858f0 !important;
  background: rgba(56, 16, 76, .58) !important;
  box-shadow: inset 0 0 13px rgba(224, 112, 255, .6);
}

.tt-odds-head {
  font: 700 11px var(--font-head);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #cbb996;
  margin-bottom: 3px;
}

.tt-odds {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  font-size: 12px;
}

.tt-odd {
  white-space: nowrap;
}

.reveal {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.rv-box {
  pointer-events: auto;
  width: min(460px, 92vw);
  max-height: 90vh;
  overflow: auto;
  background: linear-gradient(#1c120a, #0c0704);
  border: 2px solid #a07828;
  border-radius: 10px;
  padding: 14px 16px;
  text-align: center;
  box-shadow: 0 0 40px #000, 0 0 24px rgba(255, 200, 90, .3);
}

.rv-box.landed {
  border-color: var(--rc);
  box-shadow: 0 0 40px #000, 0 0 30px var(--rc);
}

.rv-box.rv-r5,
.rv-box.rv-r6,
.rv-box.rv-jackpot {
  animation: rvmythic 1s ease-in-out 3;
}

@keyframes rvmythic {
  50% {
    box-shadow: 0 0 40px #000, 0 0 70px var(--rc);
  }
}

.rv-title {
  font: 900 20px var(--font-head);
  color: var(--gold-bright);
  letter-spacing: 2px;
  margin-bottom: 4px;
}

.rv-sub {
  font-size: 12px;
  color: #bba98c;
  margin-bottom: 8px;
}

.rv-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 5px;
}

.rv-badge {
  display: inline-block;
  font: 700 10px var(--font-head);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 2px 7px;
  border: 1px solid currentColor;
  border-radius: 10px;
  background: rgba(0, 0, 0, .45);
}

.rv-tile.rv-chase {
  box-shadow: inset 0 0 14px color-mix(in srgb, var(--rc) 55%, transparent);
}

.rv-window {
  position: relative;
  height: 92px;
  overflow: hidden;
  border: 1px solid #5a4020;
  border-radius: 6px;
  background: #0a0604;
  box-shadow: inset 0 0 18px #000;
}

.rv-reel {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  will-change: transform;
}

.rv-tile {
  flex: 0 0 92px;
  height: 92px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-right: 1px solid #000;
  background: linear-gradient(color-mix(in srgb, var(--rc) 28%, #0a0604), #0a0604);
}

.rv-tile b {
  font: 700 10px var(--font-head);
  color: var(--rc);
  letter-spacing: 1px;
  text-transform: uppercase;
  text-shadow: 0 0 4px #000;
}

.rv-tile img {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
}

.rv-gem {
  width: 30px;
  height: 30px;
  transform: rotate(45deg);
  background: radial-gradient(circle at 35% 35%, #fff, var(--rc) 45%, #000 120%);
  opacity: .8;
}

.rv-tile.won {
  background: linear-gradient(color-mix(in srgb, var(--rc) 55%, #0a0604), #0a0604);
}

/* 3D Card Flip for the won tile */
.rv-flip-tile {
  perspective: 700px;
  background: transparent !important;
  padding: 0 !important;
}

.rv-card-flipper {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 0.52s cubic-bezier(0.34, 1.45, 0.64, 1);
}

.rv-card-flipper.flipped {
  transform: rotateY(180deg);
}

.rv-card-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-sizing: border-box;
}

.rv-card-front {
  transform: rotateY(0deg);
  background: linear-gradient(color-mix(in srgb, var(--rc) 28%, #0a0604), #0a0604);
}

.rv-card-back {
  transform: rotateY(180deg);
  background: linear-gradient(color-mix(in srgb, var(--rc) 60%, #0a0604), #0a0604);
  box-shadow: inset 0 0 16px color-mix(in srgb, var(--rc) 80%, transparent), 0 0 10px var(--rc);
}

.rv-tile.won .rv-card-back {
  background: linear-gradient(color-mix(in srgb, var(--rc) 70%, #0a0604), #0a0604);
  box-shadow: inset 0 0 20px color-mix(in srgb, var(--rc) 90%, transparent), 0 0 16px var(--rc);
}

.rv-result:not(:empty) {
  animation: rvFadeIn 0.35s ease-out forwards;
}

.rv-btns:not(:empty) {
  animation: rvFadeIn 0.35s ease-out forwards;
}

@keyframes rvFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.rv-marker {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: #ffe070;
  box-shadow: 0 0 8px #ffe070;
}

.rv-result {
  text-align: left;
  margin-top: 10px;
  font-size: 13px;
}

.rv-result:empty {
  display: none;
}

.rv-btns {
  justify-content: center;
  margin-top: 10px;
  gap: 8px;
}

.rv-btns:empty {
  display: none;
}

body.touch .rv-box {
  width: min(560px, 80vw);
  padding: 8px 12px;
}

body.touch .rv-title {
  font-size: 16px;
  margin-bottom: 4px;
}

body.touch .rv-window {
  height: 64px;
}

body.touch .rv-tile {
  height: 64px;
  flex-basis: 64px;
  gap: 1px;
}

body.touch .rv-tile img {
  width: 34px;
  height: 34px;
}

body.touch .rv-tile b {
  font-size: 8px;
}

body.touch .rv-gem {
  width: 20px;
  height: 20px;
}

body.touch .rv-card-face {
  gap: 1px;
}

body.touch .rv-card-face img {
  width: 34px;
  height: 34px;
}

body.touch .rv-card-face b {
  font-size: 8px;
}

body.touch .rv-card-face .rv-gem {
  width: 20px;
  height: 20px;
}

body.touch .rv-result {
  font-size: 11px;
  margin-top: 6px;
}

body.touch .rv-btns {
  margin-top: 6px;
}

/* the portal choice at a cleared exit (game.portalChoice) */
.portal-choice {
  width: min(680px, 94vw);
  max-width: min(680px, 94vw) !important;
}

.pc-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.pc-card {
  flex: 1 1 150px;
  max-width: 210px;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 8px;
  cursor: pointer;
  border: 2px solid #4a3420;
  border-radius: 8px;
  background: radial-gradient(ellipse at 50% 22%, color-mix(in srgb, var(--pc) 30%, transparent), #120a06 70%);
  color: var(--text);
  font: 400 12px var(--font-body);
  transition: transform .12s, border-color .12s;
}

.pc-card:hover {
  transform: translateY(-2px);
}

.pc-card.sel {
  border-color: var(--pc);
  box-shadow: 0 0 16px color-mix(in srgb, var(--pc) 70%, transparent);
}

.pc-swirl {
  width: 46px;
  height: 58px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--pc), #000, var(--pc), #000, var(--pc));
  box-shadow: 0 0 16px var(--pc);
  animation: pcspin 3s linear infinite;
  opacity: .9;
}

@keyframes pcspin {
  to {
    transform: rotate(360deg);
  }
}

.pc-name {
  font: 700 14px var(--font-head);
  color: var(--gold-bright);
  letter-spacing: 1px;
}

.pc-tag {
  font: 700 10px var(--font-head);
  color: var(--text-dim);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.pc-omen {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  line-height: 1.25;
  color: var(--text-dim);
}

.pc-omen b {
  font: 700 11px var(--font-head);
  letter-spacing: 1px;
}

.pc-affixes {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 150px;
  overflow-y: auto;
  padding-top: 4px;
  border-top: 1px solid rgba(150, 110, 55, .3);
  font-size: 12px;
  line-height: 1.3;
  color: #e2d1ae;
}

.pc-affixes>b {
  color: #ffd27a;
  font: 700 11px var(--font-head);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.pc-affixes span {
  display: block;
}

.pc-affixes>span>b {
  color: #ffe0a0;
  font-weight: 700;
}

.pc-affix-description {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.3;
  font-weight: normal;
  opacity: .95;
}

.pc-auto {
  min-height: 18px;
  margin: 8px 0 0 !important;
  color: #8fe0ff;
  font-size: 13px;
}

body.touch .pc-card {
  flex-basis: 110px;
  min-height: 0;
  padding: 6px;
  gap: 3px;
}

body.touch .pc-swirl {
  width: 28px;
  height: 34px;
}

body.touch .portal-choice {
  padding: 10px 12px !important;
}

body.touch .portal-choice h2 {
  font-size: 18px;
  margin-bottom: 2px;
}

body.touch .portal-choice p {
  margin: 2px 0 6px;
}

/* the spectator's dials: auto-play's stance and the Greed lever */
#hud-btncol {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  pointer-events: none;
}

#hud-dials {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  text-shadow: 0 0 4px #000;
  pointer-events: none;
}

#stance {
  display: inline-flex;
  pointer-events: auto;
  border: 1px solid #2a6a8a;
  border-radius: 4px;
  overflow: hidden;
  background: rgba(4, 20, 30, .75);
}

#stance button {
  padding: 2px 7px;
  border: 0;
  border-right: 1px solid #1a4a60;
  background: none;
  color: #6aa8c0;
  font: 700 10px var(--font-head);
  letter-spacing: .5px;
  cursor: pointer;
}

#stance button:last-child {
  border-right: 0;
}

#stance button.on {
  background: #1a6a8a;
  color: #e8fbff;
  text-shadow: 0 0 4px #2ab0ff;
}

#stance button[data-st="reckless"].on {
  background: #8a2a1a;
  text-shadow: 0 0 4px #ff6030;
}

#stance button[data-st="cautious"].on {
  background: #2a6a3a;
  text-shadow: 0 0 4px #40ff80;
}

#greed {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  pointer-events: auto;
  padding: 1px 3px;
  border: 1px solid #5a4418;
  border-radius: 4px;
  background: rgba(24, 16, 2, .75);
}

#greed.on {
  border-color: #ffb030;
  box-shadow: 0 0 8px rgba(255, 170, 40, .4);
}

.gr-btn {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid #8a6a28;
  border-radius: 3px;
  background: #2a1c06;
  color: #ffd060;
  font: 700 13px/14px var(--font-body);
  cursor: pointer;
}

.gr-btn:active {
  transform: scale(.92);
}

.gr-lever {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.gr-label {
  font: 700 8px/8px var(--font-head);
  letter-spacing: 1.5px;
  color: #c8a050;
  text-transform: uppercase;
}

#greed-pips {
  display: inline-flex;
  gap: 2px;
}

#greed-pips i {
  width: 8px;
  height: 6px;
  border-radius: 1px;
  background: #3a2a0a;
  border: 1px solid #6a5020;
}

#greed-pips i.on {
  background: linear-gradient(#ffe070, #ff9020);
  border-color: #ffd060;
  box-shadow: 0 0 4px #ffb030;
}

#hoard {
  font: 700 10px var(--font-head);
  color: #ffc040;
  letter-spacing: .5px;
}

#hoard:empty {
  display: none;
}

body.touch #stance button {
  padding: 2px 5px;
  font-size: 9px;
}

body.touch #hud-btncol {
  gap: 3px;
}

body.touch #hud-dials {
  flex-direction: row;
  flex-wrap: wrap-reverse;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  max-width: 46vw;
}

body.touch #sealed-btn {
  padding: 2px 8px 2px 3px;
  font-size: 10px;
}

body.touch.portrait #hud-btncol {
  display: contents;
}

/* the dials styling is handled in the portrait HUD section */

body.touch.portrait #stance button {
  padding: 2px 4px;
  font-size: 8px;
}

body.touch #sealed-btn i {
  width: 16px;
  height: 16px;
}

#hud-top-left {
  position: absolute;
  left: 12px;
  top: 10px;
  pointer-events: none;
  text-shadow: 0 0 4px #000, 0 0 2px #000;
}

#area-name {
  font: 700 20px var(--font-head);
  color: var(--gold-bright);
  letter-spacing: 1px;
}

#area-sub {
  font: 400 14px var(--font-body);
  color: var(--text-dim);
}

#area-affixes {
  max-width: 380px;
  margin-top: 2px;
  font: 600 12px/1.3 var(--font-body);
  color: #f0d6a1;
}

#buff-row {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  flex-wrap: wrap;
  max-width: 50vw;
}

#auto-status {
  margin-top: 6px;
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid #2a6a8a;
  border-radius: 4px;
  background: rgba(4, 20, 30, .7);
  font: 700 12px var(--font-body);
  color: #8fe0ff;
  letter-spacing: .5px;
  text-shadow: 0 0 4px #000;
  max-width: 46vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hbtn.on img {
  filter: drop-shadow(0 0 4px #2ab0ff) drop-shadow(0 0 2px #8fe0ff) hue-rotate(160deg) saturate(1.6) brightness(1.15);
  animation: autoglow 1.6s ease-in-out infinite;
}

@keyframes autoglow {
  50% {
    filter: drop-shadow(0 0 9px #4fd0ff) drop-shadow(0 0 3px #bff0ff) hue-rotate(160deg) saturate(1.8) brightness(1.3);
  }
}

.buff {
  width: 30px;
  height: 30px;
  position: relative;
  border: 1px solid var(--gold-dim);
  border-radius: 3px;
  overflow: hidden;
  background: #000;
}

.buff canvas {
  width: 100%;
  height: 100%;
}

.buff span {
  position: absolute;
  bottom: 0;
  right: 1px;
  font: 700 10px var(--font-body);
  color: #fff;
  text-shadow: 0 0 2px #000;
}

#hud-top-right {
  position: absolute;
  right: 10px;
  top: 10px;
  display: flex;
  flex-direction: row-reverse;
  align-items: flex-start;
  gap: 6px;
  pointer-events: none;
}

#minimap-row {
  display: flex;
  align-items: center;
  pointer-events: none;
}

#velscour-skull,
#Velscour-skull {
  pointer-events: auto;
  display: grid;
  place-items: center;
  width: 38px;
  height: 42px;
  padding: 3px;
  border: 1px solid #765b38;
  border-radius: 5px;
  background: linear-gradient(#29180f, #0c0705);
  box-shadow: 0 2px 6px #000;
  cursor: pointer;
  position: absolute;
  top: -10px;
  right: -10px;
}

#velscour-skull img,
#Velscour-skull img {
  display: block;
  width: 30px;
  height: 30px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 2px #000);
}

#velscour-skull:hover,
#Velscour-skull:hover {
  border-color: var(--gold-bright);
  box-shadow: 0 0 10px rgba(255, 170, 70, .55);
}

#velscour-skull:active,
#Velscour-skull:active {
  transform: scale(.94);
}

#quest-tracker-btn {
  display: none;
  place-items: center;
  border: 1px solid #765b38;
  border-radius: 5px;
  background: linear-gradient(#29180f, #0c0705);
  box-shadow: 0 2px 6px #000;
  color: #a89068;
  cursor: pointer;
}

#quest-tracker-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  filter: drop-shadow(0 1px 2px #000);
}

#quest-tracker-btn.on {
  border-color: var(--gold);
  color: var(--gold-bright);
  box-shadow: 0 0 8px rgba(212, 168, 75, .35), 0 2px 6px #000;
}

#quest-tracker-btn:active {
  transform: scale(.94);
}

/* the minimap fills the open middle of the ring art, which overhangs it by about a fifth on every side */
#minimap-wrap {
  position: relative;
  width: 150px;
  aspect-ratio: 303 / 285.5;
  margin: 30px 32px 32px;
  pointer-events: none;
}

#minimap {
  position: absolute;
  inset: -4%;
  width: 108%;
  height: 108%;
  border-radius: 50%;
  background: rgba(0, 0, 0, .6);
  cursor: pointer;
  pointer-events: auto;
}

#minimap-ring {
  position: absolute;
  width: 140%;
  pointer-events: none;
  filter: drop-shadow(0 2px 6px #000);
}

#hud-buttons {
  display: flex;
  gap: 0;
  pointer-events: none;
}

.hbtn {
  position: relative;
  width: 52px;
  height: 56px;
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0;
  display: block;
  pointer-events: auto;
}

.hbtn img {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 2px 3px #000);
  transition: filter .12s, transform .12s;
}

.hbtn:hover img {
  filter: drop-shadow(0 0 5px rgba(255, 190, 90, .75)) brightness(1.15);
}

.hbtn:active img {
  transform: scale(.94);
}

.hbtn .badge {
  top: -2px;
  right: 0;
  pointer-events: none;
}

.badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: #b0160f;
  color: #fff;
  font: 700 11px var(--font-body);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 6px #f22;
  animation: pulse 1.2s infinite;
  pointer-events: none;
}

@keyframes pulse {
  50% {
    transform: scale(1.15);
  }
}

#boss-bar {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(520px, 60vw);
  text-align: center;
  pointer-events: none;
}

#boss-name {
  font: 900 18px var(--font-head);
  color: #ff6a3a;
  text-shadow: 0 0 2px #000, 0 1px 2px #000, 0 0 6px #000, 0 0 10px #a00;
  /* (dark outline: the title stays legible over the snow) */
  letter-spacing: 2px;
}

#boss-track {
  height: 14px;
  border: 2px solid #6a1a10;
  background: #1a0503;
  margin-top: 3px;
  border-radius: 2px;
  box-shadow: 0 0 10px #000;
}

#boss-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(#ff3a20, #8a0a02);
  transition: width .15s;
}

#boss-track {
  position: relative;
}

.boss-mark {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  margin-left: -1px;
  background: #ffd890;
  box-shadow: 0 0 4px #000;
}

#boss-sub {
  font: 600 12px var(--font-body, sans-serif);
  color: #ffc8a0;
  text-shadow: 0 0 4px #000, 0 0 2px #000;
  margin-top: 2px;
  min-height: 14px;
}

#boss-bar.warded #boss-fill {
  background: linear-gradient(#80c8ff, #1a4a8a);
}

#boss-bar.warded #boss-sub {
  color: #a8d8ff;
}

#sand-objective {
  position: absolute;
  z-index: 4;
  top: 54px;
  left: 50%;
  transform: translateX(-50%);
  width: min(520px, 72vw);
  padding: 7px 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  border: 1px solid rgba(226, 178, 105, .58);
  border-radius: 5px;
  background: rgba(25, 15, 8, .82);
  color: #f3dfbd;
  font: 600 13px/1.2 var(--font-body);
  text-align: center;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}

#sand-objective.hidden,
#sand-objective.tracker-collapsed {
  display: none;
}

#sand-objective b {
  color: #ffd16c;
  font: 800 14px var(--font-head);
}

#sand-timer {
  color: #ffb86a;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

#center-msg {
  position: absolute;
  top: 24%;
  left: 0;
  right: 0;
  text-align: center;
  font: 900 clamp(22px, 4vw, 44px) var(--font-head);
  color: var(--gold-bright);
  text-shadow: 0 0 10px #000, 0 0 20px #a40;
  pointer-events: none;
  opacity: 0;
  transition: opacity .5s;
  letter-spacing: 3px;
}

#center-msg.below {
  top: 60%;
}

/* the level-up banner holds the top of the screen */
body.at-sea #levelup {
  top: 31%;
}

/* the Pirate Seas: the top band is the scenario's banners and its meter */
#center-msg.top {
  top: 64px;
  font-size: clamp(16px, 2.4vw, 26px);
  letter-spacing: 2px;
}

/* a fight's running banners, under the boss bar */
#center-msg small {
  display: block;
  font-size: .45em;
  color: var(--text);
  letter-spacing: 1px;
}

/* hero stats plaque (top left) */
#hero-stats {
  pointer-events: auto;
  margin-top: 6px;
  width: max-content;
  min-width: 162px;
  padding: 5px 8px 6px;
  border: 1px solid #5c3a1c;
  border-radius: 3px;
  background: linear-gradient(180deg, rgba(34, 10, 6, .86), rgba(10, 4, 3, .86));
  box-shadow: inset 0 0 10px #000, 0 0 0 1px rgba(0, 0, 0, .8), 0 2px 8px rgba(0, 0, 0, .7);
}

#hero-stats .hs-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  line-height: 1.25;
}

#hero-stats span {
  font: 700 10px var(--font-head);
  color: #a8876a;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

#hero-stats b {
  font: 900 16px var(--font-head);
  color: #ffd98a;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 0 #000, 0 0 6px rgba(200, 70, 0, .55);
}

#hero-stats .hs-avg b {
  color: #ff7a4a;
  text-shadow: 0 1px 0 #000, 0 0 8px rgba(255, 40, 0, .6);
}

#hero-stats .hs-tally span {
  font-size: 9px;
  letter-spacing: .3px;
  white-space: nowrap;
  margin-right: 4px;
}

#hero-stats .hs-tally b {
  font-size: 13px;
  color: #e8c890;
}

#hero-stats .hs-ping b {
  font-size: 13px;
  letter-spacing: .5px;
}

#hero-stats .hs-first {
  margin-top: 3px;
  padding-top: 2px;
  border-top: 1px solid rgba(92, 58, 28, .6);
}

#hs-spark {
  display: block;
  width: 100%;
  height: 18px;
  margin-top: 3px;
  border-top: 1px solid rgba(92, 58, 28, .6);
  image-rendering: pixelated;
}

/* party roster (streamlined automap health overlay in top-left) */
#party-roster {
  pointer-events: auto;
  margin-top: 6px;
  width: max-content;
  min-width: 162px;
  box-sizing: border-box;
  padding: 4px 7px 5px;
  border: 1px solid #5c3a1c;
  border-radius: 3px;
  background: linear-gradient(180deg, rgba(34, 10, 6, .88), rgba(10, 4, 3, .88));
  box-shadow: inset 0 0 10px #000, 0 0 0 1px rgba(0, 0, 0, .8), 0 2px 8px rgba(0, 0, 0, .7);
  display: flex;
  flex-direction: column;
  gap: 4px;
  user-select: none;
}

#party-roster.hidden {
  display: none !important;
}

.pr-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 2px;
  border-bottom: 1px solid rgba(92, 58, 28, .5);
}

.pr-header span:first-child {
  font: 700 9.5px var(--font-head);
  color: #a8876a;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.pr-header .pr-count {
  font: 700 10px var(--font-head);
  color: #e8c890;
}

.pr-member {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 2px 0 2px 5px;
  border-left: 2px solid #a8876a;
}

.pr-member.is-me {
  border-left-color: #ffd860;
}

.pr-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px;
  line-height: 1.2;
}

.pr-name {
  font: bold 10.5px var(--font-head);
  color: #e8c890;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 110px;
}

.pr-member.is-me .pr-name {
  color: #ffffff;
  text-shadow: 0 0 4px rgba(255, 216, 96, 0.4);
}

.pr-tag {
  font: 600 9px var(--font-body);
  color: #8c7f6e;
  white-space: nowrap;
}

.pr-tag.dead {
  color: #ff4030;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.pr-bar-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.pr-bar {
  flex: 1;
  height: 5px;
  background: rgba(8, 4, 3, 0.95);
  border: 1px solid rgba(80, 50, 25, 0.7);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.pr-fill {
  height: 100%;
  width: 0%;
  transition: width 0.15s ease-out;
  border-radius: 1px;
}

.pr-fill.high {
  background: linear-gradient(to right, #24aa3a, #3de058);
}

.pr-fill.mid {
  background: linear-gradient(to right, #b86a10, #ffaa20);
}

.pr-fill.low {
  background: linear-gradient(to right, #8a1010, #ff3a20);
}

.pr-hp-text {
  font: 700 8.5px var(--font-body);
  color: #a8947e;
  font-variant-numeric: tabular-nums;
  min-width: 38px;
  text-align: right;
  white-space: nowrap;
}

/* target window: portrait + name of the monster being fought (or the last one, once slain) */
#target-box {
  pointer-events: auto;
  cursor: zoom-in;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 4px;
  width: 162px;
  box-sizing: border-box;
  padding: 5px 6px 5px;
  border: 1px solid #5c3a1c;
  border-radius: 3px;
  background: linear-gradient(180deg, rgba(34, 10, 6, .86), rgba(10, 4, 3, .86));
  box-shadow: inset 0 0 10px #000, 0 0 0 1px rgba(0, 0, 0, .8), 0 2px 8px rgba(0, 0, 0, .7);
}

#target-box.hidden {
  display: none;
}

#target-box.no-pic #tb-pic {
  display: none !important;
}

#target-box.no-pic #tb-info {
  margin-top: 0;
}

#target-box.no-pic {
  cursor: default;
}

#tb-pic {
  flex: none;
  width: 96px;
  height: 96px;
  border: 1px solid #3a2412;
  border-radius: 2px;
  background: radial-gradient(circle at 50% 60%, #2a1810, #070302 75%);
}

#tb-info {
  width: 100%;
  margin-top: 4px;
  text-align: center;
}

#tb-name {
  font: 700 11px var(--font-head);
  color: #f0e0c0;
  letter-spacing: .5px;
  line-height: 1.15;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  text-shadow: 0 1px 0 #000;
}

#tb-track {
  height: 5px;
  margin-top: 3px;
  border: 1px solid #000;
  background: #1a0503;
}

#tb-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(#e03a20, #7a0a02);
  transition: width .15s;
}

#tb-sub {
  font: 600 9px var(--font-head);
  color: #a8876a;
  letter-spacing: .8px;
  text-transform: uppercase;
  line-height: 1.2;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#target-box.r-champion #tb-name {
  color: #8ab4ff;
}

#target-box.r-champion #tb-fill {
  background: linear-gradient(#5a9aff, #1a3a8a);
}

#target-box.r-unique #tb-name {
  color: #ffc860;
}

#target-box.r-unique #tb-fill {
  background: linear-gradient(#f0b040, #8a5a08);
}

#target-box.r-boss #tb-name {
  color: #ff7a4a;
}

#target-box.dead #tb-pic {
  filter: grayscale(1) brightness(.55);
}

#target-box.dead #tb-name {
  color: #8a7a6a;
}

#target-box.dead #tb-sub {
  color: #c0302a;
}

/* enlarged (tap / click the window): ~2.25x the picture, capped by the viewport so it fits any screen and rotation */
#target-box.big {
  --tbp: min(216px, 40vh, 42vw);
  width: calc(var(--tbp) + 66px);
  padding: 7px 8px 7px;
  cursor: zoom-out;
  position: relative;
  z-index: 2;
}

#target-box.big #tb-pic {
  width: var(--tbp);
  height: var(--tbp);
}

#target-box.big #tb-name {
  font-size: 15px;
}

#target-box.big #tb-track {
  height: 8px;
  margin-top: 5px;
}

#target-box.big #tb-sub {
  font-size: 11px;
  margin-top: 3px;
}

/* level-up banner */
body.at-sea #levelup {
  top: 31%;
}

/* the Pirate Seas: the top band is the scenario pressure */
#levelup {
  position: absolute;
  top: 9%;
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
  z-index: 5;
}

#levelup.hidden {
  display: none;
}

#levelup .lu-flash {
  position: fixed;
  inset: 0;
  opacity: 0;
  background: radial-gradient(ellipse at 50% 45%, rgba(0, 0, 0, 0) 30%, rgba(40, 0, 0, .55) 65%, rgba(8, 0, 0, .9) 100%);
}

#levelup .lu-burst {
  position: absolute;
  left: 50%;
  top: clamp(-34px, -3vw, -14px);
  width: min(640px, 84vw);
  height: clamp(130px, 17vw, 210px);
  margin-left: calc(min(640px, 84vw) / -2);
  opacity: 0;
  background: #c8902a;
  clip-path: polygon(50% 0%, 56% 18%, 66% 3%, 69% 21%, 82% 8%, 79% 27%, 97% 20%, 87% 38%, 100% 47%, 88% 56%, 99% 72%, 80% 70%, 85% 92%, 68% 78%, 62% 100%, 53% 82%, 43% 99%, 38% 79%, 22% 94%, 24% 72%, 3% 80%, 14% 60%, 0% 48%, 13% 39%, 2% 21%, 22% 26%, 18% 6%, 33% 20%, 37% 1%, 45% 19%);
}

#levelup .lu-burst div {
  position: absolute;
  inset: 4px;
  clip-path: inherit;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .28) 0 2px, rgba(0, 0, 0, 0) 2px 4px), radial-gradient(ellipse at 50% 50%, #a8160a 0%, #5a0805 45%, #1c0302 80%);
}

#levelup .lu-title {
  position: relative;
  display: inline-block;
  font: 900 clamp(36px, 6.4vw, 80px)/1 var(--font-head);
  letter-spacing: clamp(6px, 1.4vw, 18px);
  text-transform: uppercase;
  opacity: 0;
  color: #8a0c06;
  background: linear-gradient(#d8c8a8, #8a1008 55%, #2a0202);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 0 #000) drop-shadow(0 0 10px rgba(120, 0, 0, .9));
}

#levelup .lu-level {
  position: relative;
  margin-top: clamp(2px, .8vw, 10px);
  opacity: 0;
}

#levelup .lu-level span {
  font: 700 clamp(12px, 1.5vw, 18px) var(--font-head);
  color: #c8a070;
  letter-spacing: 6px;
  text-transform: uppercase;
  vertical-align: middle;
  margin-right: 10px;
  text-shadow: 0 0 6px #000, 0 2px 0 #000;
}

#levelup .lu-level b {
  display: inline-block;
  filter: drop-shadow(0 0 8px rgba(150, 0, 0, .9));
  vertical-align: middle;
  font: 900 clamp(30px, 4.6vw, 58px)/1 var(--font-head);
  color: #ff3a20;
  text-shadow: 2px 2px 0 #0a0303, -2px 2px 0 #0a0303, 2px -2px 0 #0a0303, -2px -2px 0 #0a0303, 0 5px 0 #3a0403, 0 0 22px rgba(255, 40, 0, .7);
}

#levelup .lu-level b.punch {
  animation: lu-punch .45s cubic-bezier(.2, 1.6, .4, 1);
}

#levelup .lu-sub {
  position: relative;
  font: 700 clamp(11px, 1.4vw, 16px) var(--font-body);
  color: var(--text);
  letter-spacing: 1px;
  text-shadow: 0 0 4px #000, 0 0 2px #000;
  opacity: 0;
  margin-top: 2px;
}

#levelup .lu-voice {
  position: relative;
  padding: 0 16px;
  margin-top: clamp(8px, 2vw, 22px);
  font: 900 clamp(14px, 2.1vw, 26px)/1.35 var(--font-head);
  letter-spacing: 2px;
  text-transform: uppercase;
}

#lu-l1 {
  color: #b8a888;
  opacity: 0;
  text-shadow: 0 0 3px #000, 0 2px 0 #000, 0 0 14px rgba(160, 20, 0, .8);
  min-height: 1.35em;
}

#lu-l2 {
  color: #b01810;
  opacity: 0;
  text-shadow: 0 0 3px #000, 0 2px 0 #000, 0 0 16px rgba(255, 0, 0, .75);
  min-height: 1.35em;
  animation: lu-flicker 2.3s steps(1) infinite;
}

#levelup .lu-burst {
  display: none;
}

#levelup .typing::after {
  content: '';
  display: inline-block;
  width: .5em;
  height: .85em;
  margin-left: 3px;
  vertical-align: -.05em;
  background: currentColor;
  animation: lu-blink .3s steps(1) infinite;
}

#levelup.play .lu-flash {
  animation: lu-flash 3.6s ease-in-out forwards;
}

#levelup.play .lu-burst {
  animation: lu-burst .5s cubic-bezier(.2, 1.5, .4, 1) forwards, lu-pulse 1.2s .5s ease-in-out infinite alternate;
}

#levelup.play .lu-title {
  animation: lu-bleed 1.1s .5s ease-out forwards;
}

#levelup.play #lu-l1 {
  animation: lu-in 1.4s 1.6s forwards;
}

#levelup.play #lu-l2 {
  animation: lu-in 1.4s 2.6s forwards, lu-flicker 2.3s 4s steps(1) infinite;
}

/* Velscour's mood (src/data/taunts.js) colours the second line: dread is the blood-red flicker above */
#levelup[data-mood="mock"] #lu-l2 {
  color: #9cc838;
  text-shadow: 0 0 3px #000, 0 2px 0 #000, 0 0 14px rgba(110, 190, 0, .7);
}

#levelup[data-mood="cheer"] #lu-l2 {
  color: #ffc838;
  text-shadow: 0 0 3px #000, 0 2px 0 #000, 0 0 16px rgba(255, 150, 0, .85);
}

#levelup[data-mood="rage"] #lu-l2 {
  color: #ff3a14;
  text-shadow: 0 0 3px #000, 0 2px 0 #000, 0 0 12px rgba(255, 40, 0, .95), 0 0 26px rgba(255, 90, 0, .6);
}

#levelup[data-mood="unhinged"] #lu-l2 {
  color: #c27cff;
  text-shadow: 0 0 3px #000, 0 2px 0 #000, 0 0 16px rgba(150, 40, 255, .8);
}

#levelup[data-mood="sulk"] #lu-l2 {
  color: #86aed4;
  text-shadow: 0 0 3px #000, 0 2px 0 #000, 0 0 14px rgba(60, 110, 200, .7);
}

#levelup.play[data-mood="mock"] #lu-l2 {
  animation: lu-in 1.4s 2.6s forwards, lu-sneer 1.6s 4s ease-in-out infinite;
}

#levelup.play[data-mood="cheer"] #lu-l2 {
  animation: lu-in 1.4s 2.6s forwards, lu-glow .9s 4s ease-in-out infinite alternate;
}

#levelup.play[data-mood="rage"] #lu-l2 {
  animation: lu-in .5s 2.6s forwards, lu-rage .14s 2.6s linear infinite;
}

#levelup.play[data-mood="unhinged"] #lu-l2 {
  animation: lu-in 1.4s 2.6s forwards, lu-wobble 2.2s 4s ease-in-out infinite;
}

#levelup.play[data-mood="sulk"] #lu-l2 {
  animation: lu-in 2s 2.6s forwards, lu-droop 3s 4.6s ease-in-out infinite alternate;
}

#levelup.play .lu-level {
  animation: lu-bleed 1s .9s ease-out forwards;
}

#levelup.play .lu-sub {
  animation: lu-in .8s 1.3s forwards;
}

#levelup.play.out .lu-burst,
#levelup.play.out .lu-title,
#levelup.play.out .lu-level,
#levelup.play.out .lu-sub,
#levelup.out .lu-voice {
  animation: lu-out 1.2s forwards;
}

@keyframes lu-flash {
  0% {
    opacity: 0;
  }

  15% {
    opacity: 1;
  }

  70% {
    opacity: .8;
  }

  100% {
    opacity: 0;
  }
}

@keyframes lu-bleed {
  0% {
    opacity: 0;
    filter: blur(10px) drop-shadow(0 0 10px rgba(120, 0, 0, .9));
    transform: scale(1.12);
  }

  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes lu-burst {
  0% {
    opacity: 0;
    transform: scale(.1) rotate(-30deg);
  }

  100% {
    opacity: .92;
    transform: scale(1) rotate(-3deg);
  }
}

@keyframes lu-pulse {
  from {
    opacity: .92;
    transform: scale(1) rotate(-3deg);
  }

  to {
    opacity: .8;
    transform: scale(1.04) rotate(-1deg);
  }
}

@keyframes lu-slam {
  0% {
    opacity: 0;
    transform: scale(3.2) skewX(-8deg);
  }

  55% {
    opacity: 1;
    transform: scale(.9) skewX(-8deg);
  }

  78% {
    transform: scale(1.07) skewX(-8deg);
  }

  100% {
    opacity: 1;
    transform: scale(1) skewX(-8deg);
  }
}

@keyframes lu-shake {

  0%,
  100% {
    translate: 0 0;
  }

  20% {
    translate: -6px 3px;
  }

  40% {
    translate: 5px -4px;
  }

  60% {
    translate: -4px -2px;
  }

  80% {
    translate: 3px 3px;
  }
}

@keyframes lu-punch {
  0% {
    transform: scale(1.3);
    filter: blur(4px);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes lu-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes lu-out {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

@keyframes lu-blink {
  50% {
    opacity: 0;
  }
}

@keyframes lu-rage {

  0%,
  100% {
    translate: 0 0;
  }

  25% {
    translate: -3px 1px;
  }

  50% {
    translate: 2px -2px;
  }

  75% {
    translate: -1px 2px;
  }
}

@keyframes lu-sneer {

  0%,
  100% {
    rotate: 0deg;
  }

  25% {
    rotate: -1.5deg;
  }

  75% {
    rotate: 1.5deg;
  }
}

@keyframes lu-glow {
  from {
    scale: 1;
    filter: brightness(1);
  }

  to {
    scale: 1.05;
    filter: brightness(1.3);
  }
}

@keyframes lu-wobble {

  0%,
  100% {
    scale: 1 1;
    rotate: 0deg;
  }

  20% {
    scale: 1.06 .94;
    rotate: 1deg;
  }

  45% {
    scale: .95 1.05;
    rotate: -2deg;
  }

  70% {
    scale: 1.03 .98;
    rotate: 1.5deg;
  }
}

@keyframes lu-droop {
  from {
    translate: 0 0;
    opacity: 1;
  }

  to {
    translate: 0 3px;
    opacity: .75;
  }
}

@keyframes lu-flicker {

  0%,
  100% {
    opacity: 1;
  }

  31% {
    opacity: .55;
  }

  33% {
    opacity: 1;
  }

  71% {
    opacity: .7;
  }

  72% {
    opacity: 1;
  }
}

#log {
  position: absolute;
  left: 12px;
  bottom: calc(var(--hud-w) * var(--hud-k) + 10px);
  width: min(420px, 60vw);
  pointer-events: none;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#log div {
  text-shadow: 0 0 3px #000, 0 0 3px #000;
  animation: logfade 6s forwards;
}

@keyframes logfade {
  0% {
    opacity: 0;
    transform: translateX(-10px);
  }

  5% {
    opacity: 1;
    transform: none;
  }

  80% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

/* ------------------------------------------------------------------- panels */
#panels {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: calc(var(--hud-w) * var(--hud-k));
  pointer-events: none;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 10px;
  padding: 10px;
  z-index: 30;
}

.panel {
  pointer-events: auto;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 0 0 1px #000, 0 6px 30px rgba(0, 0, 0, .9), inset 0 0 40px rgba(0, 0, 0, .6);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(#2a1a10, #140c08);
  border-radius: 6px 6px 0 0;
}

.panel-head h2 {
  margin: 0;
  font: 700 18px var(--font-head);
  color: var(--gold-bright);
  letter-spacing: 2px;
}

.panel-close {
  background: none;
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  width: 28px;
  height: 28px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.panel-body {
  padding: 10px;
  overflow: auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 6px 10px 0;
  flex-wrap: wrap;
}

.tab {
  font: 700 13px var(--font-head);
  color: var(--text-dim);
  background: #1a110b;
  border: 1px solid var(--line);
  border-bottom: none;
  padding: 6px 12px;
  border-radius: 4px 4px 0 0;
  cursor: pointer;
}

.tab.active {
  color: var(--gold-bright);
  background: #33200f;
}

.gold-text {
  color: #ffd34a;
  font-weight: 700;
}

.gold-clickable {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.gold-clickable:hover {
  color: #fff4b8;
  background: rgba(255, 211, 74, 0.15);
  border-color: rgba(255, 211, 74, 0.4);
  text-shadow: 0 0 8px rgba(255, 211, 74, 0.7);
  box-shadow: 0 0 8px rgba(255, 211, 74, 0.2);
  transform: translateY(-1px);
}

.gold-clickable:active {
  transform: translateY(0);
}

.dim {
  color: var(--text-dim);
}

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

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

/* inventory */
.inv-wrap {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.paperdoll {
  display: grid;
  grid-template-columns: repeat(4, 64px);
  grid-template-rows: repeat(4, 64px);
  gap: 6px;
  position: relative;
  padding: 6px;
  background: radial-gradient(#2a1a10, #0d0805);
  border: 1px solid var(--line);
  border-radius: 4px;
}

.paperdoll .portrait {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: .9;
  pointer-events: none;
  transform: translateY(8px);
}

.paperdoll .portrait img {
  max-height: 136px;
  max-width: 76px;
  object-fit: contain;
  filter: drop-shadow(0 0 6px #000);
}

.eslot {
  position: relative;
  border: 1px solid #4a3620;
  background: rgba(0, 0, 0, .55);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.eslot .lbl {
  position: absolute;
  bottom: 1px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 9px;
  color: #6d5a40;
  pointer-events: none;
  text-transform: uppercase;
}

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

.bag-buy {
  align-self: stretch;
  margin-top: 4px;
  width: 100%;
}

.bag-buy.poor {
  opacity: .55;
}

.rel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.bslot {
  position: relative;
  border: 1px solid #3a2a18;
  background: rgba(0, 0, 0, .5);
  border-radius: 2px;
  cursor: pointer;
}

.bslot.sel,
.eslot.sel {
  outline: 2px solid var(--gold-bright);
}

.bslot.drop-target,
.eslot.drop-target {
  outline: 2px dashed var(--gold);
}

.stash-panel .stash-grid {
  grid-template-columns: repeat(7, 44px);
  max-height: min(60vh, 470px);
  overflow-y: auto;
  padding-right: 4px;
}

.jewelbox-panel {
  border-color: #8c42c7 !important;
  box-shadow: 0 0 0 2px #080605, 0 20px 50px #000c, inset 0 0 0 1px #5c2885, 0 0 24px rgba(160, 60, 255, 0.22) !important;
}

.jewelbox-panel .panel-head {
  background: linear-gradient(180deg, #3d1b54, #211030 72%, #180a22) !important;
  border-bottom: 1px solid #994fd4 !important;
}

.jewelbox-panel .panel-head h2 {
  color: #eed6ff !important;
  text-shadow: 0 2px 4px #000, 0 0 10px rgba(200, 120, 255, 0.5) !important;
}

.jewelbox-dropzone {
  border-color: #7938a8 !important;
  background: rgba(45, 18, 65, 0.35) !important;
  color: #dfc8f8 !important;
}

.jewelbox-dropzone:hover {
  border-color: #bb66ff !important;
  background: rgba(75, 25, 110, 0.45) !important;
}

.jewelbox-grid .bslot {
  background: radial-gradient(circle at center, #241432 0%, #150a20 100%);
  border-color: #4b236d;
}

.jewelbox-grid .bslot:hover {
  border-color: #aa55ff;
}

.reliquary-panel {
  max-width: min(640px, 96vw);
}

.reliquary-panel .rel-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.reliquary-panel .tab.locked {
  opacity: .55;
}

.reliquary-panel .rel-grid {
  grid-template-columns: repeat(12, 44px);
  max-height: min(58vh, 430px);
  overflow-y: auto;
  padding-right: 4px;
}

.reliquary-panel .rel-note {
  font-size: 12px;
  margin-bottom: 6px;
}

.reliquary-panel .rel-locked {
  padding: 24px 6px;
}

.reliquary-panel .rel-sec {
  margin: 8px 0 4px;
  font-family: var(--font-head);
}

.reliquary-panel .rel-codex {
  display: grid;
  grid-template-columns: repeat(12, 40px);
  gap: 3px;
}

.reliquary-panel .codex-cell {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-color: #2a1c10;
}

.reliquary-panel .codex-cell img {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  filter: brightness(0) opacity(.45);
}

.reliquary-panel .codex-cell.got {
  border-color: var(--kc);
  box-shadow: inset 0 0 8px color-mix(in srgb, var(--kc) 45%, transparent);
}

.reliquary-panel .codex-cell.got img {
  filter: none;
}

.reliquary-panel .codex-glyph {
  font: 700 13px var(--font-head);
  color: #6a6050;
}

.reliquary-panel .codex-cell.got .codex-glyph {
  color: var(--kc);
}

.reliquary-panel .rel-miles {
  font-size: 12px;
}

body.touch .reliquary-panel {
  max-width: 50vw;
}

body.touch .reliquary-panel .rel-grid {
  grid-template-columns: repeat(8, 36px);
  max-height: 50vh;
}

body.touch .reliquary-panel .rel-codex {
  grid-template-columns: repeat(8, 34px);
}

body.touch .reliquary-panel .codex-cell {
  width: 34px;
  height: 34px;
}

.itemicon {
  position: absolute;
  inset: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
}

.itemicon canvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.itemicon .stack {
  position: absolute;
  right: 1px;
  bottom: 0;
  font: 700 11px var(--font-body);
  color: #fff;
  text-shadow: 0 0 3px #000;
}

.itemicon .upg {
  position: absolute;
  left: 1px;
  top: 0;
  font: 700 10px var(--font-body);
  color: #ffd34a;
  text-shadow: 0 0 3px #000;
}

.itemicon .quality-tier {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  white-space: nowrap;
  font: 900 11px/1 var(--font-body);
  text-shadow: -1px -1px 1px #000, 1px -1px 1px #000, -1px 1px 1px #000, 1px 1px 1px #000, 0 0 3px #000;
  pointer-events: none;
}

.itemicon .socks {
  position: absolute;
  left: 1px;
  bottom: 1px;
  display: flex;
  gap: 1px;
}

.itemicon .socks i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #111;
  border: 1px solid #777;
}

.itemicon .socks i.f {
  background: #ffd;
  border-color: #fff;
}

.r0 {
  border-color: #555 !important;
}

.r1 {
  border-color: #2c7a33 !important;
  background: rgba(20, 60, 20, .35) !important;
}

.r2 {
  border-color: #2d4f99 !important;
  background: rgba(20, 30, 80, .35) !important;
}

.r3 {
  border-color: #6a2d99 !important;
  background: rgba(50, 15, 80, .4) !important;
}

.r4 {
  border-color: #b8641a !important;
  background: rgba(90, 40, 5, .45) !important;
  box-shadow: inset 0 0 10px rgba(255, 140, 30, .35);
}

.r5 {
  border-color: #c0203a !important;
  background: rgba(90, 5, 20, .5) !important;
  box-shadow: inset 0 0 12px rgba(255, 50, 80, .45);
}

.r6 {
  border-color: #1aa8c0 !important;
  background: rgba(5, 50, 70, .55) !important;
  box-shadow: inset 0 0 14px rgba(32, 224, 255, .5);
}

.rheir {
  border-color: #b8923a !important;
  background: rgba(80, 58, 14, .5) !important;
  box-shadow: inset 0 0 12px rgba(217, 180, 90, .5);
}

.rcov {
  border-color: #1f9e82 !important;
  background: rgba(8, 64, 52, .5) !important;
  box-shadow: inset 0 0 12px rgba(53, 224, 184, .45);
}

.rglyph {
  border-color: #b8a878 !important;
  background: rgba(60, 52, 30, .5) !important;
  box-shadow: inset 0 0 12px rgba(242, 226, 176, .45);
}

.rsig {
  border-color: #8a7040 !important;
  background: rgba(40, 30, 15, .45) !important;
}

.c0 {
  color: var(--common);
}

.c1 {
  color: var(--uncommon);
}

.c2 {
  color: var(--rare);
}

.c3 {
  color: var(--epic);
}

.c4 {
  color: var(--legendary);
}

.c5 {
  color: var(--mythic);
}

.c6 {
  color: var(--abyssal, #20e0ff);
}

.item-detail {
  width: 280px;
  min-height: 120px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, .45);
  padding: 8px;
  border-radius: 4px;
  font-size: 14px;
}

.stats-grid {
  display: grid;
  grid-template-columns: auto auto;
  gap: 2px 14px;
  font-size: 13px;
}

.stats-grid .v {
  text-align: right;
  color: var(--gold-bright);
}

.attr-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(92, 68, 36, .35);
}

.attr-row b {
  color: var(--gold-bright);
  min-width: 36px;
  text-align: right;
}

.plus {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--gold);
  background: #3a2a0a;
  color: var(--gold-bright);
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.vanity-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: radial-gradient(circle at top left, #1e1428, #0b0710);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-sizing: border-box;
}

.vanity-grid {
  display: grid;
  grid-template-columns: repeat(2, 52px);
  grid-template-rows: repeat(2, 52px);
  gap: 6px;
}

.vanity-side {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.vanity-title {
  display: flex;
  flex-direction: column;
  font-family: Cinzel, serif;
  font-size: 12px;
  color: #d8c8ff;
  letter-spacing: 0.8px;
}

.vanity-title .dim {
  font-size: 9px;
  color: #a08ebd;
}

.vanity-helm-btn {
  width: fit-content;
  font-size: 11px;
  padding: 3px 8px;
  white-space: nowrap;
}

.vanity-note {
  font-size: 10px;
  color: #8c7b9e;
  line-height: 1.2;
}

.vslot {
  width: 52px;
  height: 52px;
  border-style: dashed;
  border-color: #5a4a78;
  position: relative;
  box-sizing: border-box;
}

.vslot.hidden-look {
  opacity: .4;
}

.vslot.inactive-look {
  opacity: .5;
  filter: grayscale(60%);
  border-color: #b04040;
  border-style: dotted;
}

.vslot.inactive-look::after {
  content: '⚠️';
  position: absolute;
  top: 1px;
  right: 2px;
  font-size: 10px;
  line-height: 1;
  pointer-events: none;
}

/* the Bard's Tabs (loaded Music Sheets) and the sheet editor (ui/sheets.js) */
.tab-row {
  margin-top: 6px;
  padding: 4px 6px 6px;
  background: rgba(20, 12, 6, .6);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 12px;
  max-width: 290px;
}

.tab-row-lbl {
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab-slots {
  display: grid;
  grid-template-columns: repeat(5, 48px);
  gap: 6px;
}

.tslot {
  width: 48px;
  height: 48px;
}

.tslot.playing {
  box-shadow: 0 0 8px #ffd88a, inset 0 0 6px rgba(255, 216, 138, .5);
  border-color: #ffd88a;
}

.sheet-dialog {
  width: min(760px, 94vw);
  max-width: min(760px, 94vw);
  text-align: left;
}

.sheet-dialog h2 {
  text-align: center;
}

.sheet-fields {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.sheet-fields label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--gold);
}

.sheet-fields input {
  background: #120c06;
  color: #f2e6c4;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 4px 6px;
  font: 14px Georgia, serif;
}

.sheet-fields .sh-title {
  width: 240px;
}

.sheet-fields .sh-bpm {
  width: 70px;
}

.sh-text {
  width: 100%;
  box-sizing: border-box;
  height: 42vh;
  min-height: 120px;
  resize: vertical;
  background: #f2e6c4;
  color: #1e1408;
  border: 2px solid #6a4a26;
  border-radius: 3px;
  padding: 6px 8px;
  font: 13px/1.25 Consolas, 'Courier New', monospace;
  white-space: pre;
  overflow: auto;
  tab-size: 4;
}

.sh-text[readonly] {
  background: #e4d4a8;
}

.sh-status {
  margin-top: 4px;
  font-size: 13px;
  min-height: 18px;
}

.sh-help {
  margin-top: 4px;
  font-size: 12px;
  color: #c8b8a0;
}

.sh-help summary {
  cursor: pointer;
  color: var(--gold);
}

.sh-help code {
  background: rgba(0, 0, 0, .4);
  padding: 0 3px;
  border-radius: 2px;
}

/* ------------------------------------------------ Lancer War Banner Customizer */
.banner-customizer-dialog {
  width: min(720px, 94vw);
  max-width: min(720px, 94vw);
  text-align: left;
}

.banner-cust-wrap {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: wrap;
  margin: 10px 0 16px;
}

.banner-preview-pane {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  flex: 0 0 160px;
}

.banner-canvas-frame {
  border: 2px solid #8e6a3c;
  background: radial-gradient(#20160d, #0b0805);
  border-radius: 6px;
  padding: 8px;
  box-shadow: inset 0 0 24px #000, 0 4px 16px rgba(0, 0, 0, 0.8);
}

.banner-live-canvas {
  display: block;
  width: 144px;
  height: 288px;
  image-rendering: pixelated;
}

.banner-unfurl-ctrl {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  font-size: 11px;
  text-align: center;
}

.banner-unfurl-slider {
  width: 100%;
  accent-color: #ffd860;
  cursor: pointer;
}

.banner-options-pane {
  flex: 1 1 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 280px;
}

.banner-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.banner-section-title {
  font: 700 12px var(--font-head);
  color: #f1cc89;
  text-transform: uppercase;
  letter-spacing: 1px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid #5a3c1e;
  padding-bottom: 3px;
}

.banner-btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.banner-sel-btn {
  font-size: 11px !important;
  padding: 4px 9px !important;
  border: 1px solid #5a3e22 !important;
  background: rgba(30, 20, 13, 0.8) !important;
  color: #d2c0a2 !important;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.banner-sel-btn:hover {
  background: #3e2a18 !important;
  border-color: #dfaa4e !important;
  color: #ffffff !important;
}

.banner-sel-btn.active {
  background: linear-gradient(180deg, #6c4b24, #3a220d) !important;
  border-color: #ffd860 !important;
  color: #ffd860 !important;
  box-shadow: 0 0 8px rgba(255, 216, 96, 0.45);
  font-weight: 700;
}

.banner-swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.banner-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid #1a1008;
  box-shadow: 0 0 0 1px #5a3c1e, 0 2px 4px #000;
  cursor: pointer;
  box-sizing: border-box;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.banner-swatch:hover {
  transform: scale(1.15);
  box-shadow: 0 0 0 2px #f0c850, 0 3px 6px #000;
}

.banner-swatch.sel {
  transform: scale(1.22);
  border-color: #ffffff;
  box-shadow: 0 0 0 2px #ffd860, 0 0 12px rgba(255, 216, 96, 0.7);
}

/* tooltip */
#tooltip {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  max-width: 320px;
  background: rgba(14, 9, 7, .96);
  border: 1px solid var(--gold-dim);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 14px;
  box-shadow: 0 6px 24px #000c, inset 0 0 20px rgba(0, 0, 0, .6);
  user-select: none;
}

#tooltip-compare {
  position: fixed;
  z-index: 101;
  pointer-events: none;
  max-width: 320px;
  background: rgba(14, 9, 7, .96);
  border: 1px solid var(--gold-dim);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 14px;
  box-shadow: 0 6px 24px #000c, inset 0 0 20px rgba(0, 0, 0, .6);
  user-select: none;
}

.tt-compare-heading {
  color: var(--gold-bright);
  font: 700 13px var(--font-head);
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
  padding-bottom: 4px;
}

.tt-compare-hint {
  color: var(--text-dim);
  border-top: 1px solid var(--line);
  font-size: 11px;
  margin-top: 7px;
  padding-top: 5px;
}

#tooltip.touch-open,
#tooltip.interactive {
  pointer-events: auto;
}

.tt-skill-tag {
  display: inline-block;
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 8px;
  background: #2a1a0e;
  border: 1px solid var(--line);
  margin-right: 4px;
  color: var(--text-dim);
}

.tt-skill-up {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.tt-skill-pts {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 6px;
}

.tt-skill-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tt-skill-btns .btn {
  flex: 1 1 auto;
}

#tooltip:not(.touch-open) .tt-actions {
  display: none;
}

.tt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.tt-actions .btn {
  flex: 1 1 auto;
  text-align: center;
  font-size: 13px;
  padding: 6px 10px;
  cursor: pointer;
}

.tt-name {
  font: 700 16px var(--font-head);
}

.tt-base {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 4px;
}

.tt-line {
  color: #8fb4ff;
}

.tt-leg {
  color: var(--legendary);
  margin-top: 4px;
}

.tt-gem {
  color: #c8f0ff;
}

.tt-sep {
  border-top: 1px solid #3a2a18;
  margin: 5px 0;
}

.tt-price {
  color: #ffd34a;
  margin-top: 4px;
}

.cmp-up {
  color: #5f5;
}

.cmp-down {
  color: #f55;
}

/* skills */
.tree-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 12px 6px 28px;
  border: 1px solid #3a2a18;
  border-radius: 0 4px 4px 4px;
  background: rgba(10, 6, 4, .45);
}

.tree-hint {
  font-size: 11.5px;
  text-align: center;
  margin-top: 6px;
  padding-right: 16px;
}

.tree {
  display: grid;
  grid-template-columns: repeat(3, 64px);
  gap: 16px 22px;
  padding: 10px 14px;
  position: relative;
  justify-content: center;
}

.tree-row-lbl {
  position: absolute;
  left: 0;
  font-size: 10px;
  color: var(--text-dim);
}

.snode {
  position: relative;
  width: 64px;
  height: 64px;
  border: 2px solid #4a3620;
  border-radius: 6px;
  background: #000;
  cursor: pointer;
}

.snode canvas {
  width: 100%;
  height: 100%;
  border-radius: 4px;
}

.snode.locked canvas {
  filter: grayscale(1) brightness(.35);
}

.snode.avail {
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(255, 200, 80, .5);
}

.snode.has {
  border-color: #c9a050;
}

.snode.sel {
  outline: 2px solid #fff;
}

.snode .lvl {
  position: absolute;
  right: -6px;
  bottom: -6px;
  background: #140c06;
  border: 1px solid var(--gold-dim);
  border-radius: 8px;
  padding: 0 5px;
  font: 700 11px var(--font-body);
  color: var(--gold-bright);
}

.snode .link {
  position: absolute;
  left: 50%;
  top: -18px;
  width: 2px;
  height: 16px;
  background: #5c4424;
}

.snode.has .link {
  background: var(--gold);
}

.skill-detail {
  width: 300px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, .45);
  padding: 10px;
  border-radius: 4px;
  font-size: 14px;
}

.skill-detail h3 {
  margin: 0 0 2px;
  font: 700 18px var(--font-head);
  color: var(--gold-bright);
}

.skill-detail .tag {
  display: inline-block;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 8px;
  background: #2a1a0e;
  border: 1px solid var(--line);
  margin-right: 4px;
  color: var(--text-dim);
}

/* Passive Talent Tree (T) */
.talent-branches {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 10px 0;
}

@media (max-width: 720px) {
  .talent-branches {
    grid-template-columns: 1fr;
  }
}

.talent-branch {
  background: rgba(14, 9, 6, 0.72);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.talent-branch-head {
  text-align: center;
  font-family: var(--font-head);
  font-size: 15px;
  padding-bottom: 5px;
  border-bottom: 2px solid var(--gold-dim);
}

.talent-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 68px;
  padding-left: 28px;
}

.talent-tier-lbl {
  position: absolute;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
}

.talent-or-badge {
  font: 700 10px var(--font-head);
  color: #ffb86c;
  background: #261408;
  border: 1px solid #6b4423;
  border-radius: 10px;
  padding: 2px 5px;
  letter-spacing: 0.5px;
}

.talent-node {
  width: 68px;
  height: 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 3px;
  background: #0d0805;
}

.talent-node canvas {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.talent-node-name {
  font-size: 9.5px;
  line-height: 1.05;
  text-align: center;
  color: #e8dcc8;
  margin-top: 2px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.talent-choice {
  border-style: double;
  border-width: 2px;
}

.talent-keystone {
  border-color: #8a6421;
}

.talent-node.choice-locked {
  border-color: #4a1c1c !important;
  opacity: 0.48;
}

.talent-node.choice-locked canvas {
  filter: grayscale(1) brightness(0.3);
}

.talent-lock-tag,
.talent-choice-tag {
  position: absolute;
  left: -4px;
  top: -7px;
  font: 700 8.5px var(--font-head);
  padding: 1px 4px;
  border-radius: 4px;
  letter-spacing: 0.4px;
}

.talent-lock-tag {
  background: #4a1010;
  border: 1px solid #ff6060;
  color: #ffb0b0;
}

.talent-choice-tag {
  background: #1c1228;
  border: 1px solid #8a64c8;
  color: #e0c8ff;
}

.talent-detail {
  width: 100%;
  box-sizing: border-box;
}

.assign-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.assign-row button {
  min-width: 34px;
  padding: 4px 6px;
  font-size: 11px;
}

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

.book-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 6px;
  border: 1px solid #3a2a18;
  border-radius: 4px;
  background: rgba(0, 0, 0, .35);
  cursor: grab;
}

.book-item canvas {
  width: 48px;
  height: 48px;
  border-radius: 4px;
  border: 1px solid var(--gold-dim);
  flex: none;
}

.book-item .meta {
  flex: 1;
  min-width: 0;
}

.book-item .meta b {
  color: var(--gold-bright);
  font-family: var(--font-head);
}

.book-item .meta p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-dim);
}

/* vendors */
.shop-grid {
  display: grid;
  grid-template-columns: repeat(8, 44px);
  grid-auto-rows: 44px;
  gap: 3px;
}

.vendor-wrap {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.vendor-greet {
  font-style: italic;
  color: var(--text-dim);
  margin-bottom: 8px;
  max-width: 520px;
}

.service-box {
  border: 1px solid var(--line);
  padding: 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, .35);
  margin-bottom: 8px;
}

/* -------------------------------------------------------------------- screens */
#screens {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 40;
}

.screen {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(40, 8, 4, .55), rgba(0, 0, 0, .94) 70%);
  overflow: auto;
}

.title-logo {
  width: min(860px, 88vw);
  max-height: 42vh;
  object-fit: contain;
  filter: drop-shadow(0 0 30px rgba(255, 80, 10, .45));
  animation: logo-in 2s ease-out;
}

@keyframes logo-in {
  from {
    opacity: 0;
    transform: scale(.94);
    filter: blur(6px);
  }
}

.title-tag {
  position: relative;
  z-index: 2;
  font: 400 18px var(--font-head);
  color: var(--text-dim);
  letter-spacing: 3px;
  margin: 6px 0 24px;
  text-align: center;
  padding: 0 12px;
}

.title-menu {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 260px;
}

.title-foot {
  position: absolute;
  z-index: 2;
  bottom: 10px;
  font-size: 12px;
  color: #6d5a40;
}

.title-fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

.title-eyes {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  image-rendering: pixelated;
}

.title-logo.intro {
  position: relative;
  z-index: 1;
  animation: none;
  opacity: 0;
  will-change: opacity, filter, transform;
}

.title-screen .title-tag,
.title-screen .title-menu,
.title-screen .title-foot,
.title-screen .title-wiki-btn {
  z-index: 3;
  transition: opacity .4s ease-out;
}

.title-screen:not(.title-lit) .title-tag,
.title-screen:not(.title-lit) .title-menu,
.title-screen:not(.title-lit) .title-foot,
.title-screen:not(.title-lit) .title-wiki-btn {
  opacity: 0;
}

.title-screen:not(.title-ready) .title-menu,
.title-screen:not(.title-ready) .title-foot,
.title-screen:not(.title-ready) .title-wiki-btn {
  pointer-events: none;
}

.title-gate {
  position: absolute;
  z-index: 3;
  bottom: 18%;
  left: 0;
  right: 0;
  text-align: center;
  font: 400 16px var(--font-head);
  letter-spacing: 6px;
  color: #8a2a1c;
  text-transform: uppercase;
  pointer-events: none;
  opacity: 0;
  transition: opacity .6s;
}

.title-screen {
  overflow: hidden;
  justify-content: safe center;
  padding: max(4vh, env(safe-area-inset-top)) env(safe-area-inset-right) max(2vh, env(safe-area-inset-bottom)) env(safe-area-inset-left);
}

.title-screen .title-logo {
  flex: 0 1 auto;
  min-height: 0;
  margin-top: 3vh;
}

.title-reload-btn {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  width: 36px;
  height: 36px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(22, 16, 12, 0.85);
  border: 1px solid rgba(160, 120, 60, 0.4);
  border-radius: 4px;
  color: #a8977c;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: all 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
  padding: 0;
}

.title-reload-btn:hover {
  color: #ffd860;
  border-color: #ffd34a;
  background: rgba(45, 34, 24, 0.95);
  box-shadow: 0 0 10px rgba(255, 216, 96, 0.35);
  transform: scale(1.05);
}

.title-reload-btn:active {
  transform: scale(0.95);
}

.title-reload-btn svg {
  display: block;
  pointer-events: none;
  transition: transform 0.2s ease;
}

.title-reload-btn:hover svg {
  transform: rotate(45deg);
}

.title-reload-btn.spinning svg {
  animation: reloadSpin 0.7s linear infinite;
}

@keyframes reloadSpin {
  100% {
    transform: rotate(360deg);
  }
}

.title-update-btn {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  height: 36px;
  padding: 0 14px;
  gap: 8px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(42, 28, 16, 0.95) 0%, rgba(20, 14, 10, 0.95) 100%);
  border: 1px solid #ffd34a;
  border-radius: 4px;
  color: #ffd860;
  font-family: var(--font-head, 'Cinzel', serif);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.7), 0 0 14px rgba(255, 211, 74, 0.25);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: all 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
  animation: titleUpdatePulse 2.4s ease-in-out infinite;
}

.title-update-btn.hidden {
  display: none !important;
}

.title-update-btn:hover {
  color: #fff4b8;
  border-color: #ffe680;
  background: linear-gradient(180deg, rgba(64, 42, 24, 0.98) 0%, rgba(32, 20, 14, 0.98) 100%);
  box-shadow: 0 0 20px rgba(255, 216, 96, 0.6), inset 0 0 10px rgba(255, 216, 96, 0.2);
  transform: scale(1.04);
}

.title-update-btn:active {
  transform: scale(0.97);
}

.title-update-btn svg {
  display: block;
  stroke: currentColor;
  flex-shrink: 0;
}

.title-wiki-btn {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom));
  right: max(14px, env(safe-area-inset-right));
  height: 36px;
  padding: 0 14px;
  gap: 7px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(32, 22, 15, 0.9) 0%, rgba(16, 11, 8, 0.92) 100%);
  border: 1px solid rgba(196, 150, 74, 0.55);
  border-radius: 4px;
  color: #e2c992;
  font-family: var(--font-head, 'Cinzel', serif);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: opacity 0.4s ease-out, color 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
}

.title-wiki-btn:hover {
  color: #ffe57f;
  border-color: #ffd34a;
  background: linear-gradient(180deg, rgba(52, 35, 22, 0.96) 0%, rgba(26, 17, 12, 0.96) 100%);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.85), 0 0 14px rgba(255, 216, 96, 0.35);
  transform: translateY(-1px);
}

.title-wiki-btn:active {
  transform: translateY(0) scale(0.97);
}

.title-wiki-btn svg {
  display: block;
  stroke: currentColor;
  flex-shrink: 0;
}

@keyframes titleUpdatePulse {

  0%,
  100% {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.7), 0 0 10px rgba(255, 211, 74, 0.25);
    border-color: rgba(255, 211, 74, 0.6);
  }

  50% {
    box-shadow: 0 2px 14px rgba(0, 0, 0, 0.8), 0 0 22px rgba(255, 211, 74, 0.6), inset 0 0 8px rgba(255, 211, 74, 0.2);
    border-color: #ffd860;
  }
}

.title-credits {
  position: absolute;
  z-index: 4;
  inset: 0;
  pointer-events: none;
}

.title-credits img {
  position: absolute;
  inset: 0;
  display: block;
  width: min(54vw, 720px);
  max-height: 32vh;
  margin: auto;
  object-fit: contain;
  opacity: 0;
}

.title-gated .title-gate {
  opacity: 1;
  animation: gate-pulse 2.6s ease-in-out infinite;
}

@keyframes gate-pulse {
  50% {
    color: #d0402a;
    text-shadow: 0 0 12px #a01808;
  }
}

.screen-title {
  margin: 6px 0 2px;
  font: 700 22px var(--font-head);
  color: var(--gold-bright);
  letter-spacing: 3px;
  text-align: center;
}

.screen-title small {
  display: block;
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--text-dim);
}

.class-screen,
.slot-screen {
  justify-content: flex-start;
  padding-top: 6px;
}

.class-screen>*,
.slot-screen>* {
  flex-shrink: 0;
}

.hero-cv {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.plaque {
  position: absolute;
  left: 50%;
  bottom: 2px;
  transform: translateX(-50%);
  width: max-content;
  max-width: 96%;
  padding: 1px 5px;
  text-align: center;
  background: linear-gradient(#2a1c10, #120a05);
  border: 1px solid #a07c40;
  outline: 1px solid #000;
  box-shadow: inset 0 0 0 1px #3c2814, 0 1px 3px #000;
  font: 700 clamp(8px, 0.82vw, 11px) var(--font-head);
  line-height: 1.15;
  color: #f6e6c0;
  text-transform: uppercase;
  text-shadow: 0 1px 0 #000;
  pointer-events: none;
}

.class-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 100px));
  justify-content: center;
  gap: 6px;
  padding: 6px 8px;
  width: min(98vw, 1070px);
}

.class-card {
  position: relative;
  height: clamp(84px, 24vh, 178px);
  border: 2px solid #3a2a18;
  border-radius: 6px;
  background: radial-gradient(ellipse at 50% 70%, #1d130c, #050302 75%);
  cursor: pointer;
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}

.class-card:hover {
  border-color: var(--gold-dim);
}

.class-card.sel {
  border-color: var(--gold-bright);
  box-shadow: 0 0 14px rgba(255, 180, 60, .6);
}

.class-info {
  display: flex;
  gap: 16px;
  align-items: center;
  max-width: 900px;
  padding: 4px 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.class-big {
  position: relative;
  width: clamp(90px, 20vh, 190px);
  height: clamp(130px, 30vh, 280px);
  flex: none;
}

.class-doll-box {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.class-text {
  flex: 1 1 300px;
}

.class-info h2 {
  margin: 0;
  font: 900 28px var(--font-head);
  color: var(--gold-bright);
  letter-spacing: 2px;
}

.class-info p {
  margin: 4px 0;
  max-width: 520px;
}

.class-gear-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 9px;
  max-height: 54px;
  overflow: auto;
  font: 11px var(--font-body);
  color: #cbbd9f;
}

.class-gear-summary b {
  color: #f0cf8c;
}

.class-card.has-hero[data-id] canvas[data-gear-preview="ready"] {
  image-rendering: auto;
}

.slot-note {
  color: #ffb070;
  margin: 4px 12px;
  text-align: center;
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 170px));
  gap: 10px;
  padding: 8px;
  max-width: 98vw;
}

.slot-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border: 2px solid #3a2a18;
  border-radius: 6px;
  background: linear-gradient(#1a110b, #070403);
  cursor: pointer;
  text-align: center;
  min-width: 0;
  transition: border-color .15s, box-shadow .15s;
}

.slot-card:hover {
  border-color: var(--gold);
  box-shadow: 0 0 14px rgba(255, 180, 60, .4);
}

.slot-card.empty {
  border-style: dashed;
  background: rgba(0, 0, 0, .35);
}

.slot-num {
  font: 700 11px var(--font-head);
  color: var(--text-dim);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.slot-hero {
  position: relative;
  width: 100%;
  height: clamp(100px, 36vh, 250px);
  border-radius: 4px;
  background: radial-gradient(ellipse at 50% 72%, #22160d, #050302 72%);
  overflow: hidden;
}

.slot-plus {
  position: absolute;
  inset: 0 0 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 400 54px var(--font-head);
  color: #4a3820;
  transition: color .15s, text-shadow .15s;
}

.slot-card.empty:hover .slot-plus {
  color: var(--gold-bright);
  text-shadow: 0 0 18px rgba(255, 180, 60, .7);
}

.slot-info {
  font-size: 13px;
  line-height: 1.25;
  min-height: 3.6em;
}

.slot-info b {
  font-family: var(--font-head);
  color: var(--gold-bright);
  font-size: 13px;
}

.slot-btns {
  display: flex;
  gap: 6px;
}

.slot-screen .save-list {
  max-height: none;
}

.name-input {
  font: 700 16px var(--font-head);
  background: #120a06;
  border: 2px solid var(--gold-dim);
  color: var(--gold-bright);
  padding: 8px 10px;
  border-radius: 4px;
  width: 220px;
}

.save-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: min(480px, 92vw);
  max-height: 60vh;
  overflow: auto;
}

.save-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 10px;
  background: rgba(0, 0, 0, .5);
  cursor: pointer;
}

.save-row:hover {
  border-color: var(--gold);
}

.save-row .info {
  flex: 1;
}

.save-row b {
  font-family: var(--font-head);
  color: var(--gold-bright);
}

.dialog-box {
  pointer-events: auto;
  background: var(--panel);
  border: 2px solid var(--gold-dim);
  border-radius: 8px;
  padding: 18px 22px;
  max-width: min(560px, 92vw);
  max-height: calc(100% - 12px);
  overflow-y: auto;
  text-align: center;
  box-shadow: 0 0 40px #000;
}

.dialog-box h2 {
  font: 900 24px var(--font-head);
  color: var(--gold-bright);
  margin: 0 0 8px;
  letter-spacing: 2px;
}

.cloud-pick {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 10px 0;
}

.cloud-pick>div {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--gold-dim);
  border-radius: 6px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, .25);
  line-height: 1.45;
}

.cloud-pick h3 {
  font: 700 14px var(--font-head);
  color: var(--gold-bright);
  margin: 0 0 4px;
  letter-spacing: 1px;
}

.cloud-conflict .row {
  flex-wrap: wrap;
  gap: 6px;
}

.backup-list {
  max-height: min(50vh, 360px);
  overflow-y: auto;
  text-align: left;
}

.backup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 4px;
  border-bottom: 1px solid rgba(180, 140, 80, .25);
  font-size: 14px;
}

.dialog-box p {
  margin: 6px 0 14px;
}

.dialog-box .row {
  justify-content: center;
}

.Velscour-contact-dialog {
  width: min(560px, 92vw);
}

.Velscour-taunt {
  color: #d2b994;
  font: 700 15px/1.5 var(--font-head);
}

.Velscour-message-label {
  display: block;
  margin: 16px 0 6px;
  color: var(--gold);
  font: 700 12px var(--font-head);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.Velscour-message-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.Velscour-message-row .name-input {
  width: min(360px, 68vw);
}

#Velscour-message-count {
  min-width: 44px;
  color: var(--text-dim);
  font-size: 11px;
}

.Velscour-biome-select {
  max-width: 82vw;
  padding: 9px 12px;
  border: 2px solid var(--gold-dim);
  border-radius: 4px;
  background: #120a06;
  color: var(--gold-bright);
  font: 700 15px var(--font-head);
}

.death-title {
  font: 900 clamp(40px, 9vw, 96px) var(--font-head);
  color: #b3140c;
  text-shadow: 0 0 30px #f00, 0 0 4px #000;
  letter-spacing: 6px;
  animation: logo-in 2s;
}

.settings-dialog {
  width: min(580px, 94vw);
  max-width: min(580px, 94vw);
}

.settings-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--gold-dim);
  margin: 0 0 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0;
}

.settings-tab-btn {
  flex: 1 1 auto;
  min-width: 0;
  padding: 8px 10px;
  text-align: center;
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: #a8977c;
  background: #140d08;
  border: 1px solid #4a3018;
  border-bottom: 2px solid transparent;
  border-radius: 5px 5px 0 0;
  cursor: pointer;
  transition: background 0.1s ease, color 0.1s ease;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}

.settings-tab-btn:hover {
  color: #ffd860;
  background: #23160e;
}

.settings-tab-btn.active {
  color: #ffd860;
  background: linear-gradient(180deg, #382012, #1b0e07);
  border-color: var(--gold-dim);
  border-bottom: 2px solid #ffd860;
  text-shadow: 0 0 6px rgba(255, 216, 96, 0.4);
}

.settings-tab-pane {
  display: none;
  min-height: 220px;
}

.settings-tab-pane.active {
  display: block;
}

.settings-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 14px;
  align-items: center;
  text-align: left;
}

.help-keys {
  text-align: left;
  font-size: 14px;
  columns: 2;
  column-gap: 24px;
}

.help-keys div {
  break-inside: avoid;
  margin-bottom: 3px;
}

.help-keys kbd {
  display: inline-block;
  min-width: 22px;
  text-align: center;
  padding: 1px 5px;
  border: 1px solid var(--gold-dim);
  border-radius: 3px;
  background: #1a110b;
  color: var(--gold-bright);
  font: 700 12px var(--font-body);
}

/* ------------------------------------------------------------------- touch */
#touch-ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 15;
}

#joy-base {
  position: absolute;
  width: 130px;
  height: 130px;
  margin: -65px 0 0 -65px;
  border-radius: 50%;
  border: 2px solid rgba(216, 178, 106, .45);
  background: radial-gradient(rgba(60, 30, 10, .35), rgba(0, 0, 0, .25));
  opacity: 0;
  transition: opacity .15s;
}

#joy-base.on {
  opacity: 1;
}

#joy-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: radial-gradient(#e2bb72, #6e4a1c);
  border: 2px solid #ffe2a0;
  box-shadow: 0 0 10px #000;
}

#touch-buttons {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
}

.tbtn {
  position: absolute;
  pointer-events: auto;
  border-radius: 50%;
  border: 2px solid var(--gold-dim);
  background: rgba(10, 6, 4, .7);
  overflow: hidden;
  box-shadow: 0 0 8px #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tbtn canvas {
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.tbtn .cd {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 100%;
  background: rgba(0, 0, 0, .7);
}

.tbtn .k {
  position: absolute;
  top: 2px;
  left: 0;
  right: 0;
  text-align: center;
  font: 700 9px var(--font-body);
  color: var(--gold);
  text-shadow: 0 0 2px #000;
}

.tbtn.pressed {
  filter: brightness(1.6);
  border-color: var(--gold-bright);
}

.tbtn.main {
  border-width: 3px;
  border-color: var(--gold);
}

.tbtn.flip {
  flex-direction: column;
  color: var(--gold-bright);
  font: 700 15px/1 var(--font-body);
  background: rgba(30, 16, 8, .8);
}

.tbtn.flip span {
  font-size: 8px;
  color: var(--text-dim);
}

.tbtn.flip.on {
  border-color: var(--gold-bright);
  box-shadow: 0 0 8px rgba(255, 190, 90, .6);
}

/* Credits are a separate, continuously animated lava scene. */
.credits-screen {
  padding: 0 !important;
  background: #030304;
  isolation: isolate;
}

.credits-canvas {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.credits-title {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 33%;
  transform: translate(-50%, -50%);
  width: min(82vw, 1040px);
  height: min(48vh, 500px);
  pointer-events: none;
}

.credits-logo {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: none;
}

.credits-logo-fire {
  position: absolute;
  z-index: 2;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  mix-blend-mode: screen;
}

.credits-speech {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 61%;
  transform: translate(-50%, -50%);
  max-width: min(88vw, 600px);
  padding: 8px 14px;
  border: 1px solid rgba(255, 192, 98, .8);
  border-radius: 10px;
  background: rgba(20, 8, 4, .88);
  color: #fff2d2;
  font: 700 clamp(13px, 2.2vw, 20px) var(--font-head);
  text-align: center;
  text-shadow: 0 1px 3px #000, 0 0 12px #f50;
  box-shadow: 0 0 16px rgba(255, 105, 20, .45);
  opacity: 0;
  transition: opacity .18s;
  pointer-events: none;
}

.credits-event {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 70%;
  transform: translate(-50%, -50%);
  color: #ffe4ad;
  font: 900 clamp(12px, 2vw, 20px) var(--font-head);
  letter-spacing: .12em;
  text-align: center;
  text-shadow: 0 0 8px #ff3700, 0 2px 4px #000;
  opacity: 0;
  pointer-events: none;
}

.credits-back {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  font-size: clamp(13px, 2vw, 17px);
  padding: 9px 18px;
}

body.touch .credits-title {
  top: 30%;
  width: min(90vw, 780px);
  height: min(38vh, 340px);
}

body.touch .credits-speech {
  top: 53%;
}

body.touch .credits-event {
  top: 67%;
}

#rotate-hint {
  position: absolute;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, .92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  font-size: 18px;
}

#rotate-hint div {
  font-size: 64px;
  color: var(--gold);
  animation: spin 2s infinite ease-in-out;
}

@keyframes spin {
  50% {
    transform: rotate(90deg);
  }
}

#loading {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: radial-gradient(circle at center, #1c0d0a 0%, #0a0403 65%, #020101 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  overflow: hidden;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.35s ease, visibility 0.35s ease;
  user-select: none;
  -webkit-user-select: none;
}

#loading.fading {
  opacity: 0 !important;
  pointer-events: none;
}

#loading.hidden {
  display: none !important;
}

.loading-backdrop {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 20px 30px, rgba(255, 140, 40, 0.25), rgba(0, 0, 0, 0)),
    radial-gradient(1.5px 1.5px at 150px 80px, rgba(255, 80, 20, 0.3), rgba(0, 0, 0, 0)),
    radial-gradient(1px 1px at 280px 220px, rgba(255, 200, 80, 0.2), rgba(0, 0, 0, 0));
  background-size: 300px 300px;
  opacity: 0.7;
  pointer-events: none;
}

.loading-frame {
  position: relative;
  width: min(540px, 92vw);
  background: rgba(14, 7, 5, 0.94);
  border: 1px solid rgba(196, 139, 54, 0.45);
  box-shadow:
    0 0 50px rgba(0, 0, 0, 0.9),
    0 0 25px rgba(226, 80, 42, 0.18),
    inset 0 0 35px rgba(24, 10, 6, 0.85);
  border-radius: 6px;
  padding: clamp(22px, 4.5vmin, 38px) clamp(20px, 5vmin, 40px);
  text-align: center;
  box-sizing: border-box;
  z-index: 1;
}

.loading-corner {
  position: absolute;
  width: 14px;
  height: 14px;
  border-color: #ffd040;
  border-style: solid;
  pointer-events: none;
}

.corner-tl {
  top: -2px;
  left: -2px;
  border-width: 2px 0 0 2px;
}

.corner-tr {
  top: -2px;
  right: -2px;
  border-width: 2px 2px 0 0;
}

.corner-bl {
  bottom: -2px;
  left: -2px;
  border-width: 0 0 2px 2px;
}

.corner-br {
  bottom: -2px;
  right: -2px;
  border-width: 0 2px 2px 0;
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.loading-sigil-wrap {
  position: relative;
  width: clamp(100px, 20vmin, 130px);
  height: clamp(100px, 20vmin, 130px);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-sigil-outer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  color: #c48b36;
  animation: spinSigil 18s linear infinite;
  filter: drop-shadow(0 0 6px rgba(226, 80, 42, 0.45));
}

.loading-sigil-inner {
  position: absolute;
  inset: 12%;
  width: 76%;
  height: 76%;
  color: #e2502a;
  animation: spinSigilRev 11s linear infinite;
  filter: drop-shadow(0 0 8px rgba(255, 120, 40, 0.55));
}

.loading-eye {
  position: absolute;
  width: clamp(56px, 12vmin, 72px);
  height: clamp(38px, 8vmin, 48px);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(0 0 10px rgba(226, 80, 42, 0.7));
  pointer-events: none;
  z-index: 2;
}

.loading-header {
  margin-bottom: 4px;
}

#loading-title {
  font-family: var(--font-head);
  font-size: clamp(18px, 4.2vmin, 24px);
  font-weight: 800;
  letter-spacing: 3.5px;
  color: #ffdf85;
  margin: 0 0 4px;
  text-shadow: 0 0 14px rgba(240, 160, 40, 0.6);
  text-transform: uppercase;
}

#loading-sub {
  font-family: var(--font-head);
  font-size: clamp(10px, 2.4vmin, 12px);
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #ba9065;
}

.loading-bar-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

#loading-bar-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.loading-bar-cap {
  width: 4px;
  height: 14px;
  background: #8a5a2a;
  border-radius: 2px;
  box-shadow: 0 0 4px #5a3818;
}

#loading-bar {
  flex: 1;
  height: 11px;
  border: 1.5px solid #4a2810;
  border-radius: 4px;
  background: #0d0705;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.85), 0 0 6px rgba(80, 40, 15, 0.4);
}

#loading-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #8a1c06 0%, #e2502a 60%, #ffd040 100%);
  position: relative;
  transition: width 0.22s cubic-bezier(0.2, 0.8, 0.3, 1);
  box-shadow: 0 0 10px #e2502a;
}

.loading-fill-glow {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 12px;
  background: #ffffff;
  filter: blur(2px);
  opacity: 0.7;
  animation: shimmerFill 1.4s ease-in-out infinite;
}

#loading-percent {
  font-family: var(--font-head);
  font-size: clamp(11px, 2.5vmin, 13px);
  font-weight: 700;
  color: #ffb428;
  min-width: 42px;
  text-align: right;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
}

#loading-text {
  font-family: var(--font-head);
  font-size: clamp(12px, 2.8vmin, 14px);
  color: #d8c2a8;
  letter-spacing: 1.5px;
  min-height: 20px;
}

#loading-tip-wrap {
  width: 100%;
  margin-top: 8px;
  padding: 10px 14px;
  border-top: 1px solid rgba(184, 134, 42, 0.25);
  background: rgba(0, 0, 0, 0.4);
  border-radius: 4px;
  box-sizing: border-box;
}

.loading-tip-label {
  font-family: var(--font-head);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #e2502a;
  margin-bottom: 4px;
  text-transform: uppercase;
}

#loading-tip-text {
  font-family: var(--font-body, Georgia, serif);
  font-size: clamp(11px, 2.5vmin, 13px);
  line-height: 1.45;
  color: #b5a08a;
  font-style: italic;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease;
}

@keyframes spinSigil {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes spinSigilRev {
  from {
    transform: rotate(360deg);
  }

  to {
    transform: rotate(0deg);
  }
}

@keyframes pulseCore {

  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 14px rgba(226, 80, 42, 0.75);
  }

  50% {
    transform: scale(1.1);
    box-shadow: 0 0 24px #ff6600, 0 0 35px rgba(255, 100, 0, 0.45);
  }
}

@keyframes shimmerFill {
  0% {
    opacity: 0.35;
  }

  50% {
    opacity: 0.9;
  }

  100% {
    opacity: 0.35;
  }
}

.spinner {
  width: 46px;
  height: 46px;
  border: 4px solid #3a2410;
  border-top-color: #e2502a;
  border-radius: 50%;
  animation: spin2 .9s linear infinite;
}

@keyframes spin2 {
  to {
    transform: rotate(360deg);
  }
}

.quest-log {
  min-width: min(340px, 86vw);
}

.q-sec {
  margin-bottom: 10px;
}

.q-sec h3 {
  margin: 0 0 4px;
  font: 700 13px var(--font-head);
  color: var(--gold);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  padding-bottom: 2px;
}

.q-title {
  font: 700 15px var(--font-head);
  color: var(--gold-bright);
  margin: 2px 0 4px;
}

.q-step {
  display: flex;
  gap: 6px;
  align-items: baseline;
  margin: 2px 0;
}

.q-step i {
  font-style: normal;
  color: #b0160f;
  width: 14px;
  flex-shrink: 0;
  text-align: center;
}

.q-step.done i {
  color: #6fd060;
}

.q-step.done span {
  color: var(--text-dim);
  text-decoration: line-through;
  text-decoration-color: rgba(255, 255, 255, .25);
}

.q-note {
  margin-top: 4px;
  font-size: 12px;
}

.q-bar {
  position: relative;
  height: 18px;
  border: 1px solid var(--gold-dim);
  border-radius: 3px;
  background: #0d0806;
  overflow: hidden;
  margin: 4px 0 6px;
}

.q-bar div {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: linear-gradient(#ff7a40, #a01808 60%, #4a0804);
  box-shadow: 0 0 8px #f42;
}

.q-bar span {
  position: relative;
  display: block;
  text-align: center;
  font: 700 11px/18px var(--font-body);
  color: #fff;
  text-shadow: 0 0 3px #000, 0 0 3px #000;
}

.q-raids {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.q-raids span {
  padding: 1px 7px;
  border: 1px solid #7a2a10;
  border-radius: 3px;
  background: rgba(90, 20, 6, .5);
  font: 700 12px var(--font-head);
  color: #ffb070;
}

#drag-ghost {
  position: fixed;
  z-index: 60;
  width: 48px;
  height: 48px;
  pointer-events: none;
  transform: translate(-50%, -50%);
  opacity: .9;
  filter: drop-shadow(0 0 6px #000);
}

#drag-ghost canvas {
  width: 100%;
  height: 100%;
}

/* ---------------------------------------------------------- touch layout */
body.touch {
  --hud-w: min(56vw, calc(100vh * 1.25));
}

/* nudge the bar left, clear of the skill buttons and their page flip */
body.touch #hud-bar {
  left: calc(50% - 4vw);
}

body.touch #minimap-wrap {
  width: 84px;
  margin: 17px 18px 18px;
}

body.touch #hud-top-right {
  flex-direction: row-reverse;
  align-items: flex-start;
}

body.touch #hud-buttons {
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 46vw;
}

body.touch {
  --cc-left: max(41%, calc(146px + min(200px, 24vw)));
}

/* the centre column (landscape): under the stance and Greed row, clear of the stats and the minimap */
body.touch #boss-bar {
  width: min(400px, 48vw);
  left: var(--cc-left);
  top: 80px;
}

body.touch #sand-objective {
  top: 80px;
  left: var(--cc-left);
  width: min(400px, 48vw);
  padding: 5px 8px;
  gap: 7px;
  font-size: 11px;
}

/* the centre column */
body.touch #boss-bar:not(.hidden)~#sand-objective {
  top: 124px;
}

/* under the boss bar (the dunes' tomb master) */
body.touch #boss-name {
  font-size: 13px;
  letter-spacing: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.touch #boss-sub {
  font-size: 10px;
  min-height: 11px;
}

body.touch .hbtn {
  width: 38px;
  height: 41px;
}

body.touch #area-name {
  font-size: 15px;
}

body.touch #area-sub {
  font-size: 12px;
}

body.touch #auto-status {
  font-size: 10px;
  margin-top: 3px;
  max-width: 34vw;
}

body.touch #hero-stats {
  width: max-content;
  min-width: 124px;
  padding: 3px 6px 4px;
  margin-top: 3px;
}

body.touch #hero-stats span {
  font-size: 8px;
  letter-spacing: .6px;
}

body.touch #hero-stats b {
  font-size: 12px;
}

body.touch #hero-stats .hs-tally span {
  font-size: 7px;
  letter-spacing: .3px;
}

body.touch #hero-stats .hs-tally b {
  font-size: 10px;
}

body.touch #hs-spark {
  height: 12px;
  margin-top: 2px;
}

body.touch #target-box {
  width: 88px;
  margin-top: 3px;
  padding: 3px 4px 4px;
}

body.touch #tb-pic {
  width: 56px;
  height: 56px;
}

body.touch #tb-info {
  margin-top: 2px;
}

body.touch #tb-name {
  font-size: 8px;
  letter-spacing: .3px;
}

body.touch #tb-track {
  height: 4px;
  margin-top: 2px;
}

body.touch #tb-sub {
  display: none;
}

body.touch #target-box.big {
  --tbp: min(128px, 32vh, 40vw);
  width: calc(var(--tbp) + 32px);
  padding: 4px 5px 5px;
}

body.touch #target-box.big #tb-name {
  font-size: 11px;
}

body.touch #target-box.big #tb-track {
  height: 6px;
  margin-top: 3px;
}

body.touch #target-box.big #tb-sub {
  display: block;
  font-size: 8px;
}

/* phone on its side: little height under the stats, so the big picture sits beside its name and bar */
body.touch:not(.portrait) #target-box.big {
  --tbp: min(120px, 30vh);
  flex-direction: row;
  width: auto;
  gap: 6px;
}

body.touch:not(.portrait) #target-box.big #tb-info {
  width: 104px;
  margin-top: 0;
  text-align: left;
}

body.touch body.at-sea #levelup {
  top: 31%;
}

/* the Pirate Seas: the top band is the scenario pressure */
#levelup {
  top: 21%;
}

body.touch #levelup .lu-burst {
  width: 58vw;
  margin-left: -29vw;
  height: 21vw;
  top: -10px;
}

body.touch #levelup .lu-title {
  font-size: min(6.4vw, 54px);
}

body.touch #levelup .lu-level b {
  font-size: min(4.6vw, 38px);
}

body.touch #levelup .lu-voice {
  font-size: min(2.6vw, 20px);
  margin-top: 6px;
}

body.touch #log {
  font-size: 12px;
  bottom: calc(var(--hud-w) * var(--hud-k) + 4px);
}

body.touch #xp-text {
  font-size: 8px;
}

body.touch .bag {
  grid-template-columns: repeat(10, 36px);
  grid-auto-rows: 36px;
}

body.touch .shop-grid {
  grid-template-columns: repeat(6, 36px);
  grid-auto-rows: 36px;
}

body.touch .vendor-panel {
  max-width: 46vw;
}

body.touch .stash-panel {
  max-width: 46vw;
}

/* Portrait uses the same game canvas with a compact orb and potion HUD. The mobile skill cluster
   moves into the lower-right safe area, leaving the left side clear for the thumb joystick. */
body.touch #hud.compact-mobile #hud-rail {
  display: none;
}

body.touch #hud.compact-mobile #xp-track {
  display: block;
  position: absolute;
  z-index: 3;
  background: #0d0806;
  border: 1px solid rgba(160, 120, 60, 0.65);
  border-radius: 3px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.8), inset 0 0 3px #000;
  pointer-events: auto;
  cursor: pointer;
  overflow: hidden;
}

body.touch #hud.compact-mobile #xp-text {
  display: flex;
  position: absolute;
  z-index: 6;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  font: 700 8.5px/1 var(--font-head);
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--gold-bright, #ffe2a0);
  text-shadow: 0 0 2px #000, 0 0 4px #000, 0 1px 2px #000;
  opacity: 0.95;
}

body.touch #hud.compact-mobile #xp-text.show-full {
  font-size: 7.5px;
}

body.touch #hud.compact-mobile .orb-cover {
  z-index: 5;
}

body.touch #hud.compact-mobile .orb-text {
  z-index: 10;
  font-size: clamp(8px, 2.2vw, 12px);
}

body.touch #hud.compact-mobile .potion-slot {
  z-index: 8;
  border: 2px solid #98703b;
  border-radius: 8px;
  background: rgba(17, 9, 5, .84);
  box-shadow: 0 1px 6px #000, inset 0 0 8px rgba(218, 145, 45, .2);
}

body.touch #hud.compact-mobile #gauge-box,
body.touch.portrait #hud.compact-mobile #gauge-box {
  top: auto;
  bottom: 68px;
  width: min(88vw, 320px);
  z-index: 9;
}

body.touch.portrait {
  --hud-w: 100vw;
  --portrait-safe-bottom: env(safe-area-inset-bottom, 0px);
}

body.touch.portrait #hud-bar {
  width: 100vw;
  left: 50%;
  bottom: var(--portrait-chat-h, 34px);
  transition: bottom 0.25s cubic-bezier(0.2, 0, 0, 1);
}

body.touch.portrait #special-actions {
  display: contents;
}

body.touch #hud.compact-mobile #hud-img,
body.touch.portrait #hud-img {
  display: none;
}

.portrait-orb-frame,
.mobile-orb-frame {
  position: absolute;
  z-index: 4;
  display: none;
  pointer-events: none;
}

body.touch.portrait #hud-top-left {
  left: max(8px, env(safe-area-inset-left));
  top: max(8px, env(safe-area-inset-top));
  width: 47vw;
}

body.touch.portrait #hero-stats {
  min-width: 0;
  width: 100%;
}

body.touch.portrait #party-roster {
  min-width: 0;
}

body.touch.portrait #hero-stats .hs-first,
body.touch.portrait #hero-stats .hs-tally,
body.touch.portrait #hs-spark {
  display: none;
}

body.touch.portrait #hud-top-right {
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  grid-template-areas:
    "buttons minimap"
    "tracker dials";
  align-items: start;
  justify-items: end;
  gap: 6px 8px;
  right: max(6px, env(safe-area-inset-right));
  top: max(6px, env(safe-area-inset-top));
  max-width: 65vw;
  pointer-events: none;
  justify-content: end;
}

body.touch.portrait #minimap-row,
body.touch.portrait #hud-btncol {
  display: contents;
}

body.touch.portrait #hud-buttons {
  grid-area: buttons;
  display: grid;
  grid-template-columns: repeat(2, 32px);
  grid-template-rows: repeat(4, 34px);
  gap: 4px;
  margin: 0;
  max-width: none;
  pointer-events: none;
}

body.touch.portrait .hbtn {
  width: 32px;
  height: 34px;
  pointer-events: auto;
}

body.touch.portrait #minimap-wrap {
  grid-area: minimap;
  width: 108px;
  aspect-ratio: 303 / 285.5;
  margin: 12px 14px 10px 8px;
  pointer-events: none;
}

body.touch.portrait #hud-dials {
  grid-area: dials;
  position: static;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 4px;
  margin: 0;
  max-width: none;
  pointer-events: none;
}

body.touch.portrait #stance {
  flex-direction: column;
  right: -42px;
  position: relative;
}

body.touch.portrait #quest-tracker-btn {
  grid-area: tracker;
  display: grid;
  align-self: start;
  justify-self: end;
  width: 32px;
  height: 34px;
  padding: 3px;
  pointer-events: auto;
}

body.touch.portrait #velscour-skull,
body.touch.portrait #Velscour-skull {
  position: absolute;
  top: -2px;
  right: -2px;
  z-index: 6;
  width: 30px;
  height: 34px;
  margin: 0;
  padding: 2px;
  pointer-events: auto;
}

body.touch.portrait #velscour-skull img,
body.touch.portrait #Velscour-skull img {
  width: 22px;
  height: 22px;
}

body.touch.portrait #boss-bar {
  top: max(168px, calc(env(safe-area-inset-top) + 160px));
  left: 50%;
  width: min(92vw, 360px);
}

/* a band of its own under MADNESS / SMITE: the stats and the buttons fill the top */
body.touch.portrait #madness {
  position: absolute;
  left: calc(100vw - max(5px, env(safe-area-inset-right)) - 21vw);
  top: calc(max(284px, env(safe-area-inset-top) + 276px) - 100vh + var(--hud-w) * var(--hud-k));
  bottom: auto;
  width: 42vw;
}

/* portrait: Rage stays inside the gauge box, which the touch layout centres between the Hearthstone and ATK */
body.touch.portrait #barbarian-rage {
  position: relative;
  left: auto;
  top: auto;
  bottom: auto;
  width: 100%;
}

body.touch.portrait #gauge-box.portrait-band {
  width: auto;
}

/* under the raised portrait boss bar */
body.touch.portrait #boss-bar:not(.hidden)~#sand-objective {
  top: max(216px, calc(env(safe-area-inset-top) + 208px));
}

body.touch.portrait #center-msg {
  top: 32%;
}

body.touch.portrait #log {
  left: 8px;
  right: 8px;
  top: auto;
  bottom: auto;
  height: min(13vh, 100px);
  max-height: none;
  overflow: hidden;
}

body.touch.portrait #touch-buttons {
  z-index: 7;
}

body.touch.portrait.panel-open #touch-buttons {
  display: none;
}

body.touch.portrait #touch-buttons.portrait-grid .tbtn.portrait-tile {
  border-radius: 9px;
  border-color: rgba(194, 151, 81, .82);
  background: linear-gradient(145deg, rgba(41, 25, 14, .94), rgba(10, 7, 6, .96));
  box-shadow: 0 2px 8px #000, inset 0 1px 0 rgba(255, 224, 160, .12);
}

body.touch.portrait #touch-buttons.portrait-grid .tbtn.portrait-tile canvas {
  border-radius: 6px;
  width: 88%;
  height: 88%;
}

body.touch.portrait #touch-buttons.portrait-grid .tbtn.portrait-tile .k {
  top: 2px;
  left: 3px;
  right: auto;
  min-width: 12px;
  padding: 0 2px;
  border-radius: 3px;
  background: rgba(7, 5, 4, .75);
  color: #f5d89e;
  font-size: 8px;
  line-height: 11px;
}

body.touch.portrait #touch-buttons.portrait-grid .tbtn.portrait-tile.pressed {
  border-color: #ffe1a0;
  box-shadow: 0 0 12px rgba(255, 202, 104, .8), inset 0 0 10px rgba(255, 202, 104, .25);
}

body.touch.portrait #touch-buttons.portrait-grid .tbtn.main {
  border-width: 4px;
  background: radial-gradient(circle at 35% 30%, #86704b, #302417 58%, #100c08);
  box-shadow: 0 0 15px rgba(0, 0, 0, .95), inset 0 0 12px rgba(255, 220, 150, .22), 0 0 16px rgba(239, 178, 84, .35);
}

body.touch.portrait #touch-buttons.portrait-grid .tbtn.main canvas {
  width: 82%;
  height: 82%;
}

body.touch.portrait #touch-buttons .touch-madness {
  position: absolute;
  z-index: 9;
  margin: 0;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  font-size: 13px;
  letter-spacing: 1.5px;
  line-height: 1;
  text-shadow: 0 0 7px #ff2050, 0 1px 2px #000;
  box-shadow: 0 0 12px rgba(255, 32, 80, .62), inset 0 0 9px rgba(255, 80, 130, .35);
}

body.touch.portrait #touch-buttons .touch-madness:active {
  transform: scale(.95);
}

body.touch.portrait #touch-buttons .touch-smite {
  position: absolute;
  z-index: 9;
  margin: 0;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  font-size: 13px;
  letter-spacing: 1.5px;
  line-height: 1;
}

body.touch.portrait #touch-buttons .touch-smite:active {
  transform: scale(.95);
}

body.touch.portrait .screen {
  padding: max(14px, env(safe-area-inset-top)) 12px max(14px, env(safe-area-inset-bottom));
  overflow-y: auto;
}

body.touch.portrait .class-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

body.touch.portrait .class-card {
  height: min(14vh, 26vw);
}

body.touch.portrait .class-info {
  display: grid;
  grid-template-columns: minmax(96px, 30vw) minmax(0, 1fr);
  gap: 8px;
  max-width: 96vw;
  padding: 4px 8px;
}

body.touch.portrait .class-text {
  min-width: 0;
}

body.touch.portrait .settings-grid {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 10px;
}

body.touch.portrait .settings-tab-btn {
  font-size: 11px;
  padding: 6px 3px;
  letter-spacing: 0.2px;
}

body.touch.portrait .settings-tab-pane {
  min-height: 180px;
}

body.touch.portrait .help-keys {
  columns: 1;
}

@media (max-width: 420px) {
  body.touch.portrait #hero-stats {
    padding: 2px 4px;
  }

  body.touch.portrait #hero-stats b {
    font-size: 11px;
  }

  body.touch.portrait #buff-row {
    max-width: 48vw;
  }
}

body.touch .stash-panel .stash-grid {
  grid-template-columns: repeat(6, 36px);
  max-height: 52vh;
}

body.touch .vendor-panel .vendor-greet {
  font-size: 12px;
  margin-bottom: 4px;
}

body.touch .panel {
  max-width: 100%;
}

body.touch .paperdoll {
  grid-template-columns: repeat(4, 52px);
  grid-template-rows: repeat(4, 52px);
}

body.touch .paperdoll .portrait {
  transform: translateY(8px);
}

body.touch .paperdoll .portrait img {
  max-height: 110px;
  max-width: 64px;
}

body.touch .vslot {
  width: 52px;
  height: 52px;
}

body.touch .tab-slots {
  grid-template-columns: repeat(5, 40px);
  gap: 5px;
}

body.touch .tslot {
  width: 40px;
  height: 40px;
}

body.touch .sh-text {
  height: 34vh;
  font-size: 12px;
}

body.touch .tree {
  grid-template-columns: repeat(3, 54px);
  gap: 12px 16px;
}

body.touch .snode {
  width: 50px;
  height: 50px;
}

body.touch #panels {
  bottom: 0;
  padding: 4px;
}

body.touch .panel-head {
  padding: 4px 8px;
}

body.touch .panel-head h2 {
  font-size: 15px;
}

body.touch .item-detail,
body.touch .skill-detail {
  width: 230px;
  font-size: 12px;
}

@media (max-width: 900px) {
  .class-grid {
    grid-template-columns: repeat(10, minmax(0, 1fr));
  }

  .plaque {
    font-size: 8px;
    padding: 0 3px;
  }

  .title-tag {
    font-size: 13px;
    margin-bottom: 12px;
  }
}

@media (max-width: 600px) {
  .class-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .class-card {
    height: min(24vh, 34vw);
  }

  .title-menu {
    min-width: min(260px, 86vw);
  }

  .slot-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .slot-hero {
    height: 24vh;
  }
}

@media (orientation: portrait) and (max-width: 700px) {
  .title-credits img {
    width: min(62vw, 460px);
    max-height: 30vh;
  }
}

@media (max-height: 500px) {
  .title-logo {
    max-height: 34vh;
  }

  .title-screen .title-logo {
    max-height: 30vh;
    margin-top: 5vh;
  }

  .title-screen .title-tag {
    font-size: 11px;
    letter-spacing: 2px;
    margin: 2px 0 8px;
  }

  .title-screen .title-menu {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 8px;
    max-width: min(640px, 94vw);
    min-width: 0;
  }

  .title-screen .title-menu .btn {
    font-size: 14px;
    padding: 6px 14px;
  }

  .title-screen .title-menu .btn.big {
    font-size: 17px;
    padding: 7px 20px;
    flex: 1 1 40%;
  }

  .title-screen .title-menu .btn.big span {
    font-size: 11px !important;
  }

  .title-gate {
    bottom: 14%;
    font-size: 13px;
  }

  .class-screen .btn.big {
    font-size: 17px;
    padding: 6px 22px;
  }

  .class-screen .name-input {
    padding: 5px 8px;
    font-size: 14px;
  }

  .class-screen .btn {
    padding-top: 5px;
    padding-bottom: 5px;
  }

  .class-info {
    gap: 10px;
    padding: 0 12px;
  }

  .title-foot {
    display: none;
  }

  .screen-title {
    font-size: 16px;
    margin: 2px 0 0;
  }

  .class-card {
    height: 20vh;
  }

  .class-big {
    height: 25vh;
    width: 17vh;
  }

  .class-screen .row {
    margin: 2px 0 6px !important;
  }

  .slot-info {
    font-size: 11px;
    min-height: 0;
  }

  .slot-btns .btn {
    padding: 2px 7px;
    font-size: 11px;
  }

  .slot-hero {
    height: 34vh;
  }

  .class-info h2 {
    font-size: 20px;
  }

  .class-info p {
    font-size: 13px;
  }
}

/* skill mastery (ui/skills.js) and the Gem Forge (ui/vendor.js) */
.mastery {
  margin: 6px 0 2px;
  font-size: 12px;
}

.mastery .mbar {
  height: 5px;
  background: #1a120c;
  border: 1px solid #3a2a1a;
  border-radius: 3px;
  margin-top: 2px;
  overflow: hidden;
}

.mastery .mbar>div {
  height: 100%;
  box-shadow: 0 0 6px currentColor;
}

.snode .mlvl {
  position: absolute;
  left: 2px;
  top: 1px;
  font-size: 10px;
  color: #8fe0ff;
  text-shadow: 0 0 3px #000, 0 0 2px #000;
}

.forge-row {
  gap: 6px;
  flex-wrap: wrap;
  margin: 4px 0;
  align-items: center;
}

.forge-row>span {
  min-width: 170px;
}

.vendor-sub {
  margin: 10px 0 4px;
}

.class-card .card-lv {
  position: absolute;
  top: 3px;
  right: 5px;
  font: 700 11px var(--font-head);
  color: var(--gold-bright);
  text-shadow: 0 1px 2px #000;
}

.class-card:not(.has-hero) canvas {
  opacity: .55;
}

.class-screen.del-mode .class-card.has-hero {
  border-color: #c03a2a;
  box-shadow: 0 0 12px rgba(220, 50, 30, .55);
}

.class-screen.del-mode .class-card:not(.has-hero) {
  opacity: .4;
  cursor: default;
}

/* THE ETERNAL BREACH: the purple portal's floor dialog (game.confirmBreach) */
.breach-dialog .Velscour-biome-select {
  width: 100%;
  border-color: #7a40b0;
  color: #e0c0ff;
}

.breach-warn {
  min-height: 1.3em;
  margin: 10px 0 0;
}

/* ---- the Endgame (docs/ENDGAME.md): the rift clock, the Altar of Heresy, the Marks, the honour board ---- */
#rift-bar {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px;
  border: 1px solid #1aa8c0;
  border-radius: 6px;
  background: rgba(2, 18, 26, .78);
  font: 700 13px var(--font-body);
  color: #a0f0ff;
  letter-spacing: .5px;
  text-shadow: 0 0 4px #000;
  pointer-events: none;
  white-space: nowrap;
}

#rift-bar b {
  font: 900 13px var(--font-head);
  color: #20e0ff;
  letter-spacing: 2px;
}

#rift-bar #rift-clock {
  font: 900 16px var(--font-head);
  color: #fff;
  min-width: 44px;
  text-align: center;
}

#rift-bar #rift-track {
  display: inline-block;
  width: 120px;
  height: 8px;
  border: 1px solid #1aa8c0;
  border-radius: 4px;
  background: #061a22;
  overflow: hidden;
}

#rift-bar #rift-fill {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(#80f0ff, #1aa8c0);
  transition: width .3s;
}

#rift-bar.urgent {
  border-color: #ff6050;
  animation: riftpulse .8s ease-in-out infinite;
}

#rift-bar.urgent #rift-clock {
  color: #ff8060;
}

#rift-bar.boss {
  top: 80px;
}

#rift-bar.guard #rift-fill {
  background: linear-gradient(#fff0a0, #e0a020);
}

#rift-bar.guard #rift-pct {
  color: #ffd860;
}

@keyframes riftpulse {
  50% {
    box-shadow: 0 0 16px #ff4030;
  }
}

body.touch #rift-bar {
  top: 80px;
  left: var(--cc-left);
  padding: 2px 8px;
  gap: 6px;
  font-size: 11px;
}

/* the centre column */
body.touch #rift-bar #rift-track {
  width: 70px;
}

body.touch #rift-bar b {
  display: none;
}

body.touch #rift-bar.boss {
  top: 124px;
}

/* under the Guardian's bar */
/* upright, the rift bar and the scenario objective join the left column (hud.js layoutMobile), under the auto-play line */
body.touch.portrait #hud-top-left>#rift-bar,
body.touch.portrait #hud-top-left>#sand-objective {
  position: relative;
  left: auto;
  top: auto;
  transform: none;
  margin-top: 4px;
}

body.touch.portrait #hud-top-left>#rift-bar {
  display: inline-flex;
}

body.touch.portrait #hud-top-left>#sand-objective {
  width: min(214px, calc(100vw - 176px));
}

/* (clear of the stance on the right) */
.hx-locked {
  padding: 8px 10px;
  margin-bottom: 8px;
  border: 1px solid #7a3020;
  border-radius: 6px;
  background: rgba(60, 10, 5, .5);
  color: #ffb0a0;
}

.hx-head {
  margin-bottom: 6px;
}

.hx-rank {
  font: 700 16px var(--font-head);
  color: #ff8060;
}

.hx-rank b {
  font-size: 22px;
  color: #ffb090;
}

.hx-bar {
  position: relative;
  height: 8px;
  margin: 4px 0 6px;
  border: 1px solid #5a2a20;
  border-radius: 4px;
  background: #1a0806;
}

.hx-bar>div {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #a02010, #ff6030);
  transition: width .25s;
}

.hx-tick {
  position: absolute;
  top: -3px;
  width: 2px;
  height: 12px;
  margin-left: -1px;
  background: #806050;
}

.hx-tick.done {
  background: #ffd860;
  box-shadow: 0 0 4px #ffd860;
}

.hx-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.hx-chip {
  display: inline-flex;
  gap: 4px;
  align-items: baseline;
  padding: 1px 7px;
  border: 1px solid #4a2a20;
  border-radius: 10px;
  background: rgba(40, 12, 6, .6);
  font-size: 12px;
}

.hx-chip i {
  font-style: normal;
  color: #a08070;
}

.hx-chip b {
  color: #ffd0a0;
}

.hx-chips.dim .hx-chip b {
  color: #8a7060;
}

.hx-note {
  margin: 0 0 8px;
  font-size: 12px;
  color: #b0a090;
}

.hx-warn {
  color: #ffb060;
}

.hx-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
}

.hx-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 7px 8px;
  border: 1px solid #3a2a2a;
  border-radius: 6px;
  background: rgba(20, 8, 6, .5);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.hx-row:hover {
  border-color: #6a3a2a;
}

.hx-row.on {
  border-color: var(--hc, #ff6040);
  background: rgba(50, 12, 6, .6);
  box-shadow: inset 0 0 14px rgba(255, 80, 40, .22);
}

.hx-row.locked {
  opacity: .5;
  cursor: default;
  filter: grayscale(.6);
}

.hx-row input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.hx-sw {
  position: relative;
  flex: none;
  width: 34px;
  height: 18px;
  margin-top: 1px;
  border-radius: 9px;
  border: 1px solid #5a3a30;
  background: #20100c;
  transition: background .15s, border-color .15s;
}

.hx-sw::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #806858;
  transition: left .15s, background .15s;
}

.hx-row input:checked+.hx-sw {
  background: var(--hc, #ff6040);
  border-color: var(--hc, #ff6040);
}

.hx-row input:checked+.hx-sw::after {
  left: 18px;
  background: #fff4e0;
}

.hx-row input:focus-visible+.hx-sw {
  outline: 2px solid #ffd860;
  outline-offset: 1px;
}

.hx-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.hx-name {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--hc, #ffd0a0);
}

.hx-pips {
  display: inline-flex;
  gap: 2px;
  margin-left: auto;
}

.hx-pips i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--hc, #ff6040);
  box-shadow: 0 0 4px var(--hc, #ff6040);
}

.hx-desc {
  font-size: 12px;
  margin-top: 2px;
  color: #a89888;
}

.hx-row.on .hx-desc {
  color: #d8c8b8;
}

.hx-foot {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 10px 0 8px;
}

.hx-miles {
  flex: 1;
  font-size: 13px;
}

.hx-mile {
  padding: 2px 0;
  color: #b0a090;
}

.hx-mile.done {
  color: #ffd860;
}

.hx-clear {
  flex: none;
}

.hx-doors {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.hx-door {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 6px 8px;
  line-height: 1.2;
}

.hx-door b {
  font: 700 13px var(--font-head);
  letter-spacing: 1px;
}

.hx-door span {
  font-size: 11px;
  opacity: .8;
}

.hx-door.hx-rift:not(:disabled) b {
  color: #20e0ff;
}

.hx-door.hx-unbound:not(:disabled) b {
  color: #ff7050;
}

.hx-door.hx-marks b {
  color: #ff9050;
}

body.touch .hx-list {
  grid-template-columns: 1fr;
  gap: 6px;
}

body.touch .hx-row {
  min-height: 50px;
  padding: 9px 10px;
  align-items: center;
  gap: 12px;
}

body.touch .hx-sw {
  width: 50px;
  height: 28px;
  border-radius: 14px;
}

body.touch .hx-sw::after {
  width: 22px;
  height: 22px;
  top: 2px;
  left: 2px;
}

body.touch .hx-row input:checked+.hx-sw::after {
  left: 24px;
}

body.touch .hx-name {
  font-size: 15px;
}

body.touch .hx-desc {
  font-size: 13px;
}

body.touch .hx-foot {
  flex-direction: column;
  align-items: stretch;
}

body.touch .hx-clear {
  min-height: 40px;
}

body.touch .hx-doors {
  grid-template-columns: 1fr;
}

body.touch .hx-door {
  min-height: 48px;
}

.mk-head {
  margin-bottom: 8px;
}

.mk-tot {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font: 700 14px var(--font-head);
  color: #d8b090;
}

.mk-tot b {
  font-size: 24px;
  color: #ff9050;
  text-shadow: 0 0 8px rgba(255, 100, 40, .5);
}

.mk-free {
  margin-left: auto;
  color: #8a7a6a;
}

.mk-free b {
  font-size: 18px;
  color: #8a7a6a;
  text-shadow: none;
}

.mk-free.on,
.mk-free.on b {
  color: #ffd860;
}

.mk-xp {
  position: relative;
  height: 14px;
  margin: 6px 0 4px;
  background: #0d0806;
  border: 1px solid #4a2a1a;
  border-radius: 3px;
  overflow: hidden;
}

.mk-xp i,
.mk-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(#ffb070, #d0401a 60%, #5a1004);
}

.mk-xp span {
  position: absolute;
  inset: 0;
  text-align: center;
  font: 700 10px/14px var(--font-head);
  color: #ffe0c0;
  text-shadow: 0 0 3px #000, 0 0 3px #000;
}

.mk-why {
  font-size: 12px;
}

.mk-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.mk-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  align-items: center;
  padding: 6px 8px;
  border: 1px solid #3a2a2a;
  border-left: 3px solid var(--mk, #ff9050);
  border-radius: 6px;
  background: rgba(20, 8, 6, .5);
}

.mk-name {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--mk, #ff9050);
  font: 700 14px var(--font-head);
}

.mk-pts {
  font: 700 12px var(--font-body, inherit);
  color: #e8d8c0;
  background: rgba(0, 0, 0, .45);
  border: 1px solid #4a3a30;
  border-radius: 9px;
  padding: 0 7px;
}

.mk-val {
  text-align: right;
  font-size: 13px;
  color: #c8b8a0;
  white-space: nowrap;
}

.mk-val b {
  font-size: 15px;
  color: var(--mk, #ff9050);
}

.mk-bar {
  grid-column: 1 / 3;
  height: 5px;
  background: #0d0806;
  border-radius: 3px;
  overflow: hidden;
}

.mk-bar i {
  background: var(--mk, #ff9050);
  box-shadow: 0 0 6px var(--mk, #ff9050);
}

.mk-next {
  font-size: 11px;
}

.mk-btns {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

.mk-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

#xp-fill.mk-xp {
  background: linear-gradient(#ffb070, #d0401a 60%, #5a1004);
  box-shadow: 0 0 8px #ff6a20;
}

body.touch .mk-list {
  grid-template-columns: 1fr 1fr;
}

body.touch .mk-why {
  display: none;
}

body.touch .mk-btns .btn,
body.touch .mk-foot .btn {
  min-width: 40px;
  min-height: 30px;
}

body.touch .mk-next {
  display: none;
}

body.touch .mk-btns {
  grid-column: 1 / 3;
}

.rift-dialog {
  border-color: #1a8aa0;
  box-shadow: 0 0 40px #000, 0 0 18px rgba(32, 224, 255, .18);
}

.rift-dialog h2 {
  color: #80f0ff;
  text-shadow: 0 0 10px rgba(32, 224, 255, .45);
}

.rift-dialog .Velscour-biome-select {
  width: 100%;
}

.rift-dialog .rb-stats {
  font-size: 12px;
  margin: 4px 0 10px;
}

.rift-results .rr-time {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 4px 10px;
  margin: 2px 0 8px;
}

.rift-results .rr-time b {
  font: 900 36px var(--font-head);
  color: #20e0ff;
  text-shadow: 0 0 12px rgba(32, 224, 255, .5);
}

.rift-results .rr-list {
  text-align: left;
  margin: 0 auto 12px;
  padding-left: 20px;
  max-width: 440px;
  line-height: 1.5;
}

.rift-board {
  width: min(620px, 94vw);
}

.rift-board .rb-note {
  font-size: 12px;
  margin: 0 0 8px;
}

.rb-head {
  margin-bottom: 8px;
}

.rb-you {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2px 10px;
  padding: 5px 8px;
  margin-bottom: 6px;
  border: 1px solid #1a6a7a;
  border-radius: 6px;
  background: rgba(32, 224, 255, .07);
  font-size: 13px;
  text-align: left;
}

.rb-you b {
  color: #20e0ff;
}

.rb-you p {
  flex-basis: 100%;
  margin: 2px 0 0;
  font-size: 12px;
}

.rb-list {
  max-height: 46vh;
  overflow: auto;
  text-align: left;
}

.rb-msg {
  padding: 14px 6px;
  text-align: center;
}

.rb-row {
  display: grid;
  grid-template-columns: 28px 1fr 64px 48px 58px;
  gap: 8px;
  align-items: baseline;
  padding: 4px 6px;
  border-bottom: 1px solid #2a2020;
  font-size: 13px;
}

.rb-row[data-i] {
  cursor: pointer;
}

.rb-row[data-i]:hover,
.rb-row.open {
  background: rgba(255, 255, 255, .04);
}

.rb-row b {
  color: #20e0ff;
}

.rb-row .rb-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--gold-bright);
}

.rb-row .rb-rank {
  color: #8a8070;
  text-align: right;
}

.rb-row.rb-top {
  font-size: 11px;
  color: #8a8070;
  text-transform: uppercase;
  letter-spacing: 1px;
  position: sticky;
  top: 0;
  background: var(--panel);
}

.rb-row.rb-top b,
.rb-row.rb-top i {
  color: #8a8070;
  font-style: normal;
  font-weight: 400;
}

.rb-row.rb-mine {
  background: rgba(32, 224, 255, .10);
}

.rb-gap {
  text-align: center;
  color: #6a6050;
}

.rb-build {
  padding: 6px 8px 8px 42px;
  border-bottom: 1px solid #2a2020;
  background: rgba(0, 0, 0, .25);
  font-size: 12px;
}

.rb-bhead {
  color: #c0b090;
  margin-bottom: 4px;
}

.rb-skills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}

.rb-skills span {
  padding: 1px 6px;
  border: 1px solid #3a3020;
  border-radius: 3px;
  background: #160e08;
}

.rb-gear div {
  display: grid;
  grid-template-columns: 62px 1fr auto;
  gap: 6px;
  padding: 1px 0;
}

body.touch .rift-board .rb-note {
  display: none;
}

body.touch .rift-board .Velscour-biome-select {
  padding: 5px 10px;
}

body.touch .rb-list {
  max-height: none;
}

body.touch .rb-row {
  grid-template-columns: 22px 1fr 54px 40px 48px;
  gap: 5px;
  font-size: 12px;
}

body.touch .rb-build {
  padding-left: 10px;
}

/* Inventory, storage and trade: a more legible companion to the game HUD. */
body:not(.touch) #panels {
  display: block;
  padding: 0;
}

body:not(.touch) #panels>.panel {
  position: absolute;
}

body:not(.touch) .panel-head {
  cursor: grab;
  touch-action: none;
  user-select: none;
}

body:not(.touch) .panel.moving .panel-head {
  cursor: grabbing;
}

.panel[data-panel="inventory"],
.panel[data-panel="character"],
.character-panel,
.vendor-panel,
.stash-panel,
.reliquary-panel {
  background: linear-gradient(150deg, #241911 0%, #130e0b 42%, #0e0b09 100%);
  border: 1px solid #9a7040;
  border-radius: 8px;
  box-shadow: 0 0 0 2px #080605, 0 20px 50px #000c, inset 0 0 0 1px #3c2918;
}

.panel[data-panel="inventory"] .panel-head,
.panel[data-panel="character"] .panel-head,
.character-panel .panel-head,
.vendor-panel .panel-head,
.stash-panel .panel-head,
.reliquary-panel .panel-head {
  min-height: 46px;
  background: linear-gradient(180deg, #43301e, #24180f 72%, #1c130d);
  border-bottom: 1px solid #a07641;
  padding: 8px 14px;
}

.panel[data-panel="inventory"] .panel-head h2,
.panel[data-panel="character"] .panel-head h2,
.character-panel .panel-head h2,
.vendor-panel .panel-head h2,
.stash-panel .panel-head h2,
.reliquary-panel .panel-head h2 {
  font-size: 17px;
  letter-spacing: 1.6px;
  color: #f8d99a;
  text-shadow: 0 2px 3px #000;
}

.panel[data-panel="inventory"] .panel-body,
.panel[data-panel="character"] .panel-body,
.character-panel .panel-body,
.vendor-panel .panel-body,
.stash-panel .panel-body,
.reliquary-panel .panel-body {
  padding: 14px;
}

body:not(.touch) .panel[data-panel="inventory"] {
  width: min(496px, calc(100vw - 24px));
}

body:not(.touch) .panel[data-panel="character"],
body:not(.touch) .character-panel {
  width: min(580px, calc(100vw - 24px));
}

body:not(.touch) .vendor-panel {
  width: min(460px, calc(100vw - 24px));
}

body:not(.touch) .stash-panel,
body:not(.touch) .reliquary-panel {
  width: min(500px, calc(100vw - 24px));
}

body:not(.touch) #panels:has(.vendor-panel, .stash-panel, .reliquary-panel) .vendor-panel {
  width: min(460px, 35vw);
}

body:not(.touch) .character-panel .inv-wrap,
body:not(.touch) .inv-wrap.character-view {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  justify-content: start;
}

body:not(.touch) .character-panel .inv-equipment {
  width: 256px;
  min-width: 0;
}

body:not(.touch) .character-panel .paperdoll {
  grid-template-columns: repeat(4, 52px);
  grid-template-rows: repeat(4, 52px);
  gap: 6px;
  padding: 8px;
  justify-content: center;
  box-sizing: border-box;
  width: 100%;
}

body:not(.touch) .character-panel .vslot {
  width: 52px;
  height: 52px;
}

body:not(.touch) .character-panel .paperdoll .portrait img {
  max-height: 110px;
  max-width: 64px;
}

body:not(.touch) .character-panel .vanity-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  box-sizing: border-box;
  width: 100%;
}

body:not(.touch) .character-panel .vanity-grid {
  grid-template-columns: repeat(2, 52px);
  grid-template-rows: repeat(2, 52px);
  gap: 6px;
  flex-shrink: 0;
}

body:not(.touch) .character-panel .vanity-side {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

body:not(.touch) .character-panel .vanity-helm-btn {
  width: fit-content;
  max-width: 100%;
  font-size: 11px;
  padding: 4px 10px;
  white-space: nowrap;
}

body:not(.touch) .character-panel .vanity-note {
  font-size: 10px;
  color: #8c7b9e;
  line-height: 1.25;
}

body:not(.touch) .character-panel .tab-row {
  width: 100%;
  box-sizing: border-box;
}

body:not(.touch) .character-panel .tab-slots {
  grid-template-columns: repeat(5, 44px);
  gap: 5px;
  justify-content: center;
}

body:not(.touch) .character-panel .tslot {
  width: 44px;
  height: 44px;
}

body:not(.touch) .character-panel .character-card {
  min-width: 0;
  width: 100%;
}

body:not(.touch) .character-panel .character-card .stats-grid {
  grid-template-columns: 1fr auto;
  gap: 3px 12px;
}

body.touch:not(.portrait) .panel[data-panel="inventory"],
body.touch:not(.portrait) .inventory-panel {
  width: min(470px, calc(100vw - 20px));
  order: 2 !important;
}

body.touch:not(.portrait) #panels:has(> .panel:nth-child(2)) .panel[data-panel="inventory"],
body.touch:not(.portrait) #panels:has(> .panel:nth-child(2)) .inventory-panel {
  max-width: 58vw;
}

body.touch:not(.portrait) .panel[data-panel="character"],
body.touch:not(.portrait) .character-panel {
  width: min(265px, calc(100vw - 20px));
  order: 1 !important;
}

body.touch:not(.portrait) #panels:has(> .panel:nth-child(2)) .panel[data-panel="character"],
body.touch:not(.portrait) #panels:has(> .panel:nth-child(2)) .character-panel {
  max-width: 38vw;
}

body.touch:not(.portrait) .character-panel .inv-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

body.touch:not(.portrait) .character-panel .inv-equipment {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

body.touch:not(.portrait) .character-panel .character-card {
  width: 100%;
  box-sizing: border-box;
}

body.touch:not(.portrait) .character-panel .panel-body {
  padding: 8px 10px;
}

body.touch:not(.portrait) .character-panel .paperdoll {
  grid-template-columns: repeat(4, 42px);
  grid-template-rows: repeat(4, 42px);
  gap: 4px;
}

body.touch:not(.portrait) .character-panel .paperdoll .portrait img {
  max-height: 98px;
  max-width: 58px;
}

body.touch:not(.portrait) .character-panel .vanity-row {
  padding: 4px 6px;
  gap: 6px;
}

body.touch:not(.portrait) .character-panel .vanity-grid {
  grid-template-columns: repeat(2, 40px);
  grid-template-rows: repeat(2, 40px);
  gap: 4px;
}

body.touch:not(.portrait) .character-panel .vslot {
  width: 40px;
  height: 40px;
}

body.touch.portrait .character-panel .vanity-row {
  padding: 6px 8px;
  gap: 8px;
}

body.touch.portrait .character-panel .vanity-grid {
  grid-template-columns: repeat(2, 48px);
  grid-template-rows: repeat(2, 48px);
  gap: 5px;
}

body.touch.portrait .character-panel .vslot {
  width: 48px;
  height: 48px;
}

body:not(.touch) .inventory-panel .inv-wrap,
body:not(.touch) .inv-wrap.bag-view {
  display: block;
}

.inv-title-label {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  color: #f1cc89;
  font: 700 12px var(--font-head);
  letter-spacing: 1.1px;
  text-transform: uppercase;
}

.inv-title-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.inv-title-actions .btn,
.inv-section-title .btn {
  font-size: 11px;
  padding: 2px 8px;
  margin-left: 0;
  line-height: 1.2;
}

.inv-wrap>.col {
  min-width: 0;
}

.inv-section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 24px;
  margin: 0 0 5px;
  padding: 0 1px 5px;
  border-bottom: 1px solid #6b4b29;
  color: #f1cc89;
  font: 700 12px var(--font-head);
  letter-spacing: 1.1px;
  text-transform: uppercase;
}

.inv-section-title.gem-bag-title {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #4a3522;
  border-bottom: 1px solid #553e6c;
  color: #e2caff;
}

.inv-section-title.gem-bag-title .inv-title-label {
  color: #dfcbff;
}

.inv-section-title.gem-bag-title span {
  color: #b09ac8;
}

.gem-bag {
  margin-bottom: 4px;
}

.gem-bag .gem-slot {
  background: radial-gradient(circle at 50% 30%, #1c1528 0%, #100b18 100%);
  border-color: #553e6c;
}

.gem-bag .gem-slot:hover {
  border-color: #a47fe0;
  box-shadow: 0 0 7px rgba(180, 130, 255, 0.4);
}

.gem-bag .gem-slot.sel {
  border-color: #e0b0ff;
  box-shadow: 0 0 10px rgba(220, 170, 255, 0.7);
}

.inv-section-title span {
  color: #b9a17d;
  font: 600 11px var(--font-body);
  letter-spacing: 0;
  text-transform: none;
}

.inv-eyebrow {
  color: #b99562;
  font: 700 10px var(--font-head);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.inv-equipment .paperdoll {
  background: radial-gradient(ellipse at 50% 54%, #4b3422 0%, #261a12 55%, #130d09 100%);
  border: 1px solid #76532c;
  border-radius: 5px;
  box-shadow: inset 0 0 30px #080503, 0 0 0 1px #100b07;
}

.paperdoll .portrait img {
  max-height: 136px;
  max-width: 76px;
  filter: drop-shadow(0 8px 9px #000) drop-shadow(0 0 7px #b07a3440);
}

.eslot,
.bslot {
  background: linear-gradient(145deg, #302218, #17110d 70%);
  border: 1px solid #72502c;
  border-radius: 3px;
  box-shadow: inset 0 1px 2px #b3843022, inset 0 -4px 8px #0008;
}

.eslot:hover,
.bslot:hover {
  border-color: #d4a65d;
  background: linear-gradient(145deg, #49301d, #22170e);
}

.eslot.sel,
.bslot.sel {
  outline: 2px solid #ffdb8e;
  outline-offset: -2px;
}

.bslot:focus-visible,
.eslot:focus-visible {
  outline: 2px solid #ffdf9f;
}

.bslot[hidden] {
  display: none !important;
}

.bslot img,
.eslot img {
  filter: drop-shadow(0 2px 3px #000b);
}

.eslot .lbl {
  color: #c2a77a;
  text-shadow: 0 1px 2px #000;
}

.inv-equipment .item-detail {
  width: 100%;
  min-height: 140px;
  padding: 11px;
  background: linear-gradient(160deg, #2b1d13, #16100c);
  border-color: #76532c;
  border-radius: 5px;
  color: #e8d8b9;
}

.inv-bag-actions {
  align-items: center;
  gap: 6px 8px;
  flex-wrap: wrap;
  padding-top: 7px;
  border-top: 1px solid #5c4126;
}

.inv-bag-actions .gold-text {
  font-weight: 700;
}

.inv-bag-actions .dim {
  font-size: 12px;
}

.character-card {
  gap: 7px;
}

.character-identity {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 5px 0 9px;
  border-bottom: 1px solid #6b4b29;
}

.character-identity b {
  color: #ffe0a3;
  font: 700 18px var(--font-head);
  overflow-wrap: anywhere;
}

.character-identity>span:not(.inv-eyebrow) {
  color: #e6cfaa;
  font-size: 13px;
}

.character-identity small {
  color: #ad9878;
  font-size: 11px;
}

.character-card .attr-row {
  padding: 4px 2px;
  font-size: 13px;
}

.character-card .stats-grid {
  gap: 3px 12px;
  font-size: 12px;
}

.character-card .stats-grid .v {
  color: #ffe0a3;
}

.character-more {
  border-top: 1px solid #5c4126;
  padding-top: 7px;
}

.character-more summary {
  cursor: pointer;
  color: #e8bc73;
  font: 700 12px var(--font-head);
}

.character-more .stats-grid {
  margin-top: 9px;
}

.character-history {
  color: #ac9778;
  font-size: 11px;
  border-top: 1px solid #4a3522;
  padding-top: 7px;
}

body:not(.touch) .inv-wrap.character-view .character-card {
  grid-column: auto;
}

.vendor-greet {
  color: #d4b98e;
  line-height: 1.3;
}

.shop-grid {
  gap: 4px;
}

.shop-grid .bslot {
  overflow: hidden;
}

.shop-price {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1px 0;
  text-align: center;
  font-size: 9px;
  font-weight: 700;
  color: #ffe1a4;
  background: #100b08d9;
  pointer-events: none;
}

.shop-sellzone,
.storage-dropzone {
  margin: 9px 0 12px;
  padding: 10px;
  border: 1px dashed #a07742;
  border-radius: 4px;
  background: #6d462522;
  color: #cfb38a;
  text-align: center;
  font-size: 12px;
}

.shop-sellzone.drop-target,
.storage-dropzone.drop-target {
  border-color: #ffe0a3;
  background: #8c5c3155;
  color: #fff0cc;
}

.storage-toolbar {
  gap: 7px;
  align-items: center;
  margin-bottom: 9px;
}

.storage-toolbar strong {
  color: #ffe0a3;
  font: 700 15px var(--font-head);
}

.storage-filters {
  display: flex;
  gap: 7px;
}

.storage-select,
.storage-search {
  min-width: 0;
  background: #1c140f;
  border: 1px solid #80603a;
  border-radius: 4px;
  color: #edd8b7;
  padding: 6px 8px;
  font: 13px var(--font-body);
}

.storage-search {
  flex: 1;
}

.stash-grid.filtered {
  align-content: start;
}

.rel-search {
  width: 100%;
  margin-top: 9px;
}

.storage-detail {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid #76532c;
  border-radius: 4px;
  background: #21170f;
}

.storage-detail .btn {
  margin-top: 9px;
}

.reliquary-panel .rel-grid {
  grid-template-columns: repeat(10, 44px);
}

body:not(.touch) #panels:has(.reliquary-panel) .reliquary-panel .rel-grid {
  grid-template-columns: repeat(10, 44px);
}

.vendor-panel .item-detail {
  background: #21170f;
  border-color: #76532c;
}

@media (max-width: 1250px) {
  body:not(.touch) .vendor-panel .shop-grid {
    grid-template-columns: repeat(6, 44px);
  }
}

body.touch .inv-section-title {
  font-size: 11px;
}

body.touch .character-card {
  min-width: 210px;
}

body.touch .shop-price {
  font-size: 8px;
}

.macros-panel .mc-why {
  font-size: 12px;
  margin-bottom: 8px;
}

.mc-row {
  padding: 6px 8px;
  margin-bottom: 6px;
  border: 1px solid #3a2e22;
  border-left: 3px solid var(--gold-dim);
  border-radius: 6px;
  background: rgba(16, 10, 6, .55);
}

.mc-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.mc-head .mc-name {
  flex: 1 1 120px;
  min-width: 0;
  width: auto;
  padding: 3px 6px;
  font-size: 14px;
}

.mc-key,
.mc-add {
  background: #160e08;
  color: #e8d8c0;
  border: 1px solid #5a4630;
  border-radius: 4px;
  padding: 3px 4px;
  font: inherit;
  font-size: 13px;
}

.mc-keep {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: #d8c8a8;
  cursor: pointer;
  white-space: nowrap;
}

.mc-skills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
}

.mc-chip {
  position: relative;
  width: 38px;
  height: 38px;
  border: 1px solid var(--gold-dim);
  border-radius: 5px;
  background: #0c0805;
  cursor: pointer;
}

.mc-chip img {
  width: 100%;
  height: 100%;
  border-radius: 4px;
  display: block;
}

.mc-chip .mc-n {
  position: absolute;
  left: 2px;
  top: 0;
  font: 700 10px var(--font-body);
  color: var(--gold);
  text-shadow: 0 0 2px #000, 0 0 2px #000;
}

.mc-chip .mc-x {
  position: absolute;
  right: 1px;
  top: -3px;
  font-size: 13px;
  color: #ff8070;
  text-shadow: 0 0 2px #000;
  opacity: 0;
}

.mc-chip:hover .mc-x,
body.touch .mc-chip .mc-x {
  opacity: 1;
}

.mc-chip.gone {
  opacity: .4;
}

body.touch .mc-chip {
  width: 42px;
  height: 42px;
}

body.touch .mc-key,
body.touch .mc-add,
body.touch .mc-head .mc-name,
body.touch .mc-row .btn {
  min-height: 32px;
  font-size: 14px;
}

body.touch .mc-keep input {
  width: 20px;
  height: 20px;
}

body.touch .macros-panel .mc-why {
  display: none;
}

.tbtn.macro {
  border-color: #8a6ad0;
  background: rgba(16, 8, 24, .8);
}

.tbtn.macro .k {
  top: auto;
  bottom: 1px;
  font-size: 8px;
  color: #d8c8ff;
}

.tt-augdmg {
  font-size: 12px;
  color: #ffcf7a;
  margin-top: 1px;
}

/* ------------------------------------------------ town portal: floor picker (game.confirmDungeon) */
.floor-pick-dialog {
  min-width: min(440px, 92vw);
}

.floor-pick {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.floor-pick-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.floor-pick-label,
.floor-pick-max {
  font-family: var(--font-title, serif);
  color: #c8a060;
  letter-spacing: 1px;
  font-size: 15px;
}

.floor-pick-num {
  display: flex;
  align-items: stretch;
  gap: 4px;
}

.floor-pick-step.btn {
  min-width: 34px;
  padding: 2px 8px;
  font-size: 18px;
  line-height: 1;
}

.floor-pick-input {
  width: 84px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  color: #ffd860;
  background: #120c08;
  border: 1px solid #8e5c2e;
  border-radius: 3px;
  box-shadow: inset 0 0 8px #000;
  padding: 4px 6px;
  font-family: inherit;
}

.floor-pick-input:focus {
  outline: none;
  border-color: #ffb050;
  box-shadow: inset 0 0 8px #000, 0 0 6px rgba(255, 160, 60, 0.5);
}

.floor-pick-range {
  --pct: 0%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, #ff5020 0%, #ffb050 var(--pct), #2a1a10 var(--pct), #2a1a10 100%);
  border: 1px solid #5a3c20;
  outline: none;
  cursor: pointer;
}

.floor-pick-range:disabled {
  opacity: 0.5;
  cursor: default;
}

.floor-pick-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #ffe0a0, #e07020 60%, #7a2a08);
  border: 2px solid #2a1406;
  box-shadow: 0 0 8px rgba(255, 110, 30, 0.8);
}

.floor-pick-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #ffe0a0, #e07020 60%, #7a2a08);
  border: 2px solid #2a1406;
  box-shadow: 0 0 8px rgba(255, 110, 30, 0.8);
}

.floor-pick-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #9a8060;
  margin-top: -4px;
}

.floor-pick-desc {
  min-height: 72px;
}

.floor-pick-desc p,
.floor-pick-note {
  margin: 4px 0;
}

/* the member's level beside the name in the party list */
.pr-lvl {
  flex-shrink: 0;
  font: 700 9.5px var(--font-head);
  color: #e8c890;
  letter-spacing: .3px;
  margin-right: auto;
  padding-left: 4px;
}

/* ------------------------------------------------ Portrait Orientation Panel Stacking */
/* Stack panels vertically, splitting 50/50 top/bottom when multiple are open (shop + inventory, etc.) */
@media (orientation: portrait) {
  #panels {
    position: absolute !important;
    left: 0 !important;
    right: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    padding: 6px !important;
    gap: 6px !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    pointer-events: none !important;
    z-index: 30 !important;
  }

  #panels>.panel,
  body.touch .vendor-panel,
  body.touch .stash-panel,
  body.touch .reliquary-panel,
  body:not(.touch) .vendor-panel,
  body:not(.touch) .stash-panel,
  body:not(.touch) .reliquary-panel,
  body:not(.touch) .panel[data-panel="inventory"] {
    position: relative !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    pointer-events: auto !important;
    display: flex !important;
    flex-direction: column !important;
  }

  /* Single panel in portrait: full height */
  #panels:not(.multi-panel):not(:has(> .panel:nth-child(2)))>.panel {
    flex: 0 1 auto !important;
    max-height: 100% !important;
  }

  /* Multiple panels in portrait (e.g. shop + inventory): 50/50 top/bottom split */
  #panels.multi-panel>.panel,
  #panels:has(> .panel:nth-child(2))>.panel {
    flex: 1 1 50% !important;
    height: calc(50% - 3px) !important;
    max-height: calc(50% - 3px) !important;
    min-height: 0 !important;
  }

  #panels>.panel .panel-head {
    flex-shrink: 0 !important;
  }

  #panels>.panel .panel-body {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .inv-wrap {
    flex-direction: column !important;
    align-items: center !important;
    gap: 8px !important;
  }

  .bag {
    grid-template-columns: repeat(6, clamp(36px, calc((100vw - 52px) / 6), 46px)) !important;
    grid-auto-rows: clamp(36px, calc((100vw - 52px) / 6), 46px) !important;
    justify-content: center !important;
  }

  #panels>.panel[data-panel="character"],
  #panels>.character-panel {
    order: 1 !important;
  }

  #panels>.panel[data-panel="inventory"],
  #panels>.inventory-panel {
    order: 2 !important;
  }
}

body.portrait #panels>.panel[data-panel="character"],
body.portrait #panels>.character-panel {
  order: 1 !important;
}

body.portrait #panels>.panel[data-panel="inventory"],
body.portrait #panels>.inventory-panel {
  order: 2 !important;
}

body.portrait #panels {
  position: absolute !important;
  left: 0 !important;
  right: 0 !important;
  top: 0 !important;
  bottom: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  padding: 6px !important;
  gap: 6px !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  pointer-events: none !important;
  z-index: 30 !important;
}

body.portrait #panels>.panel,
body.portrait.touch .vendor-panel,
body.portrait.touch .stash-panel,
body.portrait.touch .reliquary-panel,
body.portrait:not(.touch) .vendor-panel,
body.portrait:not(.touch) .stash-panel,
body.portrait:not(.touch) .reliquary-panel,
body.portrait:not(.touch) .panel[data-panel="inventory"] {
  position: relative !important;
  left: 0 !important;
  top: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  margin: 0 !important;
  pointer-events: auto !important;
  display: flex !important;
  flex-direction: column !important;
}

body.portrait #panels:not(.multi-panel):not(:has(> .panel:nth-child(2)))>.panel {
  flex: 0 1 auto !important;
  max-height: 100% !important;
}

body.portrait #panels.multi-panel>.panel,
body.portrait #panels:has(> .panel:nth-child(2))>.panel {
  flex: 1 1 50% !important;
  height: calc(50% - 3px) !important;
  max-height: calc(50% - 3px) !important;
  min-height: 0 !important;
}

body.portrait #panels>.panel .panel-head {
  flex-shrink: 0 !important;
}

body.portrait #panels>.panel .panel-body {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

body.portrait .inv-wrap {
  flex-direction: column !important;
  align-items: center !important;
  gap: 8px !important;
}

body.portrait .inv-bag {
  width: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
}

body.portrait .bag {
  grid-template-columns: repeat(6, clamp(36px, calc((100vw - 52px) / 6), 46px)) !important;
  grid-auto-rows: clamp(36px, calc((100vw - 52px) / 6), 46px) !important;
  justify-content: center !important;
}



/* ------------------------------------------------ Portrait Orientation Panel Stacking */
/* Stack panels vertically, splitting 50/50 top/bottom when multiple are open (shop + inventory, etc.) */
@media (orientation: portrait) {
  #panels {
    position: absolute !important;
    left: 0 !important;
    right: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    padding: 6px !important;
    gap: 6px !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    pointer-events: none !important;
    z-index: 30 !important;
  }

  #panels>.panel,
  body.touch .vendor-panel,
  body.touch .stash-panel,
  body.touch .reliquary-panel,
  body:not(.touch) .vendor-panel,
  body:not(.touch) .stash-panel,
  body:not(.touch) .reliquary-panel,
  body:not(.touch) .panel[data-panel="inventory"] {
    position: relative !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    pointer-events: auto !important;
    display: flex !important;
    flex-direction: column !important;
  }

  /* Single panel in portrait: full height */
  #panels:not(.multi-panel):not(:has(> .panel:nth-child(2)))>.panel {
    flex: 0 1 auto !important;
    max-height: 100% !important;
  }

  /* Multiple panels in portrait (e.g. shop + inventory): 50/50 top/bottom split */
  #panels.multi-panel>.panel,
  #panels:has(> .panel:nth-child(2))>.panel {
    flex: 1 1 50% !important;
    height: calc(50% - 3px) !important;
    max-height: calc(50% - 3px) !important;
    min-height: 0 !important;
  }

  #panels>.panel .panel-head {
    flex-shrink: 0 !important;
  }

  #panels>.panel .panel-body {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .inv-wrap {
    flex-direction: column !important;
    align-items: center !important;
    gap: 8px !important;
  }

  .bag {
    grid-template-columns: repeat(6, clamp(36px, calc((100vw - 52px) / 6), 46px)) !important;
    grid-auto-rows: clamp(36px, calc((100vw - 52px) / 6), 46px) !important;
    justify-content: center !important;
  }

  #panels>.panel[data-panel="character"],
  #panels>.character-panel {
    order: 1 !important;
  }

  #panels>.panel[data-panel="inventory"],
  #panels>.inventory-panel {
    order: 2 !important;
  }
}

body.portrait #panels>.panel[data-panel="character"],
body.portrait #panels>.character-panel {
  order: 1 !important;
}

body.portrait #panels>.panel[data-panel="inventory"],
body.portrait #panels>.inventory-panel {
  order: 2 !important;
}

body.portrait #panels {
  position: absolute !important;
  left: 0 !important;
  right: 0 !important;
  top: 0 !important;
  bottom: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  padding: 6px !important;
  gap: 6px !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  pointer-events: none !important;
  z-index: 30 !important;
}

body.portrait #panels>.panel,
body.portrait.touch .vendor-panel,
body.portrait.touch .stash-panel,
body.portrait.touch .reliquary-panel,
body.portrait:not(.touch) .vendor-panel,
body.portrait:not(.touch) .stash-panel,
body.portrait:not(.touch) .reliquary-panel,
body.portrait:not(.touch) .panel[data-panel="inventory"] {
  position: relative !important;
  left: 0 !important;
  top: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  margin: 0 !important;
  pointer-events: auto !important;
  display: flex !important;
  flex-direction: column !important;
}

body.portrait #panels:not(.multi-panel):not(:has(> .panel:nth-child(2)))>.panel {
  flex: 0 1 auto !important;
  max-height: 100% !important;
}

body.portrait #panels.multi-panel>.panel,
body.portrait #panels:has(> .panel:nth-child(2))>.panel {
  flex: 1 1 50% !important;
  height: calc(50% - 3px) !important;
  max-height: calc(50% - 3px) !important;
  min-height: 0 !important;
}

body.portrait #panels>.panel .panel-head {
  flex-shrink: 0 !important;
}

body.portrait #panels>.panel .panel-body {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

body.portrait .inv-wrap {
  flex-direction: column !important;
  align-items: center !important;
  gap: 8px !important;
}

body.portrait .inv-bag {
  width: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
}

body.portrait .bag {
  grid-template-columns: repeat(6, clamp(36px, calc((100vw - 52px) / 6), 46px)) !important;
  grid-auto-rows: clamp(36px, calc((100vw - 52px) / 6), 46px) !important;
  justify-content: center !important;
}

/* ------------------------------------------------------------------ Photosensitive Epilepsy & Seizure Warning Splash */
.seizure-warning-splash {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 2, 6, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 20px;
  opacity: 1;
  transition: opacity 0.28s ease;
  user-select: none;
  -webkit-user-select: none;
  overflow-y: auto; /* a landscape phone is shorter than the card */
}

.seizure-warning-splash.fading {
  opacity: 0;
  pointer-events: none;
}

.seizure-warning-card {
  max-width: 620px;
  width: 100%;
  background: rgba(14, 12, 18, 0.97);
  border: 1px solid rgba(220, 160, 40, 0.38);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.85), 0 0 32px rgba(220, 160, 40, 0.12);
  border-radius: 8px;
  padding: 26px 28px;
  margin: auto; /* centred, but scrolls from its top when taller than the screen */
  text-align: center;
  box-sizing: border-box;
}

.seizure-warning-icon {
  font-size: 32px;
  line-height: 1;
  margin-bottom: 8px;
  filter: drop-shadow(0 0 12px rgba(240, 192, 64, 0.5));
}

.seizure-warning-title {
  margin: 0 0 4px;
  font: 700 15px var(--font-head);
  letter-spacing: 2px;
  color: #f0c040;
  text-transform: uppercase;
}

.seizure-warning-subtitle {
  margin: 0 0 16px;
  font: 600 12px var(--font-head);
  letter-spacing: 1.5px;
  color: #e05040;
  text-transform: uppercase;
}

.seizure-warning-body {
  font: 400 13px/1.55 var(--font-body, system-ui, sans-serif);
  color: #cfc8be;
  text-align: left;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 14px 4px;
  margin-bottom: 16px;
}

.seizure-warning-body p {
  margin: 0 0 10px;
}

.seizure-warning-body p:last-child {
  margin-bottom: 0;
}

.seizure-warning-advisory {
  text-align: center !important;
  color: #fff0d0 !important;
  font-weight: 700;
  letter-spacing: 1.5px;
  margin-top: 14px !important;
  font-size: 13.5px;
}

.seizure-warning-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin: 14px 0 18px;
}

.seizure-warning-hint {
  font: 400 11.5px var(--font-body, system-ui, sans-serif);
  color: #8f877c;
}

.seizure-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  font: 500 12.5px var(--font-body, system-ui, sans-serif);
  color: #e8e0d4;
  transition: background 0.15s, border-color 0.15s;
}

.seizure-toggle-label:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(240, 192, 64, 0.4);
}

.seizure-toggle-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #f0c040;
}

.seizure-warning-prompt {
  font: 600 13px var(--font-head);
  letter-spacing: 3px;
  color: #f0a040;
  text-transform: uppercase;
  cursor: pointer;
  animation: seizurePromptPulse 2s ease-in-out infinite;
}

@keyframes seizurePromptPulse {

  0%,
  100% {
    opacity: 0.55;
    transform: scale(0.99);
  }

  50% {
    opacity: 1;
    transform: scale(1.01);
    text-shadow: 0 0 12px rgba(240, 160, 64, 0.6);
  }
}

@media (max-width: 600px) {
  .seizure-warning-card {
    padding: 18px 16px;
  }

  .seizure-warning-title {
    font-size: 13px;
    letter-spacing: 1px;
  }

  .seizure-warning-subtitle {
    font-size: 11px;
  }

  .seizure-warning-body {
    font-size: 12px;
    line-height: 1.45;
  }

  .seizure-warning-prompt {
    font-size: 11.5px;
  }
}

/* ==========================================================================
   Player Context Menu (Town Interaction: Friend, Trade, Mute, Duel)
   ========================================================================== */
.player-context-menu {
  position: fixed;
  z-index: 10000;
  min-width: 170px;
  background: rgba(16, 11, 8, 0.96);
  border: 1px solid rgba(180, 140, 70, 0.45);
  border-radius: 4px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.85), 0 0 1px 1px rgba(255, 215, 120, 0.15) inset;
  padding: 6px 0;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  font-family: var(--font-body);
  user-select: none;
  animation: pcmFadeIn 0.12s ease-out;
}

@keyframes pcmFadeIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(-2px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.pcm-header {
  padding: 6px 12px 4px 12px;
  border-bottom: 1px solid rgba(160, 120, 60, 0.2);
  margin-bottom: 4px;
}

.pcm-name {
  font-family: var(--font-head);
  font-size: 13.5px;
  font-weight: 700;
  color: #ffd860;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pcm-sub {
  font-size: 11px;
  color: #b5a489;
  margin-top: 1px;
}

.pcm-divider {
  height: 1px;
  background: rgba(160, 120, 60, 0.2);
  margin: 3px 6px;
}

.pcm-actions {
  display: flex;
  flex-direction: column;
}

.pcm-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 14px;
  background: transparent;
  border: none;
  color: #e5d8c3;
  font-family: var(--font-body);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s ease, color 0.1s ease, transform 0.08s ease;
}

.pcm-item:hover {
  background: rgba(190, 145, 65, 0.22);
  color: #ffffff;
  padding-left: 17px;
}

.pcm-item:active {
  background: rgba(190, 145, 65, 0.35);
  transform: translateX(1px);
}

.pcm-item-duel:hover {
  background: rgba(200, 45, 30, 0.28);
  color: #ffb0a0;
}

.pcm-icon {
  font-size: 13px;
  width: 16px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

.pcm-label {
  flex: 1;
  font-weight: 500;
}

/* ==========================================================================
   Trade Prompt Banner & Trade Panel Styles
   ========================================================================== */
.trade-prompt-banner {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10001;
  background: rgba(18, 12, 8, 0.96);
  border: 1px solid rgba(220, 175, 75, 0.7);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.9), 0 0 14px rgba(220, 175, 75, 0.25);
  border-radius: 6px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  animation: tpbSlideDown 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes tpbSlideDown {
  from {
    opacity: 0;
    transform: translate(-50%, -15px);
  }

  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.tpb-content {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: #eeddc5;
}

.tpb-icon {
  font-size: 18px;
}

.tpb-actions {
  display: flex;
  gap: 8px;
}

.tpb-accept {
  background: linear-gradient(180deg, #3d7a38 0%, #1f471c 100%) !important;
  border-color: #55b54d !important;
  color: #ffffff !important;
}

.tpb-accept:hover {
  background: linear-gradient(180deg, #4f964a 0%, #295c25 100%) !important;
}

.tpb-decline {
  background: linear-gradient(180deg, #7a2824 0%, #471512 100%) !important;
  border-color: #b54540 !important;
  color: #eeddc5 !important;
}

/* Trade Panel */
.trade-panel {
  min-width: 580px;
}

.trade-window-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 6px;
}

.trade-infobar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(10, 7, 5, 0.6);
  border: 1px solid rgba(160, 120, 60, 0.25);
  border-radius: 4px;
  padding: 8px 14px;
}

.trade-side-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.trade-side-info.their-side {
  text-align: right;
  align-items: flex-end;
}

.trade-side-title {
  font-family: var(--font-head);
  font-size: 12px;
  color: #d8c29d;
  letter-spacing: 0.5px;
}

.trade-side-status {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.trade-side-status.status-pending {
  color: #e09838;
}

.trade-side-status.status-locked {
  color: #4fd65a;
  text-shadow: 0 0 6px rgba(79, 214, 90, 0.5);
}

.trade-vs-badge {
  font-size: 18px;
  color: #ffd860;
  opacity: 0.7;
}

.trade-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.trade-col {
  background: rgba(14, 9, 6, 0.7);
  border: 1px solid rgba(160, 120, 60, 0.3);
  border-radius: 4px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.trade-col.locked {
  border-color: rgba(79, 214, 90, 0.6);
  box-shadow: 0 0 10px rgba(79, 214, 90, 0.15) inset;
}

.trade-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  justify-items: center;
}

.trade-slot {
  width: 44px;
  height: 44px;
  background: rgba(24, 16, 12, 0.85);
  border: 1px solid rgba(130, 95, 50, 0.4);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.1s ease;
}

.trade-slot:hover {
  border-color: rgba(220, 175, 75, 0.7);
}

.trade-gold-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(8, 6, 4, 0.7);
  border: 1px solid rgba(160, 120, 60, 0.25);
  border-radius: 3px;
  padding: 4px 8px;
}

.trade-gold-row.disabled {
  justify-content: flex-start;
}

.trade-gold-input {
  flex: 1;
  background: transparent;
  border: none;
  color: #ffd860;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 13px;
  padding: 2px 4px;
}

.trade-gold-input:focus {
  outline: none;
}

.trade-partner-gold {
  color: #ffd860;
  font-weight: 700;
  font-size: 13px;
}

.trade-action-row {
  display: flex;
  margin-top: 2px;
}

.trade-accept-btn {
  width: 100%;
  font-family: var(--font-head) !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  letter-spacing: 0.5px !important;
  padding: 8px 12px !important;
  background: linear-gradient(180deg, #44321c 0%, #24190c 100%) !important;
  border-color: rgba(210, 165, 75, 0.6) !important;
  color: #eeddc5 !important;
  transition: all 0.15s ease !important;
}

.trade-accept-btn:hover {
  background: linear-gradient(180deg, #594124 0%, #31210f 100%) !important;
  color: #ffffff !important;
}

.trade-accept-btn.active {
  background: linear-gradient(180deg, #3d7a38 0%, #1f471c 100%) !important;
  border-color: #55b54d !important;
  color: #ffffff !important;
  box-shadow: 0 0 10px rgba(85, 181, 77, 0.4) !important;
}

.trade-partner-status-box {
  width: 100%;
  text-align: center;
  padding: 7px 10px;
  border-radius: 3px;
  font-family: var(--font-head);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  user-select: none;
}

.trade-partner-status-box.waiting {
  background: rgba(14, 10, 8, 0.7);
  border: 1px dashed rgba(160, 120, 60, 0.35);
  color: #a89578;
}

.trade-partner-status-box.accepted {
  background: rgba(25, 60, 24, 0.8);
  border: 1px solid #55b54d;
  color: #7aff82;
  box-shadow: 0 0 8px rgba(85, 181, 77, 0.3);
}

.trade-security-note {
  text-align: center;
  font-size: 11px;
  color: #9f8d75;
  margin-top: 4px;
}

/* ==========================================================================
   Duel Prompt Banner & Center Display Styles
   ========================================================================== */
.duel-prompt-banner {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10001;
  background: rgba(22, 10, 8, 0.96);
  border: 1px solid rgba(220, 60, 45, 0.7);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.9), 0 0 16px rgba(220, 60, 45, 0.35);
  border-radius: 6px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  animation: dpbSlideDown 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes dpbSlideDown {
  from {
    opacity: 0;
    transform: translate(-50%, -15px);
  }

  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.dpb-content {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: #eeddc5;
}

.dpb-icon {
  font-size: 18px;
}

.dpb-actions {
  display: flex;
  gap: 8px;
}

.dpb-accept {
  background: linear-gradient(180deg, #99281f 0%, #52150f 100%) !important;
  border-color: #dd483b !important;
  color: #ffffff !important;
}

.dpb-accept:hover {
  background: linear-gradient(180deg, #b83227 0%, #691b14 100%) !important;
}

.dpb-decline {
  background: linear-gradient(180deg, #443328 0%, #241a14 100%) !important;
  border-color: #775c44 !important;
  color: #eeddc5 !important;
}

.duel-center-banner {
  position: fixed;
  top: 28%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10002;
  font-family: var(--font-head);
  font-size: 42px;
  font-weight: 900;
  letter-spacing: 3px;
  text-shadow: 0 0 20px rgba(0, 0, 0, 0.9), 0 0 12px currentColor;
  pointer-events: none;
  user-select: none;
}

.duel-center-banner.fade {
  animation: duelBannerPulse 0.4s ease-out;
}

@keyframes duelBannerPulse {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.7);
  }

  60% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
  }

  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.0);
  }
}

/* Tessariel's Keep (ui/keep.js): the Castellan's panel */
.keep-panel .panel-head h2 { color: #d8f090; }
.kp-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 6px 8px; margin-bottom: 8px; border: 1px solid #4a5a28; border-radius: 6px; background: linear-gradient(180deg, rgba(40,52,20,.55), rgba(16,14,8,.6)); }
.kp-embers { display: flex; flex-direction: column; min-width: 110px; }
.kp-embers span, .kp-renown span { font: 600 11px var(--font-head, Cinzel, serif); color: #c8c09a; letter-spacing: .04em; }
.kp-ember { color: #c8f060; font: 700 20px var(--font-head, Cinzel, serif); text-shadow: 0 0 8px rgba(160,240,80,.45); }
.kp-renown { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 2px; }
.kp-renown small { color: #a8a080; font-size: 11px; }
.kp-claim { animation: kpPulse 1.6s ease-in-out infinite; }
@keyframes kpPulse { 50% { box-shadow: 0 0 14px rgba(200,240,96,.7); } }
.kp-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.kp-tab { background: rgba(30,24,14,.8); border: 1px solid #4a3a20; color: var(--text-dim); border-radius: 4px; padding: 5px 9px; font: 600 12px var(--font-head, Cinzel, serif); cursor: pointer; }
.kp-tab.on { color: #1a1406; background: linear-gradient(180deg, #e8d48a, #b8973e); border-color: #f0e0a0; }
.kp-note { font-size: 12px; color: var(--text-dim); margin: 2px 0 8px; line-height: 1.35; }
.kp-row { position: relative; padding: 7px 9px; margin-bottom: 6px; border: 1px solid #3a2e1a; border-left: 3px solid var(--kc, #8a7040); border-radius: 5px; background: rgba(24,18,10,.72); }
.kp-row.slim { padding: 4px 8px; margin-bottom: 4px; }
.kp-row.done { opacity: .62; }
.kp-row.locked { filter: grayscale(.8); opacity: .55; }
.kp-row > .btn { position: absolute; right: 8px; top: 7px; }
.kp-title { font-size: 13px; padding-right: 92px; }
.kp-row.slim .kp-title { padding-right: 0; font-size: 12px; }
.kp-text { font-size: 12px; color: var(--text); margin: 3px 0; }
.kp-prize { color: #ffe0a0; font-size: 11px; padding: 0 5px; border: 1px solid #6a5426; border-radius: 3px; background: rgba(80,60,20,.4); white-space: nowrap; }
.kp-pay { font-size: 11px; }
.kp-pay .kp-ember, .kp-note .kp-ember, .kp-tcost .kp-ember { font-size: 13px; }
.kp-bar { position: relative; height: 12px; margin-top: 3px; border: 1px solid #3a3020; border-radius: 3px; background: #120e08; overflow: hidden; }
.kp-bar > div { height: 100%; opacity: .75; }
.kp-bar > span { position: absolute; inset: 0; text-align: center; font: 600 9px/12px "Alegreya Sans", sans-serif; color: #fff; text-shadow: 0 0 2px #000; }
.kp-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.kp-chip { background: rgba(30,24,14,.8); border: 1px solid #4a3a20; color: var(--text); border-radius: 12px; padding: 3px 9px; font-size: 12px; cursor: pointer; }
.kp-chip i { color: var(--text-dim); font-style: normal; font-size: 11px; }
.kp-chip.on { border-color: #c8f060; color: #d8f090; }
.kp-trade { display: flex; flex-direction: column; gap: 6px; }
.kp-trow { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 6px 8px; border: 1px solid #3a2e1a; border-radius: 5px; background: rgba(24,18,10,.72); }
.kp-tname { font: 700 13px var(--font-head, Cinzel, serif); min-width: 86px; }
.kp-tcost { min-width: 54px; }
.kp-vault { display: flex; flex-wrap: wrap; gap: 10px; }
.kp-vcell { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; border: 1px solid #6a5426; border-radius: 6px; background: rgba(40,30,12,.6); }
.kp-vcell .itemicon { width: 56px; height: 56px; }
.kp-slots { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.kp-slot { width: 40px; height: 50px; padding: 2px; border: 1px solid #4a3a20; border-radius: 4px; background: #14100a; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.kp-slot.on { border-color: #c8f060; box-shadow: 0 0 6px rgba(200,240,96,.5); }
.kp-empty { color: #6a5a40; font-size: 12px; }
.kp-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; }
.kp-choice { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px; border: 1px solid #4a3a20; border-radius: 5px; background: rgba(24,18,10,.8); color: var(--text); font-size: 11px; cursor: pointer; text-align: center; }
.kp-choice b { font-size: 11px; }
.kp-choice small { color: var(--text-dim); font-size: 10px; }
.kp-choice.on { border-color: #c8f060; }
.kp-choice.locked { opacity: .5; cursor: default; }
.kp-choice.locked canvas { filter: grayscale(1) brightness(.6); }
.kp-chron { overflow-x: auto; }
.kp-chron table { width: 100%; border-collapse: collapse; font-size: 12px; }
.kp-chron th { font: 600 11px var(--font-head, Cinzel, serif); color: #c8c09a; text-align: left; border-bottom: 1px solid var(--line); padding: 3px 4px; }
.kp-chron td { padding: 4px; border-bottom: 1px solid #2a2014; }
.kp-chron tr.me td { background: rgba(80,100,30,.18); }
.kp-records { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 6px; margin-top: 10px; }
.kp-records > div { display: flex; flex-direction: column; padding: 6px 8px; border: 1px solid #5a4a26; border-radius: 5px; background: rgba(40,30,12,.5); }
.kp-records span { font-size: 11px; color: var(--text-dim); }
.kp-records b { font: 700 15px var(--font-head, Cinzel, serif); color: #ffe0a0; }
.kp-records i { font-size: 11px; color: #c8c0a0; font-style: normal; }
.kp-exps { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.kp-exps i { font-style: normal; color: var(--text-dim); font-size: 10px; }
.q-keep { font-size: 12px; margin: 2px 0 6px; padding: 4px 6px; border-left: 2px solid #c8f060; background: rgba(60,80,20,.2); }
@media (max-width: 600px) { .kp-title { padding-right: 0; } .kp-row > .btn { position: static; margin-top: 4px; } .kp-tab { padding: 4px 6px; font-size: 11px; } }
body.in-keep #velscour-skull { display: none !important; }

/* Tessariel's Keep's panel: grouped tabs with badges, chapter pips, the trade's worn-gear line */
.kp-tabs { gap: 4px 14px; }
.kp-tabgroup { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.kp-tabhead { font: 600 9px var(--font-head, Cinzel, serif); letter-spacing: .12em; text-transform: uppercase; color: #8a8262; margin-right: 2px; }
.kp-tab { position: relative; }
.kp-badge { position: absolute; top: -6px; right: -5px; min-width: 15px; height: 15px; padding: 0 3px; border-radius: 8px; background: #c8f060; color: #1a2006; font: 700 10px/15px "Alegreya Sans", sans-serif; text-align: center; font-style: normal; box-shadow: 0 0 6px rgba(200,240,96,.7); }
.kp-pips { display: flex; gap: 3px; margin-top: 5px; }
.kp-pips i { width: 9px; height: 9px; transform: rotate(45deg); border: 1px solid #5a4a28; background: #16110a; }
.kp-pips i.done { background: var(--kc, #c8a050); border-color: var(--kc, #c8a050); }
.kp-pips i.now { border-color: #f0e0a0; box-shadow: 0 0 5px rgba(240,224,160,.8); animation: kpPulse 1.6s ease-in-out infinite; }
.kp-pips i.prize { border-radius: 50%; transform: none; border-color: #ffe0a0; }
.kp-pay { color: #a8a080; white-space: nowrap; }
.kp-tbtn { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.1; padding-top: 4px; padding-bottom: 4px; }
.kp-tbtn small { font: 600 9px "Alegreya Sans", sans-serif; letter-spacing: 0; text-transform: none; opacity: .95; }
.kp-tbtn.up { box-shadow: inset 0 0 0 1px rgba(200,240,96,.55), 0 0 6px rgba(200,240,96,.25); }
@media (max-height: 480px), (max-width: 620px) {
  .keep-panel .kp-head { padding: 3px 6px; margin-bottom: 4px; gap: 6px; }
  .keep-panel .kp-embers { flex-direction: row; align-items: baseline; gap: 6px; min-width: 0; }
  .keep-panel .kp-ember { font-size: 15px; }
  .keep-panel .kp-renown small { display: none; }
  .keep-panel .kp-tabhead { display: none; }
  .keep-panel .kp-tabs { gap: 3px 8px; margin-bottom: 4px; padding-bottom: 4px; }
  .keep-panel .kp-tab { padding: 4px 7px; font-size: 11px; }
  .keep-panel .kp-note { font-size: 11px; margin-bottom: 5px; }
}
.kp-title .kp-ember { font-size: 13px; }

/* Reliquary Account-Wide Gold Transfers */
.reliquary-panel .rel-gold-transfer { margin: 0 0 8px; padding: 7px 8px; border: 1px solid #604822; border-radius: 5px; background: linear-gradient(110deg, rgba(74,48,20,.34), rgba(20,14,9,.7)); }
.reliquary-panel .rel-gold-balances { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 6px; color: #c8b89d; font-size: 12px; }
.reliquary-panel .rel-gold-balances b { color: #ffd860; font-variant-numeric: tabular-nums; }
.reliquary-panel .rel-gold-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.reliquary-panel .rel-gold-amount { flex: 1 1 82px; width: 100px; min-width: 72px; box-sizing: border-box; padding: 5px 7px; border: 1px solid #80603a; border-radius: 4px; background: #1c140f; color: #f0dfbf; font: 13px var(--font-body); }
.reliquary-panel .rel-gold-controls .btn { flex: 0 0 auto; }
.reliquary-panel .rel-gold-controls .btn:disabled { opacity: .45; cursor: default; }

/* Altar of Heresy 3-column desktop grid */
@media (min-width: 860px) {
  .heresy-panel .hx-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
body.touch .hx-sw { width: 50px; height: 28px; border-radius: 14px; }
body.touch .hx-sw::after { width: 22px; height: 22px; top: 2px; left: 2px; }
body.touch .hx-row input:checked + .hx-sw::after { left: 24px; }
body.touch .hx-name { font-size: 15px; }
body.touch .hx-desc { font-size: 13px; }
body.touch .hx-foot { flex-direction: column; align-items: stretch; }
body.touch .hx-chips { grid-template-columns: repeat(2, minmax(0, 1fr)); }
body.touch .hx-clear { min-height: 40px; }
body.touch .hx-doors { grid-template-columns: 1fr; }
body.touch .hx-door { min-height: 48px; }
.marks-panel { resize: both; min-width: min(620px, 96vw); min-height: min(500px, 82vh); overflow: hidden; }
.heresy-panel { min-width: 0; overflow: hidden; }
.heresy-panel .panel-body { overflow-x: hidden; overflow-y: auto; }
.marks-panel .panel-body { display: flex; flex: 1 1 auto; flex-direction: column; gap: 8px; min-height: 0; overflow: hidden; padding: 10px; }
.mk-shell { outline: none; }
.mk-head { flex: 0 0 auto; }
.mk-summary { display: grid; grid-template-columns: minmax(210px, auto) minmax(0, 1fr); gap: 12px; align-items: center; }
.mk-tot { display: flex; flex-wrap: wrap; align-items: baseline; gap: 5px 8px; color: #d8b090; font: 700 12px var(--font-head); }
.mk-tot b { font-size: 25px; color: #ff9050; text-shadow: 0 0 8px rgba(255,100,40,.5); }
.mk-tot small { margin-left: auto; color: #ffd860; font: 700 12px var(--font-body); }
.mk-xp { position: relative; height: 19px; background: #0d0806; border: 1px solid #4a2a1a; border-radius: 3px; overflow: hidden; }
.mk-xp i { display: block; height: 100%; background: linear-gradient(#ffb070, #d0401a 60%, #5a1004); }
.mk-xp span { position: absolute; inset: 0; text-align: center; font: 700 10px/17px var(--font-head); color: #ffe0c0; text-shadow: 0 0 3px #000, 0 0 3px #000; white-space: nowrap; }
.mk-why { margin-top: 4px; color: #a99780; font-size: 11px; }
.mk-nav { display: flex; flex: 0 0 auto; align-items: stretch; gap: 4px; border-bottom: 1px solid #77502b; padding-bottom: 5px; }
.mk-nav-arrow { flex: 0 0 32px; font-size: 20px; line-height: 1; padding: 2px; }
.mk-tab { display: flex; flex: 1 1 0; min-width: 0; align-items: center; justify-content: center; gap: 6px; padding: 7px 4px; color: #b7a58a; background: linear-gradient(#1c120c, #110a07); border: 1px solid #4a321e; border-bottom: 2px solid transparent; border-radius: 4px 4px 0 0; font: 700 11px var(--font-head); cursor: pointer; }
.mk-tab span { color: #ddb866; font-size: 16px; }
.mk-tab:hover, .mk-tab.active { color: #ffe08c; background: linear-gradient(#382411, #211307); border-color: #9a6d32; border-bottom-color: #ffd860; text-shadow: 0 0 6px rgba(255,216,96,.35); }
.mk-work { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(270px, .85fr); gap: 10px; flex: 1 1 auto; min-height: 0; }
.mk-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; gap: 6px; min-height: 0; overflow-y: auto; padding-right: 4px; scrollbar-color: #72502e #130d09; }
.mk-card { display: flex; min-width: 0; min-height: 69px; align-items: center; gap: 8px; padding: 7px; color: #d8c6a6; text-align: left; background: linear-gradient(140deg, rgba(50,31,19,.82), rgba(15,9,6,.96)); border: 1px solid #55402b; border-left: 3px solid #766044; border-radius: 4px; cursor: pointer; }
.mk-card:hover { border-color: #a17a3f; background: linear-gradient(140deg, rgba(76,48,25,.9), rgba(21,12,7,.98)); }
.mk-card.selected { border-color: #d9aa53; border-left-color: #ffd860; box-shadow: inset 0 0 10px rgba(230,177,74,.14), 0 0 7px rgba(255,202,92,.18); }
.mk-card.maxed { border-left-color: #73a779; }
.mk-icon { flex: 0 0 auto; width: 42px; height: 42px; object-fit: contain; filter: drop-shadow(0 2px 3px #000); }
.mk-icon-glyph { display: grid; flex: 0 0 42px; width: 42px; height: 42px; place-items: center; color: #e8bd68; font-size: 27px; text-shadow: 0 1px 5px #000; }
.mk-card-main { display: flex; flex: 1 1 auto; min-width: 0; flex-direction: column; gap: 2px; }
.mk-card-main b { overflow: hidden; color: #f0d29a; font: 700 15px var(--font-head); text-overflow: ellipsis; white-space: nowrap; }
.mk-card-main small { color: #ae9b7e; font: 12px var(--font-body); }
.mk-card-main small:last-child { color: #e7c36d; }
.mk-rank-indicator { flex: 0 0 auto; min-width: 54px; padding-left: 4px; color: #ffd56d; text-align: right; white-space: nowrap; font: 700 20px/1 var(--font-head); text-shadow: 0 1px 3px #000; }
.mk-card.maxed .mk-rank-indicator { color: #84d891; }
.mk-detail { display: flex; min-width: 0; flex-direction: column; align-items: stretch; gap: 6px; overflow-y: auto; padding: 10px; border: 1px solid #63472a; border-radius: 5px; background: radial-gradient(ellipse at 50% 0%, rgba(93,59,24,.27), rgba(12,8,6,.9) 58%); }
.mk-detail-icon { display: grid; flex: 0 0 auto; width: 76px; height: 76px; place-items: center; align-self: center; border: 1px solid color-mix(in srgb, var(--mk-color) 55%, #392719); border-radius: 7px; background: radial-gradient(circle, color-mix(in srgb, var(--mk-color) 22%, transparent), rgba(0,0,0,.3)); box-shadow: 0 0 16px color-mix(in srgb, var(--mk-color) 14%, transparent); }
.mk-detail-icon .mk-icon { width: 68px; height: 68px; }
.mk-detail h3 { margin: 0; color: #f0d28e; text-align: center; font: 700 18px var(--font-head); }
.mk-rank { color: #b8a384; text-align: center; font-size: 11px; }
.mk-rank b { color: #ffd56d; }
.mk-desc { margin: 3px 0 6px; color: #c7b69b; font-size: 12px; line-height: 1.45; }
.mk-total { display: flex; justify-content: space-between; gap: 8px; padding: 6px 7px; border: 1px solid rgba(127,94,50,.38); background: rgba(0,0,0,.22); color: #a99576; font-size: 11px; }
.mk-total b { color: #eed08b; text-align: right; }
.mk-next-total b { color: #9ee2ac; }
.mk-gain { color: #95cb9a; text-align: right; font-size: 10px; }
.mk-max { padding: 8px; color: #91d49b; border: 1px solid #44684a; background: rgba(30,75,39,.2); text-align: center; font: 700 12px var(--font-head); }
.mk-buy-qty { display: flex; justify-content: space-between; gap: 4px; align-items: center; margin-top: auto; color: #b8a384; font-size: 11px; }
.mk-buy-qty .btn { min-width: 34px; padding: 5px; }
.mk-buy-qty .btn.active { border-color: #ffd860; color: #ffe18d; box-shadow: 0 0 6px rgba(255,216,96,.2); }
.mk-price { min-height: 18px; color: #b8a384; text-align: center; font-size: 11px; }
.mk-price b { color: #ffd860; }
.mk-purchase { width: 100%; min-height: 36px; }
.mk-purchase:disabled { opacity: .45; cursor: not-allowed; }
.mk-refund { display: flex; flex: 0 0 auto; flex-direction: column; gap: 5px; margin-top: 4px; padding-top: 8px; border-top: 1px solid rgba(128,94,53,.55); }
.mk-refund-title { color: #d7c094; font: 700 12px var(--font-head); letter-spacing: .5px; text-transform: uppercase; }
.mk-refund-qty { display: flex; justify-content: flex-end; gap: 5px; }
.mk-refund-qty .btn { min-width: 38px; padding: 4px 7px; }
.mk-refund-qty .btn.active { border-color: #ffd860; color: #ffe18d; }
.mk-refund-total { color: #b8a384; text-align: right; font-size: 12px; }
.mk-refund-total b { color: #ffd860; }
.mk-refund-button { width: 100%; }
.mk-refund-button:disabled { opacity: .45; cursor: not-allowed; }
.mk-foot { display: flex; flex: 0 0 auto; flex-wrap: wrap; align-items: center; gap: 7px; border-top: 1px solid rgba(128,94,53,.45); padding-top: 7px; }
.mk-foot-note { margin-left: auto; font-size: 10px; }
@media (max-width: 760px) {
  .marks-panel { min-width: 0; resize: none; width: 96vw !important; height: min(88vh, 760px) !important; }
  .mk-summary { grid-template-columns: 1fr; gap: 6px; }
  .mk-nav { overflow-x: auto; }
  .mk-tab { flex: 0 0 auto; min-width: 86px; }
  .mk-tab b { font-size: 10px; }
  .mk-work { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(130px, 1fr) minmax(190px, .85fr); }
  .mk-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mk-detail { display: grid; grid-template-columns: 58px 1fr; align-items: center; gap: 5px 8px; }
  .mk-detail-icon { grid-row: span 3; width: 56px; height: 56px; }
  .mk-detail-icon .mk-icon { width: 50px; height: 50px; }
  .mk-detail h3, .mk-rank { text-align: left; }
  .mk-desc, .mk-total, .mk-gain, .mk-buy-qty, .mk-price, .mk-purchase, .mk-max, .mk-refund { grid-column: 1 / -1; }
  .mk-buy-qty { margin-top: 0; }
  .mk-rank-indicator { font-size: 16px; }
  .mk-foot-note { display: none; }
}
/* The Altar and Marks library open as one centered endgame workspace. */
#panels.heresy-marks-pair { bottom: 0; overflow: visible; }
/* Dedicated editor overlay: live HUD remains visible beneath selection outlines. */
.screen.ui-layout-screen { display: block !important; overflow: hidden; background: rgba(0,0,0,.16) !important; pointer-events: none; }
.screen.ui-layout-pause-hidden { display: none !important; }
.ui-layout-dialog { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none !important; max-height: none !important; margin: 0; padding: 0; overflow: visible; border: 0; border-radius: 0; background: transparent; box-shadow: none; text-align: left; pointer-events: none; }
.ui-layout-dialog > h2 { display: none; }
.ui-layout-dialog > .dlg-body { position: absolute; inset: 0; padding: 0; overflow: visible; pointer-events: none; }
.ui-layout-stage { position: absolute; inset: 0; pointer-events: none; }
.ui-layout-item { position: absolute; z-index: 1; display: block; box-sizing: border-box; min-width: 0; min-height: 0; padding: 2px; overflow: visible; border: 1px dashed rgba(207,190,155,.9); border-radius: 3px; background: rgba(42,36,29,.16); color: #eee0c7; font: 700 11px/1.25 var(--font-head); text-align: center; text-shadow: 0 1px 3px #000,0 0 5px #000; touch-action: none; pointer-events: auto; cursor: move; }
.ui-layout-item span { display: inline-block; max-width: 100%; padding: 2px 4px; border-radius: 2px; background: rgba(10,7,5,.76); }
.ui-layout-item.selected { z-index: 2; border: 2px solid #f0c66f; background: rgba(213,168,62,.18); box-shadow: 0 0 9px rgba(255,207,106,.62), inset 0 0 0 1px rgba(0,0,0,.8); }
.ui-layout-item.locked { cursor: default; }
.ui-layout-item.world-positioned { cursor: default; }
.ui-layout-item.placeholder { border-style: dashed; border-color: rgba(184,159,119,.65); background: repeating-linear-gradient(135deg,rgba(33,25,18,.78),rgba(33,25,18,.78) 6px,rgba(70,53,32,.58) 6px,rgba(70,53,32,.58) 12px); }
.ui-layout-resize { position: absolute; right: -5px; bottom: -5px; width: 13px; height: 13px; border: 2px solid #ffe2a0; border-radius: 2px; background: #5a3d1e; box-shadow: 0 1px 4px #000; cursor: nwse-resize; }
.ui-layout-lock-mark { position: absolute; top: 1px; right: 3px; color: #ffe2a0; font-size: 9px; }
.ui-layout-guides { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.ui-layout-guides i { position: absolute; display: block; opacity: .8; }
.ui-layout-guides i.x { left: 0; right: 0; border-top: 1px solid #66d6dc; }
.ui-layout-guides i.y { top: 0; bottom: 0; border-left: 1px solid #66d6dc; }
.ui-layout-toolbox { position: absolute; z-index: 5; top: 50%; left: 50%; right: auto; display: flex; flex-direction: column; gap: 0; width: min(360px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: hidden; border: 1px solid #9b7338; border-radius: 6px; background: linear-gradient(145deg,rgba(27,18,13,.98),rgba(8,6,5,.98)); box-shadow: 0 8px 30px rgba(0,0,0,.88), inset 0 0 0 1px rgba(255,220,155,.08); color: var(--text); font-size: 13px; pointer-events: auto; transform: translate(-50%, -50%); }
.ui-layout-toolbox-content { display: flex; min-height: 0; flex: 1 1 auto; flex-direction: column; gap: 8px; overflow-x: hidden; overflow-y: auto; padding: 12px; overscroll-behavior: contain; }
.ui-layout-toolbox header { position: sticky; top: -12px; z-index: 2; display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; margin: -12px -12px 0; padding: 10px 12px 8px; border-bottom: 1px solid rgba(176,126,49,.45); background: linear-gradient(145deg,rgba(27,18,13,.99),rgba(8,6,5,.99)); color: var(--gold-bright); font: 700 17px var(--font-head); cursor: move; touch-action: none; }
.ui-layout-toolbox header button { width: 25px; height: 25px; border: 1px solid var(--gold-dim); border-radius: 3px; background: #1b110b; color: var(--gold-bright); }
.ui-layout-toolbox label { display: flex; flex-direction: column; gap: 3px; color: #d4c4a6; font-size: 12px; }
.ui-layout-toolbox select, .ui-layout-toolbox input[type=number] { width: 100%; min-height: 28px; border: 1px solid #604724; border-radius: 3px; padding: 4px 6px; background: #100a07; color: #f0dfbb; }
.ui-layout-toolbox input[type=range] { width: 100%; accent-color: #d8b26a; }
.ui-layout-toolbox output { align-self: flex-end; color: #ffe2a0; }
.ui-layout-toolbox .ui-layout-profile-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.ui-layout-toolbox .ui-layout-profile-actions button { flex: 1 1 auto; min-width: 58px; padding: 4px 6px; border: 1px solid #624822; border-radius: 3px; background: #21140c; color: #e4c47c; font: 600 10px var(--font-head); }
.ui-layout-toolbox .ui-layout-profile-actions button:disabled { opacity: .45; }
.ui-layout-toolbox .ui-layout-check { display: flex; flex-direction: row; align-items: center; gap: 7px; }
.ui-layout-toolbox .ui-layout-check input { accent-color: #d8b26a; }
.ui-layout-toolbox .ui-layout-dimensions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.ui-layout-selected { color: #ffe2a0; font: 700 13px var(--font-head); }
.ui-layout-toolbox hr { width: 100%; border: 0; border-top: 1px solid rgba(176,126,49,.35); }
.ui-layout-toolbox small, .ui-layout-world-note { margin: 0; color: #a8977c; font-size: 11px; line-height: 1.35; }
.ui-layout-toolbox-actions { display: flex; flex: 0 0 auto; flex-direction: column; gap: 6px; padding: 8px; border-top: 1px solid rgba(176,126,49,.65); background: rgba(11,7,6,.98); box-shadow: 0 -4px 14px rgba(0,0,0,.45); }
.ui-layout-toolbox-actions-secondary, .ui-layout-toolbox-actions-primary { display: flex; align-items: stretch; justify-content: center; gap: 5px; }
.ui-layout-toolbox-actions button { min-width: 0; padding: 5px 7px; border: 1px solid #624822; border-radius: 4px; background: #21140c; color: #e4c47c; font: 700 10px var(--font-head); cursor: pointer; }
.ui-layout-toolbox-actions-primary button { flex: 1 1 50%; min-height: 34px; font-size: 12px; }
.ui-layout-toolbox-actions-primary .ui-layout-save { border: 2px solid #c69a4f; background: linear-gradient(#583a1c,#241507); color: #ffe2a0; font-weight: 900; }
.ui-layout-toolbox-actions-primary .ui-layout-cancel { border-color: #8a6a45; color: #f3dfbc; }
.ui-layout-toolbox-actions button:disabled { opacity: .45; }
.ui-layout-hidden { display: none !important; }
@media (max-width: 700px) {
  .pause-dialog .row { grid-template-columns: 1fr 1fr; }
  .ui-layout-toolbox { width: min(320px, calc(100vw - 16px)); max-height: calc(100vh - 16px); font-size: 12px; }
  .ui-layout-toolbox-actions { padding: 6px; }
  .ui-layout-toolbox-actions-secondary { flex-wrap: wrap; }
  .ui-layout-toolbox-actions-secondary button { flex: 1 1 38%; }
}
.reliquary-gem-list { display: flex; flex-direction: column; gap: 6px; max-height: min(54vh, 440px); overflow-y: auto; overscroll-behavior: contain; padding: 2px 4px; text-align: left; scrollbar-color: #805d2b rgba(0, 0, 0, .24); }
.reliquary-gem-option { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 8px 10px; text-align: left; }
.reliquary-gem-option > span:first-child { min-width: 0; }
  .audio-volume-row .btn { padding-inline: 5px; }
  .audio-advanced-grid { grid-template-columns: minmax(125px, 1fr) minmax(115px, 1fr); gap: 7px; }
}
.map-opacity-control { display: flex; align-items: center; gap: 8px; min-width: 0; }
.map-opacity-control input[type="range"] { flex: 1; min-width: 80px; }
.map-opacity-control output { min-width: 3.2em; text-align: right; color: #e5c98e; font-variant-numeric: tabular-nums; }
.help-keys { text-align: left; font-size: 14px; columns: 2; column-gap: 24px; }
.help-keys div { break-inside: avoid; margin-bottom: 3px; }
.help-keys kbd { display: inline-block; min-width: 22px; text-align: center; padding: 1px 5px; border: 1px solid var(--gold-dim); border-radius: 3px; background: #1a110b; color: var(--gold-bright); font: 700 12px var(--font-body); }

/* Cursor effects are cosmetic only. The custom pointer is moved directly by pointer events, not the game loop. */
body.custom-mouse-pointer, body.custom-mouse-pointer * { cursor: none !important; }
.mouse-cursor-effects { position: fixed; z-index: 2147483645; inset: 0 auto auto 0; display: none; pointer-events: none !important; user-select: none; }
.mouse-cursor-pointer { position: fixed; z-index: 2147483647; top: 0; left: 0; width: 24px; height: 24px; display: none; overflow: visible; pointer-events: none !important; user-select: none; will-change: transform; }
.mouse-cursor-pointer svg { display: block; overflow: visible; }
.mouse-cursor-highlight { position: fixed; z-index: 2147483646; top: 0; left: 0; display: none; width: 34px; height: 34px; border: 1.5px solid #d8b26a; border-radius: 50%; box-shadow: 0 0 6px currentColor; pointer-events: none !important; user-select: none; will-change: transform; }
.mouse-cursor-pointer.pulsating-glow { animation: cursor-glow-pulse 1.2s ease-in-out infinite alternate; }
@keyframes cursor-glow-pulse { from { filter: drop-shadow(0 0 2px var(--cursor-glow)); } to { filter: drop-shadow(0 0 8px var(--cursor-glow)); } }
@keyframes cursor-hue-cycle { to { filter: hue-rotate(360deg); } }
.cursor-live-preview { display: flex; min-height: 76px; flex-direction: column; align-items: center; justify-content: center; gap: 5px; margin: 0 0 12px; border: 1px dashed rgba(202,160,82,.62); border-radius: 4px; background: radial-gradient(ellipse at center,rgba(95,62,25,.28),rgba(0,0,0,.32)); color: #e8d6b4; text-align: center; pointer-events: auto; }
.cursor-live-preview b { color: var(--gold-bright); font: 700 12px var(--font-head); letter-spacing: .7px; text-transform: uppercase; }
.cursor-live-preview span { color: var(--text-dim); font: 11px var(--font-body); }
.cursor-settings-group { margin: 10px 0 14px; padding: 9px 10px 11px; border: 1px solid rgba(141,103,48,.48); border-radius: 4px; background: rgba(0,0,0,.18); }
.cursor-settings-group h3 { margin: 0 0 9px; color: var(--gold-bright); font: 700 12px var(--font-head); letter-spacing: .8px; text-transform: uppercase; }
.cursor-settings-grid { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(160px, 1.2fr); gap: 7px 12px; align-items: center; text-align: left; }
.cursor-settings-grid input[type="range"] { width: 100%; min-width: 90px; accent-color: #d5a74f; }
.cursor-settings-grid select { width: 100%; min-width: 0; color: #e1d0ad; background: #17100c; border: 1px solid #594329; border-radius: 3px; padding: 4px 6px; }
.cursor-settings-grid input[type="color"] { width: 48px; height: 26px; padding: 2px; border: 1px solid #644a2b; border-radius: 3px; background: #17100c; }
.cursor-settings-grid output { margin-left: 4px; color: #e8c987; font-size: 11px; font-variant-numeric: tabular-nums; }
@media (max-width: 600px) { .cursor-settings-grid { grid-template-columns: minmax(108px, .8fr) minmax(120px, 1fr); gap: 7px; } }

/* ------------------------------------------------------------------- touch */
.settings-dialog { width: min(760px, 94vw); max-width: min(760px, 94vw); }
#boss-bar { --hb-target-width: 1; --hb-target-height: 1; --hb-target-base-height:124px; --hb-target-opacity: 1; --hb-target-offset: 0px; position: absolute; z-index: 3; top: calc(12px + var(--hb-target-offset)); left: 50%; transform: translateX(-50%); width: min(calc(660px * var(--hb-target-width)), 92vw); height: min(calc(var(--hb-target-base-height) * var(--hb-target-height)), 24vh); text-align: center; pointer-events: none; opacity: var(--hb-target-opacity); transition: opacity .12s; }
#boss-bar.hidden { display: none; }
#boss-frame { position: absolute; z-index:2; inset: 0; width:100%;height:100%;pointer-events:none;filter: drop-shadow(0 3px 5px #000); }
#boss-bar.healthbar-boss { --hb-target-base-height:178px;--hb-boss-frame-top:10.1124%;--hb-boss-frame-height:89.8876%;--hb-boss-track-left:23%;--hb-boss-track-right:9%;--hb-boss-track-top:39.7753%;--hb-boss-track-height:11.6854%;--hb-boss-emblem-center-x:14%;--hb-boss-emblem-center-y:45.618%;--hb-boss-emblem-width:13.4%;--hb-boss-emblem-height:55.7303%;--hb-boss-name-left:23%;--hb-boss-name-right:9%;--hb-boss-name-top:.5%;--hb-boss-name-height:9%;--hb-boss-summary-top:73.0337%;--hb-boss-extra-top:84.7191%; }
#boss-bar.healthbar-boss #boss-frame { z-index:3;top:var(--hb-boss-frame-top);height:var(--hb-boss-frame-height); }
#boss-bar.healthbar-boss #boss-emblem { left:calc(var(--hb-boss-emblem-center-x) - var(--hb-boss-emblem-width) / 2);top:var(--hb-boss-emblem-center-y);transform:translateY(-50%);width:var(--hb-boss-emblem-width);height:var(--hb-boss-emblem-height);z-index:4; }
#boss-bar.healthbar-boss #boss-name { left:var(--hb-boss-name-left);right:var(--hb-boss-name-right);top:var(--hb-boss-name-top);height:var(--hb-boss-name-height);display:flex;align-items:center;justify-content:center;white-space:normal;overflow:visible;text-overflow:clip;overflow-wrap:anywhere;line-height:.9;font-size:clamp(10px,1.1vw,15px);z-index:4; }
#boss-bar.healthbar-boss #boss-track { z-index:2;left:var(--hb-boss-track-left);right:var(--hb-boss-track-right);top:var(--hb-boss-track-top);height:var(--hb-boss-track-height);box-sizing:border-box;border:0; }
#boss-bar.healthbar-boss #boss-sub { left:var(--hb-boss-name-left);right:var(--hb-boss-name-right);top:var(--hb-boss-summary-top);z-index:4; }
#boss-bar.healthbar-boss #boss-extra { left:var(--hb-boss-name-left);right:var(--hb-boss-name-right);top:var(--hb-boss-extra-top);z-index:4; }
#boss-bar.healthbar-normal #boss-name { color:#f0c5b9; }
#boss-bar.healthbar-champion #boss-name { color:#a9cbff; }
#boss-bar.healthbar-unique #boss-name { color:#ffe08c; }
#boss-bar.healthbar-boss #boss-name { color:#ffd2aa; }
#boss-bar.healthbar-nemesis #boss-name { color:#e2b4ff; }
#boss-bar.healthbar-imp #boss-name { color:#b9f091; }
#boss-bar.healthbar-companion #boss-name { color:#9bf3e7; }
#boss-bar.healthbar-nemesis #boss-frame { filter:drop-shadow(0 0 6px rgba(160,74,230,.8)); }
#boss-emblem { position: absolute; z-index: 1; left: 1.4%; top: 50%; width: 12.7%; height: 66%; object-fit: contain; transform: translateY(-50%); }
#boss-name { position: absolute; z-index: 4; top: 18%; left: 24%; right: 12%; overflow: visible; text-overflow: clip; white-space: normal; overflow-wrap:anywhere; font: 800 clamp(12px, 1.45vw, 20px)/1.05 var(--font-head); color: #f1d99e; letter-spacing: .8px; text-shadow: 0 1px 2px #000, 0 0 6px #000, 0 0 10px #000; }
#boss-track { position: absolute; z-index: 1; left: 24%; right: 12%; top: 43%; height: 23%; overflow: hidden; border: 1px solid rgba(12,7,5,.92); background: linear-gradient(#100907,#21120b); box-shadow: inset 0 1px 4px #000, 0 1px 1px rgba(255,220,150,.4); }
#boss-health-text { position:absolute;z-index:4;inset:0;display:flex;align-items:center;justify-content:center;padding:0 5px;box-sizing:border-box;color:#fff0d4;font:700 clamp(9px,1vw,13px)/1 var(--font-body,sans-serif);font-variant-numeric:tabular-nums;text-align:center;white-space:nowrap;text-shadow:0 1px 2px #000,0 0 4px #000,0 0 6px #000;pointer-events:none; }
#boss-fill { height: 100%; width: 100%; background-color: #b50f0a; background-image: linear-gradient(180deg,rgba(255,255,255,.32),rgba(255,255,255,.05) 35%,rgba(0,0,0,.18)),url('../assets/ui/healthbars/fill-crimson.webp'); background-size: 100% 100%,auto 100%; background-repeat: no-repeat,repeat-x; box-shadow: inset 0 1px rgba(255,255,255,.28),0 0 5px #f43; }
#boss-bar.healthbar-normal #boss-fill { background-color:#b91d17; background-image:linear-gradient(180deg,rgba(255,255,255,.32),rgba(255,255,255,.04) 38%,rgba(0,0,0,.18)),url('../assets/ui/healthbars/fill-red.webp'); }
#boss-bar.healthbar-champion #boss-fill { background-color:#1553ad; background-image:linear-gradient(180deg,rgba(255,255,255,.32),rgba(255,255,255,.04) 38%,rgba(0,0,0,.18)),url('../assets/ui/healthbars/fill-blue.webp'); }
#boss-bar.healthbar-unique #boss-fill { background-color:#985607; background-image:linear-gradient(180deg,rgba(255,255,255,.32),rgba(255,255,255,.04) 38%,rgba(0,0,0,.18)),url('../assets/ui/healthbars/fill-gold.webp'); }
#boss-bar.healthbar-boss #boss-fill { background-color:#a90c06; background-image:linear-gradient(180deg,rgba(255,255,255,.32),rgba(255,255,255,.04) 38%,rgba(0,0,0,.18)),url('../assets/ui/healthbars/fill-crimson.webp'); }
#boss-bar.healthbar-nemesis #boss-fill { background-color:#59149b; background-image:linear-gradient(180deg,rgba(255,255,255,.32),rgba(255,255,255,.04) 38%,rgba(0,0,0,.18)),url('../assets/ui/healthbars/fill-purple.webp'); }
#boss-bar.healthbar-imp #boss-fill { background-color:#086520; background-image:linear-gradient(180deg,rgba(255,255,255,.32),rgba(255,255,255,.04) 38%,rgba(0,0,0,.18)),url('../assets/ui/healthbars/fill-emerald.webp'); }
#boss-bar.healthbar-companion #boss-fill { background-color:#075b6a; background-image:linear-gradient(180deg,rgba(255,255,255,.32),rgba(255,255,255,.04) 38%,rgba(0,0,0,.18)),url('../assets/ui/healthbars/fill-teal.webp'); }
#boss-bar.healthbar-smooth #boss-fill { transition: width .18s ease-out; }
#boss-bar.classic #boss-frame,#boss-bar.classic #boss-emblem { display:none; }
#boss-bar.classic { --hb-target-base-height:64px;width:min(calc(520px * var(--hb-target-width,1)),60vw);height:min(calc(var(--hb-target-base-height) * var(--hb-target-height,1)),18vh); }
#boss-bar.classic #boss-track { top:41%;height:20%;left:4%;right:4%;border:2px solid #6a1a10;border-radius:3px; }
#boss-bar.classic #boss-fill { background-image:linear-gradient(#ff3a20,#8a0a02);box-shadow:none; }
#boss-bar.classic.healthbar-champion #boss-fill { background-image:linear-gradient(#5594ff,#183b8c); }
#boss-bar.classic.healthbar-unique #boss-fill { background-image:linear-gradient(#ffd357,#a66a12); }
#boss-bar.classic.healthbar-nemesis #boss-fill { background-image:linear-gradient(#c47aff,#5c168f); }
#boss-bar.classic.healthbar-imp #boss-fill { background-image:linear-gradient(#75e052,#14752a); }
#boss-bar.classic.healthbar-companion #boss-fill { background-image:linear-gradient(#65e8df,#11777a); }
#boss-bar.classic #boss-name { top:12%;left:4%;right:4%; }
#boss-bar.classic #boss-sub { top:69%; }
#boss-bar.classic.healthbar-boss #boss-name { top:12%;left:4%;right:4%;height:auto;line-height:1.05; }
#boss-bar.classic.healthbar-boss #boss-track { top:41%;height:20%;left:4%;right:4%;border:2px solid #6a1a10; }
#boss-bar.classic.healthbar-boss #boss-sub { top:69%;left:24%;right:12%; }
#boss-bar.classic.healthbar-boss #boss-extra { top:82%;left:24%;right:12%; }
#boss-bar.no-frame:not(.classic) #boss-frame { display:none; }
#boss-track { position: absolute; }
#boss-sub { position:absolute;z-index:4;top:69%;left:24%;right:12%;overflow:hidden;text-overflow:clip;white-space:nowrap;font:600 clamp(9px,1vw,13px)/1.1 var(--font-body,sans-serif);color:#f0d5a2;text-shadow:0 1px 2px #000,0 0 5px #000; }
#boss-extra { position:absolute;z-index:4;top:82%;left:24%;right:12%;overflow:hidden;text-overflow:clip;white-space:nowrap;font:600 clamp(8px,.8vw,11px)/1 var(--font-body,sans-serif);color:#ddc9ac;text-shadow:0 1px 2px #000,0 0 5px #000; }
#boss-bar.warded #boss-frame { filter:drop-shadow(0 0 6px rgba(95,190,255,.8)); }
#boss-bar.warded #boss-sub { color:#b8e5ff; }
#boss-bar:not(.hidden) ~ #sand-objective { top:var(--healthbar-objective-top,144px); }
.healthbar-dialog { width:min(980px,95vw); max-width:min(980px,95vw); padding:16px 18px; text-align:left; border-color:#a87939; background:linear-gradient(180deg,#24170e,#0e0907); }
.healthbar-dialog > .dlg-body { max-height:min(78vh,820px); overflow:auto; }
.healthbar-settings { color:#e5d3b0; font:13px/1.35 var(--font-body); }
.healthbar-preview-card,.healthbar-settings-section { min-width:0; border:1px solid rgba(178,133,66,.54); border-radius:5px; background:linear-gradient(135deg,rgba(44,29,17,.8),rgba(12,8,6,.92)); box-shadow:inset 0 1px rgba(255,230,175,.05); }
.healthbar-preview-card { padding:9px 12px 10px; margin-bottom:10px; }
.healthbar-preview-heading { display:flex; justify-content:space-between; align-items:center; gap:8px; margin-bottom:5px; color:#f4d58c; font:700 13px var(--font-head); }
.healthbar-preview-heading > div { display:flex; align-items:center; gap:8px; }
.healthbar-preview-heading > div[hidden] { display:none; }
.healthbar-preview-heading .btn { min-width:30px; padding:3px 8px; }
.healthbar-preview-wrap { overflow:visible; padding:9px 16px; border:1px solid rgba(175,130,67,.28); border-radius:4px; background:#100b08; }
.healthbar-preview-wrap canvas { display:block; width:100%; height:auto; max-height:none; object-fit:contain; }
.healthbar-preview-controls { display:flex; gap:12px; justify-content:flex-end; flex-wrap:wrap; margin-top:7px; }
.healthbar-preview-controls label,.healthbar-control-row { display:flex; align-items:center; justify-content:space-between; gap:10px; }
.healthbar-preview-controls select,.healthbar-control-row select { min-width:0; color:#ead9b9; background:#150e09; border:1px solid #684b2b; border-radius:3px; padding:5px 7px; }
.healthbar-settings-columns { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:10px; }
.healthbar-settings-section { padding:10px 12px; }
.healthbar-settings-section h3 { margin:0 0 8px; padding:0 0 5px; border-bottom:1px solid rgba(194,149,79,.38); color:#f1cd7c; font:700 14px var(--font-head); letter-spacing:.5px; }
.healthbar-settings-section h3:not(:first-child) { margin-top:12px; }
.healthbar-control-row { min-height:30px; border-bottom:1px solid rgba(194,149,79,.12); }
.healthbar-control-row > span,.healthbar-range { display:flex; align-items:center; gap:8px; }
.healthbar-range { width:min(58%,310px); }
.healthbar-range input[type=range] { width:100%; accent-color:#d8aa53; }
.healthbar-range output { min-width:46px; text-align:right; color:#f2d08a; font-variant-numeric:tabular-nums; }
.healthbar-check-row { display:flex; align-items:center; gap:8px; min-height:28px; }
.healthbar-check-row input,.healthbar-toggle-grid input { accent-color:#d8a746; }
.healthbar-toggle-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:7px 9px; }
.healthbar-toggle-grid label { display:flex; align-items:center; gap:6px; min-width:0; }
.healthbar-settings-help { margin:10px 0 0; font-size:11px; line-height:1.35; }
.healthbar-settings-actions { display:flex; justify-content:flex-start; margin-top:9px; }
.healthbar-settings-actions .btn { color:#eed59c; border-color:#806037; }
.update-check-controls { display:flex; align-items:center; flex-wrap:wrap; gap:6px 10px; min-width:0; }
.update-check-status { min-height:1em; font-size:11px; }
@media (max-width: 680px) {
  .healthbar-settings-columns { grid-template-columns: minmax(0,1fr); }
  .healthbar-dialog { width:min(96vw,620px);max-width:96vw;padding:12px; }
  .healthbar-preview-controls { justify-content:space-between; }
  .healthbar-preview-controls label { flex:1 1 140px; }
  #boss-name { font-size:clamp(10px,3.2vw,16px); }
  #boss-sub { font-size:clamp(8px,2.4vw,11px); }
  #boss-extra { font-size:clamp(7px,2vw,9px); }
}
@media (max-width: 380px) {
  .healthbar-toggle-grid { grid-template-columns:minmax(0,1fr); }
  #boss-extra { display:none; }
}
body.touch #boss-bar { width:min(calc(520px * var(--hb-target-width,1)),76vw); height:min(calc(var(--hb-target-base-height) * var(--hb-target-height,1)),20vh); left:50%; top:calc(80px + var(--hb-target-offset,0px)); }
body.touch #boss-bar:not(.hidden) ~ #sand-objective { top:var(--healthbar-objective-top,194px); } /* directly below the expanded target bar */
body.touch #boss-bar.healthbar-boss #boss-name { white-space:normal;overflow:visible;text-overflow:clip;overflow-wrap:anywhere; }
body.touch.portrait #boss-bar { top:calc(max(168px,calc(env(safe-area-inset-top) + 160px)) + var(--hb-target-offset,0px)); left:50%; width:min(calc(92vw * var(--hb-target-width,1)),420px); height:min(calc(var(--hb-target-base-height) * var(--hb-target-height,1)),18vh); }
body.touch.portrait #boss-bar:not(.hidden) ~ #sand-objective { top:var(--healthbar-objective-top,270px); }

/* Phase 2A: First-skill tutorial coach highlight */
.first-skill-highlight {
  box-shadow: 0 0 0 2px #ffd860, 0 0 18px rgba(255, 216, 96, 0.85) !important;
  animation: firstSkillPulse 1.3s ease-in-out infinite;
}
@keyframes firstSkillPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.35); }
}
.codex-withdrawable { cursor: pointer; }
.codex-withdrawable:hover { box-shadow: 0 0 0 1px #ffd860, 0 0 10px rgba(255, 216, 96, 0.45); }

/* Phase 2B: Character Portrait HUD, Enemy History, Stat Browser, Alchemist Buy Max, Controls & Gore */
.character-portrait-hud {
  position: absolute; z-index: 12; display: flex; flex-direction: column; overflow: hidden;
  color: #ead7b4; border: 2px solid #72522d; border-radius: 6px;
  background: linear-gradient(145deg, rgba(38,25,17,.97), rgba(9,7,7,.97));
  box-shadow: 0 4px 16px rgba(0,0,0,.82), inset 0 0 0 1px rgba(255,220,155,.12), inset 0 0 14px rgba(0,0,0,.55);
  pointer-events: auto; user-select: none;
}
#hud > .character-portrait-hud { pointer-events: none; }
.character-portrait-head {
  min-height: max(18px, calc(23px * var(--portrait-scale, 1))); display: flex; align-items: center; justify-content: space-between; gap: calc(4px * var(--portrait-scale, 1));
  padding: calc(2px * var(--portrait-scale, 1)) calc(4px * var(--portrait-scale, 1)) calc(2px * var(--portrait-scale, 1)) calc(7px * var(--portrait-scale, 1)); border-bottom: 1px solid rgba(186,142,75,.55);
  background: linear-gradient(90deg, rgba(105,64,29,.75), rgba(24,15,11,.92)); cursor: grab; touch-action: none; pointer-events: auto;
}
.character-portrait-hud:not(.locked) .character-portrait-head:active { cursor: grabbing; }
.character-portrait-identity { min-width: 0; display: flex; align-items: baseline; gap: calc(5px * var(--portrait-scale, 1)); overflow: hidden; }
.character-portrait-identity b { min-width: 0; overflow: hidden; color: #ffe2a0; font: 700 max(8px, calc(10px * var(--portrait-scale, 1)))/1.2 var(--font-head); text-overflow: ellipsis; white-space: nowrap; text-shadow: 0 1px 3px #000; }
.character-portrait-identity span { flex: 0 0 auto; color: #ccb58b; font: 700 max(8px, calc(9px * var(--portrait-scale, 1)))/1 var(--font-head); white-space: nowrap; }
.character-portrait-tools { display: flex; flex: 0 0 auto; gap: calc(2px * var(--portrait-scale, 1)); }
.character-portrait-tools button { width: max(16px, calc(19px * var(--portrait-scale, 1))); height: max(16px, calc(19px * var(--portrait-scale, 1))); padding: 0; border: 1px solid #73512c; border-radius: 3px; color: #f1d49b; background: linear-gradient(#3b291b,#160e09); cursor: pointer; line-height: 1; font-size: max(10px, calc(13px * var(--portrait-scale, 1))); }
.character-portrait-tools button:hover { border-color: #e0b86e; color: #fff2d2; }
.character-portrait-content { min-height: 0; flex: 1; display: grid; grid-template-columns: minmax(58px, 41%) minmax(0,1fr); align-items: stretch; gap: calc(5px * var(--portrait-scale, 1)); padding: calc(4px * var(--portrait-scale, 1)) calc(6px * var(--portrait-scale, 1)) calc(6px * var(--portrait-scale, 1)); }
.character-portrait-content canvas { width: 100%; height: 100%; min-height: 0; border: 1px solid rgba(166,126,68,.58); border-radius: 3px; background: radial-gradient(ellipse at 50% 18%,rgba(101,73,46,.45),rgba(5,4,4,.9)); object-fit: cover; object-position: center top; image-rendering: pixelated; filter: drop-shadow(0 2px 4px #000); }
.character-portrait-vitals { min-width: 0; min-height: 0; display: flex; flex-direction: column; align-self: stretch; justify-content: flex-start; gap: max(2px, calc(3px * var(--portrait-scale, 1))); }
.character-portrait-meter { position: relative; flex: 0 0 max(16px, calc(19px * var(--portrait-scale, 1))); width: 100%; height: max(16px, calc(19px * var(--portrait-scale, 1))); overflow: hidden; border: 1px solid rgba(230,204,158,.62); border-radius: 3px; background: rgba(5,4,4,.92); box-shadow: inset 0 1px 3px #000, 0 1px 3px #000; }
.character-portrait-meter i { position: absolute; inset: 0 auto 0 0; width: 100%; transition: width .12s linear; }
.character-portrait-meter.health i { background: linear-gradient(180deg,#fa4b3d 0%,#b71920 52%,#6e0d18 100%); }
.character-portrait-meter.mana i { background: linear-gradient(180deg,#65c9ff 0%,#2476d0 52%,#123c85 100%); }
.character-portrait-meter.rage i { background: linear-gradient(90deg,#852510 0%,#e06b20 55%,#ffbe48 100%); }
.character-portrait-meter.combo i { background: linear-gradient(90deg,#650d1b 0%,#c51f39 55%,#ff5268 100%); }
.character-portrait-meter b { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff7e8; font: 700 max(8px, calc(9px * var(--portrait-scale, 1)))/1 var(--font-head); text-shadow: 0 1px 2px #000,0 0 4px #000; white-space: nowrap; pointer-events: none; }
.character-portrait-resize { position: absolute; right: 1px; bottom: 1px; width: max(11px, calc(13px * var(--portrait-scale, 1))); height: max(11px, calc(13px * var(--portrait-scale, 1))); cursor: nwse-resize; touch-action: none; pointer-events: auto; }
.character-portrait-resize::after { content: ''; position: absolute; right: 2px; bottom: 2px; width: max(6px, calc(7px * var(--portrait-scale, 1))); height: max(6px, calc(7px * var(--portrait-scale, 1))); border-right: 2px solid #b8955a; border-bottom: 2px solid #b8955a; }
.character-portrait-hud.locked .character-portrait-head { cursor: default; }
.character-portrait-hud.locked .character-portrait-resize { display: none; }

#tb-history-details { width: 100%; min-width: 0; margin-top: 4px; color: #c7b08c; font: 600 10px/1.3 var(--font-body); text-align: left; overflow-wrap: anywhere; }
#tb-history-controls { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 5px; padding-top: 4px; border-top: 1px solid rgba(133,93,48,.55); cursor: default; }
#tb-history-controls button { flex: 0 0 26px; width: 26px; height: 22px; display: inline-flex; align-items: center; justify-content: center; padding: 0; border: 1px solid rgba(145,105,54,.75); border-radius: 2px; color: #e8d2a6; background: linear-gradient(#392719,#160e09); font: 700 10px/1 var(--font-head); }
#tb-history-controls button:hover:not(:disabled) { border-color: var(--gold-bright); color: #fff1cf; }
#tb-history-controls button:disabled { opacity: .4; cursor: default; }
#tb-history-position { flex: 0 0 auto; min-width: 38px; color: #c6a96e; font: 700 8px/1 var(--font-head); text-align: center; white-space: nowrap; }
body.touch #tb-history-details { font-size: 9px; }

.rename-hero-dialog { width: min(380px, 92vw); padding: 14px 16px; }
.rename-hero-dialog .rename-hero-input { box-sizing: border-box; width: min(280px, 100%); }
.rename-hero-dialog .rename-hero-error { color: #ff8f82; font-size: 13px; }

.gore-custom-control { display: flex; align-items: center; gap: 10px; min-width: 0; }
.gore-custom-control label { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.gore-custom-control input[type="number"] { width: min(150px, 100%); min-width: 76px; }
.gore-performance-warning { grid-column: 1 / -1; min-height: 0; color: #ffb36e; font-size: 12px; line-height: 1.3; }
.keybind-capturing { border-color: #ffd860 !important; color: #fff4c0 !important; box-shadow: 0 0 10px rgba(255, 216, 96, 0.5); }

.alchemist-potion-row { display: grid; grid-template-columns: 40px minmax(100px, 1fr) minmax(240px, 1.35fr); gap: 8px; align-items: center; }
.alchemist-potion-description { min-width: 0; overflow-wrap: anywhere; }
.alchemist-buy-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.alchemist-potion-row .alchemist-buy-button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; width: 100%; min-width: 0; min-height: 44px; padding: 4px 5px; line-height: 1.05; white-space: normal; text-align: center; }
.alchemist-buy-price { font-size: 11px; color: #f4d28b; white-space: nowrap; }
@media (max-width: 700px) {
  .alchemist-potion-row { grid-template-columns: 40px minmax(0, 1fr); }
  .alchemist-buy-actions { grid-column: 1 / -1; }
}

.character-breakdown-fullwidth { grid-column: 1 / -1; align-self: stretch; width: 100%; min-width: 0; max-width: 100%; box-sizing: border-box; }
.character-equipment-breakdown { width: 100%; min-width: 0; box-sizing: border-box; border: 1px solid #5c4126; border-radius: 6px; padding: 9px 10px 11px; margin: 10px 0 0; background: linear-gradient(155deg, #1b130d, #100b08 72%); }
.character-equipment-breakdown > summary { cursor: pointer; color: #edc879; font: 700 16px var(--font-head); letter-spacing: .3px; padding: 2px 0 7px; border-bottom: 1px solid #4a3522; }
.character-breakdown-note { color: #b9a17d; font-size: 10px; line-height: 1.4; margin: 6px 0; }
.character-breakdown-controls { position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; align-items: center; margin: 5px 0 8px; padding: 4px 0 6px; background: linear-gradient(#17100b 88%, #17100b00); }
.character-breakdown-search { min-width: 0; width: 100%; box-sizing: border-box; padding: 8px 10px; color: #f1dfbd; background: #100b08; border: 1px solid #76532c; border-radius: 4px; }
.character-breakdown-filters { display: flex; flex-wrap: wrap; gap: 4px 12px; min-width: 0; padding: 4px 0; }
.character-breakdown-filter { display: inline-flex; gap: 5px; align-items: center; color: #cfb894; font-size: 10px; cursor: pointer; }
.character-breakdown-layout { display: grid; grid-template-columns: minmax(160px, 1fr) minmax(0, 2fr); gap: 9px; width: 100%; min-width: 0; max-width: 100%; box-sizing: border-box; align-items: start; }
.character-stat-categories { display: flex; flex-direction: column; gap: 3px; min-width: 0; align-self: start; position: sticky; top: 8px; padding: 3px; border: 1px solid #49351f; background: #0d0906; }
.character-stat-category { display: flex; justify-content: space-between; align-items: center; gap: 5px; width: 100%; min-width: 0; padding: 6px 7px; text-align: left; color: #d8c39d; background: #ffffff04; border: 1px solid transparent; border-radius: 3px; cursor: pointer; font: 600 10px var(--font-body); }
.character-stat-category span { min-width: 0; overflow-wrap: anywhere; }
.character-stat-category small { flex: none; color: #bb9c61; font-size: 9px; }
.character-stat-category:hover, .character-stat-category.selected { color: #ffe0a3; border-color: #8c6734; background: linear-gradient(110deg, #6d4a1b55, #24170d); }
.character-breakdown-body { display: flex; flex-direction: column; min-width: 0; max-width: 100%; }
.character-breakdown-result-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-width: 0; padding: 6px 8px; border: 1px solid #49351f; background: #17100b; }
.character-breakdown-result-title { min-width: 0; margin: 0; color: #e8bc73; font: 700 12px var(--font-head); overflow-wrap: anywhere; }
.character-breakdown-result-count { flex: none; color: #b9a17d; font-size: 10px; }
.character-breakdown-results { min-width: 0; max-width: 100%; overflow: visible; border: 1px solid #49351f; border-top: 0; background: #09060466; }
.character-stat-table-header { position: sticky; top: 0; z-index: 1; display: grid; grid-template-columns: minmax(78px, 1.3fr) minmax(42px, .7fr) minmax(38px, .65fr) minmax(48px, .8fr) minmax(60px, 1fr); gap: 4px 6px; align-items: center; min-width: 0; padding: 5px 7px; color: #b99c69; background: #17100b; border-bottom: 1px solid #604526; font-size: 8px; text-transform: uppercase; letter-spacing: .04em; }
.character-stat-table-header span { min-width: 0; overflow-wrap: anywhere; }
.character-stat-card { min-width: 0; max-width: 100%; padding: 0; background: #ffffff04; border-bottom: 1px solid #38291c; border-left: 3px solid #c7c0b3; }
.character-stat-card:nth-child(even) { background: #ffffff08; }
.character-stat-card.cap-below { border-left-color: #d8d4cb; }
.character-stat-card.cap-approaching { border-left-color: #e4c348; }
.character-stat-card.cap-at { border-left-color: #70c77a; }
.character-stat-card.cap-over { border-left-color: #ed713f; }
.character-stat-row { display: grid; grid-template-columns: minmax(78px, 1.3fr) minmax(42px, .7fr) minmax(38px, .65fr) minmax(48px, .8fr) minmax(60px, 1fr); gap: 4px 6px; align-items: center; width: 100%; min-width: 0; padding: 6px 7px; color: #ead7b3; background: transparent; border: 0; text-align: left; cursor: pointer; font: 10px var(--font-body); }
.character-stat-row:hover, .character-stat-row[aria-expanded="true"] { background: #9b713021; }
.character-stat-row span { min-width: 0; overflow-wrap: anywhere; }
.character-stat-name { color: #f0dfbd; font-weight: 700; }
.character-stat-eq { color: #c5ad87; }
.character-stat-total { color: #e9d3a5; }
.character-stat-effective { color: #ffe0a3; font-weight: 700; }
.character-stat-cap { color: #d0bd9c; font-size: 9px; }
.character-stat-card.cap-over .character-stat-cap { color: #ff8855; font-weight: 700; }
.character-stat-card.cap-approaching .character-stat-cap { color: #f0d158; }
.character-stat-card.cap-at .character-stat-cap { color: #80d88b; }
.character-stat-selected-detail { min-width: 0; max-width: 100%; margin-top: 8px; padding: 8px 9px; background: linear-gradient(150deg, #23180e, #130d08); border: 1px solid #74572f; border-radius: 4px; overflow-wrap: anywhere; }
.character-stat-selected-detail[hidden] { display: none !important; }
.character-stat-detail { display: grid; gap: 5px; min-width: 0; max-width: 100%; }
.character-stat-detail-sources { display: grid; grid-template-columns: minmax(90px, .4fr) minmax(0, 1fr); gap: 6px; min-width: 0; color: #d8c39d; font-size: 9px; line-height: 1.4; }
.character-stat-detail-sources b { color: #e8bc73; }
.character-stat-detail-source, .character-stat-detail-formula { min-width: 0; color: #b9a17d; font-size: 9px; line-height: 1.4; overflow-wrap: anywhere; }
.character-stat-empty { padding: 12px 9px; color: #b9a17d; text-align: center; font-size: 10px; }
.character-breakdown-section { width: 100%; min-width: 0; box-sizing: border-box; margin-top: 9px; padding: 8px 10px; border: 1px solid #5c4126; border-radius: 5px; background: linear-gradient(155deg, #1b130d, #100b08 72%); }
.character-breakdown-section > summary { cursor: pointer; color: #e8bc73; font: 700 13px var(--font-head); padding-bottom: 5px; border-bottom: 1px solid #49351f; }
.character-power-source { display: grid; grid-template-columns: minmax(82px, .7fr) minmax(110px, 1fr) minmax(0, 2fr); gap: 4px 10px; align-items: start; min-width: 0; padding: 7px 3px; border-bottom: 1px solid #38291c; font-size: 10px; }
.character-power-slot { color: #c6a96f; font: 700 9px var(--font-head); text-transform: uppercase; }
.character-power-item { color: #f0dfbd; overflow-wrap: anywhere; }
.character-power-description { color: #b9a17d; line-height: 1.4; overflow-wrap: anywhere; }
@media (max-width: 780px) {
  .character-breakdown-layout { grid-template-columns: minmax(132px, 1fr) minmax(0, 2fr); gap: 6px; }
  .character-stat-row, .character-stat-table-header { grid-template-columns: minmax(60px, 1fr) minmax(35px, .55fr) minmax(34px, .5fr) minmax(40px, .65fr) minmax(48px, .8fr); font-size: 9px; }
  .character-power-source { grid-template-columns: minmax(70px, .65fr) minmax(90px, .9fr) minmax(0, 2fr); gap: 4px 6px; }
}
@media (max-width: 560px) {
  .character-breakdown-layout { grid-template-columns: minmax(110px, 1fr) minmax(0, 1.6fr); gap: 5px; }
  .character-stat-table-header { display: none; }
  .character-stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px 6px; }
  .character-stat-name { grid-column: 1 / -1; }
  .character-stat-row > span:not(:first-child)::before { content: attr(data-label) ': '; color: #ad9878; font-size: 8px; font-weight: 400; }
  .character-stat-detail-sources { grid-template-columns: 1fr; }
  .character-power-source { grid-template-columns: minmax(0, 1fr); gap: 2px; }
}
