/* Keep interactive symbols and action labels centered in their real hit areas.
   Card-like navigation (large hub story tiles) keeps its intentional editorial
   layout; its separate functional buttons still use centered labels. */
button { text-align: center; }

/* True optical centering for the round/square icon-only controls. No font
   baseline, hand-made padding-bottom, or mobile line-height adjustments. */
:is(.module-back,.shell-back,.home-icon,.modal-close,.close,.loto-close,.boat-x,.round,#help,#fullscreen) {
  display: grid;
  place-items: center;
  padding: 0;
  line-height: 1.15;
  text-align: center;
}

/* A typographic multiplication sign has font-dependent side bearings and a
   low baseline. Draw two symmetric strokes at the exact center of the button.
   The original × remains in textContent / accessible label for screen readers. */
.market-look .module-back,
.modal-close,
.close,
#loto-modal .loto-close {
  position: relative;
  padding: 0 !important;
  font-size: 0 !important;
}
:is(.market-look .module-back,.modal-close,.close,#loto-modal .loto-close)::before,
:is(.market-look .module-back,.modal-close,.close,#loto-modal .loto-close)::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  width: min(45%,27px);
  height: 3.5px;
  border-radius: 9px;
  background: currentColor;
  transform-origin: center;
  pointer-events: none;
}
:is(.market-look .module-back,.modal-close,.close,#loto-modal .loto-close)::before {
  transform: translate(-50%,-50%) rotate(45deg);
}
:is(.market-look .module-back,.modal-close,.close,#loto-modal .loto-close)::after {
  transform: translate(-50%,-50%) rotate(-45deg);
}

/* Action buttons with an icon / amount / short label should center the
   content as one group horizontally and vertically, on every breakpoint. */
:is(.shell-primary,.shell-secondary,.primary,.setting-toggle,.setting-action,
    .recipe-card button,.stock-card button,.upgrade-item button,
    .recipe-actions button,.stock-market-actions button,.market-categories button,
    .story-event-choices button,.review-reply-actions button,
    .lottery-card button,.lottery-reopen,.pet-card-footer button,
    .pause-end-day,.profile-links button,#serve,#discard) {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
}

/* .primary is a block-level flex container above. Text-align:center on
   .paper does not center block boxes, unlike the inline button it replaced.
   Give the pause CTA intrinsic width and symmetric auto margins, matching the
   End-day button without changing the hit target or the resume handler. */
#pause-overlay .paper #resume {
  width: max-content;
  max-width: 100%;
  margin-inline: auto;
}

/* Price + caption remain stacked but both lines are centered. */
.stock-card button { flex-direction: column; gap: 0; }

/* The old CTA floated an arrow all the way right, so the text itself looked
   off-center. Make the label and arrow a single centered content group. */
.shell-primary > span { float: none; }

/* Home shortcuts were the remaining ordinary buttons with a left-stacked
   icon + two labels. Center all three elements as a balanced vertical group,
   including the 4-column More menu and compact mobile breakpoint. */
.hub-tools button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 2px;
  padding: 6px 4px;
}
.hub-tools button > span { flex: none; }
.hub-tools button > b,
.hub-tools button > small { width: 100%; text-align: center; }

/* Keep the coffee icon and arrow in equal-width outer columns so the CTA
   label is exactly centered between them, not visually pushed right. */
.open-shop-button {
  grid-template-columns: 56px minmax(0,1fr) 56px;
  text-align: center;
}
.open-shop-button > span:nth-child(2) { align-items: center; text-align: center; }
.open-shop-button > i { display: grid; place-items: center; }
.home-ledger-shortcut {
  grid-template-columns: 58px minmax(0,1fr) 58px;
  text-align: center;
}
.home-ledger-shortcut > span { align-items: center; text-align: center; }
@media(max-width:1050px),(max-height:600px){
  .open-shop-button { grid-template-columns: 42px minmax(0,1fr) 42px; }
  .home-ledger-shortcut { grid-template-columns: 48px minmax(0,1fr) 48px; }
  .hub-tools button { padding: 3px 2px; gap: 1px; }
}

/* The market back button remains grid-column 3, as before. Only the sign
   changes; layout, size, mouse/touch rectangle and focus ring are untouched. */

/* Help modal: the generic close-button alignment above sets position:relative
   and font-size:0, so the × silently collapses into a zero-sized flow item.
   Anchor its drawn cross in the upper-right instead of pushing modal content.
   .primary is display:flex, so the confirmation CTA also needs auto margins. */
#help-overlay .paper {
  max-height: calc(100% - 64px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
#help-overlay .paper #close-help {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: #fff8e8;
  color: #77502e;
  border: 2px solid #b88d61;
  border-radius: 12px;
  z-index: 2;
}
#help-overlay .paper #start-play {
  width: max-content;
  max-width: 100%;
  margin: 18px auto 0;
}
/* The whole 1672px game is scaled down on phones. Enlarge only these two
   controls in game coordinates so their physical touch targets remain usable. */
@media (pointer: coarse) {
  #help-overlay .paper #close-help {
    width: 96px;
    height: 96px;
    top: 8px;
    right: 8px;
    border-radius: 22px;
  }
  #help-overlay .paper #start-play {
    min-height: 116px;
  }
}
