/* Refit Bay: the equipment screen (refit-bay.mjs). Colours and fonts come from style.css; every rule here is
   under .rb, so nothing in this file can restyle the rest of the game. It has two hosts: the Refit Bay tab of the
   Battle Setup dialog and, in the campaign, #market-dialog. */
.rb {
  --well: #0c1825;
  --up: #8fe3a8;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --display: 'Barlow Condensed', sans-serif;
  container: rb / size;
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  color: #dce6ef;
  font:
    13px Inter,
    system-ui,
    sans-serif;
  text-align: left;
}
.rb h1,
.rb h2,
.rb h3,
.rb h4,
.rb p,
.rb dl,
.rb dd {
  margin: 0;
}
.rb p {
  line-height: 1.5;
}
.rb button {
  font: inherit;
  color: inherit;
  padding: 6px 10px;
  background: #152231;
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
}
.rb button:hover:not(:disabled) {
  border-color: var(--cyan);
  background: #1e3343;
}
.rb button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.rb button:focus-visible,
.rb input:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}
.rb small,
.rb em,
.rb i {
  font-style: normal;
}

/* Frame. The campaign has its own header and footer; Battle Setup supplies them from its dialog. */
.rb-head {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.rb-title small {
  color: var(--cyan);
  font: 9px var(--mono);
  letter-spacing: 2px;
}
.rb-title h2 {
  font: 600 28px var(--display);
  letter-spacing: 0.5px;
  line-height: 1.1;
}
.rb-title p {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}
.rb-ledger {
  display: flex;
  gap: 22px;
  margin-left: auto;
}
.rb-ledger span {
  display: grid;
  gap: 2px;
}
.rb-ledger small,
.rb-label,
.rb-stat small {
  color: var(--muted);
  font: 9px var(--mono);
  letter-spacing: 1.4px;
}
.rb-ledger b {
  font: 500 16px var(--mono);
  color: var(--gold);
}
.rb-head > button {
  padding: 9px 16px;
}
.rb-body {
  flex: 1;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 388px;
  min-height: 0;
  background: #0d1520;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.rb-campaign .rb-body {
  border: 0;
  border-radius: 0;
}
.rb-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-top: 1px solid var(--line);
}
.rb-foot p {
  flex: 1;
  color: var(--muted);
  font-size: 11px;
}
.rb-foot .rb-error {
  color: var(--red);
}
.rb-roster h2.is-blue {
  color: var(--cyan);
}
.rb-roster h2.is-red {
  color: var(--red);
}

/* Segmented controls */
.rb-seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
}
.rb .rb-seg button {
  border-radius: 0;
  padding: 7px 12px;
  margin-left: -1px;
}
.rb .rb-seg button:first-child {
  border-radius: 4px 0 0 4px;
  margin-left: 0;
}
.rb .rb-seg button:last-child {
  border-radius: 0 4px 4px 0;
}
.rb .rb-seg button.is-on {
  background: #17384a;
  border-color: var(--cyan);
  color: var(--cyan);
  position: relative;
  z-index: 1;
}
.rb-sort button {
  font-size: 10.5px;
  padding: 4px 9px !important;
}

/* Left: ships, or the hold in the campaign */
.rb-roster {
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 14px 12px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.rb-roster h2,
.rb-group h3,
.rb-fitted h4,
.rb-swap h4 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  color: var(--muted);
  font: 10px var(--mono);
  letter-spacing: 1.6px;
}
.rb-roster h2 {
  margin: 4px 2px 8px;
}
.rb-roster-list {
  display: grid;
  gap: 4px;
  margin-bottom: 16px;
}
.rb .rb-ship,
.rb-cargo {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 5px 8px;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
}
.rb .rb-ship.is-active {
  background: #16293a;
  border-color: var(--cyan);
}
.rb .rb-ship.is-red.is-active {
  border-color: var(--red);
}
.rb-ship.is-static {
  cursor: default;
}
.rb-thumb {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
}
.rb-thumb img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}
.rb-ship-text {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.rb-ship-text b {
  font-weight: 600;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rb-ship-text small {
  color: var(--muted);
  font: 10px var(--mono);
}
.rb-changed {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
}
.rb-cargo {
  grid-template-columns: 34px minmax(0, 1fr);
  padding: 6px 4px;
  border-bottom: 1px solid #1a2636;
  border-radius: 0;
}
.rb-cargo .rb-ship-text b {
  white-space: normal;
  font-size: 11px;
}
.rb-cargo button {
  grid-column: 2;
  justify-self: start;
  font-size: 10.5px;
  padding: 3px 8px;
}
.rb-cargo .rb-icon {
  width: 34px;
  height: 25px;
}

/* Centre */
.rb-center {
  container: rbc / inline-size;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px;
  overflow-y: auto;
  scrollbar-width: thin;
  min-width: 0;
}
.rb-ship-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
}
.rb-ship-head h2 {
  font: 600 30px var(--display);
  line-height: 1;
}
.rb-stars {
  color: var(--gold);
  font-size: 13px;
  letter-spacing: 1px;
  white-space: nowrap;
}
.rb-ship-head p {
  color: var(--muted);
  font-size: 11px;
  margin-top: 6px;
}
.rb-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(82px, auto));
  gap: 6px;
}
.rb-stat {
  display: grid;
  gap: 2px;
  padding: 7px 10px;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.rb-stat b {
  font: 500 17px var(--mono);
}
.rb-stat b i,
.rb-row-num b i,
.rb-fitted-main strong i {
  color: var(--muted);
  font: 9px var(--mono);
  margin-left: 3px;
}
.rb-delta {
  font: 10px var(--mono);
  white-space: nowrap;
}
.rb-delta.is-up {
  color: var(--up);
}
.rb-delta.is-down {
  color: var(--red);
}
.rb-delta.is-same {
  color: var(--muted);
}
.rb-quick {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.rb-quick button {
  padding: 7px 12px;
}
.rb-quick-end {
  display: flex;
  gap: 8px;
  margin-left: auto;
}
.rb-allgrade button {
  min-width: 42px;
  font: 600 14px var(--display);
}
.rb-hint {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}
.rb-stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(140px, 176px) minmax(200px, 1fr) minmax(140px, 176px);
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(#ffffff05 1px, transparent 1px) 0 0 / 100% 34px,
    linear-gradient(90deg, #ffffff05 1px, transparent 1px) 0 0 / 34px 100%,
    radial-gradient(circle at 50% 50%, #13283c, #0a121d 72%);
}
.rb-hull {
  justify-self: center;
  width: 100%;
  max-width: 420px;
  aspect-ratio: 1;
}
.rb-hull {
  position: relative;
}
.rb-hull-svg {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
}
.rb-hull-art {
  position: absolute;
  pointer-events: none;
}
.rb-hull-art img,
.rb-hull-art canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.rb-col {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}
.rb-leaders {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}
.rb-leader {
  fill: none;
  stroke: #3d5870;
  stroke-width: 1;
}
.rb-leader.is-hover,
.rb-leader.is-selected {
  stroke: var(--k);
  stroke-width: 1.6;
}
.is-energy {
  --k: var(--cyan);
}
.is-torpedo {
  --k: var(--gold);
}
.rb .rb-tile {
  display: grid;
  gap: 5px;
  padding: 7px 8px;
  text-align: left;
  background: #0f1c2bee;
  border-left: 3px solid var(--k);
}
.rb .rb-tile.is-hover {
  border-color: var(--k);
}
.rb .rb-tile.is-selected,
.rb .rb-chip.is-selected {
  background: #17304a;
  border-color: var(--k, var(--c));
  box-shadow: 0 0 0 1px var(--k, var(--c));
}
.rb .rb-tile.is-empty {
  border-style: dashed;
  border-left-style: solid;
}
.rb-tile-head,
.rb-chip-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font: 9px var(--mono);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}
.rb-tile-slot {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rb-num {
  flex: none;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--k);
  color: #06212a;
  font: 500 9px var(--mono);
}
.rb-num.is-large {
  width: 30px;
  height: 30px;
  font-size: 14px;
}
.is-module .rb-num {
  --k: var(--cyan);
}
.rb-tile-body {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.rb-tile-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.rb-tile-text b {
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.25;
}
.rb-tile-text small {
  color: var(--muted);
  font: 10px var(--mono);
  line-height: 1.5;
}
.rb-tile-text small span {
  white-space: nowrap;
}
.rb-worn {
  color: var(--gold);
}
.rb-icon {
  flex: none;
  display: block;
  width: 40px;
  height: 29px;
  background-image: url('library/weapons/arsenal-atlas.png');
  background-size: 400% 400%;
}
.rb-icon.is-empty {
  background: none;
  border: 1px dashed var(--line);
  border-radius: 4px;
}
.rb-grade {
  display: inline-block;
  min-width: 15px;
  padding: 0 3px;
  border: 1px solid currentColor;
  border-radius: 3px;
  color: var(--gold);
  font: 500 9px var(--mono);
  text-align: center;
}
.rb-swatch {
  flex: none;
  display: block;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 4px solid var(--c);
  box-shadow:
    0 0 10px color-mix(in srgb, var(--c) 55%, transparent),
    inset 0 0 8px color-mix(in srgb, var(--c) 40%, transparent);
}

/* Ship drawing */
.rb-ring-guide {
  fill: none;
  stroke: #1d2e42;
  stroke-dasharray: 2 6;
}
.rb-arc {
  cursor: pointer;
}
.rb-arc-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 30;
}
.rb-arc-line {
  fill: none;
  stroke: var(--c);
  stroke-linecap: round;
  opacity: 0.62;
  pointer-events: none;
}
.rb-arc.is-empty .rb-arc-line {
  stroke-dasharray: 3 8;
}
.rb-arc.is-hover .rb-arc-line,
.rb-arc.is-selected .rb-arc-line {
  opacity: 1;
  filter: drop-shadow(0 0 5px var(--c));
}
.rb-arc text {
  fill: var(--c);
  font: 7.5px var(--mono);
  letter-spacing: 1px;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}
.rb-arc.is-selected text {
  fill: #fff;
}
.rb-dot {
  cursor: pointer;
}
.rb-dot circle {
  fill: #0a1826;
  stroke: var(--k);
  stroke-width: 2;
}
.rb-dot text {
  fill: var(--k);
  font: 500 9px var(--mono);
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}
.rb-dot.is-empty circle {
  stroke-dasharray: 2 2.5;
}
.rb-dot.is-hover circle {
  stroke-width: 3.5;
}
.rb-dot.is-selected circle {
  fill: var(--k);
  stroke: #fff;
}
.rb-dot.is-selected text {
  fill: #06212a;
}
.rb-wedge {
  fill: color-mix(in srgb, var(--k) 13%, transparent);
  stroke: color-mix(in srgb, var(--k) 55%, transparent);
  stroke-width: 1;
  stroke-dasharray: 4 4;
  pointer-events: none;
}

/* Shield and module chips */
.rb-group {
  display: grid;
  gap: 8px;
}
.rb-group h3 {
  justify-content: flex-start;
}
.rb-group h3 small,
.rb-swap h4 small {
  letter-spacing: 0;
  text-transform: none;
  font:
    10.5px Inter,
    sans-serif;
}
.rb-chips {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.rb-chips.is-modules {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.rb .rb-chip {
  display: grid;
  gap: 4px;
  align-content: start;
  padding: 8px 10px;
  text-align: left;
  background: #0f1c2b;
  border-left: 3px solid var(--c);
}
.rb .rb-chip.is-hover {
  border-color: var(--c);
}
.rb-chip-head i:first-child {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c);
}
.rb-chip-head .rb-changed {
  margin-left: auto;
}
.rb-chip b {
  font-size: 12px;
  font-weight: 600;
}
.rb-chip small {
  color: var(--muted);
  font: 10px var(--mono);
  line-height: 1.4;
}
.is-modules .rb-chip small {
  font:
    10.5px Inter,
    sans-serif;
}

/* Right: choices for the selected slot */
.rb-picker {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  padding: 16px;
  border-left: 1px solid var(--line);
  background: var(--panel);
  --k: var(--cyan);
}
.rb-picker.is-torpedo {
  --k: var(--gold);
}
.rb-picker-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.rb-picker-head h3 {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
}
.rb-picker-head p {
  color: var(--muted);
  font-size: 11px;
  margin-top: 3px;
}
.rb-fitted {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.rb-rounds {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.rb-rounds .rb-do {
  flex: 1 1 100px;
}
.rb-rounds small {
  display: block;
  margin-top: 3px;
  font-size: 10px;
}
.rb-fitted-main {
  display: flex;
  align-items: center;
  gap: 10px;
}
.rb-fitted-main > div {
  flex: 1;
  display: grid;
  gap: 3px;
  min-width: 0;
}
.rb-fitted-main b {
  font-size: 13px;
  font-weight: 600;
}
.rb-fitted-main small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}
.rb-fitted-main strong {
  font: 500 20px var(--mono);
  color: var(--k);
  white-space: nowrap;
}
.rb-fitted-main .rb-icon {
  width: 44px;
  height: 32px;
}
.rb-facts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.rb-facts.is-two {
  grid-template-columns: repeat(2, 1fr);
}
.rb-facts div {
  padding: 6px 8px;
  background: #101c2a;
  border-radius: 4px;
}
.rb-facts dt {
  color: var(--muted);
  font: 9px var(--mono);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}
.rb-facts dd {
  font: 13px var(--mono);
  margin-top: 3px;
}
.rb-grades button {
  display: grid;
  gap: 2px;
  justify-items: center;
  padding: 5px 4px 6px !important;
}
.rb-grades span {
  font-size: 11px;
}
.rb-grades b {
  font: 600 16px var(--display);
  margin-right: 2px;
}
.rb-grades small {
  color: var(--muted);
  font: 9.5px var(--mono);
}
.rb-figures {
  font-family: var(--mono) !important;
  font-size: 10px !important;
}
.rb-toggle {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 4px 10px;
  padding: 7px 10px;
  background: #101c2a;
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
}
.rb-toggle:hover {
  border-color: var(--cyan);
}
.rb-toggle input {
  width: 16px;
  height: 16px;
  margin: 1px 0 0;
  accent-color: var(--cyan);
}
.rb-toggle span {
  display: grid;
  gap: 2px;
}
.rb-toggle b {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-weight: 600;
  font-size: 12px;
}
.rb-toggle small,
.rb-toggle em {
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.4;
}
.rb-toggle em {
  font: 400 10px var(--mono);
  white-space: nowrap;
}
.rb-swap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 120px;
}
.rb-swap-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.rb-swap > .rb-hint {
  font-size: 10.5px;
}
.rb-sandbox .rb-swap > .rb-hint {
  margin-top: -4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rb-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--well);
}
.rb-list h4 {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 10px;
  background: #132132;
  border-bottom: 1px solid var(--line);
}
.rb-list > .rb-hint {
  padding: 10px;
}
.rb .rb-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px 7px 7px;
  text-align: left;
  background: transparent;
  border: 0;
  border-left: 3px solid transparent;
  border-bottom: 1px solid #1a2636;
  border-radius: 0;
}
.rb .rb-row.is-module {
  grid-template-columns: minmax(0, 1fr);
  padding-left: 10px;
}
.rb button.rb-row:hover:not(:disabled) {
  background: #17293a;
}
.rb .rb-row:focus-visible {
  outline-offset: -2px;
}
.rb .rb-row.is-current {
  background: #14283a;
  border-left-color: var(--k);
}
.rb-row .rb-swatch {
  justify-self: center;
  width: 26px;
  height: 26px;
}
.rb-row-text {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.rb-row-text b {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
}
.rb-row-text small {
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.45;
}
.rb-row:not(.is-module) .rb-row-text small:not(.rb-action) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rb-row-text .rb-action {
  color: var(--cyan);
  font: 10px var(--mono);
}
.rb-row:disabled .rb-action {
  color: var(--red);
}
.rb-row-num {
  display: grid;
  justify-items: end;
  gap: 1px;
}
.rb-row-num b {
  font: 500 13px var(--mono);
}
.rb-row-num.is-pair {
  grid-template-columns: auto auto;
  gap: 12px;
}
.rb-row-num.is-pair span {
  display: grid;
  justify-items: end;
  gap: 1px;
}
.rb-tag {
  display: inline-block;
  margin-left: 4px;
  padding: 0 5px;
  border: 1px solid currentColor;
  border-radius: 3px;
  color: var(--gold);
  font: 8.5px var(--mono);
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
.rb-picker-foot,
.rb-actions {
  display: flex;
  gap: 8px;
}
.rb-picker-foot button,
.rb-actions button {
  padding: 7px 12px;
}
.rb-picker-foot button:first-child,
.rb-actions button:first-child {
  flex: 1;
}

.rb-toast {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 5;
  transform: translate(-50%, 12px);
  max-width: min(560px, 92vw);
  padding: 9px 14px;
  background: #0c1825;
  border: 1px solid var(--cyan);
  border-radius: 6px;
  color: #dce6ef;
  font:
    12px Inter,
    sans-serif;
  box-shadow: 0 10px 30px #000a;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.18s,
    transform 0.18s;
}
.rb-toast.is-shown {
  opacity: 1;
  transform: translate(-50%, 0);
}
.rb-toast.is-warn {
  border-color: var(--red);
}
.rb-campaign .rb-toast {
  bottom: 62px;
}

/* The fold-out under the ship: captain, dimensions and reference notes. */
.rb-details {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--well);
}
.rb-details summary {
  padding: 9px 12px;
  color: var(--muted);
  font: 10px var(--mono);
  letter-spacing: 1.6px;
  text-transform: uppercase;
  cursor: pointer;
}
.rb-details[open] {
  display: grid;
  gap: 10px;
  padding-bottom: 12px;
}
.rb-details > :not(summary) {
  margin: 0 12px;
}
.rb-details a {
  color: var(--cyan);
}

/* Campaign rows: the figures, then a button that states the cost of pressing it. */
.rb div.rb-row {
  cursor: default;
}
.rb .rb-do {
  justify-self: start;
  margin-top: 2px;
  padding: 3px 9px;
  color: var(--cyan);
  font: 10.5px var(--mono);
}
.rb .rb-do:disabled {
  color: var(--red);
  opacity: 0.8;
  border-style: dashed;
}
.rb-cargo .rb-refusal {
  grid-column: 2;
  color: var(--muted);
  font-size: 10px;
}

/* Smaller hosts. `rbc` is the centre column and `rb` the whole bay. */
@container rbc (max-width: 640px) {
  .rb-ship-head {
    flex-direction: column;
    align-items: stretch;
  }
  .rb-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
@container rbc (max-width: 520px) {
  .rb-stage {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
  .rb-hull {
    grid-column: 1 / -1;
    grid-row: 1;
    max-width: 300px;
  }
  .rb-col {
    justify-content: flex-start;
  }
  .rb-leaders {
    display: none;
  }
  .rb-stats,
  .rb-chips {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
/* A short bay: the whole choice panel scrolls instead of squeezing its list. The campaign's bay includes its own
   header and footer, so it reaches that point sooner. */
@container rb (max-height: 640px) {
  .rb-picker {
    overflow-y: auto;
    scrollbar-width: thin;
  }
  .rb-swap,
  .rb-list {
    flex: none;
    overflow: visible;
  }
  .rb-list h4 {
    position: static;
  }
}
@container rb (max-height: 760px) {
  .rb-campaign .rb-picker {
    overflow-y: auto;
    scrollbar-width: thin;
  }
  .rb-campaign .rb-swap,
  .rb-campaign .rb-list {
    flex: none;
    overflow: visible;
  }
  .rb-campaign .rb-list h4 {
    position: static;
  }
}
@container rb (max-width: 1180px) {
  .rb-body {
    grid-template-columns: 190px minmax(0, 1fr) 340px;
  }
  .rb-title p {
    display: none;
  }
}
/* The ship list becomes a strip across the top. */
@container rb (max-width: 960px) {
  .rb-body {
    grid-template-columns: minmax(0, 1fr) 320px;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .rb-roster {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }
  .rb-roster h2,
  .rb-roster-list {
    margin: 0;
    white-space: nowrap;
  }
  .rb-roster-list {
    display: flex;
  }
  .rb .rb-ship,
  .rb-cargo {
    width: auto;
    min-width: 150px;
  }
  .rb-head {
    flex-wrap: wrap;
    gap: 12px;
  }
  .rb-foot p {
    font-size: 10px;
  }
  .rb-picker {
    overflow-y: auto;
    scrollbar-width: thin;
  }
  .rb-swap,
  .rb-list {
    flex: none;
    overflow: visible;
  }
  .rb-list h4 {
    position: static;
  }
}
/* One column: the ship, then its choices, in a single scroll. */
@container rb (max-width: 700px) {
  .rb-body {
    display: block;
    overflow-y: auto;
  }
  .rb-center,
  .rb-picker {
    overflow: visible;
  }
  .rb-picker {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .rb-ledger {
    gap: 14px;
  }
}
