.build-tools {
  top: max(75px, calc(50% - 151px));
  gap: 8px;
}

.build-tool {
  width: 58px;
  min-height: 58px;
  gap: 2px;
  background: #22252cef;
  box-shadow: 0 3px 12px #090a0e5c, inset 0 0 0 1px #ffffff36;
}

.build-tool svg {
  display: block;
  width: 28px;
  height: 28px;
}

.tool-name {
  font-weight: 600;
}

.tool-fan {
  top: max(77px, calc(50% - 151px));
  left: calc(var(--edge) + 72px);
  grid-template-columns: repeat(var(--fan-pages), 82px);
  gap: 2px;
  padding: 8px 39px 8px 8px;
  border: 1px solid #ffffff24;
  border-radius: 16px;
  background: #202329f5;
  box-shadow: 0 4px 16px #10111569;
}

.tool-fan::before {
  display: none;
}

.fan-tool {
  min-width: 0;
  min-height: 57px;
  gap: 3px;
  padding: 2px 3px;
  line-height: 1.1;
}

.fan-tool svg {
  width: 35px;
  height: 35px;
}

.fan-close {
  top: 3px;
  right: 2px;
  width: 41px;
  height: 41px;
  background: transparent;
  color: #d8dbe1;
}

.build-selector {
  left: max(calc(var(--edge) + 154px), calc(50% - 400px));
  right: calc(var(--right) + 208px);
  bottom: calc(var(--bottom) + 9px);
  width: auto;
  max-width: 800px;
}

.selector-header {
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-inline: 3px;
  text-align: left;
}

.selector-title {
  margin: 0;
  color: #fff;
  font-size: clamp(14px, 1.65vw, 19px);
  line-height: 1.15;
  letter-spacing: 0;
}

.model-tray {
  display: grid;
  grid-template-columns: repeat(var(--model-count), minmax(0, 1fr));
  align-items: stretch;
  gap: clamp(4px, 1vw, 12px);
  overflow: visible;
  padding: 0;
  pointer-events: none;
  touch-action: auto;
}

.model-choice {
  display: grid;
  grid-template-rows: auto minmax(30px, auto) 3px;
  align-content: start;
  align-items: start;
  justify-content: start;
  width: 100%;
  min-height: 0;
  gap: 1px;
  padding: 0 1px 4px;
  border: 0;
  border-radius: 6px;
  color: #e1e3e7;
  opacity: 1;
  text-shadow: 0 1px 3px #11131a, 0 1px 6px #11131a;
}

.choice-model,
.model-choice[aria-pressed="true"] .choice-model {
  min-height: 0;
  flex: none;
  width: 100%;
  height: clamp(76px, 10vw, 122px);
  transform: none;
}

.choice-model > svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  opacity: 1;
  filter: drop-shadow(0 3px 3px #111318c9);
}

.model-choice[aria-pressed="true"] .choice-model::before {
  display: none;
}

.model-choice::after {
  content: "";
  display: block;
  width: clamp(24px, 42%, 64px);
  height: 3px;
  border-radius: 2px;
  background: transparent;
}

.model-choice[aria-pressed="true"]::after {
  background: var(--club);
  box-shadow: 0 0 8px #db304c68;
}

.model-name {
  position: relative;
  z-index: 1;
  align-self: start;
  width: 100%;
  max-width: none;
  min-height: 26px;
  line-height: 1.12;
  font-size: clamp(13px, 1.3vw, 15px);
  padding: 1px 0;
}

.model-choice:disabled {
  cursor: default;
  color: #edf0f3;
}

.model-choice:disabled .choice-model {
  opacity: .52;
  filter: grayscale(.75);
}

.model-reason {
  color: #e2c9ce;
  font-size: 13px;
  line-height: 1.05;
}

.model-pages {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 3px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.model-page-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  background: #262a33e8;
  box-shadow: inset 0 0 0 1px #ffffff35;
}

.model-page-button[aria-disabled="true"] {
  opacity: .55;
  cursor: default;
}

.model-page-button svg {
  width: 23px;
  height: 23px;
}

.model-page-status {
  min-width: 33px;
  text-align: center;
  text-shadow: 0 1px 5px #111;
}

.build-note:empty {
  display: none;
}

@media (hover: hover) {
  .model-choice:not(:disabled):hover .choice-model > svg {
    filter: drop-shadow(0 4px 4px #111318c9) brightness(1.13);
  }
  .model-page-button:not([aria-disabled="true"]):hover,
  .fan-close:hover {
    background: #353b45;
  }
}

@media (max-height: 450px) and (orientation: landscape) {
  .build-tools {
    top: max(62px, calc(env(safe-area-inset-top) + 52px));
    gap: 4px;
  }

  .build-tool {
    width: 48px;
    min-height: 44px;
    padding: 3px 1px;
  }

  .build-tool svg {
    width: 24px;
    height: 24px;
  }

  .tool-name {
    font-size: 13px;
  }

  .tool-fan {
    top: max(62px, calc(env(safe-area-inset-top) + 52px));
    left: calc(var(--edge) + 60px);
  }

  .build-selector {
    left: calc(var(--edge) + 104px);
    right: calc(var(--right) + 170px);
    bottom: calc(var(--bottom) + 3px);
  }

  .choice-model,
  .model-choice[aria-pressed="true"] .choice-model {
    height: clamp(67px, 11vw, 97px);
  }

  .preview-tools {
    display: grid;
    grid-template-columns: repeat(2, 44px);
    grid-template-areas:
      ". light"
      "view compare";
    gap: 4px 6px;
    bottom: var(--bottom);
  }

  .preview-tools .preview-tool:nth-child(1) {
    grid-area: view;
  }

  .preview-tools .preview-tool:nth-child(2) {
    grid-area: compare;
  }

  .preview-tools .preview-tool:last-child {
    grid-area: light;
    display: grid;
  }

  .build-review {
    gap: 8px;
    bottom: calc(var(--bottom) + 12px);
  }

  .build-readout {
    white-space: normal;
  }

  .build-readout span {
    max-width: 78px;
  }

  #game[data-mode="edit"] .wipe::before {
    bottom: 162px;
  }
}

@media (max-height: 360px) and (orientation: landscape) {
  .build-tools {
    display: grid;
    grid-template-columns: repeat(2, 48px);
  }
  .tool-fan { left: calc(var(--edge) + 111px); }
  .build-selector {
    left: calc(var(--edge) + 146px);
  }

  .preview-tools {
    grid-template-columns: repeat(3, 44px);
    grid-template-areas: "view compare light";
    gap: 3px;
  }
}

@media (orientation: portrait) {
  .build-tools {
    top: max(88px, calc(env(safe-area-inset-top) + 73px));
  }

  .build-tool {
    width: 52px;
    min-height: 49px;
  }

  .tool-fan {
    top: max(88px, calc(env(safe-area-inset-top) + 73px));
    left: calc(var(--edge) + 61px);
    right: var(--right);
    width: max-content;
    max-width: calc(100% - var(--edge) - var(--right) - 61px);
    grid-template-columns: repeat(var(--fan-portrait-columns), minmax(52px, 69px));
    padding-right: 32px;
  }

  .build-selector {
    left: var(--edge);
    right: var(--right);
    bottom: calc(var(--bottom) + 103px);
    max-width: none;
  }

  .choice-model,
  .model-choice[aria-pressed="true"] .choice-model {
    height: clamp(64px, 20vw, 108px);
  }

  .model-name {
    font-size: 13px;
  }
}

@media (max-width: 359px) and (orientation: portrait) {
  .preview-tools {
    display: grid;
    grid-template-columns: repeat(2, 44px);
    gap: 3px;
    bottom: var(--bottom);
  }

  .tool-fan {
    grid-template-columns: repeat(2, minmax(52px, 69px));
  }
}

/* Illustration, caption and selection mark occupy separate, non-shrinking rows. */
.model-choice { overflow: visible; }
.choice-model { overflow: hidden; }
.model-choice .choice-model { grid-row: 1; }
.model-choice .model-name { grid-row: 2; padding: 5px 2px 2px; background: #1b202a38; border-radius: 3px; }
.model-choice::after { grid-row: 3; justify-self: center; }
.model-reason { grid-row: 4; }
.compare-switch { position: absolute; z-index: 4; top: 76px; left: 50%; transform: translateX(-50%); display: flex; gap: 3px; padding: 3px; border-radius: 25px; background: #22252ceF; box-shadow: 0 2px 8px #0005; pointer-events: auto; }
.compare-switch button { display: grid; min-width: 80px; min-height: 44px; padding: 4px 12px; gap: 1px; align-content: center; border-radius: 22px; background: transparent; color: #f1f2f4; font-size: 13px; line-height: 1.1; }
.compare-switch small { font-size: 11.5px; color: #cbd0d8; }
.compare-switch button[aria-pressed="true"] { color: #202329; background: #f0f1f2; }
.compare-switch button[aria-pressed="true"] small { color: #3e4752; }
.wipe-input.comparison-drag { width: 76px; top: 136px; bottom: 172px; height: auto; opacity: 0; z-index: 3; pointer-events: auto; touch-action: none; user-select: none; -webkit-user-select: none; }
@media (max-height:450px) and (orientation:landscape) {
  .compare-switch { top: 55px; }
  .compare-switch button { min-height: 40px; min-width: 72px; }
  .wipe-input.comparison-drag { top: 105px; bottom: 155px; }
}
@media (orientation:portrait) {
  .compare-switch { top: 81px; left: calc(50% + 24px); }
  .compare-switch button { min-width: 65px; padding-inline: 10px; }
  .wipe-input.comparison-drag { top: 140px; bottom: 300px; }
}
