/* One final button layout contract. Components retain their dimensions,
   resource columns, selection states and keyboard focus; captions share ink
   and centering instead of inheriting older scene-specific left alignment. */
#piratequest-app :is(button,[role="button"],a.pq-button,a.gr-button,input[type="button"],input[type="submit"],input[type="reset"]),
.gr-select-popup.pq-select-popup199 button {
 text-align:center!important;
}
#piratequest-app :is(button,[role="button"],a.pq-button,a.gr-button) :is(span,strong,b,small,em,p,h2,h3,h4),
.gr-select-popup.pq-select-popup199 button :is(span,strong,b,small,em) {
 text-align:inherit!important;
 font-family:inherit;
}

/* Action captions and their semantic icon form one centered, wrapping unit.
   Rich item cards below keep their own grid rather than becoming action rows. */
#piratequest-app :is(.pq-button,.gr-button,.pq-link-button,.pq-stop,.pq-interact,.pq-goal178__heading,.pq-goal178__clear,.pq-items-toast-message165),
#piratequest-app .pq-chart-list button {
 justify-content:center!important;
 align-items:center!important;
}
#piratequest-app :is(.pq-button,.gr-button,.pq-link-button)>:is(span,strong,b,small) {
 min-width:0;
 max-width:100%;
}
#piratequest-app .pq-chat-choice-label158,
#piratequest-app .pq-help-contents .pq-link-button>span {
 flex:0 1 auto;
 align-items:center;
}
#piratequest-app :is(.pq-button,.gr-button,.pq-link-button)>svg:not([hidden]):not(.pq-item-art),
#piratequest-app .pq-button>.pq-action-icon180:not([hidden]) {
 display:inline-flex;
 flex:0 0 1.25em;
 width:1.25em;
 height:1.25em;
 margin:0;
 align-items:center;
 justify-content:center;
}
#piratequest-app :is(.pq-button,.gr-button,.pq-link-button)>svg:only-child {
 margin:0;
}
#piratequest-app .pq-dialogue .pq-button::before {
 content:none;
 display:none;
}

/* Links that act as buttons use the Pirate Quest secondary action surface,
   including visited links. Primary and danger variants are applied below. */
#piratequest-app a:is(.pq-button,.gr-button) {
 color:#f1edda!important;
 background:#183f47;
 border:2px solid #adc5b3;
 border-radius:10px;
 min-height:44px;
 padding:10px 12px;
 gap:8px;
 font:600 var(--pq-font-button)/1.25 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
 text-decoration:none!important;
}
#piratequest-app a:is(.pq-button,.gr-button):hover {
 background:#28505a;
 border-color:#f2d49a;
}
#piratequest-app .pq-welcome__actions a.pq-button { min-height:56px; padding:8px 12px; gap:10px; line-height:1.2; }

/* Primary action anchors, card captions and icons use the same palette as
   primary buttons. Component styles cannot replace it with brown/white ink. */
#piratequest-app :is(button,a):is(.pq-button--gold,.gr-default-action,.gr-button--primary) {
 color:var(--gr-control-ink,#153e3d)!important;
 background:linear-gradient(110deg,#ebcc97,#d5ae73)!important;
 border-color:#f0d49d!important;
 box-shadow:none;
 text-shadow:none;
}
#piratequest-app :is(button,a):is(.pq-button--gold,.gr-default-action,.gr-button--primary):hover:not(:disabled) {
 background:linear-gradient(110deg,#f7dda9,#e7c489)!important;
}
#piratequest-app :is(button,a):is(.pq-button--gold,.gr-default-action,.gr-button--primary) *,
#piratequest-app :is(.gr-tab,.pq-items-tab)[aria-selected="true"] *,
#piratequest-app .pq-ledger-tabs>button[aria-pressed="true"] * {
 color:inherit!important;
 text-shadow:none;
}
#piratequest-app :is(button,a).pq-button--danger {
 color:#fff3e6!important;
 background:#a72c38!important;
 border-color:#ef8a91!important;
 text-shadow:none;
}
#piratequest-app :is(button,a).pq-button--danger:hover:not(:disabled) {
 background:#be3743!important;
}
#piratequest-app :is(button,a).pq-button--danger * { color:inherit!important; }

/* Selected category filters share the same readable dark ink as gold actions.
   Do not apply this to pressed icon tools or non-gold selection surfaces. */
#piratequest-app :is(.pq-harbour-filters178,.pq-gear-filters178,.pq-cargo-filters197) .pq-button[aria-pressed="true"],
#piratequest-app :is(.gr-tab,.pq-items-tab)[aria-selected="true"],
#piratequest-app .pq-ledger-tabs>button[aria-pressed="true"] {
 color:var(--gr-control-ink,#153e3d)!important;
}
#piratequest-app :is(.pq-harbour-filters178,.pq-gear-filters178,.pq-cargo-filters197) .pq-button[aria-pressed="true"] * {
 color:inherit!important;
}

/* Keyboard focus is one outside outline rather than an inset second border.
   Patron scene hitboxes keep their existing golden arrow selection instead. */
#piratequest-app :is(button,[role="button"],a.pq-button,a.gr-button):not(.pq-tavern__patron):focus-visible,
.gr-select-popup.pq-select-popup199 button:focus-visible {
 outline:2px solid #b5e5df;
 outline-offset:2px;
}

/* A left illustration must not push a multi-line caption to the right.
   Equal inline reserves center these captions across the complete card. */
#piratequest-app .pq-merchant-choices166>.pq-button {
 position:relative;
 padding-inline:60px;
}
#piratequest-app .pq-merchant-choices166>.pq-button>svg {
 position:absolute;
 inset-inline-start:18px;
 top:0;
 bottom:0;
 margin-block:auto;
}
#piratequest-app .pq-merchant-choices166>.pq-button>span { flex:1 1 auto; }
#piratequest-app .pq-cheats178 .pq-button,
#piratequest-app .pq-combat-cargo178 .pq-button {
 position:relative;
 padding-inline:44px;
}
#piratequest-app :is(.pq-cheats178,.pq-combat-cargo178) .pq-button>svg {
 position:absolute;
 inset-inline-start:10px;
 top:0;
 bottom:0;
 margin-block:auto;
}
#piratequest-app :is(.pq-cheats178,.pq-combat-cargo178) .pq-button>span {
 flex:1 1 auto;
 align-items:center;
}

/* Rich item cards reserve matching art/status columns so their copy remains
   centered when a check appears. Price and meter columns retain their separate
   meaning in shop rows and ship resource controls. */
#piratequest-app :is(.pq-active-powerup__copy,.pq-captain174__gear-copy,.pq-item-shop__row-copy),
#piratequest-app .pq-gear-slot156>span {
 justify-items:center;
 align-items:center;
}
#piratequest-app :is(.pq-item-shop__row-copy,.pq-item-shop__abilities,.pq-captain174__gear-abilities),
#piratequest-app button.pq-resource>span {
 justify-content:center;
}
#piratequest-app .pq-combine-item150 {
 display:grid;
 grid-template-columns:48px minmax(0,1fr) 48px;
 justify-content:center;
}
#piratequest-app .pq-gear-slot156 {
 display:grid;
 grid-template-columns:44px minmax(0,1fr) 44px;
 justify-content:center;
}
#piratequest-app .pq-gear-slot156>svg:last-child:not(:first-child) { justify-self:center; }
#piratequest-app button.pq-active-powerup { grid-template-columns:56px minmax(0,1fr) 56px; }
#piratequest-app .pq-active-powerups--compact button.pq-active-powerup { grid-template-columns:44px minmax(0,1fr) 44px; }
#piratequest-app .pq-captain174__gear-slot { grid-template-columns:54px minmax(0,1fr) 54px; }
#piratequest-app .pq-item-slot__name { width:100%; }

/* Select popovers may be mounted under body or the fullscreen element.
   The owner marker is added only for Pirate Quest selects. Arrow/check cells
   sit outside the label's equal padding, so either state keeps it centered. */
#piratequest-app button.gr-select-trigger,
.gr-select-popup.pq-select-popup199 button.gr-select-option {
 position:relative;
 justify-content:center;
 gap:0;
 padding-inline:44px;
}
#piratequest-app .gr-select-trigger>.gr-select-value { text-align:center!important; }
#piratequest-app .gr-select-trigger>.gr-select-arrow {
 position:absolute;
 inset-inline-end:12px;
 top:0;
 bottom:0;
 margin-block:auto;
}
.gr-select-popup.pq-select-popup199 .gr-select-option>span:first-child {
 flex:1 1 auto;
 min-width:0;
 text-align:center!important;
}
.gr-select-popup.pq-select-popup199 .gr-select-check {
 position:absolute;
 inset-inline-end:12px;
 top:0;
 bottom:0;
 display:flex;
 align-items:center;
 justify-content:center;
 width:20px;
}
.gr-select-popup.pq-select-popup199 .gr-select-option[aria-selected="true"] {
 color:var(--gr-control-ink,#153e3d);
}
.gr-select-popup.pq-select-popup199 .gr-select-option[aria-selected="true"] * { color:inherit; }

@media(max-width:600px) {
 #piratequest-app .pq-welcome__actions a.pq-button { min-height:48px; }
 #piratequest-app .pq-merchant-choices166>.pq-button { padding-inline:48px; }
 #piratequest-app .pq-merchant-choices166>.pq-button>svg { inset-inline-start:12px; }
 #piratequest-app .pq-combine-item150 { grid-template-columns:minmax(0,1fr); justify-items:center; }
}
@media(min-width:601px) and (max-height:560px) {
 #piratequest-app .pq-welcome__actions a.pq-button { min-height:44px; padding:6px 8px; }
}
@media(max-width:600px) and (orientation:portrait) {
 #piratequest-app .pq-items-dialog--portrait162 .pq-gear-slot156 { grid-template-columns:28px minmax(0,1fr) 28px; }
}
/* Narrow captain cards need their full caption width, not two empty art cells.
   Stacking illustration and caption keeps them centered without tiny columns. */
@container(max-width:500px) {
 #piratequest-app .pq-captain174__gear-slot { grid-template-columns:minmax(0,1fr); justify-items:center; }
}
@media(max-width:500px) {
 #piratequest-app .pq-captain174__gear-slot,
 #piratequest-app button.pq-active-powerup,
 #piratequest-app .pq-active-powerups--compact button.pq-active-powerup { grid-template-columns:minmax(0,1fr); justify-items:center; }
}
