@font-face {
  font-family: 'Regular';
  src: url('images/regular-webfont.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Regular';
  src: url('images/regular-bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* Reset & Base Setup - Dark theme inspired by reference design */
:root {
  --primary-font: 'Regular', 'Noto Serif TC', 'Noto Serif', Georgia, 'Times New Roman', serif;
  --mono-font: monospace;
  --serif-font: 'Regular', 'Noto Serif TC', 'Noto Serif', Georgia, 'Times New Roman', serif;
  --cjk-fallback: "Noto Sans CJK TC", "Microsoft JhengHei", sans-serif;
  /* Vietnamese-capable families come before the generic fallbacks */
  --vi-fallback: 'Noto Serif', 'Segoe UI', 'Times New Roman', serif;
  --main-font-family: var(--primary-font), var(--vi-fallback), var(--cjk-fallback), ui-sans-serif, system-ui, sans-serif;
  --board-font: var(--primary-font);

  /* Parchment: the light card surface, shared by Team Building cards, Team
     Preset rows, Rotation cards and every slot tag, so the whole app reads as
     one material. */
  --parchment: linear-gradient(to top right, #ddb39f 0%, #d5d3cf 20%, #d5d3cf 80%, #ddb39f 100%);
  /* Older name, kept so existing rules keep working. */
  --team-card-bg: var(--parchment);

  --bg-color: #000000;
  --bg-ink: #e5e7eb;
  --panel-bg: rgba(13, 15, 18, 0.9);
  --panel-soft: rgba(255, 255, 255, 0.03);
  --panel-strong: rgba(30, 29, 28, 0.96);
  --panel-border: rgba(98, 98, 98, 0.6);
  --panel-border-subtle: rgba(255, 255, 255, 0.06);

  --text-primary: #e5e7eb;
  --text-muted: #d1d5db;
  --text-inverse: #1a1a1a;
  --accent-gold: #F6C34A;
  --accent-gold-soft: #D98224;
  --accent-r: #D05126;
  --accent-e: #04FFEE;
  --portrait-bar-active: #F6C34A;
  --portrait-bar-inactive: rgba(255, 255, 255, 0.1);

  --tier-r15: #d1783d;
  --tier-r11-14: #6d9b6c;
  --tier-r10: #d7d7d7;
  --tier-r1-9: #4a77c9;
  --tier-unowned: #9a9a9a;
  --shadow-soft: none;

  /* Custom board styling defaults */
  --tier-box-bg: transparent;
  --tier-box-border-color: rgba(255, 255, 255, 0.04);
  --tier-box-border-width: 1px;
  --tier-box-radius: 0px;
  --tier-row-spacing: 14px;

  --board-header-bg: transparent;
  --board-header-border-color: rgba(255, 255, 255, 0.1);
  --board-header-border-width: 1px;
  --board-header-spacing: 20px;

  /* Character Card scaling */
  --char-card-scale: 1;
  --char-card-width: 60px;
  --char-avatar-size: 60px;

  --char-info-bg: rgba(18, 18, 18, 0.22);
  --char-info-border-color: transparent;
  --char-info-border-width: 0px;
  --char-info-radius: 0px;

  /* Unowned dimming settings */
  --unowned-char-opacity: 0.35;

  /* Chess Pieces settings */
  --chess-piece-size: 20px;
  --chess-piece-opacity: 1;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--main-font-family);
}

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--main-font-family);
  min-height: 100vh;
  padding-bottom: 60px;
  position: relative;
  color-scheme: dark;
}

/* Native dropdown popups (select option lists) follow the app theme */
select,
select option,
select optgroup,
input,
textarea {
  color-scheme: dark;
}

/* Remove number input spin buttons across the app */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

select option {
  background-color: #1C1C1C;
  color: #ECE5D9;
  padding: 6px 10px;
}

select option:checked,
select option:hover {
  background-color: #D05126;
  color: #FFFFFF;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: url("images/background.png") center / cover no-repeat;
  pointer-events: none;
  opacity: 1;
  z-index: -1;
  will-change: transform;
}

/* Legacy Floating Toolbar (retained for sim-head) */
.top-controls:not(.global-navbar) {
  position: sticky;
  top: 0;
  z-index: 100;
  max-width: 1440px;
  margin: 18px auto 0;
  width: calc(100% - 24px);
  background: var(--panel-bg);
  border: 1px solid #D05126;
  border-radius: 12px 0 12px 0;
  display: flex;
  flex-direction: column;
  padding: 12px 18px;
  gap: 6px;
  box-shadow: none;
}

.header-primary-bar {
  width: 100%;
  display: grid;
  /* Equal side columns keep the middle column exactly on the toolbar's centre
     line, so the search row and the filter row below it share one axis. */
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.header-brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-self: start;
}

.btn-tools-toggle {
  display: none !important;
  border-color: #EBE3D7;
}

/* Desktop shows the header switcher; the drawer switcher only appears
   once the Menu button takes over (<= 1260px). */
.lang-switcher-header {
  display: inline-flex;
}

.tools-lang-group .lang-switcher {
  display: none;
}

.header-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-self: center;
  margin: 0 auto;
}

.header-search-wrap {
  display: flex;
}

.header-stats-row {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-self: end;
}

/* JSON and Reset sit beside the language switcher, so the icon-only Reset
   button matches the row height instead of the 30px default. */
.header-stats-row .btn-icon-only {
  width: 31px;
  height: 31px;
  min-width: 31px;
}

/* ================= SLIDING SEGMENTED CONTROLS ================= */

/* The language highlight glides to the active option. It is absolutely
   positioned behind the buttons and sized from the measured offset in
   syncSlidingThumbs(), so translated labels of different widths stay aligned. */
.lang-thumb {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  background: #2a2825;
  pointer-events: none;
  z-index: 0;
  transition:
    transform 0.28s cubic-bezier(0.16, 0.84, 0.32, 1),
    width 0.28s cubic-bezier(0.16, 0.84, 0.32, 1);
}

@media (prefers-reduced-motion: reduce) {
  .lang-thumb {
    transition: none;
  }
}

/* ================= LANGUAGE SWITCHER ================= */
.lang-switcher {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  border: 1px solid #B5B5B3;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 0;
  overflow: hidden;
  height: 31px;
  box-sizing: border-box;
}

.lang-btn {
  position: relative;
  z-index: 1;
  background: transparent;
  border: none;
  border-right: 1px solid #B5B5B3;
  color: #B5B5B3;
  font-family: var(--primary-font);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 0 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
  line-height: 1;
  box-sizing: border-box;
}

.lang-btn:last-child {
  border-right: none;
}

.lang-btn:hover {
  background: rgba(181, 181, 179, 0.12);
  color: #FFFFFF;
}

/* The sliding thumb supplies the fill, so the button only sets its ink. */
.lang-btn.active {
  background: transparent;
  color: #FFFFFF;
}

/* Hovering the active button must not paint over the thumb. */
.lang-btn.active:hover {
  background: transparent;
}

.lang-btn:focus {
  outline: none;
}

.lang-btn:focus-visible {
  outline: 2px solid #ED7D31;
  outline-offset: -2px;
}

.stat-badge-wrap:hover .stat-badge {
  border-color: #D05126;
}

.stat-badge-wrap {
  position: relative;
  display: inline-flex;
}

.stat-badge-tooltip {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 100%;
  background-color: rgba(22, 19, 15, 0.5);
  background-image: url("images/tooltip_background.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  color: #FFFFFF;
  border: 1px solid #FFFFFF;
  padding: 8px 12px;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.55;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  z-index: 250;
  border-radius: 0;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
}

/* Rows mirror the character tooltip typography */
.stat-badge-tooltip .stat-tip-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.stat-badge-tooltip .stat-tip-label {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #FFFFFF;
}

.stat-badge-tooltip .stat-tip-value {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: #FFFFFF;
}

.stat-badge-wrap:hover .stat-badge-tooltip {
  opacity: 1;
  visibility: visible;
}

.tools-filters-group {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-self: center;
  margin: 0 auto;
}

.header-secondary-tools {
  position: relative;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding-top: 6px;
  border-top: 1px solid rgba(17, 15, 12, 0.06);
}

/* Grouping wrapper: it only matters in the narrow drawer, so on a desktop the
   two groups sit directly in the toolbar grid and keep their old places. */
.tools-buttons-row {
  display: contents;
}

.tools-filters-group {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-self: center;
  margin: 0 auto;
}

.tools-config-group {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
}

.tools-data-group {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
}

/* Language switcher sits at the far right without disturbing the
   original left / center / right alignment of the other three groups. */
.tools-lang-group {
  position: absolute;
  right: 0;
  top: 8px;
  justify-self: auto;
}

.secondary-tools-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-btn-group {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid #B5B5B3;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 0;
  overflow: hidden;
  height: 31px;
  box-sizing: border-box;
}

.filter-btn {
  background: transparent;
  border: none;
  border-right: 1px solid #B5B5B3;
  color: #B5B5B3;
  font-family: var(--primary-font);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  line-height: 1;
  box-sizing: border-box;
}

.filter-btn:last-child {
  border-right: none;
}

.filter-btn:hover {
  background: rgba(181, 181, 179, 0.12);
  color: #ffffff;
}

.filter-btn:focus {
  outline: none;
}

.filter-btn:focus-visible {
  outline: 2px solid #ED7D31;
  outline-offset: -2px;
}

.filter-btn.active {
  background: rgba(208, 81, 38, 0.22);
  color: #FFFFFF;
}

.filter-btn.active:focus-visible {
  outline-color: #ED7D31;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-brand-icon-box {
  width: 44px;
  height: 44px;
  border: 1px solid #D05126;
  background: rgba(0, 0, 0, 0.03);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-sizing: border-box;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s ease, box-shadow 0.2s ease;
}

.app-brand-icon-box:hover {
  transform: scale(1.06);
  border-color: rgba(215, 177, 85, 0.6);
  box-shadow: 0 4px 12px rgba(215, 177, 85, 0.15);
}

.app-brand-icon {
  width: 40px;
  height: 40px;
  object-fit: contain;
  display: block;
  transition: transform 0.2s ease;
}

.app-logo-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  overflow: hidden;
}

.app-logo-img {
  height: 44px;
  width: auto;
  object-fit: contain;
  display: block;
}

/* Web Icon Lightbox Preview */
.web-icon-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.75);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.web-icon-lightbox.active {
  opacity: 1;
  visibility: visible;
}

.web-icon-lightbox-content {
  background: #161616;
  border: 1px solid rgba(215, 177, 85, 0.3);
  padding: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(215, 177, 85, 0.15);
  transform: scale(0.65);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.web-icon-lightbox.active .web-icon-lightbox-content {
  transform: scale(1);
}

.web-icon-lightbox-img {
  width: 240px;
  height: 240px;
  object-fit: contain;
  display: block;
}

.stat-badge {
  background: rgba(17, 15, 12, 0.06);
  color: #EBE3D7;
  font-family: var(--primary-font);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 0 10px;
  height: 31px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1;
  white-space: nowrap;
  border-radius: 0;
  border: 1px solid #EBE3D7;
  text-transform: uppercase;
  box-sizing: border-box;
}

.roster-stat-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
  align-self: center;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-input {
  background: rgba(17, 15, 12, 0.04);
  border: 1px solid #D05126;
  color: #ECE5D9;
  padding: 8px 12px;
  height: 31px;
  border-radius: 4px;
  font-size: 0.74rem;
  outline: none;
  transition: all 0.2s ease;
  width: 170px;
  font-family: var(--primary-font);
  box-sizing: border-box;
}

.search-input::placeholder {
  color: rgba(236, 229, 217, 0.6);
}

.search-input:focus {
  border-color: #D05126;
  box-shadow: 0 0 0 4px rgba(208, 81, 38, 0.18);
}

.header-actions-row #btn-manage-all,
.header-actions-row #btn-chubes,
.header-actions-row #btn-json {
  border: 1px solid #D05126;
  color: #ECE5D9;
  border-radius: 4px;
}

.header-actions-row #btn-manage-all:hover,
.header-actions-row #btn-chubes:hover,
.header-actions-row #btn-json:hover {
  background: rgba(208, 81, 38, 0.15);
  border-color: #D05126;
  color: #FFFFFF;
}

.header-actions-row #btn-export-image {
  border: 1px solid #D05126;
  color: #ECE5D9;
  border-radius: 4px;
}

.header-actions-row #btn-export-image:hover {
  background: #D05126;
  color: #FFFFFF;
}

/* Buttons */
.btn {
  height: 31px;
  padding: 0 16px;
  border-radius: 0;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid #B5B5B3;
  color: #B5B5B3;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.18s ease;
  font-family: var(--primary-font);
  box-sizing: border-box;
}

.btn:active {
  transform: scale(0.98);
}

.btn-reset-icon {
  width: 14px;
  height: 14px;
  object-fit: contain;
  flex-shrink: 0;
  filter: brightness(0) saturate(100%) invert(78%) sepia(3%) saturate(44%) hue-rotate(314deg) brightness(92%) contrast(88%);
}

.btn-tool-icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

/* "Reset Defaults" icon sits after the label */
.btn-reset-default-icon {
  width: 14px;
  height: 14px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

/* "Preview" header icon */
.preview-header-icon {
  width: 13px;
  height: 13px;
  object-fit: contain;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
  margin-right: 5px;
}

.customize-preview-header {
  display: inline-flex;
  align-items: center;
}

/* Modal close button rendered as an image */
.modal-close-img {
  width: 15px;
  height: 15px;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
}

.modal-close:hover {
  opacity: 1;
}

.modal-close:hover .modal-close-img {
  filter: brightness(1.6);
}

/* Every search field carries the magnifier icon — the toolbar's own search is the
   reference look. The Suitcase rename field draws a different glyph and the level
   number input (`input.search-input`, dynamically created) is not a search box, so
   both are excluded. The `:not(#…)` keeps the left gutter from being wiped by the
   narrower-viewport rules that set a shorthand `padding` on some of these fields. */
.search-input:not(#input-board-title):not([type="number"]) {
  background-image: url("images/random_icon/search_icon.png");
  background-repeat: no-repeat;
  background-position: 9px center;
  background-size: 14px 14px;
  padding-left: 30px;
}

/* Board Title ("Rename Suitcase") field carries its own icon */
#input-board-title {
  background-image: url("images/random_icon/rename_suitcase.png");
  background-repeat: no-repeat;
  background-position: 9px center;
  background-size: 14px 14px;
  padding-left: 30px;
}

.btn-primary {
  background: #111111;
  color: #B5B5B3;
  border: 1px solid #B5B5B3;
  box-shadow: none;
}

.btn-primary:hover {
  background: #1d1d1d;
  color: #ffffff;
  box-shadow: none;
}

.btn-secondary {
  background: rgba(0, 0, 0, 0.03);
  color: #B5B5B3;
  border: 1px solid #B5B5B3;
}

.btn-secondary:hover {
  background: rgba(181, 181, 179, 0.12);
  border-color: #B5B5B3;
  color: #ffffff;
}

.btn-secondary.active {
  background: #2a2825;
  color: #f7f7f7;
  border-color: #B5B5B3;
}

.btn-danger {
  background: rgba(0, 0, 0, 0.03);
  color: #B5B5B3;
  border: 1px solid #B5B5B3;
}

.btn-danger:hover {
  background: rgba(200, 50, 50, 0.15);
  color: #ff6b6b;
  border-color: #ff6b6b;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.62rem;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

/* Showcase Main Area */
.showcase-wrapper {
  max-width: 1440px;
  margin: 18px auto 0;
  padding: 0 24px;
  box-sizing: border-box;
  overflow-x: clip;
}

.showcase-board {
  position: relative;
  background: #111111;
  padding: 22px 22px 18px;
  border-radius: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  font-family: var(--board-font, var(--mono-font));
}

.showcase-board::before,
.showcase-board::after {
  content: "";
  position: absolute;
  width: 32px;
  height: 32px;
  border-color: rgba(255, 255, 255, 0.08);
  border-style: solid;
  pointer-events: none;
}

.showcase-board::before {
  top: 12px;
  left: 12px;
  border-width: 1px 0 0 1px;
}

.showcase-board::after {
  right: 12px;
  bottom: 12px;
  border-width: 0 1px 1px 0;
}

.board-header {
  margin-bottom: var(--board-header-spacing, 20px);
  padding: 8px 8px 14px;
  border-bottom: var(--board-header-border-width, 1px) solid var(--board-header-border-color, rgba(255, 255, 255, 0.1));
  background: var(--board-header-bg, transparent);
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.board-title {
  font-family: var(--board-font, var(--mono-font));
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  color: rgba(244, 239, 233, 0.84);
  text-transform: var(--board-title-case, uppercase);
}

/* Tier Row */
.tier-row {
  display: grid;
  grid-template-columns: var(--tier-label-width, 110px) 1fr;
  align-items: center;
  gap: calc(14px * var(--char-card-scale, 1));
  margin-bottom: var(--tier-row-spacing, 14px);
  padding: calc(10px * var(--char-card-scale, 1)) calc(12px * var(--char-card-scale, 1));
  min-height: calc(92px * var(--char-card-scale, 1));
  border: var(--tier-box-border-width, 1px) solid var(--tier-box-border-color, rgba(255, 255, 255, 0.04));
  border-radius: var(--tier-box-radius, 0px);
  background: var(--tier-box-bg, transparent);
  box-sizing: border-box;
}

.tier-row:last-child {
  margin-bottom: 0;
}

.tier-label {
  font-family: var(--board-font, var(--mono-font));
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: var(--tier-label-case, uppercase);
  padding-top: 2px;
  opacity: 0.92;
  cursor: default;
}

.tier-r15 { color: var(--tier-r15); }
.tier-r11-14 { color: var(--tier-r11-14); }
.tier-r10 { color: var(--tier-r10); }
.tier-r1-9 { color: var(--tier-r1-9); }
.tier-unowned { color: var(--tier-unowned); }

.tier-content {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: calc(12px * var(--char-card-scale, 1)) calc(8px * var(--char-card-scale, 1));
  min-height: calc(72px * var(--char-card-scale, 1));
}

/* Character Card */
.char-card {
  position: relative;
  width: var(--char-card-width, 60px);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.18s ease, border-color 0.18s ease;
  margin-bottom: 2px;
  padding: 0;
  border-radius: 0;
  border: 1px solid transparent;
  background: transparent;
  box-sizing: border-box;
}

.char-card:hover {
  transform: translateY(-2px);
  border-color: rgba(17, 17, 17, 0.18);
  z-index: 120;
}

/* Character Card Custom Tooltip — same surface as the mainboard
   (`.showcase-board`): #111 body, hairline white borders, cream type. */
.char-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  /* `--tooltip-shift` is set on hover so a card at the board's edge does not
     have its tooltip clipped (see clampBoardTooltip in app.js). */
  transform: translateX(calc(-50% + var(--tooltip-shift, 0px)));
  min-width: 190px;
  max-width: 262px;
  background-color: rgba(17, 17, 17, 0.97);
  background-image: none;
  color: rgba(244, 239, 233, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
  padding: 0;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 12px;
  line-height: 1.45;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  z-index: 250;
  text-align: left;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* Name header */
.char-tooltip .ct-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px 8px;
  background: var(--board-header-bg, rgba(255, 255, 255, 0.04));
  border-bottom: var(--board-header-border-width, 1px) solid var(--board-header-border-color, rgba(255, 255, 255, 0.1));
  border-radius: 0;
}

.char-tooltip .ct-name {
  font-family: var(--primary-font, Georgia, serif);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--char-name-color, rgba(244, 239, 233, 0.84));
}

/* Detail rows — typography mirrors Character Setting */
.char-tooltip .ct-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 12px 10px;
}

.char-tooltip .ct-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.char-tooltip .ct-label {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #9a9a9a;
  white-space: nowrap;
}

.char-tooltip .ct-value {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono-font), 'gg sans', 'Noto Sans', monospace;
  font-size: 12px;
  font-weight: 700;
  color: rgba(244, 239, 233, 0.92);
  white-space: nowrap;
}

.char-tooltip .ct-euphoria {
  color: var(--accent-e, #04FFEE);
}

/* Unowned cards have no build to report, so the tooltip body is a single
   muted label under the name instead of Insight/Level/Resonance rows. */
.char-tooltip .ct-unowned {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(244, 239, 233, 0.55);
}

.char-tooltip .ct-patterns {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  width: 100%;
  margin-top: 3px;
  padding-top: 7px;
  border-top: 1px solid var(--board-header-border-color, rgba(255, 255, 255, 0.1));
  box-sizing: border-box;
}

.char-tooltip .ct-pattern-icon {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  display: block;
  opacity: 0.7;
}

.char-tooltip .ct-pattern-icon.is-main {
  opacity: 1;
  filter: drop-shadow(0 0 3px rgba(237, 125, 49, 0.5));
}

.char-card:hover .char-tooltip {
  opacity: 1;
  visibility: visible;
}

/* Top Information above the Character */
.char-top-info {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  min-height: calc(14px * var(--char-card-scale, 1));
  margin-bottom: 1px;
  padding: 0;
  gap: 1px;
  width: var(--char-card-width, 60px);
  align-self: center;
  box-sizing: border-box;
}

.char-unowned-name {
  font-size: calc(0.56rem * var(--char-card-scale, 1));
  font-weight: 700;
  color: var(--char-name-color, rgba(244, 239, 233, 0.8));
  font-family: var(--board-font, var(--mono-font));
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  text-align: center;
}

.badge-resonance {
  font-size: calc(0.64rem * var(--char-card-scale, 1));
  font-weight: 700;
  color: #ffffff;  line-height: 1;
  letter-spacing: -0.02em;
  font-family: var(--board-font, var(--mono-font));
  opacity: 0.95;
}

.badge-insight-level {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  margin-left: auto;
  line-height: 1;
}

.badge-insight-img {
  width: calc(13px * var(--char-card-scale, 1));
  height: calc(13px * var(--char-card-scale, 1));
  object-fit: contain;
  display: block;
}

.badge-level-text {
  font-size: calc(0.62rem * var(--char-card-scale, 1));
  font-weight: 700;
  color: #ffffff;
  font-family: var(--board-font, var(--mono-font));
  line-height: 1;
  letter-spacing: -0.02em;
  opacity: 0.95;
}

.badge-euphoria {
  font-size: calc(0.52rem * var(--char-card-scale, 1));
  font-weight: 700;
  color: var(--accent-e);
  line-height: 1;
  letter-spacing: 0.05em;
  margin-left: auto;
  font-family: var(--board-font, var(--mono-font));
  text-transform: uppercase;
  white-space: nowrap;
}

.char-avatar-box {
  position: relative;
  width: var(--char-avatar-size, 60px);
  height: var(--char-avatar-size, 60px);
  border-radius: 0;
  background: transparent;
  overflow: hidden;
  box-shadow: none;
  border: none;
  margin-bottom: 0;
  box-sizing: border-box;
}

.char-avatar-box img.char-avatar-img,
.char-avatar-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  box-sizing: border-box;
  filter: saturate(0.82) contrast(1.05) brightness(0.9);
}

/* Decorative pin marking a favourited character (top-right of the portrait).
   Purely visual — the toggle lives in the character setting modal. */
.char-favourite-badge {
  position: absolute;
  top: 0;
  right: 0;
  width: 12px;
  height: 12px;
  z-index: 4;
  pointer-events: none;
  object-fit: contain;
  border: none;
  background: none;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.85));
}

/* Dark corner wedge sitting behind the pin. Bright portrait art would otherwise
   wash the pale pin out. Inset by the portrait's 1px frame so the frame keeps
   painting on top of it, and stacked below the pin itself. */
.char-favourite-corner {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 0;
  height: 0;
  border-top: calc(var(--char-avatar-size, 60px) * 16 / 60) solid rgba(0, 0, 0, 0.55);
  border-left: calc(var(--char-avatar-size, 60px) * 16 / 60) solid transparent;
  z-index: 3;
  pointer-events: none;
}

/* Afflatus Icon in Character Avatar Box */
.char-afflatus-icon {
  position: absolute;
  top: 0;
  left: 0;
  width: 27.08%;
  aspect-ratio: 74 / 118;
  z-index: 3;
  pointer-events: none;
  line-height: 0;
  display: flex;
}

.char-afflatus-icon img {
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
}

.char-info-overlay {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: calc(2px * var(--char-card-scale, 1)) calc(5px * var(--char-card-scale, 1)) calc(2px * var(--char-card-scale, 1)) calc(3px * var(--char-card-scale, 1));
  border-radius: var(--char-info-radius, 0px);
  background: var(--char-info-bg, rgba(18, 18, 18, 0.22));
  border: var(--char-info-border-width, 0px) solid var(--char-info-border-color, transparent);
  box-shadow: none;
  max-width: calc(100% - 4px);
  white-space: nowrap;
  box-sizing: border-box;
}

.char-info-insight {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.char-info-level {
  font-size: calc(0.58rem * var(--char-card-scale, 1));
  font-weight: 700;
  color: #ffffff;
  font-family: var(--board-font, var(--mono-font));
  line-height: 1;
  letter-spacing: -0.02em;
  opacity: 0.96;
}

.char-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  filter: saturate(0.82) contrast(1.05) brightness(0.9);
}

.char-card.is-unowned .char-avatar-img {
  opacity: var(--unowned-char-opacity, 0.35);
}

/* Rarity Indicator Line */
/* Rarity line — the in-game asset, sitting between avatar and portrait bar */
.char-rarity-line {
  display: block;
  width: calc(100% + 4px);
  margin: 0 -2px;
  height: auto;
  object-fit: fill;
  image-rendering: auto;
  box-sizing: border-box;
}

/* Portrait Bar Below the Character Avatar */
.char-portrait-bar-below {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  height: calc(3px * var(--char-card-scale, 1));
  gap: 1px;
  margin-top: 2px;
  width: calc(100% + 2px);
  margin-left: -1px;
  margin-right: -1px;
  box-sizing: border-box;
}

/* Main pattern icon beside the resonance badge */
.char-main-pattern-icon {
  width: calc(10px * var(--char-card-scale, 1));
  height: calc(10px * var(--char-card-scale, 1));
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}

/* Character name, rendered under the portrait bar */
.char-name-below {
  font-size: calc(0.56rem * var(--char-card-scale, 1));
  font-weight: 700;
  font-family: var(--board-font, var(--mono-font));
  color: var(--char-name-color, rgba(244, 239, 233, 0.8));
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  text-align: center;
  margin-top: 3px;
}

/* Some characters carry a stylised title instead of an Arcanist name.
   Placed after the base rules so it also wins over text-transform. */
.char-name-below.is-italic-name,
.char-unowned-name.is-italic-name,
.ct-name.is-italic-name,
.roster-char-name.is-italic-name,
.modal-char-title.is-italic-name {
  font-style: italic;
  text-transform: none;
  letter-spacing: 0.02em;
}

/* Helper note under the Character Info Box live preview */
.options-preview-note {
  margin: 2px 0 6px;
  text-align: center;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: #8A8A8A;
}

.portrait-dash {
  width: 100%;
  height: 100%;
  border-radius: 0;
  background-color: rgba(255, 255, 255, 0.08);
}

.portrait-dash.active {
  background: #FBAE31;
  box-shadow: none;
}

.char-bottom-euphoria {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 2px;
  width: var(--char-card-width, 60px);
  align-self: center;
}

.badge-euphoria-bottom {
  font-size: calc(0.52rem * var(--char-card-scale, 1));
  font-weight: 700;
  color: var(--accent-e);
  line-height: 1;
  letter-spacing: 0.05em;
  font-family: var(--mono-font);
  text-transform: uppercase;
  text-align: center;
}

/* Modal Popup */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.86);
  backdrop-filter: blur(3px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 20px;
}

/* The Planner's own windows — Activity settings, Wilderness, the two Resets and the
   Event tab's quantity editor — sit on a surface that is already dimmed, so the page
   behind them is not blurred as well: a plain scrim, and the wallpaper stays legible. */
#planner-modal.modal-backdrop,
#confirm-modal.modal-backdrop {
  backdrop-filter: none;
}

.modal-card {
  background: var(--panel-bg);
  border: 1px solid #D05126;
  border-radius: 12px 0 12px 0;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9);
  overflow: hidden;
  animation: modalIn 0.2s ease-out;
}

.modal-card .modal-body {
  flex: 1;
  overflow-y: auto;
}

.modal-card-large {
  max-width: 720px;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 16px 22px 14px;
  background: rgba(134, 93, 51, 0.95);
  border-bottom: 1px solid rgba(231, 229, 238, 0.925);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 20px;
  font-weight: normal;
  letter-spacing: 0;
  color: #E7D9CB;
}

.modal-char-preview {
  display: flex;
  align-items: center;
  gap: 14px;
}

.modal-char-preview img:not(.btn-favourite-img) {
  width: 52px;
  height: 52px;
  border-radius: 0;
  background: #0d0c0a;
  object-fit: cover;
  border: 1px solid #D05126;
}

.modal-char-title {
  font-family: var(--primary-font);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #FFFFFF;
}

.modal-char-sub {
  font-size: 0.72rem;
  color: #B5B5B3;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-family: var(--primary-font);
  font-weight: 700;
}

/* Favourite (pin) toggle sitting beside the character name.
   The preview block styles every descendant <img> at 52px, so the pin size
   needs to win on specificity. */
.modal-char-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-favourite {
  background: none;
  border: none;
  outline: none;
  padding: 0;
  margin: 0;
  /* Nudged up so the pin optically aligns with the name's cap height */
  position: relative;
  top: -4px;
  cursor: pointer;
  line-height: 0;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  -webkit-appearance: none;
  appearance: none;
  transition: transform 0.15s ease;
}

.btn-favourite .btn-favourite-img {
  width: 16px;
  height: 16px;
  object-fit: contain;
  display: block;
  border: 0 none;
  outline: none;
  background: none;
  box-shadow: none;
  opacity: 0.55;
  transition: opacity 0.15s ease, filter 0.15s ease;
}

.btn-favourite:hover .btn-favourite-img {
  opacity: 1;
}

.btn-favourite:hover {
  transform: scale(1.12);
}

.btn-favourite.is-favourite .btn-favourite-img {
  opacity: 1;
  filter: drop-shadow(0 0 4px rgba(246, 195, 74, 0.85));
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.6rem;
  color: #B5B5B3;
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s;
}
.modal-close:hover {
  color: #ffffff;
}

.modal-body {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  color: #FFFFFF;
  background: var(--panel-bg);
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#listing-modal .modal-body {
  gap: 8px;
}

.setting-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.setting-label-row > div,
.setting-label-row > .btn,
.setting-label-row > button {
  flex-shrink: 0;
}

.setting-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #B5B5B3;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-family: var(--primary-font);
}

/* "sh" — shared small-label style (gg sans, #BFBFBF, 11px, bold, .5px, uppercase) */
.setting-label-sh {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 11px;
  font-weight: bold;
  color: #BFBFBF;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ============================================================
   STYLING MODAL — unified typography scale
   Tier 1 (title) : #BFBFBF , 12px , bold , uppercase
   Tier 2 (body)  : #E5E7EB , 13px , normal
   Inline font-size attributes are overridden with !important.
   Preview-stage text keeps its own smaller scale.
   ============================================================ */

/* Tier 1 — group titles */
#customize-modal .custom-category-title,
#customize-modal .custom-style-section-title,
#customize-modal .setting-label,
#customize-modal .setting-label-sh {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif !important;
  font-size: 12px !important;
  font-weight: bold !important;
  letter-spacing: 0.5px !important;
  text-transform: uppercase;
}

/* Plain Tier-1 labels keep the neutral grey */
#customize-modal .setting-label,
#customize-modal .setting-label-sh {
  color: #BFBFBF !important;
}

/* "el" titles carry their own colours */
#customize-modal .custom-style-section-title {
  color: #ECE5D9 !important;
  font-size: 12px !important;
}

#customize-modal .custom-category-title {
  color: #EBE3D7 !important;
  font-size: 1.1rem !important;
}

/* Tier 2 — all body / label / value text.
   Preview boxes simulate the real board, so they are excluded everywhere. */
#customize-modal :not(:is(.customize-preview-box, .customize-preview-box *)):is(
    .custom-style-row,
    .custom-style-row span,
    .custom-style-grid label span,
    .check-text
  ),
#customize-modal .custom-style-section > :not(.customize-preview-box) > span[style]:not(.customize-preview-box *),
#customize-modal .custom-style-section > span[style]:not(.customize-preview-box *),
#customize-modal .custom-style-section label[style]:not(.customize-preview-box *),
#customize-modal .custom-style-section div[style] > span[style]:not(.customize-preview-box *),
#customize-modal .custom-style-section div[style] > div[style] > span[style]:not(.customize-preview-box *),
#customize-modal .custom-style-section div[style] > span:only-child:not(.customize-preview-box *),
#customize-modal .custom-style-section div[style*="font-size"] > span:not(.customize-preview-box *),
#customize-modal .setting-group > span[style]:not(.customize-preview-box *),
#customize-modal #board-bg-image-status,
#customize-modal span[id^="display-"] {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif !important;
  font-size: 13px !important;
  color: #E5E7EB !important;
  letter-spacing: 0.2px;
}

/* Preview-box internals keep their own colours; sizes are driven by JS inline styles */
#customize-modal .customize-preview-box .customize-preview-header {
  color: #E7D9CB !important;
  letter-spacing: inherit;
}

/* Numeric display values stay bold for scanability */
#customize-modal span[id^="display-"] {
  font-weight: 700 !important;
}

/* Clear buttons sit between the two tiers */
#customize-modal .custom-color-clear-btn {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif !important;
  font-size: 11px !important;
  letter-spacing: 0.4px;
  color: #BFBFBF !important;
}

.btn-help-icon {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-muted);
  font-family: var(--mono-font);
  font-size: 0.62rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  transition: all 0.15s ease;
}

.btn-help-icon:hover {
  background: #2a2825;
  color: #ffffff;
  border-color: #2a2825;
}

.pattern-help-box {
  background: #3a3632;
  border: 1px solid #4a4541;
  padding: 8px 10px;
  font-family: var(--mono-font);
  font-size: 0.65rem;
  color: #f6f2ed;
  line-height: 1.45;
  margin-top: 4px;
}

.pattern-help-box p {
  margin: 1px 0;
}

.setting-val-display {
  font-size: 0.86rem;
  font-weight: 800;
  color: #f6f2ed;
  font-family: var(--mono-font);
}

.resonance-box-legend {
  display: grid;
  grid-template-columns: 0.85fr 1.15fr 1.15fr 1.45fr 1.45fr;
  gap: 5px;
  margin-top: 4px;
}

/* ================= PSYCHUBE (CHUBE) CARDS ================= */
/* Chube art is 180x214 (taller than wide), so the icon box follows that
   aspect ratio instead of being forced into a square. */
.chube-card .char-avatar-box {
  position: relative;
  width: var(--char-card-width, 60px);
  height: auto;
  aspect-ratio: 180 / 214;
}

.chube-card .chube-avatar-img {
  position: relative;
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  filter: none;
}

.chube-card .chube-amp-badge {
  position: absolute;
  left: 0;
  top: calc(1px * var(--char-card-scale, 1));
  z-index: 3;
}

.chube-card .chube-level-badge {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(5px * var(--char-card-scale, 1));
  z-index: 3;
  text-align: center;
}

.chube-card .chube-level-badge,
.chube-card .chube-amp-badge {
  font-family: var(--board-font, var(--mono-font));
  font-size: calc(0.64rem * var(--char-card-scale, 1));
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}

.chube-card .chube-level-badge {
  color: var(--chube-lv-color, #ffffff);
  opacity: 0.95;
}

.chube-card .chube-amp-badge {
  color: var(--chube-amp-color, #ffffff);
  opacity: 0.95;
}

/* Amplification 5 is highlighted */
.chube-card .chube-amp-badge.is-max {
  color: var(--chube-amp-max-color, #DF7526);
}

.chube-card .chube-count-badge {
  color: var(--chube-count-color, #04FFEE);
}

/* Level overlay inside the icon is not used for chubes */
.chube-card .char-info-overlay {
  z-index: 2;
}

.chube-manage-meta {
  font-family: var(--mono-font);
  font-size: 0.5rem;
  color: var(--text-muted);
  line-height: 1;
}

.chube-tooltip .ct-name {
  font-size: 15px;
}

/* ================= SHARED PATTERN TOOLTIP ================= */
.pattern-tooltip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 3000;
  padding: 4px 10px;
  background: rgba(22, 19, 15, 0.5);
  color: #FFFFFF;
  border: 1px solid #FFFFFF;
  border-radius: 0;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.35;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(2px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
}

.pattern-tooltip.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Tier row count tooltip: same surface as the pattern tooltip, but it follows
   the cursor instead of being anchored to an element. */
.tier-count-tooltip {
  z-index: 3001;
}

/* ================= SHAPE PATTERN PICKER (Character Setting) ================= */
.shape-pattern-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-top: 4px;
}

.shape-pattern-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 3px;
  background: #111111;
  border: 1px solid #676767;
  border-radius: 0;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.shape-pattern-btn:hover {
  border-color: #B5B5B3;
  background: #1a1a1a;
}

/* Owned patterns show the family colour, same as the main one */
.shape-pattern-btn.is-owned {
  border-color: var(--pattern-color, #676767);
}

/* The main pattern is additionally filled and glows */
.shape-pattern-btn.is-main {
  border-color: var(--pattern-color, #D05126);
  background: color-mix(in srgb, var(--pattern-color, #D05126) 18%, #111111);
  box-shadow: inset 0 0 0 1px var(--pattern-color, #D05126);
}

.shape-pattern-btn img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.shape-pattern-btn.is-main img {
  filter: brightness(1.15) drop-shadow(0 0 3px rgba(255, 255, 255, 0.35));
}

/* "Main pattern" marker, pinned to the top-right corner */
.shape-pattern-main-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 2;
}

.shape-pattern-main-badge img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8));
}

/* Fallback swatch when no icon exists for the pattern */
.shape-pattern-fallback {
  width: 20px;
  height: 20px;
  background: var(--pattern-color, #4F4F4F);
  display: block;
}

.pattern-help-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 5px;
  vertical-align: middle;
}

@media (max-width: 640px) {
  .shape-pattern-grid {
    gap: 4px;
  }

  .shape-pattern-btn {
    height: 34px;
  }
}

.btn-pill.active.none {
  background: #4f4f4f;
  border-color: #4f4f4f;
  color: #ffffff;
}

.btn-pill.active.offensive {
  background: #FBAE31;
  border-color: #FBAE31;
  color: #111111;
}

.btn-pill.active.defensive {
  background: #2d8a5a;
  border-color: #2d8a5a;
  color: #ffffff;
}

.btn-pill.active.hp {
  background: #d4ad2b;
  border-color: #d4ad2b;
  color: #111111;
}

.btn-pill.active.equibalance {
  background: #3b6dc7;
  border-color: #3b6dc7;
  color: #ffffff;
}

/* Toggle Group for Owned / Unowned */
.toggle-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #3a3632;
  border: 1px solid #4a4541;
  border-radius: 0;
  padding: 3px;
  gap: 4px;
}

.btn-toggle {
  background: transparent;
  border: none;
  color: #9a8a7a;
  padding: 9px 0;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 0;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--mono-font);
}

.btn-toggle.active {
  background: #D7B155;
  color: #111111;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
}

#btn-status-unowned.active {
  background: rgba(79, 79, 79, 0.96);
  color: var(--text-inverse);
}

#btn-status-owned.active {
  background: #D7B155;
  color: #111111;
}

/* Quick Pick Buttons */
.skin-quick-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-pill-skin {
  background: #3a3632;
  border: 1px solid #4a4541;
  padding: 3px;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.btn-pill-skin:hover {
  background: #4a4541;
  border-color: #5a5551;
}

.btn-pill-skin.active {
  background: #2a2825;
  border-color: #D7B155;
  box-shadow: 0 0 0 1px #D7B155;
}

.skin-btn-img {
  width: 36px;
  height: 36px;
  object-fit: cover;
  pointer-events: none;
  filter: brightness(0.9);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.btn-pill-skin.active .skin-btn-img {
  filter: brightness(1.08);
  transform: scale(1.05);
}

.insight-quick-picks {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.btn-pill-i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 0;
  height: 38px;
}

.insight-btn-img {
  max-height: 24px;
  max-width: 24px;
  width: auto;
  height: auto;
  object-fit: contain;
  pointer-events: none;
  filter: brightness(0.9);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.btn-pill-i.active .insight-btn-img {
  filter: brightness(1.2) drop-shadow(0 0 2px rgba(255, 255, 255, 0.4));
  transform: scale(1.05);
}

.resonance-quick-picks,
.portrait-quick-picks {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.btn-pill,
.btn-pill-i,
.btn-pill-p {
  background: #3a3632;
  border: 1px solid #4a4541;
  color: #f6f2ed;
  padding: 8px 0;
  border-radius: 0;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--mono-font);
}

.btn-pill:hover,
.btn-pill-i:hover,
.btn-pill-p:hover {
  background: #4a4541;
  border-color: #5a5551;
}

.btn-pill.active {
  background: #4f4f4f;
  color: #ffffff;
  border-color: #4f4f4f;
  font-weight: 800;
}

.btn-pill-i.active {
  background: #2a2825;
  color: #f6f2ed;
  border-color: #D7B155;
  font-weight: 800;
}

.btn-pill-p.active {
  background: #2a2825;
  color: #f6f2ed;
  border-color: #D7B155;
  font-weight: 800;
}

.btn-pill.active.none,
.btn-pill-p.active.none {
  background: #4f4f4f;
  border-color: #4f4f4f;
  color: #ffffff;
}

.btn-pill.active.offensive,
.btn-pill-p.active.offensive {
  background: #FBAE31;
  border-color: #FBAE31;
  color: #111111;
}

.btn-pill.active.defensive,
.btn-pill-p.active.defensive {
  background: #2d8a5a;
  border-color: #2d8a5a;
  color: #ffffff;
}

.btn-pill.active.hp,
.btn-pill-p.active.hp {
  background: #d4ad2b;
  border-color: #d4ad2b;
  color: #111111;
}

.btn-pill.active.equibalance,
.btn-pill-p.active.equibalance {
  background: #3b6dc7;
  border-color: #3b6dc7;
  color: #ffffff;
}

/* Range Slider */
.custom-slider {
  width: 100%;
  accent-color: #D05126;
  cursor: pointer;
}

.custom-slider:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Numeric entry (e.g. Gluttony / Greed quantity) */
.custom-number-input {
  width: 100%;
  font-family: var(--board-font, var(--mono-font));
  font-size: 0.78rem;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  color: #E5E7EB;
  box-sizing: border-box;
  transition: border-color 0.18s ease;
}

.custom-number-input:hover {
  border-color: rgba(255, 255, 255, 0.4);
}

.custom-number-input:focus {
  outline: none;
  border-color: #D05126;
}

/* Euphoria Checkboxes */
.euphoria-checkboxes {
  display: flex;
  gap: 20px;
}

.check-container {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.check-container input {
  display: none;
}

.check-box {
  width: 18px;
  height: 18px;
  border-radius: 0;
  border: 1px solid #B5B5B3;
  background: rgba(0, 0, 0, 0.45);
  position: relative;
  transition: all 0.2s;
  box-sizing: border-box;
}

.check-container:hover .check-box {
  border-color: #FFFFFF;
}

.check-container input:checked + .check-box {
  background: rgba(255, 255, 255, 0.12);
  border-color: #FFFFFF;
}

.check-container input:checked + .check-box::after {
  content: "✔";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #FFFFFF;
  font-size: 0.72rem;
  font-weight: 800;
}

.check-text {
  font-family: var(--primary-font);
  font-size: 0.82rem;
  color: #FFFFFF;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* Euphoria checkbox label: the tree art replaces the name when it exists. */
.euphoria-check-thumb {
  position: relative;
  display: block;
  width: 64px;
  height: 64px;
}

.euphoria-check-icon {
  display: block;
  width: 64px;
  height: 64px;
  object-fit: cover;
  border: 1px solid rgba(181, 181, 179, 0.35);
  background: rgba(0, 0, 0, 0.4);
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* Tier tag (E1/E2, or 1狂/2狂 in CN) so two icons stay tellable apart. */
.euphoria-check-tier {
  position: absolute;
  left: 0;
  bottom: 0;
  padding: 0 5px;
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1.5;
  letter-spacing: 0.02em;
  color: #f7f7f7;
  background: rgba(0, 0, 0, 0.72);
  pointer-events: none;
}

.check-container:hover .euphoria-check-icon {
  border-color: #ED7D31;
}

.check-container input:checked ~ .check-text .euphoria-check-icon {
  border-color: #ED7D31;
  box-shadow: 0 0 8px rgba(237, 125, 49, 0.45);
}

.modal-footer {
  padding: 16px 22px;
  background: rgba(22, 20, 18, 0.95);
  border-top: 1px solid rgba(208, 81, 38, 0.4);
}

.modal-footer .btn-primary,
#modal-btn-save,
#options-btn-done {
  background: #D05126;
  border: 1px solid #D05126;
  color: #FFFFFF;
  font-family: var(--primary-font);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  padding: 10px 0;
  transition: all 0.18s ease;
}

.modal-footer .btn-primary:hover,
#modal-btn-save:hover,
#options-btn-done:hover {
  background: #B55829;
  border-color: #B55829;
  color: #FFFFFF;
  box-shadow: none;
}

/* Listing Modal Tiers List */
.listing-tiers-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

/* ============================================================
   TIERS MODAL — "el" elegance
   Thin coloured rails express hierarchy instead of nested boxes.
   Tier = orange rail · Condition group = gold rail.
   ============================================================ */

.listing-tier-item {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0 10px 0 0;
  padding: 0;
  overflow: hidden;
  transition: border-color 0.18s ease;
}

.listing-tier-item:hover {
  border-color: rgba(255, 255, 255, 0.18);
}

/* Header row reads as an "el" bar: dark panel + accent rail on the left.
   --tier-color is set inline from the tier's chosen text colour. */
.listing-tier-header-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 9px 14px;
  background: rgba(0, 0, 0, 0.4);
  border-left: 3px solid var(--tier-color, #D05126);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-sizing: border-box;
}

/* Criteria area: flat and compact, no boxed background */
.listing-tier-rules-container {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 3px 0 6px;
  margin-left: 3px;
  background: transparent;
  border: none;
}

.listing-rule-group-box {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 7px 14px 7px 12px;
  background: transparent;
  border: none;
  border-left: 2px solid rgba(246, 195, 74, 0.35);
}

.listing-rule-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.listing-rule-group-tag {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.6rem;
  font-weight: 600;
  color: #C9A227;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* One criteria row: [field] [op] [value]. Border only — no background. */
.listing-rule-condition-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 5px 8px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-sizing: border-box;
}

.btn-tier-move {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 0.55rem;
  padding: 1px 5px;
  cursor: pointer;
  color: #8E8E8E;
  line-height: 1;
  border-radius: 0;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-tier-move:hover:not(:disabled) {
  background: rgba(246, 195, 74, 0.14);
  border-color: rgba(246, 195, 74, 0.6);
  color: #F6C34A;
}

.btn-tier-move:disabled {
  opacity: 0.22;
  cursor: default;
}

.listing-tier-label-input {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  padding: 5px 9px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.3);
  color: #FFFFFF;
  width: 110px;
  box-sizing: border-box;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.listing-tier-label-input:hover {
  border-color: rgba(255, 255, 255, 0.26);
}

.listing-tier-label-input:focus {
  outline: none;
  border-color: #D05126;
  background: rgba(0, 0, 0, 0.45);
}

/* "BG" / "Border" / "BOLD" labels inside each tier header row */
.listing-tier-header-row label,
.listing-tier-header-row > span {
  color: #8E8E8E;
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Compact Clear button inside the tier header */
.listing-tier-header-row .custom-color-clear-btn {
  padding: 3px 7px;
  font-size: 0.55rem;
}

/* + AND / + Add OR buttons: quiet outline, sitting flush with the row */
.listing-rule-group-header .btn-sm,
.listing-rule-group-header .btn-flat-action {
  background: transparent;
  border: 1px solid rgba(181, 181, 179, 0.35);
  color: #B5B5B3;
  border-radius: 0;
  font-size: 0.58rem;
  padding: 3px 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.listing-rule-group-header .btn-sm:hover,
.listing-rule-group-header .btn-flat-action:hover {
  background: rgba(181, 181, 179, 0.14);
  border-color: #B5B5B3;
  color: #FFFFFF;
}

/* Tier delete button */
.listing-tier-header-row .btn-tier-del:hover {
  color: #ED7D31;
}

/* Clone button — duplicates the tier directly below the current one */
.listing-tier-header-row .btn-tier-clone {
  background: transparent;
  border: 1px solid rgba(181, 181, 179, 0.4);
  color: #B5B5B3;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 8px;
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.listing-tier-header-row .btn-tier-clone:hover {
  color: #FFFFFF;
  border-color: #B5B5B3;
  background: rgba(181, 181, 179, 0.12);
}

/* System-tier tag ("UNOWNED" / "REMAINING") */
.listing-tier-header-row > span[style] {
  color: #8E8E8E !important;
  font-size: 0.58rem !important;
  letter-spacing: 0.12em !important;
}

.listing-rule-condition-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.listing-rule-select {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.68rem;
  padding: 4px 22px 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background:
    url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23E5E7EB'/%3E%3C/svg%3E")
      no-repeat right 7px center;
  color: #E5E7EB;
  cursor: pointer;
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  border-radius: 0;
  transition: border-color 0.18s ease;
}

.listing-rule-select:hover {
  border-color: rgba(255, 255, 255, 0.4);
}

.listing-rule-select:focus {
  outline: none;
  border-color: #D05126;
}

.listing-rule-value-input {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.68rem;
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  color: #E5E7EB;
  width: 55px;
  box-sizing: border-box;
  transition: border-color 0.18s ease;
}

.listing-rule-value-input:hover {
  border-color: rgba(255, 255, 255, 0.4);
}

.listing-rule-value-input:focus {
  outline: none;
  border-color: #D05126;
}

.listing-rule-value-input:focus {
  outline: none;
  border-color: #D05126;
}

.listing-rule-or-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 3px 0;
  position: relative;
  background: rgba(0, 0, 0, 0.18);
}

.listing-rule-or-divider::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: #676767;
}

.listing-rule-or-badge {
  position: relative;
  background: #D05126;
  color: #FFFFFF;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.55rem;
  font-weight: 700;
  padding: 1px 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.listing-tier-handle {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* "+ Add OR Condition Group" — quiet text action at the bottom of a tier */
.listing-tier-rules-container > .btn-sm {
  align-self: flex-start;
  margin: 4px 0 2px 14px;
  background: transparent;
  border: 1px dashed rgba(181, 181, 179, 0.3);
  color: #8E8E8E;
  font-size: 0.56rem;
  padding: 3px 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: 0;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.listing-tier-rules-container > .btn-sm:hover {
  color: #E5E7EB;
  border-color: rgba(181, 181, 179, 0.55);
  background: rgba(255, 255, 255, 0.03);
}

/* System-tier explanatory text */
.listing-tier-rules-container > div[style] {
  padding: 9px 14px 11px 14px !important;
  color: #8E8E8E !important;
}

.listing-tier-color-input {
  width: 28px;
  height: 28px;
  border: 1px solid #676767;
  padding: 0;
  cursor: pointer;
  background: none;
}

.listing-tier-select {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.68rem;
  padding: 6px 28px 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background:
    url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23ECE5D9'/%3E%3C/svg%3E")
      no-repeat right 9px center,
    rgba(0, 0, 0, 0.42);
  color: #ECE5D9;
  flex: 1;
  min-width: 140px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  border-radius: 0;
  transition: border-color 0.18s ease, background-color 0.18s ease;
}

.listing-tier-select:hover {
  border-color: rgba(237, 125, 49, 0.55);
}

.listing-tier-select:focus {
  outline: none;
  border-color: #D05126;
}

/* Options Character Info Preview Box */
.options-char-top-illustration {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 0;
  width: 100%;
  background: transparent;
  border: none;
  box-sizing: border-box;
}

.options-char-preview-box {
  border: 1px solid #B5B5B3;
  background: rgba(0, 0, 0, 0.25);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Options live preview: fixed scale, independent of the board's card-size slider.
   Preview is enlarged (1.6x) and pinned so it always renders identically. */
#options-char-preview-card.char-card {
  --char-card-scale: 1.6;
  --char-card-width: 96px;
  --char-avatar-size: 96px;
}

.options-char-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px dashed rgba(181, 181, 179, 0.4);
  padding-bottom: 8px;
}

.options-char-preview-header span {
  font-family: var(--primary-font) !important;
  color: #B5B5B3;
  letter-spacing: 0.12em;
}

.options-char-preview-content {
  display: flex;
  flex-direction: column;
}

#options-char-preview-card {
  margin: 0;
}

.options-char-preview-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
}

/* Collapsible Option Sections */
.options-collapse-box {
  border: none !important;
  background: transparent !important;
  border-left: none !important;
  box-sizing: border-box;
  transition: none;
}

.options-collapse-box:hover {
  border-color: transparent !important;
  border-left-color: transparent !important;
}

.options-collapse-btn {
  font-family: Georgia, 'Times New Roman', serif !important;
  font-size: 0.88rem !important;
  font-weight: 700 !important;
  color: #ECE5D9 !important;
  letter-spacing: 0.08em !important;
  text-transform: uppercase !important;
  padding: 8px 0 !important;
}

.options-collapse-box .btn-sm {
  background: transparent !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  color: #ECE5D9 !important;
  font-family: Georgia, 'Times New Roman', serif !important;
  font-size: 0.72rem !important;
  font-weight: 700 !important;
  padding: 2px 8px !important;
  letter-spacing: 0.08em !important;
}

.options-collapse-box .btn-sm:hover {
  background: rgba(208, 81, 38, 0.2) !important;
  border-color: #D05126 !important;
  color: #ffffff !important;
}

/* Flattened option sections (rendered as section headers, always expanded) */
.options-flat-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Gold-railed variant used by the Character's Info Box / Name / Details
   sections and the character hiding sections. Accepts the class either on the
   wrapper or directly on the header. */
.options-el-gold > .archetype-section-header,
.archetype-section-header.options-el-gold {
  border-left-color: #FFD965;
}

/* Purple-railed variant for the Psychube detail hiding sections */
.options-el-psychube > .archetype-section-header,
.archetype-section-header.options-el-psychube {
  border-left-color: #6A4972;
}

.options-flat-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 2px 2px 4px;
}

.options-flat-content .btn-sm {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ECE5D9;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  letter-spacing: 0.08em;
}

.options-flat-content .btn-sm:hover {
  background: rgba(208, 81, 38, 0.2);
  border-color: #D05126;
  color: #ffffff;
}

/* Illustrate Live Preview Helpers */
.customize-preview-box {
  border: 1px solid rgba(215, 177, 85, 0.3);
  background: rgba(0, 0, 0, 0.35);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.customize-preview-header {
  font-family: var(--primary-font);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #D7B155;
  letter-spacing: 0.12em;
}

.customize-preview-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 6px 4px;
}

/* Archetype R1999 Panel Style (Display Options) */
.archetype-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.archetype-accent-bar {
  display: inline-block;
  width: 4px;
  height: 20px;
  background-color: #D05126;
  flex-shrink: 0;
}

.archetype-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 6px;
}

.archetype-sublabel {
  font-family: var(--primary-font);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: #9e9a95;
  text-transform: uppercase;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.archetype-content-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 12px 14px;
  box-sizing: border-box;
}

.archetype-num {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
  color: #E7D9CB;
  letter-spacing: -0.02em;
  opacity: 0.95;
  user-select: none;
  min-width: 32px;
}

.archetype-controls-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.archetype-modal-card,
#options-modal .modal-card,
#appearance-modal .modal-card {
  background-image: url("images/background.png") !important;
  background-position: center !important;
  background-size: cover !important;
  background-repeat: no-repeat !important;
  border: 1px solid #B55829 !important;
  border-radius: 0 20px 0 0 !important;
  box-shadow: 0 0 8px rgba(181, 88, 41, 0.28), 0 0 18px rgba(181, 88, 41, 0.12) !important;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif !important;
}

/* Styling modal: single rounded corner at top-right, larger radius */
#customize-modal .modal-card {
  background-image: url("images/background.png") !important;
  background-position: center !important;
  background-size: cover !important;
  background-repeat: no-repeat !important;
  border: 1px solid #B55829 !important;
  border-radius: 0 20px 0 0 !important;
  box-shadow: 0 0 8px rgba(181, 88, 41, 0.28), 0 0 18px rgba(181, 88, 41, 0.12) !important;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif !important;
}

#options-modal .modal-card * {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
}

.archetype-modal-header {
  padding: 16px 22px 14px;
  background: #212121 !important;
  border-bottom: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.archetype-modal-header::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background-color: #D05126;
  opacity: 1;
}

.archetype-modal-title {
  font-family: Georgia, 'Times New Roman', serif !important;
  font-size: 26px;
  font-weight: normal;
  letter-spacing: 0;
  text-transform: none;
  color: #ECE5D9;
  margin: 0;
}

.archetype-modal-body {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: transparent !important;
  max-height: 70vh;
  overflow-y: auto;
}

.archetype-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 3px solid #D05126;
  padding: 8px 12px;
  box-sizing: border-box;
  margin-bottom: 2px;
}

.archetype-section-title {
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #ECE5D9;
  text-transform: uppercase;
}

.archetype-section-divider {
  display: none;
}

.archetype-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  width: 100%;
  box-sizing: border-box;
}

.archetype-grid-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.14);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  box-sizing: border-box;
}

.archetype-grid-item input {
  display: none;
}

.archetype-diamond {
  font-size: 0.95rem;
  line-height: 1;
  color: #E7D9CB;
  transition: all 0.15s ease;
  font-weight: 300;
}

.archetype-item-text {
  font-size: 0.8rem;
  color: #E7D9CB;
  transition: all 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.archetype-grid-item:hover {
  border-color: rgba(208, 81, 38, 0.6);
  background: rgba(0, 0, 0, 0.35);
}

/* Checked State: mimics the DPS box (deep orange border + muted orange-brown fill + highlighted diamond and text) */
.archetype-grid-item:has(input:checked) {
  border: 1px solid #C4673B;
  background: rgba(196, 103, 59, 0.16);
}

.archetype-grid-item:has(input:checked) .archetype-diamond {
  color: #D97746;
}

.archetype-grid-item:has(input:checked) .archetype-item-text {
  color: #E68A57;
  font-weight: 600;
}

#options-modal .modal-footer {
  background: transparent !important;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 14px 20px;
}

#options-modal .modal-footer #options-btn-done {
  border-color: #D05126;
  color: #FFFFFF;
}

#options-modal .modal-footer #options-btn-done:hover {
  border-color: #D05126;
  color: #FFFFFF;
}

/* ================= STYLING MODAL — DISPLAY OPTIONS LOOK ================= */
/* card colours/radius/typography are defined upstream (near .archetype-modal-card) */

/* Sans-serif body text throughout, except the serif modal title */
#customize-modal .modal-card :not(.archetype-modal-title),
#customize-modal .modal-card :not(.archetype-modal-title)::before,
#customize-modal .modal-card :not(.archetype-modal-title)::after {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
}

#customize-modal .archetype-modal-title {
  font-family: Georgia, 'Times New Roman', serif !important;
}

#customize-modal .archetype-modal-body {
  padding: 16px 20px;
  gap: 12px;
  background: transparent !important;
}

#customize-modal .modal-footer {
  background: transparent !important;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 14px 20px;
}

#customize-modal .modal-footer .btn-primary {
  border-color: #D05126;
  color: #FFFFFF;
}

/* Group header: same bar style as Display Options section headers */
#customize-modal .custom-category-header {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 3px solid #D05126;
  padding: 8px 12px;
  margin-top: 10px;
  margin-bottom: 6px;
  box-sizing: border-box;
}

#customize-modal .custom-category-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #D05126;
  text-transform: uppercase;
}

#customize-modal .custom-category-header {
  border-left-color: #FFFFFF;
}

#customize-modal .custom-style-section {
  border-top: none;
  padding-top: 4px;
}

/* Unified label / value text — see "STYLING MODAL — unified typography scale" at end of file */
/* Section titles share the same "el" frame as group headers */
#customize-modal .custom-style-section-title {
  display: block;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 3px solid #D05126;
  padding: 6px 12px;
  margin-bottom: 8px;
  box-sizing: border-box;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #ECE5D9;
}

#customize-modal .custom-color-clear-btn {
  color: #E7D9CB;
  font-size: 0.68rem;
}

#customize-modal .custom-color-clear-btn:hover {
  color: #FFFFFF;
}

/* Preview boxes: white border, slightly larger inner text */
#customize-modal .customize-preview-box {
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.25);
}

#customize-modal .customize-preview-header {
  color: #E7D9CB;
  letter-spacing: 0.08em;
}

/* NOTE: preview-stage font sizes are set by JS inline styles — do not force them here. */

/* Amplification quick picks in the Psychube setting modal (mirrors the
   portrait pills). A5 is highlighted in the accent colour. */
#chube-modal .btn-pill-p {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  background: #111111;
  border: 1px solid #676767;
  color: #BFBFBF;
}

#chube-modal .btn-pill-p:hover {
  background: #1a1a1a;
  border-color: #B5B5B3;
}

#chube-modal .btn-pill-p.active {
  background: #D05126;
  color: #FFFFFF;
  border-color: #D05126;
}

/* Amplification quick picks: five evenly-spaced buttons. A5 reads in the same
   colour as the rest; only the card badge follows the Styling colour. */
#chube-modal .chube-amp-quick-picks {
  grid-template-columns: repeat(5, 1fr);
}

#chube-modal .btn-pill-a.is-max {
  color: #BFBFBF;
}

#chube-modal .btn-pill-a.is-max.active {
  background: #D05126;
  border-color: #D05126;
  color: #FFFFFF;
}

/* The Amplification readout is A5-coloured at max */
#chube-display-amp.is-max {
  color: var(--chube-amp-max-color, #DF7526);
}

/* A5 on the chube manager tiles + bulk options */
.bulk-opt.is-max {
  color: #DF7526;
}

/* ================= STATISTICS MODAL ================= */
#stats-modal .modal-card {
  max-height: 82vh;
  animation: statsCardIn 0.26s cubic-bezier(0.16, 0.84, 0.32, 1) both;
}

@keyframes statsCardIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Each block rises in after the card lands, one after another. */
#stats-modal .stat-section {
  animation: statsBlockIn 0.28s ease-out both;
  animation-delay: calc(70ms + var(--stat-index, 0) * 40ms);
}

@keyframes statsBlockIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Respect the OS "reduce motion" preference: show everything immediately. */
@media (prefers-reduced-motion: reduce) {
  #stats-modal .modal-card,
  #stats-modal .stat-section {
    animation: none;
  }
}

#stats-modal .modal-body {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 16px 20px;
}

.stat-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 0;
}

/* "el" title: dark panel with an accent rail on the left */
.stat-el {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #E7D9CB;
  background: #181818;
  border-left: 3px solid #D05126;
  padding: 7px 12px;
  margin-bottom: 2px;
}

/* Small clarifying note under a stat block */
.stat-note {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.62rem;
  font-style: italic;
  color: #9a9a9a;
  letter-spacing: 0.02em;
  margin-top: 4px;
  text-align: center;
}

/* Statistics header: Export PNG sits beside the title */
.stats-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.stat-block {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.stat-block-title {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #D7B155;
}

.stat-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.stat-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.stat-row-label {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: #E5E7EB;
}

.stat-row-sub .stat-row-label {
  color: #BFBFBF;
  font-size: 0.76rem;
}

.stat-row-value {
  font-family: var(--mono-font);
  font-size: 0.82rem;
  font-weight: 700;
  color: #FFFFFF;
  white-space: nowrap;
}

.stat-row-sub .stat-row-value {
  font-size: 0.76rem;
}

.stat-bar {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
  overflow: hidden;
  box-sizing: border-box;
}

.stat-bar-fill {
  display: block;
  height: 100%;
  background: var(--accent-gold, #D7B155);
  transition: width 0.25s ease;
}

.stat-sep {
  height: 1px;
  background: rgba(255, 255, 255, 0.14);
}

/* Gluttony / Greed icon row (above Total Chube Count) */
.stats-special-chubes {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 42px;
  padding: 6px 0 4px;
}

.stats-special-chube {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stats-special-chube-img {
  width: 69px;
  height: auto;
  aspect-ratio: 180 / 214;
  object-fit: contain;
  display: block;
}

.stats-special-chube-count {
  font-family: var(--mono-font);
  font-size: 1rem;
  font-weight: 700;
  color: var(--chube-count-color, #04FFEE);
  text-align: center;
}

/* Chess piece progress row (fixed scale, centred) */
.stats-chess-row {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  padding: 6px 0 2px;
}

.stats-chess-piece {
  position: relative;
  flex-shrink: 0;
}

.stats-chess-empty {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom center;
  display: block;
}

.stats-chess-mask {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
}

.stats-chess-mask img {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  display: block;
  object-fit: contain;
  object-position: bottom center;
}

/* ================= MODAL SCROLLBARS ================= */
/* Slim, themed vertical scrollbars inside modals so long lists feel smooth. */
.modal-body,
.roster-grid,
#stats-modal .modal-body,
#roster-modal .roster-grid,
#roster-modal .roster-grid {
  scrollbar-width: thin;
  scrollbar-color: rgba(181, 181, 179, 0.45) transparent;
  overscroll-behavior: contain;
}

.modal-body::-webkit-scrollbar,
.roster-grid::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.modal-body::-webkit-scrollbar-track,
.roster-grid::-webkit-scrollbar-track {
  background: transparent;
}

.modal-body::-webkit-scrollbar-thumb,
.roster-grid::-webkit-scrollbar-thumb {
  background: rgba(181, 181, 179, 0.45);
  border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover,
.roster-grid::-webkit-scrollbar-thumb:hover {
  background: rgba(208, 81, 38, 0.75);
}

/* ================= TIERS / QUICK EDIT / CONFIRM — Styling-modal look ================= */
  :is(#listing-modal, #roster-modal, #confirm-modal, #export-json-modal, #edit-modal) .modal-card {
    background-image: url("images/background.png") !important;
  background-position: center !important;
  background-size: cover !important;
  background-repeat: no-repeat !important;
    border: 1px solid #B55829 !important;
    border-radius: 0 20px 0 0 !important;
    box-shadow: 0 0 8px rgba(181, 88, 41, 0.28), 0 0 18px rgba(181, 88, 41, 0.12) !important;
    font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif !important;
  }

:is(#listing-modal, #roster-modal, #confirm-modal, #export-json-modal, #edit-modal, #appearance-modal) .modal-card * {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
}

/* The title keeps the serif the rest of the site's modals wear. The blanket `*` rule
   above lands on the `<span>` inside the `<h2>`, so setting the family on the heading
   alone (`:not(.archetype-modal-title)`) was not enough — the label still came out sans
   in Appearance and Manage while Teams and Rotations read Georgia. */
:is(#listing-modal, #roster-modal, #confirm-modal, #export-json-modal, #edit-modal, #appearance-modal) .archetype-modal-title,
:is(#listing-modal, #roster-modal, #confirm-modal, #export-json-modal, #edit-modal, #appearance-modal) .archetype-modal-title * {
  font-family: Georgia, 'Times New Roman', serif !important;
}

:is(#listing-modal, #roster-modal, #confirm-modal, #export-json-modal, #edit-modal, #appearance-modal) .archetype-modal-header {
  padding: 16px 22px 14px;
  background: #212121 !important;
  border-bottom: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

:is(#listing-modal, #roster-modal, #confirm-modal, #export-json-modal, #edit-modal, #appearance-modal) .archetype-modal-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: #D05126;
  opacity: 1;
}

:is(#listing-modal, #roster-modal, #confirm-modal, #export-json-modal, #edit-modal, #appearance-modal) .archetype-modal-title {
  font-family: Georgia, 'Times New Roman', serif !important;
  font-size: 26px;
  font-weight: normal;
  letter-spacing: 0;
  text-transform: none;
  color: #ECE5D9;
  margin: 0;
}

:is(#listing-modal, #roster-modal, #confirm-modal, #export-json-modal, #edit-modal) .archetype-modal-body {
  padding: 16px 22px 20px;
  gap: 12px;
  background: transparent !important;
}

:is(#listing-modal, #roster-modal, #confirm-modal, #export-json-modal, #edit-modal) .modal-footer {
  background: transparent !important;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 14px 22px;
}

:is(#listing-modal, #roster-modal, #confirm-modal, #export-json-modal, #edit-modal) .setting-label {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #BFBFBF;
}

:is(#listing-modal, #roster-modal, #confirm-modal, #export-json-modal, #edit-modal) .btn {
  border-radius: 0;
}

:is(#listing-modal, #roster-modal, #confirm-modal, #export-json-modal, #edit-modal) :is(.search-input, .listing-tier-select) {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  background-color: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(181, 181, 179, 0.35);
  border-radius: 0;
  color: #E5E7EB;
}

:is(#listing-modal, #roster-modal, #confirm-modal, #export-json-modal, #edit-modal) :is(.search-input, .listing-tier-select):focus {
  outline: none;
  border-color: #D05126;
}

/* Confirmation message uses the shared body tone */
#confirm-modal #confirm-modal-message {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif !important;
  font-size: 13px !important;
  color: #E5E7EB !important;
  line-height: 1.5;
}

/* Quick Edit has no .modal-body — style its dedicated regions instead */
#roster-modal .roster-toolbar {
  background: transparent !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#roster-modal .roster-grid {
  background: transparent !important;
}

#roster-modal .roster-toolbar .filter-btn-group {
  border-color: rgba(181, 181, 179, 0.5);
}

#roster-modal .roster-toolbar .filter-btn {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  color: #B5B5B3;
  border-right-color: rgba(181, 181, 179, 0.5);
}

#roster-modal .roster-toolbar .filter-btn:hover,
#roster-modal .roster-toolbar .filter-btn.active {
  color: #FFFFFF;
  background: rgba(208, 81, 38, 0.22);
}

#roster-modal .roster-toolbar .filter-btn:focus {
  outline: none;
}

#roster-modal .roster-toolbar .filter-btn:focus-visible {
  outline: 2px solid #ED7D31;
  outline-offset: -2px;
}

/* ================= CHARACTER SETTING (edit-modal) — Styling-modal look ================= */
/* Only the character portrait carries the accent frame; the favourite pin
   beside the name must stay borderless. */
#edit-modal .modal-char-preview img:not(.btn-favourite-img) {
  border: 1px solid #D05126;
}

#edit-modal .modal-char-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 26px;
  font-weight: normal;
  letter-spacing: 0;
  color: #ECE5D9;
}

#edit-modal .modal-char-sub {
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #BFBFBF;
}

/* Section labels: same Tier-1 treatment as the Styling modal */
#edit-modal .setting-label {
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #BFBFBF;
}

#edit-modal .setting-val-display {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: #E5E7EB;
}

#edit-modal .setting-group {
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

#edit-modal .setting-group:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

/* Ownership toggle (shared by the Character and Psychube setting modals) */
#edit-modal .toggle-group,
#chube-modal .toggle-group {
  background: #111111;
  border: 1px solid #676767;
}

#edit-modal .btn-toggle,
#chube-modal .btn-toggle {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #BFBFBF;
}

#edit-modal .btn-toggle.active,
#chube-modal .btn-toggle.active {
  background: #D05126;
  color: #FFFFFF;
}

/* Insight / Portrait / Pattern pills */
#edit-modal .btn-pill-i,
#edit-modal .btn-pill-p {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  background: #111111;
  border: 1px solid #676767;
  color: #BFBFBF;
}

#edit-modal .btn-pill-i:hover,
#edit-modal .btn-pill-p:hover {
  background: #1a1a1a;
  border-color: #B5B5B3;
  color: #E5E7EB;
}

#edit-modal .btn-pill-i.active,
#edit-modal .btn-pill-p.active {
  background: #D05126;
  border-color: #D05126;
  color: #FFFFFF;
}

/* Skin quick picks */
#edit-modal .btn-pill-skin {
  background: #111111;
  border: 1px solid #676767;
}

#edit-modal .btn-pill-skin:hover {
  background: #1a1a1a;
  border-color: #B5B5B3;
}

#edit-modal .btn-pill-skin.active {
  background: #1a1a1a;
  border-color: #D05126;
  box-shadow: 0 0 0 1px #D05126;
}

#edit-modal .check-text {
  font-size: 13px;
  color: #E5E7EB;
}

#edit-modal .pattern-help-box {
  background: #111111;
  border: 1px solid #676767;
  color: #B5B5B3;
}

/* Tier listing: Save & Apply button */
#listing-modal #btn-save-listing {
  border: 1px solid #D05126;
  color: #FFFFFF;
}

#listing-modal #btn-save-listing:hover {
  background: #B55829;
  border-color: #B55829;
  color: #FFFFFF;
}

/* Export JSON: "Export All" carries the accent fill */
#export-json-modal #btn-export-json-all {
  background: #D05126;
  border: 1px solid #D05126;
  color: #FFFFFF;
}

#export-json-modal #btn-export-json-all:hover {
  background: #B55829;
  border-color: #B55829;
  color: #FFFFFF;
}

#confirm-modal .modal-footer #confirm-modal-btn-yes {
  background: #D05126;
  border: 1px solid #D05126;
  color: #FFFFFF;
}

#confirm-modal .modal-footer #confirm-modal-btn-yes:hover {
  background: #B55829;
  border-color: #B55829;
  color: #FFFFFF;
}

#edit-modal .modal-footer #modal-btn-save {
  border: 1px solid #D05126;
  color: #FFFFFF;
}

#edit-modal .modal-footer #modal-btn-save:hover {
  background: #B55829;
  border-color: #B55829;
  color: #FFFFFF;
}

/* ================= DISPLAY OPTIONS FLATTENED STYLING ================= */
.archetype-section-header-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
}

.archetype-section-header .btn-flat-action {
  margin-left: auto;
  flex-shrink: 0;
  padding: 4px 10px;
  font-size: 0.68rem;
}

.btn-flat-action {
  background: rgba(13, 15, 18, 0.42);
  border: 1px solid rgba(231, 217, 203, 0.42);
  color: #E7D9CB;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.btn-flat-action:hover {
  background: rgba(208, 81, 38, 0.25);
  border-color: #D05126;
  color: #F6C34A;
}

.display-option-flat-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.flat-subgroup {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.flat-subgroup-label {
  font-family: monospace;
  font-size: 0.65rem;
  font-weight: 700;
  color: #BFBFBF;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.archetype-grid-item-inline {
  display: flex;
  align-items: center;
  gap: 6px;
}

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

/* Switch the diamond icon to a filled diamond when the checkbox is ticked */
.archetype-grid-item:has(input:checked) .archetype-diamond {
  color: #D97746;
}

.archetype-grid-item input:checked ~ .archetype-diamond::before {
  content: "◆";
}

.archetype-grid-item input:not(:checked) ~ .archetype-diamond::before {
  content: "◇";
}

.archetype-grid-item .archetype-diamond {
  font-size: 0.95rem;
  line-height: 1;
}

/* Tier Preview in Listing Modal */
.listing-tier-preview-row {
  display: grid;
  grid-template-columns: 80px 1fr;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 0;
  border: 1px solid #4a4541;
  background: #2a2825;
  width: 100%;
  box-sizing: border-box;
}

.listing-tier-preview-label {
  font-family: var(--board-font, var(--mono-font));
  font-size: 0.68rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.listing-tier-preview-items {
  display: flex;
  align-items: center;
  gap: 6px;
}

.listing-mini-card {
  width: 32px;
  height: 32px;
  border: 1px solid #4a4541;
  background: #3a3632;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.55rem;
  color: #888;
  font-family: var(--mono-font);
}

.listing-mini-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.custom-category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  margin-bottom: 4px;
  padding-bottom: 4px;
  border-bottom: 2px solid #4a4541;
}

.custom-category-title {
  font-family: var(--mono-font);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #f6f2ed;
}

.custom-style-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px dashed #4a4541;
}

.custom-style-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  font-family: var(--mono-font);
  text-transform: uppercase;
  color: #f6f2ed;
  letter-spacing: 0.08em;
}

.custom-style-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.68rem;
  font-family: var(--mono-font);
}

.custom-style-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.custom-style-color-cell {
  display: flex;
  align-items: center;
  gap: 6px;
}

.custom-color-clear-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #ECE5D9;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 6px;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.custom-color-clear-btn:hover {
  color: #F6C34A;
  border-color: #F6C34A;
  background: rgba(246, 195, 74, 0.14);
}

.btn-tier-del {
  background: transparent;
  border: none;
  font-size: 1.1rem;
  color: #D05126;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s ease;
}

.btn-tier-del:hover {
  color: #F6C34A;
}

/* Per-tier hide toggle (sits next to Bold). The icon turns red while the
   tier is hidden from the board. */
.btn-tier-hide {
  background: none;
  border: none;
  outline: none;
  padding: 0 4px;
  margin: 0;
  cursor: pointer;
  line-height: 0;
  display: inline-flex;
  align-items: center;
  -webkit-appearance: none;
  appearance: none;
  transition: filter 0.15s ease, opacity 0.15s ease;
}

.btn-tier-hide img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  display: block;
  border: 0 none;
  background: none;
  box-shadow: none;
  opacity: 0.75;
  transition: filter 0.15s ease, opacity 0.15s ease;
}

.btn-tier-hide:hover img {
  opacity: 1;
}

/* Active state: the icon turns white and lifts slightly. No box background or
   border — the glow comes from the icon itself. */
.btn-tier-hide.is-hidden {
  background: none;
  border: none;
  box-shadow: none;
}

.btn-tier-hide.is-hidden img {
  filter: brightness(0) invert(1) drop-shadow(0 0 4px rgba(255, 255, 255, 0.9));
  opacity: 1;
}

.roster-toolbar {
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid #4a4541;
}

.roster-toolbar-left {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

.roster-toolbar-left .search-input {
  flex: 1;
  max-width: 280px;
}

/* Rarity filter + Select sit together on the right */
.roster-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* ================= QUICK EDIT — BULK SELECTION ================= */
.roster-select-toggle[aria-pressed="true"] {
  background: rgba(208, 81, 38, 0.22);
  border-color: #D05126;
  color: #FFFFFF;
}

/* Action bar shown while select mode is active */
.roster-select-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 22px;
  background: transparent;
  border-top: 1px solid rgba(208, 81, 38, 0.35);
  border-bottom: 1px solid rgba(208, 81, 38, 0.35);
  box-sizing: border-box;
}

.roster-select-bar[hidden] {
  display: none;
}

.roster-select-count {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #FFFFFF;
  white-space: nowrap;
}

.roster-select-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.roster-select-actions .btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Bulk Apply carries the accent fill */
#btn-roster-bulk-apply,
#btn-chubes-bulk-apply {
  background: #D05126;
  border: 1px solid #D05126;
  color: #FFFFFF;
}

#btn-roster-bulk-apply:hover:not([disabled]),
#btn-chubes-bulk-apply:hover:not([disabled]) {
  background: #B55829;
  border-color: #B55829;
  color: #FFFFFF;
}

/* Selection state on a tile — thin accent ring, no badge or text emphasis
  (shared by Manage Characters and Chubes) */
.roster-char-item.is-selected .roster-avatar-box {
  border-color: #D05126 !important;
  box-shadow: none !important;
  filter: none !important;
}

.roster-char-item.is-selected {
  opacity: 1 !important;
}

.roster-select-mode .roster-char-item {
  position: relative;
  cursor: pointer;
}

/* Dim the unchosen tiles a touch so the selection reads at a glance */
.roster-select-mode .roster-char-item:not(.is-selected) .roster-avatar-box {
  opacity: 0.5;
}

.roster-select-mode .roster-char-item.is-selected .roster-avatar-box {
  opacity: 1;
}

.roster-select-mode .roster-char-item .roster-avatar-box {
  transition: border-color 0.12s ease, opacity 0.12s ease;
}

/* Chubes manager reuses the same select-mode visuals */
.select-mode .roster-char-item {
  position: relative;
  cursor: pointer;
}

.select-mode .roster-char-item:not(.is-selected) .roster-avatar-box {
  opacity: 0.5;
}

.select-mode .roster-char-item.is-selected .roster-avatar-box {
  opacity: 1;
}

.select-mode .roster-char-item .roster-avatar-box {
  transition: border-color 0.12s ease, opacity 0.12s ease;
}

/* Chubes manager: full 180x214 art, no tile border (a corner badge marks selection).
   Scoped to the psychube grid — the Characters tab keeps the compact bordered tile. */
/* The tile shrinks with its grid column so narrow viewports (where the grid
   drops to minmax(62px, 1fr)) never let a fixed-width tile spill over its
   neighbour. 84px stays the cap on wide layouts. */
#chubes-grid-list .roster-char-item {
  width: 100%;
  max-width: 84px;
  min-width: 0;
}

#chubes-grid-list .roster-avatar-box {
  width: 100%;
  max-width: 84px;
  height: auto;
  aspect-ratio: 180 / 214;
  background: transparent;
}

#chubes-grid-list .roster-avatar-img {
  object-fit: contain;
}

#chubes-grid-list .roster-char-item.is-owned .roster-avatar-box {
  border-color: transparent;
  box-shadow: none;
}

#chubes-grid-list .roster-char-item.is-selected .roster-avatar-box {
  border-color: transparent !important;
  box-shadow: none !important;
  opacity: 1 !important;
  filter: none !important;
}

#chubes-grid-list .roster-char-item.is-selected .roster-avatar-img {
  opacity: 1 !important;
  filter: none !important;
}

#chubes-grid-list .roster-char-item.is-selected .chube-selected-mark {
  display: block;
}

.chube-selected-mark {
  display: none;
  position: absolute;
  top: 16px;
  right: 1px;
  width: 9px;
  height: 9px;
  z-index: 5;
  pointer-events: none;
}

/* Chube setting modal: full art with no border */
#chube-modal .modal-char-preview img {
  width: 84px;
  height: auto;
  aspect-ratio: 180 / 214;
  border: none;
  background: transparent;
  object-fit: contain;
}

/* Bulk apply preview: full art, no border (wins over .bulk-apply-preview img) */
.bulk-apply-preview img.chube-bulk-preview-avatar {
  width: 48px;
  height: auto;
  aspect-ratio: 180 / 214;
  border: none;
  background: transparent;
  object-fit: contain;
}

/* ================= BULK APPLY MODAL ================= */
.bulk-apply-hint {
  margin: 0 0 4px;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  color: #E5E7EB;
}

/* Selected character avatars, so it's clear who is being edited */
.bulk-apply-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 6px 0 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.bulk-apply-preview img {
  width: 30px;
  height: 30px;
  object-fit: cover;
  border: 1px solid #B5B5B3;
  background: #111111;
  display: block;
}

.bulk-apply-preview .bulk-preview-more {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(181, 181, 179, 0.5);
  color: #B5B5B3;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 10px;
  font-weight: 700;
}

.bulk-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.bulk-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.bulk-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.bulk-row-label {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #BFBFBF;
}

/* Value readouts only appear once the field has been touched */
.bulk-row-value:empty {
  display: none;
}

.bulk-row-value {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: #E5E7EB;
}

/* Untouched rows read as inactive until the user picks something */
.bulk-row.is-untouched .bulk-row-label {
  color: #8A8A8A;
}

.bulk-row-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bulk-opt {
  min-width: 34px;
  padding: 5px 9px;
  background: #111111;
  border: 1px solid #676767;
  color: #BFBFBF;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  border-radius: 0;
  transition: background 0.13s ease, border-color 0.13s ease, color 0.13s ease;
}

.bulk-opt:hover {
  border-color: #B5B5B3;
  color: #E5E7EB;
}

.bulk-opt.is-active {
  background: #D05126;
  border-color: #D05126;
  color: #FFFFFF;
}

/* "No change" option reads as a neutral reset */
.bulk-opt.is-none.is-active {
  background: rgba(181, 181, 179, 0.22);
  border-color: #B5B5B3;
  color: #FFFFFF;
}

/* Insight options render as big, evenly-sized icon tiles (like Character Setting) */
.bulk-insight-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.bulk-insight-options .bulk-opt {
  min-width: 0;
  height: 38px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bulk-insight-options .bulk-opt img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  display: block;
}

.bulk-insight-options .bulk-opt.is-active img {
  filter: brightness(1.25) drop-shadow(0 0 3px rgba(255, 255, 255, 0.45));
}

/* Portrait options mirror the same grid rhythm */
#bulk-portrait-options {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

#bulk-portrait-options .bulk-opt {
  min-width: 0;
  height: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
}

/* Ownership buttons are roomier */
#bulk-owned-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

#bulk-owned-options .bulk-opt {
  min-width: 0;
  height: 38px;
  padding: 0 14px;
  font-size: 0.7rem;
}

/* Level / Resonance slider */
.bulk-slider-wrap {
  padding: 2px 0 4px;
}

.bulk-slider {
  width: 100%;
  accent-color: var(--accent-gold);
  cursor: pointer;
}

/* Chube bulk: Amplification renders as an even 5-column grid (like Insight),
   Ownership as two equal columns. */
#chube-bulk-amp-options {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

#chube-bulk-amp-options .bulk-opt {
  min-width: 0;
  height: 38px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#chube-bulk-amp-options .bulk-opt.is-active {
  background: #D05126;
  border-color: #D05126;
  color: #FFFFFF;
}

#chube-bulk-amp-options .bulk-opt.is-max {
  color: #BFBFBF;
}

#chube-bulk-amp-options .bulk-opt.is-max.is-active {
  background: #D05126;
  border-color: #D05126;
  color: #FFFFFF;
}

#chube-bulk-owned-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

#chube-bulk-owned-options .bulk-opt {
  min-width: 0;
  height: 38px;
  padding: 0 14px;
  font-size: 0.7rem;
}

/* The Amplification readout (right side) turns A5-coloured at max */
#chube-bulk-row-amp .bulk-row-value.is-max {
  color: var(--chube-amp-max-color, #DF7526);
}

/* Untouched rows read as inactive until the user picks something */
.bulk-row.is-untouched .bulk-row-label {
  color: #8A8A8A;
}

/* Footer: the bar itself is invisible, only the Apply button shows */
.bulk-apply-footer {
  display: flex;
  justify-content: stretch;
  background: transparent !important;
  border-top: none !important;
  padding: 8px 20px 18px;
}

.bulk-apply-footer .btn-primary {
  flex: 1;
}

.roster-grid {
  padding: 22px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 16px 12px;
  max-height: 60vh;
  overflow-y: auto;
}

.roster-char-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  text-align: center;
  gap: 5px;
}

.roster-avatar-box {
  width: 60px;
  height: 60px;
  border-radius: 0;
  overflow: hidden;
  border: 2px solid transparent;
  transition: all 0.2s;
  position: relative;
  background: #2a2825;
}

.roster-char-item.is-owned .roster-avatar-box {
  border-color: #B5B5B3;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3);
}

.roster-char-item.not-owned .roster-avatar-box {
  opacity: 0.35;
  filter: grayscale(100%);
}

.roster-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.roster-char-name {
  font-size: 0.7rem;
  color: #B5B5B3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 75px;
  font-family: var(--mono-font);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Footer Info / Credits */
.app-footer {
  max-width: 1420px;
  margin: 28px auto 0;
  padding: 16px 24px 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.app-footer p {
  font-family: var(--mono-font);
  font-size: 0.64rem;
  color: #9a8e7f;
  letter-spacing: 0.04em;
  line-height: 1.5;
}

.app-footer a {
  color: inherit;
  text-decoration: underline;
  transition: color 0.15s ease;
}

.app-footer a:hover {
  color: #f6f2ed;
}

/* The hand-drawn "Credits" wordmark doubles as the button that opens the
   credits modal. A soft shadow keeps it readable over the board background. */
.footer-credits-btn {
  align-self: center;
  display: block;
  padding: 0;
  margin: 0 0 6px;
  border: none;
  background: none;
  cursor: pointer;
  line-height: 0;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.55));
  transition: transform 0.18s ease, filter 0.18s ease;
}

.footer-credits-btn img {
  display: block;
  width: 150px;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

.footer-credits-btn:hover {
  transform: translateY(-1px);
  filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.65)) brightness(1.08);
}

.footer-credits-btn:focus-visible {
  outline: 2px solid #ED7D31;
  outline-offset: 4px;
}

/* ---- Credits modal ---- */

#credits-modal {
  z-index: 1150;
}

.credits-modal-card {
  max-width: 720px;
  width: 100%;
  height: min(84vh, 780px);
}

.credits-modal-body {
  overflow-y: auto;
  gap: 0;
  padding: 6px 0 10px;
}

.credits-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

/* One credit: a link icon, the name, and the note under it. */
.credit-entry {
  padding: 14px 24px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.credit-entry:last-child {
  border-bottom: none;
}

.credit-head {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.credit-link-icon {
  flex: none;
  width: 18px;
  height: 18px;
  fill: #7ea2e8;
  opacity: 0.9;
}

.credit-name {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  color: #ECE5D9;
  text-decoration: none;
  overflow-wrap: anywhere;
}

a.credit-name:hover {
  color: #ED7D31;
  text-decoration: underline;
}

.credit-desc {
  margin: 5px 0 0 27px;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.74rem;
  line-height: 1.55;
  color: #9d968c;
}

/* Chess Pieces Container */
.chess-pieces-container {
  display: inline-flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 8px;
  padding: 0;
  background: transparent;
  border: none;
  line-height: 1;
}

.chess-pieces-container.pos-top {
  margin-left: auto;
}

.chess-pieces-container.pos-bottom {
  display: flex;
  margin-top: 14px;
  margin-left: auto;
  margin-right: 0;
  width: fit-content;
  justify-content: flex-end;
}

.chess-piece-wrapper {
  position: relative;
  border-radius: 0;
  flex-shrink: 0;
  cursor: pointer;
}

.chess-piece-wrapper[data-piece="Rook"] {
  transform: translateX(1px);
}

.chess-piece-wrapper[data-piece="Knight"] {
  transform: translateX(2px);
}

.chess-piece-wrapper[data-piece="Bishop"] {
  transform: translateX(-1px);
}

.chess-piece-empty {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom center;
  display: block;
  z-index: 1;
}

/* Fill crop mask: uses overflow hidden instead of clip-path because
   html2canvas (used for PNG export) does not support clip-path.
   Inline `top` (insetTop%) + bottom:0 give the reveal height. */
.chess-piece-fill-mask {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  z-index: 2;
  pointer-events: none;
}

.chess-piece-filled {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  object-fit: contain;
  object-position: bottom center;
  display: block;
}

/* The fade lives on the piece art rather than on .chess-pieces-container: an
   opacity below 1 on the container creates a stacking context, which would trap
   the hover tooltip underneath the character cards further down the board. */
.chess-piece-empty,
.chess-piece-filled {
  opacity: var(--chess-piece-opacity, 1);
  transition: opacity 0.2s ease;
}

.chess-piece-tooltip {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background-color: rgba(17, 17, 17, 0.97);
  background-image: none;
  color: rgba(244, 239, 233, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 6px 12px;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.55;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  z-index: 250;
  border-radius: 0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.chess-pieces-container.pos-bottom .chess-piece-tooltip {
  top: auto;
  bottom: calc(100% + 6px);
}

/* The tooltip is trapped inside the wrapper's stacking context (the Rook/Knight/
   Bishop transforms create one), so raising the wrapper on hover is what lifts
   the tooltip above the character cards that follow it in the DOM. */
.chess-piece-wrapper:hover {
  z-index: 1000;
}

.chess-piece-wrapper:hover .chess-piece-tooltip {
  opacity: 1;
  visibility: visible;
}

/* ---- Export PNG modal ----
   Uses the same shell as the other modals (archetype card, dark header with the
   orange hairline, footer with a single accent action). The preview is the only
   thing that differs: a scrollable dark stage that holds the generated image. */

#export-modal {
  z-index: 1100;
}

.export-modal-card {
  max-width: 720px;
  width: 100%;
  height: min(88vh, 860px);
}

.export-modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  /* The preview owns the remaining height instead of the shared 70vh cap. */
  max-height: none;
  overflow: hidden;
  text-align: left;
}

.export-help-tip {
  flex: none;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.72rem;
  line-height: 1.5;
  color: #CFC7BA;
  background: rgba(215, 177, 85, 0.1);
  border: 1px solid rgba(215, 177, 85, 0.32);
  border-left: 3px solid #D7B155;
  padding: 9px 12px;
}

.export-help-tip strong {
  color: #EDD9A3;
  font-weight: 700;
}

/* The stage keeps the board's own proportions without stealing the whole modal. */
.export-preview-container {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.35)),
    #141312;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  -webkit-overflow-scrolling: touch;
}

.export-preview-container img {
  max-width: 100%;
  height: auto;
  display: block;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.55);
  user-select: auto !important;
  -webkit-user-select: auto !important;
  -webkit-touch-callout: default !important;
}

.export-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  /* Same quiet footer as the other archetype modals. */
  background: transparent;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 14px 22px;
}

.export-modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.export-modal-footer .btn {
  height: 32px;
  padding: 0 14px;
  border-radius: 0;
  font-size: 0.64rem;
  letter-spacing: 0.1em;
}

.export-modal-footer #export-modal-btn-download {
  background: #D05126;
  border: 1px solid #D05126;
  color: #FFFFFF;
}

.export-modal-footer #export-modal-btn-download:hover {
  background: #B55829;
  border-color: #B55829;
  color: #FFFFFF;
}

/* ================= RESPONSIVE TOOLBAR ================= */

/* Below 1260px the secondary row collapses into the Menu drawer. Every control
   in the header and in the drawer shares one height per breakpoint, so no
   button looks hand-placed next to its neighbours. */
@media screen and (max-width: 1260px) {
  :root {
    --toolbar-h: 32px;
  }

  /* Menu keeps its label at every width: it is the only way into the drawer. */
  .btn-tools-toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: var(--toolbar-h);
    padding: 0 12px;
    border: 1px solid #EBE3D7;
    font-size: 0.64rem;
    letter-spacing: 0.08em;
    cursor: pointer;
  }

  /* The caret glyph is swapped by the toggle handler (▾ closed / ▴ open). */
  .btn-tools-toggle .toggle-icon {
    font-size: 0.6rem;
    line-height: 1;
  }

  /* The header switcher hands over to the one inside the drawer. */
  .header-stats-row .lang-switcher-header {
    display: none;
  }

  .tools-lang-group .lang-switcher {
    display: inline-flex;
  }

  .tools-lang-group {
    position: static;
    right: auto;
    top: auto;
  }

  /* ---- Drawer shell ---- */
  .header-secondary-tools {
    display: none;
    width: 100%;
    max-width: 100%;
    padding-top: 0;
    border-top: none;
    box-sizing: border-box;
    overflow: hidden;
    grid-template-columns: none;
  }

  .top-controls.tools-open .header-secondary-tools {
    display: flex;
    flex-direction: column;
    gap: 6px;
    animation: toolsDrawerIn 0.18s ease-out;
  }

  /* Row 1: ownership + rarity, sitting right under the search group on the
     same centre line. No divider above it: the filters read as part of the
     search block, and the hairline moves down to separate the tool row. */
  .tools-filters-group {
    order: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
    margin: 0;
    padding-top: 2px;
    position: static;
  }

  .filter-btn-group {
    height: var(--toolbar-h);
    flex: 0 0 auto;
  }

  .filter-btn {
    padding: 0 10px;
    font-size: 0.64rem;
  }

  /* Row 2: display tools, guide tools, then language + JSON on the right. */
  .tools-buttons-row {
    order: 2;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    width: 100%;
    min-width: 0;
    padding-top: 6px;
    border-top: 1px dashed rgba(17, 15, 12, 0.15);
  }

  .tools-config-group,
  .tools-data-group {
    display: flex;
    align-items: center;
    gap: 6px;
    width: auto;
    margin: 0;
    justify-self: auto;
    min-width: 0;
  }

  /* Display settings and guide content are different jobs; a hairline splits
     the six icons into two readable sets. */
  .tools-data-group {
    padding-left: 12px;
    border-left: 1px solid rgba(181, 181, 179, 0.28);
  }

  /* Language switcher closes the tool row: the same hairline that splits
     display from guide also introduces it. JSON moved to the search cluster,
     so it no longer needs a rule of its own. */
  .tools-lang-group {
    display: flex;
    align-items: center;
    gap: 8px;
    width: auto;
    margin-left: 0;
    padding-left: 12px;
    border-left: 1px solid rgba(181, 181, 179, 0.28);
    justify-self: auto;
    min-width: 0;
  }

  .tools-config-group .btn,
  .tools-data-group .btn {
    height: var(--toolbar-h);
    padding: 0 10px;
    font-size: 0.64rem;
    letter-spacing: 0.06em;
    white-space: nowrap;
    flex: 0 0 auto;
    box-sizing: border-box;
  }

  /* Icon-only buttons: square, so the row reads as one set of tools. */
  .tools-buttons-row .btn-icon-tool {
    width: var(--toolbar-h);
    min-width: var(--toolbar-h);
    height: var(--toolbar-h);
    padding: 0;
    gap: 0;
    flex: 0 0 auto;
  }

  .tools-buttons-row .btn-icon-tool > span {
    display: none;
  }

  .tools-buttons-row .btn-tool-icon,
  .tools-buttons-row .btn-team-icon {
    width: 17px;
    height: 17px;
  }

  .tools-lang-group .lang-switcher {
    height: var(--toolbar-h);
  }

  .tools-lang-group .lang-btn {
    padding: 0 10px;
    font-size: 0.64rem;
  }
}

/* Wide tablets have room for the labels, so the drawer keeps the desktop
   reading of the tool buttons; squares only take over when they must. With the
   labels back the whole set fits, so it is centred under the filter row. */
@media screen and (min-width: 1001px) and (max-width: 1260px) {
  .tools-buttons-row {
    justify-content: center;
  }

  .tools-buttons-row .btn-icon-tool {
    width: auto;
    padding: 0 12px;
    gap: 6px;
  }

  .tools-buttons-row .btn-icon-tool > span {
    display: inline;
  }
}

@media screen and (max-width: 1260px) and (min-width: 769px) {
  .header-primary-bar {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  }

  .header-stats-row {
    gap: 8px;
    min-width: 0;
    flex-wrap: nowrap;
  }

  .lang-btn {
    padding: 0 8px;
    font-size: 0.64rem;
    letter-spacing: 0.05em;
  }

  .stat-badge {
    height: var(--toolbar-h);
    font-size: 0.62rem;
    padding: 0 8px;
    letter-spacing: 0.04em;
  }

  #btn-manage-all,
  #btn-chubes,
  #btn-json,
  #btn-export-image {
    height: var(--toolbar-h);
    padding: 0 10px;
    font-size: 0.62rem;
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: 0.04em;
  }

  .header-actions-row .search-input {
    height: var(--toolbar-h);
    font-size: 0.68rem;
  }
}

/* Narrow tablet / small-laptop: the centred action row no longer fits beside
   the stat badge in a single line, so it overflows its grid column and lands on
   top of the badge and the Export PNG button. Give the actions their own
   full-width row so nothing collides. The search then stretches across that
   row, so everything under it — filters included — hangs off its left edge. */
@media screen and (max-width: 1000px) and (min-width: 769px) {
  .header-primary-bar {
    grid-template-columns: auto 1fr;
    row-gap: 6px;
  }

  .header-actions-row {
    grid-column: 1 / span 2;
    grid-row: 2;
    width: 100%;
    max-width: 100%;
    justify-self: stretch;
    justify-content: flex-start;
    margin: 0;
  }

  .header-actions-row .header-search-wrap {
    flex: 1 1 auto;
    min-width: 0;
  }

  .header-actions-row .search-input {
    width: 100%;
  }

  /* The filter row starts at the same x as the stretched search field. */
  .tools-filters-group {
    justify-content: flex-start;
  }
}

/* Responsive Mobile-Only UI adjustments (phones and small screens) */
@media screen and (max-width: 768px) {
  :root {
    --toolbar-h: 30px;
  }

  body {
    padding-bottom: 40px;
  }

  /* Top Toolbar adjustments. The legacy toolbar floats as a card; the global
     navbar is a full-bleed top bar and keeps its own edges at every width. */
  .top-controls:not(.global-navbar) {
    margin: 8px auto 0;
    width: calc(100% - 16px);
    max-width: calc(100% - 16px);
    padding: 8px 10px;
    gap: 8px;
    border-radius: 12px 0 12px 0;
    box-shadow: 0 4px 16px rgba(16, 13, 10, 0.06);
    box-sizing: border-box;
    overflow: hidden;
  }

  .header-primary-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 10px;
    align-items: center;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Row 1, Left: Brand */
  .header-brand-row {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    align-items: center;
    width: auto;
    min-width: 0;
    overflow: hidden;
  }

  .app-brand {
    gap: 6px;
  }

  .app-brand-icon-box {
    width: 32px;
    height: 32px;
  }

  .app-brand-icon {
    width: 24px;
    height: 24px;
  }

  .app-logo-img {
    height: 24px;
  }

  /* Row 1, Right: roster stat + Menu. The Menu label is kept (it is the only
     entry to the drawer) but shortened to its icon on very small phones. */
  .header-stats-row {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-end;
    width: auto;
    flex-wrap: nowrap;
  }

  .stat-badge {
    height: var(--toolbar-h);
    font-size: 0.58rem;
    padding: 0 7px;
    letter-spacing: 0.04em;
  }

  .btn-tools-toggle {
    height: var(--toolbar-h);
    padding: 0 9px;
    font-size: 0.6rem;
    letter-spacing: 0.06em;
  }

  /* Row 2: Search, Manage, Export PNG */
  .header-actions-row {
    grid-column: 1 / span 2;
    grid-row: 2;
    width: 100%;
    max-width: 100%;
    display: flex;
    gap: 6px;
    align-items: center;
    box-sizing: border-box;
    min-width: 0;
    overflow: hidden;
  }

  .header-actions-row .header-search-wrap {
    flex: 1 1 auto;
    /* Keep the search field usable: the action buttons would otherwise
       squeeze it down to ~73px on a 375px phone. */
    min-width: 96px;
    display: flex;
  }

  .header-actions-row .search-input {
    width: 100%;
    height: var(--toolbar-h);
    font-size: 0.66rem;
    padding: 0 8px;
    box-sizing: border-box;
  }

  #btn-manage-all,
  #btn-chubes,
  #btn-json,
  #btn-export-image {
    height: var(--toolbar-h);
    padding: 0 8px;
    font-size: 0.58rem;
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: 0.03em;
  }

  .stat-badge-tooltip {
    right: 0;
    left: auto;
    transform: none;
  }

  /* ---- Phone drawer ---- */
  .header-secondary-tools {
    display: none;
    width: 100%;
    max-width: 100%;
    padding-top: 0;
    border-top: none;
    box-sizing: border-box;
    overflow: hidden;
  }

  .top-controls.tools-open .header-secondary-tools {
    display: flex;
    flex-direction: column;
    gap: 6px;
    animation: toolsDrawerIn 0.18s ease-out;
  }

  /* Filters stay under the stretched search row and hang off its left edge,
     matching where the search field itself starts. */
  .tools-filters-group {
    order: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    width: 100%;
    margin: 0;
    padding-top: 2px;
    position: static;
    box-sizing: border-box;
    min-width: 0;
  }

  .filter-btn-group {
    height: var(--toolbar-h);
    flex: 0 0 auto;
  }

  /* The ownership/rarity chips used to shrink to 8px padding here. They now
     live in the mainboard sub-toolbar and keep their normal size — see
     `.mainboard-toolbar .filter-btn`, which wraps instead of shrinking. */
  /* Tools on one row; the language switcher wraps below when it must. */
  .tools-buttons-row {
    order: 2;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px;
    width: 100%;
    min-width: 0;
    padding-top: 6px;
    border-top: 1px dashed rgba(17, 15, 12, 0.15);
  }

  .tools-config-group,
  .tools-data-group {
    display: flex;
    align-items: center;
    gap: 5px;
    width: auto;
    margin: 0;
    justify-self: auto;
    min-width: 0;
  }

  .tools-data-group {
    padding-left: 10px;
    border-left: 1px solid rgba(181, 181, 179, 0.28);
  }

  /* Language switcher keeps the hairline that separates it from the guide
     tools; JSON lives in the search cluster now. */
  .tools-lang-group {
    order: 3;
    display: flex;
    align-items: center;
    gap: 8px;
    width: auto;
    margin: 0;
    padding-left: 12px;
    border-left: 1px solid rgba(181, 181, 179, 0.28);
    justify-content: flex-start;
    box-sizing: border-box;
  }

  /* Square icon buttons: labels stay in the DOM for i18n and screen readers. */
  .tools-buttons-row .btn-icon-tool {
    flex: 0 0 auto;
    width: var(--toolbar-h);
    height: var(--toolbar-h);
    min-width: var(--toolbar-h);
    padding: 0;
    gap: 0;
    box-sizing: border-box;
  }

  .tools-buttons-row .btn-icon-tool > span {
    display: none;
  }

  .tools-buttons-row .btn-tool-icon,
  .tools-buttons-row .btn-team-icon {
    width: 16px;
    height: 16px;
  }

  .tools-lang-group .lang-switcher {
    height: var(--toolbar-h);
  }

  .tools-lang-group .lang-btn {
    padding: 0 9px;
    font-size: 0.6rem;
  }

  .btn {
    padding: 7px 8px;
    font-size: 0.62rem;
    letter-spacing: 0.05em;
  }

  /* Showcase Board adjustments */
  .showcase-wrapper {
    margin: 14px auto 0;
    padding: 0 8px;
  }

  .showcase-board {
    padding: 12px 10px 10px;
  }

  .showcase-board::before {
    top: 6px;
    left: 6px;
    width: 20px;
    height: 20px;
  }

  .showcase-board::after {
    right: 6px;
    bottom: 6px;
    width: 20px;
    height: 20px;
  }

  .board-header {
    margin-bottom: var(--board-header-spacing, 12px);
    padding: 4px 4px 10px;
  }

  .board-title {
    font-size: 0.7rem;
    letter-spacing: 0.18em;
  }

  .tier-row {
    grid-template-columns: 56px 1fr;
    gap: calc(8px * var(--char-card-scale, 1));
    padding: calc(6px * var(--char-card-scale, 1)) calc(4px * var(--char-card-scale, 1));
    margin-bottom: var(--tier-row-spacing, 8px);
    min-height: calc(60px * var(--char-card-scale, 1));
  }

  .tier-label {
    font-size: 0.62rem;
    letter-spacing: 0.1em;
    padding-top: 0;
    text-align: center;
    word-break: break-word;
  }

  .tier-content {
    gap: calc(8px * var(--char-card-scale, 1)) calc(4px * var(--char-card-scale, 1));
    min-height: calc(48px * var(--char-card-scale, 1));
  }

  /* Character Card scaling for small screens */
  .char-card {
    width: calc(44px * var(--char-card-scale, 1));
  }

  /* Phone tooltips: keep them readable and inside the viewport instead of
     spilling past the right edge of narrow screens. */
  .char-tooltip {
    min-width: 0;
    width: max-content;
    max-width: min(200px, calc(100vw - 24px));
  }

  .char-tooltip .ct-name {
    font-size: 14px;
  }

  .char-tooltip .ct-head,
  .char-tooltip .ct-body {
    padding-left: 10px;
    padding-right: 10px;
  }

  /* Stat & chess tooltips: let them size to content (not the tiny parent box)
     and only wrap when they would exceed the viewport. */
  .stat-badge-tooltip,
  .chess-piece-tooltip {
    width: max-content;
    max-width: calc(100vw - 24px);
    white-space: nowrap;
  }

  .char-top-info {
    width: calc(44px * var(--char-card-scale, 1));
    min-height: calc(12px * var(--char-card-scale, 1));
  }

  .char-unowned-name {
    font-size: calc(0.44rem * var(--char-card-scale, 1));
    letter-spacing: 0;
  }

  .badge-resonance {
    font-size: calc(0.52rem * var(--char-card-scale, 1));
  }

  .badge-insight-img {
    width: calc(10px * var(--char-card-scale, 1));
    height: calc(10px * var(--char-card-scale, 1));
  }

  .badge-level-text {
    font-size: calc(0.5rem * var(--char-card-scale, 1));
  }

  .char-avatar-box {
    width: calc(44px * var(--char-card-scale, 1));
    height: calc(44px * var(--char-card-scale, 1));
  }

  /* Chube art keeps its own (taller) aspect ratio on phones */
  .chube-card .char-avatar-box {
    width: calc(44px * var(--char-card-scale, 1));
    height: auto;
    aspect-ratio: 180 / 214;
  }

  .char-info-overlay {
    max-width: calc(100% - 2px);
    padding: 1px 3px;
  }

  .char-rarity-line {
    width: calc(100% + 4px);
    margin-left: -2px;
    margin-right: -2px;
    height: calc(2.5px * var(--char-card-scale, 1));
  }

  .char-portrait-bar-below {
    width: calc(100% + 2px);
    height: calc(2.5px * var(--char-card-scale, 1));
  }

  .char-bottom-euphoria {
    width: calc(44px * var(--char-card-scale, 1));
  }

  .badge-euphoria-bottom {
    font-size: calc(0.44rem * var(--char-card-scale, 1));
  }

  /* Modals Mobile Adaptation */
  .modal-backdrop {
    padding: 12px 8px;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
  }

  .modal-card {
    width: 100%;
    max-width: 100% !important;
    max-height: 90vh;
    max-height: 90dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: auto 0;
  }

  .modal-header {
    padding: 12px 14px;
    flex-shrink: 0;
  }

  .modal-header h2 {
    font-size: 1rem;
  }

  .modal-char-preview img:not(.btn-favourite-img) {
    width: 40px;
    height: 40px;
  }

  .modal-char-title {
    font-size: 1rem;
  }

  .modal-body {
    padding: 12px 14px;
    gap: 12px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
    max-height: none;
  }

  .pattern-help-box {
    font-size: 0.6rem;
    padding: 6px 8px;
  }

  .modal-footer {
    padding: 10px 14px;
    flex-shrink: 0;
  }

  /* Character Roster Manager Modal Mobile Adaptation */
  .modal-card-large {
    max-height: 92vh;
    max-height: 92dvh;
  }

  .export-help-tip {
    font-size: 0.62rem;
    padding: 8px 10px;
    border-left-width: 2px;
  }

  .export-preview-container {
    padding: 6px;
  }

  .export-modal-card {
    height: min(92vh, 900px);
    max-height: 92dvh;
  }

  .export-modal-footer {
    gap: 6px;
  }

  .export-modal-footer .btn {
    height: 30px;
    padding: 0 10px;
    font-size: 0.6rem;
  }

  .export-modal-actions {
    gap: 6px;
  }

  .roster-toolbar {
    padding: 10px 12px;
    gap: 8px;
    flex-direction: column;
    align-items: stretch;
  }

  .roster-toolbar-left {
    width: 100%;
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    align-items: center;
  }

  .roster-toolbar-left .search-input {
    flex: 1;
    min-width: 0;
    width: auto;
    height: 28px;
    font-size: 0.68rem;
    padding: 4px 8px;
  }

  #roster-filter-rarity-group {
    height: 28px;
    flex-shrink: 0;
  }

  #roster-filter-rarity-group .filter-btn {
    padding: 0 6px;
    font-size: 0.58rem;
  }

  .roster-grid {
    padding: 12px;
    grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
    gap: 10px 8px;
    max-height: 55vh;
  }

  .roster-avatar-box {
    width: 52px;
    height: 52px;
  }

  .roster-char-name {
    font-size: 0.58rem;
    max-width: 60px;
  }

  /* Listing Modal Mobile Adaptation */
  .listing-tier-item {
    gap: 6px;
    padding: 6px 8px;
  }

  .listing-tier-header-row {
    gap: 6px;
  }

  /* Section headers with inline action buttons must not squeeze the label */
  .setting-label-row {
    flex-wrap: wrap;
    row-gap: 8px;
  }

  .setting-label-row .setting-label {
    flex: 1 1 100%;
  }

  .setting-label-row > div {
    width: 100%;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
  }

  .setting-label-row .btn-sm {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    padding: 6px 8px;
    font-size: 0.58rem;
    letter-spacing: 0.03em;
    line-height: 1.15;
    text-align: center;
  }

  .listing-tier-label-input {
    width: 80px;
    font-size: 0.64rem;
    padding: 4px 6px;
  }

  .listing-tier-color-input {
    width: 24px;
    height: 24px;
  }

  .listing-tier-select {
    min-width: 100px;
    font-size: 0.6rem;
    padding: 4px 6px;
  }

  /* Customize Modal Mobile Adaptation */
  #customize-modal .modal-card {
    max-width: 100%;
  }

  /* Options Modal Mobile Adaptation */
  #options-modal .modal-card {
    max-width: 100%;
  }

  #options-modal .archetype-modal-body,
  #customize-modal .modal-body {
    max-height: 65vh;
  }

  /* App footer */
  .app-footer {
    margin: 18px auto 0;
    padding: 10px 12px 0;
  }

  .footer-credits-btn img {
    width: 118px;
  }

  .credit-entry {
    padding: 12px 16px 14px;
  }

  .credit-name {
    font-size: 0.84rem;
  }

  .credit-desc {
    font-size: 0.7rem;
    margin-left: 0;
  }

  .app-footer p {
    font-size: 0.58rem;
  }
}

/* Small phones: the brand, the crew badge and the Menu button share one row.
   The badge drops its word and the Menu drops its label so nothing is clipped. */
@media screen and (max-width: 480px) {
  .stat-badge {
    padding: 0 6px;
    gap: 4px;
  }

  .stat-badge > span[data-i18n="toolbar.crew"] {
    display: none;
  }

  .roster-stat-icon {
    width: 16px;
    height: 16px;
  }

  .btn-tools-toggle {
    width: var(--toolbar-h);
    min-width: var(--toolbar-h);
    padding: 0;
    gap: 0;
  }

  .btn-tools-toggle .toggle-text {
    display: none;
  }

  .btn-tools-toggle .toggle-icon {
    font-size: 0.7rem;
  }
}

/* ================= TEAM BUILDING ================= */

/* Toolbar entry: a labelled button in the Menu drawer's data group, so it
   borrows the shared .btn metrics and only needs icon sizing. */
.btn-team {
  flex-shrink: 0;
}

.btn-team-icon {
  width: 17px;
  height: 17px;
  object-fit: contain;
  display: block;
}

@media screen and (max-width: 1260px) {
  .btn-team-icon {
    width: 15px;
    height: 15px;
  }
}

@media screen and (max-width: 768px) {
  .btn-team-icon {
    width: 14px;
    height: 14px;
  }
}

/* Nested team pickers and the presets list open above the Team Building modal */
.team-nested-backdrop {
  z-index: 1100;
}

#team-modal {
  z-index: 1000;
}

.team-modal-card {
  /* --team-modal-max-width is written by applyTeamColumns() so the 3-column
     layout can use the extra room a wide screen has to offer. */
  max-width: var(--team-modal-max-width, 1040px);
  width: 100%;
  /* Fixed height keeps the two panes stable however many teams exist */
  height: min(88vh, 820px);
}

/* Teams-per-row selector (3 / 2) — sits beside the Presets button.
   `flex: 0 0 32px` gives both digits the same width, and the divider is drawn
   between the *visible* buttons only (see the rule below). */
.team-columns-group .filter-btn {
  flex: 0 0 32px;
  width: 32px;
  padding: 0 !important;
  font-size: 0.68rem;
  text-align: center;
  justify-content: center;
  /* The base rule draws a divider on the right of every button; here it is
     moved to the left so the last visible cell has no trailing line. */
  border-right: none;
}

/* The hidden "1" is still the last child, so `.filter-btn:last-child` would
   leave a trailing divider on "2". Draw the divider on every button that has
   one before it instead. */
.team-columns-group .filter-btn + .filter-btn {
  border-left: 1px solid #B5B5B3;
}

.team-columns-group .filter-btn[hidden] {
  display: none;
}

.team-columns-group[hidden] {
  display: none;
}

.team-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.team-unowned-toggle.active {
  background: rgba(208, 81, 38, 0.22);
  border-color: #ED7D31;
  color: #FFFFFF;
}

.team-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
  /* Split between the scrolling team list (top) and the pinned strip (bottom).
     --team-strip-ratio is written by the drag handle. */
  --team-strip-ratio: 0.32;
}

/* ---- Team list: two cards per row, so many teams stay surveyable ---- */
.team-list-wrap {
  flex: 1 1 auto;
  min-height: 96px;
  overflow-y: auto;
}

.team-list {
  display: grid;
  /* --team-columns is written by applyTeamColumns() (1 – 3, viewport-clamped) */
  grid-template-columns: repeat(var(--team-columns, 2), minmax(0, 1fr));
  /* Content-sized rows: without this the grid squeezes every row into the
     available height instead of letting the parent scroll. */
  grid-auto-rows: max-content;
  gap: 12px;
  padding: 16px 18px;
  align-content: start;
}

.team-card {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--team-card-bg);
  padding: 10px 12px 12px;
  border-radius: 0;
  box-sizing: border-box;
}

/* Drag to reorder: the handle is the only drag source. */
.team-drag-handle {
  flex: none;
  cursor: grab;
  color: rgba(50, 60, 52, 0.6);
  font-size: 13px;
  line-height: 1;
  padding: 0 2px;
  user-select: none;
  touch-action: none;
}

.team-drag-handle:hover {
  color: #ED7D31;
}

.team-drag-handle:active {
  cursor: grabbing;
}

.team-drag-handle:focus-visible {
  outline: 2px solid #ED7D31;
  outline-offset: 2px;
}

.team-card.is-dragging {
  opacity: 0.45;
}

.team-card.drop-above::before,
.team-card.drop-below::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  background: #ED7D31;
  pointer-events: none;
  z-index: 2;
}

.team-card.drop-above::before {
  top: -2px;
}

.team-card.drop-below::after {
  bottom: -2px;
}

/* No "currently edited" highlight: every team is edited in place. */

.team-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

/* Renameable team title — reads as a label until hovered/focused.
   Dark ink, because the card now carries a light gradient. */
.team-name-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 1px solid transparent;
  color: #323C34;
  font-family: var(--mono-font);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 3px 6px;
  border-radius: 0;
  transition: border-color 0.15s ease, background 0.15s ease;
  text-overflow: ellipsis;
}

.team-name-input:hover {
  border-color: rgba(50, 60, 52, 0.35);
}

.team-name-input:focus {
  outline: none;
  border-color: #ED7D31;
  background: rgba(255, 255, 255, 0.55);
}

.btn-team-del {
  background: transparent;
  border: 1px solid rgba(50, 60, 52, 0.35);
  color: #323C34;
  font-size: 1rem;
  line-height: 1;
  width: 22px;
  height: 22px;
  cursor: pointer;
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.btn-team-del:hover {
  border-color: #D05126;
  color: #FFFFFF;
  background: #D05126;
}

.team-slots {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

/* One slot = portrait block + psychube block. The two are SEPARATE siblings:
   hovering the character frames the character only, never the pair. */
.team-slot {
  position: relative;
  display: flex;
  align-items: stretch;
  aspect-ratio: 3 / 2;
  min-width: 0;
}

.team-slot-char {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  border-radius: 0;
  display: flex;
  align-items: stretch;
  gap: 0;
  text-align: left;
  transition: border-color 0.15s ease;
}

.team-slot-char:focus-visible {
  outline: 2px solid #ED7D31;
  outline-offset: 2px;
}

/* The frame lives on the button, so the hover ring stops at the portrait */
.team-slot.is-filled .team-slot-char {
  border-color: #454545;
}

.team-slot.is-filled .team-slot-char:hover {
  border-color: #ED7D31;
}

/* Portrait half of the slot */
.team-slot-portrait {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  background: #0f0e0c;
}

.team-slot-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.team-slot-portrait.is-unowned .team-slot-img {
  opacity: var(--unowned-char-opacity, 0.35);
  filter: saturate(0.82) contrast(1.05) brightness(0.9);
}

/* Afflatus emblem in the portrait's top-left corner */
.team-slot-afflatus {
  position: absolute;
  top: 0;
  left: 0;
  height: 38%;
  aspect-ratio: 74 / 118;
  display: flex;
  pointer-events: none;
  z-index: 2;
}

.team-slot-afflatus img {
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
}

/* Insight + level band across the portrait's bottom */
.team-slot-meta {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 3px 4px 5px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0.28) 70%, rgba(0, 0, 0, 0));
  pointer-events: none;
  z-index: 2;
}

.team-slot-insight {
  width: 15px;
  height: 15px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}

.team-slot-level {
  font-family: var(--mono-font);
  font-size: 0.82rem;
  font-weight: 700;
  color: #FFFFFF;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.95);
  white-space: nowrap;
}

/* Portrait tier line: two pixels of dashes, inset from both edges and sitting
   inside the portrait just above its bottom edge. Only the team list renders it
   — presets have their own markup and stay untouched. */
.team-slot-portrait-bar {
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: 2px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  height: 2px;
  z-index: 3;
  pointer-events: none;
}

.team-slot-portrait-bar .portrait-dash {
  height: 100%;
  min-width: 0;
}

/* Psychube block: a sibling of the portrait, not part of it. No resting frame;
   the red ring on hover is what tells the two blocks apart. The art keeps its
   native 180 x 214 ratio and sits at the bottom of the slot — never stretched. */
.team-slot-chube {
  flex: 0 0 33.3%;
  min-width: 0;
  align-self: flex-end;
  aspect-ratio: 180 / 214;
  border: 1px solid transparent;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.team-slot-chube:hover {
  border-color: #ED7D31;
}

.team-slot-chube img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Unowned psychube dims like an unowned character portrait (shared slider).
   Two classes deep so it outranks `.team-slot-chube img`. */
.team-slot-chube.is-unowned img {
  opacity: var(--unowned-char-opacity, 0.35);
}

.team-slot-chube-plus {
  font-size: 1.05rem;
  /* Dark ink: the plus sits on the card's light gradient, not on portrait art */
  color: #4E5650;
  line-height: 1;
  transition: color 0.15s ease;
}

/* Only the psychube block lights its own "+" — the two blocks stay independent */
.team-slot-chube:hover .team-slot-chube-plus {
  color: #ED7D31;
}

/* Duplicate marker, styled to stand out against portrait art.
   Sits inside .team-slot-char, which is now exactly the portrait box, in the
   top-right corner clear of the afflatus emblem. */
/* Used_icon.png already has its own frame, so these carry no border, background
   or padding of their own — anything extra would show as a second ring. */
.team-slot-used {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 17px;
  height: 17px;
  object-fit: contain;
  z-index: 4;
  pointer-events: none;
}

/* Empty slot placeholder */
.team-slot-plus {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: #B5B5B3;
  border: 1px dashed rgba(181, 181, 179, 0.4);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.team-slot-char:hover .team-slot-plus {
  color: #ED7D31;
  border-color: #ED7D31;
}

/* "Create your own team" affordance */
.team-add-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 96px;
  border: 1px dashed rgba(181, 181, 179, 0.4);
  background: rgba(0, 0, 0, 0.25);
  color: #B5B5B3;
  cursor: pointer;
  font-family: var(--mono-font);
  transition: border-color 0.15s ease, color 0.15s ease;
  width: 100%;
}

.team-add-card:hover {
  border-color: #ED7D31;
  color: #ED7D31;
}

.team-add-plus {
  font-size: 1.4rem;
  line-height: 1;
}

.team-add-label {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  text-align: center;
}

/* ---- Team Building PNG export ----
   An offscreen copy of the team grid, always three cards wide so the exported
   image matches the desktop layout even when captured on a phone. The desktop
   values are restated here because the mobile media queries below cannot win
   against this two-class specificity. The width is set by exportTeamsPng()
   from TEAM_MODAL_MAX_WIDTH[3]. */
.team-export-sheet {
  position: fixed;
  top: 0;
  left: -20000px;
  background: #1b1613 url("images/background.png") center / cover no-repeat;
  pointer-events: none;
  z-index: -1;
}

.team-export-sheet .team-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 16px 18px;
}

.team-export-sheet .team-card { padding: 10px 12px 12px; }
.team-export-sheet .team-card-head { margin-bottom: 8px; }
.team-export-sheet .team-name-input,
.team-export-sheet .team-name-text {
  font-family: var(--mono-font);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #323C34;
  line-height: 1.4;
  padding: 3px 6px;
  display: inline-block;
  overflow: visible;
  white-space: nowrap;
}
.team-export-sheet .team-drag-handle,
.team-export-sheet .btn-team-del,
.team-export-sheet .btn-team-share,
.team-export-sheet .btn-team-recommend {
  display: none !important;
}
.team-export-sheet .team-slots { gap: 18px; }
.team-export-sheet .team-slot-meta { gap: 4px; padding: 3px 4px 5px; }
.team-export-sheet .team-slot-insight { width: 15px; height: 15px; }
.team-export-sheet .team-slot-level { font-size: 0.82rem; }
.team-export-sheet .team-slot-afflatus { height: 38%; }
.team-export-sheet .team-slot-chube-plus { font-size: 1.05rem; }
.team-export-sheet .team-slot-plus { font-size: 1.5rem; }
.team-export-sheet .team-slot-used { top: 2px; right: 2px; width: 17px; height: 17px; }

.team-export-unused {
  padding: 12px 18px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.22);
}

.team-export-unused-head {
  margin-bottom: 10px;
}

.team-export-unused-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 8px;
}

.team-export-item:focus-visible {
  outline: 2px solid #ED7D31;
  outline-offset: -2px;
}

/* ---- Drag handle between the list and the unused strip ---- */
.team-strip-resizer {
  flex: 0 0 auto;
  height: 10px;
  cursor: row-resize;
  background: rgba(255, 255, 255, 0.03);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
  touch-action: none;
}

.team-strip-resizer::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 42px;
  height: 2px;
  background: #6a6a68;
  transition: background 0.15s ease;
}

.team-strip-resizer:hover::after,
.team-strip-resizer.is-dragging::after {
  background: #ED7D31;
}

.team-strip-resizer:focus-visible {
  outline: 2px solid #ED7D31;
  outline-offset: -2px;
}

/* While dragging, stop the cursor flickering over child elements */
body.team-resizing,
body.team-resizing * {
  cursor: row-resize !important;
  user-select: none !important;
}

/* ---- Bottom strip: characters not committed to any team ---- */
.team-unused-wrap {
  border-top: none;
  background: rgba(0, 0, 0, 0.28);
  flex: 0 0 auto;
  /* Height comes from the shared split ratio, so the handle can resize it */
  height: calc(var(--team-strip-ratio, 0.32) * 100%);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.team-unused-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.team-unused-title {
  font-family: var(--mono-font);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #F4EFE9;
}

.team-unused-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.team-unused-controls .search-input {
  width: 180px;
}

/* Grid, not flex-wrap: auto-fill + 1fr stretches every column, so the row ends
   flush with the right edge instead of leaving a ragged strip of dead pixels.
   grid-auto-rows is REQUIRED: with the default `auto` the Grid squeezes the rows
   into the grid's height (crushing every tile to a sliver) instead of scrolling. */
.team-unused-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  grid-auto-rows: max-content;
  align-content: start;
  gap: 8px;
  padding: 0 18px 14px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.team-unused-tile {
  position: relative;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: #0f0e0c;
  cursor: pointer;
  border-radius: 0;
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.team-unused-tile:hover {
  border-color: #ED7D31;
}

/* Armed tile: this character will drop into the next slot you click */
.team-unused-tile.is-pending {
  border-color: #ED7D31;
  box-shadow: 0 0 0 1px #ED7D31, 0 0 10px rgba(237, 125, 49, 0.55);
}

.team-unused-tile:focus-visible {
  outline: 2px solid #ED7D31;
  outline-offset: 2px;
}

.team-unused-tile img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
}

.team-unused-tile.is-unowned img {
  opacity: var(--unowned-char-opacity, 0.35);
  filter: saturate(0.82) contrast(1.05) brightness(0.9);
}

.team-unused-name {
  display: block;
  font-family: var(--mono-font);
  font-size: 0.5rem;
  color: #B5B5B3;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 2px 3px;
}

.team-unused-empty {
  width: 100%;
  padding: 12px 0;
  font-family: var(--mono-font);
  font-size: 0.7rem;
  color: var(--text-muted, #8a8a88);
  text-align: center;
}

/* ---- Picker tiles (Select Character / Select Psychube) ---- */
.team-picker-grid .roster-avatar-box,
#team-select-char-grid .roster-avatar-box,
#team-select-chube-grid .roster-avatar-box {
  border-color: #454545;
}

#team-select-char-grid .roster-char-item.is-selected .roster-avatar-box {
  border-color: #ED7D31;
}

/* Psychube pickers drop the frame entirely */
#team-select-chube-grid .roster-avatar-box.is-chube {
  border-color: transparent;
  background: transparent;
  aspect-ratio: 180 / 214;
  height: auto;
}

#team-select-chube-grid .roster-avatar-box.is-chube .roster-avatar-img {
  object-fit: contain;
}

#team-select-chube-grid .roster-char-item.is-owned .roster-avatar-box.is-chube {
  border-color: transparent;
  box-shadow: none;
}

/* "Used in another team" marker: dark plate + red glyph so it reads at a glance */
.team-used-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  object-fit: contain;
  z-index: 3;
  pointer-events: none;
}

/* Same marker on the main board cards */
/* (`.char-used-badge` removed: the board no longer flags characters that appear
   in several teams. The team-side badges below still do.) */

/* ================= TEAM PRESETS ================= */

/* Two archetypes per row on a desktop modal (auto-fill drops to one when narrow) */
.team-presets-body {
  padding: 16px 20px 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(500px, 1fr));
  gap: 14px 16px;
  align-content: start;
  max-height: 70vh;
  overflow-y: auto;
}

/* Shared by Team Presets and Team Recommendation: wide enough for two archetypes */
.team-presets-card {
  max-width: min(96vw, 1180px);
}

.preset-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.preset-head {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.45);
  border-left: 3px solid #D05126;
  padding: 7px 12px;
}

.preset-name {
  font-family: var(--mono-font);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #F4EFE9;
}

.preset-toggle {
  background: transparent;
  border: none;
  color: #B5B5B3;
  cursor: pointer;
  font-size: 0.7rem;
  line-height: 1;
  padding: 2px 4px;
  transition: color 0.15s ease, transform 0.15s ease;
}

.preset-toggle:hover {
  color: #ED7D31;
}

/* Chevron points right while the extra variants are hidden */
.preset-toggle.is-collapsed {
  transform: rotate(-90deg);
}

/* Variants of one archetype stack vertically inside their block */
.preset-rows {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

/* Sized to its own content — the Add button hugs the right edge of the team box.
   Carries the same surface as a Team Building card. */
.preset-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--team-card-bg);
  border: 1px solid rgba(50, 60, 52, 0.35);
  padding: 8px 10px;
  flex: 0 0 auto;
  max-width: 100%;
}

.preset-members {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

/* A slot: the primary member on top, its interchangeable alternatives beneath */
.preset-slot {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.preset-subs {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.preset-subs-label {
  font-family: var(--mono-font);
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #4E5650;
}

/* Substitute chip: portrait only, because its psychube is the player's choice */
.preset-sub {
  position: relative;
  width: 22px;
  height: 22px;
  border: 1px solid #454545;
  background: #0f0e0c;
  overflow: hidden;
  display: block;
  flex-shrink: 0;
}

.preset-sub img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Manual mode: a chip promotes its character into the main slot. */
.preset-sub.is-pickable {
  padding: 0;
  cursor: pointer;
  transition: border-color 0.12s ease, transform 0.12s ease;
}

.preset-sub.is-pickable:hover {
  border-color: #ED7D31;
  transform: translateY(-1px);
}

.preset-sub.is-pickable:focus-visible {
  outline: 1px solid #ED7D31;
  outline-offset: 1px;
}

.preset-sub.is-unowned img {
  opacity: var(--unowned-char-opacity, 0.35);
  filter: saturate(0.82) contrast(1.05) brightness(0.9);
}

/* Scaled-down Used marker so a 22px chip still reads at a glance.
   Selector is deliberately two classes deep to outrank `.preset-sub img`. */
.preset-sub .preset-sub-used {
  position: absolute;
  top: 0;
  right: 0;
  width: 11px;
  height: 11px;
  object-fit: contain;
  opacity: 1;
  filter: none;
}

/* Mirrors a team slot: portrait + insight/level band + afflatus, psychube right */
.preset-member {
  position: relative;
  display: flex;
  align-items: stretch;
  width: 96px;
  height: 64px;
  flex-shrink: 0;
}

.preset-member-portrait {
  position: relative;
  flex: 0 0 66.7%;
  min-width: 0;
  overflow: hidden;
  background: #0f0e0c;
  border: 1px solid #454545;
}

.preset-member-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.preset-member-portrait.is-unowned .preset-member-img {
  opacity: var(--unowned-char-opacity, 0.35);
  filter: saturate(0.82) contrast(1.05) brightness(0.9);
}

/* Same treatment as the team slot: native 180 x 214 ratio, bottom-aligned */
.preset-member-chube {
  flex: 0 0 33.3%;
  min-width: 0;
  align-self: flex-end;
  aspect-ratio: 180 / 214;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.preset-member-chube img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Unowned psychube dims like an unowned character portrait (shared slider).
   Two classes deep so it outranks `.preset-member-chube img`. */
.preset-member-chube.is-unowned img {
  opacity: var(--unowned-char-opacity, 0.35);
}

/* Top-right badge stack, anchored to the PORTRAIT (not the whole member, which
   also spans the psychube area) so it matches the board card and team slot.
   The euphoria chip and the Used marker share the corner instead of overlapping. */
.preset-member-badges {
  position: absolute;
  right: 2px;
  top: 2px;
  display: flex;
  align-items: center;
  gap: 2px;
  z-index: 3;
  pointer-events: none;
}

/* Euphoria chip (`euphoria` field, e.g. "E1") — dark chip, hidden while Future
   Sight is off when that tier is CN-only for the character. */
.preset-member-euphoria {
  font-family: var(--mono-font);
  font-size: 0.5rem;
  font-weight: 700;
  color: #E7DBCB;
  background: #313B33;
  padding: 0 3px;
  line-height: 1.4;
}

/* Same "used elsewhere" marker as the board card and the team slot */
.preset-member-used {
  width: 14px;
  height: 14px;
  object-fit: contain;
  display: block;
}

/* Compact scale for the insight/level band inside a preset member */
.preset-member .team-slot-afflatus {
  height: 34%;
}

.preset-member .team-slot-meta {
  gap: 3px;
  padding: 2px 3px 1px;
}

.preset-member .team-slot-insight {
  width: 13px;
  height: 13px;
}

.preset-member .team-slot-level {
  font-size: 0.68rem;
}

/* Add button: solid brand red, white label.
   margin-left: auto parks it against the right edge of the team box — the row is
   full-width (its parent stretches), so without this the button sits right after
   the members and leaves the remaining space dead. */
.preset-add-btn {
  flex-shrink: 0;
  margin-left: auto;
  min-width: 62px;
  padding: 6px 10px;
  background: #D05126;
  border: 1px solid #D05126;
  color: #FFFFFF;
  font-family: var(--mono-font);
  font-weight: 700;
  letter-spacing: 0.06em;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.preset-add-btn:hover {
  background: #ED7D31;
  border-color: #ED7D31;
  color: #FFFFFF;
}

.preset-add-btn:focus-visible {
  outline: 2px solid #ED7D31;
  outline-offset: 2px;
}

/* Recommend: appears only when the team already fields a preset's essential member */
.btn-team-recommend {
  background: transparent;
  border: 1px solid rgba(50, 60, 52, 0.35);
  color: #323C34;
  width: 22px;
  height: 22px;
  cursor: pointer;
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.btn-team-recommend:hover {
  border-color: #ED7D31;
  background: rgba(237, 125, 49, 0.22);
}

.btn-team-recommend:focus-visible {
  outline: 2px solid #ED7D31;
  outline-offset: 2px;
}

.btn-team-recommend-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Share: icon-only, copies the /sim link for the team. */
.btn-team-share {
  background: transparent;
  border: 1px solid rgba(50, 60, 52, 0.35);
  color: #323C34;
  width: 22px;
  height: 22px;
  cursor: pointer;
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.btn-team-share:hover,
.btn-team-share:focus-visible {
  border-color: #ED7D31;
  background: rgba(237, 125, 49, 0.22);
}

.btn-team-share:focus-visible {
  outline: 2px solid #ED7D31;
  outline-offset: 2px;
}

.btn-team-share.is-copied {
  border-color: #3B8C4F;
  background: rgba(59, 140, 79, 0.25);
}

.btn-team-share.is-failed {
  border-color: #B33A3A;
  background: rgba(179, 58, 58, 0.22);
}

/* The supplied icon ships grey; darken it to the card's ink. */
.btn-team-share-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter: brightness(0);
  opacity: 0.62;
  transition: opacity 0.15s ease;
}

.btn-team-share:hover .btn-team-share-icon,
.btn-team-share.is-copied .btn-team-share-icon {
  opacity: 0.95;
}

/* Name of the team the recommendation is being computed for */
.team-recommend-for {
  font-family: var(--mono-font);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #ED7D31;
}

/* Essential preset member: a bright frame plus a glow, so the must-have picks
   read at a glance. The ring is drawn with box-shadow rather than a thicker
   border so the 96x64 layout does not shift. */
.preset-member.is-essential .preset-member-portrait {
  border-color: #FF8A5B;
  box-shadow:
    0 0 0 1px rgba(255, 138, 91, 0.6),
    0 0 10px 2px rgba(208, 81, 38, 0.65);
}

/* ================= TEAM BUILDING: MOBILE ================= */

/* Presets are laid out for a wide modal: a 500px minimum column and 96x64
   member tiles overflow a phone. Below a tablet the grid drops to one column
   and the tiles scale down with it. */
@media (max-width: 900px) {
  .team-presets-body {
    grid-template-columns: minmax(0, 1fr);
    padding: 14px 16px 18px;
    gap: 12px;
  }
}

@media (max-width: 620px) {
  .team-presets-body {
    padding: 10px 10px 14px;
    gap: 10px;
  }

  /* Header controls wrap into rows instead of overflowing the modal. */
  #team-presets-modal .archetype-modal-header,
  #team-recommend-modal .archetype-modal-header {
    position: relative;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 44px 10px 12px;
  }

  /* Close button floats in the corner instead of taking a row of its own. */
  #team-presets-modal .archetype-modal-header .modal-close,
  #team-recommend-modal .archetype-modal-header .modal-close {
    position: absolute;
    top: 8px;
    right: 8px;
  }

  #team-presets-modal .archetype-modal-title,
  #team-recommend-modal .archetype-modal-title {
    font-size: 18px;
  }

  .team-header-actions {
    flex: 1 1 100%;
    flex-wrap: wrap;
    gap: 6px;
    margin-left: 0;
  }

  .team-header-actions .search-input {
    flex: 1 1 100%;
    width: 100%;
    height: 30px;
  }

  .preset-head { padding: 6px 10px; }
  .preset-name { font-size: 0.74rem; }

  .preset-row {
    flex-wrap: wrap;
    gap: 8px;
    padding: 7px 8px;
  }

  .preset-members {
    gap: 5px;
    flex: 1 1 100%;
  }

  /* Later rules widen this back to 8px, so keep it tight here. */
  .preset-row .preset-members {
    gap: 5px;
  }

  /* 4 x 72px tiles plus gaps fit a 360px card on one row. */
  .preset-member {
    width: 72px;
    height: 48px;
  }
}

/* Phones keep all four slots on ONE row (4x1) instead of wrapping to 2x2.
   That only fits by tightening the gutters and scaling every overlay down with
   the slot — an 18px insight icon would otherwise swallow a 45px portrait. */
@media (max-width: 620px) {
  .team-list {
    padding: 8px;
  }

  .team-card {
    padding: 8px 8px 10px;
  }

  .team-slots {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .team-name-input {
    font-size: 0.78rem;
    padding: 2px 4px;
  }

  .team-card-head {
    margin-bottom: 6px;
  }

  .team-slot-meta {
    gap: 2px;
    padding: 1px 2px 5px;
  }

  .team-slot-insight {
    width: 11px;
    height: 11px;
  }

  .team-slot-level {
    font-size: 0.5rem;
  }

  .team-slot-afflatus {
    height: 34%;
  }

  .team-slot-chube-plus {
    font-size: 0.7rem;
  }

  .team-slot-plus {
    font-size: 1rem;
  }

  .team-slot-used {
    top: 1px;
    right: 1px;
    width: 11px;
    height: 11px;
  }
}

@media (max-width: 768px) {
  .team-modal-card {
    max-width: 100%;
    height: min(92vh, 900px);
  }

  /* Row 1: the title, on a line of its own. Row 2: the controls, which wrap
     instead of squeezing the title — the same header pattern as InfoBook and
     Rotations. The close button floats in the corner rather than taking a
     cell in the wrapped row. */
  #team-modal .archetype-modal-header {
    position: relative;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 44px 10px 12px;
  }

  #team-modal .archetype-modal-title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 19px;
    line-height: 1.2;
  }

  .team-header-actions {
    flex: 1 1 100%;
    min-width: 0;
    flex-wrap: wrap;
    gap: 6px;
    margin-left: 0;
  }

  .team-header-actions .modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
  }

  /* The team list column count comes from applyTeamColumns(), not a media query */
  .team-list {
    padding: 12px;
  }

  .team-unused-head,
  .team-unused-grid {
    padding-left: 12px;
    padding-right: 12px;
  }

  .team-unused-controls .search-input {
    width: 130px;
  }

  .preset-row {
    gap: 8px;
    padding: 8px;
  }

  .preset-members {
    gap: 8px;
  }
}

/* ================= MANAGE MODAL: CHARACTERS / PSYCHUBES ================= */

.manage-tabs {
  display: flex;
  gap: 8px;
  padding: 10px 20px;
  border-bottom: 1px solid rgba(208, 81, 38, 0.38);
  flex: none;
}

/* Search/filter row sits right under the tabs, separated by a light rule. */
.manage-tabs + .roster-toolbar {
  padding-top: 10px;
}

/* Tabs read as buttons: outlined, white label, orange when active. */
.manage-tab {
  font: inherit;
  font-family: var(--main-font-family);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #f7f7f7;
  background: transparent;
  border: 1px solid #B5B5B3;
  border-radius: 0;
  padding: 6px 16px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.manage-tab:hover {
  border-color: #EBE3D7;
  color: #fff;
}

.manage-tab.active {
  color: #ED7D31;
  border-color: #ED7D31;
  font-weight: 700;
}

.manage-tab:focus-visible {
  outline: 2px solid #ED7D31;
  outline-offset: -2px;
}

/* The hidden attribute must win over the flex/grid display of these panels. */
.manage-panel[hidden] { display: none !important; }

/* Reset sits at the far right of the Characters / Psychubes row. */
.manage-tabs .manage-reset {
  margin-left: auto;
  width: 31px;
  height: 31px;
  min-width: 31px;
  align-self: center;
}

/* ================= CHARACTER BUILD RECOMMENDATIONS ================= */

#builds-modal { z-index: 1000; }

.guide-empty {
  margin: auto;
  padding: 28px;
  color: #B5B5B3;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.74rem;
  text-align: center;
}

/* An empty pane shows the sign instead of a sentence; the words survive in the
   image's alt text and tooltip. */
.guide-empty-sign img {
  display: block;
  width: min(100%, 220px);
  height: auto;
  margin: 0 auto;
  opacity: 0.9;
  user-select: none;
}

/* Inside the narrow rotation rail the sign has to stay small. */
.guide-empty-sign.is-rail {
  padding: 18px 10px;
}

.guide-empty-sign.is-rail img {
  width: min(100%, 140px);
  opacity: 0.75;
}

.builds-modal-card {
  max-width: 1080px;
  width: 100%;
  height: min(88vh, 820px);
  border-radius: 0 !important;
  transition: background-image 0.25s ease, background-color 0.25s ease;
}

/* Easter egg: Sotheby's special theme when viewing Sotheby in InfoBook */
.builds-modal-card.is-sotheby-theme {
  background-image: url("images/sotheby_character_bg.png") !important;
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
}

.builds-modal-card.is-sotheby-theme .archetype-modal-header {
  background: #000000 !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important;
}

/* Biến toàn bộ nền các khối thông tin thành màu đen tuyền (#111111 hoặc #000000), không transparent */
.builds-modal-card.is-sotheby-theme .builds-rail {
  background: #111111 !important;
  border-right: 1px solid rgba(255, 255, 255, 0.12) !important;
}

.builds-modal-card.is-sotheby-theme .builds-rail-tools,
.builds-modal-card.is-sotheby-theme .builds-rail-footer {
  border-color: rgba(255, 255, 255, 0.12) !important;
}

.builds-modal-card.is-sotheby-theme .builds-detail {
  background: rgba(0, 0, 0, 0.45); /* Phủ nhẹ một lớp mờ để các khối thông tin nổi bật */
}

.builds-modal-card.is-sotheby-theme .build-section {
  background: #121212 !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.6) !important;
}

.builds-modal-card.is-sotheby-theme .uttu-cards-strip {
  background: #181818 !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
}

.builds-modal-card.is-sotheby-theme .build-charts,
.builds-modal-card.is-sotheby-theme .build-psychubes,
.builds-modal-card.is-sotheby-theme .build-resonance-block {
  background: #181818 !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.builds-modal-card.is-sotheby-theme .builds-note {
  background: #1c1c1c !important;
  border-left: 3px solid #ED7D31 !important;
  color: #ECE5D9 !important;
}

#builds-modal .btn,
#builds-modal .search-input,
#builds-modal .filter-btn,
#builds-modal .builds-afflatus-btn,
#builds-modal .builds-row,
#builds-modal .builds-row-portrait,
#builds-modal .builds-hero-portrait,
#builds-modal .build-resonance-btn,
#builds-modal .item-sticker,
#builds-modal .item-sticker-qty,
#builds-modal .listing-rule-select,
#builds-modal .builds-mode-btn,
#builds-modal .builds-mode-group,
#builds-modal .builds-rail-toggle,
#builds-modal .modal-close {
  border-radius: 0 !important;
}

.builds-body {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

/* ---- Drag handle between the list and the detail pane ----
   Shared by InfoBook and Skill Rotations. It only exists in the stacked layout
   (list on top, plan below), where it changes the list's height. */
.guide-rail-resizer {
  display: none;
}

@media (max-width: 768px) {
  .guide-rail-resizer {
    display: block;
    flex: 0 0 auto;
    width: 100%;
    height: 12px;
    cursor: row-resize;
    background: rgba(255, 255, 255, 0.03);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    touch-action: none;
    box-sizing: border-box;
  }

  .guide-rail-resizer::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 46px;
    height: 2px;
    background: #6a6a68;
    transition: background 0.15s ease;
  }

  .guide-rail-resizer:hover::after,
  .guide-rail-resizer.is-dragging::after {
    background: #ED7D31;
  }

  .guide-rail-resizer:focus-visible {
    outline: 2px solid #ED7D31;
    outline-offset: -2px;
  }
}

/* While dragging, stop the cursor flickering over child elements */
body.guide-rail-resizing,
body.guide-rail-resizing * {
  cursor: row-resize !important;
  user-select: none !important;
}

/* A hidden list has no rail to resize. */
.builds-body.is-list-hidden .guide-rail-resizer,
.rotations-body.is-list-hidden .guide-rail-resizer {
  display: none;
}

/* Header actions: hide/show the list, plus close. */
.builds-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.builds-rail-toggle,
.rotations-rail-toggle {
  display: none !important;
}

.builds-rail-toggle-icon {
  width: 13px;
  height: 13px;
  object-fit: contain;
  display: block;
  opacity: 0.85;
}

/* Mode Switcher: Characters vs Items */
.builds-mode-group {
  display: inline-flex;
  gap: 8px;
  background: transparent;
  border: none;
  border-radius: 0;
  overflow: visible;
}

.builds-mode-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 10px;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #B5B5B3;
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid #B5B5B3;
  border-radius: 0;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.builds-mode-btn:hover {
  background: rgba(181, 181, 179, 0.12);
  border-color: #B5B5B3;
  color: #ffffff;
}

.builds-mode-btn.is-active {
  background: #2a2825;
  color: #f7f7f7;
  border-color: #ED7D31;
  font-weight: 700;
}

/* The Items tab is parked (see the `hidden` attribute in index.html). */
#builds-modal .builds-mode-btn[hidden] { display: none !important; }

/* Hidden list: the build takes the full width. */
.builds-body.is-list-hidden .builds-rail {
  display: none;
}

.builds-body.is-list-hidden .builds-detail {
  flex: 1 1 100%;
}

/* ---- Left rail ---- */

.builds-rail {
  flex: 0 0 264px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
}

.builds-rail-tools {
  flex: none;
  padding: 14px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.builds-rail-tools .search-input {
  width: 100%;
  max-width: none;
  height: 30px;
  font-size: 0.7rem;
}

.builds-rarity-group {
  width: 100%;
  height: 26px;
}

.builds-rarity-group .filter-btn {
  flex: 1;
  min-width: 0;
  padding: 0 2px;
  font-size: 0.6rem;
}

.builds-afflatus-group {
  display: flex;
  gap: 4px;
}

.builds-afflatus-btn {
  flex: 1;
  height: 26px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(181, 181, 179, 0.4);
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.builds-afflatus-btn img {
  width: 15px;
  height: 15px;
  object-fit: contain;
  display: block;
}

.builds-afflatus-btn:hover { opacity: 1; border-color: #EBE3D7; }

.builds-afflatus-btn.is-active {
  opacity: 1;
  border-color: #ED7D31;
  background: rgba(208, 81, 38, 0.28);
}

.builds-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px;
}

.builds-rail-footer {
  flex: none;
  padding: 8px 14px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.builds-count {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.56rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8f8a83;
}

.builds-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 7px;
  background: none;
  border: 1px solid transparent;
  color: #ECE5D9;
  text-align: left;
  cursor: pointer;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
}

.builds-row:hover { background: rgba(255, 255, 255, 0.04); }

.builds-row.is-active {
  border-color: #ED7D31;
  background: rgba(208, 81, 38, 0.16);
}

.builds-row-portrait {
  width: 34px;
  height: 34px;
  flex: none;
  overflow: hidden;
  background: #2a2825;
  border: 1px solid rgba(181, 181, 179, 0.28);
  display: block;
}

.builds-row-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.builds-row-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.builds-row-name {
  font-size: 0.7rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.builds-row-stars {
  font-size: 0.52rem;
  letter-spacing: 0.1em;
  line-height: 1;
}

/* ---- Right pane ---- */

.builds-detail {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 20px 26px 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.builds-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* Opening a character: animations disabled per request */
.builds-detail .builds-hero {
  animation: none !important;
}

.builds-detail .builds-hero-portrait img {
  animation: none !important;
}

.builds-detail .builds-grid {
  animation: none !important;
  animation-delay: 0s !important;
}

.builds-detail .build-notes-box {
  animation: none !important;
  animation-delay: 0s !important;
}

@keyframes buildsSectionIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes buildsPortraitIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.builds-hero-portrait {
  width: 76px;
  height: 76px;
  flex: none;
  overflow: hidden;
  background: #2a2825;
  border: 1px solid var(--build-accent, #D05126);
  display: block;
}

.builds-hero-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.builds-hero-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.builds-hero-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

/* Share: icon-only, copies the /sim link for this build. */
.builds-share-btn {
  margin-left: auto;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  padding: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(236, 229, 217, 0.28);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.builds-share-btn:hover,
.builds-share-btn:focus-visible {
  border-color: var(--accent-gold, #F6C34A);
  background: rgba(246, 195, 74, 0.14);
}

.builds-share-btn:focus-visible {
  outline: 2px solid var(--accent-gold, #F6C34A);
  outline-offset: 2px;
}

.builds-share-btn.is-copied {
  border-color: #4CAF6A;
  background: rgba(76, 175, 106, 0.2);
}

.builds-share-btn.is-failed {
  border-color: #C0504D;
  background: rgba(192, 80, 77, 0.2);
}

/* Dark panel: invert the grey arrow to the panel's parchment ink. */
.builds-share-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter: brightness(0) invert(1);
  opacity: 0.62;
  transition: opacity 0.15s ease;
}

.builds-share-btn:hover img,
.builds-share-btn.is-copied img,
.builds-share-btn.is-failed img {
  opacity: 1;
}

.builds-hero-name {
  margin: 0;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 26px;
  font-weight: normal;
  color: #ECE5D9;
  line-height: 1.1;
}

.builds-hero-stars {
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  line-height: 1;
}

.builds-note {
  margin: 0;
  padding: 9px 12px;
  border-left: 2px solid rgba(237, 125, 49, 0.6);
  background: rgba(208, 81, 38, 0.1);
  color: #D6D1C8;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.7rem;
}

.builds-muted {
  color: #8f8a83;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.68rem;
}

/* Portrait value chart on the left, the two loadout cards on the right. */
.builds-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: 14px;
  align-items: stretch;
}

/* One column when only one side has content to show. */
.builds-grid.is-single { grid-template-columns: minmax(0, 1fr); }

/* Three or more charts: the chart card spans the row, loadout cards sit below. */
.builds-grid.is-stacked { grid-template-columns: minmax(0, 1fr); }

.builds-grid.is-stacked .builds-column {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  align-items: start;
}

/* Without the chart, the loadout cards share the row instead of stacking. */
.builds-grid.is-single .builds-column {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  align-items: start;
}

.builds-column {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.build-section {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.28);
  border-radius: 2px;
}

.build-section-chart {
  flex: 1;
}

.build-section-chart .build-charts {
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 2px;
}

.build-psychubes {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 2px;
}

.build-resonance-block {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 2px;
}

.build-section-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #B5B5B3;
}

.build-section-title::before {
  content: "";
  flex: none;
  width: 3px;
  height: 11px;
  background: #D05126;
}

/* Charts: one per block, stacked so several read as a small dashboard. */
.build-charts {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.build-chart-block {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.build-chart-label {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ECE5D9;
}

/* Portrait value chart: bars take the character's rarity colour. */
.build-chart {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 18px;
  min-height: 140px;
  padding: 0 4px;
}

/* Several charts share the card, so each one is a little shorter. */
.build-charts.is-multi .build-chart {
  min-height: 96px;
}

/* From the third chart on, pair them up so the card does not run off-screen. */
.build-charts.is-many {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
  align-items: start;
  gap: 18px 24px;
}

/* A fixed height per chart keeps every row of the grid the same size. */
.build-charts.is-many .build-chart-block { height: 150px; }

.build-charts.is-many .build-chart-block { height: 150px; }

.build-charts.is-many .build-chart {
  min-height: 110px;
}

.build-chart-col {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}

.build-chart-val {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.6rem;
  color: #ECE5D9;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* The track shows the full scale, so short bars still read as a proportion. */
.build-chart-track {
  flex: 1;
  width: 100%;
  max-width: 46px;
  display: flex;
  align-items: flex-end;
  background: rgba(255, 255, 255, 0.045);
  border-bottom: 1px solid rgba(181, 181, 179, 0.3);
}

.build-chart-bar {
  width: 100%;
  display: block;
  background: var(--build-accent, #D05126);
  transform-origin: bottom;
  animation: buildBarGrow 0.55s cubic-bezier(0.16, 0.84, 0.32, 1) both;
  animation-delay: calc(var(--bar-index, 0) * 55ms);
}

@keyframes buildBarGrow {
  from {
    transform: scaleY(0);
    opacity: 0.35;
  }
  to {
    transform: scaleY(1);
    opacity: 1;
  }
}

/* Labels follow their bar in, so the eye reads the column top-down. */
.build-chart-val,
.build-chart-badge {
  animation: buildChartLabelIn 0.3s ease-out both;
  animation-delay: calc(180ms + var(--bar-index, 0) * 55ms);
}

@keyframes buildChartLabelIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.build-chart-badge {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #B5B5B3;
}

/* Respect the OS "reduce motion" preference: show everything immediately. */
@media (prefers-reduced-motion: reduce) {
  .builds-detail .builds-hero,
  .builds-detail .builds-hero-portrait img,
  .builds-detail .builds-grid,
  .builds-detail .build-notes-box,
  .build-chart-bar,
  .build-chart-val,
  .build-chart-badge {
    animation: none;
  }
}

/* Psychubes: one row each, no tile behind the art. */
.build-psychubes {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.build-psychube {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: #ECE5D9;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
}

.build-psychube + .build-psychube {
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.build-psychube img,
.build-psychube-blank {
  width: 54px;
  height: 64px;
  object-fit: contain;
  flex: none;
  display: block;
}

/* A missing psychube still keeps the row's height, without a filled tile. */
.build-psychube-blank {
  border: 1px dashed rgba(181, 181, 179, 0.3);
  box-sizing: border-box;
}

.build-psychube-name {
  min-width: 0;
  font-size: 0.84rem;
  line-height: 1.35;
}

/* Pattern and codes share the card, aligned to the same left edge. */
.build-resonance-block {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.build-resonance-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* The label is the copy button for its code; no code is printed any more. */
.build-resonance-btn {
  flex: 1 1 88px;
  font: inherit;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  height: 32px;
  padding: 0 14px;
  color: #fff;
  background: #D05126;
  border: 1px solid #E9853F;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.build-resonance-btn:hover { background: #ED7D31; border-color: #ED7D31; }

.build-resonance-btn.is-copied {
  background: #2f7d32;
  border-color: #2f7d32;
}

.build-pattern {
  display: flex;
  align-items: center;
  gap: 12px;
}

.build-pattern img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  flex: none;
  display: block;
}

.build-pattern-name {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* Notes close the panel as a callout, not as another boxed section. */
.build-notes-box {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 11px 14px;
  border-left: 2px solid rgba(237, 125, 49, 0.65);
  background: rgba(208, 81, 38, 0.08);
}

.build-notes-label {
  flex: none;
  padding-top: 2px;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #ED7D31;
}

.build-notes {
  margin: 0;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.72rem;
  line-height: 1.65;
  color: #D6D1C8;
  white-space: pre-wrap;
}

/* ---------------- Items Tab & Materials Grid ---------------- */

.items-grid-container {
  display: grid;
  /* Three per row: the rail is narrow, so `auto-fill` only ever fit two 68px
     stickers (the rail's scrollbar eats the third) and left a ragged column. */
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 8px;
}

/* Fill the column rather than keeping the fixed 68px sticker size. */
.items-grid-container .item-sticker {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
}

.item-sticker {
  position: relative;
  width: 68px;
  height: 68px;
  cursor: pointer;
  border-radius: 0;
  overflow: hidden;
  border: 1px solid transparent;
  transition: transform 0.15s ease, border-color 0.15s ease;
  user-select: none;
  background: transparent;
}

.item-sticker:hover {
  transform: translateY(-2px);
  border-color: #D05126;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.item-sticker.is-active {
  border-color: #fff;
  box-shadow: 0 0 0 1px #fff;
}

.item-sticker-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: scale(1.18);
  transition: transform 0.2s ease;
  z-index: 2;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: high-quality;
}

.item-sticker:hover .item-sticker-img {
  transform: scale(1.26);
}

.item-sticker-border {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  transform: scale(1.18);
  transition: transform 0.2s ease;
  z-index: 1;
  pointer-events: none;
}

.item-sticker:hover .item-sticker-border {
  transform: scale(1.26);
}

.item-sticker-qty {
  position: absolute;
  bottom: 3px;
  right: 3px;
  background: rgba(18, 18, 18, 0.88);
  color: #fff;
  font-family: var(--mono-font);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 0;
  z-index: 3;
  line-height: 1.1;
  pointer-events: none;
}

/* Material Detail View */
.material-detail-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.material-detail-hero {
  display: flex;
  align-items: center;
  gap: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.material-detail-icon-wrap {
  position: relative;
  width: 80px;
  height: 80px;
  flex: none;
}

.material-detail-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.material-detail-name {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 24px;
  color: #ECE5D9;
  margin: 0;
}

.material-detail-desc {
  font-size: 0.76rem;
  color: #B5B5B3;
  line-height: 1.5;
  margin: 0;
}

.material-detail-usage {
  font-size: 0.72rem;
  color: #D5D3CF;
  line-height: 1.4;
  margin: 0;
}

.material-detail-source {
  font-size: 0.7rem;
  color: #8f8a83;
}

/* Character Materials: the two pieces the psychube detail pane still wears.
   The arcanist build's own progression panel moved to the Planner (§14). */
.char-mats-sublabel {
  font-size: 0.62rem;
  font-weight: 700;
  color: #8f8a83;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-family: var(--primary-font);
}

.mats-result-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

/* Character Skills, Insights & Portrays Detail Section */
.char-skills-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 10px;
}

/* Character Skills, Insights & Portrays Detail Section (UTTU / In-Game Layout) */
.char-skills-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 14px;
}

.uttu-mode-bar {
  display: inline-flex;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 8px;
}

.uttu-mode-btn {
  height: 30px;
  padding: 0 14px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #B5B5B3;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.uttu-mode-btn:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.28);
}

.uttu-mode-btn.is-active {
  color: #ED7D31;
  background: #2a2825;
  border-color: #ED7D31;
  box-shadow: 0 2px 8px rgba(237, 125, 49, 0.2);
}

.uttu-skills-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.uttu-skills-showcase {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Multi-Stance Switcher Bar (Base / Bendith, Set A / Set B, etc.) */
.uttu-stance-bar {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  align-self: flex-start;
  padding: 3px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}

.uttu-stance-btn {
  height: 28px;
  padding: 0 14px;
  font-family: var(--mono-font);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #B5B5B3;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.uttu-stance-btn:hover {
  color: #ECE5D9;
  background: rgba(255, 255, 255, 0.08);
}

.uttu-stance-btn.is-active {
  color: #111111;
  background: #ED7D31;
  border-color: #ED7D31;
  box-shadow: 0 2px 8px rgba(237, 125, 49, 0.35);
}

/* Euphoria switch that reveals E1/E2-gated skill cards */
.uttu-euphoria-bar-label {
  padding: 0 4px 0 8px;
  font-family: var(--mono-font);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(236, 229, 217, 0.55);
}

/* Reinforce switch (Lucy): Base / Reinforce, swaps a card's text in place */
.uttu-reinforce-bar {
  border-color: rgba(237, 125, 49, 0.35);
}

/* Card Selection Strip */
.uttu-cards-strip {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow-x: auto;
}

.uttu-skill-card-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
  user-select: none;
  flex-shrink: 0;
}

.uttu-skill-card-item:hover {
  transform: translateY(-4px);
  filter: brightness(1.15);
}

.uttu-skill-card-item.is-selected {
  transform: translateY(-4px);
}

.uttu-skill-card-item.is-selected .rot-card {
  outline: 2px solid #ED7D31;
  outline-offset: 3px;
  box-shadow: 0 4px 14px rgba(237, 125, 49, 0.35);
}

.rot-card-unique-text {
  position: absolute;
  left: 50%;
  bottom: -4px;
  transform: translateX(-50%);
  width: 122%;
  max-width: none;
  height: auto;
  pointer-events: none;
  z-index: 5;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.85));
}

.uttu-skill-card-badge {
  font-family: var(--mono-font);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #B5B5B3;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 6px;
  border-radius: 2px;
}

.uttu-skill-card-item.is-selected .uttu-skill-card-badge {
  color: #ED7D31;
  background: rgba(237, 125, 49, 0.15);
}

/* Bottom Detail Board */
.uttu-detail-board {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 20px;
  background: var(--team-card-bg);
  border: 1.1px solid rgba(50, 60, 52, 0.45);
  border-radius: 2px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  color: #332f2a;
}

/* Rank Selector inside Detail Board */
.uttu-rank-selector {
  display: flex;
  gap: 14px;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(50, 60, 52, 0.2);
}

/* Conduit Metrics (Cost & Harmonization) */
.uttu-conduit-metrics {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.uttu-conduit-metric {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border: 1px solid rgba(50, 60, 52, 0.35);
  background: rgba(0, 0, 0, 0.03);
  border-radius: 2px;
  min-width: 0;
}

.uttu-metric-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #3b3630;
  letter-spacing: 0.02em;
}

.uttu-metric-value {
  font-size: 0.95rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.uttu-conduit-metric.u-cost .uttu-metric-value {
  color: #DD3838;
}

.uttu-conduit-metric.u-harm.is-positive .uttu-metric-value {
  color: #60A566;
}

.uttu-conduit-metric.u-harm.is-negative .uttu-metric-value {
  color: #60A566;
}

/* Conduit markers. The game marks Cost with its diamond glyph (cropped from the
   game) and Harmonization with a skewed chip; the value itself sits to the right
   of the shape, so the chip is an empty decorative plate. */
.uttu-conduit-cost {
  display: inline-block;
  width: 18px;
  height: 18px;
  flex: none;
  object-fit: contain;
}

.uttu-conduit-harm {
  --badge-color: #fddf7a;
  display: inline-block;
  width: 28px;
  height: 12px;
  flex: none;
  background: var(--badge-color);
  transform: skewX(-24deg);
  filter: drop-shadow(1px 1px 1.5px rgba(0, 0, 0, 0.28));
}

.uttu-rank-card-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  opacity: 0.65;
  transition: all 0.15s ease;
}

.uttu-rank-card-col:hover {
  opacity: 0.9;
  transform: translateY(-2px);
}

.uttu-rank-card-col.is-active {
  opacity: 1;
  transform: translateY(-2px);
}

.uttu-rank-card-col .rot-card {
  height: 64px;
  border-radius: 3px;
  overflow: hidden;
}

.uttu-rank-card-col.is-active .rot-card {
  outline: 2px solid #a84e2a;
  outline-offset: 2px;
}

.uttu-rank-pill {
  font-size: 0.6rem;
  color: #a84e2a;
  font-weight: 700;
  letter-spacing: 2px;
}

.uttu-skill-info-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.uttu-skill-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.25rem;
  color: #24201c;
  font-weight: 700;
  margin: 0;
}

.uttu-skill-type-tag {
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: #313b33;
  padding: 3px 10px;
  border-radius: 2px;
}

/* Cast option of an Adaptive card (Brume / Nautika): same plate as the card tag,
   one step down since it sits in a panel head next to the option's name. */
.uttu-skill-option-tag {
  flex: none;
  font-size: 0.58rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: #313b33;
  padding: 2px 8px;
  border-radius: 2px;
}

.uttu-skill-flavor {
  font-family: Georgia, 'Times New Roman', serif;
  font-style: italic;
  font-size: 0.82rem;
  line-height: 1.5;
  color: #5f574f;
  border-left: 2px solid rgba(168, 78, 42, 0.45);
  padding-left: 10px;
  margin: 2px 0;
}

.uttu-flavor-symbol {
  font-style: normal;
  color: #a84e2a;
  font-weight: 700;
  margin-right: 2px;
}

.uttu-skill-body-desc {
  font-size: 0.85rem;
  line-height: 1.6;
  color: #272525;
  white-space: pre-line;
}

/* Perception Incantation cards (37, Perchta, Huntsworn Lilya): three equal
   panels — the base incantation and one panel per Perception Ability. */
.uttu-skill-panels {
  display: flex;
  align-items: stretch;
  gap: 12px;
}

.uttu-skill-panel {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid rgba(50, 60, 52, 0.28);
  border-radius: 2px;
}

.uttu-skill-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.uttu-skill-panel-label {
  display: inline-block;
  font-family: var(--mono-font);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #f3ede3;
  background: #313b33;
  padding: 3px 8px;
  border-radius: 2px;
}

.uttu-skill-panel-desc {
  flex: 1 1 auto;
  font-size: 0.82rem;
  line-height: 1.6;
  color: #272525;
  white-space: pre-line;
}

/* Adaptive card options (Brume / Nautika): one panel per cast option, each with the
   option's own card art and the text for the rank selected above. */
.uttu-skill-panels.is-stacked {
  flex-direction: column;
}

.uttu-skill-panel-option {
  flex-direction: column;
  gap: 10px;
}

.uttu-skill-panels.is-stacked > .uttu-skill-panel {
  flex: none;
}

/* Each option carries its own ★1/★2/★3 picker (card art + pips), so the two cast
   choices are upgraded independently — as in the game. */
.uttu-skill-option-picker {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.uttu-skill-option-rank {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  opacity: 0.62;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.uttu-skill-option-rank:hover {
  opacity: 0.9;
}

.uttu-skill-option-rank.is-active {
  opacity: 1;
  transform: translateY(-2px);
}

.uttu-skill-option-rank .rot-card {
  height: 62px;
  border-radius: 3px;
  overflow: hidden;
}

.uttu-skill-option-rank.is-active .rot-card {
  outline: 2px solid #a84e2a;
  outline-offset: 2px;
}

.uttu-skill-panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px dashed rgba(39, 37, 37, 0.18);
}

.uttu-skill-panel-foot-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.uttu-skill-panel-cost {
  font-size: 0.7rem;
  color: #5f574f;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Perception Point cost: the game's own icon, cropped, sits before the amount. */
.uttu-skill-perception-icon {
  width: 14px;
  height: 14px;
  flex: none;
  object-fit: contain;
}

@media (max-width: 900px) {
  .uttu-skill-panels {
    flex-wrap: wrap;
  }

  .uttu-skill-panel {
    flex: 1 1 calc(50% - 6px);
  }
}

/* Inheritance / Insights Board */
.uttu-insights-board {
  --uttu-insight-icon: 28px;
  --uttu-insight-icon-small: 21px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--team-card-bg);
  border: 1.1px solid rgba(50, 60, 52, 0.45);
  padding: 16px 18px;
  border-radius: 2px;
  color: #332f2a;
}

/* Inheritance name (the Insight I title) heads the whole tree as in-game dark badge.
   The Portray tab reuses the same badge for its "Portrait Info" heading. */
.uttu-insight-head {
  display: flex;
  margin-bottom: 2px;
}

.uttu-insight-title,
.uttu-portrays-title {
  display: inline-flex;
  align-items: center;
  padding: 4px 14px;
  border-radius: 2px;
  background: #313B33;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: #E7DBCB;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

.uttu-insight-list {
  display: flex;
  flex-direction: column;
}

.uttu-insight-row {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 4px 0 6px 0;
}

/* Faded spine joining one insight icon to the next (no more row separators).
   It sits exactly on the icon column's centre line and keeps a 7px gap above and
   below every icon. */
.uttu-insight-row:not(:last-child)::after {
  content: "";
  position: absolute;
  left: calc(var(--uttu-insight-icon) / 2);
  transform: translateX(-50%);
  top: calc(4px + var(--uttu-insight-icon) + 7px);
  bottom: 3px;
  width: 1.5px;
  background: #C7BBB3;
  pointer-events: none;
}

.uttu-insight-row:last-child {
  padding-bottom: 0;
}

.uttu-insight-badge-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: none;
  width: var(--uttu-insight-icon);
  height: var(--uttu-insight-icon);
  padding-top: 0;
}

.uttu-insight-icon {
  width: var(--uttu-insight-icon);
  height: var(--uttu-insight-icon);
  object-fit: contain;
  display: block;
}

/* Precognition and Insight I sit a step smaller than the Insight II/III badges.
   The column keeps its full width and height, so the spine, the tag's vertical
   centring and the row rhythm are unchanged. */
.uttu-insight-icon.is-small {
  width: var(--uttu-insight-icon-small);
  height: var(--uttu-insight-icon-small);
}

.uttu-insight-content {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

/* The label is nudged down by half the icon's extra height so its text stays
   centred against the icon without the line box eating the gap above the text. */
.uttu-insight-tag {
  align-self: flex-start;
  margin-top: calc((var(--uttu-insight-icon) - 1.2em) / 2);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.01em;
  color: #3b3a36;
}

.uttu-insight-desc {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 0.88rem;
  line-height: 1.55;
  color: #272525;
  white-space: pre-line;
}

/* Portrays Board */
.uttu-portrays-board {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--team-card-bg);
  border: 1.1px solid rgba(50, 60, 52, 0.45);
  padding: 16px 18px;
  border-radius: 2px;
  color: #332f2a;
}

.uttu-portrays-head {
  display: flex;
  align-items: flex-start;
  margin-bottom: 8px;
}

.uttu-portrays-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.uttu-portray-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid rgba(50, 60, 52, 0.18);
}

.uttu-portray-row:last-child {
  border-bottom: none;
}

.uttu-portray-lvl {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 0.9rem;
  color: #5f574f;
  flex: none;
  width: 50px;
}

.uttu-portray-num {
  font-family: var(--mono-font);
  font-weight: 700;
  font-size: 1.05rem;
  color: #a84e2a;
}

.uttu-portray-desc {
  font-size: 0.82rem;
  line-height: 1.55;
  color: #272525;
  flex: 1;
  white-space: pre-line;
}

/* Weapons Board (Assassin's Creed Collab: Ezio & Kassandra) */
.uttu-weapons-board {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--team-card-bg);
  border: 1.1px solid rgba(50, 60, 52, 0.45);
  padding: 18px 20px;
  border-radius: 2px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.uttu-weapons-strip {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(50, 60, 52, 0.2);
}

.uttu-weapon-btn {
  padding: 10px 16px;
  background: #313B33;
  color: #ECE5D9;
  border: 1.2px solid transparent;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.15s ease;
  text-align: center;
}

.uttu-weapon-btn:hover {
  background: #3c493f;
  transform: translateY(-1px);
}

.uttu-weapon-btn.is-active {
  background: #272f29;
  color: #f7a05e;
  border-color: #ED7D31;
  box-shadow: 0 3px 10px rgba(237, 125, 49, 0.25);
}

.uttu-weapon-detail {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.uttu-weapon-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: #24201c;
  margin: 0;
}

.uttu-weapon-main-desc {
  font-size: 0.85rem;
  line-height: 1.6;
  color: #272525;
  white-space: pre-line;
}

.uttu-weapon-combos {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px dashed rgba(50, 60, 52, 0.25);
}

.uttu-weapon-combo-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.uttu-weapon-combo-name {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: #3b352f;
}

.uttu-weapon-combo-desc {
  font-size: 0.83rem;
  line-height: 1.55;
  color: #383430;
  white-space: pre-line;
}

/* ================= EZIO WEAPONS BOARD (Gnomon Style) ================= */
.ezio-weapon-board {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ezio-weapon-stage {
  display: grid;
  grid-template-columns: minmax(130px, 1.2fr) minmax(220px, 1.6fr) minmax(130px, 1.2fr);
  align-items: center;
  gap: 14px;
  padding: 18px 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  position: relative;
}

.ezio-weapon-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ezio-weapon-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 6px;
  cursor: pointer;
  user-select: none;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.ezio-weapon-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.02);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  pointer-events: none;
}

/* Skew angles matching the official AC aesthetic in Gnomon */
.ezio-weapon-card.is-primary::before {
  transform: skewY(4deg);
}

.ezio-weapon-card.is-secondary::before {
  transform: skewY(-4deg);
}

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

.ezio-weapon-card:hover::before {
  border-color: rgba(237, 125, 49, 0.5);
  background: rgba(237, 125, 49, 0.06);
}

.ezio-weapon-card.is-active::before {
  border-color: #ED7D31 !important;
  background: rgba(237, 125, 49, 0.14) !important;
  box-shadow: 0 0 14px rgba(237, 125, 49, 0.35);
}

.ezio-weapon-box {
  width: 76px;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 2;
}

.ezio-weapon-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.6));
  transition: transform 0.15s ease;
}

.ezio-weapon-card:hover .ezio-weapon-img {
  transform: scale(1.08);
}

.ezio-weapon-label {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 0.76rem;
  font-weight: 700;
  color: #ECE5D9;
  text-align: center;
  margin-top: 4px;
  position: relative;
  z-index: 2;
  line-height: 1.25;
}

.ezio-weapon-card.is-active .ezio-weapon-label {
  color: #ED7D31;
}

/* Center combo box: [Primary] × [Secondary] (Cố định size tuyệt đối, không co giãn khi đổi vũ khí) */
.ezio-weapon-center-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 4px;
}

.ezio-center-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.4);
  padding: 10px 8px;
  width: 105px;
  min-width: 105px;
  max-width: 105px;
  height: 125px;
  box-sizing: border-box;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
}

.ezio-center-box {
  width: 65px;
  height: 65px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ezio-center-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.7));
}

.ezio-center-name {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 0.7rem;
  font-weight: 700;
  color: #ECE5D9;
  text-align: center;
  width: 100%;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.ezio-center-cross {
  font-size: 1.4rem;
  color: #ED7D31;
  font-weight: 900;
  flex-shrink: 0;
}

/* Parchment detail paper below */
.ezio-weapon-detail-paper {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--team-card-bg);
  border: 1.1px solid rgba(50, 60, 52, 0.45);
  padding: 18px 22px;
  border-radius: 2px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  color: #272525;
}

.ezio-effect-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ezio-effect-badge {
  display: inline-flex;
  align-self: flex-start;
  padding: 3px 10px;
  background: #313B33;
  color: #ECE5D9;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border-radius: 2px;
}

.ezio-effect-badge.is-combo {
  background: #a84e2a;
  color: #fff;
}

.ezio-effect-desc {
  font-size: 0.85rem;
  line-height: 1.6;
  color: #272525;
  white-space: pre-line;
}

.ezio-effect-divider {
  height: 1px;
  background: rgba(50, 60, 52, 0.2);
  margin: 2px 0;
}

/* ================= KASSANDRA ABILITY BOARD ================= */
.kassandra-ability-board {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.kassandra-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.kassandra-points-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  transition: all 0.2s ease;
}

.kassandra-points-badge.is-error {
  border-color: #f26454;
  background: rgba(242, 100, 84, 0.2);
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.kassandra-pts-num {
  font-family: var(--mono-font);
  font-size: 1.1rem;
  font-weight: 700;
  color: #ED7D31;
}

.kassandra-pts-label {
  font-family: var(--mono-font);
  font-size: 0.65rem;
  font-weight: 700;
  color: #B5B5B3;
  text-transform: uppercase;
}

.kassandra-reset-btn {
  height: 26px;
  padding: 0 12px;
  font-family: var(--mono-font);
  font-size: 0.65rem;
  font-weight: 700;
  color: #ECE5D9;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-left: auto;
}

.kassandra-reset-btn:hover {
  background: rgba(208, 81, 38, 0.25);
  border-color: #ED7D31;
  color: #ED7D31;
}

/* 3 Columns Grid for Trees (Đồng bộ phong cách Sotheby / Ezio và ảnh gốc trong game) */
.kassandra-trees-container {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  padding: 24px 16px 20px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
}

.ability-tree {
  min-width: 0;
  text-align: center;
  position: relative;
}

.ability-tree-path {
  position: relative;
  height: 295px;
  max-width: 200px;
  margin: 0 auto;
}

.ability-tree-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 0; /* Nằm dưới hoàn toàn */
}

.ability-tree-lines path.tree-line-base {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.ability-tree-lines path.tree-line-active {
  fill: none;
  stroke: #8F8C86;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  opacity: 0.7;
}

.ability-node {
  position: absolute;
  left: 50%;
  width: 58px;
  height: 58px;
  padding: 0;
  border: 1.5px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  background: #151413;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6);
  cursor: pointer;
  transform: translateX(-50%);
  transition: all 0.15s ease;
  opacity: 0.65;
  z-index: 2; /* Nằm đè lên trên đường kẻ */
}

.ability-node-1 { top: 8px; }
.ability-node-2 { top: 90px; }
.ability-node-3 { top: 172px; }

.ability-tree-hunter .ability-node-2 { left: 28%; }
.ability-tree-assassin .ability-node-2 { left: 72%; }

.ability-node:hover {
  opacity: 0.95;
  border-color: #ED7D31;
}

/* Khi active/selected: nền đen đặc #151413 (không transparent), chỉ 1 viền tròn đơn giản gọn gàng */
.ability-node.active {
  opacity: 1;
  border: 2px solid #ED7D31;
  background: #151413;
  box-shadow: 0 0 10px rgba(237, 125, 49, 0.4);
  transform: translateX(-50%);
}

.ability-node.active.is-target {
  border: 2px solid #ED7D31;
  background: #151413;
  box-shadow: 0 0 12px rgba(237, 125, 49, 0.5);
  transform: translateX(-50%);
}

/* Bỏ vòng dashed bên trong, chỉ giữ 1 viền tròn duy nhất */
.ability-node-ring {
  display: none;
}

.ability-node-media {
  position: absolute;
  inset: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  overflow: hidden;
}

.ability-node-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: grayscale(0.6) brightness(0.7);
  transition: filter 0.15s ease;
}

.ability-node.active .ability-node-media img {
  filter: none;
}

.ability-node-lock {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  pointer-events: none;
  z-index: 4;
}

.ability-lock-img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  opacity: 0.8;
}

.ability-tree-emblem {
  position: absolute;
  left: 50%;
  top: 240px;
  width: 48px;
  height: 48px;
  padding: 6px;
  border: 1.5px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  background: #151413;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateX(-50%);
  z-index: 2;
  transition: all 0.2s ease;
}

.ability-tree-emblem img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0.6;
  transition: all 0.2s ease;
}

.ability-tree-emblem.is-active {
  border-color: #ED7D31;
  background: #151413;
  box-shadow: 0 0 10px rgba(237, 125, 49, 0.4);
}

.ability-tree-emblem.is-active img {
  opacity: 1;
}

/* Badge nhãn tên nhánh chuẩn như ảnh 1 (loại bỏ kim cương) */
.ability-tree-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  margin-top: 10px;
  padding: 4px 16px;
  border-radius: 2px;
  color: #8C8A87;
  font-size: 16px;
  letter-spacing: 0.04em;
  transition: all 0.2s ease;
  font-family: Georgia, 'Times New Roman', serif;
}

.tree-label-text {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 16px;
  color: inherit;
}

.ability-tree.has-unlocked .ability-tree-label {
  color: #D5D3CF;
}

/* Detail Paper / Effects List */
.kassandra-effects-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kassandra-effect-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kassandra-effect-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kassandra-effect-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.kassandra-effect-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: #313B33;
}

.kassandra-effect-body {
  font-size: 0.83rem;
  line-height: 1.55;
  color: #383430;
  white-space: pre-line;
  padding-left: 28px;
}

/* Euphoria Board & Tree Card (UTTU style matching Pasted Image 2) */
.uttu-euphoria-board {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.uttu-euphoria-tree-card {
  display: flex;
  flex-direction: column;
  gap: 20px;
  background-color: #12100e;
  background-image: url("images/euphoria_bg.webp");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border: 1.1px solid rgba(255, 255, 255, 0.12);
  padding: 24px 24px 20px;
  border-radius: 4px;
  color: #ECE5D9;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.6), 0 8px 24px rgba(0, 0, 0, 0.5);
  position: relative;
}

.uttu-euphoria-tree-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.uttu-euphoria-tree-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.45rem;
  color: #FFFFFF;
  font-weight: 700;
  margin: 0;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
}

.uttu-euphoria-tags {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.uttu-euphoria-tag {
  font-size: 0.7rem;
  font-weight: 700;
  color: #a8a49c;
  background: transparent;
  border: none;
  padding: 0 4px;
  border-radius: 0;
  letter-spacing: 0.04em;
  backdrop-filter: none;
}

.uttu-euphoria-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  position: relative;
}

@media (min-width: 640px) {
  .uttu-euphoria-layout {
    grid-template-columns: 1fr;
  }
}

.uttu-euphoria-visual-center {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px auto 14px;
  max-width: 240px;
}

.uttu-euphoria-art-img {
  width: 100%;
  height: auto;
  max-height: 220px;
  object-fit: contain;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.85));
}

.uttu-euphoria-ranks-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 640px) {
  .uttu-euphoria-ranks-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px 28px;
  }
}

.uttu-euphoria-rank-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: transparent;
  padding: 6px 0;
  border-left: none;
  border-radius: 0;
  backdrop-filter: none;
  box-shadow: none;
}

.uttu-euphoria-rank-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: #ECE5D9;
}

.uttu-euphoria-rank-desc {
  font-size: 0.82rem;
  line-height: 1.6;
  color: #D5D3CF;
  white-space: pre-line;
}

.uttu-euphoria-materials-row {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Keyword Highlighting Classes (UTTU-styled) */
.skill-kw-bracket {
  color: #4e6697;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline dotted rgba(78, 102, 151, 0.45);
  transition: color 0.15s ease, opacity 0.15s ease;
}

.skill-kw-bracket:hover {
  color: #60a5fa;
  text-decoration: underline solid #60a5fa;
}

.skill-kw-number {
  color: #c56030;
  font-weight: 700;
}

.skill-kw-stat {
  color: #a1800b;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline dotted rgba(161, 128, 11, 0.45);
  transition: color 0.15s ease, opacity 0.15s ease;
}

.skill-kw-stat:hover {
  color: #f59e0b;
  text-decoration: underline solid #f59e0b;
}

/* In-Game UTTU Term Tooltip Card (exact UTTU aesthetic) */
.uttu-term-popover {
  position: fixed;
  z-index: 10005;
  width: 360px;
  max-width: min(400px, calc(100vw - 32px));
  max-height: 60vh;
  background-color: rgba(27, 27, 27, 0.95);
  background-image: none;
  color: #e7e3db;
  border: 2px solid #333230;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.7);
  padding: 0;
  border-radius: 0;
  overflow: hidden;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  animation: uttuFadeIn 0.15s ease-out;
}

@keyframes uttuFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.uttu-term-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px 9px;
  background: rgba(35, 35, 35, 0.6);
  border-bottom: 1px solid #333230;
}

.uttu-term-popover-head-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.uttu-term-popover-title {
  font-family: var(--primary-font, Georgia, serif);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #e7e3db;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.uttu-term-popover-tag {
  font-size: 11px;
  padding: 2px 7px;
  background: #3c3c3c;
  color: #9d9d9b;
  border-radius: 0;
  text-transform: capitalize;
  font-family: var(--mono-font);
  flex-shrink: 0;
  line-height: 1.2;
}

.uttu-term-popover-close {
  background: transparent;
  border: none;
  color: #8a8882;
  font-size: 14px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s;
}

.uttu-term-popover-close:hover {
  color: #e7e3db;
}

.uttu-term-popover-body {
  padding: 12px 14px 14px;
  font-size: 13px;
  line-height: 1.6;
  color: #afaba3;
  white-space: pre-wrap;
  overflow-y: auto;
  flex: 1;
}

.uttu-term-popover-body .skill-kw-number {
  color: #c56030;
  font-weight: 700;
}

.uttu-term-popover-body .skill-kw-stat {
  color: #a1800b;
  font-weight: 700;
}

.uttu-term-popover-body .skill-kw-bracket {
  color: #4e6697;
  font-weight: 700;
}

/* Psychube detail view */
.psychube-detail-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.psychube-detail-hero {
  display: flex;
  align-items: center;
  gap: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.psychube-detail-icon-wrap {
  position: relative;
  width: 116px;
  height: 96px;
  flex: none;
}

.psychube-detail-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.psychube-detail-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.psychube-detail-name {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 24px;
  color: #ECE5D9;
  margin: 0;
}

.psychube-detail-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.psychube-detail-desc {
  font-size: 0.78rem;
  color: #B5B5B3;
  line-height: 1.6;
  white-space: pre-line;
  margin: 0;
}

.psychube-interactive-box {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.psychube-interactive-row {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.psychube-level-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.psychube-level-slider {
  width: 180px;
}

.psychube-level-number {
  font-family: var(--mono-font);
  font-size: 14px;
  font-weight: 700;
  color: #ECE5D9;
  min-width: 44px;
}

.psychube-amp-boxes {
  display: flex;
  gap: 8px;
}

.psychube-amp-btn {
  width: 34px;
  height: 34px;
  font-family: var(--mono-font);
  font-size: 13px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #B5B5B3;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.psychube-amp-btn:hover {
  border-color: #ED7D31;
  color: #fff;
}

.psychube-amp-btn.is-active {
  background: #ED7D31;
  border-color: #ED7D31;
  color: #fff;
  box-shadow: 0 0 8px rgba(237, 125, 49, 0.4);
}

.psychube-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.psychube-stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 2px;
}

.psychube-stat-name {
  font-size: 0.76rem;
  color: #a8a49c;
}

.psychube-stat-val {
  font-family: var(--mono-font);
  font-size: 0.88rem;
  font-weight: 700;
  color: #ECE5D9;
}

.psychube-amp-desc-box {
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.3);
  border-left: 3px solid #ED7D31;
  font-size: 0.84rem;
  line-height: 1.6;
  color: #D5D3CF;
}

.psychube-mats-breakdown {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.psychube-break-tiers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.psychube-break-tier {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.psychube-break-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: #ED7D31;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.psychube-break-mats {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* Glossary list in rail */
.glossary-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 14px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: #D5D3CF;
  cursor: pointer;
  transition: background 0.15s ease;
}

.glossary-row:hover {
  background: rgba(255, 255, 255, 0.05);
}

.glossary-row.is-active {
  background: rgba(237, 125, 49, 0.15);
  border-left: 3px solid #ED7D31;
  color: #fff;
}

.glossary-row-title {
  font-family: var(--primary-font, Georgia, serif);
  font-size: 0.82rem;
  font-weight: 700;
  color: #ECE5D9;
}

.glossary-row-tag {
  font-size: 0.65rem;
  color: #8f8a83;
}

/* Glossary Detail Card */
.glossary-detail-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.glossary-detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.glossary-detail-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 26px;
  color: #ECE5D9;
  margin: 0;
}

.glossary-detail-tag {
  font-size: 0.72rem;
  padding: 3px 8px;
  background: #3c3c3c;
  color: #ECE5D9;
  border-radius: 2px;
  text-transform: capitalize;
}

.glossary-detail-body {
  font-size: 0.9rem;
  line-height: 1.7;
  color: #D5D3CF;
  white-space: pre-wrap;
}

/* Promotional codes: rail rows */
.codes-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  text-align: left;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: #D5D3CF;
  cursor: pointer;
  transition: background 0.15s ease;
}

.codes-row:hover {
  background: rgba(255, 255, 255, 0.05);
}

.codes-row.is-active {
  background: rgba(237, 125, 49, 0.15);
  border-left: 3px solid #ED7D31;
  color: #fff;
}

.codes-row-code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #ECE5D9;
  word-break: break-all;
}

.codes-row-meta {
  flex: 0 0 auto;
  font-size: 0.62rem;
  color: #8f8a83;
}

/* Promotional codes: detail card */
.codes-detail-card {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.codes-detail-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.codes-code-line {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.codes-code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 28px;
  letter-spacing: 1.5px;
  color: #ECE5D9;
  word-break: break-all;
}

.codes-copy.is-copied {
  border-color: #ED7D31;
  color: #ED7D31;
}

.codes-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.codes-badge {
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 2px;
  background: #3c3c3c;
  color: #ECE5D9;
}

.codes-badge-permanent {
  background: rgba(233, 196, 106, 0.16);
  color: #E9C46A;
}

.codes-badge-date {
  background: rgba(237, 125, 49, 0.16);
  color: #ED9C63;
}

.codes-badge-unknown {
  background: rgba(255, 255, 255, 0.06);
  color: #8f8a83;
}

.codes-badge-expired {
  background: rgba(224, 122, 95, 0.18);
  color: #E07A5F;
}

.codes-badge-stale {
  background: rgba(255, 255, 255, 0.06);
  color: #8f8a83;
  font-style: italic;
}

.codes-rewards-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
}

.codes-reward {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 68px;
}

.codes-reward-name {
  font-size: 0.62rem;
  line-height: 1.25;
  color: #D5D3CF;
  text-align: center;
  word-break: break-word;
}

.codes-source {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.72rem;
  color: #8f8a83;
}

.codes-source a {
  color: #ED9C63;
  text-decoration: none;
}

.codes-source a:hover {
  text-decoration: underline;
}

.codes-empty-text {
  font-size: 0.85rem;
  color: #8f8a83;
}

.codes-detail-error {
  align-items: flex-start;
}

.codes-error-text {
  margin: 0;
  font-size: 0.95rem;
  color: #ECE5D9;
}

.codes-error-detail {
  margin: 0;
  font-size: 0.72rem;
  color: #8f8a83;
  word-break: break-word;
}

/* A narrow detail pane stacks the chart over the loadout cards. */
@media (max-width: 980px) {
  .builds-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---- InfoBook: narrower screens ---- */

/* Below a full desktop the fixed 264px rail eats the detail pane, so it
   narrows first and only then gives up its column. */
@media (max-width: 1180px) {
  .builds-rail { flex-basis: 228px; }
  .builds-rail-tools { padding: 12px 12px 10px; }
  .builds-detail { padding: 18px 20px 24px; gap: 18px; }
  .builds-hero-portrait { width: 64px; height: 64px; }
  .builds-hero-name { font-size: 23px; }
  .build-chart { gap: 14px; }
}

@media (max-width: 900px) {
  .builds-rail { flex-basis: 200px; }
  .builds-row-portrait { width: 30px; height: 30px; }
  .builds-row-name { font-size: 0.66rem; }
  .builds-rail-tools .search-input { height: 30px; font-size: 0.66rem; }
  .builds-afflatus-btn { height: 24px; }
}

/* Phones: side by side leaves a ~90px detail pane, so the list stacks on top. */
@media (max-width: 768px) {
  .builds-modal-card {
    height: min(92vh, 900px);
    max-height: 92dvh;
  }

  /* Row 1: Back + title. Row 2: the mode tabs, which wrap instead of
     overflowing the modal's header on a phone. */
  #builds-modal .archetype-modal-header {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 44px 10px 12px;
  }

  #builds-modal .archetype-modal-title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 19px;
    line-height: 1.2;
  }

  .builds-back { order: -1; padding-right: 6px; }

  .builds-header-actions {
    flex: 1 1 100%;
    margin-left: 0;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
  }

  .builds-mode-group {
    flex: 1 1 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
  }

  .builds-mode-btn {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0 7px;
    font-size: 0.56rem;
    letter-spacing: 0.03em;
  }

  .builds-header-actions .modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
  }

  /* The list/detail split is replaced by a master-detail flow on phones. */
  .builds-rail-toggle { display: none; }

  .builds-body { flex-direction: column; }

  .builds-rail {
    flex: 1 1 auto;
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  /* List view: the rail fills the body and the detail is not shown. */
  .builds-body .builds-detail { display: none; }
  .builds-body.is-list-hidden .builds-rail { display: flex; }

  /* Detail view: the picked entry takes the whole body. */
  .builds-body.is-detail .builds-rail { display: none; }
  .builds-body.is-detail .builds-detail { display: flex; flex: 1 1 auto; }

  /* No draggable separator on phones: each pane is shown on its own. */
  .builds-body .guide-rail-resizer { display: none; }

  .builds-rail-tools { padding: 10px 12px 8px; gap: 6px; }
  .builds-rail-tools .search-input { height: 32px; font-size: 0.7rem; }

  .builds-rarity-group { height: 26px; }
  .builds-rarity-group .filter-btn { font-size: 0.58rem; }
  .builds-afflatus-btn { height: 26px; }
  .builds-afflatus-btn img { width: 14px; height: 14px; }

  .builds-list { padding: 4px 6px; }

  /* The items list now spans the whole modal, so three fixed columns would blow
     each sticker up to ~230px. Add columns and cap them at icon scale instead. */
  .items-grid-container {
    grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
    justify-items: center;
  }

  .items-grid-container .item-sticker { max-width: 96px; }
  .builds-row { padding: 6px 8px; gap: 9px; }
  .builds-row-portrait { width: 34px; height: 34px; }
  .builds-row-name { font-size: 0.72rem; }
  .builds-row-stars { font-size: 0.5rem; }
  .builds-rail-footer { padding: 6px 12px 8px; }
  .builds-count { font-size: 0.52rem; }

  .builds-detail {
    flex: 1 1 auto;
    min-height: 0;
    padding: 14px 12px 20px;
    gap: 16px;
  }

  .builds-hero { gap: 12px; padding-bottom: 12px; }
  .builds-hero-portrait { width: 54px; height: 54px; }
  .builds-hero-name { font-size: 20px; }
  .builds-hero-stars { font-size: 0.66rem; letter-spacing: 0.14em; }

  .build-section { padding: 12px; gap: 12px; }
  .build-section-title { font-size: 0.54rem; }

  .build-charts { gap: 12px; }
  .build-chart { gap: 10px; min-height: 118px; padding: 0; }
  .build-charts.is-many {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 12px;
  }
  .build-charts.is-many .build-chart-block { height: 124px; }
  .build-charts.is-many .build-chart { min-height: 92px; }
  .build-chart-track { max-width: 36px; }
  .build-chart-val { font-size: 0.56rem; }
  .build-chart-badge { font-size: 0.54rem; }

  .build-psychube { gap: 10px; }
  .build-psychube img,
  .build-psychube-blank { width: 44px; height: 53px; }
  .build-psychube-name { font-size: 0.74rem; }
  .build-resonance-btn { font-size: 0.62rem; }
  .build-notes { font-size: 0.68rem; }

  /* Skills & Insight Details responsive adjustments on mobile */
  .uttu-mode-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .uttu-mode-btn {
    height: 28px;
    padding: 0 10px;
    font-size: 0.6rem;
    flex: 1 1 auto;
    text-align: center;
  }
  .uttu-stance-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    width: 100%;
  }
  .uttu-stance-btn {
    flex: 1 1 auto;
    padding: 0 8px;
    height: 26px;
    font-size: 0.6rem;
    text-align: center;
  }
  .uttu-cards-strip {
    padding: 8px 10px;
    gap: 10px;
  }

  /* Ezio weapon board responsive adjustments */
  .ezio-weapon-board {
    overflow-x: hidden;
  }
  .ezio-weapon-stage {
    grid-template-columns: minmax(110px, 1fr) auto minmax(110px, 1fr);
    gap: 8px;
    padding: 12px 6px;
    overflow-x: auto;
  }
  .ezio-weapon-card {
    padding: 6px 4px;
  }
  .ezio-weapon-box {
    width: 54px;
    height: 54px;
  }
  .ezio-weapon-label {
    font-size: 0.65rem;
  }
  .ezio-weapon-center-preview {
    gap: 6px;
    padding: 6px 2px;
  }
  .ezio-center-slot {
    width: 80px;
    min-width: 80px;
    max-width: 80px;
    height: 105px;
    padding: 6px 4px;
  }
  .ezio-center-box {
    width: 48px;
    height: 48px;
  }
  .ezio-center-name {
    font-size: 0.62rem;
  }
  .ezio-center-cross {
    font-size: 1rem;
  }
  .ezio-weapon-detail-paper {
    padding: 14px 12px;
  }

  /* Item & psychube detail: the icon shrinks and sits beside the title, so the
     description gets the full width of the card instead of a narrow column. */
  .material-detail-hero,
  .psychube-detail-hero {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    column-gap: 12px;
    row-gap: 6px;
    padding-bottom: 12px;
  }

  .material-detail-icon-wrap {
    grid-column: 1;
    grid-row: 1 / span 2;
    width: 54px;
    height: 54px;
  }

  .psychube-detail-icon-wrap {
    grid-column: 1;
    grid-row: 1 / span 2;
    width: 72px;
    height: 60px;
  }

  /* Dissolving the wrapper lets its children line up on the hero's grid. */
  .material-detail-info,
  .psychube-detail-info {
    display: contents;
  }

  .material-detail-name,
  .psychube-detail-name {
    grid-column: 2;
    grid-row: 1;
    align-self: end;
    font-size: 20px;
    line-height: 1.15;
  }

  .material-detail-stars,
  .psychube-detail-stars {
    grid-column: 2;
    grid-row: 2;
    align-self: start;
  }

  .material-detail-info > .flag,
  .material-detail-desc,
  .material-detail-usage,
  .material-detail-source,
  .psychube-detail-tags,
  .psychube-detail-desc {
    grid-column: 1 / -1;
  }

  .material-detail-desc,
  .psychube-detail-desc {
    margin-top: 2px;
  }

  /* Psychube interactive responsive adjustments */
  .psychube-interactive-box {
    padding: 12px;
  }

  .psychube-interactive-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .psychube-level-input-wrap {
    width: 100%;
    justify-content: space-between;
  }
  .psychube-level-slider {
    flex: 1 1 100px;
    min-width: 0;
    width: auto;
  }
  .psychube-amp-boxes {
    gap: 6px;
  }
  .psychube-amp-btn {
    width: 30px;
    height: 30px;
    font-size: 11px;
  }
  .psychube-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Inheritance and Portray typography and width */
  .uttu-insight-row {
    flex-direction: row;
    align-items: flex-start;
    gap: 10px;
    padding: 4px 0 6px 0;
  }
  .uttu-insight-badge-col {
    flex-direction: column;
    align-items: center;
    width: var(--uttu-insight-icon);
    padding-top: 0;
  }
  .uttu-insight-content {
    flex: 1;
    min-width: 0;
  }
  .uttu-insight-tag {
    font-size: 0.88rem;
    line-height: 1.2;
  }
  .uttu-insight-desc {
    width: 100%;
    font-size: 0.82rem;
  }
  .uttu-portray-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 8px 0;
  }
  .uttu-portray-lvl {
    width: 100%;
  }
  .uttu-portray-desc {
    width: 100%;
    font-size: 0.78rem;
  }
}

/* ================= SKILL ROTATIONS ================= */

#rotations-modal { z-index: 1000; }

.rotations-modal-card {
  max-width: 1320px;
  width: 100%;
  height: min(90vh, 860px);
}

/* The modal pops in from slightly below, a touch deeper than the other modals. */
#rotations-card {
  animation: rotationsModalIn 0.32s cubic-bezier(0.16, 0.84, 0.32, 1) both;
}

@keyframes rotationsModalIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.975);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Cards follow the modal in, one after another, so the list reads as it lands. */
.rotation-card {
  animation: rotationsCardIn 0.3s cubic-bezier(0.16, 0.84, 0.32, 1) both;
  animation-delay: calc(var(--card-index, 0) * 28ms);
}

@keyframes rotationsCardIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Opening a plan: the hero settles first, then each block slides up. */
#rotations-card.is-detail .rot-hero {
  animation: rotationsBlockIn 0.26s ease-out both;
}

#rotations-card.is-detail .rot-block {
  animation: rotationsBlockIn 0.3s ease-out both;
  animation-delay: calc(60ms + var(--block-index, 0) * 45ms);
}

@keyframes rotationsBlockIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Stagger the plan's sections in reading order. */
#rotations-card.is-detail .rot-block:nth-of-type(1) { --block-index: 0; }
#rotations-card.is-detail .rot-block:nth-of-type(2) { --block-index: 1; }
#rotations-card.is-detail .rot-block:nth-of-type(3) { --block-index: 2; }
#rotations-card.is-detail .rot-block:nth-of-type(4) { --block-index: 3; }

/* Respect the OS "reduce motion" preference: show everything immediately. */
@media (prefers-reduced-motion: reduce) {
  #rotations-card,
  .rotation-card,
  #rotations-card.is-detail .rot-hero,
  #rotations-card.is-detail .rot-block {
    animation: none;
  }
}

.rotations-header-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.rotations-header-tools .search-input {
  width: 210px;
  height: 30px;
  font-size: 0.68rem;
}

/* Back button: hidden on the list, top-left of the header on a rotation's plan. */
.rotations-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 2px 10px 2px 2px;
  margin-right: 2px;
  font: inherit;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #B5B5B3;
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.12s ease;
}

.rotations-back[hidden] { display: none; }

.rotations-back img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  display: block;
  transition: transform 0.12s ease;
}

.rotations-back:hover { color: #fff; }
.rotations-back:hover img { transform: translateX(-2px); }

.rotations-body {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

/* ---- Left rail: filters, a separator, then the rotation list ---- */

.rotations-browse {
  flex: 0 0 300px;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 18px 26px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
}

.rotations-browse-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.rotations-browse-separator {
  flex: none;
  height: 1px;
  margin: 6px 0;
  background: rgba(255, 255, 255, 0.12);
}

.rotations-browse-count {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.56rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8f8a83;
}

/* List and plan are both visible: the rail on the left, the plan on the right. */
.rotations-body.is-list-hidden .rotations-browse {
  display: none;
}

.rotations-body.is-list-hidden .rotations-detail {
  flex: 1 1 100%;
}

/* Header toggle for the list. */
.rotations-rail-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.rotations-rail-toggle-icon {
  width: 13px;
  height: 13px;
  object-fit: contain;
  display: block;
  opacity: 0.85;
}

.rotations-clear {
  font: inherit;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.56rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 2px 8px;
  color: #8f8a83;
  background: none;
  border: 1px solid rgba(181, 181, 179, 0.3);
  cursor: pointer;
}

.rotations-clear:hover { color: #fff; border-color: #EBE3D7; }

.rotations-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.rotation-filter {
  font: inherit;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.56rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  color: #B5B5B3;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(181, 181, 179, 0.35);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.rotation-filter:hover { color: #fff; border-color: #EBE3D7; }

.rotation-filter.is-active {
  color: #fff;
  border-color: #ED7D31;
  background: rgba(208, 81, 38, 0.24);
}

/* Rotation cards sit in the left rail, so they are a single column that fits
   the rail's width instead of the old multi-column grid. */
.rotations-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.rotation-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  padding: 8px 9px 9px;
  background: var(--team-card-bg);
  border: 1px solid rgba(50, 60, 52, 0.35);
  color: #1f1c19;
  cursor: pointer;
  text-align: left;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.rotation-card:hover { border-color: #D05126; }

.rotation-card:focus-visible {
  outline: 2px solid #ED7D31;
  outline-offset: 1px;
}

.rotation-card.is-active {
  border-color: #D05126;
  box-shadow: inset 0 0 0 1px rgba(208, 81, 38, 0.55);
}

.rotation-card-top {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
}

.rotation-card-name {
  flex: 1;
  min-width: 0;
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.rotation-card-tuning {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex: none;
  display: block;
  margin-top: 1px;
}

.rotation-card-team {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  min-width: 0;
}

.rotation-card-face {
  width: 32px;
  height: 32px;
  overflow: hidden;
  background: #2a2825;
  border: 1px solid rgba(31, 28, 25, 0.25);
  display: block;
  flex: none;
}

.rotation-card-face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rotation-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.rotation-card-tag {
  padding: 1px 6px;
  border: 1px solid rgba(31, 28, 25, 0.35);
  background: rgba(255, 255, 255, 0.28);
  color: #2a2622;
  font-size: 0.5rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Preset marker: the card is a read-only copy of a bundled rotation. */
.rotation-card-tag.is-preset {
  border-color: rgba(160, 60, 20, 0.55);
  background: rgba(208, 81, 38, 0.16);
  color: #7d2f10;
}

/* Remove-from-list button on a rotation card. */
.rotation-card-remove {
  flex: none;
  width: 18px;
  height: 18px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(31, 28, 25, 0.3);
  background: rgba(255, 255, 255, 0.22);
  color: #3a332c;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.rotation-card-remove:hover {
  background: rgba(208, 81, 38, 0.85);
  border-color: #D05126;
  color: #FFFFFF;
}

.rotation-card-remove:focus-visible {
  outline: 2px solid #ED7D31;
  outline-offset: 1px;
}

/* ---- Rotation presets modal ---- */

.rotation-presets-backdrop {
  z-index: 1200;
}

.rotation-presets-card {
  max-width: 1080px;
  width: 100%;
  height: min(86vh, 820px);
}

.rotation-presets-body {
  overflow-y: auto;
  gap: 12px;
  /* The presets grid scrolls inside the card instead of being capped by the
     shared modal-body limit. */
  max-height: none;
  flex: 1;
  min-height: 0;
}

/* Preset cards reuse the rotation card's look; the grid decides how many fit
   per row, so the same card works at one, two or three columns. */
.rotation-presets-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: stretch;
}

/* The presets modal's own archetype filter, above the hint and the grid. */
.rotations-presets-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.rotation-presets-list .rotation-card {
  cursor: default;
}

.rotation-presets-list .rotation-card:hover {
  border-color: rgba(50, 60, 52, 0.35);
}

.rotation-preset.is-added {
  opacity: 0.55;
}

/* Add action sits under the card's own content, on the card's light surface. */
.rotation-preset-add {
  align-self: stretch;
  margin-top: auto;
  height: 26px;
  padding: 0 10px;
  border: 1px solid rgba(31, 28, 25, 0.45);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.34);
  color: #241f1b;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.rotation-preset-add:hover:not(:disabled) {
  background: #D05126;
  border-color: #D05126;
  color: #FFFFFF;
}

.rotation-preset-add:focus-visible {
  outline: 2px solid #ED7D31;
  outline-offset: 1px;
}

.rotation-preset-add:disabled {
  cursor: default;
  opacity: 0.6;
}

@media (max-width: 1000px) {
  .rotation-presets-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .rotation-presets-list {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---- Detail pane ---- */

.rotations-detail {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 20px 26px 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.rot-hero {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* The title and the share button share one line; the tags stay under both. */
.rot-hero-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.rot-hero-head .rot-hero-name {
  min-width: 0;
}

.rot-hero-name {
  margin: 0;
  font-family: 'Amiri', var(--serif-font);
  font-size: 31px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #ECE5D9;
}

.rot-hero-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.rot-hero-tag {
  padding: 3px 10px;
  /* The old chip shape, with the fill dropped so the words stand alone. */
  border: 1px solid #ED7D31;
  background: none;
  color: #ED7D31;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Raid and Focused Flashback lead the chips and carry their own colour. */
.rot-hero-tag[data-archetype="Raid"] { color: #F5E1C3; border-color: #F5E1C3; }
.rot-hero-tag[data-archetype="Focused Flashback"] { color: #A5B9E7; border-color: #A5B9E7; }

.rot-block {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rot-block .archetype-section-header { margin: 0; }

/* The plan's own headers (Team, Notes, Rounds) all use the banner's spine. */
#rotations-card .rot-block > .archetype-section-header {
  border-left-color: #E09532;
  background:
    linear-gradient(90deg, rgba(94, 69, 36, 0.4) 0%, rgba(0, 0, 0, 0.4) 45%, rgba(0, 0, 0, 0.4) 100%);
}

/* The tuning ability closes the team row. It carries the same surface and
   hairline border as a member tile, so the row reads as one strip. */
.rot-team-tuning {
  flex: none;
  align-self: stretch;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px 14px;
  border: 1px solid rgba(181, 181, 179, 0.3);
  background: rgba(0, 0, 0, 0.22);
}

/* Sized like the member portraits, so the icon carries the tile. */
.rot-team-tuning img {
  width: auto;
  height: 56px;
  max-width: 84px;
  object-fit: contain;
  display: block;
}

.rot-team {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.rot-member {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px 7px 7px;
  border: 1px solid rgba(181, 181, 179, 0.3);
  background: rgba(0, 0, 0, 0.22);
}

.rot-member-avatar {
  display: flex;
  flex-direction: column;
  flex: none;
}

.rot-member-portrait {
  width: 56px;
  height: 56px;
  overflow: hidden;
  background: #2a2825;
  display: block;
  flex: none;
}

.rot-member-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Portrait bar under the avatar: five dashes, same look as the board cards. */
.rot-member-portrait-bar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  height: 3px;
  margin: 2px -1px 0;
  width: calc(100% + 2px);
  box-sizing: border-box;
}

.rot-member-portrait-bar .portrait-dash {
  height: 100%;
  min-width: 0;
}

.rot-member-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.rot-member-name {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.74rem;
  color: #ECE5D9;
}

.rot-member-chube {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.56rem;
  color: #8f8a83;
}

.rot-member-chube img {
  width: 26px;
  height: 31px;
  object-fit: contain;
  display: block;
  flex: none;
}

/* ---- Rounds ---- */

.rot-rounds {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* Rounds and the rail of round notes beside them. Only a rotation that has a
   round note reserves the room for it. */
.rot-rounds-body {
  position: relative;
  overflow-x: auto;
  overflow-y: visible;
  padding-bottom: 8px;
}
.rot-rounds-body.has-round-notes {
  padding-right: 150px;
}

/* Rounds Scale Control in header */
.rot-scale-control {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.65rem;
  color: #B5B5B3;
  user-select: none;
}

.rot-scale-label {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ECE5D9;
}

.rot-scale-slider {
  width: 90px;
  height: 4px;
  accent-color: #E8A33D;
  cursor: pointer;
}

.rot-scale-val {
  min-width: 32px;
  text-align: right;
  font-family: var(--mono-font, monospace);
  font-size: 0.64rem;
  color: #F0E6D2;
}

.rot-scale-reset {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #B5B5B3;
  padding: 1px 6px;
  font-size: 0.6rem;
  cursor: pointer;
  border-radius: 0;
  transition: all 0.15s ease;
}

.rot-scale-reset:hover {
  border-color: #E8A33D;
  color: #FFFFFF;
}

.rot-rounds-column {
  display: flex;
  flex-direction: column;
  gap: calc(22px * var(--rot-scale, 1));
}

.rot-round-notes-rail {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.rot-round-notes-rail-svg {
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible;
}

.rot-round-note-label {
  position: absolute;
  transform: translateY(-50%);
  font-family: var(--main-font-family);
  font-size: 0.72rem;
  line-height: 1.35;
  color: #F0E6D2;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  white-space: nowrap;
}

/* A round is a bracketed number in a gutter beside its cards, the way the plan
   sheets were written. Nothing else frames the strip. */
.rot-round {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: calc(10px * var(--rot-scale, 1));
  align-items: start;
}

/* The number sits at the top of the gutter, level with the top of the cards,
   inside an L-shaped bracket. Zero-padded, so a ten-round plan still lines up. */
/* The number is an amber bracket cut from the sheet: two rounded corners, the
   number set in Amiri over whatever the gutter shows through. It sits level with
   the top of the cards. */
.rot-round-no {
  position: relative;
  grid-column: 1;
  grid-row: 2;
  align-self: start;
  justify-self: start;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Sits level with the card strip, like the plan sheets. */
  margin-top: calc(24px * var(--rot-scale, 1));
  width: calc(36px * var(--rot-scale, 1));
  height: calc(36px * var(--rot-scale, 1));
  box-sizing: border-box;
  background: transparent;
  border: calc(2px * var(--rot-scale, 1)) solid #E09532;
  border-radius: 0 calc(9px * var(--rot-scale, 1)) 0 calc(10px * var(--rot-scale, 1));
  font-family: 'Amiri', var(--serif-font);
  font-size: calc(1.4rem * var(--rot-scale, 1));
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  color: #EADCC9;
}

/* The round note is the round's title: a plaque cut from the same material as
   the section headers, with an orange spine and serif capitals. It spans the
   whole round so the plaque starts at the Rounds header's left edge, above the
   number gutter, rather than lining up with the cards. */
.rot-round-head {
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: calc(10px * var(--rot-scale, 1));
  flex-wrap: wrap;
  min-height: 0;
  margin-bottom: calc(8px * var(--rot-scale, 1));
}

/* The round note is the round's title: a plaque cut from the same material as
   the sheet labels, with the amber spine and serif capitals. */
.rot-round-note {
  display: inline-flex;
  align-items: center;
  min-height: calc(24px * var(--rot-scale, 1));
  padding: 0 calc(14px * var(--rot-scale, 1)) 0 calc(11px * var(--rot-scale, 1));
  border-left: calc(4px * var(--rot-scale, 1)) solid #E09532;
  background: linear-gradient(
    90deg,
    #5E4524 0%,
    rgba(94, 69, 36, 0.75) 25%,
    rgba(94, 69, 36, 0.5) 50%,
    rgba(94, 69, 36, 0.25) 75%,
    rgba(94, 69, 36, 0) 100%
  );
  font-family: 'Amiri', var(--serif-font);
  font-size: calc(0.9rem * var(--rot-scale, 1));
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
  color: #DFDFDF;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

/* Cards sit edge to edge; the card border is the only gutter. */
.rot-round-slots {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  /* Every card is 5px from its neighbour, whatever shape it is. */
  gap: calc(5px * var(--rot-scale, 1));
  flex-wrap: nowrap;
  align-items: flex-end;
  width: max-content;
}

.rot-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: calc(4px * var(--rot-scale, 1));
  padding: 0;
  /* One shared height keeps every card on the same baseline. */
  height: calc(132px * var(--rot-scale, 1));
  box-sizing: border-box;
  border: none;
  background: none;
  flex-shrink: 0;
}

/* The card area sits above a small type caption, so AP, OR, 1/4 AP and TEXT
   all line up and each slot says what kind of card it is. */
.rot-slot-body {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
  box-sizing: border-box;
}

/* The caption under a card is a quiet label, not a tag: tags are the parchment
   plates, this is plain type. */
.rot-slot-type {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: calc(0.46rem * var(--rot-scale, 1));
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #6f6a63;
  line-height: 1;
  white-space: nowrap;
}

/* A caption that repeats what the card already shows keeps the space, not the
   ink, so every slot stays on the same baseline. */
.rot-slot-type.is-plain { visibility: hidden; }

/* The placeholder an empty slot shows: the plate face, dimmed, so it reads as
   "no card yet" rather than as art. */
.rot-slot.is-empty .rot-slot-body {
  width: calc(62px * var(--rot-scale, 1));
  height: calc(82px * var(--rot-scale, 1));
  padding-top: 0;
  border: 1px dashed rgba(181, 181, 179, 0.16);
  box-sizing: border-box;
}

.rot-card.is-empty {
  height: 100%;
  aspect-ratio: 164 / 217;
  opacity: 0.55;
}

.rot-card.is-empty .rot-card-art {
  border: none;
  box-shadow: none;
}

/* A text slot is a note chip: wider than one card, with room to read. */
.rot-slot.is-text .rot-slot-body {
  width: calc(132px * var(--rot-scale, 1));
  min-height: calc(81px * var(--rot-scale, 1));
  padding: calc(8px * var(--rot-scale, 1)) calc(10px * var(--rot-scale, 1));
  align-items: center;
  justify-content: flex-start;
  background: rgba(74, 119, 201, 0.18);
  border: 1px solid rgba(122, 160, 224, 0.45);
  box-sizing: border-box;
  overflow: hidden;
}

.rot-slot-text {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: calc(0.58rem * var(--rot-scale, 1));
  line-height: 1.45;
  color: #DCE6F5;
  text-align: left;
  word-break: break-word;
}

.rot-slot.is-text .rot-slot-type {
  color: #7d94b8;
}

/* Either/or: both cards shrink and overlap, so the pair reads as one slot while
   the back card still peeks out from behind the front one. The stack is exactly
   as wide as the two cards it holds, so the 5px gap to its neighbours stays even. */
.rot-slot.is-or .rot-slot-body { width: calc(78px * var(--rot-scale, 1)); justify-content: flex-start; }
.rot-slot.is-double-or .rot-slot-body { width: calc(88px * var(--rot-scale, 1)); justify-content: flex-start; }
.rot-or-stack { position: relative; width: calc(78px * var(--rot-scale, 1)); height: calc(86px * var(--rot-scale, 1)); }
.rot-or-stack.is-double { width: calc(88px * var(--rot-scale, 1)); height: calc(92px * var(--rot-scale, 1)); }
.rot-or-stack > .rot-card:not(.is-behind):not(.is-mid) { position: absolute; left: 0; bottom: 0; z-index: 3; }
.rot-or-stack > .rot-card { height: calc(66px * var(--rot-scale, 1)); }
.rot-card.is-mid {
  position: absolute;
  left: calc(18px * var(--rot-scale, 1));
  bottom: calc(13px * var(--rot-scale, 1));
  z-index: 2;
  opacity: 0.95;
  filter: brightness(0.85);
}
.rot-card.is-behind {
  position: absolute;
  left: calc(27px * var(--rot-scale, 1));
  bottom: calc(20px * var(--rot-scale, 1));
  z-index: 1;
  opacity: 0.95;
  filter: brightness(0.7);
}
.rot-or-stack.is-double .rot-card.is-behind {
  left: calc(36px * var(--rot-scale, 1));
  bottom: calc(26px * var(--rot-scale, 1));
}
/* An ultimate inside an OR stack keeps its arch but has to fit the stack, so it
   is drawn shorter than a standalone ultimate. */
.rot-or-stack > .rot-card.is-ultimate { height: calc(80px * var(--rot-scale, 1)); }

/* A card is its art. The box keeps a fixed height so every card in a round sits
   on one baseline; the width follows the art's aspect ratio. */
.rot-card {
  display: block;
  flex: none;
  position: relative;
  height: calc(84px * var(--rot-scale, 1));
  aspect-ratio: 288 / 376;
}

.rot-card-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  z-index: 2;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.rot-slot:hover .rot-card:not(.is-behind):not(.is-mid) .rot-card-art {
  border-color: rgba(237, 125, 49, 0.55);
  transform: translateY(-2px);
}

.rot-card.is-mid .rot-card-art,
.rot-card.is-behind .rot-card-art {
  border: none;
  box-shadow: none;
}

/* The Ultimate plate is opaque in the middle, so the art is drawn ON TOP of it,
   clipped to the plate's inner window (x 12–172, y 23–294 of a 183×315 card). */
.rot-card.is-ultimate {
  height: calc(126px * var(--rot-scale, 1));
  aspect-ratio: 183 / 315;
}

.rot-card.is-ultimate .rot-card-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
  pointer-events: none;
}

.rot-card.is-ultimate .rot-card-art {
  left: 6.56%;
  top: 7.30%;
  width: 87.98%;
  height: 86.35%;
  border: none;
  box-shadow: none;
  border-radius: 50% 50% 0 0 / 22% 22% 0 0;
}

/* A surface is decoration laid straight over the card, at the card's own size. */
.rot-card-surface {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 3;
  pointer-events: none;
}

/* The preferred side of an either/or slot. */
.rot-card.is-preferred::after {
  content: "";
  position: absolute;
  inset: -2px;
  border: 2px solid #e05a4f;
  border-radius: 4px;
  pointer-events: none;
  z-index: 4;
}

/* ---- slot tags ---- */

/* A tag is a ribbon cut from the plan-sheet language: ink that fades into the
   art, a screen-printed halftone tail, and Amiri set in white. The ink is per
   kind, so AP Free, Precast and an authored tag read apart at a glance. */
.rot-card > .rot-tag-plate {
  --tag-ink: #CCA329;
  --tag-ink-soft: rgba(204, 163, 41, 0.5);
  --tag-ink-none: rgba(204, 163, 41, 0);

  position: absolute;
  left: 0;
  top: calc(6px * var(--rot-scale, 1));
  z-index: 4;
  display: inline-flex;
  align-items: center;
  /* The ribbon is cut from the card itself: it starts at the card's left edge and
     runs to the right one, so it reads as part of the card rather than a chip
     floating inside it. */
  width: 100%;
  max-width: 100%;
  height: calc(16px * var(--rot-scale, 1));
  /* Only the left pad is real breathing room. The halftone tail is drawn under
     the words, so the ribbon never withholds width the label needs: on a plan
     card that is barely 60px wide, 14px of reserved tail would force the text
     to clip. */
  padding: 0 calc(8px * var(--rot-scale, 1)) 0 calc(6px * var(--rot-scale, 1));
  box-sizing: border-box;
  font-family: 'Amiri', var(--serif-font);
  font-size: calc(11px * var(--rot-scale, 1));
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.01em;
  color: #FFFFFF;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
  white-space: nowrap;
  overflow: hidden;
  pointer-events: none;
  background: linear-gradient(
    90deg,
    var(--tag-ink) 0%,
    var(--tag-ink-soft) 90%,
    var(--tag-ink-none) 100%
  );
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

/* The halftone tail: a dark dot screen that carries the fade off the card. */
.rot-card > .rot-tag-plate::after {
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  width: calc(14px * var(--rot-scale, 1));
  height: 100%;
  background: rgba(26, 26, 26, 0.78);  -webkit-mask-image: radial-gradient(circle, #000 0.9px, transparent 1.3px);
  -webkit-mask-size: calc(4px * var(--rot-scale, 1)) calc(4px * var(--rot-scale, 1));
  mask-image: radial-gradient(circle, #000 0.9px, transparent 1.3px);
  mask-size: calc(4px * var(--rot-scale, 1)) calc(4px * var(--rot-scale, 1));
  opacity: 0.85;
  transform: skewX(-10deg) scaleY(1.15);
}

/* Precast keeps the sheet's amber; a custom tag takes a cool steel ink so a
   note about a character never reads as an AP rule. */
.rot-card > .rot-tag-plate.is-plaque {
  --tag-ink: #D97B1F;
  --tag-ink-soft: rgba(217, 123, 31, 0.5);
  --tag-ink-none: rgba(217, 123, 31, 0);
}
.rot-card > .rot-tag-plate[data-tag="custom"] {
  --tag-ink: #6E88AC;
  --tag-ink-soft: rgba(110, 136, 172, 0.5);
  --tag-ink-none: rgba(110, 136, 172, 0);
}

.rot-card > .rot-tag-plate > .rot-tag-plate-text {
  position: relative;
  z-index: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* When both tags sit on one card the plaque drops clear of the badge. */
.rot-card.has-badge > .rot-tag-plate.is-plaque { top: calc(27px * var(--rot-scale, 1)); }

/* An Ultimate card is an arch, so its top corner is empty: the ribbon drops to
   where the art begins, the way the plan sheets draw it. */
.rot-card.is-ultimate > .rot-tag-plate { top: calc(30px * var(--rot-scale, 1)); }
.rot-card.is-ultimate.has-badge > .rot-tag-plate.is-plaque { top: calc(51px * var(--rot-scale, 1)); }

/* A Tuning slot keeps the AP box as a text box; the tuning card shrinks into
   its bottom-right corner so the note and the art never overlap. */
.rot-slot.is-tuning .rot-slot-body { width: calc(62px * var(--rot-scale, 1)); justify-content: center; }
.rot-slot-tuning {
  position: relative;
  display: block;
  width: calc(62px * var(--rot-scale, 1));
  height: calc(81px * var(--rot-scale, 1));
  box-sizing: border-box;
  border: 1px solid rgba(237, 125, 49, 0.55);
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.rot-slot-tuning-note {
  position: absolute;
  top: calc(4px * var(--rot-scale, 1));
  left: calc(4px * var(--rot-scale, 1));
  right: calc(4px * var(--rot-scale, 1));
  /* The extra reserve keeps long notes clear of the corner card. */
  bottom: calc((4px + var(--tuning-reserve, 0px)) * var(--rot-scale, 1));
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: calc(0.6rem * var(--rot-scale, 1));
  line-height: 1.25;
  color: #ECE5D9;
  text-align: left;
  /* Words never break mid-word; the fit pass shrinks the type instead. */
  word-break: keep-all;
  overflow-wrap: normal;
  hyphens: none;
  overflow: hidden;
  white-space: normal;
}
.rot-slot-tuning-note.is-empty { display: none; }
.rot-slot-tuning-card {
  position: absolute;
  right: calc(3px * var(--rot-scale, 1));
  bottom: calc(3px * var(--rot-scale, 1));
  z-index: 1;
}
.rot-slot-tuning-card .rot-card {
  height: calc(30px * var(--rot-scale, 1));
}
.rot-slot.is-tuning .rot-slot-type { color: #ED7D31; }

/* A quarter-size (LB) card is drawn at a quarter of the normal area. The slot
   keeps no padding, so the 5px gap to its neighbours stays even. */
.rot-slot.is-lb .rot-slot-body { padding: 0; }
.rot-card.is-lb { height: calc(42px * var(--rot-scale, 1)); }

/* ---- bracket callouts ---- */

.rot-annotations {
  grid-column: 2;
  grid-row: 3;
  position: relative;
  margin-top: calc(2px * var(--rot-scale, 1));
  width: max-content;
  min-width: 100%;
}

/* One rail per round: the SVG paths are measured from the cards down to each
   note, and the notes themselves are placed in lanes by JS. */
.rot-annotation-rail {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.rot-annotation {
  position: absolute;
  left: 0;
  top: 0;
}

.rot-connector {
  fill: none;
  stroke: rgba(214, 190, 150, 0.7);
  stroke-width: 1;
}

.rot-annotation-text {
  display: inline-block;
  max-width: calc(340px * var(--rot-scale, 1));
  padding: 0 2px;
  font-family: var(--main-font-family);
  font-size: calc(0.72rem * var(--rot-scale, 1));
  line-height: 1.4;
  color: #F0E6D2;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}

/* The note is plain type on the plan's dark ground, so the style only changes
   how its connector is drawn, not how the text sits. */
.rot-annotation.is-box .rot-annotation-text { color: #F3E4C4; }
.rot-annotation.is-fork .rot-annotation-text { color: #E4DCCB; }

.rot-or {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.5rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8f8a83;
}

/* ---- Rotations: narrower screens ---- */

/* The header packs a title, a 210px search box and a close button into one
   row; below a desktop width that no longer fits. */
@media (max-width: 1180px) {
  .rotations-browse { flex-basis: 260px; padding: 16px 16px 22px; }
  .rotations-detail { padding: 18px 20px 24px; gap: 20px; }
  .rot-hero-name { font-size: 24px; }
  .rotations-header-tools .search-input { width: 180px; }
}

@media (max-width: 900px) {
  .rotations-modal-card {
    height: min(92vh, 900px);
    max-height: 92dvh;
  }

  #rotations-modal .archetype-modal-header { gap: 8px; padding: 12px 16px 10px; }
  #rotations-modal .archetype-modal-title { font-size: 21px; }

  .rotations-header-tools { gap: 8px; min-width: 0; }
  .rotations-header-tools .search-input {
    width: 150px;
    min-width: 0;
    height: 30px;
    font-size: 0.64rem;
  }

  .rotations-browse { flex-basis: 220px; padding: 14px 12px 20px; }
  .rotations-detail { padding: 16px 16px 22px; gap: 18px; }
  .rot-hero-name { font-size: 21px; }
  .rot-member-portrait { width: 46px; height: 46px; }
  .rot-team-tuning { padding: 5px 10px; }
  .rot-team-tuning img { height: 46px; max-width: 72px; }
}

@media (max-width: 768px) {
  .rotations-modal-card {
    height: min(94vh, 900px);
    max-height: 94dvh;
  }

  /* Row 1: Back + title. Row 2: the full-width search field. */
  #rotations-modal .archetype-modal-header,
  #rotation-presets-modal .archetype-modal-header {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 44px 10px 12px;
  }

  #rotations-modal .archetype-modal-title,
  #rotation-presets-modal .archetype-modal-title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 19px;
    line-height: 1.2;
  }

  .rotations-back { order: -1; padding-right: 6px; }

  .rotations-header-tools { flex: 1 1 100%; margin-left: 0; gap: 8px; flex-wrap: wrap; }
  .rotations-header-tools .search-input {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    height: 34px;
    font-size: 0.72rem;
  }
  .rotations-header-tools .modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
  }

  /* Phones use a master-detail flow: the list fills the body first, then the
     picked plan replaces it. No draggable split and no list toggle needed. */
  .rotations-body {
    flex-direction: column;
  }

  .rotations-browse {
    flex: 1 1 auto;
    width: 100%;
    height: auto;
    max-height: none;
    padding: 12px 12px 14px;
    gap: 10px;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  /* List view: the rail fills the body and the plan is not shown. */
  .rotations-body .rotations-detail { display: none; }
  .rotations-body.is-list-hidden .rotations-browse { display: flex; }

  /* Detail view: the picked plan takes the whole body. */
  #rotations-card.is-detail .rotations-browse { display: none; }
  #rotations-card.is-detail .rotations-detail { display: flex; flex: 1 1 auto; }

  .rotations-body .guide-rail-resizer { display: none; }
  .rotations-rail-toggle { display: none; }

  .rotations-presets-btn {
    height: 30px;
    padding: 0 9px;
    font-size: 0.56rem;
  }
  .rotations-browse-head { gap: 8px; }
  .rotations-filters { gap: 4px; }
  .rotation-filter { padding: 3px 7px; font-size: 0.54rem; }

  /* A 280px minimum card would overflow a 360px phone. */
  .rotations-list { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .rotation-card { padding: 9px 10px; gap: 7px; }
  .rotation-card-name { font-size: 0.76rem; }
  .rotation-card-face { width: 32px; height: 32px; }
  .rotation-card-tag { font-size: 0.48rem; }

  .rotations-detail { padding: 14px 12px 20px; gap: 16px; }
  .rot-hero { gap: 8px; padding-bottom: 12px; }
  .rot-hero-name { font-size: 19px; }
  .rot-hero-tag { font-size: 0.52rem; padding: 2px 8px; }

  .rot-block { gap: 10px; }

  /* Two members per row: four full-width rows wasted the screen height. */
  .rot-team {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  /* The tuning tile keeps a single square cell at the end of the grid. */
  .rot-team-tuning { align-self: stretch; justify-self: start; padding: 4px 8px; }
  .rot-team-tuning img { height: 38px; max-width: 58px; }
  .rot-member { padding: 5px 8px 5px 5px; gap: 7px; min-width: 0; }
  .rot-member-portrait { width: 38px; height: 38px; }
  .rot-member-text { min-width: 0; gap: 3px; }
  .rot-member-name {
    font-size: 0.66rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .rot-member-chube { font-size: 0.5rem; gap: 4px; min-width: 0; }
  .rot-member-chube img { width: 18px; height: 22px; }
  /* The psychube name is long; clip it rather than stretch the card. */
  .rot-member-chube > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .rot-rounds { gap: 16px; }
  .rot-round { column-gap: 7px; }
  .rot-round-no { font-size: calc(1.2rem * var(--rot-scale, 1)); padding: 0 7px 1px 6px; }
  .rot-round-note { font-size: calc(0.68rem * var(--rot-scale, 1)); }

  /* Cards scale down together so a full round still fits one row. */
  .rot-slot { height: calc(108px * var(--rot-scale, 1)); }
  .rot-card { height: calc(72px * var(--rot-scale, 1)); }
  .rot-card.is-ultimate { height: calc(108px * var(--rot-scale, 1)); }
  .rot-slot.is-empty .rot-slot-body { width: calc(52px * var(--rot-scale, 1)); height: calc(68px * var(--rot-scale, 1)); }
  .rot-slot.is-text .rot-slot-body { width: calc(96px * var(--rot-scale, 1)); min-height: calc(68px * var(--rot-scale, 1)); padding: calc(6px * var(--rot-scale, 1)) calc(8px * var(--rot-scale, 1)); }
  .rot-slot-text { font-size: calc(0.52rem * var(--rot-scale, 1)); line-height: 1.4; }
  .rot-slot.is-or .rot-slot-body { width: calc(66px * var(--rot-scale, 1)); }
  .rot-slot.is-double-or .rot-slot-body { width: calc(74px * var(--rot-scale, 1)); }
  .rot-or-stack { width: calc(66px * var(--rot-scale, 1)); height: calc(72px * var(--rot-scale, 1)); }
  .rot-or-stack.is-double { width: calc(74px * var(--rot-scale, 1)); height: calc(78px * var(--rot-scale, 1)); }
  .rot-or-stack > .rot-card { height: calc(56px * var(--rot-scale, 1)); }
  .rot-card.is-mid { left: calc(15px * var(--rot-scale, 1)); bottom: calc(11px * var(--rot-scale, 1)); }
  .rot-card.is-behind { left: calc(23px * var(--rot-scale, 1)); bottom: calc(16px * var(--rot-scale, 1)); }
  .rot-or-stack.is-double .rot-card.is-behind { left: calc(30px * var(--rot-scale, 1)); bottom: calc(22px * var(--rot-scale, 1)); }
  .rot-or-stack > .rot-card.is-ultimate { height: calc(68px * var(--rot-scale, 1)); }
  .rot-card.is-lb { height: calc(36px * var(--rot-scale, 1)); }
  .rot-slot.is-tuning .rot-slot-body { width: calc(52px * var(--rot-scale, 1)); }
  .rot-slot-tuning { width: calc(52px * var(--rot-scale, 1)); height: calc(68px * var(--rot-scale, 1)); }
  .rot-slot-tuning-note { top: calc(3px * var(--rot-scale, 1)); left: calc(3px * var(--rot-scale, 1)); right: calc(3px * var(--rot-scale, 1)); bottom: calc((3px + var(--tuning-reserve, 0px)) * var(--rot-scale, 1)); }
  .rot-slot-tuning-card .rot-card { height: calc(30px * var(--rot-scale, 1)); }
}

/* ================= JSON MODAL ================= */

.json-section { display: flex; flex-direction: column; gap: 8px; }

.json-section-label {
  font-family: var(--main-font-family);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #6d665d;
}

.json-import-btn { cursor: pointer; margin: 0; }

.json-export-list { display: flex; flex-direction: column; gap: 8px; }

.json-divider {
  height: 1px;
  background: rgba(17, 15, 12, 0.16);
  margin: 2px 0;
}

.json-hint {
  margin: 0;
  font-family: var(--mono-font);
  font-size: 0.62rem;
  line-height: 1.45;
  color: #8a8378;
}

/* Icon-only destructive button (Reset) */
.btn-icon-only {
  padding: 0;
  width: 30px;
  height: 30px;
  min-width: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-icon-only .btn-reset-icon { width: 15px; height: 15px; }



/* Compact insight tier pips (the Planner's Insight rows) */
.char-mats-ins-boxes {
  display: flex;
  gap: 6px;
}

.char-mats-ins-btn {
  width: 32px;
  height: 32px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
}

.char-mats-ins-btn:hover {
  border-color: #ED7D31;
}

.char-mats-ins-btn.is-active {
  background: rgba(237, 125, 49, 0.25);
  border-color: #ED7D31;
  box-shadow: 0 0 8px rgba(237, 125, 49, 0.4);
}

.char-mats-ins-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ---------------- /sim share page ---------------- */
/*
  The share link renders a fixed overlay over the app so a visitor sees only the
  build they were sent, while the page itself stays the normal single-page app.
  app.js adds `.sim-mode` to <body> and builds `#sim-view` (see renderSimView).
*/

body.sim-mode {
  overflow: hidden;
}

.sim-view {
  position: fixed;
  inset: 0;
  z-index: 10000;
  overflow-y: auto;
  overscroll-behavior: contain;
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--main-font-family);
  animation: sim-fade 200ms ease-out;
}

/* The app's own background art, not an invented gradient — painted on a fixed layer
   exactly like the main page's `body::before`. Do not put it on `.sim-view` itself with
   `background-attachment: fixed`: iOS Safari does not support it, sizes the image against
   the scrolling element's content box instead and blows the 1920x800 art up into a few
   giant pixels (the phone-only "torn background"). `.sim-view` is `position: fixed` with
   a z-index, so it is a stacking context and the negative layer stays inside it: above
   the panel's colour, below the shell. */
.sim-view::before {
  content: "";
  position: fixed;
  inset: 0;
  background: url("images/background.png") center / cover no-repeat;
  pointer-events: none;
  z-index: -1;
}

@keyframes sim-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sim-shell {
  width: min(1060px, 100%);
  min-height: 100%;
  margin: 0 auto;
  padding: 0 26px 48px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

/* Header --------------------------------------------------------------
   The share page keeps the app's toolbar (`.top-controls` / `.header-*` /
   `.lang-switcher` / `.btn`) and only removes the middle cluster: search,
   Manage, JSON and Export PNG have nothing to act on here. */

.sim-brand {
  color: inherit;
  text-decoration: none;
}

/* The app hides its header switcher under 1260px because the drawer carries a
   copy; `/sim` has no drawer, so this one stays. */
.sim-head .header-stats-row .lang-switcher-header {
  display: inline-flex;
}

/* Toolbar buttons keep one line: `.btn` has a fixed 31px height, so a wrapped
   label would spill out of it. They also keep their own width; the toolbar's
   right column is what shrinks on a narrow window. */
.sim-head .btn,
.sim-head .lang-switcher {
  flex: none;
  white-space: nowrap;
}

/* Hero ---------------------------------------------------------------- */

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

.sim-kicker {
  margin: 0;
  font-size: 0.74rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--tier-unowned, #9a9a9a);
}

.sim-title {
  margin: 0;
  font-size: clamp(1.9rem, 4.6vw, 2.9rem);
  line-height: 1.1;
  font-weight: 700;
}

.sim-sub {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Default / no-build hero ---------------------------------------------- */

/* Team card ------------------------------------------------------------
   The share page reuses the Team Building card markup (`.team-card`,
   `.team-slots`, `.team-slot*`), so this section only sizes the single card:
   the app's board already sits on `images/background.png`, and so does the page. */

/* The card is the export card, so it takes the same width as the framed build
   pane below it rather than a narrower column. `width: 100%` matters: a centring
   `margin: auto` alone would let the grid shrink to its content, and a member
   whose art failed to load would then squeeze the whole card. */
.sim-team-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  padding: 0;
  width: 100%;
  margin: 0 auto;
}

/* Same static title the PNG export swaps in for the rename input. */
.sim-team-list .team-name-text {
  flex: 1;
  min-width: 0;
  font-family: var(--mono-font);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #323C34;
  line-height: 1.4;
  padding: 3px 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Character build ------------------------------------------------------
   `.sim-builds` is the InfoBook detail pane, copied out of the modal, and
   `.sim-build-card` is the modal's own frame around it. The card releases its
   fixed height so the page scrolls as a whole instead of trapping a scroll box. */

.sim-build-card {
  width: 100%;
  max-width: 1080px;
  height: auto;
  max-height: none;
  margin: 0 auto;
}

.sim-build-card .builds-body,
.sim-build-card .builds-detail {
  overflow: visible;
}

/* Phones swap the InfoBook's rail/detail split for a master-detail flow, so
   `.builds-body .builds-detail` is `display: none` until the body carries `.is-detail`.
   The share page copies the detail on its own and has no rail to go "back" to, so it is
   always shown. This rule sits after that media query on purpose: same specificity, later
   in the file, so it wins at every width. */
.sim-build-card .builds-detail {
  display: flex;
}

/* Rotation plan --------------------------------------------------------
   `.sim-rotation-card` is the rotations modal's own frame around a single plan.
   It releases the modal's fixed height so the page scrolls as a whole, and it
   keeps the detail pane visible at phone width (the modal hides it until its
   body carries `.is-detail`, which a rail-less share page never sets). */

.sim-rotation-card {
  width: 100%;
  max-width: 1180px;
  height: auto;
  max-height: none;
  margin: 0 auto;
  /* The page already paints the wallpaper behind everything (`.sim-view::before`), so
     the frame keeps its border but adds no surface of its own: the plan sits straight on
     the page. The rows inside carry their own translucent bands, which is what keeps them
     readable. Border, corner radius and glow still come from `.archetype-modal-card`. */
  background: none !important;
}

.sim-rotation-card .rotations-body,
.sim-rotation-card .rotations-detail {
  overflow: visible;
}

.sim-rotation-card .rotations-detail {
  display: flex;
  flex: 1 1 auto;
}

/* The modal's orange section spine; the share page has no `#rotations-card`. */
.sim-rotation-card .rot-block > .archetype-section-header {
  border-left-color: #E09532;
  background:
    linear-gradient(90deg, rgba(94, 69, 36, 0.4) 0%, rgba(0, 0, 0, 0.4) 45%, rgba(0, 0, 0, 0.4) 100%);
}

/* Small screens ------------------------------------------------------- */

@media (max-width: 768px) {
  /* Phones: the brand and the language switcher share the first line, the two
     buttons take the second. `display: contents` lets the switcher and the
     buttons sit on the header grid directly, one row each. */
  .sim-head .header-primary-bar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .sim-head .header-stats-row {
    display: contents;
  }

  .sim-head .header-stats-row .lang-switcher-header {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  .sim-head .header-stats-row .btn {
    grid-row: 2;
  }

  .sim-head .header-stats-row .btn-secondary {
    grid-column: 1;
    justify-self: start;
  }

  .sim-head .header-stats-row .btn-primary {
    grid-column: 2;
    justify-self: end;
  }
}

@media (max-width: 620px) {
  .sim-shell {
    padding: 0 14px 30px;
    gap: 18px;
  }

  /* The modal's own padding is too wide for a phone-width card. */
  .sim-build-card .builds-detail {
    padding: 16px 14px 22px;
  }
}

/* ==========================================================================
   GLOBAL TOP NAVBAR (#111111 Mainboard Theme, Original Sotheby's Vintage Design)
   ========================================================================== */

.global-navbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  width: 100%;
  background: #111111;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
  font-family: var(--primary-font);
}

.navbar-container {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 8px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-sizing: border-box;
}

/* Left cluster: Brand + Nav Links pushed far to the left */
.navbar-left {
  display: flex;
  align-items: center;
  gap: 18px;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.global-navbar .app-brand-icon-box {
  border-radius: 4px;
  border: 1px solid #D05126;
  background: rgba(0, 0, 0, 0.03);
  overflow: hidden;
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-link {
  height: 31px;
  padding: 0 14px;
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid #B5B5B3;
  border-radius: 4px;
  color: #B5B5B3;
  font-family: var(--primary-font);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none;
  box-sizing: border-box;
}

.nav-link:hover {
  background: rgba(181, 181, 179, 0.12);
  border-color: #B5B5B3;
  color: #ffffff;
}

.nav-link.active {
  background: rgba(208, 81, 38, 0.22);
  border-color: #D05126;
  color: #FFFFFF;
}

.nav-icon {
  width: 17px;
  height: 17px;
  object-fit: contain;
  display: block;
}

/* Right cluster: Everything pushed far to the right */
.navbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}

.global-navbar .stat-badge {
  background: rgba(17, 15, 12, 0.06);
  color: #EBE3D7;
  font-family: var(--primary-font);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0 10px;
  height: 31px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid #B5B5B3;
  border-radius: 4px;
  cursor: pointer;
  box-sizing: border-box;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.global-navbar .stat-badge:hover {
  border-color: #D05126;
}

/* Language Dropdown */
.lang-dropdown-wrap {
  position: relative;
  display: inline-block;
}

.lang-dropdown-btn {
  height: 31px;
  padding: 0 12px;
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid #B5B5B3;
  border-radius: 4px;
  color: #ECE5D9;
  font-family: var(--primary-font);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.18s ease;
  box-sizing: border-box;
}

.lang-dropdown-btn:hover {
  background: rgba(181, 181, 179, 0.12);
  border-color: #B5B5B3;
  color: #FFFFFF;
}

.lang-dropdown-wrap.open .lang-dropdown-btn {
  border-color: #D05126;
  background: rgba(208, 81, 38, 0.12);
  color: #FFFFFF;
}

.dropdown-caret {
  font-size: 0.65rem;
  transition: transform 0.2s ease;
  color: #B5B5B3;
  display: inline-block;
  line-height: 1;
}

.lang-dropdown-wrap.open .dropdown-caret {
  transform: rotate(180deg);
  color: #D05126;
}

.lang-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 130px;
  background: #111111;
  border: 1px solid #B5B5B3;
  border-radius: 4px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.75);
  z-index: 1050;
  display: none;
  flex-direction: column;
  gap: 2px;
  animation: fadeIn 0.15s ease-out;
}

.lang-dropdown-wrap.open .lang-dropdown-menu {
  display: flex;
}

.lang-dropdown-item {
  width: 100%;
  padding: 7px 12px;
  background: transparent;
  border: none;
  border-radius: 3px;
  color: #B5B5B3;
  font-family: var(--primary-font);
  font-size: 0.75rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  box-sizing: border-box;
  display: flex;
  align-items: center;
}

.lang-dropdown-item:hover {
  background: rgba(181, 181, 179, 0.12);
  color: #FFFFFF;
}

.lang-dropdown-item.active {
  background: rgba(208, 81, 38, 0.22);
  color: #FFFFFF;
  font-weight: 700;
}

.navbar-right #btn-json {
  height: 31px;
  padding: 0 14px;
  border: 1px solid #D05126;
  color: #ECE5D9;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.03);
  font-family: var(--primary-font);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.18s ease;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.navbar-right #btn-json:hover {
  background: rgba(208, 81, 38, 0.15);
  border-color: #D05126;
  color: #FFFFFF;
}

.navbar-hamburger {
  display: none !important;
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid #B5B5B3;
  border-radius: 4px;
  padding: 0;
  cursor: pointer;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 31px;
  box-sizing: border-box;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.navbar-hamburger:hover {
  background: rgba(181, 181, 179, 0.12);
  border-color: #B5B5B3;
}

.navbar-menu-wrap.open .navbar-hamburger {
  border-color: #D05126;
  background: rgba(208, 81, 38, 0.12);
}

.navbar-menu-wrap.open .hamburger-bar {
  background: #D05126;
}

.hamburger-bar {
  display: block;
  width: 16px;
  height: 2px;
  background: #B5B5B3;
  border-radius: 1px;
}

/* Menu dropdown — the same small panel as the language dropdown */
.navbar-menu-wrap {
  position: relative;
  display: inline-block;
}

.navbar-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 150px;
  background: #111111;
  border: 1px solid #B5B5B3;
  border-radius: 4px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.75);
  z-index: 1050;
  flex-direction: column;
  gap: 2px;
  animation: fadeIn 0.15s ease-out;
}

.navbar-menu-wrap.open .navbar-menu {
  display: flex;
}

.navbar-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 30px;
  padding: 0 10px;
  background: transparent;
  border: none;
  border-radius: 3px;
  color: #B5B5B3;
  font-family: var(--primary-font);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  box-sizing: border-box;
}

.navbar-menu-item:hover {
  background: rgba(181, 181, 179, 0.12);
  color: #FFFFFF;
}

.navbar-menu-item .nav-icon {
  width: 15px;
  height: 15px;
}

/* ==========================================================================
   MAINBOARD SUB-TOOLBAR (#111111 Mainboard Theme, Original Sotheby's Buttons)
   ========================================================================== */

.mainboard-toolbar {
  width: 100%;
  margin: 0 0 12px 0;
  background: #111111;
  border: 1px solid rgba(255, 255, 255, 0.08);
  /* Same 4px corner as the Appearance button and the search field, but a 4px
     curve disappears on a 1232×50 bar, so the bar read square next to them.
     Scaling the curve to the box gives the same visual roundness. */
  border-radius: 8px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  box-sizing: border-box;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
  font-family: var(--primary-font);
}

.mainboard-search-wrap {
  flex: 1 1 200px;
  max-width: 280px;
  min-width: 150px;
}

.mainboard-search-wrap .search-input {
  width: 100%;
  height: 31px;
  box-sizing: border-box;
  border: 1px solid #D05126;
  border-radius: 4px;
  background: rgba(17, 15, 12, 0.04);
  color: #ECE5D9;
  font-family: var(--primary-font);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.mainboard-search-wrap .search-input:focus {
  border-color: #D05126;
  box-shadow: 0 0 0 4px rgba(208, 81, 38, 0.18);
  outline: none;
}

.mainboard-filters-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.mainboard-toolbar .filter-btn-group {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid #B5B5B3;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 4px;
  overflow: hidden;
  height: 31px;
  box-sizing: border-box;
  /* Never let the flex row squeeze a group below its buttons' natural width. */
  flex: 0 0 auto;
}

.mainboard-toolbar .filter-btn {
  background: transparent;
  border: none;
  border-right: 1px solid #B5B5B3;
  color: #B5B5B3;
  font-family: var(--primary-font);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  line-height: 1;
  box-sizing: border-box;
  /* Chips keep their own size at every width; the row wraps instead of
     clipping the labels (the groups have `overflow: hidden`). */
  flex: 0 0 auto;
  white-space: nowrap;
}

.mainboard-toolbar .filter-btn:last-child {
  border-right: none;
}

.mainboard-toolbar .filter-btn:hover {
  background: rgba(181, 181, 179, 0.12);
  color: #ffffff;
}

.mainboard-toolbar .filter-btn.active {
  background: rgba(208, 81, 38, 0.22);
  color: #FFFFFF;
}

.mainboard-toolbar .filter-group-separator {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.08);
  margin: 0 2px;
}

.mainboard-actions-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.mainboard-actions-group .btn {
  height: 31px;
  padding: 0 16px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-family: var(--primary-font);
  box-sizing: border-box;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.18s ease;
}

/* Appearance / Manage / Export PNG are icon-only: the label would push the
   sub-toolbar onto a second row long before the chips needed it, and the
   tooltip (`title`) plus `aria-label` still say what each one does. */
#mainboard-toolbar .mainboard-icon-btn {
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  flex: 0 0 auto;
  font-size: 0.74rem;
  font-family: var(--primary-font);
  box-sizing: border-box;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s ease;
}

.mainboard-icon-img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

/* Appearance and Manage sit ahead of the search field. */
.mainboard-lead-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

/* The export button is the accent one; only its border/hover differ. */
#mainboard-toolbar #btn-export-image {
  padding: 0;
}

/* Exporting has no label to say "Rendering…", so the icon pulses and the
   tooltip carries the word. */
#mainboard-toolbar .mainboard-icon-btn:disabled {
  cursor: progress;
  opacity: 0.55;
}

#mainboard-toolbar .mainboard-icon-btn.is-busy .mainboard-icon-img {
  animation: mainboardIconPulse 1s ease-in-out infinite;
}

@keyframes mainboardIconPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.88); }
}

@media (prefers-reduced-motion: reduce) {
  #mainboard-toolbar .mainboard-icon-btn.is-busy .mainboard-icon-img {
    animation: none;
    opacity: 0.6;
  }
}

#mainboard-toolbar #btn-appearance,
#mainboard-toolbar #btn-manage-all {
  border: 1px solid #D05126;
  color: #ECE5D9;
  background: rgba(0, 0, 0, 0.03);
}

#mainboard-toolbar #btn-appearance:hover,
#mainboard-toolbar #btn-manage-all:hover {
  background: rgba(208, 81, 38, 0.15);
  border-color: #D05126;
  color: #FFFFFF;
}

#mainboard-toolbar #btn-export-image {
  border: 1px solid #D05126;
  color: #ECE5D9;
  background: transparent;
}

#mainboard-toolbar #btn-export-image:hover {
  background: #D05126;
  color: #FFFFFF;
}

/* ==========================================================================
   APPEARANCE MODAL & TABS (Identical Design to Other Modals)
   ========================================================================== */

#appearance-modal .appearance-modal-card {
  max-width: 820px !important;
  width: 95vw !important;
  max-height: 90vh !important;
}

/* Options and Styling keep the compact width their old stand-alone modals had
   (440px); only the Tiers panel uses the wide sheet. */
#appearance-modal[data-appearance-tab="options"] .appearance-modal-card,
#appearance-modal[data-appearance-tab="styling"] .appearance-modal-card {
  max-width: 440px !important;
}

#appearance-modal .appearance-tabs {
  margin: 0;
  padding: 10px 20px;
  border-bottom: 1px solid rgba(208, 81, 38, 0.38);
}

/* The selected tab follows the Manage modal's own tabs exactly: orange label,
   orange border, no fill (see `.manage-tab.active`). */
#appearance-modal .appearance-tab:hover:not(.active) {
  border-color: #EBE3D7;
  color: #fff;
}

.appearance-tab-panel {
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.18s ease-out;
}

.appearance-tab-panel .modal-body {
  max-height: 70vh;
  overflow-y: auto;
}

/* ==========================================================================
   PLANNER (event shop)
   The Event tab is a shopping list: one card per goods slot of the shop the
   global client is running, with a stepper for the quantity and a live total.
   Data: data/event_shop.json (scripts/sync/derive/eventShop.mjs).
   The section bars reuse the Appearance modal's section header
   (`.archetype-section-header`), so "Divine Treasure" reads like "DISPLAY FILTERS".
   ========================================================================== */

.planner-modal-card {
  max-width: 900px;
  width: 100%;
  height: min(88vh, 820px);
  border-radius: 0 !important;
}

.planner-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
}

/* Sticky head: which shop, and what the current picks cost. */
.planner-toolbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 12px 20px;
  background: rgba(0, 0, 0, 0.28);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.planner-toolbar-lead {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.planner-patch {
  flex: none;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #B5B5B3;
}

/* The shop picker. A native select is kept (it is the one control every
   platform handles well), but its own chrome is dropped so it sits in the
   modal's palette like the reset button beside it: dark field, thin border, a
   caret that is an SVG rather than the OS arrow (which differs per browser and
   ignores the dark theme). */
.planner-shop-select {
  -webkit-appearance: none;
  appearance: none;
  height: 30px;
  min-width: 168px;
  max-width: 260px;
  padding: 0 26px 0 10px;
  background-color: rgba(0, 0, 0, 0.35);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0h10L5 6z' fill='%23B5B5B3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 9px 6px;
  border: 1px solid rgba(181, 181, 179, 0.45);
  border-radius: 4px;
  color: #ECE5D9;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.planner-shop-select:hover {
  border-color: rgba(237, 125, 49, 0.75);
  background-color: rgba(0, 0, 0, 0.5);
}

.planner-shop-select:focus-visible {
  outline: 2px solid #ED7D31;
  outline-offset: 1px;
}

/* Firefox draws the option list itself; match the modal, don't inherit white. */
.planner-shop-select option {
  background: #212121;
  color: #ffffff;
}

.planner-toolbar-tail {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

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

.planner-total-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #B5B5B3;
}

.planner-total-value {
  font-size: 0.92rem;
  font-weight: 700;
  color: #ECE5D9;
  white-space: nowrap;
}

/* Reset is an icon-only button (reset_png.png), like the sub-toolbar's own. */
.planner-reset-btn {
  width: 30px;
  min-width: 30px;
  height: 30px;
  padding: 0;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
}

.planner-reset-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.planner-reset-btn:focus-visible {
  outline: 2px solid #ED7D31;
  outline-offset: 1px;
}

.planner-money-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  display: block;
}

/* The list itself */
.planner-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.planner-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* The section bar is `.archetype-section-header`; only its right side differs —
   it carries the running cost of the section instead of nothing. */
.planner-group-head {
  margin-bottom: 0;
}

.planner-group-total {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  font-weight: 700;
  color: #8f8f8d;
  opacity: 0.85;
}

.planner-group-total.is-set {
  color: #ECE5D9;
  opacity: 1;
}

/* ==========================================================================
   PLANNER (event shop)
   ========================================================================== */

/* The goods grid: board-style cards, one per slot. */
.planner-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 8px;
}

/* One goods slot */
.planner-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 6px 6px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.planner-card:hover {
  background: rgba(0, 0, 0, 0.34);
  border-color: rgba(255, 255, 255, 0.2);
}

/* A picked card is deliberately *not* tinted: the "1/1" in the box says what is
   planned, and colouring the card made the grid read as a warning. The border
   stays neutral for the same reason. */

.planner-card-art {
  position: relative;
  width: 76px;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* The game's item art already carries its own frame, so the card draws no
     chrome behind it: no background, no border, just the icon at full size. */
  background: none;
  border: none;
}

.planner-card-art img {
  width: 76px;
  height: 76px;
  object-fit: contain;
  display: block;
}

/* A row Myssal ships no art for: a dashed placeholder, never a broken image. */
.planner-card-art-empty {
  width: 24px;
  height: 24px;
  border: 1px dashed rgba(181, 181, 179, 0.6);
  border-radius: 3px;
}

/* Planned at zero: the slot reads as sold out. The art greys back and a label
   is printed across it, exactly like a slot the game has already bought out. */
.planner-card.is-soldout .planner-card-art img {
  opacity: 0.32;
  filter: grayscale(1);
}

.planner-card-soldout {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  padding: 2px 0;
  background: rgba(0, 0, 0, 0.78);
  color: #E2726B;
  font-size: 0.54rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  line-height: 1.2;
  pointer-events: none;
}

/* "×5" packs: the slot's price buys this many. */
.planner-card-bundle {
  position: absolute;
  right: 2px;
  bottom: 2px;
  font-size: 0.62rem;
  font-weight: 700;
  color: #B5B5B3;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}

.planner-card-name {
  width: 100%;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1.25;
  font-family: var(--board-font, var(--mono-font));
  color: rgba(244, 239, 233, 0.84);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  /* Two lines, then an ellipsis: the art carries the identity anyway. The box
     is pinned to two lines whether the name needs one or two, so the price and
     the stepper below it sit at the same height on every card of a row. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.5em;
}

.planner-card-price {
  display: flex;
  align-items: center;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}

/* The price carries the shop's own currency art on its left, so a row reads
   "<icon> 1000" instead of relying on the toolbar to say what the unit is. */
.planner-cost-money {
  width: 14px;
  height: 14px;
  object-fit: contain;
  display: block;
  flex: none;
}

.planner-cost-value {
  font-size: 0.76rem;
  font-weight: 700;
  color: #ffffff;
}

.planner-cost-original {
  font-size: 0.6rem;
  font-weight: 700;
  color: #7d7d7b;
  text-decoration: line-through;
}

/* Quantity stepper: [−] count [+] in one row, as wide as the card. It is
   pushed to the bottom of the card (`margin-top: auto`) so every card in a grid
   row lines its stepper up, whatever the name above it wrapped to. */
.planner-stepper {
  width: 100%;
  margin-top: auto;
  display: flex;
  align-items: stretch;
  gap: 3px;
  height: 24px;
}

.planner-count {
  flex: 1;
  min-width: 40px;
  padding: 0 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(181, 181, 179, 0.5);
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 700;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: default;
}

.planner-count.is-zero {
  color: #7d7d7b;
}

.planner-step {
  width: 20px;
  flex: 0 0 20px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid rgba(181, 181, 179, 0.5);
  border-radius: 3px;
  color: #B5B5B3;
  font-size: 0.74rem;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s ease;
}

.planner-step:hover:not(:disabled) {
  background: rgba(208, 81, 38, 0.22);
  border-color: #D05126;
  color: #ffffff;
}

.planner-step:disabled {
  opacity: 0.3;
  cursor: default;
}

.planner-step:focus-visible {
  outline: 2px solid #ED7D31;
  outline-offset: 1px;
}

/* ==========================================================================
   TOOLBAR OWNED INPUT & TOOLTIP
   ========================================================================== */
.planner-owned-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: 12px;
}

/* The shop's own currency art sits **inside** the field, immediately left of the
   number (`[icon] 123`), so the figure and its unit read as one control — the
   same order the tooltip's own lines print. */
.planner-owned-field {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.planner-owned-icon {
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  flex: none;
  object-fit: contain;
  display: block;
  pointer-events: none;
  z-index: 1;
}

.planner-owned-icon[hidden] {
  display: none;
}

.planner-owned-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #B5B5B3;
  text-transform: uppercase;
}

.planner-owned-input {
  width: 76px;
  height: 26px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(181, 181, 179, 0.5);
  border-radius: 3px;
  padding: 0 6px;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: left;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* Room for the currency art drawn inside the field's left edge, before the number. */
.planner-owned-field.has-icon .planner-owned-input {
  padding-left: 28px;
  width: 96px;
}

.planner-owned-input:focus {
  border-color: #ED7D31;
  box-shadow: 0 0 6px rgba(237, 125, 49, 0.4);
}

/* The Owned tooltip is the character card's own surface (`.char-tooltip`, same
   rule block at the top of this file) with one difference: it is `fixed` and
   positioned by `setupPlannerOwnedTooltip()` under the cursor, instead of being
   anchored above a card. That is what keeps it out of the way of the number the
   reader is typing. */
.planner-owned-tooltip {
  position: fixed;
  top: 0;
  left: 0;
  bottom: auto;
  transform: none;
  min-width: 244px;
  max-width: 400px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 3000;
}

.planner-owned-tooltip.is-visible {
  opacity: 1;
  visibility: visible;
}

/* A tooltip with no currency name draws no header bar at all. */
.planner-owned-tooltip:not(.has-head) .ct-head {
  display: none;
}

/* The tooltip's figures sit on one three-column grid — label → art → figure —
   shared by every line, so the arts and the figures below them are always in one
   vertical line, whatever the longest label turns out to be. A flex row per line
   made each art step right with its own label's width, which is what left the
   Activity figure hanging out of line with the currency above it. */
.planner-owned-tooltip .planner-tooltip-body {
  display: grid;
  grid-template-columns: max-content 18px minmax(0, 1fr);
  align-items: center;
  column-gap: 6px;
  row-gap: 4px;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
  color: rgba(244, 239, 233, 0.84);
}

/* A line hands its three parts to the body's grid instead of laying them out. */
.planner-tooltip-line {
  display: contents;
}

/* The art each figure counts: the shop currency for "still need", the hand-added
   `times` art for the runs, the game's stamina icon for Activity, and the
   currency again for what the runs leave behind. */
.planner-tooltip-icon {
  width: 18px;
  height: 18px;
  flex: none;
  object-fit: contain;
  display: block;
}

/* A hidden art keeps its cell instead of pulling the figure into the art column. */
.planner-tooltip-icon[hidden] {
  display: block;
  visibility: hidden;
}

/* "Still need" is its own node so the currency art can sit between the words
   and the figure — the icon touches the number it counts, not the sentence. */
.planner-tooltip-label {
  white-space: nowrap;
  color: rgba(244, 239, 233, 0.72);
}

/* A long figure wraps inside its own column instead of being clipped by the
   tooltip's edge; its art stays beside it. */
.planner-tooltip-value {
  min-width: 0;
}

#planner-tooltip-need,
#planner-tooltip-runs,
#planner-tooltip-rest {
  color: #F8D070;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   PLANNER QUANTITY SLIDER MODAL
   ========================================================================== */
.planner-slider-modal {
  position: absolute;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.planner-slider-modal[hidden] {
  display: none !important;
}

.planner-slider-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

.planner-slider-dialog {
  position: relative;
  z-index: 2;
  width: 90%;
  max-width: 420px;
}

.planner-slider-header {
  padding: 12px 18px 10px;
}

.planner-slider-item-preview {
  display: flex;
  align-items: center;
  gap: 14px;
}

.planner-slider-art-wrap {
  position: relative;
  width: 64px;
  height: 64px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.planner-slider-border {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  z-index: 1;
}

.planner-slider-icon {
  position: relative;
  width: 54px;
  height: 54px;
  object-fit: contain;
  z-index: 2;
}

.planner-slider-icon.is-psychube {
  width: 54px;
  height: 64px;
  object-fit: contain;
}

.planner-slider-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.planner-slider-item-name {
  font-size: 1.05rem !important;
  line-height: 1.2;
}

.planner-slider-item-limit {
  font-size: 0.68rem;
  color: #72C088;
  font-weight: 600;
}

.planner-slider-item-unit-cost {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: #B5B5B3;
  font-weight: 700;
}

.planner-slider-body {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.planner-slider-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.planner-slider-btn-quick {
  padding: 0 8px;
  height: 26px;
  font-size: 0.7rem;
  font-weight: 700;
}

.planner-slider-step-btn {
  width: 26px;
  height: 26px;
  padding: 0;
  flex: none;
  font-size: 0.85rem;
  font-weight: 700;
}

.planner-slider-track-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 4px;
}

.planner-slider-num-group {
  display: flex;
  justify-content: center;
}

.planner-slider-input {
  width: 100px;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 700;
  height: 32px;
}

.planner-slider-total-cost {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.planner-slider-cost-label {
  font-size: 0.75rem;
  color: #B5B5B3;
  font-weight: 600;
}

.planner-slider-cost-val {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.95rem;
  font-weight: 800;
  color: #ECE5D9;
}

.planner-slider-footer {
  margin-top: 4px;
}

.planner-slider-confirm-btn {
  width: 100%;
  height: 34px;
  font-weight: 700;
}

/* ==========================================================================
   PLANNER (character progression)
   The Character tab is a plan, not a form: a grid of head icons (press to edit,
   right-press to leave an arcanist out), the bill they add up to, and the farm
   route underneath that pays for it. The panels are lightboxes over the tab, so
   the column behind them never splits into a second scroller. Nothing here
   invents a second look — the fields are the Event tab's select, the section
   bars are the Appearance modal's, and a material is the InfoBook's item
   sticker without the card around it.
   ========================================================================== */

/* A pane owns the whole body; only one is visible at a time. */
.planner-pane {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.planner-pane[hidden] {
  display: none;
}

/* "+ Add arcanist" — the plus carries the accent, the label stays neutral. */
.planner-add-btn {
  height: 30px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  cursor: pointer;
}

.planner-add-plus {
  font-size: 0.94rem;
  font-weight: 700;
  line-height: 1;
  color: #ED7D31;
}

.planner-add-btn:focus-visible {
  outline: 2px solid #ED7D31;
  outline-offset: 1px;
}

/* One scrolling column: the icon grid, the hint under it, then the farm route.
   The panels (picker / editor / Goal / activity) are lightboxes over the whole
   tab, so the column itself never has a second scroller. */
.planner-char-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 20px 18px;
}

/* The plan is head icons and nothing else, so the whole roster fits at once.
   Right-clicking one leaves it out of the plan's totals (it stays, dimmed). */
.planner-char-rail {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px;
}

/* An empty plan is a sentence across the whole pane, not a grid cell. The rail is a
   grid, so a bare child would take the first 64px column and wrap itself into the
   top-left corner; spanning every column and centring the text puts it in the middle
   of the tab, where the reader is looking. */
.planner-rail-empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 34px 12px;
  font-size: 0.68rem;
  line-height: 1.5;
  color: #8f8f8d;
  text-align: center;
}

.planner-rail-hint {
  margin: 10px 0 0;
  font-size: 0.62rem;
  line-height: 1.4;
  color: #8f8f8d;
}

.planner-rail-hint:empty {
  display: none;
}

/* A plan tile is a bare head icon squared off: no radius, and one flat rule so a wall
   of them reads as a roster sheet instead of a grid of buttons. The rule is the site's
   orange while the arcanist counts toward the plan, and the flat grey `#504F4D` once
   they are filed away (right-click) — so "in the plan" is readable without dimming
   being the only signal. */
.planner-char-tile {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 0;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid #D05126;
  border-radius: 0;
  cursor: pointer;
  transition: border-color 0.15s ease, opacity 0.15s ease, filter 0.15s ease;
}

.planner-char-tile:hover {
  border-color: #ED7D31;
}

/* Left out of the plan: still one press from coming back, but clearly off. */
.planner-char-tile.is-disabled {
  border-color: #504F4D;
  opacity: 0.32;
  filter: grayscale(1);
}

.planner-char-tile.is-disabled:hover {
  border-color: #7A7876;
  opacity: 0.6;
}

.planner-char-tile:focus-visible {
  outline: 2px solid #ED7D31;
  outline-offset: 1px;
}

.planner-char-tile-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  background: rgba(0, 0, 0, 0.45);
}

span.planner-char-tile-img {
  border: 1px dashed rgba(181, 181, 179, 0.45);
}

/* ---- Farm route ---------------------------------------------------------- */

.planner-farm {
  margin-top: 18px;
}

.planner-farm-head {
  margin-top: 12px;
}

.planner-farm-head:first-child {
  margin-top: 0;
}

/* The two switches the route bar carries (Wilderness, Warehouse), kept together at
   the header's right edge. */
.planner-farm-actions {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* The Wilderness switch on the route's own bar: its own word — the board's icon
   lives in the sheet — brighter once the board is counted in the solve. */
.planner-farm-toggle {
  flex: none;
  height: 24px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  cursor: pointer;
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
  color: #BFBFBF;
  opacity: 0.75;
  transition: opacity 0.15s ease, border-color 0.15s ease, color 0.15s ease,
    background 0.15s ease;
}

.planner-farm-toggle:hover {
  opacity: 1;
  border-color: rgba(237, 125, 49, 0.7);
  color: #ffffff;
}

.planner-farm-toggle.is-active {
  opacity: 1;
  border-color: #ED7D31;
  background: rgba(237, 125, 49, 0.22);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(237, 125, 49, 0.35);
}

.planner-farm-toggle:focus-visible {
  outline: 2px solid #ED7D31;
  outline-offset: 1px;
}

/* The Wilderness card is a credit, not a run: it carries the days it paid for
   instead of runs and stamina. */
.planner-farm-card.is-wilderness {
  border-color: rgba(237, 125, 49, 0.45);
  background: rgba(237, 125, 49, 0.1);
}

.planner-farm-wild-icon {
  width: 16px;
  height: 16px;
  flex: none;
  object-fit: contain;
  opacity: 0.85;
}

.planner-farm-days {
  flex: none;
  font-size: 0.66rem;
  font-weight: 700;
  color: #ED7D31;
  white-space: nowrap;
}

/* The one number the reader came for: whole stamina, and the days it takes at
   whatever the activity settings say a day is worth. */
.planner-farm-total {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding: 8px 10px;
  background: rgba(208, 81, 38, 0.12);
  border-left: 2px solid #D05126;
  border-radius: 4px;
  font-size: 0.72rem;
  color: rgba(244, 239, 233, 0.9);
}

.planner-farm-total img {
  width: 16px;
  height: 16px;
  object-fit: contain;
}

.planner-farm-total-label {
  font-weight: 600;
  color: #b9b5ae;
}

.planner-farm-total-value {
  font-family: var(--mono-font);
  font-size: 0.86rem;
  font-weight: 700;
  color: #ffffff;
}

.planner-farm-total-days {
  margin-left: auto;
  font-size: 0.68rem;
  color: #b9b5ae;
}

.planner-farm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.planner-farm-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 7px 8px;
  background: rgba(0, 0, 0, 0.26);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
}

.planner-farm-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.planner-farm-stage {
  flex: 1;
  min-width: 0;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.25;
  color: rgba(244, 239, 233, 0.92);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.planner-farm-runs {
  flex: none;
  font-family: var(--mono-font);
  font-size: 0.66rem;
  font-weight: 700;
  color: #ED7D31;
}

.planner-farm-stamina {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: none;
  font-family: var(--mono-font);
  font-size: 0.64rem;
  font-weight: 700;
  color: #b9b5ae;
}

.planner-farm-stamina img {
  width: 13px;
  height: 13px;
  object-fit: contain;
}

/* Three drops to a line: a stage's bill is a handful of materials, and a fixed
   three-column row keeps every card's drops in the same rhythm instead of letting
   a wrap decide it (two on one line, one stranded under it). A card is ~200px, so
   the columns land near 60px and the sticker shrinks to fit its column. */
.planner-farm-drops {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

/* A drop is the item sticker the bill uses: the art already carries its own frame,
   so there is no card box around it. */
.planner-farm-drop {
  width: 100%;
  max-width: 72px;
  height: auto;
  aspect-ratio: 1 / 1;
  justify-self: start;
  flex: none;
  cursor: default;
}

.planner-farm-drop:hover {
  transform: none;
  border-color: transparent;
  box-shadow: none;
}

.planner-farm-drop .item-sticker-qty {
  font-size: 10px;
  padding: 0 3px;
  bottom: 2px;
  right: 2px;
}

/* The shop rows are a list, not a grid, so their art stays a step smaller. */
.planner-farm-shop-row .planner-farm-drop {
  width: 48px;
  height: 48px;
}

.planner-farm-shop-row .planner-farm-drop .item-sticker-qty {
  font-size: 10px;
  padding: 0 3px;
}

.planner-farm-sharpo {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--mono-font);
  font-size: 0.66rem;
  font-weight: 700;
  color: #b9b5ae;
}

.planner-farm-sharpo-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
}

.planner-farm-card.is-craft .planner-farm-stage {
  color: #ED7D31;
}

/* The two shops are rows, not cards: the reader copies the count into the shop,
   so the name has to be readable. */
.planner-farm-shoplist {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.planner-farm-shop-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 4px;
}

.planner-farm-shop-row .planner-farm-drop {
  flex: none;
}

.planner-farm-shop-name {
  flex: 1;
  min-width: 0;
  font-size: 0.7rem;
  color: rgba(244, 239, 233, 0.88);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Detail pane: hero row, then the controls, then this arcanist's own bill. It
   is the body of the editor lightbox, so it scrolls inside the card. */
.planner-char-detail {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* The editor wears the Character Setting modal's head, exactly: #212121 above a
   1px #D05126 line, the 52px portrait in its accent frame, the name in Georgia.
   It is a flex row like every other sheet head, so the close button always sits at
   the card's right edge instead of flowing after the name and wrapping under it. */
.planner-editor-header {
  flex: none;
  position: relative;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 22px 14px;
  background: #212121;
}

.planner-editor-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: #D05126;
}

.planner-editor-header .modal-char-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 26px;
  font-weight: normal;
  letter-spacing: 0;
  color: #ECE5D9;
}

/* The head carries the portrait and the name, nothing else: the plan's own numbers
   are the settings under it, so there is no rarity plate and no status line. Remove
   is a real button where the Setting modal puts its favourite pin. */
.planner-editor-header .modal-char-preview {
  min-width: 0;
}

.planner-editor-header .modal-char-preview img {
  flex: none;
}

.planner-editor-header .modal-char-name-row {
  flex-wrap: wrap;
  gap: 10px;
}

.planner-sheet-close {
  flex: none;
}

.planner-editor-remove {
  height: 24px;
  padding: 0 10px;
  font-size: 10px;
  letter-spacing: 0.5px;
}

/* The settings are the Character Setting modal's own `setting-group`s, one under
   another: the card is modal-wide (440px), so there is no second column. */
.planner-char-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: start;
}

.planner-char-controls .setting-group {
  min-width: 0;
  margin: 0;
}

.planner-char-controls .is-wide {
  grid-column: 1 / -1;
}

/* Same native select as the shop picker, one step smaller. The only select left in
   the tab is the Wilderness board's level picker — every from → to number in the
   character editor is a slider or a tier pip now. */
.planner-field-select {
  -webkit-appearance: none;
  appearance: none;
  flex: 1 1 0;
  min-width: 0;
  height: 32px;
  padding: 0 22px 0 10px;
  background-color: rgba(0, 0, 0, 0.35);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0h10L5 6z' fill='%23B5B5B3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  background-size: 8px 5px;
  border: 1px solid rgba(181, 181, 179, 0.45);
  border-radius: 3px;
  color: #ECE5D9;
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.planner-field-select:hover {
  border-color: rgba(237, 125, 49, 0.75);
  background-color: rgba(0, 0, 0, 0.5);
}

.planner-field-select:focus-visible {
  outline: 2px solid #ED7D31;
  outline-offset: 1px;
}

.planner-field-select option {
  background: #212121;
  color: #ffffff;
}

/* Insight: one row per end, each a run of the game's tier pips. The pips are the
   InfoBook's own `.char-mats-ins-btn`, so the two panels ask a tier in the same
   units, and short of the row's width they wrap rather than shrink. */
.planner-insight-picks,
.planner-level-sliders {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 2px;
}

.planner-insight-row,
.planner-level-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.planner-insight-row .char-mats-ins-boxes {
  flex-wrap: wrap;
}

/* The end a row sets ("From" / "To"), the InfoBook's sub-label at the modal's scale. */
.planner-field-mini {
  flex: none;
  min-width: 30px;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #8f8f8d;
}

/* Level: a range input per end with the figure beside it, as the InfoBook levels a
   character. A 5★ arcanist has 180 levels, which no select can offer. */
.planner-level-slider {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
}

.planner-level-number {
  flex: none;
  min-width: 40px;
  font-family: var(--mono-font);
  font-size: 13px;
  font-weight: 700;
  color: #ECE5D9;
  font-variant-numeric: tabular-nums;
}

.planner-char-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.planner-quick-goal {
  height: 26px;
  padding: 0 10px;
  font-size: 0.66rem;
  font-weight: 700;
  border-radius: 3px;
}

/* Frequency is the resonance-pattern picker: the pattern's own glyph, with its
   name underneath (the game draws glyphs only, but a bill needs the name). */
.planner-freq-row {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.planner-freq-tile {
  position: relative;
  padding: 0;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(181, 181, 179, 0.45);
  border-radius: 3px;
  cursor: pointer;
  transition: border-color 0.15s ease, opacity 0.15s ease;
}

.planner-freq-tile {
  width: 66px;
  flex: 0 0 66px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 3px 3px;
}

.planner-freq-tile img {
  display: block;
  object-fit: cover;
  opacity: 0.55;
  transition: opacity 0.15s ease;
}

.planner-freq-tile img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

/* No glyph in the cache (a board the shape map cannot resolve): keep the box. */
.planner-freq-fallback {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.planner-freq-name {
  width: 100%;
  color: rgba(236, 229, 217, 0.72);
  font-size: 0.5rem;
  line-height: 1.15;
  text-align: center;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.planner-freq-tile.is-active img {
  opacity: 1;
}

.planner-freq-tile.is-active {
  border-color: #ED7D31;
}

.planner-freq-tile:hover {
  border-color: rgba(237, 125, 49, 0.7);
}

.planner-freq-tile:focus-visible {
  outline: 2px solid #ED7D31;
  outline-offset: 1px;
}

.planner-freq-tile.is-active .planner-freq-name {
  color: #ED7D31;
}

/* Euphoria is the Character Setting modal's own tick box, and Mastery is the same
   setting: the game only offers the tiers once a facet is on, so the range sits
   under the ticks and stays switched off (and says why) until one is ticked. */
.planner-euphoria-checks {
  flex-wrap: wrap;
  gap: 8px 20px;
}

.planner-subsetting {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.planner-subsetting.is-disabled {
  opacity: 0.45;
}

.planner-subsetting.is-disabled .planner-field-select,
.planner-subsetting.is-disabled .planner-level-slider {
  cursor: not-allowed;
}

.planner-subsetting-hint {
  margin: 6px 0 0;
  font-size: 0.62rem;
  line-height: 1.4;
  color: #b9b5ae;
}

.planner-char-mats-head {
  margin-top: 2px;
}

/* A bill is a wall of art: the game's own item sticker, no card box and no name
   under it. The name and the exact figure live in the tooltip, because a plan
   can run to seventy materials and the names would drown the quantities. The
   stickers are the size the InfoBook's own material list uses, so a bill and the
   InfoBook ask for the same thing in the same units. */
.planner-mat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px;
}

.planner-mat {
  display: flex;
  justify-content: center;
}

/* The item sticker is a label, not a control, so only the box size changes and
   the lift is dropped. */
.planner-mat .planner-mat-sticker {
  width: 64px;
  height: 64px;
  flex: none;
  cursor: default;
}

.planner-mat .planner-mat-sticker:hover {
  transform: none;
  border-color: transparent;
  box-shadow: none;
}

.planner-mat .planner-mat-sticker:hover .item-sticker-img,
.planner-mat .planner-mat-sticker:hover .item-sticker-border {
  transform: scale(1.18);
}

/* The badge keeps its corner proportionate to the art it sits on. */
.planner-mat .item-sticker-qty {
  bottom: 2px;
  right: 2px;
  padding: 0 4px;
  font-size: 10px;
}

.planner-mat-art-empty {
  position: absolute;
  inset: 28%;
  border: 1px dashed rgba(181, 181, 179, 0.6);
  border-radius: 3px;
  z-index: 2;
}

.planner-mat-qty {
  font-variant-numeric: tabular-nums;
}

/* ---- Activity settings ---------------------------------------------------- */

/* A normal toolbar button beside Add / Goal: the label, then the stamina a day is
   worth, so "how many days is that" is answerable without opening the panel. */
.planner-activity-btn {
  gap: 8px;
}

/* The figure the toolbar prints: the number, then the unit it is counted in, so
   the button says "240/day" rather than a number with no denominator. */
.planner-activity-figure {
  display: inline-flex;
  align-items: baseline;
}

.planner-activity-value {
  font-family: var(--mono-font);
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #ED7D31;
}

.planner-activity-unit {
  font-size: 0.62rem;
  font-weight: 700;
  color: #b9b5ae;
}

.planner-activity-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Two ticks in a modal-wide panel: the label stays on the left and the box on the
   right, so both boxes line up in one column instead of trailing their own text. */
.planner-check-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.planner-check-list .planner-check-row {
  flex-direction: row-reverse;
  justify-content: space-between;
  width: 100%;
}

/* ---- Wilderness ----------------------------------------------------------- */

/* Three selects per row: the three buildings of one kind, side by side. */
.planner-wilderness-selects {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

/* Vigor is a typed figure, not a capped slider: a number box with its unit beside
   it, so the value and the "%" read as one control. */
.planner-vigor-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.planner-vigor-input {
  width: 96px;
  height: 32px;
  padding: 0 10px;
  background-color: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(181, 181, 179, 0.45);
  border-radius: 3px;
  color: #ECE5D9;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color 0.15s ease, background-color 0.15s ease,
    box-shadow 0.15s ease;
}

.planner-vigor-input:hover {
  border-color: rgba(237, 125, 49, 0.75);
  background-color: rgba(0, 0, 0, 0.5);
}

.planner-vigor-input:focus {
  border-color: #ED7D31;
  box-shadow: 0 0 6px rgba(237, 125, 49, 0.4);
}

.planner-vigor-unit {
  font-size: 0.8rem;
  font-weight: 700;
  color: #BFBFBF;
}

/* Dust and Sharpodonty a day: the same item sticker the bill uses, then the figure
   the game would print beside it. */
.planner-wilderness-output {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}

.planner-wilderness-output .planner-farm-drop {
  width: 48px;
  height: 48px;
}

.planner-wilderness-stat {
  display: flex;
  align-items: center;
  gap: 8px;
}

.planner-wilderness-stat-value {
  font-family: var(--mono-font);
  font-size: 0.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #ffffff;
}

/* ---- Warehouse ----------------------------------------------------------- */

/* A wall of slots rather than a stack of settings, so the card is as wide as the
   roster picker: 64px slots line up in nine columns at this width. It is scoped to
   `.planner-sheet` because `.planner-sheet-card` (which sets 440px) comes later in
   this file, so an unscoped rule of the same weight would lose to it. */
.planner-sheet .planner-warehouse-card {
  max-width: 680px;
}

.planner-warehouse-body {
  gap: 10px;
}

.planner-warehouse-hint {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 0.7rem;
  line-height: 1.5;
  color: #9C9791;
}

.planner-warehouse-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* One slot: the bill's own item sticker over the figure the reader types. The frame
   and the art come from `.item-sticker`; the slot is not a button, so it does not
   lift under the cursor. */
.planner-warehouse-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 14px 10px;
}

.planner-warehouse-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.planner-warehouse-sticker {
  width: 64px;
  height: 64px;
  max-width: 100%;
  cursor: default;
}

.planner-warehouse-sticker:hover,
.planner-warehouse-sticker:hover .item-sticker-img,
.planner-warehouse-sticker:hover .item-sticker-border {
  transform: none;
  box-shadow: none;
  border-color: transparent;
}

.planner-warehouse-input {
  width: 100%;
  max-width: 64px;
  height: 22px;
  padding: 0 2px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 3px;
  color: #ffffff;
  font-family: var(--mono-font);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
  box-sizing: border-box;
  transition: border-color 0.15s ease;
  -moz-appearance: textfield;
}

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

.planner-warehouse-input:hover {
  border-color: rgba(255, 255, 255, 0.28);
}

.planner-warehouse-input:focus {
  outline: none;
  border-color: #ED7D31;
}

.planner-warehouse-foot {
  display: flex;
  justify-content: flex-end;
}

.planner-warehouse-reset:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ---- Lightboxes over the Character tab ------------------------------------ */

/* The five panels are one object: a backdrop over the tab and a card on it, drawn
   the way the Character Setting modal draws its own card, so "add" / "edit" /
   "Goal" / "activity" / "Wilderness" all read as the same gesture. */
.planner-sheet {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.72);
}

.planner-sheet[hidden] {
  display: none;
}

/* Every sheet is the site's own modal: `.modal-card` with `.archetype-modal-card`'s
   wallpaper, #B55829 frame and single rounded corner, and `#edit-modal`'s head —
   #212121 above a 1px #D05126 line, the title in the same serif — so a Planner
   panel and a Character Setting panel read as the same object. The card is as wide
   as a normal modal, because these panels are settings, not tables. */
.planner-sheet-card {
  width: 100%;
  max-width: 440px;
  max-height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--panel-bg);
  background-image: url("images/background.png");
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  border: 1px solid #B55829;
  border-radius: 0 20px 0 0;
  box-shadow: 0 0 8px rgba(181, 88, 41, 0.28), 0 0 18px rgba(181, 88, 41, 0.12);
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  overflow: hidden;
}

/* The head is the Character Setting modal's `.archetype-modal-header`. */
.planner-sheet-head {
  flex: none;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 22px 14px;
  background: #212121;
}

.planner-sheet-head::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: #D05126;
}

.planner-sheet-head .archetype-section-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 26px;
  font-weight: normal;
  letter-spacing: 0;
  text-transform: none;
  color: #ECE5D9;
}

/* The body is `.archetype-modal-body`: the wallpaper shows through, one gap
   between the groups, the same 22px gutter as the modal's own body. */
.planner-sheet-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 22px 20px;
  background: transparent;
}

/* The settings inside a sheet are the Character Setting modal's own: the label is
   the tier-1 12px caps, the value its 13px gg sans, every group ruled off with the
   same 1px line. `#edit-modal` scopes those rules to itself, so a sheet — which is
   not inside that modal — repeats them here instead of inventing a look. */
.planner-sheet .setting-group {
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.planner-sheet .setting-group:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.planner-sheet .setting-label {
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #BFBFBF;
}

.planner-sheet .setting-val-display {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: #E5E7EB;
}

.planner-sheet .check-text {
  font-size: 13px;
  color: #E5E7EB;
}

/* The On/Off pair is `#edit-modal`'s own switch: the #111111 track, and #D05126
   with white text on the side that is chosen. */
.planner-sheet .toggle-group {
  margin-top: 8px;
  background: #111111;
  border: 1px solid #676767;
}

.planner-sheet .btn-toggle {
  font-family: 'gg sans', 'Noto Sans', 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #BFBFBF;
}

.planner-sheet .btn-toggle.active {
  background: #D05126;
  color: #FFFFFF;
}

/* A Euphoria facet is its portrait — the same 64px thumb the Character Setting
   modal draws — with the tree's name in the tooltip, and as the label if art is
   missing. */
.planner-euphoria-label {
  font-size: 13px;
  color: #E5E7EB;
}

/* ---- "Add arcanist" ------------------------------------------------------- */

/* The toolbar is the Manage modal's own (roster-toolbar + search-input +
   filter-btn-group), trimmed of the padding it carries inside that card. */
.planner-picker-card {
  max-width: 680px;
}

.planner-picker .roster-toolbar {
  flex: none;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.planner-picker .roster-toolbar-left {
  gap: 8px;
}

.planner-picker .roster-toolbar-left .search-input {
  height: 30px;
}

.planner-picker-grid {
  flex: 1;
  min-height: 0;
  max-height: none;
  padding: 12px;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 14px 10px;
}

.planner-picker-grid .guide-empty {
  grid-column: 1 / -1;
}

/* A tile is roster-char-item, so it only needs the pointer affordance; the
   avatar box keeps its owned frame (this is a list of who can be added). */
.planner-picker .planner-pick {
  cursor: pointer;
}

.planner-picker .planner-pick:hover .roster-avatar-box,
.planner-picker .planner-pick:focus-visible .roster-avatar-box {
  border-color: #ED7D31;
}

.planner-picker .planner-pick:focus-visible {
  outline: none;
}


/* ==========================================================================
   PLANNER (calculator)
   The first tab answers two questions: how many pulls can I afford by the day a
   banner closes, and what are the odds of owning 1…6 copies of its rate-up if I
   spend them? It is a ledger, so the tab reads top-down: what the reader holds,
   what they earn, what they spend, then the balance those numbers draw as one
   curve over the next six months, with a dot for every banner they plan to pull
   on. Nothing here invents a second look — the section bars are the Appearance
   modal's, the number fields are the Event tab's Owned field, the picker is the
   "Add arcanist" lightbox, and the odds chips are one width so P0…P5 read as a
   scale.
   ========================================================================== */

.calc-scroll {
  gap: 18px;
}

/* One section = a bar + its body, exactly like the Event tab's groups. */
.calc-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.calc-section .archetype-section-header {
  margin-bottom: 0;
}

/* The running figure on a section bar (the hold in pulls, what the plan costs). */
.calc-hold-total {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #ECE5D9;
  opacity: 0.85;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---- Current amounts ---- */
.calc-hold {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* The three purses, side by side. */
.calc-hold-purses {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 10px 14px;
  align-items: end;
}

/* A pair that reads as one line: a pity counter beside its guarantee box, or the
   monthly and patchly package fields. Two columns wide, one on a narrow screen. */
.calc-pair-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(184px, 1fr));
  gap: 10px 14px;
  align-items: end;
}

/* The package pair sits under its group's cards rather than inside their grid: as a
   grid item it drove `grid-auto-rows` and stretched every card to its own height once
   the two fields stacked on a phone. */
.calc-group > .calc-pair-row-packages {
  grid-template-columns: repeat(auto-fit, minmax(184px, 1fr));
}

/* A labelled control: the label above, the number in the Event tab's Owned
   field (dark plate, currency art inside its left edge). */
.calc-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.calc-field-label {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #B5B5B3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calc-field .planner-owned-field {
  display: flex;
  width: 100%;
}

.calc-field .planner-owned-input,
.calc-field .planner-owned-field.has-icon .planner-owned-input {
  width: 100%;
}

/* The Drop Outcome's daily-purchase picker is the Event tab's shop picker. */
.calc-field .planner-shop-select {
  width: 100%;
  max-width: 220px;
}

/* A tick box is a card, not a loose label: left bare in the grid the box and its
   name read as stray text on a phone, and nothing said what ticking it is worth.
   The card carries the box, the name, and the source's projected yield under it. */
.calc-check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.calc-check:hover {
  border-color: rgba(237, 125, 49, 0.45);
}

/* The card lights up the way the Event tab's picked card does not: here the tick is
   the only state the reader can see, so it has to be visible. */
.calc-check:has(input:checked) {
  background: rgba(208, 81, 38, 0.12);
  border-color: rgba(237, 125, 49, 0.55);
}

.calc-check input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  flex: none;
  accent-color: #D05126;
  cursor: pointer;
}

.calc-check-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.calc-check .calc-field-label {
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.7rem;
  color: #ECE5D9;
  white-space: normal;
  overflow: visible;
  cursor: pointer;
}

/* `+15 <unilog> /month` — what the box is worth, in the tab's own pull figure. */
.calc-check-yield {
  font-size: 0.62rem;
  font-weight: 700;
  color: #8f8f8d;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* A currency glyph standing where the word "pulls" used to be: `132 <unilog>`. */
.calc-pull-icon {
  width: 14px;
  height: 14px;
  object-fit: contain;
  display: inline-block;
  vertical-align: -2px;
  margin-left: 3px;
  flex: none;
}

/* ---- Drop income / Crystal Drop outcome ---- */
/* Income is two titled blocks — what every player earns and what a purchaser adds —
   so the free half never reads as if it needed a purchase. */
.calc-income {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.calc-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.calc-group-title {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #ED7D31;
}

.calc-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(184px, 1fr));
  /* Every row is the same height as the tallest one, and every card fills its row.
     Bottom alignment (`end`) left a one-line card short beside a two-line one, which
     read as a big button next to a small one at narrower widths. */
  grid-auto-rows: 1fr;
  gap: 8px 14px;
  align-items: stretch;
}

/* The section bar's right side when it carries a figure *and* a button. */
.calc-section-tail {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* The "?" that opens the income sheet: a small round badge on the section bar,
   drawn as an outline only — no fill behind it. */
.calc-help-btn {
  width: 22px;
  height: 22px;
  flex: none;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 800;
  line-height: 1;
  color: #ED7D31;
  background: none;
  border: 1px solid rgba(237, 125, 49, 0.45);
  border-radius: 50%;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.calc-help-btn:hover {
  border-color: #ED7D31;
  color: #FFD9BC;
}

.calc-help-btn:focus-visible {
  outline: 2px solid #ED7D31;
  outline-offset: 2px;
}

.calc-outcome {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.calc-outcome .calc-field {
  flex: 0 0 200px;
}

.calc-hint {
  flex: 1;
  min-width: 180px;
  margin: 0;
  font-size: 0.7rem;
  line-height: 1.5;
  color: #8f8f8d;
}

/* ---- The balance chart ---- */
.calc-chart {
  padding: 2px 0 0;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 4px;
}

/* The span chips and the running total share the section bar. */
.calc-chart-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* 1 / 2 / 3 / 6 months: one segmented control, the active span filled in the
   modal's orange. */
.calc-span {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
}

.calc-span-btn {
  padding: 3px 8px;
  font-family: inherit;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #B5B5B3;
  background: transparent;
  border: 0;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease;
}

.calc-span-btn:hover {
  color: #ECE5D9;
}

.calc-span-btn.is-active {
  color: #1b1b1b;
  background: #ED7D31;
}

.calc-span-btn:focus-visible {
  outline: 2px solid #ED7D31;
  outline-offset: 1px;
}

/* The row under the chart: what the plan leaves, then where it is held. A reader
   does not pre-convert Clear Drop into pulls, so the three purses print side by
   side instead of being folded into one figure. */
.calc-summary {
  display: flex;
  align-items: center;
  gap: 6px 18px;
  flex-wrap: wrap;
  padding: 8px 2px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.calc-summary-cell {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.calc-summary-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8f8f8d;
  white-space: nowrap;
}

.calc-summary-value {
  display: inline-flex;
  align-items: center;
  font-size: 0.86rem;
  font-weight: 800;
  color: #ECE5D9;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.calc-chart-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.calc-grid-line {
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 1;
}

.calc-zero-line {
  stroke: rgba(221, 56, 56, 0.55);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.calc-axis-label {
  fill: #8f8f8d;
  font-size: 10px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
}

.calc-chart-line {
  fill: none;
  stroke: #ED7D31;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

/* One dot per planned banner, on the day its pulls are spent. The whole group is
   the button, so the label above the dot is part of the hit box. */
.calc-dot {
  cursor: pointer;
}

.calc-dot circle {
  fill: #ED7D31;
  stroke: #1b1b1b;
  stroke-width: 1.5;
  transition: fill 0.15s ease;
}

.calc-dot-label {
  fill: #ECE5D9;
  font-size: 13px;
  font-weight: 800;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

/* The banner's own date, stamped over the icon so a dot says *when* as well as
   *who* without opening its sheet. Plain text — no outline, no plate: the number
   is legible on its own and the ring around it read as a badge. */
.calc-dot-date {
  fill: #ECE5D9;
  font-size: 9px;
  font-weight: 800;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  pointer-events: none;
}

.calc-dot:hover circle,
.calc-dot:focus-visible circle {
  fill: #ffb066;
}

.calc-dot:focus-visible {
  outline: none;
}

/* ---- One banner card ---- */
.calc-banner-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.calc-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  /* The kind's colour, in one place: the left rail below and the kind tag inside the
     card both read it, so a new kind only has to declare the pair once. `-ink` is the
     same colour lifted enough to print as text — `#B10202` on black is invisible. */
  --calc-kind: rgba(237, 125, 49, 0.45);
  --calc-kind-ink: #ED7D31;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-left: 3px solid var(--calc-kind);
  border-radius: 4px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

/* The left rail is the banner's kind, so a long list reads at a glance. A kind with
   no colour of its own (Collab, Yearning, …) keeps the tab's orange. */
.calc-card[data-kind="Debut"] {
  --calc-kind: #D4EDBC;
  --calc-kind-ink: #D4EDBC;
}

.calc-card[data-kind="Ripples"] {
  --calc-kind: #C6DBE1;
  --calc-kind-ink: #C6DBE1;
}

.calc-card[data-kind="Rerun"] {
  --calc-kind: #FFE5A0;
  --calc-kind-ink: #FFE5A0;
}

.calc-card[data-kind="Limited"] {
  --calc-kind: #B10202;
  --calc-kind-ink: #E4695F;
}

.calc-card[data-kind="Event"] {
  --calc-kind: #0A53A8;
  --calc-kind-ink: #5A9BE2;
}

.calc-card:hover {
  background: rgba(0, 0, 0, 0.42);
}

.calc-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.calc-card-heads {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
}

.calc-head {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(181, 181, 179, 0.35);
}

.calc-head-empty,
.calc-head-any {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #B5B5B3;
  border-style: dashed;
}

/* `…` — the picker lists three rate-ups and counts the rest in this chip. */
.calc-head-more {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  color: #8f8f8d;
  background: rgba(255, 255, 255, 0.06);
  border-style: dashed;
}

.calc-card-title {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  flex: 1;
}

.calc-card-name {
  font-size: 0.82rem;
  font-weight: 800;
  color: #ECE5D9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The round tags: kind, release, end, the pulls the budget buys by then. */
.calc-card-pills {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  min-width: 0;
}

.calc-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 19px;
  padding: 0 8px;
  border: 1px solid rgba(181, 181, 179, 0.35);
  border-radius: 10px;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  color: #B5B5B3;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.calc-pill-key {
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8f8f8d;
}

.calc-pill.is-type {
  color: #ECE5D9;
  border-color: rgba(181, 181, 179, 0.55);
}

/* The kind tag wears the card's own rail colour, so `Ripples` reads as the same ice
   blue as the band beside it and a long list can be scanned by tag alone. */
.calc-card .calc-pill.is-type {
  color: var(--calc-kind-ink, #ECE5D9);
  border-color: var(--calc-kind, rgba(181, 181, 179, 0.55));
  background: rgba(255, 255, 255, 0.05);
}

/* The patch the run ships in — the sheet's own label (`3.9`, `4.0`, `AH Collab`) —
   so a card reads `Debut` then `3.9` then the dates. */
.calc-pill.is-version {
  color: #ECE5D9;
  border-color: rgba(181, 181, 179, 0.8);
  background: rgba(255, 255, 255, 0.09);
  font-variant-numeric: tabular-nums;
}

.calc-pill.is-pulls {
  color: #ED7D31;
  border-color: rgba(237, 125, 49, 0.55);
  background: rgba(208, 81, 38, 0.12);
}

.calc-pill .calc-pull-icon {
  width: 12px;
  height: 12px;
  margin-left: 1px;
  vertical-align: 0;
}

.calc-pill.is-predicted {
  color: #7fb0d8;
  border-color: rgba(127, 176, 216, 0.55);
  background: rgba(127, 176, 216, 0.1);
}

/* A banner's own perks — the free ten-pull, the discounted ten-pull, the selector —
   wear the health-green so they read as upside, not as another date. */
.calc-pill.is-perk {
  color: #7FC98D;
  border-color: rgba(96, 165, 102, 0.55);
  background: rgba(96, 165, 102, 0.12);
}

.calc-card-remove {
  flex: none;
  width: 22px;
  height: 22px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1;
  color: #8f8f8d;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.calc-card-remove:hover {
  color: #DD3838;
  border-color: rgba(221, 56, 56, 0.5);
}

.calc-card-remove:focus-visible {
  outline: 2px solid #ED7D31;
  outline-offset: 1px;
}

/* Portrait pips: one chip per copy tier, on one line so they read as a scale. */
.calc-card-odds {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
}

.calc-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(181, 181, 179, 0.25);
  border-radius: 3px;
  font-size: 0.64rem;
  font-weight: 700;
  color: #ECE5D9;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.calc-chip b {
  font-size: 0.58rem;
  font-weight: 800;
  color: #8f8f8d;
}

.calc-card-note {
  font-size: 0.64rem;
  color: #8f8f8d;
}

.calc-card-foot {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

/* The pull count is a plain number field — the reader types it, they do not step
   it one at a time against a 200-pull banner. */
.calc-pull-field {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  flex: none;
}

.calc-pull-label {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8f8f8d;
  white-space: nowrap;
}

/* The ceiling beside the field: the same box, filled rather than typed into. It
   reads as a figure (number + the Unilog art) so it matches the pills above. */
.calc-max-field {
  cursor: default;
}

.calc-max-value {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-width: 84px;
  height: 28px;
  padding: 0 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(181, 181, 179, 0.28);
  border-radius: 3px;
  color: #B5B5B3;
  font-size: 0.78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.calc-pull-input {
  width: 84px;
  height: 28px;
  padding: 0 8px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(181, 181, 179, 0.5);
  border-radius: 3px;
  color: #ffffff;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  outline: none;
  appearance: textfield;
  -moz-appearance: textfield;
}

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

.calc-pull-input:focus {
  border-color: #ED7D31;
  box-shadow: 0 0 6px rgba(237, 125, 49, 0.4);
}

/* ---- The three sheets over the tab: "+ Add banner", a dot's banner, and the
   income help. Each is the site's own modal card (`.modal-card
   archetype-modal-card`) inside a lightbox anchored to the tab, so it wears the
   standard header, title and close button rather than a parallel look. ---- */
.calc-picker,
.calc-info,
.calc-help {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.calc-picker[hidden],
.calc-info[hidden],
.calc-help[hidden] {
  display: none;
}

.calc-picker-backdrop,
.calc-info-backdrop,
.calc-help-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
}

.calc-picker-card,
.calc-info-card,
.calc-help-card {
  position: relative;
  width: min(680px, 100%);
  max-height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.calc-picker-card > .archetype-modal-header,
.calc-info-card > .archetype-modal-header,
.calc-help-card > .archetype-modal-header {
  flex: none;
}

.calc-picker-card > .archetype-modal-body,
.calc-info-card > .archetype-modal-body,
.calc-help-card > .archetype-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
}

/* The info sheet is narrower: one banner, six odds cards. */
.calc-info-card {
  width: min(560px, 100%);
}

.calc-help-card {
  width: min(640px, 100%);
}

/* The toolbar is the Manage modal's own search box and nothing else: the type
   chips are gone, so the list is one flat set of every banner still to run and
   the field takes the whole row. */
.calc-picker .roster-toolbar {
  padding: 0 0 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.calc-picker .roster-toolbar-left {
  gap: 8px;
}

.calc-picker .roster-toolbar-left .search-input {
  height: 30px;
  max-width: none;
}

.calc-picker-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 0 0;
}

.calc-picker-list .guide-empty {
  padding: 18px 0;
}

/* One banner to add: heads, name, kind + window. */
.calc-pick {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 8px;
  font-family: inherit;
  text-align: left;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.calc-pick:hover,
.calc-pick:focus-visible {
  background: rgba(208, 81, 38, 0.14);
  border-color: rgba(237, 125, 49, 0.45);
  outline: none;
}

.calc-pick-heads {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
}

.calc-pick-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.calc-pick-name {
  flex: 1;
  min-width: 0;
  font-size: 0.78rem;
  font-weight: 700;
  color: #ECE5D9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The row's trailing cluster: the patch tag, and `Predicted` after it on a forecast.
   Both sit at the row's right edge, so neither crowds the banner's name. */
.calc-pick-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.calc-pick-version {
  flex: none;
  display: inline-flex;
  align-items: center;
  height: 16px;
  padding: 0 6px;
  border: 1px solid rgba(181, 181, 179, 0.6);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.58rem;
  font-weight: 800;
  color: #ECE5D9;
  font-variant-numeric: tabular-nums;
}

.calc-pick-meta {
  font-size: 0.62rem;
  color: #8f8f8d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- the sheet a chart dot opens ---- */
.calc-info-head {
  gap: 12px;
}

.calc-info-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.calc-info-title-wrap .archetype-modal-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calc-info-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.calc-info-heads {
  display: flex;
  align-items: center;
  gap: 3px;
  flex: none;
}

.calc-info-heads .calc-head {
  width: 34px;
  height: 34px;
}

.calc-info-pills {
  margin: 0;
}

.calc-info-rule {
  margin: 0;
  font-size: 0.74rem;
  line-height: 1.5;
  color: #ECE5D9;
}

/* The mechanical quirks — which pity counter, the free ten-pull, the discount, the
   selector — as one bullet each, under the rule they modify. */
.calc-info-notes {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.calc-info-note {
  font-size: 0.7rem;
  line-height: 1.5;
  color: #B5B5B3;
}

/* ---- the income help sheet ---- */
.calc-help-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.calc-help-lead {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.5;
  color: #B5B5B3;
}

.calc-help-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.calc-help-group-title {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #ED7D31;
}

.calc-help-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "name amount"
    "when when"
    "note note";
  gap: 2px 10px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-left: 2px solid rgba(237, 125, 49, 0.45);
  border-radius: 4px;
}

.calc-help-name {
  grid-area: name;
  font-size: 0.78rem;
  font-weight: 700;
  color: #ECE5D9;
  min-width: 0;
}

.calc-help-amount {
  grid-area: amount;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
  font-weight: 800;
  color: #ECE5D9;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.calc-help-amount:empty {
  display: none;
}

.calc-help-when {
  grid-area: when;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #ED7D31;
}

.calc-help-note {
  grid-area: note;
  font-size: 0.68rem;
  line-height: 1.45;
  color: #B5B5B3;
}

.calc-note {
  margin: 0;
  font-size: 0.66rem;
  color: #8f8f8d;
}

.calc-figures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
}

.calc-figure {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 4px;
  min-width: 0;
}

.calc-figure-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8f8f8d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calc-figure-value {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.86rem;
  font-weight: 800;
  color: #ECE5D9;
  font-variant-numeric: tabular-nums;
}

.calc-figure-icon {
  width: 16px;
  height: 16px;
  flex: none;
  object-fit: contain;
  display: block;
}

.calc-figure.is-strong {
  border-color: rgba(237, 125, 49, 0.45);
  background: rgba(208, 81, 38, 0.12);
}

.calc-figure.is-strong .calc-figure-value {
  font-size: 1.05rem;
  color: #ED7D31;
}

.calc-odds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 8px;
}

.calc-odd-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 4px;
}

.calc-odd-label {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #ED7D31;
}

.calc-odd-value {
  font-size: 1.15rem;
  font-weight: 800;
  color: #ECE5D9;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.calc-odd-hint {
  font-size: 0.58rem;
  color: #8f8f8d;
}

/* On a phone the income grid and the card foot each take their own line: a label,
   a 200-wide field and a tick box cannot share one 360px row. */
@media (max-width: 768px) {
  .calc-hold {
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  }
  .calc-group-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }
  /* The package pair narrows with the tick-box cards, so the two inputs never go
     full width while the cards above them are still two-up — that mismatch read as
     one oversized button next to a row of small ones. */
  .calc-group > .calc-pair-row-packages {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }
  .calc-outcome .calc-field {
    flex: 1 1 140px;
  }
  /* The section bar's span chips and running total each take a line of their own:
     four chips and a figure do not fit beside a section title. */
  .calc-section .archetype-section-header {
    flex-wrap: wrap;
  }
  .calc-chart-bar {
    flex: 1 1 100%;
    width: auto;
    min-width: 0;
    justify-content: space-between;
    gap: 6px;
  }
  .calc-span {
    flex: 1 1 auto;
  }
  .calc-span-btn {
    flex: 1 1 auto;
    padding: 4px 6px;
  }
  /* The summary keeps two cells a row, so `Crystal Drop` is never a 40px sliver. */
  .calc-summary {
    gap: 4px 12px;
  }
  .calc-summary-cell {
    flex: 1 1 44%;
  }
  /* The picker, the info sheet and the help sheet would scroll out from under the
     reader inside the tab. */
  .calc-picker,
  .calc-info,
  .calc-help {
    position: fixed;
  }
  .calc-card-foot {
    flex-wrap: wrap;
    gap: 8px;
  }
  /* A banner with several rate-up heads leaves the name almost no room in a 360px
     row, and the pills then stack into one 90px column. On a phone the heads and the
     remove button take the first line and the name + tags get the full width. */
  .calc-card-head {
    flex-wrap: wrap;
    align-items: flex-start;
  }
  .calc-card-heads {
    order: 1;
    flex-wrap: wrap;
  }
  .calc-card-remove {
    order: 2;
    margin-left: auto;
  }
  .calc-card-title {
    order: 3;
    flex: 1 1 100%;
  }
  .calc-card-odds {
    gap: 3px;
  }
  .calc-chip {
    font-size: 0.6rem;
    padding: 2px 5px;
  }
}

/* ==========================================================================
   RESPONSIVE ADJUSTMENTS
   ========================================================================== */

/* The wordmark is wider than the icon, so phones drop it and keep the icon. */
#lang-current-short {
  display: none;
}

/* Tablet and below: the four nav links move into the menu dropdown. The
   threshold is 1080px (not 1024px) because four labelled links plus the right
   cluster no longer fit the bar in the 1025-1048px band. */
@media (max-width: 1080px) {
  .navbar-nav {
    display: none;
  }
  .navbar-hamburger {
    display: flex !important;
  }
}

/* Small laptops / large tablets: tighten the header so nothing wraps. */
@media (max-width: 900px) {
  .navbar-container {
    padding: 8px 16px;
    gap: 12px;
  }
  .navbar-left {
    gap: 12px;
  }
  .navbar-right {
    gap: 8px;
  }
}

/* The navbar is a full-bleed bar at every width: it never becomes the legacy
   floating card that `.top-controls` turns into on small screens. */
@media (max-width: 768px) {
  .global-navbar {
    margin: 0;
    width: 100%;
    max-width: 100%;
    padding: 0;
    border-radius: 0;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
  }
  .navbar-container {
    padding: 8px 14px;
  }
  /* One step down from the 44px desktop brand, still larger than the phones'. */
  .global-navbar .app-logo-img {
    height: 30px;
  }
  .global-navbar .app-brand-icon-box {
    width: 38px;
    height: 38px;
  }
  .global-navbar .app-brand-icon {
    width: 32px;
    height: 32px;
  }
}

/* Phones: keep the whole header on one line. */
@media (max-width: 620px) {
  .navbar-container {
    padding: 8px 12px;
    gap: 10px;
  }
  .global-navbar .app-logo-img {
    height: 26px;
  }
  .global-navbar .app-brand-icon-box {
    width: 34px;
    height: 34px;
  }
  .global-navbar .app-brand-icon {
    width: 28px;
    height: 28px;
  }
  .navbar-right {
    gap: 6px;
  }
  .navbar-right #btn-json {
    padding: 0 10px;
  }
  /* The full language name is wide; the short code fits. */
  #lang-current-label {
    display: none;
  }
  #lang-current-short {
    display: inline;
  }
  .lang-dropdown-btn {
    padding: 0 8px;
  }
  /* "Crew 0/0" loses its label, keeping the count and the icon. */
  .global-navbar .stat-badge > span[data-i18n] {
    display: none;
  }
  .global-navbar .stat-badge {
    padding: 0 8px;
    gap: 4px;
  }
}

/* Very small phones: drop the wordmark entirely, the icon carries the brand. */
@media (max-width: 430px) {
  .global-navbar .app-logo-wrap {
    display: none;
  }
  .navbar-container {
    padding: 8px 10px;
  }
  .navbar-right {
    gap: 5px;
  }
  .navbar-right #btn-json {
    padding: 0 8px;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
  }
  .navbar-menu {
    min-width: 140px;
  }
}

/* Below a comfortable single row: the search and the three icon buttons share
   the first row, and the filter chips take the second one. */
@media (max-width: 900px) {
  .mainboard-toolbar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
  }
  /* In a wrapped row `flex: 1 1 200px` is fine, but the field must be allowed
     to shrink past its min-width or the icons get pushed onto their own line. */
  .mainboard-search-wrap {
    flex: 1 1 120px;
    width: auto;
    max-width: 380px;
    min-width: 0;
  }
  .mainboard-filters-group {
    order: 2;
    flex: 1 1 100%;
    justify-content: flex-start;
  }
  .mainboard-actions-group {
    order: 1;
    flex: 0 0 auto;
    margin-left: auto;
    gap: 6px;
  }
  .mainboard-actions-group .mainboard-icon-btn,
  .mainboard-actions-group #btn-export-image {
    flex: 0 0 auto;
  }
  .appearance-tabs {
    margin: 8px 0 0 0;
    width: 100%;
    justify-content: center;
  }
}

/* The filter chips and actions need to wrap rather than shrink off-screen. */
@media (max-width: 560px) {
  .mainboard-filters-group {
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-start;
  }
  /* The chips keep their desktop size here on purpose: shrinking them made the
     row look pinched. They wrap onto separate lines instead. */
  .mainboard-actions-group {
    flex-wrap: nowrap;
    gap: 5px;
  }
  /* Icon buttons keep their size; only the labels would have stretched. */
  .mainboard-actions-group .mainboard-icon-btn,
  .mainboard-actions-group #btn-export-image {
    flex: 0 0 auto;
  }
  #showcase-board {
    padding-left: 8px;
    padding-right: 8px;
  }
  /* The Appearance modal fills the width it has instead of 95vw of padding. */
  #appearance-modal .appearance-modal-card {
    width: calc(100vw - 16px) !important;
  }
  #appearance-modal .appearance-tabs {
    padding: 8px 10px;
    gap: 6px;
  }
  #appearance-modal .appearance-tabs .manage-tab {
    padding: 6px 10px;
    font-size: 0.68rem;
  }
  .appearance-tab-panel .modal-body {
    max-height: 62vh;
  }
}

/* Planner: the toolbar stacks, and the cards tighten on phones. These rules sit
   after the shared responsive blocks so they win at equal specificity. */
@media (max-width: 768px) {
  /* Same shape as the InfoBook on a phone: title on the first row, the mode
     tabs on their own row below, close button in the header's top-right corner.
     The only difference is that the tab must not grow — the generic rule lets a
     tab fill the row, which is fine for four tabs and turns a lone "Event" into
     a full-width bar sitting under the close button. */
  #planner-modal .archetype-modal-header {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 44px 10px 12px;
  }
  /* The editor's head is a sheet head, not the modal's own: portrait + name on one
     row with the close button beside them, so it must not inherit the modal's wrap
     (and the 44px gutter that wrap reserved for a floating close). */
  #planner-modal .planner-editor-header {
    flex-wrap: nowrap;
    padding: 14px 12px 12px;
  }
  #planner-modal .archetype-modal-title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 19px;
    line-height: 1.2;
  }
  #planner-modal .builds-header-actions {
    flex: 1 1 100%;
    margin-left: 0;
    flex-wrap: nowrap;
    justify-content: flex-start;
    min-width: 0;
  }
  #planner-modal .builds-mode-group {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: nowrap;
    min-width: 0;
  }
  #planner-modal .builds-mode-btn {
    flex: 0 0 auto;
    padding: 0 10px;
    font-size: 0.6rem;
  }
  .planner-toolbar {
    padding: 10px 12px;
    gap: 8px 10px;
  }
  /* A tablet is wide enough to keep the lead and its buttons on one row, so the
     tail keeps its own width and only wraps when it has to. Pushing it to 100%
     here spread three buttons across 700px of empty bar and cost the scroller a
     whole row of height; the phone rule below stacks it once it stops fitting. */
  .planner-toolbar-tail {
    margin-left: auto;
    width: auto;
    justify-content: flex-end;
    /* "<icon> OWNED [n]" + the total + reset is more than a phone's width at the
       desktop sizes, so the row tightens instead of scrolling sideways. */
    gap: 8px;
  }
  .planner-owned-wrap {
    margin-right: 0;
    gap: 4px;
  }
  .planner-owned-label {
    font-size: 0.66rem;
    letter-spacing: 0.03em;
  }
  .planner-owned-input {
    width: 58px;
  }
  /* The icon lives inside the field, so the box keeps its room here too. */
  .planner-owned-field.has-icon .planner-owned-input {
    width: 74px;
    padding-left: 24px;
  }
  .planner-owned-icon {
    left: 4px;
    width: 16px;
    height: 16px;
  }
  /* The tooltip is `fixed` under the cursor, so on a phone it never outgrows the
     screen — the figures wrap inside their own column instead. */
  .planner-owned-tooltip {
    max-width: calc(100vw - 24px);
  }
  .planner-scroll {
    padding: 12px 12px 18px;
  }
  /* Character tab: the icon grid, the bill and the farm route are one column on
     a phone, so there is still exactly one scroller — the column itself. */
  .planner-char-scroll {
    padding: 10px 12px 16px;
  }
  .planner-char-rail {
    grid-template-columns: repeat(auto-fill, minmax(54px, 1fr));
    gap: 6px;
  }
  .planner-char-controls {
    grid-template-columns: 1fr;
  }
  .planner-farm-total {
    font-size: 0.68rem;
  }
  /* The panels are lightboxes on a phone: inside a scrolling column an absolutely
     positioned overlay would scroll out from under the reader. */
  .planner-sheet {
    position: fixed;
    padding: 10px;
  }
  .planner-sheet-body {
    padding: 10px;
  }
  .planner-mat-grid {
    grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
    gap: 6px;
  }
  .planner-mat .planner-mat-sticker {
    width: 56px;
    height: 56px;
  }
  .planner-picker-grid {
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 10px 6px;
  }
  .planner-picker .roster-avatar-box {
    width: 52px;
    height: 52px;
  }
  .planner-picker .roster-char-name {
    max-width: 64px;
    font-size: 0.62rem;
  }
  .planner-picker .filter-btn {
    min-width: 26px;
    padding: 0 4px;
    font-size: 0.6rem;
  }
  .planner-warehouse-grid {
    grid-template-columns: repeat(auto-fill, minmax(54px, 1fr));
    gap: 10px 6px;
  }
  .planner-warehouse-sticker {
    width: 54px;
    height: 54px;
  }
  .planner-warehouse-input {
    max-width: 54px;
  }
}

@media (max-width: 560px) {
  .planner-modal-card {
    height: min(92vh, 820px);
  }
  /* Below ~560px the lead and the buttons stop fitting on one row, so the tail
     takes a row of its own and spreads across it. */
  .planner-toolbar-tail {
    margin-left: 0;
    width: 100%;
    justify-content: space-between;
  }
  .planner-grid {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 6px;
  }
  .planner-card {
    padding: 6px 4px 4px;
  }
  .planner-card-art {
    width: 62px;
    height: 62px;
  }
  .planner-card-art img {
    width: 62px;
    height: 62px;
  }
  .planner-card-name {
    font-size: 0.58rem;
  }
  .planner-stepper {
    height: 22px;
  }
  .planner-count {
    font-size: 0.68rem;
  }
  .planner-step {
    width: 18px;
    flex-basis: 18px;
    font-size: 0.68rem;
  }
  .planner-total-label {
    font-size: 0.62rem;
  }
  .planner-total-value {
    font-size: 0.82rem;
  }
  .planner-shop-select {
    max-width: 170px;
  }
  /* The bill is the densest thing in the modal; it shrinks a step further
     instead of the grid turning into a horizontal scroll. */
  .planner-mat-grid {
    grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  }
  .planner-mat .planner-mat-sticker {
    width: 52px;
    height: 52px;
  }
  /* A 52px sticker needs a smaller badge, or "894k" eats half the art. */
  .planner-mat .item-sticker-qty {
    font-size: 9px;
    padding: 0 3px;
  }
  .planner-add-btn {
    padding: 0 10px;
    font-size: 0.64rem;
  }
}
