/* r38 workshop controls reconstructed from the selected visual target.
   Text, quantities, images and all state remain native product data. */
#workshop-nav {
  display: none;
}
body:is(
    [data-screen="dinos"],
    [data-screen="garage"],
    [data-screen="shop"],
    [data-screen="deploy"]
  )
  #workshop-nav {
  position: fixed;
  z-index: 7;
  top: 78px;
  left: 3vw;
  right: 3vw;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}
.playing #workshop-nav {
  display: none !important;
}
#workshop-nav button,
.selection-screen .dino-card,
.selection-screen .preview-inspect,
.selection-screen .back,
.selection-screen .dino-detail,
.equipment-screen .equipment-panel {
  border: 1px solid #72818e;
  border-radius: 9px;
  background: linear-gradient(150deg, #2e3c49, #101923 75%);
  box-shadow:
    inset 0 2px #c0cbd12b,
    inset 0 -2px #080e16,
    0 4px 0 #070d14;
}
#workshop-nav button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  padding: 7px 12px;
  font-size: clamp(14px, 1.5vw, 23px);
  color: #eef1ed;
}
#workshop-nav img,
#workshop-nav svg {
  width: 37px;
  height: 37px;
  object-fit: contain;
}
#workshop-nav button[aria-current="page"] {
  color: #ffe6a7;
  border-color: #ffce69;
  background: linear-gradient(#815314, #38290e 80%);
  box-shadow:
    inset 0 0 0 2px #ffbb38,
    inset 0 3px #fff0bb,
    0 0 12px #f6a72757,
    0 4px #1b1004;
}
#workshop-nav button:active,
.selection-screen .dino-card:active {
  filter: brightness(0.9);
  box-shadow:
    inset 0 2px 5px #0008,
    0 1px #080e16;
}
body:is(
    [data-screen="dinos"],
    [data-screen="garage"],
    [data-screen="shop"],
    [data-screen="deploy"]
  )
  .screen-heading {
  top: 151px;
}
.selection-screen::before,
.equipment-screen::before {
  background: none;
}
.selection-screen .dino-list {
  top: 220px;
  bottom: 26px;
  width: min(31vw, 380px);
  max-width: none;
}
.selection-screen .dino-card {
  min-height: 145px;
  padding: 8px;
  overflow: hidden;
}
.selection-screen .dino-card img {
  height: 112px;
  top: -3px;
}
.selection-screen .dino-card strong {
  font-size: 12px;
  text-shadow: 0 2px 3px #000;
}
.selection-screen .dino-card small {
  display: none;
}
.selection-screen .dino-card .lock {
  font-size: 9px;
  border-radius: 3px;
  background: #101923df;
}
.selection-screen .dino-card.selected {
  color: #fff1c8;
  border-color: #ffe0a1;
  background: linear-gradient(#443211, #141b20 78%);
  box-shadow:
    inset 0 0 0 2px #ffb72e,
    0 0 11px #ffbb3e70,
    0 4px #100d06;
}
.selection-screen .dino-detail {
  display: block;
  bottom: 25px;
  width: 59vw;
  max-width: none;
  padding: 17px 20px;
}
.selection-screen .dino-detail #dino-progress {
  margin: 6px 0;
  padding: 6px 10px;
}
.selection-screen .dino-detail h2 {
  min-height: 0;
  font-size: clamp(22px, 2.3vw, 32px);
  margin: 0 0 8px;
}
.selection-screen #dino-id {
  display: none;
}
.selection-screen .traits {
  font-size: 12px;
  margin: 5px 0 10px;
}
.selection-screen .stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  border: 1px solid #6a7884;
  border-radius: 6px;
  padding: 10px 0;
  background: #0e1720aa;
}
.selection-screen .stat {
  padding: 0 10px;
  min-width: 0;
  border-right: 1px solid #64727f;
  font-size: 12px;
}
.selection-screen .stat:last-child {
  border: 0;
}
.selection-screen .stat strong {
  font-size: 22px;
  display: block;
  margin-top: 4px;
}
.selection-screen .skill-info {
  min-height: 0;
  font-size: 12px;
  margin: 9px 0;
}
.selection-screen .dino-choice-actions {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: stretch;
  gap: 10px;
}
.selection-screen .dino-choice-actions > button {
  grid-column: auto;
  grid-row: auto;
}
.selection-screen .primary {
  margin: 0;
  min-height: 56px;
  border: 2px solid #ffe0a0;
  border-radius: 7px;
  color: #211a0b;
  background: linear-gradient(#ffd761, #efa414 55%, #d88d0c);
  box-shadow:
    inset 0 2px #fff0b8,
    inset 0 0 0 2px #ffbd37,
    0 5px #83500a;
  font-size: 20px;
}
.selection-screen .primary:disabled {
  box-shadow: none;
  filter: grayscale(0.7);
}
.selection-screen .primary:active {
  box-shadow:
    inset 0 2px 5px #6e480c,
    0 1px #83500a;
}
.selection-screen .preview-inspect {
  padding: 8px 12px;
  font-size: 12px;
  min-height: 40px;
}
.selection-screen .preview-inspect::after {
  content: "";
  display: inline-block;
  width: 26px;
  height: 15px;
  margin-left: 8px;
  vertical-align: middle;
  border: 1px solid #81909e;
  border-radius: 10px;
  background:
    radial-gradient(circle at 7px center, #d9e0df 0 5px, transparent 6px),
    #18232e;
}
.selection-screen .preview-inspect[aria-pressed="true"]::after {
  background:
    radial-gradient(circle at 19px center, #fff0c2 0 5px, transparent 6px),
    #d99718;
  border-color: #ffcf69;
}
#dinos-preview-space {
  display: block;
  position: absolute;
  left: 37vw;
  right: 3vw;
  top: 207px;
  bottom: 340px;
  width: auto;
  height: auto;
  margin: 0;
}

@media (min-width: 601px) and (max-width: 1100px) and (min-height: 621px) {
  .selection-screen {
    display: grid;
    grid-template-columns: minmax(190px, 30%) minmax(0, 1fr);
    grid-template-areas: "heading heading" "choices preview" "choices detail";
    grid-template-rows: 40px minmax(150px, 1fr) minmax(0, 290px);
    gap: 14px;
    align-content: start;
    padding: 150px 20px 24px;
    overflow: clip;
  }
  .selection-screen .screen-heading {
    grid-area: heading;
    position: relative;
    inset: auto;
  }
  .selection-screen .dino-list {
    grid-area: choices;
    position: relative;
    inset: auto;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: none;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 8px;
  }
  .selection-screen #dinos-preview-space {
    grid-area: preview;
    position: relative;
    inset: auto;
    width: 100%;
    height: 100%;
    margin: 0;
  }
  .selection-screen .dino-detail {
    grid-area: detail;
    position: relative;
    inset: auto;
    width: 100%;
    margin: 0;
    min-height: 0;
    overflow-y: auto;
  }
  .selection-screen .dino-card {
    min-height: 137px;
  }
  .selection-screen .screen-heading h1 {
    font-size: 26px;
  }
  .equipment-screen #garage-preview-space {
    display: block;
    position: absolute;
    left: 46%;
    right: 18px;
    top: 210px;
    bottom: 40px;
    height: auto;
    margin: 0;
  }
  .equipment-screen .equipment-panel {
    top: 210px;
    width: 40%;
    max-height: calc(100dvh - 235px);
  }
  .equipment-screen .equipped-label {
    display: none;
  }
}

/* A positioned legacy heading must not offset the new grid's normal row. */
@media (max-width: 1100px) and (min-height: 621px) {
  body[data-screen="dinos"] .selection-screen .screen-heading {
    inset: auto;
  }
}
@media (min-width: 601px) and (max-width: 1100px) and (min-height: 621px) {
  .selection-screen .dino-list {
    height: 100%;
  }
}
@media (max-width: 600px) {
  body[data-screen="dinos"] .selection-screen .screen-heading {
    inset: auto;
  }
  .selection-screen .dino-list {
    height: 148px;
  }
}
@media (max-width: 600px) {
  body:is(
      [data-screen="dinos"],
      [data-screen="garage"],
      [data-screen="shop"],
      [data-screen="deploy"]
    )
    #workshop-nav {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    gap: 5px;
    padding: 8px 10px max(10px, env(safe-area-inset-bottom));
    background: #0c1622f7;
    border-top: 1px solid #657887;
  }
  #workshop-nav button {
    min-height: 64px;
    padding: 5px 2px;
    flex-direction: column;
    gap: 1px;
    font-size: 12px;
  }
  #workshop-nav img,
  #workshop-nav svg {
    width: 29px;
    height: 29px;
  }
  .selection-screen {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "heading" "preview" "choices" "detail";
    gap: 12px;
    align-content: start;
    padding: 79px 14px 108px;
    overflow-y: auto;
  }
  .selection-screen .screen-heading {
    grid-area: heading;
    position: relative;
    inset: auto;
    gap: 8px;
  }
  .selection-screen .screen-heading h1 {
    font-size: 23px;
  }
  .selection-screen .back {
    padding: 7px 9px;
    min-height: 40px;
  }
  .selection-screen .preview-inspect {
    padding: 6px;
    font-size: 10px;
  }
  .selection-screen .preview-inspect::after {
    margin-left: 4px;
  }
  .selection-screen #dinos-preview-space {
    grid-area: preview;
    position: relative;
    inset: auto;
    height: clamp(250px, 40dvh, 340px);
    width: 100%;
    margin: 0;
  }
  .selection-screen .dino-list {
    grid-area: choices;
    position: relative;
    inset: auto;
    width: 100%;
    max-width: none;
    grid-template-columns: none;
    grid-template-rows: 136px;
    grid-auto-flow: column;
    grid-auto-columns: 116px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 3px 3px 9px;
    gap: 8px;
    scroll-snap-type: x proximity;
  }
  .selection-screen .dino-card {
    min-height: 124px;
    scroll-snap-align: center;
  }
  .selection-screen .dino-detail {
    grid-area: detail;
    position: relative;
    inset: auto;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 15px;
  }
  .selection-screen .stat {
    padding: 0 6px;
    font-size: 11px;
  }
  .selection-screen .stat strong {
    font-size: 20px;
  }
  .selection-screen .dino-choice-actions {
    grid-template-columns: 1fr;
  }
  .selection-screen .dino-detail h2 {
    font-size: 24px;
  }
  .equipment-screen {
    padding-bottom: 104px;
  }
  .equipment-screen #garage-preview-space {
    margin: 128px 14px 0;
    height: 320px;
  }
  .equipment-screen .equipment-panel {
    margin: 12px 14px 104px;
    left: auto;
    width: auto;
  }
  .shop-screen .shop-detail,
  .deploy-screen .mode-list {
    padding-bottom: 105px;
  }
  body:is([data-screen="garage"], [data-screen="shop"], [data-screen="deploy"])
    .screen-heading {
    top: 83px;
  }
}
@media (min-width: 601px) and (max-height: 620px) {
  body:is(
      [data-screen="dinos"],
      [data-screen="garage"],
      [data-screen="shop"],
      [data-screen="deploy"]
    )
    #workshop-nav {
    top: 64px;
  }
  #workshop-nav button {
    min-height: 41px;
    font-size: 14px;
  }
  #workshop-nav img,
  #workshop-nav svg {
    height: 25px;
    width: 25px;
  }
  body:is(
      [data-screen="dinos"],
      [data-screen="garage"],
      [data-screen="shop"],
      [data-screen="deploy"]
    )
    .screen-heading {
    top: 119px;
  }
  .selection-screen .dino-list {
    top: 174px;
    width: 23vw;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .selection-screen .dino-detail {
    top: 174px;
    bottom: 15px;
    width: 28vw;
    max-height: calc(100dvh - 189px);
    overflow-y: auto;
    padding: 12px;
  }
  .selection-screen .dino-detail h2 {
    font-size: 20px;
  }
  .selection-screen .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 8px;
  }
  .selection-screen .dino-choice-actions {
    grid-template-columns: 1fr;
  }
  #dinos-preview-space {
    top: 163px;
    bottom: 16px;
    left: 28vw;
    right: 33vw;
  }
}

/* Keep the inspected model prominent above the desktop action panel. */
@media (min-width: 601px) and (min-height: 621px) {
  .equipment-screen .equipment-panel,
  .shop-screen .shop-items,
  .shop-screen .shop-detail,
  .deploy-screen .mode-list {
    top: 210px;
    max-height: calc(100dvh - 235px);
  }
  .equipment-screen .equipped-label {
    display: none;
  }
}
@media (min-width: 1101px) and (min-height: 621px) {
  #dinos-preview-space {
    top: 174px;
    bottom: 290px;
  }
  .selection-screen .dino-detail {
    padding: 12px 16px;
  }
  .selection-screen .dino-detail h2 {
    font-size: 24px;
    margin-bottom: 4px;
  }
  .selection-screen .traits {
    margin: 3px 0 5px;
  }
  .selection-screen .dino-detail #dino-progress {
    padding: 4px 8px;
    margin: 4px 0;
  }
  .selection-screen .stats {
    padding: 6px 0;
  }
  .selection-screen .stat strong {
    font-size: 20px;
    margin-top: 2px;
  }
  .selection-screen .skill-info {
    margin: 5px 0;
  }
  .selection-screen .primary {
    min-height: 48px;
  }
}
