/* Three compact roster rows keep the original battlefield height. */
:root {
  --dock-h: 118px;
  --roster-gap: 3px;
}
.bottom-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(290px, 30vw, 420px);
  min-height: 0;
  background: var(--surface);
  border-top: 3px solid var(--edge);
}
.bottom-workspace #dock {
  height: 100%;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr);
  grid-template-columns: minmax(0, 1fr) 140px;
  padding: 4px 8px !important;
  gap: 10px !important;
  border-top: 0;
  overflow: visible;
}
#dock > .bench-section {
  min-height: 0;
  grid-template-columns: 64px minmax(0, 1fr) !important;
  grid-template-rows: minmax(0, 2fr) minmax(0, 1fr);
  gap: 3px 8px;
}
#dock .bench-label {
  grid-row: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 3px !important;
  height: 100%;
}
#dock .bench-label > h2,
#dock .bench-label > .bench-capacity {
  display: none;
}
#dock .bench-label > .btn.icon-only {
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
}
#dock .bench-label > .bench-auto,
#dock .bench-label > .bench-auto-evolve {
  grid-column: 1 / -1;
}
#dock .bench-grid,
#reserve-bench .reserve-slots {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: var(--roster-gap);
  width: 100%;
  min-width: 0;
}
#dock .bench-grid {
  min-height: 0;
  height: 100%;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  align-content: stretch;
}
#dock .bench-group {
  min-height: 0;
}
#dock .bench-unit,
#dock .reserve-bench .bench-unit {
  height: 100% !important;
  min-height: 0;
  padding: 1px 13px 1px 2px !important;
  gap: 0 !important;
  border-radius: 2px;
  overflow: hidden;
  container-type: inline-size;
}
#dock .bench-unit > .portrait {
  width: min(100%, 28px) !important;
  height: auto !important;
  aspect-ratio: 1;
  max-height: 100%;
  object-fit: contain;
  flex-shrink: 1;
}
#dock .bench-unit .bench-number {
  top: 1px;
  left: 1px;
  font-size: 7px;
}
#dock .bench-items {
  position: absolute;
  right: 1px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  grid-template-columns: 10px;
  gap: 0;
}
#dock .bench-items > * {
  width: 10px;
  height: 10px;
}
#dock .bench-items .item-icon img {
  width: 10px;
  height: 10px;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
#reserve-bench.reserve-bench {
  grid-column: 2;
  min-height: 0;
  padding-top: 2px;
  border-top: 1px solid #718199;
}
#reserve-bench .reserve-slots {
  height: 100%;
  grid-template-rows: minmax(0, 1fr);
}
#dock .reserve-bench .bench-unit {
  background: #20304b;
  border-color: #7e9ac6;
}
.reserve-bench .bench-name {
  display: none;
}
.reserve-empty {
  color: #718199;
  font-size: 18px;
  border-style: dashed;
}
#dock .recruit-controls {
  grid-template-columns: minmax(0, 1fr) 36px !important;
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 3px !important;
  align-content: stretch;
}
#dock .recruit-controls > .recruit-button[data-ticket] {
  grid-column: 1;
  height: 100%;
  min-height: 0 !important;
  padding: 1px 18px 1px 2px !important;
}
#dock .recruit-controls > .recruit-button:nth-child(1) {
  grid-row: 1;
}
#dock .recruit-controls > .recruit-button:nth-child(2) {
  grid-row: 2;
}
#dock .recruit-controls > .recruit-button:nth-child(3) {
  grid-row: 3;
}
#dock .ticket-image {
  max-height: 100%;
  height: 28px;
  width: 44px;
}
#dock .recruit-secondary {
  display: contents !important;
}
#dock .recruit-secondary .btn.icon-only {
  grid-column: 2;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 2px;
}
#dock .recruit-secondary .btn:nth-child(1) {
  grid-row: 1;
}
#dock .recruit-secondary .btn:nth-child(2) {
  grid-row: 2;
}
#dock .recruit-secondary .btn:nth-child(3) {
  grid-row: 3;
}
.bottom-workspace #inventory-window {
  position: static !important;
  width: auto;
  max-width: none;
  min-width: 0;
  max-height: none;
  overflow: hidden;
  padding: 3px;
  border-left: 2px solid var(--edge);
}
.bottom-workspace #inventory-window > .inventory-panel {
  position: relative;
  height: 100%;
  min-height: 0;
  border-radius: 0;
}
.bottom-workspace #inventory-window .inventory-window-heading {
  position: absolute;
  z-index: 3;
  right: 0;
  bottom: 0;
  top: auto;
  min-height: 0;
  padding: 1px;
  border: 0;
  background: var(--surface-2);
  border-radius: 0;
  cursor: default;
}
.bottom-workspace #inventory-window .inventory-sort {
  min-height: 20px;
  padding: 1px 4px;
  font-size: 9px;
}
.bottom-workspace #inventory-window .inventory-body {
  box-sizing: border-box;
  height: 100%;
  min-height: 0;
  padding: 2px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.bottom-workspace #inventory-window .inventory-grid {
  flex: 1;
  height: auto;
  min-height: 0;
  grid-template-columns: repeat(auto-fill, minmax(25px, 1fr));
  grid-auto-rows: 27px;
  gap: 3px;
  padding-bottom: 22px;
}
.bottom-workspace #inventory-window .inventory-item,
.bottom-workspace #inventory-window .owned-item-button {
  height: 27px;
  min-height: 0;
}
@media (max-width: 1000px) {
  :root {
    --roster-gap: 2px;
  }
  .bottom-workspace {
    grid-template-columns: minmax(0, 1fr) 260px;
  }
  .bottom-workspace #dock {
    grid-template-columns: minmax(0, 1fr) 110px;
    gap: 5px !important;
    padding: 4px !important;
  }
  #dock > .bench-section {
    grid-template-columns: 46px minmax(0, 1fr) !important;
    gap: 2px 4px;
  }
}
@media (max-width: 900px) {
  :root {
    --dock-h: 190px;
  }
}
@media (max-height: 760px) {
  :root {
    --dock-h: 104px;
  }
}
@media (max-width: 700px) {
  .bottom-workspace {
    grid-template-columns: minmax(0, 1fr) 155px;
  }
  .bottom-workspace #dock {
    grid-template-columns: minmax(0, 1fr) 62px;
    gap: 3px !important;
  }
  #dock > .bench-section {
    grid-template-columns: 28px minmax(0, 1fr) !important;
  }
  #dock .recruit-controls {
    grid-template-columns: minmax(0, 1fr) 24px !important;
  }
  #dock .ticket-image {
    width: 26px;
  }
  #dock .recruit-controls .ticket-count {
    font-size: 8px !important;
    right: 0;
    bottom: 0;
  }
  #dock .bench-unit > .portrait {
    max-width: 100%;
    width: min(100%, 28px) !important;
    height: auto !important;
  }
  #dock .bench-label .ico,
  #dock .recruit-secondary .ico {
    width: 18px;
    height: 18px;
  }
}

/* Two field rows and a separate waiting bench share the existing dock height. */
#dock > .bench-section {
  grid-template-columns: 64px minmax(0, 1fr) clamp(170px, 18vw, 260px) !important;
  grid-template-rows: minmax(0, 1fr);
  gap: 8px;
}
#dock .bench-label {
  grid-column: 1;
  grid-row: 1;
}
#dock .bench-grid {
  grid-column: 2;
  grid-row: 1;
  width: 100%;
  height: 100%;
  grid-template-columns: repeat(10, minmax(30px, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  align-content: stretch;
  align-items: stretch;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}
#dock .bench-group {
  width: 100%;
  height: 100%;
  min-width: 0;
  aspect-ratio: auto;
}
#dock .bench-unit,
#dock .reserve-bench .bench-unit {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100% !important;
  aspect-ratio: auto;
  box-sizing: border-box;
  padding: 2px !important;
  grid-template-columns: minmax(0, 1fr);
  justify-content: stretch !important;
  justify-items: center;
  align-content: center;
}
#dock .bench-unit > .portrait {
  width: min(40px, 100%) !important;
  height: auto !important;
  max-height: 100%;
  aspect-ratio: 1;
}
#dock .bench-unit > .portrait :is(img, canvas) {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
}
#dock .bench-items {
  right: 1px;
  bottom: 1px;
  top: auto;
  transform: none;
  grid-template-columns: repeat(3, 8px);
}
#dock .bench-items > *,
#dock .bench-items .item-icon img {
  width: 8px;
  height: 8px;
}
#reserve-bench.reserve-bench {
  grid-column: 3;
  grid-row: 1;
  display: grid;
  grid-template-rows: 12px minmax(0, 1fr);
  height: 100% !important;
  align-self: stretch !important;
  box-sizing: border-box;
  gap: 3px;
  padding: 0 3px 0 7px;
  border: 0;
  border-left: 2px solid #647491;
}
.reserve-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 9px;
  line-height: 12px;
  color: #b8c9e6;
}
.reserve-heading b {
  font-size: 8px;
  color: #8ea5c7;
}
#reserve-bench .reserve-slots {
  width: 100%;
  height: 100%;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}
.reserve-seat-cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  isolation: isolate;
  border-radius: 2px;
  background: #111b2c;
  box-shadow: inset 0 0 0 1px #687c9a55;
}
.reserve-seat-back {
  position: absolute;
  z-index: -1;
  left: 22%;
  right: 22%;
  top: 12%;
  bottom: 20%;
  border: 2px solid #526582;
  border-bottom: 5px solid #657b9d;
  border-radius: 3px 3px 0 0;
  pointer-events: none;
}
.reserve-seat-back::after {
  content: "";
  position: absolute;
  left: -3px;
  right: -3px;
  bottom: -9px;
  height: 5px;
  border-left: 3px solid #657b9d;
  border-right: 3px solid #657b9d;
}
#dock .reserve-bench .bench-unit {
  position: relative;
  padding: 1px 2px 9px !important;
  background: #20304b66;
  border-color: #718bac;
  border-bottom: 3px solid #718bac;
}
#dock .reserve-bench .bench-unit[data-rarity] {
  background: color-mix(in srgb, var(--rarity-color) 16%, #20304b88);
  border-color: color-mix(in srgb, var(--rarity-color) 65%, var(--edge));
  border-bottom-color: var(--rarity-color);
}
#dock .reserve-bench .bench-unit > .portrait {
  width: min(30px, 100%) !important;
}
#dock .reserve-bench .reserve-empty {
  background: transparent;
  border-style: dashed;
  opacity: 0.65;
}
.reserve-status {
  position: absolute;
  pointer-events: none;
  left: 0;
  right: 0;
  bottom: 1px;
  text-align: center;
  font-size: 7px;
  line-height: 8px;
  color: #b7c9e4;
  text-shadow: 1px 1px #111b2c;
}
.reserve-seat-cell[data-occupied="true"] .reserve-status {
  color: #d4e9ff;
}
#dock .reserve-bench .bench-items {
  bottom: 10px;
}
@media (max-width: 1000px) {
  #dock > .bench-section {
    grid-template-columns: 46px minmax(0, 1fr) 155px !important;
    gap: 4px;
  }
}
@media (max-width: 700px) {
  #dock > .bench-section {
    grid-template-columns: 28px minmax(0, 1fr) 120px !important;
    gap: 3px;
  }
  .reserve-heading {
    font-size: 8px;
  }
}
