/* Shop layout only. The cloud artwork and existing button colors/shapes stay intact.
   The content pane owns scrolling; purchase actions and Back never scroll away. */
body[data-mode="powerMachine"] #overlay {
  overflow: hidden;
  padding: calc(env(safe-area-inset-top, 0px) + 12px)
    max(12px, env(safe-area-inset-right, 0px))
    calc(env(safe-area-inset-bottom, 0px) + 12px)
    max(12px, env(safe-area-inset-left, 0px));
  align-items: center;
}
body[data-mode="powerMachine"] #panel {
  display: flex !important;
  flex-direction: column;
  box-sizing: border-box;
  width: min(444px, 100%);
  height: min(700px, calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 24px));
  max-height: min(700px, calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 24px));
  min-height: 0;
  margin: 0;
  padding: 20px clamp(16px, 4vw, 24px) 18px !important;
  overflow: hidden;
  gap: 0;
}
body[data-mode="powerMachine"] #panel > #heading {
  flex: 0 0 auto;
  margin: 0 0 7px !important;
  font-size: clamp(23px, 6.5vw, 29px) !important;
  line-height: 1.08 !important;
  letter-spacing: -.6px;
}
body[data-mode="powerMachine"] #panel > #message,
body[data-mode="powerMachine"] #panel > #meta,
body[data-mode="powerMachine"] #panel > #portrait,
body[data-mode="powerMachine"] #panel > #trophyButton,
body[data-mode="powerMachine"] #panel > #homeButton,
body[data-mode="powerMachine"] #panel > p,
body[data-mode="powerMachine"] #panel > .pixel-eyebrow,
body[data-mode="powerMachine"] #panel > .review-back,
body[data-mode="powerMachine"] #panel > #uiLabTools {
  display: none !important;
}
body[data-mode="powerMachine"] #shop {
  flex: 1 1 0 !important;
  min-height: 0 !important;
  max-height: none !important;
  width: 100%;
  overflow: hidden !important;
  margin: 0;
}
body[data-mode="powerMachine"] #shop .combined-machine {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  height: 100%;
  min-height: 0;
  padding: 0;
  gap: 8px;
  line-height: 1.35;
}
body[data-mode="powerMachine"] .machine-content {
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  touch-action: pan-y;
  scrollbar-width: thin;
  scrollbar-color: #b7bfdf #555578;
  padding: 0 3px 3px;
}
body[data-mode="powerMachine"] .machine-shop-art {
  width: clamp(130px, 23dvh, 180px);
  height: clamp(130px, 23dvh, 180px);
  max-width: 100%;
  margin: -4px auto 0;
}
body[data-mode="powerMachine"] #panel .machine-balance {
  margin: 0 0 5px !important;
  font-size: 13px !important;
  line-height: 1.35;
  text-align: center;
  font-weight: 800;
  color: #f6f1e7 !important;
  overflow-wrap: anywhere;
}
body[data-mode="powerMachine"] #panel .machine-intro {
  margin: 3px 0 7px !important;
  font-size: 11px !important;
  line-height: 1.4;
  text-align: center;
}
body[data-mode="powerMachine"] .machine-rules {
  margin: 6px 0;
  padding: 6px 9px;
  font-size: 11px;
}
body[data-mode="powerMachine"] .machine-rules summary {
  min-height: 26px;
  line-height: 26px;
  cursor: pointer;
}
body[data-mode="powerMachine"] #panel .machine-rules p {
  margin: 7px 0 !important;
  font-size: 11px !important;
  line-height: 1.45;
}
body[data-mode="powerMachine"] .machine-stock {
  gap: 5px;
  margin: 6px 0 0;
  font-size: 10px;
}
body[data-mode="powerMachine"] .machine-stock span {
  min-width: 0;
  padding: 5px 6px;
  overflow-wrap: anywhere;
}
body[data-mode="powerMachine"] .machine-actions {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 3px; /* Keep keyboard focus rings inside the non-scrolling pane. */
}
body[data-mode="powerMachine"] .machine-buys {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
}
body[data-mode="powerMachine"] #panel .machine-buy {
  width: 100%;
  max-width: none !important;
  min-width: 0;
  min-height: 80px !important;
  margin: 0 !important;
  padding: 8px 3px !important;
  white-space: normal;
  overflow-wrap: anywhere;
}
body[data-mode="powerMachine"] .machine-buy > strong { font-size: 19px; line-height: 1.15; }
body[data-mode="powerMachine"] .machine-buy > span { font-size: 11px; line-height: 1.3; margin: 4px 0; }
body[data-mode="powerMachine"] #panel .machine-buy > small { font-size: 9px; line-height: 1.25; }
body[data-mode="powerMachine"] #panel .machine-resume {
  width: 100%;
  max-width: none !important;
  min-height: 44px !important;
  margin: 0 !important;
  padding: 8px 10px !important;
  font-size: 12px !important;
}
body[data-mode="powerMachine"] #panel .machine-pending-hint {
  margin: 0 !important;
  font-size: 10px !important;
  line-height: 1.3;
}
body[data-mode="powerMachine"] #panel .machine-feedback {
  margin: 0 !important;
  min-height: 0;
  font-size: 10px !important;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
body[data-mode="powerMachine"] .machine-feedback:empty { display: none; }
body[data-mode="powerMachine"] #panel > #secondary {
  flex: 0 0 auto;
  width: 100%;
  min-height: 44px !important;
  margin: 6px 0 0 !important;
  padding: 8px 10px !important;
}
@media (max-height: 660px) {
  body[data-mode="powerMachine"] #panel {
    border-top-width: 18px !important;
    border-bottom-width: 18px !important;
    padding-top: 16px !important;
    padding-bottom: 16px !important;
  }
  body[data-mode="powerMachine"] .machine-shop-art { width: 130px; height: 130px; }
  body[data-mode="powerMachine"] #panel > #heading { font-size: 23px !important; margin-bottom: 5px !important; }
  body[data-mode="powerMachine"] #shop .combined-machine { gap: 4px; }
  body[data-mode="powerMachine"] #panel .machine-buy { min-height: 76px !important; padding-top: 6px !important; padding-bottom: 6px !important; }
}
@media (max-width: 360px) {
  body[data-mode="powerMachine"] #panel { padding-left: 14px !important; padding-right: 14px !important; }
  body[data-mode="powerMachine"] .machine-buys { gap: 5px; }
  body[data-mode="powerMachine"] .machine-stock { font-size: 9px; }
}
