/* Two-team setup and switching share the existing lightweight battle screen. */
.party-teams-heading h2 { margin: 12px 0 5px; font-size: 1.1rem; }
.party-teams-heading p { color: var(--muted); font-size: .75rem; line-height: 1.6; }
.party-team-card { margin: 12px 0; padding: 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); }
.party-team-card.active { border-color: var(--gold); }
.party-team-card > header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.party-team-card h3 { margin: 0; font-size: .9rem; }
.party-team-card > header button { min-height: 44px; padding: 5px 8px; font-size: .7rem; }
.party-team-slot { display: grid; grid-template-columns: 48px minmax(0, 1fr) 44px; align-items: center; gap: 8px; padding: 6px 0; }
.party-team-slot label { display: grid; gap: 2px; min-width: 0; }
.party-team-slot label small { color: var(--muted); font-size: .62rem; }
.party-team-slot select { width: 100%; min-width: 0; min-height: 44px; padding: 5px 7px; font-size: .82rem; }
.party-team-slot > button { min-height: 44px; padding: 5px; font-size: .72rem; }
.party-team-portrait { display: grid; width: 48px; height: 56px; place-items: center; }
.party-team-portrait .actor-image { width: 100%; height: 100%; object-fit: contain; }

/* Team switching uses the shared battlefield portrait sizes at every viewport. */
.battle-shell .battle-actions.team-switch-actions { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 5px; }
.battle-shell .team-switch-actions > .command-button { grid-column: span 3; grid-template: auto auto / 20px minmax(0, 1fr); min-height: 48px; padding: 4px 6px; column-gap: 4px; text-align: left; }
.battle-shell .team-switch-actions > .command-button:nth-child(n + 5) { grid-column: span 4; }
.battle-shell .team-switch-actions > .command-button > :first-child { grid-area: 1 / 1 / 3 / 2; width: 20px; height: 20px; font-size: 1.15rem; }
.battle-shell .team-switch-actions .command-icon { width: 20px; height: 20px; }
.battle-shell .team-switch-actions .command-label { grid-area: 1 / 2; justify-self: start; max-width: 100%; font-size: .65rem; }
.battle-shell .team-switch-actions .command-meta { grid-area: 2 / 2; justify-self: start; max-width: 100%; font-size: .51rem; }
.battle-shell .team-switch-command { border-color: rgb(217 185 102 / 65%); }
@media (min-width: 701px) {
  body.battle-active:has(.team-switch-enabled) .global-chat { bottom: 128px; }
}

.team-switch-backdrop { position: fixed; z-index: 140; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgb(0 0 0 / 64%); }
.team-switch-dialog { width: min(100%, 400px); max-height: calc(100dvh - 32px); padding: 14px; overflow: auto; overscroll-behavior: contain; border: 1px solid var(--gold); border-radius: 9px; background: var(--surface); box-shadow: 0 12px 48px rgb(0 0 0 / 60%); }
.team-switch-dialog > header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.team-switch-dialog h2 { margin: 0; font-size: 1rem; }
.team-switch-dialog > p { font-size: .76rem; line-height: 1.5; }
.team-switch-dialog > footer { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; margin-top: 12px; }
.team-switch-dialog > footer button { min-height: 44px; }
.team-switch-member { display: grid; grid-template-columns: 50px minmax(0, 1fr); gap: 10px; align-items: center; padding: 8px 0; }
.team-switch-member strong { display: block; margin-bottom: 4px; font-size: .8rem; }
.team-switch-member small { color: var(--muted); font-size: .62rem; }
.team-switch-portrait { display: grid; width: 50px; height: 58px; place-items: center; }
.team-switch-portrait .actor-image { width: 100%; height: 100%; object-fit: contain; }
.team-switch-member .resource-meter { grid-template-columns: 14px minmax(20px, 1fr) max-content; width: 100%; font-size: .6rem; }
@media (max-width: 360px), (max-height: 740px) and (max-width: 700px) {
  .battle-shell .team-switch-actions > .command-button { padding: 3px 4px; column-gap: 2px; }
}


/* Read-only departure-style formation, compact equal-length meters, and command slots. */
.team-switch-dialog { display: flex; flex-direction: column; width: min(100%, 460px); overflow: hidden; }
.team-switch-dialog > header, .team-switch-dialog > footer { flex: 0 0 auto; }
.team-switch-content { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.team-switch-formation { margin-top: 8px; }
.team-switch-formation .party-rows-scene { height: 208px; }
.team-switch-formation .party-rows-scene-slot { height: 82px; }
.team-switch-formation .party-rows-scene-slot.is-center { top: calc(50% - 41px); }
.team-switch-formation .party-rows-character { height: 82px; }
.team-switch-formation .party-rows-character-image, .team-switch-formation .party-rows-character-image .actor-image { height: 62px; }
.team-switch-formation .party-rows-character-image .actor-image { width: 100%; max-width: 76px; }
.team-switch-formation .party-rows-character:disabled { opacity: 1; cursor: default; }
.team-switch-formation .party-rows-place-target { top: 48px; height: 30px; min-height: 30px; opacity: .65; }
.team-switch-formation .party-rows-place-label, .team-switch-formation .party-rows-grip-symbol { display: none; }
.team-switch-formation-portrait { display: grid; width: 100%; height: 62px; place-items: end center; }
.team-switch-formation-portrait.is-defeated { opacity: .35; filter: grayscale(1); }
.team-switch-formation-fallback { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.team-switch-formation-fallback .actor-image { width: 100%; height: 62px; object-fit: contain; }
.team-switch-command-heading { margin: 8px 0 5px; color: var(--muted); font-size: .65rem; }
.team-switch-members { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.team-switch-member { display: flex; flex-direction: column; min-width: 0; gap: 6px; padding: 7px 5px; border: 1px solid rgb(var(--party-color-rgb) / 40%); border-radius: 6px; background: rgb(var(--party-color-rgb) / 8%); }
.team-switch-member > header { min-height: 32px; min-width: 0; }
.team-switch-member strong { margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .72rem; }
.team-switch-member > header small { display: block; font-size: .54rem; line-height: 1.4; }
.team-switch-resources { display: grid; gap: 4px; }
.team-switch-member .resource-meter { display: grid; grid-template-columns: 11px minmax(0, 1fr); gap: 2px 3px; width: 100%; margin: 0; }
.team-switch-member .bar-icon { width: 11px; height: 11px; }
.team-switch-member .bar { display: block; width: 100%; height: 5px; align-self: center; }
.team-switch-member .bar-value { grid-column: 1 / -1; text-align: right; font-size: .56rem; line-height: 1.2; font-variant-numeric: tabular-nums; white-space: nowrap; }
.team-switch-member .team-switch-commands { flex: 1 1 auto; margin: 2px 0 0; padding-top: 4px; }
.team-switch-member .team-switch-commands li { min-height: 24px; padding: 2px 0; grid-template-columns: 10px minmax(0, 1fr); gap: 2px; font-size: .62rem; }
.team-switch-commands small { display: block; font-size: .54rem; line-height: 1.2; }
.team-switch-rule { margin: 8px 0 0; color: var(--muted); font-size: .65rem; line-height: 1.5; }
@media (max-width: 360px), (max-height: 700px) {
  .team-switch-backdrop { padding: 12px; }
  .team-switch-dialog { padding: 10px; max-height: calc(100dvh - 24px); }
  .team-switch-formation .party-rows-scene { height: 182px; }
  .team-switch-formation .party-rows-scene-slot { height: 74px; }
  .team-switch-formation .party-rows-scene-slot.is-center { top: calc(50% - 37px); }
  .team-switch-formation .party-rows-character { height: 74px; }
  .team-switch-formation .party-rows-character-image, .team-switch-formation .party-rows-character-image .actor-image, .team-switch-formation-portrait { height: 54px; }
  .team-switch-formation .party-rows-place-target { top: 42px; }
}

/* Three compact character cards per team, on mobile and desktop. */
.party-teams-heading h2 { margin: 12px 0 6px; font-size: 1.2rem; letter-spacing: .04em; }
.party-team-card {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
  padding: 14px;
  border-color: #465963;
  border-radius: 12px;
  background: linear-gradient(145deg, #1b2931, #121d24);
  box-shadow: inset 0 1px rgb(255 255 255 / 4%);
}
.party-team-card.active { border-color: #b59b5e; background: linear-gradient(145deg, #292b25, #151f23); }
.party-team-card > header { grid-column: 1 / -1; margin: 0 0 2px; padding-bottom: 10px; border-bottom: 1px solid rgb(151 176 181 / 14%); }
.party-team-card h3 { font-size: .95rem; letter-spacing: .04em; }
.party-team-card > header button { border-radius: 7px; padding: 6px 10px; }
.party-team-card.active > header button:disabled { opacity: 1; border-color: #a08a55; background: rgb(181 155 94 / 10%); color: #e3d1a2; }
.party-team-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 12px 8px 8px;
  border: 1px solid rgb(var(--party-color-rgb, 127 153 161) / 24%);
  border-radius: 9px;
  background: linear-gradient(180deg, rgb(var(--party-color-rgb, 127 153 161) / 7%), rgb(6 15 20 / 48%));
}
.party-team-portrait { width: 100%; height: 90px; }
.party-team-portrait .actor-image { max-width: 94px; filter: drop-shadow(0 4px 4px rgb(0 0 0 / 22%)); }
.party-team-slot label { width: 100%; gap: 6px; text-align: center; }
.party-team-slot label small { font-size: .65rem; letter-spacing: .03em; }
.party-team-slot:nth-child(2) label small { color: #e0c686; }
.party-team-slot select { min-height: 44px; padding: 5px 4px; border-color: #3e525c; border-radius: 6px; background-color: #09141b; color: #ecf0ee; font-size: clamp(11px, 2.7vw, 14px); font-weight: 600; }
.party-team-slot > button { width: 100%; min-height: 44px; border: 1px solid rgb(var(--party-color-rgb, 127 153 161) / 30%); border-radius: 6px; background: rgb(var(--party-color-rgb, 127 153 161) / 6%); color: #cad8db; text-decoration: none; font-size: .75rem; }
.party-team-slot > button:not(:disabled):hover { border-color: rgb(var(--party-color-rgb, 127 153 161) / 60%); background: rgb(var(--party-color-rgb, 127 153 161) / 13%); }
.party-team-slot :is(select, button):focus-visible { outline: 2px solid #dec787; outline-offset: 2px; }
@media (max-width: 390px) {
  .party-team-card { gap: 6px; padding: 10px; }
  .party-team-slot { gap: 7px; padding: 10px 4px 5px; }
  .party-team-portrait { height: 76px; }
  .party-team-slot label small { font-size: .6rem; }
}

/* Team tabs change the visible editor, independently of the expedition team. */
.party-team-tabs{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin:14px 0 0}
.party-team-tabs [role="tab"]{display:flex;align-items:center;justify-content:center;flex-wrap:wrap;gap:4px 8px;min-height:48px;padding:8px 10px;border:1px solid #435863;border-radius:9px;background:#14222a;color:#c7d5d9;font-size:.86rem;font-weight:700}
.party-team-tabs [role="tab"][aria-selected="true"]{border-color:#b59b5e;background:#34372b;color:#f2dfab;box-shadow:inset 0 -3px #b59b5e}
.party-team-tabs [role="tab"] small{padding:2px 5px;border:1px solid #a08a55;border-radius:4px;color:#e3d1a2;font-size:.56rem;white-space:nowrap}
.party-team-tabs [role="tab"]:focus-visible{outline:2px solid #dec787;outline-offset:2px}
.party-team-card[hidden]{display:none}
.party-team-standby{margin:16px 0;padding-top:14px;border-top:1px solid #435863}
.party-team-standby .formation-waiting-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin:10px 0}
.party-team-standby .formation-member-card{min-width:0}
.party-team-standby .formation-waiting-summary{min-height:120px}
.party-standby-replacements{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
.party-standby-replacements button{display:grid;gap:3px;min-width:0;min-height:68px;padding:7px 4px;overflow-wrap:anywhere}
.party-standby-replacements small,.party-standby-replacements span{font-size:.6rem}
.party-standby-replacements strong{font-size:.72rem}

/* Formation content has one surface; only controls and selectable cards need outlines. */
.formation-screen { gap: 10px; padding: 12px; border: 0; border-radius: 0; background: transparent; box-shadow: none; overflow: visible; }
.formation-screen::before, .formation-screen .formation-deck::before { display: none; }
.formation-screen .formation-deck { gap: 8px; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.formation-screen .formation-deck + .formation-deck { padding-top: 12px; border-top: 1px solid var(--line); }
.formation-screen .party-teams-heading :is(h2,p) { margin: 0; }
.formation-screen .party-teams-heading p { margin-top: 5px; }
.formation-screen .party-team-tabs { margin: 0; gap: 6px; }
.formation-screen .party-team-tabs small { font-size: .7rem; }
.formation-screen .party-team-card { margin: 0; padding: 0; gap: 6px; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.formation-screen .party-team-card > header { margin: 0; padding: 0 0 6px; border: 0; }
.formation-screen .party-team-card h3 { font-size: 1rem; }
.formation-screen .party-team-card > header button { font-size: .8rem; }
.formation-screen .party-team-slot { gap: 5px; padding: 5px 3px; border: 0; border-radius: 7px; background: linear-gradient(180deg, rgb(var(--party-color-rgb) / 9%), transparent); }
.formation-screen .party-team-portrait { width: 100%; height: 110px; }
.formation-screen .party-team-portrait .actor-image { width: 100%; max-width: 120px; height: 100%; }
.formation-screen .party-team-slot label { gap: 4px; }
.formation-screen .party-team-slot label small { font-size: .72rem; }
.formation-screen .party-team-slot select { padding: 5px 2px; font-size: .8125rem; }
.formation-screen .party-team-slot > button { border: 0; background: rgb(var(--party-color-rgb) / 10%); font-size: .8125rem; }
.formation-screen .party-team-standby { margin: 0; padding-top: 12px; }
.formation-screen .formation-roster-heading { margin: 0; }
.formation-screen .formation-roster-heading h3 { font-size: 1rem; }
.formation-screen .formation-roster-heading > span { font-size: .8125rem; }
.formation-screen .party-team-standby > p { margin: 6px 0; }
.formation-screen :is(.formation-waiting-grid,.formation-member-list) { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 8px 0 0; }
.formation-screen .formation-member-card { min-width: 0; border-color: transparent; border-radius: 7px; background: linear-gradient(180deg, rgb(var(--party-color-rgb) / 8%), transparent); box-shadow: none; }
.formation-screen .formation-member-card.selected { border-color: var(--party-color, var(--gold)); background: rgb(var(--party-color-rgb) / 13%); }
.formation-screen .formation-waiting-summary { min-height: 155px; gap: 4px; padding: 4px 2px 6px; }
.formation-screen .formation-member-portrait { width: 100%; max-width: 120px; height: 106px; }
.formation-screen .formation-member-portrait .actor-image { width: 100%; height: 100%; object-fit: contain; }
.formation-screen .formation-member-copy { gap: 3px; }
.formation-screen .formation-member-copy > strong { font-size: .875rem; line-height: 1.4; white-space: normal; overflow-wrap: anywhere; }
.formation-screen .formation-member-copy > em { font-size: .75rem; line-height: 1.5; white-space: normal; overflow-wrap: anywhere; }
.formation-screen .formation-waiting-detail { margin-top: 10px; padding: 10px; }
.formation-screen .formation-waiting-detail :is(p,small), .formation-screen .party-standby-replacements :is(small,span) { font-size: .8125rem; line-height: 1.6; }
.formation-screen .party-standby-replacements strong { font-size: .875rem; }
.formation-screen :is(.formation-waiting-guide,.formation-drag-guide,.formation-intro,.formation-auto-save-status) { font-size: .8125rem; line-height: 1.6; }
.formation-screen .formation-slot-card { padding: 4px 3px; border: 0; background: linear-gradient(180deg, rgb(var(--party-color-rgb) / 10%), transparent); box-shadow: none; }
.formation-screen .formation-slot-portrait { width: 100%; height: 106px; }
.formation-screen .formation-slot-portrait .actor-image { width: 100%; height: 100%; object-fit: contain; }
.formation-screen .formation-slot-copy strong { font-size: .875rem; white-space: normal; overflow-wrap: anywhere; }
.formation-screen .formation-slot-copy small { font-size: .75rem; }
.formation-screen .formation-slot-actions button { min-height: 44px; font-size: .75rem; }
.formation-screen .formation-drop-target { outline: 2px solid var(--gold); outline-offset: -2px; }
@media (min-width: 701px) {
  .formation-screen { max-width: 760px; margin-inline: auto; }
  .formation-screen :is(.party-team-portrait,.formation-member-portrait,.formation-slot-portrait) { height: 132px; }
}

/* Character selection uses the game's portrait, party colors and gold highlights. */
.formation-screen .party-team-slot .party-team-slot-label { display: grid; gap: 4px; width: 100%; text-align: center; }
.party-team-slot-label > small { color: var(--muted); font-size: .72rem; }
.formation-screen .party-team-slot .party-team-picker-trigger { display: flex; align-items: center; justify-content: space-between; gap: 3px; width: 100%; min-height: 44px; padding: 7px 5px; border: 1px solid rgb(var(--party-color-rgb) / 35%); border-radius: 7px; background: #09141b; color: #edf3f3; font-size: .8125rem; font-weight: 700; text-align: left; }
.party-team-picker-trigger > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.party-team-picker-trigger > i { flex-shrink: 0; color: var(--party-color, var(--gold)); font-style: normal; }
.party-team-picker-trigger:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
body.party-team-picker-modal-open { overflow: hidden; }
.party-team-picker-backdrop { position: fixed; z-index: 210; inset: 0; display: grid; place-items: center; padding: 12px; background: rgb(3 7 11 / 82%); backdrop-filter: blur(4px); }
.party-team-picker-dialog { display: flex; flex-direction: column; width: min(560px, 100%); max-height: calc(100dvh - 24px); min-height: 0; overflow: hidden; border: 1px solid #a38c55; border-radius: 16px; background: radial-gradient(ellipse at 15% 0%, rgb(var(--party-color-rgb) / 12%), transparent 55%), #101b23; color: #edf3f3; box-shadow: 0 20px 60px rgb(0 0 0 / 65%); }
.party-team-picker-heading { display: grid; grid-template-columns: 36px minmax(0, 1fr) 44px; align-items: center; gap: 9px; padding: 12px; border-bottom: 1px solid rgb(204 181 119 / 18%); }
.party-team-picker-emblem, .party-team-picker-emblem .abyss-mechanism-mark { width: 36px; height: 36px; }
.party-team-picker-heading p { margin: 0 0 3px; color: #d9c389; font-size: .8125rem; }
.party-team-picker-heading h2 { margin: 0; color: #f2ead5; font-size: 1.25rem; line-height: 1.4; }
.party-team-picker-close { width: 44px; height: 44px; padding: 0; border: 1px solid #3d505a; border-radius: 50%; background: #192831; color: #dce6e9; font-size: 1.5rem; }
.party-team-picker-current { display: flex; flex-shrink: 0; align-items: center; gap: 12px; margin: 10px 12px 0; padding: 7px 10px; border-radius: 9px; background: rgb(var(--party-color-rgb) / 10%); }
.party-team-picker-current-portrait, .party-team-picker-current-portrait .actor-image { display: block; width: 52px; height: 62px; object-fit: contain; }
.party-team-picker-current > span:nth-child(2) { display: grid; min-width: 0; gap: 2px; }
.party-team-picker-current small { color: #a8bcc5; font-size: .75rem; }
.party-team-picker-current strong { font-size: 1rem; overflow-wrap: anywhere; }
.party-team-picker-current em { color: #d9c389; font-size: .75rem; font-style: normal; }
.party-team-picker-exchange { margin-left: auto; color: #d9c389; font-size: 1.75rem; }
.party-team-picker-search { display: block; flex-shrink: 0; margin: 10px 12px; }
.party-team-picker-search input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #425c68; border-radius: 9px; background: #08151d; color: #edf3f3; font-size: 1rem; }
.party-team-picker-search input::placeholder { color: #a8bac3; }
.party-team-picker-results { flex: 1 1 auto; min-height: 0; padding: 0 12px 12px; overflow-y: auto; overscroll-behavior: contain; scrollbar-color: #6a7b80 transparent; }
.party-team-picker-group + .party-team-picker-group { margin-top: 14px; }
.party-team-picker-group > header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; }
.party-team-picker-group h3 { margin: 0; font-size: .9375rem; color: #e6ddc6; }
.party-team-picker-group > header > span { color: #a8bac3; font-size: .75rem; }
.party-team-picker-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.party-team-picker-card { display: flex; flex-direction: column; align-items: center; min-width: 0; min-height: 156px; padding: 7px 3px 8px; gap: 3px; border: 1px solid rgb(var(--party-color-rgb) / 28%); border-radius: 10px; background: linear-gradient(180deg, rgb(var(--party-color-rgb) / 13%), rgb(7 17 24 / 65%)); color: #edf3f3; text-align: center; }
.party-team-picker-card:not(:disabled):hover { border-color: var(--party-color, #d9c389); background: rgb(var(--party-color-rgb) / 23%); }
.party-team-picker-card.is-current:disabled { opacity: 1; border-color: #d9c389; background: rgb(217 195 137 / 12%); cursor: default; }
.party-team-picker-card-status { min-height: 18px; color: #a8bac3; font-size: .6875rem; line-height: 1.5; }
.party-team-picker-card-status i { margin-right: 3px; font-style: normal; }
.is-current .party-team-picker-card-status { color: #e6d395; }
.party-team-picker-portrait { display: grid; flex: 0 0 86px; min-height: 0; place-items: center; width: 100%; height: 86px; overflow: hidden; }
.party-team-picker-portrait .actor-image { width: 100%; max-width: 108px; height: 86px; max-height: 86px; object-fit: contain; filter: drop-shadow(0 3px 4px rgb(0 0 0 / 28%)); }
.party-team-picker-card strong { width: 100%; font-size: .875rem; line-height: 1.5; overflow-wrap: anywhere; }
.party-team-picker-card small { color: #d9c389; font-size: .75rem; line-height: 1.5; overflow-wrap: anywhere; }
.party-team-picker-dialog > footer { display: flex; flex-shrink: 0; align-items: center; gap: 12px; padding: 10px 12px; border-top: 1px solid #354852; background: #101b23; }
.party-team-picker-dialog > footer p { flex: 1; margin: 0; color: #b7c6ce; font-size: .8125rem; line-height: 1.6; }
.party-team-picker-dialog > footer button { min-width: 64px; min-height: 44px; font-size: .8125rem; }
.party-team-picker-dialog :is(button,input):focus-visible { outline: 2px solid #e5cf8b; outline-offset: -2px; }
.party-team-picker-empty { margin: 0; padding: 24px 8px; color: #c2d2da; font-size: .875rem; line-height: 1.7; }
@media (max-width: 700px) {
  .party-team-picker-backdrop { align-items: end; padding: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .party-team-picker-dialog { max-height: calc(100dvh - 16px - env(safe-area-inset-bottom)); }
}
@media (max-width: 360px) {
  .party-team-picker-heading { gap: 7px; padding: 10px; }
  .party-team-picker-heading h2 { font-size: 1.125rem; }
  .party-team-picker-results { padding-inline: 10px; }
  .party-team-picker-grid { gap: 5px; }
  .party-team-picker-card-status { font-size: .625rem; }
}

/* Keep the confirmation above app chrome and preserve the footer on short screens. */
.battle-shell:has(> .team-switch-backdrop) { z-index: 111; }
.team-switch-dialog { min-height: 0; }
.team-switch-member { gap: 3px; padding: 5px; }
.team-switch-member > header { width: 100%; min-height: 28px; }
.team-switch-resources { width: 100%; gap: 2px; }
.team-switch-member .resource-meter { gap: 0 3px; }
.team-switch-member .bar-icon { width: 10px; height: 10px; }
.team-switch-member .bar { height: 4px; }
.team-switch-member .bar-value { font-size: .625rem; line-height: 1.05; white-space: normal; overflow-wrap: anywhere; }
.team-switch-member .team-switch-commands { margin-top: 0; padding-top: 3px; }
.team-switch-member .team-switch-commands li { min-height: 18px; padding: 1px 0; line-height: 1.3; }
.team-switch-commands small { display: inline; margin-left: 3px; white-space: nowrap; }
.team-switch-dialog > footer { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--line); }

/* Tower formation uses the arena's portrait-first layout and flat member controls. */
#app > .tower-formation-screen {
  display:grid; gap:12px; min-width:0; padding:8px;
}
.tower-formation-screen .party-team-tabs { gap:8px; border-bottom:1px solid var(--line); }
#app > .tower-formation-screen .party-team-tabs [role="tab"] {
  min-height:48px; padding:6px 4px; border:0; border-bottom:2px solid transparent;
  border-radius:0; background:transparent; box-shadow:none; color:var(--muted); font-size:var(--ga-font-control);
}
#app > .tower-formation-screen .party-team-tabs [aria-selected="true"] {
  border-bottom-color:var(--selected-border); background:var(--surface); color:var(--selected-text);
}
#app > .tower-formation-screen .party-team-tabs small {
  padding:2px 5px; border:0; background:var(--surface-2); color:var(--selected-text); font-size:var(--ga-font-caption);
}
.tower-formation-screen .party-team-card > header { flex-wrap:wrap; margin:0; }
.tower-formation-screen :is(.party-team-card,.formation-deck) h3 { font-size:var(--ga-font-section); }
.tower-formation-screen .party-summon-members { align-items:stretch; gap:8px; }
#app > .tower-formation-screen :is(.party-team-slot,.formation-slot-card:not(.empty)) {
  display:grid; grid-template-columns:minmax(0,1fr); grid-template-rows:auto 1fr auto;
  align-items:stretch; justify-items:stretch; align-content:start; gap:4px; padding:4px;
  border:0; border-radius:var(--ga-radius-panel);
  background:linear-gradient(180deg,rgb(var(--party-color-rgb,var(--accent-rgb)) / 11%),transparent);
}
#app > .tower-formation-screen .formation-slot-card:not(.empty) { grid-template-rows:1fr auto; }
#app > .tower-formation-screen .formation-slot-card.formation-drop-target { outline:2px solid var(--gold); }
#app > .tower-formation-screen :is(.party-team-portrait,.formation-slot-portrait) {
  display:grid; grid-template: minmax(0,1fr) / minmax(0,1fr);
  width:100%; height:clamp(76px,24vw,120px); min-width:0;
  background:radial-gradient(ellipse at 50% 76%,rgb(var(--party-color-rgb,var(--accent-rgb)) / 16%),transparent 68%);
}
#app > .tower-formation-screen :is(.party-team-portrait,.formation-slot-portrait) .actor-image {
  width:100%; max-width:144px; height:100%; min-height:0; max-height:100%; object-fit:contain;
}
.tower-formation-screen .party-team-slot-label > small { font-size:var(--ga-font-note); overflow-wrap:anywhere; }
#app > .tower-formation-screen .party-team-slot .party-team-picker-trigger {
  min-height:44px; padding:4px 6px; border:0; border-radius:var(--ga-radius-control);
  background:var(--surface); color:var(--text); font-size:var(--ga-font-control);
}
#app > .tower-formation-screen .party-team-slot .party-team-picker-trigger:enabled:hover { background:var(--surface-2); }
.tower-formation-screen .tower-formation-tools {
  display:grid; min-width:0; padding-top:4px; border-top:1px solid var(--line);
}
#app > .tower-formation-screen .tower-formation-tools > button {
  display:flex; justify-content:center; align-items:center; gap:4px;
  width:100%; min-width:0; min-height:44px; padding:4px 2px; border:0;
  border-radius:var(--ga-radius-control); background:transparent; box-shadow:none;
  color:var(--text); font-size:var(--ga-font-note); overflow-wrap:anywhere;
}
#app > .tower-formation-screen .tower-formation-tools > button:enabled:hover { background:var(--surface-2); }
.tower-formation-screen .tower-formation-tools img { flex:none; object-fit:contain; }
.tower-formation-screen .tower-formation-row > span {
  padding:3px 7px; border-radius:999px; background:var(--surface-2); color:var(--selected-text);
}
.tower-formation-screen .tower-formation-row[aria-pressed="true"] > span {
  background:rgb(var(--accent-rgb) / 16%); color:var(--selected-text);
}
.tower-formation-screen .tower-formation-row i { color:var(--gold-strong); font-style:normal; }
.tower-formation-screen .formation-character-actions { width:100%; }
.tower-formation-screen .formation-auto-save-status {
  margin:0; padding:8px 0; border:0; border-bottom:1px solid var(--line);
  border-radius:0; background:transparent; color:var(--muted); font-size:var(--ga-font-note);
}
.tower-formation-screen .tower-formation-status {
  display:flex; flex-wrap:wrap; align-items:center; gap:0 8px; border-bottom:1px solid var(--line);
}
.tower-formation-screen .tower-formation-status .formation-auto-save-status {
  flex:1 1 160px; min-width:0; justify-content:flex-start; border:0; text-align:left; overflow-wrap:anywhere;
}
.tower-formation-screen .tower-formation-status > button { min-height:44px; margin-inline-start:auto; font-size:var(--ga-font-note); }
.tower-formation-screen .formation-auto-save-status[data-status="error"] { color:var(--gold-strong); }
.tower-formation-screen > .party-rows-editor { padding-top:12px; border-top:1px solid var(--line); }
.tower-formation-screen #party-rows-title { scroll-margin-top:calc(var(--mobile-header-height, 72px) + 12px); }
@media (min-width:760px) {
  #app > .tower-formation-screen { padding:12px; }
}
