:root {
  --bg: #0b0e14;
  --panel: #141a24;
  --panel-2: #1c2533;
  --accent: #d9a441;
  --accent-2: #c8821f;
  --text: #e6e6e6;
  --muted: #8a93a3;
  --danger: #e0533d;
  /* HUD-primitives design tokens (spec §4 addendum). Consumed by
     hud-primitives.css (AlertStack / ResultFlash / ResourcePips); kept here so
     :root owns the palette and a future theme swap touches one file. */
  --good: #6fd06a;            /* heal / success green */
  --info: #3498db;           /* mana / informational blue */
  --skillmsg: #b48ce0;       /* skill-channel system line (purple) */
  --warn: var(--accent-2);   /* warning tone band */
  --grid-line: #28303d;      /* table/grid hairline */
  --row-hover: rgba(255, 255, 255, 0.04);
  /* Action-bar dock height — AlertStack docks just above it. */
  --hotbar-h: calc(96px * var(--ui-scale));
  /* Class-resource pip hues (paired with per-kind glyphs, never hue-only). */
  --pip-sphere: #ffb84d;
  --pip-coin:   #e8c34a;
  --pip-soul:   #9bd0ff;
  --pip-charm:  #cdd6e0;
  --pip-shield: #9aa7b5;
  --pip-scar:   #e0533d;
  /* Accessibility UI scale: setUiScale() (palette.ts) overrides this on :root
     from the persisted value; the HUD sizes below scale off it via calc(). */
  --ui-scale: 1;
  font-family: 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body, #app {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

#app { display: flex; align-items: center; justify-content: center; }

.screen {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.panel {
  background: var(--panel);
  border: 1px solid #28303d;
  border-radius: 12px;
  padding: 28px 32px;
  width: 360px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}

.panel h1 {
  margin: 0 0 4px;
  font-size: 22px;
  letter-spacing: 0.5px;
}
.panel .subtitle { color: var(--muted); font-size: 13px; margin-bottom: 20px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid #2c3543;
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
}
.field input:focus { outline: none; border-color: var(--accent); }

button.primary {
  width: 100%;
  padding: 11px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border: none;
  border-radius: 8px;
  color: #1a1206;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}
button.primary:hover { filter: brightness(1.07); }
button.primary:disabled { opacity: 0.5; cursor: not-allowed; }

.status { margin-top: 14px; font-size: 13px; min-height: 18px; }
.status.error { color: var(--danger); }
.status.info { color: var(--muted); }

/* char select */
.char-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.char-card {
  background: var(--panel-2);
  border: 1px solid #2c3543;
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, transform 0.1s;
}
.char-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.char-card .name { font-weight: 600; margin-bottom: 4px; }
.char-card .meta { font-size: 12px; color: var(--muted); }
.char-card.empty { color: var(--muted); cursor: default; opacity: 0.5; }

.pincode-dots { display: flex; gap: 10px; justify-content: center; margin: 18px 0; }
.pincode-dots .dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--panel-2); border: 1px solid #3a4453;
}
.pincode-dots .dot.filled { background: var(--accent); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad button {
  padding: 14px; font-size: 18px; background: var(--panel-2);
  border: 1px solid #2c3543; border-radius: 8px; color: var(--text); cursor: pointer;
}
.keypad button:hover { border-color: var(--accent); }

/* in-game */
#game-canvas { width: 100vw; height: 100vh; display: block; }
.hud {
  position: fixed; top: 12px; left: 12px;
  background: rgba(10, 14, 20, 0.7);
  border: 1px solid #28303d; border-radius: 8px;
  padding: 10px 14px; font-size: 13px; pointer-events: none;
}
.hud .row { margin: 2px 0; }
.hud .label { color: var(--muted); }

/* ===== HUD overlays ===== */
/* Containers don't capture clicks; only panels/buttons do, so the canvas under
   them stays usable for movement. */
.overlay { position: fixed; pointer-events: none; z-index: 10; }
.overlay button,
.overlay input,
.inv-cell,
.skill-row,
.npc-menu-item,
.hot-slot { pointer-events: auto; cursor: pointer; }

.panel-box {
  background: rgba(10, 14, 20, 0.82);
  border: 1px solid #28303d;
  border-radius: 8px;
}

/* Status panel (top-left) */
.status-panel {
  top: 12px; left: 12px; width: calc(300px * var(--ui-scale));
  background:
    linear-gradient(180deg, rgba(19, 25, 35, 0.92), rgba(8, 12, 18, 0.88));
  border: 1px solid rgba(116, 132, 156, 0.36); border-radius: 8px;
  padding: calc(10px * var(--ui-scale)); font-size: calc(12px * var(--ui-scale));
  box-shadow: 0 10px 26px rgba(0,0,0,0.36), inset 0 1px 0 rgba(255,255,255,0.05);
}
.hud-identity {
  display: grid; grid-template-columns: calc(42px * var(--ui-scale)) minmax(0, 1fr) auto;
  align-items: center; gap: calc(8px * var(--ui-scale)); margin-bottom: calc(8px * var(--ui-scale));
}
.hud-portrait {
  width: calc(42px * var(--ui-scale)); height: calc(42px * var(--ui-scale));
  position: relative; display: grid; place-items: center; border-radius: 8px; overflow: hidden;
  color: #ffe7a8; font-size: calc(13px * var(--ui-scale)); font-weight: 900;
  letter-spacing: 0; font-variant-numeric: tabular-nums;
  background:
    linear-gradient(135deg, rgba(217,164,65,0.18), rgba(180,140,224,0.14)),
    radial-gradient(circle at 50% 28%, rgba(255,255,255,0.1), rgba(13,18,26,0.98) 62%);
  border: 1px solid rgba(217,164,65,0.48);
  box-shadow: inset 0 0 0 2px rgba(0,0,0,0.28), 0 3px 8px rgba(0,0,0,0.28);
  text-shadow: 0 1px 2px #000;
}
.hud-portrait.has-art {
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  color: transparent;
  text-shadow: none;
}
.hud-portrait > canvas.self-3d { position: absolute; inset: 0; width: 100%; height: 100%; display: none; }
.hud-portrait.has-3d > canvas.self-3d { display: block; }
.hud-portrait.has-3d {
  background-image: none !important;
  color: transparent;
  text-shadow: none;
}
.hud-title { min-width: 0; display: flex; flex-direction: column; gap: calc(2px * var(--ui-scale)); }
.hud-name {
  font-weight: 800; font-size: calc(14px * var(--ui-scale)); line-height: 1.1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hud-job {
  color: var(--muted); font-size: calc(11px * var(--ui-scale)); line-height: 1.1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hud-levels { display: flex; flex-direction: column; gap: calc(3px * var(--ui-scale)); align-items: flex-end; }
.hud-level-chip {
  display: inline-flex; align-items: baseline; gap: calc(4px * var(--ui-scale));
  min-width: calc(54px * var(--ui-scale)); justify-content: space-between;
  padding: calc(2px * var(--ui-scale)) calc(6px * var(--ui-scale));
  border-radius: 5px; border: 1px solid rgba(116,132,156,0.3);
  background: rgba(255,255,255,0.035); font-variant-numeric: tabular-nums;
}
.hud-level-base { border-color: rgba(217,164,65,0.42); }
.hud-level-job { border-color: rgba(180,140,224,0.44); }
.hud-level-key { color: var(--muted); font-size: calc(9px * var(--ui-scale)); text-transform: uppercase; }
.hud-level-value { color: var(--text); font-size: calc(13px * var(--ui-scale)); font-weight: 800; }
.hud-resource-bars { display: flex; flex-direction: column; gap: calc(5px * var(--ui-scale)); }
.hud-row { color: var(--muted); margin-top: 0; }
.status-panel .bar {
  position: relative; height: calc(16px * var(--ui-scale)); margin-top: 0;
  background: rgba(5, 8, 12, 0.82); border: 1px solid rgba(116,132,156,0.22);
  border-radius: 5px; overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.55);
}
.hud-progression {
  display: flex; flex-direction: column; gap: calc(4px * var(--ui-scale));
  margin-top: calc(8px * var(--ui-scale));
  padding-top: calc(7px * var(--ui-scale)); border-top: 1px solid rgba(116,132,156,0.18);
}
.hud-progress-row {
  display: grid; grid-template-columns: calc(34px * var(--ui-scale)) minmax(0, 1fr);
  align-items: center; gap: calc(6px * var(--ui-scale));
}
.hud-progress-label {
  color: var(--muted); font-size: calc(9px * var(--ui-scale)); font-weight: 800;
  text-transform: uppercase; letter-spacing: 0;
}
.status-panel .exp-bar { height: calc(11px * var(--ui-scale)); }
.bar-fill { height: 100%; width: 0%; transition: width 0.2s; }
.bar-fill.hp { background: linear-gradient(90deg, #c0392b, #e0533d); position: relative; z-index: 1; }
/* Recent-damage ghost: a darker red layer behind the HP fill. JS snaps it up on
   a heal and lets its width lag (~400ms) on a hit, so the exposed strip between
   ghost and fill reads the size of the burst at a glance. */
.bar-fill.hp-ghost {
  position: absolute; left: 0; top: 0; z-index: 0;
  background: linear-gradient(90deg, #7a1f17, #a3392f);
  transition: width 0.4s ease-out;
}
/* Reduce-flashing mirrors the JS (which sets transition:none) so the ghost just
   snaps with no trailing motion. */
body.reduce-flashing .bar-fill.hp-ghost { transition: none; }
.bar-fill.sp { background: linear-gradient(90deg, #2471a3, #3498db); }
.bar-fill.exp.base-exp { background: linear-gradient(90deg, #c8821f, var(--accent)); }
.bar-fill.exp.job-exp { background: linear-gradient(90deg, #7f58b8, var(--skillmsg)); }
.bar-text {
  /* z-index:2 keeps the HP/SP/EXP readout above the fill — .bar-fill.hp is
     position:relative z-index:1, so without this the HP text renders behind it
     (the SP fill has no z-index, which is why SP read fine and HP looked empty). */
  position: absolute; inset: 0; z-index: 2; text-align: center; font-size: calc(11px * var(--ui-scale));
  line-height: calc(16px * var(--ui-scale)); color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,0.7);
}
/* The EXP bar is thinner (12px), so its label sits on a shorter line. */
.status-panel .exp-bar .bar-text { line-height: calc(11px * var(--ui-scale)); font-size: calc(9px * var(--ui-scale)); }
.hud-economy {
  display: grid; grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
  align-items: center; gap: calc(6px * var(--ui-scale)); margin-top: calc(8px * var(--ui-scale));
}
.hud-economy .hud-row:first-child {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: #ffe066; font-weight: 800; font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 1px #000;
}

/* Always-on party HP/SP frames, stacked under the self status panel (top-left).
   Anchored below the status panel's footprint and scaled with --ui-scale to match. */
/* WoW-style party unit-frames: a movable cluster (drag grip) of compact ally
   frames — HP%, Lv/job, leader crown, buff/debuff chips. Click a frame to target
   the ally; right-click to cast/whisper/manage. No SP bar (no party-SP packet). */
.party-frames {
  top: calc(244px * var(--ui-scale)); left: 12px; width: calc(300px * var(--ui-scale));
  pointer-events: auto;
  display: flex; flex-direction: column; gap: calc(3px * var(--ui-scale));
}
.pf-grip {
  display: flex; align-items: center; justify-content: center;
  height: calc(12px * var(--ui-scale)); cursor: move; user-select: none;
  color: var(--muted); opacity: 0; transition: opacity 0.12s;
  border-radius: 4px; background: rgba(10, 14, 20, 0.5);
}
.party-frames:hover .pf-grip { opacity: 0.7; } /* reveal the drag handle on hover */
.pf-grip-dots { font-size: calc(11px * var(--ui-scale)); line-height: 1; letter-spacing: 2px; }
.pf-list { display: flex; flex-direction: column; gap: calc(4px * var(--ui-scale)); }
.pf-frame {
  position: relative; cursor: pointer; text-align: left;
  background: rgba(10, 14, 20, 0.82); border: 1px solid #28303d; border-radius: 6px;
  border-left: 3px solid #3a4555; /* role/status accent stripe */
  padding: calc(5px * var(--ui-scale)) calc(8px * var(--ui-scale));
  display: flex; flex-direction: column; gap: calc(3px * var(--ui-scale));
  transition: border-color 0.12s, background-color 0.12s;
}
.pf-frame:hover { border-color: var(--accent); background: rgba(16, 22, 31, 0.9); }
.pf-frame:focus-visible { outline: 2px solid #7fd0ff; outline-offset: 1px; }
.pf-frame.pf-self { border-left-color: var(--accent); }
.pf-frame.pf-offline { opacity: 0.45; }
.pf-frame.pf-oor { opacity: 0.6; cursor: default; } /* out of range: can't target/cast */
.pf-frame.pf-dead { border-left-color: #e0533d; filter: grayscale(0.6); }
.pf-frame.pf-lowhp { border-left-color: #e0533d; animation: pf-pulse 1s ease-in-out infinite; }
@keyframes pf-pulse { 0%,100% { background: rgba(10,14,20,0.82); } 50% { background: rgba(74,24,24,0.7); } }
.pf-top { display: flex; align-items: baseline; gap: calc(4px * var(--ui-scale)); }
.pf-crown { flex: none; color: var(--accent); font-size: calc(11px * var(--ui-scale)); }
.pf-name {
  flex: 1; min-width: 0; font-size: calc(12px * var(--ui-scale)); font-weight: 600;
  color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pf-bar {
  position: relative; height: calc(9px * var(--ui-scale));
  background: var(--panel-2); border-radius: 3px; overflow: hidden;
}
.pf-bar.pf-unknown {
  display: grid;
  place-items: center;
  border: 1px dashed rgba(138, 147, 163, 0.45);
  background: rgba(24, 29, 38, 0.72);
}
.pf-fill { height: 100%; width: 0%; transition: width 0.2s; }
.pf-hp .pf-fill { background: linear-gradient(90deg, #2e8b57, #5fd35f); } /* ally green */
.pf-frame.pf-lowhp .pf-hp .pf-fill { background: linear-gradient(90deg, #c0392b, #e0533d); }
.pf-pct {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: calc(8px * var(--ui-scale)); font-weight: 700; color: #fff;
  text-shadow: 0 1px 1px #000; pointer-events: none; letter-spacing: 0.3px;
}
.pf-buffs { display: flex; flex-wrap: wrap; gap: 2px; }
/* Ally buff/debuff strip — small square art tiles (the family's procedural icon),
   green-framed buff / red-framed debuff. */
.pf-chip {
  width: calc(16px * var(--ui-scale)); height: calc(16px * var(--ui-scale)); border-radius: 3px;
  background-size: cover; background-position: center; background-repeat: no-repeat;
  border: 1px solid rgba(95, 211, 95, 0.5);
}
.pf-chip.bad { border-color: rgba(224, 83, 61, 0.6); }
/* Self frame's SP bar — a thinner blue strip stacked under the green HP bar.
   rAthena streams no ally SP, so only the local player's own frame renders one. */
.pf-sp { height: calc(6px * var(--ui-scale)); margin-top: calc(2px * var(--ui-scale)); }
.pf-sp .pf-fill { background: linear-gradient(90deg, #2b6cb0, #4aa3ff); } /* mana blue */
.pf-sp .pf-pct { font-size: calc(7px * var(--ui-scale)); }
.party-focus-drop-cue {
  top: calc(332px * var(--ui-scale));
  left: calc(320px * var(--ui-scale));
  width: calc(210px * var(--ui-scale));
  min-height: calc(58px * var(--ui-scale));
  pointer-events: none;
  display: grid;
  place-items: center;
  border: 1px dashed var(--accent);
  border-radius: 6px;
  background: rgba(10, 14, 20, 0.76);
  color: var(--accent);
  font-size: calc(11px * var(--ui-scale));
  font-weight: 800;
  text-align: center;
}
.party-focus {
  top: calc(332px * var(--ui-scale));
  left: calc(320px * var(--ui-scale));
  width: calc(210px * var(--ui-scale));
  pointer-events: auto;
  background: rgba(10, 14, 20, 0.9);
  border: 1px solid #2f3948;
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: calc(7px * var(--ui-scale));
  display: flex;
  flex-direction: column;
  gap: calc(5px * var(--ui-scale));
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}
.party-focus.pf-oor,
.party-focus.pf-offline { opacity: 0.72; }
.party-focus.pf-dead,
.party-focus.pf-lowhp { border-left-color: #e0533d; }
.party-focus-drop-ready .party-focus,
.party-focus:hover {
  border-color: var(--accent);
}
.pf-focus-head {
  display: flex;
  align-items: center;
  gap: calc(6px * var(--ui-scale));
  min-width: 0;
}
.pf-focus-copy { min-width: 0; flex: 1; }
.pf-focus-name {
  color: var(--text);
  font-size: calc(12px * var(--ui-scale));
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pf-focus-meta,
.pf-focus-state {
  color: var(--muted);
  font-size: calc(10px * var(--ui-scale));
  line-height: 1.15;
}
.pf-focus-close,
.pf-focus-action {
  border: 1px solid #354050;
  background: rgba(19, 26, 36, 0.92);
  color: var(--text);
  border-radius: 5px;
  min-height: calc(22px * var(--ui-scale));
}
.pf-focus-close {
  width: calc(22px * var(--ui-scale));
  padding: 0;
  line-height: 1;
}
.pf-focus-action {
  width: 100%;
  padding: calc(4px * var(--ui-scale)) calc(7px * var(--ui-scale));
  font-size: calc(11px * var(--ui-scale));
  font-weight: 800;
}
.pf-focus-action:hover:not(:disabled),
.pf-focus-close:hover {
  border-color: var(--accent);
  background: rgba(27, 36, 48, 0.95);
}
.pf-focus-action:disabled {
  color: var(--muted);
  cursor: default;
  opacity: 0.75;
}

/* Window-toggle dock — the single consolidated command bar that opens the
   standard windows. Docked directly under the minimap (top:14 + 180px canvas +
   8px gap = 202) and right-aligned to it, reusing the minimap's glassy chrome so
   the map and its controls read as one top-right cluster and never crowd the
   180px square. (The old redundant bottom-right .cmd-bar has been removed.) */
.menu-buttons {
  top: 202px;
  right: 14px;
  left: auto;
  bottom: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  pointer-events: auto;
  background: linear-gradient(180deg, rgba(20,26,34,0.94), rgba(8,11,16,0.9));
  border: 1px solid rgba(109,124,146,0.5);
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.05);
}
.hud-layout-editing .hud-layout-widget {
  outline: 2px solid rgba(217,164,65,0.85);
  outline-offset: 3px;
  cursor: move;
}

.hud-layout-editing.hud-layout-snap::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(217,164,65,0.14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(217,164,65,0.14) 1px, transparent 1px);
  background-size: 8px 8px;
}

.hud-layout-handle {
  position: fixed;
  z-index: 64;
  display: none;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  max-width: 180px;
  padding: 3px 8px;
  border: 1px solid rgba(217,164,65,0.85);
  border-radius: 7px;
  background: rgba(12,16,22,0.94);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: grab;
  pointer-events: auto;
  box-shadow: 0 8px 20px rgba(0,0,0,0.4);
  user-select: none;
}

.hud-layout-handle::after {
  content: attr(data-hud-role-label);
  max-width: 74px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.hud-layout-handle.dragging {
  cursor: grabbing;
  background: rgba(38,30,16,0.96);
}

.hud-layout-handle.is-custom {
  border-color: rgba(217,164,65,0.95);
  background: rgba(38,30,16,0.96);
}

.hud-layout-handle.is-custom::before {
  content: '';
  width: 6px;
  height: 6px;
  margin-right: 5px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(217,164,65,0.18);
  flex: 0 0 auto;
}

.hud-layout-editing.hud-layout-precision .hud-layout-handle {
  border-color: rgba(74,163,255,0.86);
  color: #b8e4ff;
}

.hud-layout-bar {
  top: 12px;
  left: 50%;
  z-index: 63;
  transform: translateX(-50%);
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 10px;
  pointer-events: auto;
  background: rgba(10,14,20,0.9);
  border: 1px solid rgba(217,164,65,0.55);
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(0,0,0,0.38);
}

.hud-layout-title {
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.hud-layout-summary {
  min-width: 104px;
  max-width: min(280px, 38vw);
  border: 1px solid rgba(116,132,156,0.32);
  border-radius: 6px;
  padding: 3px 7px;
  color: var(--accent);
  background: rgba(217,164,65,0.1);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-layout-summary.is-default {
  color: var(--muted);
  background: rgba(255,255,255,0.035);
}

.hud-layout-action {
  border: 1px solid rgba(116,132,156,0.42);
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  color: var(--text);
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
}

.hud-layout-action:hover {
  border-color: rgba(217,164,65,0.7);
  color: var(--accent);
}

.hud-layout-action:disabled,
.hud-layout-action[aria-disabled="true"] {
  cursor: default;
  border-color: rgba(116,132,156,0.26);
  color: rgba(214,223,237,0.68);
  background: rgba(255,255,255,0.025);
}

.hud-layout-action:disabled:hover,
.hud-layout-action[aria-disabled="true"]:hover {
  border-color: rgba(116,132,156,0.26);
  color: rgba(214,223,237,0.68);
}

.hud-layout-action[aria-pressed="true"] {
  border-color: rgba(217,164,65,0.75);
  background: rgba(217,164,65,0.14);
  color: #ffe6a6;
}

.hud-layout-editing.hud-layout-precision .hud-layout-action[aria-pressed="true"] {
  border-color: rgba(74,163,255,0.78);
  background: rgba(74,163,255,0.13);
  color: #b8e4ff;
}

.hud-layout-action.primary {
  background: rgba(217,164,65,0.18);
  border-color: rgba(217,164,65,0.75);
  color: #ffe6a6;
}

.hud-layout-ghost {
  opacity: 0.72;
  filter: grayscale(0.25);
}

.hud-layout-placeholder {
  min-width: 132px;
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px 9px;
  border: 1px dashed rgba(217,164,65,0.65);
  border-radius: 7px;
  color: var(--accent);
  background: rgba(10,14,20,0.62);
  font-size: 11px;
  font-weight: 800;
}

/* Thin divider fencing the system/Options button off from the window toggles. */
.menu-divider {
  align-self: stretch;
  width: 1px;
  margin: 4px 1px;
  background: linear-gradient(180deg, transparent, rgba(109,124,146,0.62) 28%, rgba(109,124,146,0.62) 72%, transparent);
}
.menu-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 38%, rgba(255,255,255,0.08), transparent 50%),
    linear-gradient(180deg, rgba(29,36,47,0.94), rgba(8,12,18,0.96));
  border: 1px solid rgba(67,78,96,0.82);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.55), 0 2px 5px rgba(0,0,0,0.35);
  transition: color .12s ease, background-color .12s ease, border-color .12s ease, box-shadow .12s ease, transform .08s ease;
}
.menu-glyph {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 7px;
  background: radial-gradient(circle at 50% 55%, rgba(255,255,255,0.06), rgba(0,0,0,0.1) 62%, rgba(0,0,0,0.32));
}
.menu-icon {
  display: block;
  width: 34px;
  height: 34px;
  object-fit: contain;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.75));
}
.menu-btn:hover {
  color: var(--text);
  border-color: rgba(217,164,65,0.72);
  box-shadow: inset 0 0 0 1px rgba(217,164,65,0.28), 0 0 10px rgba(217,164,65,0.22), 0 3px 7px rgba(0,0,0,0.42);
  transform: translateY(-1px);
}
.menu-btn:active {
  transform: translateY(0);
  background: linear-gradient(180deg, rgba(34,28,16,0.96), rgba(12,12,14,0.96));
}
.menu-btn[aria-pressed="true"] {
  color: var(--accent);
  background: linear-gradient(180deg, rgba(54,40,16,0.94), rgba(13,14,17,0.96));
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(217,164,65,0.75) inset, 0 0 12px rgba(217,164,65,0.34), 0 3px 7px rgba(0,0,0,0.48);
}
/* Hotkey badge: runtime layer, not baked into icon art. */
.menu-key {
  position: absolute;
  right: 2px;
  bottom: 2px;
  display: grid;
  place-items: center;
  min-width: 14px;
  height: 13px;
  padding: 0 3px;
  border: 1px solid rgba(0,0,0,0.7);
  border-radius: 4px;
  background: rgba(5,7,10,0.88);
  color: #e9edf4;
  font-size: calc(8px * var(--ui-scale));
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 1px 1px #000;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 1px 2px rgba(0,0,0,0.5);
  pointer-events: none;
}
.menu-btn:hover .menu-key, .menu-btn[aria-pressed="true"] .menu-key {
  border-color: rgba(217,164,65,0.72);
  color: #ffe2a0;
}

.target-panel {
  top: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(10,14,20,0.82); border: 1px solid #28303d;
  border-radius: 6px; padding: 6px 16px;
}
.target-name { font-weight: 600; }

/* Generic windows */
.window {
  top: 80px; left: 50%; transform: translateX(-50%);
  width: 300px; flex-direction: column;
  background: var(--panel); border: 1px solid #28303d; border-radius: 10px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.5); pointer-events: auto;
}
/* Distinct default anchors so Stats/Inventory/Skills don't pile on one spot when
   opened together (drag overrides + persists; makeDraggable only sets left/top
   when a saved position exists, otherwise these anchors hold). Right-anchored so
   they clear the top-left status panel and the top-right menu buttons. */
.window.win-stats  { top: 80px;  left: auto; right: 70px;  transform: none; }
.window.win-inv    { top: 130px; left: auto; right: 24px;  transform: none; width: min(520px, calc(100vw - 48px)); }
.window.win-skills { top: 120px; left: auto; right: 120px; transform: none; width: 560px; max-width: 92vw; }
.window.win-bank { top: 185px; left: auto; right: 90px; transform: none; width: 320px; max-width: calc(100vw - 48px); }
.window.win-storage-security { top: 245px; left: auto; right: 120px; transform: none; width: 420px; max-width: calc(100vw - 48px); }
.window.win-chat-rooms { top: 190px; left: 50%; transform: translateX(-50%); width: 460px; max-width: calc(100vw - 48px); }
.window.win-quests { top: 150px; left: auto; right: 150px; transform: none; width: 460px; max-width: calc(100vw - 48px); }
.window.win-achievements { top: 190px; left: auto; right: 180px; transform: none; width: 460px; max-width: calc(100vw - 48px); }
.window.win-cash-shop { top: 155px; left: auto; right: 190px; transform: none; width: 420px; max-width: calc(100vw - 48px); }
.window.win-mail { top: 210px; left: auto; right: 210px; transform: none; width: 440px; max-width: calc(100vw - 48px); }
.window.win-item-services { top: 250px; left: auto; right: 170px; transform: none; width: 440px; max-width: calc(100vw - 48px); }
.window.win-battleground { top: 115px; left: 50%; transform: translateX(-50%); width: 430px; max-width: calc(100vw - 48px); }
.window.win-social-notifications { top: 175px; left: auto; right: 130px; transform: none; width: 390px; max-width: calc(100vw - 48px); }
.window.win-system-utility { top: 285px; left: auto; right: 130px; transform: none; width: 460px; max-width: calc(100vw - 48px); }
.window.win-skill-prompt { top: 145px; left: 50%; transform: translateX(-50%); width: 360px; max-width: calc(100vw - 48px); }
.win-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 12px; border-bottom: 1px solid #28303d; font-weight: 600;
  letter-spacing: 0.3px; border-radius: 10px 10px 0 0;
  background: linear-gradient(180deg, rgba(54,64,82,0.55), rgba(54,64,82,0));
}
.win-close {
  background: none; border: none; color: var(--muted);
  font-size: 18px; cursor: pointer; line-height: 1;
}
.win-close:hover { color: var(--text); }
.win-body { padding: 12px; max-height: 60vh; overflow-y: auto; }

.bank-summary { display: grid; gap: 6px; margin-bottom: 10px; }
.bank-summary-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 7px 8px; border: 1px solid #28303d; border-radius: 6px; background: rgba(255,255,255,0.035);
}
.bank-summary-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }
.bank-summary-value { color: var(--text); font-size: 13px; font-variant-numeric: tabular-nums; }
.bank-amount { display: grid; gap: 5px; margin-bottom: 8px; color: var(--muted); font-size: 11px; }
.bank-amount input {
  width: 100%; min-width: 0; padding: 7px 9px; border-radius: 6px;
  border: 1px solid #2c3543; background: var(--panel-2); color: var(--text);
  font: inherit; font-variant-numeric: tabular-nums;
}
.bank-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.bank-actions button {
  min-height: 30px; border: 1px solid #2c3543; border-radius: 6px;
  background: rgba(255,255,255,0.045); color: var(--text); cursor: pointer;
}
.bank-actions button:hover { border-color: var(--accent); color: #ffe0a0; }
.bank-status { margin-top: 9px; color: var(--muted); font-size: 12px; line-height: 1.35; }

.storage-sec-card,
.storage-sec-status {
  padding: 8px 9px; border: 1px solid #28303d; border-radius: 6px;
  background: rgba(255,255,255,0.035); color: var(--text); font-size: 12px;
}
.storage-sec-status { margin-top: 7px; color: var(--muted); }
.storage-log-title { margin: 12px 0 6px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }
.storage-log-list { display: grid; gap: 5px; max-height: 240px; overflow-y: auto; }
.storage-log-row {
  display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 3px 8px;
  align-items: baseline; padding: 7px 8px; border: 1px solid #28303d; border-radius: 6px;
  background: rgba(255,255,255,0.03);
}
.storage-log-put { color: #7fdc8c; font-weight: 700; }
.storage-log-take { color: #e0b86b; font-weight: 700; }
.storage-log-item { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.storage-log-meta { grid-column: 2; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; }
.storage-log-empty { padding: 8px 9px; color: var(--muted); border: 1px dashed #2c3543; border-radius: 6px; }

.cashshop-balance {
  padding: 8px 9px; border: 1px solid #28303d; border-radius: 6px;
  background: rgba(255,255,255,0.035); color: var(--text); font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.cashshop-amount { display: flex; align-items: center; gap: 8px; margin: 8px 0; color: var(--muted); font-size: 12px; }
.cashshop-amount input {
  width: 76px; min-height: 28px; border: 1px solid #2c3543; border-radius: 6px;
  background: rgba(255,255,255,0.05); color: var(--text); padding: 4px 6px;
}
.cashshop-status { min-height: 16px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.cashshop-section { margin-top: 10px; }
.cashshop-section-title,
.cashshop-tab-label { margin: 0 0 6px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }
.cashshop-tab-label { margin-top: 7px; }
.cashshop-list { display: grid; gap: 5px; max-height: 180px; overflow-y: auto; }
.cashshop-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 8px; align-items: center;
  padding: 7px 8px; border: 1px solid #28303d; border-radius: 6px; background: rgba(255,255,255,0.03);
}
.cashshop-row-info { grid-template-columns: minmax(0, 1fr); }
.cashshop-row-main { min-width: 0; }
.cashshop-row-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cashshop-row-meta { color: var(--muted); font-size: 11px; }
.cashshop-row button {
  min-height: 28px; border: 1px solid #2c3543; border-radius: 6px;
  background: rgba(255,255,255,0.045); color: var(--text); cursor: pointer;
}
.cashshop-row button:hover { border-color: var(--accent); color: #ffe0a0; }
.cashshop-empty { padding: 8px 9px; color: var(--muted); border: 1px dashed #2c3543; border-radius: 6px; }

.mail-status {
  padding: 8px 9px; border: 1px solid #28303d; border-radius: 6px;
  background: rgba(255,255,255,0.035); color: var(--text); font-size: 12px;
}
.mail-section { margin-top: 10px; }
.mail-section-title { margin-bottom: 6px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }
.mail-list { display: grid; gap: 5px; max-height: 190px; overflow-y: auto; }
.mail-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px;
  width: 100%; padding: 7px 8px; border: 1px solid #28303d; border-radius: 6px;
  background: rgba(255,255,255,0.03); color: var(--text);
}
.mail-row:hover,
.mail-row.is-selected { border-color: var(--accent); }
.mail-row-main {
  min-width: 0; display: grid; gap: 2px; padding: 0; border: 0; background: transparent;
  color: inherit; text-align: left; cursor: pointer;
}
.mail-row-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-row-meta { color: var(--muted); font-size: 11px; }
.mail-read { display: grid; gap: 5px; }
.mail-read-card {
  padding: 8px 9px; border: 1px solid #28303d; border-radius: 6px;
  background: rgba(255,255,255,0.03); color: var(--text); font-size: 12px;
}
.mail-body { white-space: pre-wrap; line-height: 1.35; }
.mail-attachments { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.mail-attachments span { padding: 3px 6px; border: 1px solid #2c3543; border-radius: 6px; color: var(--text); background: rgba(255,255,255,0.035); }
.mail-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.mail-actions button,
.mail-action {
  min-height: 28px; border: 1px solid #2c3543; border-radius: 6px;
  background: rgba(255,255,255,0.045); color: var(--text); cursor: pointer;
}
.mail-actions button:hover,
.mail-action:hover { border-color: var(--accent); color: #ffe0a0; }
.mail-compose { display: grid; gap: 7px; }
.mail-field { display: grid; gap: 4px; color: var(--muted); font-size: 11px; }
.mail-field input,
.mail-field textarea {
  width: 100%; min-width: 0; box-sizing: border-box; padding: 7px 8px;
  border: 1px solid #2c3543; border-radius: 6px; background: var(--panel-2);
  color: var(--text); font: inherit;
}
.mail-field textarea { resize: vertical; }
.mail-attach-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; }
.mail-attach-form .mail-actions { grid-column: 1 / -1; margin-top: 0; }
.mail-field-wide { grid-column: 1 / -1; }
.mail-empty { padding: 8px 9px; color: var(--muted); border: 1px dashed #2c3543; border-radius: 6px; }
.mail-result { min-height: 16px; margin-top: 8px; color: var(--muted); font-size: 12px; }

.itemsvc-status {
  padding: 8px 9px; border: 1px solid #28303d; border-radius: 6px;
  background: rgba(255,255,255,0.035); color: var(--text); font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.itemsvc-section { margin-top: 10px; }
.itemsvc-section-title { margin-bottom: 6px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }
.itemsvc-list { display: grid; gap: 5px; max-height: 180px; overflow-y: auto; }
.itemsvc-row {
  display: grid; gap: 2px; padding: 7px 8px; border: 1px solid #28303d;
  border-radius: 6px; background: rgba(255,255,255,0.03); color: var(--text);
}
.itemsvc-row-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.itemsvc-row-meta { color: var(--muted); font-size: 11px; }
.itemsvc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.itemsvc-actions input {
  width: 64px; min-width: 0; height: 28px; box-sizing: border-box; padding: 5px 7px;
  border: 1px solid #2c3543; border-radius: 6px; background: var(--panel-2);
  color: var(--text); font: inherit; font-size: 12px;
}
.itemsvc-actions input[type="text"] { width: 132px; }
.itemsvc-actions button {
  min-width: 58px; height: 28px; border: 1px solid #2c3543; border-radius: 6px;
  background: rgba(255,255,255,0.045); color: var(--text); cursor: pointer;
}
.itemsvc-actions button:hover { border-color: var(--accent); color: #ffe0a0; }
.itemsvc-empty { padding: 8px 9px; color: var(--muted); border: 1px dashed #2c3543; border-radius: 6px; }
.itemsvc-result { min-height: 16px; margin-top: 8px; color: var(--muted); font-size: 12px; }

.bgwin-status {
  padding: 8px 9px; border: 1px solid #28303d; border-radius: 6px;
  background: rgba(255,255,255,0.035); color: var(--text); font-size: 12px;
}
.bgwin-score {
  margin-top: 8px; padding: 9px; border: 1px solid #3a4556; border-radius: 6px;
  background: rgba(255,255,255,0.04); color: #ffe0a0; font-size: 20px; font-weight: 700;
  text-align: center; font-variant-numeric: tabular-nums;
}
.bgwin-section { margin-top: 10px; }
.bgwin-section-title { margin-bottom: 6px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }
.bgwin-list { display: grid; gap: 5px; max-height: 150px; overflow-y: auto; }
.bgwin-row {
  padding: 7px 8px; border: 1px solid #28303d; border-radius: 6px;
  background: rgba(255,255,255,0.03); color: var(--text); font-size: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bgwin-empty { padding: 8px 9px; color: var(--muted); border: 1px dashed #2c3543; border-radius: 6px; }
.socialnote-summary {
  padding: 8px 9px; border: 1px solid #28303d; border-radius: 6px;
  background: rgba(255,255,255,0.035); color: var(--text); font-size: 12px;
}
.socialnote-list { display: grid; gap: 5px; max-height: 280px; margin-top: 9px; overflow-y: auto; }
.socialnote-row {
  display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 8px; align-items: center;
  padding: 7px 8px; border: 1px solid #28303d; border-radius: 6px;
  background: rgba(255,255,255,0.03); color: var(--text); font-size: 12px;
}
.socialnote-group { color: #ffe0a0; font-size: 11px; text-transform: uppercase; }
.socialnote-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.socialnote-empty { padding: 8px 9px; color: var(--muted); border: 1px dashed #2c3543; border-radius: 6px; }

.sysutil-status {
  padding: 8px 9px; border: 1px solid #28303d; border-radius: 6px;
  background: rgba(255,255,255,0.035); color: var(--text); font-size: 12px;
}
.sysutil-section { margin-top: 10px; }
.sysutil-section-title { margin-bottom: 6px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }
.sysutil-list { display: grid; gap: 5px; max-height: 150px; overflow-y: auto; }
.sysutil-row {
  padding: 7px 8px; border: 1px solid #28303d; border-radius: 6px;
  background: rgba(255,255,255,0.03); color: var(--text); font-size: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sysutil-empty { padding: 8px 9px; color: var(--muted); border: 1px dashed #2c3543; border-radius: 6px; }

.skillprompt-status {
  padding: 8px 9px; border: 1px solid #28303d; border-radius: 6px;
  background: rgba(255,255,255,0.035); color: var(--text); font-size: 12px;
}
.skillprompt-section { margin-top: 10px; }
.skillprompt-section-title { margin-bottom: 6px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }
.skillprompt-list { display: grid; gap: 5px; max-height: 170px; overflow-y: auto; }
.skillprompt-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px;
  padding: 7px 8px; border: 1px solid #28303d; border-radius: 6px;
  background: rgba(255,255,255,0.03); color: var(--text);
}
.skillprompt-main { min-width: 0; }
.skillprompt-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.skillprompt-meta { color: var(--muted); font-size: 11px; }
.skillprompt-row button {
  min-height: 28px; border: 1px solid #2c3543; border-radius: 6px;
  background: rgba(255,255,255,0.045); color: var(--text); cursor: pointer;
}
.skillprompt-row button:hover { border-color: var(--accent); color: #ffe0a0; }
.skillprompt-message {
  padding: 7px 8px; border: 1px solid #28303d; border-radius: 6px;
  background: rgba(255,255,255,0.03); color: var(--text); font-size: 12px;
}
.skillprompt-empty { padding: 8px 9px; color: var(--muted); border: 1px dashed #2c3543; border-radius: 6px; }

.chatroom-form { display: grid; grid-template-columns: minmax(0, 1fr) 70px; gap: 6px; }
.chatroom-form input {
  min-width: 0; padding: 7px 9px; border-radius: 6px; border: 1px solid #2c3543;
  background: var(--panel-2); color: var(--text); font: inherit;
}
.chatroom-public { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.chatroom-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin: 8px 0 10px; }
.chatroom-actions button,
.chatroom-row button,
.chatroom-member button {
  min-height: 28px; border: 1px solid #2c3543; border-radius: 6px;
  background: rgba(255,255,255,0.045); color: var(--text); cursor: pointer;
}
.chatroom-actions button:hover,
.chatroom-row button:hover,
.chatroom-member button:hover { border-color: var(--accent); color: #ffe0a0; }
.chatroom-section { margin-top: 8px; }
.chatroom-section-title { margin-bottom: 5px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }
.chatroom-list,
.chatroom-members { display: grid; gap: 5px; max-height: 180px; overflow-y: auto; }
.chatroom-row,
.chatroom-member {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; align-items: center;
  padding: 7px 8px; border: 1px solid #28303d; border-radius: 6px; background: rgba(255,255,255,0.03);
}
.chatroom-title,
.chatroom-member span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chatroom-meta { color: var(--muted); font-size: 11px; }
.chatroom-empty { padding: 8px 9px; color: var(--muted); border: 1px dashed #2c3543; border-radius: 6px; }
.chatroom-status { margin-top: 8px; color: var(--muted); font-size: 12px; }

.qa-section { display: grid; gap: 6px; margin-bottom: 12px; }
.qa-title { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }
.qa-summary {
  padding: 8px 9px; border: 1px solid #28303d; border-radius: 6px;
  background: rgba(255,255,255,0.035); font-size: 12px;
}
.qa-list { display: grid; gap: 5px; max-height: 200px; overflow-y: auto; }
.qa-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 8px; align-items: center;
  padding: 7px 8px; border: 1px solid #28303d; border-radius: 6px; background: rgba(255,255,255,0.03);
}
.qa-row-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qa-row-meta { grid-column: 1; color: var(--muted); font-size: 11px; }
.qa-row button {
  grid-column: 2; grid-row: 1 / span 2; min-height: 28px; border: 1px solid #2c3543; border-radius: 6px;
  background: rgba(255,255,255,0.045); color: var(--text); cursor: pointer;
}
.qa-row button:hover { border-color: var(--accent); color: #ffe0a0; }
.qa-empty { padding: 8px 9px; color: var(--muted); border: 1px dashed #2c3543; border-radius: 6px; }
.qa-reward-status { min-height: 16px; color: var(--muted); font-size: 12px; }

/* Stats window — RO Alt+A: identity header, points banner, attribute|substat
   columns. Inner sizes track --ui-scale like sibling HUD surfaces; the window
   WIDTH stays fixed (win-inv/win-skills are fixed too). */
/* Scale the window with the UI scale so the columns never crowd (the inner sizes
   all track --ui-scale; a fixed width would overflow at scale > 1). */
.window.win-stats { width: calc(520px * var(--ui-scale)); max-width: 94vw; }
.stats-grid { display: flex; flex-direction: column; gap: calc(12px * var(--ui-scale)); }
/* Two-pane character sheet: attributes (+ points) | combat readout, so it fits
   without scrolling. Collapses to one column on narrow / touch layouts. */
.stats-cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: calc(16px * var(--ui-scale)); align-items: start; }
.stats-col { display: flex; flex-direction: column; gap: calc(12px * var(--ui-scale)); min-width: 0; }
.stats-col .derived-grid { grid-template-columns: 1fr; }
@media (max-width: 560px), (pointer: coarse) { .stats-cols2 { grid-template-columns: 1fr; } }

.stats-identity {
  display: grid; grid-template-columns: 1fr auto; gap: 2px calc(10px * var(--ui-scale));
  align-items: center; padding: calc(8px * var(--ui-scale)) calc(10px * var(--ui-scale));
  border-radius: 8px; border: 1px solid #2a3342;
  background: linear-gradient(180deg, rgba(217,164,65,0.12), rgba(217,164,65,0));
}
.si-name { grid-column: 1; font-size: calc(15px * var(--ui-scale)); font-weight: 700; letter-spacing: .3px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.si-job  { grid-column: 1; font-size: calc(16px * var(--ui-scale)); font-weight: 700; letter-spacing: .3px; color: var(--accent); }
.si-levels { grid-column: 2; grid-row: 1 / span 2; display: flex; flex-direction: column; gap: 3px; align-items: flex-end; }
.si-lv { display: inline-flex; gap: 6px; align-items: baseline; }
.si-lv-k { font-size: calc(10px * var(--ui-scale)); text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.si-lv-v { font-size: calc(13px * var(--ui-scale)); font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.stats-pending-head { grid-template-columns: 1fr; }
.stats-pending-note { color: var(--muted); font-size: calc(11px * var(--ui-scale)); line-height: 1.35; }
.stats-skeleton-row { opacity: 0.82; }
.stats-skeleton,
.stats-skeleton-cell,
.stats-skeleton-num {
  color: var(--muted);
}
.stats-skeleton {
  background: rgba(138,147,163,0.12);
  border-color: rgba(138,147,163,0.2);
}
.stats-skeleton-cell { cursor: default; }
.stats-skeleton-cell:hover { border-color: #2a3342; }

.stats-points {
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(7px * var(--ui-scale)) calc(12px * var(--ui-scale));
  border-radius: 8px; border: 1px solid #2a3342; background: var(--panel-2);
}
.stats-points.has {
  border-color: var(--accent-2);
  background: linear-gradient(180deg, rgba(217,164,65,0.16), rgba(217,164,65,0.04));
}
.sp-key { font-size: calc(11px * var(--ui-scale)); text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.stats-points.has .sp-key { color: var(--text); }
.sp-val { font-size: calc(16px * var(--ui-scale)); font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.stats-points.has .sp-val { color: var(--accent); }

.stats-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.sub-col { padding-left: calc(14px * var(--ui-scale)); border-left: 1px solid #232c3a; }
.col-head {
  display: flex; align-items: center; gap: 7px;
  font-size: calc(10px * var(--ui-scale)); text-transform: uppercase; letter-spacing: .6px; color: var(--muted);
  padding-bottom: 4px; margin-bottom: 5px; border-bottom: 1px solid #232c3a;
}
/* Group-coloured tick before each section heading. */
.col-head::before {
  content: ''; flex: 0 0 auto; width: 3px; height: calc(12px * var(--ui-scale));
  border-radius: 2px; background: var(--grp, var(--accent));
}
.col-head.def { margin-top: calc(10px * var(--ui-scale)); }

/* Stat-group colour coding + meaning icons (character sheet). */
.grp-attr { --grp: var(--accent); --grp-soft: rgba(217, 164, 65, 0.14); }
.grp-off  { --grp: #e8895c; --grp-soft: rgba(232, 137, 92, 0.15); }
.grp-def  { --grp: #5aa0e0; --grp-soft: rgba(90, 160, 224, 0.15); }
.stat-ico { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; color: var(--grp, var(--accent)); }
.stat-ico svg {
  width: calc(15px * var(--ui-scale)); height: calc(15px * var(--ui-scale));
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.stat-ico svg.is-fill { fill: currentColor; stroke: none; }
.stat-ico--tile {
  width: calc(28px * var(--ui-scale)); height: calc(28px * var(--ui-scale));
  border-radius: 8px; background: var(--grp-soft); border: 1px solid var(--grp-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.stat-ico--tile svg { width: calc(17px * var(--ui-scale)); height: calc(17px * var(--ui-scale)); }
/* Derived cell: icon + label grouped on the left, value on the right. */
.derived-head { display: inline-flex; align-items: center; gap: calc(7px * var(--ui-scale)); min-width: 0; }

.attr-list { display: flex; flex-direction: column; }
/* Each attribute: full name + abbr on row 1 (with value, cost, +) and an
   always-on effect hint spanning row 2. Hover the row for the full formula. */
.attr-row {
  display: grid;
  grid-template-columns: auto 1fr auto 2.6em calc(20px * var(--ui-scale));
  align-items: center; column-gap: calc(8px * var(--ui-scale)); row-gap: 1px;
  padding: calc(7px * var(--ui-scale)) 0; border-bottom: 1px solid #1e2630; cursor: help;
}
.attr-row:last-child { border-bottom: none; }
/* The icon tile spans both rows so it centers against name + hint. */
.attr-row .stat-ico--tile { grid-row: 1 / span 2; align-self: center; }
.attr-name { display: flex; align-items: baseline; gap: 6px; min-width: 0; overflow: hidden; }
.attr-full { font-size: calc(13px * var(--ui-scale)); font-weight: 700; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.attr-val { white-space: nowrap; }
.attr-abbr { font-size: calc(10px * var(--ui-scale)); font-weight: 600; letter-spacing: .5px; color: var(--muted); }
.attr-hint { grid-column: 2 / -1; font-size: calc(10px * var(--ui-scale)); color: var(--muted); line-height: 1.25; }
.attr-label { font-size: calc(12px * var(--ui-scale)); font-weight: 700; letter-spacing: .4px; color: var(--text); }
.attr-val { text-align: right; font-size: calc(14px * var(--ui-scale)); font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Equipment/buff bonus shown after the base value (RO's blue "+N"). */
.attr-bonus { margin-left: 3px; color: #7fd0ff; font-weight: 700; font-size: calc(11px * var(--ui-scale)); }
.attr-cost {
  justify-self: center; min-width: 2ch; text-align: center; padding: 1px 5px;
  border-radius: 9px; background: var(--panel-2); border: 1px solid var(--accent-2);
  font-size: calc(10px * var(--ui-scale)); font-weight: 600; color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.attr-cost.off { color: var(--muted); border-color: #2f3a49; opacity: .55; }
.attr-plus {
  width: calc(20px * var(--ui-scale)); height: calc(20px * var(--ui-scale));
  display: grid; place-items: center;
  background: var(--panel-2); border: 1px solid var(--accent); border-radius: 4px;
  color: var(--accent); font-size: calc(14px * var(--ui-scale)); line-height: 1; cursor: pointer;
  transition: background .1s ease, color .1s ease, transform .05s ease;
}
.attr-plus:hover:not(:disabled) { background: var(--accent); color: #1a1206; }
.attr-plus:active:not(:disabled) { transform: scale(.88); }
.attr-plus:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.attr-plus:disabled { border-color: #2f3a49; color: #4a5363; cursor: default; }

.sub-row { display: flex; justify-content: space-between; align-items: baseline; padding: calc(2px * var(--ui-scale)) 0; }
.sub-label { font-size: calc(11px * var(--ui-scale)); letter-spacing: .3px; color: var(--muted); }
.sub-val { font-size: calc(12px * var(--ui-scale)); font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }

/* Redesigned character sheet (renderStats): stacked Attributes / Offense /
   Defense sections; each derived stat is a hover-for-formula cell so the sheet
   teaches its own maths. */
.stats-section { display: flex; flex-direction: column; gap: calc(6px * var(--ui-scale)); }
.derived-grid { display: grid; grid-template-columns: 1fr 1fr; gap: calc(6px * var(--ui-scale)); }
.derived-cell {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: calc(6px * var(--ui-scale)) calc(9px * var(--ui-scale));
  border-radius: 7px; border: 1px solid #2a3342;
  background: linear-gradient(180deg, var(--grp-soft, transparent), transparent), var(--panel-2);
  cursor: help; transition: border-color .12s ease, background .12s ease;
}
.derived-cell:hover { border-color: var(--grp, var(--accent-2)); }
.derived-label { font-size: calc(11px * var(--ui-scale)); color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.derived-val { font-size: calc(13px * var(--ui-scale)); font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums; flex: 0 0 auto; white-space: nowrap; }
/* Secondary read-out beside a derived value (e.g. attacks-per-second for ASPD). */
.derived-sub { margin-left: 6px; font-size: calc(10px * var(--ui-scale)); font-weight: 600; color: var(--muted); }

body.high-contrast .stats-identity,
body.high-contrast .stats-points,
body.high-contrast .attr-cost,
body.high-contrast .attr-plus { border-width: 2px; }
body.high-contrast .attr-plus:disabled { border-color: #6f7d92; color: #9aa4b3; }

/* Inventory window body: a plain vertical stack (equip paperdoll, bag header, bag
   grid, footer). NOTE: the body itself must NOT be display:grid — only the inner
   .inv-grid is the icon grid. (A stray inv-grid on the body forced every section
   into 46px columns.) */
.inv-window { display: flex; flex-direction: column; gap: 8px; }
/* Only the BAG GRID scrolls — the equipment paperdoll, search and footer stay
   pinned. The body becomes a fixed-height flex column (no body scroll); the grid
   takes the remaining space and scrolls inside it. */
.win-inv .win-body { max-height: 74vh; overflow: hidden; }
.inv-window .inv-grid {
  flex: 1 1 auto; min-height: calc(172px * var(--ui-scale)); overflow-y: auto; align-content: start;
  padding: 4px 6px 4px 0; scrollbar-width: thin; scrollbar-color: #3f4b5f rgba(10,14,20,0.55);
}
.inv-window .inv-grid::-webkit-scrollbar { width: 8px; }
.inv-window .inv-grid::-webkit-scrollbar-track { background: rgba(10,14,20,0.55); border-radius: 999px; }
.inv-window .inv-grid::-webkit-scrollbar-thumb { background: #3f4b5f; border-radius: 999px; }
.inv-window .inv-grid::-webkit-scrollbar-thumb:hover { background: #58667d; }
/* Inventory bag — RO-style icon-cell grid */
.inv-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(calc(52px * var(--ui-scale)), 1fr));
  gap: 6px; justify-content: start; box-sizing: border-box;
}
.inv-cell {
  position: relative; width: 100%; min-width: 0; aspect-ratio: 1; min-height: 46px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #1b222d, #141a23);
  border: 1px solid #2c3543; border-radius: 6px; cursor: pointer;
  transition: border-color 0.12s, transform 0.08s, box-shadow 0.12s;
}
.inv-cell:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,0.38); }
.inv-cell:active { transform: translateY(0); }
.inv-cell.equipped { border-color: var(--accent); background: #23303f; }
.inv-cell .inv-icon { width: 36px; height: 36px; pointer-events: none; }
.inv-section-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.inv-count { color: var(--muted); font-size: calc(11px * var(--ui-scale)); font-weight: 600; font-variant-numeric: tabular-nums; }
.inv-name { font-size: 12px; }
.inv-amt {
  position: absolute; right: 2px; bottom: 1px; z-index: 1;
  font-size: 10px; font-weight: 700; color: #fff; line-height: 1;
  padding: 0 2px; border-radius: 3px; background: rgba(8,12,18,0.85); text-shadow: 0 1px 1px #000;
}
.inv-refine {
  position: absolute; left: 2px; top: 1px; z-index: 1;
  font-size: 10px; font-weight: 700; color: #ffe066; line-height: 1; text-shadow: 0 1px 1px #000;
}
/* Bag / Sell tab strip — own full-width row inside the panel padding so a tab
   never sits under the window border. */
.inv-tabs { display: flex; gap: 4px; width: 100%; box-sizing: border-box; margin: 6px 0; }
.inv-tab {
  flex: 1; min-width: 0; padding: 5px 8px; cursor: pointer; font-size: 12px;
  background: var(--panel-2); border: 1px solid #2c3543; border-radius: 6px; color: var(--muted);
}
.inv-tab:hover { border-color: var(--accent); }
.inv-tab.active { background: rgba(20,28,38,0.95); color: var(--accent); border-color: var(--accent); }
.inv-bag-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; width: 100%; box-sizing: border-box; }
.inv-search {
  flex: 1; min-width: 60px; padding: 4px 7px; font-size: 12px;
  background: rgba(10,14,20,0.85); border: 1px solid #28303d; border-radius: 5px; color: #e6e6e6;
}
.inv-search:focus { outline: none; border-color: var(--accent); }
.inv-hint { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
/* Inventory cell context menu reuses .context-menu chrome; size its buttons. */
.inv-ctx .context-item {
  display: block; width: 100%; border: none; background: none; color: inherit;
  font: inherit; text-align: left; font-size: 12px; padding: 6px 10px;
}
.inv-ctx .context-item.drop { color: #d9a3a3; }
.inv-ctx .context-item.drop:hover { background: #7a3a3a; color: #fff; }

/* Skills window — rendered as the job skill tree (heading per job, dependents
   indented under their prereqs). */
.skill-list { display: flex; flex-direction: column; gap: 4px; }
/* Job-tree heading (reuses .inv-section chrome); first one has no top margin. */
.skill-tree-head:first-child { margin-top: 0; }
.skill-row {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
  background: var(--panel-2); border: 1px solid #2c3543; border-radius: 6px;
  padding: 8px 10px;
}
.skill-row:hover { border-color: var(--accent); }
/* A dependent (has a learned prereq) gets a left tree-branch accent + its inline
   margin-left indent is set per-row from the prereq depth. */
.skill-row.skill-child { border-left: 2px solid var(--accent-2); }
/* Name column wraps (its own column, up to 2 lines) so a long name never clips at
   the panel edge; the 'Lv' badge and the 'requires …' branch label ride along. */
.skill-name-col { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 6px; row-gap: 1px; flex: 1; min-width: 0; }
.skill-name {
  flex: 1; min-width: 0; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-size: calc(13px * var(--ui-scale));
}
.skill-lv { flex-shrink: 0; color: var(--muted); font-size: calc(12px * var(--ui-scale)); }
/* Prereq branch label ('↳ Bash, Provoke'), dropped onto its own line under the name. */
.skill-req { flex-basis: 100%; color: var(--muted); font-size: calc(10px * var(--ui-scale)); line-height: 1.2; }
/* Learned passive marker (shared by the fallback list + the graph detail strip). */
.skill-passive-tag {
  align-self: center; padding: 2px 8px; font-size: calc(11px * var(--ui-scale));
  color: var(--muted); border: 1px solid #2c3543; border-radius: 6px;
  background: rgba(255,255,255,0.03); white-space: nowrap;
}

/* === Skills window — real top-down skill-tree GRAPH (skill-graph.ts layout) ===
   In graph mode the body stops scrolling and becomes a flex column: a job legend
   and a selected-skill detail strip stay pinned while the tree canvas scrolls. */
/* Fixed height in graph mode so zooming (which changes content size) never grows
   or shrinks the window — the tree scrolls inside a constant frame instead. */
.win-body.skill-mode-graph { display: flex; flex-direction: column; overflow: hidden; padding: 10px; gap: 10px; height: 68vh; max-height: none; min-width: 0; }
.skill-graph-wrap { display: flex; flex-direction: column; gap: 10px; min-height: 0; min-width: 0; flex: 1; }

/* Job-colour legend: compact branch chips, secondary to the icon canvas. */
.skill-legend { display: flex; flex-wrap: wrap; gap: 6px 10px; padding: 0 2px; }
.skill-legend-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border: 1px solid #2c3543; border-radius: 999px; background: rgba(10,14,20,0.34); font-size: calc(11px * var(--ui-scale)); color: var(--muted); }
.skill-legend-chip i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 2px rgba(255,255,255,0.04); }

/* The scrolling tree canvas: dark parchment grid, not a flat table. */
.skill-graph-scroll { flex: 1; min-height: 0; min-width: 0; overflow: auto; border: 1px solid #2c3543; border-radius: 12px; background: radial-gradient(circle at 1px 1px, rgba(255,255,255,0.035) 1px, transparent 0) 0 0 / 22px 22px, linear-gradient(180deg, rgba(255,255,255,0.025), rgba(0,0,0,0.10)), var(--panel-2); box-shadow: inset 0 1px 0 rgba(255,255,255,0.03); }
.skill-graph { position: relative; }
.skill-graph-inner { position: relative; transform-origin: 0 0; }
.skill-graph-svg { position: absolute; inset: 0; pointer-events: none; overflow: visible; }

/* Toolbar: skill-point counter + zoom controls. */
.skill-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 2px; }
.skill-points { display: flex; align-items: center; gap: 8px; padding: 5px 11px; border-radius: 9px; background: linear-gradient(180deg, var(--panel), var(--panel-2)); border: 1px solid #2c3543; }
.skill-points-label { font-size: calc(11px * var(--ui-scale)); color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.skill-points-val { font-size: calc(14px * var(--ui-scale)); font-weight: 700; color: var(--muted); min-width: 1ch; text-align: center; }
.skill-points.has-points { border-color: #6fc06a; box-shadow: 0 0 0 1px rgba(111,192,106,0.25); }
.skill-points.has-points .skill-points-val { color: #9fe39a; }
.skill-zoom { display: flex; align-items: center; gap: 6px; }
.skill-zoom-val { font-size: calc(11px * var(--ui-scale)); color: var(--muted); min-width: 40px; text-align: center; }
.skill-zoom-btn { width: 26px; height: 26px; padding: 0; line-height: 1; border-radius: 7px; border: 1px solid #2c3543; background: var(--panel-2); color: var(--text); cursor: pointer; font-size: 15px; }
.skill-zoom-btn:hover:not([disabled]) { border-color: var(--accent); }
.skill-zoom-btn[disabled] { opacity: 0.4; cursor: default; }

.skill-edge { fill: none; stroke-width: 2; }
.skill-edge-ok { stroke: var(--accent); opacity: 0.72; }
.skill-edge-bad { stroke: #b65b54; opacity: 0.58; stroke-dasharray: 5 4; }

/* Large icon-first node cards: the new skill art is the primary object. */
.skill-card { position: absolute; width: 156px; height: 108px; box-sizing: border-box; display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; grid-template-rows: 48px auto; column-gap: 9px; row-gap: 7px; align-items: center; padding: 9px 10px 10px; background: linear-gradient(180deg, rgba(255,255,255,0.035), rgba(0,0,0,0.12)), var(--panel); border: 1px solid #2c3543; border-left: 4px solid var(--job-accent, #2c3543); border-radius: 11px; cursor: pointer; user-select: none; box-shadow: 0 3px 10px rgba(0,0,0,0.34); transition: border-color .12s, box-shadow .12s, transform .08s, opacity .12s; }
.skill-card:hover { transform: translateY(-1px); box-shadow: 0 7px 16px rgba(0,0,0,0.48); z-index: 1; }
.skill-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.skill-card-icon { grid-column: 1; grid-row: 1; width: 48px; height: 48px; image-rendering: auto; border-radius: 9px; box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 5px 14px rgba(0,0,0,0.32); }
.skill-card-lv { grid-column: 3; grid-row: 1; justify-self: end; align-self: start; font-size: calc(10px * var(--ui-scale)); font-weight: 800; color: var(--muted); padding: 2px 6px; border-radius: 999px; background: rgba(10,14,20,0.68); border: 1px solid rgba(255,255,255,0.06); }
.skill-card-name { grid-column: 1 / -1; grid-row: 2; align-self: start; font-size: calc(12px * var(--ui-scale)); line-height: 1.16; font-weight: 800; max-height: calc(2 * 1.16em * var(--ui-scale)); display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.skill-card.skill-learned { border-color: color-mix(in srgb, var(--accent) 72%, #2c3543); }
.skill-card.skill-learned .skill-card-lv { color: #ffe3a0; }
.skill-card.skill-learnable { border-color: #6fc06a; box-shadow: 0 0 0 1px rgba(111,192,106,0.35), 0 4px 12px rgba(0,0,0,0.38); }
.skill-card.skill-learnable .skill-card-lv { color: #bdf3b9; }
.skill-card.skill-locked { opacity: 0.54; filter: grayscale(0.62); }
.skill-card.skill-selected { border-color: #ffd479; box-shadow: 0 0 0 2px rgba(255,212,121,0.55), 0 8px 20px rgba(0,0,0,0.55); }
.skill-card-flash { animation: skill-card-flash 0.5s ease-out; }
@keyframes skill-card-flash {
  from { box-shadow: 0 0 0 3px rgba(111,192,106,0.85); }
  to { box-shadow: 0 0 0 0 transparent; }
}
body.reduce-flashing .skill-card-flash { animation: none; }
.skill-card-plus { position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; padding: 0; line-height: 20px; border-radius: 50%; border: 1px solid #6fc06a; background: #1d2a1d; color: #b9f0b3; font-size: 13px; cursor: pointer; z-index: 2; }
.skill-card-plus:hover { background: #284a28; }
.skill-card-plus--chain { border-color: #6aa8e0; background: #1a2636; color: #bcdcfb; }
.skill-card-plus--chain:hover { background: #243a52; }

/* Selected-skill preview: icon, name, short description, contextual actions. */
.skill-detail { position: relative; display: grid; grid-template-columns: 72px minmax(220px, 1fr) minmax(140px, auto); align-items: stretch; gap: 14px; min-height: 122px; padding: 12px; background: var(--panel); border: 1px solid #344052; border-left: 3px solid var(--accent); border-radius: 12px; box-shadow: inset 0 1px 0 rgba(255,255,255,0.035), 0 6px 18px rgba(0,0,0,0.24); overflow: hidden; }
.skill-detail::before { content: none; }
.skill-detail-empty { display: flex; color: var(--muted); justify-content: center; align-items: center; }
.skill-detail-hint { font-size: calc(12px * var(--ui-scale)); color: var(--muted); }
.skill-detail-icon { width: 64px; height: 64px; align-self: center; justify-self: center; image-rendering: auto; border-radius: 14px; box-shadow: 0 0 0 1px rgba(255,255,255,0.12), 0 10px 24px rgba(0,0,0,0.44), 0 0 26px rgba(217,164,65,0.10); }
.skill-detail-title { display: flex; flex-direction: column; justify-content: center; gap: 4px; min-width: 0; }
.skill-detail-kicker { display: flex; align-items: center; gap: 6px; min-height: 18px; }
.skill-detail-state { display: inline-flex; align-items: center; width: fit-content; padding: 2px 7px; border-radius: 999px; border: 1px solid #2c3543; background: rgba(10,14,20,0.48); color: var(--muted); font-size: calc(10px * var(--ui-scale)); font-weight: 900; letter-spacing: 0.07em; text-transform: uppercase; }
.skill-detail-state--learned { border-color: color-mix(in srgb, var(--accent) 55%, #2c3543); color: #ffe3a0; }
.skill-detail-state--learnable { border-color: #4f7d3d; color: #bdf3b9; }
.skill-detail-state--locked { color: #d98b8b; border-color: #6f3f3a; }
.skill-detail-name { font-weight: 950; font-size: calc(17px * var(--ui-scale)); line-height: 1.06; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); letter-spacing: 0.01em; }
.skill-detail-facts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.skill-detail-fact { display: inline-flex; align-items: center; min-height: 18px; padding: 2px 7px; border-radius: 999px; border: 1px solid rgba(255,255,255,0.07); background: rgba(10,14,20,0.44); color: color-mix(in srgb, var(--text) 72%, var(--muted)); font-size: calc(10px * var(--ui-scale)); font-weight: 800; line-height: 1.15; white-space: nowrap; }
.skill-detail-desc { display: grid; gap: 3px; margin-top: 4px; color: color-mix(in srgb, var(--muted) 86%, var(--text)); font-size: calc(11px * var(--ui-scale)); line-height: 1.25; }
.skill-detail-desc span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.skill-detail-desc span.primary { color: color-mix(in srgb, var(--text) 82%, var(--accent)); font-weight: 700; }
.skill-detail-acts { display: grid; grid-auto-rows: minmax(42px, max-content); align-content: center; gap: 8px; min-width: 140px; }
.skill-detail-action { display: grid; gap: 2px; min-height: 42px; padding: 8px 12px; border-radius: 9px; border: 1px solid #344052; background: var(--panel-2); color: var(--text); font-size: calc(12px * var(--ui-scale)); font-weight: 900; cursor: pointer; text-align: left; white-space: normal; box-shadow: inset 0 1px 0 rgba(255,255,255,0.035); }
.skill-detail-action:hover, .skill-detail-action:focus-visible { border-color: var(--accent); outline: none; box-shadow: 0 0 0 2px rgba(217,164,65,0.24); }
.skill-detail-action-label { line-height: 1.1; }
.skill-detail-action-hint { color: var(--muted); font-size: calc(10px * var(--ui-scale)); font-weight: 700; line-height: 1.05; }
.skill-detail-action--cast { background: var(--accent); border-color: color-mix(in srgb, var(--accent) 76%, #2c3543); color: #1a1206; text-shadow: none; }
.skill-detail-action--cast .skill-detail-action-hint { color: rgba(26,18,6,0.72); }
.skill-detail-action--cast:hover, .skill-detail-action--cast:focus-visible { color: #1a1206; filter: brightness(1.05); }
.skill-detail-action--bar { color: #f0d999; }
.skill-detail-action--learn { color: #bdf3b9; border-color: #4f7d3d; }
.skill-detail-note { align-self: center; font-size: calc(11px * var(--ui-scale)); color: var(--muted); white-space: normal; max-width: 180px; }

@media (max-width: 720px) { .skill-detail { grid-template-columns: 56px minmax(0, 1fr); } .skill-detail-icon { width: 52px; height: 52px; } .skill-detail-acts { grid-column: 1 / -1; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); min-width: 0; } }
/* Per-prerequisite Requires block: one line per prereq + base/job gate lines,
   shown in the rich skill tooltip (skillReqsHtml). */
.skill-req-block {
  flex-basis: 100%; display: flex; flex-direction: column; gap: 1px;
  margin-top: 2px; font-size: calc(10px * var(--ui-scale)); line-height: 1.25;
}
.skill-req-block .skill-req, .skill-req-block .skill-gate { flex-basis: auto; }
.skill-req-block .skill-gate { color: var(--muted); }
.skill-req-have { opacity: 0.85; }
/* Satisfied vs unmet prerequisite/gate colouring. */
.skill-req-ok { color: #7fc08a; }
.skill-req-bad { color: #d98b8b; }
/* Skill tooltip: synthesized description lines + the inline icon in the title. */
.tt-desc { color: var(--muted); font-size: calc(11px * var(--ui-scale)); line-height: 1.3; margin: 1px 0; }
.skill-tt-icon { width: 20px; height: 20px; vertical-align: middle; margin-right: 6px; border-radius: 4px; }

/* NPC dialog (center-bottom) */
.npc-win {
  bottom: 90px; left: 50%; transform: translateX(-50%);
  width: 460px; max-width: 90vw; flex-direction: column;
  background: var(--panel); border: 1px solid #28303d; border-radius: 10px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.5); padding: 16px; pointer-events: auto;
}
.npc-cutin {
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin: -4px 0 12px;
  padding: 8px;
  border: 1px solid color-mix(in srgb, var(--accent) 46%, #28303d);
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(230, 204, 128, 0.12), rgba(13, 18, 27, 0.72));
}
.npc-cutin-sigil {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid color-mix(in srgb, var(--accent) 58%, transparent);
  border-radius: 8px;
  background:
    radial-gradient(circle at 35% 25%, rgba(255,255,255,0.18), transparent 36%),
    linear-gradient(145deg, rgba(230,204,128,0.28), rgba(59,71,86,0.24));
  color: var(--accent);
  font-weight: 800;
  font-size: calc(15px * var(--ui-scale));
  letter-spacing: 0;
  box-shadow: inset 0 0 18px rgba(230,204,128,0.08);
}
.npc-cutin-copy { min-width: 0; }
.npc-cutin-name {
  color: var(--accent);
  font-weight: 800;
  font-size: calc(13px * var(--ui-scale));
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.npc-cutin-id {
  margin-top: 2px;
  color: var(--muted);
  font-size: calc(11px * var(--ui-scale));
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.npc-text { white-space: pre-wrap; margin-bottom: 12px; line-height: 1.4; }
.npc-progress { width: 100%; margin: 2px 0 12px; }
.npc-progress-track { position: relative; overflow: hidden; height: 12px; border: 1px solid #2c3543; border-radius: 999px; background: #111720; box-shadow: inset 0 1px 2px rgba(0,0,0,0.55); }
.npc-progress-fill { height: 100%; width: 0%; background: var(--accent); box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 45%, transparent); }
.npc-progress-text { margin-top: 5px; color: var(--muted); font-size: calc(12px * var(--ui-scale)); font-variant-numeric: tabular-nums; text-align: center; }
body.reduce-motion .npc-progress-fill { transition: none !important; }
.npc-controls { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.npc-btn {
  align-self: flex-end; padding: 7px 18px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border: none; border-radius: 6px; color: #1a1206; font-weight: 600; cursor: pointer;
}
.npc-btn:hover { filter: brightness(1.07); }
.npc-menu-item {
  width: 100%; padding: 7px 10px; background: var(--panel-2);
  border: 1px solid #2c3543; border-radius: 6px;
}
.npc-menu-item:hover { border-color: var(--accent); }
.npc-menu-item.cancel { color: var(--muted); }
.npc-input {
width: 100%; padding: 8px 10px; background: var(--panel-2);
border: 1px solid #2c3543; border-radius: 6px; color: var(--text);
}

/* Kafra storage: compact searchable item grid backed by DataGrid. */
.storage-overlay {
position: fixed; inset: 0; z-index: 36; display: flex; align-items: center; justify-content: center;
background: rgba(8,10,16,0.5);
}
.storage-panel {
width: min(720px, calc(100vw - 32px));
height: min(560px, calc(100vh - 72px));
display: flex; flex-direction: column; gap: 8px;
}
.storage-panel.storage-drop { outline: 2px dashed var(--accent); outline-offset: 4px; }
.storage-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.storage-head h1 { margin: 0; }
.storage-capacity { color: var(--muted); font-size: calc(12px * var(--ui-scale)); font-variant-numeric: tabular-nums; }
.storage-grid-host { min-height: 0; flex: 1; }
.storage-grid-host .dgrid { height: 100%; }
.storage-item-cell { min-width: 0; display: flex; align-items: center; gap: 8px; }
.storage-item-icon { width: 28px; height: 28px; border-radius: 5px; flex: none; }
.storage-item-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.storage-row-action { padding: 4px 8px; font-size: calc(11px * var(--ui-scale)); border-radius: 6px; border: 1px solid #2c3543; background: var(--panel); color: var(--text); cursor: pointer; }
.storage-row-action:hover { border-color: var(--accent); color: var(--accent); }
.storage-actions { display: flex; justify-content: flex-end; gap: 6px; }
.storage-foot { color: var(--muted); font-size: calc(11px * var(--ui-scale)); }

/* Hotbar (bottom-center) */
.hotbar {
  bottom: 12px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px;
}
.hot-slot {
  width: calc(56px * var(--ui-scale)); height: calc(56px * var(--ui-scale));
  background: linear-gradient(180deg, rgba(22,28,38,0.92), rgba(10,14,20,0.92));
  border: 1px solid #2c3543; border-radius: 9px; position: relative;
  display: flex; align-items: flex-end; justify-content: center; padding: 4px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 2px 6px rgba(0,0,0,0.4);
  transition: border-color .12s, box-shadow .12s, transform .08s;
}
.hot-slot.filled { border-color: var(--accent); box-shadow: inset 0 0 0 1px rgba(217,164,65,0.22), 0 2px 8px rgba(0,0,0,0.45); }
.hot-slot:hover { border-color: var(--accent); transform: translateY(-1px); }
.hot-key {
  position: absolute; top: 2px; left: 5px; z-index: 2;
  font-size: calc(10px * var(--ui-scale)); font-weight: 600; color: var(--muted); text-shadow: 0 1px 2px #000;
}
.hot-target {
  position: absolute; top: 2px; right: 4px; z-index: 2;
  display: grid; place-items: center;
  min-width: calc(15px * var(--ui-scale)); height: calc(15px * var(--ui-scale));
  border-radius: 999px; border: 1px solid rgba(217,164,65,0.65);
  background: rgba(8,12,18,0.78); color: var(--accent);
  font-size: calc(9px * var(--ui-scale)); font-weight: 800;
  line-height: 1; text-shadow: 0 1px 2px #000;
}
.hot-slot.needs-target { box-shadow: inset 0 0 0 1px rgba(217,164,65,0.32), 0 2px 8px rgba(0,0,0,0.45); }
/* Bottom-right corner badge: stack count for items, skill level for skills. */
.hot-name {
  position: absolute; right: 3px; bottom: 2px; z-index: 2;
  font-size: calc(11px * var(--ui-scale)); font-weight: 700; line-height: 1;
  color: #eef1f5; text-shadow: 0 1px 2px #000;
  padding: 1px 4px; border-radius: 5px; background: rgba(8,12,18,0.6);
  max-width: 84%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hot-name:empty { display: none; }

/* Chat log (lives inside .chat-wrap; positioning resolved there, not fixed here) */
.chat-log {
  max-height: 180px;
  overflow-y: auto;
  padding: 2px 2px; font-size: calc(12px * var(--ui-scale));
  pointer-events: auto;
}
.chat-line { margin: 1px 0; line-height: 1.3; word-wrap: break-word; font-size: calc(12px * var(--ui-scale)); }
.chat-line.public { color: var(--text); }
.chat-line.system { color: var(--accent); }
.chat-line.whisper { color: #4fd0e0; }
.chat-line.party { color: #5fd35f; }
.chat-line.guild { color: #e0913d; }

/* Inventory / skill rows (equipped vs bag, action buttons) */
.inv-section { display:flex; align-items:center; gap:6px; font-weight:600; color:var(--accent); margin:8px 0 4px; font-size:calc(12px * var(--ui-scale)); text-transform:uppercase; letter-spacing:0.5px; border-bottom:1px solid #28303d; padding-bottom:4px; }
/* Small accent tab before a section label, premium-HUD style. */
.inv-section::before { content:''; flex:0 0 auto; width:3px; height:12px; border-radius:2px; background:linear-gradient(180deg, var(--accent), var(--accent-2)); }
.inv-empty { color:var(--muted); font-size:12px; padding:2px 0 6px; }
/* Inventory footer — live weight bar + zeny, pinned at the bottom of the window. */
.inv-footer { flex:0 0 auto; display:flex; align-items:center; gap:10px; padding-top:8px; border-top:1px solid #28303d; }
.inv-weight-bar { position:relative; flex:1; height:16px; border-radius:5px; background:rgba(10,14,20,0.7); border:1px solid #2c3543; overflow:hidden; }
.inv-weight-fill { position:absolute; left:0; top:0; bottom:0; width:0; transition:width 0.2s ease; }
.inv-weight-text { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; font-size:10px; font-weight:600; color:#eef1f5; text-shadow:0 1px 1px #000; }
.inv-zeny { flex:0 0 auto; font-size:12px; font-weight:700; color:#ffe066; white-space:nowrap; text-shadow:0 1px 1px #000; }
.inv-row { display:flex; justify-content:space-between; align-items:center; gap:8px; padding:4px 0; }
.inv-row-name { font-size:calc(12px * var(--ui-scale)); flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
/* Equipped rows stack the name over a decoded random-option sub-line (design §6:
   "items decide who you are"), so the cell becomes a vertical flex column. */
.inv-row-name--stacked { display:flex; flex-direction:column; gap:1px; overflow:visible; white-space:normal; }
.inv-row-label { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.inv-row-opts { font-size:calc(10px * var(--ui-scale)); opacity:0.85; line-height:1.2; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.inv-row-acts { display:flex; gap:4px; flex-shrink:0; }
.inv-act {
  pointer-events:auto; font-size:11px; padding:3px 8px; cursor:pointer;
  background:var(--panel-2); border:1px solid var(--accent); border-radius:5px; color:var(--accent);
}
.inv-act:hover { background:var(--accent); color:#1a1206; }
.inv-act.drop { border-color:#5a4453; color:#a98; }
.inv-act.drop:hover { background:#7a3a3a; color:#fff; border-color:#7a3a3a; }

/* Target HUD (top-center) with HP bar */
.target-panel { top: 50px; left: 50%; transform: translateX(-50%); flex-direction: column;
  align-items: center; gap: 4px; background: rgba(10,14,20,0.82); border: 1px solid #28303d;
  border-radius: 8px; padding: 6px 14px; min-width: 160px; pointer-events: none; }
.target-name { font-weight: 700; font-size: calc(14px * var(--ui-scale)); text-shadow: 0 1px 2px #000; }
.target-hp { position: relative; width: 100%; height: calc(16px * var(--ui-scale)); min-height: 16px; background: #2a1316;
  border: 1px solid #3a4453; border-radius: 4px; overflow: hidden;
  /* the OOR range cue fades rather than snaps as the player crosses the boundary
     cell (the one meaningful instant); gated off under reduce-flashing/motion. */
  transition: border-color 0.12s ease; }
.target-hp-fill { height: 100%; width: 100%; background: linear-gradient(90deg,#c0392b,#e0533d);
  position: relative; z-index: 1; transition: width 0.15s, background 0.15s; }
/* Recent-damage ghost behind the target fill (mirrors the self .hp-ghost): JS snaps
   it up on a heal and lets its width lag (~400ms) on a hit, so the exposed strip
   reads the size of the last landed hit at a glance. */
.target-hp-fill.target-hp-ghost {
  position: absolute; left: 0; top: 0; z-index: 0;
  background: linear-gradient(90deg, #7a1f17, #a3392f);
  transition: width 0.4s ease-out;
}
body.reduce-flashing .target-hp-fill.target-hp-ghost { transition: none; }
/* Execute range: shift the fill yellow→orange so a near-dead target reads as a
   "commit the kill" cue at a glance (colour only; numbers are unchanged). */
.target-hp-fill.execute { background: linear-gradient(90deg,#e0b020,#f5853a); }
.target-hp-text { position: absolute; inset: 0; z-index: 2; text-align: center; font-size: calc(11px * var(--ui-scale)); line-height: calc(16px * var(--ui-scale));
  color: #fff; text-shadow: 0 1px 1px #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding: 0 calc(30px * var(--ui-scale)); pointer-events: none; }

/* Target unit frame (ElvUI-grade): horizontal portrait tile + body column. The
   base .target-panel rule above keeps top/left/transform/pointer-events; this
   only reshapes the panel from a column into a row and adds the new sub-nodes. */
.target-panel.unit-frame { flex-direction: row; align-items: flex-start; gap: 8px;
  min-width: 240px; max-width: 300px; padding: 7px 9px; background: rgba(8,11,16,0.88);
  border: 1px solid #28303d; border-radius: 9px; box-shadow: 0 4px 14px rgba(0,0,0,.45); }

.target-portrait { position: relative; width: calc(54px * var(--ui-scale)); height: calc(54px * var(--ui-scale));
  flex: 0 0 auto; border-radius: 7px; border: 1px solid #3a4453; overflow: hidden;
  background: #0c1016 center/cover no-repeat; display: flex; align-items: center; justify-content: center;
  /* colour is only seen by the headless race/element-initial fallback (textContent
     is '' once the canvas portrait renders); #9aa7b5 keeps it legible (~8:1). */
  font: 700 calc(20px * var(--ui-scale))/1 'Segoe UI', sans-serif; color: #9aa7b5; }
/* Live 3D model viewport — absolutely fills the tile behind the size/weak overlays;
   shown only when a model is mounted (.has-3d), which also drops the 2D emblem + the
   initial-letter fallback so the two never stack. */
.target-portrait > canvas.tgt-3d { position: absolute; inset: 0; width: 100%; height: 100%; display: none; }
.target-portrait.has-3d > canvas.tgt-3d { display: block; }
.target-portrait.has-3d { background-image: none !important; }
.target-portrait.has-3d .target-portrait-initial { display: none; }
.target-portrait.elite { border-color: #ffb030; box-shadow: 0 0 6px rgba(255,176,48,.45); }
.target-portrait.mvp { border-color: #ffd54a; box-shadow: 0 0 8px rgba(255,213,74,.55);
  animation: tgt-mvp-breath 2.4s ease-in-out infinite; }
@keyframes tgt-mvp-breath { 0%,100% { box-shadow: 0 0 6px rgba(255,213,74,.40); } 50% { box-shadow: 0 0 12px 2px rgba(255,213,74,.70); } }

.target-size-pip { position: absolute; top: 1px; left: 1px; font: 700 calc(9px * var(--ui-scale))/1 monospace;
  padding: 1px 3px; border-radius: 3px; background: rgba(0,0,0,.6); color: #dfe3ea; }
.target-weak { position: absolute; right: 0; bottom: 0; display: flex; align-items: center; gap: 1px;
  padding: 1px 2px; background: rgba(0,0,0,.66); border-top-left-radius: 5px; }
.target-weak-glyph { width: calc(13px * var(--ui-scale)); height: calc(13px * var(--ui-scale)); display: block; }
.target-weak-chev { font: 700 calc(9px * var(--ui-scale))/1 monospace; color: #fff; }

.target-body { display: flex; flex-direction: column; flex: 1; min-width: 0; gap: 3px; }
.target-head { display: flex; align-items: baseline; gap: 6px; justify-content: space-between; }
.unit-frame .target-name { font-weight: 700; font-size: calc(14px * var(--ui-scale)); text-shadow: 0 1px 2px #000;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.target-dist { font-size: calc(11px * var(--ui-scale)); color: #9aa7b5; font-variant-numeric: tabular-nums;
  white-space: nowrap; flex: 0 0 auto; transition: color 0.12s ease; }
.target-dist.oor { color: var(--danger,#e0533d); }

.target-class { display: flex; gap: 4px; flex-wrap: wrap; }
.tgt-class-chip { display: inline-flex; align-items: center; gap: 3px; font-size: calc(10px * var(--ui-scale));
  line-height: 1.4; padding: 0 5px 0 3px; border-radius: 7px; border: 1px solid #3a4453;
  background: rgba(255,255,255,.04); color: #cdd3dd; }
.tgt-class-chip img { width: 12px; height: 12px; display: block; }
/* .elem chip borderColor and .tier chip borderColor are set INLINE per target from
   ELEMENT_HEX / TIER_FRAME (data-driven, no per-element classes). The elem text
   colour rides a --elem-color custom property so body.high-contrast (below) still
   outranks it and forces #fff — an inline colour would have beaten the override. */
.tgt-class-chip.elem { color: var(--elem-color, #cdd3dd); }

.target-hp-pct { position: absolute; right: 5px; top: 0; z-index: 3; line-height: calc(16px * var(--ui-scale));
  font: 700 calc(10px * var(--ui-scale))/calc(16px * var(--ui-scale)) 'Segoe UI', sans-serif; color: #fff; text-shadow: 0 1px 1px #000;
  font-variant-numeric: tabular-nums; }
.target-cast {
  position: relative; width: 100%; height: calc(13px * var(--ui-scale)); min-height: 13px;
  margin-top: 2px; background: #2a2410; border: 1px solid #5a4a20; border-radius: 4px; overflow: hidden;
}
.target-cast-fill {
  height: 100%; width: 100%; background: linear-gradient(90deg,#e0b020,#f5d35a);
  transition: width 0.06s linear;
}
.target-cast-label {
  position: absolute; inset: 0; z-index: 2; padding: 0 5px; text-align: center;
  font: 700 calc(10px * var(--ui-scale))/calc(13px * var(--ui-scale)) 'Segoe UI', sans-serif;
  color: #fff; text-shadow: 0 1px 1px #000; pointer-events: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.target-cast.interrupted { border-color: #ff6b6b; }
.target-cast.interrupted .target-cast-fill { background: #ff6b6b; }
.target-cast.interrupted .target-cast-label { color: #ff6b6b; }
.target-status { justify-content: flex-start; }  /* override the centered default */

@media (prefers-reduced-motion: reduce) {
  .target-portrait.mvp { animation: none; box-shadow: 0 0 8px rgba(255,213,74,.55); }
}
/* Mirrors the existing .target-hp-ghost reduce-flashing gate above. */
body.reduce-flashing .target-portrait.mvp { animation: none; box-shadow: 0 0 8px rgba(255,213,74,.55); }
body.high-contrast .tgt-class-chip { border-width: 2px; color: #fff; }

/* Hotbar slot flash when a skill is assigned */
.hot-slot.flash { animation: hotflash 0.6s ease-out; }
@keyframes hotflash { 0% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }

/* Hotbar rejected-action pulse, fed by server acks so failures point back to the pressed slot. */
.hot-slot.failed { animation: hotfail 0.42s ease-out; }
@keyframes hotfail {
  0% { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 72%, transparent); transform: translateX(-2px); }
  35% { transform: translateX(2px); }
  100% { box-shadow: 0 0 0 0 transparent; transform: translateX(0); }
}
body.reduce-flashing .hot-slot.failed { animation: none; border-color: var(--danger); }

/* Hotbar slot 'ready' pulse the moment a skill comes off cooldown (re-press cue) */
.hot-slot.ready { animation: hotready 0.5s ease-out; }
@keyframes hotready { 0% { box-shadow: 0 0 0 3px var(--accent-2, #5fd38a); } 100% { box-shadow: 0 0 0 0 transparent; } }

/* Entity right-click context menu */
/* Popover spawned from a window (bag context menu). z-index sits ABOVE the window
   stacking band (raiseWindow caps windows at 119) so a raised window can never
   render on top of its own menu. */
.context-menu {
  position: fixed; z-index: 200; min-width: 130px; background: rgba(12,16,24,0.97);
  border: 1px solid #3a4453; border-radius: 7px; padding: 4px; box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  pointer-events: auto; display: flex; flex-direction: column; /* items stack as a list */
}
.context-title { font-weight: 700; font-size: 12px; color: var(--accent); padding: 4px 8px 6px; border-bottom: 1px solid #28303d; }
.context-item { width: 100%; text-align: left; font-size: calc(13px * var(--ui-scale)); padding: 7px 10px; border-radius: 5px; cursor: pointer; }
.context-item:hover { background: var(--accent); color: #1a1206; }

/* Buff/debuff status tray (top-left, clear of the taller status panel) */
.status-tray { top: calc(244px * var(--ui-scale)); left: calc(324px * var(--ui-scale)); display: flex; flex-wrap: wrap; gap: 4px; max-width: calc(220px * var(--ui-scale)); }
.status-icon {
  position: relative;
  width: calc(40px * var(--ui-scale)); height: calc(40px * var(--ui-scale));
  background: rgba(10,14,20,0.9); border: 1px solid var(--accent-2);
  border-radius: 6px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: auto; cursor: default;
  --frac: 1;
}
/* Duration-depletion ring: a conic sweep (full at --frac:1, empty at 0) lets a
   player glance-read how close a Stun/Cloaking/buff is to expiring without
   parsing the tiny numeric label (which stays as the redundant channel). The
   --frac CSS var is set per tick by setStatuses; only timed statuses opt in. */
.status-icon.timed::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; z-index: 0;
  pointer-events: none;
  background: conic-gradient(
    var(--ring, rgba(255,255,255,0.16)) calc(var(--frac) * 360deg),
    transparent 0
  );
  /* Hollow it into a ring so the abbr/time stay legible over the icon body. */
  -webkit-mask: radial-gradient(circle, transparent 58%, #000 60%);
  mask: radial-gradient(circle, transparent 58%, #000 60%);
}
.status-icon.timed.buff { --ring: rgba(111,208,106,0.55); }
.status-icon.timed.debuff { --ring: rgba(224,83,61,0.6); }
/* Keep the inner content above the ring. */
.status-icon .status-abbr, .status-icon .status-time { position: relative; z-index: 1; }
.status-abbr { font-size: calc(11px * var(--ui-scale)); font-weight: 700; color: var(--accent); }
.status-time { font-size: calc(9px * var(--ui-scale)); color: var(--muted); }
/* Art-faced status tiles: the family's procedural icon fills the tile face; the
   countdown rides a dark scrim pinned to the base so it stays legible over the
   art. The depletion ring (::before) still sweeps on top. */
.status-icon.arted {
  background-size: cover; background-position: center; background-repeat: no-repeat;
  justify-content: flex-end; cursor: help;
}
.status-icon.arted .status-time {
  width: 100%; text-align: center; color: #fff; font-weight: 700;
  text-shadow: 0 1px 2px #000; line-height: 1.6;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
  border-radius: 0 0 5px 5px;
}
.status-icon.arted .status-time:empty { background: none; }
/* Focused target's buff/debuff chips under the HP/cast bars — compact art tiles
   sharing the tray's buff(green)/debuff(red) frame semantics. */
.tgt-status-chip {
  width: calc(20px * var(--ui-scale)); height: calc(20px * var(--ui-scale)); border-radius: 4px;
  background-size: cover; background-position: center; background-repeat: no-repeat;
  border: 1px solid #4f9d4f; pointer-events: auto;
}
.tgt-status-chip.debuff { border-color: var(--danger); }
/* Buffs read green, harmful debuffs/CC read red and pulse so a Stun/Freeze
   threat is unmistakable. Colour is backed by a ⚠ in the title + the abbr text,
   so meaning survives colourblindness. */
.status-icon.buff { border-color: #4f9d4f; }
.status-icon.buff .status-abbr { color: #6fd06a; }
.status-icon.debuff { border-color: var(--danger); animation: debuff-pulse 1.1s ease-in-out infinite; }
.status-icon.debuff .status-abbr { color: #ff8a76; }
/* Overflow chip: collapses the auras beyond the tray cap into one '+N' tile
   (full name list in its title) so the tray never grows past its max-width and
   pushes a survival-critical Stun/Freeze out of view. */
.status-icon.status-overflow { border-style: dashed; border-color: var(--accent-2); cursor: help; }
.status-icon.status-overflow .status-abbr { color: var(--muted); }
@keyframes debuff-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(224,83,61,0); }
  50% { box-shadow: 0 0 7px 1px rgba(224,83,61,0.7); }
}
/* Bottom-fill fallback for engines lacking conic-gradient or CSS mask: a thin
   bar across the icon's base whose width tracks --frac, conveying the same
   remaining-fraction read as the ring above. */
@supports not (background: conic-gradient(#000 0deg, #000 0)) {
  .status-icon.timed::before {
    inset: auto 0 0 0; height: 3px; border-radius: 0 0 6px 6px;
    width: calc(var(--frac) * 100%);
    background: var(--ring, rgba(255,255,255,0.3)); -webkit-mask: none; mask: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .status-icon.debuff { animation: none; box-shadow: 0 0 6px 1px rgba(224,83,61,0.6); }
  /* The depletion ring is updated by discrete per-tick var writes, but pin out
     any transition so it can never tween under reduced-motion. */
  .status-icon.timed::before { transition: none; }
}

/* Item tooltip */
.item-tooltip {
  position: fixed; z-index: 210; min-width: 150px; max-width: 210px; pointer-events: none;
  background: rgba(8,12,18,0.97); border: 1px solid #3a4453; border-radius: 7px; padding: 8px 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.55);
}
.tt-name { font-weight: 700; font-size: calc(13px * var(--ui-scale)); margin-bottom: 4px; }
.tt-line { font-size: calc(11px * var(--ui-scale)); color: #b8c0cc; margin: 1px 0; }
.tt-on { color: var(--accent); }
.tt-id { font-size: 10px; color: var(--muted); margin-top: 4px; }
/* Structured stat-tooltip body: a scannable rate → effect list (Status sheet). */
.tt-rowlabel { font-size: calc(10px * var(--ui-scale)); text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); margin: 6px 0 3px; }
.tt-stats { display: grid; grid-template-columns: auto 1fr; gap: 3px calc(10px * var(--ui-scale)); }
.tt-amt { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.tt-eff { color: #cdd3dd; font-size: calc(11px * var(--ui-scale)); }

/* Info bar (bottom-right): fps · coords · clock */
.info-bar {
  position: fixed; bottom: 8px; right: 12px; z-index: 18; pointer-events: none;
  font-size: 11px; color: #8a93a3; text-shadow: 0 1px 2px #000;
  background: rgba(10,14,20,0.5); padding: 2px 8px; border-radius: 5px;
}

/* Notification toasts (center, above hotbar) */
.toast-layer { position: fixed; top: 120px; left: 50%; transform: translateX(-50%); z-index: 36;
  display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast {
  padding: 8px 18px; border-radius: 8px; font-weight: 600; font-size: 14px; text-shadow: 0 1px 2px #000;
  background: rgba(10,14,20,0.92); border: 1px solid #3a4453; opacity: 0; transform: translateY(-8px);
  transition: opacity 0.3s, transform 0.3s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-levelup { color: #ffe066; border-color: var(--accent); }
.toast-item { color: #9be07a; border-color: #4f7d3d; }
.toast-info { color: #cdd3dd; }
.toast-loot { display:flex; align-items:center; gap:10px; padding:7px 12px 7px 8px; min-width:220px; color:var(--text); border-color:rgba(255,210,90,0.68); box-shadow:0 8px 22px rgba(0,0,0,0.28); }
.toast-loot-icon { width:34px; height:34px; flex:0 0 auto; border-radius:7px; image-rendering:auto; box-shadow:0 0 0 1px rgba(255,255,255,0.08), 0 0 12px rgba(255,210,90,0.16); }
.toast-loot-copy { display:flex; flex-direction:column; gap:1px; min-width:0; flex:1 1 auto; line-height:1.1; }
.toast-loot-label { color:var(--accent); font-size:10px; font-weight:800; letter-spacing:0.08em; text-transform:uppercase; }
.toast-loot-name { color:var(--text); font-size:13px; font-weight:800; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.toast-loot-qty { flex:0 0 auto; min-width:28px; padding:3px 7px; border-radius:999px; text-align:center; color:#fff5c2; background:rgba(255,210,90,0.16); border:1px solid rgba(255,210,90,0.42); font-weight:900; }

/* Clickable chat speaker name (whisper) + scrollable chat log */
.chat-name { color: #9fd3ff; cursor: pointer; pointer-events: auto; font-weight: 600; }
.chat-name:hover { text-decoration: underline; }
.chat-log { pointer-events: auto; overflow-y: auto; }

/* Map-name banner on entry */
.map-banner {
  position: fixed; top: 28%; left: 50%; transform: translate(-50%,-50%) scale(0.9);
  z-index: 30; pointer-events: none; font-size: 34px; font-weight: 800; letter-spacing: 1px;
  color: #fff; text-shadow: 0 2px 10px #000, 0 0 24px rgba(217,164,65,0.5);
  opacity: 0; transition: opacity 0.6s ease, transform 0.6s ease;
}
.map-banner.show { opacity: 1; transform: translate(-50%,-50%) scale(1); }

/* Draggable windows need pointer events + fixed positioning */
.window { pointer-events: auto; }
.win-head { user-select: none; }

/* Hotbar skill cooldown overlay */
.hot-slot { position: relative; overflow: hidden; }
.hot-cd {
  position: absolute; left: 0; bottom: 0; width: 100%;
  background: rgba(10,14,20,0.72); display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px #000; pointer-events: none;
}

/* Weight bar (status panel) + hover cell + window stacking */
.weight-row { position: relative; height: calc(16px * var(--ui-scale)); background: #1a2028; border: 1px solid #28303d;
  border-radius: 4px; overflow: hidden; margin-top: 0; min-width: 0; }
.weight-fill { position: absolute; left: 0; top: 0; height: 100%; background: #4f9d4f; transition: width 0.2s, background 0.2s; }
.weight-text { position: absolute; inset: 0; text-align: center; font-size: calc(10px * var(--ui-scale)); line-height: calc(16px * var(--ui-scale));
  color: #fff; text-shadow: 0 1px 1px #000; }

/* Map transition fade */
.map-transition {
  position: fixed; inset: 0; z-index: 44; pointer-events: none; background: #05070b;
  opacity: 0; transition: opacity 0.28s ease;
}
.map-transition.show { opacity: 1; pointer-events: auto; }

.virtual-stick {
  position: fixed;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 19;
  display: none;
  width: 112px;
  height: 112px;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}
.virtual-stick-base {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(217,164,65,0.45);
  border-radius: 999px;
  background: radial-gradient(circle at center, rgba(230,204,128,0.15), rgba(10,14,20,0.58) 62%, rgba(10,14,20,0.74));
  box-shadow: 0 12px 28px rgba(0,0,0,0.42), inset 0 0 18px rgba(230,204,128,0.08);
}
.virtual-stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 42px;
  height: 42px;
  margin: -21px 0 0 -21px;
  border: 1px solid rgba(230,204,128,0.78);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(230,204,128,0.92), rgba(158,111,45,0.86));
  box-shadow: 0 5px 16px rgba(0,0,0,0.42), inset 0 1px 0 rgba(255,255,255,0.28);
}
.virtual-stick.active .virtual-stick-base {
  border-color: rgba(230,204,128,0.86);
  background: radial-gradient(circle at center, rgba(230,204,128,0.23), rgba(10,14,20,0.6) 62%, rgba(10,14,20,0.78));
}
@media (pointer: coarse) {
  .virtual-stick { display: block; }
}

/* Safe-zone compass (BR) */
.safe-compass { position: fixed; top: 96px; left: 50%; transform: translateX(-50%); z-index: 17;
  pointer-events: none; text-align: center; }
.safe-arrow { font-size: 30px; color: #7fd0ff; text-shadow: 0 0 8px rgba(127,208,255,0.8), 0 2px 3px #000; line-height: 1; }
.safe-dist { font-size: 11px; color: #cfe6ff; text-shadow: 0 1px 2px #000; margin-top: 2px; }

/* Off-screen threat / aggro indicator (BR): a chevron flashing on the screen
   edge toward an attacker that hit us from off-screen. */
.threat-chevron { position: fixed; z-index: 18; pointer-events: none;
  font-size: 34px; color: #ff5a4a; line-height: 1;
  text-shadow: 0 0 10px rgba(255,90,74,0.9), 0 2px 4px #000; opacity: 0; }
.threat-chevron.show { animation: threat-flash 1s ease-out; }
@keyframes threat-flash {
  0% { opacity: 0; }
  12% { opacity: 1; }
  60% { opacity: 0.9; }
  100% { opacity: 0; }
}
body.reduce-flashing .threat-chevron.show { animation: none; opacity: 0.85; }

/* ESC-menu dropdowns (palette / shadows / FPS cap) */
.menu-select { width: 100%; padding: 6px 8px; border-radius: 6px;
  background: rgba(10,14,20,0.8); border: 1px solid #28303d; color: #e6e6e6;
  font-size: calc(12px * var(--ui-scale)); cursor: pointer; }
.menu-select:hover { border-color: var(--accent); }

/* Inventory item icons */
.inv-icon { flex-shrink: 0; image-rendering: auto; border-radius: 5px; }
.inv-row { align-items: center; gap: 8px; }

/* Equipment paperdoll — a real-RO equip surface: worn gear down the left column,
   held gear + accessories down the right, a character figure in the middle. Click
   a filled slot to unequip; drag a bag item onto a matching slot to equip; the
   hover/focus tooltip carries refine/options/cards. */
.paperdoll {
  display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center;
  margin-bottom: 2px; padding: 10px;
  background: radial-gradient(120% 90% at 50% 0%, rgba(36,46,62,0.5), rgba(8,12,18,0.5));
  border: 1px solid #2c3543; border-radius: 8px;
}
.pd-col { display: flex; flex-direction: column; gap: 6px; }
.pd-slot {
  position: relative; width: 44px; height: 44px; display: flex;
  align-items: center; justify-content: center; text-align: center;
  background: linear-gradient(160deg, rgba(22,28,38,0.9), rgba(12,16,22,0.9));
  border: 1px solid #2c3543; border-radius: 6px; cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.pd-slot.pd-filled { border-color: var(--accent); background: linear-gradient(160deg, #1e2a3a, #16202c); }
.pd-slot:not(.pd-filled) { cursor: default; }
.pd-slot:not(.pd-filled):hover { border-color: #3a4555; }
.pd-slot.pd-filled:hover { box-shadow: 0 0 0 1px var(--accent) inset, 0 0 10px rgba(80,140,200,0.25); }
.pd-label { font-size: 9px; line-height: 1.15; color: var(--muted); padding: 0 2px; overflow-wrap: anywhere; }
/* Character figure placeholder between the two slot columns. */
.pd-figure { display: flex; align-items: center; justify-content: center; min-width: 64px; align-self: stretch; }
.pd-figure svg { width: 80%; max-width: 84px; height: auto; fill: #46566a; filter: drop-shadow(0 3px 6px rgba(0,0,0,0.4)); }
/* Refine (+N) corner badge on a filled slot, mirroring the bag cell. */
.pd-refine { position: absolute; left: 2px; top: 1px; z-index: 1;
  font-size: 10px; font-weight: 700; color: #ffe066; line-height: 1; text-shadow: 0 1px 1px #000; }

/* Drag-and-drop equip */
.inv-draggable { cursor: grab; }
.inv-draggable:active { cursor: grabbing; }
.pd-slot.pd-drop { border-color: #6fd06a; box-shadow: 0 0 0 2px rgba(111,208,106,0.5) inset; }

/* Compact equipped-roll readout: only rolled/carded gear appears, so the loot
   identity is visible without turning the paperdoll into a second inventory. */
.equip-roll-summary { display: grid; gap: 3px; margin: 4px 0 2px; }
.equip-roll-row {
display: grid; grid-template-columns: minmax(72px, 0.7fr) minmax(0, 1fr); gap: 6px;
align-items: baseline; padding: 3px 6px; border-left: 2px solid var(--accent);
background: rgba(255,255,255,0.035); border-radius: 4px;
}
.equip-roll-name,
.equip-roll-options { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.equip-roll-name { font-size: calc(10px * var(--ui-scale)); color: #eef1f5; }
.equip-roll-options { font-size: calc(10px * var(--ui-scale)); color: var(--muted); }

/* Accessibility: visible keyboard-focus ring (mouse clicks don't trigger it) */
:focus-visible { outline: 2px solid #7fd0ff; outline-offset: 2px; }
button:focus-visible, .menu-btn:focus-visible, .hot-slot:focus-visible, .inv-act:focus-visible {
  outline: 2px solid #7fd0ff; outline-offset: 1px;
}
/* Respect reduced-motion for non-essential transitions */
@media (prefers-reduced-motion: reduce) {
  .toast, .map-banner, .map-transition, .target-hp-fill, .target-hp, .target-dist, .weight-fill, .menu-btn { transition: none !important; }
}

/* Server broadcast / announcement banner (top strip) */
.announce-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 38; pointer-events: none;
  padding: 7px 16px; text-align: center; font-weight: 600; font-size: 13px; color: #ffe9a8;
  background: linear-gradient(90deg, rgba(60,40,10,0) 0%, rgba(80,55,12,0.92) 20%, rgba(80,55,12,0.92) 80%, rgba(60,40,10,0) 100%);
  text-shadow: 0 1px 2px #000; transform: translateY(-110%); transition: transform 0.35s ease;
}
.announce-bar.show { transform: translateY(0); }

/* Touch + responsive layout (I10) */
#game-canvas { touch-action: none; } /* prevent browser gestures eating taps */
@media (max-width: 820px), (pointer: coarse) {
  .hot-slot { width: 52px; height: 52px; } /* bigger touch targets */
  .menu-btn { width: 48px; height: 48px; } /* bigger touch target */
  .menu-glyph, .menu-icon { width: 38px; height: 38px; }
  .inv-act { padding: 8px 12px; } /* finger-friendly */
  .window { max-width: 94vw; }
  .chat-wrap { width: 64vw; }
  .status-tray { max-width: 60vw; }
  .target-panel.unit-frame { min-width: 200px; max-width: 78vw; }
}
@media (max-width: 560px) {
  .info-bar { font-size: 9px; }
  .menu-buttons { transform: scale(0.92); }
  .target-class { display: none; } /* drop the class strip on very narrow viewports */
}

/* Chat panel: one translucent box stacking tabs + scrollable log + input
   bottom-left, so a player can read messages and see where to type. */
.chat-wrap {
  position: fixed; bottom: 12px; left: 12px; z-index: 19; width: 360px; max-width: 92vw;
  display: flex; flex-direction: column;
  background: rgba(10,14,20,0.78); border: 1px solid #28303d; border-radius: 8px;
  padding: 6px; box-shadow: 0 8px 24px rgba(0,0,0,0.4); pointer-events: auto;
}
.chat-tabs { display: flex; gap: 3px; margin-bottom: 4px; pointer-events: auto; }
.chat-tab {
  font-size: 11px; padding: 3px 9px; cursor: pointer; border-radius: 5px;
  background: rgba(10,14,20,0.7); border: 1px solid #28303d; color: var(--muted);
}
.chat-tab.active { background: rgba(20,28,38,0.95); color: var(--accent); border-color: var(--accent); }
.chat-tab { position: relative; display: inline-flex; align-items: center; gap: 5px; }
/* Per-tab unread badge: count of unseen lines in that tab's channels. */
.chat-badge {
  min-width: 16px; padding: 0 4px; border-radius: 9px; font-size: 10px; line-height: 15px;
  text-align: center; color: #1a1206; font-weight: 700;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
}
/* Timestamp toggle sits at the end of the tab strip, pushed right. */
.chat-ts-toggle { margin-left: auto; padding: 3px 7px; }
.chat-log { max-height: 150px; overflow-y: auto; }
/* 'New messages ↓' catch-up pill: shown only when a line arrives while the player
   has scrolled up; click re-pins to the bottom. */
.chat-new-msgs {
  align-self: center; margin-top: 3px; padding: 2px 12px; cursor: pointer;
  font-size: 11px; font-weight: 600; color: #1a1206; pointer-events: auto;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border: none; border-radius: 10px; box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.chat-new-msgs:hover { filter: brightness(1.08); }
/* Chat entry box, directly under the log inside the same panel. */
.chat-input {
  width: 100%; box-sizing: border-box; padding: 7px 9px; margin-top: 5px;
  background: rgba(10,14,20,0.85); border: 1px solid #28303d; border-radius: 6px;
  color: #e6e6e6; font-size: calc(12px * var(--ui-scale));
}
.chat-input:focus { outline: none; border-color: var(--accent); }
/* Line kinds beyond the per-channel colors above (set in chat-view.row). */
.chat-line.channel { color: var(--accent-2); }
.chat-line.server { color: #8fd6ff; }
.chat-line.announce { color: var(--accent); font-weight: 600; }
.chat-line.error { color: #ff7a7a; }
.chat-line.emote { color: #c9a0ff; font-style: italic; }
.chat-source {
  display: inline-block;
  margin-right: 4px;
  padding: 0 4px;
  border: 1px solid rgba(143, 214, 255, 0.45);
  border-radius: 4px;
  color: #c9ecff;
  background: rgba(65, 157, 220, 0.18);
  font-size: 0.85em;
  font-weight: 700;
  line-height: 1.25;
  text-transform: uppercase;
}
/* Optional timestamp gutter, toggled by the 🕘 button. */
.chat-time { color: var(--muted); font-size: 0.85em; opacity: 0.8; }

/* Quantity / confirm modal (drop, withdraw, skill level) */
.qd-overlay {
  position: fixed; inset: 0; z-index: 220; display: flex;
  align-items: center; justify-content: center; background: rgba(8, 10, 16, 0.55);
}
.qd-panel { width: 320px; }
.qd-field { margin: 14px 0 18px; }
.qd-field input[type='number'] {
  width: 100%; padding: 9px 12px; background: var(--panel-2);
  border: 1px solid #2c3543; border-radius: 8px; color: var(--text); font-size: 14px;
}
.qd-field input[type='number']:focus { outline: none; border-color: var(--accent); }
.qd-slider { width: 100%; margin-top: 10px; accent-color: var(--accent); }
.qd-actions { display: flex; gap: 8px; }
.qd-actions .primary { flex: 1; }
.qd-cancel {
  flex: 1; padding: 11px; background: var(--panel-2); border: 1px solid #2c3543;
  border-radius: 8px; color: var(--text); font-weight: 600; font-size: 15px; cursor: pointer;
}
.qd-cancel:hover { border-color: var(--accent); }
.qd-ok.qd-danger { background: linear-gradient(180deg, #e0533d, #b3382a); color: #fff; }

/* Low-HP urgency: pulsing HP bar + red screen-edge vignette */
.bar-fill.hp.critical { animation: hp-pulse 0.7s ease-in-out infinite; }
@keyframes hp-pulse {
  0%, 100% { background: linear-gradient(90deg, #c0392b, #e0533d); filter: brightness(1); }
  50% { background: linear-gradient(90deg, #ff5a44, #ff8a76); filter: brightness(1.5); }
}
/* Out-of-SP urgency: pulse the SP bar (cool/blue) — the caster's no-verbs cue. */
.bar-fill.sp.critical { animation: sp-pulse 0.7s ease-in-out infinite; }
@keyframes sp-pulse {
  0%, 100% { background: linear-gradient(90deg, #2471a3, #3498db); filter: brightness(1); }
  50% { background: linear-gradient(90deg, #4aa3ff, #8fd0ff); filter: brightness(1.5); }
}
.status-panel.critical { border-color: var(--danger); }
.crit-vignette {
  position: fixed; inset: 0; z-index: 9; pointer-events: none; opacity: 0;
  box-shadow: inset 0 0 110px 30px rgba(224, 53, 45, 0.55);
  transition: opacity 0.3s ease;
}
.crit-vignette.show { opacity: 1; animation: vignette-pulse 1.4s ease-in-out infinite; }
@keyframes vignette-pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .bar-fill.hp.critical, .bar-fill.sp.critical, .crit-vignette.show { animation: none; }
}
/* Menu opt-in ("Reduce screen flashing") quiets the strongest pulsing flashes,
   mirroring the OS prefers-reduced-motion block above (which only the OS sets).
   Without this the low-HP bar, crit vignette and debuff icons kept pulsing for
   users who opted in via the menu rather than the OS. */
body.reduce-flashing .bar-fill.hp.critical,
body.reduce-flashing .bar-fill.sp.critical,
body.reduce-flashing .crit-vignette.show,
body.reduce-flashing .status-icon.debuff { animation: none; }

/* In-app "Reduce motion" body class (Group A's ESC-menu checkbox). The renderer's
   JS damping only covers ambient/storm motion; these rules kill the DOM keyframe
   animations + transitions the OS @media(prefers-reduced-motion) blocks above
   disable, so an opted-in user (not just an OS-set one) gets the same stillness. */
body.reduce-motion .toast,
body.reduce-motion .map-banner,
body.reduce-motion .map-transition,
body.reduce-motion .target-hp-fill,
body.reduce-motion .target-hp,
body.reduce-motion .target-dist,
body.reduce-motion .weight-fill,
body.reduce-motion .announce-bar { transition: none !important; }
/* OOR cue snaps (no fade) when flashing is reduced — value still updates per cell. */
body.reduce-flashing .target-hp,
body.reduce-flashing .target-dist { transition: none !important; }
body.reduce-motion .bar-fill.hp.critical,
body.reduce-motion .bar-fill.sp.critical,
body.reduce-motion .crit-vignette.show,
body.reduce-motion .status-icon.debuff,
body.reduce-motion .threat-chevron.show { animation: none; }
body.reduce-motion .status-icon.timed::before { transition: none; }

/* Ground-target skill prompt (prominent, center-top) */
.ground-prompt {
  position: fixed; top: 130px; left: 50%; transform: translateX(-50%); z-index: 40;
  pointer-events: none; padding: 9px 20px; border-radius: 8px; font-weight: 700; font-size: 15px;
  color: #cdecff; background: rgba(20,40,70,0.92); border: 1px solid #6fc3ff;
  box-shadow: 0 0 16px rgba(111,195,255,0.5); text-shadow: 0 1px 2px #000;
}

/* High-contrast theme (low-vision aid). Group E toggles body.high-contrast;
   here we raise panel opacity, lighten muted text, strengthen borders/shadows
   and brighten the status bar fills. palette.ts brightens the rarity/minimap
   colours in lockstep so the 3D-adjacent HUD colours track the same toggle. */
body.high-contrast {
  --muted: #d2d8e2;        /* was #8a93a3 — readable on dark panels */
  --text: #ffffff;
  --danger: #ff5a44;
}
body.high-contrast .status-panel,
body.high-contrast .target-panel,
body.high-contrast .menu-buttons,
body.high-contrast .menu-btn,
body.high-contrast .panel-box,
body.high-contrast .hot-slot,
body.high-contrast .chat-log,
body.high-contrast .chat-tab,
body.high-contrast .npc-win {
  background: #0a0e14 !important;     /* opaque, not translucent */
  border-color: #6f7d92 !important;  /* stronger panel edges */
}
body.high-contrast .window { background: #0a0e14; border-color: #6f7d92; }
body.high-contrast .win-head { border-bottom-color: #6f7d92; }

/* ===== Guild window (guild-window.ts owns these gw-* visuals) =====
   Crest header + a full GD_* skill tree grouped by prerequisite tier, themed to
   match the dark + gold RO chrome the rest of the social windows use. */
.gw-guildhead { display: flex; align-items: center; gap: 12px; padding: 2px 2px 10px; margin-bottom: 4px; border-bottom: 1px solid #2c3543; }
.gw-crest {
  width: 48px; height: 48px; flex: none; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800; color: var(--accent);
  background: radial-gradient(circle at 30% 25%, rgba(217,164,65,0.30), rgba(20,26,36,0.92));
  border: 1px solid rgba(217,164,65,0.45);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05), 0 2px 8px rgba(0,0,0,0.45);
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.gw-crest { position: relative; overflow: hidden; }
.gw-crest-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.gw-crest.editable { cursor: pointer; }
.gw-crest.editable:hover { border-color: var(--accent); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05), 0 0 10px rgba(217,164,65,0.35); }
.gw-crest-file { display: none; }
/* Always-visible camera badge so the master immediately sees the crest is
   editable (click anywhere on the crest to change the emblem). */
.gw-crest-edit {
  position: absolute; right: -2px; bottom: -2px; z-index: 2; pointer-events: none;
  width: 16px; height: 16px; line-height: 16px; font-size: 9px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: #1a1206; border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.6); opacity: 0.95; transition: transform 0.12s ease;
}
.gw-crest.editable:hover .gw-crest-edit { transform: scale(1.12); }
.gw-crest.uploading { opacity: 0.55; }
.gw-crest.uploading::after {
  content: '…'; position: absolute; inset: 0; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--accent); background: rgba(20,26,36,0.6);
}
.gw-guildhead-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.gw-guildname { font-size: 16px; font-weight: 700; color: var(--text); letter-spacing: 0.3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gw-guildsub { font-size: 11px; color: var(--muted); }

/* Mouseover unit tooltip (ElvUI-style): floating card with the hovered player's
   name + class + guild + emblem. Pointer-transparent so it never eats hover. */
.unit-tooltip {
  position: fixed; z-index: 90; display: none; gap: 9px; align-items: center;
  max-width: 260px; padding: 8px 11px; pointer-events: none;
  background: linear-gradient(180deg, rgba(22,28,38,0.97), rgba(15,20,28,0.97));
  border: 1px solid rgba(217,164,65,0.4); border-radius: 9px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.55); backdrop-filter: blur(2px);
}
.unit-tooltip .ut-crest {
  width: 34px; height: 34px; flex: none; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800; color: var(--accent);
  background: radial-gradient(circle at 30% 25%, rgba(217,164,65,0.28), rgba(20,26,36,0.92)) center/cover;
  border: 1px solid rgba(217,164,65,0.45);
}
.unit-tooltip .ut-crest.has-img { color: transparent; }
.unit-tooltip .ut-text { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.unit-tooltip .ut-name { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unit-tooltip .ut-job { font-size: 11px; color: var(--muted); }
.unit-tooltip .ut-guild { font-size: 11px; color: #d9a441; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.gw-skilltree { display: flex; flex-direction: column; gap: 6px; margin-bottom: 2px; }
.gw-node { position: relative; }
.gw-node.gw-learned { border-color: rgba(217,164,65,0.5); background: linear-gradient(180deg, rgba(40,34,20,0.55), rgba(22,24,30,0.55)); }
.gw-node.gw-locked { opacity: 0.5; filter: grayscale(0.65); }
.gw-node.gw-locked img { filter: grayscale(1); }
.gw-node.gw-info { border-style: dashed; }
.gw-plus { margin-left: 6px; font-weight: 800; line-height: 1; min-width: 22px; text-align: center; }
/* Pre-game experience — login, character select/create/delete, pincode, and the
   connection/state overlays. One cohesive design language, in-family with the
   in-game HUD (styles.css), but fully isolated: every rule is scoped under
   .menu-root (in-flow screens) or .menu-overlay (body-level overlays) so it can
   never leak into the HUD and never collides with the frozen styles.css.
   See client/design/menu-experience-spec.md. */

.menu-root,
.menu-overlay,
.menu-toast {
  /* Neutral ramp */
  --line: #28303d;
  --line-strong: #3a4453;
  --panel-3: #232e3e;
  --ink: #1a1206;
  --text-2: #b9c0cc;
  --success: #5bbf7a;

  /* Glass surfaces — panels float over the aurora */
  --glass: rgba(20, 26, 36, 0.72);
  --glass-2: rgba(28, 37, 51, 0.55);
  --glass-hi: rgba(38, 49, 67, 0.7);
  --blur: 12px;

  /* Accent support */
  --accent-soft: rgba(217, 164, 65, 0.14);
  --accent-line: rgba(217, 164, 65, 0.55);
  --danger-soft: rgba(224, 83, 61, 0.14);

  /* Radii */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-pill: 999px;

  /* Spacing — 4pt grid */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;

  /* Elevation (top-lit) */
  --elev-1: 0 2px 8px rgba(0, 0, 0, 0.35);
  --elev-2: 0 18px 50px rgba(0, 0, 0, 0.55);
  --elev-3: 0 30px 80px rgba(0, 0, 0, 0.65);
  --elev-hero: 0 24px 70px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--accent-line),
    0 0 40px -8px rgba(217, 164, 65, 0.25);
  --inset-top: inset 0 1px 0 rgba(255, 255, 255, 0.04);

  /* Motion */
  --dur-fast: 120ms;
  --dur: 170ms;
  --dur-slow: 240ms;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);

  /* Focus ring — one source of truth, reads on dark AND on gold */
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);

  /* Layout widths */
  --panel-w: 400px;
  --hero-w: 460px;
  --rail-w: 248px;
  --stage-max: 960px;
}

/* The screen host fills #app; content sits above the fixed background. */
.menu-root {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s5);
  overflow: auto;
}
.menu-root > * {
  position: relative;
  z-index: 1;
}

/* Screen-reader-only utility (was an inline const in screens.ts). */
.menu-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================= Background == */

.menu-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: radial-gradient(120% 80% at 50% -10%, #16203a 0%, #0c1018 45%, var(--bg) 75%);
}
.menu-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 100% at 50% 40%, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}
.menu-aurora {
  position: absolute;
  inset: -20%;
  filter: blur(60px);
  opacity: 0.5;
  will-change: transform;
  background:
    radial-gradient(40% 30% at 30% 25%, rgba(64, 120, 150, 0.45), transparent 70%),
    radial-gradient(45% 35% at 70% 20%, rgba(120, 100, 160, 0.35), transparent 70%),
    radial-gradient(35% 25% at 55% 15%, rgba(217, 164, 65, 0.1), transparent 70%);
  animation: menu-aurora-drift 48s ease-in-out infinite alternate;
}
.menu-aurora.menu-aurora--b {
  opacity: 0.32;
  filter: blur(80px);
  animation-duration: 67s;
  animation-direction: alternate-reverse;
}
@keyframes menu-aurora-drift {
  from {
    transform: translate3d(-3%, 0, 0) scale(1.05);
  }
  to {
    transform: translate3d(3%, 2%, 0) scale(1.12);
  }
}
.menu-particles {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* =============================================================== Panels ==== */

.menu-panel {
  position: relative;
  background: var(--glass);
  backdrop-filter: blur(var(--blur)) saturate(120%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(120%);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--elev-2), var(--inset-top);
  padding: clamp(24px, 3vw, 32px);
  color: var(--text);
  animation: menu-surface-in var(--dur) var(--ease) both;
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .menu-panel,
  .menu-overlay__card,
  .menu-toast {
    background: var(--panel);
  }
}
/* The single heroic flourish — a gold top-edge accent line. */
.menu-panel::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.7;
}
.menu-panel.is-danger::before {
  background: linear-gradient(90deg, transparent, var(--danger), transparent);
}
.menu-panel__title {
  font-weight: 700;
  font-size: calc(20px * var(--ui-scale));
  line-height: 1.2;
  letter-spacing: 0.3px;
  margin: 0;
}
.menu-panel__sub {
  color: var(--muted);
  font-size: calc(12px * var(--ui-scale));
  margin: var(--s1) 0 var(--s5);
}
.menu-panel__body {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}
.menu-panel__actions {
  display: flex;
  gap: var(--s3);
  margin-top: var(--s2);
}

@keyframes menu-surface-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* =============================================================== Buttons ==== */

.menu-button {
  position: relative;
  padding: 11px 16px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: calc(14px * var(--ui-scale));
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  color: var(--text);
  background: var(--glass-2);
  transition:
    background var(--dur),
    box-shadow var(--dur),
    border-color var(--dur),
    filter var(--dur),
    transform var(--dur-fast);
}
.menu-button:active {
  transform: translateY(1px) scale(0.99);
}
.menu-button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.menu-button[disabled],
.menu-button[aria-disabled='true'] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.menu-button--primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: var(--ink);
  font-weight: 700;
  border-color: transparent;
}
.menu-button--primary:hover {
  filter: brightness(1.07);
}
.menu-button--block {
  width: 100%;
}

.menu-button--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}
.menu-button--ghost:hover {
  background: var(--panel-3);
  border-color: var(--line-strong);
}

.menu-button--danger {
  background: transparent;
  border-color: rgba(224, 83, 61, 0.5);
  color: var(--danger);
}
.menu-button--danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

/* Loading: hide the label, center a spinner, preserve width. */
.menu-button.is-loading {
  color: transparent;
  pointer-events: none;
}
.menu-button.is-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: calc(16px * var(--ui-scale));
  height: calc(16px * var(--ui-scale));
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent, currentColor);
  -webkit-mask: radial-gradient(circle, transparent 52%, #000 54%);
  mask: radial-gradient(circle, transparent 52%, #000 54%);
  color: var(--ink);
  animation: menu-spin 0.8s linear infinite;
}
.menu-button--ghost.is-loading::after,
.menu-button--danger.is-loading::after {
  color: var(--accent);
}

/* =============================================================== Fields ===== */

.menu-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.menu-field__label {
  font-weight: 600;
  font-size: calc(12px * var(--ui-scale));
  line-height: 1.3;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
}
.menu-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.menu-input {
  width: 100%;
  padding: 11px 12px;
  color: var(--text);
  font-size: calc(14px * var(--ui-scale));
  background: var(--glass-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  transition:
    border-color var(--dur),
    box-shadow var(--dur),
    background var(--dur);
}
.menu-input::placeholder {
  color: #5f6877;
}
.menu-input:hover {
  border-color: var(--line-strong);
}
.menu-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--glass-hi);
}
.menu-input[aria-invalid='true'] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
  padding-right: 34px;
}
/* Non-colour invalid cue. */
.menu-field.is-invalid .menu-input-wrap::after {
  content: '!';
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-weight: 800;
  color: var(--danger);
  pointer-events: none;
}
.menu-field__hint {
  font-size: calc(11px * var(--ui-scale));
  color: var(--muted);
}

/* Password reveal toggle sits inside the field. */
.menu-reveal {
  position: absolute;
  right: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--r-sm);
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: color var(--dur), background var(--dur);
}
.menu-reveal:hover {
  color: var(--text);
  background: var(--glass-2);
}
.menu-reveal:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.menu-reveal svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}

/* =============================================================== Status ===== */

.menu-status {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: calc(18px * var(--ui-scale));
  font-size: calc(12px * var(--ui-scale));
  color: var(--muted);
}
.menu-status::before {
  font-weight: 800;
}
.menu-status:empty {
  visibility: hidden;
}
.menu-status.is-info {
  color: var(--muted);
}
.menu-status.is-info::before {
  content: 'ⓘ';
}
.menu-status.is-error {
  color: var(--danger);
}
.menu-status.is-error::before {
  content: '⚠';
}

/* =============================================================== Spinner ==== */

.menu-spinner {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent, var(--accent));
  -webkit-mask: radial-gradient(circle, transparent 52%, #000 54%);
  mask: radial-gradient(circle, transparent 52%, #000 54%);
  animation: menu-spin 0.8s linear infinite;
}
@keyframes menu-spin {
  to {
    transform: rotate(360deg);
  }
}

/* =============================================================== Crest ====== */

.menu-crest {
  position: relative;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  color: var(--accent);
  background:
    radial-gradient(circle at 50% 35%, var(--crest-tint, rgba(217, 164, 65, 0.22)), rgba(8, 12, 18, 0.6) 70%);
  border: 2px solid var(--crest-ring, var(--accent-line));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 4px 14px rgba(0, 0, 0, 0.4);
}
.menu-crest__glyph {
  font-size: 28px;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}
.menu-crest--sm {
  width: 40px;
  height: 40px;
}
.menu-crest--sm .menu-crest__glyph {
  font-size: 18px;
}

/* =============================================================== Login ====== */

.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s6);
  width: min(var(--panel-w), 92vw);
}
.login-brand {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
}
.login-wordmark {
  display: inline-flex;
  align-items: center;
  gap: var(--s3);
  font-weight: 700;
  font-size: calc(48px * var(--ui-scale));
  line-height: 1.1;
  letter-spacing: 0.5px;
  background: linear-gradient(180deg, #f0cd7a, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 2px 24px rgba(217, 164, 65, 0.25);
}
.login-wordmark svg {
  width: 30px;
  height: 30px;
  fill: var(--accent);
  -webkit-text-fill-color: initial;
}
.login-kicker {
  font-weight: 600;
  font-size: calc(11px * var(--ui-scale));
  line-height: 1;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
}
.login-panel {
  width: 100%;
}

.menu-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: max(var(--s4), env(safe-area-inset-bottom));
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s4);
  font-weight: 600;
  font-size: calc(11px * var(--ui-scale));
  line-height: 1;
  letter-spacing: 0.4px;
  color: var(--muted);
  pointer-events: none;
}
.menu-footer > * {
  pointer-events: auto;
}
/* ========================================================= Character select = */

.cs-screen {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  /* Fit the hero + rail exactly so the header aligns with the rail's right edge
     (no dead grid space pushing the locale/logout controls adrift). */
  width: min(calc(var(--hero-w) + var(--rail-w) + var(--s5)), 94vw);
}
.cs-header {
  display: flex;
  align-items: center;
  gap: var(--s3);
}
.cs-header__brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font-weight: 700;
  font-size: calc(18px * var(--ui-scale));
  line-height: 1;
  color: var(--accent);
}
.cs-header__brand svg {
  width: 20px;
  height: 20px;
  fill: var(--accent);
}
.cs-header__title {
  font-weight: 700;
  font-size: calc(20px * var(--ui-scale));
  line-height: 1.2;
  letter-spacing: 0.3px;
}
.cs-header__spacer {
  flex: 1;
}
.cs-body {
  display: grid;
  grid-template-columns: var(--hero-w) var(--rail-w);
  gap: var(--s5);
  align-items: start;
}

/* Featured hero card */
.cs-hero {
  box-shadow: var(--elev-hero), var(--inset-top);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s4);
  min-height: 360px;
  text-align: center;
}
.cs-hero__stage {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background:
    radial-gradient(circle at 50% 44%, rgba(217, 164, 65, 0.14), transparent 40%),
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(8,12,18,0.22));
}
.cs-hero__stage .menu-crest {
  width: 118px;
  height: 118px;
}
.cs-hero__stage .menu-crest__glyph {
  font-size: 48px;
}
.cs-avatar {
  position: relative;
  width: min(220px, 62vw);
  height: 148px;
}
.cs-avatar__shadow,
.cs-avatar__body,
.cs-avatar__head,
.cs-avatar__hair,
.cs-avatar__glyph {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}
.cs-avatar__shadow {
  bottom: 8px;
  width: 120px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.34);
}
.cs-avatar__body {
  bottom: 18px;
  width: 104px;
  height: 72px;
  clip-path: polygon(25% 0, 75% 0, 100% 100%, 0 100%);
  border: 1px solid rgba(217, 164, 65, 0.34);
  border-radius: 18px 18px 10px 10px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.08), transparent 42%),
    linear-gradient(180deg, rgba(217,164,65,0.24), rgba(35,46,62,0.92));
}
.cs-avatar__head {
  top: 24px;
  width: 58px;
  height: 58px;
  border-radius: 44% 44% 48% 48%;
  background: linear-gradient(180deg, #d7b07a, #9f7044);
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.2), 0 10px 22px rgba(0,0,0,0.36);
}
.cs-avatar__hair {
  top: 17px;
  width: 66px;
  height: 38px;
  border-radius: 48% 48% 34% 34%;
  background: var(--hair, #caa14d);
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.16);
}
.cs-avatar__glyph {
  bottom: 44px;
  color: #ffe7a8;
  font-size: 24px;
  line-height: 1;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}
.cs-hero__id {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
  min-width: 0;
}
.cs-hero__name {
  font-weight: 700;
  font-size: calc(28px * var(--ui-scale));
  line-height: 1.15;
  letter-spacing: 0.3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cs-hero__class {
  width: fit-content;
  max-width: 100%;
  padding: 5px 9px;
  border: 1px solid var(--accent-line);
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: #ffe7a8;
  font-weight: 700;
  font-size: calc(12px * var(--ui-scale));
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cs-hero__where {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: calc(12px * var(--ui-scale));
  color: var(--muted);
}
.cs-hero__actions {
  display: flex;
  gap: var(--s3);
  margin-top: auto;
  width: 100%;
}
.cs-hero__actions .menu-button--primary {
  flex: 1;
}

/* Hero cross-fade on promote */
.cs-hero.is-promoting {
  animation: menu-fade-in var(--dur) var(--ease) both;
}
@keyframes menu-fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* First-hero empty state */
.cs-hero.is-empty {
  align-items: center;
  text-align: center;
  justify-content: center;
  gap: var(--s4);
  min-height: 320px;
}
.cs-hero.is-empty .cs-empty-plus {
  font-size: calc(56px * var(--ui-scale));
  line-height: 1;
  color: var(--accent);
  opacity: 0.8;
}

/* Slot rail (listbox) */
.cs-rail {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  max-height: 70vh;
  overflow-y: auto;
  padding-right: 2px;
}
.cs-slot {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--glass-2);
  color: var(--text);
  cursor: pointer;
  transition:
    border-color var(--dur),
    background var(--dur),
    transform var(--dur),
    box-shadow var(--dur);
}
.cs-slot:hover {
  border-color: var(--line-strong);
  background: var(--glass-hi);
  transform: translateY(-2px);
  box-shadow: var(--elev-1);
}
.cs-slot:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.cs-slot[aria-current='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}
.cs-slot__dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
}
.cs-slot[aria-current='true'] .cs-slot__dot {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(217, 164, 65, 0.7);
}
.cs-slot__body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.cs-slot__name {
  font-weight: 600;
  font-size: calc(13px * var(--ui-scale));
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cs-slot__meta {
  font-size: calc(11px * var(--ui-scale));
  color: var(--muted);
}
.cs-create {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  width: 100%;
  margin-top: var(--s2);
  border-radius: var(--r-md);
  border: 1px dashed var(--line-strong);
  background: rgba(8, 12, 18, 0.18);
  color: var(--text-2);
  cursor: pointer;
  font-weight: 700;
  font-size: calc(13px * var(--ui-scale));
  transition: border-color var(--dur), background var(--dur), color var(--dur);
}
.cs-create:hover {
  color: #ffe7a8;
  border-color: var(--accent-line);
  background: var(--accent-soft);
}
.cs-create:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
/* ============================================================= Create ====== */

.create-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--s5);
  align-items: start;
}
.create-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
}
.create-preview .menu-crest {
  width: 88px;
  height: 88px;
}
.create-preview .menu-crest__glyph {
  font-size: 40px;
}
.create-fields {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}
.create-count {
  align-self: flex-end;
  font-size: calc(11px * var(--ui-scale));
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Stepper (hair style) */
.create-stepper {
  display: flex;
  align-items: center;
  gap: var(--s2);
}
.create-stepper__btn {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--glass-2);
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  transition: border-color var(--dur), background var(--dur);
}
.create-stepper__btn:hover {
  border-color: var(--accent);
}
.create-stepper__btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.create-stepper__val {
  flex: 1;
  text-align: center;
  font-weight: 700;
  font-size: calc(15px * var(--ui-scale));
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* Swatches (hair colour) */
.create-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
}
.create-swatch {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  cursor: pointer;
  padding: 0;
  transition: transform var(--dur), border-color var(--dur), box-shadow var(--dur);
}
.create-swatch:hover {
  transform: scale(1.08);
}
.create-swatch:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.create-swatch[aria-checked='true'] {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft), 0 0 10px rgba(217, 164, 65, 0.5);
}
.create-swatch[aria-checked='true']::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}

/* ============================================================= Delete ====== */

.delete-echo {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3);
  border-radius: var(--r-md);
  background: var(--glass-2);
  border: 1px solid var(--line);
}
.delete-echo__body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.delete-echo__name {
  font-weight: 700;
  font-size: calc(15px * var(--ui-scale));
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.delete-echo__meta {
  font-size: calc(12px * var(--ui-scale));
  color: var(--muted);
}

/* ============================================================= Pincode ====== */

.pin-panel {
  width: min(340px, 92vw);
  text-align: center;
}
.pin-panel__icon {
  font-size: 28px;
  line-height: 1;
  color: var(--accent);
  margin-bottom: var(--s2);
}
.pin-dots {
  display: flex;
  justify-content: center;
  gap: var(--s4);
  margin: var(--s5) 0;
}
.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--accent-line);
  background: transparent;
  transition: transform var(--dur-fast) var(--ease), background var(--dur-fast);
}
.pin-dot.is-filled {
  background: var(--accent);
  border-color: var(--accent);
  animation: pin-pop var(--dur-fast) var(--ease);
}
@keyframes pin-pop {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.25);
  }
  100% {
    transform: scale(1);
  }
}
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s2);
}
.pin-key {
  min-height: clamp(48px, 9vw, 56px);
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--glass-2);
  color: var(--text);
  font-weight: 700;
  font-size: calc(20px * var(--ui-scale));
  line-height: 1;
  cursor: pointer;
  transition: background var(--dur), border-color var(--dur), transform var(--dur-fast);
}
.pin-key:hover {
  border-color: var(--accent);
  background: var(--glass-hi);
}
.pin-key:active {
  transform: translateY(1px) scale(0.97);
}
.pin-key:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.pin-key--util {
  color: var(--muted);
  font-size: calc(18px * var(--ui-scale));
}
.pin-panel.is-error .pin-dot {
  border-color: var(--danger);
}
.pin-panel.is-error .pin-dot.is-filled {
  background: var(--danger);
}
.pin-panel.is-error .pin-dots {
  animation: pin-shake 0.3s var(--ease);
}
@keyframes pin-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-7px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(2px);
  }
}

/* ====================================================== Overlays + toast ==== */

.menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s5);
}
.menu-overlay--fatal {
  z-index: 60;
}
.menu-overlay__scrim {
  position: absolute;
  inset: 0;
  background: rgba(8, 11, 16, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: menu-fade var(--dur) var(--ease) both;
}
.menu-overlay__card {
  position: relative;
  z-index: 1;
  width: min(360px, 90vw);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s4);
  background: var(--glass);
  backdrop-filter: blur(var(--blur)) saturate(120%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(120%);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--elev-3), var(--inset-top);
  padding: var(--s6);
  color: var(--text);
  animation: menu-pop var(--dur-slow) var(--ease) both;
}
.menu-overlay__icon {
  font-size: 34px;
  line-height: 1;
}
.menu-overlay--fatal .menu-overlay__icon {
  color: var(--danger);
}
.menu-overlay--disconnect .menu-overlay__icon {
  color: var(--muted);
}
.menu-overlay__title {
  font-weight: 700;
  font-size: calc(18px * var(--ui-scale));
  line-height: 1.2;
}
.menu-overlay__msg {
  font-size: calc(12px * var(--ui-scale));
  color: var(--muted);
  max-width: 420px;
  line-height: 1.45;
}
@keyframes menu-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes menu-pop {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Non-blocking reconnect pill (bottom-center). */
.menu-toast {
  position: fixed;
  left: 50%;
  bottom: max(var(--s5), env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 55;
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 8px 16px;
  border-radius: var(--r-pill);
  background: var(--glass);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--line);
  box-shadow: var(--elev-1);
  color: #ffd24a;
  font-weight: 600;
  font-size: calc(13px * var(--ui-scale));
  line-height: 1;
  animation: menu-toast-in var(--dur-slow) var(--ease) both;
}
.menu-toast .menu-spinner {
  width: 14px;
  height: 14px;
}
@keyframes menu-toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%);
  }
}

/* ============================================================ Responsive ==== */

@media (max-width: 959px) {
  .cs-body {
    grid-template-columns: 1fr;
  }
  .cs-rail {
    flex-direction: row;
    flex-wrap: nowrap;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 4px;
  }
  .cs-slot {
    flex: 0 0 auto;
    min-width: 180px;
  }
}
@media (max-width: 639px) {
  .login-wordmark {
    font-size: calc(40px * var(--ui-scale));
  }
  .create-grid {
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .cs-hero__actions {
    flex-direction: column;
  }
  .menu-panel__actions {
    flex-direction: column;
  }
}
@media (pointer: coarse) {
  .cs-slot {
    min-height: 56px;
  }
  .pin-key {
    min-height: 64px;
  }
}

/* ======================================================= Reduced motion ===== */

@media (prefers-reduced-motion: reduce) {
  .menu-aurora {
    animation: none;
  }
  .menu-particles {
    display: none;
  }
  .menu-panel,
  .menu-overlay__scrim,
  .menu-overlay__card,
  .menu-toast,
  .cs-hero.is-promoting {
    animation: none;
  }
  .pin-dot,
  .pin-dot.is-filled {
    animation: none;
    transition: none;
  }
  .pin-panel.is-error .pin-dots {
    animation: none;
  }
  .cs-slot:hover {
    transform: none;
  }
  .menu-button:active,
  .pin-key:active {
    transform: none;
  }
}

/* ======================================================== High contrast ===== */

body.high-contrast .menu-root,
body.high-contrast .menu-overlay,
body.high-contrast .menu-toast {
  /* --muted inherits the app-wide high-contrast lift from styles.css. */
  --line: #6f7d92;
}
body.high-contrast .menu-panel,
body.high-contrast .cs-slot,
body.high-contrast .menu-input,
body.high-contrast .menu-overlay__card,
body.high-contrast .menu-toast {
  border-width: 2px;
}
/* Stacked WoW-style action bars (layout + stacking only). The per-slot visuals
 * (.hot-slot / .hot-cd / .hot-key / .hot-name / .hot-icon, plus the .filled /
 * .insufficient / .flash / .ready states and the cooldown sweep) are reused
 * verbatim from styles.css — this file owns only the cluster layout, the bar
 * stacking, the slot-size/keybind polish, and the in-place config affordance.
 *
 * Stack order top -> bottom: Extra Bar 2, Extra Bar 1, Main. The rows are emitted
 * main-first in the DOM (so the always-on bar is the layout anchor) and rendered
 * bottom-up via flex column-reverse. */

.action-bars {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column-reverse; /* main (first child) sits at the bottom */
  align-items: center;
  gap: 4px;
  pointer-events: none; /* gaps pass clicks through; slots opt back in below */
  z-index: 30;
}

.action-bar {
  display: flex;
  flex-direction: row;
  gap: 3px;
  padding: 3px;
  border-radius: 8px;
  /* A faint backdrop frames each bar so an empty/extra bar is discoverable as a
   * place to drop skills — without it, empty slots alone read as scattered dots. */
  background: rgba(10, 14, 20, 0.42);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

/* A hidden extra bar leaves the layout so the remaining bars reflow flush. */
.action-bar.is-hidden { display: none; }

/* AAA polish: consistent 40px squares, a 1px inner bevel over the styles.css
 * frame, and a soft hover glow. Slot size is intentionally smaller than the
 * single-bar default (56px) — 12 slots × 3 stacked bars needs a tighter grid. */
.action-bars .hot-slot {
  width: calc(40px * var(--ui-scale));
  height: calc(40px * var(--ui-scale));
  pointer-events: auto;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.action-bars .hot-slot:hover {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), 0 0 6px rgba(120, 200, 255, 0.35);
}
/* Empty slots read flat/recessed so a filled loadout stands out at a glance. */
.action-bars .hot-slot:not(.filled) { opacity: 0.4; }
/* A bound slot gets a touch more presence (the loadout is what matters). */
.action-bars .hot-slot.filled {
  box-shadow: inset 0 0 0 1px rgba(120, 200, 255, 0.18);
}

/* Slot-to-slot drag: the picked-up slot fades and the valid drop target lights
 * up (the shared .pd-drop class from styles.css already tints the border). */
.action-bars .hot-slot.hot-dragging { opacity: 0.35; cursor: grabbing; }
.action-bars .hot-slot.pd-drop {
  box-shadow: inset 0 0 0 2px var(--accent), 0 0 8px rgba(120, 200, 255, 0.5);
}

/* Keybind label: top-right, compact, with a 1px shadow so it stays legible over
 * an item icon. Shows the short form (1 0 - = F1 ⇧F1). */
.action-bars .hot-key {
  top: 1px;
  right: 3px;
  left: auto;
  font-size: calc(10px * var(--ui-scale));
  font-weight: 600;
  color: var(--muted);
  text-shadow: 0 1px 1px #000;
}

/* In-place config: a small gear handle to the right of the cluster opening a
 * compact popover with the two extra-bar toggles + the editing lock. */
.action-bars__config {
  position: absolute;
  right: -34px;
  bottom: 0;
  pointer-events: auto;
}
.action-bar__handle {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid #2c3543;
  border-radius: 6px;
  background: rgba(10, 14, 20, 0.82);
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.action-bar__handle:hover { color: var(--accent); border-color: var(--accent); }

.action-bars__popover {
  position: absolute;
  right: 0;
  bottom: 32px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  white-space: nowrap;
  background: rgba(10, 14, 20, 0.94);
  border: 1px solid #2c3543;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}
.action-bars__opt {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: #d6dde6;
  cursor: pointer;
}
.action-bars__opt input { cursor: pointer; }

/* Editing-lock cue: the whole cluster reads as non-editable (the slots keep
 * firing on click — only drag/clear are gated, in hud.ts). */
.action-bars.is-locked .hot-slot { cursor: pointer; }
.action-bars.is-locked .action-bar__handle { color: var(--accent-2, #5fd38a); }
/* ESC root menu + tabbed Settings window. Standalone from styles.css (which stays
   frozen). Reuses .panel / .primary / .menu-select from styles.css read-only. */

/* --- ESC root menu (WoW-style centered button column) --------------------- */
.esc-root {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(8, 10, 16, 0.6);
}
.esc-root__panel {
  width: 240px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.esc-root__panel h1 {
  margin: 0 0 6px;
}
.esc-root__btn {
  width: 100%;
}

/* --- Settings window (left rail + scrolling content pane) ------------------ */
.settings-win {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(8, 10, 16, 0.6);
}
.settings-dialog {
  width: 600px;
  max-width: 94vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}
.settings-dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.settings-dialog__title { margin: 0; }
.settings-back {
padding: 8px 12px;
  border: 1px solid #28303d;
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
}
.settings-back:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.settings-body {
  display: flex;
  gap: 14px;
  min-height: 0;
  flex: 1;
}

/* Left rail of tabs */
.settings-rail {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 140px;
  flex: 0 0 140px;
  border-right: 1px solid #28303d;
  padding-right: 10px;
}
.settings-rail__tab {
  text-align: left;
padding: 10px 12px;
  font-size: 13px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
}
.settings-rail__tab:hover {
  background: var(--panel-2);
  color: #e6e6e6;
}
.settings-rail__tab.is-active {
  background: var(--panel-2);
  border-color: #28303d;
  color: var(--accent);
  font-weight: 600;
}

/* Content pane */
.settings-pane-host {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
}
.settings-pane {
  display: none;
  flex-direction: column;
  gap: 10px;
}

/* One control row */
.settings-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.settings-row--check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}
.settings-row__label {
  font-size: 12px;
  color: var(--muted);
}
.settings-row__head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}

/* Per-tab footer (reset row) */
.settings-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid #28303d;
}
.settings-footer__btn {
  font-size: 11px;
padding: 7px 12px;
  background: var(--panel-2);
  border: 1px solid #28303d;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
}
.settings-footer__btn:hover {
  color: #e6e6e6;
}
.settings-footer__btn--danger {
  border-color: #5a2630;
  color: #ff9b9b;
}

/* Controls (rebind grid) */
.settings-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.settings-controls__grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  align-items: center;
  font-size: 12px;
}
.settings-controls__label {
  color: var(--muted);
}
.settings-controls__key {
  min-width: 110px;
  font-size: 11px;
  padding: 3px 8px;
  background: var(--panel-2);
  border: 1px solid #28303d;
  border-radius: 6px;
  color: #e6e6e6;
  cursor: pointer;
}
.settings-controls__key.is-reassigned {
  box-shadow: 0 0 0 2px #d9a441;
  transition: box-shadow 120ms ease-out;
}
.settings-controls__ref {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
  margin-top: 4px;
}
.settings-controls__ref b {
  color: var(--accent);
}

/* Reversible hide of the Q/W/E weapon-kit bar (no standard RO equivalent). */
.weapon-kit-bar.is-hidden {
  display: none;
}
/* hud-primitives.css — shared CSS for the Wave-1 HUD feedback primitives
   (AlertStack 2.a, ResultFlash 2.d, ResourcePips 2.b). Loaded once via index.html
   alongside styles.css. The section-4 design tokens these reference
   (--good/--info/--skillmsg/--warn/--hotbar-h/--pip-*) live in styles.css :root;
   the blocks below fall back to literals where a token may be absent. */

/* ── 2.a AlertStack — UIErrorsFrame-style system/error lines ───────────────── */
.alert-stack {
  position: fixed;
  left: 50%;
  bottom: calc(var(--hotbar-h, calc(96px * var(--ui-scale))) + 12px * var(--ui-scale));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column-reverse; /* newest line nearest the action bars */
  align-items: center;
  gap: calc(4px * var(--ui-scale));
  max-width: 90vw;
  pointer-events: none;
  z-index: 22;
}

.alert-line {
  display: flex;
  align-items: baseline;
  gap: calc(6px * var(--ui-scale));
  max-width: 100%;
  padding: calc(4px * var(--ui-scale)) calc(12px * var(--ui-scale));
  border: 1px solid #28303d;
  border-left: calc(3px * var(--ui-scale)) solid var(--accent); /* gold tick */
  border-radius: calc(6px * var(--ui-scale));
  background: rgba(10, 14, 20, 0.86);
  color: var(--text);
  font-size: calc(13px * var(--ui-scale));
  font-weight: 600;
  line-height: 1.3;
  text-shadow: 0 1px 2px #000;
  animation: alert-in 140ms ease-out both;
}
.alert-line .alert-msg {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Tone bands — colour is always paired with the left gold/coloured tick + text,
   never hue-only (the message copy itself carries the meaning). */
.alert-line.error { color: var(--danger);            background: rgba(224, 83, 61, 0.12); }
.alert-line.warn  { color: var(--accent-2);          background: rgba(200, 130, 31, 0.12); border-left-color: var(--accent-2); }
.alert-line.info  { color: var(--muted);             background: rgba(138, 147, 163, 0.10); border-left-color: var(--muted); }
.alert-line.skill { color: var(--skillmsg, #b48ce0); background: rgba(180, 140, 224, 0.12); border-left-color: var(--skillmsg, #b48ce0); }

/* ×N coalesce badge — tabular so the count doesn't jitter; hidden until N>1. */
.alert-line .alert-x {
  font-variant-numeric: tabular-nums;
  font-size: calc(11px * var(--ui-scale));
  font-weight: 700;
  color: var(--accent);
  opacity: 0.9;
}
.alert-line .alert-x:empty { display: none; }

.alert-line.leaving { animation: alert-out 200ms ease-in both; }

@keyframes alert-in {
  from { opacity: 0; transform: translateY(calc(8px * var(--ui-scale))); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes alert-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* Motion opt-out: instant opacity, no slide. Gated by the OS query AND the two
   runtime body classes the HUD already toggles (readReduceFlashing /
   readReduceMotion). Removal stays timer-driven, so lines still clear on time. */
@media (prefers-reduced-motion: reduce) {
  .alert-line, .alert-line.leaving { animation: none; }
}
body.reduce-flashing .alert-line, body.reduce-flashing .alert-line.leaving,
body.reduce-motion   .alert-line, body.reduce-motion   .alert-line.leaving {
  animation: none;
}

/* ===== ResultFlash (HUD spec 2.d) — proc/success/fail glow, floaters, bursts =====
   Uses tokens: --accent, --danger, --good, --info, --ui-scale. All sizes scale
   with --ui-scale; all motion is gated by readReduceFlashing()/
   readDisableDamageFlashes() in JS (which swaps to the .rf-static / .float-num
   .static / .big-burst.static classes) AND by the reduced-motion blocks below. */

/* --- Glow rings (flashEl) --- */
@keyframes rf-success {
  0%   { box-shadow: 0 0 0 0 rgba(217, 164, 65, 0.85); }
  100% { box-shadow: 0 0 0 calc(16px * var(--ui-scale)) rgba(217, 164, 65, 0); }
}
@keyframes rf-fail {
  0%, 100% { transform: translateX(0);                              box-shadow: 0 0 0 calc(2px * var(--ui-scale)) rgba(224, 83, 61, 0); }
  20%      { transform: translateX(calc(-4px * var(--ui-scale)));   box-shadow: 0 0 0 calc(2px * var(--ui-scale)) rgba(224, 83, 61, 0.95); }
  40%      { transform: translateX(calc(4px * var(--ui-scale))); }
  60%      { transform: translateX(calc(-3px * var(--ui-scale)));   box-shadow: 0 0 0 calc(2px * var(--ui-scale)) rgba(224, 83, 61, 0.7); }
  80%      { transform: translateX(calc(3px * var(--ui-scale))); }
}
@keyframes rf-proc {
  0%   { box-shadow: 0 0 0 0 var(--rf-tint, var(--accent)); }
  55%  { box-shadow: 0 0 calc(9px * var(--ui-scale)) calc(3px * var(--ui-scale)) var(--rf-tint, var(--accent)); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@keyframes rf-levelup {
  0%   { box-shadow: 0 0 0 0 rgba(217, 164, 65, 0.9);                    filter: brightness(1.35); }
  100% { box-shadow: 0 0 0 calc(22px * var(--ui-scale)) rgba(217, 164, 65, 0); filter: brightness(1); }
}

.rf-glow          { border-radius: inherit; }
.rf-glow.success  { animation: rf-success 360ms ease-out; }
.rf-glow.fail     { animation: rf-fail    360ms ease-in-out; }
.rf-glow.proc     { animation: rf-proc    420ms ease-out; }
.rf-glow.levelup  { animation: rf-levelup 900ms ease-out; }
.rf-glow.heal     { --rf-tint: var(--good); animation: rf-proc 420ms ease-out; }
.rf-glow.mana     { --rf-tint: var(--info); animation: rf-proc 420ms ease-out; }

/* Reduced-motion glow: a held static border, no keyframe (JS clears after 600ms). */
.rf-static          { border-radius: inherit; box-shadow: 0 0 0 calc(2px * var(--ui-scale)) var(--rf-tint, var(--accent)); }
.rf-static.success,
.rf-static.levelup,
.rf-static.proc     { --rf-tint: var(--accent); }
.rf-static.fail     { --rf-tint: var(--danger); }
.rf-static.heal     { --rf-tint: var(--good); }
.rf-static.mana     { --rf-tint: var(--info); }

/* --- Floating numbers (floatNumber) — host must be position:relative --- */
@keyframes float-rise {
  0%   { opacity: 0; transform: translate(-50%, calc(2px * var(--ui-scale)))  translateX(var(--rf-drift, 0px)); }
  12%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, calc(-28px * var(--ui-scale))) translateX(var(--rf-drift, 0px)); }
}
.float-num {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translate(-50%, 0);
  font: 700 calc(15px * var(--ui-scale)) / 1 "Segoe UI", system-ui, sans-serif;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  white-space: nowrap;
  z-index: 30;
  animation: float-rise 900ms ease-out forwards;
}
.float-num.heal { color: var(--good); }
.float-num.mana { color: var(--info); }
.float-num.crit { color: var(--accent); font-size: calc(21px * var(--ui-scale)); font-weight: 800; } /* 1.4x + bolder, not colour-only */

/* Reduced-motion floater: a static pill that JS fades (opacity) and removes. */
.float-num.static { animation: none; transform: translate(-50%, calc(-6px * var(--ui-scale))); transition: opacity 240ms linear; }

/* --- Centred bursts (bigBurst) --- */
.big-burst {
  position: fixed;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 120;
  text-align: center;
  font: 800 calc(34px * var(--ui-scale)) / 1.05 "Cinzel", "Segoe UI", serif;
  letter-spacing: calc(2px * var(--ui-scale));
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.85);
  animation: rf-levelup 1200ms ease-out forwards;
}
.big-burst.levelup     { color: var(--accent); }
.big-burst.refine-ok   { color: var(--good); }
.big-burst.refine-fail { color: var(--danger); }
.big-burst.gameover    { color: var(--danger); font-size: calc(40px * var(--ui-scale)); }

/* Reduced-motion burst: a static 1s toast that JS fades (opacity) and removes. */
.big-burst.static {
  top: 22%;
  box-shadow: none;
  animation: none;
  transition: opacity 260ms linear;
}

/* --- Reduced-motion fallback (belt-and-suspenders; JS already swaps classes) --- */
@media (prefers-reduced-motion: reduce) {
  .rf-glow, .float-num, .big-burst { animation-duration: 1ms !important; }
}
body.reduce-motion .rf-glow,
body.reduce-motion .float-num,
body.reduce-motion .big-burst { animation-duration: 1ms !important; }

/* ===== ResourcePips (HUD spec 2.b) ===== */

/* Pip hue tokens (paired with per-kind glyphs, never hue-only). */
:root {
  --pip-sphere: #ffb84d;
  --pip-coin:   #e8c34a;
  --pip-soul:   #9bd0ff;
  --pip-charm:  #cdd6e0;
  --pip-shield: #9aa7b5;
  --pip-scar:   #e0533d;
}

/* Row: docks under the self unit-frame's SP bar. */
.res-pips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: calc(3px * var(--ui-scale));
  margin-top: calc(3px * var(--ui-scale));
  line-height: 1;
  pointer-events: none;
}

/* One pip. Default = dim socket; .filled = lit + glow. Carries its glyph as text. */
.res-pip {
  --pip-c: var(--muted);
  font-size: calc(11px * var(--ui-scale));
  width: calc(13px * var(--ui-scale));
  height: calc(13px * var(--ui-scale));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--pip-c);
  opacity: 0.30;                         /* dim socket */
  transform: scale(0.92);
  transition: opacity 0.14s ease, transform 0.14s ease, text-shadow 0.14s ease;
  font-variant-numeric: tabular-nums;
}
.res-pip.filled {
  opacity: 1;
  transform: scale(1);
  text-shadow: 0 0 calc(5px * var(--ui-scale)) var(--pip-c);
}

/* Per-kind hue (glyph shape is set in TS: sphere ● coin ◆ soul ✦ charm ◈ shield ⬡ scar ✕). */
.res-pip.sphere { --pip-c: var(--pip-sphere); }
.res-pip.coin   { --pip-c: var(--pip-coin); }
.res-pip.soul   { --pip-c: var(--pip-soul); }
.res-pip.charm  { --pip-c: var(--pip-charm); }
.res-pip.shield { --pip-c: var(--pip-shield); }
.res-pip.scar   { --pip-c: var(--pip-scar); }

/* Charm element tint (reuses the element palette; falls back to the charm hue). */
.res-pip.charm[data-elem="fire"]   { --pip-c: #ff6a3d; }
.res-pip.charm[data-elem="water"]  { --pip-c: #4db5ff; }
.res-pip.charm[data-elem="wind"]   { --pip-c: #6fe0a8; }
.res-pip.charm[data-elem="earth"]  { --pip-c: #d8a861; }
.res-pip.charm[data-elem="ghost"]  { --pip-c: #b48ce0; }
.res-pip.charm[data-elem="holy"]   { --pip-c: #ffe7a3; }
.res-pip.charm[data-elem="dark"], .res-pip.charm[data-elem="shadow"] { --pip-c: #8a7fb0; }
.res-pip.charm[data-elem="poison"] { --pip-c: #9bcf4a; }

/* Compact variant for nameplates / the target frame. */
.res-pips.compact { gap: calc(2px * var(--ui-scale)); margin-top: calc(1px * var(--ui-scale)); }
.res-pips.compact .res-pip {
  font-size: calc(8px * var(--ui-scale));
  width: calc(9px * var(--ui-scale));
  height: calc(9px * var(--ui-scale));
}

/* Motion: gained pip spawns (scale .4->1 + glow pulse), lost pip pops. */
@keyframes pip-spawn {
  0%   { transform: scale(0.4); opacity: 0; text-shadow: 0 0 0 transparent; }
  60%  { transform: scale(1.25); opacity: 1; text-shadow: 0 0 calc(8px * var(--ui-scale)) var(--pip-c); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes pip-pop {
  0%   { transform: scale(1); opacity: 1; }
  100% { transform: scale(0); opacity: 0; }
}
.res-pip.pip-spawn { animation: pip-spawn 180ms ease-out; }
.res-pip.pip-pop   { animation: pip-pop 140ms ease-in; }

/* High-contrast: thicken the socket so dim pips stay legible without glow. */
body.high-contrast .res-pip { opacity: 0.55; text-shadow: none; }
body.high-contrast .res-pip.filled { text-shadow: none; outline: calc(1px * var(--ui-scale)) solid var(--pip-c); border-radius: 50%; }

/* Reduced motion / flashing: instant fill/empty, no keyframes (TS also skips
   adding the classes when readReduceFlashing() is set). */
@media (prefers-reduced-motion: reduce) {
  .res-pip { transition: none; }
  .res-pip.pip-spawn, .res-pip.pip-pop { animation: none; }
}
body.reduce-motion .res-pip,
body.reduce-flashing .res-pip { transition: none; }
body.reduce-motion .res-pip.pip-spawn,
body.reduce-motion .res-pip.pip-pop,
body.reduce-flashing .res-pip.pip-spawn,
body.reduce-flashing .res-pip.pip-pop { animation: none; }

/* ===== ItemSlot + Paperdoll (HUD spec 2.e) =====
   The generic item cell + the equip mannequin built from it. Sizes scale with
   --ui-scale; each cell honours an optional per-slot --slot-size override. */

.item-slot {
  --slot-size: calc(40px * var(--ui-scale));
  position: relative;
  width: var(--slot-size);
  height: var(--slot-size);
  box-sizing: border-box;
  border: 1px solid var(--grid-line, #28303d);
  border-radius: calc(5px * var(--ui-scale));
  background: rgba(20, 26, 34, 0.95);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
}
.item-slot.empty { cursor: default; }
.item-slot.locked { cursor: default; opacity: 0.7; }

/* Hover/focus = gold outline (the "yours / actionable" cue). */
.item-slot.filled:hover,
.item-slot.filled:focus-visible {
  outline: calc(2px * var(--ui-scale)) solid var(--accent);
  outline-offset: -1px;
}

/* Icon — the 3D model render (or type-glyph fallback), fit to the cell. */
.item-slot .is-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
.item-slot .is-icon img {
  width: 100%;
  height: 100%;
  image-rendering: auto;
  display: block;
}

/* Faint EQP slot glyph on an empty cell. */
.item-slot .is-empty-glyph {
  font-size: calc(18px * var(--ui-scale));
  line-height: 1;
  color: var(--muted);
  opacity: 0.35;
}

/* Colour-independent rarity star-run, bottom-left. */
.item-slot .is-stars {
  position: absolute;
  left: calc(2px * var(--ui-scale));
  bottom: calc(1px * var(--ui-scale));
  font-size: calc(8px * var(--ui-scale));
  line-height: 1;
  color: var(--accent);
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}

/* Quantity badge, bottom-right (tabular so stacks don't jitter). */
.item-slot .is-qty {
  position: absolute;
  right: calc(2px * var(--ui-scale));
  bottom: calc(1px * var(--ui-scale));
  font-size: calc(10px * var(--ui-scale));
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}

/* Refine ▲N badge, top-left, in --accent. */
.item-slot .is-badge.refine-up {
  position: absolute;
  left: calc(2px * var(--ui-scale));
  top: calc(1px * var(--ui-scale));
  font-size: calc(9px * var(--ui-scale));
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}

/* Corner state flags — each colour paired with a glyph (never hue-only). */
.item-slot .is-flag {
  position: absolute;
  top: calc(1px * var(--ui-scale));
  right: calc(2px * var(--ui-scale));
  font-size: calc(10px * var(--ui-scale));
  line-height: 1;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}
.item-slot .is-flag.damaged { color: var(--danger); }
.item-slot .is-flag.bound { color: var(--accent); }

/* Damaged piece — red border + desaturated, dimmed icon. */
.item-slot.damaged { border-color: var(--danger); }
.item-slot.damaged .is-icon img { filter: grayscale(0.7) brightness(0.85); }

/* Bound-on-equip — gold border tint. */
.item-slot.bound { border-color: var(--accent); }

/* Equip-switch queued — ghost (dashed) ring. */
.item-slot.switch {
  outline: calc(2px * var(--ui-scale)) dashed var(--accent);
  outline-offset: calc(-2px * var(--ui-scale));
  opacity: 0.92;
}

/* Equip mannequin: two slot columns flanking a centre figure. */
.paperdoll {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(8px * var(--ui-scale));
}
.paperdoll .pd-col {
  display: flex;
  flex-direction: column;
  gap: calc(4px * var(--ui-scale));
}
.paperdoll .pd-mannequin {
  flex: 0 0 auto;
  width: calc(72px * var(--ui-scale));
  align-self: stretch;
  border: 1px solid var(--grid-line, #28303d);
  border-radius: calc(6px * var(--ui-scale));
  background: rgba(12, 16, 22, 0.6);
}
.paperdoll .pd-slot[data-eqp] { flex: 0 0 auto; }

/* High-contrast: thicken slot borders, drop the hover glow. */
body.high-contrast .item-slot { border-width: 2px; }
body.high-contrast .item-slot.filled:hover,
body.high-contrast .item-slot.filled:focus-visible { outline-width: calc(3px * var(--ui-scale)); }

/* ===== DataGrid (HUD spec 2.c) — sortable/searchable list window =============
   The workhorse list behind bag, storage, cart, vend, market, refine, mail,
   quest, roster. Lives inside a GameWindow body (the host element). Tokens:
   --grid-line (hairlines), --row-hover (hover wash), --sel-bar (selection bar,
   falls back to --accent), --accent (sort arrows). All sizes scale with
   --ui-scale; the only motion is the 120ms row enter/leave fade, gated by the
   reduced-motion blocks below (and skipped in JS via readReduceFlashing()). */
.dgrid {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  font-size: calc(13px * var(--ui-scale));
  color: var(--text);
}

/* Tools row: live search + a count chip. */
.dgrid-tools {
  display: flex;
  align-items: center;
  gap: calc(8px * var(--ui-scale));
  padding: calc(4px * var(--ui-scale)) calc(6px * var(--ui-scale));
  border-bottom: 1px solid var(--grid-line, #28303d);
}
.dgrid-search {
  flex: 1 1 auto;
  min-width: 0;
  padding: calc(4px * var(--ui-scale)) calc(8px * var(--ui-scale));
  background: var(--panel-2, #1c2533);
  border: 1px solid var(--grid-line, #28303d);
  border-radius: calc(5px * var(--ui-scale));
  color: var(--text);
  font-size: calc(13px * var(--ui-scale));
}
.dgrid-search:focus-visible { outline: calc(2px * var(--ui-scale)) solid var(--accent); outline-offset: 0; }
.dgrid-search:disabled { opacity: 0.5; }
.dgrid-count {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-size: calc(11px * var(--ui-scale));
  color: var(--muted);
}

/* Header + rows share a grid template (set inline from the column widths). */
.dgrid-head {
  display: grid;
  align-items: stretch;
  gap: calc(2px * var(--ui-scale));
  padding: 0 calc(6px * var(--ui-scale));
  border-bottom: 1px solid var(--grid-line, #28303d);
  background: var(--panel, #141a24);
  position: sticky;
  top: 0;
  z-index: 1;
}
.dgrid-th {
  display: flex;
  align-items: center;
  gap: calc(3px * var(--ui-scale));
  padding: calc(5px * var(--ui-scale)) calc(4px * var(--ui-scale));
  font-size: calc(11px * var(--ui-scale));
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  user-select: none;
}
.dgrid-th.align-r { justify-content: flex-end; }
.dgrid-th.align-c { justify-content: center; }
.dgrid-th.sortable { cursor: pointer; }
.dgrid-th.sortable:hover { color: var(--text); }
.dgrid-th.sortable:focus-visible { outline: calc(2px * var(--ui-scale)) solid var(--accent); outline-offset: -2px; }
.dgrid-th.sorted { color: var(--text); }
/* Sort arrow in --accent; empty until the column is the active sort. */
.dgrid-sort {
  font-size: calc(9px * var(--ui-scale));
  line-height: 1;
  color: var(--accent);
}
.dgrid-sort:empty { display: none; }

/* Scrolling body. */
.dgrid-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 calc(6px * var(--ui-scale)) calc(4px * var(--ui-scale));
}

/* One row — a grid mirroring the header columns. */
.dgrid-row {
  display: grid;
  align-items: center;
  gap: calc(2px * var(--ui-scale));
  padding: calc(4px * var(--ui-scale)) 0;
  border-bottom: 1px solid var(--grid-line, #28303d);
  border-left: calc(3px * var(--ui-scale)) solid transparent; /* reserve the selection bar gutter */
  cursor: default;
}
.dgrid-row:hover { outline: 1px solid var(--accent); outline-offset: calc(-1px * var(--ui-scale)); background: var(--row-hover, rgba(217,164,65,0.10)); }
.dgrid-row.selected { border-left-color: var(--sel-bar, var(--accent)); background: var(--row-hover, rgba(217,164,65,0.10)); }

.dgrid-cell {
  min-width: 0;
  padding: 0 calc(4px * var(--ui-scale));
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
/* Numeric columns: right-aligned + tabular so digits line up for scanning. */
.dgrid-cell.align-r { text-align: right; font-variant-numeric: tabular-nums; }
.dgrid-cell.align-c { text-align: center; }

/* Footer (zeny totals / pager). */
.dgrid-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: calc(8px * var(--ui-scale));
  padding: calc(5px * var(--ui-scale)) calc(8px * var(--ui-scale));
  border-top: 1px solid var(--grid-line, #28303d);
  font-variant-numeric: tabular-nums;
  font-size: calc(12px * var(--ui-scale));
  color: var(--muted);
}

/* Empty-state placeholder. */
.dgrid-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px * var(--ui-scale));
  color: var(--muted);
  font-size: calc(12px * var(--ui-scale));
  font-style: italic;
}

/* Busy overlay + spinner. */
.dgrid-busy {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 14, 20, 0.5);
  z-index: 3;
}
.dgrid-spinner {
  width: calc(28px * var(--ui-scale));
  height: calc(28px * var(--ui-scale));
  border: calc(3px * var(--ui-scale)) solid var(--grid-line, #28303d);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: dgrid-spin 720ms linear infinite;
}
@keyframes dgrid-spin { to { transform: rotate(360deg); } }

/* Row enter/leave fade — the only row motion (delta packets mutate in place). */
@keyframes dgrid-row-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes dgrid-row-out { from { opacity: 1; } to { opacity: 0; } }
.dgrid-row.dgrid-entering { animation: dgrid-row-in  120ms ease-out both; }
.dgrid-row.dgrid-leaving  { animation: dgrid-row-out 120ms ease-in  both; pointer-events: none; }

/* High-contrast: thicker hairlines + selection bar, no hover wash. */
body.high-contrast .dgrid-row { border-bottom-width: calc(1px * var(--ui-scale)); }
body.high-contrast .dgrid-row.selected { border-left-width: calc(4px * var(--ui-scale)); }
body.high-contrast .dgrid-row:hover { outline-width: calc(2px * var(--ui-scale)); background: none; }

/* Reduced motion / flashing: no spinner spin, no row fades (JS also skips the
   enter/leave classes when readReduceFlashing() is set). */
@media (prefers-reduced-motion: reduce) {
  .dgrid-spinner { animation: none; }
  .dgrid-row.dgrid-entering, .dgrid-row.dgrid-leaving { animation: none; }
}
body.reduce-motion .dgrid-spinner,
body.reduce-flashing .dgrid-spinner { animation: none; }
body.reduce-motion .dgrid-row.dgrid-entering,
body.reduce-motion .dgrid-row.dgrid-leaving,
body.reduce-flashing .dgrid-row.dgrid-entering,
body.reduce-flashing .dgrid-row.dgrid-leaving { animation: none; }

/* ===== EnhanceWindow (HUD spec §3.2) — refine / grade / enchant / reform shell ==
   Presentation-only chrome inside a GameWindow body. Composes ItemSlot (target),
   DataGrid (materials), the unit-frame `.bar` grammar (success gauge) and
   ResultFlash (results). Tokens only; all sizes scale with --ui-scale. */
.enhance-win {
  display: flex;
  flex-direction: column;
  gap: calc(10px * var(--ui-scale));
  min-width: calc(260px * var(--ui-scale));
  padding: calc(4px * var(--ui-scale));
  color: var(--text);
  font-size: calc(13px * var(--ui-scale));
}

/* Target row: the worked ItemSlot + its (refine-prefixed) name. */
.enhance-win .enhance-target {
  display: flex;
  align-items: center;
  gap: calc(10px * var(--ui-scale));
}
.enhance-win .enhance-name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.enhance-win .enhance-name.muted { color: var(--muted); font-weight: 400; font-style: italic; }

/* Material list: a short DataGrid; give it a bounded height so the gauge/action
   stay visible. The insufficient row reds its Have count (paired with the value). */
.enhance-win .enhance-mats { height: calc(132px * var(--ui-scale)); display: flex; }
.enhance-win .enhance-mats .dgrid { min-height: 0; }
.enhance-win .dgrid-row.insufficient .enhance-have-short,
.enhance-win .enhance-have-short { color: var(--danger); font-weight: 700; }

/* Zeny cost line. */
.enhance-win .enhance-zeny {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

/* Success gauge — reuses .bar/.bar-fill/.bar-text; only the container + the
   `.chance` fill gradient are local (the `.status-panel .bar` rule is scoped). */
.enhance-win .enhance-gauge { display: flex; flex-direction: column; gap: calc(3px * var(--ui-scale)); }
.enhance-win .enhance-gauge-label {
  font-size: calc(11px * var(--ui-scale));
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}
.enhance-win .enhance-gauge .bar {
  position: relative;
  height: calc(16px * var(--ui-scale));
  background: var(--panel-2, #1c2533);
  border: 1px solid var(--grid-line, #28303d);
  border-radius: calc(4px * var(--ui-scale));
  overflow: hidden;
}
.enhance-win .bar-fill.chance { background: linear-gradient(90deg, #c8821f, var(--accent)); }

/* "Safe to +N" marker — glyph + text, never hue-only. */
.enhance-win .enhance-safe {
  font-size: calc(12px * var(--ui-scale));
  font-weight: 600;
  color: var(--good, #6fd06a);
}

/* Primary action button. */
.enhance-win .enhance-action {
  align-self: stretch;
  padding: calc(7px * var(--ui-scale)) calc(12px * var(--ui-scale));
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: calc(6px * var(--ui-scale));
  color: #1a1206;
  font-size: calc(13px * var(--ui-scale));
  font-weight: 700;
  cursor: pointer;
}
.enhance-win .enhance-action:hover { filter: brightness(1.08); }
.enhance-win .enhance-action:disabled { opacity: 0.5; cursor: default; filter: none; }

body.high-contrast .enhance-win .enhance-gauge .bar { border-width: 2px; }

/* Smith pick-dialog (HUD §3.2) — the small "choose one item" window shared by
   the equip picker, the appraise list and the card-insert list. Reuses the
   GameWindow chrome + DataGrid; only the body layout + the gold confirm button
   (mirrors .enhance-action, scoped here) are local. Tokens only. */
.smith-pick {
  display: flex;
  flex-direction: column;
  gap: calc(8px * var(--ui-scale));
  min-width: calc(220px * var(--ui-scale));
  padding: calc(4px * var(--ui-scale));
  color: var(--text);
  font-size: calc(13px * var(--ui-scale));
}
.smith-pick .smith-pick-grid { height: calc(220px * var(--ui-scale)); display: flex; }
.smith-pick .smith-pick-grid .dgrid { min-height: 0; }
.smith-pick .smith-pick-action {
  align-self: stretch;
  padding: calc(7px * var(--ui-scale)) calc(12px * var(--ui-scale));
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: calc(6px * var(--ui-scale));
  color: #1a1206;
  font-size: calc(13px * var(--ui-scale));
  font-weight: 700;
  cursor: pointer;
}
.smith-pick .smith-pick-action:hover { filter: brightness(1.08); }
