/* Five independent adventures, with generous touch targets on small screens. */
.role-switch {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
}
.role-switch button {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 8px 4px;
  font-size: 13px;
  white-space: nowrap;
}
@media (max-width: 1100px) {
  .role-switch { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .role-switch button { font-size: 14px; }
  .role-switch [data-character="female3"] { grid-column: 1 / -1; }
}
@media (max-width: 370px) {
  .role-switch button { font-size: 13px; }
}

/* Icons follow the treasure owner even when viewed under another theme. */
body .item-art.mage {
  background-image: url('assets/mage-atlas.png?v=02bc6bb4');
}

/* Star Xi's ice palace gallery uses the female3 profile and independent mage role. */
body[data-character="female3"] .character-panel {
  border-color: #a8c9df70;
  background: linear-gradient(142deg, #233d53, #142a3e 78%);
}
body[data-character="female3"] .character-stage {
  height: 600px;
  container-type: inline-size;
  --stage-arch: #8abbdc45;
  background: radial-gradient(ellipse at 50% 27%, #fcfdff 0, #edf6fc 42%, #aec9e5 108%);
  border-top-color: #b8d7ef59;
  border-bottom-color: #9ebbd95c;
}
body[data-character="female3"] .character-stage::before {
  background: radial-gradient(ellipse at 12% 43%, #a9cbe724, transparent 37%),
    radial-gradient(ellipse at 92% 76%, #6c9ccd1f, transparent 40%),
    linear-gradient(116deg, transparent 22%, #fffef43b 23%, transparent 24%);
}
body[data-character="female3"] .portal {
  top: 32px;
  height: 514px;
  width: min(382px, 86%);
  border-color: var(--stage-arch);
  border-bottom-color: transparent;
}
body[data-character="female3"] .portal::before { inset: 14px; }
body[data-character="female3"] .character-sprite {
  /* Preserve the 1774 × 887 four-column sheet cell ratio. */
  top: -140px;
  height: 760px;
  width: 380px;
  
  filter: drop-shadow(0 7px 8px #42658d26);
}
body[data-character="female3"] .wardrobe-layer { filter: none; }
body[data-character="female3"] .head-layer { clip-path: polygon(20% 0, 80% 0, 85% 42%, 15% 42%); }
body[data-character="female3"] .body-layer { clip-path: polygon(14% 42%, 86% 42%, 82% 67%, 18% 67%); }
body[data-character="female3"] .arms-layer { clip-path: polygon(0 39%, 20% 39%, 25% 66%, 75% 66%, 80% 39%, 100% 39%, 100% 68%, 0 68%); }
body[data-character="female3"] .legs-layer { clip-path: polygon(18% 66%, 82% 66%, 88% 90%, 12% 90%); }
body[data-character="female3"] .feet-layer { clip-path: polygon(10% 88%, 90% 88%, 100% 100%, 0 100%); }
body[data-character="female3"] .orbit-view {
  top: 12px;
  height: 580px;
  width: 290px;
  filter: drop-shadow(0 7px 8px #42658d26);
}
/* Each mage view keeps the complete crown, robe and crystal staff. */
body[data-character="female3"] .orbit-figure { clip-path: none; }
body[data-character="female3"] .stage-floor {
  width: 246px;
  bottom: 4px;
  height: 23px;
  background: radial-gradient(ellipse, #567d9a29, #84a7c912 46%, transparent 75%);
}
body[data-character="female3"] .mount-companion {
  color: #3f6784;
  text-shadow: 0 1px 1px #fff8e9;
}
body[data-character="female3"] .preview-label {
  position: static;
  transform: none;
  width: fit-content;
  max-width: calc(100% - 32px);
  margin: 12px auto 0;
  white-space: normal;
  text-align: center;
  background: #264b6ce8;
  border-color: #b7d7ed;
  color: #fff8e9;
}
body[data-character="female3"] .character-caption {
  padding-top: 21px;
  padding-bottom: 19px;
  gap: 16px;
  align-items: flex-start;
}
body[data-character="female3"] .character-caption h2 {
  color: #f0f7ff;
  font-size: 28px;
  letter-spacing: .16em;
}
body[data-character="female3"] .character-caption p { color: #c4dbee; }
body[data-character="female3"] .character-caption > .text-button { margin-top: 9px; }
body[data-character="female3"] .portrait-button {
  min-height: 88px;
  gap: 13px;
  padding: 5px 14px 5px 5px;
  border-color: #bba07180;
  background: linear-gradient(140deg, #d6eafa12, #c9e5fb07);
  box-shadow: inset 0 0 0 1px #c4e2f50d;
}
body[data-character="female3"] .portrait-thumbnail {
  flex: 0 0 66px;
  width: 66px;
  height: 76px;
  border-color: #d2bd908c;
  background: #edf7fd;
}
body[data-character="female3"] .portrait-thumbnail img {
  top: -31px;
  left: -35px;
  width: 143px;
}
body[data-character="female3"] .portrait-button:hover {
  border-color: #dcc089;
  background: #f0d6a31c;
}
body[data-character="female3"] .portrait-button:focus-visible { outline-color: #e5c78b; }
body[data-character="female3"] .heroine-view-selector {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 13px;
}
body[data-character="female3"] .heroine-view-label {
  color: #bcd8ed;
  font-size: 12px;
  letter-spacing: .08em;
  white-space: nowrap;
}
body[data-character="female3"] .heroine-view-modes {
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid #9ebfdd50;
  border-radius: 9px;
  background: #132d44;
}
body[data-character="female3"] .heroine-view-button {
  min-height: 40px;
  padding: 7px 13px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #c4dcf1;
  background: transparent;
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
  touch-action: manipulation;
}
body[data-character="female3"] .heroine-view-button[aria-pressed="true"] {
  color: #fff6e0;
  background: linear-gradient(135deg, #4e7d9e, #294f72);
  border-color: #c6ae7845;
}
body[data-character="female3"] .heroine-view-button:hover:not(:disabled) {
  color: #fff9e9;
  border-color: #baa27070;
}
body[data-character="female3"] .heroine-view-button:focus-visible {
  outline: 2px solid #e0c59a;
  outline-offset: 3px;
}
body[data-character="female3"] .orbit-mode-button[aria-pressed="true"] {
  background: #47769c;
  color: #fff5e1;
}
body[data-character="female3"] .orbit-angle-range { accent-color: #a9cce8; }
body[data-character="female3"] .orbit-angle-label { color: #c5e1f6; }
body[data-character="female3"] .orbit-explainer { color: #bbd3e9; }
body[data-character="female3"][data-heroine-view="near"] .character-stage {
  overflow: hidden;
  overflow: clip;
}
body[data-character="female3"][data-heroine-view="near"] .orbit-view {
  top: 8px;
  height: 1050px;
  width: 525px;
}
body[data-character="female3"][data-heroine-view="near"] .character-sprite {
  top: -247px;
  height: 1250px;
  width: 625px;
}
body[data-character="female3"][data-heroine-view="near"] .gear-pins,
body[data-character="female3"][data-heroine-view="near"] .mount-companion,
body[data-character="female3"][data-heroine-view="near"] .stage-floor { visibility: hidden; }
body[data-character="female3"] .portrait-dialog {
  background: #f0f8fd;
  border-color: #b69963;
  color: #3e6385;
}
body[data-character="female3"] .portrait-heading h2 { color: #345f83; }
body[data-character="female3"] .portrait-heading p,
body[data-character="female3"] .portrait-note { color: #6182a0; }
body[data-character="female3"] .portrait-frame {
  background: radial-gradient(ellipse at 50% 30%, #fcfdff, #edf6fc 77%, #b4cfe5);
}
@media (max-width: 1100px) and (min-width: 761px) {
  body[data-character="female3"] .character-stage { height: 570px; }
  body[data-character="female3"] .character-sprite { top: -135px; height: 720px; width: 360px; }
  body[data-character="female3"] .orbit-view { height: 550px; width: 275px; }
  body[data-character="female3"] .portal { height: 490px; width: 86%; }
  body[data-character="female3"] .character-caption { gap: 10px; }
  body[data-character="female3"] .character-caption > .text-button { font-size: 12px; }
  body[data-character="female3"][data-heroine-view="near"] .orbit-view { height: 930px; width: 465px; }
  body[data-character="female3"][data-heroine-view="near"] .character-sprite { top: -234px; height: 1200px; width: 600px; }
}
@media (max-width: 760px) {
  body[data-character="female3"] .character-stage { height: 490px; }
  body[data-character="female3"] .character-sprite { top: -109px; height: 610px; width: 305px; }
  body[data-character="female3"] .orbit-view { top: 11px; height: 470px; width: 235px; }
  body[data-character="female3"] .portal { top: 27px; height: 416px; width: min(306px, 86%); }
  body[data-character="female3"] .stage-floor { width: 204px; }
  body[data-character="female3"] .character-caption { gap: 9px; padding: 19px 21px 16px; }
  body[data-character="female3"] .character-caption h2 { font-size: 25px; }
  body[data-character="female3"] .character-caption > .text-button { margin-top: 6px; }
  body[data-character="female3"] .portrait-button { min-height: 82px; gap: 9px; padding-right: 10px; }
  body[data-character="female3"] .portrait-thumbnail { flex-basis: 60px; width: 60px; height: 70px; }
  body[data-character="female3"] .portrait-thumbnail img { top: -28px; left: -33px; width: 131px; }
  body[data-character="female3"][data-heroine-view="near"] .orbit-view { top: 8px; height: 850px; width: 425px; }
  body[data-character="female3"][data-heroine-view="near"] .character-sprite { top: -218px; height: 1040px; width: 520px; }
}
@media (max-width: 370px) {
  body[data-character="female3"] .character-stage { height: 480px; }
  body[data-character="female3"] .character-sprite { top: -105px; height: 590px; width: 295px; }
  body[data-character="female3"] .orbit-view { height: 460px; width: 230px; }
  body[data-character="female3"] .portal { height: 404px; width: 258px; }
  body[data-character="female3"] .character-caption { padding-right: 17px; padding-left: 17px; gap: 8px; }
  body[data-character="female3"] .character-caption h2 { font-size: 23px; }
  body[data-character="female3"] .portrait-button { min-height: 78px; font-size: 11px; }
  body[data-character="female3"] .portrait-thumbnail { flex-basis: 56px; width: 56px; height: 66px; }
  body[data-character="female3"] .portrait-thumbnail img { top: -26px; left: -31px; width: 122px; }
  body[data-character="female3"] .heroine-view-selector { gap: 7px; }
  body[data-character="female3"] .heroine-view-button { padding-right: 10px; padding-left: 10px; }
  body[data-character="female3"][data-heroine-view="near"] .orbit-view { height: 800px; width: 400px; }
  body[data-character="female3"][data-heroine-view="near"] .character-sprite { top: -206px; height: 980px; width: 490px; }
}

/* Consistent framing for the 32 independently illustrated mage silhouettes. */
body[data-character="female3"] .orbit-view {
  --mage-height-limit: 520px;
  --mage-target-height: min(var(--mage-height-limit), calc((100cqw - 20px) / var(--mage-frame-aspect, .7)));
  --mage-target-top: 38px;
  height: calc(var(--mage-target-height) / var(--mage-frame-span, .7));
  width: calc(var(--mage-target-height) / var(--mage-frame-span, .7) / 2);
  top: calc(var(--mage-target-top) - var(--mage-frame-top, .2) * var(--mage-target-height) / var(--mage-frame-span, .7));
  left: calc(50% + (.5 - var(--mage-frame-center, .5)) * var(--mage-target-height) / var(--mage-frame-span, .7) / 2);
}
body[data-character="female3"][data-heroine-view="near"] .orbit-view {
  --mage-target-height: 850px;
  --mage-target-top: 28px;
  height: calc(var(--mage-target-height) / var(--mage-frame-span, .7));
  width: calc(var(--mage-target-height) / var(--mage-frame-span, .7) / 2);
  top: calc(var(--mage-target-top) - var(--mage-frame-top, .2) * var(--mage-target-height) / var(--mage-frame-span, .7));
}
@media (max-width: 1100px) and (min-width: 761px) {
  body[data-character="female3"] .orbit-view { --mage-height-limit: 490px; }
  body[data-character="female3"][data-heroine-view="near"] .orbit-view { --mage-target-height: 800px; }
}
@media (max-width: 760px) {
  body[data-character="female3"] .orbit-view { --mage-height-limit: 415px; --mage-target-top: 32px; }
  body[data-character="female3"][data-heroine-view="near"] .orbit-view { --mage-target-height: 700px; --mage-target-top: 24px; }
}
@media (max-width: 370px) {
  body[data-character="female3"] .orbit-view { --mage-height-limit: 405px; }
  body[data-character="female3"][data-heroine-view="near"] .orbit-view { --mage-target-height: 650px; }
}
