/* Shared by Unit, Enemy, Stage and Settings. Do not block image links/tooltips. */
img, svg, canvas {
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

:root {
  --site-width: 1800px;
  --section-gap: 16px;
  --page-width: calc(var(--site-width) - 160px);
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
  --sidebar-width: 240px;
  --portrait-width: 205px;
  --treasure-width: 375px;
  --treasure-icon-width: 95px;
  --treasure-name-width: 186px;
  --status-label-width: 76px;
  --row-height: 50px;

  --page: #b06000;
  --card: #b96d0f;
  /* ヘッダー背景。光の色も自動で追従。個別に指定する場合は --header-glow を設定。 */
  --header: #601000;
  /* ゼブラ配色1：既存配色。配色2は各段をひとつ明るくする。 */
  --zebra-1-header: #702000;
  --zebra-1-odd: #803000;
  --zebra-1-even: #944400;
  --zebra-2-header: #803000;
  --zebra-2-odd: #944400;
  --zebra-2-even: #a85800;
  --heading: var(--zebra-1-header);
  --heading-2: var(--zebra-1-odd);
  --cell: var(--zebra-1-even);
  --note-background: var(--cell);
  --line: #a85800;
  /* The site's five text colors. */
  --text-orange: #f0c030;
  --text-cyan: #30c0f0;
  --text-orange-light: #f0f080;
  --text-cyan-light: #80f0f0;
  --text-white: #e0e0e0;
  --text: var(--text-white);
  --light-text: var(--text-white);
  --value-text: var(--text-white);
  --factor: var(--text-orange);
  --hp: var(--text-cyan-light);
  --dps: var(--text-orange-light);
  --active: #b06000;
  --shadow: 0 8px 22px rgba(57, 18, 0, .36);

  color: var(--text);
  background: var(--page);
  font-family: Avenir, "Open Sans", "Helvetica Neue", Helvetica, Arial, Verdana,
    Roboto, "游ゴシック", "Yu Gothic", "メイリオ", Meiryo, sans-serif;
}

* {
  box-sizing: border-box;
}

/* 新しい補足欄には site-note を使用する。既存ページの補足欄にも同じ背景を適用する。 */
.site-note, .catalog-note, .settings-note, .list-note, .local-settings-note,
.enemy-upgrade-note, .unit-calculation-note, .unit-talent-note, .unit-equipment-note,
.stage-material-note, .stage-treasure-note, .stage-treasure-guide-body {
  background-color: var(--note-background);
}
.site-note, .catalog-note {
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

/* 解放条件の素材とアイテム詳細のWB画像は、同じ台紙に載せる。 */
.unit-evolution-material, .item-detail-image {
  background-color: var(--heading-2);
  border-radius: 5px;
}

/* Match Unit's page bar; keep the animation switch on the character heading. */
.enemy-page-bar { position:relative; z-index:5; display:flex; align-items:center; justify-content:space-between; gap:16px; min-height:var(--row-height); margin:0 0 var(--section-gap); padding:8px 18px; color:var(--text); background:var(--heading); border:1px solid #b06000; border-radius:8px; box-shadow:var(--shadow); }
.enemy-form-links { display:flex; flex:1 1 auto; min-width:0; flex-wrap:wrap; gap:8px; margin:0; }
.enemy-form-links a { padding:6px 12px; border:1px solid var(--line); border-radius:6px; background:var(--heading-2); text-decoration:none; }
.enemy-form-links a:hover { background:var(--heading); }
.enemy-form-links a:focus-visible { outline:2px solid var(--factor); outline-offset:2px; }
.enemy-card#form1 { scroll-margin-top:12px; }
/* Navigation keeps its space, but failed/loading artwork and its number stay invisible. */
[data-enemy-navigation-image], .enemy-page-bar .enemy-neighbor-number { visibility:hidden; }
.is-navigation-image-loaded > [data-enemy-navigation-image], .enemy-page-bar .is-navigation-image-loaded > .enemy-neighbor-number { visibility:visible; }
.enemy-page-bar > .enemy-heading-tools { flex:0 0 auto; }
.enemy-page-bar .enemy-menu-panel { width:270px; }

html,
body {
  background: var(--page);
}

body {
  min-width:var(--site-width);
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.65;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

/* Header */
.header {
  color: #e0e0e0;
  background: var(--header);
  border-bottom: 5px solid var(--heading);
  box-shadow: 0 4px 14px rgba(96, 16, 0, .2);
}

.header-inner,
.topnav,
.workspace {
  width: var(--page-width);
  margin-inline: auto;
}

.header-inner {
  min-height: 125px;
  display: flex;
  align-items: center;
}

.header-inner .logo {
  position: relative;
  display: block;
  width: 100%;
  height: 125px;
  max-width: 100%;
  line-height: 0;
  text-decoration: none;
}

.header-inner .logo img {
  position: relative;
  display: block;
  width: 750px;
  height: 125px;
  zoom: 1;
}

/* 発光は画像幅の中だけに描く。Firefoxでも縁まで滑らかにするため、色停止点は0～100%に収める。 */
.header-inner .logo::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 750px;
  max-width: 100%;
  pointer-events: none;
  --glow-core: var(--header-glow, color-mix(in srgb, var(--header) 45%, white));
  --glow-wide: var(--header-glow, color-mix(in srgb, var(--header) 58%, white));
  --shade-left: color-mix(in srgb, var(--header) 80%, black);
  --shade-right: color-mix(in srgb, var(--header) 90%, black);
  background:
    radial-gradient(ellipse 345px 157.5px at 215.5px 67px in srgb,
      color-mix(in srgb, var(--glow-core) 68.3%, transparent) 0%,
      color-mix(in srgb, var(--glow-core) 64.16%, transparent) 8.333%,
      color-mix(in srgb, var(--glow-core) 53.19%, transparent) 16.667%,
      color-mix(in srgb, var(--glow-core) 38.92%, transparent) 25%,
      color-mix(in srgb, var(--glow-core) 25.13%, transparent) 33.333%,
      color-mix(in srgb, var(--glow-core) 14.32%, transparent) 41.667%,
      color-mix(in srgb, var(--glow-core) 7.2%, transparent) 50%,
      color-mix(in srgb, var(--glow-core) 3.19%, transparent) 58.333%,
      color-mix(in srgb, var(--glow-core) 1.25%, transparent) 66.667%,
      color-mix(in srgb, var(--glow-core) 0.13%, transparent) 83.333%,
      transparent 100%),
    radial-gradient(ellipse 984px 406.5px at 215.5px 67px in srgb,
      color-mix(in srgb, var(--glow-wide) 21%, transparent) 0%,
      color-mix(in srgb, var(--glow-wide) 19.73%, transparent) 8.333%,
      color-mix(in srgb, var(--glow-wide) 16.35%, transparent) 16.667%,
      color-mix(in srgb, var(--glow-wide) 11.97%, transparent) 25%,
      color-mix(in srgb, var(--glow-wide) 7.73%, transparent) 33.333%,
      color-mix(in srgb, var(--glow-wide) 4.4%, transparent) 41.667%,
      color-mix(in srgb, var(--glow-wide) 2.21%, transparent) 50%,
      color-mix(in srgb, var(--glow-wide) 0.98%, transparent) 58.333%,
      color-mix(in srgb, var(--glow-wide) 0.38%, transparent) 66.667%,
      color-mix(in srgb, var(--glow-wide) 0.04%, transparent) 83.333%,
      transparent 100%),
    linear-gradient(to right, var(--shade-left), var(--shade-right));
  mask-image: linear-gradient(to right, transparent, black 50px, black calc(100% - 150px), transparent),
    linear-gradient(to bottom, transparent, black 30px, black calc(100% - 30px), transparent);
  mask-composite: intersect;
}

@supports (color: hsl(from red h s l)) {
  .header-inner .logo::before {
    --glow-core: var(--header-glow, hsl(from var(--header) calc(h + 9.92) s calc(l + (100 - l) * .3889)));
    --glow-wide: hsl(from var(--glow-core) calc(h - 5.69) s l);
    --shade-left: hsl(from var(--header) calc(h - 3.77) s calc(l - min(l * .1979, (100 - l) * .046)));
    --shade-right: hsl(from var(--header) calc(h - 1.63) s calc(l - min(l * .1042, (100 - l) * .0242)));
  }
}

.header-inner .logo:focus-visible {
  outline: 2px solid var(--text-cyan);
  outline-offset: 3px;
}

.topnav {
  display: flex;
  background: var(--heading);
}

.topnav a {
  padding: 13px 23px;
  color: #e0e0e0;
  border-right: 1px solid #944400;
  text-decoration: none;
}

.topnav a:hover {
  color: #e0e0e0;
  background: var(--heading-2);
}

.topnav .active {
  color: #e0e0e0;
  background: var(--active);
}

/* Page layout */
.workspace {
  margin-block: 22px 50px;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  gap: 22px;
}

.main {
  min-width: 0;
}

/* Sidebar */
.sidebar {
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 22px;
  color: var(--light-text);
}

.sidebar section,
.sidebar > .sidebar-primary-group {
  margin: 0;
  overflow: hidden;
  background: var(--cell);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.sidebar h2,
.sidebar .sidebar-primary-group > summary,
.sidebar :is(a, button) {
  position: relative;
  width: 100%;
  margin: 0;
  display: flex;
  align-items: center;
  font-size: 13px;
  font-weight: 400;
}

.sidebar h2,
.sidebar .sidebar-primary-group > summary {
  height: var(--row-height);
  padding: 0 16px;
  line-height: 1;
  white-space: nowrap;
  color: var(--light-text);
  background: var(--heading);
}

.sidebar h2::after,
.sidebar a:not(:last-child)::after,
.sidebar button:not(:last-of-type)::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 1px;
  background: var(--line);
  pointer-events: none;
}

.sidebar :is(a, button) {
  min-height: 42px;
  padding: 7px 14px;
  line-height: 1.5;
  white-space: normal;
  text-align: left;
  color: var(--light-text);
  background: var(--cell);
  text-decoration: none;
}

.sidebar button {
  border: 0;
  border-radius: 0;
  cursor: pointer;
}

.sidebar :is(a, button):where(:not(:disabled)):is(:hover, :focus-visible) {
  color: var(--light-text);
  background: #a05000;
  text-decoration: underline;
  text-underline-offset: .15em;
}

.sidebar :is(.current, [aria-current="page"], [aria-current="true"], button[role="tab"][aria-selected="true"], a.stage-map-membership) {
  color: var(--factor);
  background: var(--cell);
}

.sidebar button:disabled {
  opacity: .6;
  cursor: default;
}

.sidebar h2:has(> a) {
  padding: 0;
}

.sidebar h2 > a {
  height: 100%;
  padding: 0 16px;
  line-height: inherit;
  color: inherit;
  background: transparent;
}

:root .sidebar :is(a, summary, button):focus-visible {
  outline: 2px solid var(--factor);
  outline-offset: -2px;
}

/* Enemy card */
.enemy-card {
  min-height: 570px;
  overflow: hidden;
  background: var(--card);
  border: 1px solid #b06000;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.enemy-heading {
  height: var(--row-height);
  padding-inline: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #e0e0e0;
  background: var(--heading);
}

.enemy-title,
.enemy-heading-actions {
  display: flex;
  align-items: center;
}

.enemy-title {
  gap: 16px;
}

.enemy-no {
  font-size: 14px;
  opacity: .88;
}

.enemy-title-icon {
  display: block;
  width: 81px;
  height: 32px;
  flex-shrink: 0;
}

.enemy-title-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.portrait-attributes {
  width: 100%;
  min-height: var(--row-height);
  margin-top: 10px;
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.8;
  color: var(--light-text);
  background: var(--heading-2);
  box-shadow: inset 0 0 0 1px var(--line);
  border-radius: 5px;
  text-align: left;
}

.portrait-attribute {
  line-height: inherit;
}

.portrait-radar,
.portrait-radar *,
[data-wb-view],
[data-wb-view] * {
  -webkit-user-select: none;
  user-select: none;
}

.portrait-radar {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--heading-2);
  border-radius: 6px;
  overflow: hidden;
}

.radar-wb-background {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: .1; /* 90% transparent */
  pointer-events: none;
}
.radar-wb-background img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.enemy-radar { position: relative; z-index: 1; display: block; width: 100%; height: 100%; }
.radar-grid { fill: none; stroke: #f0f080; stroke-opacity: .22; stroke-width: .7; }
.radar-grid-major { stroke-opacity: .4; stroke-width: .9; }
.radar-grid-axis { stroke-opacity: .3; }
.radar-values { fill: #e0e0e0; fill-opacity: .25; stroke: #e0e0e0; stroke-width: 2; stroke-linejoin: round; }
.radar-label { fill: var(--light-text); font-size: 14px; }
.radar-total-rank {
  fill: var(--light-text);
  font-size: 18px;
  font-weight: 700;
  stroke: var(--heading-2);
  stroke-width: 3px;
  paint-order: stroke fill;
  pointer-events: none;
}

.portrait-visual {
  width: var(--portrait-width);
  height: var(--portrait-width);
  cursor: pointer;
  border-radius: 6px;
}
.portrait-visual > [hidden] { display: none; }
.portrait-visual:focus-visible { outline: 2px solid #f0c030; outline-offset: 2px; }

.enemy-detail-heading {
  display: grid;
  grid-template-columns: var(--portrait-width) minmax(0, 1fr) auto;
  column-gap: 18px;
}

.enemy-detail-heading .enemy-title {
  /* Same column as magnification: its 1px border + 8px value padding. */
  padding-inline: 16px 9px;
}
.enemy-detail-heading .enemy-title-icon { margin-inline-start: auto; }

.enemy-heading-name {
  /* Match the table's 1px border and 16px cell padding. */
  padding-left: 17px;
  min-width: 0;
}

.enemy-heading-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 100%;
}
/* OFF is 36px tools + 16px padding + 2px border. Keep that bar height ON too.
   Navigation retains its 40px artwork and 5px frame padding, centered vertically. */
.enemy-page-bar, .unit-page-bar { height:calc(var(--row-height) + 4px); }
.enemy-page-bar > .enemy-heading-tools, .unit-page-bar > .enemy-heading-tools { height:36px; }
.enemy-page-bar .enemy-heading-actions, .unit-page-bar .enemy-heading-actions { height:50px; flex-shrink:0; }
.enemy-page-bar > .enemy-form-links, .unit-page-bar > .unit-form-links { flex-wrap:nowrap; overflow-x:auto; }
.enemy-page-bar > .enemy-form-links a, .unit-page-bar > .unit-form-links a { flex-shrink:0; }
.enemy-heading-actions[hidden],
.enemy-sync-toggle[hidden],
[data-animation-menu][hidden],
.enemy-menu-panel[hidden],
[data-time-secondary][hidden] { display: none; }
.enemy-page-menu { position: relative; }
.enemy-menu-toggle,
.enemy-sync-toggle {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  color: var(--text);
  background: transparent;
  cursor: pointer;
}
.enemy-sync-toggle:hover,
.enemy-menu-toggle:hover,
.enemy-menu-toggle[aria-expanded="true"] { background: var(--heading-2); }
.enemy-sync-toggle:disabled,
.enemy-sync-toggle:disabled:hover { color: var(--text-white); background: transparent; opacity: 1; cursor: default; }
/* The same frame and two horizontal rules form both list glyphs. */
.view-list-icon {
  position:relative;display:block;width:20px;height:18px;box-sizing:border-box;
  border:2px solid currentColor;border-radius:3px;
  background:linear-gradient(currentColor,currentColor) left 3px / 100% 2px no-repeat;
}
.view-list-icon::after {
  content:"";position:absolute;left:0;right:0;top:8px;height:2px;background:currentColor;
}
.stage-status-toggle .view-list-icon::before {
  content:"";position:absolute;left:5px;top:4px;bottom:0;width:2px;background:currentColor;
  transform:scaleY(1);transition:transform 140ms ease-out 130ms;
}
.stage-status-toggle .view-list-icon::after {left:6px;transition:left 130ms ease-in}
.stage-status-toggle[aria-pressed="true"] .view-list-icon::before {
  transform:scaleY(0);transition:transform 140ms ease-in;
}
.stage-status-toggle[aria-pressed="true"] .view-list-icon::after {left:0;transition:left 130ms ease-out 140ms}

/* One reversible timeline keeps both glyphs and the central dot in sync. */
@property --bc-video-progress {syntax:"<number>";inherits:true;initial-value:0}
.enemy-sync-toggle {--bc-video-progress:0;transition:--bc-video-progress 360ms ease-in-out}
.enemy-sync-toggle[aria-pressed="true"] {--bc-video-progress:1}
.enemy-sync-toggle::before,.enemy-sync-toggle::after,.enemy-sync-toggle .view-list-icon {grid-area:1 / 1;pointer-events:none}
.enemy-sync-toggle::before {
  content:"";width:21px;height:21px;background:#fff;
  /* White film from img037_ja: outer edge, triangular cutout and eight perforations. */
  clip-path:path(evenodd,"M0.58,0.48 0.51,19.82 0.73,20.58 20.93,20.64 21.42,20.44 21.49,1.10 21.27,0.33 1.07,0.28Z\
    M17.23,17.43 18.26,16.76 20.01,16.90 20.51,17.47 20.56,18.63 20.00,19.42 17.70,19.40 17.13,18.62Z\
    M11.99,17.39 13.01,16.76 14.80,16.92 15.29,17.49 15.35,18.63 14.76,19.40 12.45,19.40 11.88,18.63Z\
    M6.73,17.45 7.20,16.92 7.76,16.76 9.53,16.90 10.06,17.49 10.12,18.63 9.50,19.42 7.22,19.40 6.65,18.62Z\
    M1.62,17.27 2.51,16.76 4.26,16.90 4.79,17.47 4.87,18.62 4.25,19.42 1.99,19.40 1.42,18.54Z\
    M6.58,5.80 7.35,5.60 16.35,10.45 16.20,10.85 7.29,15.39 6.71,15.24Z\
    M17.48,1.70 18.23,1.41 20.05,1.52 20.58,2.30 20.51,3.47 20.05,4.00 19.49,4.16 17.70,4.01 17.06,2.92Z\
    M12.23,1.70 12.98,1.41 14.80,1.52 15.37,2.28 15.29,3.47 14.24,4.16 12.45,4.01 11.81,2.92Z\
    M7.00,1.68 7.73,1.41 9.55,1.52 10.12,2.28 10.04,3.47 8.99,4.16 7.20,4.01 6.56,2.92Z\
    M1.73,1.72 2.48,1.41 4.30,1.52 4.87,2.28 4.79,3.47 3.74,4.16 1.95,4.01 1.35,2.88Z");
  transform:scale(clamp(.24,calc(1 - 1.7 * var(--bc-video-progress)),1));
  opacity:clamp(0,calc(1.5 - 3 * var(--bc-video-progress)),1);
}
.enemy-sync-toggle::after {
  content:"";width:6px;height:6px;border-radius:50%;background:currentColor;
  opacity:clamp(0,min(calc(4 * var(--bc-video-progress)),calc(4 - 4 * var(--bc-video-progress))),1);
}
.enemy-sync-toggle .view-list-icon {
  transform:scale(clamp(.24,calc(1.7 * var(--bc-video-progress) - .7),1));
  opacity:clamp(0,calc(3 * var(--bc-video-progress) - 1.5),1);
}
.enemy-menu-lines { position: relative; width: 18px; height: 14px; }
.enemy-menu-lines span {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
  transform-origin: center;
  transition: transform 180ms ease, opacity 180ms ease;
}
.enemy-menu-lines span:nth-child(1) { top: 0; }
.enemy-menu-lines span:nth-child(2) { top: 6px; }
.enemy-menu-lines span:nth-child(3) { top: 12px; }
.enemy-menu-toggle[aria-expanded="true"] .enemy-menu-lines span:nth-child(1) {
  /* Compensate for diagonal antialiasing without changing the closed bars. */
  transform: translateY(6px) rotate(45deg) scaleY(1.5);
}
.enemy-menu-toggle[aria-expanded="true"] .enemy-menu-lines span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.enemy-menu-toggle[aria-expanded="true"] .enemy-menu-lines span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg) scaleY(1.5);
}
@media (prefers-reduced-motion: reduce) {
  .enemy-menu-lines span { transition: none; }
  .enemy-sync-toggle,.stage-status-toggle .view-list-icon::before,.stage-status-toggle .view-list-icon::after,
  .stage-status-toggle[aria-pressed="true"] .view-list-icon::before,.stage-status-toggle[aria-pressed="true"] .view-list-icon::after {transition:none}
}
.enemy-menu-panel {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  z-index: 30;
  width: 270px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  background: var(--heading);
  box-shadow: 0 3px 8px rgba(0, 0, 0, .18);
}
.enemy-menu-caption { padding: 4px 8px 6px; font-size: 12px; opacity: .75; }
.enemy-menu-panel button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 36px;
  padding: 7px 8px;
  border: 0;
  border-radius: 3px;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.enemy-menu-panel button:hover:not(:disabled) { background: var(--heading-2); }
.enemy-menu-panel button:disabled { opacity: .45; cursor: default; }
.enemy-menu-state { flex-shrink: 0; font-size: 12px; opacity: .8; }
.enemy-sync-toggle:focus-visible,
.enemy-menu-toggle:focus-visible,
.enemy-menu-panel button:focus-visible { outline: 2px solid var(--factor); outline-offset: 1px; }

.enemy-title strong,
.enemy-heading-name {
  font-size: 22px;
  font-weight: 700;
}

.enemy-heading-actions {
  position: relative;
  height: 100%;
  gap: 0;
  padding: 5px;
}

.enemy-heading-actions::before {
  content: "";
  position: absolute;
  inset: 5px;
  z-index: 1;
  border: 1px solid var(--line);
  border-radius: 5px;
  pointer-events: none;
}

.enemy-heading-actions button,
.enemy-navigation-current {
  width: 60px;
  height: 40px;
  flex: 0 0 60px;
  min-width: 0;
  min-height: 0;
}

.enemy-heading-actions button {
  --neighbor-background: #7c2c00;
  /* 72 : 60 : 72 = 1.5 : 1.25 : 1.5; keep the shared 40px height. */
  width: 72px;
  flex-basis: 72px;
  position: relative;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  white-space: nowrap;
  align-items: center;
  justify-content: center;
  color: #e0e0e0;
  background: transparent;
  border: 0;
  border-radius: 5px;
  box-shadow: none;
  cursor: pointer;
}

.enemy-heading-actions button:hover {
  --neighbor-background: #8c3c00;
}

/* One continuous outline: all arcs have the same 5px radius.
   Only the inner arcs reverse direction; do not clip the focus outline. */
.enemy-heading-actions button::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--neighbor-background);
  -webkit-mask: var(--neighbor-shape) center / 100% 100% no-repeat;
  mask: var(--neighbor-shape) center / 100% 100% no-repeat;
  pointer-events: none;
}
.enemy-heading-actions button:first-child {
  --neighbor-shape: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 72 40'%3E%3Cpath fill='white' d='M5 0H72A5 5 0 0 0 67 5V35A5 5 0 0 0 72 40H5A5 5 0 0 1 0 35V5A5 5 0 0 1 5 0Z'/%3E%3C/svg%3E");
}
.enemy-heading-actions button:last-child {
  --neighbor-shape: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 72 40'%3E%3Cpath fill='white' d='M0 0H67A5 5 0 0 1 72 5V35A5 5 0 0 1 67 40H0A5 5 0 0 0 5 35V5A5 5 0 0 0 0 0Z'/%3E%3C/svg%3E");
}
.enemy-heading-actions button:focus-visible {
  outline: 2px solid #f0c030;
  outline-offset: 2px;
}

.enemy-neighbor-icon {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.enemy-neighbor-icon,
.enemy-navigation-current img {
  width: 100%;
  height: 100%;
}
.enemy-neighbor-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: .75; /* 25% transparent; leave the number fully opaque. */
}
.enemy-neighbor-number {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  padding: 1px 0;
  text-align: center;
  white-space: nowrap;
  color: #e0e0e0;
  background: transparent;
  font-size: 13px;
  font-weight: 400;
  font-family: monospace;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  pointer-events: none;
}
.enemy-neighbor-empty {
  position: relative;
  width: 100%;
  font-size: 10px;
  white-space: normal;
}

.enemy-navigation-current {
  position: relative;
  display: block;
  overflow: hidden;
}
.enemy-navigation-current img {
  position: absolute;
  inset: 0;
  display: block;
  object-fit: contain;
  opacity: .5;
  pointer-events: none;
}

.enemy-neighbor-icon,
.enemy-neighbor-number,
.enemy-navigation-current {
  -webkit-user-select: none;
  user-select: none;
}

.enemy-main {
  min-height: 520px;
  padding: 18px;
  display: grid;
  grid-template-columns: var(--portrait-width) minmax(0, 1fr);
  align-items: start;
  gap: 18px;
  background: var(--card);
}

.enemy-main.is-treasure-open {
  grid-template-columns: var(--portrait-width) minmax(0, 1fr) var(--treasure-width);
}

/* Portrait and magnification */
.portrait-column {
  width: var(--portrait-width);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.image-space {
  position: relative;
  width: var(--portrait-width);
  height: var(--portrait-width);
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #e0e0e0;
  background: var(--heading-2);
  border-radius: 6px;
}

.image-space img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.portrait-version-row {
  width: 100%;
  height: var(--row-height);
  margin-top: 10px;
  padding-inline: 16px;
  display: flex;
  align-items: center;
  overflow: hidden;
  color: var(--light-text);
  background: var(--cell);
  border: 1px solid var(--line);
  border-radius: 5px;
  text-align: left;
}

/* Match detail rows' 50px content plus 1px top/bottom borders.
   Unit has its own one-row level control; do not change its sizing here. */
.enemy-card:not(.unit-card) .portrait-column { --enemy-panel-height:calc(var(--row-height) + 2px); }
.enemy-card:not(.unit-card) .portrait-attributes { min-height:var(--enemy-panel-height); }
.enemy-card:not(.unit-card) .portrait-version-row,
.enemy-card:not(.unit-card) .portrait-magnify > .treasure-toggle-control { height:var(--enemy-panel-height); }
.enemy-card:not(.unit-card) .portrait-magnify > .treasure-toggle-control > .treasure-toggle-label,
.enemy-card:not(.unit-card) .portrait-magnify > .treasure-toggle-control > .treasure-toggle-factor { height:100%; }
.enemy-card:not(.unit-card) .portrait-magnify > .magnify-table { border:0; }
.enemy-card:not(.unit-card) .magnify-control { height:var(--enemy-panel-height); border:1px solid var(--line); }
.enemy-card:not(.unit-card) .magnify-control + .magnify-control { border-top:0; }
.enemy-card:not(.unit-card) .magnify-control + .magnify-control::before { display:none; }
.enemy-card:not(.unit-card) .magnify-label,
.enemy-card:not(.unit-card) .magnify-value { height:100%; }

.portrait-version-value {
  display: flex;
  align-items: center;
  white-space: nowrap;
}

.portrait-magnify {
  width: 100%;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--light-text);
  text-align: left;
}

.magnify-table {
  width: 100%;
  overflow: hidden;
  color: #e0e0e0;
  background: var(--cell);
  border: 1px solid var(--line);
  border-radius: 5px;
}

.magnify-control {
  position: relative;
  width: 100%;
  height: var(--row-height);
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  overflow: hidden;
  color: #e0e0e0;
  background: var(--cell);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}

.magnify-control + .magnify-control::before {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 0 0 auto;
  height: 1px;
  background: var(--line);
  pointer-events: none;
}

.magnify-label,
.magnify-value {
  height: var(--row-height);
  display: flex;
  align-items: center;
  white-space: nowrap;
}

.magnify-label {
  padding-inline: 16px;
  color: #e0e0e0;
  background: var(--heading-2);
  cursor: text;
}

.magnify-value {
  padding-inline: 8px;
  justify-content: flex-end;
  gap: 3px;
  color: var(--value-text);
  background: var(--cell);
  cursor: pointer;
}

.magnify-value input,
.treasure-input-wrap input {
  padding: 3px 2px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  outline: 0;
  text-align: right;
  cursor: pointer;
  appearance: textfield;
}

.magnify-value input {
  width: 78px;
  min-width: 78px;
  max-width: 78px;
  color: var(--value-text);
}

.magnify-value input:focus,
.treasure-input-wrap input:focus {
  border-bottom-color: var(--active);
  cursor: text;
}

.magnify-value input::-webkit-inner-spin-button,
.magnify-value input::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
}

.treasure-toggle-control {
  width: 100%;
  height: var(--row-height);
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: stretch;
  overflow: hidden;
  color: #e0e0e0;
  background: var(--heading-2);
  border: 0;
  border-radius: 5px;
  outline: 0;
  box-shadow: none;
  text-align: left;
  cursor: pointer;
}

.treasure-toggle-control:is(:hover, :focus, :focus-visible, :active, [aria-expanded="true"]) {
  color: #e0e0e0;
  background: var(--heading-2);
  outline: 0;
  box-shadow: none;
}

.treasure-toggle-label,
.treasure-toggle-factor,
.treasure-heading-title,
.treasure-heading-factor {
  height: var(--row-height);
  display: flex;
  align-items: center;
  white-space: nowrap;
}

.treasure-toggle-label {
  padding-inline: 16px;
  color: #e0e0e0;
}

.treasure-toggle-factor {
  padding-inline: 12px;
  justify-content: center;
  gap: 4px;
  color: var(--factor);
}

.treasure-toggle-factor strong,
.treasure-heading-factor strong {
  color: inherit;
  font-weight: 400;
}

/* Status */
.status-column {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.character-data { display: flex; flex-direction: column; gap: 10px; }
.character-details { display:flex; flex-direction:column; gap:10px; min-width:0; }
.character-details:empty { display:none; }
.character-view-stack { position:relative; min-width:0; }
.character-view-stack.is-view-transitioning { overflow:hidden; }
.character-data[hidden], .enemy-animation-view[hidden], .enemy-animation-message[hidden] { display: none; }
.enemy-animation-view { min-width: 0; }
.enemy-animation-stage {
  position: relative;
  height: clamp(280px, 34vw, 420px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--heading-2);
}
.enemy-animation-stage canvas { position: relative; z-index: 1; display: block; width: 100%; height: 100%; }
.enemy-animation-status-background {
  /* Cancel the stage border inset so the cloned table has the same origin and
     full width as the status table before switching to animation. */
  position: absolute; z-index: 0; inset: -1px;
  display: flex; flex-direction: column;
  opacity: .75; pointer-events: none; user-select: none; -webkit-user-select: none;
}
.enemy-animation-status-background .stats {
  mask-image: linear-gradient(to right, #000 0, #000 var(--status-fade-start, 65%), transparent calc(var(--status-fade-start, 65%) + 160px));
  -webkit-mask-image: linear-gradient(to right, #000 0, #000 var(--status-fade-start, 65%), transparent calc(var(--status-fade-start, 65%) + 160px));
}
/* Paint every separator on the cells, including the last row. Mixing the
   table's outer border with cell borders can change rasterization at zoomed
   or fractional positions. Keep the same total table height. */
.enemy-animation-status-background .stats { width: 100%; flex: 0 0 auto; border-bottom: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.enemy-animation-status-background .stats tr:last-child > * { height: 51px; border-bottom: 1px solid var(--line); }
.enemy-animation-status-background .enemy-animation-background-traits {
  flex: 0 0 auto; min-height: 52px; margin-top: -1px;
  border-top-left-radius: 0; border-top-right-radius: 0;
  position:relative; isolation:isolate; overflow:visible;
  background:transparent; border-color:transparent;
  mask-image:none; -webkit-mask-image:none;
}
/* Fade only the painted panel. The text remains outside the masked layer. */
.enemy-animation-background-traits::before {
  content:""; position:absolute; z-index:-1; inset:0 -1px -80px;
  border:1px solid var(--line); border-radius:inherit;
  border-top:0; /* The stats table already draws the shared separator. */
  background:linear-gradient(to right,var(--heading-2) 0,var(--heading-2) var(--status-label-width),var(--cell) var(--status-label-width),var(--cell) 100%);
  mask-image:linear-gradient(to right,#000 var(--status-fade-start,65%),transparent calc(var(--status-fade-start,65%) + 160px)),linear-gradient(to bottom,#000 var(--traits-fade-bottom,50px),transparent calc(var(--traits-fade-bottom,50px) + 80px));
  -webkit-mask-image:linear-gradient(to right,#000 var(--status-fade-start,65%),transparent calc(var(--status-fade-start,65%) + 160px)),linear-gradient(to bottom,#000 var(--traits-fade-bottom,50px),transparent calc(var(--traits-fade-bottom,50px) + 80px));
  mask-composite:intersect; -webkit-mask-composite:source-in;
}
.enemy-animation-background-traits > .detail-label,
.enemy-animation-background-traits > .detail-content { background:transparent; }
.enemy-animation-message {
  position: absolute; z-index: 2; inset: 0; margin: 0; padding: 24px;
  display: grid; place-items: center; text-align: center; color: #e0e0e0;
}
.detail-row.enemy-animation-controls { margin-top:10px; height:calc(var(--row-height) + 2px); min-height:calc(var(--row-height) + 2px); grid-template-rows:calc(var(--row-height) + 2px); grid-template-columns:calc(var(--status-label-width) + 1px) minmax(0,1fr); border:0; }
.enemy-animation-controls .detail-content { display: flex; flex-wrap: nowrap; align-items: center; gap: 18px; padding: 0 18px; min-height: 0; }
.enemy-animation-controls .detail-content { overflow-x:auto; }
.enemy-animation-target select { max-width:130px; }
/* Match the adjacent borderless upgrade heading's entire 52px background,
   not a 50px interior enclosed by two 1px borders. Keep the text's x position. */
.enemy-animation-controls > .detail-label { align-items:center; height:calc(var(--row-height) + 2px); min-height:0; padding-left:17px; line-height:1.8; }
.enemy-animation-motions, .enemy-animation-options, .enemy-animation-playback {
  display: flex; flex-wrap: nowrap; align-items: center; gap: 7px;
}
.enemy-animation-options, .enemy-animation-playback { margin-top: 0; }
.enemy-animation-controls button, .enemy-animation-controls select {
  padding: 5px 9px; border: 1px solid var(--line); border-radius: 4px;
  color: var(--text); background: var(--heading); font: inherit; font-size: 13px;
}
.enemy-animation-controls button { cursor: pointer; }
.enemy-animation-controls button:hover:not(:disabled),
.enemy-animation-controls button[aria-pressed="true"] { background: var(--heading-2); }
.enemy-animation-controls button:disabled { opacity: .45; cursor: default; }
.enemy-animation-controls label { display: flex; align-items: center; gap: 5px; font-size: 13px; }
.enemy-animation-controls label, .enemy-animation-controls output { white-space: nowrap; }
.enemy-animation-controls output { min-width: 40px; text-align: right; }
.enemy-animation-controls input[type="range"] {
  appearance: none; -webkit-appearance: none;
  min-width: 0; height: 20px; margin: 0; padding: 0;
  background: transparent; cursor: pointer;
}
.enemy-animation-options input[type="range"], .enemy-animation-playback input[type="range"] { width: 180px; }
.enemy-animation-controls input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border: 1px solid var(--line); border-radius: 3px; background: var(--heading-2);
}
.enemy-animation-controls input[type="range"]::-moz-range-track {
  height: 4px; border: 1px solid var(--line); border-radius: 3px; background: var(--heading-2);
}
.enemy-animation-controls input[type="range"]::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none;
  width: 14px; height: 14px; margin-top: -5px;
  border: 1px solid var(--heading-2); border-radius: 50%; background: var(--factor);
}
.enemy-animation-controls input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px; border: 1px solid var(--heading-2); border-radius: 50%; background: var(--factor);
}
.enemy-animation-controls input[type="range"]:focus-visible { outline: 1px solid var(--factor); outline-offset: 3px; border-radius: 3px; }
.enemy-animation-controls input[type="range"]:disabled { opacity: .45; cursor: default; }
.enemy-animation-controls button:focus-visible { outline: 2px solid var(--factor); outline-offset: 2px; }

.attribute-line {
  --attribute-bridge-width: 0px;
  width: 100%;
  height: 52px;
  display: grid;
  grid-template-columns: 104px var(--attribute-bridge-width) minmax(0, 1fr);
  align-items: stretch;
}

.attribute-line .image-box {
  position: relative;
  height: 52px;
  padding: 5px 6px 5px 16px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--heading-2);
  border: 1px solid var(--line);
  border-right: 0;
  border-radius: 6px 0 0 6px;
}

.attribute-line .image-box img {
  display: block;
  width: 81px;
  max-width: 100%;
  height: 40px;
  object-fit: contain;
  border-radius: 4px;
}

.image-attribute-gradient {
  height: 52px;
  background: linear-gradient(90deg, var(--heading-2) 0 18%, var(--cell));
  border-block: 1px solid var(--line);
}

.attribute-row {
  height: 52px;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  overflow: hidden;
  background: var(--cell);
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 6px 6px 0;
}

.attribute-label,
.attribute-row a {
  height: var(--row-height);
  padding-inline: 16px;
  display: flex;
  align-items: center;
}

.attribute-label {
  color: #e0e0e0;
  background: var(--heading-2);
  white-space: nowrap;
}

.attribute-row a {
  color: var(--value-text);
  text-decoration: none;
}

.stats {
  width: 100%;
  table-layout: auto;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.stats th,
.stats td {
  height: var(--row-height);
  padding-inline: 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.stats tr:not(:last-child) > * {
  height: 51px;
}

.stats tr:last-child > * {
  border-bottom: 0;
}

.stats th {
  width: 1%;
  color: #e0e0e0;
  background: var(--heading-2);
  font-weight: 400;
  text-align: left;
}

.stats th:first-child {
  width: var(--status-label-width);
  min-width: var(--status-label-width);
  max-width: var(--status-label-width);
}

.stats td {
  color: var(--light-text);
  background: var(--cell);
}

.stats :is(.value, .subvalue) {
  width: 1%;
  text-align: right;
}

.stats .hp { color: var(--hp); }
.stats .atk { color: var(--factor); }
.stats .dps { color: var(--dps); }

.stats .empty-cell {
  width: 100%;
  min-width: 0;
  padding-inline: 0;
}

.detail-row {
  width: 100%;
  min-height: 52px;
  display: grid;
  grid-template-columns: var(--status-label-width) minmax(0, 1fr);
  align-items: stretch;
  overflow: hidden;
  background: var(--cell);
  border: 1px solid var(--line);
  border-radius: 5px;
}

.detail-label,
.detail-content {
  min-height: var(--row-height);
  display: flex;
  align-items: center;
}

.detail-label {
  padding-inline: 16px;
  color: #e0e0e0;
  background: var(--heading-2);
  white-space: nowrap;
}

.detail-content {
  padding-inline: 18px;
  color: var(--light-text);
  background: var(--cell);
}

/* Center the first line in a standard 50px row, not in the full multi-line
   panel. Matching line heights/insets keep label and first body line aligned. */
.description .detail-label,
.detail-row:has(.traits-content) .detail-label {
  align-items: flex-start;
  line-height: 1.8;
  padding-block: calc((var(--row-height) - 1.8em) / 2);
}

.description .detail-content {
  padding-block: calc((var(--row-height) - 1.8em) / 2);
  display: block;
  line-height: 1.8;
}

/* Treasure panel */
.treasure-column {
  width: var(--treasure-width);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.treasure-column[hidden] {
  display: none;
}

.treasure-column-heading {
  width: 100%;
  height: var(--row-height);
  display: grid;
  grid-template-columns: var(--treasure-icon-width) minmax(0, 1fr);
  align-items: stretch;
  overflow: hidden;
  color: #e0e0e0;
  background: var(--heading-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  line-height: 1.4;
}

.treasure-heading-title {
  padding-inline: 14px;
  color: #e0e0e0;
}

.treasure-heading-factor {
  padding-inline: 16px;
  gap: 4px;
  color: var(--factor);
}

.treasure-list {
  width: 100%;
  display: grid;
  grid-template-columns: var(--treasure-icon-width) var(--treasure-name-width) minmax(92px, 1fr);
  overflow: hidden;
  color: var(--light-text);
  background: #803000;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.treasure-item {
  position: relative;
  grid-column: 1 / -1;
  height: var(--row-height);
  display: grid;
  grid-template-columns: subgrid;
  color: #e0e0e0;
  background: var(--cell);
  cursor: text;
}

@supports not (grid-template-columns: subgrid) {
  .treasure-item {
    grid-template-columns: var(--treasure-icon-width) var(--treasure-name-width) minmax(92px, 1fr);
  }
}

.treasure-item:not(:last-child)::after {
  content: "";
  position: absolute;
  z-index: 2;
  inset: auto 0 0;
  height: 1px;
  background: var(--line);
  pointer-events: none;
}

.treasure-icon,
.treasure-name,
.treasure-input-wrap {
  height: var(--row-height);
}

.treasure-icon {
  position: relative;
  padding: 5px 6px 5px 16px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--heading-2);
}

.treasure-icon img {
  display: block;
  width: auto;
  max-width: 100%;
  height: 38px;
  object-fit: contain;
  border-radius: 4px;
}

.treasure-name {
  padding-inline: 16px;
  display: flex;
  align-items: center;
  color: #e0e0e0;
  background: var(--heading-2);
  white-space: nowrap;
}

.treasure-item.is-active .treasure-name {
  color: var(--factor);
}

.treasure-input-wrap {
  width: 100%;
  min-width: 0;
  padding: 8px 9px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  color: var(--value-text);
  background: var(--cell);
  cursor: pointer;
}

.treasure-input-wrap input {
  width: 54px;
  color: #e0e0e0;
}

/* Missing images */
.enemy-upgrades { --treasure-icon-width:74px; --treasure-name-width:182px; }
.enemy-upgrades .treasure-column-heading { grid-template-columns:110px minmax(0,1fr); }
.enemy-upgrades input[type=number] { appearance:textfield; -moz-appearance:textfield; }
.enemy-upgrades input::-webkit-inner-spin-button,.enemy-upgrades input::-webkit-outer-spin-button { -webkit-appearance:none; margin:0; }
.enemy-upgrades input:disabled { opacity:.5; cursor:not-allowed; }
.upgrade-level-value { gap:0; white-space:nowrap; font-variant-numeric:tabular-nums; }
.upgrade-level-editor { display:inline-flex; align-items:center; flex:0 0 auto; cursor:text; }
.upgrade-level-value .upgrade-level-editor input { width:2ch; min-width:1ch; max-width:none; padding:3px 0; font:inherit; font-variant-numeric:tabular-nums; }
.enemy-upgrade-summary { background:var(--heading-2); }
.enemy-upgrade-summary,.enemy-upgrade-note { margin:0; padding:9px 12px; border:1px solid var(--line); border-radius:6px; }
.enemy-upgrade-summary span { color:var(--factor); }
.enemy-upgrade-note { font-size:11px; }

.is-image-missing {
  position: relative;
}

.is-image-missing::after {
  content: attr(data-missing-label);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--value-text);
  pointer-events: none;
}

.is-image-missing > img {
  visibility: hidden;
}

.footer {
  padding: 24px;
  color: #e0e0e0;
  background: var(--header);
  border-top: 5px solid var(--heading);
  text-align: center;
  font-size: 14px;
  font-weight: 400;
}

/* DB generated details; retain the prototype's layout and colour scheme. */
.traits-content { display: block; line-height: 1.8; padding-block: calc((var(--row-height) - 1.8em) / 2); }
.traits-list { margin: 0; padding-left: 1.2em; line-height: 1.8; }
.traits-with-icons { padding-left:0; list-style:none; }
.traits-with-icons > li { display:flex; align-items:center; gap:6px; }
.traits-with-icons .trait-text { min-width:0; flex:1; }
.traits-with-icons .trait-immunities { display:flex; flex-wrap:wrap; align-items:center; gap:6px; }
.trait-immunity-icons { display:inline-flex; flex-wrap:wrap; align-items:center; gap:3px; }
.trait-immunity-icons:empty { display:none; }
.traits-with-icons .trait-icon { visibility:hidden; flex:none; margin:0; }
.traits-with-icons .trait-icon.is-trait-icon-loaded { visibility:visible; }
:root .traits-with-icons img.trait-icon { width:auto; height:auto; zoom:.55; }
:root .traits-with-icons img.trait-icon:not(.is-trait-icon-loaded) { width:40px; height:40px; }
.traits-with-icons > li:not(:has(.trait-icon))::before { content:""; width:22px; flex:none; }
.enemy-heading-actions button:disabled, .treasure-toggle-control:disabled { opacity: .55; cursor: default; }
.enemy-index { width: 100%; border-collapse: collapse; }
.enemy-index th, .enemy-index td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; }
.enemy-index a { color: inherit; }
.enemy-index [hidden] { display: none; }

/* Bitmap icons default to 30% of their intrinsic pixel dimensions, not 30% of
   their container or the former fitted size. Zoom also scales the layout box.
   Trait icons override this to 50% above.
   WB, background, castle, map and numeric-glyph images remain unchanged. */
:root img[src*="/Icon/" i] {
  width:auto;
  height:auto;
  min-width:0;
  min-height:0;
  max-width:none;
  max-height:none;
  zoom:.30;
}
.enemy-title-icon { width:max-content; height:auto; }
.enemy-heading:has(.enemy-title-icon) { height:auto; min-height:var(--row-height); padding-block:6px; }
/* Keep the icon aligned to the portrait/settings column and the name to the
   stats column. Intrinsic icon width must not move either title column. */
.enemy-detail-heading .enemy-title { min-width:0; }

/* Keep the inputs visible below full-size artwork. Only the image area scrolls
   when the original icon is wider than the existing settings column. */
:root .treasure-list { display:block; }
:root .treasure-list .treasure-item {
  height:auto;
  grid-template-columns:minmax(0,1fr) 92px;
}
:root .treasure-list .treasure-icon {
  display:block;
  grid-column:1 / -1;
  height:auto;
  min-height:var(--row-height);
  padding:6px;
  overflow-x:auto;
}
:root .treasure-list .treasure-icon img { margin-inline:auto; }
:root .treasure-list :is(.treasure-name,.treasure-input-wrap) {
  height:auto;
  min-height:var(--row-height);
}
:root .treasure-list .treasure-name { min-width:0; white-space:normal; padding-block:8px; }

/* One numeric editor across details, lists and settings. Keep each field's width
   and padding, so editing never changes the table or level-row geometry. */
:root body input:is([type="number"],[inputmode="decimal"],[inputmode="numeric"]) {
  background:transparent;
  border:0;
  border-bottom:1px solid transparent;
  border-radius:0;
  outline:0;
  text-align:right;
  color:#e0e0e0;
  font-variant-numeric:tabular-nums;
  cursor:pointer;
  appearance:textfield;
  -moz-appearance:textfield;
  box-shadow:none;
}
:root body input:is([type="number"],[inputmode="decimal"],[inputmode="numeric"]):focus {
  border-bottom-color:var(--active);
  outline:0;
  cursor:text;
  text-decoration:none;
}
:root body input:is([type="number"],[inputmode="decimal"],[inputmode="numeric"])::-webkit-inner-spin-button,
:root body input:is([type="number"],[inputmode="decimal"],[inputmode="numeric"])::-webkit-outer-spin-button {
  -webkit-appearance:none;
  margin:0;
}
:root body input:is([type="number"],[inputmode="decimal"],[inputmode="numeric"]):disabled { cursor:not-allowed; }
.portrait-magnify-reset { width:100%;margin-top:10px; }
.magnify-reset {
  width:100%;height:var(--enemy-panel-height,50px);box-sizing:border-box;
  border:1px solid var(--line);border-radius:4px;background:var(--heading-2);
  color:#e0e0e0;font:inherit;cursor:pointer;
}
.magnify-reset:hover { text-decoration:underline;text-underline-offset:.15em; }
.magnify-reset:focus-visible { outline:2px solid var(--active);outline-offset:2px; }
